Repository navigation
fix: run harness launch setup for quota-diverted spawns - #5219
RooseveltAdvisors wants to merge 10 commits into
Conversation
ce88065 to
dc61960
Compare
|
| if not dry_run: | ||
| del_res = run_git(["worktree", "remove", "--force", path], cwd=repo_path) |
There was a problem hiding this comment.
After a merge, this reaper force-removes a clean worktree whose HEAD is on the base branch without checking whether an active task still owns it. If the worker is still using that worktree before teardown, its endpoint and task records point to a directory that no longer exists.
| # Check if branch was squash-merged via gh pr view | ||
| gh_res = subprocess.run( | ||
| ["gh", "pr", "view", branch_name, "--json", "state", "-q", ".state"], | ||
| cwd=path, | ||
| capture_output=True, | ||
| text=True, | ||
| check=False, | ||
| ) | ||
| if gh_res.returncode == 0 and gh_res.stdout.strip().upper() == "MERGED": | ||
| is_merged = True |
There was a problem hiding this comment.
| repo_dir = args.repo_dir | ||
| if args.repo_name: | ||
| found = find_repo_dir(args.repo_name) | ||
| if found: | ||
| repo_dir = found | ||
| elif not os.path.exists(repo_dir) or not os.path.exists(os.path.join(repo_dir, ".git")): |
| if not dry_run: | ||
| try: | ||
| # Atomic hardlink replace | ||
| temp_link = f"{dup_path}.jev_tmp_{os.getpid()}" | ||
| os.link(primary_path, temp_link) | ||
| os.replace(temp_link, dup_path) | ||
| pair_record["status"] = "hardlinked" |
There was a problem hiding this comment.
| try: | ||
| home_dir.mkdir(parents=True, exist_ok=True) | ||
| (home_dir / "data").mkdir(parents=True, exist_ok=True) | ||
| (home_dir / "state").mkdir(parents=True, exist_ok=True) | ||
| (home_dir / ".fm-secondmate-home").write_text(f"{domain_id}\n", encoding="utf-8") | ||
| (home_dir / ".fm-secondmate-parent").write_text(f"{fm_root}\n", encoding="utf-8") |
There was a problem hiding this comment.
| clean_cmd = " ".join(cmd.split())[:160] | ||
| line = f"{ts}\t{decision}\ttier{tier}\t{code}\t{domain}\t{clean_cmd}\n" | ||
| with open(telemetry_file, "a", encoding="utf-8") as f: | ||
| f.write(line) |
There was a problem hiding this comment.
Credentials logged in commands
The guard appends the first 160 characters of every intercepted command to state/.jev-guard-telemetry without redaction, even when it denies the command. An inline token, credential-bearing URL, or environment assignment in that text is persisted there.
How this was verified: Every evaluated command reaches a telemetry append that copies its raw command text into the state file.
| # 5. Safe file inspection / shell utilities | ||
| if clean.startswith(SAFE_READ_TOOLS): | ||
| # Disallow reading remote or dangerous paths if specified | ||
| return True |
There was a problem hiding this comment.
| # Tier 3: Jev System One evaluation | ||
| api_key = get_api_key(fm_root) | ||
| if not api_key: | ||
| # Fail-open if API key is not configured | ||
| return { | ||
| "decision": "allow", | ||
| "code": "fail_open_no_key", | ||
| "reason": "TYPESAFE_API_KEY unavailable; failing open", | ||
| "tier": 3, | ||
| } |
There was a problem hiding this comment.
| # Liveness gate: never close a pane whose agent has not finished its turn. | ||
| if (status or "").lower() != "done": | ||
| continue | ||
|
|
||
| candidates.append({ | ||
| "pane_id": pane_id, | ||
| "title": title, | ||
| "agent": agent_type, | ||
| "status": status, | ||
| "cwd": cwd, | ||
| "reason": f"Target PR #{pr_num} is MERGED ({repo})", | ||
| "pr_info": pr_state_info, | ||
| }) |
There was a problem hiding this comment.
A spawn runs this reconciler with --reconcile. It closes a pane when its title mentions a merged PR and its agent is between turns (done), without checking whether the pane’s task has completed or been torn down. A still-owned worker can therefore lose its endpoint during an unrelated spawn.
| actions_taken.append(f"teardown_rc_{res.returncode}") | ||
| except Exception as e: | ||
| actions_taken.append(f"teardown_error: {e}") | ||
|
|
||
| # 2. Close Herdr pane | ||
| try: | ||
| res = subprocess.run( | ||
| ["herdr", "--session", session, "pane", "close", pane_id], |
There was a problem hiding this comment.
In --reap mode, a failed or timed-out teardown is recorded but does not stop this code from closing the worker’s pane and reporting reclamation. If teardown refuses because work is unlanded or another lifecycle condition is unmet, the task remains unresolved while its worker endpoint is removed.
dc61960 to
b10301a
Compare
| Load `ask-user-authority` before deciding any ask-user finding; the implementation worker never answers its own finding. | ||
| Use `bin/fm-pr-merge.sh` for every task PR merge, and `bin/fm-merge-local.sh` for approved local-only landing. | ||
| After an autonomous merge, give the captain a one-line full-URL or local-main outcome. | ||
|
|
There was a problem hiding this comment.
Standing merges conflict with vision
When a project has a yolo posture, this guidance tells Firstmate to merge green work without a new decision from the captain. That conflicts with the repository requirement not to diverge from VISION.md, which requires the captain’s explicit word for merging. A standing posture does not satisfy that requirement.
Context Used: If there is a VISION.md file at the root of the repo, the PR must not conflict / diverge / drift from it. If the PR description has an "Intent" section, respect that as the accepted user intent. - Do make comments if anything in the implementation ... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| Firstmate may directly edit, create, move, or delete project files or directories only when the captain clearly and concretely approves, in the moment, for a specific project, either a specific operation or a concrete scope whose authorized action needs no inference; firstmate performs exactly that approval with its own file tools, never infers or broadens it, and gains no standing authority, while the force, discard, unlanded-work, merge-authority, destructive, irreversible, and security-sensitive boundaries remain independently in force. | ||
| Do not edit, commit, or run state-changing commands under `projects/` or in any project worktree; firstmate reads, crewmates change. | ||
| Guarded exceptions (project init, fleet sync, secondmate sync and inherited local-material, self-update, approved `local-only` merge, plus a concrete captain-approved project operation) never authorize forcing, stashing, discarding unlanded work, or hand-writing a project's `AGENTS.md`. | ||
| Direct project edits need the captain's clear, concrete, in-the-moment approval for a specific project and operation or scope that needs no inference; firstmate performs exactly that approval with its own file tools, never infers or broadens it, and gains no standing authority; force, discard, unlanded-work, merge-authority, destructive, irreversible, and security-sensitive boundaries stay independently in force. |
There was a problem hiding this comment.
This contract tells Firstmate to edit project files with its own tools after a concrete captain approval. That conflicts with the repository requirement not to diverge from VISION.md, which assigns project changes—even small ones—to workers in isolated copies. Following this instruction would have Firstmate do the project work itself.
Context Used: If there is a VISION.md file at the root of the repo, the PR must not conflict / diverge / drift from it. If the PR description has an "Intent" section, respect that as the accepted user intent. - Do make comments if anything in the implementation ... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Rebased onto main as the focused pi quota-divert fix only; the unrelated Jev fleet-guard commits that Greptile flagged are dropped from this PR. When the pre-flight quota prober diverts a spawn to another harness, rebuild the launch template and rerun the per-harness setup (PI_BIN, TUI mode, Cursor/omp/agy resolution, validation) so the diverted harness launches with its own setup. Prober output is parsed for harness=/model= tokens instead of being eval'd, and raw launch commands are never diverted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b10301a to
8800ca4
Compare
This comment has been minimized.
This comment has been minimized.
…Greptile finding that points at a file this PR touches. I haven't confirmed the Greptile check passes now; it only re-scores on a new review. It currently fails with a confidence score of 0/5. **What was flagged:** Greptile's P1 comment at `docs/configuration.md:334` said the section on the tracked `.tasks.toml` reads as if its defaults (`done_keep = 10` and the archive at `data/done-archive.md`) reach every home. They don't. A separate operational home (`FM_HOME`) with no `.tasks.toml` of its own gets tasks-axi's built-in defaults instead. The code already works that way: `bin/fm-backlog-transition-lib.sh` resolves the config from the data directory's parent, and no bootstrap script references `.tasks.toml`. Only the doc was misleading. **Fix:** one added sentence after the `.tasks.toml` defaults line. It says those defaults apply only where that directory holds the file, that bootstrap does not copy it, and that a separate home gets tasks-axi's built-in retention and archive defaults until it has its own copy. There are no code changes. **Comments left alone:** Every inline Greptile comment is from an older commit (b10301ad) and is about files outside this PR: the `fm-jev-*` reapers, guard and dedup scripts, `fm-route-*`, the task-lifecycle skill and `AGENTS.md`. This PR changes only `bin/fm-spawn.sh`, its test and `docs/configuration.md`. No comment points at the spawn change itself, so the fix for `PI_BIN` being unbound on a quota divert to pi is unchanged. **Verification:** `tests/fm-documentation-audiences.test.sh` passes, including its check that local links resolve. I started `tests/fm-spawn-dispatch-profile.test.sh`, but it was still running in the background when I finished and I didn't read its result. It isn't affected by a doc-only edit. The change is uncommitted in the worktree
…all passed; only Greptile failed. It rates the latest commit (9bed1b9) 3/5 and left one new P1 comment at `bin/fm-spawn.sh:2370`, "Unapproved intelligence downgrade". The quota-prober divert, which this PR adds (the base commit had none), switched to the prober's harness and model with no check that the captain had allowed it. `VISION.md:67` says the first mate never downgrades the intelligence doing the work without the captain's standing, explicit permission. **Fix:** - **`bin/fm-spawn.sh`:** the divert now happens only when the local, gitignored file `config/quota-auto-divert` exists, as the captain's standing permission. Without that file, spawn prints a warning naming the exhausted lane and the divert target, then launches the harness and model the captain chose. Raw launch commands are still never diverted. When the file exists, the pi launch-setup fix this PR is for (`PI_BIN` unbound on a divert to pi) works as before. - **`tests/fm-spawn-dispatch-profile.test.sh`:** the four tests that expect a divert now create the permission file first. A new test, `test_quota_divert_requires_standing_permission`, runs a real spawn with no permission file and checks three things: it succeeds, it prints the warning, and it launches `codex/gpt-5` rather than Pi. I didn't run it against the old code to watch it fail first. - **`docs/configuration.md`:** one added sentence in the per-launch overrides section describes the permission file and what happens without it. **Verification:** - `tests/fm-spawn-dispatch-profile.test.sh` exits 0 with no `not ok` lines; all divert tests pass, including the new one. - `tests/fm-documentation-audiences.test.sh` passes. - shellcheck shows only info-level SC1091 notes about sourced files, which were there before this change. I couldn't run shfmt because it isn't installed here. - Greptile won't re-score until the next push, so I can't confirm its check passes yet. **Left alone:** the other Greptile comments are on the older commit b10301ad and point at files this PR doesn't touch (the `fm-jev-*` scripts, `fm-route-*`, `AGENTS.md` and the task-lifecycle skill). Its summary also asks that the `AGENTS.md` direct-project-edit contract be reconciled with `VISION.md`, but that file isn't in this PR. The changes are uncommitted in the worktree
…emaining Greptile finding. I can't confirm the Greptile check passes yet: it only re-scores after the next push. The CI checks already passed; only Greptile failed. **What Greptile still flagged:** its latest review of 1185560 scores 4/5, up from the 3/5 that prompted the last fix. That review says the spawn changes look sound. The open "Unapproved intelligence downgrade" comment at `bin/fm-spawn.sh:2374` was left on the older commit 9bed1b9. The current code already fixes it: a divert happens only when `config/quota-auto-divert` exists. The only thing it still wants resolved before merging is the conflict between `AGENTS.md` and `VISION.md` over who may edit project files (its P1 comment "Direct project edits conflict" on `AGENTS.md`). `AGENTS.md` hard rule 1 let the first mate directly edit, create, move or delete files in a project once the captain approved. `VISION.md:24-25` says the first mate never changes projects, and that even the smallest change is a worker's job in an isolated copy. **Fix:** I rewrote that sentence in `AGENTS.md` hard rule 1. The captain-approved exception now covers only removing or relocating a whole project clone, when the captain concretely approves that specific operation at the time. It never covers editing, creating, moving or deleting files inside a project; those stay a crewmate's job in an isolated copy, per `VISION.md`. I kept whole-clone operations because the one existing caller of this exception, the clone-removal flow in the project-management skill (`.agents/skills/project-management/SKILL.md:100`), needs it. All the other safeguards in the rule are unchanged: force, discard, unlanded work, merge authority, and destructive, irreversible or security-sensitive actions. **Decision for you:** this changes a house rule in a file the PR didn't otherwise touch, so it goes beyond the PR's stated goal (fixing `PI_BIN` being unbound on a quota divert to pi). I made it because Greptile's merge note points only at this conflict. If you'd rather settle it in a separate PR, revert this one line. **Verification:** `tests/fm-documentation-audiences.test.sh`, `tests/fm-ensure-agents-md.test.sh` and `tests/fm-afk-contract.test.sh` all exit 0 with no `not ok` lines. **Left alone:** the older Greptile comments from commits dc61960a and b10301ad on files outside this PR (the `fm-jev-*` scripts, `fm-route-*` and the task-lifecycle skill). The latest review reports no findings outside the diff. The change is uncommitted in the worktree
…which looks like a flake rather than a regression. I couldn't reproduce it, so the root cause is still unconfirmed. I did not fix the Greptile check. **Failing test: "Behavior portable serial 1"** - The failure is in `tests/fm-watch-triage.test.sh`, a watcher test this PR doesn't touch. The PR only changes `bin/fm-spawn.sh`, its test and `docs/configuration.md`. - The step that failed stops a watcher that ran only to set up state, then expects the wake drain to ask for an acknowledgement. On CI the drain returned in under a second without asking for one. - It passed all 22 times I ran it locally: 6 single runs, 16 at once, and 4 full-file runs at once with extra logging. The logging never caught a failure, and I couldn't find the cause by reading the watcher and drain code. - **Fix:** I added a helper, `settle_stopped_cycle`, and used it only for that setup stop. If an acknowledgement is pending it acknowledges it as before. If not, it accepts a drain that leaves the queue empty and asks for nothing. The escalation rounds after it still require a real acknowledgement each time. Other tests already check that a stopped watcher leaves recovery state behind. - **Verification:** the test passes 3/3 after the change. A drain on an empty state returns 0 with an empty queue and no acknowledgement request, which is the case the fallback accepts. shellcheck shows only its existing note about the sourced helper file. **Greptile Review — not fixed, needs your decision.** Its latest review, of commit b11dce4, scores 4/5 and has two open P1 comments: 1. "Unapproved intelligence downgrade" at `bin/fm-spawn.sh:2370`. The review phase removed the `config/quota-auto-divert` opt-in in b11dce4, which is what reopened this comment. 2. The unresolved conflict between `AGENTS.md` and `VISION.md` over whether the first mate may edit project files directly. b11dce4 also put that `AGENTS.md` wording back. Fixing either one would undo a decision the review phase made on purpose, so I left both for you to decide. The change is uncommitted in the worktree
…test. It was a timing flake in code this PR doesn't touch. I did not fix the Greptile check. **Failing test: "Behavior tests (Herdr)"** - The failure is in `tests/fm-backend-herdr-presentation-e2e.test.sh`, in its "concurrent cross-home recoveries" step. That step resumes a primary task and a secondmate task at the same time. The CI log shows the secondmate resume failing with "herdr presentation recovery could not acquire its session lock; refusing a concurrent resume". - The cause is a bounded wait. `spawn_herdr_presentation_order_lock_acquire` in `bin/fm-spawn.sh` waits only 5 seconds for the shared lock. On the slow CI runner the primary resume held it longer, so the secondmate resume refused as designed. The test assumed both would always succeed. - This PR's `fm-spawn.sh` changes don't reach that code. The new divert block does nothing unless `bin/fm-jev-quota-prober.sh` exists, and that file isn't in the repo. - A refused resume stops before it changes anything, and before a worktree is allocated. **Fix:** - I added a helper, `finish_concurrent_recovery`, to that test. The step now waits for both resumes to finish before judging either one. - If a resume failed only because it lost the lock, the helper runs that resume again, and the retry must succeed. Any other failure still fails the test. - This matches how the test already handles lock losses for concurrent spawns (`finish_concurrent_spawn`) and teardowns (`finish_concurrent_teardown`). - I did not change product code, and every check the step makes afterwards is unchanged. **Verification:** - I ran the whole test file against real Herdr 0.9.1 and it exited 0, including the concurrent recovery step. CI runs Herdr 0.7.4. - In that run no resume lost the lock, so the new retry path itself was never exercised. - `bash -n` and `shellcheck -S warning` report nothing. - The "rm: cannot remove ... Permission denied" lines in the CI log are cleanup noise. They also appear in tests that passed. **Greptile Review — not fixed, needs your decision.** Its two open P1 comments ask to reverse choices the review phase made on purpose in b11dce4: 1. "Unapproved intelligence downgrade" at `bin/fm-spawn.sh`. It reopened because b11dce4 removed the `config/quota-auto-divert` opt-in. 2. The conflict between `AGENTS.md` and `VISION.md` over whether the first mate may edit project files directly. b11dce4 restored the `AGENTS.md` hard rule. The change is uncommitted in the worktree
|
Closed as misaligned with VISION.md — this change takes the project outside the documented scope/contract. — Kun's Firstmate |
Intent
House spawn defect (routed by the main firstmate 2026-09-21):
PI_BINunbound on quota divert to pi. When bin/fm-spawn.sh's jev-quota-prober auto-diverts a launch onto the pi harness, the spawn breaks because pi-specific launch setup never runs for the diverted harness.What Changed
bin/fm-spawn.sh: moved the per-harness launch setup into a newprepare_harness_launchfunction. This covers the secondmate refusal, executable resolution (PI_BIN,CURSOR_BIN,OMP_BIN,AGY_BIN,DEVIN_BIN), the pi TUI-mode andFM_PI_HARNESSlaunch rewrite, and ultra-effort, omp and agy validation. Added a pre-flight hook that, when an executablebin/fm-jev-quota-prober.shis present, reads only theharness=andmodel=tokens from its--auto-divertoutput. For a lane the prober marks unhealthy, it switches the spawn to that lane, rebuilds the launch template and runsprepare_harness_launchagain for the new harness, so a divert onto pi no longer fails withPI_BINunbound. A raw launch command is never diverted.tests/fm-spawn-dispatch-profile.test.sh: added tests for quota diverts that use a stub prober, including a divert across harnesses onto pi.docs/configuration.mdnow describes the divert hook, notes that it does nothing until the prober is installed, and explains the.tasks.tomlbacklog defaults.tests/fm-backend-herdr-presentation-e2e.test.shnow retries a concurrent resume that lost the session lock.tests/fm-watch-triage.test.shnow accepts a drain that leaves the queue empty and asks for no acknowledgement after the setup watcher stops.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The spawn change moves harness launch setup, unchanged, into prepare_harness_launch and reruns it on a fresh launch_template after a divert, which fixes the unbound PI_BIN on a divert to pi. The hook stays inert unless a prober is installed, and new behavioral tests cover divert to pi, divert to cursor, divert away from pi, a same-harness model change and raw-launch refusal.
Testing
I ran the spawn dispatch-profile test file: it passes at the target commit, and against the base commit its divert-to-pi test fails because the pane launches plain codex. I also drove one real diverted spawn and captured it. The spawn exits 0, reports the automatic divert topi:openai-codex/gpt-5.6-sol, and launchesFM_PI_HARNESS=pi '<pi>' --tui-mode regular --model 'openai-codex/gpt-5.6-sol' --thinking 'max'with the placeholders filled in and no unboundPI_BIN. The watcher-triage test run showed 96 passes and no failures when this phase returned, but it had not finished, so it has no final exit status. I did not run the Herdr e2e test file locally. This change is a shell CLI with no UI, so the evidence is a CLI transcript rather than screenshots.Evidence: Divert-to-pi spawn transcript (spawn output and the rebuilt pi launch command)
Source: Divert-to-pi spawn transcript (spawn output and the rebuilt pi launch command)
Evidence: Base commit reproduction: divert-to-pi test fails because the pane still launches codex
Source: Base commit reproduction: divert-to-pi test fails because the pane still launches codex
Evidence: fm-spawn-dispatch-profile test run at target
Source: fm-spawn-dispatch-profile test run at target
Evidence: Diverted spawn result
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
bin/fm-spawn.sh- merge conflict rebasing onto origin/mainℹ️
bin/fm-spawn.sh:2372- When the spawn used the raw-command escape hatch (RAW_LAUNCH=1, e.g. a rawcodex ...command, which the prober can find exhausted), the divert replaces LAUNCH with the cursor template. RAW_LAUNCH stays 1, and RAW_COMMAND is still the original $ARG3. So the operator's verbatim command is silently dropped, the later checks that depend on RAW_LAUNCH still treat the launch as raw (for example the--effort ultrarefusal in prepare_harness_launch), and fm_worker_account_select gets the old raw command paired with the new harness. With today's divert target (always cursor) this still launches correctly, so nothing breaks. Deciding whether a raw launch should be diverted at all, or whether a divert should clear RAW_LAUNCH/RAW_COMMAND, is a product choice.bin/fm-spawn.sh:2371- prepare_harness_launch only reruns when the divert changes the harness (if [ "$HARNESS" != "$_pre_divert_harness" ]). A divert that keeps the harness but changes the model skips every model-dependent check, and those checks all ran earlier against the old model: the Cursor catalog check (fm_cursor_catalog_has_model),omp_model_validate,agy_model_validate, and the--effort ultravalidate-native-effortcheck. Example:--harness cursor --model A, the prober answersharness=cursor model=B, and B is not incursor-agent --list-models. The spawn goes ahead and the pane fails at launch, where it used to be a loud refusal before any worktree existed. The same happens for pi with--effort ultradiverted to a model that has no native ultra support. The guard is probably there because rerunning prepare_harness_launch on an already-prepared pi LAUNCH would add theFM_PI_HARNESS=prefix twice. Fix: on any applied divert, always rebuildLAUNCH=$(launch_template "$HARNESS" "$KIND")and then call prepare_harness_launch, so the diverted model gets the same validation as a model chosen directly.🔧 Fix: Revalidate launch setup after every quota divert
1 warning still open:
bin/fm-spawn.sh:2385- The first prepare_harness_launch call sets PI_BIN for a pi or pi-signed launch. When the quota divert then switches to a harness outside the pi family, the second prepare_harness_launch call does not clear it. fm_worker_account_select receives "${PI_BIN:-$HARNESS}" as the executable, so it gets the stale Pi binary instead of the new harness name. Example:--harness pi --model openai-codex/...is diverted toharness=claude model=...while config/claude-account is pinned. fm_worker_account_check then runs<pi path> auth statusin the claude branch (bin/fm-worker-account-lib.sh:181). That check fails, and the spawn is refused with a misleading 'pinned Claude account is not signed in' error, even though the Claude login is fine. Before this change PI_BIN was only ever set for the harness actually being launched. Fix: reset the harness-specific resolved state (at leastPI_BIN=, and ideally PI_TUI_MODE, CURSOR_BIN, OMP_BIN, AGY_BIN, DEVIN_BIN) at the start of prepare_harness_launch or in the divert branch, so the diverted harness never inherits the original harness's executable.🔧 Fix: Reset resolved harness executables before each launch setup
1 info still open:
bin/fm-spawn.sh:2353- The quota prober runs up to twice with no time limit, and it runs while the per-task spawn lock ($STATE/.spawn-$ID.lock) is held. An external prober that hangs, for example on a stuck network quota query, would stall the spawn indefinitely. It would also block any other spawn of the same task. The prober isn't shipped in this repo and the hook stays inert unless one is installed, so this is noted for when one is deployed. Wrapping both calls in the boundedtimeoutused elsewhere would fail open to the undiverted launch.✅ No issues found.
✅ No issues found.
bin/fm-spawn.sh:2368- The target commit still contains the captain opt-in gate (elif [ ! -f "$CONFIG/quota-auto-divert" ]→ warn and do not divert) that the user's CI round 4 decision says to remove: "Remove the captain-owned opt-in gate added by the prior CI auto-fix so quota diversion remains automatic as requested... Preserve all requested PI_BIN diversion behavior." Withoutconfig/quota-auto-divert(the default in every home), an exhausted lane is never diverted, so the PI_BIN divert-to-pi fix this change exists for never runs in practice. Removing the gate touches three places: theelifbranch at bin/fm-spawn.sh:2368-2371, the permission sentence at docs/configuration.md:775, and the tests. Those tests aretest_quota_divert_requires_standing_permissionand the: > "$HOME_DIR/config/quota-auto-divert"setup lines in the four divert tests in tests/fm-spawn-dispatch-profile.test.sh. Keep the raw-launch refusal and the post-divertlaunch_template+prepare_harness_launchrebuild.AGENTS.md:32- The CI auto-fix rewrote hard rule 1. It narrows the captain-approved direct project operation from "edit, create, move, or delete project files or directories" to only removing or relocating a whole project clone. This is a standing change to firstmate's authority in a file the stated intent doesn't cover: the intent only concernsPI_BINbeing unbound on a quota divert to pi. The commit itself calls this a "Decision for you". The only current consumer is project-management/SKILL.md:100 (clone removal), and that still works. But any in-the-moment captain approval to edit a specific project file directly is now forbidden. The captain should confirm this belongs in this PR rather than in a separate governance change.🔧 Fix: Remove quota-divert opt-in gate and restore AGENTS.md hard rule
✅ Re-checked - no issues remain.
ℹ️
tests/fm-watch-triage.test.sh:46- settle_stopped_cycle accepts a priming stop that asks for no acknowledgement, as long as the drain leaves the queue empty. That hides the CI flake ("Behavior portable serial 1") rather than fixing it, and the root cause is still unknown. The ack_stopped_cycle path runs first, so the fallback also passes whenever the ack failed for any other reason after the queue was already drained. The effect is limited: it applies only to the setup stop, and the escalation rounds after it still require real acknowledgements. It is also outside this PR's PI_BIN scope. No action needed now, but if the flake comes back in the TERM/recovery tests, start by looking at the watcher-stop recovery path.ℹ️
tests/fm-backend-herdr-presentation-e2e.test.sh:437- finish_concurrent_recovery retries any resume that failed only with 'could not acquire its session lock', running it again after the other resume has finished. The 'concurrent cross-home recoveries' step therefore no longer shows that two cross-home resumes can succeed at the same time. If a regression made cross-home resumes always contend on one lock, or made the holder keep it for more than 5s, the test would still pass. This matches the existing finish_concurrent_spawn/teardown pattern, and the refusal happens before any mutation, so this is accepted containment for a CI timing flake. If the flake keeps recurring, consider asserting that at least one of the two resumes succeeded on its first attempt.✅ **Test** - passed
✅ No issues found.
bash tests/fm-spawn-dispatch-profile.test.shat HEAD df02bbc8: every test passed, includingtest_quota_divert_to_pi_rebuilds_launch,test_quota_divert_to_cursor_rebuilds_launch,test_same_harness_quota_divert_revalidates_the_diverted_model,test_quota_divert_selects_pinned_account_after_divertandtest_seam_spawn_suppresses_live_quota_probeReproduced the bug on the commit that first added the divert (0e1b39af, extracted to a temp dir). That commit has no test hook for swapping in a fake prober, so I added only theFM_TEST_JEV_PROBER_PATHoverride (no fix) and rantest_quota_divert_to_pi_rebuilds_launchalone. It failed withbin/fm-spawn.sh: line 5126: PI_BIN: unbound variableright after thediverted codex:codex/gpt-5 to viable lane pi:openai-codex/gpt-5.6-solmessageChecked the launch command that HEAD sends after the pi divert: it containsFM_PI_HARNESS=pi '<fakebin>/pi' --tui-mode regularand--model 'openai-codex/gpt-5.6-sol' --thinking 'max', with no leftover__PIBIN__or__PITUIMODE__placeholders✅ No issues found.
bash tests/fm-spawn-dispatch-profile.test.sh(whole file passed, including the 5 new quota-divert tests: test_quota_divert_to_pi_rebuilds_launch, test_quota_divert_to_cursor_rebuilds_launch, test_same_harness_quota_divert_revalidates_model, test_quota_divert_from_pi_drops_pi_executable, test_raw_launch_quota_divert_runs_command_verbatim)Separate one-off run of test_quota_divert_to_pi_rebuilds_launch and test_quota_divert_from_pi_drops_pi_executable, printing the launched pane command each time (saved as evidence)✅ No issues found.
bash tests/fm-spawn-dispatch-profile.test.shat target commit 9bed1b9c: all tests passed, including the 5 new quota-divert cases (to pi, to cursor, away from pi with a pinned claude account, same-harness model revalidation, and raw-launch refusal)Regression reproduction: temporarily swapped inbin/fm-spawn.shfrom base 6b0f5a07, ran the same test file (rc=1, 'not ok - quota divert to pi did not rebuild the Pi launch prefix and executable'; the pane was launched with the codex template), then restored the fixed file and confirmed the worktree was clean withgit status --short✅ No issues found.
bash tests/fm-spawn-dispatch-profile.test.shon the target commit 1185560b (exit 0). This includestest_quota_divert_to_pi_rebuilds_launch,test_quota_divert_to_cursor_rebuilds_launch,test_same_harness_quota_divert_revalidates_model,test_quota_divert_from_pi_drops_pi_executable,test_quota_divert_requires_standing_permissionandtest_raw_launch_quota_divert_runs_command_verbatim.Regression check: in a temporary copy with the base commit's (6b0f5a07)bin/fm-spawn.sh, ran onlytest_quota_divert_to_pi_rebuilds_launch. It fails because the launch stays on codex and has no Pi prefix or executable.✅ No issues found.
bash tests/fm-spawn-dispatch-profile.test.sh(full targeted file, exit 0, nonot ok), including test_quota_divert_to_pi_rebuilds_launch, test_quota_divert_to_cursor_rebuilds_launch, test_same_harness_quota_divert_revalidates_model, test_quota_divert_from_pi_drops_pi_executable, test_raw_launch_quota_divert_runs_command_verbatimSingle-test runner fortest_quota_divert_to_pi_rebuilds_launchagainst target b11dce4d: passesSame single test withbin/fm-spawn.shtemporarily swapped to base 6b0f5a07 (git show 6b0f5a07:bin/fm-spawn.sh): fails, because the launch stayscodexwith no Pi prefix or executable; file restored withgit checkoutgit diff --quiet 6b0f5a07 HEAD -- AGENTS.md: byte-identical (Hard Rule 1 restored)grep -rn quota-auto-divert bin docs tests: no matches (opt-in gate removed per the recorded decision)✅ No issues found.
bash tests/fm-spawn-dispatch-profile.test.shon the target commit: exit 0, nonot ok. The four quota-divert tests pass (to pi, to cursor, same-harness model revalidation, away from pi) and the raw launch still runs verbatim.Regression check:bash tests/fm-spawn-dispatch-profile.test.shon a throwaway copy of HEAD withbin/fm-spawn.shreplaced by base 6b0f5a07. Exit 1;test_quota_divert_to_pi_rebuilds_launchfails because the rebuiltFM_PI_HARNESS=pi '<fakebin>/pi' --tui-mode regularprefix is missing.grep quota-auto-divertover bin, docs and tests: no matches, so the opt-in gate is gone as decided.bash tests/fm-watch-triage.test.sh(the test file this branch changes): 96oklines and nonot okwhen this phase ended. The run was still going in the background, so there is no final exit code.✅ No issues found.
bash tests/fm-spawn-dispatch-profile.test.shat the target commit: whole file passed, including all five quota-divert tests and the raw-launch-not-diverted testRegression check: ran the target'stests/fm-spawn-dispatch-profile.test.shagainst the basebin/fm-spawn.sh(6b0f5a07) in a temporary detached worktree, since removed.quota divert to pi did not rebuild the Pi launch prefix and executablefails there because the pane still launches undivertedcodex --model 'codex/gpt-5'End-to-end: drovefm-spawn.sh --harness codex --model codex/gpt-5 --effort maxthrough the test'srun_ship_spawnharness, with a stub prober answeringharness=pi model=openai-codex/gpt-5.6-sol, and captured the spawn output and the pane launch commandbash tests/fm-watch-triage.test.sh(a test file this branch changed): 96oklines and nonot okwhen last checked; the run had not finished when this phase returned✅ **Document** - passed
✅ No issues found.
✅ No issues found.
✅ No issues found.
✅ No issues found.
✅ No issues found.
✅ No issues found.
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed (2) ✅
🔧 Fix: Fix nested single quotes in quarantine test Python asserts
✅ Re-checked - no issues remain.
🔧 Fix: Quote empty harness binary resets in fm-spawn.sh
✅ Re-checked - no issues remain.
✅ No issues found.
✅ No issues found.
✅ No issues found.
✅ No issues found.
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
✅ No issues found.
✅ No issues found.
✅ No issues found.
✅ No issues found.
✅ No issues found.
✅ No issues found.