Files
PaperClipAI/server/src/services/native-runtime/antigravity.test-fixture.ts
T
DottaandClaude Opus 5.5 4285366e79 test(antigravity): prove positive run-start cases reach the coordinator claim with a strict DB fake (#22947)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents can run on the Google Antigravity harness, and run start has
a release gate for it
> - #22943 added run-start tests for that gate
> - Two positive cases only checked that the error was not the gate
error, so an unrelated early failure also passed
> - The fixture database returned itself for every method and an empty
result for every query, so the tests accepted any database access
> - This pull request makes each positive case prove that the run
reached the step after admission, and makes the fake database strict
> - The benefit is that a regression before the coordinator claim, or an
unexpected database call, now fails the tests

## Linked Issues or Issue Description

Refs #22943

**What happened?**
Two positive run-start cases in `antigravity-run-start.test.ts` passed
when the run failed for any reason other than the gate. The fixture
database in `antigravity.test-fixture.ts` silently accepted any call.

**What did you expect to happen?**
Each positive case proves that the run got past admission to a known
later step. The fake database rejects calls that the tests do not use.

**Steps to reproduce**
Add a temporary `throw` in `executePaperclipNativeSessionAttempt` just
before the coordinator claim. The old tests still pass (6 of 6).

## What Changed

- The granted Core sandbox case and the released plugin Runner-task case
now require the exact `native_finalization_coordinator_missing` error.
This error comes from the coordinator claim, which is after admission.
- Both cases also check the exact database reads: the coordinator lookup
and its locked re-read. The plugin case also checks the plugin lease
lookup before them.
- The older-profile case now checks that it is refused before any
database read.
- `emptyDb()` is now a typed fake. It supports only `select`, `from`,
`innerJoin`, `where`, `limit`, `for("update")`, `then`, and
`transaction`. It records each table read and throws a clear error for
any other method or lock mode.

## Verification

- `cd server && npx vitest run
src/services/native-runtime/antigravity-run-start.test.ts
src/services/native-runtime/antigravity-release.test.ts`: 16 of 16 pass.
- Red/green: with a temporary `throw` just before the coordinator claim,
the new tests fail in the two positive cases ("got
'fixture_break_before_coordinator_claim'"). The old tests pass with the
same break (6 of 6). The temporary change is not part of this PR.
- `cd server && npx tsc --noEmit -p .`: clean.

## Risks

- Low risk. This is a test-only change. No product code changes.
- If run start adds or reorders database reads, these tests fail and
need an update. That is intended.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, in Claude Code with
tool use (shell, file edits).

## 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
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 09:48:56 -06:00

68 lines
3.3 KiB
TypeScript

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";
export const ANTIGRAVITY_FIXTURE_COMPANY_ID = "10000000-0000-4000-8000-000000000001";
export const ANTIGRAVITY_FIXTURE_MODEL = "gemini-3.8-flash-low";
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 } = {}) {
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;
}