From 6ff8f782165519756f0816d72b9391a08f93ae3c Mon Sep 17 00:00:00 2001 From: Dotta Date: Mon, 28 Sep 2026 11:46:18 -0500 Subject: [PATCH] Allow explicitly selected candidate ACPX eval diagnostics Co-Authored-By: Paperclip --- .../src/cli/eval-session-contract.test.ts | 24 +++++++++++++++-- .../src/cli/eval-session-contract.ts | 26 ++++++++++++++----- .../paperclip-runner/src/cli/eval-session.ts | 19 ++++++++++++-- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/packages/paperclip-runner/src/cli/eval-session-contract.test.ts b/packages/paperclip-runner/src/cli/eval-session-contract.test.ts index 590d575e3eb..e99893fa19e 100644 --- a/packages/paperclip-runner/src/cli/eval-session-contract.test.ts +++ b/packages/paperclip-runner/src/cli/eval-session-contract.test.ts @@ -15,6 +15,7 @@ import { evalRuntimeSystemInstructions, evalSessionProviderVersion, prepareEvalRuntimeContext, + parseEvalSessionCliArgs, } from "./eval-session.js"; function request(overrides: Record = {}): unknown { @@ -62,6 +63,25 @@ function agentCoreProfile(overrides: Record = {}) { } describe("eval-session request contract", () => { + it.each(["pi", "cursor", "copilot"] as const)("admits %s only with the matching CLI diagnostic opt-in", (agent) => { + const value = request({ provider: "acpx", acpxAgent: agent, model: "explicit-provider-model" }); + expect(() => parseEvalSessionRequest(value)).toThrow("--candidate-profile"); + expect(parseEvalSessionRequest(value, { candidateProfile: agent })).toMatchObject({ acpxAgent: agent, model: "explicit-provider-model" }); + expect(() => parseEvalSessionRequest(value, { candidateProfile: agent === "pi" ? "cursor" : "pi" })).toThrow("must match"); + expect(() => parseEvalSessionRequest(request({ provider: "acpx", acpxAgent: agent, model: "" }), { candidateProfile: agent })).toThrow("request.model"); + expect(() => parseEvalSessionRequest(request({ provider: "acpx", acpxAgent: "codex", session: { acpxAgent: agent } }))).toThrow("session.acpxAgent must match"); + expect(() => parseEvalSessionRequest(request({ provider: "acpx", acpxAgent: agent, candidateProfile: agent }))).toThrow("--candidate-profile"); + }); + + it("accepts only known diagnostic flags and rejects ambiguous repeated arguments", () => { + const args = ["--request", "/tmp/request.json", "--output", "/tmp/result.json"]; + expect(parseEvalSessionCliArgs([...args, "--candidate-profile", "pi"])).toMatchObject({ candidateProfile: "pi" }); + expect(() => parseEvalSessionCliArgs([...args, "--candidate-profile", "codex"])).toThrow("must be pi, cursor, or copilot"); + expect(() => parseEvalSessionCliArgs([...args, "--candidate-profile"])).toThrow("missing"); + expect(() => parseEvalSessionCliArgs([...args, "--request", "/tmp/other.json"])).toThrow("duplicate"); + expect(() => parseEvalSessionRequest(request(), { candidateProfile: "pi" })).toThrow("must match"); + }); + it("materializes a production-v3 runtime context for direct live providers", async () => { const workspace = await mkdtemp(join(tmpdir(), "paperclip-eval-context-")); let instructionRoot: string | null = null; @@ -145,11 +165,11 @@ describe("eval-session request contract", () => { })))).toBe("17"); }); - it("rejects Pi and accepts both qualified remote provider profiles", () => { + it("requires explicit Pi diagnosis and accepts both qualified remote provider profiles", () => { expect(() => parseEvalSessionRequest(request({ provider: "acpx", acpxAgent: "pi", - }))).toThrow("Pi ACPX profile is not available"); + }))).toThrow("--candidate-profile"); expect(parseEvalSessionRequest(request({ provider: "aws_agentcore", driver: "aws_agentcore_harness_api", diff --git a/packages/paperclip-runner/src/cli/eval-session-contract.ts b/packages/paperclip-runner/src/cli/eval-session-contract.ts index 9c48f987b97..c921500f8ed 100644 --- a/packages/paperclip-runner/src/cli/eval-session-contract.ts +++ b/packages/paperclip-runner/src/cli/eval-session-contract.ts @@ -58,6 +58,8 @@ export interface EvalSessionAgentCoreProfile { timeoutSeconds: number; } +export type EvalCandidateProfile = "pi" | "cursor" | "copilot"; + export interface EvalSessionRequest { schema: typeof EVAL_SESSION_REQUEST_SCHEMA; attemptId: string; @@ -66,7 +68,7 @@ export interface EvalSessionRequest { provider?: EvalSessionProvider; driver?: EvalSessionDriver; opencodeVersion?: string; - acpxAgent?: Exclude; + acpxAgent?: QualifiedAcpxAgent; managedProfile?: EvalSessionManagedProfile; agentCoreProfile?: EvalSessionAgentCoreProfile; runnerd: { path: string; sha256: string }; @@ -211,7 +213,10 @@ function parseAgentCoreProfile(value: unknown): EvalSessionAgentCoreProfile { } /** Fail-closed validation for the executable boundary. */ -export function parseEvalSessionRequest(value: unknown): EvalSessionRequest { +export function parseEvalSessionRequest( + value: unknown, + options: { candidateProfile?: EvalCandidateProfile } = {}, +): EvalSessionRequest { const input = object(value, "request"); if (input.schema !== EVAL_SESSION_REQUEST_SCHEMA) { throw new Error("unsupported request schema"); @@ -237,17 +242,24 @@ export function parseEvalSessionRequest(value: unknown): EvalSessionRequest { // options as JSON null. Preserve compatibility with those immutable request // artifacts while continuing to reject non-null values for the wrong lane. const acpxAgent = input.acpxAgent === null ? undefined : input.acpxAgent; - if (acpxAgent === "pi") throw new Error("The Pi ACPX profile is not available"); if ( acpxAgent !== undefined && acpxAgent !== "codex" && - acpxAgent !== "claude" + acpxAgent !== "claude" && + acpxAgent !== "pi" && acpxAgent !== "cursor" && acpxAgent !== "copilot" ) { - throw new Error("eval-session acpxAgent must be codex or claude"); + throw new Error("eval-session acpxAgent must be a registered ACPX profile"); } if (provider !== "acpx" && acpxAgent !== undefined) { throw new Error("eval-session acpxAgent requires provider acpx"); } + const candidate = acpxAgent === "pi" || acpxAgent === "cursor" || acpxAgent === "copilot"; + if (options.candidateProfile !== undefined && (provider !== "acpx" || acpxAgent !== options.candidateProfile || !candidate)) { + throw new Error("--candidate-profile must match the request's registered candidate ACPX agent"); + } + if (candidate && options.candidateProfile !== acpxAgent) { + throw new Error("Candidate ACPX profiles require an explicit matching --candidate-profile diagnostic flag"); + } const managedProfileInput = input.managedProfile === null ? undefined : input.managedProfile; @@ -306,8 +318,8 @@ export function parseEvalSessionRequest(value: unknown): EvalSessionRequest { ) { throw new Error("request.session.requestedModel must match request.model"); } - if (session.acpxAgent === "pi") { - throw new Error("The Pi ACPX profile is not available"); + if (session.acpxAgent !== undefined && session.acpxAgent !== acpxAgent) { + throw new Error("request.session.acpxAgent must match request.acpxAgent"); } return { diff --git a/packages/paperclip-runner/src/cli/eval-session.ts b/packages/paperclip-runner/src/cli/eval-session.ts index c88c047920c..88ef1d15b3d 100644 --- a/packages/paperclip-runner/src/cli/eval-session.ts +++ b/packages/paperclip-runner/src/cli/eval-session.ts @@ -30,6 +30,7 @@ import { expectedEvalSessionDriver, parseEvalSessionRequest, type EvalSessionRequest, + type EvalCandidateProfile, type EvalSessionUsage, } from "./eval-session-contract.js"; import { evalProviderTransportOptions } from "./eval-provider-runtime.js"; @@ -37,6 +38,7 @@ import { evalProviderTransportOptions } from "./eval-provider-runtime.js"; interface EvalSessionCliOptions { requestPath: string; outputPath: string; + candidateProfile?: EvalCandidateProfile; } function argument(args: string[], name: string): string { @@ -47,14 +49,23 @@ function argument(args: string[], name: string): string { } export function parseEvalSessionCliArgs(args: string[]): EvalSessionCliOptions { - const allowed = new Set(["--request", "--output"]); + const allowed = new Set(["--request", "--output", "--candidate-profile"]); + const seen = new Set(); for (let index = 0; index < args.length; index += 2) { if (!allowed.has(args[index] ?? "")) { throw new Error(`unknown argument: ${args[index] ?? ""}`); } - if (args[index + 1] === undefined) throw new Error(`missing ${args[index]}`); + if (seen.has(args[index]!)) throw new Error(`duplicate argument: ${args[index]}`); + seen.add(args[index]!); + if (args[index + 1] === undefined || args[index + 1]!.startsWith("--")) throw new Error(`missing ${args[index]}`); + } + const candidateIndex = args.indexOf("--candidate-profile"); + const candidateProfile = candidateIndex < 0 ? undefined : args[candidateIndex + 1]; + if (candidateProfile !== undefined && candidateProfile !== "pi" && candidateProfile !== "cursor" && candidateProfile !== "copilot") { + throw new Error("--candidate-profile must be pi, cursor, or copilot"); } return { + ...(candidateProfile === undefined ? {} : { candidateProfile }), requestPath: argument(args, "--request"), outputPath: argument(args, "--output"), }; @@ -276,6 +287,7 @@ export async function runEvalSessionCli( const cli = parseEvalSessionCliArgs(args); const request = parseEvalSessionRequest( JSON.parse(await readFile(cli.requestPath, "utf8")), + { candidateProfile: cli.candidateProfile }, ); const runnerdPath = resolve(request.runnerd.path); const actualDigest = await sha256(runnerdPath); @@ -299,6 +311,7 @@ export async function runEvalSessionCli( transportOptions: { ...evalProviderTransportOptions(requestedProvider, request.limits.turnTimeoutMs), runnerBinary: runnerdPath, + ...(cli.candidateProfile === undefined ? {} : { acpxCandidateProfile: cli.candidateProfile }), runtimeContext, baseInstructions: evalRuntimeSystemInstructions(runtimeContext), // The transport performs the provider-specific allowlisting. Supplying @@ -351,6 +364,7 @@ export async function runEvalSessionCli( build: PAPERCLIP_RUNNER_BUILD_METADATA, runnerd: { path: "[withheld]", sha256: `sha256:${actualDigest}` }, requestedModel: request.model, + ...(cli.candidateProfile === undefined ? {} : { diagnosticCandidateProfile: cli.candidateProfile }), provider: requestedProvider, driver: requestedDriver, providerVersion: requestedProviderVersion, @@ -424,6 +438,7 @@ export async function runEvalSessionCli( build: PAPERCLIP_RUNNER_BUILD_METADATA, runnerd: { path: "[withheld]", sha256: `sha256:${actualDigest}` }, requestedModel: request.model, + ...(cli.candidateProfile === undefined ? {} : { diagnosticCandidateProfile: cli.candidateProfile }), provider: requestedProvider, driver: requestedDriver, providerVersion: requestedProviderVersion,