feat(runner): prepare held Pi 1 production admission

Replay the inactive Pi-only admission patch on the frozen Pi 1.0.0 source, preserving profile 11, its exact digest and all native closure inputs. Cursor and Copilot remain gated. This local preparation requires complete qualification and rebuilt normal-mode acceptance before activation.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-01 15:45:57 -05:00
1 parent 5eba61ece9
commit 89284e2905
27 files changed
+191 -52

No files matched your search

@@ -447,12 +447,12 @@ describe("Paperclip Runner native provider configuration", () => {
).toThrow("provider changed after this run selected its native backend");
});
it("rejects Pi before a native descriptor is persisted", () => {
it("rejects an unqualified Pi model before a native descriptor is persisted", () => {
expect(() =>
resolvePaperclipRunnerNativeProviderInput({
backend: "acpx_runtime",
adapterConfig: { provider: "acpx", acpxAgent: "pi", model: "pi-model" },
}),
).toThrow("Pi is awaiting local and Daytona qualification");
).toThrow("requires exact model openrouter/deepseek/deepseek-v4-flash-0731");
});
});
@@ -8,7 +8,7 @@ const provider = { kind: "acpx", agent: "cursor", model: "exact-model", permissi
const authorize = (value: unknown) => ({ [ACPX_QUALIFICATION_ENV]: JSON.stringify(value) });
describe("host ACPX qualification admission", () => {
afterEach(() => vi.unstubAllEnvs());
it.each(["cursor", "copilot", "pi"])("admits %s through agent validation and native input only for the exact host pair", (agent) => {
it.each(["cursor", "copilot"])("admits %s through agent validation and native input only for the exact host pair", (agent) => {
const config = { provider: "acpx", acpxAgent: agent, model: "exact-model" };
vi.stubEnv(ACPX_QUALIFICATION_ENV, undefined);
expect(() => resolvePaperclipRunnerProviderProfile(config)).toThrow(expect.objectContaining({ code: "paperclip_runner_acpx_agent_unavailable" }));
@@ -19,6 +19,21 @@ describe("host ACPX qualification admission", () => {
expect(() => resolvePaperclipRunnerProviderProfile({ ...config, model: "other-model" })).toThrow(expect.objectContaining({ code: "paperclip_runner_acpx_qualification_invalid" }));
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, "", "different-model"]) {
expect(() => resolvePaperclipRunnerProviderProfile({ ...config, model }))
.toThrow(expect.objectContaining({ code: "paperclip_runner_acpx_model_unqualified" }));
}
}
});
it("keeps normal candidate execution closed and admits only the exact operator pair", () => {
expect(resolveAcpxQualification(provider, {})).toBeUndefined();
expect(resolveAcpxQualification(provider, authorize([{ agent: "cursor", model: "exact-model" }]))).toBe("cursor");
@@ -1163,22 +1163,32 @@ describe("remote provider pack manifest", () => {
const candidatePath = "provider-assets/pi/linux-x64";
await mkdir(join(root, candidatePath), { recursive: true });
await writeFile(join(root, candidatePath, "runtime"), "pinned runtime");
const candidates = { pi: { version: "0.0.33", profileDigest: digest("profile"),
closureDigest: digest("closure"), qualification: "pending", path: candidatePath,
const candidates = { pi: { version: "1.0.0", profileDigest: digest("profile"),
closureDigest: digest("closure"), qualification: "qualified", path: candidatePath,
sha256: sha256DirectoryTree(join(root, candidatePath)) } };
Object.assign(payload, { candidateProviders: candidates });
await writeManifest();
expect(readRemoteProviderPackManifest(root).payload.candidateProviders?.pi?.qualification).toBe("pending");
expect(readRemoteProviderPackManifest(root).payload.candidateProviders?.pi?.qualification).toBe("qualified");
await writeFile(join(root, candidatePath, "runtime"), "substitute runtime");
expect(() => readRemoteProviderPackManifest(root)).toThrow("candidate asset tree digest mismatch");
await writeFile(join(root, candidatePath, "runtime"), "pinned runtime");
for (const invalid of [{ path: "../outside" }, { qualification: "qualified" }]) {
candidates.pi.qualification = "pending";
await writeManifest();
expect(readRemoteProviderPackManifest(root).payload.candidateProviders?.pi?.qualification).toBe("pending");
candidates.pi.qualification = "qualified";
for (const invalid of [{ path: "../outside" }, { qualification: "unknown" }]) {
const original = { ...candidates.pi };
Object.assign(candidates.pi, invalid);
await writeManifest();
expect(() => readRemoteProviderPackManifest(root)).toThrow("invalid candidate identity");
candidates.pi = original;
}
for (const provider of ["cursor", "copilot"]) {
Object.assign(candidates, { [provider]: { ...candidates.pi, path: `provider-assets/${provider}/linux-x64` } });
await writeManifest();
expect(() => readRemoteProviderPackManifest(root)).toThrow("invalid candidate identity");
delete (candidates as Record<string, unknown>)[provider];
}
await writeManifest();
for (const [artifactName, substituteName] of [
["nodeCommand", "productionLock"],
@@ -8769,6 +8779,11 @@ describe("native process ownership", () => {
},
"acpx_runtime",
],
[
"Pi ACPX without candidate authorization",
{ kind: "acpx", agent: "pi", model: "openrouter/deepseek/deepseek-v4-flash-0731", permissionMode: "approve-reads" },
"acpx_runtime",
],
])(
"admits the qualified %s provider",
async (_name, provider, driverKind) => {
@@ -8807,7 +8822,7 @@ describe("native process ownership", () => {
},
);
it.each(["pi", "cursor", "copilot"])("rejects ACPX candidate %s without host authorization before constructing a backend", async (agent) => {
it.each(["cursor", "copilot"])("rejects ACPX candidate %s without host authorization before constructing a backend", async (agent) => {
const piExecution = {
...execution,
binding: { ...execution.binding, runId: "run-acpx-pi-rejected" },
@@ -7562,7 +7562,7 @@ async function executePaperclipNativeSessionWithinScope(
}
if (
input.execution.provider.kind === "acpx" &&
["pi", "cursor", "copilot"].includes(input.execution.provider.agent) &&
["cursor", "copilot"].includes(input.execution.provider.agent) &&
!resolveAcpxQualification(input.execution.provider, process.env)
) {
throw new Error(
@@ -9579,7 +9579,7 @@ type RemoteProviderPackManifest = {
bridgeDigest: string;
acpxProfileDigests: typeof REMOTE_PROVIDER_PACK_PROFILE_DIGESTS;
candidateProviders?: Partial<Record<"cursor" | "copilot" | "pi", {
version: string; profileDigest: string; closureDigest: string; qualification: "pending";
version: string; profileDigest: string; closureDigest: string; qualification: "pending" | "qualified";
path: string; sha256: string;
}>>;
artifacts: {
@@ -9755,7 +9755,10 @@ export function readRemoteProviderPackManifest(
const expectedPath = `provider-assets/${provider}/${payload.target.platform}-${payload.target.architecture}`;
if (!["cursor", "copilot", "pi"].includes(provider) || !candidate
|| Object.keys(candidate).some(key => !["version", "profileDigest", "closureDigest", "qualification", "path", "sha256"].includes(key))
|| candidate.qualification !== "pending" || candidate.path !== expectedPath
// Inventory metadata never grants admission; local profile declarations do.
// Preserve shared packs built before Pi promotion for other qualified providers.
|| (candidate.qualification !== "pending" && !(provider === "pi" && candidate.qualification === "qualified"))
|| candidate.path !== expectedPath
|| typeof candidate.version !== "string" || !candidate.version || candidate.version.length > 120
|| !/^sha256:[a-f0-9]{64}$/.test(candidate.profileDigest)
|| !/^sha256:[a-f0-9]{64}$/.test(candidate.closureDigest)
@@ -12633,7 +12636,9 @@ async function createRunnerdBackendWithinSessionClaim(
? {
acpxAgent: input.execution.provider.agent,
// Read only the server operator environment, never agent/runtime env.
acpxCandidateProfile: resolveAcpxQualification(input.execution.provider, process.env),
acpxCandidateProfile: input.execution.provider.agent === "pi"
? undefined
: resolveAcpxQualification(input.execution.provider, process.env),
acpxPermissionMode: input.execution.provider.permissionMode,
acpxCursorMode: input.execution.provider.cursorMode,
acpxPermissionModePinned:
@@ -25,6 +25,7 @@ export const QUALIFIED_ACPX_RUNNER_MODELS = {
grok: "grok-4.7",
claude: "claude-sonnet-5",
codex: "gpt-5.6-sol",
pi: "openrouter/deepseek/deepseek-v4-flash-0731",
} as const;
export type QualifiedPaperclipRunnerAcpxAgent =
@@ -462,14 +463,14 @@ export function resolvePaperclipRunnerProviderProfile(
}
throw new PaperclipRunnerProviderProfileError("paperclip_runner_acpx_agent_unavailable", `${pendingAcpxProfile.label} is awaiting local and Daytona qualification. Its profile is not enabled for production runs.`);
}
if (acpxAgent !== "claude" && acpxAgent !== "codex" && acpxAgent !== "grok") {
if (acpxAgent !== "claude" && acpxAgent !== "codex" && acpxAgent !== "grok" && acpxAgent !== "pi") {
throw new PaperclipRunnerProviderProfileError(
"paperclip_runner_acpx_agent_unavailable",
"Paperclip Runner ACPX requires a qualified agent profile.",
);
}
const qualifiedModel = QUALIFIED_ACPX_RUNNER_MODELS[acpxAgent];
if (acpxAgent === "codex" && model !== qualifiedModel) {
if ((acpxAgent === "codex" || acpxAgent === "pi") && model !== qualifiedModel) {
throw new PaperclipRunnerProviderProfileError(
"paperclip_runner_acpx_model_unqualified",
`Paperclip Runner ACPX ${acpxAgent} requires exact model ${qualifiedModel}.`,