Documentation
¶
Overview ¶
Package postgres is the Postgres driver for the state database: its own schema and its own SQL behind internal/store's contract, proven by the same conformance suite as the sqlite driver.
Where the two differ it is on purpose, each using what its database is good at: an identity column for insertion order where sqlite has rowid, FOR UPDATE SKIP LOCKED for the claim, timestamptz where sqlite stores sortable text, and advisory locks where sqlite's single writer serialized everything for free (see write).
Only internal/cli constructs one; every other package takes the store.Store it was handed.
Index ¶
- Constants
- func HasNothingRecorded(rawURL string) bool
- func HasPassword(rawURL string) bool
- func Identity(ctx context.Context, rawURL string) (string, error)
- func Redact(rawURL string) string
- type Accounts
- func (a *Accounts) Close() error
- func (a *Accounts) CreateSession(ctx context.Context, session store.Session) error
- func (a *Accounts) FindClient(ctx context.Context, id string) (store.OAuthClient, bool, error)
- func (a *Accounts) FindSession(ctx context.Context, tokenHash string) (store.Session, bool, error)
- func (a *Accounts) FindToken(ctx context.Context, tokenHash string) (store.OAuthToken, bool, error)
- func (a *Accounts) FindUser(ctx context.Context, who string) (store.User, bool, error)
- func (a *Accounts) Grants(ctx context.Context, filter store.Grant) ([]store.Connection, error)
- func (a *Accounts) IssueToken(ctx context.Context, token store.OAuthToken) error
- func (a *Accounts) RegisterClient(ctx context.Context, client store.OAuthClient, limit int) error
- func (a *Accounts) RevokeGrant(ctx context.Context, grant store.Grant) error
- func (a *Accounts) RevokeSession(ctx context.Context, tokenHash string) error
- func (a *Accounts) RevokeToken(ctx context.Context, tokenHash string) (bool, error)
- func (a *Accounts) SaveUser(ctx context.Context, user store.User) error
- type Reader
- func (r *Reader) Activity(ctx context.Context, filter store.ActivityFilter) ([]store.ActivityEntry, error)
- func (r *Reader) Close() error
- func (r *Reader) Pipelines(ctx context.Context) ([]store.PipelineRow, error)
- func (r *Reader) RecentRuns(ctx context.Context, pipelines []string, limit int) ([]store.CrossRunRow, error)
- type Store
- func (s *Store) AbortQueuedJob(ctx context.Context, jobName string) (bool, error)
- func (s *Store) AnswerQuestion(ctx context.Context, id int64, answer, by string) error
- func (s *Store) AppendRunEvent(ctx context.Context, row store.RunEventRow) error
- func (s *Store) ApprovalStatus(ctx context.Context, id int64) (store.Approval, error)
- func (s *Store) Approvals(ctx context.Context, pendingOnly bool, limit int) ([]store.Approval, error)
- func (s *Store) AskQuestion(ctx context.Context, question store.Question) (store.Question, bool, error)
- func (s *Store) CheckErrors(ctx context.Context) ([]store.CheckError, error)
- func (s *Store) CheckedResources(ctx context.Context) ([]store.CheckedResource, error)
- func (s *Store) ClaimNextJob(ctx context.Context) (store.ClaimedJob, bool, error)
- func (s *Store) Close() error
- func (s *Store) CloseQuestion(ctx context.Context, id int64, status store.QuestionStatus, answer, by string) error
- func (s *Store) CompareAndSetCheckedVersion(ctx context.Context, swap store.CheckedSwap) (bool, error)
- func (s *Store) CompleteJob(ctx context.Context, id int64, status store.QueueStatus, runErr error) error
- func (s *Store) CompletedRunSteps(ctx context.Context, runID string) ([]store.RunStep, error)
- func (s *Store) ConsumedMark(ctx context.Context, jobName, resourceName string) (int64, error)
- func (s *Store) Credential(ctx context.Context, name string) ([]byte, bool, error)
- func (s *Store) CredentialScope() string
- func (s *Store) CurrentRevision(ctx context.Context) (store.Revision, bool, error)
- func (s *Store) DecideApproval(ctx context.Context, id int64, status store.ApprovalStatus, by, reason string) error
- func (s *Store) Delete(ctx context.Context) error
- func (s *Store) DeleteStepEvents(ctx context.Context, runID string, stepID int64, eventType string) error
- func (s *Store) Delivery(ctx context.Context, resourceName string, versionJSON store.VersionKey) (store.Delivery, bool, error)
- func (s *Store) Description() string
- func (s *Store) EnqueueJob(ctx context.Context, jobName, reason, by string) error
- func (s *Store) EnqueueManualJob(ctx context.Context, jobName, reason, by string) error
- func (s *Store) EnqueueRerunJob(ctx context.Context, jobName, reason, runID, by string) error
- func (s *Store) FindRevision(ctx context.Context, sha string) (store.Revision, bool, error)
- func (s *Store) FindRunRow(ctx context.Context, id string) (store.RunRow, bool, error)
- func (s *Store) FinishRun(ctx context.Context, id string, status store.RunStatus) error
- func (s *Store) FirstRunSince(ctx context.Context, jobName string, since time.Time) (store.RunRow, bool, error)
- func (s *Store) Forget(ctx context.Context, scope string, id int64) (bool, error)
- func (s *Store) ForgetChain(ctx context.Context, jobName, rootHash string) error
- func (s *Store) ForgetScope(ctx context.Context, scope string) (int, error)
- func (s *Store) GreenVersions(ctx context.Context, resourceName string, upstreamJobs []string) ([]map[string]any, error)
- func (s *Store) HasNodeSucceeded(ctx context.Context, jobName, hash string) (bool, error)
- func (s *Store) HasNodesSucceeded(ctx context.Context, jobName string, hashes []string) (map[string]bool, error)
- func (s *Store) HasPassedVersionSet(ctx context.Context, jobName string, want map[string]store.VersionKey) (bool, error)
- func (s *Store) HasSucceededBatch(ctx context.Context, jobName string, rootHashes []string) (map[string]bool, error)
- func (s *Store) HeldJobs(ctx context.Context) ([]store.HeldJob, error)
- func (s *Store) IsJobHeld(ctx context.Context, jobName string) (bool, error)
- func (s *Store) LastChecked(ctx context.Context, resourceName string) (store.CheckedResource, bool, error)
- func (s *Store) LatestFinishedRunByJob(ctx context.Context) (map[string]store.RunRow, error)
- func (s *Store) LatestRunByJob(ctx context.Context) (map[string]store.RunRow, error)
- func (s *Store) ListMemories(ctx context.Context, scope string, limit int) ([]store.Memory, error)
- func (s *Store) ListNodes(ctx context.Context, jobName string, limit int) ([]store.NodeRow, error)
- func (s *Store) ListRuns(ctx context.Context, jobName string, limit int) ([]store.RunRow, error)
- func (s *Store) ListTriggerQueue(ctx context.Context, limit int) ([]store.QueueRow, error)
- func (s *Store) MaxStepID(ctx context.Context, runID string) (int64, error)
- func (s *Store) MemoryScopes(ctx context.Context) ([]store.MemoryScope, error)
- func (s *Store) NodeTranscript(ctx context.Context, hash string) (string, bool, error)
- func (s *Store) NodesByHash(ctx context.Context, hashes []string) (map[string]store.NodeRow, error)
- func (s *Store) PassedVersions(ctx context.Context, jobName string, limit int) ([]store.PassedVersion, error)
- func (s *Store) Pause(ctx context.Context) error
- func (s *Store) Paused(ctx context.Context) (bool, error)
- func (s *Store) Pipeline() string
- func (s *Store) Prune(ctx context.Context, policy store.Retention, keepRunID string) error
- func (s *Store) QuestionStatus(ctx context.Context, id int64) (store.Question, error)
- func (s *Store) Questions(ctx context.Context, pendingOnly bool, limit int) ([]store.Question, error)
- func (s *Store) Reader() store.Reader
- func (s *Store) RecordActivity(ctx context.Context, entry store.ActivityEntry, limit int) error
- func (s *Store) RecordAgentUsage(ctx context.Context, usage store.AgentUsage) error
- func (s *Store) RecordChainSucceeded(ctx context.Context, jobName, rootHash string) error
- func (s *Store) RecordCheckError(ctx context.Context, resourceName, message string) error
- func (s *Store) RecordCheckedVersion(ctx context.Context, resourceName string, versionJSON store.VersionKey) error
- func (s *Store) RecordConsumedMark(ctx context.Context, jobName, resourceName string, order int64) error
- func (s *Store) RecordDelivery(ctx context.Context, resourceName string, delivery store.Delivery, ...) (bool, error)
- func (s *Store) RecordJobOutcome(ctx context.Context, jobName string, succeeded bool, maxFailures int) (held bool, consecutive int, err error)
- func (s *Store) RecordNode(ctx context.Context, node store.NodeRecord, jobName string, ...) error
- func (s *Store) RecordPassedVersion(ctx context.Context, pass store.Pass) error
- func (s *Store) RecordPassedVersions(ctx context.Context, passes []store.Pass) error
- func (s *Store) RecordPlacement(ctx context.Context, placement store.Placement) error
- func (s *Store) RecordRevision(ctx context.Context, sha, source string, includes map[string]string) error
- func (s *Store) RecordRunInput(ctx context.Context, runID string, input store.RunInput) error
- func (s *Store) RecordRunParent(ctx context.Context, runID, parentID string) error
- func (s *Store) RecordRunRerun(ctx context.Context, runID, originalID string) error
- func (s *Store) RecordRunStep(ctx context.Context, runID string, step store.RunStep) error
- func (s *Store) RecordStepBlobs(ctx context.Context, actionKey string, outputs map[string]string) error
- func (s *Store) RecordVersionOrder(ctx context.Context, resourceName string, versionJSON store.VersionKey) (int64, error)
- func (s *Store) RecordVersions(ctx context.Context, resourceName string, versions []map[string]any, limit int) (int, error)
- func (s *Store) Release() error
- func (s *Store) Remember(ctx context.Context, memory store.Memory, limit int) (store.Memory, bool, error)
- func (s *Store) Rename(ctx context.Context, name string) error
- func (s *Store) RequestApproval(ctx context.Context, jobName, message string) (int64, error)
- func (s *Store) RequestApprovalFor(ctx context.Context, runID, stepKey, jobName, message string) (int64, error)
- func (s *Store) ResetJobFailures(ctx context.Context, jobName string) error
- func (s *Store) ResetStaleRunning(ctx context.Context) error
- func (s *Store) ResourceVersionsJSON(ctx context.Context, resourceName string) ([]store.VersionKey, error)
- func (s *Store) ResumableRuns(ctx context.Context) ([]store.RunRow, error)
- func (s *Store) ResumeRun(ctx context.Context, id, workspaceDir, configSHA string) error
- func (s *Store) RunCostTotals(ctx context.Context, limit int) ([]store.RunTotals, error)
- func (s *Store) RunEvents(ctx context.Context, runID string, afterSeq int64, limit int) ([]store.RunEventRow, error)
- func (s *Store) RunInputs(ctx context.Context, runID string) ([]store.RunInput, error)
- func (s *Store) RunPlacements(ctx context.Context, runID string) ([]store.Placement, error)
- func (s *Store) RunTokensSpent(ctx context.Context, runID string) (int, error)
- func (s *Store) RunUsage(ctx context.Context, runID string) ([]store.AgentUsage, error)
- func (s *Store) RunsUsingNode(ctx context.Context, hash string, limit int) ([]store.RunRow, error)
- func (s *Store) SaveCredential(ctx context.Context, name string, sealed []byte) error
- func (s *Store) SaveNodeTranscript(ctx context.Context, hash, transcript string) error
- func (s *Store) SerialGroupHolder(ctx context.Context, jobName string) (string, error)
- func (s *Store) SetCurrentRevision(ctx context.Context, sha, from string) error
- func (s *Store) SetSourcePath(ctx context.Context, source string) error
- func (s *Store) StartRun(ctx context.Context, run store.NewRun) error
- func (s *Store) StepBlobs(ctx context.Context, actionKey string) (map[string]string, error)
- func (s *Store) SyncJobLimits(ctx context.Context, groups map[string][]string, limits map[string]int) error
- func (s *Store) Unpause(ctx context.Context) error
- func (s *Store) VersionOrders(ctx context.Context, resourceName string) (map[store.VersionKey]int64, error)
- func (s *Store) VersionRuns(ctx context.Context, resourceName string, versions []store.VersionKey) ([]store.VersionRun, error)
Constants ¶
const DefaultSchema = "steps"
DefaultSchema is where steps keeps its tables unless the URL's search_path names another. Never public: a database the operator already runs has its own tables there, and CREATE TABLE IF NOT EXISTS would silently adopt one that happened to be called runs.
Variables ¶
This section is empty.
Functions ¶
func HasNothingRecorded ¶
HasNothingRecorded reports a database that exists but holds no steps schema.
func HasPassword ¶
HasPassword reports a URL carrying its own password, which a process list and a shell history both keep.
Types ¶
type Accounts ¶
type Accounts struct {
// contains filtered or unexported fields
}
Accounts is the daemon-level handle on the people who sign in; see the sqlite driver.
func OpenAccounts ¶
OpenAccounts connects and makes sure the schema is there, the way OpenStore does for its first pipeline.
func (*Accounts) CreateSession ¶
CreateSession records a signed-in browser and sweeps the ones that ended.
func (*Accounts) FindClient ¶
FindClient is a registered agent by its id.
func (*Accounts) FindSession ¶
FindSession is the live session with this digest.
func (*Accounts) IssueToken ¶
IssueToken records a token by its digest, sweeping ones that ended.
func (*Accounts) RegisterClient ¶
RegisterClient records a self-registered agent, refusing one past limit; the count and the insert share a transaction.
func (*Accounts) RevokeGrant ¶
RevokeGrant ends every token under one grant.
func (*Accounts) RevokeSession ¶
RevokeSession ends a session; a second sign-out is not an error.
func (*Accounts) RevokeToken ¶
RevokeToken ends one token.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads across every pipeline in one schema. From a Store it borrows that handle's pool; from OpenReader it owns a read-only one.
func OpenReader ¶
OpenReader opens a database for cross-pipeline reading, registering nothing and creating nothing.
Its sessions are default_transaction_read_only: the sqlite driver can only promise a reader never writes, and Postgres can hold it to that.
A schema steps has never written is store.ErrNoState — "nothing recorded" is the same answer sqlite gives a file with no tables. A database that is not there at all is an error with advice, not ErrNoState: that is a typo in --db, or a database nobody created, and reading it as "no runs yet" would hide both.
func (*Reader) Activity ¶
func (r *Reader) Activity(ctx context.Context, filter store.ActivityFilter) ([]store.ActivityEntry, error)
Activity reads the log newest first; see the sqlite driver for the pipeline filter.
func (*Reader) RecentRuns ¶
func (r *Reader) RecentRuns(ctx context.Context, pipelines []string, limit int) ([]store.CrossRunRow, error)
RecentRuns returns the newest runs across the NAMED pipelines, newest first; naming none asks for none.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is one pipeline's handle on a Postgres state database. The handle is the scope, as it is for sqlite: pipelineID is in every query's predicate.
func Attach ¶ added in v0.2.0
Attach is a writable handle on a pipeline ALREADY in the schema, over the URL's shared pool, registering nothing; see the sqlite driver.
func OpenExisting ¶
OpenExisting scopes a handle to a pipeline ALREADY in the database, rather than registering one.
Unlike OpenReader its sessions may write: approving, answering and unpausing all resolve their pipeline this way and then record something. What it never does is create — a schema, a table, or the pipeline it was asked about.
func OpenStore ¶
OpenStore connects, creates this driver's schema on first sight, and scopes the handle to the named pipeline — registering it if it is new.
steps never creates the DATABASE: that is the operator's, with its owner, encoding and backups. The schema inside it is steps'.
func (*Store) AbortQueuedJob ¶
AbortQueuedJob keeps the row, so the queue still says somebody stopped it.
func (*Store) AnswerQuestion ¶
AnswerQuestion records an answer against a pending question, holding it to the offered options when they are required.
func (*Store) AppendRunEvent ¶
AppendRunEvent persists one run event.
A reader follows a run with `seq > cursor` (RunEvents), which is only safe if one run's events COMMIT in seq order: an identity value is taken at insert, not at commit, so two concurrent inserts can commit 2 before 1 and a reader who saw 2 has already moved past 1 for good. It holds because pipeline.StoreSink calls this from ONE goroutine per bus, so a run's inserts never overlap. That is an invariant of the caller, not something taken here with a lock: this is the hottest write there is. Batching or fanning out these inserts must keep it.
func (*Store) ApprovalStatus ¶
ApprovalStatus reads one approval's current state.
func (*Store) Approvals ¶
func (s *Store) Approvals(ctx context.Context, pendingOnly bool, limit int) ([]store.Approval, error)
Approvals lists what a pipeline has asked a person to decide: waiting ones oldest first and uncapped, the audit listing newest first.
func (*Store) AskQuestion ¶
func (s *Store) AskQuestion(ctx context.Context, question store.Question) (store.Question, bool, error)
AskQuestion records a pending question, or returns the one this run already asked under the same memo key. The INSERT..SELECT is what scopes it to this pipeline; the unique index is what makes concurrent askers share one row.
func (*Store) CheckErrors ¶
CheckErrors is every resource this pipeline cannot currently check.
func (*Store) CheckedResources ¶
CheckedResources lists every resource version the watcher has recorded.
func (*Store) ClaimNextJob ¶
ClaimNextJob transitions the oldest claimable pending row to running; see the sqlite driver's ClaimNextJob for what makes a row claimable.
SKIP LOCKED alone does not keep the caps. It stops two claimers taking the SAME row, but the caps are about OTHER rows: two claimers each counting a job's running builds see neither's claim until it commits, and both admit. That is a read-then-write, so it runs under the pipeline lock (see write), which serializes claims within a pipeline; SKIP LOCKED then only lets a claim pass over a row some other statement holds rather than wait on it.
func (*Store) Close ¶
Close releases the pool. There is nothing to compact: autovacuum does what sqlite's Close does by hand.
func (*Store) CloseQuestion ¶
func (s *Store) CloseQuestion(ctx context.Context, id int64, status store.QuestionStatus, answer, by string) error
CloseQuestion resolves a question nobody answered; see the sqlite driver's for why this stays apart from AnswerQuestion.
func (*Store) CompareAndSetCheckedVersion ¶
func (s *Store) CompareAndSetCheckedVersion(ctx context.Context, swap store.CheckedSwap) (bool, error)
CompareAndSetCheckedVersion is one statement either way. Under READ COMMITTED the guarded UPDATE re-reads a row a concurrent writer changed before deciding, so the comparison is against what is committed, not what this statement's snapshot saw.
func (*Store) CompleteJob ¶
func (s *Store) CompleteJob(ctx context.Context, id int64, status store.QueueStatus, runErr error) error
CompleteJob marks a claimed row done or failed.
func (*Store) CompletedRunSteps ¶
CompletedRunSteps returns the steps a run already finished, in the order they finished.
func (*Store) ConsumedMark ¶
ConsumedMark is how far a job has fanned out over a resource; zero means nothing taken.
func (*Store) Credential ¶ added in v0.2.0
Credential is the sealed bytes saved under name for this pipeline.
func (*Store) CredentialScope ¶ added in v0.2.0
CredentialScope is the pipeline's id, which a rename keeps and an identity column never hands out twice.
func (*Store) CurrentRevision ¶
CurrentRevision reads the revision a set made current, includes and all.
func (*Store) DecideApproval ¶
func (s *Store) DecideApproval(ctx context.Context, id int64, status store.ApprovalStatus, by, reason string) error
DecideApproval records a decision, refusing to overwrite one already made.
func (*Store) Delete ¶
Delete clears the RESTRICTed current revision first, deletes the pipeline and everything cascading off it, and sweeps the shared content it left unreferenced.
func (*Store) DeleteStepEvents ¶
func (s *Store) DeleteStepEvents(ctx context.Context, runID string, stepID int64, eventType string) error
DeleteStepEvents removes a step's events of one type. One statement that reads nothing first, so it needs no write() lock.
func (*Store) Delivery ¶
func (s *Store) Delivery(ctx context.Context, resourceName string, versionJSON store.VersionKey) (store.Delivery, bool, error)
Delivery reads back the payload recorded with a version.
func (*Store) Description ¶
Description is the database and schema behind this handle, with no credential in it.
func (*Store) EnqueueJob ¶
EnqueueJob inserts a pending row for jobName unless one is already pending.
func (*Store) EnqueueManualJob ¶
EnqueueManualJob upserts, so a pending automatic row becomes manual.
func (*Store) EnqueueRerunJob ¶
EnqueueRerunJob queues a retry of a recorded run.
func (*Store) FindRevision ¶
FindRevision returns a configuration this pipeline has run, by its hash.
func (*Store) FindRunRow ¶
FindRunRow reads one run of this pipeline by id.
func (*Store) FirstRunSince ¶
func (s *Store) FirstRunSince(ctx context.Context, jobName string, since time.Time) (store.RunRow, bool, error)
FirstRunSince returns the oldest run of a job started at or after since.
func (*Store) ForgetChain ¶
ForgetChain removes (jobName, rootHash) from the skip index.
func (*Store) ForgetScope ¶
ForgetScope deletes every entry of scope.
func (*Store) GreenVersions ¶
func (s *Store) GreenVersions(ctx context.Context, resourceName string, upstreamJobs []string) ([]map[string]any, error)
GreenVersions returns the versions of a resource that EVERY named upstream job has gone green against, oldest first.
func (*Store) HasNodeSucceeded ¶
HasNodeSucceeded reports whether this exact node succeeded for this job.
func (*Store) HasNodesSucceeded ¶
func (s *Store) HasNodesSucceeded(ctx context.Context, jobName string, hashes []string) (map[string]bool, error)
HasNodesSucceeded is HasNodeSucceeded for many hashes in one query.
func (*Store) HasPassedVersionSet ¶
func (s *Store) HasPassedVersionSet(ctx context.Context, jobName string, want map[string]store.VersionKey) (bool, error)
HasPassedVersionSet reports whether jobName has one build in which EVERY (resource, version) pair in want was green at the same time. Rows with no build id can never satisfy it; an empty want is vacuously true.
func (*Store) HasSucceededBatch ¶
func (s *Store) HasSucceededBatch(ctx context.Context, jobName string, rootHashes []string) (map[string]bool, error)
HasSucceededBatch reports which of rootHashes have succeeded for jobName, in one round trip.
func (*Store) IsJobHeld ¶
IsJobHeld reports whether the breaker has taken a job out of the rotation.
func (*Store) LastChecked ¶
func (s *Store) LastChecked(ctx context.Context, resourceName string) (store.CheckedResource, bool, error)
LastChecked returns one resource's last-checked row.
func (*Store) LatestFinishedRunByJob ¶
LatestFinishedRunByJob returns every job's newest run that is no longer running, keyed by job name.
func (*Store) LatestRunByJob ¶
LatestRunByJob returns the most recent run for every job that has one, counting a rerun only when it reruns the job's latest other run.
func (*Store) ListMemories ¶
ListMemories is scope's entries, newest first.
func (*Store) ListNodes ¶
ListNodes returns the most recently recorded steps, newest first. An empty jobName covers every job.
func (*Store) ListRuns ¶
ListRuns returns run invocations, newest first. An empty jobName covers every job.
func (*Store) ListTriggerQueue ¶
ListTriggerQueue returns the most recent trigger-queue entries, newest first.
func (*Store) MemoryScopes ¶
MemoryScopes is every scope holding an entry, by name.
func (*Store) NodeTranscript ¶
NodeTranscript returns the stored transcript for a node hash.
func (*Store) NodesByHash ¶
NodesByHash returns the recorded nodes for the given hashes, keyed by hash.
func (*Store) PassedVersions ¶
func (s *Store) PassedVersions(ctx context.Context, jobName string, limit int) ([]store.PassedVersion, error)
PassedVersions lists the resource versions a job has recorded as green.
func (*Store) Prune ¶
Prune applies one build's retention policy. keepRunID survives whatever the cap says: it is the run whose build is calling this.
func (*Store) QuestionStatus ¶
QuestionStatus reads one question's current state.
func (*Store) Questions ¶
func (s *Store) Questions(ctx context.Context, pendingOnly bool, limit int) ([]store.Question, error)
Questions lists what a pipeline has asked: waiting ones oldest first, or everything with the waiting ones first and the rest newest first.
func (*Store) RecordActivity ¶
RecordActivity appends an entry under this pipeline and trims the whole log; see the sqlite driver for why the name is copied.
func (*Store) RecordAgentUsage ¶
RecordAgentUsage stores what one agent step spent, ACCUMULATING the counts on conflict (every attempt was paid for) and replacing the descriptive fields. A cost is unpriced only when both sides are.
func (*Store) RecordChainSucceeded ¶
RecordChainSucceeded adds (jobName, rootHash) to the skip index.
func (*Store) RecordCheckError ¶
RecordCheckError files why a check failed, or clears the filing when the message is empty.
func (*Store) RecordCheckedVersion ¶
func (s *Store) RecordCheckedVersion(ctx context.Context, resourceName string, versionJSON store.VersionKey) error
RecordCheckedVersion upserts the latest observed version for a resource.
func (*Store) RecordConsumedMark ¶
func (s *Store) RecordConsumedMark(ctx context.Context, jobName, resourceName string, order int64) error
RecordConsumedMark advances a job's cursor to include order, only ever forward.
func (*Store) RecordDelivery ¶
func (s *Store) RecordDelivery(ctx context.Context, resourceName string, delivery store.Delivery, dispatch store.Dispatch, limit int) (bool, error)
RecordDelivery files the version, its payload and — unless held — the resource's current version and the jobs it triggers, in one transaction.
func (*Store) RecordJobOutcome ¶
func (s *Store) RecordJobOutcome(ctx context.Context, jobName string, succeeded bool, maxFailures int) (held bool, consecutive int, err error)
RecordJobOutcome updates a job's consecutive-failure count and reports whether the job is now held. maxFailures of 0 means no breaker.
func (*Store) RecordNode ¶
func (s *Store) RecordNode(ctx context.Context, node store.NodeRecord, jobName string, status store.NodeStatus, result map[string]any, execErr error) error
RecordNode upserts a node's execution outcome, interning its content.
It holds the content lock SHARED, and the node_content sweep takes it exclusive. node_content is the one table every pipeline in the schema shares, and ON CONFLICT DO NOTHING finding a row present takes no lock on it — so without this, another pipeline's sweep could delete the row between this statement seeing it and the node's reference to it, failing the foreign key. sqlite serialized the file, so the window never existed there. Shared, so recording nodes never waits on another recording.
func (*Store) RecordPassedVersion ¶
RecordPassedVersion records that jobName completed successfully against this exact version of a resource.
func (*Store) RecordPassedVersions ¶
RecordPassedVersions records every pass in one transaction, under one pipeline lock.
func (*Store) RecordPlacement ¶
RecordPlacement stores where one placed step ran, replacing on conflict: a placement describes a machine, and the last one to answer is the one.
func (*Store) RecordRevision ¶
func (s *Store) RecordRevision(ctx context.Context, sha, source string, includes map[string]string) error
RecordRevision interns the configuration a run was started from; the conflict refreshes loaded_at, which is what the sweep reads as "served".
func (*Store) RecordRunInput ¶
RecordRunInput remembers that a run was created with this version, bound under this get.
func (*Store) RecordRunParent ¶
RecordRunParent notes that a run was forked from another by a replay.
func (*Store) RecordRunRerun ¶
RecordRunRerun notes which run a retry re-ran.
func (*Store) RecordRunStep ¶
RecordRunStep marks one step of one build of a run as done.
func (*Store) RecordStepBlobs ¶
func (s *Store) RecordStepBlobs(ctx context.Context, actionKey string, outputs map[string]string) error
RecordStepBlobs files the content digests of a step's outputs under its action key, replacing whatever the key held.
func (*Store) RecordVersionOrder ¶
func (s *Store) RecordVersionOrder(ctx context.Context, resourceName string, versionJSON store.VersionKey) (int64, error)
RecordVersionOrder files a version if it is not already known and returns the order it sits at.
func (*Store) RecordVersions ¶
func (s *Store) RecordVersions(ctx context.Context, resourceName string, versions []map[string]any, limit int) (int, error)
RecordVersions files what a check reported, assigning each new version the next check_order, and prunes beyond the cap. It returns how many versions were new to check-history.
func (*Store) Release ¶
Release is Close; the sqlite driver distinguishes them, this one has no reclaim to skip.
func (*Store) Remember ¶
func (s *Store) Remember(ctx context.Context, memory store.Memory, limit int) (store.Memory, bool, error)
Remember files the memory, or finds it already filed, and applies the cap. Under write() because the cap reads the scope's entries before deleting past them, and two rememberers under READ COMMITTED would each keep a view the other just changed.
func (*Store) RequestApproval ¶
RequestApproval records a pending approval and returns its id.
func (*Store) RequestApprovalFor ¶
func (s *Store) RequestApprovalFor(ctx context.Context, runID, stepKey, jobName, message string) (int64, error)
RequestApprovalFor finds the live approval this step of this run already made, or makes one; see the sqlite driver.
func (*Store) ResetJobFailures ¶
ResetJobFailures clears a job's consecutive-failure count and releases it.
func (*Store) ResetStaleRunning ¶
ResetStaleRunning flips this pipeline's running rows back to pending, a row whose run is still running carrying it to resume, and closes its running runs as aborted, at daemon startup. Like the sqlite driver's, it assumes it is ALONE: one `steps web` per state database, and nothing here arbitrates a second.
func (*Store) ResourceVersionsJSON ¶
func (s *Store) ResourceVersionsJSON(ctx context.Context, resourceName string) ([]store.VersionKey, error)
ResourceVersionsJSON returns the versions a CHECK has reported for a resource, oldest first.
func (*Store) ResumableRuns ¶
ResumableRuns is every run of this pipeline still recorded running, or that a queue row still waits to resume.
func (*Store) ResumeRun ¶
ResumeRun puts an existing run of this pipeline back in flight, keeping its recorded configuration when the sha names none.
func (*Store) RunCostTotals ¶
RunCostTotals rolls agent_usage up per run, newest first, counting the unpriced steps so a partial total is shown as partial.
func (*Store) RunEvents ¶
func (s *Store) RunEvents(ctx context.Context, runID string, afterSeq int64, limit int) ([]store.RunEventRow, error)
RunEvents replays a run's events in order, from afterSeq exclusive.
func (*Store) RunPlacements ¶
RunPlacements returns where every placed step of one run ran, in plan order.
func (*Store) RunTokensSpent ¶
RunTokensSpent is the total tokens already recorded against a run.
func (*Store) RunsUsingNode ¶
RunsUsingNode lists the runs whose events reference a node hash.
func (*Store) SaveCredential ¶ added in v0.2.0
SaveCredential replaces the sealed bytes saved under name.
func (*Store) SaveNodeTranscript ¶
SaveNodeTranscript stores (or replaces) an agent node's transcript, capped at MaxTranscriptBytes.
func (*Store) SerialGroupHolder ¶
SerialGroupHolder names a running job that shares a serial group with jobName, or "" when nothing is holding the lock.
func (*Store) SetCurrentRevision ¶
SetCurrentRevision refuses a sha nothing recorded rather than pointing at nothing.
func (*Store) SetSourcePath ¶
SetSourcePath records where this pipeline's YAML lives.
func (*Store) StartRun ¶
StartRun records a NEW run; an id already present anywhere in the schema is store.ErrRunExists, since run ids are global.
func (*Store) StepBlobs ¶
StepBlobs returns the digests recorded under an action key, keyed by declared output name.
func (*Store) SyncJobLimits ¶
func (s *Store) SyncJobLimits(ctx context.Context, groups map[string][]string, limits map[string]int) error
SyncJobLimits replaces the recorded admission rules with what the pipeline currently declares, in one transaction — and under the pipeline lock, so a claim never counts against half of a swap.
func (*Store) VersionOrders ¶
func (s *Store) VersionOrders(ctx context.Context, resourceName string) (map[store.VersionKey]int64, error)
VersionOrders maps every recorded version of a resource to its check_order, including the rows a check did not file.
func (*Store) VersionRuns ¶
func (s *Store) VersionRuns(ctx context.Context, resourceName string, versions []store.VersionKey) ([]store.VersionRun, error)
VersionRuns reports every run that took one of these versions of this resource as an input, newest first. DISTINCT because two gets of one resource in a run may bind the same version, and that is one run of it, not two.