Repository navigation
feat: expose a deterministic captain attention feed - #23
Merged
Merged
Conversation
…e, and ledger transport
…date and added an assertion that legacy holds preserve their opening date. The regression failed before and passes after. Attention, ledger, checkpoint, focused failure cases, lint, and documentation checks pass locally. Remaining CI failures involve missing tsc or unchanged paths that pass locally; no unrelated fixes were made
…repeated its failure. Pinned Linux CI to Ubuntu 24.04, matching passing main, after confirming ubuntu-latest moved to 26.04/Bash 5.3. Local checkpoint, ledger, contribution, closed-output tests, and workflow lint pass. Ruby contract testing is blocked by missing Ruby. Three old-head retries remain running; updated workflow needs fresh CI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Build option 1 of the attention feed: open decisions, newest first, made fully deterministic rather than depending on an agent remembering to update a board.
Context: an investigation (report at ~/firstmate/data/captain-board-deterministic/report.md, sections "The external read" and "Recommended build plan") asked how an external system such as Quarterdeck or Cadence can know which decisions are waiting on the captain and which were raised most recently. The captain asked that this be built in deterministically, not as an instruction to update a board. The report offered three scopes: (1) open decisions newest first only, (2) all three slices (plus recently discussed and Quarterdeck reading from it), (3) don't build. The captain chose option 1. Recently discussed (slice 2) and the Quarterdeck change (slice 3) are not part of this ask.
What Changed
fm-attention.sh --jsonto list current captain holds and open keyed decisions newest first, derived from local records without a separate board.Risk Assessment
✅ Low: The change is bounded to the accepted attention feed behavior, and source tracing found no remaining material defects in ordering, hold projection, or read-only collection.
Testing
Focused regressions and isolated real CLI checks passed for ordering, lifecycle, retries, legacy dates, keyed folding, large malformed ledgers, read-only behavior, and argument guards. JSON transcripts provide evidence for this CLI-only surface. Beads requires an unavailable adapter-capable tasks-axi; all disposable files were cleaned up.
Evidence: Live CLI transcript
Source: Live CLI transcript
Evidence: Large-ledger attention output
Source: Large-ledger attention output
Evidence: Read-only state comparison
Source: Read-only state comparison
Evidence: Beads capability limitation
Source: Beads capability limitation
Evidence: Repeatable verification recipe
Source: Repeatable verification recipe
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 5 issues found → auto-fixed (3) ✅
bin/fm-attention.sh:63- The entire append-only ledger is passed as one argument. Once its compact JSON exceeds Linux's approximately 128 KiB per-argument limit, jq cannot start and the attention feed returns no output. About 70 maximum-length status records suffice. Transport the ledger through stdin or a file instead, as fm-fleet-snapshot.sh already does for large JSON documents.bin/fm-attention.sh:95- Ledger ts records capture time, not decision emission time. For example, a secondmate decision raised at 10:00 but captured at 11:01 sorts ahead of a worker decision raised and immediately recorded at 11:00. Backfill and interrupted-capture retries produce the same error. Preserve source emission ordering instead of letting capture time override it. Relevant sites: bin/fm-attention.sh:75-78 selects capture timestamps, :95 applies them to keyed decisions, and :100 sorts them.bin/fm-attention.sh:82- Supported legacy date-only hold stamps are discarded. A task filed in January with 'Captain hold set: 2026-07-03' gets January's since date, incorrectly sorting behind a July 2 decision. fm-captain-hold.sh explicitly recognizes and preserves date-only stamps. Parse hold_set at day precision before falling back to since; update the precision selection at bin/fm-attention.sh:87 accordingly.bin/fm-classify-lib.sh:938- Membership after folding does not prove that the current line opened the decision. After a valid pending-reply opening, a later same-key blocked line with an unrelated note is rejected by the reserved-key rule, but this code still replaces the original timestamp, potentially erasing it when the rejected line is unstamped. Record timestamps only for accepted opening transitions. The same invariant must hold at bin/fm-attention.sh:75-78 and :95, where raw ledger status events currently bypass transition acceptance too.bin/fm-fleet-snapshot.sh:1019- Simplification: the added timestamp projection into secondmate home summaries is unnecessary for the requested option 1 feed. fm-attention.sh consumes backlog.records and tasks[].hints directly, never secondmate summaries' decisions_open. Remove the added hold_set/since projection here and opened_epoch projection at bin/fm-fleet-snapshot.sh:1073, plus their header claim at :69. Retain opened_epoch in task hints, which the feed uses.🔧 Fix applied.
6 issues (3 errors, 3 warnings) still open:
bin/fm-attention.sh:63- The entire append-only ledger is passed as one argument. Once its compact JSON exceeds Linux's approximately 128 KiB per-argument limit, jq cannot start and the attention feed returns no output. About 70 maximum-length status records suffice. Transport the ledger through stdin or a file instead, as fm-fleet-snapshot.sh already does for large JSON documents.bin/fm-attention.sh:95- Ledger ts records capture time, not decision emission time. For example, a secondmate decision raised at 10:00 but captured at 11:01 sorts ahead of a worker decision raised and immediately recorded at 11:00. Backfill and interrupted-capture retries produce the same error. Preserve source emission ordering instead of letting capture time override it. Relevant sites: bin/fm-attention.sh:75-78 selects capture timestamps, :95 applies them to keyed decisions, and :100 sorts them.bin/fm-attention.sh:82- Supported legacy date-only hold stamps are discarded. A task filed in January with 'Captain hold set: 2026-07-03' gets January's since date, incorrectly sorting behind a July 2 decision. fm-captain-hold.sh explicitly recognizes and preserves date-only stamps. Parse hold_set at day precision before falling back to since; update the precision selection at bin/fm-attention.sh:87 accordingly.bin/fm-classify-lib.sh:938- Membership after folding does not prove that the current line opened the decision. After a valid pending-reply opening, a later same-key blocked line with an unrelated note is rejected by the reserved-key rule, but this code still replaces the original timestamp, potentially erasing it when the rejected line is unstamped. Record timestamps only for accepted opening transitions. The same invariant must hold at bin/fm-attention.sh:75-78 and :95, where raw ledger status events currently bypass transition acceptance too.bin/fm-attention.sh:89- The ledger-based recency extension exceeds the required “open decisions, newest first” feed and misorders retries. Hold A at 10:00, hold B at 11:00, then retry A at 12:00: A retains its 10:00 hold-set stamp but sorts ahead of B because touched uses the new ledger timestamp. Round 1's R2 fix left this hold sibling behind. Remove ledger-based ranking and the added captain.* event machinery; existing hold-set and status timestamps supply the required ordering. Related sites: bin/fm-attention.sh:56-78 reads ledger history, :89 selects hold capture time, :101 sorts it; bin/fm-captain-hold.sh:252-280 emits events on retries; bin/fm-fleet-ledger.sh:244-251 adds held/deferred/answered events. Removing this deliberate extension needs authorization.bin/fm-classify-lib.sh:939- Round 1's R4 fix still misses the fold's declaration guard. Afterblocked [at=100]: need access, append continuation prose containing onlyblocked. The authoritative fold ignores that line, but this wrapper finds the existing default key and replaces its timestamp with an empty value, moving the decision to the undated tail. This affects both blocked and needs-decision continuations. Record timestamps only when the shared fold accepts an opening transition, including its colon-or-key declaration guard. Related consumers: bin/fm-fleet-snapshot.sh:821 projects the erased timestamp; bin/fm-attention.sh:91-101 uses it for ordering.🔧 Fix applied.
7 issues (4 errors, 3 warnings) still open:
bin/fm-attention.sh:63- The entire append-only ledger is passed as one argument. Once its compact JSON exceeds Linux's approximately 128 KiB per-argument limit, jq cannot start and the attention feed returns no output. About 70 maximum-length status records suffice. Transport the ledger through stdin or a file instead, as fm-fleet-snapshot.sh already does for large JSON documents.bin/fm-attention.sh:95- Ledger ts records capture time, not decision emission time. For example, a secondmate decision raised at 10:00 but captured at 11:01 sorts ahead of a worker decision raised and immediately recorded at 11:00. Backfill and interrupted-capture retries produce the same error. Preserve source emission ordering instead of letting capture time override it. Relevant sites: bin/fm-attention.sh:75-78 selects capture timestamps, :95 applies them to keyed decisions, and :100 sorts them.bin/fm-attention.sh:82- Supported legacy date-only hold stamps are discarded. A task filed in January with 'Captain hold set: 2026-07-03' gets January's since date, incorrectly sorting behind a July 2 decision. fm-captain-hold.sh explicitly recognizes and preserves date-only stamps. Parse hold_set at day precision before falling back to since; update the precision selection at bin/fm-attention.sh:87 accordingly.bin/fm-attention.sh:89- The ledger-based recency extension exceeds the required “open decisions, newest first” feed and misorders retries. Hold A at 10:00, hold B at 11:00, then retry A at 12:00: A retains its 10:00 hold-set stamp but sorts ahead of B because touched uses the new ledger timestamp. Round 1's R2 fix left this hold sibling behind. Remove ledger-based ranking and the added captain.* event machinery; existing hold-set and status timestamps supply the required ordering. Related sites: bin/fm-attention.sh:56-78 reads ledger history, :89 selects hold capture time, :101 sorts it; bin/fm-captain-hold.sh:252-280 emits events on retries; bin/fm-fleet-ledger.sh:244-251 adds held/deferred/answered events. Removing this deliberate extension needs authorization.bin/fm-attention.sh:79- Supported Beads homes silently lose their captain holds. fm-captain-hold.sh addresses the configured adapter, which can operate without data/backlog.md (docs/configuration.md:345-353), but this projection enumerates only the snapshot's Markdown records. Hold a task on such a home, then read attention: the captain.held event exists, yet open_decisions omits the task because ledger events supply timestamps only. Obtain hold inventory through the configured backlog boundary before projecting it. Related changed sites: bin/fm-attention.sh:54 imports the Markdown inventory; :79-89 enumerates and ranks holds.bin/fm-captain-hold.sh:982- The Round 2 re-hold fix leaves unstamped legacy holds behind. With ledger disabled, let legacy hold A have since=January and hold B have a February stamp. Retry A in March with identical reason and until: hold_changed becomes 0, but write_hold_set_stamp still writes March because A has no existing stamp. A now sorts ahead of B despite the explicitly required unchanged-retry behavior. Preserve the legacy effective opening date when preserving an existing hold. Related sites: bin/fm-captain-hold.sh:982-986 detects the unchanged hold; :1019 writes the new stamp; bin/fm-attention.sh:83 and :89 turn it into new recency.bin/fm-attention.sh:54- Simplification: the full snapshot call unnecessarily collects secondmate home summaries, although attention consumes only this home's backlog and task hints. With a registered secondmate, snapshot_cache_prepare creates state/secondmate-summary-cache; successful remote reads also replace cached summary files (bin/fm-fleet-snapshot.sh:1398 and :1831). Thus the new read stores data despite docs/fleet-ledger.md:74 promising otherwise. No option 1 requirement needs this discarded cross-home aggregation. Remove that collection from the attention path by using a local snapshot projection; retain the required captain events and ledger read.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
TMPDIR="$PWD/.validation-tmp" bash tests/fm-attention.test.sh— passedpython3 ~/.no-mistakes/evidence/01M5PAAQRNW77M8AQJJP4MDZYA/drive_attention.py— real CLI scenarios passedpython3 ~/.no-mistakes/evidence/01M5PAAQRNW77M8AQJJP4MDZYA/drive_beads.py— database initialized; tasks-axi backend capability blocked further validationCompared persisted file hashes and directory inventory across repeated attention readsChecked published and upstream tasks-axi availability; removed disposable tools, fixtures, and downloads; confirmed clean worktree✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.