// The TRANSPARENT RUNS fixture (plans/umtool-redesign.md, R3): three sweep // iterations in the article store, for e2e/run-trace.spec.ts and // lib/research/runs.test.ts. // // runfix/iterations/1 a finished agent sweep with a trace.jsonl: // scope, an enumeration, a batch with the // extractor's lines, a quote refused then // repaired, a quote DROPPED (and why), two kept // findings, the end; coverage on the iteration; // its report.json cites the research fixture // runfix-turns/iterations/1 an imported run with only turns.jsonl, TWO run // starts (an import keeps every attempt): the // projection shows them as two runs // runfix-live/iterations/1 a sweep still RUNNING: its trace has a start, a // scope and one turn; the spec appends the rest // // Synthetic, like every fixture: the words are the research fixture's // invented lines. import { mkdirSync, writeFileSync } from "node:fs"; import path from "node:path"; import { ARCHIVE, DRIFTED_QUOTE, RESEARCH_PHRASE } from "./research-fixture.mjs"; export const RUN_ARTICLE = "runfix"; export const TURNS_ARTICLE = "runfix-turns"; export const LIVE_ARTICLE = "runfix-live"; /** The editor job the live run's iteration names (running.spec places a Running row by it). */ export const LIVE_JOB = "e2e-run-live"; export const RUN_QUESTION = "What did the harbor channels say about the lighthouse budget?"; /** The quote the trace drops, and why. */ export const DROPPED = { quote: "the harbor master said the budget was always fine", reason: 'not verbatim within 90 s of 1500 s: "the harbor master said the budget was always fine"', claim: "The harbor master called the budget fine", }; /** The quote refused in the first round, then repaired and kept. */ export const REPAIRED = { was: `they voted the ${RESEARCH_PHRASE} down nine to one`, now: DRIFTED_QUOTE.now }; export const KEPT_KEEPER = `the keeper never saw the ${RESEARCH_PHRASE}`; export const BATCH_LINE = `[34:04|2044] ${DRIFTED_QUOTE.now}`; const put = (file, value) => { mkdirSync(path.dirname(file), { recursive: true }); writeFileSync(file, typeof value === "string" ? value : `${JSON.stringify(value, null, 2)}\n`); }; const jsonl = (rows) => rows.map((r) => JSON.stringify(r)).join("\n") + "\n"; const AT = (s) => new Date(Date.parse("2026-10-14T09:00:00.000Z") + s * 1000).toISOString(); const ev = (s, e) => ({ t: e.t, at: AT(s), run: e.run ?? 1, ...e }); const iteration = (article, extra) => ({ format: "archilyzer-iteration", version: 1, article, n: 1, kind: "sweep", parent: null, copyOf: null, status: "done", usage: {}, steps: [], createdAt: AT(0), updatedAt: AT(80), endedAt: AT(80), ...extra, }); /** The finished run's trace (an agent sweep): what common's sweep-agent writes. */ export function finishedTrace(source = "local:/fixture/research-public") { const cite = (video, start, extra = {}) => ({ channel: "harbor-radio", video, start, ...extra }); return [ ev(0, { t: "run", phase: "start", task: "sweep-agent", model: "claude-sonnet-5-5", extractor: "claude-haiku-4-5" }), ev(0, { t: "scope", source, channels: ["harbor-radio", "night-desk"], question: RUN_QUESTION, model: "claude-sonnet-5-5", extractor: "claude-haiku-4-5", origin: ARCHIVE, maxUsd: 2, batchSize: 10 }), ev(4, { t: "cost", step: "turn 0", usd: 0.05, model: "claude-sonnet-5-5", total: 0.05, turn: 0, phase: "agent", calls: ["enumerate_matches"] }), ev(5, { t: "enumerate", query: RESEARCH_PHRASE, n: 3, ids: ["hr-2022a", "nd-2023", "hr-2021a"], partial: false, unreached: [], total: 3, turn: 0, phase: "agent" }), ev(9, { t: "cost", step: "turn 1", usd: 0.04, model: "claude-sonnet-5-5", total: 0.09, turn: 1, phase: "agent", calls: ["extract_batch"], text: "One batch of three." }), ev(14, { t: "batch", k: 1, of: 1, ids: ["hr-2022a", "nd-2023", "hr-2021a"], lines: ["### Harbor Radio 80: the council vote", BATCH_LINE, "### Night Desk: the keeper", `[6:40|400] ${KEPT_KEEPER}`], model: "claude-haiku-4-5", usd: 0.01, turn: 1, phase: "agent" }), ev(14, { t: "cost", step: "batch 1", usd: 0.01, model: "claude-haiku-4-5", total: 0.1, turn: 1, phase: "agent" }), ev(20, { t: "cost", step: "turn 2", usd: 0.06, model: "claude-sonnet-5-5", total: 0.16, turn: 2, phase: "agent", calls: ["write_report"] }), ev(21, { t: "note", text: "agent ended: end_turn", turn: 2, phase: "agent" }), ev(22, { t: "check", quote: REPAIRED.was, cite: cite("hr-2022a", 2044, { citation: "c1" }), ok: false, reason: `not verbatim within 90 s of 2044 s: "${REPAIRED.was}"`, stage: "check", round: 1 }), ev(22, { t: "check", quote: DROPPED.quote, cite: cite("hr-2021a", 1500, { citation: "c2" }), ok: false, reason: DROPPED.reason, stage: "check", round: 1 }), ev(22, { t: "note", text: "2 quote problem(s) — one repair round", phase: "repair" }), ev(30, { t: "cost", step: "repair turn 0", usd: 0.02, model: "claude-sonnet-5-5", total: 0.18, turn: 0, phase: "repair", calls: ["edit_report"] }), ev(31, { t: "check", quote: DROPPED.quote, cite: cite("hr-2021a", 1500, { citation: "c2" }), ok: false, reason: DROPPED.reason, stage: "check", round: 2 }), ev(31, { t: "check", quote: DROPPED.quote, cite: cite("hr-2021a", 1500, { citation: "c2" }), ok: false, reason: DROPPED.reason, stage: "drop", dropped: true, claim: DROPPED.claim }), ev(32, { t: "finding", section: "The vote", claim: "The council voted the budget down", cites: [{ citation: "c1", kind: "video", channel: "harbor-radio", video: "hr-2022a", start: 2044, end: 2048, quote: REPAIRED.now }] }), ev(32, { t: "finding", section: "The keeper", claim: "The keeper says he never saw it", cites: [{ citation: "c2", kind: "video", channel: "night-desk", video: "nd-2023", start: 400, end: 404, quote: KEPT_KEEPER }] }), ev(32, { t: "check", quote: REPAIRED.now, cite: { citation: "c1", kind: "video", channel: "harbor-radio", video: "hr-2022a", start: 2044, end: 2048 }, ok: true, stage: "final", reason: "verbatim (strict)" }), ev(32, { t: "check", quote: KEPT_KEEPER, cite: { citation: "c2", kind: "video", channel: "night-desk", video: "nd-2023", start: 400, end: 404 }, ok: true, stage: "final", reason: "verbatim (strict)" }), ev(33, { t: "run", phase: "end", status: "done", summary: "“The lighthouse budget”: 2 section(s), 2 claim(s), 2 citation(s), 1 dropped — ~$0.18", usd: 0.18, minutes: 0.55, coverage: { matched: 3, read: 3, partial: false, unreached: [] } }), ]; } export const RUN_REPORT = { format: "archilyzer-report", version: 1, id: RUN_ARTICLE, kind: "sweep", title: "The lighthouse budget", citations: { c1: { kind: "video", channel: "harbor-radio", id: "hr-2022a", start: 2044, end: 2048, quote: REPAIRED.now, label: "Harbor Radio 80: the council vote", date: "2022-02-11" }, c2: { kind: "video", channel: "night-desk", id: "nd-2023", start: 400, end: 404, quote: KEPT_KEEPER, label: "Night Desk: the keeper", date: "2023-09-01" }, }, sections: [ { id: "the-vote", title: "The vote", claims: [{ id: "k1", text: "The council voted the budget down", citations: ["c1"] }] }, { id: "the-keeper", title: "The keeper", claims: [{ id: "k2", text: "The keeper says he never saw it", citations: ["c2"] }] }, ], }; /** An imported stopgap run's turns: two attempts (two "run started" notes), the turn's usd a running total. */ export function twoStartTurns() { const note = (s, text, stopgap) => ({ kind: "note", turn: 0, at: AT(s), text, ...(stopgap ? { stopgap } : {}) }); const resp = (s, turn, names, usd, text) => ({ kind: "response", turn, provider: "api", at: AT(s), stopReason: names.length ? "tool_use" : "end_turn", content: [...(text ? [{ type: "text", text }] : []), ...names.map((name) => ({ type: "tool_use", name }))], usage: {}, usd, }); const tool = (turn, name, input, chars) => ({ kind: "tool", turn, name, input, result: "", chars, error: false, ms: 0 }); const sg = { question: RUN_QUESTION, channels: ["harbor-radio"] }; return [ note(0, `imported from the stopgap run ${TURNS_ARTICLE} (transcript.jsonl)`), note(0, "stopgap run started: model claude-sonnet-5-5, extractor claude-haiku-4-5, cap $5", sg), resp(2, 0, ["enumerate_matches"], 0.03), tool(0, "enumerate_matches", { query: RESEARCH_PHRASE, channels: ["harbor-radio"] }, 1200), resp(6, 1, ["extract_batch"], 0.07), tool(1, "extract_batch", { video_ids: ["hr-2022a", "hr-2021a"], queries: [RESEARCH_PHRASE], directive: "what was said" }, 18), resp(9, 2, [], 0.09, "Stopped: the extractor answered nothing."), note(60, "stopgap run started: model claude-sonnet-5-5, extractor claude-haiku-4-5, cap $5", sg), resp(62, 0, ["enumerate_matches"], 0.04), tool(0, "enumerate_matches", { query: "council vote", channels: ["harbor-radio"] }, 900), resp(66, 1, ["get_transcripts"], 0.1), tool(1, "get_transcripts", { video_ids: ["hr-2022a"], queries: ["council vote"] }, 4100), resp(70, 2, ["write_report"], 0.15), tool(2, "write_report", {}, 92), resp(72, 3, [], 0.16, "I wrote the report."), ]; } /** A run still going: started, scoped, one turn. The spec appends the rest. */ export function liveTraceHead(source = "local:/fixture/research-public") { return [ ev(0, { t: "run", phase: "start", task: "sweep-agent", model: "claude-sonnet-5-5", extractor: "claude-haiku-4-5" }), ev(0, { t: "scope", source, channels: ["harbor-radio"], question: "Is the ferry running?", model: "claude-sonnet-5-5", extractor: "claude-haiku-4-5", origin: ARCHIVE, maxUsd: 1 }), ev(3, { t: "cost", step: "turn 0", usd: 0.03, model: "claude-sonnet-5-5", total: 0.03, turn: 0, phase: "agent", calls: ["enumerate_matches"] }), ev(4, { t: "enumerate", query: "ferry", n: 2, ids: ["hr-2019a", "hr-2020a"], partial: false, unreached: [], turn: 0, phase: "agent" }), ]; } /** What the spec appends to the live run: its next turn. */ export function liveTraceNext() { return [ev(8, { t: "cost", step: "turn 1", usd: 0.05, model: "claude-sonnet-5-5", total: 0.08, turn: 1, phase: "agent", calls: ["get_transcripts"] })]; } export const jsonLines = jsonl; export function makeRunTraceFixture({ articles, source }) { const dir = (a) => path.join(articles, a, "iterations", "1"); put( path.join(dir(RUN_ARTICLE), "iteration.json"), iteration(RUN_ARTICLE, { model: "claude-sonnet-5-5", question: RUN_QUESTION, scope: { channels: ["harbor-radio", "night-desk"] }, usage: { "claude-sonnet-5-5": { usd: 0.17, inputTokens: 30000, outputTokens: 2000, calls: 4 }, "claude-haiku-4-5": { usd: 0.01, inputTokens: 9000, outputTokens: 300, calls: 1 } }, minutes: 0.55, checks: [{ name: "convert", ok: true }, { name: "quotes", ok: true, detail: "every quote verbatim (strict); 1 finding(s) dropped" }], coverage: { matched: 3, read: 3, partial: false, unreached: [] }, }), ); put(path.join(dir(RUN_ARTICLE), "trace.jsonl"), jsonl(finishedTrace(source))); put(path.join(dir(RUN_ARTICLE), "report.json"), RUN_REPORT); put( path.join(dir(TURNS_ARTICLE), "iteration.json"), iteration(TURNS_ARTICLE, { model: "claude-sonnet-5-5", question: RUN_QUESTION, scope: { channels: ["harbor-radio"] }, usage: { "claude-sonnet-5-5": { usd: 0.16, inputTokens: 1000, outputTokens: 200, calls: 4 } }, minutes: 0.2, checks: [{ name: "convert", ok: true }, { name: "verify-quotes", ok: true }], imported: { from: "local-reports", run: TURNS_ARTICLE, at: AT(80), extractor: "claude-haiku-4-5" }, }), ); put(path.join(dir(TURNS_ARTICLE), "turns.jsonl"), jsonl(twoStartTurns())); put( path.join(dir(LIVE_ARTICLE), "iteration.json"), iteration(LIVE_ARTICLE, { model: "claude-sonnet-5-5", question: "Is the ferry running?", scope: { channels: ["harbor-radio"] }, status: "running", endedAt: undefined, jobId: LIVE_JOB }), ); put(path.join(dir(LIVE_ARTICLE), "trace.jsonl"), jsonl(liveTraceHead(source))); return { dir }; }