Documentation
¶
Overview ¶
Package sqlite is the loop's one store: a SQLite database with one versioned schema that every repository shares.
Index ¶
- Constants
- Variables
- func AdoptJobDrafts(ctx context.Context, tx *sql.Tx) error
- func Check(path string) error
- func LockStore(path string) (unlock func(), err error)
- func Megabytes(n int64) string
- func ParseKey(key string) (pr.Ref, error)
- func Refuse(path string, s Status) error
- func StoredUnit(u unit.Unit, kind, key string) unit.Unit
- func UnitPairs(units []unit.Unit) (string, error)
- type AgentSession
- type AgentWorktree
- type Backup
- type Classifications
- func (c *Classifications) Output(ctx context.Context, u unit.Unit, workflow, fingerprint string) (json.RawMessage, bool, error)
- func (c *Classifications) Save(ctx context.Context, u unit.Unit, workflow, fingerprint string, ...) error
- func (c *Classifications) Spend(ctx context.Context, at time.Time, limit int) (bool, error)
- func (c *Classifications) Spent(ctx context.Context, at time.Time) (int, error)
- type DB
- func (db *DB) Activities(ctx context.Context, provider unit.ProviderID) (map[unit.Unit]turn.Activity, error)
- func (db *DB) AgentTranscript(ctx context.Context, agentSession string) (path, kind string, err error)
- func (db *DB) AgentWorktrees(ctx context.Context) ([]AgentWorktree, error)
- func (db *DB) AllSkips(ctx context.Context) (map[unit.Unit][]string, error)
- func (db *DB) AutomatedTurns(ctx context.Context, from time.Time, except []unit.ProviderID) (int, error)
- func (db *DB) CallSpent(ctx context.Context, from, to time.Time, kinds ...string) (float64, error)
- func (db *DB) Cards() card.Store
- func (db *DB) Classifications() *Classifications
- func (db *DB) Close() error
- func (db *DB) DeleteSkip(ctx context.Context, workflow string, u unit.Unit) error
- func (db *DB) DossierMoved(ctx context.Context, seq int64) error
- func (db *DB) DossierMoves(ctx context.Context) ([]DossierMove, error)
- func (db *DB) Dossiers() dossiers.Store
- func (db *DB) DraftEffects() outbox.AppliedStore
- func (db *DB) Drafts() outbox.Store
- func (db *DB) Events() automation.Events
- func (db *DB) EventsOf(ctx context.Context, units []unit.Unit, f timeline.Filter) ([]timeline.Event, error)
- func (db *DB) EventsOfKinds(ctx context.Context, kinds []string) ([]workflow.Event, error)
- func (db *DB) Fetches() *Fetches
- func (db *DB) Gates(now func() time.Time) GateStore
- func (db *DB) HeadlessSpent(ctx context.Context, from, to time.Time) (float64, error)
- func (db *DB) Held(ctx context.Context, p unit.ProviderID) ([]unit.Unit, error)
- func (db *DB) Intakes() intake.Store
- func (db *DB) Items() coreitems.Store
- func (db *DB) ItemsHeld(ctx context.Context, u unit.Unit) (map[task.ID][]string, error)
- func (db *DB) Ledger() automation.Ledger
- func (db *DB) LinkTargets(ctx context.Context) ([]unit.Unit, error)
- func (db *DB) Links() port.LinkStore
- func (db *DB) LinksFrom(ctx context.Context, units []unit.Unit) ([]link.Link, error)
- func (db *DB) Marks(ctx context.Context, u unit.Unit) (map[string]string, error)
- func (db *DB) MergedInto(ctx context.Context, id task.ID) ([]task.ID, error)
- func (db *DB) Override(ctx context.Context, u unit.Unit) (map[string]string, error)
- func (db *DB) Projects() coretasks.ProjectStore
- func (db *DB) Props(now func() time.Time) PropStore
- func (db *DB) PutRecord(ctx context.Context, u unit.Unit, kind string, w task.Writer, data []byte, ...) error
- func (db *DB) PutUnitBrief(ctx context.Context, u unit.Unit, version, body string, at time.Time) error
- func (db *DB) R() Reader
- func (db *DB) Read(ctx context.Context, fn func(tx *sql.Tx) error) error
- func (db *DB) Records(ctx context.Context, kind string, units ...unit.Unit) (map[unit.Unit]port.Event, error)
- func (db *DB) RehomeDrafts(ctx context.Context, moves map[unit.Unit]unit.Unit) (int, error)
- func (db *DB) Retain(ctx context.Context, now time.Time, p Retention) (Retained, error)
- func (db *DB) SaveAgentSession(ctx context.Context, a AgentSession) error
- func (db *DB) SaveSkip(ctx context.Context, workflow string, u unit.Unit, at time.Time) error
- func (db *DB) SetMarks(ctx context.Context, u unit.Unit, marks map[string]string) error
- func (db *DB) SetOverride(ctx context.Context, u unit.Unit, set, ifMatch map[string]string) (written bool, err error)
- func (db *DB) Snapshot(ctx context.Context, fn func(ctx context.Context) error) error
- func (db *DB) Snapshots() snapshot.Store
- func (db *DB) Tasks() coretasks.Store
- func (db *DB) TasksHolding(ctx context.Context, u unit.Unit) ([]task.ID, error)
- func (db *DB) TasksRunByHand(ctx context.Context, kinds []string, ids ...task.ID) (map[task.ID]bool, error)
- func (db *DB) UnitEventKeys(ctx context.Context, u unit.Unit, kind string) (map[string]time.Time, error)
- func (db *DB) UnitsOf(ctx context.Context, id task.ID) ([]unit.Unit, error)
- func (db *DB) Usage() usage.Store
- func (db *DB) Wakes() WakeStore
- func (db *DB) WorkflowActivity(ctx context.Context, since time.Time) (map[string]WorkflowActivity, error)
- func (db *DB) Worktrees() Worktrees
- func (db *DB) Write(ctx context.Context, fn func(tx *Tx) error) (port.Change, error)
- type DossierMove
- type Fetches
- type GateStore
- func (s GateStore) Applied(ctx context.Context, id int64) error
- func (s GateStore) Begin(ctx context.Context, id int64) error
- func (s GateStore) Begun(ctx context.Context) ([]gate.Gate, error)
- func (s GateStore) Due(ctx context.Context, now time.Time) ([]gate.Gate, error)
- func (s GateStore) End(ctx context.Context, id int64) error
- func (s GateStore) Get(ctx context.Context, id int64) (gate.Gate, error)
- func (s GateStore) OfTask(ctx context.Context, id task.ID) ([]gate.Gate, error)
- func (s GateStore) Open(ctx context.Context, g gate.Gate) (gate.Gate, error)
- func (s GateStore) RecordSent(ctx context.Context, g gate.Gate) (gate.Gate, error)
- func (s GateStore) Resolve(ctx context.Context, id int64, r gates.Resolution) (gate.Gate, error)
- func (s GateStore) Unapplied(ctx context.Context) ([]gate.Gate, error)
- func (s GateStore) Where(ctx context.Context, q gates.Query) ([]gate.Gate, error)
- type HeatReader
- type MigrateOptions
- type MigrationError
- type Noter
- type Plan
- type PropStore
- type Reader
- type Restored
- type Retained
- type Retention
- type Rounds
- func (r *Rounds) AgentHome(ctx context.Context, ref pr.Ref) (string, error)
- func (r *Rounds) Load(ctx context.Context) (*round.Store, error)
- func (r *Rounds) Pause(ctx context.Context) (round.Pause, error)
- func (r *Rounds) Save(ctx context.Context, st *round.Store) error
- func (r *Rounds) SetPause(ctx context.Context, p round.Pause) error
- type SchemaError
- type State
- type Status
- type Store
- func (s *Store) Applied(ctx context.Context, sink string) (map[view.Key]view.Applied, error)
- func (s *Store) BindHandle(ctx context.Context, id, manager, handle, runtime string, at time.Time) error
- func (s *Store) BookOf(ctx context.Context, k turns.Key) (turn.Book, bool, error)
- func (s *Store) Books(ctx context.Context, units ...unit.Unit) (map[unit.Unit]turn.Book, error)
- func (s *Store) EndHandle(ctx context.Context, id string, at time.Time) error
- func (s *Store) LastStops(ctx context.Context, sessions []string) (map[string]turn.Stop, error)
- func (s *Store) LogStop(ctx context.Context, st turn.Stop, evs ...port.Event) error
- func (s *Store) Open(ctx context.Context) ([]unit.Unit, error)
- func (s *Store) OpenTurns(ctx context.Context) (map[unit.Unit][]turn.Turn, error)
- func (s *Store) RecordEvents(ctx context.Context, evs ...port.Event) error
- func (s *Store) RecordSourceEvents(ctx context.Context, evs ...port.Event) error
- func (s *Store) Save(ctx context.Context, b turn.Book, evs ...port.Event) (turn.Book, error)
- func (s *Store) SaveApplied(ctx context.Context, sink string, a view.Applied, evs ...port.Event) error
- func (s *Store) SaveFailure(ctx context.Context, evs ...port.Event) error
- func (s *Store) SaveSession(ctx context.Context, ses turn.Session, evs ...port.Event) error
- func (s *Store) Session(ctx context.Context, id string) (turn.Session, bool, error)
- func (s *Store) SessionOf(ctx context.Context, manager, handle string) (string, bool, error)
- func (s *Store) SessionOfHandle(ctx context.Context, handle string) (id, manager string, ok bool, err error)
- func (s *Store) Sessions(ctx context.Context) ([]turn.Session, error)
- func (s *Store) TurnCounts(ctx context.Context, units []unit.Unit) (map[unit.Unit]int, error)
- func (s *Store) UnitEvents(ctx context.Context, units []unit.Unit, kinds []string, since time.Time) ([]port.Event, error)
- func (s *Store) UnitOfTurn(ctx context.Context, seq int64) (unit.Unit, bool, error)
- func (s *Store) UnitsOf(ctx context.Context, handles []string) (map[string]unit.Unit, error)
- func (s *Store) WithTurns(ctx context.Context, i turn.Intent) ([]unit.Unit, error)
- type Tx
- type WakeStore
- func (s WakeStore) All(ctx context.Context) ([]wake.Wake, error)
- func (s WakeStore) Drop(ctx context.Context, id task.ID) error
- func (s WakeStore) Due(ctx context.Context, now time.Time) ([]wake.Wake, error)
- func (s WakeStore) Of(ctx context.Context, id task.ID) (wake.Wake, bool, error)
- func (s WakeStore) Put(ctx context.Context, w wake.Wake) error
- func (s WakeStore) UnitWakes(ctx context.Context, units []unit.Unit) (map[unit.Unit]wake.Wake, error)
- func (s WakeStore) Watching(ctx context.Context) ([]wake.Wake, error)
- type WorkflowActivity
- type Worktrees
- func (w Worktrees) Drop(ctx context.Context, path string) error
- func (w Worktrees) Keep(ctx context.Context, c wsdomain.Custody) error
- func (w Worktrees) LinkUnit(ctx context.Context, path string, u unit.Unit) error
- func (w Worktrees) Worktree(ctx context.Context, path string) (wsdomain.Custody, bool, error)
- func (w Worktrees) Worktrees(ctx context.Context) ([]wsdomain.Custody, error)
Constants ¶
const ( SessionEventsKey = "session_events" ViewEventsKey = "view_events" )
The Retained keys of the events SessionEvents and ViewEvents drop.
const ( WorkflowEventsKey = "workflow_events" UnitlessLoopRowsKey = "unitless_loop_rows" )
The Retained keys of WorkflowEvents and UnitlessLoopRows; WorkflowRuns and PlanItems count under their tables.
const ( KindPaused = "paused" KindResumed = "resumed" )
The kinds of the event a pause or a resume leaves.
const DefaultKeep = 3
DefaultKeep is how many pre-migration backups stay.
const DefaultWarmFor = 72 * time.Hour
DefaultWarmFor is items.heat.warm_for when unset.
const PreRestoreDays = 30
PreRestoreDays is how long the copies Restore keeps of a replaced store stay.
const ReadConns = 4
ReadConns is the size of the read pool.
const SchemaVersion = 13
SchemaVersion is the PRAGMA user_version of a store this release creates and migrates to.
const TimeLayout = time.RFC3339Nano
Variables ¶
var DefaultRetention = Retention{ SessionEvents: retentionWindow, ViewEvents: retentionWindow, ClosedSessions: retentionWindow, Stops: turns.StopsKept, Instructions: retentionWindow, BriefBodies: 7 * 24 * time.Hour, EndedPRs: 400 * 24 * time.Hour, WorkflowRuns: retentionWindow, PlanItems: 7 * 24 * time.Hour, WorkflowEvents: retentionWindow, UnitlessLoopRows: retentionWindow, Classifications: retentionWindow, Fetches: retentionWindow, SubjectMarks: true, VacuumPages: 4096, }
DefaultRetention is what the daemon's retain job applies. ViewRows stays zero: the views re-plan a unit whose applied rows are gone, and every ended unit with a turn book is still planned.
var ErrDamaged = errors.New("the store is damaged")
ErrDamaged is a store that fails SQLite's integrity checks.
var ErrNoSpace = errors.New("not enough free space for the store's backup")
ErrNoSpace is too little free space for the backup a migration takes.
var ErrSchema = errors.New("the store is not at this release's schema version")
var ErrStoreBusy = errors.New("another process has the store open")
ErrStoreBusy is a store whose lock another process holds.
var SessionEventKinds = []string{ turns.KindSessionIdle, turns.KindSessionActive, turns.KindSessionStarted, turns.KindSessionLaunched, turns.KindSessionAbandoned, turns.KindSessionClosed, turns.KindMCPSeen, turns.KindReconcileReport, turns.KindSessionTyped, turns.KindSessionPrompted, turns.KindSessionUnit, omnibox.KindCall, }
SessionEventKinds are the bookkeeping kinds SessionEvents drops. Pause events and every event of a pull request are kept.
Functions ¶
func AdoptJobDrafts ¶ added in v0.2.0
AdoptJobDrafts rewrites every draft the proposals job proposed under its rules, in any state, to the identity of the default workflow that replaced the rule: rule and workflow stalled-nudge to slack-stalled-nudge, closure to slack-closure, ask-owner to slack-ask-owner, rule_key unchanged, so the workflow's hold and withdrawal see them; a draft not sent gets the workflow's effects.
func Check ¶
Check refuses a store at path that this release cannot open as it is, reading its file without opening it for writing. An absent or empty file passes: Open creates it.
func LockStore ¶ added in v0.2.0
LockStore takes, without waiting, the lock of the store at path that its writer holds: the daemon while it serves, and a command that migrates or restores the store. A held lock is ErrStoreBusy.
func Refuse ¶ added in v0.2.0
Refuse is the SchemaError of a store in s at path, nil when this release opens it.
func StoredUnit ¶
StoredUnit is the unit an event of u, kind and key is stored under: u, or the session unit of the key's handle for a handle-keyed kind with no unit. Every writer of events applies it.
Types ¶
type AgentSession ¶
type AgentSession struct {
ID, Kind, Handle, Home, Worktree, Transcript string
FirstSeen, LastSeen time.Time
}
AgentSession is what the hooks told of one agent session; a resume keeps the handle and starts another.
type AgentWorktree ¶
type AgentWorktree struct{ Home, Worktree string }
AgentWorktree is a worktree an agent session of the loop ran in, with the agent's home.
type Backup ¶ added in v0.2.0
type Backup struct {
Path string
Version uint32
Taken time.Time
// PreRestore is the store as it was before a restore replaced it.
PreRestore bool
Size int64
// contains filtered or unexported fields
}
Backup is a copy of the store in the backups directory.
func Backups ¶ added in v0.2.0
Backups lists the backups in dir, newest first; an absent dir has none.
func Restorable ¶ added in v0.2.0
Restorable is the newest backup in all, newest first as Backups lists them, that this release opens or migrates; pre-restore copies are left for an explicit choice.
type Classifications ¶
type Classifications struct {
// contains filtered or unexported fields
}
Classifications caches classify outputs by unit, workflow and the unit's fingerprint, and counts the calls of each local day for the daily cap. Its writes note nothing.
func (*Classifications) Output ¶
func (c *Classifications) Output(ctx context.Context, u unit.Unit, workflow, fingerprint string) (json.RawMessage, bool, error)
Output is the stored output of workflow for u at fingerprint.
func (*Classifications) Save ¶
func (c *Classifications) Save(ctx context.Context, u unit.Unit, workflow, fingerprint string, output json.RawMessage, at time.Time) error
Save stores output, a JSON value, replacing the one stored for the same unit, workflow and fingerprint.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is the store: one writer connection, reached only through Write, and a read-only pool of ReadConns connections.
func Open ¶
Open opens the store at path, creating it at SchemaVersion when it holds no table, and refuses with a SchemaError a store it cannot open as it is: an older one, which Migrate takes first, or a newer one that is not compatible. Both handles open through connector. A nil log gets a private change log.
func OpenReadOnly ¶
OpenReadOnly opens the store at path for reads only, for a process that is not the store's writer; it creates nothing and refuses a store at another version.
func (*DB) Activities ¶ added in v0.2.0
func (db *DB) Activities(ctx context.Context, provider unit.ProviderID) (map[unit.Unit]turn.Activity, error)
Activities reads the activity of every unit of provider that has any, in one statement: one aggregated part per table.
func (*DB) AgentTranscript ¶
func (db *DB) AgentTranscript(ctx context.Context, agentSession string) (path, kind string, err error)
AgentTranscript is the transcript file and agent the hooks stored for the agent session, "" for each when none is stored.
func (*DB) AgentWorktrees ¶
func (db *DB) AgentWorktrees(ctx context.Context) ([]AgentWorktree, error)
AgentWorktrees lists the distinct worktrees the loop's sessions ran in.
func (*DB) AllSkips ¶ added in v0.4.0
AllSkips are the skipped workflows by unit, each unit's sorted by name.
func (*DB) AutomatedTurns ¶ added in v0.2.0
func (db *DB) AutomatedTurns(ctx context.Context, from time.Time, except []unit.ProviderID) (int, error)
AutomatedTurns counts the automated turns sent since from on units of providers other than except's, withdrawn ones included: a turn a workflow started spends the day's budget whatever became of it.
func (*DB) CallSpent ¶ added in v0.4.0
CallSpent is the cost of the calls recorded in [from, to) as events of kinds, whose Data is the cost.
func (*DB) Classifications ¶
func (db *DB) Classifications() *Classifications
func (*DB) Close ¶
Close closes both handles and waits, up to closeWait, for the statements in flight to release their connections, so the store's files stop changing once it returns. Connections still open then are an error.
func (*DB) DeleteSkip ¶ added in v0.4.0
DeleteSkip forgets that workflow is skipped on u; deleting none is no error.
func (*DB) DossierMoved ¶ added in v0.3.0
DossierMoved forgets the dossier move seq, done on disk.
func (*DB) DossierMoves ¶ added in v0.3.0
func (db *DB) DossierMoves(ctx context.Context) ([]DossierMove, error)
DossierMoves are the dossier moves still to do on disk, in the order they apply.
func (*DB) Dossiers ¶
Dossiers is the dossiers table, whose dossier a unit's is, and whether a dossier's owner still has open work.
func (*DB) DraftEffects ¶ added in v0.2.0
func (db *DB) DraftEffects() outbox.AppliedStore
DraftEffects keeps when the effects of a sent draft were applied.
func (*DB) Events ¶
func (db *DB) Events() automation.Events
Events reads the events table by id for event workflows, and keeps each workflow's cursor and last firing. Advancing a cursor notes nothing.
func (*DB) EventsOf ¶ added in v0.3.0
func (db *DB) EventsOf(ctx context.Context, units []unit.Unit, f timeline.Filter) ([]timeline.Event, error)
EventsOf are the events of units f keeps, newest first by their row id.
func (*DB) EventsOfKinds ¶ added in v0.4.0
EventsOfKinds are every unit's events of kinds, oldest first, as Events().Since reads them.
func (*DB) HeadlessSpent ¶
HeadlessSpent is the cost in turn_usage of the headless turns started in [from, to).
func (*DB) ItemsHeld ¶ added in v0.3.0
ItemsHeld are the items of u each task holding u or one of its items holds; a task that holds u and none of its items maps to none.
func (*DB) Ledger ¶
func (db *DB) Ledger() automation.Ledger
Ledger is the workflows' plan and runs. A write stores its rows and its events in one transaction, noting TopicLoopEvents for the events and TopicPending only when the pending set changes and TopicPlan only when what the plan serves of an item changes.
func (*DB) LinkTargets ¶
LinkTargets are the units some link that can resolve an item points to, sorted by provider and key.
func (*DB) LinksFrom ¶ added in v0.4.0
LinksFrom are the links from any of units, sorted by From, then At.
func (*DB) MergedInto ¶ added in v0.4.0
MergedInto are the tasks merged into task id, transitively, in merge order: the old ids of the aliases that lead to id, hop by hop, that no stored task holds and whose newest merge record names the alias's new id.
func (*DB) Override ¶ added in v0.3.0
Override is u's host overrides by name, the unset ones absent.
func (*DB) Projects ¶
func (db *DB) Projects() coretasks.ProjectStore
Projects are the Review's runs; a project's own fields are read and written with its task.
func (*DB) PutRecord ¶ added in v0.3.0
func (db *DB) PutRecord(ctx context.Context, u unit.Unit, kind string, w task.Writer, data []byte, at time.Time) error
PutRecord keeps data as u's record of kind, written by w at at, in place of the one it kept: the new record takes the newest Seq.
func (*DB) PutUnitBrief ¶ added in v0.3.0
func (db *DB) PutUnitBrief(ctx context.Context, u unit.Unit, version, body string, at time.Time) error
PutUnitBrief keeps body, a brief's JSON a source plugin wrote of u at version, as the brief u uses: u's brief record, and u's plugin run of at's day, updated in place, or a new ok run.
func (*DB) R ¶
R is the read pool, for a read of one statement. Under a Snapshot's ctx it reads in that snapshot's transaction.
func (*DB) Read ¶
Read runs fn in one deferred read transaction on the pool, so every statement sees one snapshot; under a Snapshot's ctx it runs in that snapshot's transaction. fn must not write.
func (*DB) Records ¶ added in v0.3.0
func (db *DB) Records(ctx context.Context, kind string, units ...unit.Unit) (map[unit.Unit]port.Event, error)
Records are the record of kind each of units keeps; with no units, every unit's.
func (*DB) RehomeDrafts ¶ added in v0.3.0
RehomeDrafts moves the drafts of each unit of moves onto the unit it maps to, in one transaction, and counts them; a second call moves none.
func (*DB) Retain ¶
Retain applies p as of now in one write transaction, noting Change.All with the topics of the tables it changed, then runs incremental_vacuum and PRAGMA optimize outside it. EndedPRs runs first, so the rules after it see the sessions and runs only an ended pull request's turns held, and a second pass at the same now changes nothing and notes nothing.
func (*DB) SaveAgentSession ¶
func (db *DB) SaveAgentSession(ctx context.Context, a AgentSession) error
SaveAgentSession upserts a; an empty field never clears a stored one, and the seen times only widen.
func (*DB) SaveSkip ¶ added in v0.4.0
SaveSkip keeps that workflow is skipped on u; saving it again keeps the first time.
func (*DB) SetMarks ¶ added in v0.3.0
SetMarks sets u's marks by name in one transaction; a value "" removes one.
func (*DB) SetOverride ¶ added in v0.3.0
func (db *DB) SetOverride(ctx context.Context, u unit.Unit, set, ifMatch map[string]string) (written bool, err error)
SetOverride sets u's host overrides of set, in one transaction, only while each of ifMatch holds its value ("" for unset); a value "" clears one. Written is false when ifMatch did not hold.
func (*DB) Snapshot ¶
Snapshot pins one deferred read transaction to the returned ctx: every store read made with it inside fn, in sqlite and inventory, uses that transaction, so a multi-method load sees one commit.
func (*DB) TasksHolding ¶ added in v0.3.0
TasksHolding are the tasks that hold u, oldest first.
func (*DB) TasksRunByHand ¶ added in v0.4.0
func (db *DB) TasksRunByHand(ctx context.Context, kinds []string, ids ...task.ID) (map[task.ID]bool, error)
TasksRunByHand are, of ids, or of every task when ids is empty, the tasks on whose own unit an event of one of kinds was recorded by a person or an agent.
func (*DB) UnitEventKeys ¶
func (db *DB) UnitEventKeys(ctx context.Context, u unit.Unit, kind string) (map[string]time.Time, error)
UnitEventKeys maps the keys of u's events of kind to when each was recorded.
func (*DB) UnitsOf ¶ added in v0.3.0
UnitsOf are the units task id holds, in its order, then the own unit of every task merged into id, in merge order.
func (*DB) WorkflowActivity ¶
func (db *DB) WorkflowActivity(ctx context.Context, since time.Time) (map[string]WorkflowActivity, error)
WorkflowActivity is each workflow's newest done run and its step refusals since since, by workflow name.
func (*DB) Write ¶
Write runs fn in one write transaction under the store file's write lock, which every handle this process has open on it shares. After COMMIT, when fn touched anything, it notes the log (still under the lock, so log order is commit order) and returns that Change; otherwise the zero Change. An error from fn rolls back and notes nothing. A nested Write panics.
type DossierMove ¶ added in v0.3.0
DossierMove is a dossier directory a merge of tasks moved in the store and that waits to move on disk, from the path under the dossiers root to the path it goes to. Seq is the order the moves apply in.
type Fetches ¶
type Fetches struct {
// contains filtered or unexported fields
}
Fetches is when each workspace was last fetched. Its writes note nothing.
type GateStore ¶ added in v0.3.0
type GateStore struct {
// contains filtered or unexported fields
}
GateStore is the gates; now stamps OpenedAt and ClosedAt.
func (GateStore) Begin ¶ added in v0.3.0
Begin marks resolved gate id's consequence run, and begun until End.
func (GateStore) Begun ¶ added in v0.3.0
Begun are the resolved gates whose consequence began and never ended.
func (GateStore) Due ¶ added in v0.3.0
Due are the open gates whose Deadline is set and not after now.
func (GateStore) RecordSent ¶ added in v0.3.0
RecordSent stores g closed as approved, opened and closed now, its consequence applied: the tool posted it.
type HeatReader ¶
type HeatReader struct {
DB *DB
WarmFor func() time.Duration // nil or zero: DefaultWarmFor
Clock port.Clock
}
HeatReader reads port.Heat from the items ledger: active while a unit has an open item, warm for WarmFor after its last item resolved, cold otherwise.
type MigrateOptions ¶ added in v0.2.0
type MigrateOptions struct {
Backups string
Now func() time.Time
// Keep is how many backups taken before a migration stay; 0 keeps
// DefaultKeep.
Keep int
// Backup, when set, is the backup's path, as a Plan named it.
Backup string
// BackedUp, when set, runs once the store's backup is written, before
// any migration; its error stops Migrate with the store unchanged.
BackedUp func(backup string) error
// Step, when set, hears of each migration as it commits.
Step func(label string, took time.Duration)
// Warn, when set, hears of what failed after the migrations committed
// without undoing them, such as removing an old backup.
Warn func(error)
}
MigrateOptions are where Migrate keeps backups and what it reports.
type MigrationError ¶ added in v0.2.0
MigrationError is a migration that failed; the store stays at Reached.
func (*MigrationError) Error ¶ added in v0.2.0
func (e *MigrationError) Error() string
func (*MigrationError) Unwrap ¶ added in v0.2.0
func (e *MigrationError) Unwrap() error
type Noter ¶
type Noter interface {
Note(t port.Topic, units ...unit.Unit) port.Change
NoteAll(t port.Topic) port.Change
}
Noter is what Write notes into; *change.Log satisfies it.
type Plan ¶ added in v0.2.0
type Plan struct {
From, To uint32
// Steps are the migrations it runs, as 0002_name.
Steps []string
// Backup is the file it copies the store to first.
Backup string
// Size is the store's size with its WAL, and Free the bytes free where
// the backup goes, -1 when unknown.
Size, Free int64
// Compatible is the oldest version a release must be at to read the store once migrated.
Compatible uint32
}
Plan is what Migrate does to a store.
func Migrate ¶ added in v0.2.0
Migrate takes the store at path to SchemaVersion: it checks the store, copies it into o.Backups, runs each pending migration in its own transaction, checks the result and prunes old backups. The caller holds the store's lock (LockStore). A store with nothing pending is left alone.
func PlanMigration ¶ added in v0.2.0
PlanMigration is what Migrate would do to the store at path, with its backup in the directory backups; it changes nothing. A store this release cannot migrate is a SchemaError.
func (Plan) ReadableAfter ¶ added in v0.4.0
ReadableAfter says a release at the store's version now still reads it once migrated.
type PropStore ¶ added in v0.3.0
type PropStore struct {
// contains filtered or unexported fields
}
PropStore is the tasks' properties; now stamps each write.
func (PropStore) SetProp ¶ added in v0.3.0
func (s PropStore) SetProp(ctx context.Context, id task.ID, name string, v task.Value, w task.Writer) error
SetProp writes the property, or deletes it for a zero v, and moves the task to a new rev, so a page since an older one lists it again; a write that changes neither value nor writer moves nothing.
type Reader ¶
type Reader interface {
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}
Reader is what a single read statement needs. An Exec through the pool fails with SQLITE_READONLY.
type Restored ¶ added in v0.2.0
type Restored struct {
From Status
// Kept is the copy of the store Restore replaced; empty when there was
// none.
Kept string
}
Restored is what Restore did.
type Retained ¶
Retained counts the rows a pass deleted or compacted, per table; the events SessionEvents and ViewEvents drop count under their own keys, and "events" counts those of ended pull requests.
type Retention ¶
type Retention struct {
SessionEvents time.Duration // events of no unit or a session unit, of the kinds in SessionEventKinds
ViewEvents time.Duration // view_applied, view_override and view_sink_failed events
// ClosedSessions drops the sessions closed that long ago that no open
// turn names, and the agent sessions last seen that long ago whose turns
// all have their usage read.
// It also drops the workflow runs of session units that old whose
// session row is gone.
ClosedSessions time.Duration
Stops time.Duration // turn_stops
Instructions time.Duration // turn_instructions, then the parts no row lists
// BriefBodies empties brief and input of the runs started that long ago
// that no unit_briefs row or turn references.
BriefBodies time.Duration
ViewRows time.Duration // view_applied rows of pull requests merged or closed that long ago
EndedPRs time.Duration // a pull request merged or closed that long ago, with every row of it
// WorkflowRuns drops the done workflow runs that old. A dismissed run
// keeps its key terminal, so it goes only with its unit's rows.
WorkflowRuns time.Duration
PlanItems time.Duration // plan items not pending, last saved that long ago
WorkflowEvents time.Duration // the engine's events, workflow.EngineKinds
// UnitlessLoopRows drops the turns, records, answers, intakes, events,
// workflow runs and plan items of a github unit the GitHub plugin does
// not report, with no overrides row and nothing newer.
UnitlessLoopRows time.Duration
Classifications time.Duration // classifications and classify_days
Fetches time.Duration
// SubjectMarks drops the marks of tasks done, in the trash or gone,
// and of Slack units the Slack plugin does not report, with no item and
// no task.
SubjectMarks bool
VacuumPages int // PRAGMA incremental_vacuum(VacuumPages) after each pass; 0 runs none
}
Retention says how long each kind of row is kept. Zero keeps forever. Every event, turn, record, answer, plan item and brief of a task, or of a unit linked to a task, is kept forever: no rule reaches them.
type Rounds ¶
type Rounds struct {
// contains filtered or unexported fields
}
Rounds is the round state's repository.
func (*Rounds) AgentHome ¶
AgentHome is the agent home remembered for the pull request's rounds, empty when none is.
type SchemaError ¶ added in v0.2.0
SchemaError is a store at a version this release cannot open as it is.
func (SchemaError) Error ¶ added in v0.2.0
func (e SchemaError) Error() string
func (SchemaError) Is ¶ added in v0.2.0
func (e SchemaError) Is(target error) bool
func (SchemaError) State ¶ added in v0.2.0
func (e SchemaError) State() State
type State ¶ added in v0.2.0
type State int
State is how a store's version stands against this release.
const ( // StateCurrent is a store at SchemaVersion, or no store yet. StateCurrent State = iota // StateOlder is a store Migrate takes to SchemaVersion. StateOlder // StateReadable is a newer store whose changes this release can still use. StateReadable // StateNewer is a newer store this release must not open. StateNewer // StateUnknown is a store at no version a release writes. StateUnknown )
type Status ¶ added in v0.2.0
type Status struct {
Version uint32
// Compatible is the lowest version a release must read to use the store.
Compatible uint32
// Empty is an absent store, or one with no table yet.
Empty bool
}
Status is a store's schema version as read from its file.
func Inspect ¶ added in v0.2.0
Inspect reads the schema version of the store at path from its header; for a store newer than this release it also reads the compatible version, opening the store for reads.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the repository of the turns, the sessions and what the views applied. Every save writes its events in its own transaction.
func (*Store) BindHandle ¶
func (s *Store) BindHandle(ctx context.Context, id, manager, handle, runtime string, at time.Time) error
BindHandle makes handle the session's open handle from at, ending the one before; binding the open handle again changes nothing.
func (*Store) OpenTurns ¶ added in v0.4.0
OpenTurns are the open turns (sent, started or asked) of every unit, in ascending Seq, with their Seq, Intent, Trigger, State, Session and SentAt.
func (*Store) RecordEvents ¶
RecordEvents writes evs on their units in one transaction.
func (*Store) RecordSourceEvents ¶ added in v0.3.0
RecordSourceEvents stores the events a source plugin observed on its units: a keyed one at most once per unit, kind and key, an unkeyed one at most once per unit, kind and time, where the stored one gains the actor and the data it lacks. It notes TopicSourceEvents on the units it changed.
func (*Store) SaveApplied ¶
func (*Store) SaveFailure ¶
func (*Store) SaveSession ¶
SaveSession writes the session's row; its handles move only through BindHandle and EndHandle, so a save of a session read before its handle ended never opens it again. A save that closes the session notes TopicPlan, whose closed sessions it lists.
func (*Store) SessionOf ¶
SessionOf is the session whose process the manager addressed by handle, the newest one when the manager gave the handle out twice.
func (*Store) SessionOfHandle ¶
func (s *Store) SessionOfHandle(ctx context.Context, handle string) (id, manager string, ok bool, err error)
SessionOfHandle is SessionOf over every manager, for a caller that knows the handle alone; ok is false when no manager or more than one gave it out.
func (*Store) TurnCounts ¶ added in v0.3.0
TurnCounts counts the turns on each of units; a unit with none is absent.
func (*Store) UnitEvents ¶ added in v0.3.0
func (s *Store) UnitEvents(ctx context.Context, units []unit.Unit, kinds []string, since time.Time) ([]port.Event, error)
UnitEvents are the events of units of kinds, every kind when kinds is empty, at or after since, oldest first.
func (*Store) UnitOfTurn ¶ added in v0.3.0
UnitOfTurn is the unit whose book holds turn seq.
type Tx ¶
Tx is a write transaction that records what it changed.
func (*Tx) DropRecord ¶ added in v0.3.0
DropRecord forgets u's record of kind; dropped says it kept one.
func (*Tx) PutRecord ¶ added in v0.3.0
func (tx *Tx) PutRecord(ctx context.Context, u unit.Unit, kind, actor, data string, at time.Time) error
PutRecord is DB.PutRecord in tx.
type WakeStore ¶ added in v0.3.0
type WakeStore struct {
// contains filtered or unexported fields
}
WakeStore is the tasks' wakes.
func (WakeStore) Due ¶ added in v0.3.0
Due are the wakes whose until or expires is set and not after now.
type WorkflowActivity ¶
type WorkflowActivity struct {
LastRun time.Time // the newest done run; zero when none is stored
Refusals int // the step refusals since the time asked
}
WorkflowActivity is what one workflow did, as doctor reports it.
type Worktrees ¶
type Worktrees struct {
// contains filtered or unexported fields
}
Worktrees is the store of worktree custody.
func (Worktrees) Keep ¶
Keep records c's owner; a worktree already in custody keeps its creator and takes c's owner, workspace id and repository when set.
Source Files
¶
- activity.go
- agentsessions.go
- backup.go
- cards.go
- classify.go
- cursors.go
- db.go
- dossier_events.go
- dossier_moves.go
- dossiers.go
- drafts.go
- drafts_effects.go
- fetches.go
- gates.go
- heat.go
- intakes.go
- items.go
- ledger.go
- links.go
- marks.go
- merged.go
- merger.go
- meter.go
- migrate.go
- migrate_v13_revisions.go
- migrate_v4.go
- migrate_v4_adopt.go
- migrate_v4_briefs.go
- migrate_v4_drafts.go
- migrate_v4_roles.go
- migrate_v4_vocabulary.go
- migrate_v6_answers.go
- migrate_v7.go
- migrate_v7_anchors.go
- migrate_v7_applied.go
- migrate_v7_briefs.go
- migrate_v7_dossiers.go
- migrate_v7_gates.go
- migrate_v7_kinds.go
- migrate_v7_pluginstores.go
- migrate_v7_props.go
- migrate_v7_prtasks.go
- migrate_v7_rename.go
- migrate_v7_rounds.go
- migrate_v7_snapshots.go
- migrate_v7_wakes.go
- overrides.go
- plugin_host.go
- projects.go
- props.go
- records.go
- registry.go
- rekey.go
- retain.go
- retain_briefs.go
- rounds.go
- skips.go
- snapshots.go
- sqlite.go
- storelock_unix.go
- tasks.go
- turns.go
- turns_automated.go
- unit_briefs.go
- usage.go
- views.go
- wakes.go
- workflowactivity.go
- worktrees.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package sqlitetest seeds a store with raw SQL in tests.
|
Package sqlitetest seeds a store with raw SQL in tests. |