mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-13 15:38:22 +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>
136 lines
8.2 KiB
TypeScript
136 lines
8.2 KiB
TypeScript
import { afterEach, expect, it, vi } from "vitest";
|
|
import * as chatFlow from "./chat-flow.js";
|
|
import type { ChatFlowInput, ChatIssue, ChatRun } from "./chat-flow.js";
|
|
import { runChatFeatureFlow } from "./chat-feature-flow.js";
|
|
import { chatFeatureScenarios } from "./chat-feature-cases.js";
|
|
|
|
const polling = vi.hoisted(() => ({ failScenario: true }));
|
|
vi.mock("@playwright/test", async importOriginal => ({
|
|
...await importOriginal<typeof import("@playwright/test")>(),
|
|
expect: (actual: { isVisible?(): Promise<boolean> }, message?: string) => Object.assign(expect(actual, message), {
|
|
toBeVisible: async () => expect(await actual.isVisible!()).toBe(true),
|
|
}),
|
|
}));
|
|
vi.mock("./api.js", async importOriginal => ({
|
|
...await importOriginal<typeof import("./api.js")>(),
|
|
pollUntil: async (input: { label: string; load(): Promise<unknown>; accept?(value: unknown): boolean; reject?(value: unknown): string | undefined }) => {
|
|
const value = await input.load();
|
|
if (input.accept?.(value)) return value;
|
|
const rejection = input.reject?.(value);
|
|
if (rejection) throw new Error(rejection);
|
|
if (polling.failScenario && input.label.startsWith("chat scenario")) throw new Error("Original scenario failure");
|
|
return value;
|
|
},
|
|
}));
|
|
|
|
afterEach(() => { vi.restoreAllMocks(); polling.failScenario = true; });
|
|
|
|
function fixture(boundary?: string) {
|
|
vi.spyOn(chatFlow, "sendChatMessage").mockResolvedValue();
|
|
const caseId = boundary ? "delegate-announcement" : "create-backlog";
|
|
const query = chatFeatureScenarios.find(scenario => scenario.id === `tasks.${caseId}`)!.query;
|
|
const source: ChatIssue = { id: "chat", companyId: "company", title: "CEO", status: "in_review",
|
|
assigneeAgentId: "ceo", conversationState: "waiting" };
|
|
const task = { id: "task", identifier: "EVA-2", companyId: "company", title: "Launch announcement",
|
|
assigneeAgentId: "morgan", projectId: "launch", status: boundary ? "todo" : "backlog", parentId: null };
|
|
const runs = [{ id: "handoff", companyId: "company", agentId: "ceo", status: "succeeded",
|
|
runtimeMode: "native", contextSnapshot: { issueId: "chat" } }];
|
|
const comments = [
|
|
{ id: "human", issueId: "chat", body: query, authorUserId: "person", createdAt: "2026-10-30T10:00:00Z" },
|
|
{ id: "reply", issueId: "chat", body: "Assigned Morgan: EVA-2, saved in backlog.", authorAgentId: "ceo", createdByRunId: "handoff", createdAt: "2026-10-30T10:00:10Z" },
|
|
];
|
|
const scopes = [{ scopeType: "company", scopeId: "company" }, ...["ceo", "morgan"].map(scopeId => ({ scopeType: "agent", scopeId }))];
|
|
const api = {
|
|
baseURL: "http://fixture.invalid", getRunObservation: vi.fn(async () => []),
|
|
get: vi.fn(async (path: string) => {
|
|
if (path.endsWith("issues?includeAgentCreatedTasks=true")) return [];
|
|
if (path.includes("issues?includeAgentCreatedTasks=true&limit=100")) return [task];
|
|
if (path.endsWith("/comments?order=asc")) return comments;
|
|
if (path.endsWith("/documents")) return [];
|
|
if (path.endsWith("/activity")) return [{ action: "issue.created", agentId: "ceo", details: { status: task.status } }];
|
|
if (path === "/api/issues/EVA-2") return task;
|
|
if (path.includes("/events?")) return [];
|
|
if (path.endsWith("/budgets/overview")) return { policies: scopes.map(scope => ({ ...scope,
|
|
amount: 500, hardStopEnabled: true, isActive: true, unpricedUsagePolicy: "allow" })) };
|
|
return { budgetMonthlyCents: 500, lifecycleState: "ready", status: "idle" };
|
|
}),
|
|
post: vi.fn(async (path: string) => ({ id: path.endsWith("/projects") ? "launch" : "morgan" })),
|
|
};
|
|
const checks: Array<{ id: string; passed: boolean }> = [];
|
|
const evidence = vi.fn(async (name: string) => {
|
|
if (boundary === "save" && name === "chat-feature.json") throw new Error("Final evidence write failed");
|
|
});
|
|
const locator = {
|
|
isVisible: async () => true,
|
|
locator: () => locator, getByRole: () => locator, nth: () => locator, click: vi.fn(),
|
|
evaluateAll: async (_callback: unknown, target?: unknown) => target ? 0 : ["/EVA/issues/EVA-2"],
|
|
};
|
|
const capture = vi.fn();
|
|
const input = {
|
|
api, nonce: "fixture", workspacePath: "/fixture",
|
|
page: { locator: () => locator, getByTestId: () => locator, reload: vi.fn(), goto: vi.fn(), url: () => "http://fixture.invalid/chat" },
|
|
fixtures: { company: { id: "company" }, agent: { id: "ceo" }, environment: { id: "local" }, secretRefs: {} },
|
|
execution: { id: "chat-features.runner-opencode.local." + caseId, suite: { id: "chat-features" }, environment: { id: "local" }, task: { id: caseId, flow: "agent_chat", expectedRunCount: boundary ? 3 : 1,
|
|
buildVisibleMarker: () => "ACORN123", turnTimeoutMs: 120_000, attemptTimeoutMs: { local: 420_000 } },
|
|
profile: { id: "runner-opencode", provider: "opencode", model: "fixture", credential: "OPENROUTER_API_KEY", buildAgent: () => ({ adapterConfig: {} }) } },
|
|
evidence, capture, check: (id: string, passed: boolean) => checks.push({ id, passed }),
|
|
} as unknown as ChatFlowInput;
|
|
let refreshes = 0;
|
|
const context: Parameters<typeof runChatFeatureFlow>[0] = { input, issue: () => source, allRuns: async () => runs,
|
|
refreshIssue: async () => {
|
|
if (++refreshes > 1 && boundary === "refresh") throw new Error("Final observation read failed");
|
|
},
|
|
};
|
|
return { context, checks, evidence, capture };
|
|
}
|
|
|
|
function oldAssignment(startedAt: string | null = null): ChatRun {
|
|
return { id: "old-assignment", companyId: "company", agentId: "ceo", status: "cancelled", runtimeMode: "legacy",
|
|
startedAt, nativeIssueId: null, errorCode: "issue_assignee_changed", contextSnapshot: { issueId: "task" },
|
|
resultJson: { stopReason: "issue_assignee_changed", timeoutSource: "stale_queued_run_gate", timeoutFired: false } };
|
|
}
|
|
|
|
it.each(["refresh", "save"])("keeps the last observed checks when final %s fails", async boundary => {
|
|
const { context, checks, evidence } = fixture(boundary);
|
|
await expect(runChatFeatureFlow(context)).rejects.toThrow("Original scenario failure");
|
|
expect(evidence).toHaveBeenCalledWith("chat-feature-evidence-error.json", expect.objectContaining({ incomplete: true }));
|
|
expect(checks).toEqual(expect.arrayContaining([
|
|
{ id: "one-assigned-task", passed: true }, { id: "agent-created-task", passed: true },
|
|
{ id: "chat-task-link", passed: true }, { id: "worker-executed", passed: false },
|
|
{ id: "completion-result-access", passed: false },
|
|
]));
|
|
expect(checks).toHaveLength(14);
|
|
});
|
|
|
|
it.each([1, 3])("continues observation past a superseded wake with %s actual work runs", async count => {
|
|
const { context, evidence } = fixture("superseded");
|
|
const runs: ChatRun[] = await context.allRuns();
|
|
if (count === 3) runs.push(
|
|
{ id: "writing", companyId: "company", agentId: "morgan", status: "queued", runtimeMode: "native", contextSnapshot: { issueId: "task" } },
|
|
{ id: "delivery", companyId: "company", agentId: "ceo", status: "queued", runtimeMode: "native", contextSnapshot: { issueId: "chat" } },
|
|
);
|
|
runs.push(oldAssignment());
|
|
context.allRuns = async () => runs;
|
|
await expect(runChatFeatureFlow(context)).rejects.toThrow("Original scenario failure");
|
|
expect(evidence).toHaveBeenCalledWith("chat-feature.json", expect.objectContaining({
|
|
observation: expect.objectContaining({ runs }), grade: expect.objectContaining({ passed: false }),
|
|
}));
|
|
});
|
|
|
|
it("still rejects a cancelled assignment that actually started", async () => {
|
|
const { context } = fixture("started");
|
|
const runs = [...await context.allRuns(), oldAssignment("2026-10-30T10:00:01Z")];
|
|
context.allRuns = async () => runs;
|
|
await expect(runChatFeatureFlow(context)).rejects.toThrow("An observed provider run failed");
|
|
});
|
|
|
|
it("retains required final evidence after the feature flow verifies browser readback", async () => {
|
|
polling.failScenario = false;
|
|
const { context, checks, evidence, capture } = fixture();
|
|
await expect(runChatFeatureFlow(context)).resolves.toMatchObject({ issue: { id: "chat" }, runs: [{ id: "handoff" }] });
|
|
expect(checks.every(check => check.passed)).toBe(true);
|
|
expect(checks).toContainEqual({ id: "browser-result-access", passed: true });
|
|
expect(capture).toHaveBeenCalledWith("final-state", expect.any(String), "final-state.png");
|
|
expect(evidence).toHaveBeenCalledWith("api-state.json", expect.objectContaining({ issue: expect.objectContaining({ id: "chat" }) }));
|
|
});
|