agy coder guard¶
Antigravity implementation uses agent-mcp when agyTarget is enabled.
The fleet defaults to disabled. The managed PreToolUse hook fences writes
to the linked worktree.
The private backend launcher in home/development/antigravity-config.nix
requires an executable /etc/antigravity/hooks/coder-guard, an exact match
for its managed entry in ~/.gemini/config/hooks.json, and a successful
owner probe for the installed version. agent-mcp sets AGY_CODER=1 and
AGY_WORKTREE to the run directory. The launcher checks that the worktree
marker matches its working directory.
What the guard allows and denies¶
The guard is modules/programs/agy-guard-adapter.sh. It only acts when AGY_CODER=1, so plain agy is
unaffected. It denies by default.
| Tool | Rule |
|---|---|
view_file, read_file, grep_search, list_dir, find_by_name, ask_question, list_permissions |
Allowed. |
write_to_file, replace_file_content, multi_replace_file_content, write_file, edit_file |
Allowed only for absolute, unencoded paths inside AGY_WORKTREE. |
run_command |
Passed to the shared coder guard; BypassSandbox is denied. |
| Any other tool | Denied. |
Denied for every tool:
- any argument that mentions
.gemini, so a session cannot edit agy's own settings or hooks; - non-ASCII key names, and duplicate keys compared case-insensitively (agy's Go decoder folds case).
Denied for file writes:
- paths under
.git,.claude,.envrc,.direnvor.githooks, and.pre-commit-config.yamlanddevenv.nix, because they run code outside the sandbox; - hard-linked targets, empty paths and extra string arguments named like a path.
Version checks¶
Run agy-guard-probe from your own Antigravity owner session on the host
after upgrading. It uses scratch Git repositories to check an allowed edit,
an out-of-tree write refusal, an allowed Git status, and refusals of Git
restore and stash. It checks HEAD and the working tree afterward, and
verifies that the ACP session remembers a value across two turns.
The command writes the installed version with the acp2 suffix to
${XDG_CACHE_HOME:-$HOME/.cache}/agy-implement/probed after all checks pass.
On failure, read the PASS/FAIL lines and check for the issue titled
agy <version>: coder guard probe failed on <host>.
With agyTarget enabled, run agent-mcp doctor --probe --backend agy after
the owner probe passes. agent-mcp has a separate per-version gate and
checks the hook registration and owner stamp before dispatch.
Files¶
home/development/antigravity-config.nix: the private agent-mcp backend, registration check and owner probe.modules/programs/agy-guard-adapter.sh: the hook adapter, installed at/etc/antigravity/hooks/coder-guard.modules/programs/agy-guard-adapter.test.sh: the guard's test cases.modules/programs/claude-code-managed.nix: builds the adapter and the shared coder guard.home/development/agent-sandbox.sh,agent-implement.sh,agent-implement.test.sh: the sandbox.home/development/claude-code-skills/handoff/SKILL.md: how Claude hands a plan to agy..claude/commands/update-antigravity.md: the update procedure.
After an agy update, run the guard tests first:
Known gaps¶
- The path-argument rule only checks string values whose key contains path or file. A
Destinationor an array-valued argument is not covered. - Some files that run code are not on the deny list:
devenv.local.nix,devenv.yaml,.mcp.jsonand.vscode/tasks.json.flake.nixis allowed on purpose. - The gate keys on the agy version only. A change to the guard does not force a new probe.
- A parallel command can race the hook’s path check by swapping a symlink after validation.
History¶
-
2087:
agy-implementand the first guard.¶ -
2291: nothing may touch
~/.gemini.¶ -
2296, #2298: write fencing to the worktree under
--dangerously-skip-permissions, and case-insensitive¶BypassSandbox. -
2453: hardening,
agy-guard-probe, and the refuse-until-probed gate.¶ -
2463: the gate runs the probe by itself.¶