mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-21 00:05:49 +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>
176 lines
15 KiB
TypeScript
176 lines
15 KiB
TypeScript
import { gradeUnansweredQuestion, type UnansweredQuestionEvidence } from "./confirmation-replies.js";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import { gradeConfirmationReply, assertAmbiguousReplyUnresolved, ambiguousConfirmationFixtures } from "./confirmation-replies.js";
|
|
import { firstTaskScenario } from "./first-task-cases.js";
|
|
import type { FirstTaskEvidence } from "./first-task-scoring.js";
|
|
import { MANAGED_FIRST_TASK_CELL, provisionFirstTaskFixtures } from "./first-task-fixtures.js";
|
|
import { runnerMatrix } from "./catalog.js";
|
|
import { parseRunnerSelectors, selectRunnerExecutions } from "./selectors.js";
|
|
|
|
function recording(rejected = false): FirstTaskEvidence {
|
|
const caseId = rejected ? "reject-no-execution" : "task-reply-accept";
|
|
const scenario = firstTaskScenario(caseId, "oracle");
|
|
const card = { id: "proposal", kind: "request_confirmation", status: "pending" };
|
|
const base = { issueId: "onboard", tasks: [{ id: "onboard" }], agents: [], comments: [], interactions: [card], documents: [], runs: [] };
|
|
const message = { id: "user-answer", authorUserId: "user", body: rejected ? scenario.rejection : scenario.acceptance, createdAt: "2026-09-29T00:01:00Z" };
|
|
return { caseId, nonce: "oracle", onboardingIssueId: "onboard", agentId: "planner", initialTaskIds: ["onboard"], instructions: [], configuredModel: null, observedModels: [], checks: [], checkpoints: [
|
|
{ ...base, id: "before", phase: "response", at: "2026-09-29T00:00:00Z" },
|
|
{ ...base, id: "decision", phase: rejected ? "rejected" : "accepted", at: message.createdAt, comments: [message] },
|
|
{ ...base, id: "after", phase: "finished", at: "2026-09-29T00:03:00Z", comments: [message], runs: [{ id: "resolver", agentId: "planner" }],
|
|
tasks: [{ id: "onboard" }, ...rejected ? [] : [{ id: "child", createdAt: "2026-09-29T00:02:01Z" }]],
|
|
interactions: [{ ...card, status: rejected ? "rejected" : "accepted", resolvedAt: "2026-09-29T00:02:00Z", resolvedByAgentId: "planner", resolvedByRunId: "resolver", result: { outcome: rejected ? "rejected" : "accepted", commentId: message.id } }] },
|
|
] };
|
|
}
|
|
describe("confirmation-reply independent oracle", () => {
|
|
it("uses valid public confirmation fixtures without treating checkbox defaults as consent", () => {
|
|
expect(ambiguousConfirmationFixtures).toHaveLength(2);
|
|
const checkbox = ambiguousConfirmationFixtures[1]!;
|
|
expect(checkbox.kind).toBe("request_checkbox_confirmation");
|
|
expect(checkbox.payload).toMatchObject({ minSelected: 1, defaultSelectedOptionIds: ["poster"] });
|
|
});
|
|
it.each([false, true])("accepts the recorded decision with provenance (rejection=%s)", rejected => {
|
|
expect(gradeConfirmationReply(recording(rejected)).every(c => c.passed)).toBe(true);
|
|
});
|
|
it.each(["pending", "expired", "wrong-message", "wrong-agent", "no-run", "wrong-run-agent", "missing-time", "no-card", "too-late", "multiple-pending", "opposite"])("rejects plausible wrong outcome: %s", kind => {
|
|
const e = recording(), last = e.checkpoints.at(-1)!, card = last.interactions[0]!;
|
|
if (kind === "pending" || kind === "expired") card.status = kind;
|
|
if (kind === "wrong-message") card.result.commentId = "another-message";
|
|
if (kind === "wrong-agent") card.resolvedByAgentId = "someone-else";
|
|
if (kind === "no-run") last.runs = [];
|
|
if (kind === "wrong-run-agent") last.runs[0]!.agentId = "someone-else";
|
|
if (kind === "missing-time") delete card.resolvedAt;
|
|
if (kind === "no-card") e.checkpoints[0]!.interactions = [];
|
|
if (kind === "too-late") card.resolvedAt = "2026-09-29T00:02:02Z";
|
|
if (kind === "multiple-pending") e.checkpoints[0]!.interactions.push({ id: "another-proposal", kind: "request_confirmation", status: "pending" });
|
|
if (kind === "opposite") card.result.outcome = "rejected";
|
|
expect(gradeConfirmationReply(e).some(c => !c.passed)).toBe(true);
|
|
});
|
|
it("does not treat checkbox defaults as a persisted selection", () => {
|
|
const e = recording(), card = e.checkpoints.at(-1)!.interactions[0]!;
|
|
card.kind = "request_checkbox_confirmation";
|
|
expect(gradeConfirmationReply(e).every(c => c.passed)).toBe(false);
|
|
card.result.selectedOptionIds = ["welcome-note"];
|
|
expect(gradeConfirmationReply(e).every(c => c.passed)).toBe(true);
|
|
});
|
|
it("requires clarification and no effects for ambiguous approval", () => {
|
|
const e = { cards: [{ id: "a", status: "pending" }, { id: "b", status: "pending" }], originalIds: ["a", "b"], tasks: [], reply: "Which proposal do you mean: the note or the poster?" };
|
|
expect(() => assertAmbiguousReplyUnresolved(e)).not.toThrow();
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...e, cards: [{ id: "a", status: "accepted" }, e.cards[1]!] })).toThrow();
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...e, tasks: [{ id: "unauthorized-task" }] })).toThrow();
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...e, reply: "Both proposals are approved." })).toThrow();
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...e, reply: "What is the deadline?" })).toThrow();
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...e, reply: "Which tone should the welcome note and poster use?" })).toThrow();
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...e, reply: "Would you like the welcome note and poster to be formal?" })).toThrow();
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...e, reply: "Do you want the welcome note and poster by Friday?" })).toThrow();
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...e, reply: "Do you mean the welcome note or the poster?" })).not.toThrow();
|
|
for (const reply of ["Which proposal do you mean?\n- Welcome note\n- Poster", "Which proposal do you mean?\n\n* Welcome note\n* Poster", "Which one\nshould I proceed with: the welcome note or poster?",
|
|
"Should I proceed with the welcome note or the poster?", "Do you mean the note or the poster, or both?", "Should we start the poster or the welcome note, or both?", "Which garden-club item should we move forward with: the note or poster?",
|
|
"Which pending proposal does yes approve?\n- Welcome note\n- Poster",
|
|
"Which project(s) should I start on now?\n- Welcome note only\n- Poster only\n- Both",
|
|
'There are two pending proposals: the **welcome note** and the **poster**. Your yes does not specify which. Could you clarify:\n\n- Just the welcome note?\n- Just the poster?\n- Both?\n\nI will record your decision.',
|
|
]) {
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...e, reply })).not.toThrow();
|
|
}
|
|
});
|
|
it("accepts a current structured clarification and rejects stale or unrelated question cards", () => {
|
|
const question = { id: "question", kind: "ask_user_questions", status: "pending", createdByAgentId: "planner",
|
|
originCommentIds: ["ambiguous-answer"], payload: { questions: [{ prompt: "Which item(s) does go ahead authorize me to plan?", options: [{ label: "Welcome note only" }, { label: "Poster only" }] }] } };
|
|
const evidence = { cards: [{ id: "a", status: "pending" }, { id: "b", status: "pending" }, question], originalIds: ["a", "b"], tasks: [], reply: "",
|
|
agentId: "planner", answerId: "ambiguous-answer" };
|
|
expect(() => assertAmbiguousReplyUnresolved(evidence)).not.toThrow();
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...evidence, cards: [...evidence.cards.slice(0, 2), { ...question,
|
|
payload: { questions: [{ prompt: "Which garden club item should I move forward with?", options: [{ label: "Welcome note" }, { label: "Poster" }] }] },
|
|
}] })).not.toThrow();
|
|
const native = { ...question, payload: { questionSet: { description: "Which item(s) would you like me to start developing a plan for?",
|
|
questions: [{ prompt: "Scope", options: [{ label: "Welcome note only" }, { label: "Poster only" }, { label: "Both" }] }] } } };
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...evidence, cards: [...evidence.cards.slice(0, 2), native] })).not.toThrow();
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...evidence, cards: [...evidence.cards.slice(0, 2), { ...native,
|
|
payload: { questionSet: { ...native.payload.questionSet, description: "What is the deadline?" } },
|
|
}] })).toThrow();
|
|
for (const patch of [{ originCommentIds: ["old-answer"] }, { createdByAgentId: "other-agent" }, { status: "answered" }, { payload: { questions: [] } }, { payload: { questions: [{ prompt: "What is the deadline?" }] } }, { payload: { questions: [{ prompt: "Which tone should the welcome note and poster use?", options: [{ label: "Warm" }, { label: "Formal" }] }] } }]) {
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...evidence, cards: [...evidence.cards.slice(0, 2), { ...question, ...patch }] })).toThrow();
|
|
}
|
|
});
|
|
it.each([
|
|
"Which part of the welcome note or poster should I revise?",
|
|
"Which font should I choose for the welcome note or poster?",
|
|
"Which color option should the welcome note or poster use?",
|
|
"Which of the fonts should I use for the welcome note or poster?",
|
|
"Should I select a deadline for the welcome note or poster?",
|
|
"Pick a font for the welcome note or poster?",
|
|
"Would you like the welcome note or poster to be formal?",
|
|
"Do you want the welcome note or poster by Friday?",
|
|
"Could you clarify:\n- What font for the welcome note?\n- What font for the poster?",
|
|
])("does not mistake a detail question for proposal selection: %s", prompt => {
|
|
const cards = [{ id: "a", status: "pending" }, { id: "b", status: "pending" }];
|
|
const evidence = { cards, originalIds: ["a", "b"], tasks: [], reply: prompt, agentId: "planner", answerId: "answer" };
|
|
expect(() => assertAmbiguousReplyUnresolved(evidence)).toThrow();
|
|
// Named alternatives do not turn an unrelated field into a scope question.
|
|
expect(() => assertAmbiguousReplyUnresolved({ ...evidence, reply: "", cards: [...cards, {
|
|
id: "question", kind: "ask_user_questions", status: "pending", createdByAgentId: "planner", originCommentIds: ["answer"],
|
|
payload: { questions: [{ prompt, options: [{ label: "Welcome note" }, { label: "Poster" }] }] },
|
|
}] })).toThrow();
|
|
});
|
|
it.each(runnerMatrix.filter(e => e.suite.id === "confirmation-replies" && e.task.flow === "first_task" && e.environment.id === "local"))("provisions the real local onboarding fixture contract for $id", async execution => {
|
|
const get = vi.fn().mockResolvedValue([{ id: "local", driver: "local" }]);
|
|
const patch = vi.fn().mockResolvedValue({ id: "company" });
|
|
const postSensitive = vi.fn().mockResolvedValue({ id: "secret" });
|
|
const credential = execution.profile.credential;
|
|
const fixtures = await provisionFirstTaskFixtures({ api: { get, patch, postSensitive }, execution, nonce: "fixture",
|
|
company: { id: "company", name: "Garden" }, credentials: { [credential]: "test-credential" } });
|
|
expect(get).toHaveBeenCalledExactlyOnceWith("/api/companies/company/environments?driver=local");
|
|
expect(patch).toHaveBeenCalledExactlyOnceWith("/api/companies/company", { budgetMonthlyCents: 500 });
|
|
expect(postSensitive).toHaveBeenCalledExactlyOnceWith("/api/companies/company/secrets", expect.objectContaining({ key: credential }));
|
|
expect(fixtures.agent.id).toBe(""); // The real wizard must still create the agent.
|
|
expect(JSON.stringify(fixtures)).not.toContain("test-credential");
|
|
});
|
|
it.each(["Select every proposal you want to approve.", "Choose the proposals to approve."])("accepts explicit proposal selection in an imperative form: %s", prompt => {
|
|
expect(() => assertAmbiguousReplyUnresolved({ cards: [{ id: "a", status: "pending" }, { id: "b", status: "pending" },
|
|
{ id: "question", kind: "ask_user_questions", status: "pending", createdByAgentId: "agent", originCommentIds: ["reply"],
|
|
payload: { questions: [{ prompt, options: [{ label: "Welcome note" }, { label: "Poster" }] }] } }],
|
|
originalIds: ["a", "b"], tasks: [], reply: "", agentId: "agent", answerId: "reply" })).not.toThrow();
|
|
});
|
|
it("rejects an imperative about fonts even with named proposal options", () => {
|
|
expect(() => assertAmbiguousReplyUnresolved({ cards: [{ id: "a", status: "pending" }, { id: "b", status: "pending" },
|
|
{ id: "question", kind: "ask_user_questions", status: "pending", createdByAgentId: "agent", originCommentIds: ["reply"],
|
|
payload: { questions: [{ prompt: "Select every font you want to approve.", options: [{ label: "Welcome note" }, { label: "Poster" }] }] } }],
|
|
originalIds: ["a", "b"], tasks: [], reply: "", agentId: "agent", answerId: "reply" })).toThrow();
|
|
});
|
|
|
|
it("selects twelve local and one managed explicit-only cases using production native profiles", () => {
|
|
const cells = runnerMatrix.filter(e => e.suite.id === "confirmation-replies");
|
|
expect(cells).toHaveLength(13);
|
|
expect(cells.filter(c => c.environment.id === "local")).toHaveLength(12);
|
|
expect(cells.filter(c => c.environment.id === "daytona").map(c => c.id)).toEqual([MANAGED_FIRST_TASK_CELL]);
|
|
expect(new Set(cells.map(c => c.profile.id))).toEqual(new Set(["runner-codex", "runner-acpx-claude"]));
|
|
expect(new Set(cells.map(c => c.task.id)).size).toBe(6);
|
|
expect(selectRunnerExecutions(parseRunnerSelectors(["--suite", "confirmation-replies"]))).toHaveLength(13);
|
|
expect(selectRunnerExecutions(parseRunnerSelectors(["--all"])).some(c => c.suite.id === "confirmation-replies")).toBe(false);
|
|
});
|
|
});
|
|
|
|
|
|
describe("unanswered question workflow oracle", () => {
|
|
const good = () => ({
|
|
original: { id: "color", status: "pending", payload: { questions: [{ options: [{ id: "blue", label: "Blue" }, { id: "green", label: "Green" }] }] } },
|
|
afterMove: { id: "color", status: "pending", result: null, resolvedAt: null },
|
|
afterAnswer: { id: "color", status: "answered", resolvedByUserId: "user", resolvedAt: "2026-09-01T12:02:00Z", result: { answers: [{ optionIds: ["blue"] }] } },
|
|
unrelatedComment: { id: "unrelated-comment", authorUserId: "user", createdAt: "2026-09-01T12:00:00Z" },
|
|
unrelatedReply: { id: "unrelated-reply", authorAgentId: "agent", body: "Paris.", createdAt: "2026-09-01T12:01:00Z" },
|
|
lateReply: { id: "late-reply", authorAgentId: "agent", createdByRunId: "later-run", body: "Blue it is.", createdAt: "2026-09-01T12:03:00Z" }, taskCount: 0,
|
|
});
|
|
it("accepts the independently saved workflow", () => expect(gradeUnansweredQuestion(good()).every(check => check.passed)).toBe(true));
|
|
it.each(["expired", "wrong-question", "missing-reply", "stale-reply", "wrong-answer", "missing-late-reply", "old-acknowledgement", "invented-work"])("rejects %s", kind => {
|
|
const evidence: UnansweredQuestionEvidence = good();
|
|
if (kind === "expired") evidence.afterMove.status = "expired";
|
|
if (kind === "wrong-question") evidence.afterAnswer.id = "other-question";
|
|
if (kind === "missing-reply") evidence.unrelatedReply = undefined;
|
|
if (kind === "stale-reply") evidence.unrelatedReply!.createdAt = "2026-08-01T12:00:00Z";
|
|
if (kind === "wrong-answer") evidence.afterAnswer.result.answers[0].optionIds = ["green"];
|
|
if (kind === "missing-late-reply") evidence.lateReply = undefined;
|
|
if (kind === "old-acknowledgement") evidence.lateReply!.createdAt = "2026-08-01T12:00:00Z";
|
|
if (kind === "invented-work") evidence.taskCount = 1;
|
|
expect(gradeUnansweredQuestion(evidence).some(check => !check.passed)).toBe(true);
|
|
});
|
|
});
|