Skip to content

fix(fm-session-start): show in-flight and queued beads instead of ready-only - #32

Merged
trillium merged 1 commit into
mainfrom
fm/beads-migration-s2-inflight-visibility
Aug 2, 2026
Merged

fix(fm-session-start): show in-flight and queued beads instead of ready-only#32
trillium merged 1 commit into
mainfrom
fm/beads-migration-s2-inflight-visibility

Conversation

@trillium

@trillium trillium commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Intent

beads-authority Stage 2 - session-start's beads-backend digest shows In flight (in_progress+blocked) and Queued (ready) sections scoped by the fleet:firstmate label, mirroring data/backlog.md's structure instead of --ready alone; default (markdown) backend output byte-identical; tests added; read/visibility only, no home flipped.

What Changed

  • print_backlog_beads_compact in bin/fm-session-start.sh now queries the beads store twice — task list --label <fleet-label> --status in_progress,blocked and task list --label <fleet-label> --ready — and renders them under ## In flight / ## Queued headings, mirroring data/backlog.md's structure instead of showing only bd's native ready set.
  • Read failure on either query falls back to the full title-line rendering of data/backlog.md rather than emitting a partial digest.
  • docs/configuration.md updated to describe the two-section beads digest, its label scoping, and the fallback behavior; tests/fm-session-start.test.sh extended with coverage for both sections rendering and the partial-failure fallback path.

Risk Assessment

✅ Low: Small, well-scoped read-only change (two task list calls instead of one, mirroring backlog.md's structure and reusing the existing fleet-label filter pattern already proven in fm-fleet-snapshot.sh); non-beads backend code paths are untouched, and both the success and partial-failure fallback paths are covered by new tests.

Testing

Ran the full fm-session-start test suite (34/34 pass, including the two new beads-digest tests), then independently reproduced the beads-backend digest end-to-end with the same fake task CLI fixtures to capture the actual captain-facing transcript showing the ## In flight / ## Queued sections, and separately confirmed the default tasks-axi backend's output is byte-for-byte identical between the base and target commits by running both versions of the script against the same fixture and diffing (only volatile tmp-path/pid text differed) — all consistent with the stated read-only, visibility-only intent.

Evidence: Real end-to-end session-start digest transcript (beads backend) showing the new In flight / Queued sections
=== FULL SESSION-START OUTPUT (beads backend) ===

================================================================================
SESSION START - /var/folders/8k/0ll7yqm179v19qqg3qmgcq3m0000gn/T//fm-session-start-tests.AfuKdz/manual-beads-verify/home
================================================================================

LOCK
--------------------------------------------------------------------------------
lock acquired: harness pid 88423

BOOTSTRAP
--------------------------------------------------------------------------------
MISSING: tasks-axi (install: npm install -g tasks-axi)
MISSING: quota-axi (install: npm install -g quota-axi)

WAKE QUEUE
--------------------------------------------------------------------------------
(no queued wakes)
================================================================================
SUPERVISION OPERATING INSTRUCTIONS - primary harness: claude
================================================================================
Current state:
- Lock: held by this session; this session owns normal supervision unless away mode says otherwise.
- Away mode: inactive.
- X mode: inactive; use the default watcher cadence.
- Ordinary wake: the Stop-owned auto-arm (bin/fm-claude-stop-autoarm.sh) already owns watcher continuity; drain and handle the wake, and do not arm another cycle yourself.

Mode: Claude Stop-hook-owned supervision.

When this session owns supervision and away mode is not active:
1. Drain first with `bin/fm-wake-drain.sh`.
2. Routine watcher arm and re-arm are owned by the Stop `asyncRewake` hook (`bin/fm-claude-stop-autoarm.sh`), never by you.
   Every turn end while supervision is needed launches or attaches one home-scoped watcher cycle with no model command and no model tokens.
   An actionable close wakes you through the hook's exit-2 rewake, delivered as a `Stop hook feedback` message.
3. On a `Stop hook feedback` wake (`signal:`, `stale:`, `check:`, or `heartbeat`), run `bin/fm-wake-drain.sh` first and handle the wake.
   Do not run `bin/fm-watch-arm.sh` after an ordinary wake; the next turn end re-arms automatically when supervision is still needed.
   Do not invent a wake from an attach-status line alone; drain and act only on real wake records or a real watcher reason line.
4. On a `Stop hook feedback` watcher-failure wake (`watcher: FAILED ...`), treat it as an alarm: drain, then repair supervision before ending the turn.
5. Manual arm is recovery only.
   When a repair is genuinely needed - the Stop hook did not claim this home, or a forced restart is required - run `bin/fm-watch-arm.sh` (or `bin/fm-watch-arm.sh --restart`) as its own Claude Code background task, never bundled with other commands, never with shell `&`.
   Source `/var/folders/8k/0ll7yqm179v19qqg3qmgcq3m0000gn/T//fm-session-start-tests.AfuKdz/manual-beads-verify/home/config/x-mode.env` first when X mode is active.
   A shell `&`, a truncating pipe, or bundling is denied automatically by the PreToolUse seatbelt (`bin/fm-arm-pretool-check.sh`) registered in `.claude/settings.json`.
6. Treat `watcher: started ...` and `watcher: attached ...` inside arm output as proof that one live cycle exists.
   On attach, the arm follows verified identity-matched successors instead of exiting when the first cycle ends.
7. The durable wake queue preserves actionable events between a rewake and the next Stop-launched arm, while the bounded turn-end guard prevents a blind Stop when recovery did not start.
   No PreToolUse hook denies fleet commands based on watcher status.
   [`watcher-continuity.md`](../watcher-continuity.md) owns the exact session-lock recovery boundary.
8. The turn-end guard (`bin/fm-turnend-guard.sh --claude`) remains the final backstop.
   It allows the stop when a watcher is healthy, when the auto-arm already owns recovery for this event epoch, or when a fresh rewake is recorded; it re-blocks only when none of those materialize, within a bounded budget.
9. Waiting on the hook-owned cycle is silent: do not send idle progress while the watcher is parked.

The watcher itself remains `bin/fm-watch.sh`, and `bin/fm-watch-arm.sh` remains the verified arm wrapper that the Stop hook foregrounds.
Re-arm attaches to an existing healthy cycle when one is already present and follows its verified successor chain.
See [`watcher-continuity.md`](../watcher-continuity.md) for the arm-layer successor and clean-close failure contract and the Claude ownership model.


================================================================================
PERSONA
================================================================================

persona.md (tracked default)
--------------------------------------------------------------------------------
# Persona

test default persona

================================================================================
CONTEXT
================================================================================

data/projects.md
--------------------------------------------------------------------------------
ABSENT

data/secondmates.md
--------------------------------------------------------------------------------
ABSENT

data/captain.md
--------------------------------------------------------------------------------
ABSENT

data/captain-shared.md (shared, main-authoritative, read-only in secondmate homes)
--------------------------------------------------------------------------------
ABSENT

data/learnings.md
--------------------------------------------------------------------------------
ABSENT

================================================================================
FLEET STATE
================================================================================

data/backlog.md
--------------------------------------------------------------------------------
compact backlog listing (beads task store; label fleet:firstmate; max 80 item(s) per section)
## In flight
inflight-task-1
inflight-task-2
## Queued
ready-task-1
ready-task-2
Full task bodies remain available on demand: task show <id> (beads task store), or data/backlog.md.

Work under way (state/*.meta)
--------------------------------------------------------------------------------
(none)

Orphan status logs (state/*.status without matching .meta)
--------------------------------------------------------------------------------
(none)

AFK
--------------------------------------------------------------------------------
absent

================================================================================
NEXT STEP
================================================================================
Follow the supervision operating instructions block above for harness 'claude'.
This script never starts supervision itself.

The digest above is complete for this session start. Do NOT re-read
persona.md, config/persona.md, data/projects.md, data/secondmates.md,
data/captain.md, data/captain-shared.md, data/learnings.md,
or state/*.meta now - they were just printed in full.
Do NOT bulk-read data/backlog.md now either: the compact identity/metadata
listing was just printed with a pointer for targeted full-body follow-up.
Do NOT bulk-read state/*.status now either: their bounded tails were just
printed with full log paths for targeted follow-up when older wake-event
history is actually needed. Re-reading everything defeats the entire point
of this command. Re-read a file only if this digest flagged it ABSENT (then
rebuild or create it per AGENTS.md), its contents looked unparseable/corrupt,
or an individual full status log is needed for older wake-event history.

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-session-start.test.sh (full suite, 34 tests, 0 failures)
  • test_backlog_compact_beads_shows_inflight_and_queued_sections — asserts '## In flight'/'## Queued' headings, both fleet:firstmate-scoped queries with --limit 80, and both sections' items present
  • test_backlog_compact_beads_partial_failure_falls_back_to_manual — asserts a failing In-flight beads read triggers full title-line fallback rather than a partial digest
  • Manual end-to-end run of bin/fm-session-start.sh against a fake beads task CLI (same fixtures as the test suite) to capture the real digest transcript a captain would see
  • Source-diff of bin/fm-session-start.sh between base and target commits confirmed only print_backlog_beads_compact changed
  • Live A/B run of the tasks-axi (default) backend path against both the base and target fm-session-start.sh, diffed after normalizing volatile tmp-path/pid text — byte-identical
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Summary by CodeRabbit

  • New Features

    • Session-start backlog summaries now separate tasks into In flight and Queued sections.
    • Listings are scoped to the configured fleet and include blocked, active, and ready work.
    • Backlog views now consistently include this information in session digests, fleet snapshots, and Bearings output.
  • Bug Fixes

    • If backlog retrieval fails, the complete manual backlog summary is shown instead of partial results.
  • Documentation

    • Updated configuration guidance to explain the new backlog sections, scoping, and fallback behavior.

Stage 2 of the beads-authority migration
(data/beads-authority-migration-scout/report.md section 4). The beads
branch of session-start's compact backlog listing queried only
`task list --ready`, which silently dropped in_progress/blocked work
from the digest - a regression against data/backlog.md's `## In flight`/
`## Queued` structure.

print_backlog_beads_compact now renders two sections mirroring that
structure, both scoped by the firstmate-fleet label
(fm_beads_fleet_label, same label fm-fleet-snapshot.sh's Stage 1 beads
read already uses):

- In flight: task list --label <label> --status in_progress,blocked
- Queued: task list --label <label> --ready

A failure on either read falls back to the whole title-line rendering
of data/backlog.md, same as before. Default (non-beads) backend output
is unchanged.
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The session-start Beads backlog now shows fleet-scoped In flight and Queued sections. Each query is bounded and failures trigger complete markdown backlog fallback. Documentation and tests cover the new queries and fallback behavior.

Changes

Beads backlog flow

Layer / File(s) Summary
Scoped backlog rendering and documented behavior
bin/fm-session-start.sh, docs/configuration.md
The renderer queries fleet-scoped in-progress or blocked tasks and dependency-ready tasks separately. Query failures print both outputs and trigger markdown fallback.
Query fixtures and fallback regression coverage
tests/fm-session-start.test.sh
Tests validate section headings, fleet scoping, query bounds, exact commands, and complete fallback after an in-flight query failure.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SessionStart
  participant BeadsCLI
  participant MarkdownBacklog
  SessionStart->>BeadsCLI: Query fleet-scoped In flight tasks
  SessionStart->>BeadsCLI: Query fleet-scoped Queued tasks
  BeadsCLI-->>SessionStart: Return listings or failure
  SessionStart->>MarkdownBacklog: Render complete fallback on failure
Loading

Possibly related PRs

  • trillium/firstmate#26: The change extends its ready-task query with fleet-scoped In flight and Queued sections, tests, and fallback handling.

Suggested reviewers: kunchenguid

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change from ready-only beads to separate in-flight and queued sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fm/beads-migration-s2-inflight-visibility

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bin/fm-session-start.sh`:
- Around line 281-283: Make the fallback output all-or-nothing in
bin/fm-session-start.sh around the query-failure handling: when either Beads
query fails, do not print either captured result before the markdown fallback,
including a successful Queued result when the In flight query fails. Update
tests/fm-session-start.test.sh in the affected fallback case to assert that
ready-task-1 is absent from the output.

In `@docs/configuration.md`:
- Line 63: Update the fallback documentation in the Beads backend section to
state that session start reads data/backlog.md for the title-line fallback when
a Beads read fails, aligning it with the behavior described near the existing
configuration guidance and implemented by bin/fm-session-start.sh.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f24cb485-8550-4f8d-a8f0-2fead362b630

📥 Commits

Reviewing files that changed from the base of the PR and between 4cabd72 and 0a15b3c.

📒 Files selected for processing (3)
  • bin/fm-session-start.sh
  • docs/configuration.md
  • tests/fm-session-start.test.sh

Comment thread bin/fm-session-start.sh
Comment on lines 281 to +283
printf 'beads task listing failed; falling back to title-line rendering.\n'
printf '%s\n' "$out"
printf '%s\n' "$out_inflight"
printf '%s\n' "$out_queued"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep the fallback output all-or-nothing.

If the In flight query fails and the Queued query succeeds, Line 283 prints the successful Queued result before the markdown fallback. The output then contains a partial Beads listing and the fallback listing.

  • bin/fm-session-start.sh#L281-L283: Do not print a successful query capture after either query fails.
  • tests/fm-session-start.test.sh#L1392-L1398: Assert that ready-task-1 is absent from fallback output.
Proposed fix
   else
     printf 'beads task listing failed; falling back to title-line rendering.\n'
-    printf '%s\n' "$out_inflight"
-    printf '%s\n' "$out_queued"
     if [ -f "$path" ]; then
       print_backlog_manual_compact "$path" "fallback"
   assert_contains "$out" "- [ ] blocked-followup - Follow compact startup" \
     "beads read failure fallback omitted the Queued backlog title line - a partial digest was printed instead of the full title-line fallback"
+  assert_not_contains "$out" "ready-task-1" \
+    "beads read failure fallback printed successful Queued-query output"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
printf 'beads task listing failed; falling back to title-line rendering.\n'
printf '%s\n' "$out"
printf '%s\n' "$out_inflight"
printf '%s\n' "$out_queued"
printf 'beads task listing failed; falling back to title-line rendering.\n'
Suggested change
printf 'beads task listing failed; falling back to title-line rendering.\n'
printf '%s\n' "$out"
printf '%s\n' "$out_inflight"
printf '%s\n' "$out_queued"
assert_contains "$out" "- [ ] blocked-followup - Follow compact startup" \
"beads read failure fallback omitted the Queued backlog title line - a partial digest was printed instead of the full title-line fallback"
assert_not_contains "$out" "ready-task-1" \
"beads read failure fallback printed successful Queued-query output"
📍 Affects 2 files
  • bin/fm-session-start.sh#L281-L283 (this comment)
  • tests/fm-session-start.test.sh#L1392-L1398
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bin/fm-session-start.sh` around lines 281 - 283, Make the fallback output
all-or-nothing in bin/fm-session-start.sh around the query-failure handling:
when either Beads query fails, do not print either captured result before the
markdown fallback, including a successful Queued result when the In flight query
fails. Update tests/fm-session-start.test.sh in the affected fallback case to
assert that ready-task-1 is absent from the output.

Comment thread docs/configuration.md
Set the local, gitignored `config/backlog-backend` file to `manual` to force manual backlog editing and suppress the verbose `BOOTSTRAP_INFO: tasks-axi available` fact, not missing-tool reporting.
Absent or `tasks-axi` selects the default tasks-axi backend.
The file format is unchanged in tasks-axi and manual modes; both produce the same `## In flight`, `## Queued`, and `## Done` sections in `data/backlog.md`.
The beads backend does not use `data/backlog.md`; all backlog state lives in the beads store and is queried dynamically at session start.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the fallback documentation.

Line 63 conflicts with Line 57 and bin/fm-session-start.sh. When a Beads read fails, session-start reads data/backlog.md for the title-line fallback.

Proposed fix
-The beads backend does not use `data/backlog.md`; all backlog state lives in the beads store and is queried dynamically at session start.
+When Beads reads succeed, backlog state is queried dynamically from the beads store. If either read fails, session-start uses `data/backlog.md` for its title-line fallback.

As per coding guidelines, “Report failures and outcomes faithfully, with concrete evidence rather than masking or minimizing failures.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
The beads backend does not use `data/backlog.md`; all backlog state lives in the beads store and is queried dynamically at session start.
When Beads reads succeed, backlog state is queried dynamically from the beads store. If either read fails, session-start uses `data/backlog.md` for its title-line fallback.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/configuration.md` at line 63, Update the fallback documentation in the
Beads backend section to state that session start reads data/backlog.md for the
title-line fallback when a Beads read fails, aligning it with the behavior
described near the existing configuration guidance and implemented by
bin/fm-session-start.sh.

Source: Coding guidelines

@trillium
trillium merged commit 23d6f30 into main Aug 2, 2026
12 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