mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-06 07:38:47 +01:00
## 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>
93 lines
11 KiB
TypeScript
93 lines
11 KiB
TypeScript
import type { RoutineDetail, RoutineRunSummary } from "../../../packages/shared/src/types/routine.js";
|
|
import type { ChatCatalogContext } from "../chat-catalog-contract.js";
|
|
import { pollUntil } from "../api.js";
|
|
import { checks, hasLink, observation, project, type Entity, type InternalObservation } from "./internal-support.js";
|
|
import { fixtureWorker } from "./internal-definition.js";
|
|
import type { BudgetOverview } from "../../../packages/shared/src/types/budget.js";
|
|
import { prepareHistoryNotes, cleanupHistoryNotes, historyNotesPhase, historyNotesCalls, waitHistoryWork, readHistoryWork, genuineHistoryWork, routineHistoryAccountingReady, completeHistoryUsage, type HistoryWorkIdentity, type HistoryWorkSnapshot, type WorkCall } from "./routine-history-work-failure.js";
|
|
export { routineHistoryAccountingReady } from "./routine-history-work-failure.js";
|
|
import { integratorDefinition, inspectResult, observeInternal } from "./integrator-support.js";
|
|
interface HistoryObservation extends InternalObservation { expectedProvider: string; routine: RoutineDetail; executions: RoutineRunSummary[] }
|
|
const root = (ctx: ChatCatalogContext) => `/api/companies/${ctx.input.fixtures.company.id}`;
|
|
async function observeHistory(ctx: ChatCatalogContext, state: Record<string, unknown>): Promise<HistoryObservation> {
|
|
state.failedWork = await readHistoryWork(ctx, state.failedIdentity as HistoryWorkIdentity);
|
|
state.completedWork = await readHistoryWork(ctx, state.completedIdentity as HistoryWorkIdentity);
|
|
const base = await observeInternal(ctx, state); const routine = state.routine as RoutineDetail;
|
|
return { ...base, expectedProvider: ctx.input.execution.profile.provider, routine: await ctx.input.api.get<RoutineDetail>(`/api/routines/${routine.id}`), executions: await ctx.input.api.get<RoutineRunSummary[]>(`/api/routines/${routine.id}/runs`) };
|
|
}
|
|
function historyObservation(value: unknown): HistoryObservation | undefined {
|
|
const o = value as HistoryObservation;
|
|
return observation(value) && !!o.routine && Array.isArray(o.executions) ? o : undefined;
|
|
}
|
|
export function gradeIntegratorRoutineHistory(value: unknown) {
|
|
const c = checks(); const o = historyObservation(value);
|
|
c.add("actual-routine-and-native-execution-history", !!o, "Requires real public invocation history plus distinct actual failed work and successful execution receipts.");
|
|
if (!o) return c.result();
|
|
const failedTask = o.tasks.find(task => task.id === o.state.failedIssueId); const completedTask = o.tasks.find(task => task.id === o.state.completedIssueId);
|
|
const failedInvocation = o.executions.find(run => run.id === o.state.failedInvocationId); const completedInvocation = o.executions.find(run => run.id === o.state.completedInvocationId);
|
|
const failure = o.state.failedWork as HistoryWorkSnapshot | undefined;
|
|
const success = o.state.completedWork as HistoryWorkSnapshot | undefined;
|
|
const failedIdentity = o.state.failedIdentity as HistoryWorkIdentity;
|
|
const completedIdentity = o.state.completedIdentity as HistoryWorkIdentity;
|
|
c.add("genuine-task-bound-failed-work", !!failedTask && genuineHistoryWork(failedIdentity, failure, o.state.failedCalls as WorkCall[] ?? [], true)
|
|
&& failedIdentity.companyId === o.companyId && failedIdentity.agentId === (o.state.worker as Entity | undefined)?.id
|
|
&& failedIdentity.issueId === failedTask.id && failedIdentity.invocationId === failedInvocation?.id
|
|
&& failedTask.status === "blocked" && failedInvocation?.status === "failed" && completeHistoryUsage(failure?.run)
|
|
&& o.runs.some(run => run.id === failedIdentity.runId && run.status === "succeeded" && run.companyId === o.companyId && run.agentId === failedIdentity.agentId && run.contextSnapshot?.issueId === failedTask.id)
|
|
&& o.state.failedWritten === null, "Actual authorized synthetic MCP work returned HTTP 200/tool_error, with company/worker/task/native-run audit, a worker-blocked task, failed public invocation and complete normal usage. Narration or patched state alone is insufficient.");
|
|
c.add("genuine-recovered-work-and-accounting", genuineHistoryWork(completedIdentity, success, o.state.completedCalls as WorkCall[] ?? [], false)
|
|
&& completedIdentity.companyId === o.companyId && completedIdentity.agentId === (o.state.worker as Entity | undefined)?.id
|
|
&& completedIdentity.issueId === completedTask?.id && completedIdentity.invocationId === completedInvocation?.id
|
|
&& completeHistoryUsage(success?.run) && typeof o.state.completedWritten === "string" && !!o.state.completedWritten,
|
|
"The restored synthetic provider received a separate authorized successful write under the second task/native run, with completed public history and normal usage.");
|
|
c.add("separate-real-successful-invocation", !!completedTask && completedTask.status === "done" && completedInvocation?.status === "completed" && completedInvocation.linkedIssueId === completedTask.id
|
|
&& completedTask.id !== failedTask?.id && o.runs.some(run => run.id === o.state.completedNativeRunId && run.status === "succeeded" && run.runtimeMode === "native" && run.contextSnapshot?.issueId === completedTask.id), "A second independently invoked routine actually completed its normal task under a successful native run.");
|
|
const start = Number(o.state.weekStart), end = Number(o.state.weekEnd);
|
|
c.add("requested-week-and-exact-history-retained", [failedInvocation, completedInvocation].every(run => !!run && Date.parse(String(run.triggeredAt)) >= start && Date.parse(String(run.triggeredAt)) < end)
|
|
&& o.executions.length === 2 && failedInvocation?.source === "manual" && completedInvocation?.source === "manual", "Both actual manual invocations fall inside the measured current week, with no hidden or duplicate history rows.");
|
|
c.add("actual-failure-and-completion-linked", !!failedTask && !!completedTask && hasLink(o, "issues", failedTask) && hasLink(o, "issues", completedTask), "The answer links both real execution tasks.");
|
|
// The reply's meaning (which run failed, no inferred scheduled success) is free-form text: a person reads it. The oracle
|
|
// grades only what the product recorded and the rendered links above, never reply vocabulary.
|
|
c.add("failed-work-not-inferred-routine-completion", !!failedTask && !!completedTask && failedTask.status === "blocked" && failedInvocation?.status === "failed"
|
|
&& completedTask.status === "done" && completedInvocation?.status === "completed",
|
|
"The product records the setup's outcomes: the failed invocation's task is blocked and the completed invocation's task is done.");
|
|
return c.result();
|
|
}
|
|
export const integratorRoutineHistoryCases = [integratorDefinition("routines", "routines.read-history", async ctx => {
|
|
const p = await project(ctx, "Launch", { description: "Synthetic Launch project: payment approval remains pending; no other active work." }); const worker = await fixtureWorker(ctx);
|
|
for (const scope of [{ scopeType: "company", scopeId: ctx.input.fixtures.company.id }, { scopeType: "agent", scopeId: worker.id }]) await ctx.input.api.post(`${root(ctx)}/budgets/policies`, { ...scope, amount: 500, hardStopEnabled: true, isActive: true, unpricedUsagePolicy: "allow" });
|
|
const connection = await prepareHistoryNotes(ctx, worker.id);
|
|
const routine = await ctx.input.api.post<RoutineDetail>(`${root(ctx)}/routines`, { title: "Morning Launch summary", projectId: p.id, assigneeAgentId: worker.id, concurrencyPolicy: "always_enqueue",
|
|
description: "Summarize the actual Launch project in a short saved task comment, link the project, and publish that summary once using the connected Synthetic Launch Notes launch_update action. This is a controlled synthetic dependency, not an official vendor service. If the actual publish returns an error, report the actual failure in this task's comment and block the task truthfully; do not mark failed work done. If the publish succeeds, save the result and mark this summary task done. Do not retry, repair the provider, edit project work or create follow-up tasks." });
|
|
const invoke = async (kind: string) => {
|
|
const invocation = await ctx.input.api.post<RoutineRunSummary>(`/api/routines/${routine.id}/run`, { source: "manual", idempotencyKey: `${kind}-history-${ctx.input.nonce}` });
|
|
if (!invocation.linkedIssueId) throw new Error("Routine prerequisite did not admit an actual execution task");
|
|
return { companyId: ctx.input.fixtures.company.id, agentId: worker.id, issueId: invocation.linkedIssueId, routineId: routine.id, invocationId: invocation.id, ...connection };
|
|
};
|
|
const failedBase = await invoke("failed");
|
|
const failure = await waitHistoryWork(ctx, failedBase, true, -1, 150_000);
|
|
const failedIdentity = { ...failedBase, runId: failure.snapshot.run!.id };
|
|
const accounting = await pollUntil({ label: "genuine failed work normal provider accounting before separate success invocation", deadlineAt: Date.now() + 60_000, intervalMs: 1000,
|
|
load: async () => ({ snapshot: await readHistoryWork(ctx, failedBase), overview: await ctx.input.api.get<BudgetOverview>(`${root(ctx)}/budgets/overview`) }),
|
|
accept: value => genuineHistoryWork(failedIdentity, value.snapshot, historyNotesCalls(ctx), true)
|
|
&& routineHistoryAccountingReady(failedIdentity, [value.snapshot.run!], value.overview) });
|
|
const failedCalls = historyNotesCalls(ctx); const failedPhase = historyNotesPhase(ctx);
|
|
if (failedPhase.written !== null) throw new Error("Failed synthetic work unexpectedly changed the notes page");
|
|
historyNotesPhase(ctx, true);
|
|
const completedBase = await invoke("success");
|
|
const success = await waitHistoryWork(ctx, completedBase, false, failedPhase.lastSequence, 180_000, true);
|
|
if ((await ctx.allRuns()).length !== 2) throw new Error("Routine history fixture exceeded its two declared real native invocations");
|
|
const weekStart = new Date(); weekStart.setUTCHours(0, 0, 0, 0); weekStart.setUTCDate(weekStart.getUTCDate() - (weekStart.getUTCDay() + 6) % 7);
|
|
return { project: p, worker: { id: worker.id }, routine, failedInvocationId: failedBase.invocationId, completedInvocationId: completedBase.invocationId,
|
|
failedIssueId: failedBase.issueId, completedIssueId: completedBase.issueId, failedIdentity, completedIdentity: { ...completedBase, runId: success.snapshot.run!.id },
|
|
failedWork: accounting.snapshot, completedWork: success.snapshot, failedCalls, completedCalls: success.calls,
|
|
failedWritten: failedPhase.written, completedWritten: historyNotesPhase(ctx).written, completedNativeRunId: success.snapshot.run!.id,
|
|
weekStart: weekStart.getTime(), weekEnd: weekStart.getTime() + 7 * 86400_000 };
|
|
|
|
}, observeHistory, gradeIntegratorRoutineHistory, async (ctx, state) => {
|
|
const routine = state.routine as RoutineDetail;
|
|
await inspectResult(ctx, `/${ctx.input.fixtures.company.issuePrefix}/routines/${routine.id}/history`, routine.title);
|
|
}, { sourceFiles: ["chat-catalog-domains/integrator-routine-history.ts", "chat-catalog-domains/routine-history-work-failure.ts", "chat-catalog-domains/external-provider.ts", "chat-catalog-domains/external-support.ts", "chat-catalog-domains/internal-definition.ts", "chat-catalog-domains/internal-support.ts", "chat-catalog-domains/integrator-support.ts", "chat-scenarios/routines.yaml"],
|
|
oracleVersion: "paperclip.chat-catalog.integrator.routine-work-failure.v5", authentication: "human-session", cleanup: cleanupHistoryNotes, expectedRunCount: 3, runPolicy: { kind: "terminal-counts", terminalStatusCounts: { succeeded: 3 } }, attemptTimeoutMs: 720_000,
|
|
})];
|