Repository navigation
Description
Settled in a grill-with-docs session (PR #2064, Q1.1–Q4.2; ADR 0016, ADR 0018, ADR 0026).
Problem Statement
Today the Console gives the Day shift rich live views of active work (Inbox, Lanes, Stages, Waterfall, Logs, Cron jobs, Resources) and specialized evaluation pages (Experiments, Scores, Bug origins), while historical Run metrics sit behind an unlinked page that dumps raw JSON in a <pre> block and a weekly CLI summary with active blind spots:
- There is no visual or tabular Metrics page in Console navigation to see whether factory Commands are succeeding or failing over time, whether reliability, churn, or post-merge quality is improving or regressing compared with the preceding period, or where runs are breaking.
- Outcome-blind averaging in weekly trends averages duration, Repairs, and CI rounds across all outcomes, so a wave of 30-second startup crashes makes speed and repair averages look better, while crashed runs with no recorded outcome are lumped together with currently live runs.
- Pass-through Pickup run dispatchers appear beside the Ticket runs and Spec runs they dispatched, inviting double-counted outcomes.
- Neither
thirdshift's own version nor structured stopping stages and failure categories are recorded on the Command record, making it hard to correlate spikes to a release or spot systemic failure clusters without opening dozens of individual logs. - Trends read only the serving OS account on one machine: configured Other-account Commands are omitted, paired Fleet machines cannot be viewed together, offline or retired Fleet machines vanish from history, and a sleeping or NATted laptop machine cannot report its Run metrics outward to an always-on Fleet Console.
Solution
Turn Metrics into a first-class Console view (with a matching m keyboard jump), paired with the metrics CLI command and local Console API endpoint under ADR 0016 and ADR 0026. Keep every signal in its own units—never combined into a composite score—and keep live "health" reserved for per-Command Slow and Silent observations.
Organize Metrics around four survivorship-safe signal groups in tension—(1) yield and kept pull-request survival, (2) post-merge quality (Bug origins and weekly Scores criterion pass rates) and human-attention load (Stop and Needs you counts), (3) succeeded-run efficiency, first-pass clean rate, effective time/cost per succeeded delivery, and wasted-effort share, and (4) stage bottlenecks against repository Usual ranges and session friction—backed by daily and weekly time buckets, window presets paired with preceding-window deltas, release/configuration correlation (thirdshift version, Harness, Model, repository, Command kind, OS account), structured failure-stage and failure-category breakdowns that link straight to the offending Commands, Other-account Command inclusion, client-side Fleet aggregation with per-peer snapshot caching, and holder-bound report-scoped outbound reporting so a sleeping or NATted worker machine appears read-only on an always-on Console without any external database server.
User Stories
- As the Day shift, I want a Metrics link in Console navigation with keyboard shortcut
m, so that I can reach historical factory Run metrics from any Console page in one keystroke or click. - As the Day shift, I want every Run metrics signal kept separate in its own units rather than collapsed into a synthetic score, so that improvements in one dimension never disguise regressions in another.
- As the Day shift, I want the Console Metrics page to default to my whole Fleet whenever paired Fleet machines or reported peer snapshots exist, while letting me switch to This machine or any individual Fleet machine, so that one Console shows my entire factory at once.
- As a CLI or script user, I want
metrics --fleetto aggregate across my paired Fleet machines and cached/reported peer snapshots while keeping each machine's Console API endpoint strictly local, so that CLI and Console behavior match without lending saved Fleet credentials over the API. - As the Day shift, I want single-Command
metrics <command>inspection to keep working unchanged in text, JSON, and the Console API, so that existing per-Command inspection workflows do not break. - As the Day shift, I want Metrics to support window presets (
7ddaily,30ddaily,12wweekly, andAllweekly) alongside explicit date bounds and daily or weekly grain selection, so that I can inspect both 24-hour regressions and multi-month trajectories. - As the Day shift, I want each window paired with an explicit comparison against the immediately preceding equal-length window showing deltas, sample sizes (
n), andobserved/missingcoverage, so that I can tell immediately whether a signal is getting better or worse and how much evidence backs it. - As the Day shift, I want work Commands (
Ticket run,Spec run,Base fix,Review run,Fix run,Triage run,Architect run,Security run) counted by their own Command kind without pooling child Ticket runs and parent Spec runs into one combined denominator, so that short high-volume runs cannot mask failures in heavier workflows. - As the Day shift, I want pass-through Pickup run dispatchers excluded from outcome denominators unless a Pickup run itself failed or died before dispatching work, and skipped idle Passes excluded completely, so that picked-up runs are never double-counted and idle cron ticks never dilute ratios.
- As the Day shift, I want ended runs classified into four explicit visible stacks—
Succeeded,Failed(including crashed/died runs, kept distinct from currentlyLiveruns),Paused(Paused Command on plan/quota limits), andStopped(human Stop)—with success/failure ratio computed asSucceeded / (Succeeded + Failed)and exact sub-outcomes preserved on drilldown, so that quota pauses and manual Stops remain visible without counting as factory failures. - As the Day shift, I want kept pull-request survival (
mergedversus unmergedclosed, read locally from the Console's kept GitHub state with zero live GitHub calls duringmetrics) shown alongside run outcomes, so that runs whose pull requests were later closed unmerged do not look indistinguishable from durable deliveries. - As the Day shift, I want confirmed Bug origins per merged cohort, weekly calibrated Scores criterion pass rates from Scoring runs, and Stop / Needs you counts surfaced alongside run yield, so that post-merge quality and human-attention load balance throughput.
- As the Day shift, I want duration, Repairs, and CI rounds averaged over succeeded runs rather than across early crashes, alongside first-pass clean rate (
Repairs == 0among succeeded runs), effective time and cost per succeeded delivery (all attempts divided by succeeded runs, separated by Model and Harness), and wasted time/spend share on failed, crashed, or stopped runs, so that startup crash waves never flatter speed or repair averages and wasted effort is directly visible. - As the Day shift, I want stage bottleneck rates (share of stages exceeding their repository Usual range, already excluding Suspended time) and per-session trajectory friction (
repeated_tool_calls,tool_errors,permission_denials,killed_work, non-zerodestructive_commands, and security-finding holds) surfaced without vanity metrics (lines of code, raw context-free token totals, pooled cross-kind pass rates, or raw review-finding counts as quality proxies), so that every displayed number points to an actionable improvement. - As the Day shift, I want each Command record to persist the
thirdshiftversion at startup—falling back toservice.versionin historical Session traces when absent—and I want Metrics to mark version transitions on the timeline and slice bythirdshiftversion alongside Harness (and harness version), Model, repository, Command kind, and OS account, so that I can correlate improvements or regressions to specific releases or configuration shifts. - As the Day shift, I want
CommandRecordcompletion to persist the structured stopping stage and deterministic failure category (falling back to the last recorded stage on historical records) and render a "Where runs failed" breakdown on Metrics, so that systemic failure clusters (such as worktree acquisition, CI watch, or Self-merge holds) stand out without opening individual logs. - As the Day shift, I want clicking any failure bucket or "Where runs failed" row on Metrics to link through to matching History or Command detail views, so that investigating a spike takes one click from aggregate trend to the offending Commands.
- As the Day shift running multiple OS accounts on one server, I want configured readable Other-account Commands included in
metricsand the Console API with OS-account tagging and filtering, so that Metrics covers the same local factory scope as Inbox andstatus. - As the Day shift watching a Fleet, I want the watching Console to cache each paired peer's last-fetched bucket summary locally on disk so that when a Fleet peer is temporarily unreachable or retired, its past history stays visible in Fleet Metrics (explicitly marked cached/offline with its last-seen timestamp) without needing a centralized PostgreSQL server.
- As the Day shift running additional compute on a sleeping or NATted laptop VM alongside a 24/7 Console, I want to issue a narrow
report-scoped Console API token bound to that worker's machine name (console token create <holder> --scopes report), so that the worker can upload only its own named Run metrics snapshot over HTTPS and cannot read private data, act on Commands, administer the host, or overwrite another machine's slot. - As the Day shift running Commands on my laptop VM, I want both an explicit
metrics --push <peer>CLI command and automatic best-effort outbound push when a Command finishes (when configured in User config, logging a warning and never failing the Command if offline), so that even ad-hoc manual laptop runs appear read-only on my 24/7 Console before I close the laptop lid. - As the Day shift viewing a pushed or offline peer's metrics on my 24/7 Console, I want to see its
pushed_at/ cached age and compact failure summaries cleanly, with read-only messaging where live inbound Command logs cannot be reached, so that unreachable workers never produce broken detail links. - As the Day shift reading Metrics on a desktop monitor or a 390px phone across built-in and custom Themes, I want server-rendered HTML tables paired with lightweight static inline SVG/CSS stacked outcome bars, compact sparklines, and version-transition markers styled through Theme tokens with zero client-side charting library and zero motion, so that trends are scannable at a glance on any device without breaking ADR 0018.
- As a maintainer pruning multi-gigabyte raw Session traces months later, I want compact Command records and Scoring checkpoints to retain everything Metrics needs, so that multi-year factory history occupies tens of megabytes per machine with zero external database maintenance.
Implementation Decisions
- Route, CLI twin, and API parity. Keep the existing
/metricspage route,/api/v1/metricslocal API endpoint, andmetricsCLI command. Add Metrics (data-jump="m") to Console navigation alongside Experiments, Scores, and Bug origins. Preserve single-Commandmetrics <command>inspection unchanged. All top-of-page GET query filters on/metricsmirror CLI flags onmetrics: scope (machine=fleet|<name>/--fleet/--machine), window preset (window=7d|30d|12w|all/--window), time grain (grain=day|week/--grain), date bounds (from,through), repository (repo, repeatable), Command kind (kind), Harness (harness), Model (model),thirdshiftversion (version), and OS account (account). Registermetrics --fleetandmetrics --pushin the CLI-only parity exclusions inventory in lockstep with ADR 0026 so local/api/v1/metricsnever relays saved Fleet or push credentials. - Durable local storage and Fleet snapshot cache (no external database). Per-machine Command records, Scoring run checkpoints, and local kept GitHub state remain the sole durable source of truth;
metricsmakes zero live GitHub calls. When a Console or CLI aggregates Fleet metrics, it fetches compact bucketed/api/v1/metricssummaries from reachable paired Fleet machines and writes each peer's latest snapshot atomically to a per-machine peer-metrics snapshot under the watching account's logs directory. When a paired peer is unreachable or only has a saved snapshot (offline, sleeping, or retired), its cached buckets remain included in Fleet views and explicitly badged as cached/offline with their last-seen/pushed timestamp. - Outbound
reporttoken scope and worker push. Extend Console API token scopes withreport. A token created for<holder>withreportscope validates<holder>as a Fleet machine name and authorizes only HTTPS uploads to a dedicated Fleet-metrics report endpoint that atomically writes that holder's own named peer-metrics snapshot (rate-limiting failed tokens under existing token rules, granting zeroread,security,act,run, oradminpermissions, and refusing writes to any other machine name). Add User config and Credentials support on a worker machine to configure one or more outbound report targets (address + savedreporttoken), exercised explicitly viametrics --push [<peer>]and triggered automatically on a best-effort bounded timeout when a Command finishes (emitting a warning and never failing the Command if the network or target Console is unreachable). Snapshots include compact per-failure summary metadata (Command name, kind, repository, timestamp, stopping stage/category, pull request/issue URL if public) so a watching Console can display read-only failure context when live inbound Command logs are unreachable. - Command record enrichment and historical fallback. Persist
thirdshift_versionon every new Command record at Command startup; when reading older records lackingthirdshift_version, recoverservice.versionfrom their referenced Session traces when available (reusing existing trace-signal caching so unchanged traces are not re-parsed on every read). At Command completion, persist optional structuredstopped_atstage and deterministic failure category (held,waiting,crashed, orstage_failed) from the structured recovery and failure-ending values rather than discarding them into free-textcause; older failed/dead records fall back to their last recorded stage anddiedversusfailedstatus, reportingobservedandmissingcounts honestly. - Other-account Commands. Update metrics snapshot loading to merge configured readable Other-account Commands on the machine alongside the serving OS account, tagging rows and buckets with their owning account and supporting account filtering, matching Inbox and
status. - Hierarchy, deduplication, and outcome taxonomy. Count work Commands (
Ticket run,Spec run,Base fix,Review run,Fix run,Triage run,Architect run,Security run) in separate per-kind series/rows (never summing parent Spec runs and child Ticket runs into one pooled pass rate). Exclude pass-through Pickup run dispatchers from outcome denominators unless the Pickup run itself failed or died before dispatching a child Command; exclude skipped idle Passes altogether. Separateliveruns from crasheddiedrecords (outcomeabsent and writer dead). Classify ended runs into four explicit classes—Succeeded,Failed(includingdied),Paused, andStopped—preserving raw sub-outcomes for breakdown/hover, and define success rate asSucceeded / (Succeeded + Failed). - Four-pillar signal calculations, windows, and version markers. Support both UTC/local-consistent daily buckets and Monday weekly buckets across presets (
7ddaily,30ddaily,12wweekly,Allweekly) plus customfrom/throughranges, computing an equal-duration preceding-window comparison (delta, currentn, priorn, andobserved/missingcoverage) when a bounded window is active:- Yield & pull-request survival: per-kind
Succeeded,Failed(withDied),Paused,Stopped,Live, success/failure rate, and kept pull-requestmergedversus unmergedclosedcounts from local kept GitHub state. - Post-merge quality & human load: confirmed Bug origins per merged cohort, weekly Scores criterion pass rates from local Scoring run checkpoints, and Stop / Needs you counts.
- Efficiency, wasted effort & Repair churn: duration, Repairs, and CI rounds computed strictly over
Succeededruns; first-pass clean rate (Repairs == 0among succeeded runs); effective time and cost per succeeded delivery (total time or priced/observed spend across all ended attempts divided by succeeded runs, broken down by Model and Harness so missing pricing on one Harness never distorts another); and wasted time/spend share on failed, died, and stopped runs. - Stage bottlenecks & session friction: per-stage share above repository Usual range (
Position::Above), per-sessionrepeated_tool_calls,tool_errors,permission_denials,killed_work, non-zerodestructive_commandsincidence, andsecurity > 0Unaddressed findings holds. Omit lines of code, pooled cross-kind pass rates, context-free token totals, and raw standards/spec finding counts as quality proxies. Detect bucket boundaries where observedthirdshift_version(or Harness / Model under a filtered slice) changes and attach timeline transition markers.
- Yield & pull-request survival: per-kind
- Server-rendered Console presentation and drilldown (ADR 0018). Render
/metricsthrough server-side HTML templates paired with static inline SVG/CSS stacked outcome bars, compact sparklines, preceding-window delta summaries, version-change markers, and a "Where runs failed" table. Style visuals exclusively with existing semantic Theme custom properties, zero client-side charting libraries, and zero motion, collapsing cleanly without horizontal page overflow at a390pxmobile viewport. Link failure counts, buckets, and "Where runs failed" rows to filtered History or Command detail views (forwarding--machine/machine=for reachable Fleet peers, and showing inline read-only summary rows when a pushed/cached peer is not reachable inbound). Update the generated user manual and hand-written site architecture/workflow pages wheremetricsand Fleet reporting are described.
Testing Decisions
- Good tests assert observable behavior at public CLI, HTTP API, filesystem-artifact, and rendered-DOM boundaries—never internal helper shapes or private aggregation structs—and make zero real sleeps or live network calls to GitHub.
- CLI and Command-lifecycle seam: test
thirdshift_versionand structuredstopped_at/ failure-category persistence on scripted Runs, historicalservice.versionSession-trace recovery without re-parsing unchanged traces, Other-account Command inclusion,Pickup runwrapper exclusion versus pre-dispatch failure inclusion,diedversusliveseparation, survivorship-safe succeeded-run duration/Repairs/CI-round math, first-pass clean rate, wasted-effort share, weekly Scores + confirmed Bug origins + kept pull-request survival with zeroghinvocations, daily/weekly window presets and preceding-window deltas, andmetrics --fleet/metrics --push+ best-effort post-Command push (verifying offline targets warn without failing the Run). Prior art: existing CLI metrics, run-metrics, scoring, and failed-run integration suites. - Console HTTP, auth, and parity seam: test
/metricsHTML versus local/api/v1/metricsJSON parity, route/OpenAPI/CLI inventory parity (includingmetrics --fleetandmetrics --pushreasoned exclusions),reporttoken creation and enforcement (accepting holder-matching HTTPS/loopback snapshot uploads while rejecting cross-holder writes and everyread/security/act/run/adminendpoint), Fleet fan-out merging with cached fallback when a paired Console stops answering, and URL-to-CLI filter equivalence. Prior art: Console metrics, API parity, Fleet, Cron jobs, token-scope, and other-accounts integration suites. - Console browser seam: test
Metricsnavigation andmkeyboard jump, Fleet default versus single-machine selection, filter submissions, inline SVG/CSS bars, sparklines, and version markers across built-in/custom Themes with zero motion,390pxmobile layout fit alongside desktop layout, and one-click drilldown links from failure buckets and "Where runs failed" rows to History / Command details (plus graceful read-only display for pushed offline peers). Prior art: Playwright Console suites for Fleet, Cron jobs, Scores, and stage/lane time views.
Out of Scope
- Centralized PostgreSQL or any external database/daemon dependency (rejected in Q2.1 and ADR 0026).
- Any composite "factory health score" combining distinct signals into one number (rejected in Q1.2 and
GLOSSARY.md). - Renaming live Command
"health"(Slow / Silent) or moving live operational queues off Inbox, Cron jobs, and Resources (Q1.1, Q1.4). - Vanity metrics: lines of code, commit counts, pooled cross-kind pass rates, context-free token volume headlines, or raw standards/spec review-finding counts treated as quality scores (Q2.6).
- Outbound worker push for live Inbox (
status) and active Command control from NATted/sleeping machines (to be tracked as a separate follow-up issue building onreporttokens, Q4.1). - Client-side JavaScript charting libraries or animated charts (Q3.2, ADR 0018).
Further Notes
- Grilling record: Record the #2036 Console Metrics grill and update Fleet/Run metrics docs #2064 (Q1.1–Q4.2), backed by the primary-source and codebase research note landed in Record the #2036 Console Metrics grill and update Fleet/Run metrics docs #2064.
- Related open Ticket: Record RunMetrics and SessionSignals on Review run, Triage run, and Fix run Command records #2047 records
RunMetricsandSessionSignalson completed Review runs, Triage runs, and Fix runs (and adds Code review to session-bearing stage detection), enriching the records that this Spec aggregates. - Live Fleet rollout after this Spec ships (
thirdshift.app24/7 Console paired with cloud peers +reporttoken configured onlima-thirdshift) is Day shift host setup and can be tracked in aready-for-humanrollout issue blocked by Spec: Console Metrics view for Run metrics, Fleet trends, and failure attribution #2036.
Activity
Merge pull request #2064 from JacobStephens2/docs/2036-console-metric…
[-]add thirdshift health view to console web ui[/-][+]Spec: Console Metrics view for Run metrics, Fleet trends, and failure attribution[/+]Address Spec review: daily windows show pushed machines, reported fai…