Skip to content

feat(agy): full native Antigravity CLI support for firstmate - #6906

Closed
faridghar wants to merge 5 commits into
kunchenguid:mainfrom
faridghar:feat/native-agy-support
Closed

faridghar wants to merge 5 commits into
kunchenguid:mainfrom
faridghar:feat/native-agy-support

Conversation

@faridghar

Copy link
Copy Markdown

Summary

Establishes full native support for the Antigravity CLI (agy) across all Firstmate fleet roles: Primary Firstmate, Persistent Secondmate, and Crewmate/Scout.

This PR supersedes and replaces #4622 by incorporating the subagent delegation check and completing the full lifecycle and wake integration so Firstmate reliably wakes up when crewmates finish.

Core Problems Solved

  1. Crewmate Turn-End Wake Failure:

    • Previously, bin/fm-spawn.sh treated agy as having no hook surface, so bin/fm-busy-event.sh was never armed and state/<id>.turn-ended was never touched.
    • Now, bin/fm-spawn.sh arms a per-task busy generation and installs $WT/.agents/hooks.json with:
      • PreInvocation: records busy state via fm-busy-event.sh.
      • Stop: touches state/<id>.turn-ended, records idle via fm-busy-event.sh, and emits {"decision":"allow"}.
    • If the project worktree already contains .agents/hooks.json, bin/fm-spawn.sh safely merges fm-crew-busy via jq rather than clobbering existing project hooks, and excludes .agents/hooks.json from git tracking.
    • On relaunch (bin/fm-control-lib.sh) and worktree teardown (bin/fm-teardown.sh), fm-crew-busy is safely pruned while preserving other project hooks.
  2. Primary Supervisor Stop-Hook Park Model:

    • Fixed hook command execution syntax in .agents/hooks.json where command precedence previously caused newline corruption during root directory resolution.
    • Primary supervisor supervision protocol documented in docs/supervision-protocols/agy.md and routed in bin/fm-supervision-instructions.sh.
    • Park mechanism foregrounds bin/fm-watch-arm.sh and returns {"decision":"continue"} upon actionable wakes, bounded by loop ceiling and block budgets.
  3. Persistent Secondmate Support:

    • Removed secondmate refusal gate for agy in bin/fm-spawn.sh.
    • Extended bin/fm-agy-trust.sh with --secondmate-home to pre-register workspace trust in ~/.gemini/antigravity-cli/settings.json.
  4. In-Process Subagent Guard (from fix(agents): restrict subagent dispatch outside fleet supervision #4622):

    • Configured bin/fm-subagent-pretool-check.sh to parse Antigravity's .toolCall.name stdin payload and deny in-process subagent tools (invoke_subagent, define_subagent, etc.) in primary homes to enforce fleet orchestration.
  5. Herdr Backend Integrity:

    • Preserves upstream agent_not_found -> no-agent logic in bin/backends/herdr.sh.

Testing

Comprehensive test suites were created and verified:

  • tests/fm-agy-crew-turnend.test.sh: 4/4 passed (hook installation, turn-end notification, hook merging without clobbering, wiring cleanup, and secondmate trust).
  • tests/fm-agy-primary.test.sh: 11/11 passed (Stop-hook park model, supervision need, loop bounds, repair followup, and hook command syntax).
  • tests/fm-busy-adapter-wiring.test.sh: 14/14 passed (agy lifecycle and stale rejection).
  • tests/fm-agy-harness.test.sh: 30/30 passed (detection, models timeout, workspace trust, secondmate gate).
  • tests/fm-subagent-pretool-check.test.sh: 13/13 passed.
  • tests/fm-send-agy-confirm.test.sh: 6/6 passed.
  • tests/fm-backend-herdr.test.sh: 167+ tests passed.
  • tests/fm-control-relaunch.test.sh: All passed.
  • tests/fm-turnend-guard.test.sh: All 92 passed.
  • tests/fm-documentation-audiences.test.sh: All passed.
  • shellcheck: Clean with zero errors across all modified scripts.

…mate trust

- Install semantic busy-state hooks (PreInvocation -> busy, Stop -> idle + touch turn-ended) in task worktree .agents/hooks.json for agy crewmates.
- Merge fm-crew-busy with pre-existing worktree hooks and exclude from git tracking.
- Prune fm-crew-busy safely on relaunch and worktree teardown.
- Enable agy as a verified persistent secondmate adapter with --secondmate-home trust pre-registration.
- Add docs/supervision-protocols/agy.md and update agy reference documentation.
- Restore clean upstream Herdr agent liveness detection.
- Add comprehensive hermetic integration suite in tests/fm-agy-crew-turnend.test.sh.
@faridghar

Copy link
Copy Markdown
Author

Closed while local testing and no-mistakes pipeline validation run.

@faridghar faridghar closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant