Documentation
¶
Overview ¶
Package actioncontinuation stores local, payload-free approval suspension records and exact-once resume leases. The authority owns approval votes and certificates; this package owns only the node-side fact that a particular adapter action may be attempted at most once after approval.
Index ¶
- Constants
- Variables
- func Fingerprint(...) string
- func RecordID(fingerprint, transactionID string) string
- type Record
- type State
- type Store
- func (store *Store) ClaimResume(ctx context.Context, id string) (Record, string, error)
- func (store *Store) FindActive(ctx context.Context, fingerprint string) (Record, error)
- func (store *Store) Finish(ctx context.Context, id, leaseToken string, succeeded bool, failureCode string) (Record, error)
- func (store *Store) Get(ctx context.Context, id string) (Record, error)
- func (store *Store) PutPending(ctx context.Context, candidate Record) (Record, error)
Constants ¶
const ( SchemaVersion uint16 = 1 MaxRecordBytes = 64 << 10 )
Variables ¶
var ( ErrNotFound = errors.New("actioncontinuation: continuation not found") ErrConflict = errors.New("actioncontinuation: continuation conflict") ErrAlreadyClaimed = errors.New("actioncontinuation: continuation already claimed") ErrExpired = errors.New("actioncontinuation: continuation expired") )
Functions ¶
func Fingerprint ¶
func Fingerprint(tenantID, agentID, action, resource, payloadHash, adapterID, resumeToken string) string
Fingerprint is deterministic for the exact side effect and local resume token. None of its inputs are recoverable from the resulting identifier.
Types ¶
type Record ¶
type Record struct {
Version uint16 `json:"version"`
ID string `json:"id"`
Fingerprint string `json:"fingerprint"`
TenantID string `json:"tenant_id"`
AgentID string `json:"agent_id"`
ActionID string `json:"action_id"`
Action string `json:"action"`
Resource string `json:"resource"`
PayloadHash string `json:"payload_hash"`
AdapterID string `json:"adapter_id"`
ResumeToken string `json:"resume_token"`
InitialDecision actionhook.DecisionReference `json:"initial_decision"`
ApprovalTransaction string `json:"approval_transaction_id"`
State State `json:"state"`
CreatedAt int64 `json:"created_at"`
ExpiresAt int64 `json:"expires_at"`
AttemptedAt int64 `json:"attempted_at,omitempty"`
FinishedAt int64 `json:"finished_at,omitempty"`
FailureCode string `json:"failure_code,omitempty"`
}
Record contains no payload, prompt, secret, local path, or peer address. ResumeToken is adapter-local and never uploaded to the authority.
func NewPending ¶
func NewPending(tenantID, agentID string, envelope actionhook.Envelope, reference actionhook.DecisionReference, transactionID string, expiresAt time.Time) (Record, error)
NewPending constructs the canonical continuation identity. ActionID is the original hook action ID for trace correlation; it is not used for lookup, because a later process creates a new envelope ID when resuming.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) ClaimResume ¶
ClaimResume atomically publishes an exclusive lease before returning a permit. A crash after this point is fail-closed: the lease is intentionally never deleted, so the side effect cannot be attempted twice ambiguously.
func (*Store) FindActive ¶
FindActive returns the one continuation that still controls an exact side effect. Successful records are historical and do not prevent a deliberate later repetition. Pending, executing, and failed records remain active; a failed/ambiguous execution therefore needs a different adapter resume token before it can be attempted again.