Repository navigation
Conversation
…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.
|
…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
This was referenced Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.
Evidence: Product CLI transcript
Source: Product CLI transcript
Evidence: Scenario observations and limitations
Source: Scenario observations and limitations
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
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 tofiles, butopenedcontains only root-matched sessions, so thisgrep ... || return 0silently 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_childrenruns 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 tofiles, butopenedcontains only root-matched sessions, so thisgrep ... || return 0silently 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.
Executed the 11 Lavish-focused functions from tests/fm-teardown.test.sh throughbash tests/.gate-lavish-selected.sh; all 25 checks passed after correcting temporary fixture placement.Reproduced issue 6130 usingfm-teardown.shfrom 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, andownership: 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 ✅
🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.