mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-22 20:29:18 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The chat eval catalog runs real agents through chat journeys and
grades the saved results
> - Full cohort 4 (OpenCode with DeepSeek v4.1 flash, master f1aef0cb58)
failed 14 cases for eval reasons, not product reasons
> - Some phase captures read links before the reply rendered. Some
graders matched keywords in free-form replies. One locator was stale.
One fixture answer looked like a placeholder. Some checks could not say
what failed
> - This pull request grades those cases on saved state, setup literals
and rendered links, and it fixes the observers and fixtures
> - The benefit is that these cases fail only when the product fails,
and a failure names the part that broke
## Linked Issues or Issue Description
**What happened?**
In full chat cohort 4, valid agent behavior failed these cases:
case-history, goals.explain-purpose and workspaces.preview-service
(phase captures read before the reply rendered); routines.pause-owned
("If you want that one stopped too, use Pause on its task page" matched
a cancellation regex); budgets-costs.spend-breakdown ("unknown, not
$0.00" matched a stated-zero regex); steering.edit-queued-message
("change ... and drag it above" missed a keyword list);
connection-setup.choose-provider (the resumed page says "Finish with
Notion"); questions-and-approvals.necessary-question (the answer "Acorn
2a4f72ec4ae2-1" was saved as "Acorn"). Some checks could not say what
failed: onboarding.new-company compared the whole members response as
JSON and saved no after-state; agents.choose-primary threw one combined
error.
**Expected behavior**
Each case grades the feature contract on saved state, setup literals and
rendered or clicked links. A valid reworded reply passes. A broken
product still fails. A failure names the clause and its values.
**Steps to reproduce**
Grade the retained cohort 4 evidence for the cases above with the
earlier oracles.
Refs #21009, #21002, #21007
## What Changed
- Phase captures (case-history first phase, goals.explain-purpose
phases, preview-service query phase, ambiguous-task clarification,
edit-queued-message guidance) now wait for the saved reply to render
(`waitForTurnReplyLinks`) before they observe. When a saved reply yields
no rendered links, the observation records thread and anchor diagnostics
(`linkDiagnostics`) and logs them.
- routines.pause-owned: remove the reply keyword clause. Saved state at
the reply proves the run kept running, and the final state proves it
completed normally.
- budgets-costs.spend-breakdown: the unresolved record is graded
structurally. The reply must identify it (rendered link, identifier or
run id), and a chat run must have read its saved accounting (cost
summary, run record or unranged company report, bound by input digest).
"$0.00" in the reply is not matched.
- steering.edit-queued-message: grade the rendered task link in the
reply, the refused agent edit and reorder (403), and the unchanged queue
at the reply. Keyword lists are removed.
- connection-setup.choose-provider: the sign-in locator also accepts
"Finish with Notion" (the resumed-draft label). The button has no test
id or other stable name.
- questions-and-approvals.necessary-question: the answer is now
"Quillmere". The case also accepts the exact answer in a saved
deliverable (a document revision or text attachment on the linked task,
saved by an agent of the company after the answer). The yaml expected
outcome records this decision, with a `changedFields` entry in the
testops manifest.
- onboarding.new-company: save the members after-state and compare
identity, role, status and grants, and name what changed. Guidance is
graded on a rendered link to `/onboarding` (the new-organization
wizard), the business literal from the query, and the saved company
count. The source company and person get realistic names for this case
and are restored at cleanup, because the CEO reasoned from the generated
names that the request was a graded test.
- agents.choose-primary: the settled-Chat check is split into four named
clauses with values, saved as evidence on failure.
- A question card the turn ended on counts as its reply (decision after
cohort 4) in cli-operations.owned-dev-instance, onboarding.new-company
and status-cards.other-authors-card. The card's Markdown-rendered fields
(question form description; confirmation prompt and details) count as
reply links. Link requirements still apply.
- Every changed case bumps its `oracleVersion`; the descriptor snapshot
and inventory digest are updated.
Why each old check was wrong and why the new one still catches a broken
product:
| Case | Old check was wrong because | A broken product still fails
because |
|---|---|---|
| phase captures | runs succeeded and the chat waited before the reply
rendered, so links were empty | the same link checks run on the rendered
reply |
| routines.pause-owned | a correct offer to pause the run read as a
cancellation | the checkpoint run must be running and the run must later
succeed |
| spend-breakdown | "unknown, not $0.00" read as "$0" | the reply must
identify the record and a chat run must read its saved accounting;
totals and per-agent amounts stay graded |
| edit-queued-message | correct wording missed a keyword list | the
reply must link the task, the agent's edit and reorder must be refused,
and the queue must be unchanged at the reply |
| choose-provider | the resumed page label was not accepted | the button
must still be visible on the selected Notion surface |
| necessary-question | the answer read as a placeholder; deliverables
did not count | the exact answer must be saved in the linked work after
the answer, by an agent of the company |
| new-company | timestamps and profiles made the JSON compare fail
without saying why | membership identity, role, status and grants must
be unchanged |
| choose-primary | one combined error | the same four conditions, each
named |
| card as reply | a card answer read as an empty reply | card text must
exist and link requirements still apply |
## Verification
- Calibration tests (valid, reworded valid, broken) for each changed
grader: `integrator-routine-pause.test.ts`,
`identity-accounting.test.ts` (includes the cohort 4 reply),
`runtime-queue-controls.test.ts` (includes the cohort 4 reply),
`external-provider-choice.test.ts`, `identity.test.ts`,
`identity-onboarding-work.test.ts`,
`runtime-primary-ready-chat.test.ts`, `integrator-status-cards.test.ts`,
`turn-response-card.test.ts`, `chat-rendered-links.test.ts`.
- The corrected spend-breakdown grader passes on the retained cohort 4
evidence (its cost-summary read binds to the unresolved task) and fails
with the reads removed.
- `npx vitest run --config tests/runner-e2e/vitest.config.ts
chat-catalog chat-rendered chat-linked`: 284 files passed.
- `node --test
tests/runner-e2e/chat-full-catalog-testops-manifest.test.mjs`: 10/10
passed.
- `node scripts/typecheck-test-projects.mjs tests/runner-e2e`: passed.
- `node tests/runner-e2e/source-sdk-public-inputs.mjs <sha> --check`:
unchanged.
- Paid run (8 cells, OpenCode + DeepSeek v4.1 flash) on this branch
combined with the guidance PR: see the PR comment for results.
## Risks
- The new-company guidance check now needs a rendered link to
`/onboarding`. A reply that only names the company switcher fails. The
companion guidance PR tells agents this route.
- spend-breakdown does not grade wording, so a reply that reads the
record and still calls it "$0" is not caught. The amounts, total and
identification are still graded.
- The new-company case renames the source company and the person for the
case and restores them at cleanup.
## Model Used
- Anthropic Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with
tool use, shell execution and code editing.
## 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
- [ ] 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>
380 lines
34 KiB
TypeScript
380 lines
34 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { companyIdentityCases, gradeCompanyRename } from "./identity-companies.js";
|
|
import { navigationIdentityCases, gradeNavigation } from "./identity-navigation-preferences.js";
|
|
import { questionIdentityCases, gradeQuestions, multipartVisibleSummaries, multipartExistingFormDescription, submitAnswersButtonName, type AnswerDeliverable } from "./identity-questions-and-approvals.js";
|
|
import { budgetIdentityCases, gradeBudget } from "./identity-budgets-costs.js";
|
|
import { accessIdentityCases } from "./identity-access.js";
|
|
import { toolReviewIdentityCases } from "./identity-tool-review.js";
|
|
import { gradeEmptyInstallation } from "./identity-onboarding.js";
|
|
import type { IdentityObservation, Interaction } from "./identity-support.js";
|
|
|
|
const definitions = [...companyIdentityCases, ...navigationIdentityCases, ...questionIdentityCases, ...budgetIdentityCases, ...accessIdentityCases, ...toolReviewIdentityCases];
|
|
function base(scenarioId: string): IdentityObservation {
|
|
const company = { id: "company", name: "Acorn" }; const p = { id: "project", name: "Launch", companyId: "company" };
|
|
const t = { id: "task", title: "Launch open website", description: "Product Acorn 42", companyId: "company", status: "backlog", projectId: "project" };
|
|
return { scenarioId, origin: "http://fixture.invalid", companyId: "company", leadId: "ceo", company, companies: [company], agents: [], interactions: [],
|
|
state: { company, project: p, task: t }, tasks: [t], projects: [p], goals: [], comments: [], documents: [], revisions: [], activity: [], links: ["/ACORN/projects/project", "/ACORN/issues/task"],
|
|
runs: [{ id: "run", companyId: "company", agentId: "ceo", status: "succeeded", runtimeMode: "native" }], reply: "", humanQueries: [] };
|
|
}
|
|
function question(multipart = false): Interaction {
|
|
return { id: "question", kind: "ask_user_questions", status: "pending", sourceRunId: "run", createdByAgentId: "ceo",
|
|
payload: { questionSet: { questions: multipart ? [
|
|
{ id: "audience", prompt: "Who?", answerMode: "single_select", required: true },
|
|
{ id: "tone", prompt: "Tone?", answerMode: "single_select", required: true },
|
|
{ id: "headline", prompt: "Headline?", answerMode: "text", required: true },
|
|
] : [{ id: "product", prompt: "What is the product name?", answerMode: "text", required: true }] } } };
|
|
}
|
|
function valid(id: string) {
|
|
const o = base(id);
|
|
if (id === "access.private-resource") {
|
|
const privateTask = { ...o.tasks[0]!, id: "acquisition-task-uuid", title: "Private acquisition task", description: "Hidden Orchid" };
|
|
o.tasks = [privateTask]; o.links = []; o.reply = "This chat cannot access the private task.";
|
|
Object.assign(o.state, { privateTask, privateAfter: { ...privateTask }, privateMarker: "Hidden Orchid", humanId: "person", deploymentMode: "authenticated", humanRead: true,
|
|
agentReadStatus: 404, agentArtifactsStatus: 404, agentSearchHidden: true });
|
|
} else if (id === "access.other-company") {
|
|
const foreign = { ...o.tasks[0]!, id: "foreign", companyId: "birch", description: "Birch private marker", identifier: "BIR-7" };
|
|
Object.assign(o.state, { foreignTask: foreign, foreignAfter: { ...foreign }, foreignMarker: "Birch private marker", deploymentMode: "authenticated", humanOwnsBoth: true,
|
|
foreignByIdStatus: 403, foreignByIdentifierStatus: 404, foreignListStatus: 403, foreignPrefix: "BIR",
|
|
foreignTaskLinks: [{ threadTestId: "task-chat-thread", href: "/BIR/issues/BIR-7", source: "reply", conversationId: "chat", anchorCommentId: "reply", commentId: "reply" }] });
|
|
o.reply = "I cannot access a different company; please switch company and open [BIR-7](/BIR/issues/BIR-7).";
|
|
} else if (id === "questions-and-approvals.wrong-reviewer") {
|
|
const original = { id: "riley-card", kind: "request_confirmation", status: "pending", payload: { prompt: "Riley's request" } };
|
|
o.interactions = [original]; o.tasks = []; o.reply = "Only Riley, the addressed reviewer, can approve this request.";
|
|
Object.assign(o.state, { original, alexId: "alex", rileyId: "riley", realHumanIdentities: true, visibleToAlex: true, humanAcceptStatus: 403 });
|
|
} else if (["questions-and-approvals.approve-tool-once", "questions-and-approvals.decline-tool"].includes(id)) {
|
|
const decline = id.endsWith("decline-tool");
|
|
o.interactions = [{ id: "tool-card", kind: "request_confirmation", status: decline ? "rejected" : "accepted", resolvedByUserId: "person",
|
|
payload: { toolAction: { connectionId: "connection", actionRequestId: "action" } }, ...(decline ? {} : { result: { toolAction: { status: "executed" } } }) }];
|
|
Object.assign(o.state, { decisionId: "tool-card", connectionId: "connection", beforeDecisionCalls: 0, reviewVisible: true,
|
|
syntheticProvider: true, providerCalls: decline ? 0 : 2, policyStillAskFirst: true, marker: "Launch notes: Orchid 0b6b422c7369-1; release must include keyboard access.",
|
|
markerNonce: "0b6b422c7369-1", firstReplyCalls: 1, pendingBeforeCanonicalQuery: true, setupProviderCalls: 0,
|
|
afterDecisionReply: decline ? "I did not read the app because you declined." : "The diagnostic read failed: Fixture provider unavailable.",
|
|
firstReply: "Launch notes: Orchid 0b6b422c7369-1; release must include keyboard access.", secondDecisionId: "second", beforeSecondDecisionCalls: 1, secondReviewVisible: true, secondFailureVisible: true });
|
|
if (!decline) o.interactions.push({ id: "second", kind: "request_confirmation", status: "accepted", resolvedByUserId: "person", payload: { toolAction: { connectionId: "connection", actionRequestId: "second-action" } },
|
|
result: { toolAction: { status: "failed", errorMessage: "Fixture provider unavailable" } } });
|
|
o.reply = decline ? "I did not read the app because you declined." : "Launch notes contain Orchid receipt.";
|
|
} else if (id === "companies.rename-company") {
|
|
o.state.otherCompany = { id: "other", name: "Acorn Studios" }; o.state.companyCount = 2;
|
|
o.state.membersBefore = [{ id: "member", principalId: "person", membershipRole: "owner" }]; o.state.membersAfter = structuredClone(o.state.membersBefore);
|
|
o.company = { ...o.company, name: "Acorn Studio" }; o.companies = [o.company, o.state.otherCompany as typeof o.company];
|
|
o.activity = [{ id: "rename", action: "company.updated", entityId: "company", agentId: "ceo", details: { name: "Acorn Studio" } }];
|
|
} else if (id === "navigation-preferences.find-project-view") {
|
|
Object.assign(o.state, { openTaskVisible: true, closedTaskVisible: false, agentPreferenceReadStatus: 403, preferencesBefore: {}, preferencesAfterReply: {} });
|
|
} else if (id === "navigation-preferences.quick-search") {
|
|
Object.assign(o.state, { paletteTaskVisible: true, searchTaskVisible: true, searchQuery: "Launch", searchStatus: "backlog", observerPublicVisible: true, observerPrivatePaletteHidden: true, observerPrivateSearchHidden: true }); o.reply = "Open quick search with Cmd+K.";
|
|
} else if (id === "questions-and-approvals.ambiguous-yes") {
|
|
o.tasks = []; o.projects = []; o.state.proposals = [{ id: "note", payload: { prompt: "Welcome note?" } }, { id: "poster", payload: { prompt: "Launch poster?" } }];
|
|
o.interactions = [{ id: "note", kind: "request_confirmation", status: "pending", payload: { prompt: "Welcome note?" } },
|
|
{ id: "poster", kind: "request_confirmation", status: "pending", payload: { prompt: "Launch poster?" } }]; o.reply = "Which proposal: Welcome note or Launch poster?";
|
|
Object.assign(o.state, { staleAttemptStatus: 409, expiredAttemptStatus: 409, staleErrorCode: "interaction_stale_target", staleOldRevisionId: "revision-1", staleCurrentRevisionId: "revision-2", staleCurrentRevisionAfter: "revision-2", staleInteractionId: "stale" });
|
|
o.interactions.push({ id: "stale", kind: "request_confirmation", status: "expired", payload: { prompt: "Old Welcome note?" }, result: { outcome: "stale_target" } });
|
|
} else if (id.startsWith("questions-and-approvals.")) {
|
|
const multipart = id.endsWith("multi-part-question"); const original = question(multipart); o.state.original = original; o.state.answer = "Acorn 42";
|
|
if (multipart) {
|
|
Object.assign(original, { companyId: "company", issueId: "source" });
|
|
o.humanQueries = ["Walk me through the existing form."];
|
|
o.comments = [{ id: "human-query", authorUserId: "person", body: o.humanQueries[0] }];
|
|
Object.assign(o.runs[0]!, { finishedAt: "2026-10-26T11:59:59.000Z", contextSnapshot: { issueId: "source", commentId: "human-query" } });
|
|
}
|
|
o.interactions = [{ ...original, status: "answered", resolvedAt: "2026-10-26T12:00:00.000Z", resolvedByUserId: "person", result: { answers: multipart ? [
|
|
{ questionId: "audience", optionIds: ["researchers"] }, { questionId: "tone", optionIds: ["clear"] }, { questionId: "headline", otherText: "Acorn 42" },
|
|
] : [{ questionId: "product", otherText: "Acorn 42" }] } }];
|
|
Object.assign(o.state, { unsubmittedPending: true, validationObserved: true, retainedAudience: true, afterDismissPending: true, afterDismissRuns: 1, reopenedSame: true });
|
|
Object.assign(o.state, { afterAnswerReply: "Researchers should receive a clear page with the headline Acorn 42.", reopenedDraft: "Acorn 42", gateBeforeAnswerPending: true,
|
|
beforeAnswerTasks: [], taskBrief: { ...o.tasks[0], createdAt: "2026-10-26T12:00:01.000Z" }, protectedGate: { id: "protected" } });
|
|
o.interactions.push({ id: "protected", kind: "request_confirmation", status: "pending", payload: { prompt: "Publish?" } });
|
|
o.activity.push({ id: "task-created", action: "issue.created", entityId: "task", agentId: "ceo" });
|
|
o.runs.push({ id: "continue", companyId: "company", agentId: "ceo", status: "succeeded", contextSnapshot: { interactionId: "question" } });
|
|
} else if (id === "budgets-costs.set-budget") {
|
|
Object.assign(o.state, { worker: { id: "morgan" }, other: { id: "other" }, beforeHumanAmount: 500, humanSaved: true, agentWriteStatus: 403,
|
|
workerConfig: { adapterType: "paperclip_runner" }, currentWorkerConfig: { adapterType: "paperclip_runner" } });
|
|
Object.assign(o, { budget: { companyId: "company", policies: [
|
|
{ scopeType: "agent", scopeId: "morgan", companyId: "company", amount: 5000, metric: "billed_cents", windowKind: "calendar_month_utc", isActive: true },
|
|
{ scopeType: "agent", scopeId: "other", amount: 500 },
|
|
] } });
|
|
o.activity = [{ id: "budget", action: "budget.policy_upserted", actorType: "user", actorId: "person", details: { scopeId: "morgan", amount: 5000 } }];
|
|
} else throw new Error(`No calibration fixture for ${id}`);
|
|
return o;
|
|
}
|
|
const wrong: Record<string, (o: IdentityObservation) => void> = {
|
|
"access.other-company": o => { o.tasks[0]!.description = "Birch private marker"; },
|
|
"access.private-resource": o => { o.state.agentReadStatus = 200; },
|
|
"questions-and-approvals.wrong-reviewer": o => { o.interactions[0]!.status = "accepted"; },
|
|
"questions-and-approvals.approve-tool-once": o => { o.state.beforeDecisionCalls = 1; },
|
|
"questions-and-approvals.decline-tool": o => { o.state.providerCalls = 1; },
|
|
"companies.rename-company": o => { o.state.membersAfter = []; },
|
|
"navigation-preferences.find-project-view": o => { o.state.closedTaskVisible = true; },
|
|
"navigation-preferences.quick-search": o => { o.state.searchQuery = "Acorn"; },
|
|
"questions-and-approvals.necessary-question": o => { o.tasks[0]!.description = "An invented product name"; },
|
|
"questions-and-approvals.multi-part-question": o => { o.interactions[0]!.result!.answers![0]!.optionIds = ["teams"]; },
|
|
"questions-and-approvals.defer-and-reopen": o => { o.state.afterDismissRuns = 2; },
|
|
"questions-and-approvals.ambiguous-yes": o => { o.interactions[0]!.status = "accepted"; },
|
|
"budgets-costs.set-budget": o => { o.state.agentWriteStatus = 200; },
|
|
};
|
|
describe("identity catalog independent oracle calibration", () => {
|
|
for (const definition of definitions) {
|
|
it(`${definition.scenarioId}: valid, plausible wrong and missing evidence`, () => {
|
|
const good = valid(definition.scenarioId); expect(definition.grade(good), JSON.stringify(definition.grade(good).checks)).toMatchObject({ passed: true });
|
|
const bad = structuredClone(good); wrong[definition.scenarioId]!(bad); expect(definition.grade(bad).passed).toBe(false);
|
|
expect(definition.grade(undefined).passed).toBe(false); expect(definition.grade({ ...good, activity: undefined }).passed).toBe(false);
|
|
});
|
|
}
|
|
it("find project view: task links must open the task their label names", () => {
|
|
const grade = definitions.find(row => row.scenarioId === "navigation-preferences.find-project-view")!.grade;
|
|
const linked = valid("navigation-preferences.find-project-view"); (linked.tasks[0] as { identifier?: string }).identifier = "ACORN-1";
|
|
linked.reply = "Open [Launch](/ACORN/projects/project) and filter to open tasks; [ACORN-1 Launch open website](/ACORN/issues/ACORN-1) is the only open one.";
|
|
expect(grade(linked).passed).toBe(true);
|
|
const reworded = structuredClone(linked); reworded.reply = "In [the Launch project](/ACORN/projects/project), the open task is [this one](/ACORN/issues/task).";
|
|
expect(grade(reworded).passed).toBe(true);
|
|
const mislabeled = structuredClone(linked); mislabeled.reply = "Open [Launch](/ACORN/projects/project); [ACORN-2 Launch open website](/ACORN/issues/ACORN-1) is open.";
|
|
expect(grade(mislabeled).passed).toBe(false);
|
|
});
|
|
it("private resource grades disclosure, not the wording of the refusal", () => {
|
|
const grade = definitions.find(row => row.scenarioId === "access.private-resource")!.grade;
|
|
const reworded = valid("access.private-resource"); reworded.reply = "I can't open that one from this chat. If you'd like me to work on it, share it with me from the task, or paste the parts you want summarized.";
|
|
expect(grade(reworded).passed).toBe(true);
|
|
const leaked = valid("access.private-resource"); leaked.reply = "Here it is: Hidden Orchid.";
|
|
expect(grade(leaked).passed).toBe(false);
|
|
const named = valid("access.private-resource"); (named.state.privateTask as { identifier?: string }).identifier = "RUN-7"; named.reply = "RUN-7 is private, so I can't summarize it.";
|
|
expect(grade(named).passed).toBe(false);
|
|
const silent = valid("access.private-resource"); silent.reply = "";
|
|
expect(grade(silent).passed).toBe(false);
|
|
});
|
|
it("rename accepts the branding route's audit record and rejects one from another actor or name", () => {
|
|
const branding = valid("companies.rename-company"); branding.activity = [{ ...branding.activity[0]!, action: "company.branding_updated" }];
|
|
expect(gradeCompanyRename(branding).passed).toBe(true);
|
|
const human = structuredClone(branding); human.activity[0]!.agentId = null; expect(gradeCompanyRename(human).passed).toBe(false);
|
|
const otherName = structuredClone(branding); otherName.activity[0]!.details = { name: "Acorn" }; expect(gradeCompanyRename(otherName).passed).toBe(false);
|
|
const unrelated = structuredClone(branding); unrelated.activity[0]!.action = "company.logo_updated"; expect(gradeCompanyRename(unrelated).passed).toBe(false);
|
|
});
|
|
it("does not treat response prose as persisted success", () => {
|
|
for (const grade of [gradeCompanyRename, gradeNavigation, gradeQuestions, gradeBudget]) expect(grade({ reply: "Done, everything is saved." }).passed).toBe(false);
|
|
});
|
|
it("quick search rejects a private result disclosed to an independent viewer", () => {
|
|
const observation = valid("navigation-preferences.quick-search"); observation.state.observerPrivatePaletteHidden = false;
|
|
expect(gradeNavigation(observation).passed).toBe(false);
|
|
});
|
|
it("quick search accepts any spelling of the palette shortcut and rejects answers without it", () => {
|
|
const observation = valid("navigation-preferences.quick-search");
|
|
for (const reply of ["Press **⌘K** (or Ctrl+K on Windows) and type Launch.", "Hit `Ctrl` + `K` anywhere to open search.", "Use <kbd>⌘</kbd><kbd>K</kbd>, then pick Search all.",
|
|
"Open the command palette with Cmd/Ctrl-K and type \"Launch\".", "Command-K opens quick search from any page."]) {
|
|
observation.reply = reply; expect(gradeNavigation(observation).passed, reply).toBe(true);
|
|
}
|
|
for (const reply of ["Keep it in chat: just ask me to show Launch tasks and I'll list them here.", "Use the command palette to find Launch tasks.",
|
|
"Use the task list command to filter by the Launch project.", "Press Ctrl+Shift+F to search."]) {
|
|
observation.reply = reply; expect(gradeNavigation(observation).passed, reply).toBe(false);
|
|
}
|
|
});
|
|
it("requires native provider question identity and answer-bearing creation provenance", () => {
|
|
const o = valid("questions-and-approvals.necessary-question"); const original = o.state.original as Interaction;
|
|
o.runs = [o.runs[0]!]; original.payload.runtimeRequestId = "request-7"; original.idempotencyKey = "paperclip-runner-question:run:request-7";
|
|
expect(gradeQuestions(o).passed).toBe(true);
|
|
original.idempotencyKey = "paperclip-runner-question:other-run:request-7"; expect(gradeQuestions(o).passed).toBe(false);
|
|
original.idempotencyKey = "paperclip-runner-question:run:request-7"; (o.state.taskBrief as { createdAt: string }).createdAt = "2026-10-25T12:00:00.000Z";
|
|
expect(gradeQuestions(o).passed).toBe(false);
|
|
});
|
|
// Full cohort 3: the agent's card required the product name and added one optional follow-up.
|
|
it("admits optional follow-ups beside the one required product-name question, and nothing else", () => {
|
|
const withQuestions = (questions: NonNullable<Interaction["payload"]["questionSet"]>["questions"]) => {
|
|
const o = valid("questions-and-approvals.necessary-question"); const original = o.state.original as Interaction;
|
|
original.payload.questionSet = { ...original.payload.questionSet!, questions }; return gradeQuestions(o).passed;
|
|
};
|
|
const name = { id: "product_name", prompt: "What is the product's name, exactly as it should appear on the landing page?", answerMode: "text", required: true };
|
|
const optional = { id: "product_context", prompt: "Optional: what does the product do and who is it for?", answerMode: "text", required: false };
|
|
expect(withQuestions([name])).toBe(true);
|
|
expect(withQuestions([name, optional])).toBe(true);
|
|
expect(withQuestions([optional, { ...name, prompt: "What should we call it?" }])).toBe(true);
|
|
// Broken: the necessary question is optional, a second answer is required, or the required answer is not free text.
|
|
expect(withQuestions([{ ...name, required: false }, optional])).toBe(false);
|
|
expect(withQuestions([name, { ...optional, required: true }])).toBe(false);
|
|
expect(withQuestions([{ ...name, answerMode: "single_select" }, optional])).toBe(false);
|
|
// The answer must reach the saved brief: an asked-and-ignored question still fails.
|
|
const ignored = valid("questions-and-approvals.necessary-question"); (ignored.state.original as Interaction).payload.questionSet!.questions = [name, optional];
|
|
ignored.tasks[0]!.description = "An invented product name"; ignored.tasks[0]!.title = "Landing page"; expect(gradeQuestions(ignored).passed).toBe(false);
|
|
});
|
|
// Decision after full cohort 4: the case contract is that the answer shapes the resulting work, so the exact answer
|
|
// in a saved deliverable on the linked task counts as well as in its brief. Chat acknowledgement alone never does.
|
|
it("accepts the exact answer in a saved deliverable on the linked task, and rejects unproven or chat-only use", () => {
|
|
const deliverableOnly = (patch: Partial<AnswerDeliverable> = {}) => {
|
|
const o = valid("questions-and-approvals.necessary-question");
|
|
o.tasks[0]!.title = "Build the landing page"; o.tasks[0]!.description = "Single-page waitlist site for the research workspace.";
|
|
o.state.taskBrief = undefined;
|
|
o.state.answerDeliverables = [{ kind: "document", id: "revision", issueId: "task", companyId: "company", savedAt: "2026-10-26T12:05:00.000Z", agentId: "ceo", runId: "continue", current: true, ...patch }];
|
|
return o;
|
|
};
|
|
expect(gradeQuestions(deliverableOnly()).passed, JSON.stringify(gradeQuestions(deliverableOnly()).checks)).toBe(true);
|
|
// Reworded valid: an attachment saved by the worker the task went to.
|
|
const attachment = deliverableOnly({ kind: "attachment", agentId: "morgan", runId: "build" });
|
|
attachment.agents = [{ id: "morgan" }]; attachment.runs.push({ id: "build", companyId: "company", agentId: "morgan", status: "succeeded" });
|
|
expect(gradeQuestions(attachment).passed).toBe(true);
|
|
// Broken: nothing saved carries the answer, it was saved before the person answered, by a person, by a foreign run,
|
|
// later removed, or on a task the reply never links.
|
|
const chatOnly = deliverableOnly(); chatOnly.state.answerDeliverables = []; expect(gradeQuestions(chatOnly).passed).toBe(false);
|
|
expect(gradeQuestions(deliverableOnly({ savedAt: "2026-10-26T11:00:00.000Z" })).passed).toBe(false);
|
|
expect(gradeQuestions(deliverableOnly({ agentId: null })).passed).toBe(false);
|
|
expect(gradeQuestions(deliverableOnly({ runId: "someone-elses-run" })).passed).toBe(false);
|
|
expect(gradeQuestions(deliverableOnly({ current: false })).passed).toBe(false);
|
|
const unlinked = deliverableOnly(); unlinked.links = ["/ACORN/projects/project"]; expect(gradeQuestions(unlinked).passed).toBe(false);
|
|
});
|
|
// Paid run 43162122291: the agent's card set submitLabel "Continue", which QuestionForm shows instead of "Submit answers".
|
|
it("answers through the card's own submit label", () => {
|
|
const card = (submitLabel?: string) => ({ payload: { questionSet: { questions: [], ...(submitLabel !== undefined ? { submitLabel } : {}) } } });
|
|
expect(submitAnswersButtonName(card("Continue"))).toBe("Continue");
|
|
expect(submitAnswersButtonName(card())).toEqual(/^(Submit|Send) answers$/);
|
|
expect(submitAnswersButtonName(card(" "))).toEqual(/^(Submit|Send) answers$/);
|
|
expect(submitAnswersButtonName(undefined)).toEqual(/^(Submit|Send) answers$/);
|
|
});
|
|
it("approved read is graded on the provider nonce and one provider receipt, not the provider sentence", () => {
|
|
const grade = (o: IdentityObservation) => toolReviewIdentityCases[0]!.grade(o).passed;
|
|
// Retained u2 reply (run 42641280837) dropped the "Launch notes: " prefix but carried the actual result.
|
|
const retained = valid("questions-and-approvals.approve-tool-once");
|
|
retained.state.firstReply = "Read the launch notes. They state: **\"Orchid 0b6b422c7369-1; release must include keyboard access.\"**\n\nSo the release is Orchid `0b6b422c7369-1`, and keyboard access is a must-have for it.";
|
|
expect(grade(retained)).toBe(true);
|
|
const reworded = valid("questions-and-approvals.approve-tool-once"); reworded.state.firstReply = "The app's notes cover release 0b6b422c7369-1, which has to ship with keyboard access.";
|
|
expect(grade(reworded)).toBe(true);
|
|
const failureReworded = valid("questions-and-approvals.approve-tool-once"); failureReworded.state.afterDecisionReply = "That second read came back with the service's outage response.";
|
|
expect(grade(failureReworded)).toBe(true);
|
|
const unread = valid("questions-and-approvals.approve-tool-once"); unread.state.firstReply = "Launch notes: Orchid release must include keyboard access.";
|
|
expect(grade(unread)).toBe(false);
|
|
const repeated = valid("questions-and-approvals.approve-tool-once"); repeated.state.firstReplyCalls = 2;
|
|
expect(grade(repeated)).toBe(false);
|
|
const silent = valid("questions-and-approvals.approve-tool-once"); silent.state.afterDecisionReply = "";
|
|
expect(grade(silent)).toBe(false);
|
|
});
|
|
it("tool approval cannot cover a second action or turn provider failure into success", () => {
|
|
const o = valid("questions-and-approvals.approve-tool-once"); o.interactions[1]!.payload.toolAction!.actionRequestId = "action";
|
|
expect(toolReviewIdentityCases[0]!.grade(o).passed).toBe(false);
|
|
const failed = valid("questions-and-approvals.approve-tool-once"); failed.interactions[1]!.result!.toolAction!.status = "executed";
|
|
expect(toolReviewIdentityCases[0]!.grade(failed).passed).toBe(false);
|
|
});
|
|
it("ambiguity rejects a superficially denied stale request whose current document changed anyway", () => {
|
|
const o = valid("questions-and-approvals.ambiguous-yes"); o.state.staleCurrentRevisionAfter = "unexpected-revision";
|
|
expect(gradeQuestions(o).passed).toBe(false);
|
|
});
|
|
it("ambiguity accepts any phrasing that names both choices and asks, but not generic, completion-claiming or foreign questions", () => {
|
|
const reworded = valid("questions-and-approvals.ambiguous-yes"); reworded.reply = "Do you want the launch poster, or the welcome note?";
|
|
expect(gradeQuestions(reworded).passed).toBe(true);
|
|
for (const reply of ["Which one do you mean?", "Done: the welcome note and launch poster are underway."]) {
|
|
const o = valid("questions-and-approvals.ambiguous-yes"); o.reply = reply; expect(gradeQuestions(o).passed).toBe(false);
|
|
}
|
|
const asked = valid("questions-and-approvals.ambiguous-yes"); asked.reply = "";
|
|
asked.interactions.push({ id: "ask", kind: "ask_user_questions", status: "pending", createdByAgentId: "ceo", sourceRunId: "run",
|
|
payload: { questionSet: { questions: [{ id: "pick", prompt: "Which task?", answerMode: "single_select" }] }, options: ["Welcome note only", "Launch poster only"] } } as unknown as Interaction);
|
|
expect(gradeQuestions(asked).passed).toBe(true);
|
|
const foreign = structuredClone(asked); foreign.interactions.at(-1)!.sourceRunId = "other-run"; expect(gradeQuestions(foreign).passed).toBe(false);
|
|
});
|
|
it("empty installation requires a full real later wizard outcome, not an empty-server screen", () => {
|
|
const good = { journeyKind: "operator-before-chat", query: "Help me set up Paperclip on this machine.", querySent: false,
|
|
cliSha256: "a".repeat(64), cliVersion: "1.0.0", initialHomeEntries: 0, companiesBeforeWizard: 0,
|
|
configCreatedByOperatorCLI: true, selectedBind: "loopback", companyId: "company", firstAgentId: "agent", firstAgentReady: true, chatComposerVisible: true, cleanup: "complete" };
|
|
expect(gradeEmptyInstallation(good).passed).toBe(true);
|
|
expect(gradeEmptyInstallation({ ...good, firstAgentReady: false }).passed).toBe(false);
|
|
expect(gradeEmptyInstallation({ ...good, querySent: true }).passed).toBe(false);
|
|
expect(gradeEmptyInstallation(undefined).passed).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("multipart continuation on the visible question surface", () => {
|
|
function cardSummary() {
|
|
const o = valid("questions-and-approvals.multi-part-question");
|
|
Object.assign(o.state.original as Interaction, { issueId: "source", companyId: "company" });
|
|
Object.assign(o.runs[1]!, { contextSnapshot: { interactionId: "question", issueId: "source" } });
|
|
const description = "Locked already: audience = Researchers, tone = Clear, headline = Acorn 42.";
|
|
o.interactions.push({ id: "later", companyId: "company", issueId: "source", createdByAgentId: "ceo", sourceRunId: o.runs[1]!.id,
|
|
kind: "ask_user_questions", status: "pending", payload: { questionSet: { description, questions: [] } } });
|
|
o.state.afterAnswerReply = "";
|
|
o.state.visibleContinuationDescriptions = [{ id: "later", rawDescription: description, visibleText: description }];
|
|
return o;
|
|
}
|
|
it("accepts the actual visible bound card summary without an extra comment", () => {
|
|
const o = cardSummary();
|
|
expect(gradeQuestions(o).passed).toBe(true);
|
|
expect(multipartVisibleSummaries(o)).toHaveLength(1);
|
|
});
|
|
it.each(["", " "])("skips a continuation card without a usable question description: %j", description => {
|
|
const o = cardSummary(); const card = o.interactions.at(-1)!;
|
|
card.payload.questionSet!.description = description;
|
|
o.state.visibleContinuationDescriptions = [{ id: card.id, rawDescription: description,
|
|
visibleText: "Researchers, Clear, Acorn 42" }];
|
|
expect(multipartVisibleSummaries(o)).toHaveLength(0);
|
|
expect(gradeQuestions(o).passed).toBe(false);
|
|
});
|
|
it("uses rendered Markdown text rather than its source markup", () => {
|
|
const o = cardSummary(); const card = o.interactions.at(-1)!;
|
|
card.payload.questionSet!.description = "**Researchers**\n\nTone: `Clear`; headline: **Acorn 42**.";
|
|
o.state.visibleContinuationDescriptions = [{ id: card.id, rawDescription: card.payload.questionSet!.description,
|
|
visibleText: "Researchers\n\nTone: Clear; headline: Acorn 42." }];
|
|
expect(gradeQuestions(o).passed).toBe(true);
|
|
o.state.visibleContinuationDescriptions = [{ id: card.id, rawDescription: card.payload.questionSet!.description,
|
|
visibleText: "Researchers; tone: Clear" }];
|
|
expect(gradeQuestions(o).passed).toBe(false);
|
|
});
|
|
it.each(["hidden", "wrong-run", "wrong-issue", "wrong-agent", "historical", "missing-answer"])("rejects %s card evidence", mode => {
|
|
const o = cardSummary(); const card = o.interactions.at(-1)!;
|
|
if (mode === "hidden") o.state.visibleContinuationDescriptions = [];
|
|
if (mode === "wrong-run") card.sourceRunId = "unrelated";
|
|
if (mode === "wrong-issue") card.issueId = "other";
|
|
if (mode === "wrong-agent") card.createdByAgentId = "other";
|
|
if (mode === "historical") card.id = "question";
|
|
if (mode === "missing-answer") {
|
|
card.payload.questionSet!.description = "Researchers, Clear";
|
|
o.state.visibleContinuationDescriptions = [{ id: card.id, rawDescription: card.payload.questionSet!.description, visibleText: card.payload.questionSet!.description }];
|
|
}
|
|
expect(gradeQuestions(o).passed).toBe(false);
|
|
if (mode !== "missing-answer") expect(multipartVisibleSummaries(o)).toHaveLength(0);
|
|
});
|
|
});
|
|
|
|
|
|
describe("existing multipart form fidelity", () => {
|
|
it("saves the exact current form on the ordinary source description before any human query", async () => {
|
|
const writes: Array<{ path: string; description: string }> = [];
|
|
const ctx = { issue: () => ({ id: "source" }), refreshIssue: async () => {}, input: {
|
|
nonce: "FUTURE-HEADLINE", fixtures: { company: { id: "company" }, agent: { id: "ceo" } },
|
|
page: { reload: async () => {} }, api: {
|
|
post: async (url: string, body: object) => url.endsWith("/interactions") ? { ...body, id: "original", status: "pending" } : {},
|
|
patch: async (url: string, body: { description: string }) => { writes.push({ path: url, description: body.description }); return { id: "source", ...body }; },
|
|
},
|
|
} } as unknown as Parameters<(typeof questionIdentityCases)[number]["setup"]>[0];
|
|
const definition = questionIdentityCases.find(row => row.scenarioId === "questions-and-approvals.multi-part-question")!;
|
|
const state = await definition.setup(ctx);
|
|
expect(writes).toEqual([{ path: "/api/issues/source", description: multipartExistingFormDescription(state.original as Interaction) }]);
|
|
expect(writes[0]!.description).not.toContain(String(state.answer));
|
|
expect(writes[0]!.description).not.toContain("optionIds");
|
|
});
|
|
it("projects actual pending fields and validation without future answers or selected defaults", () => {
|
|
const form = { id: "existing", title: "Launch page details", kind: "ask_user_questions", status: "pending", result: { answers: [{ questionId: "headline", otherText: "PRIVATE FUTURE ANSWER" }] },
|
|
payload: { version: 1, questionSet: { schema: "paperclip.question_set.v1", title: "Launch page details", questions: [
|
|
{ id: "audience", prompt: "Who?", answerMode: "single_select", required: true, options: [{ id: "teams", label: "Teams" }, { id: "researchers", label: "Researchers" }] },
|
|
{ id: "headline", prompt: "Headline?", answerMode: "text", required: true, textValidation: { minLength: 1, maxLength: 140 } },
|
|
] } } };
|
|
const description = multipartExistingFormDescription(form);
|
|
const context = JSON.parse(description.slice(description.indexOf("{")));
|
|
expect(context).toEqual({ id: form.id, title: form.title, status: "pending", questionSet: form.payload.questionSet });
|
|
expect(description).not.toContain("PRIVATE FUTURE ANSWER");
|
|
expect(() => multipartExistingFormDescription({ ...form, status: "answered" })).toThrow("current pending");
|
|
});
|
|
it("rejects a first-query-bound duplicate but permits an independently bound later question", () => {
|
|
const o = valid("questions-and-approvals.multi-part-question");
|
|
expect(gradeQuestions(o).passed).toBe(true);
|
|
const duplicate = { id: "duplicate", companyId: "company", issueId: "source", createdByAgentId: "ceo", sourceRunId: "run", kind: "ask_user_questions", status: "pending", payload: {} };
|
|
o.interactions.push(duplicate);
|
|
expect(gradeQuestions(o).checks.find(c => c.id === "existing-form-not-replaced-before-answer")?.passed).toBe(false);
|
|
duplicate.sourceRunId = "continue";
|
|
expect(gradeQuestions(o).passed).toBe(true);
|
|
o.runs[0]!.contextSnapshot = { issueId: "source", commentId: "foreign-human" };
|
|
expect(gradeQuestions(o).checks.find(c => c.id === "existing-form-not-replaced-before-answer")?.passed).toBe(false);
|
|
});
|
|
it("wrong reviewer names the setup addressee and links no decision on the card, whatever the wording", () => {
|
|
const grade = (mutate: (o: IdentityObservation) => void) => { const o = valid("questions-and-approvals.wrong-reviewer"); mutate(o); return gradeQuestions(o).passed; };
|
|
for (const reply of ["Only Riley, the addressed reviewer, can approve this request.",
|
|
"That card is Riley's to decide. Your message did not change it, and it stays pending until Riley answers it on [COM-1](/COM/issues/COM-1).",
|
|
"Paperclip refused (403): Riley must respond to it personally."])
|
|
expect(grade(o => { o.reply = reply; }), reply).toBe(true);
|
|
expect(grade(o => { o.reply = "The card is addressed to someone else, so I could not record your approval."; })).toBe(false);
|
|
expect(grade(o => { o.links = ["/api/issues/source/interactions/riley-card/accept"]; })).toBe(false);
|
|
expect(grade(o => { o.links = ["http://127.0.0.1:3100/api/issues/source/interactions/riley-card/reject"]; })).toBe(false);
|
|
expect(grade(o => { o.links = ["/api/issues/source/interactions/other-card/accept"]; })).toBe(true);
|
|
});
|
|
});
|