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>
211 lines
15 KiB
TypeScript
211 lines
15 KiB
TypeScript
import type { AgentDetail } from "../../../packages/shared/src/types/agent.js";
|
|
import { describe, it, expect } from "vitest";
|
|
import { gradeRuntimeAgents, hiringDeniedPermissions, runtimeAgentsCases } from "./runtime-agents.js";
|
|
import { updateAgentPermissionsSchema } from "../../../packages/shared/src/validators/agent.js";
|
|
import { createHash } from "node:crypto";
|
|
import type { RuntimeObservation } from "./runtime-support.js";
|
|
|
|
function valid(id: string): RuntimeObservation {
|
|
const worker = { id: "morgan", name: "Morgan", companyId: "company", reportsTo: "ceo", adapterType: "paperclip_runner", permissions: {} };
|
|
const o: RuntimeObservation = { scenarioId: id, origin: "http://fixture.invalid", companyId: "company", leadId: "ceo", state: { worker },
|
|
agents: [{ id: "ceo", companyId: "company", reportsTo: null }, worker], tasks: [], projects: [], goals: [], comments: [], activity: [], documents: [], revisions: [],
|
|
reply: "Restored Morgan's previous instructions.", links: ["/ACORN/agents/morgan"], humanQueries: [],
|
|
runs: [{ id: "run", agentId: "ceo", companyId: "company", status: "succeeded" }] };
|
|
if (id === "agents.change-manager") {
|
|
const riley = { id: "riley", companyId: "company", reportsTo: "ceo" };
|
|
o.state.riley = riley; o.state.tasksBefore = [];
|
|
o.agents = [o.agents[0]!, { ...worker, reportsTo: "riley" }, riley];
|
|
o.activity = [{ id: "change", agentId: "ceo", action: "agent.updated", entityId: "morgan" }];
|
|
} else if (id === "agents.hire-denied") {
|
|
o.agents = [o.agents[0]!]; delete o.state.worker;
|
|
Object.assign(o.state, { canCreateAgents: false, agentCreateProbeStatus: 403, agentCreateProbeDeniedBy: "agents:create", agentIdsBefore: ["ceo"] });
|
|
o.reply = "My effective permissions do not allow hiring; you can [hire Morgan yourself](/ACORN/agents/new).";
|
|
o.links = ["/ACORN/agents/new"];
|
|
} else if (id === "agents.edit-instructions") {
|
|
const revision = { id: "original", agentId: "morgan", companyId: "company", source: "seed" };
|
|
o.state.originalInstruction = { content: "Original frontend guidance", revision };
|
|
o.state.concurrentMarker = "Keep keyboard support";
|
|
o.state.concurrentInstruction = { content: "Original frontend guidance\nKeep keyboard support", revision: { ...revision, id: "concurrent", source: "board" } };
|
|
o.state.concurrentRunStatus = "running";
|
|
o.state.sideContent = "Keep accessibility"; o.instructionSideFile = { content: "Keep accessibility" };
|
|
o.instruction = { path: "AGENTS.md", content: "Original frontend guidance\nKeep keyboard support\nRun the relevant tests before handing work back.",
|
|
revision: { ...revision, id: "merged", source: "api", actorAgentId: "ceo", sourceRunId: "run" } };
|
|
o.instructionHistory = { revisions: [revision, { ...revision, id: "concurrent" }, o.instruction.revision] };
|
|
Object.assign(o.runs[0]!, { startedAt: "2026-10-27T08:00:00Z", finishedAt: "2026-10-27T08:02:00Z" });
|
|
o.state.concurrentRunId = "run";
|
|
o.activity = [
|
|
{ id: "human-write", companyId: "company", action: "agent.files_updated", entityId: "morgan", actorType: "user", actorId: "local-board", createdAt: "2026-10-27T08:00:30Z",
|
|
details: { path: "AGENTS.md", source: "board", contentHash: createHash("sha256").update("Original frontend guidance\nKeep keyboard support").digest("hex") } },
|
|
Object.assign({ id: "agent-write", companyId: "company", action: "agent.files_updated", entityId: "morgan", actorType: "agent", actorId: "ceo", agentId: "ceo",
|
|
details: { path: "AGENTS.md", source: "tool", contentHash: createHash("sha256").update(o.instruction.content).digest("hex") } }, { runId: "run" }),
|
|
];
|
|
o.reply = "Added the rule to Morgan's instructions for future work.";
|
|
} else {
|
|
const revision = { id: "token-previous", agentId: "morgan", companyId: "company", source: "api" };
|
|
o.state.previousInstruction = { path: "AGENTS.md", content: "Original guidance", revision };
|
|
o.state.unwantedInstruction = { path: "AGENTS.md", content: "Original guidance\nSkip the frontend tests", revision: { ...revision, id: "token-unwanted" } };
|
|
o.state.historyBefore = 0;
|
|
o.instruction = { path: "AGENTS.md", content: "Original guidance\nSkip the frontend tests", revision: { ...revision, id: "token-unwanted" } };
|
|
o.instructionHistory = { revisions: [] };
|
|
o.reply = "Paperclip keeps no earlier versions of Morgan's instructions, so there is nothing saved to undo from. What should the instructions say, or which rule should I remove?";
|
|
o.state.sideContent = "Keep accessibility"; o.instructionSideFile = { content: "Keep accessibility" };
|
|
}
|
|
return o;
|
|
}
|
|
describe("runtime agent oracles", () => {
|
|
it("disables hiring with the public permission contract while preserving existing task authority", () => {
|
|
for (const canAssignTasks of [true, false]) {
|
|
const payload = hiringDeniedPermissions({ permissions: { canCreateAgents: true, canCreateSkills: true }, access: { canAssignTasks, taskAssignSource: canAssignTasks ? "explicit_grant" : "none", membership: null, grants: [] } });
|
|
expect(updateAgentPermissionsSchema.safeParse(payload).success).toBe(true);
|
|
expect(payload).toMatchObject({ canCreateAgents: false, canAssignTasks, canCreateSkills: true });
|
|
}
|
|
for (const access of [undefined, {}, { canAssignTasks: "true" }, { canAssignTasks: null }]) {
|
|
const malformed = { permissions: { canCreateAgents: true, canAssignTasks: true }, access } as unknown as Pick<AgentDetail, "permissions" | "access">;
|
|
expect(() => hiringDeniedPermissions(malformed)).toThrow("Public agent access");
|
|
}
|
|
expect(hiringDeniedPermissions({ permissions: { canCreateAgents: true, canAssignTasks: true }, access: { canAssignTasks: false, taskAssignSource: "none", membership: null, grants: [] } }).canAssignTasks).toBe(false);
|
|
});
|
|
it("accepts substantive paraphrases for each authored agent outcome", () => {
|
|
const replies: Record<string, string> = {
|
|
"agents.change-manager": "Morgan now reports to Riley; the reporting relationship is saved.",
|
|
"agents.hire-denied": "Hiring is denied by my effective permissions. You can [hire Morgan from the hire form](/ACORN/agents/new).",
|
|
"agents.edit-instructions": "Morgan's saved instructions now require relevant tests before a handoff; the guidance applies to future work.",
|
|
"agents.restore-instructions": "I can't undo that: no previous version of Morgan's AGENTS.md was saved. Tell me the wording you want and I'll update it.",
|
|
};
|
|
for (const [id, reply] of Object.entries(replies)) { const o = valid(id); o.reply = reply; expect(gradeRuntimeAgents(o).passed, id).toBe(true); }
|
|
});
|
|
for (const definition of runtimeAgentsCases) {
|
|
it(`${definition.scenarioId} accepts independent valid evidence`, () => expect(definition.grade(valid(definition.scenarioId)).passed).toBe(true));
|
|
it(`${definition.scenarioId} rejects missing evidence`, () => expect(definition.grade(undefined).passed).toBe(false));
|
|
}
|
|
it("rejects a manager change that silently swaps an account", () => {
|
|
const o = valid("agents.change-manager"); o.agents[1]!.adapterConfig = { account: "different" };
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
it("rejects a reporting cycle even if Morgan reports to Riley", () => {
|
|
const o = valid("agents.change-manager"); o.agents[2]!.reportsTo = "morgan";
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
it("rejects an unrelated run or actor's attribution", () => {
|
|
const o = valid("agents.change-manager"); o.activity[0]!.agentId = "other";
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
it("rejects a disguised delegated hire after denial", () => {
|
|
const o = valid("agents.hire-denied"); o.tasks = [{ id: "hire", title: "Ask Riley to hire Morgan" }];
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
it("rejects account setup advice that links no authorized hiring route", () => {
|
|
const o = valid("agents.hire-denied"); o.reply = "Ask the board to [connect a missing Anthropic account](/ACORN/company/settings).";
|
|
o.links = ["/ACORN/company/settings"];
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
it("grades the hiring route by its rendered link, not the reply wording", () => {
|
|
for (const [reply, links] of [
|
|
["I can't add people to the team. [Turn on hiring for me](/ACORN/agents/ceo/permissions) and I'll do it.", ["/ACORN/agents/ceo/permissions"]],
|
|
["That's blocked for me. [Open the hire form](/ACORN/agents/new).", ["/ACORN/agents/new"]],
|
|
] as const) {
|
|
const o = valid("agents.hire-denied"); o.reply = reply; o.links = [...links];
|
|
expect(gradeRuntimeAgents(o).passed, reply).toBe(true);
|
|
}
|
|
const prose = valid("agents.hire-denied"); prose.reply = "My permission is denied; a board administrator can hire Morgan."; prose.links = [];
|
|
expect(gradeRuntimeAgents(prose).passed).toBe(false);
|
|
const other = valid("agents.hire-denied"); other.links = ["/ACORN/agents/riley/permissions"];
|
|
expect(gradeRuntimeAgents(other).passed).toBe(false);
|
|
const api = valid("agents.hire-denied"); api.links = ["/api/companies/company/agent-hires"];
|
|
expect(gradeRuntimeAgents(api).passed).toBe(false);
|
|
});
|
|
it("rejects a hire the agent completed through the dedicated hire tool despite the denial", () => {
|
|
const o = valid("agents.hire-denied"); o.reply = "Morgan is hired as QA Engineer. Profile: [Morgan](/ACORN/agents/morgan)"; o.links = ["/ACORN/agents/morgan"];
|
|
o.agents.push({ id: "morgan-2", name: "Morgan", companyId: "company", reportsTo: "ceo" });
|
|
o.activity = [{ id: "hire", action: "agent.hire_created", agentId: "ceo", entityId: "morgan-2" }];
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
const renamed = valid("agents.hire-denied"); renamed.agents.push({ id: "qa", name: "Quinn", companyId: "company", reportsTo: "ceo" });
|
|
expect(gradeRuntimeAgents(renamed).passed).toBe(false);
|
|
});
|
|
it("rejects a fixture whose creation probe was denied by a gate other than hiring permission", () => {
|
|
const o = valid("agents.hire-denied"); o.state.agentCreateProbeDeniedBy = "Agent keys cannot configure host-executed local adapter settings (command).";
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
it("rejects a guessed reconstruction even when it matches the earlier text", () => {
|
|
const o = valid("agents.restore-instructions"); o.instruction!.content = "Original guidance";
|
|
o.activity = [{ id: "guess", companyId: "company", action: "agent.files_updated", entityId: "morgan", actorType: "agent", actorId: "ceo", agentId: "ceo", details: { path: "AGENTS.md", source: "tool" } }];
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
const rewritten = valid("agents.restore-instructions"); rewritten.instruction!.content = "Original guidance";
|
|
expect(gradeRuntimeAgents(rewritten).passed).toBe(false);
|
|
});
|
|
it("rejects an agent write that leaves the bytes unchanged", () => {
|
|
const o = valid("agents.restore-instructions");
|
|
o.activity = [{ id: "rewrite", companyId: "company", action: "agent.files_updated", entityId: "morgan", actorType: "agent", actorId: "ceo", agentId: "ceo", details: { path: "AGENTS.md", source: "tool" } }];
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
it("rejects a fabricated history row, a changed side file or changed configuration", () => {
|
|
const fabricated = valid("agents.restore-instructions"); fabricated.instructionHistory!.revisions = [fabricated.instruction!.revision];
|
|
expect(gradeRuntimeAgents(fabricated).passed).toBe(false);
|
|
const side = valid("agents.restore-instructions"); side.instructionSideFile = { content: "rewritten" }; expect(gradeRuntimeAgents(side).passed).toBe(false);
|
|
const config = valid("agents.restore-instructions"); config.agents[1] = { ...config.agents[1]!, adapterConfig: { instructionsEntryFile: "OTHER.md" } };
|
|
expect(gradeRuntimeAgents(config).passed).toBe(false);
|
|
});
|
|
it("rejects a run whose setup found recorded history (the retired contract)", () => {
|
|
const o = valid("agents.restore-instructions"); o.state.historyBefore = 2; expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
});
|
|
|
|
it("rejects an instruction edit that overwrote concurrent human guidance", () => {
|
|
const o = valid("agents.edit-instructions"); o.instruction!.content = "Original frontend guidance\nRun the relevant tests before handing work back.";
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
it("uses actual file-mutation audits rather than the current reader's virtual revision actor/history", () => {
|
|
const o = valid("agents.edit-instructions");
|
|
o.instructionHistory = { revisions: [] };
|
|
Object.assign(o.instruction!.revision, { actorAgentId: null, sourceRunId: null, actorUserId: "local-board" });
|
|
expect(gradeRuntimeAgents(o).passed).toBe(true);
|
|
for (const change of [
|
|
{ companyId: "foreign" }, { entityId: "other-agent" }, { actorId: "other-agent" }, { runId: "other-run" },
|
|
{ details: { path: "other.md", source: "tool", contentHash: o.activity[1]!.details!.contentHash } },
|
|
{ details: { path: "AGENTS.md", source: "tool", contentHash: "wrong-hash" } },
|
|
]) {
|
|
const wrong = structuredClone(o); Object.assign(wrong.activity[1]!, change);
|
|
expect(gradeRuntimeAgents(wrong).passed).toBe(false);
|
|
}
|
|
const late = structuredClone(o); late.activity[0]!.createdAt = "2026-10-27T08:03:00Z";
|
|
expect(gradeRuntimeAgents(late).passed).toBe(false);
|
|
});
|
|
function savedAs(o: RuntimeObservation, content: string) {
|
|
o.instruction!.content = content;
|
|
o.activity[1]!.details!.contentHash = createHash("sha256").update(content).digest("hex");
|
|
return o;
|
|
}
|
|
it("grades a reworded or reordered merged rule and reply by saved structure, not wording", () => {
|
|
const o = savedAs(valid("agents.edit-instructions"),
|
|
"## Handoff\nVerify your change with the suites that cover it and share the outcome.\n\nOriginal frontend guidance\nKeep keyboard support\n");
|
|
o.reply = "Morgan will now verify changes with the covering suites before every handoff; it applies from the next run.";
|
|
expect(gradeRuntimeAgents(o).passed).toBe(true);
|
|
o.reply = "Done."; expect(gradeRuntimeAgents(o).passed).toBe(true);
|
|
});
|
|
it("rejects an unsaved rule even when the reply reports a conflict or claims success", () => {
|
|
for (const reply of ["Morgan's instructions changed concurrently; the testing rule is not saved.", "I added the testing rule for future work."]) {
|
|
const o = savedAs(valid("agents.edit-instructions"), "Original frontend guidance\nKeep keyboard support");
|
|
o.reply = reply; expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
}
|
|
});
|
|
it("rejects a merged rule that the agent did not save itself", () => {
|
|
const o = valid("agents.edit-instructions"); o.activity = [o.activity[0]!];
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
|
|
it.each(["agents.change-manager", "agents.restore-instructions"])("%s accepts real saved results without a mandatory chat href", id => {
|
|
const o = valid(id); o.links = []; expect(gradeRuntimeAgents(o).passed).toBe(true);
|
|
});
|
|
it("keeps the explicit agent-or-revision link requirement for instruction edits", () => {
|
|
const o = valid("agents.edit-instructions"); o.links = []; expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
it("accepts the exact independently saved instruction revision link", () => {
|
|
const o = valid("agents.edit-instructions"); o.links = ["/api/agents/morgan/instructions-bundle/revision/merged"];
|
|
expect(gradeRuntimeAgents(o).passed).toBe(true);
|
|
});
|
|
it("rejects an unrelated API route offered as an instruction revision result", () => {
|
|
const o = valid("agents.edit-instructions"); o.links = ["/api/agents/morgan/keys"];
|
|
expect(gradeRuntimeAgents(o).passed).toBe(false);
|
|
});
|
|
|