Repository navigation
fix(antigravity): keep the Windows hook command startable on a spaced profile - #22035
brennanb2025 wants to merge 2 commits into
Conversation
… profile Antigravity requires a decision on PreToolUse and reads silence as a deny (hook-events.ts, #2426). So a hook command it cannot start does not merely lose status - it denies every tool call. The Windows branch routed the per-event wrapper path through the shared cmd wrapper, whose safe-path whitelist excludes spaces. Any profile shaped like C:\Users\First Last therefore had its entry replaced with a multi-token encoded PowerShell launcher. Antigravity starts a hook `command` as a program (#8737), and a multi-token string is not a program name, so that entry never starts, and the gate hears nothing on a clean install with nothing deleted. Register the per-event wrapper path itself for every profile. It is the shape Antigravity can start, and it is already the file that answers: the wrapper echoes the ask decision on its own when the core script is missing, which is what fallbackStdout buys the POSIX command. Derive the wrapper path from the core script's directory so the `%~dp0` lookup the wrapper depends on is explicit rather than incidental. The shared cmd wrapper is untouched; its remaining consumers (devin, grok) get byte-identical commands. The contract test now drives the installer's own builder instead of a private copy of the Windows branch that had stopped reflecting what gets registered.
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. Warning Review limit reachedNext included review available in 1 minute. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe Antigravity hook service now creates each Windows event wrapper beside the core managed script and returns that wrapper path directly from Priority: ⬇️ Low 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives detailed user impact, implementation rationale, testing evidence, limitations, and compatibility considerations. However, it omits the required Linked Issue, does not provide the required Visual Proof or an explicit N/A statement, and leaves required checklist items unchecked. ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — Antigravity's Windows hook entry is now the bare per-event wrapper .cmd path for every profile, replacing the cmd-safe helper whose spaced/non-ASCII branch emitted a multi-token PowerShell launcher that Antigravity cannot start.
- Windows command path —
getManagedCommandreturnsgetWindowsWrapperScriptPath(...), and the helper now derives the wrapper fromdirname(scriptPath). For cmd-safe profiles this is byte-identical to the previous output, so only the diverted class changes, and the upgrade sweep still matches the old encoded entry. - Contract test — the antigravity local builder now drives the installer's own
getManagedCommandinstead of a private copy of the Windows branch, so it tracks what Antigravity actually registers. - New spawnability pin — a spaced-home test asserts every event's command is a single existing file (not a PowerShell launcher) and that
PreToolUsestill answers from the wrapper once the core script is deleted.
I confirmed the new pin is a live instrument: reverting getManagedCommand to wrapWindowsCmdHookCommand(...) fails 2 of its 3 cases while the whitelist control still passes. The related hook-service, managed-hook-command-contract, managed-hook-stdin-lifecycle, managed-hook-timeout, and remote-hook-service-installers suites all pass on this head.
The one thing this review cannot settle is the PR's own documented open question — Antigravity's launch model (argv[0] vs. cmd.exe) — which the author already flags and which needs a real Windows host to close out.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ity-windows-hook-stdout # Conflicts: # src/main/agent-hooks/managed-hook-command-contract.test.ts
|
| // Why: a program name is startable only if it names a file. A multi-token launcher string | ||
| // never does, and a hook that never starts writes no stdout at all. | ||
| expect(existsSync(command), `${event.eventName} command is not a file`).toBe(true) | ||
| expect(command, event.eventName).not.toMatch(/powershell|-EncodedCommand/i) |
There was a problem hiding this comment.
Spaced-path launch remains untested The test confirms that each registered command names an existing file, but it never launches that command. The live Windows suite launches wrappers without guaranteeing a spaced home directory. As a result, a failure to start the bare
.cmd path under a spaced profile could leave these tests green while PreToolUse denies tool calls. Please add Windows-host coverage that launches a command from a guaranteed spaced path and checks its gate response.
|
Closing: the premise did not hold up when measured. Antigravity documents that it runs hook commands through A real, separate problem remains: if the wrapper script is deleted while Antigravity's hook config survives, every tool call is denied (on main too). That will be fixed at its root by re-deriving the installed hook state, in its own PR. |

What a user hits today
On Windows, if your user profile path contains a space —
C:\Users\First Last, the ordinaryshape — Antigravity may refuse every tool call, on a clean install, with nothing deleted.
Antigravity requires a decision on
PreToolUseand reads silence as a deny(
src/main/antigravity/hook-events.ts). So a hook command Antigravity cannot start is not alost status indicator. It is a deny on every tool call, and there is nothing in the UI that
says so.
The chain, and how much of it I verified
Verified by reading the code at
663d670878:WINDOWS_CMD_SAFE_PATH(src/main/agent-hooks/installer-utils.ts:151) is/^[A-Za-z0-9_.:\\~-]+$/. No space in the character class. Verified.wrapWindowsCmdHookCommand(:153-156) therefore hands any spaced path towrapWindowsHookCommand, which emits…/powershell.exe -NoProfile -EncodedCommand <base64>— a multi-token string.Verified, and reproduced in the test run below.
commandas a program, not as a shell line, so a multi-tokenstring is not a name it can start. Not verified by me — taken on trust. See below.
getManagedCommand(src/main/antigravity/hook-service.ts:62-67) passed nofallbackStdouton either Windows branch, whileinstaller-utils.ts:133states Windowsmust match POSIX. Verified.
What is still unproven
Link 3 is the load-bearing one and I did not measure it. The repository's own basis for it is
the fix message for #8737 (
ee709b02ed), which states plainly that Antigravity launches itsagent-hook
commandasargv[0], not throughcmd.exe, and which reverted an earlierif exist … (…) else (…)compound after it failed in the field with "hook exited with code 1"on v1.4.138. Two later changes restate it, and
src/main/devin/hook-settings.ts:56andsrc/main/agent-hooks/installer-utils.test.ts:710both carry it as a comment.That is a strong, field-grounded claim, but it is still a claim in a commit message, not a
measurement. The nearest contrary-looking evidence is the process trace recorded at
src/main/antigravity/windows-hook-payload-delivery.test.ts:95-98—cmd /d /c <bare .cmd path>— which is consistent with the same model: the command string is taken as one program path, and
cmd.exeappears only because the target is a.cmd. Consistent is not the same as proven.I also fixed a stale comment next to the change that read "Antigravity wraps hook commands in
cmd.exe", because it now reads as evidence against the fix and is not what the trace shows.
What this changes
Antigravity's Windows entry is now the per-event wrapper path itself, for every profile.
That path is the shape Antigravity can start, and it is already the file that answers: the
wrapper Orca writes echoes the ask decision on its own when the core script is missing, which
is exactly what
fallbackStdoutbuys the POSIX command. So the startable path and theanswering path are the same file.
The wrapper path is now derived from the core script's directory, making explicit the
%~dp0lookup the wrapper already depended on.
Why not the existing
wrapWindowsDirectCmdHookCommandsrc/main/agent-hooks/windows-direct-cmd-hook-command.tsis Orca's shipped, EDR-clean answerfor the Claude lifecycle hook, and it was the first thing I tried. It does not fit here, for
three independent reasons:
nullfor exactly the paths this bug is about — its own test pinsC:\Users\Bob Smith\…as declined (windows-direct-cmd-hook-command.test.ts:40). It hasnothing to offer a spaced profile.
<path> || echo {}, which is multi-token. Applying it to the cmd-safemajority would put every currently-working Windows user onto a string that, under the model
in link 3, cannot start — turning a minority bug into a universal one.
{}, and{}is itself read as a deny onPreToolUse(
hook-service.test.ts:148). It answers the wrong question for a gate event.I also did not take the smallest diff — adding
fallbackStdouttowrapWindowsCmdHookCommand— because a
fallbackStdoutcannot be attached to a bare token, so implementing it that waywould force every user onto the encoded branch. Same universal-exposure trap as (2).
Blast radius
wrapWindowsCmdHookCommandis untouched. Its production consumers before this change werethree: antigravity, devin, grok. After it, two:
src/main/devin/hook-settings.ts:58src/main/grok/grok-hook-script.ts:28Both get byte-identical commands;
installer-utils.tshas a zero-line diff. The sameunstartable-fallback exposure plausibly applies to them under link 3, but their events are not
gates — silence there costs status, not tool calls — so that is a separate change, not this one.
Upgrades self-heal: the managed-command matcher decodes the old encoded entry, so the next
install()sweeps it and writes the bare path.getStatus()reportspartialuntil then.Test evidence: red, then green
New pin:
src/main/antigravity/windows-hook-command-spawnability.test.ts.It installs into a home directory whose path carries a space and asserts that every event's
registered command is a single path that names a real file, and that the PreToolUse one still
echoes the ask decision after the core script is deleted. It opens with a positive control
pinning both sides of the whitelist, so the test cannot silently stop exercising the diverted
class.
Ablated (the fix line reverted to
wrapWindowsCmdHookCommand(...), everything else identical):The control passed in the red run, so the instrument was live. With the fix restored:
Tests 3 passed (3).Wider runs:
src/main/antigravity/,src/main/agent-hooks/,src/main/devin/,src/main/grok/,src/main/codex/windows-hook-command.test.ts— 104 files, 1047 passed,35 skipped.
pnpm tcexit 0.pnpm run check:code-quality:changed— 0 new findings acrossall seven gates.
pnpm-lock.yamlis not in the commit.Four unrelated failures appeared in a broader sweep
(
claude-agent-sdk-exit-proof,claude-structured-real-cli,claude-tui-resume-real-binary,codex-structured-turn-processes). Two reproduce at a cleanorigin/mainand the other two passed on re-run; none of the four import any file this PRtouches. They spawn real agent binaries and are flaky in this environment.
What still needs a real Windows host
I did not run anything on Windows. No Windows validation is claimed. Everything above ran
on macOS, where the Windows branch is reached by mocking
process.platform.What a Windows box still has to settle:
call, and capture the process tree. The question is whether the registered string is handed
over as one program name or as a command line — that is what decides this design, and it is
the one thing I could not test.
origin/main, confirm the encoded entry reallydoes produce no stdout and that Antigravity really does deny. If it turns out the encoded
entry starts fine, this change is unnecessary and the premise should be retracted.
checking that
PreToolUseprints{"decision":"ask"}and that status still posts.spaced one; the fix covers them by construction, but that is untested.
~/.gemini/config/hooks.json,launch Orca, and confirm
install()sweeps it to the bare path and status flips toinstalled.The Windows-only live legs already in
windows-hook-payload-delivery.test.tscover (3) oncerun on a Windows runner; they are skipped everywhere else.
EDR posture
docs/reference/windows-edr-posture.mdread first. This change removes an interpreter hoprather than adding one — the registered command no longer names
powershell.exeand no longercarries
-EncodedCommandon the diverted path. No-ExecutionPolicy Bypass, nocmd.exe /cwith escaped free text, no per-operation interpreter spawn, no runtimeAdd-Type.No process spawning was added, so nothing here needs
src/shared/child-process/.