Documentation
¶
Overview ¶
Package actionhook defines Pilot's versioned before/after side-effect boundary. It is deliberately optional: a nil Hook means the application executes exactly as it did before governance was attached.
Index ¶
Constants ¶
const ( MaxAttributes = 32 MaxAttributeValue = 256 )
const SchemaVersion uint16 = 1
Variables ¶
This section is empty.
Functions ¶
func HashMetadata ¶
HashMetadata creates the payload binding for actions whose policy context is entirely metadata. Length-prefixing and sorting prevent ambiguous joins.
Types ¶
type BlockedError ¶
type BlockedError struct {
Outcome decision.Outcome
Reference DecisionReference
Reasons []string
}
BlockedError is returned by RequireUnconstrained when a valid preflight does not authorize the adapter to execute immediately.
func (*BlockedError) Error ¶
func (err *BlockedError) Error() string
type DecisionReference ¶
type DecisionReference struct {
IntentID string `json:"intent_id,omitempty"`
DecisionID string `json:"decision_id,omitempty"`
ExchangeID string `json:"exchange_id,omitempty"`
PolicyRevision uint64 `json:"policy_revision,omitempty"`
ProviderID string `json:"provider_id,omitempty"`
ApprovalTransaction string `json:"approval_transaction_id,omitempty"`
ApprovalExpiresAt int64 `json:"approval_expires_at,omitempty"`
}
DecisionReference is safe to persist in an action trace. It contains no provider request body and no opaque adapter resume state.
type Envelope ¶
type Envelope struct {
Version uint16 `json:"version"`
ID string `json:"id"`
Action string `json:"action"`
Resource string `json:"resource"`
PayloadHash string `json:"payload_hash"`
AdapterID string `json:"adapter_id"`
CreatedAt int64 `json:"created_at"`
Attributes map[string]string `json:"attributes,omitempty"`
// FederatedContent is the complete request body submitted to Pilot's
// hosted account ingress in managed mode. It is process-local hook input:
// envelope JSON, traces, continuations, and receipts never serialize it.
FederatedContent *decision.FederatedContent `json:"-"`
// ResumeToken is adapter-local state used to find a durable continuation.
// It is deliberately excluded from JSON and never sent to an evaluator.
ResumeToken string `json:"-"`
}
Envelope is evaluated before an adapter performs a side effect. Ordinary local/observe hooks use only PayloadHash. A managed hosted-federation hook may additionally carry FederatedContent to Pilot's account ingress. Attributes remain typed call metadata rather than an alternative channel for content, secrets, local paths, or peer network addresses.
func NewEnvelope ¶
func NewFederatedEnvelope ¶
type Hook ¶
type Hook interface {
BeforeAction(context.Context, Envelope) (Preflight, error)
AfterAction(context.Context, Envelope, Preflight, ObservedResult) error
}
Hook is the universal optional side-effect boundary. AfterAction is evidence-only: its failure must be surfaced to telemetry, but it cannot retroactively change or repeat the adapter side effect.
type ObservedResult ¶
type ObservedResult struct {
Status ObservedStatus `json:"status"`
ObservedAt int64 `json:"observed_at"`
ErrorCode string `json:"error_code,omitempty"`
Attributes map[string]string `json:"attributes,omitempty"`
// FederatedContent is an optional complete response or returned artifact
// for the Pilot-hosted post-hook. Like request content, it is process-local
// and is never serialized into traces or local receipts.
FederatedContent *decision.FederatedContent `json:"-"`
}
ObservedResult records what actually happened after preflight. ErrorCode is a bounded category, never an arbitrary error string that could leak data.
func (ObservedResult) Validate ¶
func (result ObservedResult) Validate() error
type ObservedStatus ¶
type ObservedStatus string
const ( StatusSucceeded ObservedStatus = "succeeded" StatusFailed ObservedStatus = "failed" StatusSkipped ObservedStatus = "skipped" StatusDenied ObservedStatus = "denied" StatusApprovalPending ObservedStatus = "approval_pending" )
type Preflight ¶
type Preflight struct {
Outcome decision.Outcome `json:"outcome"`
Reasons []string `json:"reasons,omitempty"`
Constraints []decision.Constraint `json:"constraints,omitempty"`
Reference DecisionReference `json:"reference,omitempty"`
ObserveOnly bool `json:"observe_only,omitempty"`
State any `json:"-"`
}
Preflight is the hook's answer. State is process-local opaque state used by the same Hook during AfterAction; it is never serialized or accepted from a caller. ObserveOnly makes the result evidentiary and never blocking.
func (Preflight) RequireUnconstrained ¶
RequireUnconstrained is the safe execution check for adapters that do not implement constraint operators. Observe-only hooks never block execution.