Skip to content

fix: end task-owned Lavish review sessions during teardown - #6212

Open
mremond wants to merge 7 commits into
kunchenguid:mainfrom
mremond:fm/fm-6130-teardown-ends-lavish-boards
Open

mremond wants to merge 7 commits into
kunchenguid:mainfrom
mremond:fm/fm-6130-teardown-ends-lavish-boards

Conversation

@mremond

@mremond mremond commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Intent

lance 6130 mais vérifie s'il y a déjà des PR qui proposent de corriger ce problème.

Issue #6130 ("Teardown never ends a task's Lavish review sessions, so finished boards accumulate and overflow the SessionStart hook"): nothing in Firstmate ends a task's Lavish review sessions when the task finishes, so boards from torn-down tasks stay open in Lavish indefinitely, the machine-wide session list only grows, and the Lavish SessionStart hook output eventually overflows Claude Code's 10,000-character hook cap for every session on the host.
The issue's proposal, which the maintainer's triage accepted as ready-for-pr (class restore: finishing an existing task lifecycle's cleanup, not a new captain surface): at teardown, after the landed-work and captain-hold gates pass, (1) for each Lavish session whose file is under data// or is recorded in the task's process-event sources, skip it when the task still carries an open captain call on that board, otherwise run lavish-axi end <file>; (2) retire the task's registered Lavish process-event sources in the same step, so the end does not come back as a wake for a task that no longer exists; (3) end worker boards in a scratchpad or the task's worktree before the worktree is returned, which avoids stale missing-file sessions.
Ending a session never deletes the file, and lavish-axi <file> can reopen it later, so this is safe for reference boards.

Check result for existing PRs (2026-09-30): no PR references 6130; the nearest, #5036, retires a task's Lavish pollers at teardown but explicitly keeps the review session open, so it does not fix this.

What Changed

  • End eligible task-owned Lavish sessions and retire their process-event sources before returning worktrees, including scratch, registered external boards, and forced child cleanup.
  • Preserve boards protected by open or unverifiable captain calls, including migrated entries, and sources owned by another task or home.
  • Report cleanup failures without blocking teardown, document the lifecycle, and add regression coverage for attribution, ownership, captain calls, and cleanup ordering.

Risk Assessment

🚨 High: The change can close boards awaiting a captain decision and leaves required session-cleanup paths incomplete.

Testing

Focused regressions passed after setup corrections, and the base commit reproduced the original leak. Real Lavish, tasks-axi and Treehouse checks passed with screenshots and CLI evidence. Beads migration remains untested live because bd is missing. All lab services and transient fixtures were cleaned up.

  • Live validation: ✅ go - 11 of 12 scenarios driven live against the product
Scenario Result Live Evidence
Finish a task: data, scratch and registered external boards end; listeners retire without a terminal wake; unrelated sessions remain open. ✅ pass live Product CLI transcript; before-cleanup-sessions.json; after-cleanup-sessions.json
Reopen a retained board with plain lavish-axi: the session opens and file contents remain unchanged. ✅ pass live after-reopen-sessions.json; artifact hash assertions in live_driver.py
Attempt teardown with dirty or unlanded work: cleanup refuses and preserves the review, source and work. ✅ pass live dirty-console.log
Tear down a captain-held task in automatic or manual backlog mode: its boards and listeners stay open. ✅ pass live holds-console-retry.log; Captain-held review remains open and listening
Tear down with exact, legacy or unresolved captain-call inventory: protected reviews remain open in both backlog modes. ✅ pass live holds-console-retry.log
Answer the inventoried captain call, then tear down: boards end and sources retire. ✅ pass live holds-console-retry.log
Tear down with migrated Beads inventory: resolved holds protect reviews and answered calls allow cleanup. ⏸️ untested no The bd executable is absent from PATH. Provide bd on PATH and rerun this scenario; migration behavior was covered only by executable regression fixtures.
Tear down ordinary or child tasks whose root-selected or registered boards belong to another home: foreign sessions, registrations and live claims remain untouched. ✅ pass live ownership-console.log; children-console.log
Tear down a task containing another task's review: preserve its ownership, then allow its owner to end it. ✅ pass live ownership-console.log
Return an ordinary worker's real Treehouse worktree: its review ends and the slot becomes available. ✅ pass live pool-console.log
Force secondmate cleanup: child boards use their owning home's holds and end before worktree removal or pool return. ✅ pass live children-console.log; pool-console.log
Tear down while Lavish cannot restart because its port is occupied: report the end failure and continue cleanup. ✅ pass live outage-port-conflict-console.log
Evidence: Product CLI transcript

Source: Product CLI transcript

$ bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller
~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller

exit=0
$ bin/fm-lab-home.sh tmux-dir ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller
/tmp/fml.TT5v6D

exit=0
$ tmux -L fm-lab new-session -d -s fm-lab -x 100 -y 30 -c ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ sleep 3600

exit=0
$ tmux -L fm-lab display-message -p #{socket_path},#{pid},0
/private/tmp/fml.TT5v6D/tmux-501/fm-lab,38938,0

exit=0
$ lavish-axi ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/finished/board.html --no-open
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/finished/board.html
  url: "http://127.0.0.1:57890/session/90aa385145c2ba2e"
  status: opened

exit=0
$ lavish-axi ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/scratch/board.html --no-open
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/scratch/board.html
  url: "http://127.0.0.1:57890/session/acfdf1d59ce830e9"
  status: opened

exit=0
$ lavish-axi ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/shared/review.html --no-open
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/shared/review.html
  url: "http://127.0.0.1:57890/session/affd9075179b99a4"
  status: opened

exit=0
$ lavish-axi ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/another-task/board.html --no-open
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/another-task/board.html
  url: "http://127.0.0.1:57890/session/0905602c140133b1"
  status: opened

exit=0
$ lavish-axi ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/finished/already-ended.html --no-open
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/finished/already-ended.html
  url: "http://127.0.0.1:57890/session/cbd49d0484e28191"
  status: opened

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/finished/already-ended.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/finished/already-ended.html
  status: ended

exit=0
$ bin/fm-procevent-lavish.sh arm ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/shared/review.html --for finished [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller]
registered: lavish-affd9075179b99a4 (lavish, task=finished)
armed: lavish-affd9075179b99a4
artifact: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/shared/review.html
owner-task: finished

exit=0
$ bin/fm-procevent-lavish.sh source-id ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/shared/review.html [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller]
lavish-affd9075179b99a4

exit=0
$ bin/fm-procevent.sh list [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller]
SOURCE                       ADAPTER      OWNER      PENDING
lavish-affd9075179b99a4      lavish       task:finished/listening 0

exit=0
$ bin/fm-teardown.sh finished [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller]
fm-gate-refuse: gate agent lifecycle permitted only against lab home ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no live watcher process holds this home lock (last beat: 36s ago).
●  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.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ended: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/finished/board.html
ended: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/scratch/board.html
retired: lavish-affd9075179b99a4
ended: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/shared/review.html
teardown finished complete (window fm-lab:fm-finished, worktree ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/gone-finished)
Backlog: finished just finished (this home keeps no markdown backlog at ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/backlog.md). Update ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/backlog.md - move finished to Done, keep Done to the 10 most recent, then re-scan Queued and dispatch only work whose blockers are gone and date is due.

exit=0
$ lavish-axi ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/finished/board.html --no-open
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller/data/finished/board.html
  url: "http://127.0.0.1:57890/session/90aa385145c2ba2e"
  status: opened

exit=0
$ bin/fm-lab-home.sh create ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-own
~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-own

exit=0
$ tasks-axi add finished Lifecycle lab task --kind ship --file ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-own/data/backlog.md [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-own]
ok: added finished (ship) -> Queued
task:
  id: finished
  title: Lifecycle lab task
  state: queued
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "-"
  hold_kind: "-"
  hold_until: "-"
  kind: ship
  repo: "-"
  priority: "-"
  created: 2026-09-30
  closed: "-"
  deps: none
  links: none
  body: ""
help[2]:
  - Run `tasks-axi start finished --file=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-own/data/backlog.md` to move it to in flight
  - Run `tasks-axi block finished --by <other> --file=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-own/data/backlog.md` to record a dependency

exit=0
$ tasks-axi start finished --file ~/.no-mistakes/worktre

... [113485 bytes truncated] ...

d ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-unknown/data/finished/review.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-unknown/data/finished/review.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-own/data/finished/review.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-own/data/finished/review.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-inventory/data/finished/review.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-inventory/data/finished/review.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-legacy/data/finished/review.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-legacy/data/finished/review.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/held-worker-wt/.lavish/review.html
error: "ENOENT: no such file or directory, realpath '~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/held-worker-wt/.lavish/review.html'"
code: UNKNOWN

exit=1
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/baseline-home]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/child-foreign]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/dirty]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/foreign-registered]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/foreign-root]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-answered]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-inventory]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-legacy]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-own]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-automatic-unknown]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-answered]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-inventory]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-legacy]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-own]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-unknown]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/owner-other-task]
swept: attempted=0

exit=0
$ bin/fm-procevent.sh sweep-home [FM_HOME=~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/owner-registered]
swept: attempted=0

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/held-worker-wt/.lavish/review.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/held-worker-wt/.lavish/review.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/child-home/data/held-worker/review.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/child-home/data/held-worker/review.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/held-worker-shared.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/held-worker-shared.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/held-worker-scratch/review.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/held-worker-scratch/review.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/foreign-worker-wt/.lavish/review.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/foreign-worker-wt/.lavish/review.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-unknown/data/finished/review.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/hold-manual-unknown/data/finished/review.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/foreign-worker-shared.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/foreign-worker-shared.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/dirty/data/finished/review.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/dirty/data/finished/review.html
  status: ended

exit=0
$ lavish-axi end ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/baseline-home/data/finished/review.html
session:
  file: ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/baseline-home/data/finished/review.html
  status: ended

exit=0
$ lavish-axi stop
server:
  status: stopped
  port: 57890

exit=0
$ tmux -L fm-lab kill-server

exit=0
$ bin/fm-lab-home.sh teardown ~/.no-mistakes/worktrees/acf4a767348a/01M3RP354ZWC7R9HH16YWXQDGZ/.gate-test-runtime/controller

exit=0
Evidence: Scenario observations and limitations

Source: Scenario observations and limitations

{
  "target": "793c1ec0120e2f6034615c002fc713fb27c509a3",
  "base": "eb77f02b16aeca9533102070de34b1f8812f4fa2",
  "live_observations": [
    {
      "name": "ordinary teardown",
      "result": "pass",
      "ended": [
        "data",
        "scratch",
        "registered external"
      ],
      "bystander": "open",
      "source": "retired",
      "new_terminal_results": 0,
      "artifact_hashes": "unchanged"
    },
    {
      "name": "plain reopen after teardown",
      "result": "pass",
      "file_unchanged": true
    },
    {
      "name": "captain hold automatic own",
      "result": "pass",
      "board": "open",
      "source": "preserved"
    },
    {
      "name": "captain hold automatic inventory",
      "result": "pass",
      "board": "open",
      "source": "preserved"
    },
    {
      "name": "captain hold automatic legacy",
      "result": "pass",
      "board": "open",
      "source": "preserved"
    },
    {
      "name": "captain hold automatic unknown",
      "result": "pass",
      "board": "open",
      "source": "preserved"
    },
    {
      "name": "captain hold automatic answered",
      "result": "pass",
      "board": "ended",
      "source": "retired"
    },
    {
      "name": "captain hold manual own",
      "result": "pass",
      "board": "open",
      "source": "preserved"
    },
    {
      "name": "captain hold manual inventory",
      "result": "pass",
      "board": "open",
      "source": "preserved"
    },
    {
      "name": "captain hold manual legacy",
      "result": "pass",
      "board": "open",
      "source": "preserved"
    },
    {
      "name": "captain hold manual unknown",
      "result": "pass",
      "board": "open",
      "source": "preserved"
    },
    {
      "name": "dirty worktree refusal",
      "result": "pass",
      "board": "open",
      "source": "unchanged",
      "worktree": "unchanged"
    },
    {
      "name": "captain hold manual answered",
      "result": "pass",
      "board": "ended",
      "source": "retired"
    },
    {
      "name": "unlanded worktree refusal",
      "result": "pass",
      "board": "open",
      "source": "unchanged"
    },
    {
      "name": "forced child removal",
      "result": "pass",
      "own_boards": "ended",
      "child_home": "removed",
      "child_hold": "kept open",
      "parent_hold": "did not affect child",
      "foreign_root_and_registered": "kept open with unchanged live claims"
    },
    {
      "name": "ownership root",
      "result": "pass",
      "board": "open",
      "claim": "unchanged",
      "owner_source": "unchanged"
    },
    {
      "name": "owner later ends root",
      "result": "pass",
      "board": "ended"
    },
    {
      "name": "ownership registered",
      "result": "pass",
      "board": "open",
      "claim": "unchanged",
      "owner_source": "unchanged"
    },
    {
      "name": "owner later ends registered",
      "result": "pass",
      "board": "ended"
    },
    {
      "name": "ownership other-task",
      "result": "pass",
      "board": "open",
      "claim": "unchanged",
      "owner_source": "unchanged"
    },
    {
      "name": "owner later ends other-task",
      "result": "pass",
      "board": "ended"
    },
    {
      "name": "ordinary pooled worktree return",
      "result": "pass",
      "board": "ended",
      "lease": "returned",
      "board_exists_after_return": true
    },
    {
      "name": "baseline reproduction",
      "result": "pass",
      "commit": "eb77f02b16aeca9533102070de34b1f8812f4fa2",
      "task": "removed",
      "board": "incorrectly still open",
      "source": "incorrectly still registered"
    },
    {
      "name": "forced child pooled worktree return",
      "result": "pass",
      "board": "ended",
      "lease": "returned",
      "home": "removed",
      "board_exists_after_return": true
    },
    {
      "name": "unreachable Lavish server",
      "result": "pass",
      "teardown": "completed",
      "warning": "reported",
      "board_file": "preserved"
    },
    {
      "name": "lab cleanup",
      "result": "pass",
      "claims_remaining": 0,
      "all_sessions": "ended",
      "private_tmux": "stopped and removed"
    }
  ],
  "live_limitation": "bd is absent from PATH; migrated Beads identity cases passed the executable regression fixtures only.",
  "setup_retries": [
    "Regression temporary files moved to normal test temp location to satisfy existing nested-home removal guard.",
    "Captain-hold setup retried without replacing the existing task title.",
    "Stopped Lavish auto-recovered; a real local port collision was then used to exercise end failure."
  ],
  "cleanup": "All lab sessions ended, sources retired, dedicated server ports closed, private tmux stopped and its temporary socket directory removed."
}

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 warning
  • 🚨 bin/fm-procevent-lavish.sh:395 - Registered boards outside the supplied roots are never ended. For example, arm a shared artifact with --for task-x1: task_source_artifacts adds it to files, but opened contains only root-matched sessions, so this grep ... || return 0 silently skips ending it after retiring its source. This contradicts the required selection of sessions “recorded in the task's process-event sources.” Separate session-open status from root-based attribution. Related changed sites: bin/fm-procevent-lavish.sh:424 builds the restricted set; :432 adds registered artifacts without updating that set.
  • 🚨 bin/fm-teardown.sh:3492 - The captain-call guard can incorrectly authorize closing a held board. In manual-backlog mode, this early return skips all checks although manual mode only disables automatic backlog mutations. Separately, a supported migrated inventory entry can resolve through migration notes to a held Beads task, while both literal probes here return absent. The existing captain-hold completion gate accepts that migrated entry, but teardown then ends its board. Both violate “skip it when the task still carries an open captain call on that board.” Use the captain-hold owner's complete identity resolution independently of backlog mutation eligibility. Related changed sites: bin/fm-teardown.sh:3498 and :3503 perform incomplete identity probes; :3507 accepts absence; :3529 consumes the incorrect verdict.
  • ⚠️ bin/fm-teardown.sh:3541 - The unconditional success fallback exceeds the requested durable cleanup. If Lavish is unreachable, teardown reports the failed end, then returns the worktree/removes task scratch, leaving an open session whose artifact may be gone. If retirement fails because feedback remains unacknowledged, it instead removes the task endpoint while retaining that task's source. This contradicts “end worker boards ... before the worktree is returned” and the required source retirement. Remove the continue-on-incomplete-cleanup fallback before destructive removal; adding persistent retries is unnecessary. Related changed sites: bin/fm-procevent-lavish.sh:388, :396 and :424 return cleanup failures; bin/fm-teardown.sh:3542 suppresses them; docs/configuration.md:1905 and tests/fm-teardown.test.sh:4373 explicitly encode this extra behavior.
  • ⚠️ bin/fm-teardown.sh:3640 - Forced secondmate cleanup bypasses the new board cleanup for its workers. cleanup_firstmate_home_children runs at :3386 and removes/returns child worktrees through :3268, :3288, :3295 and :3298 before reaching this hook. The hook then examines only the parent's records and, at changed line :3525, excludes the secondmate home from roots. Thus a child with an open board and no captain call leaves a stale session after its artifact disappears, contrary to “end worker boards ... before the worktree is returned.” Invoke the same cleanup using each child's owning home within the existing child-removal path; no additional traversal is needed.

🔧 Fix applied.
3 issues (2 errors, 1 warning) still open:

  • 🚨 bin/fm-procevent-lavish.sh:395 - Registered boards outside the supplied roots are never ended. For example, arm a shared artifact with --for task-x1: task_source_artifacts adds it to files, but opened contains only root-matched sessions, so this grep ... || return 0 silently skips ending it after retiring its source. This contradicts the required selection of sessions “recorded in the task's process-event sources.” Separate session-open status from root-based attribution. Related changed sites: bin/fm-procevent-lavish.sh:424 builds the restricted set; :432 adds registered artifacts without updating that set.
  • ⚠️ bin/fm-teardown.sh:3541 - The unconditional success fallback exceeds the requested durable cleanup. If Lavish is unreachable, teardown reports the failed end, then returns the worktree/removes task scratch, leaving an open session whose artifact may be gone. If retirement fails because feedback remains unacknowledged, it instead removes the task endpoint while retaining that task's source. This contradicts “end worker boards ... before the worktree is returned” and the required source retirement. Remove the continue-on-incomplete-cleanup fallback before destructive removal; adding persistent retries is unnecessary. Related changed sites: bin/fm-procevent-lavish.sh:388, :396 and :424 return cleanup failures; bin/fm-teardown.sh:3542 suppresses them; docs/configuration.md:1905 and tests/fm-teardown.test.sh:4373 explicitly encode this extra behavior.
  • 🚨 bin/fm-procevent-lavish.sh:392 - Cleanup can close another home's active review. For example, home B arms A/data/task-x/board.html for task-y, then A tears down task-x. The ownership check at :376 only examines A's registry, so B's registration is invisible and this call ends its session. Even when A also has a registration, retirement at :384 can succeed while deliberately preserving B's claim (bin/fm-procevent.sh:2210–2247). B then receives an unexpected terminal result, potentially while awaiting a captain answer. Check the existing machine-wide claim and owning registration at the shared board-ending boundary, preserving foreign-owned sessions. Both selection paths are affected: bin/fm-procevent-lavish.sh:428 (roots) and :437 (registered artifacts), through bin/fm-teardown.sh:3650 (ordinary cleanup) and :3327 (child cleanup). The round-1 attribution and child-cleanup fixes leave this ownership case unresolved.

🔧 Fix applied.
1 warning still open:

  • ⚠️ bin/fm-teardown.sh:3541 - The unconditional success fallback exceeds the requested durable cleanup. If Lavish is unreachable, teardown reports the failed end, then returns the worktree/removes task scratch, leaving an open session whose artifact may be gone. If retirement fails because feedback remains unacknowledged, it instead removes the task endpoint while retaining that task's source. This contradicts “end worker boards ... before the worktree is returned” and the required source retirement. Remove the continue-on-incomplete-cleanup fallback before destructive removal; adding persistent retries is unnecessary. Related changed sites: bin/fm-procevent-lavish.sh:388, :396 and :424 return cleanup failures; bin/fm-teardown.sh:3542 suppresses them; docs/configuration.md:1905 and tests/fm-teardown.test.sh:4373 explicitly encode this extra behavior.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 11 of 12 scenarios driven live against the product
Scenario Result Live Evidence
Finish a task: data, scratch and registered external boards end; listeners retire without a terminal wake; unrelated sessions remain open. ✅ pass live Product CLI transcript; before-cleanup-sessions.json; after-cleanup-sessions.json
Reopen a retained board with plain lavish-axi: the session opens and file contents remain unchanged. ✅ pass live after-reopen-sessions.json; artifact hash assertions in live_driver.py
Attempt teardown with dirty or unlanded work: cleanup refuses and preserves the review, source and work. ✅ pass live dirty-console.log
Tear down a captain-held task in automatic or manual backlog mode: its boards and listeners stay open. ✅ pass live holds-console-retry.log; Captain-held review remains open and listening
Tear down with exact, legacy or unresolved captain-call inventory: protected reviews remain open in both backlog modes. ✅ pass live holds-console-retry.log
Answer the inventoried captain call, then tear down: boards end and sources retire. ✅ pass live holds-console-retry.log
Tear down with migrated Beads inventory: resolved holds protect reviews and answered calls allow cleanup. ⏸️ untested no The bd executable is absent from PATH. Provide bd on PATH and rerun this scenario; migration behavior was covered only by executable regression fixtures.
Tear down ordinary or child tasks whose root-selected or registered boards belong to another home: foreign sessions, registrations and live claims remain untouched. ✅ pass live ownership-console.log; children-console.log
Tear down a task containing another task's review: preserve its ownership, then allow its owner to end it. ✅ pass live ownership-console.log
Return an ordinary worker's real Treehouse worktree: its review ends and the slot becomes available. ✅ pass live pool-console.log
Force secondmate cleanup: child boards use their owning home's holds and end before worktree removal or pool return. ✅ pass live children-console.log; pool-console.log
Tear down while Lavish cannot restart because its port is occupied: report the end failure and continue cleanup. ✅ pass live outage-port-conflict-console.log
  • Executed the 11 Lavish-focused functions from tests/fm-teardown.test.sh through bash tests/.gate-lavish-selected.sh; all 25 checks passed after correcting temporary fixture placement.
  • Reproduced issue 6130 using fm-teardown.sh from base eb77f02b16aeca9533102070de34b1f8812f4fa2 against a real Lavish session.
  • python3 live_driver.py setup: isolated Lavish server, marked lab home, private tmux socket, real task-owned listener.
  • python3 live_scenarios.py holds, dirty, and ownership: captain holds, refusal gates and ownership protections.
  • python3 live_children.py: forced child cleanup using byte-identical executable copies.
  • python3 live_pool.py: ordinary and child cleanup with real Treehouse leases.
  • python3 live_outage.py: real Lavish failure caused by a local port collision.
  • chrome-devtools-axi screenshot: captured and inspected open, ended and protected review surfaces.
  • python3 cleanup_live.py: retired lab listeners, ended sessions and stopped private services; removed transient fixtures and confirmed clean git status.
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

…e their sources

Nothing ended a task's Lavish sessions when the task finished, so boards from
torn-down tasks stayed open indefinitely and the machine-wide session list only
grew. After every refusal gate has passed and before the worktree is returned,
teardown now asks bin/fm-procevent-lavish.sh end-task to retire the sources that
listened on the task's boards and end their sessions, attributing boards by path
only (data/<id>/, the task worktree and scratch, and artifacts of sources
registered for the task). A task still carrying an open captain call keeps its
boards, and a failure to end a session is reported without blocking teardown.
@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High risk] Adds task-owned Lavish session cleanup to teardown.

The PR appears safe to merge based on this review; no new actionable finding or outstanding previous finding remains.

Reviews (3) · Last reviewed commit: "fix(ci): Captain, fixed all three findin..."

Comment thread bin/fm-procevent-lavish.sh Resolved
Comment thread bin/fm-procevent.sh Resolved
Comment thread bin/fm-teardown.sh Resolved
…quired captain-call reads while still rejecting public-followup operations. Five focused cases, targeted lint, and diff checks pass. Production code unchanged; full CI shard not rerun
…ks, exact task ownership, and child refusal ordering. Added executable regressions. Teardown: 132 passed, 1 Darwin skip; 7 ownership checks, targeted lint, and diff checks passed. Procevent reached 137 passing cases before missing `setsid` blocked completion
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