mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-04 21:21:27 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The chat eval catalog runs real chat journeys and grades saved
product state
> - Three cases failed in runs 43088288923 and 43101125481. In two of
them the product did the right thing
> - `cases.update-case-facts` used a word allow-list on a saved field.
`cases.create-case` read a field the product never fills for a new task
> - `task-coordination.block-on-design` timed out in the browser on a
missing row, which hid the real cause
> - This pull request grades what the user asked for, binds records by
structure, and stops with the real cause
> - The benefit is that each case fails only when the product fails, and
says why
## Linked Issues or Issue Description
**What happened**
- `cases.update-case-facts`: the CEO saved `browser: "Mobile Safari only
(bug reproduces only on mobile Safari)"` and kept the other fields. The
grader allowed only the words "safari" and mobile qualifiers, so "bug
reproduces" failed the first phase. The earlier rewording of the
scripted follow-up was not the cause: it is sent only after this phase.
- `cases.create-case`: the CEO created the case, the `workflow` and
`customer_brief` documents and Morgan's kickoff in one run, before
Morgan started. The grader required the kickoff's `sourceRunId` to be a
CEO run. The product sets `sourceRunId` to the run that holds the task
being handed off, so it is always null when the kickoff creates the
task. The grade never passed, so the harness kept waiting. Morgan then
found no app to test, handed the case back to the CEO, and the extra CEO
run broke the run bound.
- `task-coordination.block-on-design`: the CEO saved no Design blocker.
The scripted human then waited 30 s for the "Blocked by" row and failed
with a locator timeout.
**Expected behavior**
Each case accepts every valid product behavior and rejects the failures
that matter. A failure names its cause.
**Steps to reproduce**
1. Regrade the retained observation of run 43101125481 for
`cases.create-case` with the old grader: `real-first-morgan-kickoff` and
`required-documents-persist-before-investigation` fail although the
records are correct.
2. Call `corrected({ browser: "Mobile Safari only (bug reproduces only
on mobile Safari)" })` with the old grader: it returns false.
3. Run `task-coordination.block-on-design` when the CEO saves no
blocker: it fails on a UI locator instead of on the missing blocker.
## What Changed
- `cases.update-case-facts` (oracle v8): grade the saved correction
structurally, with no word lists. The browser fact differs from the
case's own setup value, and no field keeps the setup's stale literal
"not yet confirmed", in the saved case and in the reviewer's handoff
context. A person reads whether the wording says mobile Safari.
- `cases.create-case` (oracle case-create.v2): bind the kickoff and its
documents to the CEO chat run that was active when the kickoff was
saved, not to `sourceRunId`. Admit one CEO run on the primary task woken
by Morgan's own case handoff back to the CEO, and add a check that binds
it to that handoff. Run bound is now 2 to 3.
- Shared run policy (`chat-catalog-run-policy.ts`,
`chat-catalog-contract.ts`): new optional `maximumLeadCaseHandbackRuns`
for `source-settled-with-active-work`. The default is 0, so other cases
grade exactly as before. No other oracle version changes.
- `task-coordination.block-on-design` (oracle v9): after the first turn,
stop with "The CEO did not save Design as a blocker on Website" when the
edge is missing.
- Descriptors updated for the three cases.
## Verification
- `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts` on
`integrator-case-create`, `integrator-case-facts`, `runtime-dependency`,
`chat-catalog-run-policy`, `chat-catalog-readiness`,
`chat-catalog-failure-retirement`, `chat-catalog-consistency` and
`chat-ordinary-phase-callers` tests: all pass.
- Calibration in both directions:
- case facts: the retained values of runs 43088288923 and 43107042937
and four rewordings pass. The unchanged setup value, a kept stale
literal (in any field), empty facts and a first turn that left the value
unchanged fail.
- create-case: the retained run 43101125481 regrades to pass. Documents
from another run, a kickoff outside the CEO run, a kickoff by Morgan, a
handback with no handoff, a handback woken another way and two handbacks
fail.
- run policy: an undeclared handback, a lead run woken another way and a
second handback fail.
- `npx tsc --noEmit -p tests/runner-e2e`: no errors in changed files.
- `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check`:
unchanged.
- End-to-end: chat eval run linked in a comment below.
## Risks
- Low risk. Only eval code changes. The shared run-policy option is
opt-in, and its default keeps the old result.
## Model Used
- Anthropic Claude Opus 5.5 (`claude-opus-5-5`), tool use and code
execution in Claude Code.
## 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>
80 lines
8.8 KiB
TypeScript
80 lines
8.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { corrected, gradeIntegratorCaseFacts, SETUP_BROWSER } from "./integrator-case-facts.js";
|
|
const FIRST = "Updated case COM-C1: browser is now **\"Mobile Safari only\"**, with customer, expected result, and severity preserved. See [COM-1](/COM/issues/COM-1).";
|
|
// Recorded follow-up reply from run 42584001490 (escalation value substituted).
|
|
const FOLLOW_UP = "Yes. The case's saved facts still include your correction: `browser` = **Mobile Safari only**. The other facts are unchanged: customer **Acorn Test Shop**, expected **Pay should submit a single order**, severity **normal**.\n\nThe saved support escalation is **support-123**.\n\nOne caveat: the separate reproduction brief document still says \"The affected device has not yet been confirmed.\" Case COM-C1 is linked to [COM-1](/COM/issues/COM-1).";
|
|
function withFollowUp(reply: string) { const v = valid(); v.state.collaborationCheckpoint.reply = `${FIRST}\n${reply}`; return v; }
|
|
function valid() {
|
|
const original = { id: "case", identifier: "COM-C1", workIssueId: "primary", handoffVersion: 1, fields: { browser: "Safari; device unknown", customer: "Acorn", severity: "normal", expected: "one order" } };
|
|
const brief = { id: "brief", issueId: "primary", latestRevisionId: "v1", body: "Customer reproduction" };
|
|
const fields = { ...original.fields, browser: "Mobile Safari only", supportEscalation: "support-123" };
|
|
const base = { scenarioId: "cases.update-case-facts", origin: "https://fixture.test", companyId: "company", leadId: "ceo",
|
|
state: { initialRunId: "initial", sourceId: "chat", worker: { id: "morgan" }, case: original, brief, collaboratorValue: "support-123", reviewer: { id: "riley" } }, caseRecord: { ...original, fields }, brief, workComments: [] as Array<{ id: string; issueId: string; createdByRunId: string }>,
|
|
briefRevisions: [{ id: "v1", issueId: "primary", body: brief.body }], projects: [], tasks: [{ id: "primary", identifier: "COM-1" }], goals: [], documents: [], revisions: [], comments: [], links: [], activity: [], humanQueries: [],
|
|
reply: "The reproduction occurs exclusively on mobile Safari. Support escalation is support-123.",
|
|
runs: [{ id: "initial", status: "cancelled", runtimeMode: "native", agentId: "morgan", contextSnapshot: { issueId: "primary", paperclipCase: { id: "case", taskId: "primary", data: "{}" } } },
|
|
{ id: "turn-1", status: "succeeded", runtimeMode: "native", agentId: "ceo", contextSnapshot: { issueId: "chat" } }, { id: "turn-2", status: "succeeded", runtimeMode: "native", agentId: "ceo", contextSnapshot: { issueId: "chat" } },
|
|
{ id: "review", status: "succeeded", runtimeMode: "native", agentId: "riley", contextSnapshot: { issueId: "primary", paperclipCase: { id: "case", taskId: "primary", data: JSON.stringify({ fields }) } } }] };
|
|
const first = { ...structuredClone(base), reply: FIRST };
|
|
return { ...base, caseRecord: { ...base.caseRecord, handoffVersion: 2 }, state: { ...base.state, firstCorrection: first, collaborationCheckpoint: { ...structuredClone(base), reply: `${FIRST}\n${FOLLOW_UP}` } } };
|
|
}
|
|
describe("current case facts and real subsequent context", () => {
|
|
it("accepts a substantive correction, preserved collaborator field and actual native projection", () => {
|
|
expect(gradeIntegratorCaseFacts(valid()).passed).toBe(true);
|
|
expect(gradeIntegratorCaseFacts(undefined).passed).toBe(false);
|
|
for (const reply of ["COM-C1 still limits the bug to iOS Safari — nothing was overwritten. The current support escalation is support-123.",
|
|
"Your correction survived support's edit on [COM-1](/COM/issues/COM-1): affected browser is Safari on iPhone. Escalation saved: support-123."])
|
|
expect(gradeIntegratorCaseFacts(withFollowUp(reply)).passed).toBe(true);
|
|
const structured = valid(); structured.caseRecord.fields.browser = "mobile Safari"; expect(gradeIntegratorCaseFacts(structured).passed).toBe(true);
|
|
});
|
|
it("rejects lost unrelated fields and an initially wrong correction repaired later", () => {
|
|
const lost = valid(); lost.caseRecord.fields.customer = "Other"; expect(gradeIntegratorCaseFacts(lost).passed).toBe(false);
|
|
const repaired = valid(); repaired.state.firstCorrection.caseRecord.fields.browser = repaired.state.case.fields.browser; expect(gradeIntegratorCaseFacts(repaired).passed).toBe(false);
|
|
const stale = valid(); stale.state.collaborationCheckpoint.caseRecord.fields.supportEscalation = "stale"; expect(gradeIntegratorCaseFacts(stale).passed).toBe(false);
|
|
});
|
|
it("rejects stale handoff context, chat-only projection and moved document ownership", () => {
|
|
const stale = valid(); (stale.runs[3]!.contextSnapshot as { paperclipCase: { data: string } }).paperclipCase.data = JSON.stringify({ fields: stale.state.case.fields }); expect(gradeIntegratorCaseFacts(stale).passed).toBe(false);
|
|
const chat = valid(); chat.runs[3]!.contextSnapshot.issueId = "chat"; expect(gradeIntegratorCaseFacts(chat).passed).toBe(false);
|
|
const moved = valid(); moved.brief.issueId = "case"; expect(gradeIntegratorCaseFacts(moved).passed).toBe(false);
|
|
const missing = valid(); missing.briefRevisions = []; expect(gradeIntegratorCaseFacts(missing).passed).toBe(false);
|
|
});
|
|
it("rejects a follow-up without the case reference or the saved escalation literal", () => {
|
|
for (const reply of ["Yes, COM-C1 still says mobile Safari only. The escalation is support-999.",
|
|
"Yes, COM-C1 still says mobile Safari only.",
|
|
"Yes, it still says mobile Safari only. Support escalation is support-123.",
|
|
`${FIRST}`])
|
|
expect(gradeIntegratorCaseFacts(withFollowUp(reply)).passed, reply).toBe(false);
|
|
// The first reply already named the case; the follow-up must answer on its own.
|
|
const reusedFirst = valid(); reusedFirst.state.collaborationCheckpoint.reply = `${FIRST}\nYes, it still says mobile Safari only. Support escalation is support-123.`;
|
|
expect(gradeIntegratorCaseFacts(reusedFirst).passed).toBe(false);
|
|
});
|
|
it("grades the saved correction structurally, leaving the meaning of its wording to a person", () => {
|
|
// Any rewording of the correction passes, including the retained gha-43088288923 value.
|
|
for (const browser of ["Mobile Safari only (bug reproduces only on mobile Safari)", "Mobile Safari only", "iOS Safari", "Safari on iPhone/iPad only"])
|
|
expect(corrected({ browser }), browser).toBe(true);
|
|
expect(corrected({ browser: "Safari", platform: "mobile only" })).toBe(true);
|
|
// Broken saves fail: the unchanged setup value, the stale setup literal kept in any field, or the facts removed.
|
|
for (const fields of [{ browser: SETUP_BROWSER }, { browser: "Mobile Safari; affected device not yet confirmed" }, { browser: "Mobile Safari", note: "device not yet confirmed" }, { browser: "" }, {},
|
|
{ browser: "", customer: "Acorn", severity: "normal", expected: "one order" }, { customer: "Acorn", severity: "normal", expected: "one order", supportEscalation: "support-1" }, { browser: " ", platform: "mobile" }])
|
|
expect(corrected(fields), JSON.stringify(fields)).toBe(false);
|
|
});
|
|
});
|
|
|
|
// Retained gha-42926018003 (full cohort on 9296c74e8d): the CEO's first turn saved the correction and also told
|
|
// Morgan on the case task; that comment woke Morgan (issue_commented), so the old raw count never settled.
|
|
describe("role-bound case-fact runs", () => {
|
|
const continuation = (id: string, commentId: string) => ({ id, status: "succeeded", runtimeMode: "native", agentId: "morgan", contextSnapshot: { issueId: "primary", commentId, wakeReason: "issue_commented" } });
|
|
it("admits one Morgan continuation per CEO turn woken by that turn's task comment", () => {
|
|
const o = valid(); o.workComments = [{ id: "notify", issueId: "primary", createdByRunId: "turn-1" }];
|
|
o.runs.splice(2, 0, continuation("morgan-1", "notify") as typeof o.runs[number]);
|
|
expect(gradeIntegratorCaseFacts(o).passed).toBe(true);
|
|
});
|
|
it("rejects unprompted, duplicate or foreign extra runs", () => {
|
|
const unprompted = valid(); unprompted.runs.push(continuation("morgan-x", "missing") as typeof unprompted.runs[number]); expect(gradeIntegratorCaseFacts(unprompted).passed).toBe(false);
|
|
const twice = valid(); twice.workComments = [{ id: "a", issueId: "primary", createdByRunId: "turn-1" }, { id: "b", issueId: "primary", createdByRunId: "turn-1" }];
|
|
twice.runs.push(continuation("m1", "a") as typeof twice.runs[number], continuation("m2", "b") as typeof twice.runs[number]); expect(gradeIntegratorCaseFacts(twice).passed).toBe(false);
|
|
const second = valid(); second.runs.push({ ...second.runs[3]!, id: "review-2" }); expect(gradeIntegratorCaseFacts(second).passed).toBe(false);
|
|
const third = valid(); third.runs.push({ id: "turn-3", status: "succeeded", runtimeMode: "native", agentId: "ceo", contextSnapshot: { issueId: "chat" } } as typeof third.runs[number]); expect(gradeIntegratorCaseFacts(third).passed).toBe(false);
|
|
});
|
|
});
|