Documentation
¶
Overview ¶
Package execution defines portable run identity, tool-attempt, approval, and versioned dispatch contracts. Persistence is supplied by the host.
Index ¶
- Constants
- Variables
- func IsTaskPlanStale(task Task, plan Plan) bool
- func WithIdentity(ctx context.Context, identity Identity) (context.Context, error)
- type AdmissionDecision
- type AdmissionEnvelopeBuilder
- type AdmissionStore
- type AdmittedInput
- type ApprovalDecision
- type ApprovalPendingError
- type ApprovalRecord
- type ApprovalRequest
- type ApprovalState
- type ApprovalStore
- type Approver
- type Attempt
- type AttemptLedger
- type AttemptSettlement
- type AttemptState
- type AuthorizationResolver
- type AuthorizationTarget
- type CanonicalAdmission
- type Canonicalizer
- type Capability
- type CapabilityPage
- type CapabilityQuery
- type CapabilitySummary
- type Catalog
- type CatalogSnapshot
- func (s CatalogSnapshot) CanonicalOperation(ref ToolRef, assertedResource, arguments string) (Operation, error)
- func (s CatalogSnapshot) Capabilities(toolSet string, snapshot policy.Snapshot) []Capability
- func (s CatalogSnapshot) Discover(query CapabilityQuery, snapshot policy.Snapshot) (CapabilityPage, error)
- func (s CatalogSnapshot) Refs(policySnapshot policy.Snapshot) []ToolRef
- func (s CatalogSnapshot) Resolve(ref ToolRef) (ToolSpec, bool)
- func (s CatalogSnapshot) Version() string
- type ChildRun
- type ChildRunStore
- type ChildStatus
- type Dispatcher
- type ExistingAttemptError
- type Flow
- type FlowNode
- type Goal
- type Identity
- type IndeterminateError
- type InputMode
- type InputPriority
- type InputState
- type MemoryAdmissionStore
- func (s *MemoryAdmissionStore) Create(ctx context.Context, in AdmittedInput) (AdmittedInput, bool, error)
- func (s *MemoryAdmissionStore) Get(ctx context.Context, owner Identity, id string) (AdmittedInput, bool, error)
- func (s *MemoryAdmissionStore) Pending(ctx context.Context, owner Identity, limit int) ([]AdmittedInput, error)
- func (s *MemoryAdmissionStore) Transition(ctx context.Context, owner Identity, id string, expected uint64, ...) (AdmittedInput, error)
- type MemoryApprovalStore
- func (s *MemoryApprovalStore) Create(ctx context.Context, request ApprovalRequest) (ApprovalRecord, bool, error)
- func (s *MemoryApprovalStore) Get(ctx context.Context, owner Identity, requestID string) (ApprovalRecord, bool, error)
- func (s *MemoryApprovalStore) Resolve(ctx context.Context, owner Identity, requestID string, expected uint64, ...) (ApprovalRecord, error)
- type MemoryAttemptLedger
- func (l *MemoryAttemptLedger) Admit(ctx context.Context, in Attempt) (Attempt, bool, error)
- func (l *MemoryAttemptLedger) Get(ctx context.Context, owner Identity, id string) (Attempt, bool, error)
- func (l *MemoryAttemptLedger) ListForReconciliation(ctx context.Context, owner Identity, limit int) ([]Attempt, error)
- func (l *MemoryAttemptLedger) Settle(ctx context.Context, owner Identity, id string, expected uint64, ...) (Attempt, error)
- func (l *MemoryAttemptLedger) Start(ctx context.Context, owner Identity, id string, expected uint64, at time.Time) (Attempt, error)
- type MemoryChildRunStore
- type MemoryRunStore
- type MemoryTaskMailbox
- func (m *MemoryTaskMailbox) Ack(ctx context.Context, owner Identity, recipient string, sequence uint64) (TaskMailboxState, error)
- func (m *MemoryTaskMailbox) Append(ctx context.Context, message TaskMessage) (TaskMessage, bool, error)
- func (m *MemoryTaskMailbox) Replay(ctx context.Context, owner Identity, recipient string, after uint64, limit int) ([]TaskMessage, error)
- type MemoryToolRoundStore
- func (s *MemoryToolRoundStore) Create(ctx context.Context, round ToolRound) (ToolRound, bool, error)
- func (s *MemoryToolRoundStore) Get(ctx context.Context, owner Identity, id string) (ToolRound, bool, error)
- func (s *MemoryToolRoundStore) Open(ctx context.Context, owner Identity, limit int) ([]ToolRound, error)
- func (s *MemoryToolRoundStore) Transition(ctx context.Context, owner Identity, roundID string, expected uint64, ...) (ToolRound, error)
- type MemoryWorkStore
- func (s *MemoryWorkStore) CreatePlan(ctx context.Context, record PlanRecord) (PlanRecord, error)
- func (s *MemoryWorkStore) CreateTask(ctx context.Context, task Task) (Task, error)
- func (s *MemoryWorkStore) GetPlan(ctx context.Context, owner Identity, id string) (PlanRecord, bool, error)
- func (s *MemoryWorkStore) GetTask(ctx context.Context, owner Identity, id string) (Task, bool, error)
- func (s *MemoryWorkStore) ListTasks(ctx context.Context, owner Identity, goalID string) ([]Task, error)
- func (s *MemoryWorkStore) TransitionTask(ctx context.Context, owner Identity, id string, expected uint64, ...) (Task, error)
- func (s *MemoryWorkStore) UpdatePlan(ctx context.Context, owner Identity, id string, expected uint64, ...) (PlanRecord, error)
- type Operation
- type OperationEnvelope
- type OperationRequest
- type Plan
- type PlanRecord
- type PlanStep
- type PlanStore
- type ResourceResolver
- type Run
- type RunDeliveryState
- type RunExecutionState
- type RunStore
- type SessionCoordinator
- func (c *SessionCoordinator) Admit(ctx context.Context, in AdmittedInput) (AdmissionDecision, error)
- func (c *SessionCoordinator) ConsumeWake(sessionID string) bool
- func (c *SessionCoordinator) Finish(ctx context.Context, owner Identity, id string, expected uint64, ...) (AdmittedInput, *AdmittedInput, error)
- func (c *SessionCoordinator) Interrupt(ctx context.Context, owner Identity, id string, expected uint64) (AdmittedInput, *AdmittedInput, error)
- func (c *SessionCoordinator) Recover(inputs []AdmittedInput) error
- type Task
- type TaskMailbox
- type TaskMailboxState
- type TaskMessage
- type TaskStore
- type ToolCallRecord
- type ToolCallState
- type ToolClass
- type ToolFunc
- type ToolOmission
- type ToolRef
- type ToolRound
- type ToolRoundAssessment
- type ToolRoundStore
- type ToolSpec
- type Validator
Constants ¶
const ( RunPending RunExecutionState = "pending" RunExecuting RunExecutionState = "executing" RunPaused RunExecutionState = "paused" RunSucceeded RunExecutionState = "succeeded" RunFailed RunExecutionState = "failed" RunCancelled RunExecutionState = "cancelled" DeliveryPending RunDeliveryState = "pending" DeliveryStreaming RunDeliveryState = "streaming" DeliveryDelivered RunDeliveryState = "delivered" DeliveryFailed RunDeliveryState = "failed" )
const ( PlanStepPending = "pending" PlanStepRunning = "running" PlanStepCompleted = "completed" PlanStepBlocked = "blocked" TaskPending = "pending" TaskClaimed = "claimed" TaskRunning = "running" TaskCompleted = "completed" TaskFailed = "failed" TaskCancelled = "cancelled" )
const OperationEnvelopeVersion = 1
Variables ¶
var ( ErrApprovalRevisionConflict = errors.New("approval revision conflict") ErrApprovalOwnerMismatch = errors.New("approval owner mismatch") )
var ( ErrAttemptConflict = errors.New("attempt identity reused with different input") ErrAttemptRevisionConflict = errors.New("attempt revision conflict") ErrAttemptOwnerMismatch = errors.New("attempt owner mismatch") ErrAttemptTerminal = errors.New("attempt already settled") )
var ( ErrInputConflict = errors.New("input ID reused with different request") ErrInputRevision = errors.New("input revision conflict") ErrSessionBusy = errors.New("session has an active input") ErrGlobalBusy = errors.New("global run limit reached") )
var ( ErrToolRoundConflict = errors.New("tool round ID reused with different intent") ErrToolRoundRevision = errors.New("tool round revision conflict") )
Functions ¶
func IsTaskPlanStale ¶
IsTaskPlanStale reports whether a task was admitted against an older plan revision. Hosts can surface this without mutating either durable record.
Types ¶
type AdmissionDecision ¶
type AdmissionDecision struct {
Input AdmittedInput
Join bool
Wake bool
ActiveID string
// InterruptID is populated only for an explicit now-priority input. The
// host remains responsible for cancelling the active provider/tool work.
InterruptID string
}
type AdmissionEnvelopeBuilder ¶
type AdmissionEnvelopeBuilder struct {
Attempts AttemptLedger
MaxReconciliation int
}
func (AdmissionEnvelopeBuilder) Build ¶
func (b AdmissionEnvelopeBuilder) Build(ctx context.Context, identity Identity, inputID, policyVersion, catalogVersion, contextDigest, harnessDigest string) (CanonicalAdmission, error)
type AdmissionStore ¶
type AdmissionStore interface {
Create(context.Context, AdmittedInput) (AdmittedInput, bool, error)
Transition(context.Context, Identity, string, uint64, InputState, string, string) (AdmittedInput, error)
Get(context.Context, Identity, string) (AdmittedInput, bool, error)
Pending(context.Context, Identity, int) ([]AdmittedInput, error)
}
type AdmittedInput ¶
type AdmittedInput struct {
ID string `json:"id"`
Identity Identity `json:"identity"`
PayloadHash string `json:"payload_hash"`
Mode InputMode `json:"mode"`
Priority InputPriority `json:"priority"`
State InputState `json:"state"`
FailureCode string `json:"failure_code,omitempty"`
AdmittedAt time.Time `json:"admitted_at"`
UpdatedAt time.Time `json:"updated_at"`
Revision uint64 `json:"revision"`
SteersInputID string `json:"steers_input_id,omitempty"`
}
AdmittedInput stores a digest, not prompt text. Hosts retain sensitive request bodies in their own encrypted store.
type ApprovalDecision ¶
type ApprovalDecision struct {
RequestID string `json:"request_id"`
EnvelopeHash string `json:"envelope_hash"`
Allowed bool `json:"allowed"`
Reason string `json:"reason,omitempty"`
ExpiresAt time.Time `json:"expires_at,omitempty"`
}
ApprovalDecision settles one approval request.
type ApprovalPendingError ¶
type ApprovalPendingError struct{ Request ApprovalRequest }
func (*ApprovalPendingError) Error ¶
func (e *ApprovalPendingError) Error() string
type ApprovalRecord ¶
type ApprovalRecord struct {
Request ApprovalRequest `json:"request"`
Decision ApprovalDecision `json:"decision,omitempty"`
State ApprovalState `json:"state"`
Revision uint64 `json:"revision"`
}
type ApprovalRequest ¶
type ApprovalRequest struct {
Version int `json:"version"`
ID string `json:"id"`
Envelope OperationEnvelope `json:"envelope"`
EnvelopeHash string `json:"envelope_hash"`
ReasonCode string `json:"reason_code"`
CreatedAt time.Time `json:"created_at"`
}
ApprovalRequest is a reconnect-safe authorization question.
func NewApprovalRequest ¶
func NewApprovalRequest(id string, envelope OperationEnvelope, reason string, at time.Time) (ApprovalRequest, error)
NewApprovalRequest seals an approval question to the exact operation envelope. It is also useful to durable-store conformance suites and out-of-process approval presenters.
type ApprovalState ¶
type ApprovalState string
const ( ApprovalPending ApprovalState = "pending" ApprovalApproved ApprovalState = "approved" ApprovalDenied ApprovalState = "denied" )
type ApprovalStore ¶
type ApprovalStore interface {
Create(context.Context, ApprovalRequest) (ApprovalRecord, bool, error)
Resolve(context.Context, Identity, string, uint64, ApprovalDecision) (ApprovalRecord, error)
Get(context.Context, Identity, string) (ApprovalRecord, bool, error)
}
ApprovalStore is the durable, owner-scoped reconnect boundary.
type Approver ¶
type Approver interface {
Approve(context.Context, ApprovalRequest) (ApprovalDecision, error)
}
Approver may block while a durable host mediates a request. It must return when ctx is cancelled.
type Attempt ¶
type Attempt struct {
ID string `json:"id"`
Identity Identity `json:"identity"`
RequestID string `json:"request_id,omitempty"`
Tool ToolRef `json:"tool"`
PolicyVersion string `json:"policy_version"`
CatalogVersion string `json:"catalog_version"`
SchemaDigest string `json:"schema_digest"`
ArgsHash string `json:"args_hash"`
TargetHash string `json:"target_hash"`
IdempotencyKey string `json:"idempotency_key"`
SourceEventIDs []string `json:"source_event_ids,omitempty"`
State AttemptState `json:"state"`
ReasonCode string `json:"reason_code,omitempty"`
ResultHash string `json:"result_hash,omitempty"`
ReconcileAction string `json:"reconcile_action,omitempty"`
AdmittedAt time.Time `json:"admitted_at"`
StartedAt time.Time `json:"started_at,omitempty"`
SettledAt time.Time `json:"settled_at,omitempty"`
Revision uint64 `json:"revision"`
}
Attempt records immutable intent plus CAS-guarded lifecycle settlement.
type AttemptLedger ¶
type AttemptLedger interface {
Admit(context.Context, Attempt) (Attempt, bool, error)
Start(context.Context, Identity, string, uint64, time.Time) (Attempt, error)
Settle(context.Context, Identity, string, uint64, AttemptSettlement) (Attempt, error)
Get(context.Context, Identity, string) (Attempt, bool, error)
ListForReconciliation(context.Context, Identity, int) ([]Attempt, error)
}
AttemptLedger is the durable, owner-scoped CAS boundary used by Dispatcher.
type AttemptSettlement ¶
type AttemptState ¶
type AttemptState string
AttemptState is the durable lifecycle of one invocation.
const ( AttemptAdmitted AttemptState = "admitted" AttemptExecuting AttemptState = "executing" AttemptSucceeded AttemptState = "succeeded" AttemptFailed AttemptState = "failed" AttemptDenied AttemptState = "denied" AttemptIndeterminate AttemptState = "indeterminate" AttemptCancelledBefore AttemptState = "cancelled_before_effect" )
type AuthorizationResolver ¶
type AuthorizationResolver func(canonicalArguments string) ([]AuthorizationTarget, error)
type AuthorizationTarget ¶
type CanonicalAdmission ¶
type CanonicalAdmission struct {
Identity Identity `json:"identity"`
InputID string `json:"input_id"`
PolicyVersion string `json:"policy_version"`
CatalogVersion string `json:"catalog_version"`
ContextDigest string `json:"context_digest"`
HarnessDigest string `json:"harness_digest,omitempty"`
Reconciliation []Attempt `json:"reconciliation,omitempty"`
AdmissionDigest string `json:"admission_digest"`
}
CanonicalAdmission is the pre-provider boundary. It pins the projections that must not be rediscovered or silently changed mid-run.
func (CanonicalAdmission) ReadyForProvider ¶
func (a CanonicalAdmission) ReadyForProvider() bool
type Canonicalizer ¶
type Capability ¶
type CapabilityPage ¶
type CapabilityPage struct {
CatalogVersion string `json:"catalog_version"`
Items []CapabilitySummary `json:"items"`
NextCursor string `json:"next_cursor,omitempty"`
}
type CapabilityQuery ¶
type CapabilityQuery struct {
ToolSet string `json:"tool_set,omitempty"`
Search string `json:"search,omitempty"`
Cursor string `json:"cursor,omitempty"`
Limit int `json:"limit,omitempty"`
IncludeSchemas bool `json:"include_schemas,omitempty"`
MaxSchemaBytes int `json:"max_schema_bytes,omitempty"`
}
CapabilityQuery pages through the policy-filtered catalog. Schemas are opt-in so a large tool registry does not consume every provider request.
type CapabilitySummary ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog registers tools and produces immutable per-run snapshots.
func NewCatalog ¶
func NewCatalog() *Catalog
type CatalogSnapshot ¶
type CatalogSnapshot struct {
// contains filtered or unexported fields
}
CatalogSnapshot is an immutable admitted tool catalog.
func (CatalogSnapshot) CanonicalOperation ¶
func (s CatalogSnapshot) CanonicalOperation(ref ToolRef, assertedResource, arguments string) (Operation, error)
CanonicalOperation validates a tool call and derives its immutable policy target. assertedResource is only a caller-side consistency check.
func (CatalogSnapshot) Capabilities ¶
func (s CatalogSnapshot) Capabilities(toolSet string, snapshot policy.Snapshot) []Capability
Capabilities is the versioned source for model discovery. Consumers should generate provider-specific tool schemas from this same snapshot.
func (CatalogSnapshot) Discover ¶
func (s CatalogSnapshot) Discover(query CapabilityQuery, snapshot policy.Snapshot) (CapabilityPage, error)
Discover returns a deterministic page tied to this admitted catalog generation. A cursor from another generation fails instead of drifting.
func (CatalogSnapshot) Refs ¶
func (s CatalogSnapshot) Refs(policySnapshot policy.Snapshot) []ToolRef
func (CatalogSnapshot) Version ¶
func (s CatalogSnapshot) Version() string
Version returns the catalog generation pinned at admission.
type ChildRun ¶
type ChildRun struct {
ID string `json:"id"`
ParentRunID string `json:"parent_run_id"`
ParentNodeID string `json:"parent_node_id,omitempty"`
ExpertID string `json:"expert_id"`
Identity Identity `json:"identity"`
Model string `json:"model"`
CapabilityVersion string `json:"capability_version"`
ContextDigest string `json:"context_digest,omitempty"`
Status ChildStatus `json:"status"`
ArtifactRef string `json:"artifact_ref,omitempty"`
FailureCode string `json:"failure_code,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Revision uint64 `json:"revision"`
}
ChildRun is the optional durable projection for inspectable or detached delegated work. It intentionally stores manifests and artifacts, not a full child transcript.
type ChildRunStore ¶
type ChildStatus ¶
type ChildStatus string
const ( ChildPending ChildStatus = "pending" ChildRunning ChildStatus = "running" ChildCompleted ChildStatus = "completed" ChildFailed ChildStatus = "failed" ChildCancelled ChildStatus = "cancelled" ChildPressure ChildStatus = "pressure" )
type Dispatcher ¶
type Dispatcher struct {
Catalog CatalogSnapshot
Policy policy.Snapshot
Ledger AttemptLedger
Approver Approver
Approvals ApprovalStore
Now func() time.Time
}
Dispatcher validates and canonicalizes before it authorizes, records, or exposes an approval. Every later phase consumes the same sealed envelope.
func (Dispatcher) Execute ¶
func (d Dispatcher) Execute(ctx context.Context, attemptID string, ref ToolRef, resource, arguments string) (string, error)
Execute is the compact compatibility entry point. resource is an assertion, never the policy target; registered tools derive that target from arguments.
func (Dispatcher) ExecuteOperation ¶
func (d Dispatcher) ExecuteOperation(ctx context.Context, request OperationRequest) (string, error)
ExecuteOperation runs one request from its canonical operation envelope.
type ExistingAttemptError ¶
type ExistingAttemptError struct{ Attempt Attempt }
func (*ExistingAttemptError) Error ¶
func (e *ExistingAttemptError) Error() string
type Flow ¶
type Flow struct {
ID string `json:"id"`
Revision uint64 `json:"revision"`
Nodes []FlowNode `json:"nodes"`
}
Flow describes dependencies between tasks. It is a contract only; the framework intentionally does not provide a workflow scheduler.
type Goal ¶
type Goal struct {
ID string `json:"id"`
Objective string `json:"objective"`
Status string `json:"status"`
Revision uint64 `json:"revision"`
}
Goal is a durable user objective independent of any one run.
type Identity ¶
type Identity struct {
PrincipalID string `json:"principal_id"`
TenantID string `json:"tenant_id,omitempty"`
SessionID string `json:"session_id"`
RunID string `json:"run_id"`
}
Identity is the immutable server-admitted execution identity inherited by child work. It must never be populated from model tool arguments.
func IdentityFromContext ¶
IdentityFromContext returns the admitted identity.
type IndeterminateError ¶
type IndeterminateError struct{ Err error }
IndeterminateError means execution may have produced an external effect; callers must reconcile rather than automatically retry.
func (*IndeterminateError) Error ¶
func (e *IndeterminateError) Error() string
func (*IndeterminateError) Unwrap ¶
func (e *IndeterminateError) Unwrap() error
type InputPriority ¶
type InputPriority string
InputPriority declares the safe boundary at which a newly admitted input may affect an active session. It is persisted with the input so reconnects do not silently change interrupt semantics.
const ( InputPriorityNow InputPriority = "now" InputPriorityNext InputPriority = "next" InputPriorityLater InputPriority = "later" )
type InputState ¶
type InputState string
const ( InputAdmitted InputState = "admitted" InputQueued InputState = "queued" InputSteering InputState = "steering" InputRunning InputState = "running" InputCompleted InputState = "completed" InputFailed InputState = "failed" InputCancelled InputState = "cancelled" )
type MemoryAdmissionStore ¶
type MemoryAdmissionStore struct {
// contains filtered or unexported fields
}
func NewMemoryAdmissionStore ¶
func NewMemoryAdmissionStore() *MemoryAdmissionStore
func (*MemoryAdmissionStore) Create ¶
func (s *MemoryAdmissionStore) Create(ctx context.Context, in AdmittedInput) (AdmittedInput, bool, error)
func (*MemoryAdmissionStore) Get ¶
func (s *MemoryAdmissionStore) Get(ctx context.Context, owner Identity, id string) (AdmittedInput, bool, error)
func (*MemoryAdmissionStore) Pending ¶
func (s *MemoryAdmissionStore) Pending(ctx context.Context, owner Identity, limit int) ([]AdmittedInput, error)
func (*MemoryAdmissionStore) Transition ¶
func (s *MemoryAdmissionStore) Transition(ctx context.Context, owner Identity, id string, expected uint64, next InputState, failure, steers string) (AdmittedInput, error)
type MemoryApprovalStore ¶
type MemoryApprovalStore struct {
// contains filtered or unexported fields
}
func NewMemoryApprovalStore ¶
func NewMemoryApprovalStore() *MemoryApprovalStore
func (*MemoryApprovalStore) Create ¶
func (s *MemoryApprovalStore) Create(ctx context.Context, request ApprovalRequest) (ApprovalRecord, bool, error)
func (*MemoryApprovalStore) Get ¶
func (s *MemoryApprovalStore) Get(ctx context.Context, owner Identity, requestID string) (ApprovalRecord, bool, error)
func (*MemoryApprovalStore) Resolve ¶
func (s *MemoryApprovalStore) Resolve(ctx context.Context, owner Identity, requestID string, expected uint64, decision ApprovalDecision) (ApprovalRecord, error)
type MemoryAttemptLedger ¶
type MemoryAttemptLedger struct {
// contains filtered or unexported fields
}
MemoryAttemptLedger is a concurrency-safe reference implementation.
func NewMemoryAttemptLedger ¶
func NewMemoryAttemptLedger() *MemoryAttemptLedger
func (*MemoryAttemptLedger) ListForReconciliation ¶
type MemoryChildRunStore ¶
type MemoryChildRunStore struct {
// contains filtered or unexported fields
}
func NewMemoryChildRunStore ¶
func NewMemoryChildRunStore() *MemoryChildRunStore
func (*MemoryChildRunStore) Create ¶
func (s *MemoryChildRunStore) Create(ctx context.Context, run ChildRun) error
func (*MemoryChildRunStore) Transition ¶
func (s *MemoryChildRunStore) Transition(ctx context.Context, id string, expected uint64, next ChildStatus, artifactRef, failureCode string) (ChildRun, error)
type MemoryRunStore ¶
type MemoryRunStore struct {
// contains filtered or unexported fields
}
func NewMemoryRunStore ¶
func NewMemoryRunStore() *MemoryRunStore
func (*MemoryRunStore) Update ¶
func (s *MemoryRunStore) Update(ctx context.Context, owner Identity, id string, expected uint64, execution RunExecutionState, delivery RunDeliveryState, failure string, cursor uint64) (Run, error)
type MemoryTaskMailbox ¶
type MemoryTaskMailbox struct {
// contains filtered or unexported fields
}
func NewMemoryTaskMailbox ¶
func NewMemoryTaskMailbox() *MemoryTaskMailbox
func (*MemoryTaskMailbox) Ack ¶
func (m *MemoryTaskMailbox) Ack(ctx context.Context, owner Identity, recipient string, sequence uint64) (TaskMailboxState, error)
func (*MemoryTaskMailbox) Append ¶
func (m *MemoryTaskMailbox) Append(ctx context.Context, message TaskMessage) (TaskMessage, bool, error)
type MemoryToolRoundStore ¶
type MemoryToolRoundStore struct {
// contains filtered or unexported fields
}
func NewMemoryToolRoundStore ¶
func NewMemoryToolRoundStore() *MemoryToolRoundStore
func (*MemoryToolRoundStore) Transition ¶
func (s *MemoryToolRoundStore) Transition(ctx context.Context, owner Identity, roundID string, expected uint64, callID string, next ToolCallState, attemptID string, omission *ToolOmission) (ToolRound, error)
type MemoryWorkStore ¶
type MemoryWorkStore struct {
// contains filtered or unexported fields
}
func NewMemoryWorkStore ¶
func NewMemoryWorkStore() *MemoryWorkStore
func (*MemoryWorkStore) CreatePlan ¶
func (s *MemoryWorkStore) CreatePlan(ctx context.Context, record PlanRecord) (PlanRecord, error)
func (*MemoryWorkStore) CreateTask ¶
func (*MemoryWorkStore) GetPlan ¶
func (s *MemoryWorkStore) GetPlan(ctx context.Context, owner Identity, id string) (PlanRecord, bool, error)
func (*MemoryWorkStore) TransitionTask ¶
func (*MemoryWorkStore) UpdatePlan ¶
func (s *MemoryWorkStore) UpdatePlan(ctx context.Context, owner Identity, id string, expected uint64, steps []PlanStep) (PlanRecord, error)
type Operation ¶
type Operation struct {
Tool ToolRef `json:"tool"`
CatalogVersion string `json:"catalog_version"`
SchemaDigest string `json:"schema_digest"`
CanonicalArguments string `json:"canonical_arguments"`
ArgsHash string `json:"args_hash"`
Resource string `json:"resource,omitempty"`
TargetHash string `json:"target_hash"`
Authorizations []AuthorizationTarget `json:"authorizations,omitempty"`
}
Operation is the canonical, schema-pinned value authorized by policy and approvals. It contains no caller-authored description of the target.
type OperationEnvelope ¶
type OperationEnvelope struct {
Version int `json:"version"`
Identity Identity `json:"identity"`
AttemptID string `json:"attempt_id"`
RequestID string `json:"request_id,omitempty"`
PolicyVersion string `json:"policy_version"`
IdempotencyKey string `json:"idempotency_key"`
SourceEventIDs []string `json:"source_event_ids,omitempty"`
Operation
}
OperationEnvelope is the closed record used for intent, approval, dispatch, reconciliation, and audit.
type OperationRequest ¶
type OperationRequest struct {
AttemptID string `json:"attempt_id"`
RequestID string `json:"request_id,omitempty"`
IdempotencyKey string `json:"idempotency_key,omitempty"`
SourceEventIDs []string `json:"source_event_ids,omitempty"`
Tool ToolRef `json:"tool"`
Resource string `json:"resource,omitempty"`
Arguments string `json:"arguments"`
}
OperationRequest binds an operation to its admitted execution provenance.
type Plan ¶
type Plan struct {
ID string `json:"id"`
Revision uint64 `json:"revision"`
Steps []PlanStep `json:"steps"`
UpdatedAt time.Time `json:"updated_at"`
}
Plan describes intended steps and may be revised without becoming a task.
type PlanRecord ¶
type PlanStore ¶
type PlanStore interface {
CreatePlan(context.Context, PlanRecord) (PlanRecord, error)
UpdatePlan(context.Context, Identity, string, uint64, []PlanStep) (PlanRecord, error)
GetPlan(context.Context, Identity, string) (PlanRecord, bool, error)
}
type ResourceResolver ¶
type Run ¶
type Run struct {
ID string `json:"id"`
InputID string `json:"input_id"`
Identity Identity `json:"identity"`
Execution RunExecutionState `json:"execution"`
Delivery RunDeliveryState `json:"delivery"`
FailureCode string `json:"failure_code,omitempty"`
DeliveryCursor uint64 `json:"delivery_cursor,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Revision uint64 `json:"revision"`
}
type RunDeliveryState ¶
type RunDeliveryState string
type RunExecutionState ¶
type RunExecutionState string
type SessionCoordinator ¶
type SessionCoordinator struct {
// contains filtered or unexported fields
}
SessionCoordinator serializes each session and bounds global running work. Its wake bit coalesces repeated scheduler notifications.
func NewSessionCoordinator ¶
func NewSessionCoordinator(store AdmissionStore, maxActive int) (*SessionCoordinator, error)
func (*SessionCoordinator) Admit ¶
func (c *SessionCoordinator) Admit(ctx context.Context, in AdmittedInput) (AdmissionDecision, error)
func (*SessionCoordinator) ConsumeWake ¶
func (c *SessionCoordinator) ConsumeWake(sessionID string) bool
func (*SessionCoordinator) Finish ¶
func (c *SessionCoordinator) Finish(ctx context.Context, owner Identity, id string, expected uint64, state InputState, failure string) (AdmittedInput, *AdmittedInput, error)
func (*SessionCoordinator) Interrupt ¶
func (c *SessionCoordinator) Interrupt(ctx context.Context, owner Identity, id string, expected uint64) (AdmittedInput, *AdmittedInput, error)
func (*SessionCoordinator) Recover ¶
func (c *SessionCoordinator) Recover(inputs []AdmittedInput) error
Recover rebuilds process-local scheduling state from durable nonterminal inputs. Hosts call it once after loading owner-scoped pending records.
type Task ¶
type Task struct {
ID string `json:"id"`
GoalID string `json:"goal_id,omitempty"`
ParentTaskID string `json:"parent_task_id,omitempty"`
PlanID string `json:"plan_id,omitempty"`
PlanRevision uint64 `json:"plan_revision,omitempty"`
RunID string `json:"run_id,omitempty"`
Status string `json:"status"`
Assignee string `json:"assignee,omitempty"`
Owner Identity `json:"owner"`
Revision uint64 `json:"revision"`
UpdatedAt time.Time `json:"updated_at"`
}
Task is one executing unit with ownership and terminal state.
type TaskMailbox ¶
type TaskMailboxState ¶
type TaskMessage ¶
type TaskMessage struct {
ID string `json:"id"`
Owner Identity `json:"owner"`
SenderTaskID string `json:"sender_task_id"`
RecipientTaskID string `json:"recipient_task_id"`
PayloadHash string `json:"payload_hash"`
Sequence uint64 `json:"sequence"`
CreatedAt time.Time `json:"created_at"`
}
TaskMessage carries only a payload digest; hosts retain message content in their encrypted task store. Sequence is assigned by the mailbox.
type ToolCallRecord ¶
type ToolCallRecord struct {
ID string `json:"id"`
Tool ToolRef `json:"tool"`
Required bool `json:"required"`
State ToolCallState `json:"state"`
AttemptID string `json:"attempt_id,omitempty"`
Omission *ToolOmission `json:"omission,omitempty"`
UpdatedAt time.Time `json:"updated_at"`
}
type ToolCallState ¶
type ToolCallState string
const ( ToolCallPlanned ToolCallState = "planned" ToolCallAdmitted ToolCallState = "admitted" ToolCallApprovalPending ToolCallState = "approval_pending" ToolCallExecuting ToolCallState = "executing" ToolCallSucceeded ToolCallState = "succeeded" ToolCallFailed ToolCallState = "failed" ToolCallDenied ToolCallState = "denied" ToolCallIndeterminate ToolCallState = "indeterminate" ToolCallOmitted ToolCallState = "omitted" )
type ToolClass ¶
type ToolClass struct {
Category string `json:"category"`
SideEffecting bool `json:"side_effecting"`
HostAction bool `json:"host_action"`
TrustedOutput bool `json:"trusted_output"`
}
ToolClass describes side effects and trust independently of prompts.
type ToolOmission ¶
type ToolRound ¶
type ToolRound struct {
ID string `json:"id"`
Identity Identity `json:"identity"`
PolicyVersion string `json:"policy_version"`
CatalogVersion string `json:"catalog_version"`
Calls []ToolCallRecord `json:"calls"`
Revision uint64 `json:"revision"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ToolRound is the durable closure boundary for one model tool-call batch. Calls retain proposal order while settlement uses a round-wide CAS revision.
func (ToolRound) Assess ¶
func (r ToolRound) Assess() ToolRoundAssessment
type ToolRoundAssessment ¶
type ToolRoundStore ¶
type ToolRoundStore interface {
Create(context.Context, ToolRound) (ToolRound, bool, error)
Transition(context.Context, Identity, string, uint64, string, ToolCallState, string, *ToolOmission) (ToolRound, error)
Get(context.Context, Identity, string) (ToolRound, bool, error)
Open(context.Context, Identity, int) ([]ToolRound, error)
}
type ToolSpec ¶
type ToolSpec struct {
Ref ToolRef
Description string
Schema json.RawMessage
SchemaDigest string
ToolSets []string
Class ToolClass
Validate Validator
// Canonicalize returns the exact JSON passed to execution and hashed into
// approvals. When nil, the catalog uses deterministic JSON encoding.
Canonicalize Canonicalizer
// ResolveResource derives the policy resource from canonical arguments.
// Resource-sensitive and side-effecting tools must provide it; callers are
// never trusted to describe their own authorization target.
ResolveResource ResourceResolver
// ResolveAuthorizations adds argument-derived capabilities, such as the
// selected expert or skill, that must also pass the admitted policy.
ResolveAuthorizations AuthorizationResolver
Execute ToolFunc
}
ToolSpec is one immutable, executable catalog registration.