Skip to content

fix: allow scout cleanup after answered calls are archived - #31

Merged
peterOC26 merged 3 commits into
mainfrom
fm/fm-teardown-pruned-decision-key-k1
Oct 22, 2026
Merged

peterOC26 merged 3 commits into
mainfrom
fm/fm-teardown-pruned-decision-key-k1

Conversation

@peterOC26

@peterOC26 peterOC26 commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Intent

Scout cleanup refuses when its answered captain call was pruned to the done archive.

2026-10-16: pv-voice-reliability-program-p1 cleanup refuses at the captain-call completion gate because its task record's decision_keys names pv-voice-reliability-program-approve-a1, which was answered (Q765 A) and then pruned from data/backlog.md into data/done-archive.md by the done_keep retention; bin/fm-captain-hold.sh complete cannot resolve it either.

2026-10-20: second case. pv-voice-sibilant-listen-l1 (Q930 Y: close it, keep the report) refuses cleanup the same way: decision_keys names pv-voice-sibilant-listen-l1-review, answered 2026-10-19 and pruned to data/done-archive.md (Resolution mode: answered). Both records and isolated copies stay until this is fixed. Never --force.

Q1178 C 2026-10-22 ("q1178 C but instead of gpt-6.1-sol xhigh use astra medium"): diagnosis/plan steps on gpt-6-astra medium, code on gpt-6.1-sol high, Claude Opus checks.

Q1180 A 2026-10-22 ("q1180 A"): firstmate-repo PRs go to the fork peterOC26/firstmate (the kunchenguid remote was renamed so the role gate resolves the fork).

What Changed

  • Resolve pruned captain-call inventory entries from the configured markdown done archive, including legacy identities, so answered calls allow scout cleanup.
  • Require recorded resolutions for archived calls, preserve live-row precedence, and retain origin checks.
  • Document archive handling and add regression coverage for successful cleanup and invalid inventory refusals.

Risk Assessment

✅ Low: The change adds a read-only fallback to the done archive for inventory validation only, and it fails closed. I checked it against the tasks-axi 0.2.6 source: archive path precedence and defaults, the Done-section parser and the archive heading format all match. It still requires a recorded resolution and the right origin, live rows still take precedence, and other lookups stay live-only.

Testing

Real CLI scenarios reproduced the base failure and verified successful archived-answer cleanup, configuration and legacy compatibility, and adversarial refusals. Product transcripts and persisted-state evidence were captured; all checks passed and temporary worktree files were removed.

  • Live validation: ✅ go - 12 of 12 scenarios driven live against the product
Scenario Result Live Evidence
Prune the answered program approval: base completion refuses; changed completion and cleanup succeed while preserving the report ✅ pass live Live CLI transcripts: answered-program
Prune the answered sibilant review: complete, verify, and cleanup succeed without force ✅ pass live Live CLI transcripts: answered-sibilant
Archive a released call at a configured path containing spaces and #: completion and cleanup succeed ✅ pass live Live CLI transcripts: released-custom
Use a legacy decision key referencing an archived answer: verification and cleanup succeed ✅ pass live Live CLI transcripts: legacy
Archive a call closed without an answer: completion and cleanup refuse and preserve task records ✅ pass live Live CLI transcripts: unanswered
Leave only a hold annotation on a malformed archived row: cleanup remains blocked ✅ pass live Live CLI transcripts: held-annotation
Reference a call absent from both backlog and archive: refusal preserves metadata, report, and existing scratch files ✅ pass live Live CLI transcripts: missing
Recreate an unanswered live call sharing an archived answered ID: the live row takes precedence and blocks cleanup ✅ pass live Live CLI transcripts: live-shadow
Reference an archived answer belonging to another origin: completion and cleanup refuse ✅ pass live Live CLI transcripts: wrong-origin
Duplicate the archived call ID: ambiguity blocks completion and cleanup ✅ pass live Live CLI transcripts: duplicate
Retain an active live captain hold: the existing durable-inventory completion behavior still succeeds ✅ pass live Live CLI transcripts: active-live
Attempt to answer an archived-only call: ordinary mutation refuses and the archive remains unchanged ✅ pass live Live CLI transcripts: answered-program
Evidence: Live CLI transcripts, archive records, and cleanup results

Source: Live CLI transcripts, archive records, and cleanup results

Real fm-captain-hold.sh, fm-teardown.sh and tasks-axi 0.2.6; disposable marked FM_HOME directories; no force and no mocked executables.
Lab records represent completed scouts whose runtime endpoint and scratch copy have departed, except the missing-inventory refusal which retains an existing scratch directory.

SCENARIO: answered-program
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/answered-program
~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/answered-program
[exit 0]
$ tasks-axi add pv-voice-reliability-program-p1 Completed scout awaiting cleanup --kind scout --repo sample --start
ok: added pv-voice-reliability-program-p1 (scout, repo sample) -> In flight
task:
  id: pv-voice-reliability-program-p1
  title: Completed scout awaiting cleanup
  state: in_flight
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: sample
  priority: "-"
  created: 2026-10-22
  closed: "-"
  deps: none
  links: none
  body: ""
help[2]:
  - Run `tasks-axi done pv-voice-reliability-program-p1 --pr <url>` when it ships
  - Run `tasks-axi block pv-voice-reliability-program-p1 --by <other>` to record a dependency
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh hold pv-voice-reliability-program-approve-a1 --title Choose the review outcome --reason Captain choice pending --repo sample --origin pv-voice-reliability-program-p1
pv-voice-reliability-program-approve-a1
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh answer pv-voice-reliability-program-approve-a1 --decision-file ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/answered-program/answer.txt
answered: pv-voice-reliability-program-approve-a1
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh complete pv-voice-reliability-program-p1 pv-voice-reliability-program-approve-a1
complete: pv-voice-reliability-program-p1 captain-call inventory reviewed (pv-voice-reliability-program-approve-a1)
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh verify pv-voice-reliability-program-p1
verified: pv-voice-reliability-program-p1 captain-call inventory
[exit 0]
$ tasks-axi prune --keep 0
ok: prune done -> archived 1 (kept 0)
help[1]:
  - Run `tasks-axi list --state done` to see retained Done items
[exit 0]
$ tasks-axi show pv-voice-reliability-program-approve-a1 --full
error: "Task \"pv-voice-reliability-program-approve-a1\" not found in this backlog"
code: NOT_FOUND
help[1]: Run `tasks-axi list` to see existing tasks
[exit 1]
PERSISTED DONE ARCHIVE:

## Archived 2026-10-22
- [x] pv-voice-reliability-program-approve-a1 - Choose the review outcome (repo: sample) (kind: captain) (done 2026-10-22) (hold: fm-hold-v1:Q2FwdGFpbiBjaG9pY2UgcGVuZGluZw==) (hold-kind: captain)
  Resolution recorded by fm-captain-hold.
  Decision digest: 815c98a9d74bd473c8f063bcd37102b4bc142a62f1af5193f3ca0f77054e94de
  Resolution mode: answered

  Captain decision:
  Close it, keep the report.

  Captain hold origin: pv-voice-reliability-program-p1

  Origin: pv-voice-reliability-program-p1


$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/.fm-captain-hold-baseline.sh complete pv-voice-reliability-program-p1 --none
fm-captain-hold: no captain-held task pv-voice-reliability-program-approve-a1 and no migrated hold for it in this home's configured backlog (data directory ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/answered-program/data); the nearest legacy identity pv-voice-reliability-program-p1-decision-pv-voice-reliability-program-approve-a1 also resolves to nothing
[exit 1]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-remote-job-reap-orphans.sh --dry-run
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh verify pv-voice-reliability-program-p1
verified: pv-voice-reliability-program-p1 captain-call inventory
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh complete pv-voice-reliability-program-p1 --none
complete: pv-voice-reliability-program-p1 captain-call inventory reviewed (pv-voice-reliability-program-approve-a1)
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh answer pv-voice-reliability-program-approve-a1 --decision-file ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/answered-program/answer.txt
fm-captain-hold: captain-held task pv-voice-reliability-program-approve-a1 is absent from this home's configured backlog (data directory ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/answered-program/data)
[exit 1]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-teardown.sh pv-voice-reliability-program-p1
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/answered-program
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision with a foreground checkpoint: bin/fm-watch-checkpoint.sh --seconds 180.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
warning: lsof is unavailable; cannot resolve the tmux pane process group for pv-voice-reliability-program-p1
teardown pv-voice-reliability-program-p1 complete (window fm-lab-cleanup:fm-pv-voice-reliability-program-p1, worktree ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/answered-program/projects/departed-pv-voice-reliability-program-p1)
Backlog: pv-voice-reliability-program-p1 is closed in ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/answered-program/data/backlog.md. Run bin/fm-tasks-axi.sh ready for dependency-cleared candidates, check date gates, and dispatch only work whose blockers are gone and date is due.
[exit 0]
$ tasks-axi show pv-voice-reliability-program-p1 --full
task:
  id: pv-voice-reliability-program-p1
  title: Completed scout awaiting cleanup data/pv-voice-reliability-program-p1/report.md
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: sample
  priority: "-"
  created: "-"
  closed: 2026-10-22
  deps: none
  links: "report:data/pv-voice-reliability-program-p1/report.md"
  body: ""
[exit 0]
$ tasks-axi show pv-voice-reliability-program-p1 --full
task:
  id: pv-voice-reliability-program-p1
  title: Completed scout awaiting cleanup data/pv-voice-reliability-program-p1/report.md
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: sample
  priority: "-"
  created: "-"
  closed: 2026-10-22
  deps: none
  links: "report:data/pv-voice-reliability-program-p1/report.md"
  body: ""
[exit 0]
PERSISTED RESULT: task metadata removed; origin is done.
PERSISTED RESULT: report bytes preserved; done archive unchanged.

SCENARIO: answered-sibilant
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX

... [41432 bytes truncated] ...

  body: ""
help[2]:
  - Run `tasks-axi done review-duplicate --pr <url>` when it ships
  - Run `tasks-axi block review-duplicate --by <other>` to record a dependency
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh hold call-duplicate --title Choose the review outcome --reason Captain choice pending --repo sample --origin review-duplicate
call-duplicate
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh answer call-duplicate --decision-file ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/duplicate/answer.txt
answered: call-duplicate
[exit 0]
$ tasks-axi prune --keep 0
ok: prune done -> archived 1 (kept 0)
help[1]:
  - Run `tasks-axi list --state done` to see retained Done items
[exit 0]
$ tasks-axi show call-duplicate --full
error: "Task \"call-duplicate\" not found in this backlog"
code: NOT_FOUND
help[1]: Run `tasks-axi list` to see existing tasks
[exit 1]
PERSISTED DONE ARCHIVE:

## Archived 2026-10-22
- [x] call-duplicate - Choose the review outcome (repo: sample) (kind: captain) (done 2026-10-22) (hold: fm-hold-v1:Q2FwdGFpbiBjaG9pY2UgcGVuZGluZw==) (hold-kind: captain)
  Resolution recorded by fm-captain-hold.
  Decision digest: 815c98a9d74bd473c8f063bcd37102b4bc142a62f1af5193f3ca0f77054e94de
  Resolution mode: answered

  Captain decision:
  Close it, keep the report.

  Captain hold origin: review-duplicate

  Origin: review-duplicate


$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh verify review-duplicate
fm-captain-hold: captain-call inventory call-duplicate is ambiguous in done archive ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/duplicate/data/done-archive.md
[exit 1]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh complete review-duplicate --none
fm-captain-hold: captain-call inventory call-duplicate is ambiguous in done archive ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/duplicate/data/done-archive.md
[exit 1]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-teardown.sh review-duplicate
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/duplicate
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision with a foreground checkpoint: bin/fm-watch-checkpoint.sh --seconds 180.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
fm-captain-hold: captain-call inventory call-duplicate is ambiguous in done archive ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/duplicate/data/done-archive.md
REFUSED: scout task review-duplicate has not passed the captain-call completion gate.
Inventory its report and any visual review through bin/fm-captain-hold.sh before teardown.
[exit 1]
PERSISTED RESULT: refusal preserved task metadata.
PERSISTED RESULT: report bytes preserved; done archive unchanged.

SCENARIO: active-live
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/active-live
~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/active-live
[exit 0]
$ tasks-axi add review-active-live Completed scout awaiting cleanup --kind scout --repo sample --start
ok: added review-active-live (scout, repo sample) -> In flight
task:
  id: review-active-live
  title: Completed scout awaiting cleanup
  state: in_flight
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: sample
  priority: "-"
  created: 2026-10-22
  closed: "-"
  deps: none
  links: none
  body: ""
help[2]:
  - Run `tasks-axi done review-active-live --pr <url>` when it ships
  - Run `tasks-axi block review-active-live --by <other>` to record a dependency
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh hold call-active-live --title Choose the review outcome --reason Captain choice pending --repo sample --origin review-active-live
call-active-live
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh verify review-active-live
verified: review-active-live captain-call inventory
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-captain-hold.sh complete review-active-live --none
complete: review-active-live captain-call inventory reviewed (call-active-live)
[exit 0]
$ bash ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/bin/fm-teardown.sh review-active-live
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/active-live
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision with a foreground checkpoint: bin/fm-watch-checkpoint.sh --seconds 180.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
warning: lsof is unavailable; cannot resolve the tmux pane process group for review-active-live
teardown review-active-live complete (window fm-lab-cleanup:fm-review-active-live, worktree ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/active-live/projects/departed-review-active-live)
Backlog: review-active-live is closed in ~/.no-mistakes/worktrees/7f0ec18181b6/01M5HE5B2T4PX6W0SD17VS5PYR/.lv/active-live/data/backlog.md. Run bin/fm-tasks-axi.sh ready for dependency-cleared candidates, check date gates, and dispatch only work whose blockers are gone and date is due.
[exit 0]
$ tasks-axi show review-active-live --full
task:
  id: review-active-live
  title: Completed scout awaiting cleanup data/review-active-live/report.md
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: sample
  priority: "-"
  created: "-"
  closed: 2026-10-22
  deps: none
  links: "report:data/review-active-live/report.md"
  body: ""
[exit 0]
$ tasks-axi show review-active-live --full
task:
  id: review-active-live
  title: Completed scout awaiting cleanup data/review-active-live/report.md
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: scout
  repo: sample
  priority: "-"
  created: "-"
  closed: 2026-10-22
  deps: none
  links: "report:data/review-active-live/report.md"
  body: ""
[exit 0]
PERSISTED RESULT: task metadata removed; origin is done.
PERSISTED RESULT: report bytes preserved; done archive unchanged.
Evidence: Reproducible isolated CLI scenario driver

Source: Reproducible isolated CLI scenario driver

import os, subprocess, pathlib, shutil, json, hashlib, time, sys
ROOT=pathlib.Path.cwd()
EVIDENCE=pathlib.Path('~/.no-mistakes/evidence/01M5HE5B2T4PX6W0SD17VS5PYR')
LABROOT=ROOT/'.lv'
BASE=ROOT/'bin/.fm-captain-hold-baseline.sh'
assert not LABROOT.exists() and not BASE.exists()
LABROOT.mkdir()
base_env=dict(os.environ)
for key in list(base_env):
    if (key.startswith('FM_') and (key.endswith('_OVERRIDE') or key in ['FM_HOME','FM_GATE_REFUSE_BYPASS','FM_TEST_SEAM','FM_TASK_ID'])) or key in ['TASKS_AXI_FILE','TASKS_AXI_BACKEND','TMUX']:
        base_env.pop(key,None)
prior=json.loads((EVIDENCE/"scenario-results.json").read_text()) if sys.argv[1:] else []
results=[]
log=None

def run(args,home,expected=0):
    env=dict(base_env,FM_HOME=str(home),TMPDIR=str(home/'tmp'),TMUX=str(LABROOT/'s')+',0,0')
    log.write('$ '+ ' '.join(map(str,args))+'\n');log.flush()
    p=subprocess.run(list(map(str,args)),cwd=home,env=env,text=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT,timeout=45)
    log.write(p.stdout+'[exit '+str(p.returncode)+']\n');log.flush()
    if expected is not None:
        assert (p.returncode==0)==(expected==0), (args,p.returncode,p.stdout)
    return p

def cap(home,*args,expected=0,baseline=False):
    return run(['bash',BASE if baseline else ROOT/'bin/fm-captain-hold.sh',*args],home,expected)

def tasks(home,*args,expected=0):
    return run(['tasks-axi',*args],home,expected)

try:
    BASE.write_bytes(subprocess.check_output(['git','show','9a124ef969e2a20d33fa66e92ce0dddd93fda254:bin/fm-captain-hold.sh']))
    cases=['answered-program','answered-sibilant','released-custom','legacy','unanswered','held-annotation','missing','live-shadow','wrong-origin','duplicate','active-live']
    if sys.argv[1:]: cases=sys.argv[1:]
    for case in cases:
        start=time.time()
        home=LABROOT/case
        logpath=EVIDENCE/(case+'.log')
        log=logpath.open('w')
        try:
            run(['bash',ROOT/'bin/fm-lab-home.sh','create',home],ROOT)
        except FileNotFoundError:
            raise
        (home/'tmp').mkdir()
        archive=home/'data'/('retained calls #1.md' if case=='released-custom' else 'done-archive.md')
        (home/'.tasks.toml').write_text('backend = "markdown"\n[markdown]\npath = "data/backlog.md"\narchive = "'+str(archive.relative_to(home))+'"\ndone_keep = 10\n')
        (home/'data/backlog.md').write_text('## In flight\n\n## Queued\n\n## Done\n')
        origin={'answered-program':'pv-voice-reliability-program-p1','answered-sibilant':'pv-voice-sibilant-listen-l1'}.get(case,'review-'+case)
        call={'answered-program':'pv-voice-reliability-program-approve-a1','answered-sibilant':'pv-voice-sibilant-listen-l1-review'}.get(case,'call-'+case)
        if case=='legacy':call=origin+'-decision-choice'
        tasks(home,'add',origin,'Completed scout awaiting cleanup','--kind','scout','--repo','sample','--start')
        meta=home/'state'/(origin+'.meta')
        scratch=home/'projects'/('departed-'+origin)
        if case=='missing':
            scratch.mkdir()
            (scratch/'uncommitted-research.txt').write_text('Preserve this unfinished scratch work.\n')
        meta.write_text('window=fm-lab-cleanup:fm-'+origin+'\nworktree='+str(home/'projects'/('departed-'+origin))+'\nproject='+str(home/'projects/sample')+'\nharness=codex\nkind=scout\nspawn_gen=lab-'+origin+'\ndecisions_reviewed=1\ndecision_keys='+('choice' if case=='legacy' else call)+'\n')
        report=home/'data'/origin/'report.md'
        report.parent.mkdir()
        report.write_text('# Scout report\n\nInvestigation complete; keep this report after cleanup.\n')
        digest=hashlib.sha256(report.read_bytes()).hexdigest()
        (home/'state'/(origin+'.status')).write_text('done: report complete\n')
        positive=case in ['answered-program','answered-sibilant','released-custom','legacy','active-live']
        if case!='missing':
            cap(home,'hold',call,'--title','Choose the review outcome','--reason','Captain choice pending','--repo','sample','--origin','another-review' if case=='wrong-origin' else origin)
            if case not in ['unanswered','held-annotation','active-live']:
                decision=home/'answer.txt';decision.write_text('Close it, keep the report.\n')
                cap(home,'answer',call,'--decision-file',decision,*(['--release'] if case=='released-custom' else []))
                if case=='released-custom':tasks(home,'done',call)
            elif case!='active-live':tasks(home,'done',call)
            if case!='active-live':
                if case in ['answered-program','answered-sibilant','released-custom','legacy']:
                    cap(home,'complete',origin,call)
                    cap(home,'verify',origin)
                tasks(home,'prune','--keep','0')
                tasks(home,'show',call,'--full',expected=1)
                log.write('PERSISTED DONE ARCHIVE:\n'+archive.read_text()+'\n')
                if case=='held-annotation':archive.write_text(archive.read_text().replace('- [x]','- [ ]'))
                if case=='live-shadow':tasks(home,'add',call,'Reopened call without recorded answer','--repo','sample')
                if case=='duplicate':archive.write_text(archive.read_text()+'\n'+archive.read_text())
        archive_before=archive.read_bytes() if archive.exists() else None
        if case=='answered-program':
            old=cap(home,'complete',origin,'--none',baseline=True,expected=1)
            assert 'no captain-held task' in old.stdout,old.stdout
            old=run(['bash',ROOT/'bin/fm-remote-job-reap-orphans.sh','--dry-run'],home)
            assert not old.stdout.strip(),'Unsafe external orphan cleanup candidates: '+old.stdout
        want=0 if positive else 1
        cap(home,'verify',origin,expected=want)
        cap(home,'complete',origin,'--none',expected=want)
        if case=='answered-program':
            # Archive lookup is read-only inventory support, not an answer mutation path.
            cap(home,'answer',call,'--decision-file',home/'answer.txt',expected=1)
        p=run(['bash',ROOT/'bin/fm-teardown.sh',origin],home,expected=want)
        if positive:
            assert not meta.exists(),'cleanup retained task metadata'
            tasks(home,'show',origin,'--full')
            assert 'state: done' in tasks(home,'show',origin,'--full').stdout
            log.write('PERSISTED RESULT: task metadata removed; origin is done.\n')
        else:
            assert 'has not passed the captain-call completion gate' in p.stdout,p.stdout
            assert meta.exists(),'refusal removed task metadata'
            log.write('PERSISTED RESULT: refusal preserved task metadata.\n')
        if case=='missing':
            assert (scratch/'uncommitted-research.txt').read_text()=='Preserve this unfinished scratch work.\n'
            log.write('PERSISTED RESULT: refused cleanup preserved the existing scratch directory and its uncommitted file.\n')
        assert hashlib.sha256(report.read_bytes()).hexdigest()==digest,'report changed'
        assert (archive.read_bytes() if archive.exists() else None)==archive_before,'inventory/cleanup mutated archive'
        log.write('PERSISTED RESULT: report bytes preserved; done archive unchanged.\n')
        results.append({'case':case,'result':'pass','live':True,'evidence':str(logpath)})
        log.close();log=None
        print(case+': PASS ('+str(round(time.time()-start,1))+'s)',flush=True)
        shutil.rmtree(home)
except Exception as e:
    if log:
        log.write('DRIVER FAILURE: '+repr(e)+'\n');log.close();log=None
    results.append({'case':locals().get('case','setup'),'result':'fail','live':True,'error':repr(e)})
    print('FAILED: '+repr(e),flush=True)
finally:
    if BASE.exists():BASE.unlink()
    shutil.rmtree(LABROOT)
    merged={r['case']:r for r in prior}
    merged.update({r['case']:r for r in results})
    (EVIDENCE/'scenario-results.json').write_text(json.dumps(list(merged.values()),indent=2)+'\n')
if any(r['result']=='fail' for r in results):raise SystemExit(1)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ tests/fm-captain-hold-lifecycle.test.sh:4680 - The held case is meant to check the new rule that an archived row still bearing a captain hold is refused (the TASK_SHOW_ARCHIVED guard at bin/fm-captain-hold.sh:619). It never reaches that guard. The case rewrites the archived row to - [ ] id - ..., but the snapshot turns every ## Archived heading into ## Done, and tasks-axi parses Done sections with DONE_RE (^- \[x\] ...) only. So the row is never parsed, tasks-axi show returns NOT_FOUND, and the case refuses because the call is absent, not because of the guard. If the TASK_SHOW_ARCHIVED = 0 condition were deleted, this test would still pass. Fix: build the archived fixture so the row parses as non-done with hold_kind captain. For example, put it under a column-0 ## In flight heading in the archive, which the snapshot sed leaves alone. Then the refusal actually depends on the guard. A side note: archives written by tasks-axi only have ## Archived headings, so in practice the guard is defense in depth for hand-edited archives.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 12 of 12 scenarios driven live against the product
Scenario Result Live Evidence
Prune the answered program approval: base completion refuses; changed completion and cleanup succeed while preserving the report ✅ pass live Live CLI transcripts: answered-program
Prune the answered sibilant review: complete, verify, and cleanup succeed without force ✅ pass live Live CLI transcripts: answered-sibilant
Archive a released call at a configured path containing spaces and #: completion and cleanup succeed ✅ pass live Live CLI transcripts: released-custom
Use a legacy decision key referencing an archived answer: verification and cleanup succeed ✅ pass live Live CLI transcripts: legacy
Archive a call closed without an answer: completion and cleanup refuse and preserve task records ✅ pass live Live CLI transcripts: unanswered
Leave only a hold annotation on a malformed archived row: cleanup remains blocked ✅ pass live Live CLI transcripts: held-annotation
Reference a call absent from both backlog and archive: refusal preserves metadata, report, and existing scratch files ✅ pass live Live CLI transcripts: missing
Recreate an unanswered live call sharing an archived answered ID: the live row takes precedence and blocks cleanup ✅ pass live Live CLI transcripts: live-shadow
Reference an archived answer belonging to another origin: completion and cleanup refuse ✅ pass live Live CLI transcripts: wrong-origin
Duplicate the archived call ID: ambiguity blocks completion and cleanup ✅ pass live Live CLI transcripts: duplicate
Retain an active live captain hold: the existing durable-inventory completion behavior still succeeds ✅ pass live Live CLI transcripts: active-live
Attempt to answer an archived-only call: ordinary mutation refuses and the archive remains unchanged ✅ pass live Live CLI transcripts: answered-program
  • tasks-axi --version and tmux -V capability checks.
  • python3 ~/.no-mistakes/evidence/01M5HE5B2T4PX6W0SD17VS5PYR/drive-archived-cleanup.py drove real hold, answer, prune, complete, verify, and teardown commands in marked lab homes.
  • Executed the base-commit completion script against the same pruned-answer state to reproduce the original refusal.
  • python3 ~/.no-mistakes/evidence/01M5HE5B2T4PX6W0SD17VS5PYR/drive-archived-cleanup.py missing additionally verified preservation of existing scratch files.
  • Checked persisted archive bytes, report hashes, metadata removal or retention, and completed backlog state; removed temporary labs and confirmed clean git status --short.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

peterOC26 and others added 3 commits October 22, 2026 11:07
… waiting for both concurrent recoveries and restoring fixture-directory permissions before cleanup. Targeted lint and portable Herdr tests passed. Live E2E verification was blocked by the worktree’s Unix socket path length
@peterOC26
peterOC26 merged commit 98ac9c3 into main Oct 22, 2026
34 of 37 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