Skip to content

fix(bin): require freeform answers and stop the bearings board claiming lost answers as queued - #27

Merged
alandomio merged 9 commits into
mainfrom
fm/board-freeform-required
Sep 12, 2026
Merged

alandomio merged 9 commits into
mainfrom
fm/board-freeform-required

Conversation

@alandomio

Copy link
Copy Markdown
Owner

Intent

Require every Captain's Call card in the /bearings lavish fleet board to carry an open response textbox, per the captain's explicit instruction that the decision widget must always present one, and firstmate's own retrospective finding that a written rule alone had already failed to fire three sessions running - so this is a fail-closed validator refusal, not guidance. In bin/fm-bearings-board.sh's validate_payload, allow_freeform is now required and must be true on every captains_call item (was optional, only load-bearing when a card had no options); the now-dead 'options length>0 OR allow_freeform' disjunct was removed since freeform is unconditional. The composer-facing rule is stated in .agents/skills/bearings/SKILL.md's Lavish board mode section, and the script's own header gained the matching one-line correction (it already singles out the invariant in prose, so allow_freeform gets the same treatment). Kept freeform_hint optional by deliberate choice: a hint composers are forced to fill with filler is worse than one they omit when it adds nothing. There is no stored payload to migrate - the board is rebuilt from a fresh payload every invocation. Folded in a second, related defect found and confirmed live the same day: board-template.html's decision-card submit handler and its charted dispatch-bar click handler both marked their UI is-queued (and, for the decision card, dealt the next card) even when window.lavish.queuePrompt was absent, so a lost Lavish bridge silently swallowed the captain's answer while the board claimed it was queued. Both handlers now refuse instead, surfacing an error through the same .bb-limit/dispatch-bar alert element the existing 512-byte answer-limit check already uses, rather than falsely marking the answer queued. Test coverage: extended tests/fm-bearings-board.test.sh's payload-validation cases with a missing-allow_freeform and a false-allow_freeform refusal proof, and added a new tests/fm-bearings-board-dom-harness.js - a minimal hand-rolled DOM shim executing the template's real runtime script (extracted verbatim, not re-typed) inside a Node vm context - because this repo's test suite is bash-only with no jsdom/browser dependency available, and a source-text/regex assertion would violate the repo's test-quality rule. Verified by hand that the harness reproduces both bugs against the pre-fix template and passes clean post-fix, so the tests are not vacuous. This touches firstmate's own shared tracked material, so firstmate-coding-guidelines was loaded and followed before editing.

What Changed

  • bin/fm-bearings-board.sh's validate_payload now requires allow_freeform: true on every captains_call item instead of accepting it as an optional boolean, and the now-dead options length > 0 or allow_freeform disjunct is gone; freeform_hint stays optional. The script header and the Lavish board mode section of .agents/skills/bearings/SKILL.md state the matching rule, and assets/board-template.html renders the response textbox on every decision card unconditionally.
  • The board template's decision-card submit handler and charted dispatch-bar click handler now refuse when window.lavish.queuePrompt is missing or throws, surfacing a "reload the board" error through the card's existing .bb-limit alert and a new dedicated #bb-dispatch-limit alert on the dispatch bar, rather than marking the UI is-queued and dealing the next card. The refusal path also clears a stale queued mark and, on the dispatch bar, resets the alert and mark whenever the selection changes.
  • Added tests/fm-bearings-board-dom-harness.js, a Node vm-based DOM shim that executes the template's real runtime script extracted verbatim, and wired new bridge-loss cases into tests/fm-bearings-board.test.sh (skipped when node is absent) alongside missing- and false-allow_freeform payload-refusal proofs. bin/fm-test-run.sh maps tests/*-harness.js to the referencing suite, with CONTRIBUTING.md and tests/fm-test-run.test.sh updated to record the non-bash test helpers.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change is well-bounded and conforms to the stated intent: a fail-closed validator tightening with no stored payload to migrate and no other payload producer in the repo, plus client-side handlers that strictly replace a silent swallow with a visible refusal, all covered by behavioral tests that execute the real runtime and would fail against the pre-fix template.

Testing

Ran the two relevant suites (tests/fm-bearings-board.test.sh, tests/fm-test-run.test.sh) plus the real --changed selection path, then verified the intent the way a captain experiences it: the board built by bin/fm-bearings-board.sh build was rendered in headless Chrome and its real handlers driven, showing the mandatory response box on every Captain's Call card (including one with no options at all), the new Answer not sent … / Dispatch not sent … alerts with no queued mark when the bridge is gone, and the unchanged queue-and-deal behavior when it is healthy; the same payload and clicks against the base-commit template reproduce both defects (silent · 1 answered, a card with no box), so the coverage is not vacuous. The CLI transcript shows the validator refusing a missing and a false allow_freeform with exit 1 without touching the board already on disk. Everything passed; the only failure is the pre-existing tasks-axi-gated case in the bearings suite, which is an environment gap on this host and unrelated to the change.

Evidence: Evidence index (what each artifact proves)

Source: Evidence index (what each artifact proves)

# /bearings board: mandatory response box + honest bridge refusal

All screenshots are the **real shipped board** (`bin/fm-bearings-board.sh build` output, or the
same template with the same payload injected) rendered in headless Google Chrome 152 from
`file://`. In a plain browser there is no Lavish host runtime, so `window.lavish` is genuinely
absent - which is exactly the lost-bridge condition the new guards exist for.

| file | what it shows |
| --- | --- |
| `01-board-card1-response-box.png` | the built board as the captain sees it; the first Captain's Call card carries the open response box under its preset options |
| `02-card3-option-less-freeform-only.png` | card 3 has `options: []` - answerable only through the box (`your orders, captain`), the shape the new rule unlocks |
| `03-answer-refused-no-bridge.png` | **post-fix**: answering with the bridge gone shows `Answer not sent - the board's connection is unavailable. Reload the board and try again.` in the card's own alert; no queued mark, deck stays on card 1, header still says 3 items wait |
| `04-answer-queued-healthy-bridge.png` | the healthy path is untouched: with a working `queuePrompt` the answer queues, the deck deals card 2, header reads `card 2 of 3 · 1 answered` - and card 2 carries its own box (`name a condition, captain`) |
| `05-dispatch-refused-no-bridge.png` | the dispatch bar refuses in its own new `role="alert"` element beside the unchanged `1 picked for dispatch` count; no queued badge |
| `06-PREFIX-answer-falsely-marked-queued.png` | **pre-fix (base commit) template, identical payload and identical click**: no error at all, the deck advanced and the header claims `· 1 answered` - the silent swallow this change removes (compare with 03) |
| `07-PREFIX-merge-card-without-a-response-box.png` | **pre-fix**: a card whose payload omits `allow_freeform` renders with preset options only - the captain cannot answer anything the composer did not think of |
| `08-POSTFIX-same-card-still-gets-the-response-box.png` | **post-fix**, same flag-less payload: the renderer gives the box anyway (and `fm-bearings-board.sh build` refuses that payload outright - see the CLI transcript) |
| `validator-cli-transcript.txt` | `build` accepts a payload where every card carries `allow_freeform: true`, and refuses (exit 1) both a card missing the flag and a card with `allow_freeform: false`, without touching the board already on disk |
| `regression-prefix-vs-postfix.txt` | the DOM harness run against the base-commit runtime vs the fixed one: missing bridge, throwing bridge, and flag-less option-less card |
Evidence: CLI transcript: build accepts the compliant payload and refuses missing / false allow_freeform

Source: CLI transcript: build accepts the compliant payload and refuses missing / false allow_freeform

$ fm-bearings-board.sh build valid-payload.json # all three cards carry allow_freeform: true board: .../.lavish/bearings-board.html served: .../.lavish/bearings-board.html bound: lavish-49f440ee3d54e83b armed: lavish-49f440ee3d54e83b [exit 0] $ jq "del(.captains_call[1].allow_freeform)" valid-payload.json > no-flag.json $ fm-bearings-board.sh build no-flag.json fm-bearings-board: board data does not satisfy fm-bearings-board.v1: .../board-noflag.json [exit 1] $ jq ".captains_call[1].allow_freeform = false" valid-payload.json > false-flag.json $ fm-bearings-board.sh build false-flag.json fm-bearings-board: board data does not satisfy fm-bearings-board.v1: .../board-false.json [exit 1] # both refusals happened before the board on disk was touched: the board on disk is still byte-identical to the one the accepted payload built

$ fm-bearings-board.sh build valid-payload.json      # all three cards carry allow_freeform: true
  board: /tmp/fmbb.GaApS7/home/.lavish/bearings-board.html
  served: /tmp/fmbb.GaApS7/home/.lavish/bearings-board.html
  bound: lavish-49f440ee3d54e83b
  already-armed: lavish-49f440ee3d54e83b
  [exit 0]

$ jq "del(.captains_call[1].allow_freeform)" valid-payload.json > no-flag.json
$ fm-bearings-board.sh build no-flag.json
  fm-bearings-board: board data does not satisfy fm-bearings-board.v1: /tmp/fmbb.GaApS7/board-noflag.json
  [exit 1]

$ jq ".captains_call[1].allow_freeform = false" valid-payload.json > false-flag.json
$ fm-bearings-board.sh build false-flag.json
  fm-bearings-board: board data does not satisfy fm-bearings-board.v1: /tmp/fmbb.GaApS7/board-false.json
  [exit 1]

# both refusals happened before the board on disk was touched:
  the board on disk is still byte-identical to the one the accepted payload built
Evidence: Regression proof: base-commit runtime vs fixed runtime under the same DOM harness

Source: Regression proof: base-commit runtime vs fixed runtime under the same DOM harness

-- bridge ABSENT, mode=decision pre-fix : {"isQueued":true,"errorVisible":false,"stackText":"card 1 of 1 · 1 answered",...} post-fix : {"isQueued":false,"errorVisible":true,"errorText":"Answer not sent - the board's connection is unavailable. Reload the board and try again.","stackText":"card 1 of 1",...} -- bridge THROWS, mode=decision pre-fix : UNCAUGHT Error: the bridge refused the prompt (handler aborts -> no queued mark, no error shown: the silent no-op) post-fix : {"isQueued":false,"errorVisible":true,"errorText":"Answer not sent - ...","queueCalls":1} -- bridge ABSENT, mode=dispatch pre-fix : {"isQueued":true,"errorVisible":false,"queueCalls":0} post-fix : {"isQueued":false,"errorVisible":true,"errorText":"Dispatch not sent - ...","queueCalls":0} -- bridge THROWS, mode=dispatch pre-fix : UNCAUGHT Error: the bridge refused the prompt (silent no-op) post-fix : {"isQueued":false,"errorVisible":true,"errorText":"Dispatch not sent - ...","queueCalls":1} -- card with options:[] and no allow_freeform flag reaching the renderer pre-fix : {"hasFreeform":false,"queueCalls":0,"isQueued":false} post-fix : {"hasFreeform":true,"queueCalls":1,"isQueued":true,"queuedText":"Captain's Call answer - Say it in your own words: hold this course"}

\### Regression proof: same DOM harness, same payloads, PRE-fix vs POST-fix template runtime

-- bridge ABSENT, mode=decision
   pre-fix  : {"isQueued":true,"errorVisible":false,"errorText":"","stackText":"card 1 of 1 · 1 answered","hasFreeform":true,"queuedText":"","queueCalls":0}
   post-fix : {"isQueued":false,"errorVisible":true,"errorText":"Answer not sent - the board's connection is unavailable. Reload the board and try again.","stackText":"card 1 of 1","hasFreeform":true,"queuedText":"","queueCalls":0}
-- bridge THROWS, mode=decision
   pre-fix  : UNCAUGHT Error: the bridge refused the prompt (handler aborts -> no queued mark, no error shown: the silent no-op)
   post-fix : {"isQueued":false,"errorVisible":true,"errorText":"Answer not sent - the board's connection is unavailable. Reload the board and try again.","stackText":"card 1 of 1","hasFreeform":true,"queuedText":"Captain's Call answer - Pick one: yes","queueCalls":1}
-- bridge ABSENT, mode=dispatch
   pre-fix  : {"isQueued":true,"errorVisible":false,"errorText":"","queueCalls":0}
   post-fix : {"isQueued":false,"errorVisible":true,"errorText":"Dispatch not sent - the board's connection is unavailable. Reload the board and try again.","queueCalls":0}
-- bridge THROWS, mode=dispatch
   pre-fix  : UNCAUGHT Error: the bridge refused the prompt (handler aborts -> no queued mark, no error shown: the silent no-op)
   post-fix : {"isQueued":false,"errorVisible":true,"errorText":"Dispatch not sent - the board's connection is unavailable. Reload the board and try again.","queueCalls":1}
-- card with options:[] and no allow_freeform flag reaching the renderer (mode=decision, bridge present)
   pre-fix  : {"isQueued":false,"errorVisible":false,"errorText":"","stackText":"card 1 of 1","hasFreeform":false,"queuedText":"","queueCalls":0}
   post-fix : {"isQueued":true,"errorVisible":false,"errorText":"","stackText":"card 1 of 1 · 1 answered","hasFreeform":true,"queuedText":"Captain's Call answer - Say it in your own words: hold this course","queueCalls":1}
- Outcome: ⚠️ 1 warning across 1 run (8m12s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 3 issues found → auto-fixed (6) ✅
  • ⚠️ tests/fm-bearings-board.test.sh:455 - The dispatch-bar regression test only proves the bar is not marked queued and queuePrompt is not called; it never asserts that an error was surfaced. The harness hardcodes errorVisible: false for dispatch mode (tests/fm-bearings-board-dom-harness.js:170) and returns errorText: barCount.textContent, but the test asserts on neither. Concretely: delete the refreshBar("Dispatch not sent - ...") line at board-template.html:705 and leave a bare return;, and both dispatch assertions still pass — the captain would get a silently dead Queue-dispatch button with the stale "1 picked for dispatch" label and no indication the order was dropped. The decision-card half does assert errorVisible == true (line 430), so the two halves of the same claimed fix have asymmetric proof. Remedy is mechanical and stays inside the change: assert on the already-returned errorText for the no-bridge dispatch run (e.g. that it differs from the plain picked-count label / matches the refusal text).
  • ℹ️ .agents/skills/bearings/assets/board-template.html:520 - if (item.allow_freeform) is now an unreachable-false branch: the validator guarantees allow_freeform === true on every captains_call item before any payload reaches the slot. The script header and SKILL.md both now assert "there is no card the composer may render without an open response textbox", yet the renderer still contains the branch that would render exactly such a card. Rendering the textbox unconditionally would put the invariant in the renderer too, so the template cannot silently drop the box if the payload path ever changes. Behavior-identical today; noting it rather than asserting a live defect.
  • ℹ️ .agents/skills/bearings/assets/board-template.html:554 - Both new refusal messages tell the captain to "Reload the board and try again." window.lavish is injected by the Lavish host runtime, not by the served page, so if the bridge is absent because the Lavish session died, a reload of the same stable board path yields the same missing bridge — the effective remedy is a rebuild (which is what build does: re-establish the session, then bind and arm). The template's own established idiom for an unusable board is renderBoardError's "ask firstmate to rebuild the board" (line 399). Worth confirming the recovery instruction the captain is given actually recovers; this is deliberate author-written copy, so flagging rather than changing it. Same text at line 705.

🔧 Fix: assert dispatch-bar bridge-loss error in DOM harness test
3 issues (1 warning, 2 infos) still open:

  • ⚠️ .agents/skills/bearings/assets/board-template.html:714 - The dispatch-bar click handler never clears a previous refusal before queueing, so a bridge-loss message can survive a later successful dispatch and the bar then asserts two contradictory things at once. Concrete sequence in one page session: captain picks one item and clicks Queue dispatch while window.lavish is absent -> line 705 sets barCount.textContent to "Dispatch not sent - the board's connection is unavailable. Reload the board and try again." and returns. The bridge then becomes available (it is injected by the Lavish host runtime, not by the served page - the guard at line 704 exists precisely because it can be absent at click time). The captain clicks again without touching any checkbox, so the pick 'change' handler that would call refreshBar() never fires. queuePrompt now succeeds and line 714 adds is-queued, which CSS rule .is-queued .bb-queued { display: inline-flex; } (line 229) reveals as a green "queued" checkmark - sitting directly beside a label still reading "Dispatch not sent". The order was in fact queued; the board says it was not, which invites a duplicate dispatch of the same ids. Note the sibling handler this same change wrote does clear first: the decision-card submit does answerLimit.classList.remove("is-visible") on entry (line 540), so only the dispatch half has the gap. The 512-byte message at line 701 cannot reach this state (unchanged picks are still over the limit), so the staleness is new with the bridge refusal. Remedy is one line and stays inside the change: call refreshBar() on entry to the click handler, or on the success path before adding is-queued. Reachability of the second click depends on host-side bridge timing, which this repo does not pin down, hence warning rather than error.
  • ℹ️ tests/fm-bearings-board.test.sh:439 - The fix round added errorVisible == false to the dispatch bar's bridge-present case (line 467) but left the decision-card's bridge-present case without the matching assertion, inverting the asymmetry the previous round set out to remove. As written, the bridge-present decision run asserts only isQueued==true and queueCalls==1, so a template that both queued the answer AND left a visible .bb-limit error on the card would still pass. The harness already returns errorVisible for decision mode (fm-bearings-board-dom-harness.js:159, a real is-visible class check), so this is a one-line addition after line 440 mirroring line 467.
  • ℹ️ tests/fm-bearings-board.test.sh:458 - [ "$(... jq -r .errorText)" != "1 picked for dispatch" ] adds no coverage beyond the errorVisible check two lines above it: the harness defines errorVisible as barCount.textContent !== labelBeforeClick, and labelBeforeClick is exactly "1 picked for dispatch" for this one-dispatchable-item payload. It does add brittleness in the wrong direction - if refreshBar's count wording in board-template.html:652 ever changes, this assertion becomes vacuously true and silently stops testing anything, while still reading like a second independent proof. Dropping it, or asserting a distinguishing substring of the refusal text instead, keeps the same strength without the copy coupling.

🔧 Fix: clear stale dispatch refusal label; tighten bridge tests
2 issues (1 warning, 1 info) still open:

  • ⚠️ .agents/skills/bearings/assets/board-template.html:715 - The round-3 fix closed only one direction of the dispatch bar's two-stories problem. bar.classList.add("is-queued") at line 715 is never removed — grep -n "is-queued" board-template.html shows adds at 567 and 715 and no remove anywhere — so a successful dispatch's green QUEUED badge survives a later refusal. Concrete sequence in one page session: bridge present, captain picks A and clicks Queue dispatch order -> queuePrompt succeeds, line 715 adds is-queued, CSS .is-queued .bb-queued { display: inline-flex; } (line 229) reveals the checkmark. The Lavish session then dies (window.lavish is host-injected, which is exactly why the guard at line 705 exists). Captain also picks B and clicks again: the new refreshBar() at line 697 correctly resets the label, then line 705 writes "Dispatch not sent - the board's connection is unavailable" into #bb-dispatch-count (markup line 335) — which sits immediately left of the still-visible #bb-dispatch-queued badge (markup line 336). B was not queued, yet the bar shows a queued mark beside the refusal, inviting the captain to assume the order went through. This is the same defect class round 2 accepted and round 3 fixed in the opposite direction; the one-line remedy stays inside the change: bar.classList.remove("is-queued") next to the existing refreshBar() call at line 697. The decision card has the identical gap at line 567 (navigate back with stackPrev to an answered card, bridge now lost, resubmit -> .bb-limit error beside the card's queued badge), reachable via deliberate re-navigation rather than a bare second click. The prior fix round is minimal and does not need reverting — this is the untouched half of the same invariant.
  • ℹ️ .agents/skills/bearings/assets/board-template.html:705 - The intent describes both refusals as surfacing "through the same .bb-limit/dispatch-bar alert element", but only the decision card's element is actually an alert: answerLimit gets role="alert" at line 535 and the danger-colored .bb-limit treatment (line 230). The dispatch refusal instead overwrites #bb-dispatch-count, which carries no alert role and renders in the ordinary muted count-label style, so a captain using a screen reader gets no announcement that the order was dropped and a sighted captain sees the refusal in the same visual register as "1 picked for dispatch". Nothing else on the bar changes (the button stays enabled, no color shift), so this is the weaker half of the fail-closed claim. Noting rather than changing it: putting role="alert" on #bb-dispatch-count would also announce every routine pick-count change, so the right remedy (a separate alert span on the bar, mirroring the card) is a product call on deliberate author-written markup, not a mechanical edit.

🔧 Fix: drop stale dispatch queued badge on refusal
1 warning still open:

  • ⚠️ .agents/skills/bearings/assets/board-template.html:567 - The decision card's is-queued class is added at line 567 and never removed anywhere (grep -n is-queued shows adds at 567 and 715, removes only at 698 for the bar), so the green QUEUED badge survives a later refusal on the same card. Reachable without any back-navigation: with a single Captain's Call item, showCard(active < cards.length - 1 ? active + 1 : active) (line 568) keeps the answered card on screen, and nothing disables its form or submit button. Sequence: bridge present, captain picks an option and submits -> queuePrompt succeeds, line 567 adds is-queued, CSS .is-queued .bb-queued { display: inline-flex; } (line 229) reveals the checkmark in .bb-decision__foot. The Lavish session then dies (window.lavish is host-injected, which is why the guard at line 553 exists). The captain amends the answer and resubmits -> line 554 writes "Answer not sent - the board's connection is unavailable" into the .bb-limit span appended at line 534, which sits immediately beside the still-visible queued badge appended at line 531. The amended answer was not queued, yet the card shows a queued mark next to the refusal. This is exactly the state round 3's approved instruction covered ("and any equivalent visual queued state"), and the fixer applied it only to the dispatch bar. Remedy stays inside the change: card.classList.remove("is-queued") on the two refusal paths (lines 550 and 555), NOT unconditionally at handler entry - an unconditional remove at line 541 would also make showCard's answered = deck.querySelectorAll(".is-queued").length (line 587) undercount cards whose first answer really was delivered. Note the same undercount applies on the refusal paths too, so if the stack-count label matters, the fix should refresh it deliberately rather than leave it stale.

🔧 Fix: drop stale card queued mark and count on refusal
4 infos still open:

  • ℹ️ .agents/skills/bearings/assets/board-template.html:658 - Pre-existing, not introduced here, but it is the last open hole in this change's own invariant ("the board must never claim queued when it isn't"), so flagging as a non-blocking follow-up. Both queued badges are cleared only inside their click/submit handlers; nothing clears them when the selection changes. Dispatch bar: captain picks A, clicks Queue dispatch order with the bridge up -> line 723 adds is-queued and CSS .is-queued .bb-queued { display: inline-flex; } (:229) reveals #bb-dispatch-queued (:336). Captain then unchecks A and checks B; the change handler at :672 calls refreshBar(), which touches only barCount.textContent and barBtn.disabled (:658-662) and never the class. The bar now reads "1 picked for dispatch" with a green queued checkmark beside it, while B has not been dispatched at all - no bridge failure required, a single ordinary session. The decision card has the same shape: after a successful answer, changing the radio or editing .bb-freeform leaves the card's :531 queued span showing beside an unsubmitted selection. Marked ask-user because the remedy is a product call on what the badge denotes - the last dispatch that was sent, or the current selection's state - and not a mechanical correction; the four prior fix rounds all scoped the badge to the send path, so changing it to track selection is a deliberate semantic shift the author should authorize rather than something I should prescribe.
  • ℹ️ .agents/skills/bearings/assets/board-template.html:541 - Noting the accepted tradeoff the round-5 fix locks in; no action recommended, since round 4's approved instruction named the length-limit path explicitly. refuseAnswer() now clears is-queued and refreshes the deal count on BOTH refusal paths, so the board can now deny an answer that genuinely reached the bridge. Concrete sequence with a two-card payload, bridge up throughout: captain answers card 1 -> queuePrompt delivered, :574 adds is-queued, the :576 timer deals card 2, header reads "card 2 of 2 · 1 answered". Captain clicks stackPrev back to card 1 (enabled because active=1, :606) and submits a >512-byte freeform note -> the :557 branch calls refuseAnswer, which removes card 1's is-queued and calls showCard(active) at :545, recomputing answered = deck.querySelectorAll(".is-queued").length (:594) down to 0. The header now reads "card 1 of 2" with no queued mark, although firstmate already received and likely closed that task. Because the card's queuePrompt carries no queueKey (unlike the bar's "dispatch.charted" at :721), a captain who re-answers on that cue queues a second answer under the same question key. This trades the old false-positive for a false-negative, which is the safer direction and is what the prior round authorized - recording it so the tradeoff is visible rather than reopening it.
  • ℹ️ .agents/skills/bearings/assets/board-template.html:717 - The new guards test only that the bridge EXISTS (!window.lavish || !window.lavish.queuePrompt), never that the call succeeded. The return value of queuePrompt is discarded at both :569 and :717, and the call sites sit inside event listeners, so the IIFE's try { ... } catch (e) { renderBoardError(...) } (which closes at :725) has already exited and cannot catch anything thrown at click time. Two residual outcomes: a throwing queuePrompt skips :574/:723, leaving the captain with no queued mark AND no error - a silent no-op, the same swallow the change set out to remove; a queuePrompt returning a rejected promise adds is-queued and the board claims queued for an answer that never landed, which is the exact falsehood in the intent. I cannot prove either is reachable - the Lavish host runtime that injects window.lavish is not in this repo, and nothing here documents queuePrompt's failure contract - so this is hardening of the new guard, not a demonstrated defect. The remedy stays inside the change and reuses the authored strings: wrap each call in try/catch (plus a .catch when the result is thenable) and route to the existing refuseAnswer(...) / refreshBar("Dispatch not sent - ...") path.
  • ℹ️ tests/fm-bearings-board.test.sh:173 - Removing the (.options | length) > 0 or .allow_freeform == true disjunct newly ADMITS a card with options: [] (previously that shape was only reachable via the disjunct's freeform arm), and that is precisely the shape the intent's rationale unlocks - a card answerable only through the freeform box. The old test that exercised empty options was repurposed into the allow_freeform=false refusal at :173, so nothing now covers the positive case. It is worth a case because the template's render path for it is untested end to end: :503 item.options.forEach produces an empty .bb-opts div, and on submit fd.get("answer") is null so the answer becomes the bare note (:559) - answerable, but only by inspection. Add one build case with .captains_call[0].options = [] asserting rc 0, and optionally a decision harness run on a zero-option payload asserting queueCalls==1 with the freeform input as the only answer source.

🔧 Fix: refuse failing bridge calls; give dispatch bar its own alert
4 issues (2 warnings, 2 infos) still open:

  • ⚠️ .agents/skills/bearings/assets/board-template.html:589 - The rejected-promise refusal added this round surfaces nothing to the captain once the deck has more than one card, reproducing the silent swallow the change exists to remove. refuseAnswer (:548-553) writes the message onto the submitted card's own answerLimit span and then calls showCard(active). Concrete sequence with a two-card payload and a queuePrompt that returns a promise: captain answers card 1 -> the sync path adds is-queued (:591) and the 450ms timer at :593 deals card 2, so active === 1 and card 1 is hidden; the promise then rejects -> :589 calls refuseAnswer(ANSWER_BRIDGE_LOST), which sets is-visible on card 1's answerLimit (invisible, card1.hidden === true) and calls showCard(1), recomputing answered = deck.querySelectorAll(".is-queued").length down to 0. Net visible result: the header's "· 1 answered" silently disappears and no error appears anywhere, which is exactly the outcome the intent forbids ("surfacing an error through the same .bb-limit/dispatch-bar alert element ... rather than falsely marking the answer queued"). Smallest correction, entirely inside the new code: in refuseAnswer use showCard(cards.indexOf(card)) instead of showCard(active), which is a no-op for every synchronous refusal path (indexOf(card) === active there) and brings the refused card back into view with its message for the async one. Note the added coverage cannot catch this: every harness mode builds a single-card deck (tests/fm-bearings-board-dom-harness.js:170-184) and stubs setTimeout as an immediate call (:163), so the deal-advance never separates the refused card from the active one.
  • ⚠️ tests/fm-bearings-board-dom-harness.js:1 - Adding this non-.sh file under tests/ hard-breaks bin/fm-test-run.sh --changed, the changed-file selection path CONTRIBUTING.md:81 documents. families_for_changed_path (bin/fm-test-run.sh:1044-1081) matches cases in order: the reference-scan case only covers tests/lib.sh|tests/*-helpers.sh (:1048, .sh-only), tests/fixtures// and bin/* do not apply, so tests/fm-bearings-board-dom-harness.js reaches the catch-all tests/*) at :1073 and emits __unmapped__:tests/fm-bearings-board-dom-harness.js, which select_changed turns into die "no changed-test mapping for source path: ..." at :1104 (exit 2). Anyone running bin/fm-test-run.sh --changed --base <base> on this branch gets a refusal instead of a test run; the existing guard in tests/fm-test-run.test.sh:78 uses --base HEAD on a clean tree, so it diffs nothing and never exercises this path. The repo already has the precedent for the remedy: tests/fm-backend-herdr-eventwait.test.py gets its own explicit case at bin/fm-test-run.sh:898. Add an equivalent case (e.g. tests/*-dom-harness.js) routed through families_for_test_reference "$(basename "$path")", which finds fm-bearings-board.test.sh because it references the basename) so the harness selects the bearings family. This corrects a regression the change introduces rather than extending its scope.
  • ℹ️ .agents/skills/bearings/assets/board-template.html:761 - The new rejection handlers are not generation-guarded, so a late rejection from a superseded call overwrites the state of a later call that actually landed - the board then reports a wrong label ("Dispatch not sent") for an order that was sent. Concrete sequence on the dispatch bar with a thenable queuePrompt: captain clicks Queue dispatch order -> handoff A pending, is-queued added (:765). Nothing visibly settles, so the captain clicks again -> the handler's :734-735 refreshBar()/remove("is-queued") reset, queuePrompt is called again -> handoff B resolves fine, is-queued re-added. Handoff A then rejects -> :761-764 removes is-queued and shows DISPATCH_BRIDGE_LOST, although B reached the bridge under the same queueKey "dispatch.charted". The captain is told the dispatch failed and is prompted to reload, when the live order is queued; the card path at :589 has the same shape for a card resubmitted after navigating back with stackPrev. Minimal fix inside the change: capture a monotonically increasing token per click/submit and have each rejection handler return early unless its token is still the latest.
  • ℹ️ .agents/skills/bearings/assets/board-template.html:530 - Flagging for the captain rather than fixing, because the remedy is a product/security decision that extends this change rather than correcting it. The validator now requires allow_freeform: true on every card type including "credential" (bin/fm-bearings-board.sh:87, :102), and the template renders the box unconditionally, so a credential card is now guaranteed to present an input type="text" (not type="password") for what SKILL.md:114 describes as "a credential or login to provide". The typed value is echoed on screen, and :578-582 interpolates it verbatim into the queuePrompt summary string ("Captain's Call answer - " + item.title + ": " + answer) plus the ctxData answer, which then travels the poll/answer-intake path that docs/captain-hold-lifecycle.md records against tasks. Previously a composer could omit allow_freeform on such a card; now the plaintext secret-entry path is mandatory and validator-enforced. In practice credential cards almost certainly already carried the flag (preset options cannot hold a secret), so this amplifies rather than creates the exposure - which is why it is info, not a blocker. Any remedy (password-type input for type === "credential", or keeping the secret out of the human-readable prompt summary) is new behavior the captain's "always present one" instruction did not cover, so it needs authorization; it should not be applied silently.

🔧 Fix: drop async queue machinery; clear marks on reselection
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 warning
  • ⚠️ tests/fm-bearings-board.test.sh:233 - tests/fm-bearings-board.test.sh cannot run to completion on this host: the pre-existing, unchanged case test_registration_cannot_consume_before_any_origin_binding aborts the whole script with fm-captain-hold: compatible tasks-axi is required because the tasks-axi binary is not installed here, and tests/lib.sh's fail() exits immediately. This is an environment gap, not a product failure (bin/fm-captain-hold.sh and bin/fm-decision-hold.sh are untouched by this change), and installing a system tool is outside the worktree boundary. I worked around it by re-running the suite with only that case stubbed, so all 13 other cases including the 8 new ones executed and passed; CI, which has tasks-axi, owns the real run of that case.
  • bash tests/fm-bearings-board.test.sh — aborts at the pre-existing test_registration_cannot_consume_before_any_origin_binding because tasks-axi is not installed on this host
  • Re-ran the same suite with only that tasks-axi-gated case stubbed out: all 13 remaining cases pass, including the 8 new ones (test_decision_card_refuses_to_queue_without_a_lavish_bridge, test_dispatch_bar_refuses_to_queue_without_a_lavish_bridge, test_dispatch_bar_clears_a_stale_refusal_once_the_bridge_returns, test_decision_card_drops_its_queued_mark_when_a_later_answer_is_refused, test_dispatch_bar_drops_its_queued_mark_when_a_later_dispatch_is_refused, test_an_option_less_card_is_built_and_answerable_through_its_freeform_box, test_a_throwing_bridge_is_refused_like_a_missing_one, test_changing_the_selection_drops_a_stale_queued_mark)
  • bash tests/fm-test-run.test.sh — 18/18 pass, covering the new tests/*-harness.js changed-path mapping
  • bin/fm-test-run.sh --list --changed --base 4a6429ba6b2f276c0ea15e10c74a02bf96bfa7c1 — succeeds on the real repo and selects tests/fm-bearings-board.test.sh (pre-fix this path died with no changed-test mapping)
  • bin/fm-bearings-board.sh build against a 3-card payload: accepted with allow_freeform: true everywhere; refused (exit 1) with the flag deleted and with allow_freeform: false; board on disk verified byte-identical after both refusals
  • node tests/fm-bearings-board-dom-harness.js <runtime> <payload> {0|1|throw} {decision|dispatch} run against the base-commit template runtime and the fixed one, for missing bridge, throwing bridge, and a flag-less option-less card
  • Manual visual verification: built board rendered in headless Google Chrome 152 from file:// (no Lavish host runtime present), driving the real click/submit handlers — default view, card navigation to the option-less card, answer submit with and without a bridge, and dispatch-bar pick + click
⚠️ **Document** - 1 info
  • ℹ️ README.md:176 - Out-of-scope follow-up, not caused by this change: README's /bearings row and the mode list at :183-186 document only chat-only, file, and include PRs, never /bearings lavish - the interactive fleet board whose composer contract this change tightens. README owns the user-facing introduction, so a captain reading it cannot discover the board mode at all. I left it alone because the omission predates this branch and adding a board section is new user-facing documentation rather than a stale fact this change created.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Alan Domio and others added 9 commits September 11, 2026 10:13
allow_freeform was optional and only load-bearing when a card had no
preset options, so a composer's guess about whether options might be
insufficient decided whether the captain got a free-text answer. Make
fm-bearings-board.sh's validate_payload require allow_freeform: true
on every captains_call item, state the rule in the bearings skill's
Lavish board mode section, and prove the refusal fires in
tests/fm-bearings-board.test.sh.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
The decision-card submit handler and the charted dispatch bar both marked
their UI is-queued and moved on even when window.lavish.queuePrompt was
absent, so a lost Lavish bridge silently swallowed the answer while the
board told the captain it was queued. Refuse instead: surface an error
the same way the existing 512-byte answer limit already does, and leave
the card/bar unmarked so a retry is possible.

Covered by a new Node vm DOM shim (tests/fm-bearings-board-dom-harness.js)
that runs the template's real runtime script, extracted verbatim, so the
test exercises actual behavior rather than the source text; this repo's
tests are otherwise bash-only with no jsdom/browser dependency, so this
is a deliberate, scoped substitution for this one behavioral case.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@alandomio
alandomio merged commit b0f7d73 into main Sep 12, 2026
13 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