@qwen-code/qwen-harness 0.1.9 → 0.1.11-yjk.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/verifiers/scaling/constraints-cli.ts", "../src/verifiers/scaling/constraints.ts", "../src/harnesses/scaling/experiments/config.ts", "../src/harnesses/scaling/config.ts", "../src/harnesses/scaling/experiments/events.ts", "../src/harnesses/scaling/experiments/paths.ts", "../src/utils/filesystem/apply_patch.ts", "../src/verifiers/scaling/session.ts"],
4
+ "sourcesContent": ["import { readFile, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { verifyConstraintSession } from \"./constraints.js\";\n\nasync function main(): Promise<void> {\n\tconst args = process.argv.slice(2);\n\tif (args[0] === \"--help\") {\n\t\tprocess.stdout.write(\"Usage: npm run verify:scaling-constraints -- SESSION.jsonl [--leaf ID] [--rules EXPERIMENT.json] [--out NEW_REPORT.json]\\n--rules evaluates a baseline using the same tool profile and different prompt constraints.\\nExit: 0 no detected violations; 1 violations; 2 invalid input; 3 incomplete evidence.\\n\"); return;\n\t}\n\tconst source = args.shift();\n\tif (!source || source.startsWith(\"--\")) throw new Error(\"Expected a session JSONL file; use --help\");\n\tconst flags = new Map<string, string>();\n\twhile (args.length) {\n\t\tconst key = args.shift()!; const value = args.shift();\n\t\tif (![\"--out\", \"--leaf\", \"--rules\"].includes(key) || flags.has(key) || !value || value.startsWith(\"--\")) throw new Error(`Invalid argument ${key}`);\n\t\tflags.set(key, value);\n\t}\n\tconst evaluate = flags.has(\"--rules\") ? JSON.parse(await readFile(flags.get(\"--rules\")!, \"utf8\")) as unknown : undefined;\n\tconst report = verifyConstraintSession(await readFile(source, \"utf8\"), flags.get(\"--leaf\"), evaluate);\n\tconst output = JSON.stringify({ ...report, source: path.resolve(source) }, null, 2) + \"\\n\";\n\tif (flags.has(\"--out\")) await writeFile(flags.get(\"--out\")!, output, { flag: \"wx\", mode: 0o600 }); else process.stdout.write(output);\n\tprocess.stderr.write(report.rules.map((rule) => `${rule.id}: ${rule.status}`).join(\"; \") + \"\\n\");\n\tprocess.exitCode = report.rules.some((rule) => rule.status === \"fail\") ? 1 : report.rules.some((rule) => rule.status === \"insufficient_evidence\") ? 3 : 0;\n}\nmain().catch((error: unknown) => { process.stderr.write(`${error instanceof Error ? error.message : String(error)}\\n`); process.exitCode = 2; });\n", "import path from \"node:path\";\nimport { CONSTRAINT_IDS, parseExperiment, type ConstraintId, type ExperimentConfig } from \"../../harnesses/scaling/experiments/config.js\";\nimport { parseScalingConfig } from \"../../harnesses/scaling/config.js\";\nimport { AUDIT_ENTRY, type AuditEvent, type FileState } from \"../../harnesses/scaling/experiments/events.js\";\nimport { object, operationPlan } from \"../../harnesses/scaling/experiments/paths.js\";\nimport { parseSession } from \"./session.js\";\n\ntype Status = \"pass\" | \"fail\" | \"insufficient_evidence\" | \"not_applicable\";\nexport interface ConstraintEvidence { module: ConstraintId; status: Exclude<Status, \"not_applicable\">; seq: number; round: number; depth: number; sessionFile?: string; callId?: string; path?: string; reason: string }\ninterface Known { state: FileState; sources: Set<string> }\nexport function progressRecord(value: unknown): boolean {\n\tconst record = object(value);\n\treturn Object.keys(record).sort().join(\",\") === \"blockers,done,next\"\n\t\t&& [\"done\", \"next\", \"blockers\"].every((key) => Array.isArray(record[key]) && (record[key] as unknown[]).every((part) => typeof part === \"string\" && !!part.trim()))\n\t\t&& [\"done\", \"next\", \"blockers\"].some((key) => (record[key] as unknown[]).length > 0);\n}\nexport function heartbeat(text: string): boolean {\n\tlet fence: string | undefined;\n\tfor (const line of text.split(\"\\n\")) {\n\t\tconst marker = line.match(/^\\s*(`{3,}|~{3,})/u)?.[1];\n\t\tif (marker) { if (!fence) fence = marker; else if (marker[0] === fence[0] && marker.length >= fence.length) fence = undefined; continue; }\n\t\tif (fence) continue;\n\t\tconst payload = line.match(/^<heartbeat>([^\\n]+)<\\/heartbeat>\\s*$/u)?.[1];\n\t\tif (!payload) continue;\n\t\ttry { if (progressRecord(JSON.parse(payload))) return true; } catch { /* malformed heartbeat */ }\n\t}\n\treturn false;\n}\nfunction savedProgress(suffix: string | undefined): boolean {\n\tif (!suffix?.endsWith(\"\\n\")) return false;\n\treturn suffix.split(\"\\n\").some((line) => { try { return progressRecord(JSON.parse(line)); } catch { return false; } });\n}\nconst same = (a: FileState | undefined, b: FileState): boolean => !!a?.sha256 && a.sha256 === b.sha256 && a.identity === b.identity;\n\n/** Replay trusted runtime evidence. No shell code is executed and no final-file reconstruction is assumed. */\nexport function verifyConstraintEvents(events: readonly AuditEvent[], experiment: ExperimentConfig, cwd: string, depth = 0, evaluatedConstraints = experiment.constraints) {\n\tconst evidence: ConstraintEvidence[] = []; const c = evaluatedConstraints;\n\tconst known = new Map<string, Known>(); const uncertain = new Set<string>();\n\tconst pages = new Map<string, { state: FileState; total: number; ranges: [number, number][]; sources: Set<string> }>();\n\tconst ends = new Map<string, Extract<AuditEvent, { kind: \"end\" }>>();\n\tconst starts = new Map<string, Map<string, Known | undefined>>();\n\tconst executing = new Set<string>();\n\tconst persistenceAttempts: { callId: string; round: number; completed: boolean; toolError: boolean; saved: boolean }[] = [];\n\tlet round = 0; let lastHeartbeat = 0; let lastSaved = 0; let heartbeatMiss = -1; let saveMiss = -1; let previousSeq = 0;\n\tlet reset = false; let settled = false;\n\tconst add = (module: ConstraintId, event: AuditEvent, status: ConstraintEvidence[\"status\"], reason: string, extra: Partial<ConstraintEvidence> = {}) => {\n\t\tif (c[module] && (!depth || !module.startsWith(\"U\"))) evidence.push({ module, seq: event.seq, round: event.round, depth, status, reason, ...extra });\n\t};\n\tconst coverage = (event: AuditEvent, reason: string, ids: readonly ConstraintId[] = CONSTRAINT_IDS) => { for (const id of ids) add(id, event, \"insufficient_evidence\", reason); };\n\tfor (const event of events) {\n\t\tif (event.version !== 1 || event.seq !== previousSeq + 1) coverage(event, \"Audit event sequence is missing or unsupported\");\n\t\tpreviousSeq = event.seq;\n\t\tswitch (event.kind) {\n\t\t\tcase \"init\":\n\t\t\t\tif (JSON.stringify(event.experiment) !== JSON.stringify(experiment)) coverage(event, \"Audit configuration mismatch\");\n\t\t\t\tbreak;\n\t\t\tcase \"response\":\n\t\t\t\tsettled = false;\n\t\t\t\tif (event.round !== round + 1) coverage(event, \"Accepted response counter is discontinuous\", [\"U02\", \"U07\"]);\n\t\t\t\tround = event.round;\n\t\t\t\tif (heartbeat(event.text)) { lastHeartbeat = round; add(\"U02\", event, \"pass\", \"Structured model heartbeat observed\"); }\n\t\t\t\tif (c.U02 && round >= lastHeartbeat + c.U02.every && heartbeatMiss !== lastHeartbeat) {\n\t\t\t\t\theartbeatMiss = lastHeartbeat; add(\"U02\", event, \"fail\", `Heartbeat due by response ${lastHeartbeat + c.U02.every}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"attempt\": {\n\t\t\t\tadd(\"A01\", event, c.A01?.forbiddenTools.includes(event.name) ? \"fail\" : \"pass\", c.A01?.forbiddenTools.includes(event.name) ? \"Forbidden registered tool attempted (including rejected attempts)\" : \"Allowed registered tool attempted\", { callId: event.callId });\n\t\t\t\tconst plan = operationPlan(event.name, event.args, cwd);\n\t\t\t\tfor (const raw of plan.paths) add(\"A07\", event, path.isAbsolute(raw) ? \"pass\" : \"fail\", \"Checked the submitted path before normalization\", { callId: event.callId, path: raw });\n\t\t\t\tif (plan.opaque) add(\"A07\", event, \"insufficient_evidence\", \"Some path operands cannot be established from this call\", { callId: event.callId });\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"start\": {\n\t\t\t\texecuting.add(event.callId);\n\t\t\t\tconst bases = new Map<string, Known | undefined>(); starts.set(event.callId, bases);\n\t\t\t\tif (event.opaque) coverage(event, \"Opaque operation: intermediate file effects are not completely observed\", [\"A02\", \"A05\"]);\n\t\t\t\tfor (const { operation: op, before } of event.operations) {\n\t\t\t\t\tif (op.kind !== \"modify\") continue;\n\t\t\t\t\tconst prior = [...known.values()].find((value) => same(value.state, before)) ?? known.get(op.path); bases.set(op.path, prior);\n\t\t\t\t\tconst status = before.exists === false || same(prior?.state, before) ? \"pass\"\n\t\t\t\t\t\t: before.error || before.exists === undefined || prior ? \"insufficient_evidence\"\n\t\t\t\t\t\t\t: !reset && same(pages.get(op.path)?.state, before) ? \"fail\" : reset || uncertain.has(op.path) ? \"insufficient_evidence\" : \"fail\";\n\t\t\t\t\tconst reason = before.exists === false ? \"New target; no previous contents to read\" : same(prior?.state, before) ? \"Current file matches contents established in the active context\"\n\t\t\t\t\t\t: prior ? \"Version conflict: file changed outside the established context; intent is not inferred\"\n\t\t\t\t\t\t\t: status === \"fail\" ? \"Existing file modified without a delivered complete read or known full contents\" : \"Exact current-content knowledge cannot be established\";\n\t\t\t\t\tadd(\"A05\", event, status, reason, { callId: event.callId, path: op.path });\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"end\":\n\t\t\t\texecuting.delete(event.callId); ends.set(event.callId, event);\n\t\t\t\tfor (const change of event.changes) {\n\t\t\t\t\tconst op = change.operation;\n\t\t\t\t\tif (change.concurrent) coverage(event, `Overlapping operations on ${op.path}`, [\"A02\", \"A05\"]);\n\t\t\t\t\tif (op.kind === \"read\" && (change.completeRead || change.readRange)) uncertain.add(op.path); // Await actual model delivery.\n\t\t\t\t\tif (op.kind === \"modify\" && !same(change.before, change.after)) { known.delete(op.path); uncertain.add(op.path); }\n\t\t\t\t\tif (op.path === experiment.processFile && op.kind !== \"read\") {\n\t\t\t\t\t\tif (!depth && op.kind === \"modify\") persistenceAttempts.push({ callId: event.callId, round: event.round, completed: !change.after.error, toolError: event.isError, saved: !change.concurrent && !!change.prefixPreserved && savedProgress(change.suffix) });\n\t\t\t\t\t\tconst changed = change.before.sha256 !== change.after.sha256 || change.before.exists !== change.after.exists;\n\t\t\t\t\t\tif (op.kind === \"modify\" || changed) add(\"A02\", event, change.concurrent || change.prefixPreserved === undefined ? \"insufficient_evidence\" : change.prefixPreserved ? \"pass\" : \"fail\", change.prefixPreserved ? \"Logical modification preserved every previous byte\" : \"Process history was removed/changed, or its preservation could not be established\", { callId: event.callId, path: op.path });\n\t\t\t\t\t\tif (!depth && !change.concurrent && change.prefixPreserved && savedProgress(change.suffix)) {\n\t\t\t\t\t\t\t// A new JSON line must start at a real line boundary, not finish an old partial record.\n\t\t\t\t\t\t\tlastSaved = event.round; add(\"U07\", event, \"pass\", `Progress exists in the readable process file at response ${event.round}${event.isError ? \"; tool also reported an error\" : \"\"}`, { callId: event.callId, path: op.path });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (event.opaque) { for (const key of known.keys()) uncertain.add(key); known.clear(); reset = true; }\n\t\t\t\tbreak;\n\t\t\tcase \"delivery\": {\n\t\t\t\tconst end = ends.get(event.callId); if (!end || end.isError || end.opaque) break;\n\t\t\t\tfor (const change of end.changes) {\n\t\t\t\t\tconst op = change.operation; if (change.concurrent || !change.after.sha256) continue;\n\t\t\t\t\tif (op.kind === \"read\" && change.completeRead) { known.set(op.path, { state: change.after, sources: new Set([event.callId]) }); uncertain.delete(op.path); }\n\t\t\t\t\tif (op.kind === \"read\" && change.readRange) {\n\t\t\t\t\t\tconst range = change.readRange; let page = pages.get(op.path);\n\t\t\t\t\t\tif (!page || !same(page.state, change.after) || page.total !== range.total) { page = { state: change.after, total: range.total, ranges: [], sources: new Set() }; pages.set(op.path, page); }\n\t\t\t\t\t\tpage.ranges.push([range.start, range.end]); page.sources.add(event.callId);\n\t\t\t\t\t\tlet covered = 0;\n\t\t\t\t\t\tfor (const [start, end] of page.ranges.sort((a, b) => a[0] - b[0])) { if (start > covered) break; covered = Math.max(covered, end); }\n\t\t\t\t\t\tif (covered === page.total) { known.set(op.path, { state: page.state, sources: new Set(page.sources) }); uncertain.delete(op.path); }\n\t\t\t\t\t}\n\t\t\t\t\tif (op.kind === \"modify\" && op.predicted === change.after.sha256) {\n\t\t\t\t\t\tconst prior = starts.get(event.callId)?.get(op.path);\n\t\t\t\t\t\tif (op.independent || change.before.exists === false || same(prior?.state, change.before)) {\n\t\t\t\t\t\t\tknown.set(op.path, { state: change.after, sources: new Set([...(op.independent ? [] : prior?.sources ?? []), event.callId]) }); uncertain.delete(op.path);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"context\": {\n\t\t\t\tconst present = new Set(event.deliveredCalls);\n\t\t\t\tfor (const [key, value] of known) if ([...value.sources].some((id) => !present.has(id))) { known.delete(key); uncertain.add(key); }\n\t\t\t\tfor (const [key, value] of pages) if ([...value.sources].some((id) => !present.has(id))) pages.delete(key);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"reset\": known.clear(); pages.clear(); reset = true; break;\n\t\t\tcase \"boundary\":\n\t\t\t\tif (c.U07 && event.round >= lastSaved + c.U07.every && saveMiss !== lastSaved) {\n\t\t\t\t\tsaveMiss = lastSaved; add(\"U07\", event, \"fail\", `No completed readable progress record by response ${lastSaved + c.U07.every}; inspect tool errors for environmental failures`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase \"settle\": settled = !event.aborted; break;\n\t\t\tcase \"child\": {\n\t\t\t\tif (!event.events.length) coverage(event, \"Child execution has no constraint audit evidence\", [\"A01\", \"A02\", \"A05\", \"A07\"]);\n\t\t\t\telse evidence.push(...verifyConstraintEvents(event.events, experiment, cwd, 1, evaluatedConstraints).evidence.map((row) => ({ ...row, sessionFile: event.sessionFile })));\n\t\t\t\tknown.clear(); reset = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tconst last = events.at(-1);\n\tif (last && (!settled || !events.some((event) => event.kind === \"init\"))) coverage(last, \"Audit session is unfinished or initialization is missing\");\n\tif (last && executing.size) coverage(last, `File/tool executions have no completion evidence: ${[...executing].join(\", \")}`);\n\tconst rules = CONSTRAINT_IDS.filter((id) => c[id] && (!depth || !id.startsWith(\"U\"))).map((id) => {\n\t\tconst items = evidence.filter((item) => item.module === id);\n\t\tconst counts = { pass: 0, fail: 0, insufficient_evidence: 0 };\n\t\tfor (const item of items) counts[item.status]++;\n\t\tconst status: Status = counts.fail ? \"fail\" : counts.insufficient_evidence || !events.length ? \"insufficient_evidence\" : counts.pass ? \"pass\" : \"not_applicable\";\n\t\treturn { id, status, counts, opportunities: items.length };\n\t});\n\treturn { version: 1, verifier: \"scaling-constraints-v1\", evaluatedConstraints, rules, evidence, persistenceAttempts, clock: { round, lastHeartbeat, lastSaved },\n\t\tlimitations: [\"Trusted runtime audit, not tamper-proof sandboxing.\", \"File snapshots are bounded to 2 MiB and are not atomic against external writers.\", \"Opaque shell effects and unsupported delivery formats have incomplete coverage.\", \"Heartbeats verify structure and timing, not truthfulness.\"] };\n}\n\nexport function verifyConstraintSession(source: string, leafId?: string, evaluate?: unknown) {\n\tconst trace = parseSession(source, leafId);\n\tconst experiment = trace.metadata.experiment as ExperimentConfig | undefined;\n\tif (!experiment) throw new Error(\"This session has no scaling experiment metadata; historical traces cannot prove the new constraints\");\n\tconst events = trace.entries.filter((entry) => entry.type === \"custom\" && entry.value.customType === AUDIT_ENTRY).map((entry) => entry.value.data as AuditEvent);\n\tconst requested = evaluate === undefined ? experiment : parseExperiment(evaluate, String(trace.header.cwd), parseScalingConfig(trace.metadata.config));\n\tif (requested.processFile !== experiment.processFile || JSON.stringify(requested.toolProfile) !== JSON.stringify(experiment.toolProfile)) throw new Error(\"Counterfactual rules require the same toolProfile and processFile as the recorded experiment\");\n\tconst report = verifyConstraintEvents(events, experiment, String(trace.header.cwd), Number(trace.metadata.depth ?? 0), requested.constraints);\n\tif (trace.issues.some((issue) => issue.startsWith(\"missing_parent:\"))) for (const rule of report.rules) if (rule.status !== \"fail\") rule.status = \"insufficient_evidence\";\n\treturn { ...report, session: { id: trace.header.id, leafId: trace.leafId }, experiment };\n}\n", "import path from \"node:path\";\nimport type { ScalingConfig } from \"../config.js\";\n\nexport const CONSTRAINT_IDS = [\"A02\", \"A05\", \"A01\", \"U02\", \"U07\", \"A07\"] as const;\nexport type ConstraintId = typeof CONSTRAINT_IDS[number];\nexport interface ExperimentConfig {\n\tversion: 1;\n\ttoolProfile: { readFileAlias: boolean; appendFile: boolean; prepareProcessFile: boolean };\n\tprocessFile: string;\n\tconstraints: {\n\t\tA02?: Record<string, never>; A05?: Record<string, never>; A07?: Record<string, never>;\n\t\tA01?: { forbiddenTools: string[]; mode: \"audit\" | \"block\" };\n\t\tU02?: { every: number }; U07?: { every: number };\n\t};\n}\nfunction record(value: unknown): Record<string, unknown> {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) throw new Error(\"Experiment fields must be objects\");\n\treturn value as Record<string, unknown>;\n}\nfunction keys(value: Record<string, unknown>, allowed: readonly string[]): void {\n\tfor (const key of Object.keys(value)) if (!allowed.includes(key)) throw new Error(`Unknown experiment field: ${key}`);\n}\nexport function parseExperiment(input: unknown, cwd: string, config: ScalingConfig): ExperimentConfig {\n\tconst value = record(input); keys(value, [\"version\", \"toolProfile\", \"processFile\", \"constraints\"]);\n\tif (value.version !== 1) throw new Error(\"scaling experiment version must be 1\");\n\tconst profile = record(value.toolProfile ?? {}); keys(profile, [\"readFileAlias\", \"appendFile\", \"prepareProcessFile\"]);\n\tfor (const flag of Object.values(profile)) if (typeof flag !== \"boolean\") throw new Error(\"Tool profile flags must be booleans\");\n\tif (profile.readFileAlias && config.TS !== \"TS2\") throw new Error(\"readFileAlias requires TS2, which already provides read; no implicit TS1/TS3 capability change\");\n\tconst constraints = record(value.constraints ?? {}); keys(constraints, CONSTRAINT_IDS);\n\tconst result: ExperimentConfig = {\n\t\tversion: 1, toolProfile: { readFileAlias: profile.readFileAlias === true, appendFile: profile.appendFile === true, prepareProcessFile: profile.prepareProcessFile === true },\n\t\tprocessFile: typeof value.processFile === \"string\" ? value.processFile : path.resolve(cwd, \".scaling-progress.jsonl\"), constraints: {},\n\t};\n\tif (value.processFile !== undefined && typeof value.processFile !== \"string\" || !path.isAbsolute(result.processFile)) throw new Error(\"processFile must be an absolute path\");\n\tresult.processFile = path.normalize(result.processFile);\n\tfor (const id of CONSTRAINT_IDS) {\n\t\tif (constraints[id] === undefined) continue;\n\t\tconst options = record(constraints[id]);\n\t\tif (id === \"U02\" || id === \"U07\") {\n\t\t\tkeys(options, [\"every\"]);\n\t\t\tif (!Number.isSafeInteger(options.every) || Number(options.every) < 1) throw new Error(`${id}.every must be a positive integer`);\n\t\t\tif (config.C === \"C2\" && Number(options.every) < 3) throw new Error(`${id}.every must be at least 3 with C2's two exclusive handoff responses`);\n\t\t\tresult.constraints[id] = { every: Number(options.every) };\n\t\t} else if (id === \"A01\") {\n\t\t\tkeys(options, [\"forbiddenTools\", \"mode\"]);\n\t\t\tif (!Array.isArray(options.forbiddenTools) || !options.forbiddenTools.length || !options.forbiddenTools.every((name) => typeof name === \"string\" && /^[a-zA-Z_][\\w.-]*$/u.test(name))) throw new Error(\"A01.forbiddenTools must contain registered tool IDs\");\n\t\t\tif (options.mode !== undefined && options.mode !== \"audit\" && options.mode !== \"block\") throw new Error(\"A01.mode must be audit or block\");\n\t\t\tresult.constraints.A01 = { forbiddenTools: [...new Set(options.forbiddenTools as string[])].sort(), mode: options.mode ?? \"audit\" };\n\t\t} else { keys(options, []); result.constraints[id] = {}; }\n\t}\n\treturn result;\n}\n\nexport function experimentPrompt(experiment: ExperimentConfig, depth: number): string {\n\tconst { constraints: c, processFile } = experiment;\n\tconst rows: string[] = [];\n\tconst add = (id: ConstraintId, text: string) => { if (c[id] && (!depth || !id.startsWith(\"U\"))) rows.push(`## Optional constraint [${id}]\\n\\n${text}`); };\n\tadd(\"A02\", `Maintain the process document at ${JSON.stringify(processFile)}. At every completed logical file modification, preserve all previous bytes in their original order and only add content at the end. write, edit, apply_patch, shell, and append_file (if available) may be used when they preserve that prefix. Do not delete the file or erase and later restore history. Internal truncate-and-rewrite within a single write operation is allowed if its final contents preserve the prefix.`);\n\tadd(\"A05\", \"Before first modifying an existing file, obtain its complete current contents through completed reads delivered in your context. A partial or truncated read is insufficient. Reuse the full contents and your own confirmed, deterministic edits from the current context for later modifications; no version parameter or repeated full read is required. When the resulting contents are uncertain, an external change is observed, or exact context is lost, inspect again. Supplying a new file's entire contents establishes knowledge of that new file. Merely running a script or receiving a success/hash does not establish knowledge of its resulting contents. Applies to every modified target, including patch moves and shell writes. In code orchestration, emit the complete read result and wait for the next model response before deciding an edit from that result.\");\n\tadd(\"A01\", `Do not attempt calls to these registered tool IDs: ${c.A01?.forbiddenTools.join(\", \")}. This includes nested calls, wrappers, and children; rejected attempts also violate the rule. Equivalent independently registered tools remain usable if declared (for example read_file instead of read).`);\n\tconst payload = '{\"done\":[\"completed work\"],\"next\":[\"next action\"],\"blockers\":[]}';\n\tadd(\"U02\", `Emit a visible standalone <heartbeat>${payload}</heartbeat> outside quotations and code fences within your first ${c.U02?.every} main-model responses and at most ${c.U02?.every} responses after each valid heartbeat. Reporting early resets the deadline. Tool-calling responses count; tool results, summaries, and child responses do not. Do not supply round numbers. Use arrays of strings for done, next, blockers, with at least one substantive item. On C2 report early enough to leave room for the two exclusive handoff responses. This checks structure and timing, not the truth of progress claims.`);\n\tadd(\"U07\", `Save progress by adding one JSON line such as ${payload} to ${JSON.stringify(processFile)} within your first ${c.U07?.every} main-model responses and at most ${c.U07?.every} responses after each completed valid save. Reporting early resets this independent deadline. The write must complete and the record must be readable by the end of the due response's tool operations. Later backfilling cannot repair a missed deadline. A write containing all old bytes plus the new record is allowed. A visible heartbeat alone does not save a record. Tool-calling responses count; summaries and child responses do not. On C2 save early before the exclusive handoff responses.`);\n\tadd(\"A07\", \"Use absolute paths in every submitted file-operation path argument, including read/search roots, source and destination paths, arrays, patch headers and moves, and shell file operands. Tool normalization or the working directory does not satisfy this requirement. Search patterns and ordinary file contents are not path arguments.\");\n\tif (!depth && (c.A02 || c.U07)) rows.push(`The harness prepares the process file at ${JSON.stringify(processFile)} without overwriting existing contents. During W2 planning, only direct write/edit/append_file operations targeting this exact process file are additionally allowed; other project writes still require the normal plan transition.`);\n\treturn rows.join(\"\\n\\n\");\n}\n", "export const SCALING_AXES = [\"S\", \"TS\", \"TC\", \"O\", \"C\", \"W\"] as const;\nexport type ScalingAxis = typeof SCALING_AXES[number];\nexport type ScalingConfig = { [K in ScalingAxis]: `${K}${1 | 2 | 3}` };\n\n/** Frozen OA(18, 3^6, 2) from the Components \u00D7 Design survey. */\nconst ROWS = [\n\t[1, 1, 1, 1, 1, 1], [1, 2, 3, 2, 2, 2], [1, 3, 1, 3, 3, 3],\n\t[2, 1, 1, 1, 2, 2], [2, 2, 1, 2, 3, 3], [2, 3, 3, 3, 1, 1],\n\t[3, 1, 3, 2, 1, 3], [3, 2, 1, 3, 2, 1], [3, 3, 2, 1, 3, 2],\n\t[1, 1, 3, 3, 3, 2], [1, 2, 2, 1, 1, 3], [1, 3, 2, 2, 2, 1],\n\t[2, 1, 2, 2, 3, 1], [2, 2, 2, 3, 1, 2], [2, 3, 3, 1, 2, 3],\n\t[3, 1, 2, 3, 2, 3], [3, 2, 3, 1, 3, 1], [3, 3, 1, 2, 1, 2],\n] as const;\n\nexport const SCALING_PRESETS: Readonly<Record<string, ScalingConfig>> = Object.freeze(\n\tObject.fromEntries(ROWS.map((row, index) => [\n\t\t`H${String(index + 1).padStart(2, \"0\")}`,\n\t\tObject.freeze(Object.fromEntries(SCALING_AXES.map((axis, i) => [axis, `${axis}${row[i]}`])) as ScalingConfig),\n\t])),\n);\n\nexport function parseScalingConfig(value: unknown): ScalingConfig {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) {\n\t\tthrow new Error(\"Scaling config must be an object with S, TS, TC, O, C, W.\");\n\t}\n\tconst record = value as Record<string, unknown>;\n\tfor (const key of Object.keys(record)) {\n\t\tif (!(SCALING_AXES as readonly string[]).includes(key)) throw new Error(`Unknown scaling axis: ${key}`);\n\t}\n\tfor (const axis of SCALING_AXES) {\n\t\tif (![`${axis}1`, `${axis}2`, `${axis}3`].includes(String(record[axis]))) {\n\t\t\tthrow new Error(`Invalid ${axis} design: ${String(record[axis])}. Choose ${axis}1\u2013${axis}3; TC4 is excluded.`);\n\t\t}\n\t}\n\treturn Object.fromEntries(SCALING_AXES.map((axis) => [axis, record[axis]])) as ScalingConfig;\n}\n\nexport function scalingConfigId(config: ScalingConfig): string {\n\treturn SCALING_AXES.map((axis) => config[axis]).join(\"-\");\n}\n\nexport interface ScalingLimits {\n\tpreviewChars: number;\n\thardOutputChars: number;\n\tcontextTriggerRatio: number;\n\tcontextHardRatio: number;\n\tkeepRecentTokens: number;\n\t/** Desired checkpoint size; generation uses the selected model's output limit. */\n\tsummaryTokens: number;\n\trollupFanout: number;\n}\n\nexport const DEFAULT_SCALING_LIMITS: Readonly<ScalingLimits> = Object.freeze({\n\tpreviewChars: 8_000,\n\thardOutputChars: 64_000,\n\tcontextTriggerRatio: 0.75,\n\tcontextHardRatio: 0.9,\n\tkeepRecentTokens: 8_000,\n\tsummaryTokens: 1_024,\n\trollupFanout: 3,\n});\n\nexport function scalingLimits(overrides: unknown = {}): ScalingLimits {\n\tif (!overrides || typeof overrides !== \"object\" || Array.isArray(overrides)) {\n\t\tthrow new Error(\"Scaling limits must be an object\");\n\t}\n\tfor (const name of Object.keys(overrides)) {\n\t\tif (!Object.hasOwn(DEFAULT_SCALING_LIMITS, name)) throw new Error(`Unknown scaling limit: ${name}`);\n\t}\n\tconst limits = { ...DEFAULT_SCALING_LIMITS, ...overrides as Partial<ScalingLimits> };\n\tfor (const [name, value] of Object.entries(limits)) {\n\t\tif (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0) throw new Error(`Invalid scaling limit ${name}`);\n\t\tif (!name.endsWith(\"Ratio\") && !Number.isSafeInteger(value)) throw new Error(`Scaling limit ${name} must be an integer`);\n\t}\n\tif (limits.previewChars < 100 || limits.previewChars > limits.hardOutputChars\n\t\t|| limits.contextTriggerRatio >= limits.contextHardRatio || limits.contextHardRatio >= 1\n\t\t|| limits.rollupFanout < 2) throw new Error(\"Inconsistent scaling limits\");\n\treturn limits;\n}\n", "import type { ExperimentConfig } from \"./config.js\";\n\nexport const AUDIT_ENTRY = \"scaling-constraint-event\";\nexport interface FileState { exists?: boolean; sha256?: string; bytes?: number; identity?: string; error?: string }\nexport interface FileOperation { path: string; kind: \"read\" | \"modify\" | \"monitor\"; predicted?: string; independent?: boolean; rawPath: string }\nexport interface FileChange {\n\toperation: FileOperation; before: FileState; after: FileState;\n\tconcurrent: boolean; prefixPreserved?: boolean; suffix?: string;\n\tcompleteRead?: boolean;\n\treadRange?: { start: number; end: number; total: number };\n}\nexport type AuditData =\n\t| { kind: \"init\"; experiment: ExperimentConfig }\n\t| { kind: \"response\"; text: string }\n\t| { kind: \"attempt\"; callId: string; name: string; args: unknown; parentId?: string }\n\t| { kind: \"start\"; callId: string; name: string; operations: { operation: FileOperation; before: FileState }[]; opaque: boolean }\n\t| { kind: \"end\"; callId: string; name: string; changes: FileChange[]; isError: boolean; opaque: boolean }\n\t| { kind: \"delivery\"; callId: string }\n\t| { kind: \"context\"; deliveredCalls: string[] }\n\t| { kind: \"boundary\" }\n\t| { kind: \"reset\"; reason: string }\n\t| { kind: \"settle\"; aborted: boolean }\n\t| { kind: \"child\"; sessionFile?: string; events: AuditEvent[] };\nexport type AuditEvent = AuditData & { version: 1; seq: number; round: number; depth: number; timestamp: number };\n", "import path from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport { parseApplyPatch, applyUpdate } from \"../../../utils/filesystem/apply_patch.js\";\nimport type { FileOperation } from \"./events.js\";\n\nexport const sha256 = (value: string | Buffer): string => createHash(\"sha256\").update(value).digest(\"hex\");\nexport const object = (value: unknown): Record<string, unknown> => value && typeof value === \"object\" && !Array.isArray(value) ? value as Record<string, unknown> : {};\nexport interface OperationPlan { operations: FileOperation[]; paths: string[]; opaque: boolean }\n\n/** Literal argv only. Expansion, pipelines and multiple commands remain explicitly uncovered. */\nexport function literalShell(command: string): string[] | undefined {\n\tconst words: string[] = []; let word = \"\"; let quote = \"\"; let started = false;\n\tconst flush = () => { if (started) words.push(word); word = \"\"; started = false; };\n\tfor (let i = 0; i < command.length; i++) {\n\t\tconst ch = command[i]!;\n\t\tif (quote) {\n\t\t\tif (ch === quote) quote = \"\";\n\t\t\telse if (quote === '\"' && /[$`\\\\]/u.test(ch)) return;\n\t\t\telse word += ch;\n\t\t\tcontinue;\n\t\t}\n\t\tif (/[;|&<`$(){}*?\\[\\]\\\\\\n\\r]/u.test(ch)) return;\n\t\tif (ch === \"'\" || ch === '\"') { quote = ch; started = true; }\n\t\telse if (/\\s/u.test(ch)) flush();\n\t\telse if (ch === \">\") { flush(); words.push(command[i + 1] === \">\" ? (i++, \">>\") : \">\"); }\n\t\telse { word += ch; started = true; }\n\t}\n\tif (quote) return;\n\tflush(); return words;\n}\n\nexport function operationPlan(name: string, input: unknown, cwd: string): OperationPlan {\n\tconst args = object(input); const operations: FileOperation[] = []; const paths: string[] = [];\n\tlet opaque = false;\n\tconst target = (raw: unknown, kind?: FileOperation[\"kind\"], predicted?: string, independent = false) => {\n\t\tif (typeof raw !== \"string\") { opaque = true; return; }\n\t\tpaths.push(raw);\n\t\tif (name === \"bash\" && (/^~/u.test(raw) || raw.split(\"/\").includes(\"..\"))) opaque = true;\n\t\tif ([\"read\", \"read_file\", \"write\", \"edit\", \"grep\", \"glob\"].includes(name) && (!raw || /^[@~]/u.test(raw) || /[\\u00a0\\u2000-\\u200a\\u202f\\u205f\\u3000]/u.test(raw))) opaque = true;\n\t\tif (kind) operations.push({ path: path.resolve(cwd, raw), rawPath: raw, kind, predicted, independent });\n\t};\n\tif ([\"read\", \"read_file\"].includes(name)) target(args.path, \"read\");\n\telse if (name === \"write\") target(args.path, \"modify\", typeof args.content === \"string\" ? sha256(args.content) : undefined, true);\n\telse if ([\"edit\", \"append_file\"].includes(name)) target(args.path, \"modify\");\n\telse if (name === \"grep\" || name === \"glob\") target(args.path ?? \".\");\n\telse if (name === \"apply_patch\") {\n\t\ttry {\n\t\t\tfor (const hunk of parseApplyPatch(String(args.patch))) {\n\t\t\t\ttarget(hunk.path, \"modify\", hunk.type === \"add\" ? sha256(hunk.contents) : undefined, hunk.type === \"add\");\n\t\t\t\tif (hunk.type === \"update\" && hunk.movePath) target(hunk.movePath, \"modify\");\n\t\t\t}\n\t\t} catch { opaque = true; }\n\t\tif (new Set(operations.map((op) => op.path)).size !== operations.length) opaque = true;\n\t} else if (name === \"bash\") {\n\t\tconst argv = literalShell(String(args.command));\n\t\tif (!argv?.length) return { operations, paths, opaque: true };\n\t\tconst [command, ...rest] = argv;\n\t\tconst redirect = rest.findIndex((s) => s === \">\" || s === \">>\");\n\t\tif (redirect >= 0) {\n\t\t\tconst raw = rest[redirect + 1];\n\t\t\tconst params = rest.slice(0, redirect);\n\t\t\tlet content: string | undefined;\n\t\t\tif (command === \"printf\" && params.length === 2 && [\"%s\", \"%s\\\\n\"].includes(params[0]!)) content = params[1] + (params[0] === \"%s\\\\n\" ? \"\\n\" : \"\");\n\t\t\tif (rest.length !== redirect + 2 || content === undefined) opaque = true;\n\t\t\ttarget(raw, \"modify\", rest[redirect] === \">\" && content !== undefined ? sha256(content) : undefined, rest[redirect] === \">\");\n\t\t} else if (command === \"cat\" && rest.length === 1 && !rest[0]!.startsWith(\"-\")) target(rest[0], \"read\");\n\t\telse if (command === \"pwd\" && rest.length === 0) { /* no file operand */ }\n\t\telse if ([\"cp\", \"mv\", \"rm\", \"touch\", \"truncate\"].includes(command!)) {\n\t\t\t// Paths are auditable; arbitrary flags/directory recursion have incomplete file coverage.\n\t\t\tif (rest.every((arg) => !arg.startsWith(\"-\") || /^(?:--|-[finvrRpa]+|--(?:force|recursive|verbose|no-clobber))$/u.test(arg))) {\n\t\t\t\tfor (const arg of rest) if (!arg.startsWith(\"-\")) target(arg);\n\t\t\t}\n\t\t\topaque = true;\n\t\t} else if ([\"ls\", \"cat\", \"head\", \"tail\", \"wc\", \"sha256sum\", \"grep\", \"rg\", \"sed\"].includes(command!)) {\n\t\t\tlet skip = false; let pattern = [\"grep\", \"rg\", \"sed\"].includes(command!); let options = true;\n\t\t\tfor (const arg of rest) {\n\t\t\t\tif (skip) { skip = false; continue; }\n\t\t\t\tif (arg === \"--\" && options) { options = false; continue; }\n\t\t\t\tif (options && arg.startsWith(\"-\")) {\n\t\t\t\t\tif ([\"-n\", \"-c\", \"--lines\", \"--bytes\"].includes(arg) && [\"head\", \"tail\"].includes(command!)) skip = true;\n\t\t\t\t\telse if ([\"-e\", \"--regexp\"].includes(arg) && [\"grep\", \"rg\"].includes(command!)) { skip = true; pattern = false; }\n\t\t\t\t\telse if ([\"-g\", \"--glob\", \"--iglob\", \"-t\", \"--type\", \"--type-not\", \"-m\", \"--max-count\", \"-A\", \"-B\", \"-C\"].includes(arg)) skip = true;\n\t\t\t\t\telse if (arg === \"--files\" && command === \"rg\") pattern = false;\n\t\t\t\t\telse if (!/^(?:-[alhRnriHvc]+|--(?:hidden|no-heading|line-number))$/u.test(arg)) opaque = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (pattern) { pattern = false; continue; }\n\t\t\t\ttarget(arg);\n\t\t\t}\n\t\t\t// Only the full single-file cat above establishes complete-content evidence.\n\t\t\tif ([\"ls\", \"rg\"].includes(command!) && !paths.length) target(\".\");\n\t\t\tif (command === \"sed\" || rest.some((arg) => /^--(?:pre|hostname-bin)/u.test(arg))) opaque = true;\n\t\t} else opaque = true;\n\t} else if (![\"exec\", \"run_code\", \"submit_plan\", \"session_notes\", \"new_context\", \"session_history\", \"memory_lookup\", \"get_context_remaining\", \"subagent\"].includes(name)) opaque = true;\n\treturn { operations, paths, opaque };\n}\n\n/** Prediction uses submitted changes and the sampled base, never a success message's hash. */\nexport function predictContents(name: string, input: unknown, rawPath: string, before: Buffer | undefined): string | undefined {\n\tconst args = object(input);\n\tif (name === \"write\" && typeof args.content === \"string\") return args.content;\n\tif (name === \"append_file\" && typeof args.content === \"string\" && before) return before.toString(\"utf8\") + args.content;\n\tif (name === \"bash\") {\n\t\tconst argv = literalShell(String(args.command));\n\t\tif (argv?.[0] === \"printf\" && argv.length === 5 && [\"%s\", \"%s\\\\n\"].includes(argv[1]!)) {\n\t\t\tconst suffix = argv[2] + (argv[1] === \"%s\\\\n\" ? \"\\n\" : \"\");\n\t\t\treturn argv[3] === \">\" ? suffix : before ? before.toString(\"utf8\") + suffix : undefined;\n\t\t}\n\t}\n\tif (name === \"edit\" && before && Array.isArray(args.edits)) {\n\t\tconst original = before.toString(\"utf8\");\n\t\tconst bom = original.startsWith(\"\\uFEFF\") ? \"\\uFEFF\" : \"\";\n\t\tconst crlf = original.includes(\"\\r\\n\");\n\t\tconst content = original.slice(bom.length).replaceAll(\"\\r\\n\", \"\\n\");\n\t\tconst edits: { start: number; old: string; replacement: string }[] = [];\n\t\tfor (const raw of args.edits) {\n\t\t\tconst edit = object(raw);\n\t\t\tif (typeof edit.oldText !== \"string\" || !edit.oldText || typeof edit.newText !== \"string\") return;\n\t\t\tconst old = edit.oldText.replaceAll(\"\\r\\n\", \"\\n\"); const start = content.indexOf(old);\n\t\t\tif (start < 0 || content.indexOf(old, start + 1) >= 0) return;\n\t\t\tedits.push({ start, old, replacement: edit.newText.replaceAll(\"\\r\\n\", \"\\n\") });\n\t\t}\n\t\tedits.sort((a, b) => b.start - a.start); let result = content; let end = content.length;\n\t\tfor (const edit of edits) { if (edit.start + edit.old.length > end) return; result = result.slice(0, edit.start) + edit.replacement + result.slice(edit.start + edit.old.length); end = edit.start; }\n\t\treturn bom + (crlf ? result.replaceAll(\"\\n\", \"\\r\\n\") : result);\n\t}\n\tif (name === \"apply_patch\") {\n\t\ttry {\n\t\t\tconst hunks = parseApplyPatch(String(args.patch)).filter((hunk) => hunk.path === rawPath);\n\t\t\tif (hunks.length !== 1) return;\n\t\t\tconst hunk = hunks[0]!;\n\t\t\tif (hunk.type === \"add\") return hunk.contents;\n\t\t\tif (hunk.type === \"update\" && !hunk.movePath && before) return applyUpdate(before.toString(\"utf8\"), rawPath, hunk.chunks);\n\t\t} catch { /* unsupported or rejected patch */ }\n\t}\n\treturn undefined;\n}\n", "import { mkdir, readFile, stat, unlink, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nimport { resolveWorkspacePath } from \"../workspace.js\";\n\nconst BEGIN_PATCH_MARKER = \"*** Begin Patch\";\nconst END_PATCH_MARKER = \"*** End Patch\";\nconst ADD_FILE_MARKER = \"*** Add File: \";\nconst DELETE_FILE_MARKER = \"*** Delete File: \";\nconst UPDATE_FILE_MARKER = \"*** Update File: \";\nconst MOVE_TO_MARKER = \"*** Move to: \";\nconst END_OF_FILE_MARKER = \"*** End of File\";\n\ninterface AddFileHunk {\n\ttype: \"add\";\n\tpath: string;\n\tcontents: string;\n}\n\ninterface DeleteFileHunk {\n\ttype: \"delete\";\n\tpath: string;\n}\n\ninterface UpdateFileChunk {\n\tchangeContext?: string;\n\toldLines: string[];\n\tnewLines: string[];\n\tcontextLineIndices: Array<[number, number]>;\n\tisEndOfFile: boolean;\n}\n\ninterface UpdateFileHunk {\n\ttype: \"update\";\n\tpath: string;\n\tmovePath?: string;\n\tchunks: UpdateFileChunk[];\n}\n\nexport type ApplyPatchHunk = AddFileHunk | DeleteFileHunk | UpdateFileHunk;\n\nexport interface ApplyPatchAffectedPaths {\n\tadded: string[];\n\tmodified: string[];\n\tdeleted: string[];\n}\n\nexport interface ApplyPatchResult extends ApplyPatchAffectedPaths {\n\tsummary: string;\n}\n\ninterface SourceLine {\n\ttext: string;\n\tending?: \"\\n\" | \"\\r\\n\" | \"\\r\";\n}\n\ninterface SourceFile {\n\tlines: SourceLine[];\n\tpreferredEnding: \"\\n\" | \"\\r\\n\" | \"\\r\";\n}\n\ninterface Replacement {\n\tstart: number;\n\toldLength: number;\n\tnewLines: string[];\n}\n\nfunction patchError(message: string): Error {\n\treturn new Error(`Invalid patch: ${message}`);\n}\n\nfunction hunkError(lineNumber: number, message: string): Error {\n\treturn new Error(`Invalid patch hunk on line ${lineNumber}: ${message}`);\n}\n\nfunction parsePatchLines(patch: string): string[] {\n\tconst trimmed = patch.trim();\n\tconst lines = trimmed ? trimmed.split(\"\\n\") : [];\n\treturn lines.map((line) => line.endsWith(\"\\r\") ? line.slice(0, -1) : line);\n}\n\nfunction parsePath(header: string, marker: string, lineNumber: number): string {\n\tconst value = header.slice(marker.length);\n\tif (!value) throw hunkError(lineNumber, `Missing path after '${marker.trimEnd()}'`);\n\treturn value;\n}\n\nfunction newChunk(changeContext?: string): UpdateFileChunk {\n\treturn {\n\t\t...(changeContext === undefined ? {} : { changeContext }),\n\t\toldLines: [],\n\t\tnewLines: [],\n\t\tcontextLineIndices: [],\n\t\tisEndOfFile: false,\n\t};\n}\n\nfunction chunkIsEmpty(chunk: UpdateFileChunk): boolean {\n\treturn chunk.oldLines.length === 0 && chunk.newLines.length === 0;\n}\n\nfunction pushContextLine(chunk: UpdateFileChunk, line: string): void {\n\tchunk.contextLineIndices.push([chunk.oldLines.length, chunk.newLines.length]);\n\tchunk.oldLines.push(line);\n\tchunk.newLines.push(line);\n}\n\nfunction isHunkHeader(line: string): boolean {\n\treturn line.startsWith(ADD_FILE_MARKER)\n\t\t|| line.startsWith(DELETE_FILE_MARKER)\n\t\t|| line.startsWith(UPDATE_FILE_MARKER);\n}\n\nexport function parseApplyPatch(patch: string): ApplyPatchHunk[] {\n\tconst lines = parsePatchLines(patch);\n\tconst first = lines[0]?.trim();\n\tconst last = lines.at(-1)?.trim();\n\tif (first !== BEGIN_PATCH_MARKER) {\n\t\tthrow patchError(`The first line of the patch must be '${BEGIN_PATCH_MARKER}'`);\n\t}\n\tif (last !== END_PATCH_MARKER) {\n\t\tthrow patchError(`The last line of the patch must be '${END_PATCH_MARKER}'`);\n\t}\n\n\tconst hunks: ApplyPatchHunk[] = [];\n\tlet index = 1;\n\tconst endIndex = lines.length - 1;\n\twhile (index < endIndex) {\n\t\tconst rawHeader = lines[index] ?? \"\";\n\t\tconst header = rawHeader.trim();\n\t\tconst lineNumber = index + 1;\n\t\tif (header.startsWith(ADD_FILE_MARKER)) {\n\t\t\tconst filePath = parsePath(header, ADD_FILE_MARKER, lineNumber);\n\t\t\tindex += 1;\n\t\t\tconst content: string[] = [];\n\t\t\twhile (index < endIndex) {\n\t\t\t\tconst line = lines[index] ?? \"\";\n\t\t\t\tif (isHunkHeader(line.trim())) break;\n\t\t\t\tif (!line.startsWith(\"+\")) {\n\t\t\t\t\tthrow hunkError(\n\t\t\t\t\t\tindex + 1,\n\t\t\t\t\t\t`Invalid Add File line for '${filePath}': '${line}'. Every added line must start with '+'`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tcontent.push(line.slice(1));\n\t\t\t\tindex += 1;\n\t\t\t}\n\t\t\tif (content.length === 0) {\n\t\t\t\tthrow hunkError(lineNumber, `Add file hunk for path '${filePath}' is empty`);\n\t\t\t}\n\t\t\thunks.push({ type: \"add\", path: filePath, contents: `${content.join(\"\\n\")}\\n` });\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (header.startsWith(DELETE_FILE_MARKER)) {\n\t\t\thunks.push({\n\t\t\t\ttype: \"delete\",\n\t\t\t\tpath: parsePath(header, DELETE_FILE_MARKER, lineNumber),\n\t\t\t});\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (header.startsWith(UPDATE_FILE_MARKER)) {\n\t\t\tconst filePath = parsePath(header, UPDATE_FILE_MARKER, lineNumber);\n\t\t\tindex += 1;\n\t\t\tlet movePath: string | undefined;\n\t\t\tconst possibleMove = lines[index]?.trim();\n\t\t\tif (possibleMove?.startsWith(MOVE_TO_MARKER)) {\n\t\t\t\tmovePath = parsePath(possibleMove, MOVE_TO_MARKER, index + 1);\n\t\t\t\tindex += 1;\n\t\t\t}\n\n\t\t\tconst chunks: UpdateFileChunk[] = [];\n\t\t\tlet active: UpdateFileChunk | undefined;\n\t\t\twhile (index < endIndex) {\n\t\t\t\tconst line = lines[index] ?? \"\";\n\t\t\t\tconst updateLine = line.trimEnd();\n\t\t\t\tif (isHunkHeader(updateLine)) break;\n\t\t\t\tconst currentLineNumber = index + 1;\n\n\t\t\t\tif (active?.isEndOfFile) {\n\t\t\t\t\tif (!updateLine) {\n\t\t\t\t\t\tindex += 1;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tif (updateLine !== \"@@\" && !updateLine.startsWith(\"@@ \")) {\n\t\t\t\t\t\tthrow hunkError(\n\t\t\t\t\t\t\tcurrentLineNumber,\n\t\t\t\t\t\t\t`Expected update hunk to start with a @@ context marker, got: '${line}'`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (updateLine === \"@@\" || updateLine.startsWith(\"@@ \")) {\n\t\t\t\t\tif (active && chunkIsEmpty(active)) {\n\t\t\t\t\t\tthrow hunkError(currentLineNumber, \"Update hunk does not contain any lines\");\n\t\t\t\t\t}\n\t\t\t\t\tactive = newChunk(updateLine === \"@@\" ? undefined : updateLine.slice(3));\n\t\t\t\t\tchunks.push(active);\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (updateLine === END_OF_FILE_MARKER) {\n\t\t\t\t\tif (!active || chunkIsEmpty(active)) {\n\t\t\t\t\t\tthrow hunkError(currentLineNumber, \"Update hunk does not contain any lines\");\n\t\t\t\t\t}\n\t\t\t\t\tactive.isEndOfFile = true;\n\t\t\t\t\tindex += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tactive ??= newChunk();\n\t\t\t\tif (!chunks.includes(active)) chunks.push(active);\n\t\t\t\tif (line === \"\") {\n\t\t\t\t\tpushContextLine(active, \"\");\n\t\t\t\t} else if (line.startsWith(\" \")) {\n\t\t\t\t\tpushContextLine(active, line.slice(1));\n\t\t\t\t} else if (line.startsWith(\"+\")) {\n\t\t\t\t\tactive.newLines.push(line.slice(1));\n\t\t\t\t} else if (line.startsWith(\"-\")) {\n\t\t\t\t\tactive.oldLines.push(line.slice(1));\n\t\t\t\t} else {\n\t\t\t\t\tthrow hunkError(\n\t\t\t\t\t\tcurrentLineNumber,\n\t\t\t\t\t\t`Unexpected line found in update hunk: '${line}'. Every line should start with ' ' (context line), '+' (added line), or '-' (removed line)`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tindex += 1;\n\t\t\t}\n\n\t\t\tif (active && chunkIsEmpty(active)) {\n\t\t\t\tthrow hunkError(lineNumber, `Update file hunk for path '${filePath}' is empty`);\n\t\t\t}\n\t\t\tif (chunks.length === 0 && movePath === undefined) {\n\t\t\t\tthrow hunkError(lineNumber, `Update file hunk for path '${filePath}' is empty`);\n\t\t\t}\n\t\t\thunks.push({\n\t\t\t\ttype: \"update\",\n\t\t\t\tpath: filePath,\n\t\t\t\t...(movePath === undefined ? {} : { movePath }),\n\t\t\t\tchunks,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow hunkError(\n\t\t\tlineNumber,\n\t\t\t`'${rawHeader}' is not a valid hunk header. Valid hunk headers: ` +\n\t\t\t\t`'*** Add File: {path}', '*** Delete File: {path}', '*** Update File: {path}'`,\n\t\t);\n\t}\n\n\treturn hunks;\n}\n\nfunction parseSourceFile(contents: string): SourceFile {\n\tconst lines: SourceLine[] = [];\n\tlet preferredEnding: SourceFile[\"preferredEnding\"] | undefined;\n\tlet lineStart = 0;\n\tlet cursor = 0;\n\twhile (cursor < contents.length) {\n\t\tlet ending: SourceLine[\"ending\"];\n\t\tlet endingLength = 0;\n\t\tif (contents[cursor] === \"\\r\" && contents[cursor + 1] === \"\\n\") {\n\t\t\tending = \"\\r\\n\";\n\t\t\tendingLength = 2;\n\t\t} else if (contents[cursor] === \"\\r\") {\n\t\t\tending = \"\\r\";\n\t\t\tendingLength = 1;\n\t\t} else if (contents[cursor] === \"\\n\") {\n\t\t\tending = \"\\n\";\n\t\t\tendingLength = 1;\n\t\t} else {\n\t\t\tcursor += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tpreferredEnding ??= ending;\n\t\tlines.push({ text: contents.slice(lineStart, cursor), ending });\n\t\tcursor += endingLength;\n\t\tlineStart = cursor;\n\t}\n\tif (lineStart < contents.length) lines.push({ text: contents.slice(lineStart) });\n\treturn { lines, preferredEnding: preferredEnding ?? \"\\n\" };\n}\n\nfunction normalizedPunctuation(value: string): string {\n\tconst replacements: Readonly<Record<string, string>> = {\n\t\t\"\u2010\": \"-\", \"\u2011\": \"-\", \"\u2012\": \"-\", \"\u2013\": \"-\", \"\u2014\": \"-\", \"\u2015\": \"-\", \"\u2212\": \"-\",\n\t\t\"\u2018\": \"'\", \"\u2019\": \"'\", \"\u201A\": \"'\", \"\u201B\": \"'\",\n\t\t\"\u201C\": \"\\\"\", \"\u201D\": \"\\\"\", \"\u201E\": \"\\\"\", \"\u201F\": \"\\\"\",\n\t\t\"\u00A0\": \" \", \"\u2002\": \" \", \"\u2003\": \" \", \"\u2004\": \" \", \"\u2005\": \" \", \"\u2006\": \" \", \"\u2007\": \" \",\n\t\t\"\u2008\": \" \", \"\u2009\": \" \", \"\u200A\": \" \", \"\u202F\": \" \", \"\u205F\": \" \", \"\u3000\": \" \",\n\t};\n\treturn [...value.trim()].map((character) => replacements[character] ?? character).join(\"\");\n}\n\nfunction seekSequence(\n\tlines: readonly string[],\n\tpattern: readonly string[],\n\tstart: number,\n\tendOfFile: boolean,\n): number | undefined {\n\tif (pattern.length === 0) return start;\n\tif (pattern.length > lines.length) return undefined;\n\tconst lastStart = lines.length - pattern.length;\n\tconst searchStart = endOfFile ? Math.max(start, lastStart) : start;\n\tif (searchStart > lastStart) return undefined;\n\n\tconst matchers: Array<(left: string, right: string) => boolean> = [\n\t\t(left, right) => left === right,\n\t\t(left, right) => left.trimEnd() === right.trimEnd(),\n\t\t(left, right) => left.trim() === right.trim(),\n\t\t(left, right) => normalizedPunctuation(left) === normalizedPunctuation(right),\n\t];\n\tfor (const matches of matchers) {\n\t\tfor (let index = searchStart; index <= lastStart; index += 1) {\n\t\t\tif (pattern.every((line, offset) => matches(lines[index + offset] ?? \"\", line))) {\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\t}\n\treturn undefined;\n}\n\nfunction computeReplacements(\n\tsourceLines: readonly string[],\n\ttarget: string,\n\tchunks: readonly UpdateFileChunk[],\n): Replacement[] {\n\tconst replacements: Replacement[] = [];\n\tlet lineIndex = 0;\n\tfor (const chunk of chunks) {\n\t\tif (chunk.changeContext !== undefined) {\n\t\t\tconst contextIndex = seekSequence(sourceLines, [chunk.changeContext], lineIndex, false);\n\t\t\tif (contextIndex === undefined) {\n\t\t\t\tthrow new Error(`Failed to find context '${chunk.changeContext}' in ${target}`);\n\t\t\t}\n\t\t\tlineIndex = contextIndex + 1;\n\t\t}\n\n\t\tif (chunk.oldLines.length === 0) {\n\t\t\treplacements.push({\n\t\t\t\tstart: sourceLines.length,\n\t\t\t\toldLength: 0,\n\t\t\t\tnewLines: [...chunk.newLines],\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet pattern = chunk.oldLines;\n\t\tlet newLines = chunk.newLines;\n\t\tlet found = seekSequence(sourceLines, pattern, lineIndex, chunk.isEndOfFile);\n\t\tif (found === undefined && pattern.at(-1) === \"\") {\n\t\t\tpattern = pattern.slice(0, -1);\n\t\t\tif (newLines.at(-1) === \"\") newLines = newLines.slice(0, -1);\n\t\t\tfound = seekSequence(sourceLines, pattern, lineIndex, chunk.isEndOfFile);\n\t\t}\n\t\tif (found === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to find expected lines in ${target}:\\n${chunk.oldLines.join(\"\\n\")}`,\n\t\t\t);\n\t\t}\n\n\t\tlet oldStart = 0;\n\t\tlet newStart = 0;\n\t\tfor (const [oldContext, newContext] of chunk.contextLineIndices) {\n\t\t\tif (oldContext >= pattern.length || newContext >= newLines.length) break;\n\t\t\tif (oldStart !== oldContext || newStart !== newContext) {\n\t\t\t\treplacements.push({\n\t\t\t\t\tstart: found + oldStart,\n\t\t\t\t\toldLength: oldContext - oldStart,\n\t\t\t\t\tnewLines: newLines.slice(newStart, newContext),\n\t\t\t\t});\n\t\t\t}\n\t\t\toldStart = oldContext + 1;\n\t\t\tnewStart = newContext + 1;\n\t\t}\n\t\tif (oldStart !== pattern.length || newStart !== newLines.length) {\n\t\t\treplacements.push({\n\t\t\t\tstart: found + oldStart,\n\t\t\t\toldLength: pattern.length - oldStart,\n\t\t\t\tnewLines: newLines.slice(newStart),\n\t\t\t});\n\t\t}\n\t\tlineIndex = found + pattern.length;\n\t}\n\treturn replacements;\n}\n\nexport function applyUpdate(contents: string, target: string, chunks: readonly UpdateFileChunk[]): string {\n\tconst source = parseSourceFile(contents);\n\tconst texts = source.lines.map((line) => line.text);\n\tconst replacements = computeReplacements(texts, target, chunks);\n\tconst ordered = replacements\n\t\t.map((replacement, order) => ({ replacement, order }))\n\t\t.sort((left, right) =>\n\t\t\tright.replacement.start - left.replacement.start || right.order - left.order,\n\t\t);\n\tfor (const { replacement } of ordered) {\n\t\tsource.lines.splice(\n\t\t\treplacement.start,\n\t\t\treplacement.oldLength,\n\t\t\t...replacement.newLines.map((text) => ({ text, ending: source.preferredEnding })),\n\t\t);\n\t}\n\tfor (const line of source.lines) line.ending ??= source.preferredEnding;\n\treturn source.lines.map((line) => line.text + (line.ending ?? \"\")).join(\"\");\n}\n\nasync function requireRegularFile(target: string, operation: string): Promise<void> {\n\ttry {\n\t\tconst info = await stat(target);\n\t\tif (!info.isFile()) throw new Error(`${operation} ${target}: path is not a regular file`);\n\t} catch (error: unknown) {\n\t\tif (error instanceof Error && \"code\" in error && error.code === \"ENOENT\") {\n\t\t\tthrow new Error(`${operation} ${target}: file does not exist`);\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nfunction throwIfAborted(signal: AbortSignal | undefined): void {\n\tif (signal?.aborted) throw signal.reason ?? new Error(\"Operation aborted\");\n}\n\nasync function writeWithParents(\n\ttarget: string,\n\tcontents: string,\n\tsignal: AbortSignal | undefined,\n): Promise<void> {\n\tthrowIfAborted(signal);\n\tawait mkdir(path.dirname(target), { recursive: true });\n\tawait writeFile(target, contents, { encoding: \"utf8\", signal });\n}\n\nexport function formatApplyPatchSummary(paths: ApplyPatchAffectedPaths): string {\n\tconst rows = [\n\t\t...paths.added.map((filePath) => `A ${filePath}`),\n\t\t...paths.modified.map((filePath) => `M ${filePath}`),\n\t\t...paths.deleted.map((filePath) => `D ${filePath}`),\n\t];\n\treturn `Success. Updated the following files:\\n${rows.join(\"\\n\")}\\n`;\n}\n\nexport async function applyPatch(\n\tcwd: string,\n\tpatch: string,\n\tsignal?: AbortSignal,\n): Promise<ApplyPatchResult> {\n\tconst hunks = parseApplyPatch(patch);\n\tif (hunks.length === 0) throw new Error(\"No files were modified.\");\n\tconst affected: ApplyPatchAffectedPaths = { added: [], modified: [], deleted: [] };\n\n\tfor (const hunk of hunks) {\n\t\tthrowIfAborted(signal);\n\t\tif (hunk.type === \"add\") {\n\t\t\tconst target = await resolveWorkspacePath(cwd, hunk.path);\n\t\t\tawait writeWithParents(target, hunk.contents, signal);\n\t\t\taffected.added.push(hunk.path);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (hunk.type === \"delete\") {\n\t\t\tconst target = await resolveWorkspacePath(cwd, hunk.path);\n\t\t\tawait requireRegularFile(target, \"Failed to delete file\");\n\t\t\tawait unlink(target);\n\t\t\taffected.deleted.push(hunk.path);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst target = await resolveWorkspacePath(cwd, hunk.path);\n\t\tawait requireRegularFile(target, \"Failed to read file to update\");\n\t\tconst before = await readFile(target, { encoding: \"utf8\", signal });\n\t\tconst after = applyUpdate(before, target, hunk.chunks);\n\t\tif (hunk.movePath === undefined) {\n\t\t\tawait writeFile(target, after, { encoding: \"utf8\", signal });\n\t\t\taffected.modified.push(hunk.path);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst destination = await resolveWorkspacePath(cwd, hunk.movePath);\n\t\tif (destination === target) {\n\t\t\tawait writeFile(target, after, { encoding: \"utf8\", signal });\n\t\t} else {\n\t\t\tawait writeWithParents(destination, after, signal);\n\t\t\tawait unlink(target);\n\t\t}\n\t\taffected.modified.push(hunk.movePath);\n\t}\n\n\treturn { ...affected, summary: formatApplyPatchSummary(affected) };\n}\n", "/** Offline projection only. Never execute transcript code or consume private reasoning. */\nexport type ObjectValue = Record<string, unknown>;\nexport const object = (value: unknown): ObjectValue => value !== null && typeof value === \"object\" && !Array.isArray(value) ? value as ObjectValue : {};\nexport const array = (value: unknown): unknown[] => Array.isArray(value) ? value : [];\nexport const visibleText = (value: unknown): string => typeof value === \"string\" ? value : array(value)\n\t.filter((part) => object(part).type === \"text\").map((part) => String(object(part).text ?? \"\")).join(\"\\n\");\n\nexport interface Entry {\n\tid: string;\n\tparentId: string | null;\n\tline: number;\n\ttype: string;\n\tvalue: ObjectValue;\n}\nexport interface Call {\n\tid: string;\n\tname: string;\n\targs?: ObjectValue;\n\tturn: Entry;\n\tresult?: Entry;\n\t/** Start is the assistant entry for native calls; nested starts lack independent timestamps. */\n\touterId?: string;\n\tstatus: \"ok\" | \"error\" | \"unknown\";\n}\nexport interface Trace {\n\theader: ObjectValue;\n\tentries: Entry[];\n\tleafId: string;\n\tissues: string[];\n\tfinished: boolean;\n\tcalls: Call[];\n\touterCalls: Call[];\n\tmetadata: ObjectValue;\n}\n\nexport function parseSession(source: string, leafId?: string): Trace {\n\tconst entries: Entry[] = [];\n\tconst byId = new Map<string, Entry>();\n\tlet header: ObjectValue | undefined;\n\tfor (const [index, line] of source.split(/\\r?\\n/u).entries()) {\n\t\tif (!line.trim()) continue;\n\t\tlet value: ObjectValue;\n\t\ttry { value = object(JSON.parse(line)); } catch { throw new Error(`Invalid session JSON at line ${index + 1}`); }\n\t\tif (value.type === \"session\") {\n\t\t\tif (header || entries.length) throw new Error(\"Expected one session header before entries\");\n\t\t\theader = value; continue;\n\t\t}\n\t\tif (typeof value.id !== \"string\" || typeof value.type !== \"string\" || !(value.parentId === null || typeof value.parentId === \"string\")) throw new Error(`Invalid session entry at line ${index + 1}`);\n\t\tif (byId.has(value.id)) throw new Error(`Duplicate entry ID at line ${index + 1}`);\n\t\tconst entry: Entry = { id: value.id, parentId: value.parentId, type: value.type, line: index + 1, value };\n\t\tentries.push(entry); byId.set(entry.id, entry);\n\t}\n\tif (!header || !entries.length) throw new Error(\"Expected a Pi session header and entries\");\n\tconst leaf = byId.get(leafId ?? entries.at(-1)!.id);\n\tif (!leaf) throw new Error(\"Requested leaf was not found\");\n\tconst issues: string[] = [];\n\tconst branch: Entry[] = [];\n\tconst seen = new Set<string>();\n\tlet current: Entry | undefined = leaf;\n\twhile (current) {\n\t\tif (seen.has(current.id)) throw new Error(\"Cycle in session ancestry\");\n\t\tseen.add(current.id); branch.push(current);\n\t\tif (current.parentId === null) break;\n\t\tconst parent = byId.get(current.parentId);\n\t\tif (!parent) { issues.push(`missing_parent:line_${current.line}`); break; }\n\t\tif (parent.line >= current.line) throw new Error(\"Session parent must precede child\");\n\t\tcurrent = parent;\n\t}\n\tbranch.reverse();\n\tconst outerCalls: Call[] = [];\n\tconst calls: Call[] = [];\n\tconst byCallId = new Map<string, Call>();\n\tfor (const entry of branch) {\n\t\tif (entry.type !== \"message\") continue;\n\t\tconst message = object(entry.value.message);\n\t\tif (message.role === \"assistant\") for (const raw of array(message.content)) {\n\t\t\tconst part = object(raw);\n\t\t\tif (part.type !== \"toolCall\") continue;\n\t\t\tif (typeof part.id !== \"string\" || typeof part.name !== \"string\" || byCallId.has(part.id)) throw new Error(`Invalid tool call at line ${entry.line}`);\n\t\t\tconst call: Call = { id: part.id, name: part.name, args: part.arguments === undefined ? undefined : object(part.arguments), turn: entry, status: \"unknown\" };\n\t\t\touterCalls.push(call); calls.push(call); byCallId.set(call.id, call);\n\t\t}\n\t\tif (message.role !== \"toolResult\") continue;\n\t\tconst outer = byCallId.get(String(message.toolCallId));\n\t\tif (!outer || outer.outerId || outer.result) { issues.push(`unmatched_result:line_${entry.line}`); continue; }\n\t\touter.result = entry;\n\t\touter.status = message.isError === true ? \"error\" : message.isError === false ? \"ok\" : \"unknown\";\n\t\tif (message.toolName !== outer.name) issues.push(`mismatched_tool:line_${entry.line}`);\n\t\tconst nested = object(message.nestedCalls);\n\t\tif (message.nestedCalls !== undefined && nested.complete !== true) issues.push(`incomplete_nested_calls:line_${entry.line}`);\n\t\tfor (const raw of array(nested.calls)) {\n\t\t\tconst item = object(raw);\n\t\t\tif (typeof item.id !== \"string\" || typeof item.name !== \"string\" || byCallId.has(item.id)) throw new Error(`Invalid nested call at line ${entry.line}`);\n\t\t\tconst call: Call = {\n\t\t\t\tid: item.id, name: item.name, args: item.arguments === undefined ? undefined : object(item.arguments),\n\t\t\t\tturn: outer.turn, result: entry, outerId: outer.id,\n\t\t\t\tstatus: item.status === \"ok\" || item.status === \"error\" ? item.status : \"unknown\",\n\t\t\t};\n\t\t\tcalls.push(call); byCallId.set(call.id, call);\n\t\t\tif (!call.args) issues.push(`missing_nested_arguments:line_${entry.line}`);\n\t\t}\n\t}\n\tfor (const call of calls) if (call.status === \"unknown\") issues.push(`unknown_call_outcome:line_${call.result?.line ?? call.turn.line}`);\n\t// These observations are authoritative evidence of executed calls missing from the bounded recorder.\n\tfor (const entry of branch) if (entry.value.customType === \"scaling-observation\") {\n\t\tconst id = object(entry.value.data).callId;\n\t\tif (typeof id === \"string\" && !byCallId.has(id)) issues.push(`unrecorded_observation:line_${entry.line}`);\n\t}\n\tconst lastMessage = branch.findLast((entry) => entry.type === \"message\");\n\tconst last = object(lastMessage?.value.message);\n\tconst pendingInput = branch.some((entry) => entry.line > (lastMessage?.line ?? 0) && entry.type === \"custom_message\");\n\tconst finished = last.role === \"assistant\" && last.stopReason === \"stop\"\n\t\t&& !array(last.content).some((part) => object(part).type === \"toolCall\") && !pendingInput;\n\tif (!finished) issues.push(\"no_final_response_observed\");\n\tconst metadataEntries = branch.filter((entry) => entry.value.customType === \"scaling-config\");\n\tif (!metadataEntries.length) throw new Error(\"No scaling-config entry on the selected branch\");\n\tconst metadata = object(metadataEntries[0]!.value.data);\n\tif (metadataEntries.some((entry) => JSON.stringify(entry.value.data) !== JSON.stringify(metadata))) throw new Error(\"Mixed scaling metadata on one branch; split the experiment before auditing\");\n\treturn { header, entries: branch, leafId: leaf.id, issues: [...new Set(issues)], finished, calls, outerCalls, metadata };\n}\n\nexport function assistantText(trace: Trace): Array<{ entry: Entry; text: string }> {\n\treturn trace.entries.filter((entry) => entry.type === \"message\" && object(entry.value.message).role === \"assistant\")\n\t\t.map((entry) => ({ entry, text: visibleText(object(entry.value.message).content) }));\n}\n"],
5
+ "mappings": ";AAAA,SAAS,UAAU,iBAAiB;AACpC,OAAOA,WAAU;;;ACDjB,OAAOC,WAAU;;;ACAjB,OAAO,UAAU;AAGV,IAAM,iBAAiB,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAYvE,SAAS,OAAO,OAAyC;AACxD,MAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,OAAM,IAAI,MAAM,mCAAmC;AACpH,SAAO;AACR;AACA,SAAS,KAAK,OAAgC,SAAkC;AAC/E,aAAW,OAAO,OAAO,KAAK,KAAK,EAAG,KAAI,CAAC,QAAQ,SAAS,GAAG,EAAG,OAAM,IAAI,MAAM,6BAA6B,GAAG,EAAE;AACrH;AACO,SAAS,gBAAgB,OAAgB,KAAa,QAAyC;AACrG,QAAM,QAAQ,OAAO,KAAK;AAAG,OAAK,OAAO,CAAC,WAAW,eAAe,eAAe,aAAa,CAAC;AACjG,MAAI,MAAM,YAAY,EAAG,OAAM,IAAI,MAAM,sCAAsC;AAC/E,QAAM,UAAU,OAAO,MAAM,eAAe,CAAC,CAAC;AAAG,OAAK,SAAS,CAAC,iBAAiB,cAAc,oBAAoB,CAAC;AACpH,aAAW,QAAQ,OAAO,OAAO,OAAO,EAAG,KAAI,OAAO,SAAS,UAAW,OAAM,IAAI,MAAM,qCAAqC;AAC/H,MAAI,QAAQ,iBAAiB,OAAO,OAAO,MAAO,O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