mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-08 01:57:31 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - The Runner executes agents through native and managed provider drivers. > - The direct live eval layer had drifted from the current Runner contracts. > - The old local workflow did not provide a complete parallel campaign or durable report history. > - The Runner also needed current native OpenCode and OpenRouter qualification. > - This pull request restores the direct campaign, corrects the runtime gaps that the campaign found, and adds safe hosted Evalbook history. > - The benefit is repeatable model comparison against an immutable Runner and eval source revision. ## Linked Issues or Issue Description Refs #11297 Refs #11634 **What existing behavior does this improve?** This improves the direct live `paperclip-runner` eval workflow, provider execution contract, and static Evalbook reporting path. **Current behavior** The direct evals do not have one maintained full campaign on current `master`. OpenCode has no qualified multi-model OpenRouter roster. Parallel provider bursts can compact committed events before the transport observes them. Local reports do not have a separate safe S3 history index. **Proposed behavior** Run one immutable roster-plus-case matrix. Use the shared paid AWS runner fleet. Keep raw artifacts access-controlled. Publish a sanitized canonical Evalbook report under the separate `runner-protocol-evals` S3 prefix. Keep immutable campaign directories plus root history, latest, and latest-green pointers. **Reason and benefit** Maintainers can compare native Codex, native OpenCode, ACPX, Claude Managed, and AWS AgentCore behavior over time. They can inspect failures without mixing this direct protocol layer with browser full-stack E2E. **Breaking changes** None. The new workflow and S3 prefix are additive. The existing Runner full-stack E2E workflow and report remain separate. ## What Changed - Added a trusted two-shard direct live workflow for up to 393 roster-plus-case cells. - Reused the numeric actor allowlist, protected paid environment, and RunsOn fleet controls from Runner full-stack E2E. - Added immutable Runner and eval revision resolution, exact credential boundaries, bounded retries, and cost ceilings. - Added a public report projection that removes sessions, transcripts, tool payloads, state, traces, raw failures, remote profile identities, and credential-shaped values. - Added additive S3 history under `runner-protocol-evals`, with immutable campaigns and mutable root index pointers. - Added native OpenCode model injection and current OpenRouter pricing contracts. - Fixed direct eval completion, workflow execution, semantic discovery, warm-attach state reset, executable binding, and event-burst handling. - Kept Runner browser full-stack E2E behavior and publication separate. - Documented local and hosted direct eval operation. ## Verification - `pnpm --filter @paperclipai/paperclip-runner test:runner-protocol-eval-publish` — 15 passed. - `pnpm --filter @paperclipai/paperclip-runner build:typescript` — passed. - `actionlint .github/workflows/runner-protocol-live-evals.yml .github/workflows/runner-full-stack-e2e.yml` — passed. - Local current matrix at the revision in [paperclip-evals#17](https://github.com/paperclipai/paperclip-evals/pull/17) — 323 cells across 10 enabled configurations completed. - Final local current matrix — 269 passed, 11 behavior failures, and 43 expected macOS-only ACPX platform failures. - Targeted Runner checks — 13/13 eval-session tests, 15/15 publisher/security tests, and package typecheck passed; complete PR CI is green, including all browser E2E shards. ## Risks - Paid live campaigns can consume provider budget. Actor authorization, exact per-cell ceilings, protected environments, and explicit schedule enablement bound this risk. - Public reports can leak provider data. The workflow publishes only a separately projected report and validates every file before upload. - The new workflow cannot publish until it is present on the default branch. This pull request does not change the existing `runner-full-stack-e2e` publication path. - The campaign is large. It uses two GitHub matrices and caps combined concurrency at the shared fleet limit. > 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 OpenAI Codex on GPT-5. The exact deployment ID and context-window size are not exposed. The model used reasoning, code editing, browser inspection, repository tools, and live provider 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
350 lines
11 KiB
JavaScript
350 lines
11 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import { mkdtemp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import test from "node:test";
|
|
|
|
import {
|
|
aggregateProtocolEvalCampaign,
|
|
buildProtocolEvalCatalog,
|
|
credentialForConfig,
|
|
sanitizeProtocolEvalRuns,
|
|
} from "./runner-protocol-eval-campaign.mjs";
|
|
|
|
const roots = [];
|
|
test.afterEach(async () => {
|
|
await Promise.all(
|
|
roots.splice(0).map((root) => rm(root, { recursive: true, force: true })),
|
|
);
|
|
});
|
|
|
|
async function fixture() {
|
|
const root = await mkdtemp(join(tmpdir(), "runner-protocol-campaign-"));
|
|
roots.push(root);
|
|
const program = join(root, "evals/paperclip-runner");
|
|
await Promise.all([
|
|
mkdir(join(program, "rosters"), { recursive: true }),
|
|
mkdir(join(program, "configs"), { recursive: true }),
|
|
mkdir(join(program, "cases"), { recursive: true }),
|
|
]);
|
|
const config = {
|
|
schema: "paperclip-runner/eval-config/v1",
|
|
id: "live-opencode-model",
|
|
provider: "opencode",
|
|
driver: "opencode_server",
|
|
model: "openrouter/example/model",
|
|
opencodeVersion: "1.18.17",
|
|
};
|
|
const evalCase = {
|
|
schema: "paperclip-runner/eval-case/v1",
|
|
id: "get-task-context",
|
|
title: "Get context",
|
|
description: "Synthetic public fixture",
|
|
prompt: "Inspect the synthetic task.",
|
|
fixture: "../fixtures/company.json",
|
|
authority: { actorId: "agent-1", taskId: "task-1" },
|
|
checks: [{ id: "context", kind: "semantic_operation" }],
|
|
};
|
|
const roster = {
|
|
schema: "paperclip-runner/live-roster/v1",
|
|
id: "protocol-live-opencode-model",
|
|
model: config.model,
|
|
config: "../configs/live-opencode-model.json",
|
|
cases: [evalCase.id],
|
|
};
|
|
await Promise.all([
|
|
writeFile(
|
|
join(program, "configs/live-opencode-model.json"),
|
|
JSON.stringify(config),
|
|
),
|
|
writeFile(
|
|
join(program, "cases/get-task-context.json"),
|
|
JSON.stringify(evalCase),
|
|
),
|
|
writeFile(
|
|
join(program, "rosters/live-opencode-model.json"),
|
|
JSON.stringify(roster),
|
|
),
|
|
]);
|
|
return { root, program, config, evalCase, roster };
|
|
}
|
|
|
|
test("maps every qualified driver to one explicit credential boundary", () => {
|
|
assert.equal(credentialForConfig({ provider: "codex" }), "OPENAI_API_KEY");
|
|
assert.equal(
|
|
credentialForConfig({ provider: "opencode" }),
|
|
"OPENROUTER_API_KEY",
|
|
);
|
|
assert.equal(
|
|
credentialForConfig({ provider: "acpx", acpxAgent: "claude" }),
|
|
"ANTHROPIC_API_KEY",
|
|
);
|
|
assert.equal(
|
|
credentialForConfig({ provider: "aws_agentcore" }),
|
|
"AWS_AGENTCORE_OIDC",
|
|
);
|
|
assert.throws(
|
|
() => credentialForConfig({ provider: "unknown" }),
|
|
/credential policy/,
|
|
);
|
|
});
|
|
|
|
test("catalogs roster plus case cells and emits bounded balanced shards", async () => {
|
|
const { root } = await fixture();
|
|
const catalog = await buildProtocolEvalCatalog({
|
|
evalsRoot: root,
|
|
campaignId: "gha-42-1",
|
|
maxParallel: 80,
|
|
});
|
|
assert.equal(catalog.cells.length, 1);
|
|
assert.equal(catalog.cells[0].credentialName, "OPENROUTER_API_KEY");
|
|
assert.equal(catalog.maxParallelPerShard, 40);
|
|
assert.equal(catalog.matrices[0].include.length, 1);
|
|
assert.equal(catalog.matrices[1].include.length, 0);
|
|
await assert.rejects(
|
|
buildProtocolEvalCatalog({
|
|
evalsRoot: root,
|
|
campaignId: "gha-42-1",
|
|
rosterSelection: "missing-roster",
|
|
}),
|
|
/Unknown live roster/,
|
|
);
|
|
await assert.rejects(
|
|
buildProtocolEvalCatalog({
|
|
evalsRoot: root,
|
|
campaignId: "gha-42-1",
|
|
maxParallel: 1,
|
|
}),
|
|
/from 2 through 100/,
|
|
);
|
|
});
|
|
|
|
test("aggregates retained attempts and synthesizes missing cells as infrastructure", async () => {
|
|
const { root, config, evalCase } = await fixture();
|
|
const catalog = await buildProtocolEvalCatalog({
|
|
evalsRoot: root,
|
|
campaignId: "gha-42-1",
|
|
});
|
|
const catalogPath = join(root, "catalog.json");
|
|
await writeFile(catalogPath, JSON.stringify(catalog));
|
|
const campaign = await aggregateProtocolEvalCampaign({
|
|
catalogPath,
|
|
downloadsRoot: join(root, "missing-downloads"),
|
|
evalsRoot: root,
|
|
runsOut: join(root, "merged-runs"),
|
|
campaignOut: join(root, "campaign.json"),
|
|
source: {
|
|
paperclip: { sha: "a".repeat(40), ref: "refs/heads/master" },
|
|
evals: { repository: "paperclipai/paperclip-evals", sha: "b".repeat(40) },
|
|
workflowRunUrl: "https://example.test/actions/runs/42",
|
|
},
|
|
});
|
|
assert.deepEqual(campaign.totals, {
|
|
selected: 1,
|
|
passed: 0,
|
|
behaviorFailures: 0,
|
|
infrastructureFailures: 1,
|
|
});
|
|
assert.equal(campaign.results[0].disposition, "infrastructure_failure");
|
|
assert.equal(campaign.complete, true);
|
|
assert.equal(campaign.allPassed, false);
|
|
const attempt = campaign.results[0].finalAttemptId;
|
|
assert.deepEqual(
|
|
JSON.parse(await readFile(join(root, "merged-runs", attempt, "case.json"))),
|
|
evalCase,
|
|
);
|
|
assert.deepEqual(
|
|
JSON.parse(
|
|
await readFile(join(root, "merged-runs", attempt, "config.json")),
|
|
),
|
|
config,
|
|
);
|
|
});
|
|
|
|
test("rejects downloaded cells that were not declared by the immutable catalog", async () => {
|
|
const { root } = await fixture();
|
|
const catalog = await buildProtocolEvalCatalog({
|
|
evalsRoot: root,
|
|
campaignId: "gha-42-1",
|
|
});
|
|
const catalogPath = join(root, "catalog.json");
|
|
const downloads = join(root, "downloads/unexpected");
|
|
await mkdir(downloads, { recursive: true });
|
|
await Promise.all([
|
|
writeFile(catalogPath, JSON.stringify(catalog)),
|
|
writeFile(
|
|
join(downloads, "cell.json"),
|
|
JSON.stringify({
|
|
cellId: "protocol-live-opencode-model--undeclared",
|
|
rosterFile: "live-opencode-model.json",
|
|
caseId: "undeclared",
|
|
exitCode: 1,
|
|
}),
|
|
),
|
|
]);
|
|
await assert.rejects(
|
|
aggregateProtocolEvalCampaign({
|
|
catalogPath,
|
|
downloadsRoot: join(root, "downloads"),
|
|
evalsRoot: root,
|
|
runsOut: join(root, "merged-runs"),
|
|
campaignOut: join(root, "campaign.json"),
|
|
source: {},
|
|
}),
|
|
/unexpected cell/,
|
|
);
|
|
});
|
|
|
|
test("public run projection removes provider sessions, traces, transcripts, evidence, and state", async () => {
|
|
const { root, config, evalCase } = await fixture();
|
|
const attemptId = "get-task-context-opencode-gha-42-1-attempt-01";
|
|
const source = join(root, "raw-runs", attemptId);
|
|
await mkdir(source, { recursive: true });
|
|
await Promise.all([
|
|
writeFile(
|
|
join(source, "artifact.json"),
|
|
JSON.stringify({
|
|
schema: "paperclip-runner/eval-session-artifact/v1",
|
|
attemptId,
|
|
createdAt: "2026-09-05T00:00:00.000Z",
|
|
requestedModel: config.model,
|
|
provider: config.provider,
|
|
driver: config.driver,
|
|
providerVersion: config.opencodeVersion,
|
|
providerSessionId: "private-session-id",
|
|
trace: { secret: "private" },
|
|
usage: {
|
|
agentTurns: 1,
|
|
inputTokens: 100,
|
|
estimatedCostNanodollars: 5000,
|
|
},
|
|
turn: { status: "completed", turnId: "private-turn" },
|
|
snapshot: {
|
|
createdAt: "2026-09-05T00:00:00.000Z",
|
|
providerModel: { id: config.model, provider: "openrouter" },
|
|
transcript: [{ role: "assistant", text: "private transcript" }],
|
|
evidence: [{ kind: "tool_call", data: { token: "private" } }],
|
|
},
|
|
issueThread: { messages: ["private"] },
|
|
devtools: { revisions: [{ state: { private: true } }] },
|
|
}),
|
|
),
|
|
writeFile(
|
|
join(source, "score.json"),
|
|
JSON.stringify({
|
|
schema: "paperclip-runner/eval-score/v1",
|
|
attemptId,
|
|
caseId: evalCase.id,
|
|
disposition: "passed",
|
|
passed: true,
|
|
infrastructureErrors: [],
|
|
checks: [
|
|
{
|
|
id: "context",
|
|
kind: "semantic_operation",
|
|
passed: true,
|
|
detail: "private result",
|
|
evidenceRefs: ["event-1"],
|
|
},
|
|
],
|
|
digest: "sha256:test",
|
|
}),
|
|
),
|
|
writeFile(join(source, "case.json"), JSON.stringify(evalCase)),
|
|
writeFile(
|
|
join(source, "config.json"),
|
|
JSON.stringify({ ...config, managedProfile: { profileId: "private" } }),
|
|
),
|
|
]);
|
|
await sanitizeProtocolEvalRuns({
|
|
runsRoot: join(root, "raw-runs"),
|
|
publicRunsRoot: join(root, "public-runs"),
|
|
});
|
|
const serialized = await readFile(
|
|
join(root, "public-runs", attemptId, "artifact.json"),
|
|
"utf8",
|
|
);
|
|
assert.doesNotMatch(
|
|
serialized,
|
|
/private-session|private transcript|private-turn|issueThread|trace/,
|
|
);
|
|
const artifact = JSON.parse(serialized);
|
|
assert.deepEqual(artifact.snapshot.transcript, []);
|
|
assert.deepEqual(artifact.snapshot.evidence, []);
|
|
assert.deepEqual(artifact.devtools.revisions, []);
|
|
const score = JSON.parse(
|
|
await readFile(join(root, "public-runs", attemptId, "score.json"), "utf8"),
|
|
);
|
|
assert.deepEqual(score.checks[0], {
|
|
id: "context",
|
|
kind: "semantic_operation",
|
|
passed: true,
|
|
detail: "passed",
|
|
evidenceRefs: [],
|
|
});
|
|
const publicConfig = await readFile(
|
|
join(root, "public-runs", attemptId, "config.json"),
|
|
"utf8",
|
|
);
|
|
assert.doesNotMatch(publicConfig, /managedProfile|private/);
|
|
});
|
|
|
|
test("public run projection redacts remote profile version identities", async () => {
|
|
const { root, config, evalCase } = await fixture();
|
|
const attemptId = "get-task-context-claude-managed-gha-42-1-attempt-01";
|
|
const source = join(root, "raw-runs", attemptId);
|
|
await mkdir(source, { recursive: true });
|
|
await Promise.all([
|
|
writeFile(
|
|
join(source, "artifact.json"),
|
|
JSON.stringify({
|
|
schema: "paperclip-runner/eval-session-artifact/v1",
|
|
attemptId,
|
|
createdAt: "2026-09-05T00:00:00.000Z",
|
|
requestedModel: "claude-sonnet-5",
|
|
provider: "claude_managed",
|
|
driver: "claude_managed_agents_api",
|
|
providerVersion: "private-agent-version-id",
|
|
usage: {},
|
|
turn: { status: "completed" },
|
|
snapshot: {
|
|
createdAt: "2026-09-05T00:00:00.000Z",
|
|
providerModel: { id: "claude-sonnet-5", provider: "anthropic" },
|
|
},
|
|
}),
|
|
),
|
|
writeFile(
|
|
join(source, "score.json"),
|
|
JSON.stringify({
|
|
schema: "paperclip-runner/eval-score/v1",
|
|
attemptId,
|
|
caseId: evalCase.id,
|
|
disposition: "passed",
|
|
passed: true,
|
|
checks: [],
|
|
}),
|
|
),
|
|
writeFile(join(source, "case.json"), JSON.stringify(evalCase)),
|
|
writeFile(
|
|
join(source, "config.json"),
|
|
JSON.stringify({
|
|
...config,
|
|
id: "live-claude-managed",
|
|
model: "claude-sonnet-5",
|
|
provider: "claude_managed",
|
|
driver: "claude_managed_agents_api",
|
|
}),
|
|
),
|
|
]);
|
|
await sanitizeProtocolEvalRuns({
|
|
runsRoot: join(root, "raw-runs"),
|
|
publicRunsRoot: join(root, "public-runs"),
|
|
});
|
|
const publicArtifact = await readFile(
|
|
join(root, "public-runs", attemptId, "artifact.json"),
|
|
"utf8",
|
|
);
|
|
assert.match(publicArtifact, /remote profile redacted/);
|
|
assert.doesNotMatch(publicArtifact, /private-agent-version-id/);
|
|
});
|