test(antigravity): prove positive run-start cases reach the coordinator claim with a strict DB fake

The granted-sandbox and released plugin Runner-task cases now assert the run
fails at the coordinator claim and record the exact DB reads that got it
there, instead of only "not the gate error". The fixture DB is a typed fake
that records each read and throws on any method or lock mode the tests do not
use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DottaandClaude Opus 5.5 committed 2026-11-25 09:39:30 -06:00
1 parent 5a683696eb
commit 18b629d7ca
2 files changed
+53 -16

No files matched your search

@@ -73,10 +73,12 @@ const pluginTarget = () => ({ kind: "remote", transport: "sandbox", providerKey:
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",
const runStart = (execution: NativeExecutionInput, runnerExecutionTarget: AdapterExecutionTarget, db = emptyDb()) =>
executePaperclipNativeSession({ db, execution, useRunnerd: true, runnerInstanceId: "antigravity-run-start",
runnerIngressAuthorized: true, runnerExecutionTarget });
const INELIGIBLE = /paperclip_runner_antigravity_candidate_ineligible/;
const COORDINATOR_CLAIM = /^native_finalization_coordinator_missing$/;
const coordinatorReads = [{ table: "native_run_finalizations", locked: false }, { table: "native_run_finalizations", locked: true }];
let ownerFactory: MockInstance<typeof pluginTaskRuntime.createPluginRunnerTaskOwner>;
beforeEach(() => {
@@ -100,8 +102,9 @@ describe("Antigravity run start while the profile is pending", () => {
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);
const db = emptyDb();
await expect(runStart(antigravityExecution(), sandboxTarget(), db)).rejects.toThrow(COORDINATOR_CLAIM);
expect(db.reads).toEqual(coordinatorReads);
expect(grant.targets).toContainEqual({ platform: "linux", architecture: "x64" });
await expect(runStart(antigravityExecution(), pluginTarget())).rejects.toThrow(INELIGIBLE);
expect(describeTask).not.toHaveBeenCalled();
@@ -112,12 +115,14 @@ describe("Antigravity run start while the profile is pending", () => {
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 db = emptyDb();
await expect(runStart(antigravityExecution(), pluginTarget(), db)).rejects.toThrow(COORDINATOR_CLAIM);
expect(db.reads).toEqual([{ table: "environment_leases", locked: false }, ...coordinatorReads]);
const older = antigravityExecution();
(older.provider as { profile: { agentProfileVersion: number } }).profile.agentProfileVersion -= 1;
await expect(runStart(older, pluginTarget())).rejects.toBeInstanceOf(NativeProviderStateIncompatibleError);
const olderDb = emptyDb();
await expect(runStart(older, pluginTarget(), olderDb)).rejects.toBeInstanceOf(NativeProviderStateIncompatibleError);
expect(olderDb.reads).toEqual([]);
});
it.each(["api_key", "sign_in"] as const)("hands a %s plugin Runner task only its typed credential", async method => {
@@ -1,4 +1,5 @@
import type { Db } from "@paperclipai/db";
import { getTableName, type Table } from "drizzle-orm";
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";
@@ -6,14 +7,45 @@ 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 type AntigravityDbRead = { table: string; locked: boolean };
export type AntigravityFixtureDb = Db & { reads: AntigravityDbRead[] };
function strict<T extends object>(target: T, label: string): T {
return new Proxy(target, {
get: (object, key) => {
if (typeof key === "symbol" || key in object) return Reflect.get(object, key);
throw new Error(`antigravity fixture: unexpected ${label}.${key}`);
},
});
}
export function emptyDb(): AntigravityFixtureDb {
const reads: AntigravityDbRead[] = [];
const select = () => strict({
from: (table: Table) => {
const read = { table: getTableName(table), locked: false };
reads.push(read);
const query = strict({
innerJoin: () => query,
where: () => query,
limit: () => query,
for: (mode: string) => {
if (mode !== "update") throw new Error(`antigravity fixture: unexpected lock ${mode}`);
read.locked = true;
return query;
},
then: (resolve: (rows: never[]) => unknown, reject?: (error: unknown) => unknown) =>
Promise.resolve([] as never[]).then(resolve, reject),
}, `select from ${read.table}`);
return query;
},
}, "select");
const db = strict({
reads,
select,
transaction: async (operation: (tx: Db) => unknown) => operation(strict({ select }, "transaction") as unknown as Db),
}, "db");
return db as unknown as AntigravityFixtureDb;
}
export function antigravityExecution(input: { runId?: string; issueId?: string; workspaceId?: string; sessionId?: string } = {}) {