mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-20 15:09:57 +02:00
## Thinking Path > - Paperclip is the open source control plane for agent companies. > - People choose a harness when creating an agent. > - The server should resolve that harness to a qualified runner. > - Codex is the first harness in the staged default rollout. > - Saved agents must retain their execution choices. > - New Codex agents therefore use Paperclip Runner on qualified macOS/Linux targets, with an explicit Legacy override. ## Linked Issues or Issue Description Refs #16028, #15555, #15673, #15422, #15631, #15926, #15932, #16149. The runtime/install prerequisite and release repair are merged. This slice owns Codex creation, setup, configuration and preservation. Other harness defaults remain unchanged. It adds no database migration; incoming master migrations, required maps and regression coverage are retained. ## What Changed - Resolve `runner: auto | paperclip | legacy` at the common creation boundary across onboarding, API/CLI, hires, built-ins, plugins and imports. Freeze pending hires and export resolved execution choices. - Preserve existing runners on upgrades, unrelated edits and import updates, including compatible accounts, workspace settings, Codex effort and intentional clears. - Use the underlying harness picker and branding; put the runner override in Advanced. Use the shared dropdown and update production-component stories and creation contracts. - Support qualified Apple Silicon, Intel Mac, Linux x64 and Linux ARM64. Linux requires GNU libc 2.39+. Disabled, external, unsupported and unqualified combinations retain their applicable Legacy execution. - Test the selected runtime/account/model/environment. Ordinary Connect probes eligible immutable managed targets and refreshes scoped discovery. Creation/discovery do not provision. Auth, dependency, incompatible-setting and cleanup failures remain actionable without changing runners. - Keep setup probes read-only, preserve local/SSH isolation and resolve packaged assets before staging credentials. Bound cleanup reads by the remaining absolute deadline; physically close every owned ingress socket before endpoint release. Unconfirmed cleanup retains recovery state. - Preserve validated completed-onboarding callbacks through startup recovery. First file-producing work belongs to the child task and uses the existing dependency/block handoff and task-scoped registration. - Reuse existing E2E fixtures, artifact checks, reporting and controls. Keep Docker/Cargo/native compilation remote. Paperclip tarballs contain no Codex payloads; official optional npm platform dependencies remain. ## Verification Current tested head: `1c03a8815672d82c264a9b08d4ea1984e8fae107`. **Merge-ready: required CI, fresh review, package qualification, Mac core acceptance and Test task/follow-up acceptance pass.** The existing attachment and native-continuity oracles independently verify both Test downloads, run attribution and unchanged native/provider/workspace identities. The maintainer authorized a code-owner-review exception for this PR only. The first Test setup failure and normal Board completion-review friction are retained below. Actual post-merge packages and private Cloud distribution remain separate qualification gates. - [Current CI](https://github.com/paperclipai/paperclip/actions/runs/38564241625): all 48 ordinary jobs and required verify/E2E pass. Attempt 1 retained six simultaneous host-shutdown cancellations. One failed-only retry passes those six lanes and two aggregates, preserving 40 successes. Actual integration checkout `53104c1` combines this head with master `c80`; it is not relabeled as the branch tree. Fresh exact-head Greptile 5/5, 30 resolved threads, no actionable findings. - [Exact-source package qualification](https://github.com/paperclipai/paperclip/actions/runs/38565287239): nine applicable jobs pass, nine conditional jobs skip. Four remote native producers; Linux x64 clean install; Intel Mac, Apple Silicon and Linux ARM64 native startup/physical cleanup controls. All 18 tarballs/four daemon source/hash/manifest bindings and 343 migrations through 0344 verify. No Codex payload is packed. These hosted tarballs are not a published npm canary. - Normal Apple Silicon installation and credential-free native startup/cleanup pass using the packaged daemon, with no source build or provider turn. Fresh installed DB initialization passes. Upgrade 651a→1c03 preserves all three complete execution configs, accounts, ten recorded run profiles, paused budgets, active incidents, cost summaries and two historical unpriced events. Historical recovery state is retained. - Cleanup regressions: four delayed-read baseline failures become 15 passing deadline/authority controls. No-acknowledgement and prior-error socket ownership regressions become 12 passing controls. Direct runtime/server types, maps: 35 areas / 176 IDs, diff checks and independent reviews pass. Permission/auth/reconnect policy and the 10-second setup budget remain intact. - Existing source coverage includes creation/selection/imports, pending approvals, recovery, account/lifecycle handling, mounted forms, dropdowns and E2E support. Full typechecks/tests/build/token and applicable Storybook checks pass in the recorded current CI; no duplicate suite or weakened grader. - Literal 9546 live Mac proof: ordinary Auto Codex onboarding, useful document, real completed-child callback/reply, seven successful native runs, manual follow-up and independently downloaded1,101-byte child file. Existing Legacy title edit/reload preserves execution; two real Legacy runs produce independently checked15/34-byte files. These remain historical source records. - Current literal 1c03 Mac core acceptance passes independent checks: ordinary Auto native Codex onboarding without runner override; only timeout 180 seconds/concurrency 1 saved; six successful native runs and six serialized turns (maximum overlap 1); both same-task continuity checks and five mechanical callback checks; actual rendered parent reply and exact child downloads. The useful handoff advances from revision 1 to 2. Both files are 48 bytes, SHA-256 `8b742bd4e8123a7c078f0a8d9f3449fbfa8a320d7d90be641a2818db3c53d92c` and `f42db9774fa06e804ab7d596fc8b922a2b638921c418b87d0111151d290a6afe`; exactly one byte changes and old history remains. The agent is paused with zero active runs/errors. Both artifact work products have `isPrimary=false`, and descriptive titles fail a stricter title-helper assumption; these retained results are scoped editorial follow-up, not new merge gates. Six source-bound screenshots are uploaded and verified in the private primary QA report. - [Literal 9546 managed proof](https://d1p6rlowie26tp.cloudfront.net/runner-e2e/campaigns/gha-38485488621-1/index.html): original 19 assertions and completed judge pass, four native turns, child-bound240-byte file and session/workspace continuity. Checkout reports a verified generated target-lock mutation; full final porcelain was not retained. Signed execution-image identity remains separate from Core source. - Actual 651a Test deployment succeeds on one owned/pinned target. One ordinary Auto API-key Connect then fails native cleanup before hire. Controller turn/drain/suspend completion and service-recorded environment cleanup are observed; they do not certify physical deletion or native authority retirement. Failure/recovery/unknown holds are retained. No Legacy switch or unchanged paid retry. The two source repairs above require actual treatment. - [Current immutable Core preview](https://github.com/paperclipai/paperclip/actions/runs/38570365725) and matching DB/shared artifacts pass. One owned, pinned Test target serves exact `1c03`; identical migration history correctly skips the migrator. Ordinary Auto Codex Connect succeeds and hires native; saved native selection and QA bounds survive reload. The initial child preparation attempt fails before provider work, with actual stdout identifying `renewal_deadline`; its trigger remains unknown and the failure is retained. Normal Board **Try again** and **Resume** recover the child to Done, producing a browser-verified 44-byte file, SHA-256 `0a8458b1efcc2d7a0d815689458c4caab039a46c7c7a3e5805de6bc8b1a96ecc`. The actual parent callback reports the completed child document/file. The existing validator requires a parent-owned attachment, so recovery enters normal Review; after byte checking, normal **Approve completion** reaches parent Done. No forced status or duplicate parent file is used. The validator is unchanged from integrated and current master. Autonomous initial callback-to-Done is not proven. The same-child follow-up completes document revision 2 and publishes a second independently downloaded 44-byte file, SHA-256 `22022257300fae762784632d08d3bbe0bab61e2ce81f91864a14dcd7aa464591`; only the revision digit changes. The unchanged existing native-continuity and attachment oracles pass. All ten recorded runs are terminal: nine native successes and the retained pre-provider setup failure. The QA agent is paused with zero active runs. The pre-existing parent evidence scope mismatch is a separate follow-up, with ordinary completion review exercised rather than a forced status or relaxed validation. This unsigned Core preview remains distinct from post-merge private Cloud composition. ## Risks - Saved agents are not migrated. Explicit runner changes use normal configuration/session rules; historical runs retain their recorded execution. - Native readiness depends on verified assets and server-owned target qualification. A Legacy probe, HTTP200 or successful account save cannot prove native readiness. - Recovery exceptions remain restricted to validated completed-onboarding reports; process-loss, ownership and terminal-state safeguards remain active. Unexecuted live journeys stay open. - Linux ARM paid tasks, Windows, Alpine and 32-bit ARM remain deferred. Cold Cargo cache misses are recorded; no warm-cache speedup is claimed. - Historical invoices/physical cleanup remain unconfirmed and held. After merge, exact published npm canary, signed standard image/migrator, private composition and serving/live acceptance still require qualification. Production deployment/default promotion is not authorized. ## Model Used OpenAI Codex, GPT-6 family, with reasoning, tools, code execution and parallel agents. Exact serving snapshot and context-window size are not exposed. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used with available 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 linked public issues or PRs above - [x] I have not referenced internal/instance-local Paperclip issues or links - [x] My branch name describes the change and contains no internal ticket id - [x] I have run the stated focused tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation - [x] I have considered and documented risks - [x] All Paperclip CI gates are green on the current candidate - [x] Greptile is 5/5 with no open findings on the current candidate - [x] I will address all reviewer comments before requesting merge --------- Co-authored-by: Paperclip <noreply@paperclip.ing>
187 lines
15 KiB
TypeScript
187 lines
15 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { runsCompletionUpdateProbe, COMPLETION_QUALITY_CONFIG, completionQualityControls, completionQualityStatus, completionQualityRequest, judgeCompletionQuality, reserveCompletionQuality, validateCompletionQuality } from "./completion-quality.js";
|
|
import { runnerMatrix } from "./catalog.js";
|
|
import { MANAGED_FIRST_TASK_CELL } from "./first-task-fixtures.js";
|
|
const observation = { sourceId: "chat", marker: "REF", worker: { id: "task", title: "Welcome", status: "done", completedAt: "2026-09-01T00:00:00Z" }, documents: [{ id: "doc", issueId: "task", key: "welcome", body: "Welcome to the garden. Meet at 10:30." }], comments: [{ id: "reply", issueId: "chat", authorAgentId: "agent", createdAt: "2026-09-01T00:01:00Z", body: "The note is ready at /issues/task", createdByRunId: "run" }], runs: [] };
|
|
const criteria = Object.keys(COMPLETION_QUALITY_CONFIG.rubric).map(id => ({ id, passed: true, rationale: "Supported by the saved note and reply", evidenceIds: ["reply", "doc"] }));
|
|
const reports = [{ replyId: "reply", rationale: "Reports the completed task", completedTaskIdsReferenced: ["task"], resultAccessTaskIds: ["task"], correctsReplyIds: [] as string[] }];
|
|
describe("completion semantic qualification", () => {
|
|
it.each(["runner-codex", "runner-acpx-claude"])("requires a completion judge only for accepted work on %s", profile => {
|
|
const cells = runnerMatrix.filter(e => e.suite.id === "confirmation-replies" && e.profile.id === profile && e.environment.id === "local");
|
|
expect(cells).toHaveLength(6);
|
|
expect(cells.filter(runsCompletionUpdateProbe).map(e => e.task.id).sort()).toEqual([
|
|
"interview-plan-accept", "task-card-accept", "task-reply-accept",
|
|
]);
|
|
});
|
|
it("requires the existing completion judge for accepted managed onboarding work", () => {
|
|
const managed = runnerMatrix.find(e => e.id === MANAGED_FIRST_TASK_CELL);
|
|
expect(managed).toBeDefined();
|
|
expect(runsCompletionUpdateProbe(managed!)).toBe(true);
|
|
});
|
|
it("retains the completion suite's gate and excludes ordinary chat journeys", () => {
|
|
const completion = runnerMatrix.filter(e => e.suite.id === "completion-updates");
|
|
expect(completion).toHaveLength(10);
|
|
expect(completion.every(runsCompletionUpdateProbe)).toBe(true);
|
|
expect(runnerMatrix.filter(e => !["confirmation-replies", "completion-updates"].includes(e.suite.id)).some(runsCompletionUpdateProbe)).toBe(false);
|
|
});
|
|
it("uses a pinned no-tool judge and separates untrusted evidence from instructions", () => {
|
|
const request = completionQualityRequest(observation);
|
|
expect(request.model).toBe(COMPLETION_QUALITY_CONFIG.model); expect(request).not.toHaveProperty("tools");
|
|
expect(request.instructions).toContain("untrusted evidence"); expect(request.input).toContain("10:30");
|
|
expect(request.text.format.schema.properties.criteria.items.properties.evidenceIds.items.enum)
|
|
.toEqual(["task", "doc", "reply"]);
|
|
});
|
|
it("includes only observed, same-reply links to known task results", () => {
|
|
const o = { ...observation, worker: { ...observation.worker, identifier: "GARDEN-2" }, renderedLinks: [
|
|
{ commentId: "reply", href: "/GARDEN/issues/GARDEN-2?private-query=ignored" },
|
|
{ commentId: "reply", href: "/GARDEN/issues/GARDEN-2" },
|
|
{ commentId: "other-reply", href: "/issues/task" },
|
|
{ commentId: "reply", href: "/issues/foreign" },
|
|
{ commentId: "reply", href: "https://external.invalid/issues/task" },
|
|
{ commentId: "reply", href: "//external.invalid/issues/task" },
|
|
{ commentId: "reply", href: "/%invalid/issues/task" },
|
|
] };
|
|
const evidence = JSON.parse(completionQualityRequest(o).input);
|
|
expect(evidence.replies[0].renderedResultLinks).toEqual([{ taskId: "task", href: "/GARDEN/issues/GARDEN-2" }]);
|
|
expect(JSON.parse(completionQualityRequest(observation).input).replies[0].renderedResultLinks).toEqual([]);
|
|
});
|
|
it("preserves a failure even when the other criteria pass", () => {
|
|
expect(validateCompletionQuality({ criteria, reports }, observation).passed).toBe(true);
|
|
expect(validateCompletionQuality({ reports, criteria: criteria.map((c, i) => ({ ...c, passed: i !== 0 })) }, observation).passed).toBe(false);
|
|
});
|
|
it("separates product failures from a missing or miscalibrated judge", () => {
|
|
const product = { ...reserveCompletionQuality(observation, 1), status: "completed" as const,
|
|
name: "completion-update.json", purpose: "product" as const, expectedPass: true, passed: true };
|
|
const negativeControl = { ...product, name: "stale", purpose: "calibration" as const, expectedPass: false, passed: false };
|
|
expect(completionQualityStatus([product, negativeControl])).toBe("passed");
|
|
expect(completionQualityStatus([{ ...product, passed: false }, negativeControl])).toBe("failed");
|
|
expect(completionQualityStatus([product, { ...negativeControl, passed: true }])).toBe("unqualified");
|
|
expect(completionQualityStatus([{ ...product, status: "failed" }])).toBe("unqualified");
|
|
expect(completionQualityStatus([])).toBe("unqualified");
|
|
});
|
|
const twoReplies = { ...observation, worker: { ...observation.worker, companyId: "fixture" },
|
|
relatedTasks: [{ task: { id: "second", companyId: "fixture", status: "done", completedAt: observation.worker.completedAt },
|
|
documents: [{ id: "second-doc", issueId: "second", key: "result", body: "Second result" }] }],
|
|
comments: [...observation.comments, { ...observation.comments[0], id: "reply-again", createdAt: "2026-09-01T00:02:00Z" }],
|
|
};
|
|
it.each([
|
|
[["task"], ["task"], [], false],
|
|
[["task"], ["task", "second"], [], true],
|
|
[["task", "second"], ["task"], [], false],
|
|
[[], ["task"], [], true],
|
|
[["task"], ["task"], ["reply"], true],
|
|
[["task"], ["second"], [], true],
|
|
[["task"], [], [], true],
|
|
])("evaluates newly reported results and corrections (%j → %j)", (first, second, corrections, passed) => {
|
|
const inventory = [
|
|
{ ...reports[0], completedTaskIdsReferenced: first as string[], resultAccessTaskIds: first as string[] },
|
|
{ ...reports[0], replyId: "reply-again", completedTaskIdsReferenced: second as string[], resultAccessTaskIds: second as string[], correctsReplyIds: corrections as string[] },
|
|
];
|
|
const verdict = validateCompletionQuality({ criteria, reports: inventory }, twoReplies);
|
|
expect(verdict.passed).toBe(passed);
|
|
expect(verdict.reports).toEqual(inventory);
|
|
if (!passed) expect(verdict.criteria.at(-1)?.evidenceIds).toEqual(["reply", "reply-again"]);
|
|
});
|
|
it("accepts first result access after a status-only announcement, but rejects a third redundant reply", () => {
|
|
const inventory = [{ ...reports[0], resultAccessTaskIds: [] }, { ...reports[0], replyId: "reply-again" }];
|
|
expect(validateCompletionQuality({ criteria, reports: inventory }, twoReplies).passed).toBe(true);
|
|
const repeated = { ...twoReplies, comments: [...twoReplies.comments,
|
|
{ ...observation.comments[0], id: "third", createdAt: "2026-09-01T00:03:00Z" }] };
|
|
expect(validateCompletionQuality({ criteria, reports: [...inventory, { ...reports[0], replyId: "third" }] }, repeated).passed).toBe(false);
|
|
});
|
|
it("requires result access to reference unique, inventoried tasks", () => {
|
|
for (const access of [undefined, ["foreign"], ["second"], ["task", "task"]]) {
|
|
expect(() => validateCompletionQuality({ criteria, reports: [{ ...reports[0], resultAccessTaskIds: access }] }, observation)).toThrow(/inventory/);
|
|
}
|
|
});
|
|
it("uses recorded chronology instead of model report order", () => {
|
|
const inventory = [{ ...reports[0], replyId: "reply-again", completedTaskIdsReferenced: ["task", "second"] }, reports[0]];
|
|
expect(validateCompletionQuality({ criteria, reports: inventory }, { ...twoReplies, comments: [...twoReplies.comments].reverse() }).passed).toBe(true);
|
|
});
|
|
it("rejects omitted, duplicate, foreign, and forward-looking report references", () => {
|
|
for (const inventory of [
|
|
reports, [reports[0], reports[0]],
|
|
[reports[0], { ...reports[0], replyId: "foreign" }],
|
|
[reports[0], { ...reports[0], replyId: "reply-again", completedTaskIdsReferenced: ["foreign-task"] }],
|
|
[reports[0], { ...reports[0], replyId: "reply-again", completedTaskIdsReferenced: ["task", "task"] }],
|
|
[{ ...reports[0], correctsReplyIds: ["reply-again"] }, { ...reports[0], replyId: "reply-again" }],
|
|
[reports[0], { ...reports[0], replyId: "reply-again", correctsReplyIds: ["reply-again"] }],
|
|
[reports[0], { ...reports[0], replyId: "reply-again", correctsReplyIds: ["foreign"] }],
|
|
]) expect(() => validateCompletionQuality({ criteria, reports: inventory }, twoReplies)).toThrow(/inventory/);
|
|
});
|
|
it("grounds a joint reply in the other delegated task's result without including foreign or plan documents", () => {
|
|
const input = { ...observation, worker: { ...observation.worker, companyId: "fixture" }, relatedTasks: [
|
|
{ task: { id: "second", companyId: "fixture", status: "done", completedAt: observation.worker.completedAt, title: "PRIVATE TITLE" },
|
|
documents: [{ id: "second-doc", issueId: "second", key: "welcome", body: "Another saved welcome note. Contact alice@example.com." },
|
|
{ id: "plan", issueId: "second", key: "plan", body: "PRIVATE PLAN" },
|
|
{ id: "foreign-doc", issueId: "elsewhere", key: "welcome", body: "PRIVATE OTHER TASK" }] },
|
|
{ task: { id: "foreign", companyId: "other", status: "done", completedAt: observation.worker.completedAt },
|
|
documents: [{ id: "foreign-doc", issueId: "foreign", key: "welcome", body: "PRIVATE COMPANY" }] },
|
|
] };
|
|
const evidence = JSON.parse(completionQualityRequest(input).input);
|
|
expect(evidence.relatedTasks).toHaveLength(1);
|
|
expect(evidence.relatedTasks[0].documents).toEqual([{ id: "second-doc", body: "Another saved welcome note. Contact [REDACTED_EMAIL]." }]);
|
|
expect(JSON.stringify(evidence)).not.toContain("PRIVATE");
|
|
expect(validateCompletionQuality({ reports, criteria: criteria.map(c => ({ ...c, evidenceIds: ["reply", "second-doc"] })) }, input).passed).toBe(true);
|
|
});
|
|
it("rejects invented references, missing evidence, duplicate criteria and missing replies", () => {
|
|
expect(() => validateCompletionQuality({ reports, criteria: criteria.map(c => ({ ...c, evidenceIds: ["invented"] })) }, observation)).toThrow();
|
|
expect(() => validateCompletionQuality({ reports, criteria: criteria.map(c => ({ ...c, evidenceIds: ["doc"] })) }, observation)).toThrow();
|
|
expect(() => validateCompletionQuality({ reports, criteria: criteria.map((c, i) => i === 1 ? criteria[0] : c) }, observation)).toThrow();
|
|
expect(() => completionQualityRequest({ ...observation, comments: [] })).toThrow();
|
|
expect(() => reserveCompletionQuality(observation, 0.000001)).toThrow();
|
|
});
|
|
it("calibrates repeated announcements without rejecting corrections or distinct-task updates", () => {
|
|
const controls = completionQualityControls(observation);
|
|
expect(controls.map(c => [c.name, c.expectedPass])).toEqual([["accurate", true], ["stale", false], ["unsupported", false], ["corrected", true],
|
|
["duplicate", false], ["redundant-acknowledgement", false], ["distinct-tasks", true],
|
|
["pending-then-joint", true], ["joint-then-repeated", false], ["supported-content-check", true], ["unsupported-content-check", false], ["rendered-task-link", true], ["unlinked-status-only", false], ["completion-then-result", true], ["completion-then-result-then-repeat", false], ["recap-with-new-result", true]]);
|
|
expect(controls[3].observation.comments).toHaveLength(2);
|
|
expect(controls[4].observation.comments[0].body).not.toBe(controls[4].observation.comments[1].body);
|
|
const distinct = JSON.parse(completionQualityRequest(controls[6].observation).input);
|
|
expect(distinct.relatedTasks).toHaveLength(1);
|
|
expect(distinct.replies[1].body).toContain(distinct.relatedTasks[0].task.id);
|
|
expect(observation.comments).toHaveLength(1);
|
|
for (const c of controls) expect(completionQualityRequest(c.observation).input).toContain("10:30");
|
|
});
|
|
it("requires approval and sends only minimized, redacted fixture evidence", async () => {
|
|
const privateObservation = { ...observation, fixtureRequest: "Save a garden note. Contact alice@example.com. Key private-fixture-value.", worker: { ...observation.worker, title: "PRIVATE TITLE" },
|
|
documents: [...observation.documents.map(d => ({ ...d, body: d.body + " Key private-fixture-value contact alice@example.com or 212-555-0199" })),
|
|
{ id: "unrelated", issueId: "other", key: "note", body: "PRIVATE OTHER TASK" }, { id: "plan", issueId: "task", key: "plan", body: "PRIVATE PLAN" }],
|
|
comments: [...observation.comments, { ...observation.comments[0], id: "other", issueId: "other", body: "PRIVATE OTHER CHAT" }] };
|
|
const secrets = ["private-fixture-value"];
|
|
const pending = reserveCompletionQuality(privateObservation, 0.5, secrets);
|
|
let calls = 0;
|
|
const fetcher: typeof fetch = async (_url, init) => {
|
|
calls++;
|
|
const request = String(init?.body);
|
|
expect(request).not.toMatch(/private-fixture-value|alice@example.com|212-555-0199|PRIVATE/);
|
|
expect(request).toContain("REDACTED");
|
|
expect(JSON.parse(JSON.parse(request).input).fixtureRequest).toContain("Save a garden note.");
|
|
return new Response(JSON.stringify({ status: "completed", model: COMPLETION_QUALITY_CONFIG.model, usage: { input_tokens: 100, output_tokens: 50 }, output: [{ content: [{ type: "output_text", text: JSON.stringify({ criteria, reports }) }] }] }));
|
|
};
|
|
expect((await judgeCompletionQuality(privateObservation, pending, "fixture-key", fetcher)).status).toBe("failed");
|
|
expect(calls).toBe(0);
|
|
expect((await judgeCompletionQuality(privateObservation, pending, "fixture-key", fetcher, { approvedFixture: true, secrets })).status).toBe("completed");
|
|
expect(calls).toBe(1);
|
|
});
|
|
it("fails closed on missing usage and does not retry", async () => {
|
|
let calls = 0;
|
|
const result = await judgeCompletionQuality(observation, reserveCompletionQuality(observation, 1), "fixture-key", async () => {
|
|
calls++; return new Response(JSON.stringify({ status: "completed", model: COMPLETION_QUALITY_CONFIG.model }));
|
|
}, { approvedFixture: true, secrets: [] });
|
|
expect(result.status).toBe("failed"); expect(result.passed).toBe(false); expect(calls).toBe(1);
|
|
});
|
|
it("retains a redacted invalid verdict for diagnosis without accepting its references", async () => {
|
|
const result = await judgeCompletionQuality(observation, reserveCompletionQuality(observation, 1), "fixture-key", async () =>
|
|
new Response(JSON.stringify({ status: "completed", model: COMPLETION_QUALITY_CONFIG.model,
|
|
usage: { input_tokens: 100, output_tokens: 50 }, output: [{ content: [{ type: "output_text", text: JSON.stringify({
|
|
reports, criteria: criteria.map(c => ({ ...c, evidenceIds: ["invented"], rationale: "private-fixture-value alice@example.com" })),
|
|
}) }] }] })), { approvedFixture: true, secrets: ["private-fixture-value"] });
|
|
expect(result.status).toBe("failed"); expect(result.passed).toBe(false);
|
|
expect(result).toHaveProperty("rejectedVerdict", expect.stringContaining("invented"));
|
|
expect(JSON.stringify(result)).not.toMatch(/private-fixture-value|alice@example.com/);
|
|
expect(result.estimatedCostUsd).toBeGreaterThan(0);
|
|
});
|
|
});
|