diff --git a/doc/plans/2026-11-25-antigravity-cloud-rollout.md b/doc/plans/2026-11-25-antigravity-cloud-rollout.md index c2c55e885af..0a821683165 100644 --- a/doc/plans/2026-11-25-antigravity-cloud-rollout.md +++ b/doc/plans/2026-11-25-antigravity-cloud-rollout.md @@ -342,7 +342,7 @@ in that repository. | 3 | Keep per-turn-only harnesses per-turn on warm plugin environments | Core | `server/src/services/runner-environment-lifecycle.ts`, `server/src/routes/agents.ts` (save check), tests | An Antigravity agent on a plugin environment with `runnerLifecycleMode: "warm"` runs per-turn, or save refuses it in plain words; no run fails with the warm refusal | none | A | | 4 | Hosted Google sign-in (spike, then route and UI) | Core | `server/src/routes/ai-connections.ts`, `server/src/services/local-ai-login.ts`, `local-ai-browser-login.ts`, Runner `antigravity-auth.ts`, UI connection dialog | Spike answers the loopback question first. Then: on an authenticated public instance, a user completes Google sign-in by pasting the redirect; wrong `state`, reused code and another user's attempt are refused; the connection lists models | none | A | | 5 | Delete the saved Google sign-in on disconnect (no revoke at Google, see G10) | Core | AI connection removal and grant revocation paths, activity log | Disconnect deletes the saved sign-in (a shared one is kept; a failed delete keeps a retryable reference), the activity entry says in plain words that the sign-in stays valid at Google until the person removes it there, a later run asks to reconnect | none | A | -| 6 | Allow Antigravity on plugin Runner-task and remote sign-in targets | Core | `antigravity-release.ts`, `antigravity-connection-probe.ts` (use the plugin probe path, `server/src/services/native-runtime/plugin-runner-probe.ts`), `antigravity-connection-policy.ts`, `antigravity-runner-credentials.ts`, `agents.ts` | Tested against a released-profile fixture (the real profile is still pending when this merges): picker offers Antigravity on a plugin environment; Test runs the plugin probe; save and run accept sign-in on remote targets when 2 is present. The Core sandbox path gets the same sign-in support. Re-verified live in item 12 | 1, 2, 3 | C | +| 6 | Allow Antigravity on plugin Runner-task and remote sign-in targets | Core | `antigravity-release.ts`, `antigravity-connection-probe.ts` (use the plugin probe path, `server/src/services/native-runtime/plugin-runner-probe.ts`), `antigravity-connection-policy.ts`, `antigravity-runner-credentials.ts`, `agents.ts` | Tested against a released-profile fixture (the real profile is still pending when this merges): picker offers Antigravity on a plugin environment; Test runs the plugin probe; save and run accept sign-in on remote targets when 2 is present. The Core sandbox path gets the same sign-in support. Re-verified live in item 12. **Status: done.** Merged in #22940; run-start tests (pending profile refused on plugin and sandbox targets without a grant, released profile hands the plugin Runner its typed API-key or sign-in credential) added in a follow-up | 1, 2, 3 | C | | 7 | Qualification runs on a paid key (waived as item 8 blocker on 2026-11-25; deferred) | Core (ledger) | `doc/plans/2026-11-22-antigravity-qualification.md` | All NOT RUN rows in section 4 pass live (24 cells local and Daytona, both lineups, session-load or no claim, attended sign-in journey, image pull time) | paid key (owner) | A (deferred) | | 8 | Flip Antigravity from pending to qualified | Core | `packages/paperclip-runner` release declaration and generated profiles (profile v2), capability profile (`recovery: "unverified"`), adapter-utils, server routes/profile/qualification, docs | Owner waiver recorded honestly in ledger; the Core image's `linux-x64` provider pack includes the closure without a candidate flag; no operator grant needed | 3 (7 waived on 2026-11-25) | D | | 9 | Run Antigravity on agent computers through ACPX | Cloud | `extensions/plugin-agent-computer/src/harnesses.ts`, `agent-computer/harness/harnesses.json`, `harness.go`, Launcher `task_credentials.go`, `configured_environment.go`, `agent-computer/runtime/select-pack.mjs`, `assemble.mjs`, `pack-manifest.mjs`, `verify*.mjs`, tests (copy Cloud #1696) | Row `antigravity`: driver `acpx`, `acpxAgent: "antigravity"`, `projectAuthProvider: "google"`, credential `task-env` with key sets `GEMINI_API_KEY` or the sign-in key, reserved prefixes `GEMINI_` and `GOOGLE_`, reserved exact key `PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET` with a negative test (a configured or project environment that sets it is refused), blocked project settings for `.gemini/settings.json` endpoint and key fields, the Runner's runtime root (so `agentHomeDirectory`) in the private task path, with a test that a concurrent task of the same agent cannot read the staged file, `/proc//environ` or Runner memory, per-turn, closure under `provider-assets/antigravity/linux-x64` copied into the ROM. Tests pin the two tables together | 1, 2 (types); ROM content needs 8 | B (code), E (ROM) | diff --git a/server/src/services/native-runtime/antigravity-release.test.ts b/server/src/services/native-runtime/antigravity-release.test.ts index 6369f5082e2..c1178f4864d 100644 --- a/server/src/services/native-runtime/antigravity-release.test.ts +++ b/server/src/services/native-runtime/antigravity-release.test.ts @@ -29,35 +29,12 @@ import { antigravityUsesRunScopedState, assertAntigravityExecutionAdmissible, } from "./antigravity-release.js"; -import { buildNativeExecutionInput } from "./native-execution-input.js"; import { nativeSessionFailureDisposition, nativeSessionFailureSourceCode, retireNeverOpenedCandidateRunRoot, scopedRunnerdStateRoot } from "./native-session-executor.js"; import { NATIVE_PROVIDER_STATE_INCOMPATIBLE } from "./native-session-resume.js"; -import { nativeRuntimeContextFixture } from "./runtime-context.test-fixture.js"; +import { ANTIGRAVITY_FIXTURE_COMPANY_ID as companyId, ANTIGRAVITY_FIXTURE_MODEL as model, antigravityExecution } from "./antigravity.test-fixture.js"; -const companyId = "10000000-0000-4000-8000-000000000001"; -const model = "gemini-3.8-flash-low"; -const localHost = process.platform === "darwin" && process.arch === "arm64"; const distributions = JSON.parse(readFileSync(new URL("../../../../packages/paperclip-runner/antigravity-distributions.json", import.meta.url), "utf8")); -function antigravityExecution(input: { runId?: string; issueId?: string; workspaceId?: string; sessionId?: string } = {}) { - const runId = input.runId ?? "40000000-0000-4000-8000-000000000004"; - const execution = buildNativeExecutionInput({ - companyId, runId, agentId: "30000000-0000-4000-8000-000000000003", - issue: { id: input.issueId ?? "20000000-0000-4000-8000-000000000002", identifier: "AG-1", title: "Test", description: null, workMode: "standard" }, - taskPrompt: "Only the current turn", - workspace: { id: input.workspaceId ?? "90000000-0000-4000-8000-000000000009", cwd: "/workspace", repoUrl: null, repoRef: null, branchName: null }, - normalizedSessionId: input.sessionId ?? "60000000-0000-4000-8000-000000000006", - provider: "acpx", acpxAgent: "antigravity", model, acpxPermissionMode: "approve-all", - completionContract: { id: "70000000-0000-4000-8000-000000000007", sha256: `sha256:${"a".repeat(64)}`, schemaVersion: "paperclip.run-result.v1", - contract: { revision: "1", objective: "Test", criteria: [{ id: "objective", requirement: "Answer" }] } }, - runtimeContext: nativeRuntimeContextFixture(), - }) as NativeExecutionInput; - // The execution input binds the profile version the running release declares. - (execution.provider as { profile: { agentProfileVersion: number } }).profile.agentProfileVersion = - QUALIFIED_ACPX_PROFILES.antigravity.agentProfileVersion; - return execution; -} - const candidateGrant = (target = "darwin-arm64", changes: Record = {}) => { const [platform, architecture] = target.split("-"); return JSON.stringify({ schema: "paperclip.acpx-candidate-admission.v1", companyId, diff --git a/server/src/services/native-runtime/antigravity-run-start.test.ts b/server/src/services/native-runtime/antigravity-run-start.test.ts new file mode 100644 index 00000000000..a7068f6bb5d --- /dev/null +++ b/server/src/services/native-runtime/antigravity-run-start.test.ts @@ -0,0 +1,158 @@ +import { mkdir, mkdtemp, realpath, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { afterEach, beforeEach, describe, expect, it, vi, type MockInstance } from "vitest"; +import type { AdapterExecutionTarget } from "@paperclipai/adapter-utils/execution-target"; + +const release = vi.hoisted(() => ({ pending: false })); +const grant = vi.hoisted(() => ({ admitted: false, targets: [] as Array<{ platform: string; architecture: string } | undefined> })); +const backend = vi.hoisted(() => ({ options: undefined as undefined | { codexTransportFactory?: () => unknown } })); + +vi.mock("../../vendor/paperclip-runner/index.js", async importOriginal => { + const original = await importOriginal(); + const pending = { + ...original.QUALIFIED_ACPX_PROFILES.antigravity, + agentProfileVersion: original.QUALIFIED_ACPX_PROFILES.antigravity.agentProfileVersion - 1, + qualificationStatus: "pending" as const, + }; + const profiles = { ...original.QUALIFIED_ACPX_PROFILES }; + Object.defineProperty(profiles, "antigravity", { enumerable: true, + get: () => release.pending ? pending : original.QUALIFIED_ACPX_PROFILES.antigravity }); + return { + ...original, + QUALIFIED_ACPX_PROFILES: profiles, + createNativeSessionBackend: vi.fn((_session: unknown, options: { codexTransportFactory?: () => unknown }) => { + backend.options = options; + return { kind: "test", openSession: vi.fn() }; + }), + createRunnerdCodexTransport: vi.fn(() => ({ transport: { close: vi.fn(async () => undefined) } })), + executeNativeSession: vi.fn(async () => { throw new Error("fixture: provider execution is out of scope"); }), + }; +}); + +vi.mock("./acpx-qualification.js", async importOriginal => { + const original = await importOriginal(); + return { + ...original, + resolveAntigravityCandidateAdmission: vi.fn((input: Parameters[0]) => { + grant.targets.push(input.target); + if (!grant.admitted || input.target?.platform !== "linux" || input.target.architecture !== "x64") return undefined; + return { schema: "paperclip.acpx-candidate-admission.v1", companyId: input.companyId, agent: "antigravity", model: input.model, + platform: "linux", architecture: "x64" }; + }), + }; +}); + +vi.mock("./native-runner-file-handoff.js", () => ({ + stageNativeRunnerWakeAttachments: vi.fn(async () => ({ attachments: [], cleanup: async () => undefined })), + renderNativeRunnerStagedAttachmentPrompt: vi.fn(() => null), +})); + +vi.mock("./native-controller-recovery.js", async importOriginal => ({ + ...await importOriginal(), + resolveNativeControllerRecovery: vi.fn(async () => ({ kind: "no_prior_execution" })), +})); + +vi.mock("../../runtime-api.js", async importOriginal => ({ + ...await importOriginal(), + resolveLocalRuntimeApiUrl: vi.fn(() => "http://127.0.0.1:43219"), +})); + +import { NativeProviderStateIncompatibleError, type NativeExecutionInput } from "../../vendor/paperclip-runner/index.js"; +import { antigravityReleasePending } from "./antigravity-release.js"; +import { createRunnerdBackend, executePaperclipNativeSession } from "./native-session-executor.js"; +import * as pluginTaskRuntime from "./plugin-runner-task.js"; +import * as pluginCredentialWriteback from "../plugin-task-credential-writeback.js"; +import { antigravityExecution, emptyDb } from "./antigravity.test-fixture.js"; + +const describeTask = vi.fn(async (operation: { kind: string }) => operation.kind === "describe" + ? { kind: "description", launchPreparationVersion: 1, projectAuthCheckVersion: 1, taskId: "task", + runner: { version: "fixture", digest: `sha256:${"a".repeat(64)}` } } + : { kind: "accepted", taskId: "task" }); +const pluginTarget = () => ({ kind: "remote", transport: "sandbox", providerKey: "plugin", leaseId: "lease", + remoteCwd: "/unused", runnerTask: describeTask }) as unknown as AdapterExecutionTarget; +const sandboxTarget = () => ({ kind: "remote", transport: "sandbox", remoteCwd: "/workspace", + runner: { execute: vi.fn() } }) as unknown as AdapterExecutionTarget; +const runStart = (execution: NativeExecutionInput, runnerExecutionTarget: AdapterExecutionTarget) => + executePaperclipNativeSession({ db: emptyDb(), execution, useRunnerd: true, runnerInstanceId: "antigravity-run-start", + runnerIngressAuthorized: true, runnerExecutionTarget }); +const INELIGIBLE = /paperclip_runner_antigravity_candidate_ineligible/; + +let ownerFactory: MockInstance; +beforeEach(() => { + grant.admitted = false; grant.targets = []; backend.options = undefined; + describeTask.mockClear(); + ownerFactory = vi.spyOn(pluginTaskRuntime, "createPluginRunnerTaskOwner"); +}); +afterEach(() => { release.pending = false; ownerFactory.mockRestore(); vi.unstubAllEnvs(); }); + +describe("Antigravity run start while the profile is pending", () => { + beforeEach(() => { release.pending = true; }); + + it.each([["plugin Runner-task", pluginTarget], ["Core sandbox", sandboxTarget]] as const)( + "refuses a %s run without an operator grant before any launch", async (_name, target) => { + expect(antigravityReleasePending()).toBe(true); + await expect(runStart(antigravityExecution(), target())).rejects.toThrow(INELIGIBLE); + expect(describeTask).not.toHaveBeenCalled(); + expect(ownerFactory).not.toHaveBeenCalled(); + expect(backend.options).toBeUndefined(); + }); + + it("admits a granted Core sandbox run past the gate, and still refuses the same grant on a plugin Runner-task target", async () => { + grant.admitted = true; + const admitted = await runStart(antigravityExecution(), sandboxTarget()).then(() => null, (error: unknown) => error); + expect(String(admitted)).not.toMatch(INELIGIBLE); + expect(grant.targets).toContainEqual({ platform: "linux", architecture: "x64" }); + await expect(runStart(antigravityExecution(), pluginTarget())).rejects.toThrow(INELIGIBLE); + expect(describeTask).not.toHaveBeenCalled(); + expect(ownerFactory).not.toHaveBeenCalled(); + }); +}); + +describe("Antigravity run start once the profile is released", () => { + it("passes the gate on a plugin Runner-task target and refuses state saved under another profile version", async () => { + expect(antigravityReleasePending()).toBe(false); + const current = await runStart(antigravityExecution(), pluginTarget()).then(() => null, (error: unknown) => error); + expect(String(current)).not.toMatch(INELIGIBLE); + expect(current).not.toBeInstanceOf(NativeProviderStateIncompatibleError); + const older = antigravityExecution(); + (older.provider as { profile: { agentProfileVersion: number } }).profile.agentProfileVersion -= 1; + await expect(runStart(older, pluginTarget())).rejects.toBeInstanceOf(NativeProviderStateIncompatibleError); + }); + + it.each(["api_key", "sign_in"] as const)("hands a %s plugin Runner task only its typed credential", async method => { + const directory = await realpath(await mkdtemp(join(tmpdir(), "antigravity-run-start-"))); + vi.stubEnv("PAPERCLIP_RUNNER_STATE_DIR", join(directory, "runner")); + const managedHome = join(directory, "managed-home"); + await mkdir(join(managedHome, "antigravity-acp"), { recursive: true, mode: 0o700 }); + const signIn = JSON.stringify({ + client_id: "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com", client_secret: "fixture-client-secret", + refresh_token: "fixture-google-refresh", token_uri: "https://oauth2.googleapis.com/token", + scopes: ["https://www.googleapis.com/auth/cloud-platform", "https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/aicode"], + }); + await writeFile(join(managedHome, "antigravity-acp", "acp_token.json"), signIn, { mode: 0o600 }); + const owner = { launcher: vi.fn(), registration: vi.fn(), readWorkspaceFile: vi.fn(), isRetired: () => false, rebind: vi.fn(), + driver: { authorityRunId: "run", prepareLaunch: vi.fn(), runnerProcessLauncher: vi.fn(), controlPlaneRegistration: vi.fn() } }; + ownerFactory.mockReturnValue(owner as never); + const handoff = vi.spyOn(pluginCredentialWriteback, "registerPluginTaskCredentialHandoff").mockResolvedValue(undefined as never); + try { + await createRunnerdBackend({ db: emptyDb(), execution: antigravityExecution(), runnerInstanceId: "antigravity-run-start", + runnerIngressAuthorized: true, managedAiCredentialHome: managedHome, managedAiCredentialIdentity: "revision", + managedAiAccountIdentity: "account", + ...(method === "sign_in" ? { managedAiCredentialWriteback: { grantId: "10000000-0000-4000-8000-0000000000a1", + secretId: "10000000-0000-4000-8000-0000000000a2", sessionEpoch: 1, versionSelector: "latest" as const, + google: { credentialSha256: "c".repeat(64) } } } : {}), + runnerEnvironment: { ...(method === "api_key" ? { GEMINI_API_KEY: "fixture-gemini" } : {}), + GOOGLE_API_KEY: "ambient-google", GEMINI_HOME: "/ambient" }, + runnerExecutionTarget: pluginTarget() }); + await backend.options!.codexTransportFactory!(); + expect(ownerFactory).toHaveBeenCalledOnce(); + expect(ownerFactory).toHaveBeenCalledWith(expect.objectContaining({ credential: { type: "provider-env", provider: "antigravity", + environment: method === "api_key" ? { GEMINI_API_KEY: "fixture-gemini" } : { PAPERCLIP_ACPX_ANTIGRAVITY_AUTH_JSON_SECRET: signIn } } })); + expect(handoff).toHaveBeenCalledTimes(method === "sign_in" ? 1 : 0); + } finally { + handoff.mockRestore(); + await rm(directory, { recursive: true, force: true }); + } + }); +}); diff --git a/server/src/services/native-runtime/antigravity.test-fixture.ts b/server/src/services/native-runtime/antigravity.test-fixture.ts new file mode 100644 index 00000000000..68ca4d45e89 --- /dev/null +++ b/server/src/services/native-runtime/antigravity.test-fixture.ts @@ -0,0 +1,35 @@ +import type { Db } from "@paperclipai/db"; +import { QUALIFIED_ACPX_PROFILES, type NativeExecutionInput } from "../../vendor/paperclip-runner/index.js"; +import { buildNativeExecutionInput } from "./native-execution-input.js"; +import { nativeRuntimeContextFixture } from "./runtime-context.test-fixture.js"; + +export const ANTIGRAVITY_FIXTURE_COMPANY_ID = "10000000-0000-4000-8000-000000000001"; +export const ANTIGRAVITY_FIXTURE_MODEL = "gemini-3.8-flash-low"; + +export function emptyDb(): Db { + const db: Db = new Proxy(() => undefined, { + get: (_target, key) => key === "then" ? (resolve: (rows: unknown[]) => unknown) => resolve([]) + : key === "transaction" ? async (operation: (tx: Db) => unknown) => operation(db) + : () => db, + apply: () => db, + }) as unknown as Db; + return db; +} + +export function antigravityExecution(input: { runId?: string; issueId?: string; workspaceId?: string; sessionId?: string } = {}) { + const runId = input.runId ?? "40000000-0000-4000-8000-000000000004"; + const execution = buildNativeExecutionInput({ + companyId: ANTIGRAVITY_FIXTURE_COMPANY_ID, runId, agentId: "30000000-0000-4000-8000-000000000003", + issue: { id: input.issueId ?? "20000000-0000-4000-8000-000000000002", identifier: "AG-1", title: "Test", description: null, workMode: "standard" }, + taskPrompt: "Only the current turn", + workspace: { id: input.workspaceId ?? "90000000-0000-4000-8000-000000000009", cwd: "/workspace", repoUrl: null, repoRef: null, branchName: null }, + normalizedSessionId: input.sessionId ?? "60000000-0000-4000-8000-000000000006", + provider: "acpx", acpxAgent: "antigravity", model: ANTIGRAVITY_FIXTURE_MODEL, acpxPermissionMode: "approve-all", + completionContract: { id: "70000000-0000-4000-8000-000000000007", sha256: `sha256:${"a".repeat(64)}`, schemaVersion: "paperclip.run-result.v1", + contract: { revision: "1", objective: "Test", criteria: [{ id: "objective", requirement: "Answer" }] } }, + runtimeContext: nativeRuntimeContextFixture(), + }) as NativeExecutionInput; + (execution.provider as { profile: { agentProfileVersion: number } }).profile.agentProfileVersion = + QUALIFIED_ACPX_PROFILES.antigravity.agentProfileVersion; + return execution; +}