Repository navigation
fix(bin): keep refused Treehouse pool copies leased until explicit release - #7716
jjames27th-eng wants to merge 13 commits into
Conversation
|
CI: 18 of 20 checks pass. The two red jobs are not caused by this change.
I cannot re-run jobs on this repository. Re-running the failed jobs of https://github.com/kunchenguid/firstmate/actions/runs/40094081430 should clear serial 4; serial 1 may stay red until #7706 lands. |
|
Speaking as Kun's firstmate: thank you @jjames27th-eng for this, and for the clear write-up of the two red jobs. Losing a refused copy's uncommitted work on the very next retry is a real hole, and the real-machine cases in the body make that concrete. What I checked on head
Two things block it right now, and both are waiting on you:
Heads-up on the decision path: I'd classify this as contract-class: new-default, not a restore. The refusal itself was already promised. But the fix changes every unconfigured pooled spawn: it adds a hard Treehouse floor (refuse without |
867ffe2 to
c168eb9
Compare
[Medium impact] The changes affect Treehouse-backed spawn and pool reuse across local Firstmate homes. Fix the custom-layout lease bypass before merging; refused edits can still be discarded in that configuration. Reviews (2) · Last reviewed commit: "no-mistakes(document): Document recorded..." · Reviewed by Greptile |
|
Speaking as Kun's firstmate: thank you @jjames27th-eng for coming back to this with a full re-raise and real paired live runs. The unpatched/patched transcripts (shell exit plus one empty Enter, then a retry landing in copy 2 with copy 1's edit intact) are exactly the evidence I hoped for. I read head Waiting on you for one thing: the open Greptile P1 on The Full suite only runs once we add our label, so its red mark doesn't count against you. Please ignore the rebase request in my October note. Conflicts are ours to fix now, and there are none anyway. Contract-class stays new-default (a hard Treehouse v3 floor and leases that outlive a refusal on every pooled spawn), and the VISION read is unchanged. Because this changes the installer's pinned checksums, Kun will make the merge decision himself once your side is done. |
Keep refused copies reserved until explicit return, require in-place Treehouse lease support, and pin CI to v3.1.5. Reproduce detached-commit loss with real Treehouse and cover retained refusals and migrated secondmate leases.
…ixtures, missing CI Git identity, and the flaky remote launch deadline. All nine targeted suites and fast lint passed. Full lint analysis was stopped after stalling. Temporary files removed; five changed files remain for the outer executor
c168eb9 to
038bfe1
Compare
|
Speaking as Kun's firstmate: thank you @jjames27th-eng, this round does exactly what I asked. I read head On Greptile's new "Custom layouts skip lease protection" note, I agree with your reply, and so does Greptile, which withdrew it as out of scope. A templated Waiting on you for one small thing: please mark that withdrawn "Custom layouts skip lease protection" thread as resolved, since it's the only open thread left. No code change or re-run is needed. The Full suite only runs once we add our label, so its red mark doesn't count against you. Contract-class stays new-default, and the VISION read is unchanged. This PR changes the installer's pinned checksums, so once that thread is resolved it goes to Kun, and he'll make the merge decision himself. That step will be waiting on Kun, not on you. |
Intent
Protect a pooled Treehouse worktree after bin/fm-spawn.sh refuses it as not clean.
Keep its durable lease after refusal and interactive shell exit so an empty response to Treehouse's normal-return prompt cannot discard the refused edit, and a retry uses a different copy.
Only a person's explicit release may make the refused copy reusable.
Require the
treehouse leasecapability (Treehouse v3.0.0 or newer) in bootstrap and spawn, raise the installer/CI pin from v2.0.1 to v3.1.5, and add a real-Treehouse lease regression.Keep protecting every locally recorded pool copy under the project lock before either acquisition path runs, as the maintainer asked on 3 Nov: 'a paused task whose recorded copy is still clean at origin/main has no unlanded work, so treehouse get can hand that copy to a new spawn'; add a regression for a clean, unleased copy recorded by a paused task in another home.
Rebase the existing fix onto current main and validate with unmodified Treehouse v3.1.8 through the product on scratch infrastructure.
Show both unpatched and patched refusal, normal shell exit plus one empty Enter, and retry, recording HEAD, status and edit content before and after.
Publish the evidence and explain the scope in the existing #7716 through no-mistakes.
What Changed
bin/fm-spawn.shnow durably leases each pane-driven pool copy withtreehouse leasebefore base refresh (T3 and Herdr already hold a lease fromget --lease). A refusal or abort leaves the lease and edits in place, so a retry gets a different copy, and the refusal prints the explicittreehouse return --forcerelease command. Polytoken abort cleanup and endpoint messages no longer promise that closing an endpoint returns the slot.treehouse status, or lease refuses the spawn, naming that record and copy.bin/fm-bootstrap.shreportsOUTDATEDand spawn refuses whentreehouse leaseis unavailable, and the installer/CI pin moves from v2.0.1 to v3.1.5. Newtests/fm-treehouse-lease-e2e.test.shexercises the real Treehouse executable;tests/fm-spawn-pool-base-freshen.test.shadds dirty-retry and paused-copy-in-another-home regressions; fixtures, adjacent tests, and docs are updated to match.🤖 Generated with Claude Code
Risk Assessment
Testing
I drove the real bin/fm-spawn.sh with real Git and unmodified Treehouse v3.1.8 and pinned v3.1.5, in disposable lab homes on a private tmux socket and in an isolated Herdr lab session. The paired runs show the unpatched base losing the edit and reusing the copy, while the patched code keeps the edit and lease and retries in another copy until an explicit release. Recorded-copy protection, the moved-root refusal, the old-Treehouse refusals, the v3.1.5 installer and all six changed test suites passed; two suites first failed for environment reasons and passed once those were corrected. Live T3 spawning could not be driven and is marked untested, and this is a CLI change with no visual surface, so the evidence is sanitized transcripts rather than screenshots.
Evidence: Evidence index
Source: Evidence index
Evidence: Unpatched paired proof, Treehouse v3.1.8
Source: Unpatched paired proof, Treehouse v3.1.8
Evidence: Patched paired proof, Treehouse v3.1.8
Source: Patched paired proof, Treehouse v3.1.8
Evidence: Unpatched paired proof, pinned v3.1.5
Source: Unpatched paired proof, pinned v3.1.5
Evidence: Patched paired proof, pinned v3.1.5
Source: Patched paired proof, pinned v3.1.5
Evidence: Recorded copy at origin/main, patched
Source: Recorded copy at origin/main, patched
Evidence: Recorded copy at origin/main, patched, pinned v3.1.5
Source: Recorded copy at origin/main, patched, pinned v3.1.5
Evidence: Recorded copy at origin/main, unpatched reuse
Source: Recorded copy at origin/main, unpatched reuse
Evidence: Recorded copy with unlanded commit, patched
Source: Recorded copy with unlanded commit, patched
Evidence: Recorded copy with unlanded commit, unpatched
Source: Recorded copy with unlanded commit, unpatched
Evidence: Recorded copy already leased, patched
Source: Recorded copy already leased, patched
Evidence: Recorded copy already leased, unpatched
Source: Recorded copy already leased, unpatched
Evidence: Herdr acquisition path, unpatched reuse
Source: Herdr acquisition path, unpatched reuse
~/.no-mistakes/evidence/01M6FVFS7HDFBKJH1WFFH0V9WR/driver)Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
🔧 **Rebase** - 2 issues found → auto-fixed ✅
bin/fm-spawn.sh- merge conflict rebasing onto origin/mainbin/fm-wake-lib.sh- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
bin/fm-spawn.sh:4785- The recorded-copy scan compares a fully resolved path with Treehouse's unresolved status path.recorded=$(real_path_or_raw "$recorded")runspwd -P, then jq requires.path == $pathagainsttreehouse status --json, and zero matches raises 'recorded copy missing from pool status', so the scan returns 1. I ran real Treehouse v3.1.8 in scratch with a symlinked HOME and default root, and separately with a symlinkedroot =value. In both, status reported.../linkhome/.treehouse/<pool>/1/projectwhilepwd -Pgave.../realhome/.treehouse/<pool>/1/project. On any home whose pool path crosses a symlink (for example a symlinked /home or a symlinked ~/.treehouse), once one task record names a copy in this project's pool, every later fresh spawn for that project fails with 'could not protect locally recorded Treehouse copies'. That includes records whose copy is already leased, because the lookup runs before the leased check. This is a new regression, because fm_treehouse_pool_slot and the post-acquisition lease check at bin/fm-spawn.sh:6017 both tolerate symlinks. The same exit also fires when a record points at a managed pool that the project's current Treehouse root no longer lists, such as after a root change. The stand-in tests/fixtures.sh:406-417 emits the same path form the test records, so it cannot catch this. Fix: find the row by slot name,basename(dirname(recorded)), and comparereal_path_or_rawof that row's.pathwith the recorded path. Add a regression using a symlinked pool root.tests/fm-treehouse-lease-e2e.test.sh:5- Simplification: theFM_TREEHOUSE_TEST_LEASE=0mode (lines 5, 26, 33, 74) runs the regression without leasing to reproduce old behavior on Treehouse v2. No intent requirement needs it, because the intent requires lease support (v3.0.0 or newer) and asks for a real-Treehouse lease regression. No caller or CI lane in the change sets it, and on v3 the unlanded-copy skip means it no longer shows the lease protecting anything. Recommend removing the mode and always leasing.🔧 Fix applied.
3 issues (1 error, 2 infos) still open:
bin/fm-spawn.sh:4785- The recorded-copy scan compares a fully resolved path with Treehouse's unresolved status path.recorded=$(real_path_or_raw "$recorded")runspwd -P, then jq requires.path == $pathagainsttreehouse status --json, and zero matches raises 'recorded copy missing from pool status', so the scan returns 1. I ran real Treehouse v3.1.8 in scratch with a symlinked HOME and default root, and separately with a symlinkedroot =value. In both, status reported.../linkhome/.treehouse/<pool>/1/projectwhilepwd -Pgave.../realhome/.treehouse/<pool>/1/project. On any home whose pool path crosses a symlink (for example a symlinked /home or a symlinked ~/.treehouse), once one task record names a copy in this project's pool, every later fresh spawn for that project fails with 'could not protect locally recorded Treehouse copies'. That includes records whose copy is already leased, because the lookup runs before the leased check. This is a new regression, because fm_treehouse_pool_slot and the post-acquisition lease check at bin/fm-spawn.sh:6017 both tolerate symlinks. The same exit also fires when a record points at a managed pool that the project's current Treehouse root no longer lists, such as after a root change. The stand-in tests/fixtures.sh:406-417 emits the same path form the test records, so it cannot catch this. Fix: find the row by slot name,basename(dirname(recorded)), and comparereal_path_or_rawof that row's.pathwith the recorded path. Add a regression using a symlinked pool root.bin/fm-spawn.sh:4802- The recorded-copy refusal does not name the record or copy that blocked it. This path was changed by this run's round 1 fix. Sequence: a paused task's record names <old-root>/<pool>/1/<repo>, and the project's Treehouse root later changes. fm_treehouse_pool_slot still passes because the old pool state and Git common dir still match. Status lists slot 1 at a different path, so bin/fm-spawn.sh:4792 returns 1 silently. If no slot 1 exists, the only extra text is jq's 'recorded copy missing from pool status'. Every later spawn for that project then fails with only 'could not protect locally recorded Treehouse copies', and the operator must search every local home's records for the culprit. The refusal itself is correct and should stay. Fix: print the meta path and recorded copy on each failing return in spawn_protect_recorded_pool_copies, at bin/fm-spawn.sh:4775-4795.bin/fm-home-seed.sh:396- A third acquisition path has no recorded-copy protection. acquire_treehouse_home runstreehouse get --leasewithout the project lock or the scan. A pre-upgrade paused task on the firstmate repo with a clean, unleased copy at origin/main can be handed to a newly seeded secondmate home if seeding happens before any crewmate spawn for that project runs the scan. This is noted only: the intent limits the requirement to 'either acquisition path' in spawn, and the exposure ends once a scan has leased those records. This file is not part of the change, so it does not block merge.🔧 Fix applied.
4 issues (1 error, 3 infos) still open:
bin/fm-spawn.sh:4785- The recorded-copy scan compares a fully resolved path with Treehouse's unresolved status path.recorded=$(real_path_or_raw "$recorded")runspwd -P, then jq requires.path == $pathagainsttreehouse status --json, and zero matches raises 'recorded copy missing from pool status', so the scan returns 1. I ran real Treehouse v3.1.8 in scratch with a symlinked HOME and default root, and separately with a symlinkedroot =value. In both, status reported.../linkhome/.treehouse/<pool>/1/projectwhilepwd -Pgave.../realhome/.treehouse/<pool>/1/project. On any home whose pool path crosses a symlink (for example a symlinked /home or a symlinked ~/.treehouse), once one task record names a copy in this project's pool, every later fresh spawn for that project fails with 'could not protect locally recorded Treehouse copies'. That includes records whose copy is already leased, because the lookup runs before the leased check. This is a new regression, because fm_treehouse_pool_slot and the post-acquisition lease check at bin/fm-spawn.sh:6017 both tolerate symlinks. The same exit also fires when a record points at a managed pool that the project's current Treehouse root no longer lists, such as after a root change. The stand-in tests/fixtures.sh:406-417 emits the same path form the test records, so it cannot catch this. Fix: find the row by slot name,basename(dirname(recorded)), and comparereal_path_or_rawof that row's.pathwith the recorded path. Add a regression using a symlinked pool root.bin/fm-spawn.sh:4802- The recorded-copy refusal does not name the record or copy that blocked it. This path was changed by this run's round 1 fix. Sequence: a paused task's record names <old-root>/<pool>/1/<repo>, and the project's Treehouse root later changes. fm_treehouse_pool_slot still passes because the old pool state and Git common dir still match. Status lists slot 1 at a different path, so bin/fm-spawn.sh:4792 returns 1 silently. If no slot 1 exists, the only extra text is jq's 'recorded copy missing from pool status'. Every later spawn for that project then fails with only 'could not protect locally recorded Treehouse copies', and the operator must search every local home's records for the culprit. The refusal itself is correct and should stay. Fix: print the meta path and recorded copy on each failing return in spawn_protect_recorded_pool_copies, at bin/fm-spawn.sh:4775-4795.bin/fm-home-seed.sh:396- A third acquisition path has no recorded-copy protection. acquire_treehouse_home runstreehouse get --leasewithout the project lock or the scan. A pre-upgrade paused task on the firstmate repo with a clean, unleased copy at origin/main can be handed to a newly seeded secondmate home if seeding happens before any crewmate spawn for that project runs the scan. This is noted only: the intent limits the requirement to 'either acquisition path' in spawn, and the exposure ends once a scan has leased those records. This file is not part of the change, so it does not block merge.bin/fm-spawn.sh:4479- Operator text still says closing an endpoint returns the slot, which is false once the copy holds a durable lease. spawn_endpoint_hint prints 'window X is closed on exit, returning any pool slot it held'. Sequence: a fresh polytoken spawn on tmux confirms its lease at bin/fm-spawn.sh:6030-6035, then fm_treehouse_slot_owner_claim fails at bin/fm-spawn.sh:6044 because the slot directory is not writable. The refusal says the slot is being returned, and the abort footer at bin/fm-spawn.sh:1719 then says the lease 'was left in place; a refusal never releases'. An operator gets two opposite statements about whether the copy is reusable. Other sites with the same wording: bin/fm-spawn.sh:6031 (lease failure, followed by the 'unconfirmed' warning, where nothing proves a return) and bin/fm-spawn.sh:1892 ('close it by hand so its slot returns to the pool', also false after a confirmed lease). Fix: reword these messages to say the window closes and the slot returns only if it holds no durable lease, and otherwise needs the printed explicit release. No behavior change.🔧 Fix applied.
1 info still open:
bin/fm-home-seed.sh:396- A third acquisition path has no recorded-copy protection. acquire_treehouse_home runstreehouse get --leasewithout the project lock or the scan. A pre-upgrade paused task on the firstmate repo with a clean, unleased copy at origin/main can be handed to a newly seeded secondmate home if seeding happens before any crewmate spawn for that project runs the scan. This is noted only: the intent limits the requirement to 'either acquisition path' in spawn, and the exposure ends once a scan has leased those records. This file is not part of the change, so it does not block merge.driver/paired.sh unpatched (f641b44b) and patched (5bcf2dc5) on unmodified Treehouse v3.1.8 and pinned v3.1.5: real bin/fm-spawn.sh, private tmux socket, marked lab home, bounded outside writer, exit plus one empty Enter, retryAdversarial steps in the patched paired run: treehouse prune, plain treehouse return with stdin at EOF, a second task spawn, then treehouse return --force and a next spawn that reuses the released copydriver/recorded.sh for default-tip, unlanded and leased modes, unpatched and patched, on v3.1.8, plus patched default-tip on v3.1.5driver/herdr.sh through bin/fm-herdr-lab.sh in a throwaway fm-lab-* session on Herdr 0.9.5: recorded copy (patched and unpatched), no double lease, slot-owner claim, dirty refusal, retrydriver/rootchange.sh: a moved Treehouse root makes protection fail, and the refusal names the record and copydriver/old-th.sh: spawn on real Treehouse v2.0.1 refuses before acquiring anythingdriver/bootstrap.sh: FM_BOOTSTRAP_DETECT_ONLY=1 FM_BOOTSTRAP_NETWORK=skip bin/fm-bootstrap.sh from extracted copies of the target and base commits, against v2.0.1, v3.1.5 and v3.1.8bin/fm-install-treehouse.sh installing v3.1.5 from the official release with checksum verification, and the base commit's installer fetching v2.0.1 as the old fixturetests/fm-treehouse-lease-e2e.test.sh on real Treehouse v3.1.8 and v3.1.5tests/fm-spawn-pool-base-freshen.test.sh, tests/fm-bootstrap.test.sh, tests/fm-polytoken-harness.test.shtests/fm-secondmate-harness.test.sh with TMPDIR outside the repository, and tests/fm-backend-t3code.test.sh with Python 3.13 and a scratch tasks-axi 0.2.6driver/t3.sh live attempts against a disposable loopback T3 server: stable 0.1.6, nightly 0.1.7-nightly.20261103.4106, and documented 0.0.46-nightly.20261010.2935Public evidence search for /Users, /private/var, +07:00 and default interactive shell: zero matches for all four✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.