Documentation
¶
Overview ¶
Package postgres implements the state.Store interface using PostgreSQL via pgx. This is the production backend for multi-node deployments.
Index ¶
- type Option
- type Store
- func (s *Store) AckActionDelivery(ctx context.Context, id, token string) error
- func (s *Store) BeginRunAttempt(ctx context.Context, id string, generation int64) (bool, error)
- func (s *Store) ClaimActionDeliveries(ctx context.Context, sinkID string, now, leaseUntil time.Time, limit int) ([]*state.ActionDelivery, error)
- func (s *Store) Close() error
- func (s *Store) CompleteRun(ctx context.Context, c *state.RunCompletion) (state.CompletionResult, error)
- func (s *Store) ConsumeApprovedAction(ctx context.Context, tenantID, agentID, runID string, generation int64, ...) (string, error)
- func (s *Store) CountActiveRuns(ctx context.Context, agentID string) (int, error)
- func (s *Store) CountAgents(ctx context.Context) (int, error)
- func (s *Store) CountRunsByStatus(ctx context.Context) (map[string]int, error)
- func (s *Store) CountRunsCreatedSince(ctx context.Context, since time.Time, agentID string) (int, error)
- func (s *Store) CountRunsSince(ctx context.Context, tenantID, agentID string, since time.Time) (int64, error)
- func (s *Store) CountThreadsByStatus(ctx context.Context) (map[string]int, error)
- func (s *Store) CreateBreakGlassWindow(ctx context.Context, w *models.BreakGlassWindow) error
- func (s *Store) CreateCachedRun(ctx context.Context, run *models.Run, caps *state.RunAdmissionCaps) error
- func (s *Store) CreateConnectorAction(ctx context.Context, a *models.ConnectorAction, mutation string) (*models.ConnectorAction, error)
- func (s *Store) CreatePendingAction(ctx context.Context, a *models.PendingAction) error
- func (s *Store) CreateRun(ctx context.Context, run *models.Run) error
- func (s *Store) CreateRunAdmitted(ctx context.Context, run *models.Run, caps *state.RunAdmissionCaps) error
- func (s *Store) CreateThread(ctx context.Context, thread *models.Thread) error
- func (s *Store) CredentialLeaseStorage() (credentials.Store, error)
- func (s *Store) DeleteBoundOpaqueCheckpoint(ctx context.Context, binding state.RunCheckpointBinding, checkpointID string) error
- func (s *Store) DeleteBreakGlassWindow(ctx context.Context, id string) error
- func (s *Store) DeleteCronSchedule(ctx context.Context, name string) error
- func (s *Store) DeleteFinOpsOverlay(ctx context.Context) error
- func (s *Store) DeleteItem(ctx context.Context, namespace []string, key string) error
- func (s *Store) DeleteKillSwitch(ctx context.Context, id string) error
- func (s *Store) DeleteMandatoryHITLRule(ctx context.Context, id string) error
- func (s *Store) DeleteOpaqueCheckpoint(ctx context.Context, threadID, checkpointID string) error
- func (s *Store) DeletePolicyGrant(ctx context.Context, id string) error
- func (s *Store) DeleteRegistryEntry(ctx context.Context, name string) error
- func (s *Store) DeleteRun(ctx context.Context, runID string) error
- func (s *Store) DeleteThread(ctx context.Context, threadID string) error
- func (s *Store) Downgrade(ctx context.Context) error
- func (s *Store) ExpireGovernancePending(ctx context.Context, now time.Time) error
- func (s *Store) ExpireUsageHolds(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *Store) FailActionDelivery(ctx context.Context, id, token string, nextAt time.Time, reason string, ...) error
- func (s *Store) FindActiveBreakGlass(ctx context.Context, tenantID, agentID string) (*models.BreakGlassWindow, error)
- func (s *Store) FindActiveKill(ctx context.Context, tenantID, agentID string) (*models.KillSwitch, error)
- func (s *Store) FindOpenPendingAction(ctx context.Context, tenantID, agentID, runID string, generation int64, ...) (*models.PendingAction, error)
- func (s *Store) FinishConnectorAction(ctx context.Context, id string, version int64, dispatch string, ...) (*models.ConnectorAction, error)
- func (s *Store) GetAgent(ctx context.Context, agentID string) (*models.Agent, error)
- func (s *Store) GetAgentSchema(ctx context.Context, agentID string) (*models.AgentSchema, error)
- func (s *Store) GetAgentVersion(ctx context.Context, agentID string, version int) (*models.AgentVersion, error)
- func (s *Store) GetBreakGlassWindow(ctx context.Context, id string) (*models.BreakGlassWindow, error)
- func (s *Store) GetCachedRunResult(ctx context.Context, cacheKey string) (*models.CachedRunResult, error)
- func (s *Store) GetConnectorAction(ctx context.Context, id string) (*models.ConnectorAction, error)
- func (s *Store) GetFinOpsOverlay(ctx context.Context) (*models.FinOpsOverlay, error)
- func (s *Store) GetItem(ctx context.Context, namespace []string, key string, refreshTTL bool) (*models.StoreItem, error)
- func (s *Store) GetKillSwitch(ctx context.Context, id string) (*models.KillSwitch, error)
- func (s *Store) GetLastCronFireTime(ctx context.Context, scheduleName string) (time.Time, bool, error)
- func (s *Store) GetLatestCheckpoint(ctx context.Context, threadID string) (*models.ThreadState, error)
- func (s *Store) GetLatestOpaqueCheckpoint(ctx context.Context, threadID, namespace string) (*models.OpaqueCheckpoint, error)
- func (s *Store) GetMandatoryHITLRule(ctx context.Context, id string) (*models.MandatoryHITLRule, error)
- func (s *Store) GetOpaqueCheckpoint(ctx context.Context, threadID, checkpointID string) (*models.OpaqueCheckpoint, error)
- func (s *Store) GetPendingAction(ctx context.Context, id string) (*models.PendingAction, error)
- func (s *Store) GetPolicyGrant(ctx context.Context, id string) (*models.PolicyGrant, error)
- func (s *Store) GetRegistryEntry(ctx context.Context, name string) (*models.RegistryEntry, error)
- func (s *Store) GetRegistryEntryVersion(ctx context.Context, name string, version int) (*models.RegistryEntryVersion, error)
- func (s *Store) GetRun(ctx context.Context, runID string) (*models.Run, error)
- func (s *Store) GetRunUsage(ctx context.Context, binding state.RunUsageBinding) (*models.RunUsageSnapshot, error)
- func (s *Store) GetThread(ctx context.Context, threadID string) (*models.Thread, error)
- func (s *Store) GetWebhookDeadLetter(ctx context.Context, id string) (*models.WebhookDeadLetter, error)
- func (s *Store) Init(ctx context.Context) error
- func (s *Store) ListActiveRunsCreatedBefore(ctx context.Context, before time.Time, limit int) ([]*models.Run, error)
- func (s *Store) ListAgentVersions(ctx context.Context, agentID string) ([]*models.AgentVersion, error)
- func (s *Store) ListBreakGlassWindows(ctx context.Context) ([]*models.BreakGlassWindow, error)
- func (s *Store) ListCheckpoints(ctx context.Context, threadID string, limit int, before string) ([]*models.ThreadState, error)
- func (s *Store) ListConnectorActionEvents(ctx context.Context, id string, after int64, limit int) ([]*models.ConnectorActionEvent, error)
- func (s *Store) ListCronSchedules(ctx context.Context) ([]*models.CronSchedule, error)
- func (s *Store) ListKillSwitches(ctx context.Context) ([]*models.KillSwitch, error)
- func (s *Store) ListMandatoryHITLRules(ctx context.Context) ([]*models.MandatoryHITLRule, error)
- func (s *Store) ListNamespaces(ctx context.Context, req *models.StoreListNamespacesRequest) ([][]string, error)
- func (s *Store) ListOpaqueCheckpoints(ctx context.Context, threadID string, limit int) ([]models.OpaqueCheckpointMeta, error)
- func (s *Store) ListPendingActionApprovals(ctx context.Context, id string) ([]models.PendingActionApproval, error)
- func (s *Store) ListPolicyGrants(ctx context.Context) ([]*models.PolicyGrant, error)
- func (s *Store) ListRegistryEntryVersions(ctx context.Context, name string) ([]*models.RegistryEntryVersion, error)
- func (s *Store) ListWebhookDeadLetters(ctx context.Context, limit int) ([]*models.WebhookDeadLetter, error)
- func (s *Store) MarkExpiredConnectorActionsUnknown(ctx context.Context, cutoff time.Time, limit int) (int, error)
- func (s *Store) PeekApprovedConnectorAction(ctx context.Context, id string) (*models.PendingAction, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) PrepareConnectorActionDispatch(ctx context.Context, id string, version int64, approval, source string, ...) (*state.ConnectorActionDispatch, error)
- func (s *Store) PruneCheckpoints(ctx context.Context, keepLast int) (int64, error)
- func (s *Store) PruneConnectorActions(ctx context.Context, cutoff time.Time, limit int) (int, error)
- func (s *Store) PruneCronClaims(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *Store) PruneExpiredStoreItems(ctx context.Context) (int64, error)
- func (s *Store) PruneOpaqueCheckpoints(ctx context.Context, keepLast int) (int64, error)
- func (s *Store) PruneRuns(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *Store) PruneTerminalHookClaims(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *Store) PruneWebhookDeadLetters(ctx context.Context, olderThan time.Time) (int64, error)
- func (s *Store) PublishRegistryEntry(ctx context.Context, entry *models.RegistryEntry) error
- func (s *Store) PutBoundOpaqueCheckpoint(ctx context.Context, binding state.RunCheckpointBinding, checkpointID string, ...) (int64, error)
- func (s *Store) PutItem(ctx context.Context, item *models.StoreItem) error
- func (s *Store) PutOpaqueCheckpoint(ctx context.Context, threadID, checkpointID string, data []byte, ...) (int64, error)
- func (s *Store) RecordConnectorActionDecision(ctx context.Context, id string, version int64, ...) (*models.ConnectorAction, error)
- func (s *Store) ReleaseCronClaim(ctx context.Context, scheduleName string, fireTime time.Time) error
- func (s *Store) ReleaseThreadIfNoOtherActive(ctx context.Context, threadID, excludeRunID string, status models.ThreadStatus) (bool, error)
- func (s *Store) ReleaseUsageHold(ctx context.Context, runID string) error
- func (s *Store) ReportRunUsage(ctx context.Context, binding state.RunUsageBinding, ...) (*models.RunUsageSnapshot, bool, error)
- func (s *Store) RetryActionDelivery(ctx context.Context, tenantID, id string) error
- func (s *Store) SaveCachedRunResult(ctx context.Context, result *models.CachedRunResult) error
- func (s *Store) SaveCheckpoint(ctx context.Context, threadID string, ts *models.ThreadState) error
- func (s *Store) SaveWebhookDeadLetter(ctx context.Context, dl *models.WebhookDeadLetter) error
- func (s *Store) SearchActionDeliveries(ctx context.Context, req *state.ActionDeliverySearchRequest) ([]*state.ActionDelivery, error)
- func (s *Store) SearchAgents(ctx context.Context, req *models.AgentSearchRequest) ([]*models.Agent, error)
- func (s *Store) SearchAuditEvents(ctx context.Context, req *models.AuditSearchRequest) ([]*models.AuditEvent, error)
- func (s *Store) SearchBreakGlassWindows(ctx context.Context, req *models.BreakGlassSearchRequest) ([]*models.BreakGlassWindow, error)
- func (s *Store) SearchConnectorActions(ctx context.Context, req *models.ConnectorActionSearchRequest) ([]*models.ConnectorAction, error)
- func (s *Store) SearchItems(ctx context.Context, req *models.StoreSearchRequest) ([]*models.StoreItem, error)
- func (s *Store) SearchKillSwitches(ctx context.Context, req *models.KillSwitchSearchRequest) ([]*models.KillSwitch, error)
- func (s *Store) SearchMandatoryHITLRules(ctx context.Context, req *models.MandatoryHITLSearchRequest) ([]*models.MandatoryHITLRule, error)
- func (s *Store) SearchPendingActions(ctx context.Context, req *models.PendingActionSearchRequest) ([]*models.PendingAction, error)
- func (s *Store) SearchPolicyGrants(ctx context.Context, req *models.PolicyGrantSearchRequest) ([]*models.PolicyGrant, error)
- func (s *Store) SearchRegistryEntries(ctx context.Context, req *models.RegistrySearchRequest) ([]*models.RegistryEntry, error)
- func (s *Store) SearchRuns(ctx context.Context, req *models.RunSearchRequest) ([]*models.Run, error)
- func (s *Store) SearchThreads(ctx context.Context, req *models.ThreadSearchRequest) ([]*models.Thread, error)
- func (s *Store) SearchUsageSummary(ctx context.Context, req *models.UsageSummaryRequest) ([]models.UsageSummaryRow, error)
- func (s *Store) SetPendingActionApproved(ctx context.Context, id, decidedBy string) error
- func (s *Store) SetPendingActionStatus(ctx context.Context, id, fromStatus, toStatus string) error
- func (s *Store) SetThreadStatus(ctx context.Context, threadID string, status models.ThreadStatus) error
- func (s *Store) SumUsage(ctx context.Context, tenantID, agentID string, since, until time.Time) (tokensIn, tokensOut int64, usd float64, err error)
- func (s *Store) SumUsageHolds(ctx context.Context, tenantID, agentID string, since, until time.Time) (usd float64, tokens int64, count int64, err error)
- func (*Store) SupportsWorkloadIdentity() bool
- func (s *Store) TruncateAll(ctx context.Context) error
- func (s *Store) TryClaimCronFire(ctx context.Context, scheduleName string, fireTime time.Time) (bool, error)
- func (s *Store) TryClaimTerminalHook(ctx context.Context, runID string) (bool, error)
- func (s *Store) TryClaimThread(ctx context.Context, threadID string) (bool, error)
- func (s *Store) TryMarkRunTimeout(ctx context.Context, runID string, errMsg string) (bool, error)
- func (s *Store) UpdateRunStatus(ctx context.Context, runID string, status models.RunStatus, output []byte, ...) error
- func (s *Store) UpdateThread(ctx context.Context, threadID string, patch *models.ThreadPatch) (*models.Thread, error)
- func (s *Store) UpsertAgent(ctx context.Context, agent *models.Agent) error
- func (s *Store) UpsertAgentSchema(ctx context.Context, schema *models.AgentSchema) error
- func (s *Store) UpsertCronSchedule(ctx context.Context, sched *models.CronSchedule) error
- func (s *Store) UpsertFinOpsOverlay(ctx context.Context, o *models.FinOpsOverlay) error
- func (s *Store) UpsertKillSwitch(ctx context.Context, k *models.KillSwitch) error
- func (s *Store) UpsertMandatoryHITLRule(ctx context.Context, r *models.MandatoryHITLRule) error
- func (s *Store) UpsertPolicyGrant(ctx context.Context, g *models.PolicyGrant) error
- func (s *Store) UpsertUsageHold(ctx context.Context, h *models.UsageHold) error
- func (s *Store) WriteAuditEvent(ctx context.Context, ev *models.AuditEvent) error
- func (s *Store) WriteUsageEvent(ctx context.Context, ev *models.UsageEvent) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Store)
Option configures optional Postgres store behavior.
func WithRLS ¶
WithRLS enables opt-in Postgres row-level security: FORCE RLS policies on tenant-scoped tables plus per-acquire app.tenant_id / app.is_system GUCs derived from context. Off by default — application WHERE clauses remain the primary isolation mechanism. Turning the flag off and restarting clears Runkite's policies (see disableRLS) so FORCE does not stick.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements state.Store with a PostgreSQL database.
func (*Store) AckActionDelivery ¶ added in v0.7.0
func (*Store) BeginRunAttempt ¶
func (*Store) ClaimActionDeliveries ¶ added in v0.7.0
func (*Store) CompleteRun ¶
func (s *Store) CompleteRun(ctx context.Context, c *state.RunCompletion) (state.CompletionResult, error)
func (*Store) ConsumeApprovedAction ¶
func (s *Store) ConsumeApprovedAction(ctx context.Context, tenantID, agentID, runID string, generation int64, connector, tool, argsDigest, targetRevision, policyRevision, toolRevision string) (string, error)
ConsumeApprovedAction atomically marks an approved action consumed for the matching run/generation/connector/tool and argument digest. Unbound legacy approvals cannot authorize a newly interpreted operation.
func (*Store) CountActiveRuns ¶
func (*Store) CountRunsByStatus ¶
func (*Store) CountRunsCreatedSince ¶
func (*Store) CountRunsSince ¶
func (s *Store) CountRunsSince(ctx context.Context, tenantID, agentID string, since time.Time) (int64, error)
CountRunsSince counts runs created at/after since for tenant (optional agent).
func (*Store) CountThreadsByStatus ¶
func (*Store) CreateBreakGlassWindow ¶
func (*Store) CreateCachedRun ¶
func (*Store) CreateConnectorAction ¶ added in v0.7.0
func (s *Store) CreateConnectorAction(ctx context.Context, a *models.ConnectorAction, mutation string) (*models.ConnectorAction, error)
func (*Store) CreatePendingAction ¶
CreatePendingAction inserts or reuses a scoped open approval. The canonical action ID is written back to a.ID. A nullable unique key arbitrates concurrent creates; legacy rows are reused without changing their stored history.
func (*Store) CreateRunAdmitted ¶
func (s *Store) CreateRunAdmitted(ctx context.Context, run *models.Run, caps *state.RunAdmissionCaps) error
CreateRunAdmitted locks admission scopes, COUNTs, then INSERTs in one transaction so concurrent creates serialize per tenant/agent.
func (*Store) CreateThread ¶
func (*Store) CredentialLeaseStorage ¶ added in v0.7.0
func (s *Store) CredentialLeaseStorage() (credentials.Store, error)
func (*Store) DeleteBoundOpaqueCheckpoint ¶
func (*Store) DeleteBreakGlassWindow ¶
func (*Store) DeleteCronSchedule ¶
func (*Store) DeleteFinOpsOverlay ¶
DeleteFinOpsOverlay removes the singleton overlay (file baseline only).
func (*Store) DeleteItem ¶
func (*Store) DeleteKillSwitch ¶
func (*Store) DeleteMandatoryHITLRule ¶
DeleteMandatoryHITLRule removes a rule by id. Missing id is not an error.
func (*Store) DeleteOpaqueCheckpoint ¶
func (*Store) DeletePolicyGrant ¶
DeletePolicyGrant removes a grant by id. Missing id is not an error.
func (*Store) DeleteRegistryEntry ¶
DeleteRegistryEntry also removes the entry's own version history, not just its current row -- real bug found via live testing: without this, a delete-then-republish of the same name hits the version snapshot table's "ON CONFLICT (tenant_id, name, version) DO NOTHING" against ORPHANED rows left over from before the delete, so the new publish's own v1 snapshot is silently discarded and ListRegistryEntryVersions keeps showing pre-delete content. Deleting history alongside the entry means a republish always starts from a genuinely clean version 1, matching what "deleted" should mean for a scoped-to-tenant, no-op cascading resource with no other backend to preserve the audit trail for once its own parent row is gone (unlike agent versioning, which never deletes an agent at all today).
func (*Store) DeleteThread ¶
func (*Store) Downgrade ¶
Downgrade rolls back the most recently applied migration under the same advisory lock Init uses.
func (*Store) ExpireGovernancePending ¶
ExpireGovernancePending denies embedded rows past expires_at. ponytail: no index on expires_at. Upgrade path is an index on (status, expires_at) if this sweep shows up in traces.
func (*Store) ExpireUsageHolds ¶
ExpireUsageHolds deletes open holds with created_at strictly before olderThan.
func (*Store) FailActionDelivery ¶ added in v0.7.0
func (*Store) FindActiveBreakGlass ¶
func (s *Store) FindActiveBreakGlass(ctx context.Context, tenantID, agentID string) (*models.BreakGlassWindow, error)
FindActiveBreakGlass returns the most specific active window: agent-scoped wins over tenant-wide (agent_id empty), then earliest expiry.
func (*Store) FindActiveKill ¶
func (*Store) FindOpenPendingAction ¶
func (s *Store) FindOpenPendingAction(ctx context.Context, tenantID, agentID, runID string, generation int64, connector, tool, argsDigest, targetRevision, policyRevision, toolRevision string, embedded bool) (*models.PendingAction, error)
FindOpenPendingAction returns the oldest still-pending row for this call tuple and argument digest. Different amounts do not share a row.
func (*Store) FinishConnectorAction ¶ added in v0.7.0
func (*Store) GetAgentSchema ¶
func (*Store) GetAgentVersion ¶
func (*Store) GetBreakGlassWindow ¶
func (*Store) GetCachedRunResult ¶
func (*Store) GetConnectorAction ¶ added in v0.7.0
func (*Store) GetFinOpsOverlay ¶
GetFinOpsOverlay returns the singleton overlay row, or (nil, nil) when absent.
func (*Store) GetKillSwitch ¶
func (*Store) GetLastCronFireTime ¶
func (*Store) GetLatestCheckpoint ¶
func (*Store) GetLatestOpaqueCheckpoint ¶
func (s *Store) GetLatestOpaqueCheckpoint(ctx context.Context, threadID, namespace string) (*models.OpaqueCheckpoint, error)
GetLatestOpaqueCheckpoint returns the newest opaque blob for threadID. namespace "" = root graph keys (checkpoint_id with no "\x1f"); otherwise keys prefixed with namespace+"\x1f" (LangGraph folds checkpoint_ns into the opaque path key this way).
func (*Store) GetMandatoryHITLRule ¶
func (s *Store) GetMandatoryHITLRule(ctx context.Context, id string) (*models.MandatoryHITLRule, error)
GetMandatoryHITLRule returns one rule by id, or state.ErrNotFound.
func (*Store) GetOpaqueCheckpoint ¶
func (*Store) GetPendingAction ¶
GetPendingAction returns one row by id.
func (*Store) GetPolicyGrant ¶
GetPolicyGrant returns one grant by id, or state.ErrNotFound.
func (*Store) GetRegistryEntry ¶
func (*Store) GetRegistryEntryVersion ¶
func (*Store) GetRunUsage ¶ added in v0.8.0
func (s *Store) GetRunUsage(ctx context.Context, binding state.RunUsageBinding) (*models.RunUsageSnapshot, error)
func (*Store) GetWebhookDeadLetter ¶
func (*Store) Init ¶
Init applies pending numbered schema migrations. Safe to call concurrently from multiple processes against the same database (e.g. several `runkite serve` replicas starting up at once) -- wrapped in a session-level advisory lock so only one process runs DDL while the others wait. Without this, concurrent CREATE TABLE IF NOT EXISTS calls against a table that doesn't exist yet can race on Postgres's own catalog (confirmed live: "duplicate key value violates unique constraint \"pg_type_typname_nsp_index\"" when 3 replicas started together against a fresh database).
func (*Store) ListActiveRunsCreatedBefore ¶
func (*Store) ListAgentVersions ¶
func (*Store) ListBreakGlassWindows ¶
func (*Store) ListCheckpoints ¶
func (*Store) ListConnectorActionEvents ¶ added in v0.7.0
func (*Store) ListCronSchedules ¶
ListCronSchedules -- see the SQLite equivalent's doc comment: always called from a system context in practice (the scheduler loop must see every tenant's schedules), TenantID is always populated on the returned rows so the caller can dispatch each fire under its own tenant.
func (*Store) ListKillSwitches ¶
func (*Store) ListMandatoryHITLRules ¶
ListMandatoryHITLRules returns every durable mandatory-HITL rule.
func (*Store) ListNamespaces ¶
func (*Store) ListOpaqueCheckpoints ¶
func (*Store) ListPendingActionApprovals ¶ added in v0.7.0
func (*Store) ListPolicyGrants ¶
ListPolicyGrants returns every durable grant (Admin reload / startup).
func (*Store) ListRegistryEntryVersions ¶
func (*Store) ListWebhookDeadLetters ¶
func (*Store) MarkExpiredConnectorActionsUnknown ¶ added in v0.7.0
func (*Store) PeekApprovedConnectorAction ¶ added in v0.7.0
func (*Store) PrepareConnectorActionDispatch ¶ added in v0.7.0
func (*Store) PruneCheckpoints ¶
func (*Store) PruneConnectorActions ¶ added in v0.7.0
func (*Store) PruneCronClaims ¶
func (*Store) PruneExpiredStoreItems ¶
func (*Store) PruneOpaqueCheckpoints ¶
func (*Store) PruneTerminalHookClaims ¶
func (*Store) PruneWebhookDeadLetters ¶
func (*Store) PublishRegistryEntry ¶
PublishRegistryEntry follows the exact same transaction + RETURNING + conditional-version-snapshot pattern as UpsertAgent above -- see its comment for the full rationale (a single UPSERT's CASE expression can't also conditionally write a second table's row).
func (*Store) PutBoundOpaqueCheckpoint ¶
func (*Store) PutOpaqueCheckpoint ¶
func (*Store) RecordConnectorActionDecision ¶ added in v0.7.0
func (*Store) ReleaseCronClaim ¶
func (*Store) ReleaseThreadIfNoOtherActive ¶
func (s *Store) ReleaseThreadIfNoOtherActive(ctx context.Context, threadID, excludeRunID string, status models.ThreadStatus) (bool, error)
ReleaseThreadIfNoOtherActive is a single conditional UPDATE -- the inverse of TryClaimThread -- so a late StatusCallback cannot idle a thread that a newer run already claimed.
func (*Store) ReleaseUsageHold ¶
func (*Store) ReportRunUsage ¶ added in v0.8.0
func (s *Store) ReportRunUsage(ctx context.Context, binding state.RunUsageBinding, report models.RunUsageReport) (*models.RunUsageSnapshot, bool, error)
func (*Store) RetryActionDelivery ¶ added in v0.7.0
func (*Store) SaveCachedRunResult ¶
func (*Store) SaveCheckpoint ¶
func (*Store) SaveWebhookDeadLetter ¶
func (*Store) SearchActionDeliveries ¶ added in v0.7.0
func (s *Store) SearchActionDeliveries(ctx context.Context, req *state.ActionDeliverySearchRequest) ([]*state.ActionDelivery, error)
func (*Store) SearchAgents ¶
func (*Store) SearchAuditEvents ¶
func (s *Store) SearchAuditEvents(ctx context.Context, req *models.AuditSearchRequest) ([]*models.AuditEvent, error)
SearchAuditEvents lists policy decisions newest-first. Keyset cursor is (ts, id). System context sees every tenant unless TenantID is set; a normal tenant context is always scoped to that tenant.
func (*Store) SearchBreakGlassWindows ¶
func (s *Store) SearchBreakGlassWindows(ctx context.Context, req *models.BreakGlassSearchRequest) ([]*models.BreakGlassWindow, error)
func (*Store) SearchConnectorActions ¶ added in v0.7.0
func (s *Store) SearchConnectorActions(ctx context.Context, req *models.ConnectorActionSearchRequest) ([]*models.ConnectorAction, error)
func (*Store) SearchItems ¶
func (*Store) SearchKillSwitches ¶
func (s *Store) SearchKillSwitches(ctx context.Context, req *models.KillSwitchSearchRequest) ([]*models.KillSwitch, error)
func (*Store) SearchMandatoryHITLRules ¶
func (s *Store) SearchMandatoryHITLRules(ctx context.Context, req *models.MandatoryHITLSearchRequest) ([]*models.MandatoryHITLRule, error)
SearchMandatoryHITLRules lists rules with optional filters and keyset paging.
func (*Store) SearchPendingActions ¶
func (s *Store) SearchPendingActions(ctx context.Context, req *models.PendingActionSearchRequest) ([]*models.PendingAction, error)
SearchPendingActions lists pending actions with optional filters.
func (*Store) SearchPolicyGrants ¶
func (s *Store) SearchPolicyGrants(ctx context.Context, req *models.PolicyGrantSearchRequest) ([]*models.PolicyGrant, error)
SearchPolicyGrants lists grants with optional filters and keyset paging.
func (*Store) SearchRegistryEntries ¶
func (s *Store) SearchRegistryEntries(ctx context.Context, req *models.RegistrySearchRequest) ([]*models.RegistryEntry, error)
func (*Store) SearchRuns ¶
func (*Store) SearchThreads ¶
func (*Store) SearchUsageSummary ¶
func (s *Store) SearchUsageSummary(ctx context.Context, req *models.UsageSummaryRequest) ([]models.UsageSummaryRow, error)
SearchUsageSummary groups usage_events by tenant/agent/UTC day.
func (*Store) SetPendingActionApproved ¶
SetPendingActionApproved moves pending → approved and records who decided.
func (*Store) SetPendingActionStatus ¶
SetPendingActionStatus updates status if the row is still in fromStatus (optimistic). Returns ErrConflict if the row moved on.
func (*Store) SetThreadStatus ¶
func (*Store) SumUsage ¶
func (s *Store) SumUsage(ctx context.Context, tenantID, agentID string, since, until time.Time) (tokensIn, tokensOut int64, usd float64, err error)
SumUsage aggregates tokens and USD for a tenant (and optional agent) in [since, until).
func (*Store) SumUsageHolds ¶
func (*Store) SupportsWorkloadIdentity ¶ added in v0.8.0
func (*Store) TruncateAll ¶
TruncateAll removes all rows from all tables. For testing only.
func (*Store) TryClaimCronFire ¶
func (*Store) TryClaimTerminalHook ¶
func (*Store) TryClaimThread ¶
func (*Store) TryMarkRunTimeout ¶
func (*Store) UpdateRunStatus ¶
func (*Store) UpdateThread ¶
func (*Store) UpsertAgent ¶
func (*Store) UpsertAgentSchema ¶
func (*Store) UpsertCronSchedule ¶
func (*Store) UpsertFinOpsOverlay ¶
UpsertFinOpsOverlay replaces the singleton overlay document.
func (*Store) UpsertKillSwitch ¶
func (*Store) UpsertMandatoryHITLRule ¶
UpsertMandatoryHITLRule inserts or replaces a rule by id; enforces unique (tenant_id, agent_id, connector).
func (*Store) UpsertPolicyGrant ¶
UpsertPolicyGrant inserts or replaces a grant by id; enforces unique (tenant_id, agent_id, connector).
func (*Store) UpsertUsageHold ¶
func (*Store) WriteAuditEvent ¶
WriteAuditEvent persists one policy/security decision. SQL backends (Postgres/MySQL/SQLite) implement this; Mongo callers type-assert and skip durable audit.
func (*Store) WriteUsageEvent ¶
WriteUsageEvent upserts one usage row keyed by (run_id, source).