Skip to content

fix(captain-hold): resolve attested captain calls from the done archive - #1

Merged
demy00 merged 4 commits into
mainfrom
fm/fm-hold-gate-pruned-keys
Sep 22, 2026
Merged

demy00 merged 4 commits into
mainfrom
fm/fm-hold-gate-pruned-keys

Conversation

@demy00

@demy00 demy00 commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

Automated checks now run on this repository and this pull request is green.
An earlier version of this description said the automated verdict was unavailable. That was true when it was written: automation had never been confirmed on this copy of the repository, so no workflow had ever run here. It has since been enabled, this pull request was re-triggered, and both the build and the description compliance check passed.
Review, test, document and lint had already passed locally in the no-mistakes pipeline before that point.

Intent

The captain's overnight instruction was: "do not merge anything but any PRs are welcome that are created ... please open PRs but do not merge them. build upon each PRs state expecting that it will be merged. (rebase from the prev PR) you can continue on any project roadmap you find and are set up." Nothing merges tonight; the captain reviews everything tomorrow.

This defect was found by a worker on another task, cp-fe-audit-b2, which hit it while trying to close out completed work. That worker diagnosed it precisely and then deliberately stopped rather than hand-editing firstmate's own data to get past the refusal. That was the correct call, and it is why this task exists instead of a silently corrupted record.

What it hit, in its own words: complete cp-fe-audit-b2 and verify both refuse with "no captain-held task cp-admin-portal-brandable and no migrated hold for it". The mechanism it traced: command_complete unions the agent's supplied inventory with the previously attested decision_keys recorded in state/<id>.meta, then re-resolves EVERY entry through resolve_entry at bin/fm-captain-hold.sh:1554-1565.

I verified the premise independently before filing this. state/cp-fe-audit-b2.meta carries decision_keys=cp-admin-portal-brandable,cp-role-delete-semantics. Both captain calls were genuinely answered and closed - cp-admin-portal-brandable on 2026-09-08, cp-role-delete-semantics on 2026-09-09 - and both are recorded [x] done in data/done-archive.md with the captain's recorded answers intact. They have since been pruned out of data/backlog.md, which is normal retention, so tasks-axi show now returns NOT_FOUND for each.

So the gate wedges on a completely normal lifecycle: answer a captain call, let retention archive it, and every future completion attempt for that origin fails forever. No supported command reaches it - answer and hold both require the task to exist, and reconcile requires a pending board request that does not exist. The blocked worker is a real, current cost: its work is finished and delivered but it cannot attest completion.

What Changed

  • bin/fm-captain-hold.sh: the completion gate (complete and verify) now resolves an inventory entry from the live backlog first and from the markdown done archive second, via new resolve_attested_entry / task_show_durable. An answered captain call that retention pruned out of the backlog no longer refuses with "no captain-held task ... and no migrated hold for it". Only the lookup widens: an archived row closed without a recorded captain answer, or a key naming no row in either place, still refuses with the original message, and a read-bound hit (124) still propagates. Mutating subcommands (hold, answer, reconcile) keep resolving from the live backlog alone.
  • The archived row is read with tasks-axi itself through a private scratch copy (the archive is never written) that renames ## Archived <date> headings to ## Done and keeps only the newest row block for a reused id, so an older answered row never vouches for a later unanswered close and vice versa. bin/fm-tasks-axi-lib.sh adds fm_tasks_axi_markdown_archive_resolve, which finds the archive with tasks-axi's own precedence: [markdown] archive in the root .tasks.toml, then $HOME/.tasks-axi/config.toml, else done-archive.md beside the backlog file.
  • tests/fm-captain-hold-lifecycle.test.sh adds an archived-answer family driven by tasks-axi's real retention (answered call before and after pruning, --none re-attestation, bare-done and unknown-key refusals, archived + live key union, homes with no root .tasks.toml, and reused keys in both directions); docs/captain-hold-lifecycle.md documents the archive lookup and its limits.

Risk Assessment

✅ Low: The change widens only the read-only completion-gate lookup to the done archive, keeps verify_hold_durable's rule unchanged so unanswered or absent keys still refuse, propagates the 124 read bound, leaves mutating paths on the live backlog, and its archive precedence, newest-row dedup, and heading rename traced correctly against a real tasks-axi archive.

Testing

No baseline commands ran before this step. I ran only the seven archive-related completion-gate tests from the captain-hold lifecycle suite against real tasks-axi 0.2.5 retention, and all passed. I then replayed the intent's scenario end to end with HOME pinned to an empty directory: two answered captain calls pruned into data/done-archive.md, with an origin whose meta carries both decision_keys. On base 259a669, verify and complete --none refuse with the exact reported message. On target 04d802b both succeed, an unknown key is still refused, and the archive file is unchanged after the gate reads it. There is no UI surface, so the evidence is CLI transcripts. The worktree is clean, but a denied cleanup command left two scratch items in /tmp.

Evidence: E2E transcript BEFORE fix (base 259a669) - wedge reproduced

Source: E2E transcript BEFORE fix (base 259a669) - wedge reproduced

$ cap verify cp-fe-audit-b2 fm-captain-hold: no captain-held task cp-admin-portal-brandable and no migrated hold for it in this home's configured backlog (data directory <tmp>~); the nearest legacy identity cp-fe-audit-b2-decision-cp-admin-portal-brandable also resolves to nothing [exit 1] $ cap complete cp-fe-audit-b2 --none fm-captain-hold: no captain-held task cp-admin-portal-brandable and no migrated hold for it ... [exit 1]

=== BEFORE fix (base 259a669) ===

$ cap complete cp-fe-audit-b2 cp-admin-portal-brandable cp-role-delete-semantics
complete: cp-fe-audit-b2 captain-call inventory reviewed (cp-admin-portal-brandable,cp-role-delete-semantics)
[exit 0]

$ grep decision_keys <tmp>~/cp-fe-audit-b2.meta
decision_keys=cp-admin-portal-brandable,cp-role-delete-semantics
[exit 0]

--- retention prunes the answered calls into the archive ---

$ t show cp-admin-portal-brandable
error: "Task \"cp-admin-portal-brandable\" not found in this backlog"
code: NOT_FOUND
help[1]: Run `tasks-axi list` to see existing tasks
[exit 1]

$ grep -n ^- \[x\] cp- <tmp>~/done-archive.md
4:- [x] cp-role-delete-semantics - Decide cp-role-delete-semantics (repo: sample) (kind: captain) (done 2026-09-21) (hold: captain choice pending) (hold-kind: captain)
12:- [x] cp-admin-portal-brandable - Decide cp-admin-portal-brandable (repo: sample) (kind: captain) (done 2026-09-21) (hold: captain choice pending) (hold-kind: captain)
[exit 0]

--- the blocked worker's commands ---

$ cap verify cp-fe-audit-b2
fm-captain-hold: no captain-held task cp-admin-portal-brandable and no migrated hold for it in this home's configured backlog (data directory <tmp>~); the nearest legacy identity cp-fe-audit-b2-decision-cp-admin-portal-brandable also resolves to nothing
[exit 1]

$ cap complete cp-fe-audit-b2 --none
fm-captain-hold: no captain-held task cp-admin-portal-brandable and no migrated hold for it in this home's configured backlog (data directory <tmp>~); the nearest legacy identity cp-fe-audit-b2-decision-cp-admin-portal-brandable also resolves to nothing
[exit 1]

$ grep -E decision_keys|decisions_reviewed <tmp>~/cp-fe-audit-b2.meta
decisions_reviewed=1
decision_keys=cp-admin-portal-brandable,cp-role-delete-semantics
[exit 0]

--- archive untouched by the gate, unknown key still refused ---

$ cap complete cp-fe-audit-b2 cp-never-existed
fm-captain-hold: no captain-held task cp-admin-portal-brandable and no migrated hold for it in this home's configured backlog (data directory <tmp>~); the nearest legacy identity cp-fe-audit-b2-decision-cp-admin-portal-brandable also resolves to nothing
[exit 1]
archive checksum unchanged
Evidence: E2E transcript AFTER fix (target 04d802b) - archived answered calls resolve

Source: E2E transcript AFTER fix (target 04d802b) - archived answered calls resolve

$ t show cp-admin-portal-brandable error: "Task &#34;cp-admin-portal-brandable&#34; not found in this backlog" code: NOT_FOUND [exit 1] $ grep -n '^- [x] cp-' <tmp>~/done-archive.md 4:- [x] cp-role-delete-semantics - ... (kind: captain) (done 2026-09-21) ... 12:- [x] cp-admin-portal-brandable - ... (kind: captain) (done 2026-09-21) ... $ cap verify cp-fe-audit-b2 verified: cp-fe-audit-b2 captain-call inventory [exit 0] $ cap complete cp-fe-audit-b2 --none complete: cp-fe-audit-b2 captain-call inventory reviewed (cp-admin-portal-brandable,cp-role-delete-semantics) [exit 0] $ cap complete cp-fe-audit-b2 cp-never-existed fm-captain-hold: no captain-held task cp-never-existed and no migrated hold for it ... [exit 1] archive checksum unchanged

=== AFTER fix (target 04d802b) ===

$ cap complete cp-fe-audit-b2 cp-admin-portal-brandable cp-role-delete-semantics
complete: cp-fe-audit-b2 captain-call inventory reviewed (cp-admin-portal-brandable,cp-role-delete-semantics)
[exit 0]

$ grep decision_keys <tmp>~/cp-fe-audit-b2.meta
decision_keys=cp-admin-portal-brandable,cp-role-delete-semantics
[exit 0]

--- retention prunes the answered calls into the archive ---

$ t show cp-admin-portal-brandable
error: "Task \"cp-admin-portal-brandable\" not found in this backlog"
code: NOT_FOUND
help[1]: Run `tasks-axi list` to see existing tasks
[exit 1]

$ grep -n ^- \[x\] cp- <tmp>~/done-archive.md
4:- [x] cp-role-delete-semantics - Decide cp-role-delete-semantics (repo: sample) (kind: captain) (done 2026-09-21) (hold: captain choice pending) (hold-kind: captain)
12:- [x] cp-admin-portal-brandable - Decide cp-admin-portal-brandable (repo: sample) (kind: captain) (done 2026-09-21) (hold: captain choice pending) (hold-kind: captain)
[exit 0]

--- the blocked worker's commands ---

$ cap verify cp-fe-audit-b2
verified: cp-fe-audit-b2 captain-call inventory
[exit 0]

$ cap complete cp-fe-audit-b2 --none
complete: cp-fe-audit-b2 captain-call inventory reviewed (cp-admin-portal-brandable,cp-role-delete-semantics)
[exit 0]

$ grep -E decision_keys|decisions_reviewed <tmp>~/cp-fe-audit-b2.meta
decisions_reviewed=1
decision_keys=cp-admin-portal-brandable,cp-role-delete-semantics
[exit 0]

--- archive untouched by the gate, unknown key still refused ---

$ cap complete cp-fe-audit-b2 cp-never-existed
fm-captain-hold: no captain-held task cp-never-existed and no migrated hold for it in this home's configured backlog (data directory <tmp>~); the nearest legacy identity cp-fe-audit-b2-decision-cp-never-existed also resolves to nothing
[exit 1]
archive checksum unchanged
Evidence: Targeted archive gate tests (7 cases, all ok)

Source: Targeted archive gate tests (7 cases, all ok)

ok - the completion gate accepts an answered captain call pruned into the archive ok - the gate still refuses an archived call with no recorded answer and an unknown key ok - the completion gate unions archived and live inventory and keeps a held call open ok - the gate reads tasks-axi's default archive in a home that configures none ok - the gate reads the archive the user's tasks-axi config names ok - the gate refuses a reused key whose newest archived close recorded no answer ok - the gate accepts a reused key whose newest archived close is answered

ok - the completion gate accepts an answered captain call pruned into the archive
ok - the gate still refuses an archived call with no recorded answer and an unknown key
ok - the completion gate unions archived and live inventory and keeps a held call open
ok - the gate reads tasks-axi's default archive in a home that configures none
ok - the gate reads the archive the user's tasks-axi config names
ok - the gate refuses a reused key whose newest archived close recorded no answer
ok - the gate accepts a reused key whose newest archived close is answered
- Outcome: ⚠️ 1 info across 1 run (2m11s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 info
  • ℹ️ My final cleanup command (rm -rf of /tmp/fm-base., /tmp/fm-e2e-demo.sh, /tmp/fm-e2e-home.) was denied by the permission mode, so I did not retry it. Left behind outside the worktree: /tmp/fm-base.gliVqd (a git-archive extract of base commit 259a669 used for the before-fix run) and /tmp/fm-e2e-demo.sh (the demo driver). The per-run /tmp/fm-e2e-home.* dirs were removed by the script itself. The worktree is clean (git status empty); the temporary targeted test runner I created under tests/ was deleted. These /tmp leftovers are harmless and can be deleted manually.
  • tests/fm-captain-hold-lifecycle.test.sh restricted to the 7 archive cases (test_completion_gate_accepts_an_archived_answered_call, _refuses_an_archived_call_with_no_recorded_answer, _unions_archived_and_live_inventory, _accepts_an_archived_answer_without_a_tasks_toml, _reads_the_archive_named_by_the_user_config, _refuses_a_reused_key_whose_newest_archived_close_is_unanswered, _accepts_a_reused_key_whose_newest_archived_close_is_answered) - all ok, against real tasks-axi 0.2.5
  • Manual E2E on base 259a669 (extracted with git archive): hold + answer cp-admin-portal-brandable and cp-role-delete-semantics, complete cp-fe-audit-b2 &lt;keys&gt;, prune with tasks-axi done filler --keep 0, then fm-captain-hold.sh verify cp-fe-audit-b2 and complete cp-fe-audit-b2 --none - both refuse with the exact reported message 'no captain-held task cp-admin-portal-brandable and no migrated hold for it'
  • Same manual E2E on target 04d802b: verify prints 'verified: cp-fe-audit-b2 captain-call inventory' (exit 0), complete --none re-attests both archived keys (exit 0), decision_keys preserved in state meta
  • On target: complete cp-fe-audit-b2 cp-never-existed still refuses (exit 1) and the done-archive.md checksum is unchanged after the gate reads it
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Observed failures against the unfixed code

The new user-config archive test was run against the code before the fix and failed with the original wedge:

not ok - the gate refused an answered call archived where the user config names: fm-captain-hold: no captain-held task sample-usercfg-call and no migrated hold for it in this home's configured backlog (data directory .../archived-user-config/data); the nearest legacy identity sample-usercfg-review-decision-sample-usercfg-call also resolves to nothing

With the fix, the full tests/fm-captain-hold-lifecycle.test.sh suite passes locally.
The original live reproduction (state/cp-fe-audit-b2.meta) had already been cleaned up from the home by the time this branch was resumed, so it could not be re-run; the synthetic fixtures driven by tasks-axi's own retention stand as the evidence.
Failure output from the earlier archived-key tests on this branch was not preserved across the worker restart.

The completion gate re-resolves every previously attested decision key on
every later attempt, but resolved them from the live backlog only. Retention
prunes an answered captain call out of that backlog into the configured
archive, so a completely ordinary lifecycle - answer the call, let retention
archive it - permanently wedged every later `complete` and `verify` for that
origin with "no captain-held task <id> and no migrated hold for it". No
supported command could reach it: `answer` and `hold` require the task to
exist, and `reconcile` requires a pending board request.

The recorded answer was never lost, only unreachable. The archive is an
ordinary markdown backlog whose sections are dated "## Archived <date>"
headings rather than "## Done", which tasks-axi's markdown parser skips
outright, reading the file as zero tasks. The gate now reads an archived row
through a private scratch copy with those headings renamed, so the row is
parsed by tasks-axi itself into the same --full field shape as a live one.
The archive is never written.

Only the lookup widens. verify_hold_durable applies the same rule to an
archived row as to a live one, and an archived row is closed by definition, so
it satisfies the gate solely on a recorded captain answer; a key naming no row
in either place still refuses with exactly the message it always did. The
mutating subcommands keep resolving from the live backlog alone, because
tasks-axi cannot address an archived row and it must never be handed to hold,
answer, or reconcile as if it could.
…urce and bound its read

Archive resolution now follows tasks-axi's own precedence, including
$HOME/.tasks-axi/config.toml, through one resolver in fm-tasks-axi-lib.sh.
The archive read uses the backlog row read bound, and a bound hit propagates
instead of reading as an absent row. The no-toml test pins HOME so the
developer's ambient tasks-axi config cannot decide it.
@demy00 demy00 closed this Sep 22, 2026
@demy00 demy00 reopened this Sep 22, 2026
@demy00
demy00 merged commit 999f9d8 into main Sep 22, 2026
20 checks passed
demy00 added a commit that referenced this pull request Oct 16, 2026
## Conflict resolutions

The trial merge listed 13 conflicted files; the actual merge also conflicts in `tests/fm-procevent.test.sh` (14 total).

| File | Fork origin | Resolution |
| --- | --- | --- |
| `.agents/skills/agent-skill-trigger-index/SKILL.md` | 09efd59 (#6, clickup-tickets) | Fork's `clickup-tickets` trigger line re-added to upstream's list unchanged. |
| `AGENTS.md` | 3843b2c (#8, skill selection); 89e1459 (#3, `feature/` prefix) | Fork's `fm-skill-select.sh --apply` line and the `feature/` default wording re-applied on upstream's new section 7 text (upstream added `--base-branch` and self-repo consent lines next to it; both kept). |
| `README.md` | 89e1459 (#3), via earlier fork syncs | Default ship-branch prefix wording stays `feature/` in upstream's rewritten bullet. |
| `bin/fm-captain-hold.sh` | 999f9d8 (#1, done-archive evidence) | Fork's done-archive lookup re-applied unchanged on upstream's version. |
| `bin/fm-dod-lib.sh` | 89e1459 (#3), 16cc4bd | Upstream's new base-branch/forge/consent code kept; its two `fm/$id` defaults now call `fm_task_branch` and the lib sources `fm-task-branch-lib.sh`, as the fork did before. |
| `bin/fm-procevent-lavish.sh` | 826e32b, 79d101b, d0ac8f4, cbfb295 (#7) | True clash, decided by the captain (option A) - see below. |
| `bin/fm-spawn.sh` | 89e1459 (#3), 16cc4bd, b7edc11, 153f4e2, de04c2d | Fork's `feature/` branch naming and legacy-brief branch binding re-applied unchanged on upstream's version. |
| `bin/fm-timeout-lib.sh` | 9e8b923 (bash without `BASHPID`) | Upstream fixed the same macOS bash 3.2 bug independently (5838f10, kunchenguid#6028, perl watchdog takes the pre-exec parent). Took upstream's code; the fork's regression test for it is kept and passes on upstream's fix. |
| `docs/architecture.md` | 89e1459 (#3) | `feature/` default and the `fm-task-branch-lib.sh` ownership line re-applied. |
| `tests/fm-brief.test.sh` | 89e1459 (#3), via earlier fork syncs | Expected branch names stay `feature/<id>` in upstream's updated cases. |
| `tests/fm-calm-pi-extension.test.sh` | bc3f178 (#10), 1757302 (#8 CI fix) | Upstream fixed the `/reload` geometry flake its own way (`wait_for_geometry_reload` on a durable status row), so the fork's `pipe-pane` version is dropped. Kept the fork's lookup-counting export renderer, the report-based Chrome hang attempt check, and the `tuiMode: regular` settings pin next to upstream's `--tui-mode regular` flag. |
| `tests/fm-procevent.test.sh` | #7 | Both test sets kept; see the Lavish decision. |
| `tests/fm-review-diff.test.sh` | 89e1459 (#3) | Fork's two unrecorded-`feature/` branch cases re-added; case letters shifted after upstream's new cases. |
| `tests/fm-timeout-lib.test.sh` | 9e8b923 | Fork's no-`BASHPID` test kept on top of upstream's tests. |

## Decision: Lavish list-form parser (captain chose option A)

Both sides fixed the same bug: Lavish emits queued feedback as a TOON list (not a table) when items carry nested content, and the adapter read it as an empty, complete result.

- Fork (#7): one parser that flattens and presents every nested field (table-cell `target:`, `attachments:`, other `fields:`, message uid/selector/text), adds `unpresented_items:`, and refuses `complete: yes` when nested content cannot be parsed.
- Upstream (fc8972c, kunchenguid#5404): one parser that skips nested targets and attachments; its tests assert nested content is absent from `read`. It also adds stricter refusals (unrecognized header keeps its declared count and counts as malformed; `answers`/`reconciles` exit 3 when not fully accounted for), and 228b27d renames the message count to `captain_message_count`.

Options:

- **A (chosen):** keep the fork's presenting parser, port upstream's strictness onto it (declared count + malformed on an unrecognized header, `answers`/`reconciles` exit 3, `captain_message_count`), keep both test sets, and adapt upstream's three "absent" assertions to check nested content appears only under its own labelled section and never replaces the item's own text.
  Cost: this region will likely conflict again on the next upstream sync.
- **B:** take upstream's parser and tests wholesale and drop the fork's nested presentation.
  Cost: Lavish reads lose table-cell location, text-selection range, and image attachment paths.
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