Documentation
¶
Overview ¶
Package store is the platform's durable operational store on PostgreSQL (design §13.1). Every query is scoped by organisation, and by memory store where records are involved. Uniqueness, deduplication and optimistic concurrency are enforced by database constraints; fenced writes check the caller's lease generation inside the same transaction (ADR-0005).
Index ¶
- Constants
- Variables
- func ExternalRef(channel, thread string) string
- func SplitExternalRef(ref string) (channel, thread string)
- type ConsoleOperationFilter
- type ConversationSummary
- type Fence
- type Gauges
- type HumanMessage
- type HumanReply
- type Ingested
- type Message
- type NewOperation
- type NewRecord
- type NextFunc
- type Organization
- type OutboxItem
- type Record
- type RecordChange
- type RevisionConflict
- type RevisionInfo
- type Schedule
- type SearchHit
- type Seat
- type SeatMessage
- type Sent
- type Store
- func (s *Store) Ack(ctx context.Context, f Fence, deliveryID int64, req runtimeapi.InboxAckRequest) error
- func (s *Store) AcquireLease(ctx context.Context, seatID, podUID string) (*runtimeapi.LeaseResponse, error)
- func (s *Store) ActiveOrganizations(ctx context.Context) ([]string, error)
- func (s *Store) ActiveStoreIDs(ctx context.Context, orgID string, keys []string) (map[string]string, error)
- func (s *Store) AppendEvents(ctx context.Context, f Fence, executionID string, ...) error
- func (s *Store) BeginOperation(ctx context.Context, f Fence, in NewOperation) (op *runtimeapi.Operation, created bool, err error)
- func (s *Store) CancelSchedule(ctx context.Context, f Fence, id string) error
- func (s *Store) Checkpoints(ctx context.Context, seatID string) ([]runtimeapi.Checkpoint, error)
- func (s *Store) ClaimOutbox(ctx context.Context, limit int) ([]OutboxItem, error)
- func (s *Store) Close()
- func (s *Store) ConsoleActivity(ctx context.Context, orgID string, after time.Time, limit int) ([]runtimeapi.ConsoleActivityItem, error)
- func (s *Store) ConsoleArtifacts(ctx context.Context, orgID string, limit int) ([]runtimeapi.ConsoleArtifact, error)
- func (s *Store) ConsoleConversation(ctx context.Context, id string) (*runtimeapi.ConsoleConversationDetail, error)
- func (s *Store) ConsoleConversations(ctx context.Context, orgID string, includeSystem bool, limit int) ([]runtimeapi.ConsoleConversation, error)
- func (s *Store) ConsoleExecution(ctx context.Context, id string) (*runtimeapi.ConsoleExecutionDetail, error)
- func (s *Store) ConsoleExecutions(ctx context.Context, seatID string, before time.Time, limit int) ([]runtimeapi.ConsoleExecution, error)
- func (s *Store) ConsoleOperations(ctx context.Context, orgID string, f ConsoleOperationFilter) ([]runtimeapi.ConsoleOperation, error)
- func (s *Store) ConsoleOrganization(ctx context.Context, orgID string) (*runtimeapi.ConsoleOrganization, error)
- func (s *Store) ConsoleOrganizationExecutions(ctx context.Context, orgID, state string, limit int) ([]runtimeapi.ConsoleExecution, error)
- func (s *Store) ConsoleOrganizations(ctx context.Context) ([]runtimeapi.ConsoleOrganization, error)
- func (s *Store) ConsoleSeat(ctx context.Context, seatID string, runs int) (*runtimeapi.ConsoleSeatDetail, error)
- func (s *Store) ConsoleSeatStatuses(ctx context.Context, orgID string, keys []string) ([]runtimeapi.ConsoleSeatStatus, error)
- func (s *Store) Conversation(ctx context.Context, orgID, id string) (kind, binding string, participants []string, err error)
- func (s *Store) ConversationMessages(ctx context.Context, orgID, convID string, offset, limit int) ([]Message, error)
- func (s *Store) Conversations(ctx context.Context, orgID, seatID string, offset, limit int) ([]ConversationSummary, error)
- func (s *Store) CreateProbe(ctx context.Context, orgID, seatID string) (string, error)
- func (s *Store) CreateSchedule(ctx context.Context, f Fence, orgID, schedule string, next time.Time, ...) (*Schedule, error)
- func (s *Store) DeleteOrganization(ctx context.Context, orgID string, purge bool) error
- func (s *Store) ExpireSending(ctx context.Context) (int, error)
- func (s *Store) ExpireStaleOperations(ctx context.Context, olderThan time.Duration) (int64, error)
- func (s *Store) FenceSeat(ctx context.Context, orgID, seatID string, expected int64) (*runtimeapi.LeaseResponse, error)
- func (s *Store) FinishOperation(ctx context.Context, id, status, receipt string, result json.RawMessage, ...) error
- func (s *Store) FireDue(ctx context.Context, now time.Time, limit int, next NextFunc) (int, error)
- func (s *Store) Gauges(ctx context.Context) (*Gauges, error)
- func (s *Store) Handoff(ctx context.Context, seatID string) (*runtimeapi.Handoff, error)
- func (s *Store) History(ctx context.Context, orgID, recordID string, storeIDs []string, ...) ([]RevisionInfo, error)
- func (s *Store) IngestHuman(ctx context.Context, in HumanMessage) (*Ingested, error)
- func (s *Store) LeaseNext(ctx context.Context, f Fence) (*runtimeapi.InboxDelivery, error)
- func (s *Store) Message(ctx context.Context, orgID, id string) (*Message, error)
- func (s *Store) Migrate(ctx context.Context) error
- func (s *Store) Operation(ctx context.Context, orgID, seatID, id string) (*runtimeapi.Operation, error)
- func (s *Store) Organization(ctx context.Context, orgID string) (*Organization, error)
- func (s *Store) PendingDeliveries(ctx context.Context, seatID string) (int, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) ProbeStatus(ctx context.Context, orgID, seatID, probeID string) (*runtimeapi.ProbeResponse, error)
- func (s *Store) Record(ctx context.Context, orgID, recordID string, storeIDs []string) (*Record, error)
- func (s *Store) RecordConnectionCheck(ctx context.Context, orgID, connection string, res runtimeapi.CheckResult) error
- func (s *Store) RecordRevision(ctx context.Context, orgID, recordID string, revision int, storeIDs []string) (*Record, error)
- func (s *Store) ReleaseLease(ctx context.Context, seatID string, gen int64) error
- func (s *Store) RenewLease(ctx context.Context, seatID, podUID string, gen int64) (*runtimeapi.LeaseResponse, error)
- func (s *Store) ReplyToHuman(ctx context.Context, f Fence, in HumanReply) (*Sent, error)
- func (s *Store) ReportState(ctx context.Context, f Fence, req runtimeapi.StateRequest) error
- func (s *Store) RequeueExpired(ctx context.Context) (int, error)
- func (s *Store) ResolveOutbox(ctx context.Context, it OutboxItem, state, receipt, errText string, ...) error
- func (s *Store) ReviseRecord(ctx context.Context, f Fence, in RecordChange, storeIDs []string) (*Record, error)
- func (s *Store) SaveCheckpoint(ctx context.Context, f Fence, cp runtimeapi.Checkpoint) error
- func (s *Store) SaveHandoff(ctx context.Context, f Fence, h runtimeapi.Handoff) error
- func (s *Store) Schedules(ctx context.Context, seatID string) ([]Schedule, error)
- func (s *Store) Search(ctx context.Context, orgID string, storeIDs []string, query string, ...) ([]SearchHit, error)
- func (s *Store) Seat(ctx context.Context, seatID string) (*Seat, error)
- func (s *Store) SeatByKey(ctx context.Context, orgID, key string) (*Seat, error)
- func (s *Store) SeatByServiceAccount(ctx context.Context, namespace, serviceAccount string) (string, error)
- func (s *Store) SeatOrganization(ctx context.Context, seatID string) (string, error)
- func (s *Store) SeatRuntimes(ctx context.Context, orgID string, keys []string) (map[string]runtimeapi.SeatRuntime, error)
- func (s *Store) SendSeatMessage(ctx context.Context, f Fence, in SeatMessage) (*Sent, error)
- func (s *Store) SyncOrganization(ctx context.Context, in SyncInput) (*runtimeapi.SyncResponse, error)
- func (s *Store) UnknownOperations(ctx context.Context, seatID string, limit int) ([]runtimeapi.Operation, error)
- func (s *Store) WriteRecord(ctx context.Context, f Fence, in NewRecord) (*Record, error)
- type SyncInput
Constants ¶
const ( DeliveryLease = 15 * time.Minute MaxAttempts = 5 MaxPendingDeliveries = 1000 MaxEventBytes = 8 << 10 )
Inbox limits (contracts.md, ADR-0006).
const ( OriginHuman = "human" OriginSeat = "seat" OriginSystem = "system" OriginSchedule = "schedule" OriginProbe = "probe" )
Message origins. They are assigned by trusted code only (§9.2).
const ( ConvHuman = "human" ConvInternal = "internal" ConvSystem = "system" )
Conversation kinds.
const ( OpPending = "pending" OpSucceeded = "succeeded" OpFailed = "failed" OpUnknown = "unknown" )
Operation statuses (§10.3).
const ( OutboxPending = "pending" OutboxSending = "sending" OutboxSent = "sent" OutboxUnknown = "unknown" OutboxDead = "dead" )
Outbox states. A claimed row is "sending" until resolved; a claim that is never resolved (crash mid-send) becomes unknown, never a blind resend.
const LeaseTTL = 30 * time.Second
LeaseTTL is the execution lease lifetime without renewal (contracts.md).
const MaxConsoleEvents = 2000
MaxConsoleEvents bounds the events returned for one run.
const MaxSchedulesPerSeat = 50
MaxSchedulesPerSeat bounds a seat's active wake schedules.
Variables ¶
var ( ErrNotFound = errors.New("not found") // ErrFenced means the caller's lease generation is not the current one. ErrFenced = errors.New("fenced") ErrConflict = errors.New("conflict") ErrInvalid = errors.New("invalid") // ErrInboxFull means the recipient already has MaxPendingDeliveries (ADR-0006). ErrInboxFull = errors.New("recipient inbox full") )
Functions ¶
func ExternalRef ¶
ExternalRef encodes an external channel and thread as a conversation ref.
func SplitExternalRef ¶
SplitExternalRef reverses ExternalRef.
Types ¶
type ConsoleOperationFilter ¶
ConsoleOperationFilter narrows ConsoleOperations.
type ConversationSummary ¶
type ConversationSummary struct {
ID string `json:"conversation_id"`
Kind string `json:"kind"`
Binding string `json:"binding,omitempty"`
CreatedAt time.Time `json:"created_at"`
LastAt time.Time `json:"last_message_at"`
}
ConversationSummary describes a conversation the seat takes part in.
type Gauges ¶
type Gauges struct {
// SeatsByState counts active seats per organisation key and state.
SeatsByState map[[2]string]int
// OldestPending is the oldest undelivered message age per organisation key.
OldestPending map[string]float64
}
Gauges is a snapshot for the §14 operational gauges.
type HumanMessage ¶
type HumanMessage struct {
OrganizationID string
Connection string
Binding string
ExternalUserID string
// ExternalRef identifies the external conversation (channel and thread).
ExternalRef string
EventID string
RepresentativeID string
Body string
}
HumanMessage is a verified inbound event for a representative.
type HumanReply ¶
type HumanReply struct {
OrganizationID string
SeatID string
Binding string
Connection string
// ConversationID is the human conversation replied to; when empty the
// representative's latest conversation for the binding is used.
ConversationID string
ParentID string
Body string
}
HumanReply is an outbound message from a representative to its bound human.
type Ingested ¶
type Ingested struct {
MessageID string
Duplicate bool
// OverCap reports that the representative's inbox exceeded its cap. The
// message is still accepted: accepted human messages are never dropped.
OverCap bool
}
Ingested is the outcome of IngestHuman.
type Message ¶
type Message struct {
ID string `json:"message_id"`
ConversationID string `json:"conversation_id"`
ConversationKind string `json:"-"`
Binding string `json:"binding,omitempty"`
Participants []string `json:"-"`
Origin string `json:"origin"`
SenderSeatID string `json:"-"`
SenderSeat string `json:"sender_seat,omitempty"`
RecipientSeatID string `json:"-"`
RecipientSeat string `json:"recipient_seat,omitempty"`
RecipientBinding string `json:"recipient_binding,omitempty"`
ParentID string `json:"parent_id,omitempty"`
CorrelationID string `json:"correlation_id,omitempty"`
Body string `json:"body"`
CreatedAt time.Time `json:"created_at"`
}
Message is a stored message with its conversation context.
type NewOperation ¶
type NewOperation struct {
OrganizationID string
SeatID string
ExecutionID string
Connection string
Operation string
Target string
RequestHash string
IdempotencyKey string
}
NewOperation is a connector side effect about to be attempted.
type NewRecord ¶
type NewRecord struct {
OrganizationID string
StoreID string
AuthorID string
Title string
Body string
Tags []string
SourceRefs []string
}
NewRecord is the content of a new memory record.
type NextFunc ¶
NextFunc computes a schedule's next trigger after firing at fired; ok=false means the schedule is finished.
type Organization ¶
Organization is an active organisation and its effective manifest.
type OutboxItem ¶
type OutboxItem struct {
ID int64
OrganizationID string
MessageID string
OperationID string
Connection string
Binding string
ExternalRef string
Body string
Attempts int
}
OutboxItem is a claimed outbound message.
type Record ¶
type Record struct {
ID string `json:"record_id"`
Store string `json:"store"`
StoreID string `json:"-"`
Revision int `json:"revision"`
Title string `json:"title"`
Body string `json:"body"`
Tags []string `json:"tags,omitempty"`
SourceRefs []string `json:"source_refs,omitempty"`
Author string `json:"author_seat"`
Archived bool `json:"archived,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Record is the current revision of a memory record.
type RecordChange ¶
type RecordChange struct {
OrganizationID string
RecordID string
AuthorID string
ExpectedRevision int
Title *string
Body *string
Tags []string
SourceRefs []string
Archive bool
}
RecordChange is a compare-and-swap update of a record. Nil fields keep their current value.
type RevisionConflict ¶
RevisionConflict reports a stale expected revision (A11).
func IsConflict ¶
func IsConflict(err error) (*RevisionConflict, bool)
IsConflict extracts a revision conflict.
func (*RevisionConflict) Error ¶
func (e *RevisionConflict) Error() string
func (*RevisionConflict) Is ¶
func (e *RevisionConflict) Is(target error) bool
type RevisionInfo ¶
type RevisionInfo struct {
Revision int `json:"revision"`
Title string `json:"title"`
Author string `json:"author_seat"`
Generation *int64 `json:"author_generation,omitempty"`
SourceRefs []string `json:"source_refs,omitempty"`
Archived bool `json:"archived,omitempty"`
BodyBytes int `json:"body_bytes"`
CreatedAt time.Time `json:"created_at"`
}
RevisionInfo is one entry of a record's history (body omitted).
type Schedule ¶
type Schedule struct {
ID string `json:"id"`
Schedule string `json:"schedule"`
Note string `json:"note,omitempty"`
NextTriggerAt time.Time `json:"next_trigger_at"`
LastFiredAt *time.Time `json:"last_fired_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
Schedule is a durable wake trigger (§9.3).
type SearchHit ¶
type SearchHit struct {
RecordID string `json:"record_id"`
Store string `json:"store"`
Title string `json:"title"`
Snippet string `json:"snippet"`
Tags []string `json:"tags,omitempty"`
Revision int `json:"revision"`
Author string `json:"author_seat"`
UpdatedAt time.Time `json:"updated_at"`
}
SearchHit is a bounded, attributed search result.
type Seat ¶
type Seat struct {
ID string
OrganizationID string
Key string
ConfigRevision string
PolicyRevision int64
Manifest compile.SeatManifest
}
Seat is an active seat with its current policy revision.
type SeatMessage ¶
type SeatMessage struct {
OrganizationID string
SenderID string
RecipientID string
// ConversationID continues an internal conversation the sender takes part in.
ConversationID string
ParentID string
CorrelationID string
Route string
Body string
}
SeatMessage is an internal message between seats. Route authorisation is the caller's responsibility; the store enforces conversation membership.
type Sent ¶
type Sent struct {
MessageID string `json:"message_id"`
ConversationID string `json:"conversation_id"`
CorrelationID string `json:"correlation_id"`
}
Sent identifies an accepted message.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps a pgx connection pool.
func (*Store) Ack ¶
func (s *Store) Ack(ctx context.Context, f Fence, deliveryID int64, req runtimeapi.InboxAckRequest) error
Ack completes a leased delivery and its execution. A failed outcome counts as an attempt and is retried with backoff until dead-lettered.
func (*Store) AcquireLease ¶
func (s *Store) AcquireLease(ctx context.Context, seatID, podUID string) (*runtimeapi.LeaseResponse, error)
AcquireLease grants the seat's execution lease to podUID when it is expired, unheld or already held by podUID, incrementing the generation. Deliveries leased by an older generation go back to the queue as a failed attempt.
func (*Store) ActiveOrganizations ¶
ActiveOrganizations lists the ids of all non-deleted organisations.
func (*Store) ActiveStoreIDs ¶
func (s *Store) ActiveStoreIDs(ctx context.Context, orgID string, keys []string) (map[string]string, error)
ActiveStoreIDs maps the given store keys to the ids of their active stores. Unknown or retired keys are omitted.
func (*Store) AppendEvents ¶
func (s *Store) AppendEvents(ctx context.Context, f Fence, executionID string, events []runtimeapi.ExecutionEvent) error
AppendEvents records execution events for one of the seat's executions. Oversized payloads are replaced by a marker (ADR-0006).
func (*Store) BeginOperation ¶
func (s *Store) BeginOperation(ctx context.Context, f Fence, in NewOperation) (op *runtimeapi.Operation, created bool, err error)
BeginOperation records a pending operation before its side effect, in a fenced transaction. If the idempotency key was already used, the existing operation is returned with created=false and must not be re-executed.
func (*Store) CancelSchedule ¶
CancelSchedule deactivates one of the seat's schedules.
func (*Store) Checkpoints ¶
func (s *Store) Checkpoints(ctx context.Context, seatID string) ([]runtimeapi.Checkpoint, error)
Checkpoints returns the seat's checkpoints, most recent first.
func (*Store) ClaimOutbox ¶
ClaimOutbox claims up to limit due outbound messages and records a pending connector operation for each before anything is sent.
func (*Store) ConsoleActivity ¶
func (s *Store) ConsoleActivity(ctx context.Context, orgID string, after time.Time, limit int) ([]runtimeapi.ConsoleActivityItem, error)
ConsoleActivity returns the organisation's activity after the given time, oldest first: messages, runs starting and finishing, tool calls, harness errors and connector operation status changes. With a zero after it returns the most recent items instead.
func (*Store) ConsoleArtifacts ¶
func (s *Store) ConsoleArtifacts(ctx context.Context, orgID string, limit int) ([]runtimeapi.ConsoleArtifact, error)
ConsoleArtifacts lists the organisation's artifacts, newest first.
func (*Store) ConsoleConversation ¶
func (s *Store) ConsoleConversation(ctx context.Context, id string) (*runtimeapi.ConsoleConversationDetail, error)
ConsoleConversation returns a conversation with its messages and their deliveries.
func (*Store) ConsoleConversations ¶
func (s *Store) ConsoleConversations(ctx context.Context, orgID string, includeSystem bool, limit int) ([]runtimeapi.ConsoleConversation, error)
ConsoleConversations lists the organisation's conversations, most recently active first. System conversations (probes, schedules) are included only when asked for.
func (*Store) ConsoleExecution ¶
func (s *Store) ConsoleExecution(ctx context.Context, id string) (*runtimeapi.ConsoleExecutionDetail, error)
ConsoleExecution returns a run with its trigger message, events, connector operations and the messages its seat sent under that run's lease.
func (*Store) ConsoleExecutions ¶
func (s *Store) ConsoleExecutions(ctx context.Context, seatID string, before time.Time, limit int) ([]runtimeapi.ConsoleExecution, error)
ConsoleExecutions pages a seat's runs, newest first, started before before (zero for the latest). Runs from every lease generation are included, so the history outlives any one Pod.
func (*Store) ConsoleOperations ¶
func (s *Store) ConsoleOperations(ctx context.Context, orgID string, f ConsoleOperationFilter) ([]runtimeapi.ConsoleOperation, error)
ConsoleOperations lists the organisation's connector operations, newest first.
func (*Store) ConsoleOrganization ¶
func (s *Store) ConsoleOrganization(ctx context.Context, orgID string) (*runtimeapi.ConsoleOrganization, error)
ConsoleOrganization returns an organisation's committed configuration with its connections' last verification results.
func (*Store) ConsoleOrganizationExecutions ¶
func (s *Store) ConsoleOrganizationExecutions(ctx context.Context, orgID, state string, limit int) ([]runtimeapi.ConsoleExecution, error)
ConsoleOrganizationExecutions pages the organisation's runs, newest first, optionally only those in the given state (running, completed, failed, interrupted).
func (*Store) ConsoleOrganizations ¶
func (s *Store) ConsoleOrganizations(ctx context.Context) ([]runtimeapi.ConsoleOrganization, error)
ConsoleOrganizations lists the active organisations' configuration.
func (*Store) ConsoleSeat ¶
func (s *Store) ConsoleSeat(ctx context.Context, seatID string, runs int) (*runtimeapi.ConsoleSeatDetail, error)
ConsoleSeat returns an active seat's configuration, live state, recovery state, memory metadata and recent runs.
func (*Store) ConsoleSeatStatuses ¶
func (s *Store) ConsoleSeatStatuses(ctx context.Context, orgID string, keys []string) ([]runtimeapi.ConsoleSeatStatus, error)
ConsoleSeatStatuses reports the live state of the organisation's active seats, optionally restricted to the given keys, ordered by key.
func (*Store) Conversation ¶
func (s *Store) Conversation(ctx context.Context, orgID, id string) (kind, binding string, participants []string, err error)
Conversation returns a conversation's kind, binding and participants.
func (*Store) ConversationMessages ¶
func (s *Store) ConversationMessages(ctx context.Context, orgID, convID string, offset, limit int) ([]Message, error)
ConversationMessages pages a conversation's messages, oldest first.
func (*Store) Conversations ¶
func (s *Store) Conversations(ctx context.Context, orgID, seatID string, offset, limit int) ([]ConversationSummary, error)
Conversations lists conversations the seat participates in, most recent first.
func (*Store) CreateProbe ¶
CreateProbe queues a synthetic probe message for the seat; the probe id is the message id.
func (*Store) CreateSchedule ¶
func (s *Store) CreateSchedule(ctx context.Context, f Fence, orgID, schedule string, next time.Time, note string) (*Schedule, error)
CreateSchedule registers a wake schedule for the seat itself.
func (*Store) DeleteOrganization ¶
DeleteOrganization removes an organisation's runtime. With purge=false (retain) the organisation is marked deleted and every seat retired so all capabilities are revoked while durable data stays recoverable (A19). With purge=true every row of the organisation is deleted.
func (*Store) ExpireSending ¶
ExpireSending marks outbound messages whose claim lapsed without a recorded outcome as unknown.
func (*Store) ExpireStaleOperations ¶
ExpireStaleOperations marks operations left pending by a crashed attempt as unknown: the side effect may have happened, so they are never replayed.
func (*Store) FenceSeat ¶
func (s *Store) FenceSeat(ctx context.Context, orgID, seatID string, expected int64) (*runtimeapi.LeaseResponse, error)
FenceSeat expires the seat's lease and increments its generation so the previous holder's calls are rejected. The controller calls it only after confirming the previous Pod is gone (contracts.md).
func (*Store) FinishOperation ¶
func (s *Store) FinishOperation(ctx context.Context, id, status, receipt string, result json.RawMessage, errText string, attempts int) error
FinishOperation records an operation's outcome. Its result is recorded regardless of later fencing: it describes what happened externally.
func (*Store) FireDue ¶
FireDue fires up to limit due schedules of active seats. Each fire inserts a schedule-origin message and delivery, deduplicated on (schedule, fire time) so a repeated fire never queues a second wake. It returns the number of wakes queued.
func (*Store) History ¶
func (s *Store) History(ctx context.Context, orgID, recordID string, storeIDs []string, offset, limit int) ([]RevisionInfo, error)
History pages a record's revisions, newest first.
func (*Store) IngestHuman ¶
IngestHuman persists an inbound human message and its delivery. Events are deduplicated on (organisation, connection, external event id) (A09).
func (*Store) LeaseNext ¶
func (s *Store) LeaseNext(ctx context.Context, f Fence) (*runtimeapi.InboxDelivery, error)
LeaseNext atomically leases the seat's oldest eligible delivery. Within a conversation deliveries are handed out in order, and a conversation with a leased delivery is skipped. The execution row records the configuration revision and lease generation the turn runs under (A14). It returns nil when nothing is eligible.
func (*Store) Operation ¶
func (s *Store) Operation(ctx context.Context, orgID, seatID, id string) (*runtimeapi.Operation, error)
Operation loads one of the seat's operations.
func (*Store) Organization ¶
Organization loads a non-deleted organisation.
func (*Store) PendingDeliveries ¶
PendingDeliveries counts the seat's undelivered (pending or leased) messages.
func (*Store) ProbeStatus ¶
func (s *Store) ProbeStatus(ctx context.Context, orgID, seatID, probeID string) (*runtimeapi.ProbeResponse, error)
ProbeStatus reports a probe's progress from its delivery and execution. It passes when the runner acknowledged it as completed and no reported check failed.
func (*Store) Record ¶
func (s *Store) Record(ctx context.Context, orgID, recordID string, storeIDs []string) (*Record, error)
Record reads a record from one of the authorised stores.
func (*Store) RecordConnectionCheck ¶
func (s *Store) RecordConnectionCheck(ctx context.Context, orgID, connection string, res runtimeapi.CheckResult) error
RecordConnectionCheck stores a verification result for readiness (§5.4).
func (*Store) RecordRevision ¶
func (s *Store) RecordRevision(ctx context.Context, orgID, recordID string, revision int, storeIDs []string) (*Record, error)
RecordRevision reads a past revision of a record in an authorised store.
func (*Store) ReleaseLease ¶
ReleaseLease gives up the lease at generation gen and records Stopped.
func (*Store) RenewLease ¶
func (s *Store) RenewLease(ctx context.Context, seatID, podUID string, gen int64) (*runtimeapi.LeaseResponse, error)
RenewLease extends the lease held by podUID at generation gen.
func (*Store) ReplyToHuman ¶
ReplyToHuman writes the outbound message and its outbox row in one fenced transaction; the dispatcher delivers it (§9.2).
func (*Store) ReportState ¶
func (s *Store) ReportState(ctx context.Context, f Fence, req runtimeapi.StateRequest) error
ReportState records the runner's execution state and adopted revision.
func (*Store) RequeueExpired ¶
RequeueExpired returns deliveries whose 15-minute lease expired to the queue with backoff and dead-letters exhausted ones. It returns the number of deliveries dead-lettered.
func (*Store) ResolveOutbox ¶
func (s *Store) ResolveOutbox(ctx context.Context, it OutboxItem, state, receipt, errText string, retryIn time.Duration) error
ResolveOutbox records the outcome of a send. state is one of the outbox states; for OutboxPending the row is retried after retryIn.
func (*Store) ReviseRecord ¶
func (s *Store) ReviseRecord(ctx context.Context, f Fence, in RecordChange, storeIDs []string) (*Record, error)
ReviseRecord applies a change only if the record is still at the expected revision; otherwise it returns a *RevisionConflict naming the current one.
func (*Store) SaveCheckpoint ¶
func (s *Store) SaveCheckpoint(ctx context.Context, f Fence, cp runtimeapi.Checkpoint) error
SaveCheckpoint stores the seat's harness checkpoint (ADR-0005).
func (*Store) SaveHandoff ¶
SaveHandoff replaces the seat's portable handoff (§8.4).
func (*Store) Search ¶
func (s *Store) Search(ctx context.Context, orgID string, storeIDs []string, query string, tags []string, offset, limit int) ([]SearchHit, error)
Search runs a Postgres full-text query (websearch syntax) over the authorised stores. An empty query lists the most recently updated records.
func (*Store) Seat ¶
Seat loads an active seat and its committed manifest. Retired seats and seats of deleted organisations are not found, which revokes their access.
func (*Store) SeatByServiceAccount ¶
func (s *Store) SeatByServiceAccount(ctx context.Context, namespace, serviceAccount string) (string, error)
SeatByServiceAccount maps an authenticated ServiceAccount to its active seat.
func (*Store) SeatOrganization ¶
SeatOrganization returns the organisation of any seat, active or retired.
func (*Store) SeatRuntimes ¶
func (s *Store) SeatRuntimes(ctx context.Context, orgID string, keys []string) (map[string]runtimeapi.SeatRuntime, error)
SeatRuntimes reports the runtime view of the organisation's active seats, optionally restricted to the given keys.
func (*Store) SendSeatMessage ¶
SendSeatMessage persists an internal message and its delivery in one fenced transaction. A full recipient inbox is rejected (ADR-0006).
func (*Store) SyncOrganization ¶
func (s *Store) SyncOrganization(ctx context.Context, in SyncInput) (*runtimeapi.SyncResponse, error)
SyncOrganization idempotently upserts the organisation, its seats and its memory stores in one transaction (§6.1). Seats missing from the manifest are retired with their data retained. A seat's policy revision is bumped when its authority changes; because tools read the committed seat manifest on every call, the new policy is in force when this returns (A13).
func (*Store) UnknownOperations ¶
func (s *Store) UnknownOperations(ctx context.Context, seatID string, limit int) ([]runtimeapi.Operation, error)
UnknownOperations lists the seat's operations whose outcome is unknown, for agent-led reconciliation (§10.3).