mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 20:00:32 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The Paperclip Runner executes Google Antigravity agents on local hosts and remote sandboxes > - Previously, Paperclip shipped two separate Google runtimes: an 853 MiB IDE-extension ACP bundle (`agy_acp_server.par` 1.5.2 + `localharness_external` + Python admission monkey-patch) for ordinary turns and a separate `agy` 1.5.15 CLI binary for local-only `/swarm` turns > - Because the legacy server lacked `/swarm` and the CLI path refused remote targets and required macOS Keychain or Linux user namespaces (`auto` mode), remote sandboxes could not run `/swarm` and carried 853 MiB of legacy binaries > - This pull request unifies all Antigravity surfaces (ordinary turns, `/swarm`, interactive sign-in, and model discovery) onto one pinned `agy` 1.5.19 CLI binary (`1.5.19-4821414830800896`) with file-backed OAuth isolation (`AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1`) and `--dangerously-skip-permissions` support for remote sandboxes > - The benefit is one 268 MiB Linux binary instead of 853 MiB (saving ~585 MiB in remote images), no Python runtime monkey-patching, full `/swarm` support on both local and remote hosts, and a unified 25-model catalog including Gemini 4 Neon, Carbon, Hydrogen, and Argon ## Linked Issues or Issue Description **What existing behavior does this improve?** The Google Antigravity Runner driver, provider pack materialization, Google sign-in flow, model discovery, and `/swarm` execution in `packages/paperclip-runner`, `packages/shared`, `server`, and `ui`. **Subsystem affected** Cross-cutting (multiple of the above) **Current behavior** Ordinary Antigravity turns use the legacy 1.5.2 IDE-extension ACP server (`agy_acp_server.par` + `localharness_external` + Python monkey-patch) at ~853 MiB on `linux-x64`. Native `/swarm` turns require a separate `agy` 1.5.15 CLI binary, refuse remote execution targets (`input.remote`), and fail on Linux sandboxes without user namespaces (`auto` mode). **Proposed behavior** All Antigravity flows use one pinned `agy` 1.5.19 binary (`1.5.19-4821414830800896`, ~268 MiB on `linux-x64`) across all four platforms (`darwin-arm64`, `darwin-x64`, `linux-x64`, `linux-arm64`). Ordinary turns speak ACP directly through `openAntigravityAcpRuntime`. Both ordinary and `/swarm` turns stage file-backed OAuth tokens under `<agentHomeDirectory>/antigravity-cli/antigravity-oauth-token` with `AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1`, isolate from host keychains, and allow `/swarm` on remote targets using `--dangerously-skip-permissions`. Interactive Google sign-in runs `agy acp --login` with `https://antigravity.google/oauth-callback`, pre-creates `<home>/antigravity-cli` with mode `0700`, and prompts for the authorization code in the UI. **Reason and benefit** Unifying onto `agy` 1.5.19 cuts the `linux-x64` provider-pack footprint by ~585 MiB, removes Python bytecode patching from materialization, enables `/swarm` in headless Linux sandboxes without user namespaces or D-Bus, and aligns ordinary turns, model discovery, and `/swarm` on the same 25-model catalog. **Breaking changes** - `acpx-profiles.json` bumps `antigravity` to `agentProfileVersion: 3` (`native:antigravity-cli`, version `1.5.19`). Existing saved legacy 1.5.2 sessions fail closed as incompatible saved state and start fresh cleanly. - Existing Google OAuth connections carrying `client_secret` remain fully backward-compatible; new `agy acp --login` connections store canonical credentials with `auth_method: "consumer"` and no `client_secret`. ## What Changed - Pin `agy` `1.5.19-4821414830800896` across all four platforms (`darwin-arm64`, `darwin-x64`, `linux-x64`, `linux-arm64`) in `antigravity-distributions.json`, `antigravity-cli-distributions.json`, `antigravity-cli-pins.ts`, and `acpx-profiles.json` (`agentProfileVersion: 3`), and regenerate TypeScript and Rust profile artifacts. - Replace ZIP + Python patch materialization with strict single-member `tar.gz` verification (`materialize-antigravity-distribution.mjs`, `provision-antigravity.mjs`, `probe-antigravity-metadata.mjs`, `candidate-provider-pack.mjs`, `release-provider-pack.mjs`). - Regenerate `packages/shared/src/antigravity-models.generated.ts` from `agy` 1.5.19 (25 models across 8 families, including Gemini 4 Neon, Carbon, Hydrogen, and Argon) and update `packages/shared/src/antigravity-models.ts` and `tests/runner-e2e/antigravity-qualification-cases.ts` for `xhigh` thinking levels. - Add direct ACP runtime `packages/paperclip-runner/src/drivers/acpx/antigravity-acp-runtime.ts` (`openAntigravityAcpRuntime`) for ordinary Antigravity turns with OAuth and `GEMINI_API_KEY` support, `session/new` + `session/resume`, `readOnly`/plan mode enforcement, HTTP and stdio MCP forwarding, live `setModel`, slash-command neutralization, refusal classification, cancellation, and lineage retirement; route ordinary Antigravity turns unconditionally in `acpx-runtime-adapter.ts` without an ACPX fallback seam. - Update `antigravity-auth.ts`, `antigravity-credentials.ts`, `antigravity-models.ts`, `antigravity-process.ts`, `runtime-host.ts`, and `runtime-sandbox.ts` to run `agy acp --login`, pre-create `<home>/antigravity-cli` with mode `0700` (preventing Go `os.MkdirAll` `0755` readback failures), force file-backed token storage (`AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1`), align `--gemini-dir` with `agentHomeDirectory`, bound model-discovery token sync cleanup, and scrub live CLI token files on cleanup. - Enable remote `/swarm` by removing the `input.remote` refusal in `server/src/services/antigravity-swarm.ts` and allowing `--dangerously-skip-permissions` + `default` mode in `antigravity-swarm-route.ts`, `antigravity-swarm-guard.ts`, and `antigravity-swarm-runtime.ts` when `permissionMode === "approve-all"`. - Update `ui/src/components/AdapterLoginChrome.tsx` copy to prompt for an authorization code (`Submit code`) for `https://antigravity.google/oauth-callback` while preserving callback URL handling for loopback redirects. - Add unit tests for `openAntigravityAcpRuntime`, direct Antigravity routing, `0700` token directory pre-creation, and hosted authorization-code login UX, and update Runner, script, shared, server, Rust, UI, and runner-e2e test suites for `agy` 1.5.19. ## Verification - Runner driver tests: `vitest run` across Antigravity driver test files (`antigravity-auth.test.ts`, `antigravity-models.test.ts`, `antigravity-acp-runtime.test.ts`, `antigravity-swarm-route.test.ts`, `codex-credentials.test.ts`, `acpx-runtime-adapter.test.ts`, `candidate-admission.test.ts`, `native-distribution-integrity.test.ts`) — all passing. - Runner script tests: `node --test` across all 7 Antigravity & provider-pack script suites — 98/98 passed. - Shared, UI, Server, and runner-e2e tests: `antigravity-models.test.ts`, `AdapterLoginChrome.test.tsx` (23/23), `antigravity-thread.test.tsx`, 23 server Antigravity/provider-pack suites, and 7 `runner-e2e` Antigravity suites — all passing. - Rust tests: `cargo test --manifest-path packages/paperclip-runner/runner/Cargo.toml --locked -p paperclip-runner-core -- acpx antigravity` — 145/145 passed. - Typechecks & generators: `@paperclipai/shared`, `@paperclipai/paperclip-runner` (TS + Rust), `@paperclipai/server` (all layers), `@paperclipai/ui`, `generate-acpx-profiles.mjs --check`, `generate-antigravity-models.mjs --check` — all passing. - Live E2E against real pinned `agy` 1.5.19 binaries (macOS `darwin-arm64`, headless Linux `linux-arm64` Docker with `--security-opt no-new-privileges`, and a live remote test deployment): - Verified `materialize-antigravity-distribution.mjs` on all 4 platform archives and `probe-antigravity-metadata.mjs` on macOS and headless Linux Docker. - Verified live Google OAuth sign-in end-to-end via `agy acp --login` + `https://antigravity.google/oauth-callback` authorization code exchange on a live remote deployment, creating a working Antigravity connection. - Verified `stageManagedAntigravityCredential` + `AGY_CLI_FORCE_FILE_TOKEN_STORAGE=1` file-backed isolation and cleanup scrub on macOS and headless Linux Docker. - Verified live `openAntigravityAcpRuntime` ordinary turn + HTTP MCP tool call + `_meta.antigravity.systemPrompt.append` + `setModel(gemini-4-argon-low)` + `session/resume` on real `agy` 1.5.19. - Verified live `openAntigravitySwarmRuntime` `/swarm` turn with `--dangerously-skip-permissions` spawning a real helper, writing workspace file, calling `paperclip_finish`, and retiring cleanly. ## Risks - **Coordinated Cloud deployment**: Remote sandboxes use the companion transition-safe Cloud update to expect `provider-assets/antigravity/linux-x64/agy`, accept `auth_method: "consumer"` credentials without `client_secret`, and scrub `antigravity-cli/antigravity-oauth-token`. - **Saved session continuity**: Existing saved 1.5.2 sessions fail closed as `ANTIGRAVITY_SAVED_STATE_INCOMPATIBLE` and start fresh cleanly on 1.5.19. ## Model Used - Google Gemini (Antigravity agentic coding assistant, reasoning/tool-use/code-execution enabled) ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [x] All Paperclip CI gates are green - [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
309 lines
25 KiB
TypeScript
309 lines
25 KiB
TypeScript
import { mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { QUALIFIED_ACPX_PROFILES } from "../../packages/paperclip-runner/src/drivers/acpx/qualified-profiles.js";
|
|
import { ANTIGRAVITY_DISTRIBUTION_PINS } from "../../packages/paperclip-runner/src/drivers/acpx/generated-profiles.js";
|
|
import { antigravityCandidateAdmissionForExecution, isAntigravityAdmittedExecution } from "./antigravity-admission.js";
|
|
import { ANTIGRAVITY_API_KEY_LINEUP, ANTIGRAVITY_GEMINI4_LINEUP, antigravityLineupProfileId } from "./antigravity-qualification-cases.js";
|
|
import { runnerMatrix, runnerSuites } from "./catalog.js";
|
|
import { buildRunnerE2EProcessEnvironment, buildPaperclipServerEnvironment } from "./harness-env.js";
|
|
import { evaluateMatchers } from "./matchers.js";
|
|
import { observeActiveStopPending, readActiveStopCaller, readActiveStopSettlement, readDeniedPermissionSettlement } from "./native-active-stop-evidence.js";
|
|
import { assertProviderLossSettlement } from "./native-provider-loss-flow.js";
|
|
import { buildMatrixJobs, daytonaCandidateProviders, parseRunnerSelectors, selectRunnerExecutions } from "./selectors.js";
|
|
import { readRestartRequest } from "./server-restart-request.js";
|
|
|
|
type Row = Record<string, any>;
|
|
const suiteId = "antigravity-qualification";
|
|
const cells = runnerMatrix.filter(cell => cell.suite.id === suiteId);
|
|
const companyId = "11111111-1111-4111-8111-111111111111";
|
|
const select = (...args: string[]) => selectRunnerExecutions(parseRunnerSelectors(args));
|
|
|
|
describe("Google Antigravity explicit Product qualification", () => {
|
|
it("lists twelve journeys in local and Daytona without entering --all", () => {
|
|
expect(cells).toHaveLength(24);
|
|
expect(new Set(cells.map(cell => cell.environment.id))).toEqual(new Set(["local", "daytona"]));
|
|
expect(new Set(cells.map(cell => cell.task.id))).toEqual(new Set([
|
|
"message-marker", "plan-revise-accept", "ask-question", "structured-question-resume", "structured-question-restart-resume",
|
|
"file-edit-validate", "warm-three-turn", "stop-new-resume", "continuity-restart", "pending-permission-stop", "permission-deny-stop", "pending-permission-provider-loss",
|
|
]));
|
|
expect(select("--suite", suiteId)).toHaveLength(24);
|
|
expect(select("--all").some(cell => cell.profile.qualificationCandidate === "antigravity")).toBe(false);
|
|
expect(() => select("--profile", "runner-acpx-antigravity")).toThrow("zero executions");
|
|
expect(runnerSuites.find(suite => suite.id === suiteId)?.definitionMetadata).toMatchObject({
|
|
model: "gemini-3.8-flash-low", authentication: "gemini-api-key", scheduling: "explicit-only",
|
|
qualification: QUALIFIED_ACPX_PROFILES.antigravity.qualificationStatus === "pending" ? "pending" : "qualified",
|
|
});
|
|
});
|
|
|
|
it("reuses the shared lifecycle fixtures on per-turn Daytona leases", () => {
|
|
const lifecycle = cells.filter(cell => cell.task.flow === "native_active_stop" || cell.task.flow === "native_provider_loss");
|
|
expect(lifecycle.map(cell => cell.task.id).sort()).toEqual(["pending-permission-provider-loss", "pending-permission-provider-loss", "pending-permission-stop", "pending-permission-stop", "permission-deny-stop", "permission-deny-stop"]);
|
|
const cursorLoss = runnerMatrix.find(cell => cell.suite.id === "native-provider-loss" && cell.environment.id === "local")!;
|
|
expect(cells.find(cell => cell.task.id === "pending-permission-provider-loss")!.task.buildPrompt("n")).toBe(cursorLoss.task.buildPrompt("n"));
|
|
for (const cell of lifecycle.filter(cell => cell.environment.id === "daytona")) expect(cell.environment.configurationKey).toBeUndefined();
|
|
const warmDaytona = cells.find(cell => cell.environment.id === "daytona" && cell.task.id === "message-marker")!;
|
|
expect(warmDaytona.environment).not.toBe(lifecycle.find(cell => cell.environment.id === "daytona")!.environment);
|
|
});
|
|
|
|
it("binds only the selected encrypted Gemini key on a per-turn native agent", () => {
|
|
const ref = { type: "secret_ref" as const, secretId: "22222222-2222-4222-8222-222222222222", version: "latest" as const };
|
|
for (const cell of cells) {
|
|
expect(cell.suite.manualOnly).toBe(true);
|
|
expect(cell.task.automaticRetryPolicy).toBe("single_attempt");
|
|
expect(cell.requiredCredentials).toEqual(cell.environment.id === "local" ? ["GEMINI_API_KEY"] : ["GEMINI_API_KEY", "DAYTONA_API_KEY"]);
|
|
expect(cell.profile).toMatchObject({ id: "runner-acpx-antigravity", qualificationCandidate: "antigravity", model: "gemini-3.8-flash-low", credential: "GEMINI_API_KEY" });
|
|
expect(cell.profile.buildAgent({ executionId: cell.id, environmentId: "env", environmentFixtureId: cell.environment.id,
|
|
workspacePath: "/workspace", secretRefs: { GEMINI_API_KEY: ref } })).toMatchObject({
|
|
adapterType: "paperclip_runner", adapterConfig: { provider: "acpx", acpxAgent: "antigravity", model: "gemini-3.8-flash-low",
|
|
lifecycleMode: "per_turn", timeoutSec: 120, env: { GEMINI_API_KEY: ref } },
|
|
});
|
|
}
|
|
});
|
|
|
|
it("admits CI matrix jobs for unattended cells but still refuses the attended journey", () => {
|
|
const jobs = buildMatrixJobs(select("--suite", suiteId));
|
|
expect(jobs).toHaveLength(24);
|
|
expect(new Set(jobs.map(job => job.credentialName))).toEqual(new Set(["GEMINI_API_KEY"]));
|
|
expect(jobs.filter(job => job.needsDaytona)).toHaveLength(12);
|
|
expect(() => buildMatrixJobs(select("--suite", "antigravity-agent-journey"))).toThrow("Attended connection journeys");
|
|
});
|
|
|
|
it("asks CI for an Antigravity image and controller pack only for pending Daytona cells", () => {
|
|
const pending = QUALIFIED_ACPX_PROFILES.antigravity.qualificationStatus === "pending";
|
|
expect(daytonaCandidateProviders(select("--suite", suiteId))).toEqual(pending ? ["antigravity"] : []);
|
|
expect(daytonaCandidateProviders(select("--suite", suiteId, "--environment", "local"))).toEqual([]);
|
|
// Released providers live in the default pack and are never requested.
|
|
expect(daytonaCandidateProviders(select("--id", "rolling-web-deployment.runner-acpx-kimi.daytona.recover-controller"))).toEqual([]);
|
|
});
|
|
|
|
it("keeps candidate authority out of the shared operator list and rejects unrelated suites", () => {
|
|
const cell = cells[0]!;
|
|
const ambient = { PAPERCLIP_RUNNER_ACPX_QUALIFICATION: "ambient", PAPERCLIP_ACPX_CANDIDATE_ADMISSION: "ambient" };
|
|
const env = buildRunnerE2EProcessEnvironment(ambient, cells);
|
|
expect(env.PAPERCLIP_RUNNER_ACPX_QUALIFICATION).toBeUndefined();
|
|
expect(env.PAPERCLIP_ACPX_CANDIDATE_ADMISSION).toBeUndefined();
|
|
for (const suite of [{ ...cell.suite, manualOnly: false }, { ...cell.suite, id: "extended-harnesses" }, { ...cell.suite, id: "kimi-qualification" }]) {
|
|
expect(() => buildRunnerE2EProcessEnvironment({}, [{ ...cell, suite }])).toThrow("explicit provider qualification suite");
|
|
}
|
|
expect(() => buildRunnerE2EProcessEnvironment({}, [{ ...cell, profile: { ...cell.profile, id: "unrelated-profile" } }])).toThrow("explicit provider qualification suite");
|
|
const chat = runnerMatrix.find(row => row.suite.id === "chat-features" && row.profile.qualificationCandidate === "antigravity")!;
|
|
expect(isAntigravityAdmittedExecution(chat)).toBe(true);
|
|
expect(isAntigravityAdmittedExecution({ ...chat, profile: { ...chat.profile, explicitOnly: undefined } })).toBe(false);
|
|
});
|
|
|
|
it("removes ambient Google credentials before starting the product server", () => {
|
|
const source = { GEMINI_API_KEY: "selected", GOOGLE_API_KEY: "ambient", GOOGLE_APPLICATION_CREDENTIALS: "/adc.json", GEMINI_HOME: "/login" };
|
|
const server = buildPaperclipServerEnvironment(source);
|
|
for (const name of Object.keys(source)) expect(server[name]).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe("Antigravity company-bound candidate grant", () => {
|
|
const local = cells.find(cell => cell.environment.id === "local")!;
|
|
const remote = cells.find(cell => cell.environment.id === "daytona")!;
|
|
const pending = QUALIFIED_ACPX_PROFILES.antigravity.qualificationStatus === "pending";
|
|
|
|
it.runIf(pending)("binds the disposable company, exact model, digests and darwin-arm64 target", () => {
|
|
const now = Date.now();
|
|
expect(antigravityCandidateAdmissionForExecution(local, companyId, now, { platform: "darwin", arch: "arm64" })).toMatchObject({
|
|
schema: "paperclip.acpx-candidate-admission.v1", companyId, agent: "antigravity", model: "gemini-3.8-flash-low",
|
|
profileDigest: QUALIFIED_ACPX_PROFILES.antigravity.commandDigest, platform: "darwin", architecture: "arm64", expiresAt: now + 3_600_000,
|
|
});
|
|
expect(() => antigravityCandidateAdmissionForExecution(local, "not-a-company")).toThrow("exact disposable company");
|
|
expect(() => antigravityCandidateAdmissionForExecution({ ...local, suite: { ...local.suite, id: "extended-harnesses" } }, companyId)).toThrow("explicit Antigravity suite");
|
|
expect(antigravityCandidateAdmissionForExecution({ ...local, profile: { ...local.profile, qualificationCandidate: "kimi" } }, companyId)).toBeUndefined();
|
|
});
|
|
|
|
it.runIf(pending)("stages a linux-x64 grant with the patched closure for a Daytona cell on any controller host", () => {
|
|
const now = Date.now();
|
|
for (const host of [{ platform: "darwin", arch: "arm64" }, { platform: "linux", arch: "x64" }] as const) {
|
|
expect(antigravityCandidateAdmissionForExecution(remote, companyId, now, host)).toMatchObject({
|
|
companyId, agent: "antigravity", model: "gemini-3.8-flash-low", platform: "linux", architecture: "x64",
|
|
nativeClosureDigest: `sha256:${ANTIGRAVITY_DISTRIBUTION_PINS["linux-x64"].closureSha256}`, expiresAt: now + 3_600_000,
|
|
});
|
|
}
|
|
});
|
|
|
|
it.runIf(pending)("fails before provider spend on a target without an admitted closure", () => {
|
|
expect(() => antigravityCandidateAdmissionForExecution(local, companyId, Date.now(), { platform: "win32", arch: "x64" })).toThrow(/no admitted runtime closure|does not match/i);
|
|
});
|
|
|
|
it.runIf(pending)("stages the grant only for a selected Antigravity cell and its model", async () => {
|
|
const root = await mkdtemp(join(tmpdir(), "antigravity-restart-"));
|
|
try {
|
|
const path = join(root, "request.json"), grant = antigravityCandidateAdmissionForExecution(local, companyId, Date.now(), process)!;
|
|
if (`${process.platform}-${process.arch}` !== "darwin-arm64") return;
|
|
await writeFile(path, JSON.stringify({ requestId: "antigravity-startup", kimiCandidateAdmission: grant }));
|
|
await expect(readRestartRequest(path, [local.id])).resolves.toMatchObject({ kimiCandidateAdmission: { agent: "antigravity", companyId } });
|
|
await expect(readRestartRequest(path, [runnerMatrix.find(cell => cell.suite.id === "kimi-qualification")!.id])).rejects.toThrow("explicit Kimi or Antigravity");
|
|
await writeFile(path, JSON.stringify({ requestId: "antigravity-startup", kimiCandidateAdmission: { ...grant, model: "gemini-3.1-pro-low" } }));
|
|
await expect(readRestartRequest(path, [local.id])).rejects.toThrow("does not match the selected execution");
|
|
} finally { await rm(root, { recursive: true, force: true }); }
|
|
expect(remote.environment.expectedExecutionTarget.kind).toBe("remote");
|
|
});
|
|
|
|
it.runIf(!pending)("needs no grant once the profile is released", () => {
|
|
expect(antigravityCandidateAdmissionForExecution(local, companyId)).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe("Antigravity model lineups", () => {
|
|
it("parameterises one exact-model cell per API-key and Gemini 4 model", () => {
|
|
for (const [suite, models] of [["antigravity-model-lineup", ANTIGRAVITY_API_KEY_LINEUP], ["antigravity-model-lineup-gemini4", ANTIGRAVITY_GEMINI4_LINEUP]] as const) {
|
|
const lineup = runnerMatrix.filter(cell => cell.suite.id === suite);
|
|
expect(lineup.map(cell => cell.profile.model)).toEqual(models);
|
|
expect(lineup.every(cell => cell.environment.id === "local" && cell.task.id === "model-receipt" && cell.id === `${suite}.${antigravityLineupProfileId(cell.profile.model)}.local.model-receipt`)).toBe(true);
|
|
expect(lineup.every(cell => cell.id.split(".").length === 4)).toBe(true);
|
|
expect(select("--suite", suite)).toHaveLength(models.length);
|
|
expect(lineup.every(isAntigravityAdmittedExecution)).toBe(true);
|
|
expect(() => buildRunnerE2EProcessEnvironment({}, lineup)).not.toThrow();
|
|
expect(buildMatrixJobs(lineup).every(job => job.credentialName === "GEMINI_API_KEY" && !job.needsDaytona)).toBe(true);
|
|
}
|
|
// Exactly what a 1.5.19 `gemini-api-key` session lists for Gemini 3 (live, prompt-free).
|
|
expect(ANTIGRAVITY_API_KEY_LINEUP).toEqual([
|
|
"gemini-3.8-flash-high", "gemini-3.8-flash-medium", "gemini-3.8-flash-low",
|
|
"gemini-3.7-flash-high", "gemini-3.7-flash-medium", "gemini-3.7-flash-low",
|
|
"gemini-3.6-flash-high", "gemini-3.6-flash-medium", "gemini-3.6-flash-low",
|
|
"gemini-3.1-pro-high", "gemini-3.1-pro-low",
|
|
]);
|
|
expect(ANTIGRAVITY_API_KEY_LINEUP).not.toContain("gemini-3.1-pro-extra_high");
|
|
// Each Gemini 4 family keeps its own levels; none offers minimal.
|
|
expect(ANTIGRAVITY_GEMINI4_LINEUP).toEqual([
|
|
"gemini-4-neon-high", "gemini-4-neon-xhigh", "gemini-4-neon-medium", "gemini-4-neon-low",
|
|
"gemini-4-carbon-high", "gemini-4-carbon-medium", "gemini-4-carbon-low",
|
|
"gemini-4-hydrogen-high", "gemini-4-hydrogen-xhigh", "gemini-4-hydrogen-medium", "gemini-4-hydrogen-low",
|
|
"gemini-4-argon-high", "gemini-4-argon-medium", "gemini-4-argon-low",
|
|
]);
|
|
expect(() => antigravityLineupProfileId("auto")).toThrow("Invalid Antigravity model ID");
|
|
});
|
|
|
|
it("requires the Runner's exact-model receipt, not merely a reply", async () => {
|
|
const cell = runnerMatrix.find(row => row.suite.id === "antigravity-model-lineup-gemini4" && row.profile.model === "gemini-4-neon-high")!;
|
|
const receiptMatchers = cell.task.buildMatchers("nonce", cell).filter(matcher => matcher.kind === "json_path");
|
|
expect(receiptMatchers).toHaveLength(4);
|
|
const run = (effectiveModel: string) => ({ runnerProfileJson: { nativeExecutionInput: { provider: { kind: "acpx", agent: "antigravity", model: "gemini-4-neon-high" } },
|
|
sessionCheckpoint: { providerIdentity: { requestedModel: "gemini-4-neon-high", effectiveModel } } } });
|
|
const grade = (value: Row) => evaluateMatchers(receiptMatchers, { message: "", json: { run: value } } as never);
|
|
expect((await grade(run("gemini-4-neon-high"))).every(result => result.passed)).toBe(true);
|
|
expect((await grade(run("gemini-4-neon-low"))).every(result => result.passed)).toBe(false);
|
|
expect((await grade({})).some(result => result.passed)).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("Antigravity opt-in profiles in shared eval suites", () => {
|
|
it.each(["chat-features", "native-completion"])("%s keeps Antigravity behind an explicit profile selector", suite => {
|
|
const all = select("--suite", suite);
|
|
expect(all.some(cell => cell.profile.qualificationCandidate === "antigravity")).toBe(false);
|
|
const opted = select("--suite", suite, "--profile", "runner-acpx-antigravity");
|
|
expect(opted.length).toBeGreaterThan(0);
|
|
expect(opted.every(cell => cell.profile.qualificationCandidate === "antigravity" && cell.profile.explicitOnly === true)).toBe(true);
|
|
expect(() => buildRunnerE2EProcessEnvironment({}, opted.slice(0, 1))).not.toThrow();
|
|
});
|
|
});
|
|
|
|
describe("Antigravity pending-permission lifecycle evidence", () => {
|
|
const caller = readActiveStopCaller({ deploymentMode: "local_trusted" }, { session: { userId: "local-board", id: "paperclip:local_implicit:local-board" } });
|
|
const cancellationRequestId = "11111111-2222-4333-8444-555555555555";
|
|
function fixture() {
|
|
const scope = { provider: "antigravity" as const, companyId: "company", issueId: "issue", runId: "run", target: "pc-denied/active-stop.txt" };
|
|
const row = (eventType: string, payload: Row): Row => {
|
|
const seq = events.length + 1;
|
|
return { companyId: "company", runId: "run", seq, eventType, protocolSchemaVersion: 1,
|
|
payload: { prpEvent: { schema: "paperclip.prp.event.v1", schemaVersion: 1, sourceKind: "runner", eventType, runId: "run", turnId: "turn",
|
|
normalizedSessionId: "session", sourceInstanceId: "runner", sourceSeq: seq, sourceEventId: `runner:run:${seq}`, emittedAt: "2026-11-22T00:00:00Z", payload } } };
|
|
};
|
|
const tool = (executionId: string, operation: string, target: string | null, status = "running") => ({ schema: "paperclip.tool.execution.v1", executionId, transport: "builtin", name: null, operation, target, status });
|
|
const events: Row[] = [];
|
|
const push = (eventType: string, payload: Row) => { events.push(row(eventType, payload)); };
|
|
push("tool.execution.started", tool("read-1", "read", "README.md"));
|
|
push("tool.execution.completed", tool("read-1", "read", "README.md", "completed"));
|
|
push("tool.execution.started", tool("write-1", "edit", scope.target));
|
|
push("runtime_request.created", { request: { schema: "paperclip.runtime_request.v2", type: "permission", requestKind: "permission_approval", status: "pending",
|
|
requestId: "request", turnId: "turn", itemId: "item", prompt: `Edit ${scope.target}`, details: { toolCallId: "write-1" },
|
|
choices: [{ key: "accept" }, { key: "decline" }], origin: { adapter: "acpx-runtime-sidecar", provider: "antigravity", method: "session/request_permission" } } });
|
|
const run: Row = { id: "run", companyId: "company", nativeIssueId: "issue", runtimeMode: "native", status: "running", resultJson: {}, error: null };
|
|
const issue: Row = { id: "issue", companyId: "company", status: "in_progress" };
|
|
const observe = () => observeActiveStopPending({ events, run, issue, scope, caller, cancellationRequestId });
|
|
return { scope, events, run, issue, push, tool, observe };
|
|
}
|
|
|
|
it("observes the exact pending native edit from canonical events alone", () => {
|
|
const f = fixture();
|
|
expect(f.observe()).toMatchObject({ requestId: "request", toolCallId: "write-1", turnId: "turn", normalizedSessionId: "session" });
|
|
});
|
|
|
|
it("rejects an extra mutation, a completed write, a foreign provider or a missing target", () => {
|
|
const extra = fixture(); extra.events.splice(2, 0, ...[]); extra.push("tool.execution.started", extra.tool("write-2", "edit", "other.txt"));
|
|
expect(() => extra.observe()).toThrow(/extra native operation/);
|
|
const done = fixture(); done.push("tool.execution.completed", done.tool("write-1", "edit", done.scope.target, "completed"));
|
|
expect(() => done.observe()).toThrow(/mutation lifecycle/);
|
|
const foreign = fixture(); foreign.events[3]!.payload.prpEvent.payload.request.origin.provider = "cursor";
|
|
expect(() => foreign.observe()).toThrow(/permission identity/);
|
|
const elsewhere = fixture(); elsewhere.events[2]!.payload.prpEvent.payload.target = null; elsewhere.events[3]!.payload.prpEvent.payload.request.prompt = "Edit file";
|
|
expect(() => elsewhere.observe()).toThrow(/mutation lifecycle/);
|
|
});
|
|
|
|
it("requires cancellation of the retained request for Stop and expiry for provider loss", () => {
|
|
const stop = fixture(), pending = stop.observe(), dispatchMonotonicNs = (BigInt(pending.observedMonotonicNs) + 1n).toString();
|
|
stop.push("runtime_request.cancelled", { requestId: "request", requestKind: "permission_approval", turnId: "turn", itemId: "item", reason: "turn_terminal" });
|
|
stop.push("turn.cancelled", { status: "cancelled", error: null });
|
|
expect(() => readActiveStopSettlement({ events: stop.events, run: stop.run, issue: stop.issue, pending, dispatchMonotonicNs })).toThrow(/acknowledgement/);
|
|
stop.run.status = "cancelled";
|
|
stop.run.resultJson = { startupCancellation: { cancellationRequestId, requestedBy: { type: "board", userId: "local-board" } }, nativeCancellation: {
|
|
schema: "paperclip.native-cancellation.v1", intentId: `native-cancellation:${cancellationRequestId}`, companyId: "company", runId: "run", issueId: "issue", scope: "run",
|
|
dispatched: true, dispatchState: "acknowledged", reasonCode: "cancellation_run_only", effects: ["release_run_resources"], intentAuditId: "intent", acknowledgementAuditId: "ack" } };
|
|
expect(readActiveStopSettlement({ events: stop.events, run: stop.run, issue: stop.issue, pending, dispatchMonotonicNs })).toMatchObject({ branch: "pending_permission_cancelled", replayAllowed: false });
|
|
|
|
const loss = fixture(), lost = loss.observe();
|
|
loss.push("runtime_request.expired", { requestId: "request", requestKind: "permission_approval", turnId: "turn", reason: "provider_process_lost", replayAllowed: false });
|
|
loss.push("turn.failed", { error: { code: "provider_transport_lost" } });
|
|
Object.assign(loss.run, { status: "failed", error: "Provider transport lost" }); loss.issue.status = "blocked";
|
|
expect(assertProviderLossSettlement(loss.run, loss.issue, loss.events, lost)).toMatchObject({ requestClosure: "runtime_request.expired", replayAllowed: false });
|
|
loss.push("tool.execution.completed", loss.tool("write-1", "edit", loss.scope.target, "completed"));
|
|
expect(() => assertProviderLossSettlement(loss.run, loss.issue, loss.events, lost)).toThrow(/completed mutation/);
|
|
});
|
|
|
|
it("requires a delivered decline of the exact request, no completed mutation and the operator's Stop", () => {
|
|
const acknowledged = (run: Row) => Object.assign(run, { status: "cancelled", resultJson: {
|
|
startupCancellation: { cancellationRequestId, requestedBy: { type: "board", userId: "local-board" } }, nativeCancellation: {
|
|
schema: "paperclip.native-cancellation.v1", intentId: `native-cancellation:${cancellationRequestId}`, companyId: "company", runId: "run", issueId: "issue", scope: "run",
|
|
dispatched: true, dispatchState: "acknowledged", reasonCode: "cancellation_run_only", effects: ["release_run_resources"], intentAuditId: "intent", acknowledgementAuditId: "ack" } } });
|
|
const denied = () => {
|
|
const f = fixture(), pending = f.observe();
|
|
f.push("runtime_request.resolved", { requestId: "request", requestKind: "permission_approval", turnId: "turn", itemId: "item", action: "decline" });
|
|
f.push("tool.execution.completed", f.tool("write-1", "edit", f.scope.target, "failed"));
|
|
return { ...f, pending };
|
|
};
|
|
const stopped = denied();
|
|
stopped.push("turn.cancelled", { status: "cancelled", error: null }); acknowledged(stopped.run);
|
|
expect(readDeniedPermissionSettlement({ events: stopped.events, run: stopped.run, issue: stopped.issue, pending: stopped.pending, stopDispatched: true }))
|
|
.toMatchObject({ branch: "denied_then_stopped", requestId: "request", replayAllowed: false });
|
|
// A cancellation nobody asked for is not this journey.
|
|
expect(() => readDeniedPermissionSettlement({ events: stopped.events, run: stopped.run, issue: stopped.issue, pending: stopped.pending, stopDispatched: false })).toThrow(/without the operator's Stop/);
|
|
|
|
const finished = denied();
|
|
finished.push("turn.completed", { status: "completed" }); finished.run.status = "succeeded";
|
|
expect(readDeniedPermissionSettlement({ events: finished.events, run: finished.run, issue: finished.issue, pending: finished.pending, stopDispatched: false }))
|
|
.toMatchObject({ branch: "denied_then_finished" });
|
|
finished.issue.status = "done";
|
|
expect(() => readDeniedPermissionSettlement({ events: finished.events, run: finished.run, issue: finished.issue, pending: finished.pending, stopDispatched: false })).toThrow(/claims completion/);
|
|
|
|
const accepted = fixture(), acceptedPending = accepted.observe();
|
|
accepted.push("runtime_request.resolved", { requestId: "request", requestKind: "permission_approval", turnId: "turn", itemId: "item", action: "accept" });
|
|
accepted.push("turn.cancelled", { status: "cancelled", error: null }); acknowledged(accepted.run);
|
|
expect(() => readDeniedPermissionSettlement({ events: accepted.events, run: accepted.run, issue: accepted.issue, pending: acceptedPending, stopDispatched: true })).toThrow(/denial was not delivered/);
|
|
|
|
const cancelledOnly = fixture(), cancelledPending = cancelledOnly.observe();
|
|
cancelledOnly.push("runtime_request.cancelled", { requestId: "request", requestKind: "permission_approval", turnId: "turn", itemId: "item", reason: "turn_terminal" });
|
|
cancelledOnly.push("turn.cancelled", { status: "cancelled", error: null }); acknowledged(cancelledOnly.run);
|
|
expect(() => readDeniedPermissionSettlement({ events: cancelledOnly.events, run: cancelledOnly.run, issue: cancelledOnly.issue, pending: cancelledPending, stopDispatched: true })).toThrow(/denial was not delivered/);
|
|
|
|
const written = denied();
|
|
written.events.pop(); written.push("tool.execution.completed", written.tool("write-1", "edit", written.scope.target, "completed"));
|
|
written.push("turn.cancelled", { status: "cancelled", error: null }); acknowledged(written.run);
|
|
expect(() => readDeniedPermissionSettlement({ events: written.events, run: written.run, issue: written.issue, pending: written.pending, stopDispatched: true })).toThrow();
|
|
});
|
|
});
|