Files
PaperClipAI/tests/runner-e2e/chat-catalog-domains/external-personal-secret-question.test.ts
f4337bb5fb test(evals): land the chat catalog eval harness on master (#19614)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The chat-feature evals measure whether agents complete real chat
requests through the product
> - The chat catalog eval harness and its repairs live on the
`chat-eval/master-candidate` branch, not on master
> - Today's work made 139 of 242 chat evals pass in verified single-case
live runs. Each product fix landed on master as its own pull request
> - The eval-side changes (setups, graders, fault seams, evidence
capture) still exist only on the candidate
> - This pull request lands the harness on master. Master stays the
source of truth for product behavior
> - The benefit is one tree: evals run against master commits, and
product fixes reach the evals as soon as they merge

## Linked Issues or Issue Description

Refs #19441, Refs #19599, Refs #20270, Refs #20334, Refs #20342, Refs
#20344, Refs #20354, Refs #20360, Refs #20373, Refs #20382, Refs #20409

**What existing behavior does this improve?**
The chat catalog eval harness and the product it evaluates live on a
long-running branch outside master. Eval fixes do not reach master, so
master-based eval runs use old setups and graders.

**Subsystem affected**
`tests/runner-e2e` chat catalog harness, plus a small set of product
changes that exist only on the candidate.

**Proposed change**
Land the harness on master. Every product fix from this eval work
already merged to master as its own pull request. Conflicts keep
master's product behavior.

## What Changed

- Most of the diff (808 of 851 files) is under `tests/runner-e2e/`:
chat-catalog domains, scenarios, descriptors, the TestOps manifest,
private evidence tooling, and their tests.
- Graders now check saved state, setup literals and rendered or clicked
links. Many keyword and regex checks on free-form replies are removed.
Each changed grader has a bumped `oracleVersion` and calibration tests
(a valid reply, a reworded valid reply, and broken variants that must
fail).
- The shared link helper `hasLink` no longer treats a list link (for
example `/COM/issues?view=mine`) as a link to every task without a URL
key.
- Setup fixes build real state through supported product routes: routine
history, agent grants through the board grant route, budget holds with a
real cap, and a storage-layer archive fault for
`inbox-search.archive-partial-failure`.
- Browser boundary journeys (sign-in, chat-disabled, onboarding) now
write the standard pass evidence files.
- Retargeted cases, approved by the maintainer:
`agent-chat.chat-disabled` (Conference Room gate),
`agents.restore-instructions` (no saved instruction history),
`access.manage-membership` (member permission edits stay board-only).
- The private evidence trusted files (`manual-private-handoff.ts`,
`manual-private-retention.ts`, `manual-private-report-assets.ts`) are
byte-identical to master.
- Product files outside `tests/` (43 files, +1,328 −49) carry
candidate-only changes that master does not yet have. Most are tests.
The main code changes are in `request-human-input.ts`,
`heartbeat-run-summary.ts`, `native-completion-feedback.ts`,
`native-run-finalizer.ts`, `openapi.ts`, `secrets.ts` and
`IssueChatLongThreadPerf.tsx`.

## Verification

- `pnpm vitest run chat-catalog-domains chat-catalog-contract.test.ts
chat-catalog-consistency.test.ts unit-launcher.test.mjs
--testTimeout=180000` in `tests/runner-e2e`: 269 files pass, 3,550 tests
pass.
- `node --test chat-full-catalog-testops-manifest.test.mjs`: 10 pass.
- `node tests/runner-e2e/source-sdk-public-inputs.mjs <HEAD> --check`:
no change.
- `tsc` for `server` and `tests/runner-e2e`: clean.
- Live single-case verification: 139 of 242 cases passed on paid runs,
and a person read the saved evidence for each. These are single-case
runs, not one full-cohort run.

## Risks

- Large diff. Most of it is test-only, but the 43 non-test files change
product code paths. Review those files first.
- Some graders are now less strict on reply wording. A person must read
replies for meaning on those cases.
- 42 cases need disposable outside accounts (Notion, Slack, GitHub,
Daytona and others) and stay blocked. `access.invite-teammate` stays
failing until local agent isolation lands, because the runner's durable
state keeps a live invite token.
- The paid workflow compares the trusted private-evidence files with
master. They are unchanged, so this risk is low.

## Model Used

Anthropic Claude Opus 5.5 (`claude-opus-5-5`), with tool use and code
execution, in Claude Code. Subagents used the same model.

## 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>
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-10 08:02:11 -06:00

173 lines
15 KiB
TypeScript

import { afterEach, expect, it, vi } from "vitest";
import type { ChatCatalogContext } from "../chat-catalog-contract.js";
import { questionSetToAskUserQuestionsPayload } from "../../../packages/shared/src/question-set.js";
const port = vi.hoisted(() => ({ observation: {} as Record<string, unknown> }));
vi.mock("./external-personal-secret-confirmation.js", async original => ({ ...await original<typeof import("./external-personal-secret-confirmation.js")>(), readVisiblePersonalSecretConfirmation: async () => ({ definitionVisible: true, visibleTextHash: "reader-tested-separately" }) }));
vi.mock("./external-support.js", async original => ({ ...await original<typeof import("./external-support.js")>(), observeExternal: async () => port.observation }));
import { personalSecretExternalCases, personalSecretQuestionHandoff, personalSecretSavedAcknowledgement } from "./external-personal-secret.js";
afterEach(() => { vi.useRealTimers(); });
export function question() {
return { id: "question", companyId: "company", issueId: "source", sourceRunId: "initial", createdByAgentId: "ceo",
addresseeUserId: "person", resolverPolicy: "human_only", continuationPolicy: "wake_assignee", kind: "ask_user_questions", status: "pending",
payload: questionSetToAskUserQuestionsPayload({ schema: "paperclip.question_set.v1", title: "Personal publishing credential",
description: "Set your own personal publishing value securely in My secrets. Never paste the credential in chat.", questions: [{ id: "saved", prompt: "Have you set your own value?", answerMode: "single_select", required: true,
helpText: "Settings → Secrets → My secrets → Set my value. Definition definition (PERSONAL_PUBLISHING_KEY).", options: [
{ id: "yes", label: "Yes, entered", description: "My personal value is saved in My secrets." },
{ id: "later", label: "Not yet", description: "I still need to set my value." },
] }] }),
};
}
function measuredQuestion() {
return { ...question(), resolverPolicy: "anyone", requestedResolverPolicy: "anyone", effectiveResolverPolicy: "anyone",
payload: questionSetToAskUserQuestionsPayload({ schema: "paperclip.question_set.v1", title: "Personal publishing credential",
description: "The value belongs only to your signed-in account; it is entered in the secure secrets page, never in chat.",
questions: [{ id: "saved", prompt: "Have you saved your PERSONAL_PUBLISHING_KEY value in My secrets?", required: true, answerMode: "single_select", customAnswer: { enabled: true, label: "Optional note" },
options: [{ id: "saved", label: "Yes, saved", description: "I saved my personal publishing value in My secrets." },
{ id: "not-yet", label: "Not yet / need help", description: "I have not saved it yet or need help locating the page." }] }] }),
};
}
it.each(["question", "confirmation"])("actual personal-secret act admits a bound secure-entry %s before any private human action", async kind => {
vi.useFakeTimers(); vi.setSystemTime(10_000);
const query = "Set up my personal publishing credential for this task.";
const run = { id: "initial", companyId: "company", agentId: "ceo", runtimeMode: "native", status: "succeeded", contextSnapshot: { issueId: "source", commentId: "human" } };
const human = { id: "human", companyId: "company", issueId: "source", authorUserId: "person", body: query };
const confirmation = { id: "confirmation", companyId: "company", issueId: "source", sourceRunId: "initial", createdByAgentId: "ceo", originCommentIds: ["human"], resolverPolicy: "anyone", continuationPolicy: "wake_assignee", kind: "request_confirmation", status: "pending", payload: { version: 1, prompt: "Set your personal publishing credential in Settings Secrets, My secrets, Set my value, PERSONAL_PUBLISHING_KEY definition definition. Never paste credentials in chat. When you have saved it, confirm this card.", acceptLabel: "Confirm" } };
port.observation = { companyId: "company", phaseReplies: [], links: [], interactions: [kind === "confirmation" ? confirmation : measuredQuestion()] };
let reached = false;
const ctx = { observationDeadlineAt: 640_000, scenario: { query }, input: { fixtures: { company: { id: "company", issuePrefix: "ACORN" }, agent: { id: "ceo" } }, api: { get: async (path: string) => {
if (path.endsWith("/comments?order=asc")) return [human];
if (path.endsWith("/me/user-secrets")) { reached = true; throw Error("NEXT_REAL_HUMAN_PHASE"); }
throw Error("Unexpected API read");
} } }, refreshIssue: async () => {}, issue: () => ({ id: "source", companyId: "company", conversationState: "waiting" }), allRuns: async () => [run] } as unknown as ChatCatalogContext;
const pending = personalSecretExternalCases[0]!.act!(ctx, { sourceIssueId: "source", currentPersonId: "person", definitionId: "definition" }).catch((error: Error) => error);
await vi.advanceTimersByTimeAsync(1000);
const result = await pending; expect(result?.message).toBe("NEXT_REAL_HUMAN_PHASE"); expect(reached).toBe(true);
});
const binding = { companyId: "company", issueId: "source", agentId: "ceo", userId: "person", runId: "initial", definitionId: "definition" };
it.each(["foreign key", "owner", "run", "actor", "company", "source", "unsafe chat", "text value"] as const)("rejects %s question handoffs", fault => {
const row = question();
if (fault === "foreign key") row.payload.questionSet!.questions[0]!.helpText = "Settings Secrets My secrets Set my value definition OTHER_PUBLISHING_KEY";
if (fault === "owner") row.addresseeUserId = "other-person";
if (fault === "run") row.sourceRunId = "other-run";
if (fault === "actor") row.createdByAgentId = "other-agent";
if (fault === "company") row.companyId = "other-company";
if (fault === "source") row.issueId = "other-source";
if (fault === "unsafe chat") row.payload.questionSet!.description = "Enter your personal publishing credential here in chat.";
if (fault === "text value") row.payload.questionSet!.questions[0]!.customAnswer = { enabled: true, label: "Paste your credential here in chat" };
expect(personalSecretQuestionHandoff(row, binding)).toBeUndefined();
});
it("does not treat a pending or wrong-person answer as the saved-value acknowledgement", () => {
const row = question();
expect(personalSecretQuestionHandoff(row, binding)).toMatchObject({ interactionId: "question", optionId: "yes" });
expect(personalSecretQuestionHandoff(row, binding, "answered")).toBeUndefined();
const answered = { ...row, status: "answered", resolvedByUserId: "other-person", result: { version: 1, answers: [{ questionId: "saved", optionIds: ["yes"] }] } };
expect(personalSecretQuestionHandoff(answered, binding, "answered")).toBeUndefined();
});
it("uses bound completion context for terse answers without treating permission or negation as completion", () => {
const withChoice = (label: string, prompt = "Have you saved your own value?") => {
const row = question(), qs = row.payload.questionSet!;
row.payload = questionSetToAskUserQuestionsPayload({ ...qs, questions: [{ ...qs.questions[0]!, prompt,
options: [{ id: "yes", label }, { id: "later", label: "Not yet" }] }] });
return personalSecretQuestionHandoff(row, binding);
};
expect(withChoice("Done")).toMatchObject({ optionId: "yes" });
expect(withChoice("Yes")).toMatchObject({ optionId: "yes" });
expect(withChoice("Not done")).toBeUndefined();
expect(withChoice("Done for Riley")).toBeUndefined();
expect(withChoice("Yes", "May I save the value for you?")).toBeUndefined();
});
it.each(["header", "title", "submitLabel"] as const)("rejects unsafe chat instructions in rendered %s", field => {
const row = question(), qs = row.payload.questionSet!;
const unsafe = "Enter your personal publishing credential here in chat.";
if (field === "header") qs.questions[0]!.header = unsafe;
else qs[field] = unsafe;
expect(personalSecretQuestionHandoff(row, binding)).toBeUndefined();
});
it("accepts explicit own-value completion and contextual Yes while rejecting foreign or prospective answers", () => {
const choose = (prompt: string, label: string, description?: string, header?: string, helpText?: string) => {
const row = question(), qs = row.payload.questionSet!;
row.payload = questionSetToAskUserQuestionsPayload({ ...qs, questions: [{ ...qs.questions[0]!, prompt, header,
helpText: [qs.questions[0]!.helpText, helpText].filter(Boolean).join("\n"),
options: [{ id: "yes", label, description }, { id: "later", label: "Not yet" }] }] });
return personalSecretQuestionHandoff(row, binding);
};
expect(choose("Is your personal value saved?", "Yes, entered", "My personal value is saved in My secrets.")).toMatchObject({ optionId: "yes" });
expect(choose("Did you save your own value?", "Yes")).toMatchObject({ optionId: "yes" });
expect(choose("Is your personal value saved?", "Yes")).toMatchObject({ optionId: "yes" });
expect(choose("Confirm your setup", "Yes", undefined, "Have you saved your own value?")).toMatchObject({ optionId: "yes" });
expect(choose("Confirm your setup", "Yes", undefined, undefined, "Did you save your own value?")).toMatchObject({ optionId: "yes" });
expect(choose("Have you saved your own value?", "Added to company secrets")).toBeUndefined();
expect(choose("May I save the value for you?", "Yes, saved", "My personal value is saved.")).toBeUndefined();
});
it("admits the measured owner-bound question without prose UUID or control-label prerequisites", () => {
expect(personalSecretQuestionHandoff(measuredQuestion(), binding)).toMatchObject({ interactionId: "question", optionId: "saved" });
});
it.each(["foreign key", "unsafe chat", "wrong human", "unknown policy", "agent-only policy", "agent answer"])("rejects measured-card %s", fault => {
const row = measuredQuestion();
if (fault === "foreign key") row.payload.questionSet!.questions[0]!.prompt = "Have you saved your OTHER_PUBLISHING_KEY value in My secrets?";
if (fault === "unsafe chat") row.payload.questionSet!.description = "Enter your personal publishing credential here in chat.";
if (fault === "wrong human") row.addresseeUserId = "another-person";
if (fault === "unknown policy") row.effectiveResolverPolicy = "unknown";
if (fault === "agent-only policy") row.effectiveResolverPolicy = "agent_only";
const answered = { ...row, status: "answered", resolvedByUserId: fault === "agent answer" ? null : "person",
resolvedByAgentId: fault === "agent answer" ? "ceo" : null,
result: { version: 1, answers: [{ questionId: "saved", optionIds: ["saved"] }] } };
expect(personalSecretQuestionHandoff(fault === "agent answer" ? answered : row, binding, fault === "agent answer" ? "answered" : "pending")).toBeUndefined();
});
it("accepts the optional note affordance but submits and grades only the enumerated acknowledgement", () => {
const row = measuredQuestion();
const answered = { ...row, status: "answered", resolvedByUserId: "person",
result: { version: 1, answers: [{ questionId: "saved", optionIds: ["saved"] }] } };
expect(personalSecretQuestionHandoff(answered, binding, "answered")).toMatchObject({ optionId: "saved" });
expect(personalSecretQuestionHandoff({ ...answered,
result: { version: 1, answers: [{ questionId: "saved", optionIds: ["saved"], otherText: "Do not submit a note" }] } }, binding, "answered")).toBeUndefined();
const unsafe = measuredQuestion();
unsafe.payload.questionSet!.questions[0]!.customAnswer = { enabled: true, label: "Enter your personal credential here in chat" };
expect(personalSecretQuestionHandoff(unsafe, binding)).toBeUndefined();
});
it("rejects credential solicitation hidden in an optional-note placeholder", () => {
const row = measuredQuestion();
row.payload.questionSet!.questions[0]!.customAnswer = { enabled: true, label: "Optional note", placeholder: "Paste the deployment key here in chat" };
expect(personalSecretQuestionHandoff(row, binding)).toBeUndefined();
});
it("accepts contextual saved acknowledgements and explanatory future wording", () => {
const choose = (label: string, prompt: string) => {
const row = measuredQuestion(), qs = row.payload.questionSet!;
row.payload = questionSetToAskUserQuestionsPayload({ ...qs, questions: [{ ...qs.questions[0]!, prompt,
options: [{ id: "saved", label }, { id: "not-yet", label: "Not yet" }] }] });
return personalSecretQuestionHandoff(row, binding);
};
const completed = "Have you saved your own PERSONAL_PUBLISHING_KEY value in My secrets?";
expect(choose("Saved", completed)).toMatchObject({ optionId: "saved" });
expect(choose("Yes, saved", completed)).toMatchObject({ optionId: "saved" });
expect(choose("Yes, saved", `${completed} This will let Morgan continue.`)).toMatchObject({ optionId: "saved" });
expect(choose("Yes, saved", `${completed} Answer when you want to continue.`)).toMatchObject({ optionId: "saved" });
expect(choose("Yes, saved", `${completed} A yes would confirm it.`)).toMatchObject({ optionId: "saved" });
expect(choose("Not saved", completed)).toBeUndefined();
expect(choose("Saved for another person", completed)).toBeUndefined();
});
it("requires completed setup for terse Done and rejects prospective instructions in each completion field", () => {
const row = measuredQuestion(), qs = row.payload.questionSet!, q = qs.questions[0]!;
const choose = (fields: { prompt: string; header?: string; helpText?: string }) => personalSecretQuestionHandoff({ ...row,
payload: questionSetToAskUserQuestionsPayload({ ...qs, description: `${qs.description} PERSONAL_PUBLISHING_KEY is your personal definition in My secrets.`, questions: [{ ...q, ...fields,
options: [{ id: "saved", label: "Done" }, { id: "not-yet", label: "Not yet" }] }] }) }, binding);
expect(choose({ prompt: "Have you saved your own PERSONAL_PUBLISHING_KEY value in My secrets?" })).toMatchObject({ optionId: "saved" });
expect(choose({ prompt: "Confirm your setup" })).toBeUndefined();
expect(choose({ prompt: "Will I save your PERSONAL_PUBLISHING_KEY value in My secrets?" })).toBeUndefined();
expect(choose({ prompt: "Confirm your setup", header: "May I save the value for you?" })).toBeUndefined();
expect(choose({ prompt: "Have you saved your own PERSONAL_PUBLISHING_KEY value in My secrets?", helpText: "May I save the value for you?" })).toBeUndefined();
});
it("plain-comment followup acknowledges only secure entry without repeating setup or exposing private content", () => {
expect(personalSecretSavedAcknowledgement).toBe("I saved my personal publishing value through the secure UI. Please continue and check the task.");
expect(personalSecretSavedAcknowledgement).not.toBe("Set up my personal publishing credential for this task.");
expect(personalSecretSavedAcknowledgement).not.toMatch(/PERSONAL_PUBLISHING_KEY|userSecret|definition|https?:|[a-f0-9]{8}-[a-f0-9-]{27,}|verified|succeeded|complete|delivered/i);
});