server

package
v0.46.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 31 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package server is the HTTP API that `ingestion serve` answers. Every route but the probes and the RFC 9728 metadata answers only a request carrying a bearer token the identity provider signed. A person's token reaches every route. A service's token reaches only the routes its scopes list.

Index

Constants

View Source
const (
	// ScopeDeclarationsApply admits a caller to apply a set of declarations.
	ScopeDeclarationsApply = "ingestion.declarations.apply"
	// ScopeConnectorsRead admits a caller to read each connector's state.
	ScopeConnectorsRead = "ingestion.connectors.read"
	// ScopeConnectorsRun admits a caller to run a connector now.
	ScopeConnectorsRun = "ingestion.connectors.run"
	// ScopeConnectorsHold admits a caller to hold a connector, which keeps
	// its polls and every queued task of its items from the claims.
	ScopeConnectorsHold = "ingestion.connectors.hold"
	// ScopeConnectorsRelease admits a caller to release a connector's hold
	// and its first fill. That sends every task they held to the claims, and
	// spends the model stages on every item the fill held.
	ScopeConnectorsRelease = "ingestion.connectors.release"
	// ScopeItemsDrop admits a caller to drop a file into a drop connector.
	ScopeItemsDrop = "ingestion.items.drop"
)

Scopes of the connector routes.

View Source
const (
	CodeConnectorNotFound   = "connector_not_found"
	CodeConnectorMode       = "connector_mode"
	CodeInvalidDeclarations = "invalid_declarations"
	CodeDeclarationsMoved   = "declarations_moved"
	CodeDropTooLarge        = "drop_too_large"
	CodeInvalidDrop         = "invalid_drop"
)

Refusal codes of the connector routes.

View Source
const (
	DefaultItemsListed = 100
	MaxItemsListed     = 1000
)

DefaultItemsListed bounds a list whose caller names no limit, and MaxItemsListed bounds every page. A larger limit answers a page of MaxItemsListed and its next cursor, so a caller pages on without knowing it.

View Source
const (
	FoundInSource   = "source"
	FoundInSentence = "sentence"
)

Where a suggestion's finding was found.

View Source
const (
	// WaitingFirstFill is a task that a connector's first fill holds.
	WaitingFirstFill = "first-fill"
	// WaitingHeld is a task of a connector that a person holds.
	WaitingHeld = "held"
	// WaitingUnclaimed is a task that no worker heard from lately claims.
	WaitingUnclaimed = "unclaimed"
	// WaitingQueued is a task that a worker claims next.
	WaitingQueued = "queued"
	// WaitingDispatched is a run that the model port started and that has
	// not answered.
	WaitingDispatched = "dispatched"
)

Why an item waits at a model stage.

View Source
const (
	// CodeInvalidLink is a url that is not an http or https URL naming a
	// host, or one that names its artifact only through a redirect, such as a
	// Reddit share link.
	CodeInvalidLink = "invalid_link"
	// CodeLinkNotRead is a link of a kind that no extractor of this build
	// reads at its source, or a page that no extractor fetches, so the push
	// stores nothing.
	CodeLinkNotRead = "link_not_read"
	// CodeMediaNotRead is a body that is neither a JSON link nor the audio of
	// a memo in a container that store.MemoMediaTypes names.
	CodeMediaNotRead = "media_not_read"
	// CodeMemoTooLarge is a memo past MaxMemoBytes.
	CodeMemoTooLarge = "memo_too_large"
)

Refusal codes of the push route.

View Source
const (
	// LinkReadAtSource is a link that an extractor reads at its source, such
	// as a video's, so its item holds no bytes.
	LinkReadAtSource = "read-at-source"
	// LinkPage is a link to a web page, whose item's bytes are the page that a
	// GET of it answers.
	LinkPage = "page"
)

How a link lands.

View Source
const (
	CodeIdempotencyKeyMissing = "idempotency_key_missing"
	CodeIdempotencyKeyReused  = "idempotency_key_reused"
	CodeStageNotReplayable    = "stage_not_replayable"
	CodeNoItemFromConnector   = "no_item_from_connector"
	// CodePlacedByNotReplayable is a replay over the labeled items, of a
	// stage that holds no such replay.
	CodePlacedByNotReplayable = "placed_by_not_replayable"
	// CodeModelNotReplayable is a replay that names a model, of a stage that
	// runs on the model its worker's config names.
	CodeModelNotReplayable = "model_not_replayable"
	// CodeModelMissing is a replay of a measurement arm that names no model.
	CodeModelMissing = "model_missing"
)

Refusal codes of a replay.

View Source
const (
	ScopeReviewRead  = "ingestion.review.read"
	ScopeReviewPlace = "ingestion.review.place"
)

ScopeReviewRead admits a caller to read the items that wait on a person's placement. ScopeReviewPlace admits it to place or drop an item for the person whose login its body names.

View Source
const (
	CodeDestinationNotDeclared   = "destination_not_declared"
	CodeActingForAnother         = "acting_for_another"
	CodeChapterOfBook            = "chapter_of_book"
	CodeDestinationPushOnly      = "destination_push_only"
	CodeDestinationTakesPlaylist = "destination_takes_playlist"
	CodeChoiceRefused            = "choice_refused"
)

CodeDestinationNotDeclared refuses a placement on a destination that the set in force does not declare. CodeActingForAnother refuses a person's token whose body names another person's login. CodeChapterOfBook refuses a placement of a book's chapter, which takes its book's placement. CodeDestinationPushOnly refuses a placement from review on a push-only destination, which only a push places an item at. CodeDestinationTakesPlaylist refuses a placement on a destination whose deliverer adds the item to the playlist that a person picks, which only the watch choice places an item at. CodeChoiceRefused refuses a pick that its choice cannot carry out on the item, such as a watch that names no playlist where serve names no default.

View Source
const (
	CommentsUnread    = "unread"
	CommentsReading   = "reading"
	CommentsUnclaimed = "unclaimed"
	CommentsDone      = "done"
	CommentsFailed    = "failed"
)

The states of a read of an item's comments. Unread is an item whose comments a source reads and that nobody asked about. Unclaimed is a read queued while no worker heard from lately claims its tasks.

View Source
const (
	ItemsListVersion  = 3
	ItemVersion       = 2
	ReviewListVersion = 4
	PlacementVersion  = 2
)

The schema versions of the answers whose shape more than one writer prints: schemas/items-list.schema.json, item.schema.json, review-list.schema.json and review-placement.schema.json.

View Source
const (
	CodeRoutingRuleRefused  = "routing_rule_refused"
	CodeRoutingRuleNotFound = "routing_rule_not_found"
)

CodeRoutingRuleRefused refuses a rule that the set in force refuses, such as one naming a connector or a destination that it does not declare. CodeRoutingRuleNotFound refuses a retirement of a rule that nobody accepted.

View Source
const (
	CodeInvalidBody   = "invalid_body"
	CodeInvalidQuery  = "invalid_query"
	CodeRouteNotFound = "route_not_found"
	CodeTaskNotFound  = "task_not_found"
	CodeItemNotFound  = "item_not_found"
	CodeParseNotFound = "parse_not_found"
	CodeStaleLease    = "stale_lease"
	CodeTaskDone      = "task_done"
	// CodeTaskSuperseded is a retry of a draft whose misses a later prompt
	// proposal holds.
	CodeTaskSuperseded = "task_superseded"
	CodeInternal       = "internal"
	CodeUnknownField   = "unknown_field"
	CodeInvalidKey     = "invalid_key"
	CodeInvalidBlob    = "invalid_blob"
	CodeBlobNotFound   = "blob_not_found"
	// CodeBlobBytesMissing is a blob whose row holds and whose bytes are gone,
	// which the unpaired report also names.
	CodeBlobBytesMissing = "blob_bytes_missing"
	CodeDigestMismatch   = "digest_mismatch"
)

Refusal codes, by the status each answers with. A client branches on the code, and the message is for a person.

View Source
const (
	OutcomeDone   = "done"
	OutcomeFailed = "failed"
	OutcomeRetry  = "retry"
)

Report outcomes.

View Source
const (
	ScopeMarksWrite   = "ingestion.marks.write"
	ScopeTrustPromote = "ingestion.trust.promote"
)

ScopeMarksWrite admits a caller to mark an item for a person, who its body may name. ScopeTrustPromote admits it to promote a gate family for the person whose login its body names.

View Source
const CodeCommentsNotRead = "comments_not_read"

CodeCommentsNotRead refuses a read of the comments of an item whose media type no source that this build carries reads comments of.

View Source
const CodeFamilyNotFound = "family_not_found"

CodeFamilyNotFound refuses a promotion naming a family that the store holds no standing of.

View Source
const IdempotencyKey = "Idempotency-Key"

IdempotencyKey is the header that a keyed route finds an earlier request's work by, so a retry after a lost answer never starts it twice.

View Source
const ItemsOutcomeVersion = 3

ItemsOutcomeVersion is the first version of the items list that gives each item its outcome and reads ?outcome= and ?chapters=. A serve of an earlier version ignores both and answers every item, so a client that filters refuses its answer.

View Source
const MaxBlobBytes = 4 << 30

MaxBlobBytes bounds one blob that a worker writes.

View Source
const MaxDropBytes = 256 << 20

MaxDropBytes bounds one dropped file. A folder connector takes larger files, such as books, by reference.

View Source
const MaxListed = 1000

MaxListed is the most tasks one list answers.

View Source
const MaxMemoBytes = 100 << 20

MaxMemoBytes bounds one pushed memo's body, and a body past it answers 413. It holds about 3.5 hours of audio at 64 kbps. The route streams the body to the blob volume, so serve's memory stays flat in the memo's size.

View Source
const Product = "ingestion"

Product names the client id prefixes the API accepts: ingestion-cli- for a person's device login, ingestion-svc- for a service.

View Source
const ScopeCommentsRead = "ingestion.comments.read"

ScopeCommentsRead admits a caller to ask for the read of what an item's top comments say, which costs one model call per item.

View Source
const ScopeItemsPush = "ingestion.items.push"

ScopeItemsPush admits a caller to push a link or a memo, such as a phone's client, which holds no other scope.

View Source
const ScopeItemsRead = "ingestion.items.read"

ScopeItemsRead admits a caller to read items and their records.

View Source
const ScopeItemsReplay = "ingestion.items.replay"

ScopeItemsReplay admits a caller to run a stage again over landed items.

View Source
const ScopeRoutingRulesWrite = "ingestion.routing-rules.write"

ScopeRoutingRulesWrite admits a caller to accept or retire a routing rule for a person, who its body may name.

View Source
const ScopeTasksClaim = "ingestion.tasks.claim"

ScopeTasksClaim admits a worker to claim tasks, extend their leases and report them.

View Source
const WorkersHeardWithin = 10 * time.Minute

WorkersHeardWithin is how recently a worker was heard from for the list to show it by default. Each process start is a worker of its own, so the workers that stopped outnumber the live ones within a few releases.

Variables

View Source
var (
	RouteVersion          = Route{"GET /api/v1/version", ScopeTasksClaim, RepeatRead}
	RouteTaskClaims       = Route{"POST /api/v1/tasks/claims", ScopeTasksClaim, RepeatOnce}
	RouteTaskHeartbeats   = Route{"POST /api/v1/tasks/{id}/heartbeats", ScopeTasksClaim, RepeatByContent}
	RouteTaskReports      = Route{"POST /api/v1/tasks/{id}/reports", ScopeTasksClaim, RepeatByContent}
	RouteTaskParse        = Route{"GET /api/v1/tasks/{id}/parse", ScopeTasksClaim, RepeatRead}
	RouteTaskRetries      = Route{"POST /api/v1/tasks/{id}/retries", "", RepeatByContent}
	RouteTasks            = Route{"GET /api/v1/tasks", "", RepeatRead}
	RouteBlob             = Route{"GET /api/v1/blobs/{sha256}", ScopeTasksClaim, RepeatRead}
	RouteBlobWrite        = Route{"PUT /api/v1/blobs/{sha256}", ScopeTasksClaim, RepeatByContent}
	RouteBlobsUnpaired    = Route{"GET /api/v1/blobs/unpaired", "", RepeatRead}
	RouteItems            = Route{"GET /api/v1/items", ScopeItemsRead, RepeatRead}
	RouteItemsPush        = Route{"POST /api/v1/items", ScopeItemsPush, RepeatKeyed}
	RouteItem             = Route{"GET /api/v1/items/{key}", ScopeItemsRead, RepeatRead}
	RouteItemParse        = Route{"GET /api/v1/items/{key}/parse", ScopeItemsRead, RepeatRead}
	RouteReplays          = Route{"POST /api/v1/replays", ScopeItemsReplay, RepeatKeyed}
	RouteDeclarations     = Route{"PUT /api/v1/declarations", ScopeDeclarationsApply, RepeatByContent}
	RouteConnectors       = Route{"GET /api/v1/connectors", ScopeConnectorsRead, RepeatRead}
	RouteConnector        = Route{"GET /api/v1/connectors/{name}", ScopeConnectorsRead, RepeatRead}
	RouteConnectorRuns    = Route{"POST /api/v1/connectors/{name}/runs", ScopeConnectorsRun, RepeatKeyed}
	RouteConnectorHold    = Route{"POST /api/v1/connectors/{name}/hold", ScopeConnectorsHold, RepeatByContent}
	RouteConnectorRelease = Route{"POST /api/v1/connectors/{name}/release", ScopeConnectorsRelease, RepeatByContent}
	RouteConnectorDrops   = Route{"POST /api/v1/connectors/{name}/drops", ScopeItemsDrop, RepeatKeyed}
	RouteReview           = Route{"GET /api/v1/review", ScopeReviewRead, RepeatRead}
	RouteReviewPlace      = Route{"POST /api/v1/review/{key}/place", ScopeReviewPlace, RepeatByContent}
	RouteReviewArchive    = Route{"POST /api/v1/review/{key}/archive", ScopeReviewPlace, RepeatByContent}
	RouteReviewDrop       = Route{"POST /api/v1/review/{key}/drop", ScopeReviewPlace, RepeatByContent}
	RouteGateAgreement    = Route{"GET /api/v1/gates/agreement", ScopeItemsRead, RepeatRead}
	RouteItemMarks        = Route{"POST /api/v1/items/{key}/marks", ScopeMarksWrite, RepeatByContent}
	RouteItemComments     = Route{"POST /api/v1/items/{key}/comments", ScopeCommentsRead, RepeatByContent}
	RouteGateTrust        = Route{"GET /api/v1/gates/trust", ScopeItemsRead, RepeatRead}
	// RouteGateTrustPromote's family is <connector>@<prompt version>@<model>@<effort>.
	RouteGateTrustPromote  = Route{"POST /api/v1/gates/trust/{family}/promote", ScopeTrustPromote, RepeatByContent}
	RouteGateProposals     = Route{"GET /api/v1/gates/proposals", ScopeItemsRead, RepeatRead}
	RouteRoutingRules      = Route{"GET /api/v1/routing-rules", ScopeItemsRead, RepeatRead}
	RouteRoutingRule       = Route{"PUT /api/v1/routing-rules/{name}", ScopeRoutingRulesWrite, RepeatByContent}
	RouteRoutingRuleRetire = Route{"POST /api/v1/routing-rules/{name}/retire", ScopeRoutingRulesWrite, RepeatByContent}
)

The route table. Each package registers its rows with Router.Handle, and a client sends through the row of the route it calls.

ReplayStages are the stages that a replay request may name, as schemas/replay.schema.json's stage enum holds them. ReplayRoutes takes the stages that the service replays.

Functions

func Claimed added in v0.33.0

func Claimed(ctx context.Context, st *store.Store) (map[string]bool, error)

Claimed is each capability that a worker heard from within WorkersHeardWithin holds, so a queued task of any other waits on no worker.

func GateConfig

func GateConfig(issuer string) goapiauth.Config

GateConfig is the token check for issuer, accepting this product's person and service clients.

func Handler

func Handler(cfg Config, routes ...Routes) http.Handler

Handler is every route: the probes, which answer with no token so a kubelet can call them, the metadata, and each of routes behind the token check.

func JSON

func JSON(w http.ResponseWriter, status int, body any)

JSON answers status with body encoded as JSON.

func Refuse

func Refuse(w http.ResponseWriter, status int, code, format string, args ...any)

Refuse answers status with a refusal carrying code and the sentence that format and args make.

func SniffMemo added in v0.37.0

func SniffMemo(head []byte) (string, bool)

SniffMemo is the media type of a memo whose body opens with head, and false where head opens none of store.MemoMediaTypes: an MP4 whose ftyp box names an audio brand, an MP3 that opens with its ID3 tag or a frame, or a RIFF WAVE. The route reads the bytes rather than the Content-Type, because a phone's share may name no type or the wrong one.

func ValidCause

func ValidCause(cause string) bool

ValidCause reports whether cause is spelled as the place and drop routes take one.

Types

type AfterStage

type AfterStage func(ctx context.Context, tx *store.Tx, task store.Task) error

AfterStage runs in the write that ends an item's task done, after the stage's outputs, such as the scan and the gates that follow an item's parse. An error rolls the whole report back, so the task stays leased.

type ArchiveRequest added in v0.43.0

type ArchiveRequest struct {
	Liked          string           `json:"liked,omitempty"`
	Login          string           `json:"login,omitempty"`
	Presented      *store.Presented `json:"presented,omitempty"`
	DecidedAfterMS *int64           `json:"decided_after_ms,omitempty"`
}

ArchiveRequest archives an item: done, its record kept with no destination, and the read mark written where the caller may write marks. Liked names what the person liked, one of route.Likes, and an archive that names none is kept as unstated. Login, Presented and DecidedAfterMS are a PlaceRequest's.

type BlobAnswer

type BlobAnswer struct {
	SchemaVersion int    `json:"schema_version"`
	SHA256        string `json:"sha256"`
	MD5           string `json:"md5"`
	SizeBytes     int64  `json:"size_bytes"`
	MediaType     string `json:"media_type"`
	CreatedTS     string `json:"created_ts"`
}

BlobAnswer is what a blob write answers: schemas/blob.schema.json.

type ClaimAnswer

type ClaimAnswer struct {
	Tasks []LeasedTask `json:"tasks"`
}

ClaimAnswer is every task that the claim leased, and none where nothing waits.

type ClaimRequest

type ClaimRequest struct {
	WorkerID        string               `json:"worker_id"`
	Capabilities    []string             `json:"capabilities"`
	Version         string               `json:"version"`
	StartedTS       string               `json:"started_ts"`
	Max             int                  `json:"max"`
	MaxByCapability map[string]int       `json:"max_by_capability,omitempty"`
	SlotGroups      map[string]SlotGroup `json:"slot_groups,omitempty"`
	LeaseSeconds    int                  `json:"lease_seconds"`
}

ClaimRequest is a worker asking for up to Max tasks whose capability it holds, each leased for LeaseSeconds. MaxByCapability bounds how many of each capability it names the claim leases, such as a worker whose slot limit for one capability holds one of its slots free for the rest. Each of SlotGroups bounds the tasks of its capabilities together, such as two heavy parses where the worker's memory holds one. A capability sits in one group at most, and MaxByCapability names no grouped one.

type CommentsState added in v0.33.0

type CommentsState func(r store.ItemRecords, claimed map[string]bool) *ReviewComments

CommentsState is how the read of an item's comments stands in its records, given each capability that a live worker claims, and nil where no source of this build reads the item's comments. The comments stage answers it, so the review list reports the state that its route acts on.

type Config

type Config struct {
	Store *store.Store
	Gate  TokenGate
	// Issuer is the identity provider whose tokens the API accepts.
	Issuer string
	// PublicURL is where callers reach the API. Where it is set, the
	// API serves RFC 9728 metadata there, from which `ingestion auth login`
	// learns the issuer.
	PublicURL string
	Version   string
	Log       *slog.Logger
}

Config is what the API serves from.

type ConnectorConfig

type ConnectorConfig struct {
	Store     *store.Store
	Lander    *landing.Lander
	Scheduler *connectors.Scheduler
	// Roots names each [serve.homes] root a folder connector may read.
	Roots []string
	// AfterApply runs in the write that applies a changed set.
	AfterApply connectors.AfterApply
	// Links answers whether an extractor reads a pushed link, or fetches the
	// page that it names. Nil lands none.
	Links LinkExtractors
	Log   *slog.Logger
}

ConnectorConfig is what the connector routes serve from.

type ConnectorView

type ConnectorView struct {
	Name string `json:"name"`
	Mode string `json:"mode"`
	// Zone is nil for a push connector, whatever the stored set holds, because
	// the route sets each item's zone by what the push carries: a link lands
	// outside, and a memo as the owner's.
	Zone           *store.Zone `json:"zone"`
	Source         string      `json:"source"`
	Tags           []string    `json:"tags"`
	AppliedCommit  string      `json:"applied_commit"`
	LastRunTS      *string     `json:"last_run_ts"`
	LastDeliveryTS *string     `json:"last_delivery_ts"`
	// LastError is why the last run failed, null since one succeeded, and
	// Failures counts the failed runs since then.
	LastError   *string `json:"last_error"`
	LastErrorTS *string `json:"last_error_ts"`
	Failures    int     `json:"failures"`
	Items       int     `json:"items"`
	Waiting     int     `json:"waiting"`
	Review      int     `json:"review"`
	Failed      int     `json:"failed"`
	Schedule    *string `json:"schedule"`
	DueInterval *string `json:"due_interval"`
	Freshness   *string `json:"freshness"`
	DueAt       string  `json:"due_at"`
	Overdue     bool    `json:"overdue"`
	// OverdueSince is when the connector went overdue, and null while it is not.
	OverdueSince *string `json:"overdue_since"`
	// FinishedTS is when a connector scheduled once ran a poll that ended
	// done, after which the scheduler never runs it, and null until then.
	FinishedTS *string `json:"finished_ts"`
	// HeldTS is when a person held the connector, and HoldDecidedBy who held
	// it. Both are null while it is not held.
	HeldTS        *string `json:"held_ts"`
	HoldDecidedBy *string `json:"hold_decided_by"`
	// HeldTasks counts the queued tasks held by the connector, through a
	// person's hold or its first fill.
	HeldTasks int `json:"held_tasks"`
	// FirstFill is answered on one connector alone.
	FirstFill *FirstFillView `json:"first_fill,omitempty"`
}

ConnectorView is one applied connector, its counts and its due time.

type ConnectorsAnswer

type ConnectorsAnswer struct {
	SchemaVersion int `json:"schema_version"`
	// AppliedCommit is the commit of the set in force, and null where no set
	// has been applied.
	AppliedCommit *string         `json:"applied_commit"`
	Connectors    []ConnectorView `json:"connectors"`
}

ConnectorsAnswer is what GET /api/v1/connectors answers: schemas/connectors-list.schema.json.

type DecidedView added in v0.45.0

type DecidedView struct {
	Gate        string   `json:"gate"`
	Verdict     string   `json:"verdict"`
	Decider     string   `json:"decider"`
	DecidedBy   string   `json:"decided_by"`
	Rule        *string  `json:"rule"`
	Confidence  *float64 `json:"confidence"`
	Cause       string   `json:"cause"`
	Destination *string  `json:"destination"`
	Playlist    *string  `json:"playlist"`
	DecidedTS   string   `json:"decided_ts"`
}

DecidedView is the decision that left an item at its outcome: its gate and verdict, who made it, as store.Decision.Decider names them and as decided_by spells it, the rule's name where a rule made it, why, the destination and playlist it placed the item on, and when.

type DecisionView

type DecisionView struct {
	Gate           string           `json:"gate"`
	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           *string          `json:"lens"`
	Playlist       *string          `json:"playlist"`
	ClientID       *string          `json:"client_id"`
	Presented      *store.Presented `json:"presented"`
	DecidedAfterMS *int64           `json:"decided_after_ms"`
	DecidedTS      string           `json:"decided_ts"`
}

DecisionView is one gate's decision.

type DeclarationsAnswer

type DeclarationsAnswer struct {
	SchemaVersion int    `json:"schema_version"`
	Commit        string `json:"commit"`
	AppliedTS     string `json:"applied_ts"`
	AppliedBy     string `json:"applied_by"`
	Unchanged     bool   `json:"unchanged"`
	Connectors    int    `json:"connectors"`
	RoutingRules  int    `json:"routing_rules"`
	Destinations  int    `json:"destinations"`
}

DeclarationsAnswer is what an apply answers: schemas/declarations-applied.schema.json.

type DeclarationsRequest

type DeclarationsRequest struct {
	Commit string `json:"commit"`
	// Replaces is the commit the caller saw in force, and null where it saw
	// none. An apply that replaces another commit is refused.
	Replaces *string `json:"replaces"`
	connectors.Set
}

DeclarationsRequest is what PUT /api/v1/declarations reads: schemas/declarations.schema.json.

type DeliveryView

type DeliveryView struct {
	Destination   string  `json:"destination"`
	DestinationID *string `json:"destination_id"`
	Outcome       string  `json:"outcome"`
	Attempts      int     `json:"attempts"`
	LastError     *string `json:"last_error"`
	Playlist      *string `json:"playlist"`
	// UnclaimedCapability is the capability of the delivery's queued task
	// where no worker heard from lately holds it, and null otherwise.
	UnclaimedCapability *string `json:"unclaimed_capability"`
}

DeliveryView is one delivery to one destination.

type DropRequest

type DropRequest struct {
	Cause          string           `json:"cause,omitempty"`
	Note           *string          `json:"note,omitempty"`
	Login          string           `json:"login,omitempty"`
	Presented      *store.Presented `json:"presented,omitempty"`
	DecidedAfterMS *int64           `json:"decided_after_ms,omitempty"`
}

DropRequest drops an item, which keeps its row. Cause names the aspect that decided it, and a drop that names none is kept as unstated. A drop for low-quality also writes the low-quality mark where the caller may write marks. Presented and DecidedAfterMS are a PlaceRequest's.

type FindingView

type FindingView struct {
	store.Finding
	Span *string `json:"span"`
}

FindingView is one scanner finding and the text it matched.

type FirstFillView

type FirstFillView struct {
	State   string                  `json:"state"`
	ItemKey *string                 `json:"item_key"`
	Held    int                     `json:"held"`
	Tokens  map[string]store.Tokens `json:"tokens"`
}

FirstFillView is a connector's first fill: its state, the one item it ran end to end, the items held behind it, and that item's tokens by model stage.

type GateTrustAnswer added in v0.27.0

type GateTrustAnswer struct {
	SchemaVersion int               `json:"schema_version"`
	Rule          TrustRule         `json:"rule"`
	Families      []store.GateTrust `json:"families"`
}

GateTrustAnswer is what GET /api/v1/gates/trust answers: schemas/gate-trust-list.schema.json.

type HeartbeatRequest

type HeartbeatRequest struct {
	Token        int64 `json:"token"`
	LeaseSeconds int   `json:"lease_seconds"`
}

HeartbeatRequest extends a lease by LeaseSeconds from now.

type HoldAnswer added in v0.38.0

type HoldAnswer struct {
	SchemaVersion int    `json:"schema_version"`
	Connector     string `json:"connector"`
	// HeldTS and HoldDecidedBy are the first hold's, which a second hold
	// keeps.
	HeldTS        string `json:"held_ts"`
	HoldDecidedBy string `json:"hold_decided_by"`
	// Held counts the queued tasks held by the connector now.
	Held int `json:"held"`
}

HoldAnswer is what POST /api/v1/connectors/{name}/hold answers: schemas/connector-hold.schema.json.

type HomeView

type HomeView struct {
	Root       string  `json:"root"`
	Path       string  `json:"path"`
	ModifiedTS *string `json:"modified_ts"`
	FoundTS    string  `json:"found_ts"`
	GoneTS     *string `json:"gone_ts"`
}

HomeView names where the item's file lives under a named root.

type ItemAnswer

type ItemAnswer struct {
	SchemaVersion int            `json:"schema_version"`
	Item          ItemView       `json:"item"`
	Homes         []HomeView     `json:"homes"`
	Sightings     []SightingView `json:"sightings"`
	Outputs       []OutputView   `json:"outputs"`
	Decisions     []DecisionView `json:"decisions"`
	Deliveries    []DeliveryView `json:"deliveries"`
	// Sections are the item's sections, each producer version's in order.
	Sections []SectionView `json:"sections"`
	// Undelivered says why an item placed on a side and read as is reaches
	// no deliverer, and is null where it does.
	Undelivered *UndeliveredView `json:"undelivered"`
	// Waiting says why the item waits at a model stage, and is null where it
	// waits at none.
	Waiting *WaitingView `json:"waiting"`
	// Progress is the parse's and the scan's progress, as
	// store.ItemRecords.Progress reads it from their tasks and outputs.
	Progress []store.StageProgress `json:"progress"`
	// Suggestion is the item's latest suggestion, and null where no model
	// read holds a sentence.
	Suggestion *SuggestionView `json:"suggestion"`
	// QualityAnswer is the quality gate's newest done answer, as
	// store.NewestDone picks it and the review route serves it, and null where
	// the gate gave none.
	QualityAnswer json.RawMessage `json:"quality_answer"`
	// ModelRead is the newest done model read, as store.NewestDone picks it,
	// with the scanner's findings over its sentence, and null where none is
	// done.
	ModelRead *OutputView `json:"model_read"`
}

ItemAnswer is what GET /api/v1/items/{key} answers: schemas/item.schema.json.

type ItemCommentsAnswer added in v0.33.0

type ItemCommentsAnswer struct {
	SchemaVersion int            `json:"schema_version"`
	Key           string         `json:"key"`
	Comments      ReviewComments `json:"comments"`
}

ItemCommentsAnswer is what POST /api/v1/items/{key}/comments answers: schemas/item-comments.schema.json.

type ItemListed

type ItemListed struct {
	Key        string     `json:"key"`
	Zone       store.Zone `json:"zone"`
	MediaType  string     `json:"media_type"`
	Title      *string    `json:"title"`
	URL        *string    `json:"url"`
	Connectors []string   `json:"connectors"`
	// Channel is who published the item, as its sightings name it, and null
	// where none does.
	Channel   *string `json:"channel"`
	Phase     string  `json:"phase"`
	WaitingAt *string `json:"waiting_at"`
	Side      *string `json:"side"`
	// Outcome is where the item's decisions leave it, as
	// store.ItemRecords.Outcome decides it, and Decided the decision that left
	// it there, null where it waits.
	Outcome string       `json:"outcome"`
	Decided *DecidedView `json:"decided"`
	// ReviewReason is why the item waits in review, as route.ReviewReasons
	// names it, and null where it waits on no person.
	ReviewReason *string `json:"review_reason"`
	CreatedTS    string  `json:"created_ts"`
}

ItemListed is one item as the list shows it.

type ItemView

type ItemView struct {
	Key        string     `json:"key"`
	Zone       store.Zone `json:"zone"`
	MediaType  string     `json:"media_type"`
	Title      *string    `json:"title"`
	URL        *string    `json:"url"`
	SourceTS   *string    `json:"source_ts"`
	BlobSHA256 *string    `json:"blob_sha256"`
	SizeBytes  *int64     `json:"size_bytes"`
	MD5        *string    `json:"md5"`
	ParentKey  *string    `json:"parent_key"`
	FlowID     string     `json:"flow_id"`
	Phase      string     `json:"phase"`
	WaitingAt  *string    `json:"waiting_at"`
	CreatedTS  string     `json:"created_ts"`
}

ItemView is the item, with its bytes' size and MD5 and its derived phase.

type ItemsAnswer

type ItemsAnswer struct {
	SchemaVersion int          `json:"schema_version"`
	Items         []ItemListed `json:"items"`
	Next          *string      `json:"next"`
}

ItemsAnswer is what GET /api/v1/items answers: schemas/items-list.schema.json. Next is the cursor of the next page, and null where none is left.

type LeasedProposal added in v0.28.0

type LeasedProposal struct {
	Prompt        string `json:"prompt"`
	PromptVersion string `json:"prompt_version"`
	// PromptText is the template of the prompt at PromptVersion, which the
	// draft's edits apply to.
	PromptText     string          `json:"prompt_text"`
	LabeledAfter   *string         `json:"labeled_after"`
	LabeledThrough string          `json:"labeled_through"`
	MissCount      int             `json:"miss_count"`
	Misses         json.RawMessage `json:"misses"`
}

LeasedProposal is the prompt proposal that a prompt-proposal task drafts: the prompt it changes, at the version it changes, and the misses labeled after LabeledAfter, through LabeledThrough, as one JSON array.

type LeasedSighting added in v0.24.0

type LeasedSighting struct {
	Connector   string            `json:"connector"`
	ExternalKey string            `json:"external_key"`
	Fields      map[string]string `json:"fields"`
}

LeasedSighting is one connector's sighting of a delete task's item, which the task removes from that connector's source: the source's own key for the item, and the fields read from its payload, such as a playlist item's id.

type LeasedTask

type LeasedTask struct {
	ID      string  `json:"id"`
	ItemKey *string `json:"item_key"`
	// FlowID is the flow of the task's item, a W3C trace id, which each call
	// that the task makes for the item carries in its traceparent. A task
	// that names no item carries none.
	FlowID         string  `json:"flow_id,omitempty"`
	Connector      *string `json:"connector"`
	Source         *string `json:"source,omitempty"`
	Stage          string  `json:"stage"`
	Capability     string  `json:"capability"`
	Attempts       int     `json:"attempts"`
	LeaseToken     int64   `json:"lease_token"`
	LeaseExpiresTS string  `json:"lease_expires_ts"`
	// WaitedSeconds is how long before this claim a report first said the
	// task waits, and 0 where none has.
	WaitedSeconds int64 `json:"waited_seconds,omitempty"`
	// MediaType and BlobSHA256 are the item's, so a worker reads its bytes
	// holding no scope to read items. A poll carries neither, and BlobSHA256
	// is null where the item holds no bytes.
	MediaType  string  `json:"media_type"`
	BlobSHA256 *string `json:"blob_sha256"`
	// Zone, Title, URL and LandedTS are the item's too, so a deliverer writes
	// it holding no scope to read items. A deliver task's Title, URL and
	// SourceTS are its delivery's, as they were when it was first queued, so
	// a retry sends what the first attempt sent. SourceTS is when the item
	// was made at its source, and null where its source gave no time. Path
	// is a deliver task's file below its deliverer's root, kept the same way,
	// and absent for a deliverer that writes no file. A poll carries none of
	// them.
	Zone     store.Zone `json:"zone,omitempty"`
	Title    *string    `json:"title"`
	URL      *string    `json:"url"`
	LandedTS string     `json:"landed_ts,omitempty"`
	SourceTS *string    `json:"source_ts,omitempty"`
	Path     *string    `json:"path,omitempty"`
	// Playlist is a watch's deliver task's: the playlist that the delivery
	// adds the video to, kept the same way. Every other task carries none.
	Playlist *string `json:"playlist,omitempty"`
	// Chapter is a deliver task's of a book's chapter, kept the same way:
	// the destination's id for its book's record, and where the chapter
	// sits in the book. Every other task carries none.
	Chapter *store.ChapterInBook `json:"chapter,omitempty"`
	// Destination names where a deliver task writes its item, and is null
	// for every other task.
	Destination *string `json:"destination"`
	// StageOutputs are the item's outputs at a model stage's task's stage,
	// so a task whose run is already dispatched follows that run rather than
	// starting another. Every other task carries none.
	StageOutputs []StageOutput `json:"stage_outputs,omitempty"`
	// Parse is the done parse that the prompt of a model stage's task quotes,
	// as the claim read it: the item's reading parse, or the one extractor's
	// that the stage reads. The task's call reads it, and its output names it.
	// It is absent where the stage quotes no parse or the item holds none.
	Parse *store.ParseRef `json:"parse,omitempty"`
	// Lens, Note and NoteDraft are a model read's task's: the lens of the
	// item's newest read decision, the note that a person wrote on it, and
	// the note stage's draft where the decision took one instead. A draft
	// never rides in Note, so a reader that knows only Note never reads a
	// model's draft as the owner's. A note task carries Lens alone, and every
	// other task none of them.
	Lens      *string `json:"lens,omitempty"`
	Note      *string `json:"note,omitempty"`
	NoteDraft *string `json:"note_draft,omitempty"`
	// Model is a measurement arm's task's. The task asks its run for this
	// model in place of the worker's configured one. Every other task
	// carries none.
	Model *string `json:"model,omitempty"`
	// Cursor and Declaration are a poll's: its connector's position, where an
	// earlier poll moved it, and the connector's declaration as the set in
	// force holds it, so the source's handler reads what its connector names.
	// Declaration is absent where the connector is missing from the set in
	// force. Every other task carries neither.
	Cursor      *string         `json:"cursor,omitempty"`
	Declaration json.RawMessage `json:"declaration,omitempty"`
	// Sighting is a delete task's: the sighting whose source the task removes
	// the item from. Every other task carries none.
	Sighting *LeasedSighting `json:"sighting,omitempty"`
	// ProposalID and Proposal are a prompt-proposal task's: the prompt proposal that
	// it drafts, and the misses that the draft reads. Its StageOutputs hold
	// the proposal's run, once one was sent. Every other task carries
	// neither.
	ProposalID *string         `json:"proposal_id,omitempty"`
	Proposal   *LeasedProposal `json:"proposal,omitempty"`
	// Keys are a refresh-metrics task's: the key of each item in review that
	// a connector of its source sighted, as the claim read them, whose
	// metrics the task reads again. Every other task carries none.
	Keys []string `json:"keys,omitempty"`
}

LeasedTask is one leased task, with the token for every heartbeat and report on it. A stage's task names its item. A poll names its connector, and its capability is poll:<source>, so each source's handler claims its own. A refresh of a source's metrics names its source, and its capability is refresh-metrics:<source>.

func (LeasedTask) Answers added in v0.32.0

func (t LeasedTask) Answers() *string

Answers is the note that a model read's task answers: the person's note where the task carries one, the draft otherwise, and nil with neither.

type LinkExtractors added in v0.31.0

type LinkExtractors interface {
	// LinkLanding is how the link keyed key lands, where link is its
	// canonical URL.
	LinkLanding(key, link string) LinkLanding
	// LinkKinds names, in order, each kind of key whose link an extractor
	// reads.
	LinkKinds() []string
	// PageMediaType is the media type that a link to a web page lands as,
	// with no bytes, so that its parse fetches the page. It is false where no
	// extractor fetches pages.
	PageMediaType() (string, bool)
}

LinkExtractors answers whether an extractor reads a pushed link at its source, or fetches the web page that it names, and as what media type and URL it lands.

type LinkLanding added in v0.40.0

type LinkLanding struct {
	// Lands is LinkReadAtSource or LinkPage, and "" where the link does not
	// land.
	Lands string
	// MediaType and URL are what the item lands as, where the link lands.
	MediaType, URL string
	// Site is the kind of key whose site hosts a link that does not land,
	// such as youtube for a channel's page, and "" otherwise.
	Site string
}

LinkLanding is how a link lands as an item, as the extractors of a build read it. The push route and a feed's poll both ask it, so a link lands alike whichever connector meets it first.

type MarkAnswer added in v0.27.0

type MarkAnswer struct {
	SchemaVersion int               `json:"schema_version"`
	Mark          store.Mark        `json:"mark"`
	Families      []store.GateTrust `json:"families"`
}

MarkAnswer is what a mark answers: schemas/item-mark.schema.json. Families is each family's standing after the mark moved it, and empty where the mark moved none.

type MarkRequest added in v0.27.0

type MarkRequest struct {
	Mark  string `json:"mark"`
	Login string `json:"login,omitempty"`
}

MarkRequest marks an item low-quality or read. A service marking for a person may name the person's Login, since its token carries none. Without one, the mark is the service's, which relays a person's word under its scope.

type OutputView

type OutputView struct {
	Stage           string          `json:"stage"`
	Producer        string          `json:"producer"`
	ProducerVersion string          `json:"producer_version"`
	Lens            *string         `json:"lens"`
	LensVersion     *string         `json:"lens_version"`
	NoteDigest      *string         `json:"note_digest"`
	InputProducer   *string         `json:"input_producer"`
	InputVersion    *string         `json:"input_version"`
	State           string          `json:"state"`
	Units           *int            `json:"units"`
	Findings        []FindingView   `json:"findings"`
	RulesVersion    *string         `json:"rules_version"`
	Answer          json.RawMessage `json:"answer"`
	RunID           *string         `json:"run_id"`
	DispatchID      *string         `json:"dispatch_id"`
	Model           *string         `json:"model"`
	Effort          *string         `json:"effort"`
	AnsweredModel   *string         `json:"answered_model"`
	Tokens          *store.Tokens   `json:"tokens"`
	Error           *string         `json:"error"`
}

OutputView is one stage's output, with a parse's units counted and each finding beside its span.

type ParseAnswer

type ParseAnswer struct {
	SchemaVersion    int            `json:"schema_version"`
	Key              string         `json:"key"`
	Zone             store.Zone     `json:"zone"`
	Title            *string        `json:"title"`
	URL              *string        `json:"url"`
	MediaType        string         `json:"media_type"`
	Extractor        string         `json:"extractor"`
	ExtractorVersion string         `json:"extractor_version"`
	Text             string         `json:"text"`
	Units            []store.Unit   `json:"units"`
	RulesVersion     *string        `json:"rules_version"`
	Findings         []ParseFinding `json:"findings"`
}

ParseAnswer is what GET /api/v1/items/{key}/parse answers: schemas/item-parse.schema.json. Text is the units' text in order, joined by a blank line.

type ParseFinding

type ParseFinding struct {
	store.Finding
	Span string `json:"span"`
}

ParseFinding is one finding of the newest scan of the parse, with the text it matched. Its offset counts bytes from its unit's start.

type PlaceRequest

type PlaceRequest struct {
	Destination    string           `json:"destination,omitempty"`
	Choice         string           `json:"choice,omitempty"`
	Playlist       string           `json:"playlist,omitempty"`
	Cause          string           `json:"cause,omitempty"`
	Note           *string          `json:"note,omitempty"`
	Login          string           `json:"login,omitempty"`
	Presented      *store.Presented `json:"presented,omitempty"`
	DecidedAfterMS *int64           `json:"decided_after_ms,omitempty"`
}

PlaceRequest places an item on Destination, one the set in force declares, or by Choice, one of review's placing choices, and names one of the two. Playlist is the playlist that a watch adds the video to, and a watch that names none takes serve's [watch] default_playlist. Cause names the aspect that decided it, such as subreddit, channel, theme or title, and Note the questions and why the item was saved. A service placing for a person names the person's Login, since its token carries none. Presented is the review card as drawn when the person decided, and DecidedAfterMS how long after the drawing they decided, which a client that drew no card leaves out.

type PlacementAnswer

type PlacementAnswer struct {
	SchemaVersion int            `json:"schema_version"`
	Key           string         `json:"key"`
	Decisions     []DecisionView `json:"decisions"`
}

PlacementAnswer is what a placement, an archive or a drop answers: schemas/review-placement.schema.json. Decisions are the side decision and, where it places the item on a side, the read decision after it.

type PromoteRequest added in v0.27.0

type PromoteRequest struct {
	Login string `json:"login,omitempty"`
}

PromoteRequest promotes a gate family. A service promoting for a person names the person's Login, since its token carries none.

type PromotionAnswer added in v0.27.0

type PromotionAnswer struct {
	SchemaVersion int             `json:"schema_version"`
	Family        store.GateTrust `json:"family"`
}

PromotionAnswer is what a promotion answers: schemas/gate-trust-promotion.schema.json.

type PushAnswer

type PushAnswer struct {
	SchemaVersion int          `json:"schema_version"`
	Items         []PushedItem `json:"items"`
}

PushAnswer is what a push or a drop answers: schemas/push.schema.json.

type PushRequest added in v0.31.0

type PushRequest struct {
	// Connector names the push connector that the link arrives through, one
	// that the set in force declares.
	Connector string `json:"connector"`
	// URL is the link, an http or https URL naming a host.
	URL string `json:"url"`
	// Destination is where the person places the item, one that the set in
	// force declares. Empty leaves the item to the gates.
	Destination string `json:"destination,omitempty"`
}

PushRequest is what POST /api/v1/items reads as a link.

type PushedItem

type PushedItem struct {
	Key  string     `json:"key"`
	Zone store.Zone `json:"zone"`
	// Created is false where the item was already landed, and this was one
	// more sighting of it.
	Created bool `json:"created"`
}

PushedItem is one item a push or a drop landed.

type ReleaseAnswer added in v0.38.0

type ReleaseAnswer struct {
	SchemaVersion int    `json:"schema_version"`
	Connector     string `json:"connector"`
	// Released counts the held queued tasks that this request returned to the
	// claims, which is 0 for a connector already released.
	Released int `json:"released"`
}

ReleaseAnswer is what POST /api/v1/connectors/{name}/release answers: schemas/connector-release.schema.json.

type Repeat

type Repeat string

Repeat says what a second copy of a route's request does, so a client's retry and a handler's dedupe read one answer.

const (
	// RepeatRead reads, so a second copy changes nothing.
	RepeatRead Repeat = "read"
	// RepeatKeyed writes once per Idempotency-Key. The client sets one key
	// per call and sends it on every retry of that call, and the router
	// refuses a request that carries none.
	RepeatKeyed Repeat = "keyed"
	// RepeatByContent writes what its body names, so a second copy of one
	// body leaves the state as the first copy left it.
	RepeatByContent Repeat = "byContent"
	// RepeatOnce may do its work twice when sent twice, so a client sends it
	// again only where the first copy never reached the server.
	RepeatOnce Repeat = "once"
)

type ReplayAnswer

type ReplayAnswer struct {
	SchemaVersion int           `json:"schema_version"`
	Stage         string        `json:"stage"`
	Connector     *string       `json:"connector"`
	Key           *string       `json:"key"`
	PlacedBy      *string       `json:"placed_by"`
	Model         *string       `json:"model"`
	Items         int           `json:"items"`
	Queued        bool          `json:"queued"`
	Estimate      *store.Tokens `json:"estimate"`
}

ReplayAnswer is what POST /api/v1/replays answers: schemas/replay.schema.json.

type ReplayRequest

type ReplayRequest struct {
	Stage     string  `json:"stage"`
	Connector *string `json:"connector"`
	Key       *string `json:"key"`
	PlacedBy  *string `json:"placed_by,omitempty"`
	Model     *string `json:"model,omitempty"`
	Confirm   bool    `json:"confirm"`
}

ReplayRequest asks to run Stage again over the items that Connector and Key select, each absent selecting every item. PlacedBy store.PlacedByPerson narrows them to the labeled items. Model names the model that a measurement arm asks. Confirm runs a model stage once a person has read its estimate.

type Replayable

type Replayable struct {
	// Capability is the capability of the stage's task on item, and false
	// where the stage does not run on item. A replay queues one task of that
	// capability for each item it covers.
	Capability func(item store.Item) (string, bool)
	// Queue, where it is set, queues the stage's tasks for one item instead,
	// and answers whether it queued any. A stage whose task names more than
	// its item, such as a delivery's destination, sets it.
	Queue store.ReplayQueue
	// Estimate is how many of items a model stage would run on, and its
	// tokens by kind over them. Where it is set, a replay answers the
	// estimate and queues nothing until a request confirms it. A model-free
	// stage leaves it nil, and queues at once.
	// Its tokens are nil where it holds no stored run to estimate from.
	Estimate func(ctx context.Context, items []store.Item) (int, *store.Tokens, error)
	// PlacedByPerson, where it is set, is the stage run only over the
	// labeled items, as a measurement of the stage against each placement. A
	// request asks for it with placed_by person.
	PlacedByPerson *Replayable
	// OnModel, where it is set, is a measurement arm: the stage asked of the
	// model that a request names. A request to such a stage names its model,
	// and one to any other stage names none.
	OnModel func(model string) Replayable
}

Replayable is one stage that a replay runs again.

type ReportArrival added in v0.24.0

type ReportArrival struct {
	Key       string `json:"key,omitempty"`
	URL       string `json:"url,omitempty"`
	MediaType string `json:"media_type"`
	Title     string `json:"title,omitempty"`
	// ExternalKey is the source's own key for the item, such as a playlist
	// item's id, which a deleter removes.
	ExternalKey string            `json:"external_key,omitempty"`
	Fields      map[string]string `json:"fields,omitempty"`
	Metrics     map[string]int64  `json:"metrics,omitempty"`
	SourceTS    *string           `json:"source_ts,omitempty"`
	// BlobSHA256 names the item's bytes, which the worker kept through the
	// blob route before it reported the arrival, such as a page's HTML.
	BlobSHA256 *string `json:"blob_sha256,omitempty"`
}

ReportArrival is one item that a poll found at its source. serve lands it under the poll's connector, with the zone and tags that the set in force declares for it. Key or URL names the item, and landing refuses a key that the URL does not derive. Title, ExternalKey and Fields are outsider text where the connector's zone is outside. Metrics are the source's counts by name, which ship on the record channel. SourceTS is when the item was made at its source, in RFC 3339.

type ReportDelivery

type ReportDelivery struct {
	Outcome       string  `json:"outcome"`
	DestinationID *string `json:"destination_id,omitempty"`
	Error         *string `json:"error,omitempty"`
}

ReportDelivery is how one write of a deliver task's item ended: its outcome, the destination's id for the record that holds the item, and the destination's answer where the delivery is pending or refused.

type ReportMetrics added in v0.30.0

type ReportMetrics struct {
	Key     string           `json:"key"`
	Metrics map[string]int64 `json:"metrics"`
}

ReportMetrics is one item's metrics as a refresh read them again at its source, by name, such as a video's views. serve writes them onto each sighting of the item by a connector of the task's source, and stamps when they were read. It changes nothing else of the sighting.

type ReportOutput

type ReportOutput struct {
	Producer        string  `json:"producer"`
	ProducerVersion string  `json:"producer_version"`
	Lens            *string `json:"lens,omitempty"`
	LensVersion     *string `json:"lens_version,omitempty"`
	// NoteDigest is store.NoteDigest of the note that a model read answered.
	NoteDigest    *string       `json:"note_digest,omitempty"`
	State         string        `json:"state"`
	BlobSHA256    *string       `json:"blob_sha256,omitempty"`
	DispatchID    *string       `json:"dispatch_id,omitempty"`
	RunID         *string       `json:"run_id,omitempty"`
	Model         *string       `json:"model,omitempty"`
	Effort        *string       `json:"effort,omitempty"`
	AnsweredModel *string       `json:"answered_model,omitempty"`
	Tokens        *store.Tokens `json:"tokens,omitempty"`
	// InputProducer and InputVersion name the parse that a later stage read.
	InputProducer *string `json:"input_producer,omitempty"`
	InputVersion  *string `json:"input_version,omitempty"`
	// Findings and Spans are a scan's, and a model read's over its
	// suggestion sentence. A scan that found nothing sends an empty list,
	// which reads apart from a stage that sends none. RulesVersion is the
	// version of the rules that made them.
	Findings       []store.Finding `json:"findings"`
	RulesVersion   *string         `json:"rules_version,omitempty"`
	Quality        *int            `json:"quality,omitempty"`
	Fit            *int            `json:"fit,omitempty"`
	SideGuess      *string         `json:"side_guess,omitempty"`
	SideConfidence *float64        `json:"side_confidence,omitempty"`
	// Units are a parse's, numbered from 1 in order, which the service writes
	// as rows of parse_units under the producer and its version.
	Units  []store.Unit    `json:"units,omitempty"`
	Spans  []store.Span    `json:"spans"`
	Answer json.RawMessage `json:"answer,omitempty"`
	Error  *string         `json:"error,omitempty"`
}

ReportOutput is one output a worker reports: each field of an outputs row that the stage's work decides, and a parse's units. The service takes the item and stage from the task and stamps the row, so a column the store adds for itself never changes what a worker sends.

type ReportPage added in v0.40.0

type ReportPage struct {
	BlobSHA256 string `json:"blob_sha256"`
	Title      string `json:"title,omitempty"`
	MediaType  string `json:"media_type,omitempty"`
}

ReportPage is the page that a parse GET at its item's URL, because the item held no bytes, and kept through the blob route before it reported. serve makes it the item's bytes in the write that ends the lease, whatever the parse's outcome, where the item still holds none. Title is the page's own title, which fills an item that holds no title, and is outsider text. MediaType is the type that the item takes where the page is not of the type that the item landed as, such as a PDF. The item's parse is then the parse of that type's extractor, and MediaType is "" otherwise.

type ReportRequest

type ReportRequest struct {
	Token             int64 `json:"token"`
	RetryAfterSeconds int   `json:"retry_after_seconds,omitempty"`
	TaskResult
}

ReportRequest ends a lease with the result of the task's run, under the token that holds the lease. A retry's wait travels in whole seconds.

type RetireRuleRequest added in v0.34.0

type RetireRuleRequest struct {
	Login string `json:"login,omitempty"`
}

RetireRuleRequest retires a routing rule, for the person a service names.

type ReviewAnswer

type ReviewAnswer struct {
	SchemaVersion        int                 `json:"schema_version"`
	Items                []ReviewItem        `json:"items"`
	Destinations         []ReviewDestination `json:"destinations"`
	Choices              []ReviewChoice      `json:"choices"`
	WatchDefaultPlaylist *string             `json:"watch_default_playlist"`
}

ReviewAnswer is what GET /api/v1/review answers: schemas/review-list.schema.json. Destinations are those a placement by destination takes, in the order the set in force declares them, and Choices each of review's choices with the destination it places on. Both are nil where the set in force could not be read. WatchDefaultPlaylist is the playlist a watch takes where the pick names none, and nil where serve names none.

type ReviewChoice added in v0.43.0

type ReviewChoice struct {
	Choice      string  `json:"choice"`
	Side        *string `json:"side"`
	Destination *string `json:"destination"`
	Playlist    bool    `json:"playlist"`
	RunsHere    bool    `json:"runs_here"`
	Missing     *string `json:"missing"`
}

ReviewChoice is one of review's choices under the set in force: the side and the destination it places an item on, each nil for archive and drop, whether its pick names a playlist, whether the client that picks it runs psyche relate on its own machine, and why it places nothing where the set declares no destination it takes.

type ReviewComments added in v0.33.0

type ReviewComments struct {
	State  string          `json:"state"`
	Answer json.RawMessage `json:"answer"`
	TaskID *string         `json:"task_id"`
	Error  *string         `json:"error"`
}

ReviewComments is how the read of an item's comments stands, and its answer once done. The answer is a model's over outsider text.

type ReviewDestination

type ReviewDestination struct {
	Name string  `json:"name"`
	Side *string `json:"side"`
}

ReviewDestination is a declared destination and the side it gives an item. Side is null where the destination drops what it takes.

type ReviewGuess

type ReviewGuess struct {
	Side       string  `json:"side"`
	Confidence float64 `json:"confidence"`
}

ReviewGuess is the quality gate's side guess on an item.

type ReviewItem

type ReviewItem struct {
	Key   string     `json:"key"`
	Zone  store.Zone `json:"zone"`
	Title *string    `json:"title"`
	URL   *string    `json:"url"`
	// Reason is why the item waits, as schemas/review-list.schema.json
	// enumerates it.
	Reason string `json:"reason"`
	// Rule is the routing rule that would have decided an item that waits as
	// rule-would-hide, and nil under any other reason.
	Rule  *ReviewRule  `json:"rule"`
	Guess *ReviewGuess `json:"guess"`
	// QualityAnswer is the quality gate's newest done answer as the store
	// keeps it, and null where the gate gave none.
	QualityAnswer json.RawMessage `json:"quality_answer"`
	// NoteDraft is the note stage's newest done draft as the store keeps it,
	// and null where none was drafted.
	NoteDraft json.RawMessage `json:"note_draft"`
	// MediaType is the item's, and SourceTS when its artifact was made at its
	// source, such as a video's upload, and null where the source gave none.
	MediaType string  `json:"media_type"`
	SourceTS  *string `json:"source_ts"`
	// Channel is who published the item, as its sightings name it, such as a
	// video's channel or a save's subreddit as r/<name>, and null where none
	// does. ChannelFields are the sighting fields that a drop decided by the
	// channel stands for, empty where a drop names the channel's field as its
	// own cause.
	Channel       *string  `json:"channel"`
	ChannelFields []string `json:"channel_fields"`
	// LengthS is how long the item runs in seconds, and Views, Likes and
	// CommentCount how it was received, each null where no sighting carries
	// it.
	LengthS      *int64 `json:"length_s"`
	Views        *int64 `json:"views"`
	Likes        *int64 `json:"likes"`
	CommentCount *int64 `json:"comment_count"`
	// Comments is how the read of what the item's top comments say stands,
	// and nil where no source of this build reads the item's comments.
	Comments       *ReviewComments  `json:"comments"`
	Connectors     []string         `json:"connectors"`
	Sightings      []ReviewSighting `json:"sightings"`
	WaitingSinceTS string           `json:"waiting_since_ts"`
}

ReviewItem is one item that waits on a person's placement, and why.

type ReviewRule added in v0.34.0

type ReviewRule struct {
	Name        string  `json:"name"`
	Destination *string `json:"destination"`
}

ReviewRule is the routing rule whose review share drew an item: its name, and the destination that a keep would place it on, which is nil where a block would drop it.

type ReviewSighting

type ReviewSighting struct {
	Connector string            `json:"connector"`
	Tags      []string          `json:"tags"`
	Fields    map[string]string `json:"fields"`
	Metrics   map[string]int64  `json:"metrics"`
}

ReviewSighting is one connector's arrival of a waiting item: the tags the side gate read and the source's fields, such as a Reddit save's subreddit.

type Route

type Route struct {
	Pattern string
	Scope   string
	Repeat  Repeat
}

Route is one row of the API's route table: its pattern as ServeMux reads it ("POST /api/v1/x"), the scope a service's token needs, and what a repeat does. An empty scope admits a person's token alone.

func (Route) Method

func (r Route) Method() string

Method is the route's HTTP method.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router is where a package registers a handler for each of its rows in the route table.

func (*Router) Handle

func (r *Router) Handle(route Route, h http.HandlerFunc)

Handle serves route with h. A service reaches it only while its token carries the route's scope. A keyed route refuses a request with no Idempotency-Key before h runs, and h reads the key with requestKey.

type Routes

type Routes func(*Router)

Routes registers one package's routes.

func BlobRoutes

func BlobRoutes(l *landing.Lander, log *slog.Logger) Routes

BlobRoutes are the routes for a worker to read and write bytes through, and the report for a person of where the volume and the blob rows disagree.

func ConnectorRoutes

func ConnectorRoutes(cfg ConnectorConfig) Routes

ConnectorRoutes are the routes for a person to apply the declarations, read, run, hold and release each connector, drop a file and push a link or a memo.

func ItemRoutes

func ItemRoutes(st *store.Store, log *slog.Logger) Routes

ItemRoutes are the routes for a person or a service holding ingestion.items.read to read items. A key in the path is one escaped segment, such as reddit%2Ft3_aq7ggd, and a URL there resolves to its key. The parse route answers the item's newest done parse, or the newest of the extractor and at the version that its query names.

func ReplayRoutes

func ReplayRoutes(st *store.Store, stages map[string]Replayable, log *slog.Logger) Routes

ReplayRoutes is the route for a person to run one of stages again over landed items. It is keyed: a request carries an Idempotency-Key, and a repeat under the same key answers the replay that the first one queued.

func ReviewRoutes

func ReviewRoutes(st *store.Store, comments CommentsState, watchDefault string, log *slog.Logger) Routes

ReviewRoutes are the routes for a person, or a service acting for one, to read the review queue, and place, archive or drop an item. A placement, an archive or a drop sent again with the same body appends nothing. watchDefault is the playlist that a watch takes where its pick names none, and "" where serve names none.

func RoutingRuleRoutes added in v0.34.0

func RoutingRuleRoutes(st *store.Store, log *slog.Logger) Routes

RoutingRuleRoutes are the routes for a person, or a service acting for one, to accept a routing rule, retire one, and read each rule's newest version. A write sent again with the same body appends nothing.

func TaskRoutes

func TaskRoutes(st *store.Store, lander *landing.Lander, log *slog.Logger, after AfterStage) Routes

TaskRoutes are the routes for a worker to lease tasks through and read a task's input, and the list for a person to read. lander lands what each poll found, in the write that ends the poll's lease. after runs in the write that ends each item's task done, and nil runs nothing.

func TrustRoutes added in v0.27.0

func TrustRoutes(st *store.Store, log *slog.Logger) Routes

TrustRoutes are the routes for a person, or a service acting for one, to mark an item, read each gate family's standing, and promote a family. A mark or a promotion sent again with the same body changes nothing.

type RoutingRuleAnswer added in v0.34.0

type RoutingRuleAnswer struct {
	SchemaVersion int             `json:"schema_version"`
	Rule          RoutingRuleView `json:"rule"`
	Appended      bool            `json:"appended"`
}

RoutingRuleAnswer is what a write of a routing rule answers: schemas/routing-rule-version.schema.json.

type RoutingRuleRequest added in v0.34.0

type RoutingRuleRequest struct {
	Action      string           `json:"action"`
	Match       connectors.Match `json:"match"`
	Destination string           `json:"destination,omitempty"`
	ReviewShare *float64         `json:"review_share,omitempty"`
	Login       string           `json:"login,omitempty"`
	Proposal    string           `json:"proposal,omitempty"`
}

RoutingRuleRequest accepts a routing rule: schemas/routing-rules.schema.json#/$defs/accepted. A service writing it for a person names the person's Login, and writes it as its own where it names none.

type RoutingRuleView added in v0.34.0

type RoutingRuleView struct {
	Name        string           `json:"name"`
	Sequence    int              `json:"sequence"`
	Action      string           `json:"action"`
	Match       connectors.Match `json:"match"`
	Destination *string          `json:"destination"`
	ReviewShare float64          `json:"review_share"`
	Retired     bool             `json:"retired"`
	Proposal    *string          `json:"proposal"`
	DecidedBy   string           `json:"decided_by"`
	ClientID    *string          `json:"client_id"`
	DecidedTS   string           `json:"decided_ts"`
}

RoutingRuleView is one version of an accepted routing rule: schemas/routing-rules.schema.json#/$defs/version.

type RoutingRulesAnswer added in v0.34.0

type RoutingRulesAnswer struct {
	SchemaVersion int               `json:"schema_version"`
	Rules         []RoutingRuleView `json:"rules"`
}

RoutingRulesAnswer is what GET /api/v1/routing-rules answers: schemas/routing-rules-list.schema.json.

type RunAnswer

type RunAnswer struct {
	SchemaVersion int     `json:"schema_version"`
	Connector     string  `json:"connector"`
	Mode          string  `json:"mode"`
	TaskID        *string `json:"task_id"`
	DueAt         string  `json:"due_at"`
}

RunAnswer is what POST /api/v1/connectors/{name}/runs answers: schemas/connector-run.schema.json. A poll answers its task, and a folder the due time that the scheduler scans it at.

type SectionView added in v0.20.0

type SectionView struct {
	Producer         string  `json:"producer"`
	ProducerVersion  string  `json:"producer_version"`
	N                int     `json:"n"`
	ParentN          *int    `json:"parent_n"`
	Level            int     `json:"level"`
	Kind             string  `json:"kind"`
	Title            *string `json:"title"`
	PDFPageStart     int     `json:"pdf_page_start"`
	PDFPageEnd       int     `json:"pdf_page_end"`
	PrintedPageStart *string `json:"printed_page_start"`
	PrintedPageEnd   *string `json:"printed_page_end"`
	StartPlacedBy    string  `json:"start_placed_by"`
	ChildKey         *string `json:"child_key"`
}

SectionView is one entry of an item's sections, as the sections table holds it.

type SightingView

type SightingView struct {
	Connector      string            `json:"connector"`
	ExternalKey    string            `json:"external_key"`
	Tags           []string          `json:"tags"`
	Fields         map[string]string `json:"fields"`
	Metrics        map[string]int64  `json:"metrics"`
	Zone           store.Zone        `json:"zone"`
	CursorPosition *string           `json:"cursor_position"`
	FirstSeenTS    string            `json:"first_seen_ts"`
	LastSeenTS     string            `json:"last_seen_ts"`
	// MetricsReadTS is when the metrics were last taken from the source, by
	// an arrival or by a refresh of an item in review, and null where no read
	// stamped them.
	MetricsReadTS *string `json:"metrics_read_ts"`
}

SightingView is one connector's arrival of the item.

type SlotGroup added in v0.29.0

type SlotGroup struct {
	Capabilities []string `json:"capabilities"`
	Max          int      `json:"max"`
}

SlotGroup is the capabilities of one slot group in a claim, and the most of them together that the claim leases.

type StageOutput

type StageOutput struct {
	Producer        string  `json:"producer"`
	ProducerVersion string  `json:"producer_version"`
	NoteDigest      *string `json:"note_digest"`
	InputProducer   *string `json:"input_producer"`
	InputVersion    *string `json:"input_version"`
	State           string  `json:"state"`
	DispatchID      *string `json:"dispatch_id"`
	Model           *string `json:"model"`
	Effort          *string `json:"effort"`
	Error           *string `json:"error"`
}

StageOutput is one output that a model stage's task carries: which prompt wrote it over which parse, how far it got, and the dispatch it waits on. Error is why a waiting one has not started, or why a failed one failed.

type SuggestionFindingView

type SuggestionFindingView struct {
	Rule     string  `json:"rule"`
	Severity string  `json:"severity"`
	In       string  `json:"in"`
	Span     *string `json:"span"`
}

SuggestionFindingView is one scanner finding beside a suggestion, in its source or in its sentence.

type SuggestionView

type SuggestionView struct {
	SchemaVersion int    `json:"schema_version"`
	ItemKey       string `json:"item_key"`
	Sentence      string `json:"sentence"`
	// Summary is the same read's summary, and nil where it answered a
	// suggestion alone. The scanner reads only the sentence.
	Summary       *string                 `json:"summary"`
	Title         *string                 `json:"title"`
	URL           *string                 `json:"url"`
	Zone          store.Zone              `json:"zone"`
	Findings      []SuggestionFindingView `json:"findings"`
	PromptVersion string                  `json:"prompt_version"`
	// Lens names the read's lens and its version, as "fleet 1-9dcd3940".
	Lens        *string `json:"lens"`
	SuggestedTS string  `json:"suggested_ts"`
}

SuggestionView is an item's latest suggestion, as schemas/suggestion.schema.json publishes it: its newest done model read whose answer holds a sentence, with the scanner's findings first.

type TaskParseAnswer

type TaskParseAnswer struct {
	SchemaVersion    int          `json:"schema_version"`
	Key              string       `json:"key"`
	Extractor        string       `json:"extractor"`
	ExtractorVersion string       `json:"extractor_version"`
	Units            []store.Unit `json:"units"`
}

TaskParseAnswer is what GET /api/v1/tasks/{id}/parse answers: schemas/task-parse.schema.json. It carries the units alone, because the parse's whole text is the units joined.

type TaskResult added in v0.40.0

type TaskResult struct {
	// Outcome is OutcomeDone, OutcomeFailed or OutcomeRetry.
	Outcome string  `json:"outcome"`
	Error   *string `json:"error,omitempty"`
	// RetryAfter is how long a retry waits before its next claim. The report
	// carries it as RetryAfterSeconds.
	RetryAfter time.Duration `json:"-"`
	// Wait marks a retry that waits on the far end, or on a stopping worker,
	// rather than one that a fault in the run caused. Such a retry spends no
	// attempt, and the service counts how long the task has waited since the
	// first, as the claim's waited_seconds.
	Wait     bool            `json:"wait,omitempty"`
	Outputs  []ReportOutput  `json:"outputs,omitempty"`
	Delivery *ReportDelivery `json:"delivery,omitempty"`
	Arrivals []ReportArrival `json:"arrivals,omitempty"`
	Cursor   *string         `json:"cursor,omitempty"`
	Metrics  []ReportMetrics `json:"metrics,omitempty"`
	// Page is the page that a parse fetched and kept for an item that held
	// no bytes, which the service makes the item's bytes.
	Page *ReportPage `json:"page,omitempty"`
}

TaskResult is how a worker's run of a task ended, as its handler answers it and its report carries it. Outputs are the stage's records for the task's item, and Delivery is how a deliver task's write ended. Arrivals are what a poll that ends done found at its source, in source order, and Cursor the connector's next position, where the poll moves it. Metrics are what a refresh of a source's metrics read again, however it ended, so a refresh stopped partway keeps what it read. Each is written in the same transaction that ends the lease. A poll that ends done has reported every item its source holds past its cursor, so a connector scheduled once never polls after it.

type TaskRetryAnswer

type TaskRetryAnswer struct {
	SchemaVersion int      `json:"schema_version"`
	Task          TaskView `json:"task"`
}

TaskRetryAnswer is what POST /api/v1/tasks/{id}/retries answers: schemas/task-retry.schema.json.

type TaskView

type TaskView struct {
	ID      string  `json:"id"`
	ItemKey *string `json:"item_key"`
	// Connector names a poll's connector, and the connector whose sighting a
	// delete removes from its source.
	Connector   *string `json:"connector"`
	Destination *string `json:"destination"`
	Model       *string `json:"model"`
	// ProposalID names the prompt proposal that a prompt-proposal task drafts.
	ProposalID *string `json:"proposal_id"`
	// Source names the source whose metrics a refresh-metrics task reads
	// again.
	Source         *string `json:"source"`
	Stage          string  `json:"stage"`
	Capability     string  `json:"capability"`
	State          string  `json:"state"`
	HeldBy         *string `json:"held_by"`
	Lapsed         bool    `json:"lapsed"`
	LeaseHolder    *string `json:"lease_holder"`
	LeaseExpiresTS *string `json:"lease_expires_ts"`
	Attempts       int     `json:"attempts"`
	HasError       bool    `json:"has_error"`
	NotBeforeTS    *string `json:"not_before_ts"`
	WaitingSinceTS *string `json:"waiting_since_ts"`
	CreatedTS      string  `json:"created_ts"`
	UpdatedTS      string  `json:"updated_ts"`
}

TaskView is one task as the list shows it. It leaves out the lease token and the task's error, which can quote outsider text, and says in has_error whether one is kept.

type TasksAnswer

type TasksAnswer struct {
	Tasks   []TaskView     `json:"tasks"`
	Workers []store.Worker `json:"workers"`
	// WorkersHidden counts the workers not heard from within
	// WorkersHeardWithin, which the list leaves out unless asked for all.
	WorkersHidden int `json:"workers_hidden"`
}

TasksAnswer is what GET /api/v1/tasks answers: schemas/tasks-list.schema.json.

type TokenGate

type TokenGate interface {
	goapiauth.TokenVerifier
	Ready() error
}

TokenGate verifies a bearer token, and says why it cannot yet.

type TrustRule added in v0.27.0

type TrustRule struct {
	// Run is the straight run of a person's agreeing marks that earns asking,
	// and climbs each rung above 1.
	Run   int     `json:"run"`
	First float64 `json:"first"`
	Lower float64 `json:"lower"`
	Floor float64 `json:"floor"`
	// Shares is the share of drops shown on each rung from 1 up.
	Shares []float64 `json:"shares"`
}

TrustRule is the ladder that every family climbs, as a reader shows it.

type UndeliveredView

type UndeliveredView struct {
	Reason      string  `json:"reason"`
	Side        string  `json:"side"`
	Destination *string `json:"destination"`
	Message     string  `json:"message"`
}

UndeliveredView is why an item reaches no deliverer, in the words of connectors.Undelivered.

type UnpairedAnswer

type UnpairedAnswer struct {
	SchemaVersion int            `json:"schema_version"`
	Files         int            `json:"files"`
	Rows          int            `json:"rows"`
	Unrowed       []UnpairedFile `json:"unrowed"`
	Missing       []BlobAnswer   `json:"missing"`
	Leftovers     []UnpairedFile `json:"leftovers"`
	Unnamed       []BlobAnswer   `json:"unnamed"`
}

UnpairedAnswer is what GET /api/v1/blobs/unpaired answers: schemas/blobs-unpaired.schema.json.

type UnpairedFile

type UnpairedFile struct {
	SHA256     *string `json:"sha256"`
	Path       *string `json:"path"`
	SizeBytes  int64   `json:"size_bytes"`
	ModifiedTS string  `json:"modified_ts"`
}

UnpairedFile is one file in the volume that no row pairs with.

type WaitingView

type WaitingView struct {
	Stage      string `json:"stage"`
	Reason     string `json:"reason"`
	Capability string `json:"capability"`
	// HeldBy is the connector that holds the task, by a person's hold or its
	// first fill.
	HeldBy *string `json:"held_by"`
	// DispatchID is the run's dispatch, where the port started one.
	DispatchID *string `json:"dispatch_id"`
	// LastError is why the task's last try did not go through, such as a
	// dispatch service that did not answer, where it ended so.
	LastError *string `json:"last_error"`
	Message   string  `json:"message"`
}

WaitingView is why an item waits at a model stage.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL