Skip to content

feat(bin): add a live, self-refreshing bearings fleet board - #54

Merged
alandomio merged 3 commits into
mainfrom
fm/live-board
Sep 30, 2026
Merged

alandomio merged 3 commits into
mainfrom
fm/live-board

Conversation

@alandomio

@alandomio alandomio commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

Intent

Captain request (firstmate shared tracked material): a LIVE interactive fleet board that regenerates itself every 60-120s without firstmate's LLM, showing workers and their current state/age, open PRs/MRs, captain decisions (same interactive answer channel and keyed-answer intake as today's /bearings lavish board: bin/fm-captain-hold.sh binding, procevent lavish source), queued work, and quotas. The captain said on 30/09 the board must stay interactive and refresh every 1-2 minutes.

Design constraints from the brief: (1) regeneration is a deterministic script (no model call) run by a user-level systemd timer or an equivalent supervised loop documented in docs; (2) the page auto-refreshes but must NEVER lose an answer the captain is typing or has submitted but not yet delivered (preserve form state across refresh, or refresh data via fetch instead of full reload); (3) decision cards require composed captain-facing text: reuse the latest firstmate-composed card text when available (persist composed cards in a private data file that firstmate updates when it builds the board) and fall back to the raw hold reason for new holds, clearly marked; (4) merge cards keep the existing merge-click ruling guards; (5) optional Tailscale exposure documented but off by default; (6) off by default, enabled by a config flag documented in docs/configuration.md. Tests colocated, docs updated.

Later firstmate requirement (supersedes the earlier "refresh steps aside during away mode" behavior): the live board must keep refreshing during away mode - that is exactly when the captain watches it from outside. The refresh path bypasses the bearings snapshot's afk guard because it is read-only and model-free, with a test. Implemented as fm-bearings-snapshot.sh --unattended (skips the fm-afk-return.sh guard for both away mode and the return catch-up; only the live refresh uses it, every /bearings captain request still honors the guard; the existing incident regression that plain Bearings refuses behind the return gate is kept and extended).

Implementation decisions: bin/fm-bearings-board.sh gains refresh (deterministic, off unless config/live-board's first non-blank line is exactly "on"; skips with a skipped: line and exit 0 when off or when no board has been built yet), loop [--interval] for non-systemd supervisors, and systemd-units [--interval] [--dir] that prints/writes a home-scoped user service+timer (default 90s, minimum 30s, values escaped and quoted). refresh reads the snapshot uncapped for decisions, in-flight tasks and recorded PRs (gates stay capped with charted_more). refresh never rewrites the board page, never calls lavish-axi, and never binds or arms anything: it only atomically replaces a sibling data file .lavish/bearings-board.data.js (a script calling window.fmBearingsBoardData(payload)). This was chosen over fetch because the Lavish artifact iframe is sandboxed without allow-same-origin and asset responses carry no CORS header, and it was empirically verified (docs/verification/live-board.md) that Lavish 0.1.53 hot-reloads only on a change to the page file itself; queued answers live in the Lavish chrome's sessionStorage, outside the iframe. build additionally writes the same data file and replaces the private composed-card store data/bearings-board-cards.json (fm-bearings-board-cards.v1, mode 0600, raw cards excluded). Composition: stored composed card kept while its key is still an open captain hold (merge. cards while that task is in flight with a recorded PR); malformed stored cards are filtered out individually; a new hold becomes a raw card (raw: true, badge "raw hold reason", options [], free text only, close "release" because a raw card cannot tell a question from held work - firstmate finishes the call at wake time, documented in the bearings skill). Underway = every in-flight task plus active secondmates with since from status-log mtime; prs = locally recorded PRs with last reported state (no network call, deliberately); charted dispatchable only when no blocker and no gate reason. Payload schema stays fm-bearings-board.v1 with optional fields source, since, raw, prs; validation defs are shared between build and refresh. The template's renderer is re-runnable: every 30s the page reloads the data script, and Captain's Call cards are reconciled by key - a card in use (option picked, text typed, focus inside, answer queued) is never rebuilt and shows a note when newer text waits; a call that left the fleet keeps its card only while it holds unsent words; dispatch picks survive while their rows remain; live data older than six minutes is flagged. Docs: docs/configuration.md "Live fleet board" section with Tailscale Serve (never funnel) instructions, AGENTS.md layout lines, docs/scripts.md, new verification record registered in docs/documentation-audiences.json. Tests extend tests/fm-bearings-board.test.sh, its DOM harness, and tests/fm-afk-return.test.sh.

What Changed

  • bin/fm-bearings-board.sh gains refresh, loop [--interval] and systemd-units. refresh is deterministic and makes no model call. It is off unless config/live-board says on. Each run atomically rewrites only the .lavish/bearings-board.data.js data file. It never rewrites the board page, never calls lavish-axi and never binds anything. systemd-units prints or writes a user service and timer; the default interval is 90s and the minimum is 30s. build also writes the data file and the private composed-card store data/bearings-board-cards.json (mode 0600). A stored composed card is reused while its hold is still open. A new hold falls back to a card marked "raw hold reason". The payload now also carries in-flight work with its age, recorded PRs and dispatchable queued work. Decisions, in-flight tasks and PRs are read uncapped.
  • bin/fm-bearings-snapshot.sh gets an --unattended flag that skips the fm-afk-return.sh guard. Only the live refresh uses it, so the board keeps updating during away mode. Every /bearings request still honors the guard.
  • The board template re-renders every 30s by reloading the data script. It matches Captain's Call cards by key and never rebuilds a card that is in use (an option picked, text typed, focus inside, or an answer queued). When newer text is waiting, the card shows a note instead. The board flags live data older than six minutes.
  • Docs: docs/configuration.md has a new "Live fleet board" section that covers optional Tailscale Serve exposure, off by default. AGENTS.md, docs/scripts.md and the bearings skill are updated, and a new docs/verification/live-board.md record is registered in docs/documentation-audiences.json.
  • Tests: new cases in tests/fm-bearings-board.test.sh and its DOM harness, and in tests/fm-afk-return.test.sh.

Risk Assessment

✅ Low: The latest change is small and does what the intent asks. Only the live refresh passes --unattended to skip the afk guard, and plain /bearings still honors it. The downstream fleet snapshot and quota readers have no second guard that would block the refresh. Findings from the earlier review rounds were already dealt with.

Testing

I ran the three targeted test files: the bearings board suite (with its DOM harness), the afk-return suite and the snapshot suite. All passed. For visual evidence I built a board, turned the live board on, ran refresh, and rendered the resulting page in headless Chrome. The screenshot shows the header "live · updated just now". It shows a composed decision card among three Captain's Call cards, and Underway items with their ages. It also shows an Open Pull Requests section with each worker's last reported state, Charted Next with its dispatch bar and "+3 more", the quota panel, and a "live-refresh" source footer. That source footer shows the data came from the refreshed data file, not a rebuilt page. The worktree was left clean.

Evidence: Built board page and refreshed data file

Source: Built board page and refreshed data file

(function (d) { if (typeof window.fmBearingsBoardData === "function") window.fmBearingsBoardData(d); })({"schema":"fm-bearings-board.v1","home":"alan/test-home","generated":"2026-09-30T08:04:28Z","source":"live-refresh","prs_live":false,"captains_call":[{"key":"composed-call","type":"decision","repo":"widget","title":"Composed title","about":"Composed about text","decide":"Ship it?","close":"release","options":[{"value":"yes","label":"Yes"},{"value":"no","label":"No"}],"allow_freeform":true},{"key":"merge.ship-a","type":"merge","repo":"widget","title":"Merge: widget fix","detail":"fixes the widget","risk":"low","pr_url":"https://github.com/example/widget/pull/9","options":[{"value":"merge","label":"Merge now"},{"value":"hold","label":"Not yet"}],"allow_freeform":true},{"key":"new-call","type":"decision","repo":null,"title":"Pick the export window","about":"Pick the export window: nightly or weekly, why now - the disk fills on Friday","detail":"Firstmate has not written this call up yet: this is the raw reason recorded with the hold. Answer in your own words; firstmate reads it and finishes the call.","options":[],"allow_freeform":true,"close":"release","raw":true,"freeform_hint":"your answer, captain"}],"underway":[{"id":"ship-a","repo":"widget","state":"done","doing":"checks green: PR ready for review","kind":"ship","since":"2026-09-30T07:00:00Z"},{"id":"scout-b","repo":null,"state":"working","doing":"reading the export job","kind":"scout","since":null},{"id":"android","repo":null,"state":"working","doing":"one child task working","kind":"second mate","since":"2026-09-30T08:02:28Z"}],"landed":[{"id":"old-fix","repo":"widget","what":"Old fix","owner":"(main)","pr_url":"https://github.com/example/widget/pull/7"}],"charted":[{"id":"free-work","repo":null,"title":"Free work","reason":"","dispatchable":true},{"id":"blocked-work","repo":null,"title":"Blocked work","reason":"waiting on free-work","dispatchable":false},{"id":"main-inventory","repo":null,"title":"in-flight backlog item has no child metadata","reason":"fleet records integrity warning","dispatchable":false},{"id":"ios","repo":null,"title":"Second mate ios","reason":"home state unreadable","dispatchable":false}],"charted_more":3,"prs":[{"id":"ship-a","repo":"widget","url":"https://github.com/example/widget/pull/9","state":"done","doing":"checks green: PR ready for review"},{"id":"landed-already","repo":"api","url":"https://gitlab.com/example/api/-/merge_requests/3","state":"not in flight","doing":""}],"quota":{"source":"quota-axi","generated":null,"available":false,"status":"tool_missing","detail":"quota-axi is not installed","providers":[]}});
Evidence: Board test transcript

Source: Board test transcript

ok - path prints the stable home-scoped board location
ok - build refuses malformed payloads before touching the board
ok - build injects the payload, binds any-origin, then arms the source
not-autohandled: lavish-18e0245aaf656b6d (left for the handler; still unacknowledged)
ok - registration can consume answers only after any-origin binding exists
ok - build establishes the Lavish session before binding and arming
ok - rebuild refreshes the board in place without double-arming
ok - build refuses a template without exactly one data slot
ok - a decision card refuses to queue and surfaces an error without a Lavish bridge
ok - the dispatch bar refuses to queue and surfaces an error without a Lavish bridge
ok - the dispatch bar drops a stale refusal once the bridge returns
ok - a decision card drops its queued mark when a later answer is refused
ok - the dispatch bar drops its queued mark when a later dispatch is refused
ok - an option-less card is built and answerable through its freeform box
ok - a decision card shows every decision-card element
ok - a queuePrompt that throws is refused like a missing bridge
ok - changing the selection drops a stale queued mark
ok - build accepts an optional quota section and refuses a malformed one
ok - the quota panel shows reported values and says why anything is unavailable
ok - refresh does nothing until the flag is on and a board exists
ok - refresh keeps the board live during away mode and the return catch-up
ok - build writes the live data file and the composed-card store
ok - refresh composes a live payload from the fleet without touching the page or its session
ok - refresh drops a malformed stored card and keeps the last data when the snapshot fails
ok - refresh sees every open hold, in-flight task, and recorded PR past the snapshot caps
ok - systemd-units describes a user timer that runs refresh for this home
ok - systemd-units escapes quotes, backslashes, and specifiers in quoted values
ok - a live update never rebuilds or drops a card holding an unsent answer
ok - a queued answer's card stays as sent until its call closes
ok - an idle card takes new text and a malformed update is ignored
ok - dispatch picks and their queued mark survive a live update while they still apply
ok - a raw card is marked plainly, old live data is flagged, and the PR list renders
Evidence: AFK return test transcript

Source: AFK return test transcript

ok - return catch-up precedes Bearings, owns live blocker remediation, preserves evidence once, and clears idempotently
ok - tmux and Herdr blockers require the same explicit durable reclassification before ordinary work
ok - needs-decision remains reportable without masquerading as a firstmate-actionable blocker
ok - AFK return re-drains published wakes until handling acknowledges
ok - away-mode re-entry fails closed while the prior return catch-up is pending
ok - check retries recorded terminal teardown and keeps catch-up gated until success

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-bearings-board.test.sh covers: refresh gating (off unless the config line is exactly on, skips when no board is built), refresh during away mode, the live data file and private card store, composed vs raw cards, uncapped holds and in-flight tasks, systemd unit escaping, and DOM live-update preservation of unsent, queued and dispatch-pick answers
  • bash tests/fm-afk-return.test.sh (--unattended bypass, and plain bearings still refused behind the return gate)
  • bash tests/fm-bearings-snapshot.test.sh
  • Manual: ran test_refresh_composes_a_live_payload_without_touching_the_page alone via a temporary copy of the test script (since removed), kept its build+refresh .lavish output, and rendered bearings-board.html with headless google-chrome to a screenshot
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Alan Domio added 3 commits September 30, 2026 09:37
The /bearings lavish board could only change when firstmate rebuilt it,
so it went stale between builds. Add a deterministic refresh that keeps
it current every minute or two with no model call.

- bin/fm-bearings-board.sh refresh composes a fresh payload from the
  bearings snapshot and quota readers and replaces only a sibling data
  file; it never rewrites the page, touches the Lavish session, or binds
  and arms anything. It is off unless config/live-board says "on", skips
  until a board has been built, and steps aside during away mode.
- build now also writes that data file and a private store of the
  Captain's Call cards firstmate composed; refresh reuses a stored card
  while its call stays open and shows a new hold as a clearly marked raw
  card that lifts the hold instead of closing the task.
- The board page re-reads the data file every 30 seconds and re-renders
  in place, keeping by key every card the captain is using (option
  picked, words typed, focus, or answer queued), keeping dispatch picks
  that still apply, and flagging live data older than six minutes. It
  adds worker ages and an open pull request list.
- systemd-units prints or writes a user timer for the refresh; loop
  covers other supervisors.

Docs cover setup, limits, and optional Tailscale Serve exposure; a
verification record captures the Lavish reload and queue behavior the
design relies on.
Away mode is exactly when the captain watches the live board from
elsewhere, but refresh stepped aside because the bearings snapshot
refuses reads while the away-mode return guard is up.

Add fm-bearings-snapshot.sh --unattended, which skips that guard, and
have the live board refresh use it. The refresh is read-only and
model-free and no captain request proceeds through it; every /bearings
request still honors the guard.

Tests cover the refresh during away mode and during the return
catch-up, and the unattended read behind a pending return gate.
@alandomio alandomio changed the title feat(bin): add a live, self-refreshing fleet board feat(bin): add a live, self-refreshing bearings fleet board Sep 30, 2026
@alandomio
alandomio merged commit e133691 into main Sep 30, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant