mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-27 03:07:57 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The daily QA staging smoke runs the `question-answer-resume` product
journey against a real agent
> - The board answers the agent's reference question with the text `Use
<marker>.`
> - The grader required the literal text `Use <marker>.` in the saved
note
> - Agents read `Use X.` as an instruction. Some save `Use X.`, others
save only `X`. Both notes are correct
> - This pull request grades the saved note by the complete marker
token, not by the answer's instruction wording
> - The benefit is that the smoke case no longer fails at random on a
correct note
## Linked Issues or Issue Description
**Describe the bug**
The QA staging smoke case `question-answer-resume` failed with
`journey_operation_failed`. The failed checks were
`question-resume.complete-evidence` and `question-document-reloaded`.
**Steps to reproduce**
1. Run the QA staging smoke journeys (full run on 2026-11-25).
2. The agent asks for a reference. The board answers `Use
AMBERjourney179560441987913f9fa70.`
3. The agent saves `Welcome to the club meetup this afternoon — we're
glad you're here; reference: AMBERjourney179560441987913f9fa70.`
4. The grader fails the note because it does not contain the word `Use`.
**Expected behavior**
A note that contains the complete submitted reference and the selected
time passes. A second campaign on the same day passed only because that
agent kept `Use` in the note.
**Additional context**
The private record also showed 4 `Invalid JSON body` responses. They
come from one failed `POST /api/issues/{id}/interactions` call that the
agent made itself, before it retried with a valid body and got 201. That
call is not the cause of the failure. The journey and the server route
are correct.
## What Changed
- Add `includesSubmittedReference` in
`tests/runner-e2e/question-resume-scoring.ts`. It matches the complete
marker token with no extra letters or digits on either side.
- Use it in `question-resume.complete-evidence` and in
`question-document-reloaded`.
- `waitForClarificationDocument` waits for the complete marker
(`submittedReferencePattern`), not for `Use <marker>.`. Before, a
correct note without `Use` timed out in the browser readback.
- Change the old unit test that rejected a note with only the marker. It
now accepts that note. New cases reject a shortened marker, an extended
marker, and a prefixed marker.
## Verification
- Red: the new cases failed on the old grader (3 failed, 144 passed).
The new readback case timed out on the old wait (1 failed, 3 passed).
- Green: `pnpm exec vitest run --config
tests/runner-e2e/vitest.config.ts` on the question-resume,
clarification, and question-documentation tests: 6 files, 170 tests
pass.
- `pnpm test:e2e:runner:typecheck` passes.
- After merge: a single-case `qa-staging-smoke.yml` run for
`question-answer-resume` on the new harness pin.
## Risks
Low risk. Test code only. The grader still requires the full marker. The
marker is a unique nonce, so a truncated or changed reference still
fails.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, 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>
63 lines
3.2 KiB
TypeScript
63 lines
3.2 KiB
TypeScript
import { afterEach, expect, it, vi } from "vitest";
|
|
import type { Locator } from "@playwright/test";
|
|
|
|
const clock = vi.hoisted(() => ({ now: 0, locator: {} }));
|
|
const marker = "AMBERreadback", answer = `Use ${marker}.`;
|
|
let body = `Welcome to the afternoon meetup. ${answer}`, partial = answer;
|
|
|
|
function stateAt(now: number) {
|
|
return { count: now >= 100 ? 1 : 0, visible: now >= 100,
|
|
text: now >= 1_300 ? body : now >= 600 ? partial : "Loading" };
|
|
}
|
|
|
|
vi.mock("@playwright/test", async importOriginal => {
|
|
const actual = await importOriginal<typeof import("@playwright/test")>();
|
|
const wait = (accept: (state: ReturnType<typeof stateAt>) => boolean, options: { timeout: number }) => {
|
|
if (!Number.isFinite(options.timeout) || options.timeout <= 0) throw Error("Invalid wait budget");
|
|
if (accept(stateAt(clock.now))) return;
|
|
const deadline = clock.now + options.timeout;
|
|
const readyAt = [100, 600, 1_300].find(time => time > clock.now && time <= deadline && accept(stateAt(time)));
|
|
clock.now = readyAt ?? deadline;
|
|
if (readyAt === undefined) throw Error("Document not ready within wait budget");
|
|
};
|
|
return { ...actual, expect: (locator: Locator) => {
|
|
if (locator !== clock.locator) throw Error("Unexpected document locator");
|
|
return {
|
|
async toHaveCount(count: number, options: { timeout: number }) { wait(state => state.count === count, options); },
|
|
async toBeVisible(options: { timeout: number }) { wait(state => state.visible, options); },
|
|
async toContainText(text: string | RegExp, options: { timeout: number }) {
|
|
wait(state => typeof text === "string" ? state.text.includes(text) : text.test(state.text), options);
|
|
},
|
|
};
|
|
} };
|
|
});
|
|
|
|
import { waitForClarificationDocument } from "./clarification-flow.js";
|
|
|
|
afterEach(() => vi.restoreAllMocks());
|
|
|
|
it("shares one document deadline and retains rejection evidence through a later scheduler stall", async () => {
|
|
clock.now = 0;
|
|
vi.spyOn(Date, "now").mockImplementation(() => clock.now);
|
|
const observed = await waitForClarificationDocument(clock.locator as Locator, marker, 1_000).then(
|
|
() => ({ outcome: "resolved", at: clock.now, text: stateAt(clock.now).text }),
|
|
(error: Error) => ({ outcome: "rejected", error: error.message, at: clock.now, text: stateAt(clock.now).text }),
|
|
);
|
|
clock.now += 10_000;
|
|
expect(stateAt(clock.now).text).toBe(body);
|
|
expect(observed).toEqual({ outcome: "rejected", error: "Document not ready within wait budget", at: 1_000, text: answer });
|
|
});
|
|
|
|
it.each([
|
|
["Welcome to the club meetup this afternoon; reference: AMBERreadback.", "resolved"],
|
|
["Welcome to the afternoon meetup. Use AMBERreadback.", "resolved"],
|
|
["Welcome to the afternoon meetup. Use AMBERreadbac.", "rejected"],
|
|
])("waits for the complete submitted reference, not the answer's instruction wording: %s", async (saved, outcome) => {
|
|
clock.now = 0;
|
|
vi.spyOn(Date, "now").mockImplementation(() => clock.now);
|
|
body = saved; partial = "Saving";
|
|
const observed = await waitForClarificationDocument(clock.locator as Locator, marker, 5_000).then(() => "resolved", () => "rejected");
|
|
body = `Welcome to the afternoon meetup. ${answer}`; partial = answer;
|
|
expect(observed).toBe(outcome);
|
|
});
|