Repository navigation
fix(computer): run Antigravity probes in private state temp dir - #792
NightRain233 wants to merge 1 commit into
Conversation
84496f0 to
6bec3fb
Compare
There was a problem hiding this comment.
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 fromantigravity_runtime_test.go.provider.probeRuntimeProtocol(protocol_probe.go:105) is called only from tests.native.DiscoverModels'antigravitybranch (native/catalog.go:51) is unreachable.discoverRuntimeModelsnow handlesantigravitybefore it callsnative.DiscoverModels(discovery.go:327-342).detection_policy.go:36still registersprobeAntigravityAuthentication.probeRuntimeAuthenticationnow interceptsantigravitybefore it callsauthenticationProbe(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
PrepareOperationTempnow callsprivatefs.EnsureDiron 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 parentStateDirectoryis already created withprivatefs.EnsureDir(main.go:130). The Windows ancestor check therefore passes for the same paths as before. On Unix,EnsureDiris 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 beforereleaseRootcloses the OperationTemp lock (protocol_probe.go:131-132, deferred LIFO). On the prepare-failure path,releaseRoot()runs explicitly (:126). A concurrent daemon start'sPruneOperationTemps(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
probePreparationErrorand map toRUNTIME_DIAGNOSTIC_FAILED(protocol_probe.go:85-91).RUNTIME_INCOMPATIBLEstays for real handshake failures (:93). The auth and model-catalog paths match onnative.ErrAntigravityProbePreparethrougherrors.Is(antigravity_probe.go:312,discovery.go:335), not on message text. - CLI temp base:
loginderives<dir(config)>/state, the same conventionexecuteLoginalready uses forstateDirectory(cli.go:498).doctoruses the configured state directory only when its check passed (doctor.go:57-59).validatedProbeTempBaserequiresprivatefs.CheckPathto pass first (runtimes.go:181-189), so the CLI never creates a state directory that doesn't exist. --temp-baseis rejected when relative, becauseprobe-runtimessetsRequireAbsolutePaths(computerconfig/runtime_discovery.go:57-60).- The PR adds no network round trip or file walk on the user message →
provider_readypath. 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.
d5b06be to
d2a026d
Compare
d2a026d to
6cae84a
Compare
There was a problem hiding this comment.
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-basehad no caller, so Desktop still used%TEMP%. The flag and its tests were removed fromprobe_runtimes.go. Desktop's managed-runtime probe only asks forcodex|claude|pi(packages/local-installation/src/managed-runtimes.ts:22,:369), so it never probes Antigravity throughprobe-runtimes. The path in #774 is daemon discovery, which now getsTempBase(cmd/linger-computer-daemon/main.go:190). - Resolved: leftover
PrepareAntigravityProtocolProbe/ProbeAntigravitywrappers. The*Invariants are gone. The existing functions now takerootdirectly (native/antigravity_catalog.go:54,:139,:176), and the bypassedcase "antigravity"was removed fromnative.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.PrepareOperationTempalready returns a unique, owner-only, lock-tracked directory, andOperationTemp.Closeis already idempotent throught.once(internal/workspace/operation_temp.go:74).prepareAntigravityProbethen callsEnsureDir(root)again and creates anotherMkdirTempchild inside it, andallocateAntigravityProbeRootwrapsClosein a secondsync.Once. Simpler:return opTemp.Path, func() { _ = opTemp.Close() }, nil. Also,probePreparationErroris only ever built forantigravity, so the generic "Runtime diagnostic environment could not be prepared" branch inprotocol_probe.gocan't be reached. The message could be fixed. Optional.
Verified as fine
- Classification: preparation failures become
RUNTIME_DIAGNOSTIC_FAILEDwith no path or SID in the message. Logs pass throughredact.Text.RUNTIME_INCOMPATIBLEis 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.godefers;operation_temp.go:83-89). A probe dir left behind by a crash sits under a lock-tracked dir thatPruneOperationTempssweeps at startup (main.go:147). PrepareOperationTempswitched toprivatefs.EnsureDir. On Unix this is the sameMkdirAll+ chmod 0700, plus an owner/no-symlink check (privatefs_unix.go:60-78). On Windows the state directory is alreadyEnsureDir-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-tmponly afterprivatefs.CheckPathpasses (computercli/runtimes.go:63,doctor.go:57). A firstloginwith no state directory yet falls back to OS temp, as the PR body says. - The regression test
TestWindowsAntigravityProbeHandlesUntrustedTempAncestorruns incheck (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.
Fixes #774
Problem
PrepareAntigravityProtocolProbeandProbeAntigravity(antigravity_catalog.go) always created isolated temporary directories under the OS%TEMP%directory and calledprivatefs.EnsureDiron them. On Windows machines where default%TEMP%grants modify/replace permissions to accounts such asLOCAL SERVICE(S-1-5-19),privatefs.EnsureDirrejects the ancestor ACL beforeagy acpever starts.probeRuntimeProtocolreturned that preparation error without logging, andprobeRuntimeclassified any non-timeout error asStatus: "incompatible", Code: "RUNTIME_INCOMPATIBLE", causing Linger to report "Update needed" /Runtime protocol handshake failedeven thoughagyis 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: hardenedPrepareOperationTempto protect bothbaseand the allocated lock-tracked directory viaprivatefs.EnsureDir(retainingLockTaskTempDir/PruneOperationTempscrash cleanup and never weakeningprivatefsortrusted_sid.go).apps/computer/local-daemon/internal/provider/native/antigravity_catalog.go&catalog.go:PrepareAntigravityProtocolProbe(root),ProbeAntigravity(ctx, inv, root), andDiscoverAntigravityModels(ctx, inv, root)directly with aroot stringparameter (empty falls back to the OS temp directory). Whenrootis supplied, validatesfilepath.IsAbs(root)andprivatefs.EnsureDir(root), allocates a uniqueos.MkdirTemp(root, "linger-antigravity-probe-")child directory (safe under concurrent calls and leaving caller-owned lock handles intact), and cleans up only that child viasync.Once.case "antigravity":branch fromnative.DiscoverModels.ErrAntigravityProbePreparewrapping preparation failures so callers can distinguish setup failures fromagy acpruntime/protocol failures.apps/computer/local-daemon/internal/provider/{discovery,protocol_probe,detection_policy,antigravity_probe,runtime_monitor}.go:DiscoveryOptions.TempBase(aligned with PR fix(local-daemon): enforce privatefs ACLs on Claude credentials and secret peers (WHI-897) #777'sTempBaseshape) andprobeOptions{runtimeHomeRoot, tempBase}.tempBaseuniformly throughprobeRuntimeProtocol,runtimeDetectionPolicy.authenticationProbe(usingwithoutTempBasefor Codex/Claude/Pi), periodic auth refresh, and uncached Antigravity model discovery usinglocalworkspace.PrepareOperationTemp(tempBase)(cleaning the probe subdirectory before releasing theOperationTemplock).apps/computer/local-daemon/cmd/linger-computer-daemon/main.go: wiredTempBase: operationTempBase(<StateDirectory>/operation-tmp) intocurrentDiscoveryOptions().apps/computer/local-daemon/internal/computerconfig/runtime_discovery.goandinternal/computercli/{runtimes,doctor,cli,runtime_login}.go:RuntimeDiscoveryRequest.TempBase(validated unconditionally as absolute when non-empty).<stateDirectory>/operation-tmpintolinger-computer doctor,login,runtime check, andruntime loginwhen a private state directory already exists.2. Accurate Diagnostic Classification & Redacted Local Logging
apps/computer/local-daemon/internal/provider/protocol_probe.go:probePreparationError, logged redacted failure details viaslog.Warn("runner.runtime_probe.prepare_failed", ...), and mapped them toStatus: "error", Code: "RUNTIME_DIAGNOSTIC_FAILED"("Antigravity diagnostic environment could not be prepared") without leaking local paths or SIDs.RUNTIME_INCOMPATIBLEstrictly for version checks and actual protocol handshake mismatches.apps/computer/local-daemon/internal/provider/{antigravity_probe,discovery}.go:runner.runtime_auth.prepare_failed/runner.runtime_auth.probe_failedandrunner.runtime_models.prepare_failed(redacted) and returned categorical preparation error messages onErrAntigravityProbePrepare.apps/computer/local-daemon/README.md.Latency & Compatibility
provider_readypath: Adds zero network round trips and zero file walks on the critical path (only affects Runtime discovery / periodic probes).TempBase/rootcontinues to fall back to OS temp withprivatefs.EnsureDir, andDiscoveryOptions.TempBasematches PR fix(local-daemon): enforce privatefs ACLs on Claude credentials and secret peers (WHI-897) #777's naming and semantics. Note: once PR fix(local-daemon): enforce privatefs ACLs on Claude credentials and secret peers (WHI-897) #777 merges, its peeros.MkdirTemp("", ...)+privatefs.EnsureDircall sites (antigravity_hook.go,claude_mcp_config.go,playground_tools.go) should also move under<StateDirectory>to avoid hitting the same Windows%TEMP%ancestor ACL issue.Verification
go test -count=1 ./internal/workspace ./internal/computerconfig ./internal/computercli ./internal/provider ./cmd/linger-computer-daemon-> PASSgo test -count=1 ./internal/provider/native -run 'TestAntigravity|TestDiscoverModels|TestClaudeCatalog|TestDiscoveryWithCancelledContext|TestCodexCatalog'-> PASSGOOS=windows GOARCH=amd64 go build ./...andGOOS=windows GOARCH=amd64 go test -c -o /dev/nullon./internal/providerand./internal/provider/native-> PASSmake -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-> PASSprotocol_probe_windows_test.go) reproducing a%TEMP%ancestor withS-1-5-19(LOCAL SERVICE) modify rights (executed directly incheck (computer-go-windows)viago test -v ./internal/provider -run '^TestWindowsAntigravityProbeHandlesUntrustedTempAncestor$').