mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-13 15:55:46 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The chat-feature evals measure whether agents complete real chat requests through the product > - The chat catalog eval harness and its repairs live on the `chat-eval/master-candidate` branch, not on master > - Today's work made 139 of 242 chat evals pass in verified single-case live runs. Each product fix landed on master as its own pull request > - The eval-side changes (setups, graders, fault seams, evidence capture) still exist only on the candidate > - This pull request lands the harness on master. Master stays the source of truth for product behavior > - The benefit is one tree: evals run against master commits, and product fixes reach the evals as soon as they merge ## Linked Issues or Issue Description Refs #19441, Refs #19599, Refs #20270, Refs #20334, Refs #20342, Refs #20344, Refs #20354, Refs #20360, Refs #20373, Refs #20382, Refs #20409 **What existing behavior does this improve?** The chat catalog eval harness and the product it evaluates live on a long-running branch outside master. Eval fixes do not reach master, so master-based eval runs use old setups and graders. **Subsystem affected** `tests/runner-e2e` chat catalog harness, plus a small set of product changes that exist only on the candidate. **Proposed change** Land the harness on master. Every product fix from this eval work already merged to master as its own pull request. Conflicts keep master's product behavior. ## What Changed - Most of the diff (808 of 851 files) is under `tests/runner-e2e/`: chat-catalog domains, scenarios, descriptors, the TestOps manifest, private evidence tooling, and their tests. - Graders now check saved state, setup literals and rendered or clicked links. Many keyword and regex checks on free-form replies are removed. Each changed grader has a bumped `oracleVersion` and calibration tests (a valid reply, a reworded valid reply, and broken variants that must fail). - The shared link helper `hasLink` no longer treats a list link (for example `/COM/issues?view=mine`) as a link to every task without a URL key. - Setup fixes build real state through supported product routes: routine history, agent grants through the board grant route, budget holds with a real cap, and a storage-layer archive fault for `inbox-search.archive-partial-failure`. - Browser boundary journeys (sign-in, chat-disabled, onboarding) now write the standard pass evidence files. - Retargeted cases, approved by the maintainer: `agent-chat.chat-disabled` (Conference Room gate), `agents.restore-instructions` (no saved instruction history), `access.manage-membership` (member permission edits stay board-only). - The private evidence trusted files (`manual-private-handoff.ts`, `manual-private-retention.ts`, `manual-private-report-assets.ts`) are byte-identical to master. - Product files outside `tests/` (43 files, +1,328 −49) carry candidate-only changes that master does not yet have. Most are tests. The main code changes are in `request-human-input.ts`, `heartbeat-run-summary.ts`, `native-completion-feedback.ts`, `native-run-finalizer.ts`, `openapi.ts`, `secrets.ts` and `IssueChatLongThreadPerf.tsx`. ## Verification - `pnpm vitest run chat-catalog-domains chat-catalog-contract.test.ts chat-catalog-consistency.test.ts unit-launcher.test.mjs --testTimeout=180000` in `tests/runner-e2e`: 269 files pass, 3,550 tests pass. - `node --test chat-full-catalog-testops-manifest.test.mjs`: 10 pass. - `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check`: no change. - `tsc` for `server` and `tests/runner-e2e`: clean. - Live single-case verification: 139 of 242 cases passed on paid runs, and a person read the saved evidence for each. These are single-case runs, not one full-cohort run. ## Risks - Large diff. Most of it is test-only, but the 43 non-test files change product code paths. Review those files first. - Some graders are now less strict on reply wording. A person must read replies for meaning on those cases. - 42 cases need disposable outside accounts (Notion, Slack, GitHub, Daytona and others) and stay blocked. `access.invite-teammate` stays failing until local agent isolation lands, because the runner's durable state keeps a live invite token. - The paid workflow compares the trusted private-evidence files with master. They are unchanged, so this risk is low. ## Model Used Anthropic Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code execution, in Claude Code. Subagents used the same model. ## 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> Co-authored-by: Paperclip <noreply@paperclip.ing>
106 lines
12 KiB
TypeScript
106 lines
12 KiB
TypeScript
import { createHash } from "node:crypto";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import { applyRemoteCell, validateRemoteCell, remoteCellUsage, validateRemoteHostRefusal, type RemoteArtifactDocument, type RemoteCampaign } from "./chat-remote-campaign.js";
|
|
import { DATABASE_LANE_ENV, POSTGRES_ARTIFACT_ENV, POSTGRES_IMAGE_ID_ENV, POSTGRES_AMD64_IMAGE, POSTGRES_AMD64_IMAGE_IDS, POSTGRES_VERSION } from "./docker-postgres.js";
|
|
import { CHAT_OPENCODE_MODEL } from "./chat-runtime-profile.js";
|
|
import type { CampaignAttempt } from "./chat-campaign.js";
|
|
const digest = (x: string) => createHash("sha256").update(x).digest("hex");
|
|
const source = "a".repeat(40), hash = "b".repeat(64), runId = "12345";
|
|
const execution = "chat-features.runner-opencode.local.create-backlog";
|
|
const wrap = (name: string, value: unknown): RemoteArtifactDocument => { const bytes = JSON.stringify(value); return { path: `tests/runner-e2e/results/remote/${name}`, bytes, sha256: digest(bytes) }; };
|
|
function fixture() {
|
|
const result: any = { schema: "paperclip.runner-e2e.result/v2", executionId: execution, attempt: 1, status: "failed", cleanup: "passed", profileId: "runner-opencode", provider: "opencode", model: CHAT_OPENCODE_MODEL, environmentId: "local", source: { sha: source, workflowRunUrl: `https://github.com/paperclipai/paperclip/actions/runs/${runId}` }, accountingIdentity: { campaignId: "actual-workflow-generated", attemptId: "c".repeat(32) }, suiteDefinitionHash: hash, startedAt: "2026-10-27T14:00:00Z", finishedAt: "2026-10-27T14:01:00Z", durationMs: 60000,
|
|
databaseIdentity: { lane: "owned-docker-postgres", image: POSTGRES_AMD64_IMAGE, imageId: POSTGRES_AMD64_IMAGE_IDS[0], architecture: "amd64", imageVersion: POSTGRES_VERSION, artifactVerified: true, contextSha256: hash, engineSha256: hash, containerId: "d".repeat(64), cluster: { version: "18.6 (Debian)", systemIdentifier: "12345" }, status: "removed" } };
|
|
const host: any = { schema: "paperclip.chat-remote-host/v1", status: "qualified-host-only", scope: "before-evaluation", evaluationAdmitted: false, spotVerified: true, lifecycle: "spot", architecture: "x86_64", region: "us-east-1", workflowRef: "paperclipai/paperclip/.github/workflows/runner-full-stack-e2e.yml@refs/heads/master", workflowRunId: runId, workflowAttempt: 1, sourceRevision: source, executionIds: [execution], automaticRetries: 0, dockerEngineSha256: hash, postgres: { image: POSTGRES_AMD64_IMAGE, imageId: POSTGRES_AMD64_IMAGE_IDS[0], architecture: "amd64", version: POSTGRES_VERSION } };
|
|
const definition: any = { scenarioId: "tasks.create-backlog", definitionDigest: hash, graderDigest: hash, suiteDefinitionHash: hash };
|
|
const input = () => ({ intent: { campaignId: "remote-campaign", sourceRevision: source, selected: [{ scenarioId: "tasks.create-backlog", executionId: execution, remoteOrdinal: 1 as const }] }, provenance: { repository: "paperclipai/paperclip" as const, workflow: "runner-full-stack-e2e.yml" as const, workflowRef: "refs/heads/master" as const, runId, runAttempt: 1, artifactId: "998", archiveSha256: hash, targetSourceRevision: source }, result: wrap("result.json", result), host: wrap("chat-remote-host.json", host), definition: wrap("chat-catalog-definition.json", definition) });
|
|
return { result, host, definition, input };
|
|
}
|
|
afterEach(() => vi.unstubAllEnvs());
|
|
describe("remote Actions cell import", () => {
|
|
it("retains actual cell facts independently of any reporting-job conclusion", () => {
|
|
const f = fixture(), cell = validateRemoteCell(f.input());
|
|
expect(cell.result.status).toBe("failed"); expect(cell.result.accountingIdentity?.campaignId).toBe("actual-workflow-generated"); expect(cell.databaseLane).toMatchObject({ architecture: "amd64" });
|
|
});
|
|
it.each([
|
|
["OnDemand", (f: ReturnType<typeof fixture>) => { f.host.lifecycle = "on-demand"; }],
|
|
["wrong source", (f: ReturnType<typeof fixture>) => { f.result.source.sha = "e".repeat(40); }],
|
|
["wrong model", (f: ReturnType<typeof fixture>) => { f.result.model = "gpt-5.6"; }],
|
|
["wrong workflow", (f: ReturnType<typeof fixture>) => { f.host.workflowRef = "fork/workflow"; }],
|
|
["wrong database", (f: ReturnType<typeof fixture>) => { f.result.databaseIdentity.architecture = "arm64"; }],
|
|
["mixed engine", (f: ReturnType<typeof fixture>) => { f.result.databaseIdentity.engineSha256 = "e".repeat(64); }],
|
|
["wrong scenario", (f: ReturnType<typeof fixture>) => { f.definition.scenarioId = "tasks.other"; }],
|
|
["missing accounting", (f: ReturnType<typeof fixture>) => { delete f.result.accountingIdentity; }],
|
|
] as const)("rejects %s without recording a measurement", (_name, mutate) => { const f = fixture(); mutate(f); expect(() => validateRemoteCell(f.input())).toThrow("Remote import:"); });
|
|
it("imports the ordinary embedded lane only under an explicit matching intent", () => {
|
|
const f = fixture();
|
|
delete f.result.databaseIdentity; delete f.host.postgres; delete f.host.dockerEngineSha256;
|
|
f.host.databaseLane = "embedded-postgres";
|
|
expect(() => validateRemoteCell(f.input())).toThrow("host database lane mismatch");
|
|
const input = f.input();
|
|
expect(validateRemoteCell({ ...input, intent: { ...input.intent, databaseLane: { lane: "embedded-postgres" } } }).databaseLane).toEqual({ lane: "embedded-postgres" });
|
|
});
|
|
it.each(["host lane", "Docker receipt", "Docker engine", "Docker artifact"])("rejects embedded/Docker mixed evidence: %s", variant => {
|
|
const f = fixture(); const docker = f.result.databaseIdentity;
|
|
delete f.result.databaseIdentity; delete f.host.postgres; delete f.host.dockerEngineSha256;
|
|
f.host.databaseLane = "embedded-postgres";
|
|
if (variant === "host lane") f.host.databaseLane = "owned-docker-postgres";
|
|
if (variant === "Docker receipt") f.result.databaseIdentity = docker;
|
|
if (variant === "Docker engine") f.host.dockerEngineSha256 = hash;
|
|
if (variant === "Docker artifact") f.host.postgres = {};
|
|
const input = f.input();
|
|
expect(() => validateRemoteCell({ ...input, intent: { ...input.intent, databaseLane: { lane: "embedded-postgres" } } })).toThrow("database");
|
|
});
|
|
it("rejects changed bytes, foreign result paths and unreviewed Actions reruns", () => {
|
|
const f = fixture(), changed = f.input(); changed.result.bytes += " "; expect(() => validateRemoteCell(changed)).toThrow("bytes changed");
|
|
const foreign = f.input(); foreign.result.path = "../result.json"; expect(() => validateRemoteCell(foreign)).toThrow("artifact path");
|
|
const rerun = f.input(); rerun.provenance.runAttempt = 2; expect(() => validateRemoteCell(rerun)).toThrow("job rerun");
|
|
});
|
|
it("accepts proven normal-fleet fallback only under a new explicit intent and matching receipt", () => {
|
|
const f = fixture(); f.host.hostPolicy = "aws-fleet-spot-or-on-demand"; f.host.lifecycle = "on-demand"; f.host.spotVerified = false;
|
|
expect(() => validateRemoteCell(f.input())).toThrow("intent policy");
|
|
const allowed = () => { const input = f.input(); return { ...input, intent: { ...input.intent, hostPolicy: "aws-fleet-spot-or-on-demand" as const } }; };
|
|
expect(validateRemoteCell(allowed())).toMatchObject({ hostLifecycle: "on-demand", hostPolicy: "aws-fleet-spot-or-on-demand" });
|
|
f.host.spotVerified = true; expect(() => validateRemoteCell(allowed())).toThrow("intent policy");
|
|
f.host.spotVerified = false; f.host.lifecycle = "unknown"; expect(() => validateRemoteCell(allowed())).toThrow("intent policy");
|
|
f.host.lifecycle = "on-demand"; delete f.host.hostPolicy; expect(() => validateRemoteCell(allowed())).toThrow("intent policy");
|
|
f.host.hostPolicy = "aws-fleet-spot-or-on-demand"; f.host.lifecycle = "spot"; f.host.spotVerified = true;
|
|
expect(validateRemoteCell(allowed()).hostLifecycle).toBe("spot");
|
|
});
|
|
it("imports actual On-Demand refusal only as an operation with zero case ordinals", () => {
|
|
const f = fixture(); Object.assign(f.host, { status: "blocked", lifecycle: "on-demand", reason: "on-demand-or-unknown-host-refused-before-evaluation", instanceId: "i-12345678", imageId: "ami-12345678" });
|
|
delete f.host.postgres; delete f.host.dockerEngineSha256;
|
|
const operation = validateRemoteHostRefusal(f.input());
|
|
expect(operation.caseMeasurements).toBe(0); expect(operation.caseOrdinalsConsumed).toBe(0); expect(operation.initialIntentConsumed).toBe(false);
|
|
f.host.evaluationAdmitted = true; expect(() => validateRemoteHostRefusal(f.input())).toThrow("host refusal");
|
|
f.host.evaluationAdmitted = false; f.host.lifecycle = "spot"; expect(() => validateRemoteHostRefusal(f.input())).toThrow("host refusal");
|
|
});
|
|
it("retains Spot image-qualification refusal separately and rejects invented admission", () => {
|
|
const f = fixture(); Object.assign(f.host, { status: "blocked", lifecycle: "spot", reason: "owned-linux-amd64-postgres-image-unqualified", instanceId: "i-12345678", imageId: "ami-12345678" });
|
|
delete f.host.postgres; delete f.host.dockerEngineSha256;
|
|
const operation = validateRemoteHostRefusal(f.input());
|
|
expect(operation.actualHost.lifecycle).toBe("spot"); expect(operation.caseOrdinalsConsumed).toBe(0);
|
|
f.host.reason = "unknown-failure"; expect(() => validateRemoteHostRefusal(f.input())).toThrow("host refusal");
|
|
f.host.reason = "owned-linux-amd64-postgres-image-unqualified"; f.host.postgres = {};
|
|
expect(() => validateRemoteHostRefusal(f.input())).toThrow("host refusal");
|
|
});
|
|
it("keeps unknown billing unknown and reported OpenRouter billing separate", () => {
|
|
const f = fixture(); expect(remoteCellUsage(f.result)).toEqual({ costUsd: null, tokens: null, coverage: "unavailable" });
|
|
f.result.billing = { llm: { totalTokens: 123, reportedCostUsd: 0.02, costStatus: "reported" } };
|
|
expect(remoteCellUsage(f.result)).toEqual({ costUsd: 0.02, tokens: 123, coverage: "reported" });
|
|
});
|
|
it("imports exactly once through existing campaign guards and never changes historical input", () => {
|
|
vi.stubEnv(DATABASE_LANE_ENV, "owned-docker-postgres"); vi.stubEnv(POSTGRES_ARTIFACT_ENV, "linux-amd64"); vi.stubEnv(POSTGRES_IMAGE_ID_ENV, POSTGRES_AMD64_IMAGE_IDS[0]);
|
|
const f = fixture(), cell = validateRemoteCell(f.input());
|
|
const campaign = { campaignId: "remote-campaign", scenarios: [{ id: cell.scenarioId, executionId: execution, readiness: "implemented", authoringStatus: "complete", productPolicy: { lane: "source-build", sourceBaselineRevision: source }, attempts: [] }] } as unknown as RemoteCampaign;
|
|
const attempt: CampaignAttempt = { ordinal: 1, executionId: execution, outcome: "running", startedAt: f.result.startedAt, finishedAt: null, sourceRevision: source, workingTreeDigest: hash, definitionDigest: hash, graderDigest: hash, suiteDefinitionDigest: hash, profile: "runner-opencode", model: CHAT_OPENCODE_MODEL, environment: "local", automaticRetries: 0, correction: null, classification: null, observedFailure: null, evidencePaths: [], usage: { costUsd: null, tokens: null, coverage: "unavailable" }, cleanup: "pending", corePrDependencies: [], databaseLane: cell.databaseLane };
|
|
const qualification = { attempt, completion: { outcome: "failed" as const, finishedAt: f.result.finishedAt, definitionDigest: hash, graderDigest: hash, evidencePaths: [cell.resultPath], cleanup: "passed" as const, usage: attempt.usage, classification: "candidate_failure", observedFailure: null, corePrDependencies: [] } };
|
|
const imported = applyRemoteCell(campaign, cell, qualification);
|
|
expect(() => applyRemoteCell({ ...campaign, campaignId: "historical-local" }, cell, qualification)).toThrow("historical or foreign campaign");
|
|
expect(campaign.scenarios[0]!.attempts).toHaveLength(0); expect(imported.campaign.scenarios[0]!.attempts).toHaveLength(1);
|
|
expect(applyRemoteCell(imported.campaign, cell, qualification).duplicate).toBe(true);
|
|
expect(() => applyRemoteCell(imported.campaign, { ...cell, resultSha256: "e".repeat(64) }, qualification)).toThrow("duplicate ordinal");
|
|
expect(() => applyRemoteCell(campaign, cell, { ...qualification, completion: { ...qualification.completion, outcome: "passed" } })).toThrow("outcome or cleanup rewritten");
|
|
});
|
|
});
|