Skip to content

fix: enable isolated live validation in no-mistakes gates - #5615

Closed
kunchenguid wants to merge 11 commits into
mainfrom
fm/fm-gate-lab-live-validation-r1
Closed

kunchenguid wants to merge 11 commits into
mainfrom
fm/fm-gate-lab-live-validation-r1

Conversation

@kunchenguid

@kunchenguid kunchenguid commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Intent

Make Firstmate's no-mistakes pipeline perform honest live validation of pull requests inside isolated labs, motivated by live-validation gaps on PRs 5496 and 5503, by implementing two captain-authorized fixes only. Fix 1: harness-sensitive suites that directly invoke the launch path get a test-only simulated-harness seam (FM_TEST_HARNESS) that is honored only under the FM_TEST_SEAM marker so a leaked variable stays inert in production, plus per-harness 'primary in a lab' recipes in .no-mistakes.yaml for claude, codex, cursor, opencode, grok, and omp covering a disposable lab home, a private tmux socket or named non-default Herdr lab session, the machine's existing credentials, and honest reporting of missing CLI or login (never faked). Fix 2: replace the broad FM_GATE_REFUSE_BYPASS honor-system flag with structurally scoped lab authorization - a gate lifecycle call proceeds only when FM_HOME is a helper-marked disposable lab home under the temp root that is registered in no real home's registry and is not the primary checkout, and the resolved backend target is the lab's own isolation (fm-lab-* Herdr session, private tmux socket dir, or a lab-local tool). Deliberate decisions: the authorized lab proof covers FM_HOME and the backend target ONLY - worktree= and project= meta fields and orca_worktree_id are deliberately NOT location-checked because a real treehouse or Orca spawn legitimately lands its worktree in the shared pool outside the lab dir, so pinning it inside would force a fake treehouse (the captain explicitly forbade faking treehouse); the spawn-tools check that required a lab-local treehouse binary was removed for the same reason; production fm-harness.sh detect_own precedence is unchanged; .no-mistakes.yaml does not pin agent: claude; a real home stays refused even with forged lab markers; missing CLI or unavailable login is reported, never faked; Cause 4 (crediting prior worker live evidence) is deferred and no changes to the no-mistakes repo are included. Verified live: fm-gate-refuse 24/24 under a real gate marker including forged-marker and real-home refusals, fm-omp-harness and fm-afk-launch fully green under pi ancestry plus gate, fm-control-relaunch fully green under gate with relaunch sweeps driven live in disposable lab homes (the 5496 scenario), fm-backend-herdr-presentation-e2e green end-to-end under gate with real treehouse delegation and a named Herdr lab session, and the instruction-refresh live E2E green in an isolated Pi session.

What Changed

  • Replace the gate lifecycle bypass with authorization for helper-marked disposable lab homes and their isolated backend targets; real fleet homes remain refused.
  • Add a test-only harness seam for direct launch-path tests and lab-primary recipes for six harness CLIs using existing credentials.
  • Update test fixtures and gate-refusal coverage to exercise lab authorization, forged markers, and isolated lifecycle paths.

Risk Assessment

🚨 High: Recursive secondmate teardown can reach records or backend endpoints that the new gate lab authorization never checks, so the isolation boundary should be corrected before merge.

Testing

Targeted gate, launch, and relaunch checks passed. In a disposable named Herdr lab, real Claude detected itself despite a leaked test variable; Codex, OpenCode, and Pi answered one-shot prompts; and a Pi worker relaunched after pane closure with its task identity and Treehouse worktree preserved. A real-home gate call refused before delivery. The lab and pool slot were cleaned up. This was CLI validation, with no UI-facing change requiring visual evidence.

  • Live validation: ✅ go - 4 of 7 scenarios driven live against the product
Scenario Result Live Evidence
A gate agent targets a real home and is refused before sending ✅ pass live real-home-refusal.txt: exit 3, lab authorization failed
A real Claude primary ignores leaked FM_TEST_HARNESS without the seam marker ✅ pass live claude-detection.txt: Claude ran the detection command and reported claude
Codex, OpenCode, and Pi use existing logins to answer one-shot prompts in lab panes ✅ pass live oneshot-codex.txt, oneshot-opencode.txt, and oneshot-pi.txt each show LAB_OK
A real worker whose Herdr pane is closed relaunches with its task and worktree preserved ✅ pass live live-relaunch.txt and liveworker-before.meta/liveworker-after.meta: liveworker retained its worktree and harness while rebinding to a new pane in the same named session
A lab cannot authorize another lab’s session, external state, or descendant endpoint ⏸️ untested no A second disposable Herdr lab session and home would be needed to drive the cross-lab boundary against two live backends; provision both through bin/fm-herdr-lab.sh for that demonstration.
Cursor and Grok complete authenticated primary launches without persisting workspace trust ⏸️ untested no Workspace trust requires a non-persistent session-scoped option or permission to accept persistent trust. Neither was supplied; rerun only with a documented session-scoped option.
An OMP primary launches using an installed CLI ⏸️ untested no The omp CLI is not on PATH. Provide an installed CLI on PATH or a repository-local executable path to test its primary launch.
Evidence: Real-home gate refusal

Source: Real-home gate refusal

error: no-mistakes gate agent must not drive the fleet (NO_MISTAKES_GATE set)
note: lab authorization failed - FM_HOME is not a marked disposable lab home under the temp root
Evidence: Claude primary detects claude, not leaked omp

Source: Claude primary detects claude, not leaked omp


 ▐▛███▛█   Claude Code v2.1.282
▝▜██████▀  Opus 4.8 with high effort · Claude Max
 ▝▝   ▝▝   ~/.no-mistakes/worktrees/52b07e9083e7/01M3AX1TJX6ESSN5R2G88FEAMB


❯ Run exactly this read-only shell command and report its stdout verbatim, without changing any files: env -u
  FM_TEST_SEAM bash -c '. bin/fm-afk-launch.sh; fm_afk_launch_primary_harness'. Then stop.

  Ran 1 shell command

⏺ Captain, here is the command's stdout verbatim:

  claude

✻ Worked for 22s · done 6:49 PM



















───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯ Now the same for the away-supervisor harness
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  Opus 4.8 ctx window                 73.7k / 1.0M
  ⏵⏵ auto mode on (shift+tab to cycle) · ← for agents
Evidence: Real worker relaunch output

Source: Real worker relaunch output

●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e ~/.no-mistakes/worktrees/52b07e9083e7/01M3AX1TJX6ESSN5R2G88FEAMB/.pi/extensions/fm-primary-turnend-guard.ts -e ~/.no-mistakes/worktrees/52b07e9083e7/01M3AX1TJX6ESSN5R2G88FEAMB/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
warning: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T//fm-lab-home-501/livecheck-qLvBzW/data/liveworker/launch-brief.md records no ship branch; defaulting to legacy branch fm/liveworker
warning: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T//fm-lab-home-501/livecheck-qLvBzW/data/liveworker/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
relaunched liveworker harness=pi from=pi model=default effort=default backend=herdr endpoint=fm-lab-livecheck-25824-1043:w4:p2 worktree=~/.treehouse/01M3AX1TJX6ESSN5R2G88FEAMB-8bf1b0/1/01M3AX1TJX6ESSN5R2G88FEAMB
Evidence: Worker task record before relaunch

Source: Worker task record before relaunch

window=fm-lab-livecheck-25824-1043:w3:p2
endpoint_task_id=liveworker
worktree=~/.treehouse/01M3AX1TJX6ESSN5R2G88FEAMB-8bf1b0/1/01M3AX1TJX6ESSN5R2G88FEAMB
project=~/.no-mistakes/worktrees/52b07e9083e7/01M3AX1TJX6ESSN5R2G88FEAMB
harness=pi
kind=ship
mode=no-mistakes
yolo=off
branch=fm/liveworker
tasktmp=/tmp/fm-liveworker
model=default
effort=default
busy_gen=g1790301008.76808.6657
spawn_gen=s1790301008.65869.4200
backend=herdr
herdr_session=fm-lab-livecheck-25824-1043
herdr_workspace_id=w3
herdr_tab_id=w3:t2
herdr_pane_id=w3:p2
Evidence: Worker task record after relaunch

Source: Worker task record after relaunch

window=fm-lab-livecheck-25824-1043:w4:p2
endpoint_task_id=liveworker
worktree=~/.treehouse/01M3AX1TJX6ESSN5R2G88FEAMB-8bf1b0/1/01M3AX1TJX6ESSN5R2G88FEAMB
project=~/.no-mistakes/worktrees/52b07e9083e7/01M3AX1TJX6ESSN5R2G88FEAMB
harness=pi
kind=ship
mode=no-mistakes
yolo=off
branch=fm/liveworker
tasktmp=/tmp/fm-liveworker
model=default
effort=default
busy_gen=g1790301017.92042.11832
spawn_gen=s1790301017.89691.25902
backend=herdr
herdr_session=fm-lab-livecheck-25824-1043
herdr_workspace_id=w4
herdr_tab_id=w4:t2
herdr_pane_id=w4:p2
control_relaunch_tx=88872.20260925T015016Z.19838
Evidence: Codex one-shot response

Source: Codex one-shot response

01M3AX1TJX6ESSN5R2G88FEAMB HEAD
❯ env -u NO_MISTAKES_GATE codex exec --skip-git-repo-check "Reply only LAB_OK; do not use tools."
OpenAI Codex v0.155.1
--------
workdir: ~/.no-mistakes/worktrees/52b07e9083e7/01M3AX1TJX6ESSN5R2G88FEAMB
model: gpt-5.6-sol
provider: openai
approval: never
sandbox: danger-full-access
reasoning effort: low
reasoning summaries: none
session id: 01a0d642-06f4-7623-8175-bd7ca0a7d592
--------
user
Reply only LAB_OK; do not use tools.
warning: Skill descriptions were shortened to fit the skills context budget. Codex can still see every skill, but some d
escriptions are shorter. Disable unused skills or plugins to leave more room for the rest.
hook: SessionStart
hook: SessionStart
hook: SessionStart
hook: SessionStart
hook: SessionStart Completed
hook: SessionStart Completed
hook: SessionStart Completed
hook: SessionStart Completed
codex
LAB_OK
tokens used
19,192
01M3AX1TJX6ESSN5R2G88FEAMB HEAD 7s
❯
Evidence: OpenCode one-shot response

Source: OpenCode one-shot response

01M3AX1TJX6ESSN5R2G88FEAMB HEAD
❯ env -u NO_MISTAKES_GATE opencode run -m opencode/big-pickle "Reply only LAB_OK; do not use tools."

> build · big-pickle

LAB_OK

01M3AX1TJX6ESSN5R2G88FEAMB HEAD 8s
❯
Evidence: Pi one-shot response

Source: Pi one-shot response

01M3AX1TJX6ESSN5R2G88FEAMB HEAD
❯ env -u NO_MISTAKES_GATE pi --print --no-session --no-extensions --no-context-files "Reply only LAB_OK; do not use tool
s."
LAB_OK
01M3AX1TJX6ESSN5R2G88FEAMB HEAD
❯
- Outcome: 🔧 2 issues found → no changes applied (3) ✅ across 5 runs (1h2m1s)

Gate-suite proofs (driven live before the pipeline run)

Recorded against this change before submission; each suite ran with NO_MISTAKES_GATE=1 from a shell whose process ancestry resolves to pi (the same ancestry the gate agent runs under):

  • PR 5503 harness coverage: tests/fm-omp-harness.test.sh and tests/fm-afk-launch.test.sh fully green under real pi ancestry plus the gate marker, including the check that a leaked FM_TEST_HARNESS stays inert without FM_TEST_SEAM and is honored only alongside it.
  • Forged-marker refusals: tests/fm-gate-refuse.test.sh 24/24 - a forged .fm-lab-home marker on a non-lab directory, a forged lab binding record, and a real home carrying a valid marker are all refused; a properly created lab home authorizes.
  • PR 5496 relaunch scenario: tests/fm-control-relaunch.test.sh fully green under the gate, with relaunch sweeps driven live through bin/fm-spawn.sh in adopted disposable lab homes - corroborated above by the real-agent relaunch preserving task, endpoint rebinding, and Treehouse worktree.
  • End-to-end Herdr backend: tests/fm-backend-herdr-presentation-e2e.test.sh green end-to-end under the gate with real treehouse delegation, a marked lab root, and a named fm-lab-* Herdr session - no bypass flag.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 5 issues (1 error, 4 warnings)
  • 🚨 bin/fm-spawn.sh:2836 - The intent says the lab proof covers FM_HOME and the backend target ONLY, and deliberately does not location-check project=. This new assertion rejects a lab-backed spawn whose project is outside the lab, including a legitimate shared-pool project. Remove the project-location assertion.
  • 🚨 tests/herdr-test-safety.sh:35 - The intent explicitly forbids faking treehouse, but this new helper replaces treehouse get with git worktree add. Its new uses in tests/fm-backend-autodetect-smoke.test.sh:66, tests/fm-backend-herdr-launcher-workspace-e2e.test.sh:50, and tests/fm-backend-herdr-workspace-per-home-e2e.test.sh:69 turn live spawn evidence into fake-treehouse evidence. Remove the helper and those substitutions rather than hardening the fake.
  • 🚨 bin/fm-gate-refuse-lib.sh:168 - The intent requires the backend target to be the lab's own isolation. With FM_HOME in lab A and TMUX_TMPDIR or a tool in marked lab B, this helper authorizes access to B's backend. The same cross-lab acceptance is used by the tmux check at line 200 and tool check at line 181; tests/lib.sh:137 deliberately provisions the shared socket in a separate adopted lab. Align those paths with the authorized home's lab, or ask the captain to authorize shared lab backends.
  • 🚨 bin/fm-gate-refuse-lib.sh:357 - A marked FM_HOME and isolated backend can pass authorization while FM_STATE_OVERRIDE points at a real home's empty state directory: this scan accepts it, and fm-spawn.sh:490 then uses that directory for task records. FM_DATA_OVERRIDE similarly redirects spawn data at fm-spawn.sh:491; fm-send.sh:235 and fm-teardown.sh:284-286 also consume overrides. This is a concrete route to modifying real fleet state despite .no-mistakes.yaml's prohibition. The intent expressly limits the lab proof to FM_HOME and backend target, so a remedy that constrains overrides needs a policy decision: may gate labs use overrides outside the lab?
  • ⚠️ .no-mistakes.yaml:43 - The required per-harness primary-in-a-lab recipe starts tmux -L fm-lab new-session -d without a harness command, then only lists CLI names separately. Following it creates an empty session, not a Claude/Codex/etc. primary; subsequent firstmate tmux commands also do not supply -L fm-lab. Specify an executable launch for each harness on the same private socket.
  • ⚠️ tests/fm-gate-refuse.test.sh:614 - The newly added awk assertion extracts the first matching source line rather than checking the consumed YAML value. It can pass when that line is commented, nested, or overridden later. Remove this unrelated assertion or parse the configuration semantically, as the test-quality rule requires.

🔧 Fix applied.
6 issues (5 errors, 1 warning) still open:

  • 🚨 bin/fm-gate-refuse-lib.sh:168 - The intent requires the backend target to be the lab's own isolation. With FM_HOME in lab A and TMUX_TMPDIR or a tool in marked lab B, this helper authorizes access to B's backend. The same cross-lab acceptance is used by the tmux check at line 200 and tool check at line 181; tests/lib.sh:137 deliberately provisions the shared socket in a separate adopted lab. Align those paths with the authorized home's lab, or ask the captain to authorize shared lab backends.
  • 🚨 bin/fm-gate-refuse-lib.sh:357 - A marked FM_HOME and isolated backend can pass authorization while FM_STATE_OVERRIDE points at a real home's empty state directory: this scan accepts it, and fm-spawn.sh:490 then uses that directory for task records. FM_DATA_OVERRIDE similarly redirects spawn data at fm-spawn.sh:491; fm-send.sh:235 and fm-teardown.sh:284-286 also consume overrides. This is a concrete route to modifying real fleet state despite .no-mistakes.yaml's prohibition. The intent expressly limits the lab proof to FM_HOME and backend target, so a remedy that constrains overrides needs a policy decision: may gate labs use overrides outside the lab?
  • 🚨 bin/fm-lab-home.sh:75 - The round-1 fix scoped tools to the authorized lab but left a symlink escape: canon_loose resolves a symlink to a regular executable as its lab-local parent plus basename, not its target. Put a symlink to the real tmux in the lab's PATH, leave TMUX_TMPDIR unset, and the gate authorizes calls to the default tmux server. The same check is used for lab-local herdr, ssh, zellij, orca, and cmux at bin/fm-gate-refuse-lib.sh:172-225. Resolve executable symlinks to their actual targets before accepting any of these tools.
  • 🚨 bin/fm-gate-refuse-lib.sh:417 - The round-1 override fix confines FM_STATE_OVERRIDE and FM_DATA_OVERRIDE but leaves their default siblings unchecked. A marked lab home with state symlinked to a real home's empty state directory and a private backend passes authorization; bin/fm-spawn.sh:490 then writes task records there. A data symlink similarly redirects writes through bin/fm-spawn.sh:491, while send and teardown consume the corresponding default directories. Check the effective state and data directories, including default paths, at the shared authorization boundary.
  • 🚨 bin/fm-gate-refuse-lib.sh:205 - The round-1 cross-lab fix bound socket directories and tools to the home's lab but left the Herdr sibling unchanged. With FM_HOME in lab A, HERDR_SESSION naming lab B's live fm-lab-* session passes here; an explicit fm-send target for B also passes at line 501, and recorded endpoints pass at line 372. A gate call can therefore steer B's pane. The captain required the home's own isolated session. Binding a session to its owning lab needs an authorized session-naming or ownership rule; the remedy, rather than the defect, needs a human decision.
  • ⚠️ bin/fm-gate-refuse-lib.sh - recorded fix decision 01M3AX52275JG73W547Y30J59W/cross-lab-backend (review round 1): contradicted: The round-1 fix places fixture socket directories within their suite labs and scopes tool and tmux paths at bin/fm-gate-refuse-lib.sh:160-200. However, lines 205-209, 369-374, and 499-505 accept any fm-lab-* Herdr session without establishing that it belongs to the FM_HOME lab.

🔧 Fix applied.
5 issues (4 errors, 1 warning) still open:

  • 🚨 bin/fm-gate-refuse-lib.sh:168 - The intent requires the backend target to be the lab's own isolation. With FM_HOME in lab A and TMUX_TMPDIR or a tool in marked lab B, this helper authorizes access to B's backend. The same cross-lab acceptance is used by the tmux check at line 200 and tool check at line 181; tests/lib.sh:137 deliberately provisions the shared socket in a separate adopted lab. Align those paths with the authorized home's lab, or ask the captain to authorize shared lab backends.
  • 🚨 bin/fm-gate-refuse-lib.sh:357 - A marked FM_HOME and isolated backend can pass authorization while FM_STATE_OVERRIDE points at a real home's empty state directory: this scan accepts it, and fm-spawn.sh:490 then uses that directory for task records. FM_DATA_OVERRIDE similarly redirects spawn data at fm-spawn.sh:491; fm-send.sh:235 and fm-teardown.sh:284-286 also consume overrides. This is a concrete route to modifying real fleet state despite .no-mistakes.yaml's prohibition. The intent expressly limits the lab proof to FM_HOME and backend target, so a remedy that constrains overrides needs a policy decision: may gate labs use overrides outside the lab?
  • 🚨 bin/fm-gate-refuse-lib.sh:417 - The round-1 override fix confines FM_STATE_OVERRIDE and FM_DATA_OVERRIDE but leaves their default siblings unchecked. A marked lab home with state symlinked to a real home's empty state directory and a private backend passes authorization; bin/fm-spawn.sh:490 then writes task records there. A data symlink similarly redirects writes through bin/fm-spawn.sh:491, while send and teardown consume the corresponding default directories. Check the effective state and data directories, including default paths, at the shared authorization boundary.
  • 🚨 bin/fm-gate-refuse-lib.sh:205 - The round-1 cross-lab fix bound socket directories and tools to the home's lab but left the Herdr sibling unchanged. With FM_HOME in lab A, HERDR_SESSION naming lab B's live fm-lab-* session passes here; an explicit fm-send target for B also passes at line 501, and recorded endpoints pass at line 372. A gate call can therefore steer B's pane. The captain required the home's own isolated session. Binding a session to its owning lab needs an authorized session-naming or ownership rule; the remedy, rather than the defect, needs a human decision.
  • ⚠️ bin/fm-gate-refuse-lib.sh - recorded fix decision 01M3AX52275JG73W547Y30J59W/cross-lab-backend (review round 1): contradicted: The round-1 fix places fixture socket directories within their suite labs and scopes tool and tmux paths at bin/fm-gate-refuse-lib.sh:160-200. However, lines 205-209, 369-374, and 499-505 accept any fm-lab-* Herdr session without establishing that it belongs to the FM_HOME lab.

🔧 Fix applied.
2 warnings still open:

  • ⚠️ tests/fm-spawn-batch.test.sh:31 - The change introduces a fake treehouse executable even though these cases stop at the missing-brief check and the lab authorization no longer requires a lab-local treehouse. No intent requirement needs this component; remove the stub and its PATH injection at lines 40, 109, and 114.
  • ⚠️ tests/lib.sh:212 - Fixture cleanup removes the adopted lab with rm -rf but leaves its binding record. Each subsequent record-herdr-session call scans every binding (bin/fm-lab-home.sh:224), so repeated gate runs accumulate stale records and progressively slow session registration. The same cleanup pattern remains in the changed Herdr suites, including tests/fm-backend-herdr-presentation-e2e.test.sh:306 and tests/fm-backend-herdr-launcher-workspace-e2e.test.sh:78. Use the existing lab teardown helper for adopted labs.

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

  • 🚨 bin/fm-gate-refuse-lib.sh:361 - Authorization scans only the selected home's state directory. A lab secondmate task can name a child home inside the lab whose state directory contains a task on another Herdr session—or whose state directory symlinks outside the lab. Gate-authorized teardown of the parent then traverses that child home and can close the foreign pane or process its external records. The sibling path is bin/fm-teardown.sh:3060-3080 (recursive preflight) and :3128-3169 (recursive close). Enforce the lab boundary on descendant homes, effective directories, and endpoints before recursive teardown reaches them.
  • ⚠️ recorded fix decision 01M3B04VA33HCK4GXJCAM96V56/test-2 (test round 1): unverified: .no-mistakes.yaml:43 provides the structural live recipe and bin/fm-afk-launch.sh:200-205 gates the seam, but this review phase is prohibited from running the requested live primary and relaunch scenarios. Later test rulings permit honest blocked outcomes for specified harnesses.
  • ⚠️ recorded fix decision 01M3B19WPYF0YB6EG0847S8X9M/test-2 (test round 2): unverified: The source supplies named-session recording in bin/fm-lab-home.sh:202-232 and the lab recipe in .no-mistakes.yaml:43; live one-shot login and real-worker relaunch evidence cannot be independently established without executing the test phase.
  • ⚠️ recorded fix decision 01M3B1YDPNTTSFEMJQW73G6S63/real-relaunch-evidence (test round 3): unverified: bin/fm-spawn.sh:1653-1678 uses the recorded task and endpoint for relaunch, and its existing relaunch path supports the authorized shared-pool worktree; this review did not run the required real-agent kill-and-relaunch demonstration.
  • ⚠️ recorded fix decision 01M3B1YDPNTTSFEMJQW73G6S63/test-2 (test round 3): unverified: The source permits the named Herdr lab and does not location-check the shared-pool worktree (bin/fm-gate-refuse-lib.sh:356-359). The requested live retest and final harness outcomes belong to the test phase and were not executed here.

🔧 Fix applied.
5 issues (1 error, 4 warnings) still open:

  • 🚨 bin/fm-gate-refuse-lib.sh:361 - Authorization scans only the selected home's state directory. A lab secondmate task can name a child home inside the lab whose state directory contains a task on another Herdr session—or whose state directory symlinks outside the lab. Gate-authorized teardown of the parent then traverses that child home and can close the foreign pane or process its external records. The sibling path is bin/fm-teardown.sh:3060-3080 (recursive preflight) and :3128-3169 (recursive close). Enforce the lab boundary on descendant homes, effective directories, and endpoints before recursive teardown reaches them.
  • ⚠️ recorded fix decision 01M3B04VA33HCK4GXJCAM96V56/test-2 (test round 1): unverified: .no-mistakes.yaml:43 provides the structural live recipe and bin/fm-afk-launch.sh:200-205 gates the seam, but this review phase is prohibited from running the requested live primary and relaunch scenarios. Later test rulings permit honest blocked outcomes for specified harnesses.
  • ⚠️ recorded fix decision 01M3B19WPYF0YB6EG0847S8X9M/test-2 (test round 2): unverified: The source supplies named-session recording in bin/fm-lab-home.sh:202-232 and the lab recipe in .no-mistakes.yaml:43; live one-shot login and real-worker relaunch evidence cannot be independently established without executing the test phase.
  • ⚠️ recorded fix decision 01M3B1YDPNTTSFEMJQW73G6S63/real-relaunch-evidence (test round 3): unverified: bin/fm-spawn.sh:1653-1678 uses the recorded task and endpoint for relaunch, and its existing relaunch path supports the authorized shared-pool worktree; this review did not run the required real-agent kill-and-relaunch demonstration.
  • ⚠️ recorded fix decision 01M3B1YDPNTTSFEMJQW73G6S63/test-2 (test round 3): unverified: The source permits the named Herdr lab and does not location-check the shared-pool worktree (bin/fm-gate-refuse-lib.sh:356-359). The requested live retest and final harness outcomes belong to the test phase and were not executed here.
🔧 **Test** - 2 issues found → no changes applied (3) ✅
  • ⚠️ This run did not demonstrate an authenticated primary launch for each harness or a real-agent relaunch. The relaunch test uses a simulated session provider; live evidence for those parts of the intent is still needed.
  • ⚠️ live validation verdict: inconclusive (3 of 6 scenarios were driven live against the product); untested: A leaked FM_TEST_HARNESS value stays inert without FM_TEST_SEAM, Each configured harness launches an authenticated primary on its lab-private socket, A real agent relaunch preserves its task and endpoint in an isolated lab
  • Live validation: ⚠️ inconclusive - 3 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A gate agent uses a recorded named Herdr session from its disposable lab and reaches spawn validation ✅ pass live herdr-lab-live.txt: running named server, authorization, missing-brief response, and absent session after teardown
A gate agent targets an unrecorded Herdr session and is refused before fleet access ✅ pass live herdr-lab-live.txt: lab authorization refusal with exit 3
A worker spawned through real Treehouse lands beside its Herdr launcher without disturbing another workspace ✅ pass live herdr-launcher-e2e.log: real Herdr E2E results and unchanged default fleet session
A leaked FM_TEST_HARNESS value stays inert without FM_TEST_SEAM ⏸️ untested no A running authenticated primary carrying the leaked variable was not available in this test turn; provide an isolated primary session to verify the production path live.
Each configured harness launches an authenticated primary on its lab-private socket ⏸️ untested no Existing logins for the six harness CLIs were not verified, and omp was not on PATH. Provide the missing CLI and authenticated isolated primary sessions to drive each recipe.
A real agent relaunch preserves its task and endpoint in an isolated lab ⏸️ untested no No authenticated agent was launched for a live relaunch; provide an isolated authenticated lab primary and task to drive it.
  • tests/fm-gate-refuse.test.sh
  • tests/fm-control-relaunch.test.sh
  • tests/fm-omp-harness.test.sh
  • tests/fm-afk-launch.test.sh
  • tests/fm-backend-herdr-launcher-workspace-e2e.test.sh
  • Provisioned and tore down a named session with bin/fm-herdr-lab.sh; drove gate authorization and bin/fm-spawn.sh against its recorded lab home

🔧 No changes applied.
2 warnings still open:

  • ⚠️ A real Claude worker spawned in an isolated lab, but its post-kill relaunch could not be demonstrated. After the pane was killed, fm-control refused to treat the missing tmux window as proof the agent had stopped. A real-agent relaunch on an isolated Herdr endpoint still needs live evidence.
  • ⚠️ live validation verdict: inconclusive (4 of 6 scenarios were driven live against the product); untested: Every configured harness primary completes launch using an existing login, After a real worker pane dies, supervision relaunches it while preserving task identity and worktree
  • Live validation: ⚠️ inconclusive - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A gate agent uses a marked lab with a private socket and reaches ordinary spawn validation ✅ pass live gate-live-boundaries.txt: spawn reached missing-brief validation rather than gate refusal
A gate agent tries an external state directory or unisolated tmux backend and is refused ✅ pass live gate-live-boundaries.txt: both attempts returned gate refusal, exit 3
A real Claude primary ignores a stray FM_TEST_HARNESS without FM_TEST_SEAM ✅ pass live claude-leaked-harness.txt: the primary shows FM_TEST_HARNESS=cursor and detect_own prints claude
Installed harness primaries open on isolated private sockets ✅ pass live claude-leaked-harness.txt and primary-codex.txt, primary-cursor-agent.txt, primary-opencode.txt, primary-grok.txt, and primary-pi-session-only.txt
Every configured harness primary completes launch using an existing login ⏸️ untested no Cursor and Grok require workspace-trust approval that may persist outside the worktree; provide a permitted session-only trust path or pretrusted isolated workspace and rerun. Login/model readiness fo…
After a real worker pane dies, supervision relaunches it while preserving task identity and worktree ⏸️ untested no The tmux adapter cannot prove a deleted recorded window belongs to the addressed server, so it refuses this recovery by design. Re-drive the scenario with a real worker in a named Herdr lab session, u…
  • NO_MISTAKES_GATE=1 tests/fm-gate-refuse.test.sh
  • NO_MISTAKES_GATE=1 tests/fm-omp-harness.test.sh
  • NO_MISTAKES_GATE=1 tests/fm-afk-launch.test.sh
  • NO_MISTAKES_GATE=1 tests/fm-control-relaunch.test.sh (timed out after 180 seconds)
  • Launched Claude, Codex, Cursor Agent, OpenCode, Grok, and Pi in disposable lab homes on private tmux -L fm-lab sockets; captured their terminal output and tore down each lab.
  • Ran bin/fm-harness.sh detect_own from the live Claude primary with FM_TEST_HARNESS=cursor and no FM_TEST_SEAM.
  • Invoked bin/fm-spawn.sh under the gate with an authorized lab socket, an external state override, and an unisolated backend.
  • Spawned a real Claude task in a lab-private tmux backend, killed its worker pane, and invoked bin/fm-control.sh liverl relaunch --note ...; cleaned up the lab and local Treehouse fixture.

🔧 No changes applied.
2 warnings still open:

  • ⚠️ A real Claude worker spawned in a named Herdr lab, but its task worktree was allocated in Treehouse's pool outside the permitted worktree. I closed the pane and returned the worktree rather than drive a relaunch that would write there. A real-agent post-kill relaunch and preservation of its task record and endpoint remain undemonstrated; rerun with an authorized Treehouse pool inside the worktree or explicit permission for the external pool.
  • ⚠️ live validation verdict: inconclusive (3 of 7 scenarios were driven live against the product); untested: After its pane dies, supervision relaunches the real worker while preserving task identity and worktree, A leaked FM_TEST_HARNESS does not override real Claude detection without FM_TEST_SEAM, Cursor and Grok complete authenticated primary launch without changing persistent workspace trust, An OMP primary launches using the installed CLI
  • Live validation: ⚠️ inconclusive - 3 of 7 scenarios driven live against the product
Scenario Result Live Evidence
A marked lab home cannot spawn against another lab's recorded Herdr session ✅ pass live cross-lab-refusal.txt: lab authorization failed for the Herdr backend; exit 3
Codex, OpenCode, and Pi answer a trivial prompt in a named isolated Herdr lab ✅ pass live one-shot-herdr-lab.txt: each command exited 0 and answered LAB_OK
A real Claude worker spawns into its lab's recorded Herdr session ✅ pass live one-shot-herdr-lab.txt: persisted task record names a Claude worker and the named lab session
After its pane dies, supervision relaunches the real worker while preserving task identity and worktree ⏸️ untested no Treehouse allocated the task checkout in its external pool. Provide an authorized pool inside this worktree, or permission to use that external pool, to complete the relaunch.
A leaked FM_TEST_HARNESS does not override real Claude detection without FM_TEST_SEAM ⏸️ untested no The worktree's absolute path made the private tmux socket pathname too long. Provide an authorized shorter worktree path or another isolated primary-launch transport.
Cursor and Grok complete authenticated primary launch without changing persistent workspace trust ⏸️ untested no Workspace trust requires persistence in the user's tool stores; provide a documented session-scoped, non-persisting trust option to drive these launches.
An OMP primary launches using the installed CLI ⏸️ untested no The omp CLI is not on PATH and no repository-local executable was supplied; provide one to test this harness.
  • bin/fm-herdr-lab.sh provision/run/teardown with a named fm-lab-* session and a recorded lab-home binding
  • herdr pane run in that lab: one-shot Codex, OpenCode free-model, and Pi prompts
  • NO_MISTAKES_GATE=1 bin/fm-spawn.sh with a different marked lab home targeting the first lab's Herdr session
  • NO_MISTAKES_GATE=1 bin/fm-spawn.sh realrl ... --harness claude --backend herdr; closed its pane and ran treehouse return --force

🔧 No changes applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A real Claude primary ignores a stray FM_TEST_HARNESS without FM_TEST_SEAM ✅ pass live primaries.log shows bin/fm-harness.sh own returning claude despite FM_TEST_HARNESS=omp.
Installed primary harnesses answer a one-shot prompt using existing logins in a disposable lab ✅ pass live primaries.log shows Codex and Pi replies; opencode-free.log shows the OpenCode free-model reply; primaries.log also shows the Claude primary.
Cursor and Grok launch without persisting workspace trust ⏸️ untested no Workspace trust was blocked, as directed. Provide a documented session-scoped trust option that persists nothing outside the lab to enable this check.
An OMP primary launches from an installed CLI ⏸️ untested no OMP is not on PATH and no repository-local executable was supplied; provide one to enable a live launch.
Supervision relaunches a real worker after its Herdr pane closes without reallocating its worktree ✅ pass live real-relaunch.log records the pane close, successful relaunch, unchanged task and worktree, a rebound endpoint, and worktree return after evidence capture.
A gate lab refuses another lab's Herdr session and an escaped state directory ✅ pass live boundary-live.log shows cross-lab targeting refused with status 3; the state-symlink attempt was refused before spawn.
  • NO_MISTAKES_GATE=1 tests/fm-gate-refuse.test.sh
  • NO_MISTAKES_GATE=1 tests/fm-control-relaunch.test.sh
  • NO_MISTAKES_GATE=1 tests/fm-afk-launch.test.sh
  • NO_MISTAKES_GATE=1 tests/fm-omp-harness.test.sh
  • Launched real Claude, Codex, OpenCode, and Pi one-shot prompts in disposable named Herdr labs; retried OpenCode with its free model.
  • Spawned a real Claude worker through Treehouse in a named Herdr lab, closed its pane, and ran fm-control.sh relaunch before returning its worktree.
  • Tried cross-lab Herdr targeting and an escaping state symlink under NO_MISTAKES_GATE=1; tore down the labs and removed transient test scripts.

✅ No issues found.

  • Live validation: ✅ go - 4 of 7 scenarios driven live against the product
Scenario Result Live Evidence
A gate agent targets a real home and is refused before sending ✅ pass live real-home-refusal.txt: exit 3, lab authorization failed
A real Claude primary ignores leaked FM_TEST_HARNESS without the seam marker ✅ pass live claude-detection.txt: Claude ran the detection command and reported claude
Codex, OpenCode, and Pi use existing logins to answer one-shot prompts in lab panes ✅ pass live oneshot-codex.txt, oneshot-opencode.txt, and oneshot-pi.txt each show LAB_OK
A real worker whose Herdr pane is closed relaunches with its task and worktree preserved ✅ pass live live-relaunch.txt and liveworker-before.meta/liveworker-after.meta: liveworker retained its worktree and harness while rebinding to a new pane in the same named session
A lab cannot authorize another lab’s session, external state, or descendant endpoint ⏸️ untested no A second disposable Herdr lab session and home would be needed to drive the cross-lab boundary against two live backends; provision both through bin/fm-herdr-lab.sh for that demonstration.
Cursor and Grok complete authenticated primary launches without persisting workspace trust ⏸️ untested no Workspace trust requires a non-persistent session-scoped option or permission to accept persistent trust. Neither was supplied; rerun only with a documented session-scoped option.
An OMP primary launches using an installed CLI ⏸️ untested no The omp CLI is not on PATH. Provide an installed CLI on PATH or a repository-local executable path to test its primary launch.
  • tests/fm-gate-refuse.test.sh
  • tests/fm-afk-launch.test.sh
  • tests/fm-control-relaunch.test.sh
  • NO_MISTAKES_GATE=1 FM_HOME="$PWD" bin/fm-send.sh not-a-task 'must not deliver'
  • bin/fm-herdr-lab.sh provision/run/teardown with a recorded, named fm-lab-* session
  • Launched a real Claude primary with stray FM_TEST_HARNESS=omp and no FM_TEST_SEAM; asked it to run fm_afk_launch_primary_harness
  • Ran Codex, OpenCode, and Pi one-shot prompts in isolated Herdr lab panes
  • Spawned a real Pi worker, closed its pane, ran fm-control.sh liveworker relaunch, compared task records, returned the Treehouse slot, and tore down the lab
✅ **Document** - passed

✅ No issues found.

✅ No issues found.

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

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

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

✅ No issues found.

The gate refusal blocked every fleet lifecycle call, so a gate agent could
never run honest live validation of a PR inside an isolated lab; the only
escape was an honor-system bypass flag that trusted whatever exported it.
Replace it with a structural proof: bin/fm-lab-home.sh mints marker-bound
disposable lab homes under the temp root, and the gate authorizes a call
only when the resolved FM_HOME carries a bound marker, sits under the temp
root, is registered nowhere real, and the resolved backend target is the
lab's own isolation (fm-lab-* Herdr session, private tmux socket dir, or a
lab-local tool). Worktree and spawning-project locations are deliberately
unpinned: a real treehouse or Orca spawn legitimately lands in the shared
pool, and pinning it inside would force a fake pool. Everything else stays
refused exactly as before - a real home refuses even with a forged marker.

Also add the per-harness "primary in a lab" recipe to .no-mistakes.yaml
(claude, codex, cursor, opencode, grok, omp: disposable home, private
socket or named lab session, existing credentials, honest missing-login
reports), and gate the test-only FM_TEST_HARNESS seam behind the
FM_TEST_SEAM marker so a leaked variable stays inert in production.

Verified: tests/fm-gate-refuse.test.sh 24/24 under a real gate marker;
fm-omp-harness and fm-afk-launch fully green under pi ancestry plus gate;
fm-control-relaunch fully green under gate (relaunch sweeps driven live in
disposable lab homes); fm-backend-herdr-presentation-e2e green end-to-end
with real treehouse delegation, a marked lab root, and a named Herdr lab
session; instruction-refresh live E2E green in an isolated Pi session.
…test to require refusal for an unmarked home, and quoted the Herdr relationship value to satisfy ShellCheck without changing behavior. The focused tests, ShellCheck, syntax checks, and diff check pass
…gs now stop the owned watcher and clear its lifecycle state before the next leg. The wake-queue suite, ShellCheck, and diff check pass locally
…cle-e2e.test.sh: the liveness fixture now waits for lock acquisition, not just lock-directory creation. The focused test, ShellCheck, syntax check, and diff check pass locally
kunchenguid added a commit that referenced this pull request Sep 25, 2026
* fix(bin): let gate agents drive lifecycle against marked lab homes

Part 2 of the #5615 split. A no-mistakes gate agent runs inside a
checkout carrying the fleet-captain identity, so fm-gate-refuse-lib
refuses fleet mutation on the gate signal. That refusal was absolute,
which kept gate validation from ever exercising the real lifecycle.

Stamp a disposable lab FM_HOME with a .fm-lab-home marker file that
only bin/fm-lab-home.sh writes, and only onto a fresh empty dir, so
no call path can mark a populated real home. fm_refuse_if_gate_agent
then permits lifecycle only when FM_HOME carries the marker and is
driven through its stock layout - any FM_*_OVERRIDE relocation stays
refused so part of the "lab" cannot be split back onto the real fleet.
The threat model is a confused agent touching the real fleet, not
deliberate forgery, so the marker is a plain token file rather than a
bound record. FM_GATE_REFUSE_BYPASS is unchanged: it still serves the
test harness, which cannot mark hundreds of temp homes.

Teardown's slot-ownership scan compared state-dir paths textually
while fm_firstmate_root_home canonicalizes, so a lab home under a
symlinked TMPDIR scanned its own record twice and self-collided;
compare file identity (-ef) instead.

* no-mistakes(review): Refuse unlistable lab homes and hardlinked slot records

* no-mistakes(review): Mint lab markers only on verified-empty fresh dirs

* no-mistakes(document): Clarify lab-home gate documentation and comment contracts

* no-mistakes(document): Clarify lab-home gate documentation and remove stale claims

* no-mistakes(document): Clarify gate lab-home documentation and boundary wording
@kunchenguid

Copy link
Copy Markdown
Owner Author

Superseded by the split the maintainer asked for: #5635 (minimal lab-home gate allowance, merged) and #5638 (test-only harness seam, lab primary recipe, and flaky-test fixes). Closing this larger version unmerged.

kunchenguid added a commit that referenced this pull request Sep 25, 2026
Part 1 of the #5615 split: the pieces that let the no-mistakes pipeline
live-validate firstmate changes, without the gate-refusal rescoping.

- bin/fm-afk-launch.sh: FM_TEST_HARNESS pins the detected harness only
  alongside the FM_TEST_SEAM=1 marker test suites set, so a leaked variable
  in a real primary's environment stays inert and unknown tokens fall
  through to real detection.
- tests/lib.sh: export FM_TEST_SEAM=1 for every suite.
- .no-mistakes.yaml: per-harness recipe for running a real fixture primary
  from a gate run - a plain mktemp lab FM_HOME on a private tmux socket,
  with FM_GATE_REFUSE_BYPASS=1 scoped to it and NO_MISTAKES_GATE scrubbed.
- tests/fm-wake-queue.test.sh: stop the owned watcher fixture with KILL and
  clear its lifecycle state so the next leg starts clean; TERM could leave
  bash waiting in a child on some runners.
- tests/fm-remote-secondmate-lifecycle-e2e.test.sh: wait for the liveness
  lock holder's post-acquire marker instead of the lock dir, which is
  published before the claim finishes.
kunchenguid added a commit that referenced this pull request Sep 25, 2026
* feat(tests): add FM_TEST_SEAM launch seam and gate lab-primary recipe

Part 1 of the #5615 split: the pieces that let the no-mistakes pipeline
live-validate firstmate changes, without the gate-refusal rescoping.

- bin/fm-afk-launch.sh: FM_TEST_HARNESS pins the detected harness only
  alongside the FM_TEST_SEAM=1 marker test suites set, so a leaked variable
  in a real primary's environment stays inert and unknown tokens fall
  through to real detection.
- tests/lib.sh: export FM_TEST_SEAM=1 for every suite.
- .no-mistakes.yaml: per-harness recipe for running a real fixture primary
  from a gate run - a plain mktemp lab FM_HOME on a private tmux socket,
  with FM_GATE_REFUSE_BYPASS=1 scoped to it and NO_MISTAKES_GATE scrubbed.
- tests/fm-wake-queue.test.sh: stop the owned watcher fixture with KILL and
  clear its lifecycle state so the next leg starts clean; TERM could leave
  bash waiting in a child on some runners.
- tests/fm-remote-secondmate-lifecycle-e2e.test.sh: wait for the liveness
  lock holder's post-acquire marker instead of the lock dir, which is
  published before the claim finishes.

* no-mistakes(review): Scrub lab home overrides and require FM_TEST_SEAM separately

* no-mistakes(document): Clarify test seam and disposable lab bypass documentation

* no-mistakes(document): Clarify lab isolation and test-seam documentation

* no-mistakes(ci): Fixed the CI failure: test cleanup killed the remote worker child but left its supervisor able to restart it during fixture removal. Cleanup now stops the worker tree. The lifecycle test passed locally; ShellCheck and diff checks passed
mituso89 pushed a commit to mituso89/firstmate that referenced this pull request Sep 26, 2026
…enguid#5635)

* fix(bin): let gate agents drive lifecycle against marked lab homes

Part 2 of the kunchenguid#5615 split. A no-mistakes gate agent runs inside a
checkout carrying the fleet-captain identity, so fm-gate-refuse-lib
refuses fleet mutation on the gate signal. That refusal was absolute,
which kept gate validation from ever exercising the real lifecycle.

Stamp a disposable lab FM_HOME with a .fm-lab-home marker file that
only bin/fm-lab-home.sh writes, and only onto a fresh empty dir, so
no call path can mark a populated real home. fm_refuse_if_gate_agent
then permits lifecycle only when FM_HOME carries the marker and is
driven through its stock layout - any FM_*_OVERRIDE relocation stays
refused so part of the "lab" cannot be split back onto the real fleet.
The threat model is a confused agent touching the real fleet, not
deliberate forgery, so the marker is a plain token file rather than a
bound record. FM_GATE_REFUSE_BYPASS is unchanged: it still serves the
test harness, which cannot mark hundreds of temp homes.

Teardown's slot-ownership scan compared state-dir paths textually
while fm_firstmate_root_home canonicalizes, so a lab home under a
symlinked TMPDIR scanned its own record twice and self-collided;
compare file identity (-ef) instead.

* no-mistakes(review): Refuse unlistable lab homes and hardlinked slot records

* no-mistakes(review): Mint lab markers only on verified-empty fresh dirs

* no-mistakes(document): Clarify lab-home gate documentation and comment contracts

* no-mistakes(document): Clarify lab-home gate documentation and remove stale claims

* no-mistakes(document): Clarify gate lab-home documentation and boundary wording
mituso89 pushed a commit to mituso89/firstmate that referenced this pull request Sep 26, 2026
…henguid#5638)

* feat(tests): add FM_TEST_SEAM launch seam and gate lab-primary recipe

Part 1 of the kunchenguid#5615 split: the pieces that let the no-mistakes pipeline
live-validate firstmate changes, without the gate-refusal rescoping.

- bin/fm-afk-launch.sh: FM_TEST_HARNESS pins the detected harness only
  alongside the FM_TEST_SEAM=1 marker test suites set, so a leaked variable
  in a real primary's environment stays inert and unknown tokens fall
  through to real detection.
- tests/lib.sh: export FM_TEST_SEAM=1 for every suite.
- .no-mistakes.yaml: per-harness recipe for running a real fixture primary
  from a gate run - a plain mktemp lab FM_HOME on a private tmux socket,
  with FM_GATE_REFUSE_BYPASS=1 scoped to it and NO_MISTAKES_GATE scrubbed.
- tests/fm-wake-queue.test.sh: stop the owned watcher fixture with KILL and
  clear its lifecycle state so the next leg starts clean; TERM could leave
  bash waiting in a child on some runners.
- tests/fm-remote-secondmate-lifecycle-e2e.test.sh: wait for the liveness
  lock holder's post-acquire marker instead of the lock dir, which is
  published before the claim finishes.

* no-mistakes(review): Scrub lab home overrides and require FM_TEST_SEAM separately

* no-mistakes(document): Clarify test seam and disposable lab bypass documentation

* no-mistakes(document): Clarify lab isolation and test-seam documentation

* no-mistakes(ci): Fixed the CI failure: test cleanup killed the remote worker child but left its supervisor able to restart it during fixture removal. Cleanup now stops the worker tree. The lifecycle test passed locally; ShellCheck and diff checks passed
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…enguid#5635)

* fix(bin): let gate agents drive lifecycle against marked lab homes

Part 2 of the kunchenguid#5615 split. A no-mistakes gate agent runs inside a
checkout carrying the fleet-captain identity, so fm-gate-refuse-lib
refuses fleet mutation on the gate signal. That refusal was absolute,
which kept gate validation from ever exercising the real lifecycle.

Stamp a disposable lab FM_HOME with a .fm-lab-home marker file that
only bin/fm-lab-home.sh writes, and only onto a fresh empty dir, so
no call path can mark a populated real home. fm_refuse_if_gate_agent
then permits lifecycle only when FM_HOME carries the marker and is
driven through its stock layout - any FM_*_OVERRIDE relocation stays
refused so part of the "lab" cannot be split back onto the real fleet.
The threat model is a confused agent touching the real fleet, not
deliberate forgery, so the marker is a plain token file rather than a
bound record. FM_GATE_REFUSE_BYPASS is unchanged: it still serves the
test harness, which cannot mark hundreds of temp homes.

Teardown's slot-ownership scan compared state-dir paths textually
while fm_firstmate_root_home canonicalizes, so a lab home under a
symlinked TMPDIR scanned its own record twice and self-collided;
compare file identity (-ef) instead.

* no-mistakes(review): Refuse unlistable lab homes and hardlinked slot records

* no-mistakes(review): Mint lab markers only on verified-empty fresh dirs

* no-mistakes(document): Clarify lab-home gate documentation and comment contracts

* no-mistakes(document): Clarify lab-home gate documentation and remove stale claims

* no-mistakes(document): Clarify gate lab-home documentation and boundary wording
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…henguid#5638)

* feat(tests): add FM_TEST_SEAM launch seam and gate lab-primary recipe

Part 1 of the kunchenguid#5615 split: the pieces that let the no-mistakes pipeline
live-validate firstmate changes, without the gate-refusal rescoping.

- bin/fm-afk-launch.sh: FM_TEST_HARNESS pins the detected harness only
  alongside the FM_TEST_SEAM=1 marker test suites set, so a leaked variable
  in a real primary's environment stays inert and unknown tokens fall
  through to real detection.
- tests/lib.sh: export FM_TEST_SEAM=1 for every suite.
- .no-mistakes.yaml: per-harness recipe for running a real fixture primary
  from a gate run - a plain mktemp lab FM_HOME on a private tmux socket,
  with FM_GATE_REFUSE_BYPASS=1 scoped to it and NO_MISTAKES_GATE scrubbed.
- tests/fm-wake-queue.test.sh: stop the owned watcher fixture with KILL and
  clear its lifecycle state so the next leg starts clean; TERM could leave
  bash waiting in a child on some runners.
- tests/fm-remote-secondmate-lifecycle-e2e.test.sh: wait for the liveness
  lock holder's post-acquire marker instead of the lock dir, which is
  published before the claim finishes.

* no-mistakes(review): Scrub lab home overrides and require FM_TEST_SEAM separately

* no-mistakes(document): Clarify test seam and disposable lab bypass documentation

* no-mistakes(document): Clarify lab isolation and test-seam documentation

* no-mistakes(ci): Fixed the CI failure: test cleanup killed the remote worker child but left its supervisor able to restart it during fixture removal. Cleanup now stops the worker tree. The lifecycle test passed locally; ShellCheck and diff checks passed
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…enguid#5635)

* fix(bin): let gate agents drive lifecycle against marked lab homes

Part 2 of the kunchenguid#5615 split. A no-mistakes gate agent runs inside a
checkout carrying the fleet-captain identity, so fm-gate-refuse-lib
refuses fleet mutation on the gate signal. That refusal was absolute,
which kept gate validation from ever exercising the real lifecycle.

Stamp a disposable lab FM_HOME with a .fm-lab-home marker file that
only bin/fm-lab-home.sh writes, and only onto a fresh empty dir, so
no call path can mark a populated real home. fm_refuse_if_gate_agent
then permits lifecycle only when FM_HOME carries the marker and is
driven through its stock layout - any FM_*_OVERRIDE relocation stays
refused so part of the "lab" cannot be split back onto the real fleet.
The threat model is a confused agent touching the real fleet, not
deliberate forgery, so the marker is a plain token file rather than a
bound record. FM_GATE_REFUSE_BYPASS is unchanged: it still serves the
test harness, which cannot mark hundreds of temp homes.

Teardown's slot-ownership scan compared state-dir paths textually
while fm_firstmate_root_home canonicalizes, so a lab home under a
symlinked TMPDIR scanned its own record twice and self-collided;
compare file identity (-ef) instead.

* no-mistakes(review): Refuse unlistable lab homes and hardlinked slot records

* no-mistakes(review): Mint lab markers only on verified-empty fresh dirs

* no-mistakes(document): Clarify lab-home gate documentation and comment contracts

* no-mistakes(document): Clarify lab-home gate documentation and remove stale claims

* no-mistakes(document): Clarify gate lab-home documentation and boundary wording
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…henguid#5638)

* feat(tests): add FM_TEST_SEAM launch seam and gate lab-primary recipe

Part 1 of the kunchenguid#5615 split: the pieces that let the no-mistakes pipeline
live-validate firstmate changes, without the gate-refusal rescoping.

- bin/fm-afk-launch.sh: FM_TEST_HARNESS pins the detected harness only
  alongside the FM_TEST_SEAM=1 marker test suites set, so a leaked variable
  in a real primary's environment stays inert and unknown tokens fall
  through to real detection.
- tests/lib.sh: export FM_TEST_SEAM=1 for every suite.
- .no-mistakes.yaml: per-harness recipe for running a real fixture primary
  from a gate run - a plain mktemp lab FM_HOME on a private tmux socket,
  with FM_GATE_REFUSE_BYPASS=1 scoped to it and NO_MISTAKES_GATE scrubbed.
- tests/fm-wake-queue.test.sh: stop the owned watcher fixture with KILL and
  clear its lifecycle state so the next leg starts clean; TERM could leave
  bash waiting in a child on some runners.
- tests/fm-remote-secondmate-lifecycle-e2e.test.sh: wait for the liveness
  lock holder's post-acquire marker instead of the lock dir, which is
  published before the claim finishes.

* no-mistakes(review): Scrub lab home overrides and require FM_TEST_SEAM separately

* no-mistakes(document): Clarify test seam and disposable lab bypass documentation

* no-mistakes(document): Clarify lab isolation and test-seam documentation

* no-mistakes(ci): Fixed the CI failure: test cleanup killed the remote worker child but left its supervisor able to restart it during fixture removal. Cleanup now stops the worker tree. The lifecycle test passed locally; ShellCheck and diff checks passed
ashkonmousavi added a commit to ashkonmousavi/firstmate that referenced this pull request Sep 26, 2026