Skip to content

feat(bin): promote agy to a full primary and secondmate harness - #7941

Merged
kunchenguid merged 6 commits into
kunchenguid:mainfrom
nogoo9:fm/agy-full-harness
Oct 29, 2026
Merged

kunchenguid merged 6 commits into
kunchenguid:mainfrom
nogoo9:fm/agy-full-harness

Conversation

@eterna2

@eterna2 eterna2 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Promote Antigravity CLI (agy) in Firstmate from a crewmate/scout-only adapter to a full Firstmate harness supporting Primary Supervisor, Persistent Secondmate (--secondmate agy), and Crewmate/Scout roles.

Requirements and design decisions:

  • Understand how other primary and secondmate harnesses (Claude Code, Codex, Cursor, OpenCode, Grok, OMP, Pi) are wired in Firstmate, write comprehensive unit/integration and live E2E test suites first, and ensure every portable and live E2E test passes against agy 1.4.9.
  • Ship tracked project-local hooks in .agents/hooks.json using Antigravity 1.4.9's named hook spec ({"firstmate":{...}}), wiring SessionStart to bin/fm-sessionstart-agy.sh, PreToolUse (run_command|bash|Bash and .* matchers) to bin/fm-arm-pretool-check.sh --agy, bin/fm-cd-pretool-check.sh --agy, and bin/fm-subagent-pretool-check.sh --agy, and Stop (with timeout: 28800) to bin/fm-turnend-guard-agy.sh, with Windows cmd /c-safe sh -c "..." || cd . command wrappers.
  • Implement SessionStart run-tier startup digest delivery in bin/fm-sessionstart-agy.sh via {"injectSteps":[{"systemMessage":{"systemMessage":...}}]} JSON with {} fail-open and worker/gate-worktree skip guards.
  • Implement Stop-hook parked supervision in bin/fm-turnend-guard-agy.sh and bin/fm-turnend-guard.sh --agy using autoarm supervision semantics (polling a tracked background bin/fm-watch-arm.sh or bin/fm-supervision-host.sh park child, with supersession, session-lock ownership, NO_TOOL_CALL termination filtering, and loop-ceiling checks) and emitting {"decision":"continue","reason":...} JSON on stdout when continuing or {} when allowing stop.
  • Extend bin/fm-arm-pretool-check.sh, bin/fm-cd-pretool-check.sh, and bin/fm-subagent-pretool-check.sh with --agy transport flags exiting 0 and emitting {"decision":"deny","reason":...} JSON on stdout for blocked tool calls.
  • Extend bin/fm-session-lock-lib.sh (agy ancestor recognition), bin/fm-wake-lib.sh (agy autoarm supervision model), bin/fm-control-lib.sh (agy in primary/secondmate adapter lists), bin/fm-afk-launch.sh (agy in fm_afk_launch_host_primary), bin/fm-agy-trust.sh (--secondmate-home workspace trust pre-registration), bin/fm-spawn.sh (--secondmate agy trust pre-seeding), and bin/fm-supervision-instructions.sh (--harness agy protocol rendering from docs/supervision-protocols/agy.md and docs/supervision-protocols/supervision-host.md).
  • Update documentation and audience inventory (AGENTS.md, .agents/skills/harness-adapters/*, docs/supervision-protocols/*, docs/supervision-host.md, docs/verification/agy.md, docs/sessionstart-nudge.md, docs/turnend-guard.md, docs/arm-pretool-check.md, docs/subagent-guard.md, docs/documentation-audiences.json, and docs/fm-test-portable-shards.md) and register tests/fm-agy-primary.test.sh and tests/fm-agy-primary-live-e2e.test.sh in bin/fm-test-run.sh.

What Changed

  • Adds tracked project-local agy hooks in .agents/hooks.json using the live-verified {"firstmate":{...}} named hook spec and Windows cmd /c-safe sh -c "..." || cd . commands. SessionStart runs bin/fm-sessionstart-agy.sh, delivering the startup digest via injectSteps[].systemMessage.systemMessage, failing open with {}, and skipping worker and gate worktrees. The PreToolUse hooks call fm-arm-pretool-check.sh, fm-cd-pretool-check.sh, and fm-subagent-pretool-check.sh with --agy, blocking disallowed tool calls by printing {"decision":"deny","reason":...} and exiting 0. Stop runs bin/fm-turnend-guard-agy.sh (and fm-turnend-guard.sh --agy), parking on a tracked background fm-watch-arm.sh / fm-supervision-host.sh park cycle and returning {"decision":"continue","reason":...} on actionable wakes or repair notices.
  • Lets agy run as a primary and as a --secondmate: the session-lock, wake, away-launch (fm_afk_launch_host_primary), and control libraries accept agy as a primary/secondmate adapter. fm-agy-trust.sh gains --secondmate-home <home> <id> mode, which pre-registers workspace trust for a seeded secondmate home after checking its marker, ownership, and directory layout. fm-spawn.sh pre-seeds that trust for --secondmate agy, and fm-supervision-instructions.sh --harness agy renders docs/supervision-protocols/agy.md and docs/supervision-protocols/supervision-host.md.
  • Adds portable tests (tests/fm-agy-primary.test.sh) and live E2E tests (tests/fm-agy-primary-live-e2e.test.sh) and registers both in bin/fm-test-run.sh. Updates the README, AGENTS.md, harness-adapter skill references, hook/guard docs, docs/supervision-host.md, docs/verification/agy.md, and the documentation audience inventory to show agy as a verified primary and secondmate harness.

Risk Assessment

🟢 Low:
All hook schemas, JSON payload contracts (injectSteps, decision: "continue", decision: "deny"), Stop-hook watcher parking (fm-watch-arm.sh / fm-supervision-host.sh park), and --secondmate agy trust pre-seeding are verified both by portable behavior suites (tests/fm-agy-primary.test.sh, tests/fm-afk-launch.test.sh) and end-to-end against the real agy 1.4.9 binary (tests/fm-agy-primary-live-e2e.test.sh, tests/fm-agy-signals-live-e2e.test.sh).

Testing

I ran the 4 targeted portable suites, the coverage check and the doc-audience check, and all exited 0. They use fixtures rather than the live product, so they are not counted as live validation. Both live E2E suites passed against the real agy 1.4.9 binary. The primary suite covered SessionStart digest injection and lock, a PreToolUse deny with positive BLOCKED/[watcher-direct] evidence, the Stop-hook park, and the --secondmate agy launch with pre-seeded trust. The signals suite covered busy-footer detection, launch-prompt processing, the Escape cancel and /quit. I also ran a short fm-lab tmux agy primary from the gate worktree under an isolated HOME. Isolating HOME meant the operator's real ~/.gemini trust store was never written. The run confirmed the linked-worktree skip guard: the hook returned no digest and wrote no state, and the session kept working. The lab was torn down in the same turn and the worktree is clean. This is a CLI/hook change with no rendered UI, so the evidence is CLI transcripts and tmux pane captures.

  • Live validation: ✅ go - 6 of 7 scenarios driven live against the product
Scenario Result Live Evidence
agy primary session start in a Firstmate home injects the run-tier digest into model context and takes state/.lock ✅ pass live live-primary-run2.log: 'ok - agy primary live: SessionStart hook acquires lock and injects digest into live model context'
agy primary trying to run bin/fm-watch.sh directly is denied by the PreToolUse --agy hook with BLOCKED/[watcher-direct] ✅ pass live live-primary-run2.log: 'ok - agy primary live: PreToolUse --agy deny blocks a direct watcher command'
agy primary turn end with supervision needed parks in the Stop hook and records the park owner ✅ pass live live-primary-run2.log: 'ok - agy primary live: Stop hook parks the turn boundary while supervision is needed'
--secondmate agy with pre-seeded workspace trust launches straight into the secondmate home's digest with no trust dialog ✅ pass live live-primary-run2.log: 'ok - agy secondmate live: pre-seeded workspace trust launches straight into the secondmate home's digest'
Real agy worker busy footer, Escape cancel and /quit signals are recognized ✅ pass live live-signals-run2.log (exit 0, no 'not ok' lines)
Adversarial: agy primary launched from a linked/gate worktree gets no digest, takes no lock and does not park, and the session stays usable ✅ pass live fm-lab-agy-primary-worktree-standdown.txt: model answered NONE, $LAB/state empty, direct hook run printed {}
Portable hook transports, supervision rendering, turn-end guard, test-runner registration and doc audience inventory ⏸️ untested no The prior payload did not establish a live result for this scenario. The portable suites, coverage check and doc-audience check exited 0, but they ran against fixtures rather than the live product. Th…
Evidence: Live agy primary E2E transcript (SessionStart, PreToolUse deny, Stop park, secondmate trust launch)

Source: Live agy primary E2E transcript (SessionStart, PreToolUse deny, Stop park, secondmate trust launch)

ok - agy primary live: SessionStart hook acquires lock and injects digest into live model context
ok - agy primary live: PreToolUse --agy deny blocks a direct watcher command
ok - agy primary live: Stop hook parks the turn boundary while supervision is needed
ok - agy secondmate live: pre-seeded workspace trust launches straight into the secondmate home's digest
exit 0
Evidence: Live agy signals E2E transcript

Source: Live agy signals E2E transcript

ok - the real agy busy footer matches fm_busy_agy_tail_busy in flight
ok - the real agy worker processed its launch prompt
ok - a single Escape cancels the real agy turn
ok - /quit stops the real agy process
exit 0
Evidence: fm-lab agy primary in gate worktree: SessionStart stand-down pane capture

Source: fm-lab agy primary in gate worktree: SessionStart stand-down pane capture

# fm-lab agy 1.4.9 primary launched from gate worktree (linked worktree), FM_HOME=/tmp/fm-lab.7FWWIf, isolated HOME
      ▄▀▀▄        Antigravity CLI 1.4.9
     ▀▀▀▀▀▀       [email protected] (Google AI Ultra)
    ▀▀▀▀▀▀▀▀      Gemini 4 Argon (Medium)
   ▄▀▀    ▀▀▄     ~/.no-mistakes/worktrees/b9f183dd9296/01M62E40FHVHP52DDH147NQB01
  ▄▀▀      ▀▀▄
────────────────────────────────────────────────────────────
> Without running any tools, quote the first line of any Firstmate startup digest or system message you were given at session start, or say NONE.
▸ Thought for 7s, 138 tokens
  NONE.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
>
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
? for shortcuts                                                                                                                                                                  Gemini 4 Argon · medium
# state dir after turn:
# direct hook run in same worktree:
{}
Evidence: Portable agy primary suite output

Source: Portable agy primary suite output

1..14
ok - .agents/hooks.json: valid JSON and hook commands resolve from both .agents/ and repo root
warning: re-init: ignored --initial-branch=main
ok - fm-sessionstart-agy: runs in primary and seeded secondmate homes, stands down with {} in crewmate worktree
ok - fm-turnend-guard-agy: actionable arm close returns continue decision and resets turnend-blocks
ok - fm-turnend-guard-agy: an opted-in home parks on the supervision host with the agy pin
ok - fm-turnend-guard-agy: park timeout stops the arm and returns continue with [supervision-park]
ok - fm-turnend-guard-agy: returns {} when the fleet is empty or a healthy watcher owns the home
ok - fm-turnend-guard-agy: non-normal terminationReason values pass through with {}
ok - fm-turnend-guard-agy: the loop ceiling notifies once while supervision is needed, then passes through
ok - fm-turnend-guard-agy: superseded park owner returns {}
ok - fm-turnend-guard --agy & fm-turnend-guard-agy: bounded repair nag blocks 3 times then fails open with {}
ok - fm-arm-pretool-check --agy: denies through the shared policy and allows ordinary commands
warning: re-init: ignored --initial-branch=main
ok - fm-cd-pretool-check --agy: denies persistent cd in primary, allows subshell cd, inert in worktree
warning: re-init: ignored --initial-branch=main
ok - fm-subagent-pretool-check --agy: denies invoke_subagent, allows observe-only tools, inert in worktree
ok - session-lock & supervision model: agy ancestry, autoarm model, and supervision instructions verified
FM_TEST_COMPLETE
exit 0
Evidence: Portable agy harness suite output

Source: Portable agy harness suite output

ok - fm-harness.sh: ancestry detects a natively-named agy command
ok - fm-harness.sh: ancestry rejects unrelated agy mentions
ok - fm-harness.sh: no inherited launcher marker claims the agy identity
ok - fm-control-lib: agy mechanics are Escape once, no clear key, and /quit
ok - fm-busy-lib: only the pinned esc-to-cancel row carries the agy busy verdict
ok - fm-composer-lib: agy delivery signatures never cross harnesses
ok - fm-busy-lib: agy classifies busy on its marker and unknown without it
ok - bin/fm-agent-process-lib.sh: agy is an agent, fragments are not
ok - herdr exit detection: done with a live registry and an agy process view stays live and refuses replacement
ok - herdr exit detection: a registered status over a shell-only pane is stale-agent and still refuses closing
ok - herdr exit detection: a registered pane with an agy foreground stays live however its shell ranks
ok - herdr exit detection: only a positively unregistered pane is agent-free
ok - herdr exit detection: malformed and failed reads stay unknown
ok - fm-spawn: agy launch carries brief, model, effort, and autonomy with cleared markers
ok - fm-spawn: agy omits xhigh from the launch but records it in task metadata
ok - fm-spawn: an unlisted agy model refuses before pane creation
ok - fm-spawn: an unreachable agy listing establishes nothing and launches
ok - fm-spawn: a hung agy listing is cut off by the shared bound and launches unvalidated
ok - fm-spawn: a zero FM_AGY_MODELS_TIMEOUT is clamped to the default bound
ok - fm-agy-trust.sh: registers the logical and resolved worktree paths and preserves the store
ok - fm-agy-trust.sh: creates agy's settings store when none exists
ok - fm-agy-trust.sh: refuses every out-of-scope path and never rewrites a broken store
ok - fm-spawn: agy pre-registers the worktree and launches straight into a busy turn
ok - fm-spawn: agy answers a dialog that renders anyway exactly once, then confirms busy
ok - fm-spawn: on an unregistered path a premature busy verdict waits for the dialog to be answered
ok - fm-spawn: a busy verdict on an unregistered path without a dialog fails and closes the endpoint
ok - fm-spawn: an agy dialog that never turns busy fails the spawn and closes the endpoint
ok - fm-spawn: a missing agy executable refuses before pane creation
ok - fm-spawn: agy secondmate pre-trusts the secondmate home and records kind=secondmate
ok - fm-spawn: agy arms no busy wiring and writes no sidecar
exit 0
- Outcome: 🔧 1 issue found → no changes applied ✅ across 2 runs (43m32s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 3 issues (1 error, 2 warnings)
  • 🚨 bin/fm-turnend-guard-agy.sh:91 - The Stop-hook park calls bin/fm-watch.sh --timeout N directly and branches on exit codes 0, 2 and 3. The real bin/fm-watch.sh does not parse --timeout (it ignores arguments). It never exits 2 or 3, and it exits 0 with watcher: already running pid N whenever another watcher holds state/.watch.lock (bin/fm-watch.sh:3365-3390). Concrete paths: (a) a watcher is already running, so rc=0 and the hook returns {decision:continue, reason:'watcher: already running pid N'}. That fakes a wake, starts a new turn, and loops until the executionNum ceiling. (b) No watcher is running, so fm-watch.sh blocks with no bound until a wake arrives. The 360s hooks.json timeout kills the hook, which bypasses the 2→re-park and 3→fleet-empty branches entirely. Those branches are dead code. tests/fm-agy-primary.test.sh:103-150 stubs fm-watch.sh with invented exit codes, so the suite cannot catch this. The park also bypasses bin/fm-watch-arm.sh (the arm-command policy says fm-watch.sh must not be run directly; docs/supervision-protocols/agy.md:28 claims the hook runs fm-watch-arm.sh). Fix: park on bin/fm-watch-arm.sh, or on bin/fm-supervision-host.sh when the host is enabled, the way bin/fm-turnend-guard-cursor.sh:317-335 does. Bound the park with its own timer and classify outcomes from the arm's output rather than invented exit codes. Rewrite the tests to use the real watcher contract.
  • 🚨 bin/fm-sessionstart-agy.sh:47 - Several required intent constraints are contradicted. (1) Intent: SessionStart delivers the digest 'via hookSpecificOutput.additionalContext JSON'. The diff emits {injectSteps:[{systemMessage:{systemMessage:$msg}}]} (bin/fm-sessionstart-agy.sh:47). (2) Intent: the Stop hook translates non-empty stdout 'to decision: block JSON on stdout'. The diff emits {decision:&#34;continue&#34;,reason:...} (bin/fm-turnend-guard-agy.sh wake/timeout branches; bin/fm-turnend-guard.sh block_stop agy branch). (3) Intent: the --agy pretool checks emit 'permissionDecision: deny on stdout'. The diff emits {decision:&#34;deny&#34;,reason:...} (bin/fm-arm-pretool-check.sh:198,233; bin/fm-cd-pretool-check.sh:198; bin/fm-subagent-pretool-check.sh:217). (4) Intent: the PreToolUse matchers are 'run_command and invoke_subagent'. .agents/hooks.json:17 uses run_command|bash|Bash and :32 uses .*, so the subagent guard runs on every tool call. The shapes the author used may reflect verified agy 1.4.9 behaviour, but they conflict with the stated acceptance criteria, so a human needs to decide which is authoritative.
  • ⚠️ bin/fm-supervision-instructions.sh:745 - agy was added to the host-snippet harness list, and docs/supervision-protocols/supervision-host.md:4 now tells an agy primary that 'The Stop-hook park runs the supervision host in the arm's place' and that 'Only a wake the host hands back reaches you'. bin/fm-turnend-guard-agy.sh never checks fm_supervision_host_enabled and never runs bin/fm-supervision-host.sh. On a home with config/supervision-host, the rendered protocol (and the agy repair line at bin/fm-supervision-instructions.sh:229-234) therefore describes a host that never runs. Either run the host from the park as the Cursor guard does, or drop agy from the host lists.
  • ⚠️ bin/fm-inbox.sh:895 - agy now maps to the autoarm supervision model in fm_supervision_model (bin/fm-wake-lib.sh:289) and in bin/fm-spawn.sh:7019. bin/fm-inbox.sh's lock-holder model resolution still maps only claude|cursor to autoarm, so an agy lock holder resolves to persistent. The inbox consumer verdict for an agy primary or secondmate home then demands a live watcher process instead of the autoarm fresh-beacon rule, and reports supervision unhealthy between parks. Add agy to that case.
  • ⚠️ bin/fm-arm-pretool-check.sh:187 - The new agy-only 'manual-arm-redundant' deny is not required by the intent, which asks only for a --agy transport flag. It matches *fm-watch-arm.sh* anywhere in the command string. While a watcher is healthy, it therefore also denies bin/fm-watch-arm.sh --stop, --restart, --take-over, and read-only commands such as cat bin/fm-watch-arm.sh or git log -- bin/fm-watch-arm.sh, before the shared policy (bin/fm-arm-command-policy.mjs) classifies them. Recommend removing this agy-specific branch and leaving classification to the shared policy.
  • ⚠️ bin/fm-turnend-guard-agy.sh:64 - When executionNum reaches the ceiling (default 4), the hook returns {} before checking whether supervision is needed. It neither parks nor routes through the bounded repair nag. If executionNum counts consecutive hook-continued turns, then after about 4 park cycles with crewmates still in flight the turn ends with no watcher. This is the 'turn would end blind' state the guard exists to prevent, and it happens silently. The ceiling semantics and the fallback (for example, delegating to fm-turnend-guard.sh --agy) need a product decision.
  • ⚠️ tests/fm-agy-primary-live-e2e.test.sh:52 - Intent requires comprehensive live E2E suites against agy 1.4.9. The live test only exercises SessionStart digest injection. It never drives the Stop-hook park, the PreToolUse denies, or a --secondmate agy launch against a real agy binary, which is why the fm-watch.sh exit-code mismatch above went undetected. It also hardcodes --model gemini-3.8-flash-low.
  • ⚠️ bin/fm-spawn.sh:6584 - New fallbacks resolve fm-git-strip-ai-trailers.sh (and fm-agy-trust.sh at :5729-5730) from $SCRIPT_DIR when $FM_ROOT/bin lacks the script. The strip-hook fallback applies to every harness and no intent requirement needs it; it appears to exist only for the test fixture's FM_ROOT_OVERRIDE=''. Recommend removing it, or narrowing it to what the agy secondmate path strictly needs.
  • ℹ️ bin/fm-subagent-pretool-check.sh:162 - The new case managesubagents|managetask) exit 0 duplicates the OBSERVE_ONLY_TOOLS entries added at :66. The manage_subagents/manage_task entries can never match, because NORMALIZED strips underscores (:151). Keep only managesubagents managetask in OBSERVE_ONLY_TOOLS and drop the extra case block.
  • ℹ️ docs/supervision-protocols/agy.md:13 - Several doc claims do not match the code. agy.md:13 says the park 'polls at FM_AGY_PARK_POLL seconds up to FM_AGY_PARK_TIMEOUT', but the code uses a single value with POLL overriding TIMEOUT. agy.md:28 says the hook runs fm-watch-arm.sh as its tracked child, but it runs fm-watch.sh. docs/sessionstart-nudge.md:377 says the wrapper sources fm-primary-scope-lib.sh and captures output from fm-session-start.sh, but it only calls fm-sessionstart-run.sh, which owns scope. docs/arm-pretool-check.md and docs/subagent-guard.md describe the decision:deny shape, which conflicts with the intent's permissionDecision shape.

🔧 Fix applied.
9 issues (2 errors, 6 warnings, 1 info) still open:

  • 🚨 bin/fm-turnend-guard-agy.sh:91 - The Stop-hook park calls bin/fm-watch.sh --timeout N directly and branches on exit codes 0, 2 and 3. The real bin/fm-watch.sh does not parse --timeout (it ignores arguments). It never exits 2 or 3, and it exits 0 with watcher: already running pid N whenever another watcher holds state/.watch.lock (bin/fm-watch.sh:3365-3390). Concrete paths: (a) a watcher is already running, so rc=0 and the hook returns {decision:continue, reason:'watcher: already running pid N'}. That fakes a wake, starts a new turn, and loops until the executionNum ceiling. (b) No watcher is running, so fm-watch.sh blocks with no bound until a wake arrives. The 360s hooks.json timeout kills the hook, which bypasses the 2→re-park and 3→fleet-empty branches entirely. Those branches are dead code. tests/fm-agy-primary.test.sh:103-150 stubs fm-watch.sh with invented exit codes, so the suite cannot catch this. The park also bypasses bin/fm-watch-arm.sh (the arm-command policy says fm-watch.sh must not be run directly; docs/supervision-protocols/agy.md:28 claims the hook runs fm-watch-arm.sh). Fix: park on bin/fm-watch-arm.sh, or on bin/fm-supervision-host.sh when the host is enabled, the way bin/fm-turnend-guard-cursor.sh:317-335 does. Bound the park with its own timer and classify outcomes from the arm's output rather than invented exit codes. Rewrite the tests to use the real watcher contract.
  • 🚨 bin/fm-sessionstart-agy.sh:47 - Several required intent constraints are contradicted. (1) Intent: SessionStart delivers the digest 'via hookSpecificOutput.additionalContext JSON'. The diff emits {injectSteps:[{systemMessage:{systemMessage:$msg}}]} (bin/fm-sessionstart-agy.sh:47). (2) Intent: the Stop hook translates non-empty stdout 'to decision: block JSON on stdout'. The diff emits {decision:&#34;continue&#34;,reason:...} (bin/fm-turnend-guard-agy.sh wake/timeout branches; bin/fm-turnend-guard.sh block_stop agy branch). (3) Intent: the --agy pretool checks emit 'permissionDecision: deny on stdout'. The diff emits {decision:&#34;deny&#34;,reason:...} (bin/fm-arm-pretool-check.sh:198,233; bin/fm-cd-pretool-check.sh:198; bin/fm-subagent-pretool-check.sh:217). (4) Intent: the PreToolUse matchers are 'run_command and invoke_subagent'. .agents/hooks.json:17 uses run_command|bash|Bash and :32 uses .*, so the subagent guard runs on every tool call. The shapes the author used may reflect verified agy 1.4.9 behaviour, but they conflict with the stated acceptance criteria, so a human needs to decide which is authoritative.
  • ⚠️ bin/fm-supervision-instructions.sh:745 - agy was added to the host-snippet harness list, and docs/supervision-protocols/supervision-host.md:4 now tells an agy primary that 'The Stop-hook park runs the supervision host in the arm's place' and that 'Only a wake the host hands back reaches you'. bin/fm-turnend-guard-agy.sh never checks fm_supervision_host_enabled and never runs bin/fm-supervision-host.sh. On a home with config/supervision-host, the rendered protocol (and the agy repair line at bin/fm-supervision-instructions.sh:229-234) therefore describes a host that never runs. Either run the host from the park as the Cursor guard does, or drop agy from the host lists.
  • ⚠️ bin/fm-turnend-guard-agy.sh:64 - When executionNum reaches the ceiling (default 4), the hook returns {} before checking whether supervision is needed. It neither parks nor routes through the bounded repair nag. If executionNum counts consecutive hook-continued turns, then after about 4 park cycles with crewmates still in flight the turn ends with no watcher. This is the 'turn would end blind' state the guard exists to prevent, and it happens silently. The ceiling semantics and the fallback (for example, delegating to fm-turnend-guard.sh --agy) need a product decision.
  • ⚠️ tests/fm-agy-primary-live-e2e.test.sh:52 - Intent requires comprehensive live E2E suites against agy 1.4.9. The live test only exercises SessionStart digest injection. It never drives the Stop-hook park, the PreToolUse denies, or a --secondmate agy launch against a real agy binary, which is why the fm-watch.sh exit-code mismatch above went undetected. It also hardcodes --model gemini-3.8-flash-low.
  • ⚠️ .agents/hooks.json:2 - This is an intent-conformance question. The intent says to 'Ship tracked project-local hooks in .agents/hooks.json (version 1)', and the recorded human decision says to keep the .agents/hooks.json matchers 'unchanged'. Fix round 418a5af nonetheless replaced {&#34;version&#34;:1,&#34;hooks&#34;:{...}} with a single named spec {&#34;firstmate&#34;:{...}}. It also flattened SessionStart and Stop to bare handler lists while PreToolUse keeps the matcher/hooks groups. The fixer justifies this in .agents/skills/harness-adapters/references/harness/agy.md:54 ('any other top-level key, such as a version field, silently disables the whole file (verified live)'). The unit test at tests/fm-agy-primary.test.sh:198-205 was rewritten in the same round to assert the new shape, so it is not independent evidence. A human needs to confirm whether the live-verified agy 1.4.9 schema supersedes the 'version 1' wording in the intent. If it does not, revert the shape to the original version-1 file.
  • ⚠️ bin/fm-turnend-guard-agy.sh:144 - PARK_TIMEOUT (330s) is reset for each arm attempt (waited=0 sits inside the attempt loop at :134-144), and ARM_ATTEMPTS=2. The hook timeout in .agents/hooks.json is 360s. Concrete case: attempt 1 attaches to an existing cycle, and after about 300s fm-watch-arm.sh exits with 'FAILED - attached watcher ... stalled' or 'cycle ended without an actionable reason'. If no healthy watcher remains, attempt 2 starts with another 330s budget. agy then kills the hook mid-park, at about 360s, before it can emit the [supervision-park] continue or reach the repair nag. The EXIT trap may not run, leaving the arm child and .agy-park-output.* behind. This defect is in code added by fix round 418a5af, which ported the Cursor park loop but added a per-attempt bound. The Cursor guard has no hook-timeout budget, so it never needed one. Fix: compute one deadline before the attempt loop (for example DEADLINE=$((SECONDS + PARK_TIMEOUT))) and check SECONDS -ge DEADLINE in the poll loop. Skip the retry when too little budget remains.
  • ⚠️ bin/fm-turnend-guard-agy.sh:154 - Every idle park timeout returns {decision:&#34;continue&#34;,reason:&#34;[supervision-park] ...&#34;}, which forces another hook-driven turn and raises executionNum. LOOP_CEILING defaults to 4 (:48). Cursor's equivalent ceiling defaults to 180. Concrete case: a primary has crewmates in flight for an hour and no wakes arrive. Parks 1-3 time out (about 330s each), executionNum 4 gets the one-time 'CEILING REACHED' notice (:103), and executionNum 5 returns {}. From then on no Stop-hook park delivers wakes until the captain sends a message, so supervision goes dark after about 20 minutes of quiet. The original commit used the same &lt; 4 ceiling, and fix round 418a5af kept it while adding the notice. Whether timeout re-parks should count toward the ceiling, or whether the ceiling should be raised (and to what agy's forced-invocation cap allows), is a product decision.
  • ℹ️ tests/fm-agy-primary-live-e2e.test.sh:92 - The live PreToolUse deny check, added in fix round 418a5af, only asserts that state/live-deny-ran is absent. That also passes when the model declines or never issues the command, so a broken or unregistered PreToolUse hook still passes. Also assert that the output carries the deny evidence: BLOCKED together with the [watcher-direct] reason code that the hook returns.

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

  • 🚨 bin/fm-sessionstart-agy.sh:47 - Several required intent constraints are contradicted. (1) Intent: SessionStart delivers the digest 'via hookSpecificOutput.additionalContext JSON'. The diff emits {injectSteps:[{systemMessage:{systemMessage:$msg}}]} (bin/fm-sessionstart-agy.sh:47). (2) Intent: the Stop hook translates non-empty stdout 'to decision: block JSON on stdout'. The diff emits {decision:&#34;continue&#34;,reason:...} (bin/fm-turnend-guard-agy.sh wake/timeout branches; bin/fm-turnend-guard.sh block_stop agy branch). (3) Intent: the --agy pretool checks emit 'permissionDecision: deny on stdout'. The diff emits {decision:&#34;deny&#34;,reason:...} (bin/fm-arm-pretool-check.sh:198,233; bin/fm-cd-pretool-check.sh:198; bin/fm-subagent-pretool-check.sh:217). (4) Intent: the PreToolUse matchers are 'run_command and invoke_subagent'. .agents/hooks.json:17 uses run_command|bash|Bash and :32 uses .*, so the subagent guard runs on every tool call. The shapes the author used may reflect verified agy 1.4.9 behaviour, but they conflict with the stated acceptance criteria, so a human needs to decide which is authoritative.
  • ⚠️ bin/fm-supervision-instructions.sh:745 - agy was added to the host-snippet harness list, and docs/supervision-protocols/supervision-host.md:4 now tells an agy primary that 'The Stop-hook park runs the supervision host in the arm's place' and that 'Only a wake the host hands back reaches you'. bin/fm-turnend-guard-agy.sh never checks fm_supervision_host_enabled and never runs bin/fm-supervision-host.sh. On a home with config/supervision-host, the rendered protocol (and the agy repair line at bin/fm-supervision-instructions.sh:229-234) therefore describes a host that never runs. Either run the host from the park as the Cursor guard does, or drop agy from the host lists.
  • ⚠️ .agents/hooks.json:2 - This is an intent-conformance question. The intent says to 'Ship tracked project-local hooks in .agents/hooks.json (version 1)', and the recorded human decision says to keep the .agents/hooks.json matchers 'unchanged'. Fix round 418a5af nonetheless replaced {&#34;version&#34;:1,&#34;hooks&#34;:{...}} with a single named spec {&#34;firstmate&#34;:{...}}. It also flattened SessionStart and Stop to bare handler lists while PreToolUse keeps the matcher/hooks groups. The fixer justifies this in .agents/skills/harness-adapters/references/harness/agy.md:54 ('any other top-level key, such as a version field, silently disables the whole file (verified live)'). The unit test at tests/fm-agy-primary.test.sh:198-205 was rewritten in the same round to assert the new shape, so it is not independent evidence. A human needs to confirm whether the live-verified agy 1.4.9 schema supersedes the 'version 1' wording in the intent. If it does not, revert the shape to the original version-1 file.
  • ℹ️ docs/verification/agy.md:162 - Fix round 941141c made the park unbounded by default (FM_AGY_PARK_TIMEOUT now defaults to 0, under the 28800s hook timeout). It updated docs/supervision-protocols/agy.md, docs/turnend-guard.md and the harness-adapters agy reference, but left this sibling behind. The line still says the park runs 'until woken by an incoming event or its bounded park timeout', which implies a default bound that no longer exists. Reword it to say the park waits under the 28800s hook timeout and is bounded only when the optional FM_AGY_PARK_TIMEOUT is set. No other stale references remain: grepping for 'default 330', '360s' and 'default 4)' finds nothing.

🔧 Fix applied.
3 issues (1 error, 2 warnings) still open:

  • 🚨 bin/fm-sessionstart-agy.sh:47 - Several required intent constraints are contradicted. (1) Intent: SessionStart delivers the digest 'via hookSpecificOutput.additionalContext JSON'. The diff emits {injectSteps:[{systemMessage:{systemMessage:$msg}}]} (bin/fm-sessionstart-agy.sh:47). (2) Intent: the Stop hook translates non-empty stdout 'to decision: block JSON on stdout'. The diff emits {decision:&#34;continue&#34;,reason:...} (bin/fm-turnend-guard-agy.sh wake/timeout branches; bin/fm-turnend-guard.sh block_stop agy branch). (3) Intent: the --agy pretool checks emit 'permissionDecision: deny on stdout'. The diff emits {decision:&#34;deny&#34;,reason:...} (bin/fm-arm-pretool-check.sh:198,233; bin/fm-cd-pretool-check.sh:198; bin/fm-subagent-pretool-check.sh:217). (4) Intent: the PreToolUse matchers are 'run_command and invoke_subagent'. .agents/hooks.json:17 uses run_command|bash|Bash and :32 uses .*, so the subagent guard runs on every tool call. The shapes the author used may reflect verified agy 1.4.9 behaviour, but they conflict with the stated acceptance criteria, so a human needs to decide which is authoritative.
  • ⚠️ bin/fm-supervision-instructions.sh:745 - agy was added to the host-snippet harness list, and docs/supervision-protocols/supervision-host.md:4 now tells an agy primary that 'The Stop-hook park runs the supervision host in the arm's place' and that 'Only a wake the host hands back reaches you'. bin/fm-turnend-guard-agy.sh never checks fm_supervision_host_enabled and never runs bin/fm-supervision-host.sh. On a home with config/supervision-host, the rendered protocol (and the agy repair line at bin/fm-supervision-instructions.sh:229-234) therefore describes a host that never runs. Either run the host from the park as the Cursor guard does, or drop agy from the host lists.
  • ⚠️ .agents/hooks.json:2 - This is an intent-conformance question. The intent says to 'Ship tracked project-local hooks in .agents/hooks.json (version 1)', and the recorded human decision says to keep the .agents/hooks.json matchers 'unchanged'. Fix round 418a5af nonetheless replaced {&#34;version&#34;:1,&#34;hooks&#34;:{...}} with a single named spec {&#34;firstmate&#34;:{...}}. It also flattened SessionStart and Stop to bare handler lists while PreToolUse keeps the matcher/hooks groups. The fixer justifies this in .agents/skills/harness-adapters/references/harness/agy.md:54 ('any other top-level key, such as a version field, silently disables the whole file (verified live)'). The unit test at tests/fm-agy-primary.test.sh:198-205 was rewritten in the same round to assert the new shape, so it is not independent evidence. A human needs to confirm whether the live-verified agy 1.4.9 schema supersedes the 'version 1' wording in the intent. If it does not, revert the shape to the original version-1 file.
🔧 **Test** - 1 issue found → no changes applied ✅
  • ⚠️ The Test agent did not finish within its invocation budget. Reported: agent run tests timed out after 30m0s: agent last produced output 2s ago (128 observed); agent reported: claude parse events: context deadline exceeded. This is a budget or provider-slowness cut, not a code failure. Re-running the same request costs another full budget, so no further attempt is made automatically. If this repository's targeted tests or evidence gathering routinely approach the default 30m0s, raise test_agent_timeout in global config. Respond with fix to spend another budget: a repair turn runs only for selected findings other than this budget cut, then validation re-runs. Or abort and retry after raising the budget.

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

  • Live validation: ✅ go - 6 of 7 scenarios driven live against the product
Scenario Result Live Evidence
agy primary session start in a Firstmate home injects the run-tier digest into model context and takes state/.lock ✅ pass live live-primary-run2.log: 'ok - agy primary live: SessionStart hook acquires lock and injects digest into live model context'
agy primary trying to run bin/fm-watch.sh directly is denied by the PreToolUse --agy hook with BLOCKED/[watcher-direct] ✅ pass live live-primary-run2.log: 'ok - agy primary live: PreToolUse --agy deny blocks a direct watcher command'
agy primary turn end with supervision needed parks in the Stop hook and records the park owner ✅ pass live live-primary-run2.log: 'ok - agy primary live: Stop hook parks the turn boundary while supervision is needed'
--secondmate agy with pre-seeded workspace trust launches straight into the secondmate home's digest with no trust dialog ✅ pass live live-primary-run2.log: 'ok - agy secondmate live: pre-seeded workspace trust launches straight into the secondmate home's digest'
Real agy worker busy footer, Escape cancel and /quit signals are recognized ✅ pass live live-signals-run2.log (exit 0, no 'not ok' lines)
Adversarial: agy primary launched from a linked/gate worktree gets no digest, takes no lock and does not park, and the session stays usable ✅ pass live fm-lab-agy-primary-worktree-standdown.txt: model answered NONE, $LAB/state empty, direct hook run printed {}
Portable hook transports, supervision rendering, turn-end guard, test-runner registration and doc audience inventory ⏸️ untested no The prior payload did not establish a live result for this scenario. The portable suites, coverage check and doc-audience check exited 0, but they ran against fixtures rather than the live product. Th…
  • ./tests/fm-agy-primary.test.sh
  • ./tests/fm-agy-harness.test.sh
  • ./tests/fm-supervision-instructions.test.sh
  • ./tests/fm-turnend-guard.test.sh
  • ./bin/fm-test-run.sh --check-coverage
  • ./bin/fm-doc-audience-check.sh
  • FM_AGY_PRIMARY_LIVE=1 ./tests/fm-agy-primary-live-e2e.test.sh
  • FM_AGY_SIGNALS_LIVE=1 ./tests/fm-agy-signals-live-e2e.test.sh
  • fm-lab tmux primary: bin/fm-lab-home.sh create $LAB + tmux -L fm-lab new-session ... -e FM_HOME=$LAB -e HOME=$LAB/user-home agy from the gate worktree, prompted for startup digest, inspected $LAB/state, ran bin/fm-sessionstart-agy.sh directly, then tmux -L fm-lab kill-server and rm -rf $LAB
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…ness

Add tracked .agents/hooks.json, bin/fm-sessionstart-agy.sh, bin/fm-turnend-guard-agy.sh, PreToolUse --agy seatbelt flags, session-lock agy ancestry, autoarm supervision model, and --secondmate agy workspace trust pre-registration and spawn support.
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link