Files
PaperClipAI/server/src/services/native-runtime/acpx-qualification.test.ts
T
DottaandPaperclip c5107f12fe feat(runner): flip Google Antigravity ACPX profile to qualified (#22939)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Paperclip Runner executes native ACPX providers using
release-verified profiles, capability declarations, and provider packs
> - Google Antigravity is wired across Runner, server routes, UI
pickers, and remote provider packs, but its ACPX profile remained
`qualificationStatus: "pending"` behind operator candidate grants
> - The owner waived the paid-key `runner-e2e-paid` gate on 2026-11-25
so Google Antigravity can ship to staging and be tested there live
> - This pull request flips the Google Antigravity ACPX profile from
`pending` to `qualified` (profile revision 2), updates its capability
declaration while keeping `recovery: "unverified"`, enables ordinary
server/UI/pack admission without candidate grants, and updates tests and
qualification docs honestly
> - The benefit is that Google Antigravity enters the default
`linux-x64` remote provider pack and ordinary board setup/execution
flows on staging, while candidate-era v1 saved sessions are cleanly
rejected and unverified recovery/paid-key evidence remains honestly
labeled

## Linked Issues or Issue Description

Refs #22923
Refs #22935 (merge after #22935
`fix/per-turn-harness-on-warm-environment`)

**What existing behavior does this improve?**
Google Antigravity native ACPX profile qualification, remote
provider-pack assembly, and Paperclip Runner agent setup/admission
across `packages/paperclip-runner`, `packages/adapter-utils`,
`packages/adapters/codex-local`, `server`, `ui`, and `tests/runner-e2e`.

**Subsystem affected**
Cross-cutting (multiple of the above)

**Current behavior**
`packages/paperclip-runner/acpx-profiles.json` declares `antigravity` at
`agentProfileVersion: 1` with `qualificationStatus: "pending"`.
`PAPERCLIP_RUNNER_ACPX_PROFILES` marks `antigravity.qualified = false`,
remote `linux-x64` provider packs exclude Antigravity unless built with
`--candidate-providers=antigravity`, and server/Runner admission
requires a short-lived operator candidate grant.

**Proposed behavior**
Remove `qualificationStatus: "pending"` from `antigravity` and bump
`agentProfileVersion` from `1` to `2` so candidate-era v1 saved state is
refused permanently as `provider_state_incompatible`. Flip
`PAPERCLIP_RUNNER_ACPX_PROFILES.antigravity.qualified` to `true`, mark
`ACPX_CAPABILITY_PROFILES.antigravity` as `qualified` with `models:
"explicit-provider-verified"` while keeping `recovery: "unverified"`,
require an explicit provider model in config builders and server
validation, and admit qualified Antigravity through the ordinary ACPX
path without candidate grants.

**Reason and benefit**
Unblocks staging deployment and live testing of Google Antigravity under
the 2026-11-25 owner waiver of `runner-e2e-paid`, including default
`linux-x64` provider pack inclusion (local `darwin-arm64` continues to
use `paperclipai runtime setup antigravity`).

**Breaking changes**
Any candidate-era v1 Google Antigravity saved session state is
intentionally refused as `provider_state_incompatible` due to the
`agentProfileVersion` bump (`1` -> `2`).

## What Changed

- **Runner profile & generated contracts**:
- `packages/paperclip-runner/acpx-profiles.json`: removed
`qualificationStatus: "pending"` on `antigravity` and bumped
`agentProfileVersion` from `1` to `2`.
- Regenerated
`packages/paperclip-runner/src/drivers/acpx/generated-profiles.ts` and
`packages/paperclip-runner/runner/crates/runner-core/src/generated_acpx_profiles.rs`
(`qualification_pending: false`).
- `packages/paperclip-runner/src/drivers/acpx/capability-profiles.ts`:
set `antigravity.qualification` to `"qualified"` and `models` to
`"explicit-provider-verified"` when released; kept `recovery:
"unverified"` (never claiming `session-load` without live proof).
- **Adapter utils & config builder**:
- `packages/adapter-utils/src/paperclip-runner-permissions.ts`: flipped
`PAPERCLIP_RUNNER_ACPX_PROFILES.antigravity.qualified` to `true`.
- `packages/adapters/codex-local/src/ui/build-config.ts`: added
`"antigravity"` to the explicit-provider-model validation check.
- **Server admission & routes**:
- `server/src/services/native-runtime/provider-profile.ts`: added
`antigravity: null` to `DEFAULT_ACPX_RUNNER_MODELS`, included
`antigravity` in explicit-model-required and qualified ACPX checks.
- `server/src/services/native-runtime/acpx-qualification.ts`:
short-circuited `resolveAntigravityCandidateAdmission` to return
`undefined` once `qualificationStatus !== "pending"`.
- `server/src/routes/agents.ts`: allowed qualified `antigravity` without
`experimental.enableNativeRunner` (matching Copilot and UI rules),
preserved empty model on provisional setup draft transitions, and
allowed `setupOnly` draft creation before model selection.
- **Tests**:
- Updated Runner TS/Rust tests (`profile-compatibility.test.ts`,
`candidate-provider-pack.test.mjs`, `release-provider-pack.test.mjs`,
`antigravity-provider-pack-smoke.test.mjs`,
`candidate-admission*.test.ts`, `antigravity-models.test.ts`,
`acpx-runtime-sidecar.test.ts`, `runner-core` Rust unit/integration
tests).
- Updated `@paperclipai/adapter-utils`,
`@paperclipai/adapter-codex-local`, `@paperclipai/server`,
`@paperclipai/ui`, and `tests/runner-e2e` (`catalog.test.ts`,
`controller-rolling-deployment.test.ts`) tests for qualified Antigravity
behavior.
- **Documentation & maps**:
- `doc/plans/2026-11-22-antigravity-qualification.md`,
`doc/plans/2026-11-25-antigravity-cloud-rollout.md`, and
`packages/paperclip-runner/README.md`: recorded the 2026-11-25 owner
waiver of `runner-e2e-paid` for staging verification while keeping all
`NOT RUN` paid-key rows honestly marked `NOT RUN` / deferred.
- Minimal in-place accuracy updates in
`maps/feature-map/instance-operations.md` and
`maps/agent-access-map/instance-operations.md` (`node
scripts/check-maps.mjs` passing).

## Verification

- `pnpm --filter @paperclipai/paperclip-runner build` (TS + Rust release
binary + `check:acpx-profiles`, `generate-antigravity-models --check`,
`check:protocol-types`,
capability/attestation/traceability/replay-golden checks) — passed.
- `pnpm --filter @paperclipai/paperclip-runner test:typescript:prep`
(468 tests) and focused Runner Vitest suites
(`acpx-runtime-sidecar.test.ts` 127/127, `antigravity-models.test.ts`
22/22, `candidate-admission*.test.ts`, `profile-compatibility.test.ts`,
`runnerd-codex-transport-antigravity-release.test.ts`, pack script
tests) — passed.
- Rust tests in `packages/paperclip-runner/runner`: `cargo fmt --all --
--check`, `paperclip_process_table` (3/3), `paperclip_runner_core --lib`
(670/670, skipping macOS-incompatible `task_memory::tests::monitor_*`),
`paperclip-runnerd` bin tests (11/11), and `acpx_provider_resolutions`
(12/12) — passed.
- `packages/adapter-utils` (`paperclip-runner-permissions.test.ts`
50/50) and `packages/adapters/codex-local` (`build-config.test.ts`
64/64) — passed.
- `scripts/__tests__/prepare-runner-release-image.test.mjs`, `node
scripts/check-maps.mjs`, and `node
tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check` — passed.
- Server suites: `adapter-routes.test.ts` (36/36), `registry.test.ts`
(67/67), `agent-adapter-validation-routes.test.ts` (`Antigravity|YAML`),
`antigravity-connection-probe.test.ts`,
`antigravity-save-refusal.test.ts`, `antigravity-release.test.ts`
(10/10), `acpx-qualification.test.ts` (39/39),
`antigravity-candidate-admission.test.ts`,
`remote-provider-pack.test.ts` (60/60),
`native-session-executor.test.ts` (`Antigravity|provider pack`),
`plugin-runner-credentials.test.ts`,
`plugin-runner-credential-names.test.ts`,
`antigravity-plugin-task-credential-writeback.test.ts` — passed.
- CLI (`runtime.test.ts`, `runtime-setup.test.ts` 15/15), UI (6
Antigravity/setup suites 58/58 + `AgentConfigForm.render.test.tsx`), and
`tests/runner-e2e` (`catalog.test.ts`,
`controller-rolling-deployment.test.ts`,
`antigravity-qualification.test.ts`, `eval-gateway-drain.test.ts`, and
690+ unit files) — passed.
- Typechecks: `@paperclipai/adapter-utils`,
`@paperclipai/adapter-codex-local`, `@paperclipai/paperclip-runner`,
`@paperclipai/server` (all 7 layers), `@paperclipai/ui`, and `pnpm
test:e2e:runner:typecheck` — all passed.
- **Not run locally**: Live paid-key `runner-e2e` suites
(`antigravity-qualification`, `antigravity-model-lineup`,
`antigravity-agent-journey`) were waived by the owner on 2026-11-25 to
enable staging testing and remain marked `NOT RUN` / deferred in the
qualification docs. Rust `task_memory::tests::monitor_*` cgroup tests
require Linux CI.

## Risks

- **Merge sequencing**: Merge after #22935
(`fix/per-turn-harness-on-warm-environment`) so warm environments keep
Antigravity on its per-turn lifecycle.
- **Deferred live qualification**: Paid-key `antigravity-qualification`
cells have not run in CI;
`ACPX_CAPABILITY_PROFILES.antigravity.recovery` remains `"unverified"`
until live multi-turn and restart continuity are verified on staging.
- **Profile version reset**: Bumping `agentProfileVersion` from `1` to
`2` intentionally rejects any candidate-era v1 saved sessions as
`provider_state_incompatible`; new runs start a clean replacement
conversation in the same workspace.
- **Remote provider pack targets**: Remote provider packs intentionally
target `linux-x64` (Core Docker images and Linux sandboxes); local
`darwin-arm64` hosts continue to provision via `paperclipai runtime
setup antigravity`.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Google Gemini (Antigravity agent with tool use and code execution)

## 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>
2026-11-25 09:02:06 -06:00

169 lines
12 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { readFileSync } from "node:fs";
import { ACPX_QUALIFICATION_ENV, ANTIGRAVITY_CANDIDATE_ADMISSION_ENV, resolveAcpxQualification, resolveKimiCandidateAdmission } from "./acpx-qualification.js";
import { QUALIFIED_ACPX_PROFILES, KIMI_DISTRIBUTION_CLOSURE_SHA256 } from "../../vendor/paperclip-runner/index.js";
import type { NativeExecutionInput } from "../../vendor/paperclip-runner/index.js";
import { resolvePaperclipRunnerProviderProfile, resolvePaperclipRunnerNativeProviderInput } from "./provider-profile.js";
const provider = { kind: "acpx", agent: "copilot", model: "exact-model", permissionMode: "approve-all" } as Extract<NativeExecutionInput["provider"], { kind: "acpx" }>;
const authorize = (value: unknown) => ({ [ACPX_QUALIFICATION_ENV]: JSON.stringify(value) });
describe("host ACPX qualification admission", () => {
afterEach(() => vi.unstubAllEnvs());
it.each([undefined, "malformed", JSON.stringify(kimiAdmission("linux", "x64"))])("admits released Kimi without candidate authority (%s)", authority => {
vi.stubEnv(ANTIGRAVITY_CANDIDATE_ADMISSION_ENV, authority);
vi.stubEnv(ACPX_QUALIFICATION_ENV, "malformed-unrelated-authority");
const config = { provider: "acpx", acpxAgent: "kimi", model: "kimi-for-coding" };
expect(QUALIFIED_ACPX_PROFILES.kimi.agentProfileVersion).toBe(17);
expect(QUALIFIED_ACPX_PROFILES.kimi.qualificationStatus).not.toBe("pending");
expect(resolveKimiCandidateAdmission({ companyId: "candidate-company", model: config.model })).toBeUndefined();
expect(resolvePaperclipRunnerProviderProfile(config, { companyId: "candidate-company" })).toMatchObject(config);
expect(resolvePaperclipRunnerNativeProviderInput({ companyId: "candidate-company", backend: "acpx_runtime", adapterConfig: config }))
.toMatchObject({ ...config, acpxPermissionMode: "approve-all" });
expect(() => resolvePaperclipRunnerProviderProfile({ ...config, model: "" }))
.toThrow(expect.objectContaining({ code: "paperclip_runner_acpx_model_required" }));
});
it.each([undefined, "malformed", JSON.stringify([{ agent: "antigravity", model: "exact-model" }])])(
"admits released Antigravity without candidate authority (%s)", host => {
vi.stubEnv(ANTIGRAVITY_CANDIDATE_ADMISSION_ENV, host);
vi.stubEnv(ACPX_QUALIFICATION_ENV, host);
const config = { provider: "acpx", acpxAgent: "antigravity", model: "exact-model" };
expect(QUALIFIED_ACPX_PROFILES.antigravity.agentProfileVersion).toBe(2);
expect(QUALIFIED_ACPX_PROFILES.antigravity.qualificationStatus).not.toBe("pending");
expect(resolvePaperclipRunnerProviderProfile(config, { companyId: "candidate-company" })).toMatchObject(config);
expect(resolvePaperclipRunnerNativeProviderInput({ companyId: "candidate-company", backend: "acpx_runtime", adapterConfig: config }))
.toMatchObject({ ...config, acpxPermissionMode: "approve-all" });
expect(() => resolvePaperclipRunnerProviderProfile({ ...config, model: "" }))
.toThrow(expect.objectContaining({ code: "paperclip_runner_acpx_model_required" }));
},
);
it("admits only the exact Pi model without host authorization and preserves permission modes", () => {
const config = { provider: "acpx", acpxAgent: "pi", model: "openrouter/deepseek/deepseek-v4-flash-0731" };
for (const authorization of [undefined, "malformed unrelated candidate authorization"]) {
vi.stubEnv(ACPX_QUALIFICATION_ENV, authorization);
expect(resolvePaperclipRunnerProviderProfile(config)).toMatchObject(config);
for (const acpxPermissionMode of [undefined, "approve-all", "approve-paperclip", "approve-reads", "deny-all"]) {
expect(resolvePaperclipRunnerNativeProviderInput({ backend: "acpx_runtime", adapterConfig: { ...config, acpxPermissionMode } }))
.toMatchObject({ ...config, acpxPermissionMode: acpxPermissionMode ?? "approve-all" });
}
for (const model of [undefined, ""]) {
expect(() => resolvePaperclipRunnerProviderProfile({ ...config, model }))
.toThrow(expect.objectContaining({ code: "paperclip_runner_acpx_model_required" }));
}
}
});
it.each([[], {}, [{ agent: "cursor", model: "" }], [{ agent: "cursor", model: " exact-model" }],
[{ agent: "cursor", model: "exact-model", allowAll: true }], [{ agent: "claude", model: "exact-model" }],
[{ agent: "cursor", model: "exact-model" }, { agent: "cursor", model: "exact-model" }],
])("rejects malformed or broad authorization %j", entries => {
expect(() => resolveAcpxQualification({ ...provider, agent: "pi" }, authorize(entries))).toThrow("Invalid ACPX");
});
it("admits Cursor through ordinary configuration and ignores unrelated qualification authority", () => {
const config = { provider: "acpx", acpxAgent: "cursor", model: "exact-cursor-model" };
vi.stubEnv(ACPX_QUALIFICATION_ENV, JSON.stringify([{ agent: "pi", model: "pi-model" }]));
expect(resolvePaperclipRunnerProviderProfile(config)).toMatchObject({ acpxAgent: "cursor", model: config.model });
expect(resolvePaperclipRunnerNativeProviderInput({ backend: "acpx_runtime", adapterConfig: config })).toMatchObject({ acpxAgent: "cursor", model: config.model });
expect(resolveAcpxQualification({ ...provider, agent: "cursor" } as typeof provider, authorize([]))).toBeUndefined();
expect(() => resolvePaperclipRunnerProviderProfile({ ...config, model: "" })).toThrow(expect.objectContaining({ code: "paperclip_runner_acpx_model_required" }));
});
it.each([undefined, "malformed", JSON.stringify([{agent:"pi",model:"pi-model"}])])("admits ordinary Copilot without host overrides (%s)", host => {
vi.stubEnv(ACPX_QUALIFICATION_ENV,host);
const config={provider:"acpx",acpxAgent:"copilot",model:"gpt-5.6-luna"};
expect(resolvePaperclipRunnerProviderProfile(config)).toMatchObject({acpxAgent:"copilot",model:config.model});
expect(resolvePaperclipRunnerNativeProviderInput({backend:"acpx_runtime",adapterConfig:config})).toMatchObject({acpxAgent:"copilot",model:config.model});
expect(resolveAcpxQualification({...provider,model:config.model},{})).toBe("copilot");
});
it.each(["", " ", "auto", "default"])("refuses implicit Copilot model %s",model=>{
expect(()=>resolvePaperclipRunnerProviderProfile({provider:"acpx",acpxAgent:"copilot",model})).toThrow(expect.objectContaining({code:"paperclip_runner_acpx_model_required"}));
expect(()=>resolveAcpxQualification({...provider,model},{})).toThrow("explicit available model");
});
it("does not alter existing qualified providers", () => {
expect(resolveAcpxQualification({ ...provider, agent: "codex" } as typeof provider, authorize([]))).toBeUndefined();
});
it.each(["claude", "codex", "grok", "cursor", "pi"])("keeps %s model selection open to native verification", (acpxAgent) => {
const adapterConfig = { provider: "acpx", acpxAgent, model: "explicit-new-model" };
expect(resolvePaperclipRunnerProviderProfile(adapterConfig))
.toMatchObject({ acpxAgent, model: "explicit-new-model" });
expect(resolvePaperclipRunnerNativeProviderInput({ backend: "acpx_runtime", adapterConfig }))
.toMatchObject({ acpxAgent, model: "explicit-new-model" });
});
it("admits Fable 5.2 because the bundled Agent SDK ships Claude Code 2.1.328", () => {
expect(QUALIFIED_ACPX_PROFILES.claude.agentRuntimeVersion).toBe("0.3.328");
for (const model of ["claude-fable-5-2", "claude-fable-5-2[1m]", "claude-opus-5-5", "claude-sonnet-5-5", "claude-fable-5-1"]) {
expect(resolvePaperclipRunnerProviderProfile({ provider: "acpx", acpxAgent: "claude", model }))
.toMatchObject({ acpxAgent: "claude", model });
}
});
it("admits GPT-6.2 because the qualified ACPX runtime is Codex 0.170.0", () => {
expect(QUALIFIED_ACPX_PROFILES.codex.agentRuntimeVersion).toBe("0.170.0");
for (const model of ["gpt-6.2-sol", "gpt-6.2-astra", "gpt-6.1-sol", "gpt-6-astra"]) {
expect(resolvePaperclipRunnerProviderProfile({ provider: "acpx", acpxAgent: "codex", model }))
.toMatchObject({ acpxAgent: "codex", model });
}
});
it("names the CLI gap when a bundled runtime predates the model's minimum", async () => {
vi.resetModules();
vi.doMock("../../vendor/paperclip-runner/index.js", async (importOriginal) => {
const original = await importOriginal<typeof import("../../vendor/paperclip-runner/index.js")>();
const olderRuntime = { claude: "0.3.286", codex: "0.160.0" } as Record<string, string>;
return {
...original,
resolveQualifiedAcpxProfile: (agent: string, model: string) => {
const profile = original.resolveQualifiedAcpxProfile(agent as never, model);
return olderRuntime[agent] ? { ...profile, agentRuntimeVersion: olderRuntime[agent] } : profile;
},
};
});
try {
const { resolvePaperclipRunnerProviderProfile: resolveWithOlderRuntime } = await import("./provider-profile.js");
expect(() => resolveWithOlderRuntime({ provider: "acpx", acpxAgent: "claude", model: "claude-fable-5-2" }))
.toThrow(expect.objectContaining({
code: "paperclip_runner_claude_cli_version_incompatible",
message: expect.stringContaining("requires Claude Code 2.1.321 or newer; this Paperclip Runner bundles Claude Code 2.1.286"),
}));
expect(() => resolveWithOlderRuntime({ provider: "acpx", acpxAgent: "codex", model: "gpt-6.2-sol" }))
.toThrow(expect.objectContaining({
code: "paperclip_runner_codex_cli_version_incompatible",
message: expect.stringContaining("requires Codex 0.169.1 or newer; this Paperclip Runner bundles Codex 0.160.0"),
}));
expect(resolveWithOlderRuntime({ provider: "acpx", acpxAgent: "codex", model: "gpt-6.1-sol" }))
.toMatchObject({ acpxAgent: "codex", model: "gpt-6.1-sol" });
} finally {
vi.doUnmock("../../vendor/paperclip-runner/index.js");
vi.resetModules();
}
});
it("requires an explicit Codex ACP selection", () => {
for (const model of [undefined, "", " "]) {
expect(() => resolvePaperclipRunnerProviderProfile({ provider: "acpx", acpxAgent: "codex", model }))
.toThrow(expect.objectContaining({ code: "paperclip_runner_acpx_model_unqualified" }));
}
});
it("preserves product defaults separately from qualification examples", () => {
for (const [acpxAgent, model] of [["claude", "claude-opus-5-5"], ["grok", "grok-4.7"]]) {
expect(resolvePaperclipRunnerProviderProfile({ provider: "acpx", acpxAgent }))
.toMatchObject({ acpxAgent, model });
}
});
it("binds the executor to host process environment rather than agent configuration", () => {
const source = readFileSync(new URL("./native-session-executor.ts", import.meta.url), "utf8");
expect(source).toContain("resolveAcpxQualification(input.execution.provider, process.env)");
expect(source).not.toContain("resolveAcpxQualification(input.execution.provider, effectiveRunnerEnvironment)");
});
});
it.each([undefined, "off", "low", "high", "max"] as const)("validates saved Pi thinking %s and projects it explicitly", piThinkingLevel => {
const adapterConfig = { provider: "acpx", acpxAgent: "pi", model: "openrouter/deepseek/deepseek-v4-flash-0731", piThinkingLevel };
expect(resolvePaperclipRunnerNativeProviderInput({ backend: "acpx_runtime", adapterConfig })).toMatchObject({ piThinkingLevel: piThinkingLevel ?? "low" });
for (const alias of ["medium", "minimal", "xhigh"]) expect(() => resolvePaperclipRunnerProviderProfile({ ...adapterConfig, piThinkingLevel: alias })).toThrow(expect.objectContaining({ code: "paperclip_runner_pi_thinking_invalid" }));
});
function kimiAdmission(platform: "darwin" | "linux", architecture: "arm64" | "x64") {
return { schema: "paperclip.acpx-candidate-admission.v1", companyId: "candidate-company", agent: "kimi", model: "kimi-for-coding",
platform, architecture, expiresAt: Date.now() + 60_000, profileDigest: QUALIFIED_ACPX_PROFILES.kimi.commandDigest,
nativeClosureDigest: `sha256:${KIMI_DISTRIBUTION_CLOSURE_SHA256[`${platform}-${architecture}` as "darwin-arm64" | "linux-x64"]}` };
}