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 eval catalog runs real chat journeys and grades the
saved product state
> - Two cases failed in eval run gha-43069861174 because of the eval,
not the product
> - `cases.update-case-facts` gave its investigator the wrong tool
content. `task-coordination.block-on-design` waited for a run count that
the product does not promise
> - A wrong fixture or a wrong wait hides real product results, so these
must be correct
> - This pull request gives the case-facts investigator the content its
case would really serve, and lets block-on-design accept the product's
bounded blocked-interaction reply
> - The benefit is that both cases test their real feature again, and
the checks still reject the failures that matter
## Linked Issues or Issue Description
**What happened**
`cases.update-case-facts`: the shared Website Brief app served the
website prerequisite text ("record a short implementation note and
complete the task") to the case investigator. The investigator said that
the text did not match the case. It then asked the board for the missing
evidence. The task went to `in_review`, so the harness's later board
handoff got a correct 422 ("Resolve task mode, blockers, or review
before handing off").
`task-coordination.block-on-design`: the CEO saved the Design blocker
and also commented on the blocked Website task. The product woke Morgan
in its bounded blocked-interaction mode (`dependencyBlockedInteraction:
true`). Morgan only acknowledged the hold. The pre-approval wait
required exactly one run, so it timed out.
**Expected behavior**
Each fixture gives the agent the facts its own scenario has. Each wait
accepts every behavior that the product contract allows.
**Steps to reproduce**
1. Run `chat-features.runner-opencode.local.cases.update-case-facts`.
Morgan's continuation reads the website brief and asks the board for
evidence. The review handoff gets a 422.
2. Run
`chat-features.runner-opencode.local.task-coordination.block-on-design`.
The CEO comments on Website. Morgan gets a blocked-interaction run. The
first wait times out.
## What Changed
- `startRunBriefGate` takes an optional `briefText`. The default text
does not change for the other cases.
- `cases.update-case-facts` serves "no further reproduction evidence has
been received yet; the affected device is still unconfirmed" after
release (oracle v7).
- `task-coordination.block-on-design` (oracle v8):
- The pre-approval wait accepts Morgan runs only when the server stamped
them as blocked interactions on Website that name the Design blocker,
and they succeeded. Any other Morgan run, a failed run, or a second CEO
run rejects the wait at once.
- New check: before approval, Website has no documents and its status is
not `in_progress`, `in_review` or `done`.
- After approval, exactly one Morgan work run must still produce the
saved result.
- Calibration tests: the valid interaction passes. An unstamped run, a
wrong blocker, a wrong task, a failed run, a missing declared run, a
document saved before approval, and a second Morgan work run each fail.
## Verification
- `pnpm exec vitest run --config tests/runner-e2e/vitest.config.ts
--testTimeout=180000
tests/runner-e2e/chat-catalog-domains/runtime-dependency.test.ts
tests/runner-e2e/chat-catalog-domains/integrator-case-facts.test.ts
tests/runner-e2e/chat-catalog-contract.test.ts
tests/runner-e2e/chat-catalog-consistency.test.ts`: 34 passed.
- `npx tsc --noEmit -p tests/runner-e2e`: no errors in the changed
files.
- `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check`:
unchanged.
- A paid eval run of the three affected cases is in progress. The PR
comments will have its result.
## Risks
- Low risk. Only eval fixtures, waits and graders change. The other
cases that use `startRunBriefGate` keep the same text.
## Model Used
- Anthropic Claude Opus 5.5 (`claude-opus-5-5`), extended thinking, 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>
66 lines
8.5 KiB
TypeScript
66 lines
8.5 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { gradeDesignDependency, isBlockedInteractionRun, readTaskState } from "./runtime-dependency.js";
|
|
import { savedCall } from "./api-read-receipts.test-fixtures.js";
|
|
function valid() { return { scenarioId: "task-coordination.block-on-design", companyId: "company", leadId: "ceo", agents: [], links: [], humanQueries: [], reply: "",
|
|
tasks: [{ id: "website", assigneeAgentId: "morgan", status: "done" }, { id: "design", status: "done" }], runs: ["save-edge", "implement", "report"].map(id => ({ id, status: "succeeded", agentId: id === "implement" ? "morgan" : "ceo" })) as Array<{ id: string; status: string; agentId: string; contextSnapshot?: Record<string, unknown> }>,
|
|
activity: [{ id: "edge", action: "issue.blockers_updated", entityId: "website", agentId: "ceo", details: { addedBlockedByIssueIds: ["design"] } }],
|
|
state: { task: { id: "website" }, design: { id: "design" }, worker: { id: "morgan" }, waitingTask: { id: "website", companyId: "company", assigneeAgentId: "morgan", blockedBy: [{ id: "design" }] },
|
|
designUnfinishedAtWait: true, blockerVisible: true, noWorkerBeforeApproval: true, noWebsiteResultBeforeApproval: true, preApprovalInteractionRunIds: [] as string[], attemptedBeforeApproval: true, beforeApprovalStatus: 200,
|
|
queryReply: "Website now depends on Design and will wait for approval.", humanApprovedDesign: true, workerAdmissionAfterApproval: true, actualWebsiteResult: true,
|
|
finalReplyAttributed: true, finalReadTaskState: true, finalReply: "Website is complete. Morgan delivered the saved plan after Design approval." } }; }
|
|
it("accepts a saved first-class blocker, held early admission and one eligible actual result", () => expect(gradeDesignDependency(valid()).passed).toBe(true));
|
|
it("accepts natural dependency and later result reporting", () => { const o = valid(); o.state.queryReply = "Design approval is a prerequisite for Website; the relationship is saved."; o.state.finalReply = "Morgan finished Website once the design was approved, and the actual document is available."; expect(gradeDesignDependency(o).passed).toBe(true); });
|
|
it("rejects missing independent admission evidence", () => expect(gradeDesignDependency(undefined).passed).toBe(false));
|
|
it("rejects a waiting comment without the actual saved edge", () => { const o = valid(); o.state.waitingTask.blockedBy = []; expect(gradeDesignDependency(o).passed).toBe(false); });
|
|
it("rejects similarly named foreign task scope", () => { const o = valid(); o.state.waitingTask.companyId = "foreign"; expect(gradeDesignDependency(o).passed).toBe(false); });
|
|
it("rejects admitting Website while Design was unfinished", () => { const o = valid(); o.state.noWorkerBeforeApproval = false; expect(gradeDesignDependency(o).passed).toBe(false); });
|
|
it("rejects a fabricated approval without a real human decision", () => { const o = valid(); o.state.humanApprovedDesign = false; expect(gradeDesignDependency(o).passed).toBe(false); });
|
|
it("rejects worker admission predating actual approval", () => { const o = valid(); o.state.workerAdmissionAfterApproval = false; expect(gradeDesignDependency(o).passed).toBe(false); });
|
|
it("rejects a saved document from the wrong native run", () => { const o = valid(); o.state.actualWebsiteResult = false; expect(gradeDesignDependency(o).passed).toBe(false); });
|
|
it("rejects pre-approval prose substituted for the later result phase", () => { const o = valid(); o.state.finalReplyAttributed = false; expect(gradeDesignDependency(o).passed).toBe(false); });
|
|
it("accepts reworded replies because saved state, not wording, proves the outcome", () => { const o = valid(); o.state.queryReply = "OK — COM-2 now waits on COM-1."; o.state.finalReply = "COM-2 is in its final state; see the saved plan."; expect(gradeDesignDependency(o).passed).toBe(true); });
|
|
it("rejects a final answer given without re-reading saved task state", () => { const o = valid(); o.state.finalReadTaskState = false; expect(gradeDesignDependency(o).passed).toBe(false); });
|
|
it("rejects an empty final reply", () => { const o = valid(); o.state.finalReply = " "; expect(gradeDesignDependency(o).passed).toBe(false); });
|
|
it("reads Website's saved state only from completed product reads tied to Website", () => {
|
|
const website = { id: "website", identifier: "COM-2", companyId: "company" };
|
|
const event = (name: string, output: string, status = "completed") => ({ eventType: "tool.execution.completed", payload: { prpEvent: { sourceKind: "runner", payload: { name, status, output } } } });
|
|
expect(readTaskState([event("paperclip_get_task", '{"id":"website","status":"done"}')], website)).toBe(true);
|
|
expect(readTaskState([event("paperclip_search_tasks", '{"tasks":[{"identifier":"COM-2"}]}')], website)).toBe(true);
|
|
expect(readTaskState([event("paperclip_get_task", '{"id":"design"}')], website)).toBe(false);
|
|
expect(readTaskState([event("paperclip_get_task", '{"id":"website"}', "failed")], website)).toBe(false);
|
|
// call_api bodies are redacted before saving: the read is bound by its saved input digest.
|
|
expect(readTaskState(savedCall({ operationId: "GET /api/issues/{id}", pathParams: { id: "COM-2" } }, 200), website)).toBe(true);
|
|
expect(readTaskState(savedCall({ operationId: "GET /api/issues/{id}", pathParams: { id: "COM-1" } }, 200), website)).toBe(false);
|
|
expect(readTaskState(savedCall({ operationId: "GET /api/issues/{id}", pathParams: { id: "website" } }, 404), website)).toBe(false);
|
|
expect(readTaskState([{ eventType: "item.completed", payload: { prpEvent: { sourceKind: "runner", payload: { text: "I read paperclip_get_task website" } } } }], website)).toBe(false);
|
|
});
|
|
|
|
const interaction = (overrides: Record<string, unknown> = {}) => ({ id: "triage", status: "succeeded", agentId: "morgan",
|
|
contextSnapshot: { issueId: "website", dependencyBlockedInteraction: true, unresolvedBlockerIssueIds: ["design"], wakeReason: "issue_commented", ...overrides } });
|
|
function withInteraction(run = interaction()) { const o = valid(); o.runs.splice(1, 0, run); o.state.preApprovalInteractionRunIds = [run.id]; return o; }
|
|
it("accepts a server-marked blocked-interaction reply from Morgan before approval", () => expect(gradeDesignDependency(withInteraction()).passed).toBe(true));
|
|
it("rejects a pre-approval Morgan run the server did not mark as a blocked interaction", () => {
|
|
expect(gradeDesignDependency(withInteraction(interaction({ dependencyBlockedInteraction: undefined }))).passed).toBe(false);
|
|
expect(gradeDesignDependency(withInteraction(interaction({ unresolvedBlockerIssueIds: [] }))).passed).toBe(false);
|
|
expect(gradeDesignDependency(withInteraction(interaction({ issueId: "design" }))).passed).toBe(false);
|
|
expect(gradeDesignDependency(withInteraction({ ...interaction(), status: "failed" })).passed).toBe(false);
|
|
});
|
|
it("rejects a declared interaction run that is missing from the saved runs", () => { const o = valid(); o.state.preApprovalInteractionRunIds = ["triage"]; expect(gradeDesignDependency(o).passed).toBe(false); });
|
|
it("rejects Website work saved before approval even from an interaction reply", () => { const o = withInteraction(); o.state.noWebsiteResultBeforeApproval = false; expect(gradeDesignDependency(o).passed).toBe(false); });
|
|
it("still requires exactly one Morgan work run after approval alongside an interaction reply", () => {
|
|
const o = withInteraction(); o.runs.push({ id: "again", status: "succeeded", agentId: "morgan" }); expect(gradeDesignDependency(o).passed).toBe(false);
|
|
});
|
|
it("identifies blocked-interaction runs only from server-stamped context", () => {
|
|
expect(isBlockedInteractionRun(interaction(), { id: "website" }, { id: "design" }, "morgan")).toBe(true);
|
|
expect(isBlockedInteractionRun(interaction(), { id: "website" }, { id: "design" }, "ceo")).toBe(false);
|
|
expect(isBlockedInteractionRun({ id: "x", status: "succeeded", agentId: "morgan" }, { id: "website" }, { id: "design" }, "morgan")).toBe(false);
|
|
});
|
|
it("declares a run bound that admits one blocked-interaction reply and no other extra run", async () => {
|
|
const { gradeChatCatalogRuns } = await import("../chat-catalog-run-policy.js");
|
|
const { runtimeDependencyCases } = await import("./runtime-dependency.js");
|
|
const run = (id: string, agentId: string) => ({ id, companyId: "company", agentId, status: "succeeded", runtimeMode: "native" });
|
|
const grade = (count: number) => gradeChatCatalogRuns({ implementation: runtimeDependencyCases[0]!, companyId: "company", leadId: "ceo",
|
|
runs: ["save-edge", "triage", "implement", "report", "extra"].slice(0, count).map(id => run(id, id === "triage" || id === "implement" ? "morgan" : "ceo")) }).passed;
|
|
expect([2, 3, 4, 5].map(grade)).toEqual([false, true, true, false]);
|
|
});
|