ops

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 25 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.

README

Operations

The owner's workstream board (modules/ops, in Desk). A workstream is a concept of any size: one task, a feature across two repos, or a mesh-wide change such as auth, identity and secrets with smaller workstreams under it. Each is one revisioned Caster document under the contract ops/v1; the module's database is only a working copy. Torque CW-20261120-0117; the design is the Operations module design (Tesseract workspace project/surface/workspace/operations, key operations_module_design_2026_11_20).

Operations never launches anything. Its Tether link is its own and allowlisted (ops.go, allowed): no session launch, team, dispatch, claim or start tool is on it, and a test fails if one is added.

Data: ops/v1

Caster Holds
caster://ops/ws.<id> One workstream: YAML front matter and a Markdown body. Every write is a revision, so Caster's log is its history.
caster://ops/queue ops: v1 and order: [<id>, …]: the Queued band's launch order. One document, so a reorder is one write.
caster://ops/followups Markdown: follow-ups a seed could not place on a workstream, for the owner.

A workstream:

---
ops: v1
id: registry-source-of-truth   # the Ops id: 3-64 of [a-z0-9-], not ending in a dash, never re-keyed; text form ops:<id>
title: Registry as source of truth for workstreams and correlation
owner: owner                   # a name or an agent urn
project: PRJ-20990101-0001     # optional Torque project
status_ns: project/registry/event/status   # optional: where its status entries are read
parent: auth-identity-secrets  # optional: the workstream it sits inside
stage: in_flight               # planned | parked | queued | in_flight | landing | complete | dropped
stage_since: 2026-11-20T13:37:12Z
held: {reason: "awaiting a review", since: ...}   # optional: a flag in any lane, not a stage
active_when:                   # what goal completion means for this one
  - {text: "Torque dispatch ensures workstream ids", done: false, ref: CW-20990101-0002}
links:                         # each kind is a Cite kind, so each link is a chip
  - {kind: work.item, id: garden/ab12cd34, role: origin}
  - {kind: torque.epic, id: EP-20990101-0004, role: scope}
  - {kind: torque.task, id: CW-20990101-0090, role: task, label: "Registry ensure"}
  - {kind: registry.record, id: "workstream:01J…", role: identity}
correlation:
  labels: [registry-source-of-truth]   # free-text unit_plan.workstream_id values it answers to
transitions:                   # the last 50 moves; Caster's log is the whole record
  - {from: queued, to: in_flight, at: ..., by: owner, why: "launched"}
---
## Purpose
## Active means
## Notes

Keys and headings Ops does not know are kept as they are when it writes.

Writes. Every write reads the document again and applies the change to it. Caster has no expected-revision put ("write only if still at revision N"), so a write is checked by the revision it answers: one further on than expected means someone wrote in between and this write now sits over theirs. Their revision is read at once, the change applied to it again and written once more (up to twice), so the window in which the latest revision lacks their change is one read and one put long. What a write reports always matches what Caster holds:

  • success: the change is the latest revision, built on everyone else's;
  • refused ("id taken", or 409 for an update that replaces what its caller read, or when others kept writing through every retry): the change does not stand. The latest foreign revision seen is put back as the latest, and that restore is checked the same way: when someone wrote after this change it is left as they wrote it, and when a write lands on the restore itself, theirs is put back on top. The 409 names the revision now latest.

A race can still lose a write: a writer who builds on this write's revision before it is re-applied builds without the change it overwrote. Caster's history keeps every revision, so nothing is gone from it, and a conditional put in Caster would close the window (a follow-up below). A reorder is worked out on the queue as it is at the write. ops_update needs base_rev for what replaces something read (notes, purpose, active_means, active_when, labels, tick). Link kinds kept: ops.workstream, work.item, torque.task|epic|plan|project|sprint, registry.record (<kind>:<id>, the chip registry:<kind>:<id>), caster.doc, tesseract.item|key, tether.agent|message, url, and tether.team|session, which show as text until they have a resolver.

Ids. The Ops id is 1:1 with the Registry workstream key: Torque dispatch's workstream_ensure(key=<ops id>) mints the workstream:<ULID>, and Ops keeps it as the identity link. Ops never mints a Registry id.

Lifecycle

planned → parked → queued → in_flight → landing → complete, plus the separate discarded state dropped. Any move is allowed, explicit and recorded (transitions, and a Caster revision). Moving into Queued appends the id to ops/queue; moving out removes it. The stage decides membership and the queue document decides order, so a queue that lags a move (two writes) still shows every queued workstream, the unnamed ones last by stage_since. The order is advisory: it does not drive dispatch.

Moves are the owner's. When a workstream's tasks point elsewhere (a task in progress while it is Planned, Parked or Queued; nothing in progress and the rest done or in review while it is In Flight), Ops shows a suggested stage with a button. It never moves anything by itself.

The board shows all six lifecycle stages in that order, including the Queued band. Parked is between Planned and Queued. In Flight means agents are dispatched and actually working. Landing means built work is being taken into use. Complete means the workstream met its goal; finishing every task does not automatically complete a workstream. Dropped remains opt-in.

Old ops/v1 documents remain readable: planning maps to planned; flight (or in flight) to in_flight; review, in_review and adoption to landing; active to complete. A legacy planning or planned document with a nonempty held.reason reads as parked; held remains a separate flag in every stage. Unknown stages retain their raw value, carry a problem marker and appear in an Unknown stage section instead of silently becoming Planned. New writes and tool schemas use the current vocabulary. Reading does not rewrite documents or historical transitions. Existing active_when and Active means document fields remain compatible; the page labels them “Complete when” and “Complete means”.

Before the live writer switches vocabulary, record a read-only report of document revisions, stored stages and mapped stages. The writer owns the live rewrite after the compatible reader is deployed, including staging workstreams from their current operational state. Surface does not bulk-rewrite those documents. Caster revisions preserve the earlier content.

Nesting

A workstream has an optional parent; its children are worked out from the copy. Only a workstream that cannot sit where its document says goes to the top level, with a problem saying why: one whose own parent is not in Ops, one on a loop of parents (lifting one breaks the loop), and the topmost of a chain deeper than allowed. Everything under it stays under it, so nothing drops off the board. This mirrors Tether's workstreams, which carry a parent as ;parent=ws:<id> inside workflow_id rather than as a field. Rules: the parent exists, no loops, and nothing deeper than 6 below the top, counting what is inside the workstream being moved. parent: "" makes one top level.

  • The board shows one level: the top concepts by default. "N inside" steps into one (a breadcrumb leads back), and the window's args say the level, so the agent knows it.
  • The board layout toggle switches between Kanban | Cards | Activity | Fleet | Follow-ups:
    • Activity (modules/ops/web/activity.tsx, activity-row.tsx) renders a flight-itinerary-inspired 3-column timeline ([Timestamp + Elapsed Delta] [Vertical Spine + Semantic Action Icon] [Milestone + Clickable Rich Card + Shaded Callout Div]) grouped into day episodes.
    • Follow-ups (modules/ops/web/followups.tsx) renders caster://ops/followups as a full-page card triage workbench using the ops/followup/v1 template (- [KIND] <Title> | at: <Timestamp> | priority: <needs_you|high|normal|deferred> | owner: <Owner> | workstream: <ops:id> | refs: <...> :: <Summary> :: Action: <...> :: Evidence: <...>), with click-into detail modals, workstream note routing, and inline marks.
  • The Queued band lists queued siblings in launch order (without number prefixes): ops/queue is one global order, and a reorder moves one workstream before or after a queued sibling (same parent), or one place up or down among them.
  • x of y work breakdown & inline card expansion: Every workstream card computes done of total (x of y) units of work across child workstreams, active_when checklist items, and linked/correlated Torque tasks (as new tasks or checks are added, y simply increases). Clicking a workstream card expands the units of work under it inline with status badges, per-unit notes/comments (<UnitNotesInline /> backed by Surface Marks), Request status, <ObjectActionsMenu />, and a button to open the full workstream detail view in-place.
  • Tasks and activity roll up: a workstream's roll-up reads its own links and every descendant's.

Activity

Read when a drill-in or the board's Activity layout opens, on its refresh button, and every minute while an Operations window is open (ops.activity); cached per workstream in the module database for a minute. One feed, newest first, each row {at, source, state, summary, task, workstream, verified}:

Source Read
Torque (torque) torque_task_get of each linked task and of the children of linked epics (torque_task_list epic_id) and plans (torque_plan_list_children)
Status comments (comment) torque_comment_list per task; lines starting STATUS, REVIEW, VERDICT, INCIDENT or Independent review
Status stream (status) event_list on the workstream's status_ns, filtered to its tasks. Shown as claimed: no writer is trusted yet
Ops (ops) its own transitions

Bounded: 80 tasks and 6 calls at once per roll-up, 20 comments per task, 300 rows kept. A task's read is kept for a minute and shared by every roll-up (a task under a concept and under its child is read once); a finished task's comments are not read. A STATUS comment that mirrors a status-stream entry for the same task is shown once, as the status entry. Rows sort by their parsed time.

Directly linked tasks also reveal their immediate parent when it is a Torque kind=plan, and reveal epics through epic_id (or an EP parent). Discovered containers expand through the same reader as explicit links: their children count and feed Activity, ops_get, and the focused slot. Discovery is one level only, seeded by the first 80 distinct direct task links; it never recursively walks child tasks or parent cycles. Parent metadata is cached for a minute; failed reads stay retryable. Explicit links take precedence over discovered provenance. A discovered plan is marked “via CW-…”; “Link this plan” uses the existing owner-only link route on its source workstream, then refreshes. Discovery itself never writes links. Epic-derived task rows show the epic and discovery task.

Linked torque.plan entries expand into ordered phases and tasks in the Tasks tab. Plan and phase states come from torque_plan_get; child task states and STATUS comments use the same task cache and feed as direct and epic links. A task linked several ways counts once. Plans and their children are cached for a minute, including across parent/child workstream roll-ups. Child pages are followed up to the 80-task bound; incomplete reads are shown as problems, not as an empty plan. At most 80 distinct plans are expanded per roll-up. ops_get includes plans, and the focused workstream's slot context includes cached plans and task counts.

The board's Activity layout merges the same per-workstream caches across every level, newest first, with a Cite chip (ops:<id>) on each row. Workstream, current stage, source and since (UTC) filters are kept in the window args and applied before the global 300-row limit. Rows repeated in parent and child roll-ups appear once; a task explicitly linked to different workstreams keeps each association. GET /activity accepts workstream, stage, source, since and refresh=1.

A shared refresh cycle starts with in-flight workstreams, then visits all other lanes. Each batch reads at most 12 workstreams, 240 Torque/status calls (including plan and epic expansion), and takes at most a minute; the existing six-call concurrency limit applies. Automatic batches run at most once a minute, even with multiple viewers. Remaining workstreams continue in the next batch, so later lanes cannot starve. Fresh caches are reused; a manual refresh starts a new cycle when none is pending. Budget-interrupted reads preserve the previous complete cache and retry later. The response reports pending work, truncation and source errors; partial coverage is shown in the view. Background refresh uses the same cycle and publishes ops.activity; the page does not poll. Caster board synchronization keeps its existing separate read-back schedule.

Live agents

The board's Agents tab reads Tether's tether_agents_live snapshot: launched sessions and kit seats, with authoritative host, busy/idle state, activity time and summary, and workstream identity. Busy is shown as Awake and idle as Sleeping. Missing state stays unknown; stale registrations are excluded. Agent and workstream references open Cite identities.

GET /agents and the read-only ops_agents tool share the same cache with Fleet. At most one Tether snapshot is fetched per 15 seconds, with a 12-second deadline and a 500-row display bound. Errors are cached too, and a truncated result is labelled incomplete. The open Agents/Fleet tab triggers server refresh events; the page does not poll. A failed refresh explicitly labels any previous observation. If Tether explicitly reports tether_agents_live missing, the reader temporarily uses bounded tether_session_list and health reads (two list pages, at most 50 health calls, four at once). A banner explains that kit-booted agents appear when the unified feed is deployed; unknown hosts remain labelled. Every expired cache retries the unified feed automatically. Other source failures never trigger this fallback and never appear as an empty healthy fleet.

Assigned, no live agent

Gap G6 of the system-of-record brief (Torque CW-20261121-0152). Each roll-up checks its open tasks (linked, epic, plan or discovered) that are assigned or claimed against the live agents, using the same cached reader as the Agents tab. A task's holder is read from its typed Torque record (liveness.go, taskAssignment): Torque's assignment object (CW-20261121-0148: assignee_urn, tether_session_id, team_run_id, claim_id, source owner|doing|claim|dispatch, state active|expired|released, end_reason), else metadata.owner_urn when it is an agent urn (until 0148 ships; Torque then projects it into assignment). A released assignment is no holder; an expired one is flagged whoever is live. A holder bound to a session is live only when that session is (session:<id>); otherwise its urn, or its team run (seat:<run>), must be live.

  • Each task carries holder: {agent, session, run, source, live: live|none|unknown, why, unconfirmed}.
  • The roll-up and the board card list no_live_agent (task ids); ops_list, ops_get and the slot's in-flight rows carry it too.
  • Each flagged task adds a feed row with source liveness (state no_live_agent) to the workstream's and the global activity, filterable as source=liveness. It does not replace a card's latest activity.
  • The check never guesses: unreadable or truncated live agents mark holders unknown and flag nothing. The fallback source (no kit seats) flags as unconfirmed.
  • Roll-ups with no held task do not read the live agents.

Torque's half (CW-20261121-0148) expires an assignment when its session ends or its lease lapses; Ops covers the window before that and owner assignments, which have no session.

Seeding from the tracker

The owner's workstream tracker (kept by the Local Orchestrator: threads with stage, phase, owner, summary, phase note and [Torque id, title, state] tasks, plus loose follow-ups) is read as data and mapped, never copied. Always a preview first: POST /seed/preview (or the agent's ops_seed, which takes the JSON only) keeps a plan in the module database and opens it; the owner edits it in the window and applies it there. Nothing is written before that, and the agent cannot apply one. A path on this machine is read only from the owner's page: an absolute path to a regular .json file (not a link), at most 4 MB, with one answer for every way it can fail. Apply claims the kept preview atomically (it applies once) and applies the preview as kept, never a plan sent with the request; an apply that wrote nothing gives the claim back.

Tracker Ops
stage: flight In Flight
stage: queued Queued (end of the band, in tracker order)
stage: review Landing
stage: landed Landing: merged or deployed work is being adopted. Complete requires the workstream goal to be met, not just its tasks to be done.
name title, and the id (a slug of it, editable in the preview; a name with too few plain letters gets a made-up id, flagged)
tasks torque.task links (role task, the title as label; a run CW-…-0097..0105 is expanded). The tracker's state is not copied: Torque is read live.
summary, phase_note, phase_label notes
owner owner (flagged when missing)
followups onto a workstream's notes when they name one of its tasks, or two of its distinctive name words (also a workstream Ops had already); the rest, and any whose workstream was not made, to caster://ops/followups

Proposed concepts (conceptRules in seed.go), each only when it gathers two threads, all off until the owner ticks them: Auth, identity and secrets (Warden, Gatecrasher, identity and service tokens, the approval flow); Observability and status; MCP gateway and the Ops MCP; Agent runtime and chat; Fleet and placement. A ticked concept is made as a workstream and its threads nest under it; an unticked one leaves them at the top. An id Ops already has is skipped, never overwritten. A preview is applied once.

testdata/tracker.json is a synthetic tracker in the same shape (invented threads, people and ids), for the tests.

Routes (/api/m/ops/)

Route
GET /agents Live agent observations shared with Fleet
GET /activity Global feed with workstream, stage, source and since filters; refresh=1 refreshes a bounded batch
GET /board (?force=1) Every workstream with its cached roll-up line, the queue, the owner's follow-ups
POST /workstreams Create
GET /workstreams/{id} One, with its children and the path above it
PUT /workstreams/{id} Update (base_rev; 409 when it moved on)
POST /workstreams/{id}/move {stage, why}
POST /workstreams/{id}/links, DELETE /workstreams/{id}/links?kind=&ref= Link, unlink
GET /workstreams/{id}/activity (?refresh=1) The roll-up and feed
GET /workstreams/{id}/history, GET /workstreams/{id}/at/{rev} Transitions and Caster revisions; one revision's text
POST /queue/reorder `{id, before
POST /seed/preview, `GET PUT /seed/{plan}, POST /seed/{plan}/apply`

Routes that change something (and a seed preview from a path) are the owner's own actions, from the page, and ask nothing; anyone else (an outside client, the agent) gets 403 and uses the ops_* tools, which ask the owner. Writes are recorded as the actor the core names. Every write publishes ops.changed {id?, what}.

Agent tools and slot

Tool Level
ops_agents read Live agent identity, host, state and last activity
ops_list read The board by lane at one level (parent, or all), the queue, filters stage, owner, held
ops_get read One workstream, its roll-up and last 10 activity rows
ops_activity read Without id, global activity; with id, a workstream roll-up. Filters: workstream, stage (global), since, source, task; bounded limit
ops_create, ops_update, ops_move, ops_queue_reorder, ops_link, ops_unlink write Asked of the owner each time (an approval can stand)
ops_seed act A seed preview from the tracker's JSON, opened for the owner; writes nothing

The ops slot (views ops, ops.workstream, ops.seed) gives lane counts, the queue head, what is in flight with held reasons, task counts and the age of its last activity, and the workstream in front, all from the working copy, plus a one-line latest activity across workstreams. Cite: ops:<id> is ops.workstream, resolved from the copy only; opening it runs ops.open.

Settings: ops.tether_command, or ops.tether_url with ops.tether_token_file.

Not yet

  • Status stream: read per status_ns only (no cross-project read), and every row is "claimed" until trusted writers are configured. It is near-empty today, so Torque is the main source.
  • Registry identity: the identity link is added by hand; there is no lookup by key until workstream_ensure is deployed, and no correlation records as activity.
  • Teams: no tether.team Cite kind; team links show as text. No grouping of activity by team, no StateTimeline.
  • ops_request_agent, ops_launch_request, ops_drop (phase 1.5), and the Planner → Task Ops hook.
  • A conditional put in Caster (caster_put with an expected revision, refused when the item moved on). Until Caster has one, a race between writers can still lose a write (see Writes); with it, putOver becomes a plain compare-and-swap loop.
Settle and Send to orchestration

A Complete workstream can be settled. Its stage stays complete; Caster keeps settled_at (RFC3339), settled_by, and settled_summary, a one-paragraph snapshot of the reviewed revision, completion checks, linked-task counts, tracking read time and source warnings. Complete is the owner's judgment: unfinished linked tasks or unavailable tracking sources are recorded, not silently treated as done. A same-stage transition records the action. Unsettle clears those three fields and records another transition; previous summaries remain in Caster revisions.

Board and ops_list hide settled workstreams by default. Show settled includes them; Activity and direct workstream History remain available. Hiding a settled parent promotes unfinished children to its nearest visible ancestor in the board projection only. It never reparents or deletes documents. Unsettle before moving a settled workstream to another stage.

  • POST /workstreams/{id}/settle and /unsettle: {base_rev}.
  • GET /board?show_settled=1; ops_list accepts show_settled: true.
  • ops_settle: {id, base_rev}, a write tool requiring owner approval.

Send to orchestration is an owner-only action on Planned, Parked and Queued cards and workstream headers. The dialog accepts an optional note. Configure ops.sender_address with Surface's Tether identity; the existing Ops Tether link must permit tether_message_send. This is the only additional Tether capability. It asks the Lead Orchestrator to sequence and launch by current priorities (or its judgment when none are set) and queue for execution. The Orchestrator handles acknowledgement, stage movement and dispatch.

POST /workstreams/{id}/orchestration takes {base_rev, request_id, note}. The request ID is a fresh UUID per intentional send and must stay unchanged for retries. The note is limited to 4096 bytes. Tether receives kind=request, subject Sequence and launch: <title>, and these flat payload fields:

  • kind=request, to=@claude-code, re=ops:<id>, attention=agent, awaiting=@claude-code, plus the subject and request body;
  • intent=sequence_and_launch, schema_version=1, request_id, workstream_id (the Ops ID / Registry key), optional registry_id from the workstream's Registry identity link, title, stage, links:[{kind,id}], note, cite=ops:<id>, requested_by, and RFC3339 at.

Before delivery, orchestration_request stores {at,note,message_id,request_id} with an empty receipt, plus the exact sender and serialized payload for recovery. Those recovery fields stay out of the public Workstream JSON. Delivery uses a stable Tether idempotency key. A failed or ambiguous send remains Send pending; retry sends the same envelope, including after restart. A received message ID is recorded without overwriting intervening stage changes, adds an Ops activity row, and displays Sent to orchestration. Pending requests must be retried before starting another. The badge confirms delivery, not execution. Caster remains the record; no local-only outbox or dispatch mechanism is introduced.

All three action routes reject delegates. Sending has no agent tool: an agent cannot bypass the owner's dialog through Ops. Settling through ops_settle uses the usual owner-approved write-tool path.

Fleet

The board's Fleet tab and read-only ops_fleet tool share the Cerberus health projection (GET /fleet?host=...). The selected machine is saved in the window's host argument. Tether agent placement uses the same reader and row as Agents; unknown placement is counted, never inferred from names.

The preferred source is cerberus_fleet_snapshot v1: at most 100 hosts and 12 recent five-minute buckets, with CPU utilization, memory and per-mount disk usage. Empty buckets and nullable metrics remain unknown. Each bucket shows the latest actual observation, not an interpolated value. Older collectors may lack CPU utilization or per-mount disks. If the snapshot read fails, the view labels its fallback to bounded cerberus_host_list (four pages of 25) plus the selected host's cerberus_host_samples (one hour, 5m grain, 12 entries). Fallback CPU is core count, and fallback history contains averages. Load is never called CPU utilization. Inventory connection details and hardware identifiers are omitted.

Fleet refreshes every 30 seconds while mounted, without overlapping browser requests. The module shares cached reads, including failures, for 30 seconds across tools/windows; upstream calls have a 20-second request deadline. No background probes or machine-control actions are added.

Documentation

Overview

Package ops is Operations: the owner's workstream board. Each workstream is one revisioned Caster document under the ops/v1 contract (caster://ops/ws.<id>), the Queued band's order is one document (caster://ops/queue), and the module's database is only a working copy read again every 15 seconds. Workstreams nest: a workstream is a concept of any size, with an optional parent. Activity and tasks are read from Torque (and the Tesseract status stream where a workstream names one) and rolled up from children. README.md has the format.

Ops reaches Tether through its own allowlisted link. It never launches anything: no session, team, dispatch or claim tool is on its list, whatever is asked.

Index

Constants

View Source
const (
	HolderLive    = "live"
	HolderNone    = "none"
	HolderUnknown = "unknown"
)

Liveness of a task's holder.

View Source
const (
	StagePlanned  = "planned"
	StageParked   = "parked"
	StageQueued   = "queued"
	StageInFlight = "in_flight"
	StageLanding  = "landing"
	StageComplete = "complete"
	StageDropped  = "dropped"
)

The owner's six lifecycle stages, plus the separate discarded state.

View Source
const Contract = "v1"

Contract is the value of a workstream's `ops:` key.

View Source
const FollowupsName = "followups"

FollowupsName is the document of the owner's follow-ups the seed could not place.

View Source
const Namespace = "ops"

Namespace is Ops' namespace in Caster.

View Source
const QueueName = "queue"

QueueName is the queue's document name.

View Source
const SourceLiveness = "liveness"

SourceLiveness is the feed source for "assigned, no live agent" rows.

Variables

View Source
var (
	// ErrNoCaster says there is no way to reach Caster configured.
	ErrNoCaster = errors.New("Caster is not reachable: set ops.tether_command (or ops.tether_url) in Settings")
	// ErrNotFound says there is no such workstream.
	ErrNotFound = errors.New("there is no such workstream")
)
View Source
var ErrApplied = errors.New("this preview was applied already; make a new one")

ErrApplied says a preview was applied already (or is being applied): make a new one.

View Source
var StageLabel = map[string]string{
	StagePlanned: "Planned", StageParked: "Parked", StageQueued: "Queued", StageInFlight: "In Flight",
	StageLanding: "Landing", StageComplete: "Complete", StageDropped: "Dropped",
}

StageLabel is a stage as a person reads it.

Stages are the lifecycle in board order, followed by the optional discarded state.

Functions

func CountsText

func CountsText(c map[string]int) string

CountsText is a roll-up as a card says it: "2 doing · 1 review · 5 todo".

func DocRef

func DocRef(name string) string

DocRef is a document's Caster ref.

func Finished

func Finished(s string) bool

Finished says whether a task status is an end.

func ReadStage added in v0.12.0

func ReadStage(s string) string

ReadStage maps legacy ops/v1 and tracker vocabulary without changing the document. Unknown values remain unknown so migration callers can flag them for review.

func ReadTracker

func ReadTracker(path string) ([]byte, error)

ReadTracker reads a tracker from a path on this machine: an absolute path to a regular .json file (not a link), opened once and read to at most maxTracker bytes. Only the owner's page gives a path.

func Ref

func Ref(id string) string

Ref is a workstream as text: ops:<id>, the Cite form.

func ValidID

func ValidID(id string) bool

ValidID reports whether id can name a workstream: a slug of 3 to 64 letters, digits and dashes, not ending in a dash (the page's Cite detector drops a trailing dash as punctuation). It is also the Registry workstream key (1:1), so it is never re-keyed.

func ValidStage

func ValidStage(s string) bool

ValidStage reports whether s is a current stage accepted for new writes.

func WSName

func WSName(id string) string

WSName is a workstream's document name in the namespace.

func When

func When(s string) time.Time

When reads an entry's time (RFC 3339, with or without fractions, or Torque's "2006-01-02 15:04:05"). The zero time when it cannot.

Types

type Board

type Board struct {
	Workstreams []Workstream `json:"workstreams"`
	// Queue is the Queued band in launch order: every workstream at stage queued, in the
	// order the queue document gives, then any it does not name yet (oldest first).
	Queue []string `json:"queue"`
}

Board is every workstream in the copy and the queue order.

func (Board) Descendants

func (b Board) Descendants(id string) []Workstream

Descendants are a workstream's children, theirs, and so on (not itself), from b. All has already broken loops and over-deep chains, so every level is walked.

func (Board) Find

func (b Board) Find(id string) (Workstream, bool)

Find is a workstream in b.

type Body

type Body struct {
	Lead     string
	Sections []Section
}

Body is an item's body split on its "## " headings. Text before the first heading and sections with headings the kind does not name are kept as they are.

func ParseBody

func ParseBody(body string) Body

ParseBody splits a body on its "## " headings.

func (Body) Get

func (b Body) Get(name string) string

Get is a section's text (heading matched without case, spaces or dashes).

func (*Body) Put

func (b *Body) Put(name, text string, order []string)

Put sets a section's text, in place when it is there; a new one goes in the order given (the kind's sections) among those it names, else at the end.

func (Body) String

func (b Body) String() string

String is the body again.

type Brief added in v0.15.0

type Brief struct {
	GeneratedAt  string        `json:"generated_at"`
	Since        string        `json:"since"`
	Scope        string        `json:"scope"`
	Sources      []BriefSource `json:"sources"`
	Warnings     []string      `json:"warnings,omitempty"`
	NeedsMe      BriefSection  `json:"needs_me"`
	Stalled      BriefSection  `json:"stalled"`
	ChangedSince BriefSection  `json:"changed_since"`
	Suggestions  BriefSection  `json:"suggestions"`
	InFlight     BriefSection  `json:"in_flight"`
	Untracked    BriefSection  `json:"untracked"`
	Fleet        BriefFleet    `json:"fleet"`
	Budgets      []BriefBudget `json:"budgets"`
	Gaps         []string      `json:"gaps"`
	Markdown     string        `json:"markdown"`
}

type BriefAgent added in v0.15.0

type BriefAgent struct {
	Name  string `json:"name"`
	Host  string `json:"host,omitempty"`
	State string `json:"state"`
}

type BriefBudget added in v0.15.0

type BriefBudget struct {
	Source string `json:"source"`
	Title  string `json:"title"`
	Status string `json:"status"`
	Line   string `json:"line"`
}

type BriefChange added in v0.15.0

type BriefChange struct {
	At      string `json:"at"`
	Kind    string `json:"kind"` // transition or the activity source (torque, comment, status)
	Summary string `json:"summary"`
	Ref     string `json:"ref,omitempty"`
}

type BriefFleet added in v0.15.0

type BriefFleet struct {
	Agents   map[string]int `json:"agents"` // by state
	ByHost   map[string]int `json:"by_host"`
	Down     []string       `json:"down"` // machines not online, agents not awake
	Warnings []string       `json:"warnings,omitempty"`
}

type BriefItem added in v0.15.0

type BriefItem struct {
	ID     string   `json:"id"`
	Ref    string   `json:"ref"`
	Title  string   `json:"title"`
	Stage  string   `json:"stage"`
	Owner  string   `json:"owner,omitempty"`
	Why    string   `json:"why,omitempty"`
	Latest string   `json:"latest,omitempty"`
	At     string   `json:"at,omitempty"`
	Age    string   `json:"age,omitempty"`
	Refs   []string `json:"refs,omitempty"`
	// In flight only.
	Counts map[string]int `json:"counts,omitempty"`
	Doing  []string       `json:"doing,omitempty"`
	Agents []BriefAgent   `json:"agents,omitempty"`
	// Changed only: the moves and activity since the window opened, newest first.
	Changes []BriefChange `json:"changes,omitempty"`
}

BriefItem is one line of a section: an item, why it is there, and refs to its sources.

type BriefSection added in v0.15.0

type BriefSection struct {
	Items     []BriefItem `json:"items"`
	Truncated int         `json:"truncated,omitempty"` // items left out by max_items
}

type BriefSource added in v0.15.0

type BriefSource struct {
	Name    string `json:"name"`
	AsOf    string `json:"as_of,omitempty"`
	Stale   bool   `json:"stale"`
	Problem string `json:"problem,omitempty"`
}

type Card

type Card struct {
	Workstream
	Tasks      string         `json:"tasks,omitempty"`
	TaskCounts map[string]int `json:"task_counts,omitempty"`
	TaskList   []Task         `json:"task_list,omitempty"`
	Last       *Entry         `json:"last,omitempty"`
	Suggest    string         `json:"suggest,omitempty"`
	SuggestWhy string         `json:"suggest_why,omitempty"`
	// NoLiveAgent is the open tasks assigned or claimed that no live agent holds.
	NoLiveAgent []string `json:"no_live_agent,omitempty"`
}

Card is a workstream as the board draws it: the document's fields, and what the cached roll-up says (no network on the board).

type Caster

type Caster interface {
	// List is every document in the namespace, latest revision each.
	List(ctx context.Context) ([]Head, error)
	// Get is a document's text at a revision (0 = latest). ok is false when there is none.
	Get(ctx context.Context, name string, rev int) (it Item, ok bool, err error)
	// Put makes a new revision (none when the content is the same) and returns it.
	Put(ctx context.Context, name, content, title, mime string) (rev int, err error)
	// Log is a document's revisions, newest first.
	Log(ctx context.Context, name string) ([]Revision, error)
}

Caster is where the workstreams live: namespace "ops", one document per workstream (ws.<id>) and the queue (queue). The store keeps a working copy and writes through this. A port of Work's GatewayCaster (modules/work/caster.go), not an import: the seam forbids it.

type Check

type Check struct {
	Text string `yaml:"text" json:"text"`
	Done bool   `yaml:"done" json:"done"`
	Ref  string `yaml:"ref,omitempty" json:"ref,omitempty"`
}

Check is one line of a workstream's definition of "active".

type Conflict

type Conflict struct {
	Rev  int
	Note string
}

Conflict says the change does not stand: the document moved on, and it could not be applied to what is there. Rev is the revision now latest; Note, when set, says what happened.

func (*Conflict) Error

func (c *Conflict) Error() string

type Correlation

type Correlation struct {
	Labels            []string `yaml:"labels,omitempty" json:"labels,omitempty"`
	TetherWorkstreams []string `yaml:"tether_workstreams,omitempty" json:"tether_workstreams,omitempty"`
}

Correlation is how a workstream answers to things that do not link to it.

type Doc

type Doc struct {
	Body  string
	Plain bool
	// contains filtered or unexported fields
}

Doc is a document's text: YAML front matter and a markdown body, or (Plain) a YAML document with no body, as the queue is. Keys Ops does not know are kept as they are when it writes the document again. Ported from modules/work (doc.go): a module may not import another.

func ParseDoc

func ParseDoc(text string) (*Doc, error)

ParseDoc splits front matter from the body. Text without front matter is all body.

func ParsePlain

func ParsePlain(text string) (*Doc, error)

ParsePlain reads a YAML document (a kind, a view). A leading "---" line is allowed.

func (*Doc) Bool

func (d *Doc) Bool(key string) bool

func (*Doc) Decode

func (d *Doc) Decode(key string, v any) error

Decode reads a key into v (for the structured keys: fields, links, material, published).

func (*Doc) Del

func (d *Doc) Del(key string)

Del takes a key out.

func (*Doc) Has

func (d *Doc) Has(key string) bool

Has says whether the key is there.

func (*Doc) Num

func (d *Doc) Num(key string) float64

func (*Doc) Set

func (d *Doc) Set(key string, v any) error

Set writes a key, in place when it is there, at the end when it is not.

func (*Doc) Str

func (d *Doc) Str(key string) string

Str reads a key (as Num, Bool and Strings do for their shapes) ("" or zero when it is absent or of another shape).

func (*Doc) String

func (d *Doc) String() string

String is the item's text again.

func (*Doc) Strings

func (d *Doc) Strings(key string) []string

type Entry

type Entry struct {
	At         string   `json:"at"`
	Source     string   `json:"source"` // torque, comment, status, ops, liveness
	State      string   `json:"state,omitempty"`
	Summary    string   `json:"summary"`
	SubjectURN string   `json:"subject_urn,omitempty"`
	Task       string   `json:"task,omitempty"`
	Workstream string   `json:"workstream"`
	Refs       []string `json:"refs,omitempty"`
	// Verified is true only for a status entry from a trusted writer. Today no writer is
	// trusted (phase 2), so status rows show as claimed.
	Verified bool `json:"verified"`
}

Entry is one row of the merged feed.

type FleetDisk added in v0.13.0

type FleetDisk struct {
	Mount string   `json:"mount"`
	Used  *float64 `json:"used"`
	Total *float64 `json:"total"`
}

FleetDisk exposes only health facts. Connection details, inventory serials and credentials from Cerberus never cross this projection into the page or agent context.

type FleetHost added in v0.13.0

type FleetHost struct {
	Name      string            `json:"name"`
	Role      string            `json:"role"`
	Provider  string            `json:"provider,omitempty"`
	Owner     string            `json:"owner,omitempty"`
	Labels    map[string]string `json:"labels,omitempty"`
	State     string            `json:"state"`
	Reason    string            `json:"reason,omitempty"`
	LastSeen  string            `json:"last_seen,omitempty"`
	ProbedAt  string            `json:"probed_at,omitempty"`
	CheckedAt string            `json:"checked_at,omitempty"`
	Stale     bool              `json:"stale"`
	Metrics   FleetMetrics      `json:"metrics"`
}

type FleetMetrics added in v0.13.0

type FleetMetrics struct {
	CPUPercent      *float64          `json:"cpu_percent,omitempty"`
	MemoryUsed      *float64          `json:"memory_used,omitempty"`
	Disks           []FleetDisk       `json:"disks,omitempty"`
	CPU             *float64          `json:"cpu,omitempty"`
	CPUModel        string            `json:"cpu_model,omitempty"`
	GPUCount        *int              `json:"gpu_count,omitempty"`
	GPUModel        string            `json:"gpu_model,omitempty"`
	OS              string            `json:"os,omitempty"`
	OSVersion       string            `json:"os_version,omitempty"`
	Arch            string            `json:"arch,omitempty"`
	Kernel          string            `json:"kernel,omitempty"`
	DiskMount       string            `json:"disk_mount,omitempty"`
	UptimeSeconds   *int64            `json:"uptime_seconds,omitempty"`
	Tools           map[string]bool   `json:"tools,omitempty"`
	Units           map[string]string `json:"units,omitempty"`
	Load1           *float64          `json:"load1,omitempty"`
	Load5           *float64          `json:"load5,omitempty"`
	Load15          *float64          `json:"load15,omitempty"`
	MemoryAvailable *float64          `json:"memory_available,omitempty"`
	MemoryTotal     *float64          `json:"memory_total,omitempty"`
	DiskFree        *float64          `json:"disk_free,omitempty"`
	DiskTotal       *float64          `json:"disk_total,omitempty"`
}

type FleetResult added in v0.13.0

type FleetResult struct {
	Source string `json:"source"`

	Hosts     []FleetHost   `json:"hosts"`
	Host      string        `json:"host,omitempty"`
	Samples   []FleetSample `json:"samples"`
	FetchedAt string        `json:"fetched_at"`
	Truncated bool          `json:"truncated"`
	Warning   string        `json:"warning,omitempty"`
	// contains filtered or unexported fields
}

type FleetSample added in v0.13.0

type FleetSample struct {
	SampleAt string `json:"sample_at,omitempty"`
	At       string `json:"at"`
	Count    int    `json:"count"`
	FleetMetrics
}

type GatewayCaster

type GatewayCaster struct {
	Link func() (tetherlink.Caller, error)
}

GatewayCaster reaches Caster through the Tether gateway. Link is asked for the client at each call, so the module's settings are read at the moment of use.

func (GatewayCaster) Get

func (g GatewayCaster) Get(ctx context.Context, name string, rev int) (Item, bool, error)

func (GatewayCaster) List

func (g GatewayCaster) List(ctx context.Context) ([]Head, error)

func (GatewayCaster) Log

func (g GatewayCaster) Log(ctx context.Context, name string) ([]Revision, error)

func (GatewayCaster) Put

func (g GatewayCaster) Put(ctx context.Context, name, content, title, mime string) (int, error)
type Head struct {
	Name    string
	Rev     int
	Title   string
	Updated string
}

Head is a listed document: its name in the namespace and latest revision.

type Held

type Held struct {
	Reason string `yaml:"reason" json:"reason"`
	Since  string `yaml:"since,omitempty" json:"since,omitempty"`
}

Held marks a workstream blocked, in any lane. It is a flag, not a stage.

type Holder added in v0.16.0

type Holder struct {
	// Agent is the assignee or claimant: an agent urn (msg://agent/...).
	Agent string `json:"agent,omitempty"`
	// Session and Run name a claim's holder when Torque records one.
	Session string `json:"session,omitempty"`
	Run     string `json:"run,omitempty"`
	// Source is how it was assigned: Torque's owner, doing, claim or dispatch.
	Source string `json:"source"`
	// Live is "live", "none" (nobody live holds it) or "unknown" (the check could not tell).
	Live string `json:"live"`
	// Why says what was found, for the drill-in and the agent.
	Why string `json:"why,omitempty"`
	// Unconfirmed is set when the fallback source, which cannot see kit-booted agents, found none.
	Unconfirmed bool `json:"unconfirmed,omitempty"`
}

Holder says who a task is assigned to or claimed by, and whether they are live.

type InputError

type InputError struct{ Msg string }

InputError is a change refused for what it asks.

func (*InputError) Error

func (e *InputError) Error() string

type Item

type Item struct {
	Name    string
	Rev     int
	Title   string
	Content string
}

Item is a document's text at a revision.

type Link struct {
	Kind  string `yaml:"kind" json:"kind"`
	ID    string `yaml:"id" json:"id"`
	Role  string `yaml:"role,omitempty" json:"role,omitempty"`
	Label string `yaml:"label,omitempty" json:"label,omitempty"`
}

Link is a typed link: Kind is a Cite kind, so every link is a chip.

type NewWorkstream

type NewWorkstream struct {
	ID          string      `json:"id"`
	Title       string      `json:"title"`
	Owner       string      `json:"owner,omitempty"`
	Project     string      `json:"project,omitempty"`
	StatusNS    string      `json:"status_ns,omitempty"`
	Stage       string      `json:"stage,omitempty"`
	Parent      string      `json:"parent,omitempty"`
	Links       []Link      `json:"links,omitempty"`
	ActiveWhen  []Check     `json:"active_when,omitempty"`
	Correlation Correlation `json:"correlation,omitempty"`
	Purpose     string      `json:"purpose,omitempty"`
	Notes       string      `json:"notes,omitempty"`
	Why         string      `json:"why,omitempty"`
}

NewWorkstream is what a create takes.

type OrchestrationRequest added in v0.12.1

type OrchestrationRequest struct {
	At        string `json:"at" yaml:"at"`
	Note      string `json:"note" yaml:"note"`
	MessageID string `json:"message_id" yaml:"message_id"`
	RequestID string `json:"request_id" yaml:"request_id"`
	Sender    string `json:"-" yaml:"sender,omitempty"`
	Payload   string `json:"-" yaml:"payload,omitempty"`
}

OrchestrationRequest also retains a pending delivery's exact envelope, so retries after a lost response or restart use the same sender, payload and idempotency key.

type Patch

type Patch struct {
	Title       *string `json:"title,omitempty"`
	Owner       *string `json:"owner,omitempty"`
	Project     *string `json:"project,omitempty"`
	StatusNS    *string `json:"status_ns,omitempty"`
	Parent      *string `json:"parent,omitempty"`
	Purpose     *string `json:"purpose,omitempty"`
	ActiveMeans *string `json:"active_means,omitempty"`
	Notes       *string `json:"notes,omitempty"`
	// AppendNote adds a paragraph to the notes, dated.
	AppendNote *string `json:"append_note,omitempty"`
	// Held sets the held flag with a reason; "" clears it.
	Held *string `json:"held,omitempty"`
	// ActiveWhen replaces the checklist; Tick sets one line's done by its index; AddCheck adds one.
	ActiveWhen *[]Check  `json:"active_when,omitempty"`
	Tick       *Tick     `json:"tick,omitempty"`
	AddCheck   *Check    `json:"add_check,omitempty"`
	Labels     *[]string `json:"labels,omitempty"`
}

Patch is what an update may change. A nil field is left as it is.

type Phase added in v0.9.0

type Phase struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Order int    `json:"order"`
	State string `json:"state"`
}

type Plan added in v0.9.0

type Plan struct {
	ID         string  `json:"id"`
	Title      string  `json:"title"`
	Status     string  `json:"status"`
	Workstream string  `json:"workstream"`
	Phases     []Phase `json:"phases"`
	Via        string  `json:"via,omitempty"` // directly linked task that revealed this plan
	Truncated  bool    `json:"truncated,omitempty"`
}

Plan is a linked Torque plan and its ordered phases. Tasks remain in Rollup.Tasks, deduplicated with direct and epic links, and join the same activity reads.

type Revision

type Revision struct {
	Rev   int    `json:"rev"`
	At    string `json:"at"`
	Title string `json:"title"`
}

Revision is one entry of a document's history.

type Rollup

type Rollup struct {
	Workstream string         `json:"workstream"`
	Counts     map[string]int `json:"counts"`
	Tasks      []Task         `json:"tasks"`
	Plans      []Plan         `json:"plans,omitempty"`
	Entries    []Entry        `json:"entries"`
	// Last is the newest entry, for a card's "last activity" line.
	Last *Entry `json:"last,omitempty"`
	// Suggest is a stage the tasks suggest the workstream is in, when it differs (a hint:
	// moves are the owner's).
	Suggest    string   `json:"suggest,omitempty"`
	SuggestWhy string   `json:"suggest_why,omitempty"`
	Errors     []string `json:"errors,omitempty"`
	// NoLiveAgent is the open tasks assigned or claimed that no live agent holds.
	NoLiveAgent []string `json:"no_live_agent,omitempty"`
	FetchedAt   string   `json:"fetched_at"`
	Unavailable bool     `json:"unavailable,omitempty"`
}

Rollup is a workstream's tasks and activity, with its children's.

type Section

type Section struct {
	Heading string
	Text    string
}

type SeedConcept

type SeedConcept struct {
	Accept  bool     `json:"accept"`
	ID      string   `json:"id"`
	Title   string   `json:"title"`
	Why     string   `json:"why"`
	Members []string `json:"members"`
	Stage   string   `json:"stage"`
	Exists  bool     `json:"exists,omitempty"`
}

SeedConcept is a proposed umbrella workstream over several threads.

type SeedFollowup

type SeedFollowup struct {
	Index      int    `json:"index"`
	Text       string `json:"text"`
	Workstream string `json:"workstream,omitempty"`
	Why        string `json:"why,omitempty"`
}

SeedFollowup is a follow-up line and where it goes: a workstream's notes, or the owner's list.

type SeedItem

type SeedItem struct {
	Include   bool   `json:"include"`
	ID        string `json:"id"`
	Title     string `json:"title"`
	Stage     string `json:"stage"`
	FromStage string `json:"from_stage"`
	Phase     string `json:"phase,omitempty"`
	Owner     string `json:"owner,omitempty"`
	// Parent is a proposed concept (applied only when that concept is ticked), another seed
	// workstream, or a workstream already in Ops.
	Parent string `json:"parent,omitempty"`
	Notes  string `json:"notes"`
	Links  []Link `json:"links"`
	// Exists marks an id Ops has already: applying skips it and never overwrites.
	Exists   bool     `json:"exists,omitempty"`
	Problems []string `json:"problems,omitempty"`
}

SeedItem is one tracker thread as a workstream.

type SeedPlan

type SeedPlan struct {
	ID             string         `json:"id"`
	Source         string         `json:"source"`
	TrackerUpdated string         `json:"tracker_updated,omitempty"`
	CreatedAt      string         `json:"created_at"`
	AppliedAt      string         `json:"applied_at,omitempty"`
	Workstreams    []SeedItem     `json:"workstreams"`
	Concepts       []SeedConcept  `json:"concepts"`
	Followups      []SeedFollowup `json:"followups"`
	// Mapping says, in lines, how the tracker's fields became Ops'.
	Mapping []string `json:"mapping"`
}

SeedPlan is a preview: what applying would write, as the owner edits it.

func Preview

func Preview(t Tracker, source string, existing map[string]bool) SeedPlan

Preview maps a tracker. existing are the ids Ops has already.

type SeedResult

type SeedResult struct {
	Created   []string `json:"created"`
	Skipped   []string `json:"skipped"`
	Failed    []string `json:"failed"`
	Followups int      `json:"followups_for_owner"`
	// Noted are the workstreams Ops had already that got follow-ups on their notes.
	Noted []string `json:"noted"`
}

SeedResult is what an apply did.

type SessionRow added in v0.13.0

type SessionRow struct {
	ID             string `json:"id"`
	Kind           string `json:"kind"`
	AgentID        string `json:"agent_id"`
	AgentName      string `json:"agent_name"`
	AgentRef       string `json:"agent_ref,omitempty"`
	Host           string `json:"host"`
	State          string `json:"state"`
	RawState       string `json:"raw_state"`
	LastActivityAt string `json:"last_activity_at,omitempty"`
	LastActivity   string `json:"last_activity,omitempty"`
	WorkstreamID   string `json:"workstream_id,omitempty"`
	TaskID         string `json:"task_id,omitempty"`
	Stale          bool   `json:"stale"`
	Warning        string `json:"warning,omitempty"`
}

SessionRow is the shared Agents/Fleet view of an authoritative Tether observation. Unknown observations stay unknown: lifecycle state and age do not imply idleness.

type SessionsResult added in v0.13.0

type SessionsResult struct {
	Sessions  []SessionRow `json:"sessions"`
	FetchedAt string       `json:"fetched_at"`
	Truncated bool         `json:"truncated"`
	Warning   string       `json:"warning,omitempty"`
}

type Store

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

Store is the working copy of Ops' documents in Caster: a mirror for quick views and for reading while Caster is away. Every write goes to Caster at once, each after reading the document again, and the new revision is kept here. Nothing lives only here.

Caster's put takes no expected revision, so a write is checked by the revision it answers: one further on than the read plus one means someone else wrote in between. Their revision is then read, the change applied to it again and written once more (putOver), so neither write is lost; a change that cannot be applied to theirs puts theirs back and is refused.

func NewStore

func NewStore(db *sql.DB, caster Caster) *Store

NewStore is the working copy in db over caster. caster may be nil: the copy is then read only and says why.

func (*Store) All

func (s *Store) All(ctx context.Context) (Board, error)

All reads the copy. A workstream whose parent is missing, makes a loop or nests too deep is shown at the top level, with a problem saying why, so nothing drops off the board.

func (*Store) Apply

func (s *Store) Apply(ctx context.Context, p SeedPlan, by string) (SeedResult, error)

Apply writes a preview as the owner left it (the caller has claimed it): the ticked concepts, then the included workstreams (a parent before its children), each with the follow-ups placed on it. Follow-ups for a workstream Ops had already go onto its notes; any whose workstream was not made go to the owner's list with the unplaced ones. An id Ops has already is skipped. Errors on one workstream do not stop the others.

func (*Store) At

func (s *Store) At(ctx context.Context, id string, rev int) (Item, bool, error)

At is a workstream's document at a revision.

func (*Store) Cached

func (s *Store) Cached(ctx context.Context) map[string]Rollup

Cached are the cached roll-ups of every workstream, for the board (no network).

func (*Store) ClaimPlan

func (s *Store) ClaimPlan(ctx context.Context, id string) error

ClaimPlan marks a preview applied, atomically: only one apply can claim it. ErrApplied when it was claimed before.

func (*Store) Create

func (s *Store) Create(ctx context.Context, in NewWorkstream, by string) (Workstream, error)

Create writes a new workstream (refused when the id is taken, even by a write that lands between the check and this one: theirs is put back) and, at stage queued, puts it at the end of the queue.

func (*Store) Followups

func (s *Store) Followups(ctx context.Context) []string

Followups is the owner's follow-up list from the copy.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (Workstream, bool, error)

Get is one workstream from the copy, with its children.

func (*Store) LastError

func (s *Store) LastError() string

LastError is what went wrong on the last refresh, if anything.

func (s *Store) Link(ctx context.Context, id string, l Link) (Workstream, error)

Link adds a typed link (the same kind and id again replaces its role and label).

func (*Store) Log

func (s *Store) Log(ctx context.Context, id string) ([]Revision, error)

Log is a workstream's revisions in Caster, newest first.

func (*Store) Move

func (s *Store) Move(ctx context.Context, id, to, why, by string) (Workstream, error)

Move changes a workstream's stage, records the move, and keeps the queue: moving into Queued puts it at the end of the queue, moving out takes it off.

func (*Store) NewPlan

func (s *Store) NewPlan(ctx context.Context, p SeedPlan) (SeedPlan, error)

NewPlan keeps a new preview.

func (*Store) Plan

func (s *Store) Plan(ctx context.Context, id string) (SeedPlan, bool, error)

Plan is a kept preview, with when it was applied.

func (*Store) Refresh

func (s *Store) Refresh(ctx context.Context, force bool) (int, error)

Refresh brings the copy up to date with Caster: one listing, and a read of each document whose revision moved. At most every refreshEvery unless forced. It returns how many changed.

func (*Store) Refreshed added in v0.15.0

func (s *Store) Refreshed() time.Time

Refreshed is when the copy was last refreshed from Caster (zero before the first).

func (*Store) ReleasePlan

func (s *Store) ReleasePlan(ctx context.Context, id string) error

ReleasePlan gives a claimed preview back, for an apply that wrote nothing.

func (*Store) Reorder

func (s *Store) Reorder(ctx context.Context, id, before, after, dir string) ([]string, error)

Reorder moves a queued workstream within the Queued band, among its siblings only (the queued workstreams with the same parent): before or after another, or one place up or down. The move is worked out on the queue as it is in Caster at the write, not as the copy last saw it.

func (*Store) SavePlan

func (s *Store) SavePlan(ctx context.Context, p SeedPlan) error

SavePlan keeps the owner's edits to a preview that has not been applied (ErrApplied when it has, or is being).

func (*Store) Settle added in v0.12.1

func (s *Store) Settle(ctx context.Context, id string, baseRev int, tracking Rollup, by string) (Workstream, error)

Settle preserves the final tracking in the revisioned document. It is not a stage: the workstream remains complete and addressable by its original Ops/Caster references.

func (s *Store) Unlink(ctx context.Context, id, kind, ref string) (Workstream, error)

Unlink takes a link out. One that is not there is not an error.

func (*Store) Unsettle added in v0.12.1

func (s *Store) Unsettle(ctx context.Context, id string, baseRev int, by string) (Workstream, error)

func (*Store) Update

func (s *Store) Update(ctx context.Context, id string, baseRev int, p Patch) (Workstream, error)

Update applies a patch over baseRev (0: whatever is there now, for a patch that replaces nothing the caller read).

type Taken

type Taken struct{ ID string }

Taken says a create found the id taken (by someone who wrote it first).

func (*Taken) Error

func (t *Taken) Error() string

type Task

type Task struct {
	ID         string `json:"id"`
	Title      string `json:"title"`
	Status     string `json:"status"`
	Updated    string `json:"updated,omitempty"`
	Workstream string `json:"workstream"`
	// Via is how the workstream reaches it: a link, epic or plan.
	Via           string `json:"via,omitempty"`
	PlanID        string `json:"plan_id,omitempty"`
	PhaseID       string `json:"phase_id,omitempty"`
	ParentID      string `json:"parent_id,omitempty"`
	EpicID        string `json:"epic_id,omitempty"`
	Kind          string `json:"kind,omitempty"`
	DiscoveredVia string `json:"discovered_via,omitempty"`
	// Holder is who the task is assigned to or claimed by, and whether they are live
	// (liveness.go); nil when nobody is.
	Holder *Holder `json:"holder,omitempty"`
}

Task is one Torque task as the roll-up shows it.

type Tick

type Tick struct {
	Index int  `json:"index"`
	Done  bool `json:"done"`
}

Tick sets one active-when line's done.

type Tracker

type Tracker struct {
	Updated   string          `json:"updated"`
	Note      string          `json:"note"`
	Threads   []TrackerThread `json:"threads"`
	Followups []any           `json:"followups"`
}

Tracker is the tracker's JSON.

func ParseTracker

func ParseTracker(raw []byte) (Tracker, error)

ParseTracker reads the tracker's JSON.

type TrackerThread

type TrackerThread struct {
	Name       string  `json:"name"`
	Stage      string  `json:"stage"`
	Phase      string  `json:"phase"`
	PhaseLabel string  `json:"phase_label"`
	Owner      string  `json:"owner"`
	Summary    string  `json:"summary"`
	PhaseNote  string  `json:"phase_note"`
	Tasks      [][]any `json:"tasks"`
}

TrackerThread is one thread of the tracker.

type Transition

type Transition struct {
	From string `yaml:"from" json:"from"`
	To   string `yaml:"to" json:"to"`
	At   string `yaml:"at" json:"at"`
	By   string `yaml:"by,omitempty" json:"by,omitempty"`
	Why  string `yaml:"why,omitempty" json:"why,omitempty"`
}

Transition is one lifecycle move.

type UsageAlert added in v0.13.1

type UsageAlert struct {
	At        string `json:"at"`
	Provider  string `json:"provider,omitempty"`
	Model     string `json:"model,omitempty"`
	Operation string `json:"operation,omitempty"`
	Error     string `json:"error,omitempty"`
}

type UsageBudget added in v0.13.1

type UsageBudget struct {
	Provider    string   `json:"provider"`
	Model       string   `json:"model,omitempty"`
	Level       string   `json:"level,omitempty"`
	Scope       string   `json:"scope,omitempty"`
	Window      string   `json:"window,omitempty"`
	WindowStart string   `json:"window_start,omitempty"`
	ResetAt     string   `json:"reset_at,omitempty"`
	MaxCostUSD  *float64 `json:"max_cost_usd,omitempty"`
	MaxRequests *float64 `json:"max_requests,omitempty"`
	MaxTokens   *float64 `json:"max_tokens,omitempty"`
	Exhausted   bool     `json:"exhausted"`
	Error       string   `json:"error,omitempty"`
}

type UsageCard added in v0.13.1

type UsageCard struct {
	ID     string `json:"id"`
	Title  string `json:"title"`
	Kind   string `json:"kind"` // gateway or subscription
	Status string `json:"status"`
	// Used and Limit share Unit; either is nil when the source does not report it.
	Used  *float64 `json:"used"`
	Limit *float64 `json:"limit"`
	// Remaining is a balance (credits) where the source reports one instead of a limit.
	Remaining *float64 `json:"remaining,omitempty"`
	Unit      string   `json:"unit,omitempty"`
	Window    string   `json:"window,omitempty"`
	ResetAt   string   `json:"reset_at,omitempty"`
	Summary   string   `json:"summary,omitempty"`
	Gap       string   `json:"gap,omitempty"`
	Observed  string   `json:"observed_at,omitempty"`
}

type UsageDetail added in v0.13.1

type UsageDetail struct {
	Windows    []UsageWindow `json:"windows,omitempty"`
	ByProvider []UsageTotals `json:"by_provider,omitempty"`
	ByModel    []UsageTotals `json:"by_model,omitempty"`
	Budgets    []UsageBudget `json:"budgets,omitempty"`
	Alerts     []UsageAlert  `json:"alerts,omitempty"`
	Spend      []UsageSpend  `json:"spend,omitempty"`
	Recent     []UsageEvent  `json:"recent,omitempty"`
	Notes      []string      `json:"notes,omitempty"`
	Warnings   []string      `json:"warnings,omitempty"`
}

UsageDetail is a card's details. Only the gateway has them so far. Sections are omitted when a source has nothing of that kind.

type UsageEvent added in v0.15.0

type UsageEvent struct {
	ID     string   `json:"id"`
	At     string   `json:"at"`
	What   string   `json:"what"`
	Amount *float64 `json:"amount,omitempty"`
	Unit   string   `json:"unit,omitempty"`
	Note   string   `json:"note,omitempty"`
	OK     bool     `json:"ok"`
}

UsageEvent is one recent charge.

type UsageResult added in v0.13.1

type UsageResult struct {
	Cards     []UsageCard  `json:"cards"`
	Source    string       `json:"source,omitempty"`
	Detail    *UsageDetail `json:"detail,omitempty"`
	FetchedAt string       `json:"fetched_at"`
}

type UsageSpend added in v0.15.0

type UsageSpend struct {
	Provider string  `json:"provider"`
	Calls    int64   `json:"calls"`
	Failed   int64   `json:"failed"`
	CostUSD  float64 `json:"cost_usd"`
}

UsageSpend is one provider's spend in a window.

type UsageTotals added in v0.13.1

type UsageTotals struct {
	Key             string `json:"key"`
	Requests        int64  `json:"requests"`
	Successes       int64  `json:"successes"`
	Errors          int64  `json:"errors"`
	InputTokens     int64  `json:"input_tokens"`
	OutputTokens    int64  `json:"output_tokens"`
	ReasoningTokens int64  `json:"reasoning_tokens"`
	CacheReadTokens int64  `json:"cache_read_tokens"`
}

UsageTotals is one aggregate row from the gateway: a provider, a model or a whole window.

type UsageWindow added in v0.13.1

type UsageWindow struct {
	Label string      `json:"label"`
	Since string      `json:"since"`
	Total UsageTotals `json:"total"`
}

type Workstream

type Workstream struct {
	OrchestrationRequest *OrchestrationRequest `json:"orchestration_request,omitempty"`
	SettledAt            string                `json:"settled_at,omitempty"`
	SettledBy            string                `json:"settled_by,omitempty"`
	SettledSummary       string                `json:"settled_summary,omitempty"`
	ID                   string                `json:"id"`
	Title                string                `json:"title"`
	Owner                string                `json:"owner,omitempty"`
	Project              string                `json:"project,omitempty"`
	StatusNS             string                `json:"status_ns,omitempty"`
	Stage                string                `json:"stage"`
	StageSince           string                `json:"stage_since,omitempty"`
	Parent               string                `json:"parent,omitempty"`
	Held                 *Held                 `json:"held,omitempty"`
	ActiveWhen           []Check               `json:"active_when"`
	Links                []Link                `json:"links"`
	Correlation          Correlation           `json:"correlation"`
	Transitions          []Transition          `json:"transitions"`
	Purpose              string                `json:"purpose,omitempty"`
	ActiveMeans          string                `json:"active_means,omitempty"`
	Notes                string                `json:"notes,omitempty"`

	Rev     int    `json:"rev"`
	Updated string `json:"updated,omitempty"`
	// Children are the workstreams whose parent this is (from the copy, not the document).
	Children []string `json:"children"`
	// Problem says why the document could not be read whole.
	Problem string `json:"problem,omitempty"`
}

Workstream is one ops/v1 document as the app reads it.

Jump to

Keyboard shortcuts

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