Skip to content

fix(computer): run Antigravity probes in private state temp dir - #792

Open
NightRain233 wants to merge 1 commit into
mainfrom
fix/antigravity-probe-private-temp
Open

NightRain233 wants to merge 1 commit into
mainfrom
fix/antigravity-probe-private-temp

Conversation

@NightRain233

@NightRain233 NightRain233 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #774

Problem

  1. PrepareAntigravityProtocolProbe and ProbeAntigravity (antigravity_catalog.go) always created isolated temporary directories under the OS %TEMP% directory and called privatefs.EnsureDir on them. On Windows machines where default %TEMP% grants modify/replace permissions to accounts such as LOCAL SERVICE (S-1-5-19), privatefs.EnsureDir rejects the ancestor ACL before agy acp ever starts.
  2. probeRuntimeProtocol returned that preparation error without logging, and probeRuntime classified any non-timeout error as Status: "incompatible", Code: "RUNTIME_INCOMPATIBLE", causing Linger to report "Update needed" / Runtime protocol handshake failed even though agy is up to date and never failed an ACP handshake.

Changes

1. Private Per-Probe Temp Directory Under Daemon State (<state>/operation-tmp)

  • apps/computer/local-daemon/internal/workspace/operation_temp.go: hardened PrepareOperationTemp to protect both base and the allocated lock-tracked directory via privatefs.EnsureDir (retaining LockTaskTempDir / PruneOperationTemps crash cleanup and never weakening privatefs or trusted_sid.go).
  • apps/computer/local-daemon/internal/provider/native/antigravity_catalog.go & catalog.go:
    • Extended PrepareAntigravityProtocolProbe(root), ProbeAntigravity(ctx, inv, root), and DiscoverAntigravityModels(ctx, inv, root) directly with a root string parameter (empty falls back to the OS temp directory). When root is supplied, validates filepath.IsAbs(root) and privatefs.EnsureDir(root), allocates a unique os.MkdirTemp(root, "linger-antigravity-probe-") child directory (safe under concurrent calls and leaving caller-owned lock handles intact), and cleans up only that child via sync.Once.
    • Removed the unreachable case "antigravity": branch from native.DiscoverModels.
    • Exported ErrAntigravityProbePrepare wrapping preparation failures so callers can distinguish setup failures from agy acp runtime/protocol failures.
  • apps/computer/local-daemon/internal/provider/{discovery,protocol_probe,detection_policy,antigravity_probe,runtime_monitor}.go:
    • Added DiscoveryOptions.TempBase (aligned with PR fix(local-daemon): enforce privatefs ACLs on Claude credentials and secret peers (WHI-897) #777's TempBase shape) and probeOptions{runtimeHomeRoot, tempBase}.
    • Passed tempBase uniformly through probeRuntimeProtocol, runtimeDetectionPolicy.authenticationProbe (using withoutTempBase for Codex/Claude/Pi), periodic auth refresh, and uncached Antigravity model discovery using localworkspace.PrepareOperationTemp(tempBase) (cleaning the probe subdirectory before releasing the OperationTemp lock).
  • apps/computer/local-daemon/cmd/linger-computer-daemon/main.go: wired TempBase: operationTempBase (<StateDirectory>/operation-tmp) into currentDiscoveryOptions().
  • apps/computer/local-daemon/internal/computerconfig/runtime_discovery.go and internal/computercli/{runtimes,doctor,cli,runtime_login}.go:
    • Added RuntimeDiscoveryRequest.TempBase (validated unconditionally as absolute when non-empty).
    • Wired validated <stateDirectory>/operation-tmp into linger-computer doctor, login, runtime check, and runtime login when a private state directory already exists.

2. Accurate Diagnostic Classification & Redacted Local Logging

  • apps/computer/local-daemon/internal/provider/protocol_probe.go:
    • Wrapped Antigravity probe preparation errors as probePreparationError, logged redacted failure details via slog.Warn("runner.runtime_probe.prepare_failed", ...), and mapped them to Status: "error", Code: "RUNTIME_DIAGNOSTIC_FAILED" ("Antigravity diagnostic environment could not be prepared") without leaking local paths or SIDs.
    • Reserved RUNTIME_INCOMPATIBLE strictly for version checks and actual protocol handshake mismatches.
  • apps/computer/local-daemon/internal/provider/{antigravity_probe,discovery}.go:
    • Logged runner.runtime_auth.prepare_failed / runner.runtime_auth.probe_failed and runner.runtime_models.prepare_failed (redacted) and returned categorical preparation error messages on ErrAntigravityProbePrepare.
  • Updated apps/computer/local-daemon/README.md.

Latency & Compatibility

Verification

  • go test -count=1 ./internal/workspace ./internal/computerconfig ./internal/computercli ./internal/provider ./cmd/linger-computer-daemon -> PASS
  • go test -count=1 ./internal/provider/native -run 'TestAntigravity|TestDiscoverModels|TestClaudeCatalog|TestDiscoveryWithCancelledContext|TestCodexCatalog' -> PASS
  • GOOS=windows GOARCH=amd64 go build ./... and GOOS=windows GOARCH=amd64 go test -c -o /dev/null on ./internal/provider and ./internal/provider/native -> PASS
  • make -C apps/teamhub lint-go-daemon BASE=origin/main -> PASS (0 issues)
  • commitlint, pnpm env:inventory:check, bash scripts/ci/check-changed-files.sh origin/main HEAD, node scripts/check-doc-links.mjs -> PASS
  • Added Windows-only regression test (protocol_probe_windows_test.go) reproducing a %TEMP% ancestor with S-1-5-19 (LOCAL SERVICE) modify rights (executed directly in check (computer-go-windows) via go test -v ./internal/provider -run '^TestWindowsAntigravityProbeHandlesUntrustedTempAncestor$').

@NightRain233
NightRain233 force-pushed the fix/antigravity-probe-private-temp branch from 84496f0 to 6bec3fb Compare November 26, 2026 13:12

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve with nits (2 P2)

Scope: base main, merge base 844d56cc, 1 commit, 25 files reviewed. Helper skills (coderbook, ponytail-review, karpathy-guidelines) were not loaded; I applied the linger-pr-review checklist directly. The review ran in a separate session.

Findings

P2

1. probe-runtimes --temp-base has no caller, so the Desktop/installer probe path still uses %TEMP%. apps/computer/local-daemon/cmd/linger-computer-daemon/probe_runtimes.go:89
The resident Daemon now passes TempBase (main.go:190), and the control CLI does too. The other entry point is the Desktop/local-installation runtime probe, probeRuntimesWithDaemon in packages/local-installation/src/daemon-runtime-probe.ts:213, and it builds probe-runtimes --json [--include-bundled] [--runtime …] [--<kind>-path …] without --temp-base. On the machine from #774, Antigravity probes started by setup inspection and runtime reconciliation therefore still allocate under %TEMP% and still fail privatefs.EnsureDir. The failure now shows as RUNTIME_DIAGNOSTIC_FAILED, which is better, but Antigravity still isn't usable from that flow. Either pass --temp-base <state>/operation-tmp from probeRuntimesWithDaemon in this PR, or drop the unused flag and track the installer path as a follow-up. As it stands, the PR adds a flag and README text for a path nothing uses.

2. Compatibility wrappers in internal packages are left behind as dead code. apps/computer/local-daemon/internal/provider/native/antigravity_catalog.go:43
The body describes these as "backward-compatible". They live under internal/, so no external caller can depend on them, and the repo's deletion rule applies:

  • native.PrepareAntigravityProtocolProbe() (antigravity_catalog.go:43) has no callers.
  • native.ProbeAntigravity (:142) is called only from antigravity_runtime_test.go.
  • provider.probeRuntimeProtocol (protocol_probe.go:105) is called only from tests.
  • native.DiscoverModels' antigravity branch (native/catalog.go:51) is unreachable. discoverRuntimeModels now handles antigravity before it calls native.DiscoverModels (discovery.go:327-342).
  • detection_policy.go:36 still registers probeAntigravityAuthentication. probeRuntimeAuthentication now intercepts antigravity before it calls authenticationProbe (protocol_probe.go:421-423), so the registered function only acts as a non-nil flag. That gives Antigravity authentication two dispatch paths.

Fix: give the *In variants the original names, or delete the wrappers and point the tests at the *In versions. Either pass tempBase through the policy's probe signature or keep the special case, but not both.

Verified as fine

  • PrepareOperationTemp now calls privatefs.EnsureDir on the base and on the child (internal/workspace/operation_temp.go:36,43). The Task executor and ModelInvoker use the same base (main.go:465,479), and its parent StateDirectory is already created with privatefs.EnsureDir (main.go:130). The Windows ancestor check therefore passes for the same paths as before. On Unix, EnsureDir is MkdirAll + an O_NOFOLLOW owner check + chmod 0700 (privatefs_unix.go:60-78), which is stricter than the old MkdirAll+Chmod and does not loosen anything.
  • Cleanup order: releaseProbe (RemoveAll of the probe child) runs before releaseRoot closes the OperationTemp lock (protocol_probe.go:131-132, deferred LIFO). On the prepare-failure path, releaseRoot() runs explicitly (:126). A concurrent daemon start's PruneOperationTemps (main.go:147) skips directories whose lock is held, so a CLI probe running at the same time is not swept.
  • Classification: preparation errors in the protocol probe become probePreparationError and map to RUNTIME_DIAGNOSTIC_FAILED (protocol_probe.go:85-91). RUNTIME_INCOMPATIBLE stays for real handshake failures (:93). The auth and model-catalog paths match on native.ErrAntigravityProbePrepare through errors.Is (antigravity_probe.go:312, discovery.go:335), not on message text.
  • CLI temp base: login derives <dir(config)>/state, the same convention executeLogin already uses for stateDirectory (cli.go:498). doctor uses the configured state directory only when its check passed (doctor.go:57-59). validatedProbeTempBase requires privatefs.CheckPath to pass first (runtimes.go:181-189), so the CLI never creates a state directory that doesn't exist.
  • --temp-base is rejected when relative, because probe-runtimes sets RequireAbsolutePaths (computerconfig/runtime_discovery.go:57-60).
  • The PR adds no network round trip or file walk on the user message → provider_ready path. Only discovery and periodic auth refresh are touched.

Process notes

  • Merge state is BLOCKED (required review). The branch has a single conventional commit, with no merge or fixup commits. The commit author is linked to NightRain233.

CI

All checks run on 6bec3fb pass: computer-go, computer-go-windows (which covers the new protocol_probe_windows_test.go), desktop, web, repository-gate, CodeQL. Checks not selected for this change were skipped. CI runs the daemon's Go tests without -race. The PR adds only sync.Once release guards and no new goroutines, so I did not run anything locally.

Automated review by Claude Code


Automated review of 6bec3fb by Claude Code.

@NightRain233
NightRain233 force-pushed the fix/antigravity-probe-private-temp branch 2 times, most recently from d5b06be to d2a026d Compare November 26, 2026 13:53
@NightRain233
NightRain233 force-pushed the fix/antigravity-probe-private-temp branch from d2a026d to 6cae84a Compare November 26, 2026 13:57

@linger-review linger-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve with nits (1 P3)

Scope: follow-up on 6bec3fb. The PR was rebased since then, so I compared the old patch (844d56c..6bec3fb) with the new one (665356a1..6cae84a) and then re-reviewed the whole merge-base diff. Base main, merge base 665356a1, 1 commit, 26 files. Loaded coderbook, ponytail-review and karpathy-guidelines. Ran in a separate session.

Previous findings

  • Resolved: --temp-base had no caller, so Desktop still used %TEMP%. The flag and its tests were removed from probe_runtimes.go. Desktop's managed-runtime probe only asks for codex|claude|pi (packages/local-installation/src/managed-runtimes.ts:22, :369), so it never probes Antigravity through probe-runtimes. The path in #774 is daemon discovery, which now gets TempBase (cmd/linger-computer-daemon/main.go:190).
  • Resolved: leftover PrepareAntigravityProtocolProbe / ProbeAntigravity wrappers. The *In variants are gone. The existing functions now take root directly (native/antigravity_catalog.go:54, :139, :176), and the bypassed case "antigravity" was removed from native.DiscoverModels (native/catalog.go:47).

Findings

P3

  • apps/computer/local-daemon/internal/provider/antigravity_probe.go:15: there are two layers of temporary directory where one is enough. PrepareOperationTemp already returns a unique, owner-only, lock-tracked directory, and OperationTemp.Close is already idempotent through t.once (internal/workspace/operation_temp.go:74). prepareAntigravityProbe then calls EnsureDir(root) again and creates another MkdirTemp child inside it, and allocateAntigravityProbeRoot wraps Close in a second sync.Once. Simpler: return opTemp.Path, func() { _ = opTemp.Close() }, nil. Also, probePreparationError is only ever built for antigravity, so the generic "Runtime diagnostic environment could not be prepared" branch in protocol_probe.go can't be reached. The message could be fixed. Optional.

Verified as fine

  • Classification: preparation failures become RUNTIME_DIAGNOSTIC_FAILED with no path or SID in the message. Logs pass through redact.Text. RUNTIME_INCOMPATIBLE is now returned only after a real handshake failure (internal/provider/protocol_probe.go:77-89).
  • Cleanup order: the probe child is removed first, then the operation lock is released and the directory removed through RemoveTaskTempDir (protocol_probe.go defers; operation_temp.go:83-89). A probe dir left behind by a crash sits under a lock-tracked dir that PruneOperationTemps sweeps at startup (main.go:147).
  • PrepareOperationTemp switched to privatefs.EnsureDir. On Unix this is the same MkdirAll + chmod 0700, plus an owner/no-symlink check (privatefs_unix.go:60-78). On Windows the state directory is already EnsureDir-validated at daemon start (main.go:130), so executor and model-invoke callers don't gain a new failure mode.
  • The CLI uses <state>/operation-tmp only after privatefs.CheckPath passes (computercli/runtimes.go:63, doctor.go:57). A first login with no state directory yet falls back to OS temp, as the PR body says.
  • The regression test TestWindowsAntigravityProbeHandlesUntrustedTempAncestor runs in check (computer-go-windows) (.github/workflows/ci.yml:326). The README section on Antigravity discovery is updated.

Process notes

  • None. The branch is up to date with main, it is a single commit, and the author is linked (NightRain233).

CI
All checks pass, including check (computer-go) and check (computer-go-windows). I didn't run tests myself: the change adds no new concurrency, and CI ran the touched Go packages.

Automated review by Claude Code


Automated review of 6cae84a by Claude Code.

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.

Windows: Antigravity probe rejects TEMP permissions and reports “Update needed”

1 participant