Documentation
¶
Overview ¶
Package sqlcompletion shares the transactional completion invariant between SQL backends. Drivers supply only transaction and placeholder adapters.
Index ¶
- Constants
- func ActionDeliverySchema(dialect string) []string
- func ConnectorActionSchema(dialect string) []string
- func PendingApprovalSchema(dialect string) []string
- func ScanPendingAction(row Row) (*models.PendingAction, error)
- type ActionRows
- type Driver
- func (d Driver) AckActionDelivery(ctx context.Context, id, token string) error
- func (d Driver) ApprovePendingAction(ctx context.Context, id, actor string) error
- func (d Driver) BeginRunAttempt(ctx context.Context, runID, incarnation string, generation int64) (bool, error)
- func (d Driver) BindPendingAction(ctx context.Context, a *models.PendingAction) error
- func (d Driver) ClaimActionDeliveries(ctx context.Context, sinkID string, now, leaseUntil time.Time, limit int) ([]*state.ActionDelivery, error)
- func (d Driver) CompleteRun(ctx context.Context, c *state.RunCompletion) (state.CompletionResult, error)
- func (d Driver) CompleteRunInTx(ctx context.Context, tx Tx, c *state.RunCompletion) (state.CompletionResult, error)
- func (d Driver) ConsumeApprovedPendingAction(ctx context.Context, tenantID, agentID, runID string, generation int64, ...) (string, error)
- func (d Driver) CreateConnectorAction(ctx context.Context, input *models.ConnectorAction, mutation string) (*models.ConnectorAction, error)
- func (d Driver) DeleteBoundOpaqueCheckpoint(ctx context.Context, binding state.RunCheckpointBinding, checkpointID string) error
- func (d Driver) FailActionDelivery(ctx context.Context, id, token string, nextAt time.Time, reason string, ...) error
- func (d Driver) FindOpenPendingCall(ctx context.Context, tenantID, agentID, runID string, generation int64, ...) (*models.PendingAction, error)
- func (d Driver) FinishConnectorAction(ctx context.Context, id string, version int64, dispatchID string, ...) (*models.ConnectorAction, error)
- func (d Driver) GetConnectorAction(ctx context.Context, id string) (*models.ConnectorAction, error)
- func (d Driver) GetPendingAction(ctx context.Context, id string) (*models.PendingAction, error)
- func (d Driver) GetRunUsage(ctx context.Context, binding state.RunUsageBinding) (*models.RunUsageSnapshot, error)
- func (d Driver) ListConnectorActionEvents(ctx context.Context, id string, after int64, limit int) ([]*models.ConnectorActionEvent, error)
- func (d Driver) ListPendingActionApprovals(ctx context.Context, id string) ([]models.PendingActionApproval, error)
- func (d Driver) LockOpaqueCheckpoint(ctx context.Context, tx Tx, binding state.RunCheckpointBinding) error
- func (d Driver) LockRunCheckpoint(ctx context.Context, tx Tx, binding state.RunCheckpointBinding) error
- func (d Driver) LockThread(ctx context.Context, tx Tx, threadID string) (models.ThreadStatus, error)
- func (d Driver) MarkExpiredConnectorActionsUnknown(ctx context.Context, cutoff time.Time, limit int) (int, error)
- func (d Driver) PeekApprovedConnectorAction(ctx context.Context, id string) (*models.PendingAction, error)
- func (d Driver) PendingRunIncarnation(ctx context.Context, tenantID, agentID, runID string) (string, error)
- func (d Driver) PrepareConnectorActionDispatch(ctx context.Context, id string, version int64, approvalID, source string, ...) (*state.ConnectorActionDispatch, error)
- func (d Driver) PruneConnectorActions(ctx context.Context, cutoff time.Time, limit int) (int, error)
- func (d Driver) RecordConnectorActionDecision(ctx context.Context, id string, version int64, ...) (*models.ConnectorAction, error)
- func (d Driver) ReleaseRunUsageHold(ctx context.Context, runID, incarnation string) error
- func (d Driver) ReportRunUsage(ctx context.Context, binding state.RunUsageBinding, ...) (*models.RunUsageSnapshot, bool, error)
- func (d Driver) RetryActionDelivery(ctx context.Context, tenantID, id string) error
- func (d Driver) SearchActionDeliveries(ctx context.Context, req *state.ActionDeliverySearchRequest) ([]*state.ActionDelivery, error)
- func (d Driver) SearchConnectorActions(ctx context.Context, request *models.ConnectorActionSearchRequest) ([]*models.ConnectorAction, error)
- func (d Driver) TryClaimRunTerminalHook(ctx context.Context, runID, incarnation string) (bool, error)
- func (d Driver) UpsertRunUsageHold(ctx context.Context, incarnation string, hold *models.UsageHold) error
- func (d Driver) WithRunCheckpoint(ctx context.Context, binding state.RunCheckpointBinding, mutate func(Tx) error) error
- func (d Driver) WithRunIdentity(ctx context.Context, runID, incarnation string, mutate func(Tx, string) error) error
- func (d Driver) WithThread(ctx context.Context, threadID string, mutate func(Tx) error) error
- func (d Driver) WriteRunUsageEvent(ctx context.Context, incarnation string, event *models.UsageEvent) error
- func (d Driver) WriteUsageEvent(ctx context.Context, event *models.UsageEvent) error
- type Row
- type Tx
Constants ¶
const PendingActionSelectColumns = `` /* 421-byte string literal not displayed */
PendingActionSelectColumns keeps the SQL backends and transactional approval core on the same metadata projection. Counts are derived, never caller supplied.
const SQLiteTimestampLayout = "2006-01-02T15:04:05.000000000Z"
SQLiteTimestampLayout preserves nanosecond chronology in text comparisons. RFC3339Nano removes trailing zeros, making older fractions sort after newer.
Variables ¶
This section is empty.
Functions ¶
func ActionDeliverySchema ¶ added in v0.7.0
ActionDeliverySchema deliberately has no action/run foreign key. Delivery recovery remains possible after explicit action evidence retention.
func ConnectorActionSchema ¶ added in v0.7.0
ConnectorActionSchema has no run foreign key. Explicit action retention owns deletion; run or thread deletion must not silently erase effect evidence.
func PendingApprovalSchema ¶ added in v0.7.0
PendingApprovalSchema keeps approval history separate from run lifetime. A unique exact identity prevents concurrent retries becoming additional votes.
func ScanPendingAction ¶ added in v0.7.0
func ScanPendingAction(row Row) (*models.PendingAction, error)
Types ¶
type ActionRows ¶ added in v0.7.0
ActionRows is the small read adapter needed by the shared action lifecycle.
type Driver ¶
type Driver struct {
Begin func(context.Context) (Tx, error)
Dialect string
ValidateValues func(context.Context, Tx, []byte) error
}
func DatabaseSQL ¶
DatabaseSQL adapts database/sql transactions. SQLite uses BEGIN IMMEDIATE so read/modify/write is serialized before the metadata is inspected.
func (Driver) AckActionDelivery ¶ added in v0.7.0
func (Driver) ApprovePendingAction ¶ added in v0.7.0
ApprovePendingAction serializes votes with capability consumption. Managed paths lock the run before the pending row, matching dispatch's lock order.
func (Driver) BeginRunAttempt ¶
func (Driver) BindPendingAction ¶ added in v0.7.0
BindPendingAction freezes the approval plan and derives managed requester identity from the durable run, never from submitted tool arguments.
func (Driver) ClaimActionDeliveries ¶ added in v0.7.0
func (Driver) CompleteRun ¶
func (d Driver) CompleteRun(ctx context.Context, c *state.RunCompletion) (state.CompletionResult, error)
func (Driver) CompleteRunInTx ¶
func (d Driver) CompleteRunInTx(ctx context.Context, tx Tx, c *state.RunCompletion) (state.CompletionResult, error)
CompleteRunInTx shares the completion writes with synchronous cached-run creation. The caller owns the transaction and must commit only after every admission, parent-ownership and completion operation succeeds.
func (Driver) ConsumeApprovedPendingAction ¶ added in v0.7.0
func (d Driver) ConsumeApprovedPendingAction(ctx context.Context, tenantID, agentID, runID string, generation int64, connector, tool, digest, targetRevision, policyRevision, toolRevision string) (string, error)
ConsumeApprovedPendingAction locks the current run before approval authority. A status flip alone never supplies votes for a quorum-bound capability.
func (Driver) CreateConnectorAction ¶ added in v0.7.0
func (d Driver) CreateConnectorAction(ctx context.Context, input *models.ConnectorAction, mutation string) (*models.ConnectorAction, error)
func (Driver) DeleteBoundOpaqueCheckpoint ¶
func (Driver) FailActionDelivery ¶ added in v0.7.0
func (Driver) FindOpenPendingCall ¶ added in v0.7.0
func (d Driver) FindOpenPendingCall(ctx context.Context, tenantID, agentID, runID string, generation int64, connector, tool, digest string, embedded bool, incarnation, targetRevision, policyRevision, toolRevision string, plan *models.PendingAction) (*models.PendingAction, error)
FindOpenPendingCall shares exact revision and immutable-plan matching across all SQL dialects. Public lookups omit plan; creation supplies the frozen plan.
func (Driver) FinishConnectorAction ¶ added in v0.7.0
func (Driver) GetConnectorAction ¶ added in v0.7.0
func (Driver) GetPendingAction ¶ added in v0.7.0
func (Driver) GetRunUsage ¶ added in v0.8.0
func (d Driver) GetRunUsage(ctx context.Context, binding state.RunUsageBinding) (*models.RunUsageSnapshot, error)
func (Driver) ListConnectorActionEvents ¶ added in v0.7.0
func (Driver) ListPendingActionApprovals ¶ added in v0.7.0
func (Driver) LockOpaqueCheckpoint ¶ added in v0.10.0
func (d Driver) LockOpaqueCheckpoint(ctx context.Context, tx Tx, binding state.RunCheckpointBinding) error
LockOpaqueCheckpoint retains the shared attempt lock and additionally pins an opaque mutation to the immutable row captured when it was dispatched.
func (Driver) LockRunCheckpoint ¶
func (d Driver) LockRunCheckpoint(ctx context.Context, tx Tx, binding state.RunCheckpointBinding) error
LockRunCheckpoint uses the same run-row lock as attempt advancement and completion. The caller must keep tx open until its blob mutation commits.
func (Driver) LockThread ¶
func (d Driver) LockThread(ctx context.Context, tx Tx, threadID string) (models.ThreadStatus, error)
LockThread binds a child mutation to the current parent owner. The row lock must be retained through the child write: a preceding API lookup cannot fence deletion and reuse of the same custom thread ID by a different tenant.
func (Driver) MarkExpiredConnectorActionsUnknown ¶ added in v0.7.0
func (Driver) PeekApprovedConnectorAction ¶ added in v0.7.0
func (Driver) PendingRunIncarnation ¶ added in v0.7.0
func (Driver) PrepareConnectorActionDispatch ¶ added in v0.7.0
func (Driver) PruneConnectorActions ¶ added in v0.7.0
func (Driver) RecordConnectorActionDecision ¶ added in v0.7.0
func (Driver) ReleaseRunUsageHold ¶ added in v0.10.0
func (Driver) ReportRunUsage ¶ added in v0.8.0
func (d Driver) ReportRunUsage(ctx context.Context, binding state.RunUsageBinding, report models.RunUsageReport) (*models.RunUsageSnapshot, bool, error)
func (Driver) RetryActionDelivery ¶ added in v0.7.0
func (Driver) SearchActionDeliveries ¶ added in v0.7.0
func (d Driver) SearchActionDeliveries(ctx context.Context, req *state.ActionDeliverySearchRequest) ([]*state.ActionDelivery, error)
func (Driver) SearchConnectorActions ¶ added in v0.7.0
func (d Driver) SearchConnectorActions(ctx context.Context, request *models.ConnectorActionSearchRequest) ([]*models.ConnectorAction, error)
func (Driver) TryClaimRunTerminalHook ¶ added in v0.10.0
func (d Driver) TryClaimRunTerminalHook(ctx context.Context, runID, incarnation string) (bool, error)
TryClaimRunTerminalHook keeps original-record validation and claim insertion under the same run lock, including against concurrent deletion/recreation.
func (Driver) UpsertRunUsageHold ¶ added in v0.10.0
func (Driver) WithRunCheckpoint ¶
func (Driver) WithRunIdentity ¶ added in v0.10.0
func (d Driver) WithRunIdentity(ctx context.Context, runID, incarnation string, mutate func(Tx, string) error) error
WithRunIdentity keeps the original run row locked for the entire mutation. A second read outside this transaction cannot provide the same guarantee.
func (Driver) WithThread ¶
func (Driver) WriteRunUsageEvent ¶ added in v0.10.0
func (Driver) WriteUsageEvent ¶ added in v0.10.0
WriteUsageEvent retains the trusted, unbound Go-store compatibility path. API finalization must use WriteRunUsageEvent instead.
type Tx ¶
type Tx interface {
Exec(context.Context, string, ...interface{}) error
Row(context.Context, string, ...interface{}) Row
Commit(context.Context) error
Rollback(context.Context) error
}
func WrapSQLTransaction ¶
WrapSQLTransaction lets a store reuse the completion lock inside an existing database/sql transaction without opening another connection.
func WrapSQLiteConnection ¶
WrapSQLiteConnection adapts an already-open BEGIN IMMEDIATE transaction.