Repository navigation
fix(backlog-handoff): move full item blocks including indented bodies - #401
Merged
Merged
Conversation
fm-backlog-handoff only moved the checklist header line, so multi-line item bodies were left orphaned in the source backlog and never reached the secondmate. Move the full block (header plus indented body lines) atomically, treating body membership by indentation so lines like ## Intent stay with the item, and add regression coverage.
kunchenguid
added a commit
that referenced
this pull request
Jul 10, 2026
fm-backlog-handoff.sh's two-pass awk was a second parser of the backlog format and the source of the PR #401 body-orphaning drift. Delete it and delegate the move to `tasks-axi mv <id>... --to <dest>` (v0.2.2 atomic multi-id), the single owner of the format: a connected set (blocker plus dependents) moves together with blocked-by preserved, item blocks stay byte-exact, and destination section placement holds. The helper keeps only the fleet-level validation tasks-axi cannot know - secondmate-home resolution, the seeded-home safety checks, the In-flight refusal, and idempotent per-key reporting - and is atomic: on any move failure nothing moves. Tests: fm-backlog-handoff.test.sh keeps PR #401's regression matrix but now exercises the delegated path and skips cleanly when tasks-axi is absent; the two whole-file fixtures move to tasks-axi's canonical whitespace. The lifecycle-e2e and safety move-cases gain the same skip guard. CI installs tasks-axi so the delegated path is exercised. Docs state that config/backlog-backend=manual governs firstmate's own hand-editing, not this validated helper, which delegates fleet-wide because bootstrap requires tasks-axi on PATH. Remove the now-redundant WIP design note.
kunchenguid
added a commit
that referenced
this pull request
Jul 10, 2026
* wip(handoff): record verified delegation design + tasks-axi mv blocker No production code changed yet. tasks-axi mv (v0.2.1) cannot atomically move a blocked-by-linked item set across backlogs (deadlocks both orders, no batch/--force), which fm-secondmate-lifecycle-e2e requires. Parked pending a tasks-axi connected-set mv enhancement; note captures the verified design, semantics, test/CI/doc changes, and resume checklist. * refactor(handoff): delegate the item move to tasks-axi mv fm-backlog-handoff.sh's two-pass awk was a second parser of the backlog format and the source of the PR #401 body-orphaning drift. Delete it and delegate the move to `tasks-axi mv <id>... --to <dest>` (v0.2.2 atomic multi-id), the single owner of the format: a connected set (blocker plus dependents) moves together with blocked-by preserved, item blocks stay byte-exact, and destination section placement holds. The helper keeps only the fleet-level validation tasks-axi cannot know - secondmate-home resolution, the seeded-home safety checks, the In-flight refusal, and idempotent per-key reporting - and is atomic: on any move failure nothing moves. Tests: fm-backlog-handoff.test.sh keeps PR #401's regression matrix but now exercises the delegated path and skips cleanly when tasks-axi is absent; the two whole-file fixtures move to tasks-axi's canonical whitespace. The lifecycle-e2e and safety move-cases gain the same skip guard. CI installs tasks-axi so the delegated path is exercised. Docs state that config/backlog-backend=manual governs firstmate's own hand-editing, not this validated helper, which delegates fleet-wide because bootstrap requires tasks-axi on PATH. Remove the now-redundant WIP design note. * no-mistakes(review): Captain: harden atomic backlog handoffs * no-mistakes(review): Captain: enforce queued-only backlog handoffs * no-mistakes(review): Captain: harden handoff section parsing * no-mistakes(document): Document delegated backlog handoffs * no-mistakes(lint): Silence ShellCheck source diagnostics
Keigyoku
pushed a commit
to Keigyoku/firstmate
that referenced
this pull request
Jul 11, 2026
…kunchenguid#401) * fix(backlog-handoff): move full item blocks including indented bodies fm-backlog-handoff only moved the checklist header line, so multi-line item bodies were left orphaned in the source backlog and never reached the secondmate. Move the full block (header plus indented body lines) atomically, treating body membership by indentation so lines like ## Intent stay with the item, and add regression coverage. * no-mistakes(review): Captain: preserve EOF handoff terminators * no-mistakes(review): treat blank lines inside item bodies as movable body * no-mistakes(document): sync backlog-handoff docs with full-block move behavior (cherry picked from commit 600075e)
Keigyoku
pushed a commit
to Keigyoku/firstmate
that referenced
this pull request
Jul 11, 2026
* wip(handoff): record verified delegation design + tasks-axi mv blocker No production code changed yet. tasks-axi mv (v0.2.1) cannot atomically move a blocked-by-linked item set across backlogs (deadlocks both orders, no batch/--force), which fm-secondmate-lifecycle-e2e requires. Parked pending a tasks-axi connected-set mv enhancement; note captures the verified design, semantics, test/CI/doc changes, and resume checklist. * refactor(handoff): delegate the item move to tasks-axi mv fm-backlog-handoff.sh's two-pass awk was a second parser of the backlog format and the source of the PR kunchenguid#401 body-orphaning drift. Delete it and delegate the move to `tasks-axi mv <id>... --to <dest>` (v0.2.2 atomic multi-id), the single owner of the format: a connected set (blocker plus dependents) moves together with blocked-by preserved, item blocks stay byte-exact, and destination section placement holds. The helper keeps only the fleet-level validation tasks-axi cannot know - secondmate-home resolution, the seeded-home safety checks, the In-flight refusal, and idempotent per-key reporting - and is atomic: on any move failure nothing moves. Tests: fm-backlog-handoff.test.sh keeps PR kunchenguid#401's regression matrix but now exercises the delegated path and skips cleanly when tasks-axi is absent; the two whole-file fixtures move to tasks-axi's canonical whitespace. The lifecycle-e2e and safety move-cases gain the same skip guard. CI installs tasks-axi so the delegated path is exercised. Docs state that config/backlog-backend=manual governs firstmate's own hand-editing, not this validated helper, which delegates fleet-wide because bootstrap requires tasks-axi on PATH. Remove the now-redundant WIP design note. * no-mistakes(review): Captain: harden atomic backlog handoffs * no-mistakes(review): Captain: enforce queued-only backlog handoffs * no-mistakes(review): Captain: harden handoff section parsing * no-mistakes(document): Document delegated backlog handoffs * no-mistakes(lint): Silence ShellCheck source diagnostics (cherry picked from commit 31afb8c)
Intent
Fix bin/fm-backlog-handoff.sh so secondmate backlog handoffs move the full item block, not just the checklist header line.
Bug (confirmed live 2026-07-09): handing ha-codex-fast-default-4e to a secondmate only moved the
- [ ] <id> ...header; the item's indented multi-line body stayed in the source data/backlog.md and visually attached to the preceding item. The secondmate worked from the title alone and the spec had to be re-delivered by hand.Required behavior:
Prior pipeline run completed intent/rebase/review/test; review auto-fixed EOF terminator preservation (commit 8c9276c on this branch). Document step failed only because of a Codex usage limit; the gate daemon now runs Claude. Re-validate the full branch including that review fix through to a green PR.
Deliberate scope: only bin/fm-backlog-handoff.sh and tests/fm-backlog-handoff.test.sh. Sibling crews own other files; do not expand scope.
What Changed
bin/fm-backlog-handoff.shso a handoff carries the- [ ] <id>header plus every following indented body line - including internal blank lines and indented##lines - up to the next item line or section heading, atomically and byte-exact, instead of moving only the header and orphaning the body in the source.##markers (e.g.## Intent) are no longer misread as section boundaries, and preserved existing safeguards (## In flightrefusal, seeded-secondmate-home destination validation, idempotent re-run, untouched-line preservation) plus EOF handoff terminators.tests/fm-backlog-handoff.test.shcovering body-followed-by-item, body-followed-by-section-heading, multi-paragraph internal blanks, EOF last lines, indented##tokenizer trap, and idempotent re-run; updated the script header comment,CONTRIBUTING.md, and the secondmate-provisioning skill to describe the full-block move behavior.Risk Assessment
✅ Low: The change is well-bounded to two files, correctly fixes the prior round's body-orphaning finding, carefully preserves byte-exact EOF terminators, and is backed by thorough regression tests covering item/section/EOF boundaries, indented headings, internal blanks, and idempotence; I found no correctness bugs.
Testing
Baseline test command had already passed; I additionally ran the colocated tests/fm-backlog-handoff.test.sh (8 passing regression cases covering all five required scenarios) plus the two related secondmate suites (safety and lifecycle-e2e), all green. To demonstrate the intent as an end user experiences it, I built an E2E reproduction of the exact 2026-07-09 incident: the base-commit script moved only the
- [ ]header and orphaned the indented body (## Intent / spec / ## Acceptance) onto the preceding item, while the fixed branch moved the entire block atomically to the secondmate backlog with neighbors untouched and the source clean. I also confirmed the retained safety behavior (in-flight refusal, unseeded-destination refusal) and idempotent re-run. This is a CLI/data-file change with no rendered UI surface, so evidence is the before/after backlog transcripts rather than screenshots. Working tree left clean.Evidence: E2E before/after backlog transcript: base (buggy) vs fixed script on the ha-codex-fast-default-4e incident, plus idempotence re-run
Evidence: Safety refusals transcript: ## In flight handoff refused (source unchanged) and unseeded-destination-home refused
Evidence: Base-commit (pre-fix) copy of fm-backlog-handoff.sh used for the buggy-vs-fixed contrast
Evidence: Key contrast excerpt (source backlog after handoff)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-backlog-handoff.sh:316- A body block stops at the first blank line, which contradicts the documented contract and can re-orphan body lines. The header comment (lines 10-12) and pass-1 comment (lines 264-267) both state the block runs "up to the next item line or section heading." But a blank line is not indented, so it fails themoving && /^[ \t]/continuation rule and falls through to the catch-all (line 322), which setsmoving = 0. Any indented lines AFTER an internal blank line are then no longer moving, so they are left (orphaned) in the source and never reach the destination. Multi-paragraph markdown item bodies with a blank line between paragraphs (e.g.- [ ] x\n para one\n\n para two\n- [ ] next) split: onlypara onemoves,para twostays orphaned in data/backlog.md attached to nothing - the same failure mode this change fixes. No test covers an internal-blank body (the referenceextract_item_blockin the test also treats blank as a terminator, so the suite shares the blind spot). Either treat blank lines inside a body as part of the block (match the documented "up to the next item line or section heading" semantics) or document explicitly that a blank line terminates a body block and rely on the firstmate convention that bodies are contiguous indented lines.🔧 Fix: treat blank lines inside item bodies as movable body
1 info still open:
bin/fm-backlog-handoff.sh:320- Consistent-with-intent side effect (not a defect): under the new blank-is-body rule, a blank line between a moved item's body and the following column-0 section heading is captured as trailing body and moves with the item. For blank-separated items this keeps the source well-formed, but handing off the last item in a section consumes that section's trailing blank separator, leaving two##headings adjacent in the source. Purely cosmetic, valid backlog, and re-normalized on the next tasks-axi mutation; noted only so the behavior is on record.✅ **Test** - passed
✅ No issues found.
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"bash tests/fm-backlog-handoff.test.sh(8 tests: body followed by item, by section heading, multi-paragraph internal blanks, EOF last-lines, seeded-destination boundary, untouched-EOF terminator, idempotent re-run, indented ## tokenizer trap) - exit 0bash tests/fm-secondmate-safety.test.sh- exit 0 (includes handoff atomic-abort and unsafe-home refusal)bash tests/fm-secondmate-lifecycle-e2e.test.sh- exit 0 (includes single-line handoff happy path)E2E contrast: ran base-commit script (80ecc8d copy) vs fixed bin/fm-backlog-handoff.sh on the ha-codex-fast-default-4e incident scenario, capturing before/after of both source and destination backlog.mdManual safety checks: verified## In flighthandoff refusal leaves source unchanged, and refusal of a destination that is not a seeded secondmate homeVerified idempotence: second handoff run reports 'already present' and mutates neither backlog (destination header count stays 1)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.