Documentation
¶
Overview ¶
Package store holds ingestion's SQLite store: every item, its sightings, its bytes' records, each stage's outputs and decisions, its deliveries, the task leases and the connector cursors.
The store is one writer connection beside a pool of readers. Each stage's tables come from an embedded schema file of its own in this directory, converged on every open. A stage adds a table in its file and declares it in Tables, and Open refuses a table that is in neither Tables nor unlogged. Every write runs through Update, which stamps it later than every write before it, so the outbox reads each table in commit order by stamp. Update also settles the phase of each item the write touched, on the item's row, so the outbox ships the phase that ItemRecords.Phase decides.
Index ¶
- Constants
- Variables
- func CheckMetrics(metrics map[string]int64) error
- func DecidedByModel(run string) string
- func DecidedByParent(key string) string
- func DecidedByPerson(login string) string
- func DecidedByRule(name string) string
- func DecidedByService(clientID string) string
- func DeleteCapability(source string) string
- func DeliverCapability(deliverer string) string
- func JoinUnits(units []Unit) (text string, starts []int)
- func ModelStages() []string
- func NewFlowID() string
- func NoteAnswered(answered, note *string) bool
- func NoteDigest(note *string) *string
- func PollCapability(source string) string
- func Precedes(step, later string) bool
- func PreferParse(extractor string)
- func ReadingParseScanned(outputs []Output) bool
- func RefreshMetricsCapability(source string) string
- func ScanRules(producerVersion string) string
- func ScanVersion(rules, extractor, extractorVersion string) string
- func Stamp(t time.Time) string
- type Blob
- type ChapterInBook
- type Claim
- type Condition
- type ConnectorCounts
- type Cursor
- type Decision
- type Declarations
- type Delivery
- type DeliveryAttempt
- type Finding
- type GateTrust
- type GateTrustDecision
- type Home
- type Item
- type ItemPage
- type ItemRecords
- func (r ItemRecords) Conditions() []Condition
- func (r ItemRecords) NewestDecision(gate string) (Decision, bool)
- func (r ItemRecords) NoUsableParse() bool
- func (r ItemRecords) Phase() string
- func (r ItemRecords) Progress() []StageProgress
- func (r ItemRecords) ReviewPlacement() (Decision, bool)
- func (r ItemRecords) Side() (string, bool)
- func (r ItemRecords) SideSettled() bool
- func (r ItemRecords) UnitCount(o Output) (int, bool)
- func (r ItemRecords) WaitingAt() string
- func (r ItemRecords) WaitsOnPerson() (reason, since string, ok bool)
- type KeyedRequest
- type Leased
- type Mark
- type Option
- type OutboxMark
- type Outcome
- type Output
- type Parse
- type ParsePick
- type ParseUnit
- type Presented
- type PromptProposal
- type Replay
- type ReplayQueue
- type RoutingRule
- type Row
- type Section
- type Sighting
- type SlotGroup
- type Span
- type StageProgress
- type StageRun
- type Store
- func (s *Store) AppliedDeclarations(ctx context.Context) (Declarations, bool, error)
- func (s *Store) Blob(ctx context.Context, sum string) (Blob, error)
- func (s *Store) Blobs(ctx context.Context) ([]Blob, error)
- func (s *Store) Claim(ctx context.Context, c Claim) ([]Leased, error)
- func (s *Store) Close() error
- func (s *Store) ConnectorCounts(ctx context.Context) (map[string]ConnectorCounts, error)
- func (s *Store) Cursor(ctx context.Context, connector string) (Cursor, bool, error)
- func (s *Store) Deliveries(ctx context.Context, key string) ([]Delivery, error)
- func (s *Store) DraftedItems(ctx context.Context) ([]ItemRecords, error)
- func (s *Store) GateTrusts(ctx context.Context) ([]GateTrust, error)
- func (s *Store) Heartbeat(ctx context.Context, id string, token int64, lease time.Duration) (Task, error)
- func (s *Store) Item(ctx context.Context, key string) (ItemRecords, error)
- func (s *Store) ItemRow(ctx context.Context, key string) (Item, bool, error)
- func (s *Store) ItemZones(ctx context.Context, keys []string) (map[string]Zone, error)
- func (s *Store) Items(ctx context.Context, page ItemPage) ([]ItemRecords, string, error)
- func (s *Store) ItemsWithNoSourceTime(ctx context.Context, mediaTypes []string, after string, limit int) ([]Item, error)
- func (s *Store) KeepOutboxMark(ctx context.Context, m OutboxMark, version string) error
- func (s *Store) KeyedRequest(ctx context.Context, caller, key string) (KeyedRequest, bool, error)
- func (s *Store) Leased(ctx context.Context, id string, token int64) (Task, error)
- func (s *Store) LiveHomes(ctx context.Context, sum string) ([]Home, error)
- func (s *Store) LiveHomesAt(ctx context.Context, root, pathSHA256 string) ([]Home, error)
- func (s *Store) MarksBetween(ctx context.Context, after, through string) ([]Mark, error)
- func (s *Store) NewestDonePromptProposal(ctx context.Context) (PromptProposal, bool, error)
- func (s *Store) NewestPromptProposal(ctx context.Context) (PromptProposal, bool, error)
- func (s *Store) NewestRefreshMetrics(ctx context.Context, source string) (Task, bool, error)
- func (s *Store) Now() time.Time
- func (s *Store) OutboxMarks(ctx context.Context) (map[string]OutboxMark, error)
- func (s *Store) Outputs(ctx context.Context, key string) ([]Output, error)
- func (s *Store) Parse(ctx context.Context, key string, pick ParsePick) (Parse, error)
- func (s *Store) Ping(ctx context.Context) error
- func (s *Store) PromptProposals(ctx context.Context) ([]PromptProposal, error)
- func (s *Store) Reader() *sql.DB
- func (s *Store) Replay(ctx context.Context, r Replay, queue ReplayQueue) (Replay, bool, error)
- func (s *Store) ReplayItems(ctx context.Context, r Replay, takes func(Item) bool) ([]Item, error)
- func (s *Store) Report(ctx context.Context, id string, token int64, outcome Outcome, ...) (Task, error)
- func (s *Store) RetryTask(ctx context.Context, id string) (Task, error)
- func (s *Store) ReviewPlacedItems(ctx context.Context) ([]ItemRecords, error)
- func (s *Store) ReviewQueue(ctx context.Context) ([]Waiting, error)
- func (s *Store) RoutingRules(ctx context.Context) ([]RoutingRule, error)
- func (s *Store) SettlePhases(ctx context.Context) (items, moved int, err error)
- func (s *Store) Sighted(ctx context.Context, key, connector string) (bool, error)
- func (s *Store) StageTokens(ctx context.Context, stage string, limit int) ([]Tokens, error)
- func (s *Store) Tasks(ctx context.Context, q TaskQuery) ([]Task, error)
- func (s *Store) Update(ctx context.Context, fn func(*Tx) error) error
- func (s *Store) Workers(ctx context.Context, since string) ([]Worker, int, error)
- type Table
- type Task
- type TaskQuery
- type Tokens
- type Tx
- func (t *Tx) AddDecision(ctx context.Context, d Decision) (Decision, error)
- func (t *Tx) AddGateTrustDecision(ctx context.Context, d GateTrustDecision) (GateTrustDecision, error)
- func (t *Tx) AddKeyedRequest(ctx context.Context, r KeyedRequest) error
- func (t *Tx) AddMark(ctx context.Context, m Mark) (Mark, error)
- func (t *Tx) AddPromptProposal(ctx context.Context, p PromptProposal) (PromptProposal, error)
- func (t *Tx) AddRoutingRule(ctx context.Context, r RoutingRule) (RoutingRule, error)
- func (t *Tx) AppliedDeclarations(ctx context.Context) (Declarations, bool, error)
- func (t *Tx) Blob(ctx context.Context, sum string) (Blob, bool, error)
- func (t *Tx) ChapterSection(ctx context.Context, key string) (Section, bool, error)
- func (t *Tx) Chapters(ctx context.Context, key string) ([]Item, error)
- func (t *Tx) Children(ctx context.Context, key string) ([]Item, error)
- func (t *Tx) Cursor(ctx context.Context, connector string) (Cursor, bool, error)
- func (t *Tx) Decisions(ctx context.Context, key string) ([]Decision, error)
- func (t *Tx) DeleteOutstanding(ctx context.Context, key, connector string) (bool, error)
- func (t *Tx) Deliveries(ctx context.Context, key string) ([]Delivery, error)
- func (t *Tx) Delivery(ctx context.Context, key, destination string) (Delivery, bool, error)
- func (t *Tx) DraftOutstanding(ctx context.Context) (Task, bool, error)
- func (t *Tx) Enqueue(ctx context.Context, task Task) (Task, error)
- func (t *Tx) GateTrust(ctx context.Context, family string) (GateTrust, bool, error)
- func (t *Tx) GateTrustDecisions(ctx context.Context, family string) ([]GateTrustDecision, error)
- func (t *Tx) GateTrusts(ctx context.Context) ([]GateTrust, error)
- func (t *Tx) HasTask(ctx context.Context, key, stage string) (bool, error)
- func (t *Tx) Item(ctx context.Context, key string) (Item, bool, error)
- func (t *Tx) KeepRun(ctx context.Context, task Task, o Output, units []Unit) error
- func (t *Tx) KeyedRequest(ctx context.Context, caller, key string) (KeyedRequest, bool, error)
- func (t *Tx) LiveHomes(ctx context.Context, sum string) ([]Home, error)
- func (t *Tx) LiveHomesAt(ctx context.Context, root, pathSHA256 string) ([]Home, error)
- func (t *Tx) LiveHomesUnder(ctx context.Context, root string) ([]Home, error)
- func (t *Tx) NewestDecision(ctx context.Context, key, gate string) (Decision, bool, error)
- func (t *Tx) NewestMark(ctx context.Context, key string) (Mark, bool, error)
- func (t *Tx) NewestPromptProposal(ctx context.Context) (PromptProposal, bool, error)
- func (t *Tx) NewestRoutingRule(ctx context.Context, name string) (RoutingRule, bool, error)
- func (t *Tx) Now() time.Time
- func (t *Tx) OpenTask(ctx context.Context, key, stage string) (Task, bool, error)
- func (t *Tx) Outputs(ctx context.Context, key string) ([]Output, error)
- func (t *Tx) Parse(ctx context.Context, key string, pick ParsePick) (Parse, error)
- func (t *Tx) PollInFlight(ctx context.Context, connector string) (Task, bool, error)
- func (t *Tx) PromptProposal(ctx context.Context, id string) (PromptProposal, bool, error)
- func (t *Tx) PutBlob(ctx context.Context, b Blob) error
- func (t *Tx) PutCursor(ctx context.Context, c Cursor) error
- func (t *Tx) PutDeclarations(ctx context.Context, d Declarations) error
- func (t *Tx) PutDelivery(ctx context.Context, d Delivery) error
- func (t *Tx) PutGateTrust(ctx context.Context, g GateTrust) error
- func (t *Tx) PutHome(ctx context.Context, h Home, gone bool) error
- func (t *Tx) PutItem(ctx context.Context, item Item) error
- func (t *Tx) PutOutput(ctx context.Context, o Output) error
- func (t *Tx) PutOutputWithUnits(ctx context.Context, o Output, units []Unit) error
- func (t *Tx) PutPromptProposal(ctx context.Context, p PromptProposal) error
- func (t *Tx) PutSections(ctx context.Context, sections []Section) (bool, error)
- func (t *Tx) PutSighting(ctx context.Context, s Sighting) error
- func (t *Tx) PutSightingMetrics(ctx context.Context, key, connector string, metrics map[string]int64) (bool, error)
- func (t *Tx) QueueDelivery(ctx context.Context, item Item, path *string, chapter *ChapterInBook, ...) (bool, error)
- func (t *Tx) RecordDelivery(ctx context.Context, task Task, a DeliveryAttempt) error
- func (t *Tx) Records(ctx context.Context, key string) (ItemRecords, error)
- func (t *Tx) RefreshMetricsOutstanding(ctx context.Context, source string) (Task, bool, error)
- func (t *Tx) ReleaseFirstFill(ctx context.Context, connector string) (int, error)
- func (tx *Tx) RetryTask(ctx context.Context, id string) (Task, error)
- func (t *Tx) ReviewKeysSightedBy(ctx context.Context, connectors []string, readSince string) ([]string, error)
- func (t *Tx) RoutingRules(ctx context.Context) ([]RoutingRule, error)
- func (t *Tx) RoutingRulesInForce(ctx context.Context) ([]RoutingRule, error)
- func (t *Tx) Sections(ctx context.Context, key string) ([]Section, error)
- func (t *Tx) Sighting(ctx context.Context, key, connector string) (Sighting, bool, error)
- func (t *Tx) Sightings(ctx context.Context, key string) ([]Sighting, error)
- func (t *Tx) UndeliveredChapterKeys(ctx context.Context) ([]string, error)
- func (t *Tx) UnplacedScannedKeys(ctx context.Context) ([]string, error)
- func (t *Tx) UnsettledKeysReadAs(ctx context.Context, verdict string) ([]string, error)
- func (t *Tx) WithdrawDeliveries(ctx context.Context, key, keep string) error
- func (t *Tx) WithdrawQueued(ctx context.Context, key, stage, why string) error
- type Unit
- type Waiting
- type Worker
- type Writes
- type Zone
Constants ¶
const ( ConditionTrue = "True" ConditionFalse = "False" ConditionUnknown = "Unknown" )
Condition statuses, as Kubernetes writes them.
const ( ProgressRunning = "running" ProgressDone = "done" ProgressFailed = "failed" )
The states of a StageProgress.
const ( StagePoll = "poll" StageLand = "land" StageParse = "parse" // StageStructure profiles a PDF's bytes: its outline, page labels, // creation date and fonts. StageStructure = "structure" // StageContents is a model's reading of the printed contents pages of a // PDF whose outline gives it no sections. StageContents = "contents" // StageSections is the write of an item's sections that serve makes from // its structure or its contents, which queues no task. StageSections = "sections" StageScan = "scan" StageQuality = "quality" // StageNote is a model's draft of the note that a model read answers, // where the read decision carries no person's note. StageNote = "note" StageModelRead = "model-read" StageDeliver = "deliver" )
Stages, in the order that an item passes them, after the poll that fetches it. A task or an output names one.
const ( GateQuality = "quality" GateSide = "side" GateRead = "read" )
Gates, each deciding by an appended decision.
const ( OutputWaiting = "waiting" OutputDone = "done" OutputFailed = "failed" // OutputDeferred is a parse whose extractor found no text of its own and // handed the item to another, such as a video with no caption track that // Whisper transcribes. The parse reads as Unknown until the other ends. OutputDeferred = "deferred" )
Output states for a stage's output.
const ( SortNewest = "newest" SortQuality = "quality" SortLikesPerView = "likes-per-view" SortLength = "length" SortFit = "fit" GroupByReason = "reason" GroupByConnector = "connector" GroupByChannel = "channel" GroupByVerdict = "verdict" GroupByNone = "none" )
The sorts and the groupings that a review card's Presented names, the first of each the review tab's default. schemas/ingestion-record.schema.json enumerates the same values, and a test holds the two equal.
const ( VerdictPass = "pass" VerdictDrop = "drop" VerdictReview = "review" )
Each verdict beside a side: the quality gate's pass, and either gate's drop and review. An item dropped on a destination that takes no side keeps its row.
const ( DecidedByTag = "tag" // DecidedByGate is the side gate itself, where no rung placed the item. DecidedByGate = "gate" )
Who decided, as decided_by spells it, beside the forms that the DecidedBy functions write.
const ( DeliveryPending = "pending" DeliveryDelivered = "delivered" DeliveryDeliveredToExisting = "delivered-to-existing" DeliveryRefused = "refused" )
Delivery outcomes.
const ( FirstFillNone = "none" FirstFillHeld = "held" FirstFillReleased = "released" )
A connector's first fill: none until an item reaches a model stage, held once one has, and released once a person lets the rest through.
const ( KeyedRouteDrops = "drops" KeyedRouteRuns = "runs" KeyedRoutePushes = "pushes" )
The keyed routes, as a KeyedRequest's Route names each. KeyedRoutes lists them, and the record schema's route enum holds the same names.
const ( ReasonNoParse = "no-parse" ReasonQualityReview = "quality-review" )
Why an item waits on a person where no side decision sent it to review, in the words of schemas/review-list.schema.json. Every other reason is the cause of the side decision that sent the item to review.
const ( RuleBlock = "block" RuleKeep = "keep" )
The actions of an accepted routing rule: a block drops each item that the rule matches, and a keep places it on the rule's destination.
const ( // SectionsFromOutline are sections read from a PDF's own outline, or one // section over the whole of a short PDF that has none. SectionsFromOutline = "outline" // SectionsFromContents are sections read from a book's printed contents // pages. SectionsFromContents = "contents" )
Producers of an item's sections.
const ( SectionPart = "part" SectionChapter = "chapter" SectionSection = "section" SectionFrontMatter = "front-matter" SectionBackMatter = "back-matter" )
Kinds of section.
const ( TaskQueued = "queued" TaskLeased = "leased" TaskDone = "done" TaskFailed = "failed" )
Task states.
const ( // LapsedClaimsFail is how many leases in a row may lapse with no report // accepted before the claim that finds the last fails its task rather than // return it to the next claim. A run that ends its worker, such as an // extractor killed for its memory, never reports, and would otherwise take // down a worker every lease. A task that reports a retry, such as a delete // waiting out its source's quota, starts the count again. LapsedClaimsFail = 3 // HeartbeatEvery is how often a worker's claims write its row, which is // how fresh a worker's last heartbeat reads. HeartbeatEvery = time.Minute )
const MediaTypeChapter = "application/x-book-chapter"
MediaTypeChapter is a book's chapter: a child item that holds no bytes of its own and takes its parent's side and read decisions.
const PhaseReview = "review"
PhaseReview is the phase of an item that waits on a person's placement.
const PlacedByPerson = "person"
PlacedByPerson is the placed_by of a replay that runs a stage only over the labeled items, each one that a person placed from review.
const SchemaGeneration = 3
SchemaGeneration is the generation of the schema files. Raise it with any change to them that rebuilds a table: a column made nullable, a CHECK changed, or a table constraint changed. A store keeps the highest generation that converged it in PRAGMA user_version. A build whose generation is older rebuilds none of its tables, so a release reverted after a later one converged the store keeps that release's columns and constraints.
const StageComments = "comments"
StageComments is a model's reading of what a video's top comments say about it, which a person asks for on one review card. It sits on no item's line, so its tasks and outputs move no item's phase, decision or delivery.
const StageDelete = "delete"
StageDelete removes a landed item from its connector's source, such as a save from the playlist it was captured in, where the connector declares after_landing delete. It sits on no item's line, so its tasks move no item's phase.
const StagePromptProposal = "prompt-proposal"
StagePromptProposal drafts a change to a model stage's prompt from the quality gate's misses against a person's word. Its task names a prompt proposal and no item, so it sits on no item's line.
const StageQualityArm = "quality-arm"
StageQualityArm is the quality gate's prompt answered by a model that its task names, as a measurement against each label beside the gate's own answer. It sits on no item's line, so its tasks and outputs move no item's phase, decision or delivery.
const StageRefreshMetrics = "refresh-metrics"
StageRefreshMetrics reads again, at a source, the metrics of each item that the source's connectors sighted and that waits in review, and writes them onto those sightings. Its task names its source rather than an item, so it sits on no item's line and moves no item's phase.
const StampLayout = "2006-01-02T15:04:05.000Z"
StampLayout is how every table writes an instant: RFC 3339 in UTC at a fixed width, so the text sorts as it reads.
Variables ¶
var ( PresentedSorts = []string{SortNewest, SortQuality, SortLikesPerView, SortLength, SortFit} PresentedGroupings = []string{GroupByReason, GroupByConnector, GroupByChannel, GroupByVerdict, GroupByNone} )
var ( // ErrNoTask is a call naming a task the store does not hold. ErrNoTask = errors.New("no such task") // ErrStaleLease is a heartbeat or report under a token that does not hold // the task's lease: a later claim took the lapsed lease, or the task ended. ErrStaleLease = errors.New("the task's lease is not held under this token") )
var ErrBadCursor = errors.New("not a cursor this list wrote")
ErrBadCursor refuses a page cursor that Items did not write.
var ErrInvalidMetric = errors.New("a metric is named in lowercase letters, digits and underscores, from a letter")
ErrInvalidMetric is a metric whose name metricName refuses.
var ErrNoBlob = errors.New("no such blob")
ErrNoBlob is a read naming bytes with no blob row.
var ErrNoCursor = errors.New("no cursor for the connector")
ErrNoCursor names a connector with no cursor, because no applied set declared it.
var ErrNoItem = errors.New("no such item")
ErrNoItem is a write or read naming an item the store does not hold.
var ErrNoParse = errors.New("no done parse")
ErrNoParse is a read of an item that holds no done parse to match it.
var ErrNoSighting = errors.New("the connector sighted no item")
ErrNoSighting is a replay naming a connector that sighted no item.
var ErrReplayDiffers = errors.New("the replay's id names a replay of another stage or other items")
ErrReplayDiffers is a replay whose id names one already recorded with another stage, connector, key or placed_by.
var ErrRunWithoutSubject = errors.New("the task names no item or prompt proposal to keep a run on")
ErrRunWithoutSubject is a run reported for a task that names no item and no prompt proposal, such as a poll's.
var ErrTaskDone = errors.New("the task ended done")
ErrTaskDone is a retry of a task that ended done, which a replay runs again instead.
var ErrTaskSuperseded = errors.New("a later prompt proposal reads its misses")
ErrTaskSuperseded is a retry of a failed draft whose misses a later prompt proposal reads, so a retry would draft them twice.
var ErrUnitsOutOfOrder = errors.New("a parse's units are numbered from 1 in their order")
ErrUnitsOutOfOrder is a parse whose units are not numbered 1, 2, 3 in order.
var ErrUnitsOutsideParse = errors.New("only a parse holds units")
ErrUnitsOutsideParse is a stage other than parse reporting units.
var KeyedRoutes = []string{KeyedRouteDrops, KeyedRouteRuns, KeyedRoutePushes}
KeyedRoutes is every keyed route's name.
var ReadAwaitsNote = func(Decision, []Output) bool { return true }
ReadAwaitsNote says whether a read decision waits on the note stage's draft, given the item's outputs. The read gate sets it from its own rule, so the phase and the gate never disagree on it. Unset, every read waits.
var Tables = []Table{ { Name: "items", Key: []string{"key"}, Stamp: []string{"updated_ts"}, Text: []string{"title", "url"}, Kept: []string{"created_ts", "flow_id", "parent_flow_id"}, Writes: Upserts, }, { Name: "sightings", Key: []string{"item_key", "connector"}, Stamp: []string{"written_ts", "last_seen_ts"}, JSON: []string{"tags", "fields", "metrics"}, Text: []string{"external_key", "fields"}, Kept: []string{"first_seen_ts"}, Writes: Upserts, }, {Name: "blobs", Key: []string{"sha256"}, Stamp: []string{"created_ts"}, Writes: Appends}, { Name: "homes", Key: []string{"blob_sha256", "root", "path_sha256"}, Stamp: []string{"gone_ts", "found_ts"}, Text: []string{"path"}, Writes: Upserts, }, { Name: "outputs", Key: []string{"item_key", "stage", "producer", "producer_version"}, Stamp: []string{"updated_ts"}, JSON: []string{"tokens", "findings", "units", "spans", "answer"}, Text: []string{"text", "units", "spans", "answer", "error"}, Kept: []string{"created_ts"}, Writes: Upserts, }, { Name: "parse_units", Key: []string{"item_key", "extractor", "extractor_version", "n"}, Stamp: []string{"created_ts"}, Text: []string{"label", "text"}, Writes: Appends, }, { Name: "sections", Key: []string{"item_key", "producer", "producer_version", "n"}, Stamp: []string{"created_ts"}, Text: []string{"title"}, Writes: Appends, }, {Name: "replays", Key: []string{"id"}, Stamp: []string{"requested_ts"}, Writes: Appends}, {Name: "decisions", Key: []string{"item_key", "gate", "sequence"}, Stamp: []string{"decided_ts"}, JSON: []string{"presented"}, Writes: Appends}, { Name: "deliveries", Key: []string{"item_key", "destination"}, Stamp: []string{"updated_ts"}, Text: []string{"last_error", "title", "url", "path"}, Writes: Upserts, }, { Name: "tasks", Key: []string{"id"}, Stamp: []string{"updated_ts"}, Text: []string{"error"}, Kept: []string{"created_ts"}, Writes: Upserts, }, { Name: "workers", Key: []string{"id"}, Stamp: []string{"heartbeat_ts"}, JSON: []string{"capabilities"}, Kept: []string{"started_ts"}, Writes: Upserts, }, { Name: "cursors", Key: []string{"connector"}, Stamp: []string{"updated_ts"}, Text: []string{"position", "last_error"}, Kept: []string{"created_ts"}, Writes: Upserts, }, { Name: "declarations", Key: []string{"commit"}, Stamp: []string{"applied_ts"}, JSON: []string{"connectors", "routing_rules", "destinations"}, Writes: Upserts, }, { Name: "keyed_requests", Key: []string{"caller", "idempotency_key"}, Stamp: []string{"created_ts"}, JSON: []string{"answer"}, Writes: Appends, }, {Name: "marks", Key: []string{"item_key", "sequence"}, Stamp: []string{"marked_ts"}, JSON: []string{"families"}, Writes: Appends}, { Name: "gate_trust", Key: []string{"family"}, Stamp: []string{"updated_ts"}, Bool: []string{"asks_promotion"}, Kept: []string{"created_ts"}, Writes: Upserts, }, { Name: "gate_trust_decisions", Key: []string{"family", "sequence"}, Stamp: []string{"decided_ts"}, Bool: []string{"promoted"}, Writes: Appends, }, { Name: "prompt_proposals", Key: []string{"id"}, Stamp: []string{"updated_ts"}, JSON: []string{"misses", "tokens", "answer"}, Kept: []string{"created_ts"}, Writes: Upserts, }, { Name: "routing_rules", Key: []string{"name", "sequence"}, Stamp: []string{"decided_ts"}, JSON: []string{"match_values"}, Bool: []string{"retired"}, Text: []string{"match_values"}, Writes: Appends, }, }
Tables is every table the outbox ships. A stage adding a table adds it here, beside its schema file.
Functions ¶
func CheckMetrics ¶ added in v0.30.0
CheckMetrics refuses a metric in metrics whose name is not a metric's, with ErrInvalidMetric.
func DecidedByModel ¶ added in v0.27.0
DecidedByModel is a model's decision, under the run that answered.
func DecidedByParent ¶ added in v0.27.0
DecidedByParent is a decision that an item took from its parent, under the parent's key.
func DecidedByPerson ¶ added in v0.27.0
DecidedByPerson is a person's decision, under their login.
func DecidedByRule ¶ added in v0.27.0
DecidedByRule is a routing rule's decision, under its name.
func DecidedByService ¶ added in v0.27.0
DecidedByService is a service's word, under its client id, where the service names no person.
func DeleteCapability ¶ added in v0.24.0
DeleteCapability is the capability of a delete from source, so a worker claims only the deletes of the sources whose deleter it opened.
func DeliverCapability ¶
DeliverCapability is the capability of a deliver task that deliverer runs, so a worker claims only the tasks of the deliverers it holds.
func JoinUnits ¶
JoinUnits joins units' text in order by a blank line, and answers where each unit's text starts in the joined text.
func ModelStages ¶ added in v0.21.0
func ModelStages() []string
ModelStages are the stages that read an item with a model.
func NoteAnswered ¶
NoteAnswered says whether an output that answered the note under answered, a NoteDigest, answers note. An output answers a decision that carries no note whatever note it answered, so only a new note reads an item again.
func NoteDigest ¶
NoteDigest is the hex SHA-256 of a read decision's note, trimmed, and nil where the note is empty.
func PollCapability ¶ added in v0.24.0
PollCapability is the capability of a poll of a source's connector, so a worker claims only the polls of the sources it reads.
func PreferParse ¶ added in v0.22.0
func PreferParse(extractor string)
PreferParse registers extractor as preferred: an item's readers take its done parse over any other extractor's, whichever was written later. An extractor that reads a selected item better than its primary one registers so, from its package's init. Every reader of a parse, from the scan to the item's parse route, then reads the same one, and a newer parse by the primary extractor never takes its place.
func ReadingParseScanned ¶ added in v0.22.0
ReadingParseScanned says whether outputs, oldest first as Tx.Outputs reads them, hold a done scan of the item's reading parse: its newest done parse by a preferred extractor where it holds one, and its newest done parse otherwise. The side gate places an item only then, so no item is placed before the scan of the parse that its readers read.
func RefreshMetricsCapability ¶ added in v0.30.0
RefreshMetricsCapability is the capability of a refresh of a source's metrics, so a worker claims only the refreshes of the sources whose refresher it opened.
func ScanVersion ¶
ScanVersion is the producer version of a scan by rules that read the parse extractor wrote at extractorVersion. The parse is part of it, so a scan of each parse keeps its own row beside the parse it read.
Types ¶
type Blob ¶
type Blob struct {
SHA256 string `json:"sha256"`
MD5 string `json:"md5"`
SizeBytes int64 `json:"size_bytes"`
MediaType string `json:"media_type"`
CreatedTS string `json:"created_ts"`
}
Blob is landed bytes, written once.
type ChapterInBook ¶ added in v0.23.0
type ChapterInBook struct {
BookDestinationID string `json:"book_destination_id"`
PDFPageStart int `json:"pdf_page_start"`
PDFPageEnd int `json:"pdf_page_end"`
PrintedPageStart *string `json:"printed_page_start"`
PrintedPageEnd *string `json:"printed_page_end"`
}
ChapterInBook is where a book's chapter sits in its destination: the destination's id for its book's record, from the book's settled delivery, and the chapter's pages in the book, from the newest sections that name it. A deliver task carries it whole, as its delivery first kept it.
type Claim ¶
type Claim struct {
Worker Worker
// Max bounds how many tasks the claim leases.
Max int
// MaxByCapability bounds how many tasks of each capability it names the
// claim leases, within Max. A capability that it does not name is bound
// by Max alone.
MaxByCapability map[string]int
// SlotGroups bound how many tasks the claim leases of each group's
// capabilities together, within Max, such as two heavy parses that the
// worker's memory holds only one of. A capability sits in one group at
// most, and a grouped one takes its group's bound in place of its own.
SlotGroups map[string]SlotGroup
Lease time.Duration
// Admit, where it is not nil, runs before the claim leases each task. It
// answers why nobody should run the task now, and "" otherwise. Such a
// task may be a poll of a connector that the set in force lacks, or a
// refresh with no item left to read. When it answers a reason, the claim
// ends the task done with that reason as its error, and leases it to
// nobody.
Admit func(ctx context.Context, tx *Tx, task Task) (string, error)
// Lapsed, where it is not nil, runs in the claim's write whenever the
// claim fails a task because its leases lapsed. It gets the reason that
// the task keeps.
Lapsed func(ctx context.Context, tx *Tx, task Task, reason string) error
}
Claim is a worker asking for work.
type Condition ¶
type Condition struct {
// Type is a stage or a gate.
Type string `json:"type"`
Status string `json:"status"`
// Reason is a decision's verdict, an output's or a delivery's state.
Reason string `json:"reason"`
}
Condition is how far one stage or gate has gone with an item.
type ConnectorCounts ¶
type ConnectorCounts struct {
Items int
Waiting int
Review int
Failed int
// Held counts the items whose model stage the connector's own first fill
// holds.
Held int
}
ConnectorCounts counts the items each connector sighted: all of them, and those that wait at a model stage, wait on a person's placement, or failed.
type Cursor ¶
type Cursor struct {
Connector string `json:"connector"`
Position *string `json:"position"`
DueAt string `json:"due_at"`
// StaleAt is written by the connectors package, which holds the freshness.
StaleAt *string `json:"stale_at"`
LastRunTS *string `json:"last_run_ts"`
LastDeliveryTS *string `json:"last_delivery_ts"`
LastError *string `json:"last_error"`
LastErrorTS *string `json:"last_error_ts"`
Failures int `json:"failures"`
FirstFill string `json:"first_fill"`
FirstFillItemKey *string `json:"first_fill_item_key"`
// FinishedTS is when a connector scheduled once ran a poll that ended
// done, after which it never runs again, and nil until then.
FinishedTS *string `json:"finished_ts"`
CreatedTS string `json:"created_ts"`
UpdatedTS string `json:"updated_ts"`
}
Cursor is one connector's position and when it is next due.
type Decision ¶
type Decision struct {
ItemKey string `json:"item_key"`
Gate string `json:"gate"`
Sequence int `json:"sequence"`
Verdict string `json:"verdict"`
DecidedBy string `json:"decided_by"`
Confidence *float64 `json:"confidence"`
Cause string `json:"cause"`
Destination *string `json:"destination"`
Note *string `json:"note"`
// Lens is set on a read decision whose verdict is model.
Lens *string `json:"lens"`
ClientID *string `json:"client_id"`
// Presented is the card as the person saw it when they decided, and
// DecidedAfterMS how long after it was drawn they decided. Both are nil
// on a decision that no card preceded, such as a rule's or a command's.
Presented *Presented `json:"presented"`
DecidedAfterMS *int64 `json:"decided_after_ms"`
DecidedTS string `json:"decided_ts"`
}
Decision is one gate's decision on one item. The newest at a gate decides.
func ReviewBefore ¶ added in v0.28.0
ReviewBefore is the review among decisions that sent the item to the person who made placement: the newest side review before it, else the newest quality review before it, and false where neither came before it.
func ReviewPlacement ¶
ReviewPlacement is the label among decisions, one item's at every gate: the newest side decision, where a person made it after the gates sent the item to review. The gates sent it there where an earlier side decision was a review, or where the quality gate's review came before the placement. A placement that no review came before labels nothing, as one made before the gates ran, or one carried over from a judgment made elsewhere.
func (Decision) ByParent ¶ added in v0.20.0
ByParent says whether the item took d from its parent, as its decided_by parent:<key> records.
func (Decision) ByPerson ¶
ByPerson says whether a person made d, as its decided_by person:<login> records.
func (Decision) ModelRun ¶ added in v0.27.0
ModelRun is the run that answered d, where a model made it, as its decided_by model:<run> records.
func (Decision) Provisional ¶ added in v0.27.0
Provisional says whether a side decision waits on a later input: a review that the side gate wrote for want of a rule or a guess, or for an error, and a model's review or drop. A rule that a later set adds, or a later answer of the quality gate, then decides the item again. Every other side decision, by a tag, a rule, a person, a parent or a model's confident guess, is settled, and no later answer of the quality gate moves it.
type Declarations ¶
type Declarations struct {
Commit string `json:"commit"`
AppliedTS string `json:"applied_ts"`
AppliedBy string `json:"applied_by"`
Connectors []json.RawMessage `json:"connectors"`
RoutingRules []json.RawMessage `json:"routing_rules"`
Destinations []json.RawMessage `json:"destinations"`
}
Declarations is one applied set of connectors, routing rules and destinations, each declaration as its JSON.
type Delivery ¶
type Delivery struct {
ItemKey string `json:"item_key"`
Destination string `json:"destination"`
DestinationID *string `json:"destination_id"`
Outcome string `json:"outcome"`
Attempts int `json:"attempts"`
LastError *string `json:"last_error"`
// Title, URL and SourceTS are the item's when the delivery was first
// queued, which every attempt sends. So is Path, for a deliverer that
// writes an item by its file: its live home's path below the root that
// the deliverer's config names. It is nil for every other deliverer.
Title *string `json:"title"`
URL *string `json:"url"`
SourceTS *string `json:"source_ts"`
Path *string `json:"path"`
// BookDestinationID and the pages are a book's chapter's, kept the same
// way from its ChapterInBook, and nil for every other item.
BookDestinationID *string `json:"book_destination_id"`
PDFPageStart *int `json:"pdf_page_start"`
PDFPageEnd *int `json:"pdf_page_end"`
PrintedPageStart *string `json:"printed_page_start"`
PrintedPageEnd *string `json:"printed_page_end"`
UpdatedTS string `json:"updated_ts"`
}
Delivery is one item's delivery to one destination.
func (Delivery) Chapter ¶ added in v0.23.0
func (d Delivery) Chapter() *ChapterInBook
Chapter is where the delivery's chapter sits in its book's record, as the delivery first kept it, and nil where the delivery is no chapter's.
type DeliveryAttempt ¶
DeliveryAttempt is how one run of a deliver task ended: the outcome, the destination's own id for the record that holds the item, and the destination's answer where it is pending or refused.
type Finding ¶
type Finding struct {
Rule string `json:"rule"`
Severity string `json:"severity"`
Unit *int `json:"unit"`
Offset int `json:"offset"`
Length int `json:"length"`
}
Finding is one scanner rule's match, without its span: where it starts and how many bytes it covers. Unit names the parse's unit it starts in, and its offset counts from that unit's start. A finding from Scanner.Scan names no unit.
type GateTrust ¶ added in v0.27.0
type GateTrust struct {
Family string `json:"family"`
Connector string `json:"connector"`
PromptVersion string `json:"prompt_version"`
// Model and Effort are what answered under the family, as the family's
// name holds them.
Model string `json:"model"`
Effort string `json:"effort"`
Rung int `json:"rung"`
Run int `json:"run"`
StraightRun int `json:"straight_run"`
Threshold int `json:"threshold"`
AsksPromotion bool `json:"asks_promotion"`
// PromotedBy is person:<login> once a person said yes, and nil before.
PromotedBy *string `json:"promoted_by"`
PromotedClientID *string `json:"promoted_client_id"`
PromotedTS *string `json:"promoted_ts"`
// LastChange names what moved the row last, and LastItemKey the item it
// moved on, where one did.
LastChange string `json:"last_change"`
LastItemKey *string `json:"last_item_key"`
CreatedTS string `json:"created_ts"`
UpdatedTS string `json:"updated_ts"`
}
GateTrust is one family's standing on the trust ladder, as gate_trust holds it.
type GateTrustDecision ¶ added in v0.27.0
type GateTrustDecision struct {
Family string `json:"family"`
// Model and Effort are the family's, so a reader filters by them without
// parsing its name.
Model string `json:"model"`
Effort string `json:"effort"`
Sequence int `json:"sequence"`
ItemKey string `json:"item_key"`
// Kind is mark or placement.
Kind string `json:"kind"`
// Agreement is agreed or disagreed, as the word read against the gate's
// answer that GateDecidedBy names.
Agreement string `json:"agreement"`
// Promoted says whether the family was promoted when the gate answered
// the item.
Promoted bool `json:"promoted"`
DecidedBy string `json:"decided_by"`
ClientID *string `json:"client_id"`
GateDecidedBy string `json:"gate_decided_by"`
DecidedTS string `json:"decided_ts"`
}
GateTrustDecision is one person's word that counts on a family's ladder, as gate_trust_decisions holds it.
type Home ¶
type Home struct {
BlobSHA256 string `json:"blob_sha256"`
Root string `json:"root"`
PathSHA256 string `json:"path_sha256"`
Path string `json:"path"`
// ModifiedTS is the file's modification time, to the nanosecond, when its
// bytes were last hashed at Path. A file whose size or modification time
// differs is hashed again before it is read as the blob.
ModifiedTS *string `json:"modified_ts"`
FoundTS string `json:"found_ts"`
GoneTS *string `json:"gone_ts"`
}
Home names where a file already lives, under a named root.
type Item ¶
type Item struct {
Key string `json:"key"`
MediaType string `json:"media_type"`
Zone Zone `json:"zone"`
BlobSHA256 *string `json:"blob_sha256"`
ParentKey *string `json:"parent_key"`
FlowID string `json:"flow_id"`
ParentFlowID *string `json:"parent_flow_id"`
Title *string `json:"title"`
URL *string `json:"url"`
// SourceTS is when the artifact was made at its source, such as a Reddit
// post's creation, as a store stamp, and nil where the source gives none.
SourceTS *string `json:"source_ts"`
// Phase is what the write's settle decides before it commits, replacing
// any value that a put carried. A put of an item with no phase leaves the
// column as it was.
Phase *string `json:"phase,omitempty"`
CreatedTS string `json:"created_ts"`
UpdatedTS string `json:"updated_ts"`
}
Item is one artifact.
func (Item) PlacedThroughParent ¶ added in v0.20.0
PlacedThroughParent says whether the item takes every side and read decision from its parent, as a book's chapter does. A person places its parent instead, so neither the review queue nor a placement takes it.
type ItemPage ¶
ItemPage asks for up to Limit items, newest first, after the item that the cursor After names.
type ItemRecords ¶
type ItemRecords struct {
Item Item
// Blob is the row of the item's bytes, and nil where it holds none.
Blob *Blob
Homes []Home
Sightings []Sighting
Outputs []Output
Decisions []Decision
Deliveries []Delivery
Tasks []Task
// Sections are the item's sections, each producer version's in order.
Sections []Section
// contains filtered or unexported fields
}
ItemRecords is one item with every stage record written about it.
func (ItemRecords) Conditions ¶
func (r ItemRecords) Conditions() []Condition
Conditions derives each stage's and gate's condition from which records exist, as Kubernetes derives a pod's status from its conditions. A stage with no record is left out. So an item that a tag, a rule or a person settled before a gate read it shows no gate at all rather than one that failed.
func (ItemRecords) NewestDecision ¶
func (r ItemRecords) NewestDecision(gate string) (Decision, bool)
NewestDecision is the item's newest decision at gate, and false where none is.
func (ItemRecords) NoUsableParse ¶
func (r ItemRecords) NoUsableParse() bool
NoUsableParse says whether the item's parse failed and no parse is done, so it waits in review rather than passing a gate on empty text.
func (ItemRecords) Phase ¶
func (r ItemRecords) Phase() string
Phase is the item's phase in the words of schemas/items-list.schema.json: dropped where the newest side decision drops it, review where WaitsOnPerson says it waits, failed where another stage on the line holds a newest task that failed, dropped where the quality gate drops it before any side decision, waiting where a model stage holds it, and otherwise the furthest stage whose condition is True. A person can place an item whose parse or quality gate failed, which moves it on from that stage. A failed stage of besideScan fails no phase, and neither does a failed note where the newest read decision waits on no draft.
func (ItemRecords) Progress ¶ added in v0.31.0
func (r ItemRecords) Progress() []StageProgress
Progress is the parse's and the scan's progress. A stage that a retry queued again reads running whatever its last output was, and one whose task failed with no output reads failed. A stage with no task and no output is left out, since nothing queued it.
func (ItemRecords) ReviewPlacement ¶
func (r ItemRecords) ReviewPlacement() (Decision, bool)
ReviewPlacement is the item's label, as ReviewPlacement decides it from the item's decisions.
func (ItemRecords) Side ¶
func (r ItemRecords) Side() (string, bool)
Side is the newest side decision's verdict where it placed the item on a side, and false where none has.
func (ItemRecords) SideSettled ¶ added in v0.27.0
func (r ItemRecords) SideSettled() bool
SideSettled says whether the item's newest side decision is one that no later answer of the quality gate moves, as Decision.Provisional decides it. The gate answers such an item too, and its run holds and fails nothing.
func (ItemRecords) UnitCount ¶
func (r ItemRecords) UnitCount(o Output) (int, bool)
UnitCount counts the units of the parse o, and is false where o is no parse.
func (ItemRecords) WaitingAt ¶
func (r ItemRecords) WaitingAt() string
WaitingAt is the model stage that holds the item, and "" where none does.
func (ItemRecords) WaitsOnPerson ¶
func (r ItemRecords) WaitsOnPerson() (reason, since string, ok bool)
WaitsOnPerson says why the item waits on a person's placement, and since when. It is the one answer that Phase, the review queue and each connector's count read. A chapter whose book waits in review waits too, on the book's placement. An item waits where its newest side decision sent it to review, under that decision's cause. It waits too where that decision placed it on a side and its newest read decision sent it to review, as a note's draft below its floor does, under the read decision's cause. Where no side decision holds it, the item waits as no-parse where no parse is usable, and as quality-review where the quality gate's newest decision sent it there. It is false where the item waits on nobody.
type KeyedRequest ¶
type KeyedRequest struct {
Caller string `json:"caller"`
IdempotencyKey string `json:"idempotency_key"`
Route string `json:"route"`
Connector *string `json:"connector"`
Fingerprint string `json:"fingerprint"`
Status int `json:"status"`
Answer json.RawMessage `json:"answer"`
CreatedTS string `json:"created_ts"`
}
KeyedRequest is one request a caller sent under an Idempotency-Key, and what it answered.
type Leased ¶
type Leased struct {
Task
Item Item
Delivery *Delivery
Outputs []Output
Read *Decision
Draft *Output
Cursor *Cursor
Sighting *Sighting
Proposal *PromptProposal
}
Leased is a leased task with its item's row, so a worker runs the task holding no scope to read items. A poll task has no item, so its Item is empty. A deliver task carries its delivery's row too, whose title, URL and source time every attempt sends. A model stage's task carries the item's outputs at its stage, so a task whose run is already dispatched reads that run rather than starting another. A model read's task carries the item's newest read decision, whose lens and note the read answers, and the item's newest done note draft, which the read answers where the decision took it. A note task carries the newest read decision too, whose lens it drafts under. A poll carries its connector's cursor, whose position it reads on from. A delete task carries the sighting whose source it removes the item from. A prompt-proposal task carries the prompt proposal that it drafts, which holds its run's dispatch.
type Mark ¶ added in v0.27.0
type Mark struct {
ItemKey string `json:"item_key"`
Sequence int `json:"sequence"`
Mark string `json:"mark"`
DecidedBy string `json:"decided_by"`
ClientID *string `json:"client_id"`
// GateVerdict and GateDecidedBy are the quality gate's newest decision on
// the item when the mark was made, and PromptVersion the version of the
// prompt that answered it. Each is nil where the gate had decided nothing.
GateVerdict *string `json:"gate_verdict"`
GateDecidedBy *string `json:"gate_decided_by"`
PromptVersion *string `json:"prompt_version"`
// Agreement is agreed, disagreed or neither, as the mark read against
// GateVerdict.
Agreement string `json:"agreement"`
// Families names each family whose standing the mark moved.
Families []string `json:"families"`
MarkedTS string `json:"marked_ts"`
}
Mark is a person's word on an item, as marks holds it.
type OutboxMark ¶
type OutboxMark struct {
Table string
ThroughStamp string
ThroughRowID int64
// Shipped counts the records every accepted batch carried, resends
// included.
Shipped int64
}
OutboxMark is how far the outbox has shipped one table.
type Outcome ¶
type Outcome struct {
// State is TaskDone, TaskFailed, or TaskQueued to try again after
// RetryAfter.
State string
Error *string
RetryAfter time.Duration
// Wait marks a task queued again because its far end asked it to wait, or
// its worker stopped, so the claim spends none of its attempts.
Wait bool
}
Outcome is how a worker's task ended.
type Output ¶
type Output struct {
ItemKey string `json:"item_key"`
Stage string `json:"stage"`
StageRun
Lens *string `json:"lens"`
LensVersion *string `json:"lens_version"`
// NoteDigest is NoteDigest of the note that a model read answered.
NoteDigest *string `json:"note_digest"`
// InputProducer and InputVersion name the parse a later stage read, such
// as the parse a scan's findings index the units of.
InputProducer *string `json:"input_producer"`
InputVersion *string `json:"input_version"`
BlobSHA256 *string `json:"blob_sha256"`
Findings []Finding `json:"findings"`
// RulesVersion is the scanner rules' version that made Findings.
RulesVersion *string `json:"rules_version"`
Quality *int `json:"quality"`
// Fit is the quality gate's 0 to 10 of how the item bears on the
// owner's current work, and nil where the gate read no context.
Fit *int `json:"fit"`
SideGuess *string `json:"side_guess"`
SideConfidence *float64 `json:"side_confidence"`
Spans []Span `json:"spans"`
CreatedTS string `json:"created_ts"`
UpdatedTS string `json:"updated_ts"`
}
Output is one stage's output for one item from one producer at one version.
func NewestDone ¶
NewestDone is the newest done output of stage among outputs, and nil where none is. A model stage's newest done output is its answer.
type Parse ¶
type Parse struct {
Item Item
Output Output
Units []Unit
// Scan is the newest done scan that read this parse, and nil where none did.
Scan *Output
}
Parse is one item's done parse with its units, and the newest done scan of it.
type ParsePick ¶
ParsePick picks one of an item's done parses: the newest, of Extractor and at Version where each is set.
type ParseUnit ¶
type ParseUnit struct {
ItemKey string `json:"item_key"`
Extractor string `json:"extractor"`
ExtractorVersion string `json:"extractor_version"`
N int `json:"n"`
Label *string `json:"label"`
Text string `json:"text"`
CreatedTS string `json:"created_ts"`
}
ParseUnit is one unit as parse_units holds it.
type Presented ¶ added in v0.33.0
type Presented struct {
Sort string `json:"sort"`
Grouping string `json:"grouping"`
Rank int `json:"rank"`
Position int `json:"position"`
Shown int `json:"shown"`
Quality *int `json:"quality"`
Fit *int `json:"fit"`
Verdict *string `json:"verdict"`
VerdictConfidence *float64 `json:"verdict_confidence"`
Side *string `json:"side"`
SideConfidence *float64 `json:"side_confidence"`
DrawnTS string `json:"drawn_ts"`
}
Presented is a review card as a person saw it when they decided: the sort and grouping in force, the card's rank under that sort and its position among the rows shown, how many rows were shown, the quality gate's quality, fit, verdict and side guess with their confidences, and when the card was drawn. A row shown is one on the table once the filter and the folds hid theirs, on the screen or scrolled off it. Each holds no outsider text, so it ships as a record.
type PromptProposal ¶ added in v0.28.0
type PromptProposal struct {
ID string `json:"id"`
// Prompt names the stage whose prompt the draft changes, PromptVersion
// the version it changes, and PromptText that version's template, so a
// worker of another build drafts against the same text.
Prompt string `json:"prompt"`
PromptVersion string `json:"prompt_version"`
PromptText string `json:"prompt_text"`
// LabeledAfter and LabeledThrough bound when each miss was labeled: after
// the first, which is nil where no earlier draft is done, and at or before
// the second.
LabeledAfter *string `json:"labeled_after"`
LabeledThrough string `json:"labeled_through"`
MissCount int `json:"miss_count"`
// Misses is the projection that the draft reads, one object per miss.
Misses json.RawMessage `json:"misses"`
Zone Zone `json:"zone"`
StageRun
CreatedTS string `json:"created_ts"`
UpdatedTS string `json:"updated_ts"`
}
PromptProposal is one draft of a change to a model stage's prompt, as prompt_proposals holds it. Serve writes the prompt and the projection that the draft reads, and the task's run writes its StageRun, as a model stage writes an item's output.
type Replay ¶
type Replay struct {
// ID derives from the caller and its Idempotency-Key.
ID string `json:"id"`
Stage string `json:"stage"`
Connector *string `json:"connector"`
ItemKey *string `json:"item_key"`
// PlacedBy is PlacedByPerson where the replay ran only over the labeled
// items, and nil where it ran over every item it selected.
PlacedBy *string `json:"placed_by"`
// Model is the model that a measurement arm's replay asked each task's
// run for, and nil for every other replay.
Model *string `json:"model"`
// Items counts the tasks queued, one per item.
Items int `json:"items"`
RequestedBy string `json:"requested_by"`
RequestedTS string `json:"requested_ts"`
}
Replay is one replay that queued a stage again over the items its connector and key select.
type ReplayQueue ¶
ReplayQueue queues a stage's tasks for item, and answers whether it queued any.
type RoutingRule ¶ added in v0.34.0
type RoutingRule struct {
Name string `json:"name"`
Sequence int `json:"sequence"`
Action string `json:"action"`
// MatchConnector, MatchTag, MatchField and MatchValues are what the rule
// holds for, as a declared rule's match names them. A nil one names
// nothing.
MatchConnector *string `json:"match_connector"`
MatchTag *string `json:"match_tag"`
MatchField *string `json:"match_field"`
MatchValues []string `json:"match_values"`
// Destination is a keep's, and nil on a block.
Destination *string `json:"destination"`
// in review instead, marked rule-would-hide.
ReviewShare float64 `json:"review_share"`
// Retired is a version that takes the rule out of force. It copies the
// version before it.
Retired bool `json:"retired"`
// Proposal names the proposal that the person accepted, where one did.
Proposal *string `json:"proposal"`
DecidedBy string `json:"decided_by"`
ClientID *string `json:"client_id"`
DecidedTS string `json:"decided_ts"`
}
RoutingRule is one version of a routing rule that a person accepted, as routing_rules holds it.
type Row ¶
Row is one row as its table holds it: each column by name, a JSON column as json.RawMessage, and its rowid.
type Section ¶ added in v0.20.0
type Section struct {
ItemKey string `json:"item_key"`
Producer string `json:"producer"`
ProducerVersion string `json:"producer_version"`
N int `json:"n"`
// ParentN is the n of the entry that holds this one, and nil at the top.
ParentN *int `json:"parent_n"`
Level int `json:"level"`
Kind string `json:"kind"`
Title *string `json:"title"`
// PDFPageStart and PDFPageEnd are the section's first and last PDF pages,
// from 1. A positional parse holds PDF page n as unit n, so the range
// names the section's units.
PDFPageStart int `json:"pdf_page_start"`
PDFPageEnd int `json:"pdf_page_end"`
// PrintedPageStart and PrintedPageEnd are the pages as the book prints
// them, and nil where it gives no way to tell.
PrintedPageStart *string `json:"printed_page_start"`
PrintedPageEnd *string `json:"printed_page_end"`
// StartPlacedBy says how the start page was found, such as outline.
StartPlacedBy string `json:"start_placed_by"`
// ChildKey is the key of the item made for a chapter, and nil where none
// was.
ChildKey *string `json:"child_key"`
CreatedTS string `json:"created_ts"`
}
Section is one entry of an item's sections, as sections holds it.
type Sighting ¶
type Sighting struct {
ItemKey string `json:"item_key"`
Connector string `json:"connector"`
Tags []string `json:"tags"`
// Fields hold the source payload's values by name, such as a Reddit
// save's subreddit, for a routing rule to match.
Fields map[string]string `json:"fields"`
// Metrics hold the source's counts by name, such as a video's views and
// duration. No outsider wrote them, so they ship on the record channel.
Metrics map[string]int64 `json:"metrics"`
Zone Zone `json:"zone"`
CursorPosition *string `json:"cursor_position"`
ExternalKey string `json:"external_key"`
FirstSeenTS string `json:"first_seen_ts"`
// LastSeenTS is the last arrival that changed the sighting.
LastSeenTS string `json:"last_seen_ts"`
// WrittenTS stamps every write of the row, an arrival's or a refresh's,
// and is nil on a row written before the store kept it.
WrittenTS *string `json:"written_ts"`
// MetricsReadTS is when the counts were last taken from the source: by
// an arrival that changed them, or by a refresh that read them, changed or
// not. It is nil where no read has taken any.
MetricsReadTS *string `json:"metrics_read_ts"`
}
Sighting is one connector's arrival of an item.
type Span ¶
Span is the text one finding matched. An output's spans hold one per finding, in the findings' order.
type StageProgress ¶ added in v0.31.0
type StageProgress struct {
Stage string `json:"stage"`
// State is running where a task of the stage is queued or leased, done
// where one of its outputs is done, and failed otherwise, since no task
// of it is left to run.
State string `json:"state"`
// Error is why the stage failed, from its newest task where that failed
// and from a failed output otherwise, and nil where neither says.
Error *string `json:"error"`
}
StageProgress is how far one stage has gone with an item, read from the stage's tasks as well as its outputs.
type StageRun ¶ added in v0.28.0
type StageRun struct {
Producer string `json:"producer"`
ProducerVersion string `json:"producer_version"`
// State is OutputWaiting, OutputDone or OutputFailed.
State string `json:"state"`
DispatchID *string `json:"dispatch_id"`
RunID *string `json:"run_id"`
// Model and Effort are what a model stage asked its run for, and
// AnsweredModel the model that its run reports answering on.
Model *string `json:"model"`
Effort *string `json:"effort"`
AnsweredModel *string `json:"answered_model"`
Tokens *Tokens `json:"tokens"`
Answer json.RawMessage `json:"answer"`
Error *string `json:"error"`
}
StageRun is how one producer's run of a stage over its subject went, as both a subject's tables hold it: an outputs row for an item, and a prompt_proposals row for a draft. The modelstage protocol reads and writes these columns alone, so a column it adds is added here once.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the open database.
func Open ¶
Open opens the database at path, creating it and its directory where they are missing, and converges every schema file and every logged table's guard.
func (*Store) AppliedDeclarations ¶
AppliedDeclarations reads the set in force, the one applied last, and false where no set has been applied.
func (*Store) Claim ¶
Claim records the worker's heartbeat and leases it up to c.Max tasks whose capability it holds, the oldest first: each queued task past its backoff that no first fill holds, and each leased task whose lease lapsed. It leases no more of a capability than c.MaxByCapability names, and no more of a slot group's capabilities together than c.SlotGroups names. Every claim runs through the one writer, so two workers asking at once never lease one task twice.
func (*Store) ConnectorCounts ¶
ConnectorCounts reads every connector's counts, by its name. A connector that sighted nothing is absent.
func (*Store) Deliveries ¶ added in v0.23.0
Deliveries reads each of the item's deliveries, one per destination.
func (*Store) DraftedItems ¶ added in v0.32.0
func (s *Store) DraftedItems(ctx context.Context) ([]ItemRecords, error)
DraftedItems reads every item that holds a done note draft, with its records, oldest first.
func (*Store) GateTrusts ¶ added in v0.27.0
GateTrusts reads every family's standing, by connector and then prompt version.
func (*Store) Heartbeat ¶
func (s *Store) Heartbeat(ctx context.Context, id string, token int64, lease time.Duration) (Task, error)
Heartbeat extends the lease on task id that token holds by lease from now, and records its worker's heartbeat.
func (*Store) ItemRow ¶
ItemRow reads the item row under key alone, and false where the store holds none.
func (*Store) ItemZones ¶
ItemZones reads each of keys' zone, by key, and leaves out each key with no item.
func (*Store) Items ¶
Items reads a page of items, newest first, each with its records, and the cursor of the next page, which is "" where none is left. It reads the page in one snapshot.
func (*Store) ItemsWithNoSourceTime ¶
func (s *Store) ItemsWithNoSourceTime(ctx context.Context, mediaTypes []string, after string, limit int) ([]Item, error)
ItemsWithNoSourceTime reads up to limit items that hold bytes and no source time, of one of mediaTypes, whose key sorts after after, in key order.
func (*Store) KeepOutboxMark ¶
KeepOutboxMark writes m, under the release that moved it.
func (*Store) KeyedRequest ¶
KeyedRequest reads the request caller sent under key, and false where the store holds none.
func (*Store) Leased ¶
Leased reads task id where token holds its lease, so a worker reads the input of a task it holds and of no other. It answers ErrNoTask where there is no such task, and ErrStaleLease where token does not hold its lease.
func (*Store) LiveHomesAt ¶
LiveHomesAt reads every home at root and pathSHA256 that is not gone, whatever blob it names.
func (*Store) MarksBetween ¶ added in v0.28.0
MarksBetween reads every mark made after after, through through, the oldest first. An empty after reads from the first mark.
func (*Store) NewestDonePromptProposal ¶ added in v0.28.0
NewestDonePromptProposal reads the done proposal whose misses were labeled latest, and false where no draft is done. Its labeled_through is where the next draft's misses start, so a failed draft's misses roll into the next.
func (*Store) NewestPromptProposal ¶ added in v0.28.0
NewestPromptProposal reads the proposal whose misses were labeled latest, and false where the store holds none.
func (*Store) NewestRefreshMetrics ¶ added in v0.30.0
NewestRefreshMetrics is source's newest refresh-metrics task, whatever its state, and false where the store holds none.
func (*Store) OutboxMarks ¶
OutboxMarks reads every table's mark. A table missing from the answer has shipped nothing.
func (*Store) Parse ¶
Parse reads the done parse of the item under key that pick names, with its units. It answers ErrNoItem where the store holds no such item, and ErrNoParse where no done parse matches. It reads in one transaction, so the units are the ones written with the output.
func (*Store) PromptProposals ¶ added in v0.28.0
func (s *Store) PromptProposals(ctx context.Context) ([]PromptProposal, error)
PromptProposals reads every proposal, the one whose misses were labeled latest first.
func (*Store) Reader ¶
Reader is the pool of read-only connections, for a reader such as the outbox that walks a table past a mark.
func (*Store) Replay ¶
Replay runs queue over each item that r covers, then records r with the count of items queue queued for, in one write. A replay already recorded under r.ID answers as recorded and queues nothing, and one recorded with another stage, connector, key or placed_by answers ErrReplayDiffers. The bool says whether this call queued.
func (*Store) ReplayItems ¶
ReplayItems reads the items that r covers, oldest first: each item that r's connector sighted and r's key names, or every item where neither is set, that takes says the stage runs on. It answers ErrNoItem where r's key names no item, and ErrNoSighting where r's connector sighted none.
func (*Store) Report ¶
func (s *Store) Report(ctx context.Context, id string, token int64, outcome Outcome, write func(*Tx, Task, *Outcome) error) (Task, error)
Report ends the lease that token holds on task id, with outcome. write runs in the same transaction before the lease ends, so a stage's records, such as a model stage's dispatch id, are stored exactly when the task ends. write may change the outcome, such as to fail a poll whose report it could land only in part. The store refuses a token that does not hold the lease with ErrStaleLease, and write never runs. A report repeated under the token that ended the task answers the task as it ended, and write never runs again, so a worker whose answer was lost can send its report again.
func (*Store) RetryTask ¶
RetryTask queues the failed task id again, with its attempts and backoff cleared, and answers it. A task that is queued or leased is answered as it is, so a retry sent twice queues it once. It answers ErrNoTask where there is no such task, ErrTaskDone where it ended done, and ErrTaskSuperseded where it drafts a proposal that a later one replaced.
func (*Store) ReviewPlacedItems ¶
func (s *Store) ReviewPlacedItems(ctx context.Context) ([]ItemRecords, error)
ReviewPlacedItems reads every labeled item, each one that a person placed after the gates sent it to review, with its records, oldest first.
func (*Store) ReviewQueue ¶
ReviewQueue reads every item that waits on a person's placement, the longest waiting first.
func (*Store) RoutingRules ¶ added in v0.34.0
func (s *Store) RoutingRules(ctx context.Context) ([]RoutingRule, error)
RoutingRules reads the newest version of every rule, each retired one included, by name.
func (*Store) SettlePhases ¶
SettlePhases settles every item's phase, a batch to a write, and answers how many items it read and how many it moved. A store that an earlier release wrote holds no phase, or one that an earlier Phase decided, and each item it moves ships again. Other writes run between its batches.
func (*Store) StageTokens ¶
StageTokens reads the tokens by kind of up to limit of stage's outputs that hold any, the newest first, which a model stage's replay estimates from.
type Table ¶
type Table struct {
Name string
// Key names a row within the table. Its columns joined with a slash are
// the record's ingestion.record.id, and an upsert conflicts on them.
Key []string
// Stamp is the columns whose first non-null value says when the row was
// last written. Each write sets it from the transaction's stamp.
Stamp []string
// JSON names the columns holding JSON text.
JSON []string
// Bool names the columns holding a boolean, which SQLite keeps as 0 or 1
// and a read answers as false or true.
Bool []string
// Text names the outsider-written columns, which ship as ingestion.text
// and never as ingestion.record.
Text []string
// Kept names the columns written once, on insert, and never by an upsert.
Kept []string
Writes Writes
}
Table is one table the outbox ships each row of, as the store writes it.
func TableNamed ¶
TableNamed is the table called name, and false where none is.
type Task ¶
type Task struct {
ID string `json:"id"`
ItemKey *string `json:"item_key"`
Connector *string `json:"connector"`
// Destination names the destination that a deliver task writes its item
// to, and is nil for every other task.
Destination *string `json:"destination"`
// Model names the model that a measurement arm's task asks its run for,
// and is nil for every other task.
Model *string `json:"model"`
// SightingConnector names the connector whose sighting a delete task
// removes from that connector's source, and is nil for every other task.
SightingConnector *string `json:"sighting_connector"`
// ProposalID names the prompt proposal that a prompt-proposal task drafts, and is
// nil for every other task.
ProposalID *string `json:"proposal_id"`
// Source names the source whose metrics a refresh-metrics task reads
// again, and is nil for every other task.
Source *string `json:"source"`
Stage string `json:"stage"`
Capability string `json:"capability"`
State string `json:"state"`
// HeldBy names the connector whose first fill holds this model stage's
// task. No claim takes it until a person releases the fill.
HeldBy *string `json:"held_by"`
// LeaseHolder is the worker that claimed the task last.
LeaseHolder *string `json:"lease_holder"`
// LeaseToken is the fencing token of the last claim. Each claim takes one
// higher, so a report under an older token is refused.
LeaseToken *int64 `json:"lease_token"`
LeaseExpiresTS *string `json:"lease_expires_ts"`
// Attempts counts the claims that leased the task, but each that ended
// waiting.
Attempts int `json:"attempts"`
// Lapses counts the leases in a row that lapsed with no report accepted.
Lapses int `json:"lapses"`
// WaitingSinceTS is when a report first said the task waits, and nil where
// none has.
WaitingSinceTS *string `json:"waiting_since_ts"`
NotBeforeTS *string `json:"not_before_ts"`
Error *string `json:"error"`
CreatedTS string `json:"created_ts"`
UpdatedTS string `json:"updated_ts"`
}
Task is one stage's work on one item, one poll of a connector, the draft of one prompt proposal, or one refresh of a source's metrics, which a worker holding its capability leases. A task names exactly one of its item, its connector, its proposal and its source.
func DeleteTask ¶ added in v0.24.0
DeleteTask is the task that removes the item under key from the source of connector, which a worker holding the capability delete:<source> claims.
func PollTask ¶
PollTask is the task that polls connector once, which a worker holding the capability poll:<source> claims.
func RefreshMetricsTask ¶ added in v0.30.0
RefreshMetricsTask is the task that reads again, at source, the metrics of each item that its connectors sighted and that waits in review, which a worker holding the capability refresh-metrics:<source> claims.
type TaskQuery ¶
type TaskQuery struct {
// States keeps tasks in these states, and every state but done where empty.
States []string
Limit int
}
TaskQuery selects tasks to list.
type Tokens ¶
type Tokens struct {
UncachedInput int64 `json:"uncached_input"`
CacheWrite int64 `json:"cache_write"`
CacheRead int64 `json:"cache_read"`
Output int64 `json:"output"`
}
Tokens is a model run's tokens by kind.
func MedianTokens ¶
MedianTokens is each kind's median over runs, each kind taken apart.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is one writing transaction. Every row it writes carries its stamp.
func (*Tx) AddDecision ¶
AddDecision appends a gate's decision on an item, numbered after the item's last at that gate, and answers it as written.
func (*Tx) AddGateTrustDecision ¶ added in v0.27.0
func (t *Tx) AddGateTrustDecision(ctx context.Context, d GateTrustDecision) (GateTrustDecision, error)
AddGateTrustDecision appends d to its family's decisions, numbered after the family's last, and answers it as written.
func (*Tx) AddKeyedRequest ¶
func (t *Tx) AddKeyedRequest(ctx context.Context, r KeyedRequest) error
AddKeyedRequest records a request and its answer. A key the caller already sent is left as it is.
func (*Tx) AddMark ¶ added in v0.27.0
AddMark appends a mark on an item, numbered after the item's last, and answers it as written.
func (*Tx) AddPromptProposal ¶ added in v0.28.0
func (t *Tx) AddPromptProposal(ctx context.Context, p PromptProposal) (PromptProposal, error)
AddPromptProposal writes p as a new proposal waiting on its draft, under a fresh id, and answers it as written.
func (*Tx) AddRoutingRule ¶ added in v0.34.0
func (t *Tx) AddRoutingRule(ctx context.Context, r RoutingRule) (RoutingRule, error)
AddRoutingRule appends r as its name's newest version, numbered after the name's last, and answers it as written.
func (*Tx) AppliedDeclarations ¶
AppliedDeclarations reads the set in force as this write sees it, and false where no set has been applied.
func (*Tx) ChapterSection ¶ added in v0.23.0
ChapterSection reads the newest section that names the chapter item under key, and false where none does.
func (*Tx) Chapters ¶ added in v0.20.0
Chapters reads the chapter items made from the book under key.
func (*Tx) Cursor ¶
Cursor reads connector's cursor as this write sees it, and false where the store holds none.
func (*Tx) DeleteOutstanding ¶ added in v0.26.0
DeleteOutstanding says whether a delete of the item under key from connector's source is queued, leased, or failed. A failed delete is one that the source refused for good, which waits for a person to retry it.
func (*Tx) Deliveries ¶ added in v0.23.0
Deliveries reads each of the item's deliveries, one per destination.
func (*Tx) Delivery ¶
Delivery reads the item's delivery to destination, and false where the store holds none.
func (*Tx) DraftOutstanding ¶ added in v0.28.0
DraftOutstanding reads the prompt-proposal task that is queued or leased, and false where none is.
func (*Tx) Enqueue ¶
Enqueue adds a queued task for task's item, connector, proposal or source, stage and capability, and answers it as written. A model stage's task for an item that a connector's first fill holds is held by that connector.
func (*Tx) GateTrust ¶ added in v0.27.0
GateTrust reads family's standing as this write sees it, and false where the store holds none.
func (*Tx) GateTrustDecisions ¶ added in v0.27.0
GateTrustDecisions reads family's decisions as this write sees them, the oldest first.
func (*Tx) GateTrusts ¶ added in v0.27.0
GateTrusts reads every family's standing as this write sees it.
func (*Tx) Item ¶
Item reads the item under key as this write sees it, and false where the store holds none.
func (*Tx) KeepRun ¶ added in v0.28.0
KeepRun writes a run that task's worker reported where its subject keeps it: an item's run as the item's output at the task's stage, with the units a parse wrote, and a prompt proposal's run on the proposal.
func (*Tx) KeyedRequest ¶
KeyedRequest reads the request caller sent under key, and false where the store holds none.
func (*Tx) LiveHomes ¶ added in v0.19.0
LiveHomes reads every home of the blob sum that is not gone, oldest first.
func (*Tx) LiveHomesAt ¶
LiveHomesAt reads every home at root and pathSHA256 that is not gone, whatever blob it names.
func (*Tx) LiveHomesUnder ¶
LiveHomesUnder reads every home at root that is not gone, in path order.
func (*Tx) NewestDecision ¶
NewestDecision reads the newest decision at gate on the item under key, and false where none is.
func (*Tx) NewestMark ¶ added in v0.27.0
NewestMark reads the newest mark on the item under key, and false where none is.
func (*Tx) NewestPromptProposal ¶ added in v0.28.0
NewestPromptProposal reads the proposal whose misses were labeled latest, as this write sees it, and false where the store holds none.
func (*Tx) NewestRoutingRule ¶ added in v0.34.0
NewestRoutingRule reads the newest version of the rule called name as this write sees it, and false where none was accepted.
func (*Tx) OpenTask ¶
OpenTask reads the item under key's task at stage that is queued or leased, and false where none is.
func (*Tx) Outputs ¶
Outputs reads every output of the item under key, oldest first, in the order that Store.Outputs reads them.
func (*Tx) Parse ¶ added in v0.20.0
Parse reads the done parse of the item under key that pick names, with its units, as this write sees it. It answers ErrNoItem and ErrNoParse as Store.Parse does.
func (*Tx) PollInFlight ¶
PollInFlight is connector's poll task that is queued or leased, and false where none is.
func (*Tx) PromptProposal ¶ added in v0.28.0
PromptProposal reads the proposal under id as this write sees it, and false where the store holds none.
func (*Tx) PutDeclarations ¶
func (t *Tx) PutDeclarations(ctx context.Context, d Declarations) error
PutDeclarations records one applied set of declarations, stamped now. A commit applied again is stamped again, so it is the set in force.
func (*Tx) PutDelivery ¶
PutDelivery writes one item's delivery to one destination.
func (*Tx) PutGateTrust ¶ added in v0.27.0
PutGateTrust writes one family's standing, keeping when it was created.
func (*Tx) PutHome ¶
PutHome records where a file lives. gone marks it gone from its root, and the item stays.
func (*Tx) PutItem ¶
PutItem writes item, keeping the created stamp and flow of a row already there. An item new to the store starts a fresh flow where it names none.
func (*Tx) PutOutputWithUnits ¶
PutOutputWithUnits writes o, a stage's output, and the units that only a parse holds. A done output is kept against a later one that is not done and answers the same note, so a rerun that fails leaves the done output readable and fails only its task. A model read of a new note replaces it, so its dispatch is stored. A done parse is kept against any later one, output and units alike. A changed extractor takes a new version, which writes beside the old.
func (*Tx) PutPromptProposal ¶ added in v0.28.0
func (t *Tx) PutPromptProposal(ctx context.Context, p PromptProposal) error
PutPromptProposal writes p again in place, keeping when it was created.
func (*Tx) PutSections ¶ added in v0.20.0
PutSections writes one producer version's sections of an item, once. Where that version already wrote sections, they stay as they are, and PutSections answers false.
func (*Tx) PutSighting ¶
PutSighting writes one connector's arrival of an item, keeping when it was first seen. Where the arrival took the sighting's counts, the caller sets MetricsReadTS to the write's time.
func (*Tx) PutSightingMetrics ¶ added in v0.30.0
func (t *Tx) PutSightingMetrics(ctx context.Context, key, connector string, metrics map[string]int64) (bool, error)
PutSightingMetrics writes metrics, as a read of the source just took them, onto connector's sighting of the item under key, each by its name. It keeps the sighting's other metrics, its fields and tags, and when it was last seen, and stamps when its metrics were read, whether or not one changed. It writes nothing where the store holds no such sighting. It answers whether a metric changed.
func (*Tx) QueueDelivery ¶
func (t *Tx) QueueDelivery(ctx context.Context, item Item, path *string, chapter *ChapterInBook, destination, deliverer string) (bool, error)
QueueDelivery queues the task that writes item to destination through deliverer, and records the delivery pending where it is new, with the item's title, URL and source time, path and chapter as every attempt sends them. path is the item's file below the deliverer's root, and nil for a deliverer that writes no file. chapter is where a book's chapter sits in its book's record, and nil for every other item. It queues nothing where the delivery is settled, because a destination can forget a record it held, so a second write could save the item again. It queues nothing where a deliver task for the item and destination is queued or leased. It answers whether it queued.
func (*Tx) RecordDelivery ¶
RecordDelivery writes how the deliver task's run ended into its delivery, counting the attempt. A pending attempt keeps the id an earlier one found.
func (*Tx) Records ¶ added in v0.21.0
Records reads the records of the item under key as this write sees them, and ErrNoItem where the store holds none.
func (*Tx) RefreshMetricsOutstanding ¶ added in v0.30.0
RefreshMetricsOutstanding is source's refresh-metrics task that is queued or leased, and false where none is.
func (*Tx) ReleaseFirstFill ¶
ReleaseFirstFill marks connector's first fill released, and returns to the claims every task it held whose item no other connector's fill holds. A task whose item another held fill sighted moves to that fill. It answers how many queued tasks it returned. A held task that a person's placement already finished loses its hold too, and is not counted.
func (*Tx) ReviewKeysSightedBy ¶ added in v0.30.0
func (t *Tx) ReviewKeysSightedBy(ctx context.Context, connectors []string, readSince string) ([]string, error)
ReviewKeysSightedBy reads, in key order, the key of each item in phase review that one of connectors sighted, leaving out each item whose metrics such a sighting took at or after readSince, where it is not empty.
func (*Tx) RoutingRules ¶ added in v0.34.0
func (t *Tx) RoutingRules(ctx context.Context) ([]RoutingRule, error)
RoutingRules reads the newest version of every rule, each retired one included, by name, as this write sees them.
func (*Tx) RoutingRulesInForce ¶ added in v0.34.0
func (t *Tx) RoutingRulesInForce(ctx context.Context) ([]RoutingRule, error)
RoutingRulesInForce reads the newest version of each rule that is not retired, by name, as this write sees them.
func (*Tx) Sections ¶ added in v0.20.0
Sections reads every section of the item under key, each version's in order.
func (*Tx) Sighting ¶
Sighting reads connector's sighting of the item under key, and false where the store holds none.
func (*Tx) UndeliveredChapterKeys ¶ added in v0.23.0
UndeliveredChapterKeys reads the key of each book's chapter that holds no delivery while its book holds one delivered or delivered to existing, each book's chapters in their order.
func (*Tx) UnplacedScannedKeys ¶
UnplacedScannedKeys reads the key of each item with a done scan whose newest side decision is a review or a drop, or that holds none. The side gate decides again only a review or a model's drop, so it narrows these to those, and to the items whose newest parse is the one scanned.
func (*Tx) UnsettledKeysReadAs ¶
UnsettledKeysReadAs reads the key of each item whose newest read decision has verdict and that holds no settled delivery: each item that a changed set may now send to a destination. A book's chapters follow each other in their order, so #2 comes before #10.
func (*Tx) WithdrawDeliveries ¶
WithdrawDeliveries ends each queued deliver task of the item under key whose destination is not keep, and says on its pending delivery why it stopped. keep is the destination that the item's decisions now send it to, and "" for none, as after a drop. A task already leased runs on, and its report records what the destination answered.
type Waiting ¶
type Waiting struct {
ItemRecords
// Reason is why it waits, in the words of schemas/review-list.schema.json.
Reason string
// Since is when it began to wait.
Since string
}
Waiting is one item that waits on a person's placement.
type Worker ¶
type Worker struct {
ID string `json:"id"`
Capabilities []string `json:"capabilities"`
Version string `json:"version"`
StartedTS string `json:"started_ts"`
HeartbeatTS string `json:"heartbeat_ts"`
}
Worker is one worker process, as its claims and heartbeats record it.
type Writes ¶
type Writes int
Writes is how the store writes a table, which decides how the outbox reads it past its mark and how a row's version counts.