mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 06:03:51 +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. It grades saved state, rendered links and run ledgers. > - Chat-eval cohort 15 (OpenCode with `openrouter/deepseek/deepseek-v4.1-flash-1017`, master `36101ebcb9`) failed four cases where the agent did the right thing or where our own server text misled it. > - One failure was a harness race introduced by #21667. Two failures came from graders that read free-form text with keyword regexes. One failure came from an unprefixed approval link in the server's completion feedback, plus a grader that required a literal prefix. > - This pull request fixes the harness step, replaces the free-form graders with saved-state and clicked-link checks, and makes the server emit company-prefixed board links. > - The benefit is that these cases measure the feature again. The retained correct outcomes pass, and the relevant broken outcomes still fail. ## Linked Issues or Issue Description Refs #21667 **What happened?** In chat-eval cohort 15, four cases failed: - `projects.share-project`: the harness followed the agent's ID-based project link. The app then rewrote the URL to the project slug and redrew the page. The owner step timed out because Riley's option in the people picker was "detached from the DOM". #21667 introduced this path. - `skills.author-skill`: the saved skill was a correct, richer checklist. Per-sentence keyword regexes rejected it. For example, "ignore the mouse" tripped the forbidden word "ignore". - `inbox-search.show-decisions`: the reply linked the right approval and tasks and said the question was "addressed to a different teammate". A regex required the word "Riley". - `agents.hire-needs-approval`: both replies linked `/approvals/<id>` without the company prefix. The agent copied that link from `server/src/services/native-runtime/native-completion-feedback.ts`. The grader required a literal `/<prefix>/approvals/<id>`, although the board redirects the unprefixed route. **Expected behavior** Correct agent behaviour passes. Grading uses saved state, setup literals and rendered or clicked links, not free-form wording. The server gives agents canonical company-prefixed board links. **Steps to reproduce** 1. Use the retained cohort-15 evidence for the four cases. 2. Run the old graders on the retained skill markdown and decisions reply. Both fail. 3. For share-project, open a project configuration page by ID while the app rewrites the route after a delay, then use the access picker before the rewrite completes. 4. For hire-needs-approval, finish a task with a pending linked approval. The feedback links `/approvals/<id>`. **Paperclip version or commit** master `36101ebcb9` (cohort 15); fixed on top of current master. ## What Changed - `projects.share-project` (`internal-privacy.ts`, `runtime-support.ts`): after the harness follows the agent's link, it waits until the URL settles on the project's canonical route key. This reuses the #21667 approach for agent profiles: `settleAgentProfileRoute` now calls a shared `settleRouteKey`, and `projectRouteKey` follows the app's `projectRouteRef`. The owner's picker selection (`addProjectAccessMember`) now retries as one unit. If the dialog or picker closes, or an option detaches, it reopens them, searches again and selects again. It continues only when the picker shows the person and Add is enabled. - `skills.author-skill` (`integrator-skills.ts`): removed the keyword-regex checklist grader, the waiver regexes, and the reply regexes for "global activation" and "attached to me" claims. The saved-state checks stay: one agent-created writable skill, its current revision authored by the responding agent, the same bytes on the skill and the revision, the Skills/Studio inspection with reload, and assignment scope from saved assignments and audit rows. The checklist check now requires the setup literals `375`, `WCAG` and `AA` as whole tokens in the saved SKILL.md and in the rendered editor. Whether the skill still asks for keyboard-only navigation and visible labels, and whether it waives a check, is left to human review. Oracle version `skill-authoring.v10`. - `inbox-search.show-decisions` (`internal-decision-search.ts`): removed all reply regexes, including the `Riley` requirement and the wording-based separation checks. The grade now uses saved state (pending decisions unchanged, answered history unchanged, each person's own attention queue and resolver) and rendered links to the exact approval, the question's task and the history task. Oracle version `decision-search.v3`. - Product (`native-completion-feedback.ts`): the completion feedback now links `/<prefix>/approvals/<id>` and `/<prefix>/issues/<identifier>`. This fixes the approval link and the four sibling task links in the same file. - `agents.hire-needs-approval` (`runtime-hiring.ts`): the harness now clicks each reply's rendered link to its approval and records where the UI lands. The grade accepts a prefixed link, or an unprefixed link that the board redirect lands on `/<prefix>/approvals/<id>` with the proposed hire visible. Without such a link, the harness still opens the approval directly so later phases keep their evidence, and the grade fails. Oracle version `runtime-hiring.v4`. - No eval YAML changed, so the TestOps manifest does not change. `chat-catalog-descriptors.json` records the three oracle version bumps. ## Verification - Red/green tests (each new test fails on the old code and passes on the new code): - `internal-privacy-share-route.test.ts` (real Chromium): the project page rewrites its route after 0, 400 and 1500 ms, and one case closes the picker while its first results render. With the old flow, the 400 ms rewrite and the closed picker both time out on the option click (the cohort-15 failure). With the fix, Riley is added on the settled route in all cases. - `integrator-skills.test.ts`: the retained cohort-15 SKILL.md passes. The old grader rejects it. A stale skill body, another author, and a lost 375 width still fail. - `internal-decision-search.test.ts`: the retained cohort-15 reply and a reworded reply pass. The old grader rejects the retained reply. A missing or wrong approval, question-task or history-task link fails. - `native-completion-feedback.test.ts`: a pending linked approval produces `[the pending approval](/<prefix>/approvals/<id>)`, and a pending review stage produces a prefixed task link. The old code produces `/approvals/<id>`. - `runtime-hiring.test.ts`: unprefixed links that the redirect lands on the right approval pass. The old grader rejects them. A link that did not land, landed on another approval, was not clicked, or is another href still fails. - `npx vitest run --config tests/runner-e2e/vitest.config.ts chat-catalog`: all passed (one negative control in `internal.test.ts` changed from a reply wording to "approved while listing"). - `pnpm test:e2e:runner:typecheck` and `server` `tsc --noEmit`: passed. - `server` vitest for `native-completion-feedback`, `native-current-wake-completion-feedback` and `heartbeat/run-completion`: 201 tests passed. - Narrow paid run of the four full case ids on this branch: run 43657390762 (results are added in a comment). ## Risks - Low risk. The product change only adds the company prefix to links in agent feedback text. It adds one indexed company read, and only on the branches that return a link. - Less is graded automatically, by design. `skills.author-skill` no longer checks that the skill keeps the keyboard-only and visible-label checks or that it does not waive a check. `inbox-search.show-decisions` no longer checks how the reply names resolvers or separates the person's decision from others' and from history. `skills.author-skill` no longer checks whether the reply describes the assignment scope truthfully. A person reviews this meaning. Saved state and links still catch the plausible broken outcomes listed above. - `agents.hire-needs-approval` now needs a reply link that really opens the approval. A reply without a link to its approval fails as before. ## Model Used - Claude, model ID `claude-opus-5-5` (Claude Code agent with tool use and code execution). ## 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>
155 lines
12 KiB
TypeScript
155 lines
12 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { gradeIntegratorSkills, integratorSkillsCases, websiteChecklist, keepsWebsiteChecklistLiterals } from "./integrator-skills.js";
|
|
|
|
function valid(id: string) {
|
|
const markdown = websiteChecklist.join("\n");
|
|
const version = { id: "revision", companyId: "company", companySkillId: "skill", authorAgentId: "ceo", fileInventory: [{ path: "SKILL.md", content: markdown }] };
|
|
const skill = { id: "skill", companyId: "company", name: "Accessibility review", editable: true, markdown, currentVersionId: "revision", usedByAgents: [] };
|
|
const denied = id === "skills.explicit-restriction";
|
|
return { scenarioId: id, origin: "https://fixture.test", companyId: "company", leadId: "ceo", state: denied ? { skill: structuredClone(skill), versions: [structuredClone(version)], policyRevision: 3 } : { authoredSkillInspection: {companyId:"company",skillId:"skill",versionId:"revision",libraryVisible:true,editorVisible:true,editorSurface:"studio",editable:true,checklistVisible:true,reloaded:true,readbackMatched:true} },
|
|
tasks: [], projects: [], goals: [], comments: [], documents: [], revisions: [], humanQueries: [], runs: [{ id: "run", agentId: "ceo", status: "succeeded" }],
|
|
activity: denied ? [] : [{ id: "create", entityId: "skill", action: "company.skill_created", agentId: "ceo" }],
|
|
reply: denied ? "Company policy denies my skill edits. Ask an administrator to request a change." : "Created the reusable review skill; it is available in Studio. This does not enable it for all agents.",
|
|
links: ["/ACORN/skills/studio/skill"], skills: [skill], versions: { skill: [version] }, policy: { revision: 3 },
|
|
editDecision: { allowed: !denied, matchedRuleId: denied ? "deny-ceo-skill-edits" : null } };
|
|
}
|
|
describe("authored skill outcomes", () => {
|
|
for (const definition of integratorSkillsCases) {
|
|
it(`${definition.scenarioId}: real-shaped saved outcome and missing evidence`, () => {
|
|
expect(gradeIntegratorSkills(valid(definition.scenarioId)).passed).toBe(true);
|
|
expect(gradeIntegratorSkills(undefined).passed).toBe(false);
|
|
expect(gradeIntegratorSkills({ ...valid(definition.scenarioId), versions: undefined }).passed).toBe(false);
|
|
});
|
|
}
|
|
it("rejects a suggestion without creation, lost checklist requirement, or no saved revision", () => {
|
|
const o = valid("skills.author-skill");
|
|
expect(gradeIntegratorSkills({ ...o, activity: [] }).passed).toBe(false);
|
|
const missing = structuredClone(o); missing.skills[0]!.markdown = "Review the website."; missing.versions.skill[0]!.fileInventory[0]!.content = "Review the website.";
|
|
expect(gradeIntegratorSkills(missing).passed).toBe(false);
|
|
const notInspected = structuredClone(o); delete (notInspected.state as {authoredSkillInspection?:unknown}).authoredSkillInspection; expect(gradeIntegratorSkills(notInspected).passed).toBe(false);
|
|
});
|
|
it("rejects a policy denial explained as success, a fictional source limitation, or a stealth fork", () => {
|
|
const o = valid("skills.explicit-restriction");
|
|
for (const reply of ["The policy allows me to rewrite it. Ask an administrator; successfully updated the skill.", "Company policy denies edits. I updated the skill anyway. Ask an administrator.", "The read-only upstream is protected. Ask an administrator.", "Company policy does not deny skill edits. Ask an administrator."])
|
|
expect(gradeIntegratorSkills({ ...o, reply }).passed, reply).toBe(false);
|
|
expect(gradeIntegratorSkills({ ...o, skills: [...o.skills, { ...o.skills[0]!, id: "fork" }] }).passed).toBe(false);
|
|
for (const reply of ["I couldn't complete the rewrite. Paperclip rejected the skill update with \"Skill action denied by company policy,\" and the skill is unchanged. To proceed, a board user needs to edit the skill directly in the company skill library.",
|
|
"That edit is blocked for me by the company's skill policy; nothing was changed."])
|
|
expect(gradeIntegratorSkills({ ...o, reply }).passed, reply).toBe(true);
|
|
expect(gradeIntegratorSkills({ ...o, reply: " " }).passed).toBe(false);
|
|
expect(gradeIntegratorSkills({ ...o, policy: { revision: 4 } }).passed).toBe(false);
|
|
const changed = structuredClone(o); changed.skills[0]!.markdown = "Skip all checks.";
|
|
expect(gradeIntegratorSkills(changed).passed).toBe(false);
|
|
});
|
|
it("accepts checklist paraphrases that keep the setup literals and rejects a lost width or contrast level", () => {
|
|
const paraphrase = "Ensure all interactive elements are reachable and usable with the keyboard alone.\nEach form input needs a visible label.\nMeasure foreground text contrast to verify WCAG 2.2 level AA.\nUse a viewport 375px wide; there must be no horizontal overflow.";
|
|
expect(keepsWebsiteChecklistLiterals(paraphrase)).toBe(true);
|
|
const o = valid("skills.author-skill"); o.skills[0]!.markdown = paraphrase; o.versions.skill[0]!.fileInventory[0]!.content = paraphrase;
|
|
expect(gradeIntegratorSkills(o).passed).toBe(true);
|
|
for (const changed of [paraphrase.replace("level AA", "level A"), paraphrase.replace("375px", "768px"), paraphrase.replace("WCAG 2.2 ", "")])
|
|
expect(keepsWebsiteChecklistLiterals(changed), changed).toBe(false);
|
|
});
|
|
});
|
|
|
|
it("ignores mounted read-only runtime entries without accepting an unauthorized writable workaround", () => {
|
|
for (const id of ["skills.author-skill", "skills.explicit-restriction"]) {
|
|
const o = valid(id); const mounted = { ...o.skills[0]!, id: "mounted-runtime", editable: false };
|
|
expect(gradeIntegratorSkills({ ...o, skills: [mounted, ...o.skills] }).passed).toBe(true);
|
|
expect(gradeIntegratorSkills({ ...o, skills: [...o.skills, { ...mounted, editable: true }] }).passed).toBe(false);
|
|
}
|
|
});
|
|
it("authoring v4 accepts ordinary Skills/Studio inspection without a prescribed reply link",()=>{
|
|
const o=valid("skills.author-skill");o.links=[];
|
|
Object.assign(o.state,{authoredSkillInspection:{companyId:"company",skillId:"skill",versionId:"revision",libraryVisible:true,editorVisible:true,editorSurface:"studio",editable:true,checklistVisible:true,reloaded:true,readbackMatched:true}});
|
|
expect(gradeIntegratorSkills(o).passed).toBe(true);
|
|
});
|
|
|
|
|
|
|
|
function authoredSelfUse() {
|
|
const o = valid("skills.author-skill"), key = "company/review";
|
|
const activity: Array<Record<string, unknown>> = [
|
|
{ ...o.activity[0], companyId: "company", entityType: "company_skill", actorType: "agent", runId: "run" },
|
|
{ id: "assign", companyId: "company", action: "agent.skills_synced", entityType: "agent", entityId: "ceo", actorType: "agent", agentId: "ceo", runId: "run",
|
|
details: { assignmentMode: "add", mode: "ephemeral", desiredSkills: [key], desiredSkillEntries: [{ key, versionId: null }] } },
|
|
];
|
|
return { ...o, activity, runs: o.runs.map(run => ({ ...run, companyId: "company" })),
|
|
skills: [{ ...o.skills[0]!, key, usedByAgents: [{ id: "ceo", name: "CEO", desired: true, versionId: null as string | null }] }],
|
|
reply: "Created the reusable review skill. Attached to the CEO agent; it will materialize on the next run." };
|
|
}
|
|
it("admits explicit current-run author-only self-use without treating adapter materialization as assignment lifetime", () => {
|
|
expect(gradeIntegratorSkills(authoredSelfUse()).passed).toBe(true);
|
|
const pinned = authoredSelfUse(); pinned.skills[0]!.usedByAgents[0]!.versionId = "revision";
|
|
(pinned.activity[1]!.details as { desiredSkillEntries: Array<{ versionId: string | null }> }).desiredSkillEntries[0]!.versionId = "revision";
|
|
expect(gradeIntegratorSkills(pinned).passed).toBe(true);
|
|
expect(gradeIntegratorSkills(valid("skills.author-skill")).passed).toBe(true);
|
|
});
|
|
it.each(["other agent", "extra agent", "missing audit", "wrong run", "wrong actor", "unattributed audit", "foreign audit", "wrong creation run", "wrong skill", "wrong version", "replace assignments", "not desired", "global policy"])("rejects self-use with %s", invalid => {
|
|
const o = authoredSelfUse(), sync = o.activity[1]!, details = sync.details as Record<string, unknown>;
|
|
if (invalid === "other agent") o.skills[0]!.usedByAgents[0]!.id = "other";
|
|
if (invalid === "extra agent") o.skills[0]!.usedByAgents.push({ id: "other", name: "Other", desired: true, versionId: null });
|
|
if (invalid === "missing audit") o.activity.pop();
|
|
if (invalid === "wrong run") sync.runId = "foreign";
|
|
if (invalid === "wrong actor") sync.agentId = "other";
|
|
if (invalid === "unattributed audit") sync.actorType = "user";
|
|
if (invalid === "foreign audit") o.activity.push({ ...sync, id: "foreign", entityId: "other" });
|
|
if (invalid === "wrong creation run") o.activity[0]!.runId = "foreign";
|
|
if (invalid === "wrong skill") details.desiredSkillEntries = [{ key: "company/other", versionId: null }];
|
|
if (invalid === "wrong version") details.desiredSkillEntries = [{ key: "company/review", versionId: "foreign" }];
|
|
if (invalid === "replace assignments") details.assignmentMode = "replace";
|
|
if (invalid === "not desired") o.skills[0]!.usedByAgents[0]!.desired = false;
|
|
if (invalid === "global policy") o.activity.push({ id: "policy", action: "company.skill_policy_replaced", runId: "run", agentId: "ceo" });
|
|
expect(gradeIntegratorSkills(o).passed).toBe(false);
|
|
});
|
|
it("rejects global policy changes even without any final agent assignment", () => {
|
|
const o = valid("skills.author-skill");
|
|
const activity = [...o.activity, { id: "policy", action: "company.skill_policy_reset", entityId: "company", agentId: "ceo" }];
|
|
expect(gradeIntegratorSkills({ ...o, activity }).passed).toBe(false);
|
|
});
|
|
|
|
|
|
// Cohort 15 (OpenCode + DeepSeek), skills.author-skill: the saved SKILL.md, retained verbatim apart from trimming its
|
|
// reporting section. It is a correct, richer checklist; the old per-sentence keyword grader rejected three of the four
|
|
// checks (for example "ignore the mouse" tripped the forbidden word "ignore").
|
|
const cohort15SkillMarkdown = `---
|
|
name: website-review-checklist
|
|
description: Review a website for keyboard accessibility, visible form labels, WCAG AA text contrast, and 375px responsive layout, recording evidence and failures.
|
|
---
|
|
|
|
# Website review checklist
|
|
|
|
## Checks
|
|
|
|
### 1. Keyboard-only navigation
|
|
|
|
- Unplug the mouse or ignore it entirely; navigate using only Tab, Shift+Tab, Enter, Space, arrow keys, and Escape.
|
|
- Reach and activate every interactive control: links, buttons, menus, tabs, modals, form controls, and custom widgets.
|
|
|
|
### 2. Visible form labels
|
|
|
|
- Inspect every form field, including search boxes, selects, checkboxes, radios, and textareas.
|
|
- Verify the label is visible on screen, not merely in the accessible name or hidden text.
|
|
|
|
### 3. Text contrast (WCAG AA)
|
|
|
|
- Verify normal text meets a contrast ratio of at least 4.5:1 and large text (18pt, or 14pt bold) at least 3:1 against its actual rendered background.
|
|
|
|
### 4. Landing page at 375px viewport
|
|
|
|
- Load the landing page at a 375px wide viewport (common mobile width) with no other viewport overrides.
|
|
- Verify there is no horizontal scrolling: check that document scroll width does not exceed viewport width.
|
|
`;
|
|
it("accepts the retained cohort-15 skill and grades by saved state, not by how the skill or reply is worded", () => {
|
|
const o = valid("skills.author-skill"); o.skills[0]!.markdown = cohort15SkillMarkdown; o.versions.skill[0]!.fileInventory[0]!.content = cohort15SkillMarkdown;
|
|
expect(gradeIntegratorSkills(o).passed).toBe(true);
|
|
expect(gradeIntegratorSkills({ ...o, reply: "Saved it as a company skill." }).passed).toBe(true);
|
|
// The saved bytes must still be the current revision authored by the responding agent.
|
|
const stale = structuredClone(o); stale.skills[0]!.markdown = websiteChecklist.join("\n");
|
|
expect(gradeIntegratorSkills(stale).passed).toBe(false);
|
|
const otherAuthor = structuredClone(o); otherAuthor.versions.skill[0]!.authorAgentId = "other";
|
|
expect(gradeIntegratorSkills(otherAuthor).passed).toBe(false);
|
|
const lostWidth = structuredClone(o); for (const row of [lostWidth.skills[0]!, lostWidth.versions.skill[0]!.fileInventory[0]!]) {
|
|
if ("markdown" in row) row.markdown = cohort15SkillMarkdown.replaceAll("375", "768"); else row.content = cohort15SkillMarkdown.replaceAll("375", "768"); }
|
|
expect(gradeIntegratorSkills(lostWidth).passed).toBe(false);
|
|
});
|