@tangle-network/agent-eval 0.139.3 → 0.140.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.
- package/CHANGELOG.md +14 -0
- package/dist/analyst/index.d.ts +15 -13
- package/dist/analyst/index.d.ts.map +1 -1
- package/dist/analyst/index.js +6 -6
- package/dist/{benchmark-DDVdWcwA.d.ts → benchmark-DxaZfy0w.d.ts} +3 -3
- package/dist/{benchmark-DDVdWcwA.d.ts.map → benchmark-DxaZfy0w.d.ts.map} +1 -1
- package/dist/{benchmark-command-xvi2liH7.js → benchmark-command-CK0UnXAD.js} +54 -33
- package/dist/benchmark-command-CK0UnXAD.js.map +1 -0
- package/dist/benchmarks/index.d.ts +1 -1
- package/dist/benchmarks/index.js +1 -1
- package/dist/{benchmarks-zxhy1QV3.js → benchmarks-HwoBE32G.js} +4 -4
- package/dist/{benchmarks-zxhy1QV3.js.map → benchmarks-HwoBE32G.js.map} +1 -1
- package/dist/campaign/index.d.ts +5 -5
- package/dist/campaign/index.js +3 -3
- package/dist/{campaign-DrS6_hLd.js → campaign-BzjYNYVZ.js} +5 -5
- package/dist/{campaign-DrS6_hLd.js.map → campaign-BzjYNYVZ.js.map} +1 -1
- package/dist/cli.js +2 -2
- package/dist/{client-BohnDFBq.d.ts → client-BoqGxEqx.d.ts} +4 -4
- package/dist/{client-BohnDFBq.d.ts.map → client-BoqGxEqx.d.ts.map} +1 -1
- package/dist/{completion-verifier-IPoP4fQO.d.ts → completion-verifier-D15NHYSk.d.ts} +5 -5
- package/dist/{completion-verifier-IPoP4fQO.d.ts.map → completion-verifier-D15NHYSk.d.ts.map} +1 -1
- package/dist/contract/index.d.ts +10 -10
- package/dist/contract/index.js +6 -6
- package/dist/control.d.ts +2 -2
- package/dist/{cost-ledger-CZ9diLxY.js → cost-ledger-DMFxsLKr.js} +22 -8
- package/dist/cost-ledger-DMFxsLKr.js.map +1 -0
- package/dist/{cost-ledger-DKgyIWRj.d.ts → cost-ledger-FuQvHxPm.d.ts} +8 -2
- package/dist/{cost-ledger-DKgyIWRj.d.ts.map → cost-ledger-FuQvHxPm.d.ts.map} +1 -1
- package/dist/{default-registry-B8vf7Rmf.d.ts → default-registry-Ci7wAAR8.d.ts} +5 -5
- package/dist/{default-registry-B8vf7Rmf.d.ts.map → default-registry-Ci7wAAR8.d.ts.map} +1 -1
- package/dist/{default-registry-BgJJItGr.js → default-registry-DCp-6hc-.js} +3 -3
- package/dist/{default-registry-BgJJItGr.js.map → default-registry-DCp-6hc-.js.map} +1 -1
- package/dist/{dspy-rlm-engine-DTkVyDX-.js → dspy-rlm-engine-Bkak4nzo.js} +11 -4
- package/dist/dspy-rlm-engine-Bkak4nzo.js.map +1 -0
- package/dist/{eval-campaign-BmptJj50.js → eval-campaign-YdkpWWoT.js} +2 -2
- package/dist/{eval-campaign-BmptJj50.js.map → eval-campaign-YdkpWWoT.js.map} +1 -1
- package/dist/{exact-types-MaaFcllV.d.ts → exact-types-B0lJV3tu.d.ts} +2 -2
- package/dist/{exact-types-MaaFcllV.d.ts.map → exact-types-B0lJV3tu.d.ts.map} +1 -1
- package/dist/{external-optimizer-contracts-BrxY2Sli.d.ts → external-optimizer-contracts-nb7c_WAR.d.ts} +12 -2
- package/dist/{external-optimizer-contracts-BrxY2Sli.d.ts.map → external-optimizer-contracts-nb7c_WAR.d.ts.map} +1 -1
- package/dist/{extract-usage-DZs601Va.js → extract-usage-C5vMw-0R.js} +2 -2
- package/dist/{extract-usage-DZs601Va.js.map → extract-usage-C5vMw-0R.js.map} +1 -1
- package/dist/{feedback-trajectory-BJUWOkJM.d.ts → feedback-trajectory-BCHqzLh3.d.ts} +3 -3
- package/dist/{feedback-trajectory-BJUWOkJM.d.ts.map → feedback-trajectory-BCHqzLh3.d.ts.map} +1 -1
- package/dist/fuzz.d.ts +1 -1
- package/dist/fuzz.js +1 -1
- package/dist/hosted/index.d.ts +3 -3
- package/dist/{index-_66rVpwN.d.ts → index-CKI1CXTL.d.ts} +5 -5
- package/dist/{index-_66rVpwN.d.ts.map → index-CKI1CXTL.d.ts.map} +1 -1
- package/dist/{index-CWOPCJiw.d.ts → index-D2enbqA0.d.ts} +2 -2
- package/dist/{index-CWOPCJiw.d.ts.map → index-D2enbqA0.d.ts.map} +1 -1
- package/dist/{index-BTm_P9aC.d.ts → index-DCP4I2Qx.d.ts} +10 -10
- package/dist/{index-BTm_P9aC.d.ts.map → index-DCP4I2Qx.d.ts.map} +1 -1
- package/dist/{index-CtR1xh4V.d.ts → index-DFLVtPZ9.d.ts} +3 -3
- package/dist/{index-CtR1xh4V.d.ts.map → index-DFLVtPZ9.d.ts.map} +1 -1
- package/dist/index.d.ts +23 -23
- package/dist/index.js +13 -13
- package/dist/{insight-report-Bu5Wi9tG.d.ts → insight-report-Bh_8ksel.d.ts} +4 -4
- package/dist/{insight-report-Bu5Wi9tG.d.ts.map → insight-report-Bh_8ksel.d.ts.map} +1 -1
- package/dist/{integrity-COTh3DTH.d.ts → integrity-DRXobPEs.d.ts} +2 -2
- package/dist/{integrity-COTh3DTH.d.ts.map → integrity-DRXobPEs.d.ts.map} +1 -1
- package/dist/{kind-factory-CFxA0JQX.js → kind-factory-DB7nIs35.js} +2 -2
- package/dist/{kind-factory-CFxA0JQX.js.map → kind-factory-DB7nIs35.js.map} +1 -1
- package/dist/{llm-client-bkztEfIx.js → llm-client-B3WXSH5Y.js} +2 -2
- package/dist/{llm-client-bkztEfIx.js.map → llm-client-B3WXSH5Y.js.map} +1 -1
- package/dist/meta-eval/index.d.ts +2 -2
- package/dist/multishot/index.d.ts +2 -2
- package/dist/openapi.json +1 -1
- package/dist/{release-report-fZarvIm-.d.ts → release-report-B_bQOHM-.d.ts} +3 -3
- package/dist/{release-report-fZarvIm-.d.ts.map → release-report-B_bQOHM-.d.ts.map} +1 -1
- package/dist/{replay-DjG4IG60.d.ts → replay-BqTgoioO.d.ts} +6 -6
- package/dist/{replay-DjG4IG60.d.ts.map → replay-BqTgoioO.d.ts.map} +1 -1
- package/dist/{replay-SA4OB7O7.js → replay-k2MsOmv5.js} +4 -4
- package/dist/{replay-SA4OB7O7.js.map → replay-k2MsOmv5.js.map} +1 -1
- package/dist/reporting.d.ts +4 -4
- package/dist/{researcher-BxhtGfKa.d.ts → researcher-C6lzl-rP.d.ts} +5 -5
- package/dist/{researcher-BxhtGfKa.d.ts.map → researcher-C6lzl-rP.d.ts.map} +1 -1
- package/dist/{reward-hacking-CqSLiV51.d.ts → reward-hacking-CEVVmy3h.d.ts} +2 -2
- package/dist/{reward-hacking-CqSLiV51.d.ts.map → reward-hacking-CEVVmy3h.d.ts.map} +1 -1
- package/dist/rl.d.ts +5 -5
- package/dist/rl.js +1 -1
- package/dist/rollout/index.d.ts +1 -1
- package/dist/{rubric-predictive-validity-DQBQj6uV.d.ts → rubric-predictive-validity-C2CthIfY.d.ts} +2 -2
- package/dist/{rubric-predictive-validity-DQBQj6uV.d.ts.map → rubric-predictive-validity-C2CthIfY.d.ts.map} +1 -1
- package/dist/{run-evidence-C4RcRQT5.d.ts → run-evidence-8Ou28QSa.d.ts} +3 -3
- package/dist/{run-evidence-C4RcRQT5.d.ts.map → run-evidence-8Ou28QSa.d.ts.map} +1 -1
- package/dist/{run-record-CztDMXVF.d.ts → run-record-Tb3TTtUn.d.ts} +2 -2
- package/dist/{run-record-CztDMXVF.d.ts.map → run-record-Tb3TTtUn.d.ts.map} +1 -1
- package/dist/{semantic-concept-judge-BuIJ9IfB.js → semantic-concept-judge-DJQtFr95.js} +3 -3
- package/dist/{semantic-concept-judge-BuIJ9IfB.js.map → semantic-concept-judge-DJQtFr95.js.map} +1 -1
- package/dist/{server-DaCpLfi0.js → server-Cu4M3NSO.js} +3 -3
- package/dist/{server-DaCpLfi0.js.map → server-Cu4M3NSO.js.map} +1 -1
- package/dist/{single-run-lock-BTTtPZ9N.js → single-run-lock-CiQThJxB.js} +22 -12
- package/dist/single-run-lock-CiQThJxB.js.map +1 -0
- package/dist/{skill-usage-B-BFS8M2.d.ts → skill-usage-CVVnoIx-.d.ts} +26 -10
- package/dist/skill-usage-CVVnoIx-.d.ts.map +1 -0
- package/dist/{skillopt-optimization-method-BbGnCC53.js → skillopt-optimization-method-CSBQ8Qma.js} +4 -4
- package/dist/{skillopt-optimization-method-BbGnCC53.js.map → skillopt-optimization-method-CSBQ8Qma.js.map} +1 -1
- package/dist/{skillopt-optimization-method-_s0Tub7Y.d.ts → skillopt-optimization-method-D1dqGzzH.d.ts} +11 -11
- package/dist/{skillopt-optimization-method-_s0Tub7Y.d.ts.map → skillopt-optimization-method-D1dqGzzH.d.ts.map} +1 -1
- package/dist/{statistics-B5d0Zd-z.d.ts → statistics-B4u_CiFd.d.ts} +2 -2
- package/dist/{statistics-B5d0Zd-z.d.ts.map → statistics-B4u_CiFd.d.ts.map} +1 -1
- package/dist/{store-otlp-DX4fGIcf.js → store-otlp-vRByAR6h.js} +2 -2
- package/dist/{store-otlp-DX4fGIcf.js.map → store-otlp-vRByAR6h.js.map} +1 -1
- package/dist/{summary-report-Cg7BifAM.d.ts → summary-report-o3eJ3gxG.d.ts} +3 -3
- package/dist/{summary-report-Cg7BifAM.d.ts.map → summary-report-o3eJ3gxG.d.ts.map} +1 -1
- package/dist/{tool-groups-CdYq22lX.d.ts → tool-groups-DVQTy9lq.d.ts} +8 -8
- package/dist/{tool-groups-CdYq22lX.d.ts.map → tool-groups-DVQTy9lq.d.ts.map} +1 -1
- package/dist/traces.d.ts +6 -6
- package/dist/traces.js +4 -4
- package/dist/{types-uPrS6mD-.d.ts → types-BjMFz88h.d.ts} +2 -2
- package/dist/{types-uPrS6mD-.d.ts.map → types-BjMFz88h.d.ts.map} +1 -1
- package/dist/{types-DoEYskCd.d.ts → types-D3jh6F98.d.ts} +4 -4
- package/dist/{types-DoEYskCd.d.ts.map → types-D3jh6F98.d.ts.map} +1 -1
- package/dist/{types-BBFNHxSK.d.ts → types-Dk7PB7vh.d.ts} +5 -5
- package/dist/{types-BBFNHxSK.d.ts.map → types-Dk7PB7vh.d.ts.map} +1 -1
- package/dist/wire/index.d.ts +3 -3
- package/dist/wire/index.js +1 -1
- package/package.json +1 -1
- package/dist/benchmark-command-xvi2liH7.js.map +0 -1
- package/dist/cost-ledger-CZ9diLxY.js.map +0 -1
- package/dist/dspy-rlm-engine-DTkVyDX-.js.map +0 -1
- package/dist/single-run-lock-BTTtPZ9N.js.map +0 -1
- package/dist/skill-usage-B-BFS8M2.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"benchmark-command-xvi2liH7.js","names":["nonEmpty","isRecord","isRecord","nonEmpty","isRecord","summarizeRunner","escapeCell","rate","number","mean","requiredString","safeInteger","positiveInteger","rate","isRecord","TextDecoder","isNodeError","slashRelative","trajectoryIdFromCaseId","isPaidCallControlError","isRecord","mean","escapeCell","rate"],"sources":["../src/analyst/benchmark-dataset-utils.ts","../src/analyst/benchmark-dataset-agentrx.ts","../src/analyst/benchmark-dataset-codetrace.ts","../src/analyst/benchmark-agentrx-calibration.ts","../src/analyst/benchmark-command-validation.ts","../src/analyst/benchmark-command-artifact.ts","../src/analyst/benchmark-implementation.ts","../src/analyst/benchmark-evidence-validation.ts","../src/analyst/benchmark-verification-outcome.ts","../src/analyst/benchmark-verification-artifacts.ts","../src/analyst/benchmark-public-prompt.ts","../src/analyst/benchmark-public-adapters.ts","../src/analyst/benchmark-public-types.ts","../src/analyst/benchmark-public-data.ts","../src/analyst/benchmark-public-errors.ts","../src/analyst/benchmark-response-cache.ts","../src/analyst/benchmark-public-model.ts","../src/analyst/benchmark-public-rlm.ts","../src/analyst/benchmark-command-persistence.ts","../src/analyst/benchmark-comparison.ts","../src/analyst/benchmark-public-calibration.ts","../src/analyst/benchmark-command-result.ts","../src/analyst/benchmark-report.ts","../src/analyst/benchmark-command.ts"],"sourcesContent":["import type { ExternalId } from './benchmark-dataset-types'\n\nexport function normalizeBenchmarkLabel(value: string): string {\n const normalized = nonEmpty(value, 'benchmark label')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-|-$/g, '')\n if (!normalized) throw new TypeError('benchmark label must contain letters or digits')\n return normalized\n}\n\nexport function predictionConfidence(value: number | undefined): number {\n const confidence = value ?? 0.5\n if (!Number.isFinite(confidence) || confidence < 0 || confidence > 1) {\n throw new RangeError('upstream prediction confidence must be between 0 and 1')\n }\n return confidence\n}\n\nexport function assertStepWithinRange(\n step: number,\n stepCount: number | undefined,\n field: string,\n): void {\n if (stepCount === undefined) return\n const count = positiveStep(stepCount, `${field} stepCount`)\n if (step > count) throw new RangeError(`${field} step ${step} exceeds stepCount ${count}`)\n}\n\nexport function defaultStepUri(trajectoryId: string, step: number): string {\n return `trace://${encodeURIComponent(trajectoryId)}/span/step-${step}`\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport function positiveStep(value: number, field: string): number {\n if (!Number.isSafeInteger(value) || value < 1) {\n throw new RangeError(`${field} must be a positive safe integer`)\n }\n return value\n}\n\nexport function externalId(value: ExternalId | undefined, field: string): string {\n if (typeof value !== 'string' && typeof value !== 'number') {\n throw new TypeError(`${field} must be a string or number`)\n }\n if (typeof value === 'number' && !Number.isSafeInteger(value)) {\n throw new TypeError(`${field} must be a safe integer when numeric`)\n }\n return nonEmpty(String(value), field)\n}\n\nexport function nonEmpty(value: string, field: string): string {\n if (!value.trim()) throw new TypeError(`${field} must not be empty`)\n return value\n}\n","import type { AnalystBenchmarkCase } from './benchmark'\nimport type {\n AgentRxBenchmarkCaseOptions,\n AgentRxPrediction,\n AgentRxPredictionReport,\n AgentRxRow,\n ExternalId,\n UpstreamPredictionAdapterOptions,\n} from './benchmark-dataset-types'\nimport {\n assertStepWithinRange,\n defaultStepUri,\n externalId,\n isRecord,\n normalizeBenchmarkLabel,\n positiveStep,\n predictionConfidence,\n} from './benchmark-dataset-utils'\nimport { type AnalystFinding, makeFinding } from './types'\n\nexport function agentRxBenchmarkCase<TInput>(\n row: AgentRxRow,\n input: TInput,\n options: AgentRxBenchmarkCaseOptions = {},\n): AnalystBenchmarkCase<TInput> {\n const trajectoryId = externalId(row.trajectory_id, 'AgentRx trajectory_id')\n if (!Array.isArray(row.failures) || row.failures.length === 0) {\n throw new TypeError(`AgentRx trajectory '${trajectoryId}' must contain failures`)\n }\n if (row.num_failures !== undefined && row.num_failures !== row.failures.length) {\n throw new TypeError(\n `AgentRx trajectory '${trajectoryId}' declares ${row.num_failures} failures but contains ${row.failures.length}`,\n )\n }\n const rootCauseId = externalId(\n row.root_cause_failure_id ?? row.root_cause?.failure_id,\n `AgentRx trajectory '${trajectoryId}' root cause failure id`,\n )\n const failureIds = new Set<string>()\n const failureMetadata: Array<{ id: string; step: number; category: string }> = []\n const evidenceKind = options.evidenceKind ?? 'span'\n const uri = options.stepUri ?? defaultStepUri\n const allIssues = row.failures.map((failure) => {\n const failureId = externalId(\n failure.failure_id,\n `AgentRx trajectory '${trajectoryId}' failure id`,\n )\n if (failureIds.has(failureId)) {\n throw new TypeError(`AgentRx trajectory '${trajectoryId}' repeats failure id '${failureId}'`)\n }\n failureIds.add(failureId)\n const step = positiveStep(failure.step_number, `AgentRx trajectory '${trajectoryId}'`)\n const evidence = [{ kind: evidenceKind, uri: uri(trajectoryId, step) }]\n if (typeof failure.failure_category !== 'string') {\n throw new TypeError(\n `AgentRx trajectory '${trajectoryId}' failure '${failureId}' category must be a string`,\n )\n }\n const category = normalizeAgentRxCategory(failure.failure_category)\n if (!AGENT_RX_TAXONOMY_BY_LABEL.has(category)) {\n throw new RangeError(\n `AgentRx trajectory '${trajectoryId}' failure '${failureId}' category '${failure.failure_category}' is outside the AgentRx taxonomy`,\n )\n }\n failureMetadata.push({ id: failureId, step, category })\n return {\n id: failureId,\n areas: [category],\n ...(failureId === rootCauseId && (options.target ?? 'root-cause') === 'root-cause'\n ? {}\n : { evidence }),\n criticalEvidence: failureId === rootCauseId ? evidence : undefined,\n }\n })\n if (!failureIds.has(rootCauseId)) {\n throw new TypeError(\n `AgentRx trajectory '${trajectoryId}' root cause '${rootCauseId}' is not in failures`,\n )\n }\n if (\n options.stepCount !== undefined &&\n row.failures.some((failure) => failure.step_number > options.stepCount!)\n ) {\n throw new RangeError(\n `AgentRx trajectory '${trajectoryId}' contains a failure beyond stepCount ${options.stepCount}`,\n )\n }\n const expectedIssues =\n (options.target ?? 'root-cause') === 'root-cause'\n ? allIssues.filter((issue) => issue.id === rootCauseId)\n : allIssues\n const rootCause = failureMetadata.find((failure) => failure.id === rootCauseId)!\n const orderedFailures = [...failureMetadata].sort(\n (left, right) => left.step - right.step || left.id.localeCompare(right.id),\n )\n\n return {\n id: `agentrx:${trajectoryId}`,\n clusterId: `agentrx:${trajectoryId}`,\n labelState: 'positive',\n input,\n expectedIssues,\n labeledEvidence: expectedIssues.flatMap(\n (issue) => issue.evidence ?? issue.criticalEvidence ?? [],\n ),\n tags: ['agentrx'],\n metadata: {\n benchmark: 'AgentRx',\n trajectoryId,\n failureSummary: row.failure_summary,\n rootCauseReason: row.root_cause_reason ?? row.root_cause?.reason_for_root_cause,\n annotatedFailures: row.failures.length,\n target: options.target ?? 'root-cause',\n rootCauseStep: rootCause.step,\n rootCauseCategory: rootCause.category,\n allFailureCategories: [...new Set(failureMetadata.map((failure) => failure.category))].sort(),\n earliestFailureCategory: orderedFailures[0]!.category,\n terminalFailureCategory: orderedFailures.at(-1)!.category,\n ...(options.stepCount === undefined ? {} : { trajectoryLength: options.stepCount }),\n },\n }\n}\n\n/** Translate AgentRx `Report.to_dict()` output or its `failures` array into findings. */\nexport function agentRxPredictionsToFindings(\n trajectoryIdValue: ExternalId,\n output: unknown,\n options: UpstreamPredictionAdapterOptions = {},\n): AnalystFinding[] {\n const trajectoryId = externalId(trajectoryIdValue, 'AgentRx prediction trajectory id')\n const parsed = parseAgentRxPredictions(output, trajectoryId)\n for (const prediction of parsed.predictions) {\n assertStepWithinRange(\n prediction.step_number,\n parsed.report?.trajectory_length,\n `AgentRx prediction '${trajectoryId}' report`,\n )\n assertStepWithinRange(\n prediction.step_number,\n options.stepCount,\n `AgentRx prediction '${trajectoryId}'`,\n )\n }\n const consensus = agentRxConsensus(parsed, trajectoryId)\n if (consensus.failureCase === 0) return []\n const confidence = predictionConfidence(options.confidence)\n const uri = options.stepUri ?? defaultStepUri\n assertStepWithinRange(consensus.step, options.stepCount, `AgentRx prediction '${trajectoryId}'`)\n const area = AGENT_RX_TAXONOMY.get(consensus.failureCase)!\n return [\n makeFinding({\n analyst_id: options.analystId ?? 'agentrx',\n produced_at: options.producedAt,\n area,\n subject: 'root-cause',\n claim: `AgentRx classified step ${consensus.step} as ${area}.`,\n id_basis: `${area}:${consensus.step}`,\n rationale: consensus.representative.description,\n severity: 'high',\n confidence,\n evidence_refs: [\n {\n kind: options.evidenceKind ?? 'span',\n uri: uri(trajectoryId, consensus.step),\n },\n ],\n metadata: {\n upstream: 'AgentRx',\n failure_case: consensus.failureCase,\n step: consensus.step,\n step_mean: consensus.stepMean,\n judge_votes: parsed.predictions.length,\n consensus_votes: consensus.votes,\n category_agreement: consensus.votes / parsed.predictions.length,\n ...(consensus.representative.checklist_reasoning === undefined ||\n consensus.representative.checklist_reasoning === null\n ? {}\n : { checklist_reasoning: consensus.representative.checklist_reasoning }),\n },\n }),\n ]\n}\n\nconst AGENT_RX_TAXONOMY = new Map<number, string>([\n [1, 'instruction-plan-adherence-failure'],\n [2, 'invention-of-new-information'],\n [3, 'invalid-invocation'],\n [4, 'misinterpretation-of-tool-output-handoff-failure'],\n [5, 'intent-plan-misalignment'],\n [6, 'underspecified-user-intent'],\n [7, 'intent-not-supported'],\n [8, 'guardrails-triggered'],\n [9, 'system-failure'],\n [10, 'inconclusive'],\n])\n\nconst AGENT_RX_CATEGORY_ALIASES = new Map<string, string>([\n ['instruction-adherence-failure', 'instruction-plan-adherence-failure'],\n ['misinterpretation-of-tool-output', 'misinterpretation-of-tool-output-handoff-failure'],\n])\n\nconst AGENT_RX_TAXONOMY_BY_LABEL = new Map(\n [...AGENT_RX_TAXONOMY].map(([failureCase, label]) => [label, failureCase]),\n)\n\nexport function normalizeAgentRxCategory(value: string): string {\n const normalized = normalizeBenchmarkLabel(value)\n return AGENT_RX_CATEGORY_ALIASES.get(normalized) ?? normalized\n}\n\nfunction parseAgentRxFailureCase(value: unknown, field: string): number {\n if (typeof value !== 'number' && typeof value !== 'string') {\n throw new TypeError(`${field} must be a taxonomy number or label`)\n }\n if (typeof value === 'string' && !/^\\d+$/.test(value.trim())) {\n const normalized = normalizeAgentRxCategory(value)\n const failureCase = AGENT_RX_TAXONOMY_BY_LABEL.get(normalized)\n if (failureCase === undefined) {\n throw new RangeError(`${field} '${value}' is not an AgentRx taxonomy label`)\n }\n return failureCase\n }\n const numeric = typeof value === 'number' ? value : Number(value)\n if (!Number.isSafeInteger(numeric)) {\n throw new TypeError(`${field} must be a taxonomy number or label`)\n }\n if (numeric < 0 || numeric > 10) {\n throw new RangeError(`${field} ${numeric} is outside 0-10`)\n }\n return numeric\n}\n\ninterface ParsedAgentRxPredictions {\n predictions: Array<\n Omit<AgentRxPrediction, 'failure_case'> & {\n failure_case: number\n }\n >\n report?: AgentRxPredictionReport\n}\n\nfunction parseAgentRxPredictions(output: unknown, trajectoryId: string): ParsedAgentRxPredictions {\n let failures: unknown\n let report: AgentRxPredictionReport | undefined\n if (Array.isArray(output)) {\n failures = output\n } else if (isRecord(output)) {\n assertMatchingAgentRxTaskId(output.task_id, trajectoryId, 'report.task_id')\n if (!Object.hasOwn(output, 'failures')) {\n throw new TypeError(`AgentRx prediction '${trajectoryId}' report must contain failures`)\n }\n failures = output.failures\n if (output.num_judges !== undefined) {\n if (!Number.isSafeInteger(output.num_judges) || (output.num_judges as number) < 0) {\n throw new RangeError(\n `AgentRx prediction '${trajectoryId}' report.num_judges must be a non-negative safe integer`,\n )\n }\n }\n if (output.trajectory_length !== undefined) {\n positiveStep(\n output.trajectory_length as number,\n `AgentRx prediction '${trajectoryId}' report.trajectory_length`,\n )\n }\n if (output.step_mean !== undefined) {\n if (typeof output.step_mean !== 'number' || !Number.isFinite(output.step_mean)) {\n throw new TypeError(`AgentRx prediction '${trajectoryId}' report.step_mean must be finite`)\n }\n }\n if (output.modes !== undefined && !Array.isArray(output.modes)) {\n throw new TypeError(`AgentRx prediction '${trajectoryId}' report.modes must be an array`)\n }\n report = output as unknown as AgentRxPredictionReport\n } else {\n throw new TypeError(`AgentRx prediction '${trajectoryId}' must be a report or failures array`)\n }\n if (!Array.isArray(failures)) {\n throw new TypeError(`AgentRx prediction '${trajectoryId}' failures must be an array`)\n }\n if (failures.length === 0) {\n throw new TypeError(\n `AgentRx prediction '${trajectoryId}' failures must contain a judge prediction`,\n )\n }\n if (\n isRecord(output) &&\n output.num_judges !== undefined &&\n output.num_judges !== failures.length\n ) {\n throw new TypeError(\n `AgentRx prediction '${trajectoryId}' declares ${output.num_judges} judges but contains ${failures.length} failures`,\n )\n }\n const predictions = failures.map((value, index) => {\n const field = `AgentRx prediction '${trajectoryId}' failures[${index}]`\n if (!isRecord(value)) throw new TypeError(`${field} must be an object`)\n assertMatchingAgentRxTaskId(value.task_id, trajectoryId, `${field}.task_id`)\n const failureCase = parseAgentRxFailureCase(value.failure_case, `${field}.failure_case`)\n if (!Number.isSafeInteger(value.step_number)) {\n throw new TypeError(`${field}.step_number must be a safe integer`)\n }\n const stepNumber = value.step_number as number\n if (failureCase === 0 ? stepNumber !== 0 : stepNumber < 1) {\n throw new RangeError(\n failureCase === 0\n ? `${field}.step_number must be 0 when failure_case is 0`\n : `${field}.step_number must be positive when failure_case is 1-10`,\n )\n }\n if (value.description !== undefined && typeof value.description !== 'string') {\n throw new TypeError(`${field}.description must be a string`)\n }\n if (\n value.checklist_reasoning !== undefined &&\n value.checklist_reasoning !== null &&\n typeof value.checklist_reasoning !== 'string'\n ) {\n throw new TypeError(`${field}.checklist_reasoning must be a string or null`)\n }\n return {\n ...(value.task_id === undefined ? {} : { task_id: value.task_id as ExternalId }),\n failure_case: failureCase,\n step_number: stepNumber,\n ...(value.description === undefined ? {} : { description: value.description as string }),\n ...(value.checklist_reasoning === undefined\n ? {}\n : { checklist_reasoning: value.checklist_reasoning as string | null }),\n }\n })\n return { predictions, report }\n}\n\nfunction agentRxConsensus(\n parsed: ParsedAgentRxPredictions,\n trajectoryId: string,\n): {\n failureCase: number\n step: number\n stepMean: number\n votes: number\n representative: ParsedAgentRxPredictions['predictions'][number]\n} {\n const counts = new Map<number, number>()\n for (const prediction of parsed.predictions) {\n counts.set(prediction.failure_case, (counts.get(prediction.failure_case) ?? 0) + 1)\n }\n const maxVotes = Math.max(...counts.values())\n let failureCase = [...counts].find(([, count]) => count === maxVotes)![0]\n if (parsed.report?.most_common_failure !== undefined) {\n const declared = parseAgentRxFailureCase(\n parsed.report.most_common_failure,\n `AgentRx prediction '${trajectoryId}' report.most_common_failure`,\n )\n if ((counts.get(declared) ?? 0) !== maxVotes) {\n throw new TypeError(\n `AgentRx prediction '${trajectoryId}' report.most_common_failure disagrees with failures`,\n )\n }\n failureCase = declared\n }\n if (parsed.report?.modes !== undefined) {\n const declaredModes = parsed.report.modes.map((value, index) =>\n parseAgentRxFailureCase(value, `AgentRx prediction '${trajectoryId}' report.modes[${index}]`),\n )\n if (new Set(declaredModes).size !== declaredModes.length) {\n throw new TypeError(`AgentRx prediction '${trajectoryId}' report.modes contains duplicates`)\n }\n const expectedModes = [...counts]\n .filter(([, count]) => count === maxVotes)\n .map(([value]) => value)\n .sort((left, right) => left - right)\n if (\n [...new Set(declaredModes)].sort((left, right) => left - right).join(',') !==\n expectedModes.join(',')\n ) {\n throw new TypeError(\n `AgentRx prediction '${trajectoryId}' report.modes disagrees with failures`,\n )\n }\n }\n\n const computedStepMean =\n parsed.predictions.reduce((sum, prediction) => sum + prediction.step_number, 0) /\n parsed.predictions.length\n if (\n parsed.report?.step_mean !== undefined &&\n Math.abs(parsed.report.step_mean - computedStepMean) > 1e-12\n ) {\n throw new TypeError(\n `AgentRx prediction '${trajectoryId}' report.step_mean disagrees with failures`,\n )\n }\n const stepMean = parsed.report?.step_mean ?? computedStepMean\n const step =\n failureCase === 0\n ? 0\n : positiveStep(\n roundAgentRxStep(stepMean),\n `AgentRx prediction '${trajectoryId}' consensus step`,\n )\n const representative =\n parsed.predictions\n .filter((prediction) => prediction.failure_case === failureCase)\n .sort(\n (left, right) => Math.abs(left.step_number - step) - Math.abs(right.step_number - step),\n )[0] ?? parsed.predictions[0]!\n return {\n failureCase,\n step,\n stepMean,\n votes: counts.get(failureCase)!,\n representative,\n }\n}\n\n/** Match Python's round() behavior used by AgentRx for consensus steps. */\nexport function roundAgentRxStep(value: number): number {\n if (!Number.isFinite(value)) {\n throw new TypeError('AgentRx step mean must be finite')\n }\n const lower = Math.floor(value)\n const fraction = value - lower\n if (Math.abs(fraction - 0.5) <= Number.EPSILON * Math.max(1, Math.abs(value))) {\n return lower % 2 === 0 ? lower : lower + 1\n }\n return Math.round(value)\n}\n\nfunction assertMatchingAgentRxTaskId(value: unknown, trajectoryId: string, field: string): void {\n if (value === undefined) return\n const taskId = externalId(value as ExternalId, `AgentRx prediction '${trajectoryId}' ${field}`)\n if (taskId !== trajectoryId) {\n throw new TypeError(\n `AgentRx prediction '${trajectoryId}' ${field} '${taskId}' does not match trajectory id`,\n )\n }\n}\n","import type { AnalystBenchmarkCase } from './benchmark'\nimport type {\n CodeTraceBenchCaseOptions,\n CodeTraceBenchLabelSet,\n CodeTraceBenchRow,\n CodeTracerPredictionAdapterOptions,\n CodeTracerPredictions,\n CodeTracerStepLabel,\n CodeTraceStageAnnotation,\n} from './benchmark-dataset-types'\nimport {\n assertStepWithinRange,\n defaultStepUri,\n isRecord,\n nonEmpty,\n positiveStep,\n predictionConfidence,\n} from './benchmark-dataset-utils'\nimport { type AnalystFinding, makeFinding } from './types'\n\nexport function codeTraceBenchCase<TInput>(\n row: CodeTraceBenchRow,\n input: TInput,\n options: CodeTraceBenchCaseOptions = {},\n): AnalystBenchmarkCase<TInput> {\n const trajectoryId = requiredCodeTraceString(row.traj_id, 'CodeTraceBench traj_id')\n const taskName = requiredCodeTraceString(\n row.task_name,\n `CodeTraceBench '${trajectoryId}' task_name`,\n )\n const agent = requiredCodeTraceString(row.agent, `CodeTraceBench '${trajectoryId}' agent`)\n const model = requiredCodeTraceString(row.model, `CodeTraceBench '${trajectoryId}' model`)\n const difficulty = optionalCodeTraceString(\n row.difficulty,\n `CodeTraceBench '${trajectoryId}' difficulty`,\n )\n const category = optionalCodeTraceString(\n row.category,\n `CodeTraceBench '${trajectoryId}' category`,\n )\n const sourceRelpath = optionalSourceRelativePath(row.source_relpath, trajectoryId)\n const solved = codeTraceSolved(row.solved, trajectoryId)\n const tags = parseTags(row.tags, trajectoryId)\n const stepCount = positiveStep(row.step_count, `CodeTraceBench '${trajectoryId}' step_count`)\n const stages = parseCodeTraceStages(row.incorrect_stages, trajectoryId)\n const evidenceKind = options.evidenceKind ?? 'span'\n const uri = options.stepUri ?? defaultStepUri\n const labelSet = codeTraceLabelSet(options.labelSet)\n const labels = new Set<string>()\n const expectedIssues = stages.flatMap((stage) => {\n const incorrect = stepIssues('incorrect', stage.incorrect_step_ids ?? [])\n const unuseful = stepIssues('unuseful', stage.unuseful_step_ids ?? [])\n return labelSet === 'incorrect-only' ? incorrect : [...incorrect, ...unuseful]\n })\n const labelState =\n expectedIssues.length > 0 ? 'positive' : solved === true ? 'trusted-negative' : 'unlabeled'\n\n return {\n id: `codetrace:${trajectoryId}`,\n clusterId: `codetrace-task:${taskName}`,\n labelState,\n input,\n expectedIssues,\n ...(labelState === 'unlabeled'\n ? {}\n : { labeledEvidence: expectedIssues.flatMap((issue) => issue.evidence ?? []) }),\n tags: [\n 'codetracebench',\n agent,\n model,\n ...(difficulty === undefined ? [] : [difficulty]),\n ...(category === undefined ? [] : [category]),\n ...tags,\n ],\n metadata: {\n benchmark: 'CodeTraceBench',\n trajectoryId,\n taskName,\n agent,\n model,\n solved,\n stepCount,\n labelSet,\n ...(sourceRelpath === undefined ? {} : { sourceRelpath }),\n ...(difficulty === undefined ? {} : { difficulty }),\n ...(category === undefined ? {} : { category }),\n },\n }\n\n function stepIssues(label: 'incorrect' | 'unuseful', steps: readonly number[]) {\n return steps.map((rawStep) => {\n const step = positiveStep(rawStep, `CodeTraceBench '${trajectoryId}' ${label} step`)\n if (step > stepCount) {\n throw new RangeError(\n `CodeTraceBench '${trajectoryId}' ${label} step ${step} exceeds step_count ${stepCount}`,\n )\n }\n const id = `${label}:${step}`\n if (labels.has(id)) {\n throw new TypeError(`CodeTraceBench '${trajectoryId}' repeats label '${id}'`)\n }\n labels.add(id)\n return {\n id,\n areas: [label],\n evidence: [{ kind: evidenceKind, uri: uri(trajectoryId, step) }],\n }\n })\n }\n}\n\n/** Translate CodeTracer's `codetracer_labels.json` into shared findings. */\nexport function codeTracerPredictionsToFindings(\n trajectoryIdValue: string,\n predictions: CodeTracerPredictions,\n options: CodeTracerPredictionAdapterOptions = {},\n): AnalystFinding[] {\n const trajectoryId = nonEmpty(trajectoryIdValue, 'CodeTracer prediction trajectory id')\n const labels = parseCodeTracerPredictionLabels(predictions, trajectoryId)\n const confidence = predictionConfidence(options.confidence)\n const uri = options.stepUri ?? defaultStepUri\n const labelSet = codeTraceLabelSet(options.labelSet)\n const seen = new Set<string>()\n const findings: AnalystFinding[] = []\n for (const label of labels) {\n const step = positiveStep(\n label.step,\n `CodeTracer prediction '${trajectoryId}' ${label.area} step`,\n )\n assertStepWithinRange(step, options.stepCount, `CodeTracer prediction '${trajectoryId}'`)\n const key = `${label.area}:${step}`\n if (seen.has(key)) {\n throw new TypeError(`CodeTracer prediction '${trajectoryId}' repeats label '${key}'`)\n }\n seen.add(key)\n if (label.area === 'unuseful' && labelSet === 'incorrect-only') continue\n findings.push(\n makeFinding({\n analyst_id: options.analystId ?? 'codetracer',\n produced_at: options.producedAt,\n area: label.area,\n subject: `step-${step}`,\n claim: `CodeTracer labeled step ${step} as ${label.area}.`,\n id_basis: key,\n rationale: label.reasoning,\n severity: 'medium',\n confidence,\n evidence_refs: [\n {\n kind: options.evidenceKind ?? 'span',\n uri: uri(trajectoryId, step),\n },\n ],\n metadata: {\n upstream: 'CodeTracer',\n stage_id: label.stageId,\n step,\n },\n }),\n )\n }\n return findings\n}\n\nfunction parseCodeTraceStages(\n value: CodeTraceBenchRow['incorrect_stages'],\n trajectoryId: string,\n): readonly CodeTraceStageAnnotation[] {\n let parsed: unknown = value\n if (typeof value === 'string') {\n try {\n parsed = JSON.parse(value) as unknown\n } catch (error) {\n throw new TypeError(\n `CodeTraceBench '${trajectoryId}' incorrect_stages is invalid JSON: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n if (!Array.isArray(parsed)) {\n throw new TypeError(`CodeTraceBench '${trajectoryId}' incorrect_stages must be an array`)\n }\n const stageIds = new Set<number>()\n for (const stage of parsed) {\n if (\n !stage ||\n typeof stage !== 'object' ||\n !Number.isSafeInteger((stage as CodeTraceStageAnnotation).stage_id) ||\n (stage as CodeTraceStageAnnotation).stage_id < 1 ||\n !optionalStepArray((stage as CodeTraceStageAnnotation).incorrect_step_ids) ||\n !optionalStepArray((stage as CodeTraceStageAnnotation).unuseful_step_ids) ||\n ((stage as CodeTraceStageAnnotation).reasoning !== undefined &&\n typeof (stage as CodeTraceStageAnnotation).reasoning !== 'string')\n ) {\n throw new TypeError(`CodeTraceBench '${trajectoryId}' contains an invalid stage annotation`)\n }\n const stageId = (stage as CodeTraceStageAnnotation).stage_id\n if (stageIds.has(stageId)) {\n throw new TypeError(`CodeTraceBench '${trajectoryId}' repeats stage_id ${stageId}`)\n }\n stageIds.add(stageId)\n }\n return parsed as unknown as readonly CodeTraceStageAnnotation[]\n}\n\nfunction parseCodeTracerPredictionLabels(\n value: CodeTracerPredictions,\n trajectoryId: string,\n): Array<{\n stageId: string | number\n area: CodeTracerStepLabel['label']\n step: number\n reasoning?: string\n}> {\n let parsed: unknown = value\n if (typeof value === 'string') {\n try {\n parsed = JSON.parse(value) as unknown\n } catch (error) {\n throw new TypeError(\n `CodeTracer prediction '${trajectoryId}' is invalid JSON: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n if (!Array.isArray(parsed)) {\n throw new TypeError(`CodeTracer prediction '${trajectoryId}' must be an array`)\n }\n if (parsed.length === 0) return []\n\n if (parsed.every(isCodeTraceStageAnnotation)) {\n return (parsed as readonly CodeTraceStageAnnotation[]).flatMap((stage) => [\n ...(stage.incorrect_step_ids ?? []).map((step) => ({\n stageId: stage.stage_id,\n area: 'incorrect' as const,\n step,\n ...(stage.reasoning === undefined ? {} : { reasoning: stage.reasoning }),\n })),\n ...(stage.unuseful_step_ids ?? []).map((step) => ({\n stageId: stage.stage_id,\n area: 'unuseful' as const,\n step,\n ...(stage.reasoning === undefined ? {} : { reasoning: stage.reasoning }),\n })),\n ])\n }\n\n const flat: Array<{\n stageId: string | number\n area: CodeTracerStepLabel['label']\n step: number\n reasoning?: string\n }> = []\n for (const [index, item] of parsed.entries()) {\n if (isCodeTracerStepLabel(item)) {\n flat.push(\n toCodeTracerPredictionLabel(\n item,\n codeTracerStageId(item, index + 1, trajectoryId),\n trajectoryId,\n ),\n )\n continue\n }\n if (!isRecord(item) || !Array.isArray(item.labels)) {\n throw new TypeError(\n `CodeTracer prediction '${trajectoryId}' contains an unsupported label row`,\n )\n }\n const stageId = codeTracerStageId(item, index + 1, trajectoryId)\n for (const label of item.labels) {\n if (!isCodeTracerStepLabel(label)) {\n throw new TypeError(\n `CodeTracer prediction '${trajectoryId}' contains an invalid step label`,\n )\n }\n flat.push(toCodeTracerPredictionLabel(label, stageId, trajectoryId))\n }\n }\n return flat\n}\n\nfunction isCodeTraceStageAnnotation(value: unknown): value is CodeTraceStageAnnotation {\n return (\n isRecord(value) &&\n Number.isSafeInteger(value.stage_id) &&\n (value.stage_id as number) > 0 &&\n optionalStepArray(value.incorrect_step_ids as readonly number[] | undefined) &&\n optionalStepArray(value.unuseful_step_ids as readonly number[] | undefined) &&\n (value.reasoning === undefined || typeof value.reasoning === 'string')\n )\n}\n\nfunction isCodeTracerStepLabel(value: unknown): value is CodeTracerStepLabel {\n return (\n isRecord(value) &&\n Number.isSafeInteger(value.step_id) &&\n (value.step_id as number) > 0 &&\n (value.stage === undefined ||\n typeof value.stage === 'string' ||\n typeof value.stage === 'number') &&\n (value.stage_name === undefined ||\n typeof value.stage_name === 'string' ||\n typeof value.stage_name === 'number') &&\n (value.stage_id === undefined ||\n typeof value.stage_id === 'string' ||\n typeof value.stage_id === 'number') &&\n (value.label === 'incorrect' || value.label === 'unuseful') &&\n (value.rationale === undefined || typeof value.rationale === 'string') &&\n (value.reason === undefined || typeof value.reason === 'string') &&\n (value.note === undefined || typeof value.note === 'string') &&\n (value.comment === undefined || typeof value.comment === 'string')\n )\n}\n\nfunction toCodeTracerPredictionLabel(\n label: CodeTracerStepLabel,\n stageId: string | number,\n trajectoryId: string,\n): {\n stageId: string | number\n area: CodeTracerStepLabel['label']\n step: number\n reasoning?: string\n} {\n if (!isCodeTracerStepLabel(label)) {\n throw new TypeError(`CodeTracer prediction '${trajectoryId}' contains an invalid step label`)\n }\n return {\n stageId,\n area: label.label,\n step: label.step_id,\n ...codeTracerReason(label, trajectoryId),\n }\n}\n\nfunction codeTracerStageId(\n value: { stage?: unknown; stage_name?: unknown; stage_id?: unknown },\n fallback: number,\n trajectoryId: string,\n): string | number {\n const candidates = [value.stage, value.stage_name, value.stage_id].filter(\n (candidate): candidate is string | number =>\n typeof candidate === 'string' || typeof candidate === 'number',\n )\n if (new Set(candidates).size > 1) {\n throw new TypeError(`CodeTracer prediction '${trajectoryId}' has conflicting stage fields`)\n }\n return candidates[0] ?? fallback\n}\n\nfunction codeTracerReason(\n label: CodeTracerStepLabel,\n trajectoryId: string,\n): { reasoning?: string } {\n const candidates = [label.rationale, label.reason, label.note, label.comment].filter(\n (candidate): candidate is string => candidate !== undefined,\n )\n if (new Set(candidates).size > 1) {\n throw new TypeError(\n `CodeTracer prediction '${trajectoryId}' step ${label.step_id} has conflicting reason fields`,\n )\n }\n return candidates[0] === undefined ? {} : { reasoning: candidates[0] }\n}\n\nfunction parseTags(value: CodeTraceBenchRow['tags'], trajectoryId: string): string[] {\n if (value === undefined) return []\n let parsed: unknown = value\n if (typeof value === 'string') {\n try {\n parsed = JSON.parse(value) as unknown\n } catch (error) {\n throw new TypeError(\n `CodeTraceBench '${trajectoryId}' tags is invalid JSON: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n if (!Array.isArray(parsed)) {\n throw new TypeError(`CodeTraceBench '${trajectoryId}' tags must be an array of strings`)\n }\n const tags = parsed.map((tag, index) =>\n requiredCodeTraceString(tag, `CodeTraceBench '${trajectoryId}' tags[${index}]`),\n )\n if (new Set(tags).size !== tags.length) {\n throw new TypeError(`CodeTraceBench '${trajectoryId}' tags must not repeat values`)\n }\n return tags\n}\n\nfunction codeTraceLabelSet(value: CodeTraceBenchLabelSet | undefined): CodeTraceBenchLabelSet {\n if (value === undefined || value === 'incorrect-only') return 'incorrect-only'\n if (value === 'incorrect-and-unuseful') return value\n throw new TypeError(\n \"CodeTraceBench labelSet must be 'incorrect-only' or 'incorrect-and-unuseful'\",\n )\n}\n\nfunction optionalStepArray(value: readonly number[] | undefined): boolean {\n return value === undefined || (Array.isArray(value) && value.every(Number.isSafeInteger))\n}\n\nfunction requiredCodeTraceString(value: unknown, field: string): string {\n if (typeof value !== 'string') throw new TypeError(`${field} must be a string`)\n return nonEmpty(value, field)\n}\n\nfunction optionalCodeTraceString(value: unknown, field: string): string | undefined {\n if (value === undefined) return undefined\n return requiredCodeTraceString(value, field)\n}\n\nfunction optionalSourceRelativePath(value: unknown, trajectoryId: string): string | undefined {\n const path = optionalCodeTraceString(value, `CodeTraceBench '${trajectoryId}' source_relpath`)\n if (path === undefined) return undefined\n const segments = path.replaceAll('\\\\', '/').split('/')\n if (\n path.startsWith('/') ||\n /^[a-zA-Z]:[\\\\/]/.test(path) ||\n segments.some((segment) => segment === '..')\n ) {\n throw new TypeError(\n `CodeTraceBench '${trajectoryId}' source_relpath must stay within the artifact root`,\n )\n }\n return path\n}\n\nfunction codeTraceSolved(value: unknown, trajectoryId: string): boolean | null | undefined {\n if (value === undefined || value === null || typeof value === 'boolean') return value\n throw new TypeError(`CodeTraceBench '${trajectoryId}' solved must be a boolean or null`)\n}\n","import type { AnalystBenchmarkObservation, AnalystBenchmarkResult } from './benchmark'\nimport { roundAgentRxStep } from './benchmark-datasets'\n\nexport const AGENT_RX_UPSTREAM_REVISION = 'f228165bfec60a801fd5fedd9d8ffe0f9de0c69d'\n\nexport interface AgentRxCalibrationRunnerSummary {\n runnerId: string\n selectedRuns: number\n completedRuns: number\n failedRuns: number\n predictedRuns: number\n missingPredictionRuns: number\n exactStepAccuracy: number | null\n stepAccuracyWithin1: number | null\n stepAccuracyWithin2: number | null\n stepAccuracyWithin3: number | null\n stepAccuracyWithin4: number | null\n stepAccuracyWithin5: number | null\n meanStepDistance: number | null\n normalizedMeanStepDistance: number | null\n normalizedDistanceRuns: number\n normalizedDistanceUnknownRuns: number\n rootCauseCategoryAccuracy: number | null\n anyFailureCategoryAccuracy: number | null\n earliestFailureCategoryAccuracy: number | null\n terminalFailureCategoryAccuracy: number | null\n}\n\nexport interface AgentRxCalibrationSummary {\n protocol: 'official-agentrx-root-cause'\n upstreamRevision: string\n rationale: string\n runners: AgentRxCalibrationRunnerSummary[]\n}\n\nexport function summarizeAgentRxCalibration(\n result: AnalystBenchmarkResult,\n upstreamRevision: string,\n): AgentRxCalibrationSummary {\n if (!upstreamRevision.trim()) {\n throw new TypeError('AgentRx calibration requires an upstream revision')\n }\n return {\n protocol: 'official-agentrx-root-cause',\n upstreamRevision,\n rationale:\n 'Matches AgentRx root-category accuracy, Python-rounded exact and tolerance step accuracy, unrounded mean step distance, normalized distance, and any, earliest, and terminal category accuracy. Failed runs and empty predictions score as no prediction.',\n runners: result.provenance.runnerIds.map((runnerId) =>\n summarizeRunner(\n runnerId,\n result.observations.filter((observation) => observation.runnerId === runnerId),\n ),\n ),\n }\n}\n\nexport function renderAgentRxCalibrationMarkdown(summary: AgentRxCalibrationSummary): string {\n return [\n '## AgentRx Published Metrics',\n '',\n summary.rationale,\n '',\n `Upstream revision: \\`${summary.upstreamRevision}\\`.`,\n '',\n '| Runner | Completed/selected | Failed | Predictions | Missing predictions | Exact step | Within 1 | Within 2 | Within 3 | Within 4 | Within 5 | Mean step distance | Normalized distance | Normalized known/unknown | Root category | Any category | Earliest category | Terminal category |',\n '| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |',\n ...summary.runners.map(\n (runner) =>\n `| ${escapeCell(runner.runnerId)} | ${runner.completedRuns}/${runner.selectedRuns} | ${runner.failedRuns} | ${runner.predictedRuns} | ${runner.missingPredictionRuns} | ${rate(runner.exactStepAccuracy)} | ${rate(runner.stepAccuracyWithin1)} | ${rate(runner.stepAccuracyWithin2)} | ${rate(runner.stepAccuracyWithin3)} | ${rate(runner.stepAccuracyWithin4)} | ${rate(runner.stepAccuracyWithin5)} | ${number(runner.meanStepDistance)} | ${number(runner.normalizedMeanStepDistance)} | ${runner.normalizedDistanceRuns}/${runner.normalizedDistanceUnknownRuns} | ${rate(runner.rootCauseCategoryAccuracy)} | ${rate(runner.anyFailureCategoryAccuracy)} | ${rate(runner.earliestFailureCategoryAccuracy)} | ${rate(runner.terminalFailureCategoryAccuracy)} |`,\n ),\n ].join('\\n')\n}\n\nfunction summarizeRunner(\n runnerId: string,\n observations: readonly AnalystBenchmarkObservation[],\n): AgentRxCalibrationRunnerSummary {\n const scored = observations.map(scoredObservation)\n const normalized = scored.filter(\n (row): row is ReturnType<typeof scoredObservation> & { normalizedDistance: number } =>\n row.normalizedDistance !== null,\n )\n const predicted = scored.filter(\n (row): row is ReturnType<typeof scoredObservation> & { distance: number } =>\n row.distance !== null,\n )\n return {\n runnerId,\n selectedRuns: observations.length,\n completedRuns: observations.filter((observation) => !observation.error).length,\n failedRuns: observations.filter((observation) => Boolean(observation.error)).length,\n predictedRuns: predicted.length,\n missingPredictionRuns: scored.length - predicted.length,\n exactStepAccuracy: mean(scored.map((row) => Number(row.roundedDistance === 0))),\n stepAccuracyWithin1: mean(\n scored.map((row) => Number(row.roundedDistance !== null && row.roundedDistance <= 1)),\n ),\n stepAccuracyWithin2: mean(\n scored.map((row) => Number(row.roundedDistance !== null && row.roundedDistance <= 2)),\n ),\n stepAccuracyWithin3: mean(\n scored.map((row) => Number(row.roundedDistance !== null && row.roundedDistance <= 3)),\n ),\n stepAccuracyWithin4: mean(\n scored.map((row) => Number(row.roundedDistance !== null && row.roundedDistance <= 4)),\n ),\n stepAccuracyWithin5: mean(\n scored.map((row) => Number(row.roundedDistance !== null && row.roundedDistance <= 5)),\n ),\n meanStepDistance: mean(predicted.map((row) => row.distance)),\n normalizedMeanStepDistance: mean(normalized.map((row) => row.normalizedDistance)),\n normalizedDistanceRuns: normalized.length,\n normalizedDistanceUnknownRuns: scored.length - normalized.length,\n rootCauseCategoryAccuracy: mean(scored.map((row) => Number(row.rootCategoryMatch))),\n anyFailureCategoryAccuracy: mean(scored.map((row) => Number(row.anyCategoryMatch))),\n earliestFailureCategoryAccuracy: mean(scored.map((row) => Number(row.earliestCategoryMatch))),\n terminalFailureCategoryAccuracy: mean(scored.map((row) => Number(row.terminalCategoryMatch))),\n }\n}\n\nfunction scoredObservation(observation: AnalystBenchmarkObservation) {\n const metadata = record(observation.caseMetadata)\n const rootStep = requiredPositiveNumber(\n metadata.rootCauseStep,\n observation.caseId,\n 'rootCauseStep',\n )\n const rootCategory = requiredString(\n metadata.rootCauseCategory,\n observation.caseId,\n 'rootCauseCategory',\n )\n const allCategories = requiredStringArray(\n metadata.allFailureCategories,\n observation.caseId,\n 'allFailureCategories',\n )\n const earliestCategory = requiredString(\n metadata.earliestFailureCategory,\n observation.caseId,\n 'earliestFailureCategory',\n )\n const terminalCategory = requiredString(\n metadata.terminalFailureCategory,\n observation.caseId,\n 'terminalFailureCategory',\n )\n const finding = observation.error ? undefined : observation.findings[0]\n const findingMetadata = record(finding?.metadata)\n const stepMean = finding\n ? finiteNonNegative(\n findingMetadata.step_mean ?? findingMetadata.step,\n observation.caseId,\n 'predicted step',\n )\n : null\n const roundedDistance = stepMean === null ? null : Math.abs(roundAgentRxStep(stepMean) - rootStep)\n const distance = stepMean === null ? null : Math.abs(stepMean - rootStep)\n const trajectoryLength =\n metadata.trajectoryLength === undefined\n ? null\n : requiredPositiveNumber(metadata.trajectoryLength, observation.caseId, 'trajectoryLength')\n const predictedCategory = finding?.area\n return {\n roundedDistance,\n distance,\n normalizedDistance:\n trajectoryLength === null || distance === null ? null : distance / trajectoryLength,\n rootCategoryMatch: predictedCategory === rootCategory,\n anyCategoryMatch: predictedCategory !== undefined && allCategories.includes(predictedCategory),\n earliestCategoryMatch: predictedCategory === earliestCategory,\n terminalCategoryMatch: predictedCategory === terminalCategory,\n }\n}\n\nfunction record(value: unknown): Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {}\n}\n\nfunction requiredPositiveNumber(value: unknown, caseId: string, field: string): number {\n const numberValue = finiteNonNegative(value, caseId, field)\n if (numberValue <= 0) throw new TypeError(`${caseId}: ${field} must be positive`)\n return numberValue\n}\n\nfunction finiteNonNegative(value: unknown, caseId: string, field: string): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) {\n throw new TypeError(`${caseId}: ${field} must be a finite non-negative number`)\n }\n return value\n}\n\nfunction requiredString(value: unknown, caseId: string, field: string): string {\n if (typeof value !== 'string' || !value.trim()) {\n throw new TypeError(`${caseId}: ${field} must be a non-empty string`)\n }\n return value\n}\n\nfunction requiredStringArray(value: unknown, caseId: string, field: string): string[] {\n if (\n !Array.isArray(value) ||\n value.length === 0 ||\n value.some((entry) => typeof entry !== 'string' || !entry.trim())\n ) {\n throw new TypeError(`${caseId}: ${field} must be a non-empty string array`)\n }\n return value as string[]\n}\n\nfunction mean(values: readonly number[]): number | null {\n return values.length === 0\n ? null\n : values.reduce((total, value) => total + value, 0) / values.length\n}\n\nfunction rate(value: number | null): string {\n return value === null ? 'n/a' : value.toFixed(3)\n}\n\nfunction number(value: number | null): string {\n return value === null ? 'n/a' : value.toFixed(3)\n}\n\nfunction escapeCell(value: string): string {\n return value.replaceAll('|', '\\\\|').replaceAll('\\n', ' ')\n}\n","import { z } from 'zod'\nimport type { AnalystBenchmarkObservation } from './benchmark'\nimport type { AnalystBenchmarkArtifact } from './benchmark-command-artifact'\n\nconst nonEmptyString = z.string().refine((value) => value.trim().length > 0, {\n message: 'must be a non-empty string',\n})\nconst safeInteger = z.number().refine(Number.isSafeInteger, {\n message: 'must be a safe integer',\n})\nconst nonNegativeInteger = safeInteger.refine((value) => value >= 0, {\n message: 'must be a non-negative safe integer',\n})\nconst positiveInteger = safeInteger.refine((value) => value > 0, {\n message: 'must be a positive safe integer',\n})\nconst nonNegativeNumber = z.number().nonnegative()\nconst rate = z.number().min(0).max(1)\nconst nullableRate = rate.nullable()\nconst finiteNumber = z.number()\nconst nullableFiniteNumber = finiteNumber.nullable()\nconst sha256 = z.string().regex(/^[a-f0-9]{64}$/, 'must be a lowercase SHA-256 digest')\nconst revision = z\n .string()\n .regex(/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/, 'must be a lowercase 40 or 64 character revision')\nconst timestamp = z.string().refine((value) => Number.isFinite(Date.parse(value)), {\n message: 'must be a valid timestamp',\n})\nconst stringArray = z.array(z.string())\nconst nonEmptyStringArray = z.array(nonEmptyString)\nconst metadata = z.record(z.string(), z.unknown())\n\nconst errorSchema = z.strictObject({\n class: nonEmptyString,\n message: nonEmptyString,\n code: nonEmptyString.optional(),\n status: z.number().int().min(100).max(599).optional(),\n})\n\nconst evidenceSchema = z.strictObject({\n kind: z.enum(['span', 'event', 'artifact', 'finding', 'metric']),\n uri: nonEmptyString,\n excerpt: z.string().optional(),\n})\n\nconst findingSchema = z.strictObject({\n schema_version: z.literal('1.0.0'),\n finding_id: nonEmptyString,\n analyst_id: nonEmptyString,\n produced_at: timestamp,\n severity: z.enum(['critical', 'high', 'medium', 'low', 'info']),\n area: nonEmptyString,\n claim: nonEmptyString,\n rationale: z.string().optional(),\n evidence_refs: z.array(evidenceSchema),\n recommended_action: z.string().optional(),\n validation_plan: z.string().optional(),\n confidence: rate,\n subject: z.string().optional(),\n derived_from_judge: z.boolean().optional(),\n metadata: metadata.optional(),\n})\n\nconst tokenUsageSchema = z\n .strictObject({\n input: nonNegativeInteger,\n output: nonNegativeInteger,\n reasoning: nonNegativeInteger.optional(),\n cached: nonNegativeInteger.optional(),\n cacheWrite: nonNegativeInteger.optional(),\n })\n .superRefine((usage, context) => {\n if (usage.reasoning !== undefined && usage.reasoning > usage.output) {\n context.addIssue({\n code: 'custom',\n path: ['reasoning'],\n message: 'must not exceed output tokens',\n })\n }\n })\n\nconst costSchema = z.discriminatedUnion('kind', [\n z.strictObject({\n kind: z.literal('observed'),\n usd: nonNegativeNumber,\n }),\n z.strictObject({\n kind: z.literal('estimated'),\n usd: nonNegativeNumber,\n }),\n z.strictObject({\n kind: z.literal('uncaptured'),\n usd: z.null(),\n }),\n])\n\nconst usageSchema = z.strictObject({\n calls: nonNegativeInteger.nullable(),\n tokens: tokenUsageSchema.nullable(),\n cost: costSchema,\n knownCostUsd: nonNegativeNumber.optional(),\n})\n\nconst findingScoreSchema = z.strictObject({\n expectedIssueCount: nonNegativeInteger,\n matchedIssueIds: nonEmptyStringArray,\n missedIssueIds: nonEmptyStringArray,\n supportedFindingIndexes: z.array(nonNegativeInteger),\n unsupportedFindingIndexes: z.array(nonNegativeInteger),\n unlabeledEvidence: z.array(evidenceSchema),\n issueRecall: rate,\n findingPrecision: rate,\n f1: rate,\n criticalStepAccuracy: nullableRate,\n citationCoverage: nullableRate,\n citationExcerptCoverage: nullableRate,\n citationLabelAgreement: nullableRate,\n predictionOnLabelEmptyCase: z.boolean(),\n})\n\nconst evidenceResolutionSchema = z.strictObject({\n checked: nonNegativeInteger,\n resolved: nonNegativeInteger,\n unresolvedEvidence: z.array(evidenceSchema),\n errors: z.array(\n z.strictObject({\n evidence: evidenceSchema,\n class: nonEmptyString,\n message: nonEmptyString,\n }),\n ),\n validity: nullableRate,\n})\n\nconst observationSchema: z.ZodType<AnalystBenchmarkObservation> = z\n .strictObject({\n runnerId: nonEmptyString,\n caseId: nonEmptyString,\n clusterId: nonEmptyString,\n labelState: z.enum(['positive', 'trusted-negative', 'unlabeled']),\n repetition: nonNegativeInteger,\n executionIndex: nonNegativeInteger,\n latencyMs: nonNegativeNumber.nullable(),\n latencySource: z.enum(['benchmark-clock', 'runner-reported', 'uncaptured']),\n findings: z.array(findingSchema),\n score: findingScoreSchema,\n evidenceResolution: evidenceResolutionSchema.optional(),\n caseTags: stringArray,\n caseMetadata: metadata.optional(),\n usage: usageSchema.optional(),\n runnerMetadata: metadata.optional(),\n error: errorSchema.optional(),\n })\n .superRefine((observation, context) => {\n const latencyIsMissing = observation.latencyMs === null\n if (\n (observation.latencySource === 'uncaptured' && !latencyIsMissing) ||\n (observation.latencySource !== 'uncaptured' && latencyIsMissing)\n ) {\n context.addIssue({\n code: 'custom',\n path: ['latencyMs'],\n message: `must ${observation.latencySource === 'uncaptured' ? '' : 'not '}be null for '${observation.latencySource}' latency`,\n })\n }\n })\n\nconst latencyDistributionSchema = z.strictObject({\n min: nonNegativeNumber,\n mean: nonNegativeNumber,\n p50: nonNegativeNumber,\n p95: nonNegativeNumber,\n max: nonNegativeNumber,\n})\n\nconst summarySchema = z.strictObject({\n runnerId: nonEmptyString,\n plannedRuns: nonNegativeInteger,\n completedRuns: nonNegativeInteger,\n failedRuns: nonNegativeInteger,\n issueBearingRuns: nonNegativeInteger,\n trustedNegativeRuns: nonNegativeInteger,\n unlabeledRuns: nonNegativeInteger,\n issueRecall: nullableRate,\n findingPrecision: nullableRate,\n f1: nullableRate,\n macroIssueRecall: nullableRate,\n macroFindingPrecision: nullableRate,\n macroF1: nullableRate,\n criticalStepAccuracy: nullableRate,\n citationCoverage: nullableRate,\n citationExcerptCoverage: nullableRate,\n citationLabelAgreement: nullableRate,\n citationResolution: nullableRate,\n citationResolutionUnknownRuns: nonNegativeInteger,\n unresolvedCitations: nonNegativeInteger,\n citationResolutionErrors: nonNegativeInteger,\n trustedNegativeFalsePositiveRate: nullableRate,\n trustedNegativeFailureRate: nullableRate,\n unlabeledPredictionRate: nullableRate,\n unlabeledFailureRate: nullableRate,\n predictionAgreement: nullableRate,\n predictionAgreementCases: nonNegativeInteger,\n matchedLabelAgreement: nullableRate,\n matchedLabelAgreementCases: nonNegativeInteger,\n latencyMs: latencyDistributionSchema.nullable(),\n benchmarkClockLatencyRuns: nonNegativeInteger,\n runnerReportedLatencyRuns: nonNegativeInteger,\n latencyUnknownRuns: nonNegativeInteger,\n calls: nonNegativeInteger,\n callsUnknownRuns: nonNegativeInteger,\n inputTokens: nonNegativeInteger,\n outputTokens: nonNegativeInteger,\n reasoningTokens: nonNegativeInteger,\n cachedTokens: nonNegativeInteger,\n cacheWriteTokens: nonNegativeInteger,\n tokenUsageUnknownRuns: nonNegativeInteger,\n reasoningTokenUsageUnknownRuns: nonNegativeInteger,\n cachedTokenUsageUnknownRuns: nonNegativeInteger,\n cacheWriteTokenUsageUnknownRuns: nonNegativeInteger,\n knownCostUsd: nonNegativeNumber,\n costUnknownRuns: nonNegativeInteger,\n})\n\nconst provenanceSchema = z\n .strictObject({\n id: nonEmptyString.optional(),\n dataset: z\n .strictObject({\n id: nonEmptyString,\n revision: nonEmptyString,\n split: nonEmptyString.optional(),\n })\n .optional(),\n command: nonEmptyString.optional(),\n environment: z.record(z.string(), z.string()).optional(),\n metadata: metadata.optional(),\n startedAt: timestamp,\n endedAt: timestamp,\n caseCount: positiveInteger,\n runnerIds: nonEmptyStringArray.min(1),\n repetitions: positiveInteger,\n maxConcurrency: positiveInteger,\n runnerOrderSeed: safeInteger,\n })\n .superRefine((provenance, context) => {\n if (Date.parse(provenance.endedAt) < Date.parse(provenance.startedAt)) {\n context.addIssue({\n code: 'custom',\n path: ['endedAt'],\n message: 'must not precede startedAt',\n })\n }\n })\n\nconst resultSchema = z.strictObject({\n provenance: provenanceSchema,\n observations: z.array(observationSchema),\n summaries: z.array(summarySchema),\n})\n\nconst comparisonMetricSchema = z.strictObject({\n metric: z.enum([\n 'completion',\n 'issueRecall',\n 'findingPrecision',\n 'f1',\n 'criticalStepAccuracy',\n 'citationCoverage',\n 'citationExcerptCoverage',\n 'citationLabelAgreement',\n 'citationResolution',\n 'trustedNegativeAccuracy',\n 'latencyMs',\n 'calls',\n 'inputTokens',\n 'outputTokens',\n 'reasoningTokens',\n 'cachedTokens',\n 'cacheWriteTokens',\n 'costUsd',\n ]),\n direction: z.enum(['higher', 'lower']),\n pairedCases: nonNegativeInteger,\n pairedClusters: nonNegativeInteger,\n eligibleObservations: nonNegativeInteger,\n pairedObservations: nonNegativeInteger,\n baselineMissingObservations: nonNegativeInteger,\n candidateMissingObservations: nonNegativeInteger,\n asymmetricMissingObservations: nonNegativeInteger,\n survivorOnly: z.boolean(),\n baselineMean: nullableFiniteNumber,\n candidateMean: nullableFiniteNumber,\n meanDelta: nullableFiniteNumber,\n intervalLow: nullableFiniteNumber,\n intervalHigh: nullableFiniteNumber,\n confidence: z.number().gt(0).lt(1),\n resamples: positiveInteger,\n minimumSampleMet: z.boolean(),\n populationInferenceEligible: z.boolean(),\n inferenceLimitations: stringArray,\n})\n\nconst comparisonSchema = z.strictObject({\n baselineRunnerId: nonEmptyString,\n candidateRunnerId: nonEmptyString,\n metrics: z.array(comparisonMetricSchema),\n})\n\nconst valueDistributionSchema = z.strictObject({\n total: nonNegativeInteger,\n missing: nonNegativeInteger,\n counts: z.record(z.string(), nonNegativeInteger),\n})\n\nconst distributionsSchema = z.strictObject({\n class: valueDistributionSchema,\n agent: valueDistributionSchema,\n model: valueDistributionSchema,\n difficulty: valueDistributionSchema,\n solved: valueDistributionSchema,\n})\n\nconst selectionReportSchema = z.strictObject({\n method: z.enum(['census', 'deterministic-hash']),\n seed: safeInteger,\n sourceCount: positiveInteger,\n selectedCount: positiveInteger,\n stratified: z.literal(false),\n representativeOfInput: z.boolean(),\n source: distributionsSchema,\n selected: distributionsSchema,\n})\n\nconst verificationOutcomeSchema = z.strictObject({\n status: z.enum(['passed', 'failed', 'unavailable']),\n reason: z\n .enum([\n 'missing-result',\n 'result-output-unavailable',\n 'result-parse-error',\n 'result-label-disagreement',\n ])\n .optional(),\n parseError: errorSchema.optional(),\n sources: z.array(\n z.strictObject({\n path: nonEmptyString,\n format: z.enum(['terminal-bench', 'swe-bench', 'swe-multi']),\n status: z.enum(['passed', 'failed', 'unavailable']),\n }),\n ),\n passedCheckCount: nonNegativeInteger,\n failedCheckCount: nonNegativeInteger,\n passedChecks: stringArray,\n failedChecks: stringArray,\n})\n\nconst verificationArtifactRole = z.enum(['final-test-output', 'final-result', 'final-metrics'])\n\nconst verificationArtifactSchema = z.strictObject({\n traceId: nonEmptyString,\n status: z.enum(['present', 'missing']),\n outcome: verificationOutcomeSchema,\n outcomeSpanId: nonEmptyString,\n caseDirectory: nonEmptyString,\n caseDirectoriesSearched: nonEmptyStringArray,\n totalBytes: nonNegativeInteger,\n maxBytes: positiveInteger,\n files: z.array(\n z.strictObject({\n role: verificationArtifactRole,\n path: nonEmptyString,\n relativePath: nonEmptyString,\n sha256,\n bytes: nonNegativeInteger,\n spanId: nonEmptyString,\n }),\n ),\n missingRoles: z.array(verificationArtifactRole),\n searched: z.strictObject({\n 'final-test-output': stringArray,\n 'final-result': stringArray,\n 'final-metrics': stringArray,\n }),\n})\n\nconst verificationAvailabilitySchema = z.strictObject({\n cases: nonNegativeInteger,\n resultFilesPresent: nonNegativeInteger,\n resultFilesMissing: nonNegativeInteger,\n outcomes: z.strictObject({\n passed: nonNegativeInteger,\n failed: nonNegativeInteger,\n unavailable: nonNegativeInteger,\n }),\n})\n\nconst codeTraceCalibrationSchema = z.strictObject({\n protocol: z.literal('labeled-positive-and-solved-negative'),\n rationale: nonEmptyString,\n runners: z.array(\n z.strictObject({\n runnerId: nonEmptyString,\n selectedRuns: nonNegativeInteger,\n positiveRuns: nonNegativeInteger,\n trustedNegativeRuns: nonNegativeInteger,\n unlabeledRuns: nonNegativeInteger,\n failedLabelEmptyRuns: nonNegativeInteger,\n unknownLabelEmptyRuns: nonNegativeInteger,\n completedRuns: nonNegativeInteger,\n failedRuns: nonNegativeInteger,\n expectedIncorrectSteps: nonNegativeInteger,\n predictedIncorrectSteps: nonNegativeInteger,\n matchedIncorrectSteps: nonNegativeInteger,\n officialAllRowF1: nullableRate,\n officialAllRowRuns: nonNegativeInteger,\n precision: nullableRate,\n recall: nullableRate,\n f1: nullableRate,\n trustedNegativeFalsePositiveRate: nullableRate,\n trustedNegativeFailureRate: nullableRate,\n unlabeledPredictionRate: nullableRate,\n unlabeledFailureRate: nullableRate,\n }),\n ),\n})\n\nconst agentRxCalibrationSchema = z.strictObject({\n protocol: z.literal('official-agentrx-root-cause'),\n upstreamRevision: revision,\n rationale: nonEmptyString,\n runners: z.array(\n z.strictObject({\n runnerId: nonEmptyString,\n selectedRuns: nonNegativeInteger,\n completedRuns: nonNegativeInteger,\n failedRuns: nonNegativeInteger,\n predictedRuns: nonNegativeInteger,\n missingPredictionRuns: nonNegativeInteger,\n exactStepAccuracy: nullableRate,\n stepAccuracyWithin1: nullableRate,\n stepAccuracyWithin2: nullableRate,\n stepAccuracyWithin3: nullableRate,\n stepAccuracyWithin4: nullableRate,\n stepAccuracyWithin5: nullableRate,\n meanStepDistance: nonNegativeNumber.nullable(),\n normalizedMeanStepDistance: nullableRate,\n normalizedDistanceRuns: nonNegativeInteger,\n normalizedDistanceUnknownRuns: nonNegativeInteger,\n rootCauseCategoryAccuracy: nullableRate,\n anyFailureCategoryAccuracy: nullableRate,\n earliestFailureCategoryAccuracy: nullableRate,\n terminalFailureCategoryAccuracy: nullableRate,\n }),\n ),\n})\n\nconst artifactSchema: z.ZodType<AnalystBenchmarkArtifact> = z\n .strictObject({\n kind: z.literal('agent-eval/analyst-benchmark-result'),\n runIdentitySha256: sha256,\n inputs: z.strictObject({\n dataset: z.enum(['agentrx', 'codetracebench']),\n datasetRevision: revision,\n datasetSplit: nonEmptyString,\n labelsSha256: sha256,\n sourceRowCount: positiveInteger,\n traceFiles: z.array(\n z.strictObject({\n traceId: nonEmptyString,\n relativePath: nonEmptyString,\n sha256,\n }),\n ),\n verificationArtifacts: z.array(verificationArtifactSchema),\n verificationAvailability: verificationAvailabilitySchema,\n selection: z.strictObject({\n limit: positiveInteger,\n seed: safeInteger,\n selectedCaseIds: nonEmptyStringArray.min(1),\n report: selectionReportSchema,\n }),\n execution: z.strictObject({\n repetitions: positiveInteger,\n concurrency: positiveInteger,\n model: nonEmptyString,\n maxOutputTokens: positiveInteger,\n timeoutMs: positiveInteger,\n maxCostUsd: nonNegativeNumber,\n maxArtifactBytes: positiveInteger,\n analystProtocolSha256: sha256,\n implementationSha256: sha256,\n dependencyLockSha256: sha256,\n }),\n }),\n result: resultSchema,\n comparisons: z.array(comparisonSchema),\n codeTraceCalibration: codeTraceCalibrationSchema.optional(),\n agentRxCalibration: agentRxCalibrationSchema.optional(),\n })\n .superRefine((artifact, context) => {\n const isCodeTrace = artifact.inputs.dataset === 'codetracebench'\n if (isCodeTrace && !artifact.codeTraceCalibration) {\n context.addIssue({\n code: 'custom',\n path: ['codeTraceCalibration'],\n message: 'is required for CodeTraceBench artifacts',\n })\n }\n if (isCodeTrace && artifact.agentRxCalibration) {\n context.addIssue({\n code: 'custom',\n path: ['agentRxCalibration'],\n message: 'is not allowed for CodeTraceBench artifacts',\n })\n }\n if (!isCodeTrace && !artifact.agentRxCalibration) {\n context.addIssue({\n code: 'custom',\n path: ['agentRxCalibration'],\n message: 'is required for AgentRx artifacts',\n })\n }\n if (!isCodeTrace && artifact.codeTraceCalibration) {\n context.addIssue({\n code: 'custom',\n path: ['codeTraceCalibration'],\n message: 'is not allowed for AgentRx artifacts',\n })\n }\n })\n\nexport function assertAnalystBenchmarkObservation(\n value: unknown,\n context: string,\n): asserts value is AnalystBenchmarkObservation {\n assertSchema(observationSchema, value, context)\n}\n\nexport function assertAnalystBenchmarkArtifact(\n value: unknown,\n context: string,\n): asserts value is AnalystBenchmarkArtifact {\n assertSchema(artifactSchema, value, context)\n}\n\nfunction assertSchema(schema: z.ZodType, value: unknown, context: string): void {\n const result = schema.safeParse(value)\n if (result.success) return\n throw new TypeError(formatIssue(result.error.issues[0]!, context))\n}\n\nfunction formatIssue(issue: z.core.$ZodIssue, context: string): string {\n const path = issue.path.length === 0 ? context : `${context}.${issue.path.join('.')}`\n if (issue.code === 'unrecognized_keys') {\n return `${path} contains unknown field '${issue.keys[0]}'`\n }\n return `${path} ${issue.message}`\n}\n","import { createHash } from 'node:crypto'\nimport type { AnalystBenchmarkObservation, AnalystBenchmarkResult } from './benchmark'\nimport type { AgentRxCalibrationSummary } from './benchmark-agentrx-calibration'\nimport type { AnalystRunnerComparison } from './benchmark-comparison'\nimport type { CodeTraceCalibrationSummary } from './benchmark-public-calibration'\nimport type {\n PublicAnalystBenchmarkDataset,\n PublicBenchmarkSelectionReport,\n} from './benchmark-real-model'\nimport type { VerificationArtifactManifest } from './benchmark-verification-artifacts'\n\nexport { assertAnalystBenchmarkObservation } from './benchmark-command-validation'\n\nexport interface AnalystBenchmarkArtifact {\n kind: 'agent-eval/analyst-benchmark-result'\n runIdentitySha256: string\n inputs: {\n dataset: PublicAnalystBenchmarkDataset\n datasetRevision: string\n datasetSplit: string\n labelsSha256: string\n sourceRowCount: number\n traceFiles: Array<{ traceId: string; relativePath: string; sha256: string }>\n verificationArtifacts: VerificationArtifactManifest[]\n verificationAvailability: VerificationAvailabilitySummary\n selection: {\n limit: number\n seed: number\n selectedCaseIds: string[]\n report: PublicBenchmarkSelectionReport\n }\n execution: {\n repetitions: number\n concurrency: number\n model: string\n maxOutputTokens: number\n timeoutMs: number\n maxCostUsd: number\n maxArtifactBytes: number\n analystProtocolSha256: string\n implementationSha256: string\n dependencyLockSha256: string\n }\n }\n result: AnalystBenchmarkResult\n comparisons: AnalystRunnerComparison[]\n codeTraceCalibration?: CodeTraceCalibrationSummary\n agentRxCalibration?: AgentRxCalibrationSummary\n}\n\nexport interface VerificationAvailabilitySummary {\n cases: number\n resultFilesPresent: number\n resultFilesMissing: number\n outcomes: {\n passed: number\n failed: number\n unavailable: number\n }\n}\n\nexport interface AnalystBenchmarkRunIdentity {\n config: {\n dataset: PublicAnalystBenchmarkDataset\n datasetRevision: string\n datasetSplit: string\n model: {\n id: string\n maxOutputTokens: number\n timeoutMs: number\n }\n limit: number\n seed: number\n concurrency: number\n repetitions: number\n maxCostUsd: number\n maxArtifactBytes: number\n analystProtocolSha256: string\n implementationSha256: string\n dependencyLockSha256: string\n runnerIds: readonly ['empty', string]\n }\n inputs: {\n labelsSha256: string\n sourceRowCount: number\n selectedCaseIds: string[]\n traceFiles: Array<{ traceId: string; relativePath: string; sha256: string }>\n verificationArtifactsSha256: string\n caseDefinitionsSha256: string\n }\n}\n\nexport interface AnalystBenchmarkRunManifest {\n kind: 'agent-eval/analyst-benchmark-run'\n createdAt: string\n identitySha256: string\n localIdentitySha256: string\n identity: AnalystBenchmarkRunIdentity\n}\n\nexport interface AnalystBenchmarkLocalRunReceipt {\n kind: 'agent-eval/analyst-benchmark-local-run'\n runIdentitySha256: string\n localIdentitySha256: string\n local: {\n labelsPath: string\n traceDir: string\n artifactDir?: string\n outputDir: string\n baseUrl: string\n apiKeyEnvironment: string\n }\n command: string\n environment: {\n node: string\n platform: string\n arch: string\n }\n files: {\n manifest: string\n observations: string\n costLedger: string\n modelResponses: string\n result: string\n report: string\n }\n}\n\nexport interface AnalystBenchmarkProgressRow {\n sequence: number\n runIdentitySha256: string\n previousRowSha256: string | null\n observation: AnalystBenchmarkObservation\n rowSha256: string\n}\n\nexport const ANALYST_BENCHMARK_MANIFEST_FILE = 'manifest.json'\nexport const ANALYST_BENCHMARK_OBSERVATIONS_FILE = 'observations.jsonl'\nexport const ANALYST_BENCHMARK_LOCAL_RECEIPT_FILE = 'run.local.json'\nexport const ANALYST_BENCHMARK_COST_LEDGER_FILE = 'cost-ledger.jsonl'\n\nexport function observationKey(observation: {\n runnerId: string\n caseId: string\n repetition: number\n}): string {\n return `${observation.runnerId}\\u0000${observation.caseId}\\u0000${observation.repetition}`\n}\n\nexport function parseJson(text: string, source: string): unknown {\n try {\n return JSON.parse(text)\n } catch {\n throw new Error(`invalid JSON in ${source}`)\n }\n}\n\nexport function assertExactKeys(\n value: Record<string, unknown>,\n allowed: readonly string[],\n context: string,\n optional: readonly string[] = [],\n): void {\n const allowedSet = new Set(allowed)\n const optionalSet = new Set(optional)\n for (const key of Object.keys(value)) {\n if (!allowedSet.has(key)) throw new TypeError(`${context} contains unknown field '${key}'`)\n }\n for (const key of allowed) {\n if (!optionalSet.has(key) && !(key in value)) {\n throw new TypeError(`${context} is missing field '${key}'`)\n }\n }\n}\n\nexport function digestCanonical(value: unknown): string {\n return createHash('sha256').update(canonicalJson(value)).digest('hex')\n}\n\nexport function canonicalJson(value: unknown): string {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') {\n return JSON.stringify(value)\n }\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) throw new TypeError('cannot hash a non-finite number')\n return JSON.stringify(value)\n }\n if (Array.isArray(value)) return `[${value.map(canonicalJson).join(',')}]`\n if (isRecord(value)) {\n return `{${Object.keys(value)\n .filter((key) => value[key] !== undefined)\n .sort()\n .map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`)\n .join(',')}}`\n }\n throw new TypeError(`cannot hash ${typeof value}`)\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport function isSha256(value: unknown): value is string {\n return typeof value === 'string' && /^[a-f0-9]{64}$/.test(value)\n}\n\nexport function isNonNegativeSafeInteger(value: unknown): value is number {\n return Number.isSafeInteger(value) && Number(value) >= 0\n}\n\nexport function isNonNegativeFinite(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value) && value >= 0\n}\n","export const ANALYST_BENCHMARK_IMPLEMENTATION_DIGEST_ALGORITHM = 'sha256-canonical-source-manifest'\n\nexport const ANALYST_BENCHMARK_DEPENDENCY_LOCK_DIGEST_ALGORITHM = 'sha256-canonical-file-manifest'\n\nexport const ANALYST_BENCHMARK_DEPENDENCY_LOCK_FILES = Object.freeze([\n 'clients/python/pyproject.toml',\n 'clients/python/uv.lock',\n 'package.json',\n 'pnpm-lock.yaml',\n])\n\nexport const ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256 =\n '11ea62baf2914dba71dd62e45ba4bb8e856b2cefdd5b1b73dc2f14b4b6e6d115'\n\n/** The published benchmark evidence was produced at this package version, by\n * the retired one-shot direct runner, before trace analysts moved to the\n * recursive DSPy RLM engine. Both evidence digests below are historical facts\n * about that artifact: the current implementation and dependency manifest have\n * since changed, so they cannot describe the current engine. A fresh certified\n * run must replace the published evidence before any accuracy number is\n * attributed to the engine that ships today. */\nexport const ANALYST_BENCHMARK_EVIDENCE_PACKAGE_VERSION = '0.137.0'\n\nexport const ANALYST_BENCHMARK_EVIDENCE_DEPENDENCY_LOCK_SHA256 =\n '1e03f2daed356d60316aabefb407ec1e437ac94d408d61eea4ae096e9c6fbb5b'\n\nexport const ANALYST_BENCHMARK_EVIDENCE_IMPLEMENTATION_SHA256 =\n '4dba263b6256a30d56c7fdb2d992d3a953c0035d731f359b704db806f68f75ac'\n\nexport const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([\n 'clients/python/src/agent_eval_rpc/dspy_rlm_bridge.py',\n 'clients/python/src/agent_eval_rpc/optimizer_bridge_common.py',\n 'src/analyst/benchmark-agentrx-calibration.ts',\n 'src/analyst/benchmark-command-artifact.ts',\n 'src/analyst/benchmark-command-persistence.ts',\n 'src/analyst/benchmark-command-result.ts',\n 'src/analyst/benchmark-command-validation.ts',\n 'src/analyst/benchmark-command.ts',\n 'src/analyst/benchmark-comparison.ts',\n 'src/analyst/benchmark-dataset-agentrx.ts',\n 'src/analyst/benchmark-dataset-codetrace.ts',\n 'src/analyst/benchmark-dataset-utils.ts',\n 'src/analyst/benchmark-datasets.ts',\n 'src/analyst/benchmark-evidence-validation.ts',\n 'src/analyst/benchmark-public-adapters.ts',\n 'src/analyst/benchmark-public-calibration.ts',\n 'src/analyst/benchmark-public-data.ts',\n 'src/analyst/benchmark-public-errors.ts',\n 'src/analyst/benchmark-public-model.ts',\n 'src/analyst/benchmark-public-prompt.ts',\n 'src/analyst/benchmark-public-rlm.ts',\n 'src/analyst/benchmark-public-types.ts',\n 'src/analyst/benchmark-real-model.ts',\n 'src/analyst/benchmark-report.ts',\n 'src/analyst/benchmark-response-cache.ts',\n 'src/analyst/benchmark-scoring.ts',\n 'src/analyst/benchmark-summary.ts',\n 'src/analyst/benchmark-verification-artifacts.ts',\n 'src/analyst/benchmark-verification-outcome.ts',\n 'src/analyst/benchmark.ts',\n 'src/analyst/dspy-rlm-engine.ts',\n 'src/analyst/engine.ts',\n 'src/analyst/exact-types.ts',\n 'src/analyst/finding-signature.ts',\n 'src/analyst/finding-subject.ts',\n 'src/analyst/kind-factory.ts',\n 'src/analyst/parse-tolerant.ts',\n 'src/analyst/tool-groups.ts',\n 'src/analyst/trace-tool-callback.ts',\n 'src/analyst/types.ts',\n 'src/analyst/usage-receipt.ts',\n 'src/campaign/external-optimizer-contracts.ts',\n 'src/campaign/external-optimizer-http.ts',\n 'src/campaign/external-optimizer-model-proxy.ts',\n 'src/campaign/external-optimizer-resources.ts',\n 'src/campaign/external-optimizer-subprocess.ts',\n 'src/campaign/search-ledger-errors.ts',\n 'src/campaign/search-ledger-file.ts',\n 'src/campaign/single-run-lock.ts',\n 'src/campaign/storage.ts',\n 'src/concurrency.ts',\n 'src/cost-ledger.ts',\n 'src/errors.ts',\n 'src/judge-calibration.ts',\n 'src/ledger-core/atomic-file-lock.ts',\n 'src/ledger-core/canonical.ts',\n 'src/ledger-core/deep-freeze.ts',\n 'src/ledger-core/index.ts',\n 'src/ledger-core/journal-file.ts',\n 'src/ledger-core/journal.ts',\n 'src/ledger-core/trusted-head.ts',\n 'src/llm-client.ts',\n 'src/math/normal.ts',\n 'src/math/special-functions.ts',\n 'src/math/student-t.ts',\n 'src/metrics.ts',\n 'src/statistics.ts',\n 'src/trace-analyst/errors.ts',\n 'src/trace-analyst/otlp-span.ts',\n 'src/trace-analyst/shared-abortable-task.ts',\n 'src/trace-analyst/store-boundary.ts',\n 'src/trace-analyst/store-bounds.ts',\n 'src/trace-analyst/store-contract.ts',\n 'src/trace-analyst/store-otlp.ts',\n 'src/trace-analyst/store-schemas.ts',\n 'src/trace-analyst/store.ts',\n 'src/trace-analyst/tools.ts',\n 'src/trace-analyst/types.ts',\n 'src/trace/attribute-vocabulary.ts',\n 'src/trace/otlp-attributes.ts',\n 'src/trace/raw-provider-sink.ts',\n])\n\nexport const ANALYST_BENCHMARK_IMPLEMENTATION_SHA256 =\n '26820de559ca069145eb9649283d2efba51a0a7b8d3662d4c378b9ecebfd4777'\n\nexport function analystBenchmarkImplementationDigest() {\n return ANALYST_BENCHMARK_IMPLEMENTATION_SHA256\n}\n\nexport function analystBenchmarkDependencyLockDigest() {\n return ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256\n}\n","import { TRACE_ANALYSIS_LIMITS, type TraceAnalysisStore } from '../trace-analyst/store'\nimport type { AnalystFinding, EvidenceRef } from './types'\n\nconst MIN_ACTION_EXCERPT_CHARACTERS = 12\nexport const MAX_ASSISTANT_STEP_EVIDENCE_EXCERPT_CHARACTERS = 512\nconst MAX_LABEL_SCAN_DEPTH = 64\nconst MAX_SERIALIZED_JSON_SCAN_BYTES = 64 * 1024\nconst MAX_SERIALIZED_JSON_SCAN_DEPTH = 8\n\nconst BENCHMARK_LABEL_KEYS = new Set([\n 'category_reason',\n 'failure_category',\n 'failure_summary',\n 'incorrect_stages',\n 'incorrect_step_ids',\n 'root_cause',\n 'root_cause_failure_id',\n 'root_cause_reason',\n 'step_reason',\n 'unuseful_step_ids',\n])\nconst BENCHMARK_LABEL_KEY_TOKENS = [...BENCHMARK_LABEL_KEYS].sort(\n (left, right) => right.length - left.length,\n)\n\nconst BENCHMARK_LABEL_PATH_MARKERS = [\n 'bench_manifest.verified',\n 'codetracer_labels.json',\n '/ground_truth/',\n '\\\\ground_truth\\\\',\n] as const\n\nexport interface BenchmarkLabelLeakScan {\n passed: true\n scannedBytes: number\n scannedValues: number\n}\n\nexport function assertNoBenchmarkLabelsInTrace(options: {\n traceId: string\n otlpText: string\n}): BenchmarkLabelLeakScan {\n let scannedValues = 0\n for (const [index, line] of options.otlpText.split(/\\r?\\n/).entries()) {\n if (!line.trim()) continue\n let value: unknown\n try {\n value = JSON.parse(line)\n } catch (error) {\n throw new TypeError(\n `trace '${options.traceId}' line ${index + 1} is invalid JSON: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n scannedValues += scanValue(value, options.traceId, `$line[${index + 1}]`, 0, 0)\n }\n if (scannedValues === 0) {\n throw new Error(`trace '${options.traceId}' contains no JSON values`)\n }\n return {\n passed: true,\n scannedBytes: Buffer.byteLength(options.otlpText),\n scannedValues,\n }\n}\n\nexport function assertNoBenchmarkLabelsInArtifact(options: {\n traceId: string\n relativePath: string\n content: string\n}): void {\n const normalizedPath = options.relativePath.toLowerCase()\n for (const marker of BENCHMARK_LABEL_PATH_MARKERS) {\n if (normalizedPath.includes(marker.toLowerCase())) {\n throw new Error(\n `trace '${options.traceId}' verification artifact path contains benchmark label marker '${marker}'`,\n )\n }\n }\n const normalizedContent = options.content.toLowerCase()\n for (const key of BENCHMARK_LABEL_KEYS) {\n if (normalizedContent.includes(key)) {\n throw new Error(\n `trace '${options.traceId}' verification artifact contains benchmark label key '${key}'`,\n )\n }\n }\n for (const marker of BENCHMARK_LABEL_PATH_MARKERS) {\n if (normalizedContent.includes(marker.toLowerCase())) {\n throw new Error(\n `trace '${options.traceId}' verification artifact contains benchmark label path marker '${marker}'`,\n )\n }\n }\n}\n\nexport async function validateCodeTraceFindingEvidence(options: {\n trajectoryId: string\n findings: readonly AnalystFinding[]\n store: TraceAnalysisStore\n signal?: AbortSignal\n}): Promise<void> {\n const citations = options.findings.flatMap((finding) =>\n finding.evidence_refs.map((evidence) => ({\n evidence,\n findingId: finding.finding_id,\n location: codeTraceStepFromEvidence(evidence.uri),\n })),\n )\n if (citations.length === 0) return\n\n for (const citation of citations) {\n if (!citation.location || citation.location.traceId !== options.trajectoryId) {\n throw new Error(\n `model finding '${citation.findingId}' cites non-case evidence '${citation.evidence.uri}'`,\n )\n }\n }\n\n const spanIds = [...new Set(citations.map((citation) => `step-${citation.location!.step}`))]\n const { spans, missing } = await fetchTraceSpans(options.store, {\n trajectoryId: options.trajectoryId,\n spanIds,\n ...(options.signal ? { signal: options.signal } : {}),\n })\n if (missing.length > 0) {\n throw new Error(\n `model finding evidence is unavailable in the case trace: ${missing.join(', ')}`,\n )\n }\n\n for (const citation of citations) {\n const spanId = `step-${citation.location!.step}`\n const span = spans.get(spanId)\n if (!span) {\n throw new Error(`model finding '${citation.findingId}' cites missing span '${spanId}'`)\n }\n if (span.kind !== 'LLM') {\n throw new Error(\n `model finding '${citation.findingId}' cites '${spanId}', which is ${span.kind}, not an assistant LLM span`,\n )\n }\n assertExactActionExcerpt(citation.findingId, citation.evidence, spanId, span.attributes.content)\n }\n}\n\n/**\n * Resolve assistant-step evidence for a trajectory.\n *\n * `steps` are claims the model made explicitly: an unresolvable one is a model\n * error and throws. `optionalSteps` are derived by the runner (a block's\n * interior, a block's consequence step), so an unresolvable one is simply\n * absent from the returned map and the caller decides what that means.\n */\nexport async function resolveAssistantStepEvidence(options: {\n trajectoryId: string\n steps: readonly number[]\n optionalSteps?: readonly number[]\n store: TraceAnalysisStore\n signal?: AbortSignal\n}): Promise<Map<number, EvidenceRef>> {\n const required = [...new Set(options.steps)]\n const optional = [...new Set(options.optionalSteps ?? [])].filter(\n (step) => !required.includes(step),\n )\n for (const step of [...required, ...optional]) {\n if (!Number.isSafeInteger(step) || step < 1) {\n throw new TypeError(`assistant evidence step must be a positive safe integer: ${step}`)\n }\n }\n const steps = [...required, ...optional]\n if (steps.length === 0) return new Map()\n\n const { spans, missing } = await fetchTraceSpans(options.store, {\n trajectoryId: options.trajectoryId,\n spanIds: steps.map((step) => `step-${step}`),\n ...(options.signal ? { signal: options.signal } : {}),\n })\n const missingRequired = missing.filter((spanId) =>\n required.some((step) => `step-${step}` === spanId),\n )\n if (missingRequired.length > 0) {\n throw new Error(`model selected unavailable assistant steps: ${missingRequired.join(', ')}`)\n }\n\n const evidence = new Map<number, EvidenceRef>()\n for (const step of steps) {\n const spanId = `step-${step}`\n const optionalStep = optional.includes(step)\n const span = spans.get(spanId)\n if (!span) {\n if (optionalStep) continue\n throw new Error(`model selected missing assistant step '${spanId}'`)\n }\n if (span.kind !== 'LLM') {\n if (optionalStep) continue\n throw new Error(\n `model selected '${spanId}', which is ${span.kind}, not an assistant LLM span`,\n )\n }\n const content = span.attributes.content\n if (typeof content !== 'string' || content.trim().length === 0) {\n if (optionalStep) continue\n throw new Error(`model selected '${spanId}' without action content`)\n }\n evidence.set(step, {\n kind: 'span',\n uri: codeTraceStepEvidenceUri(options.trajectoryId, step),\n excerpt: content.trim().slice(0, MAX_ASSISTANT_STEP_EVIDENCE_EXCERPT_CHARACTERS),\n })\n }\n return evidence\n}\n\n/**\n * Read spans by id, paging over the store's byte-budget omissions.\n *\n * `omitted_span_ids` names spans that exist but did not fit the response\n * ceiling; the store guarantees at least one span lands per call, so\n * re-requesting exactly the omitted ids terminates. Only `missing_span_ids`\n * describes a span the trace does not contain.\n */\nasync function fetchTraceSpans(\n store: TraceAnalysisStore,\n options: { trajectoryId: string; spanIds: readonly string[]; signal?: AbortSignal },\n): Promise<{\n spans: Map<string, Awaited<ReturnType<TraceAnalysisStore['viewSpans']>>['spans'][number]>\n missing: string[]\n}> {\n const spans = new Map<\n string,\n Awaited<ReturnType<TraceAnalysisStore['viewSpans']>>['spans'][number]\n >()\n const missing: string[] = []\n const unique = [...new Set(options.spanIds)]\n const context = options.signal ? { signal: options.signal } : undefined\n for (let offset = 0; offset < unique.length; offset += TRACE_ANALYSIS_LIMITS.viewSpans) {\n let pending = unique.slice(offset, offset + TRACE_ANALYSIS_LIMITS.viewSpans)\n while (pending.length > 0) {\n const result = await store.viewSpans(\n { trace_id: options.trajectoryId, span_ids: pending },\n context,\n )\n for (const span of result.spans) spans.set(span.span_id, span)\n missing.push(...result.missing_span_ids)\n const omitted = result.omitted_span_ids.filter((spanId) => !spans.has(spanId))\n if (omitted.length >= pending.length) {\n throw new Error(\n `trace '${options.trajectoryId}' cannot project spans within the store response budget: ${omitted.join(', ')}`,\n )\n }\n pending = omitted\n }\n }\n return { spans, missing }\n}\n\nfunction scanValue(\n value: unknown,\n traceId: string,\n path: string,\n depth: number,\n serializedDepth: number,\n): number {\n if (depth > MAX_LABEL_SCAN_DEPTH) {\n throw new Error(`trace '${traceId}' exceeds benchmark label scan depth at ${path}`)\n }\n if (Array.isArray(value)) {\n return (\n 1 +\n value.reduce(\n (count, entry, index) =>\n count + scanValue(entry, traceId, `${path}[${index}]`, depth + 1, serializedDepth),\n 0,\n )\n )\n }\n if (typeof value === 'object' && value !== null) {\n let count = 1\n for (const [key, entry] of Object.entries(value)) {\n if (BENCHMARK_LABEL_KEYS.has(key.toLowerCase())) {\n throw new Error(`trace '${traceId}' exposes benchmark label key '${key}' at ${path}`)\n }\n count += scanValue(entry, traceId, `${path}.${key}`, depth + 1, serializedDepth)\n }\n return count\n }\n if (typeof value === 'string') {\n const normalized = value.toLowerCase()\n const labelKey = BENCHMARK_LABEL_KEY_TOKENS.find((candidate) => normalized.includes(candidate))\n if (labelKey) {\n throw new Error(\n `trace '${traceId}' exposes benchmark label key '${labelKey}' inside a string at ${path}`,\n )\n }\n const marker = BENCHMARK_LABEL_PATH_MARKERS.find((candidate) => normalized.includes(candidate))\n if (marker) {\n throw new Error(\n `trace '${traceId}' exposes benchmark label path marker '${marker}' at ${path}`,\n )\n }\n const trimmed = value.trim()\n if (\n serializedDepth < MAX_SERIALIZED_JSON_SCAN_DEPTH &&\n Buffer.byteLength(trimmed) <= MAX_SERIALIZED_JSON_SCAN_BYTES &&\n looksLikeSerializedJson(trimmed)\n ) {\n let parsed: unknown\n try {\n parsed = JSON.parse(trimmed)\n } catch {\n return 1\n }\n return (\n 1 + scanValue(parsed, traceId, `${path}<serialized-json>`, depth + 1, serializedDepth + 1)\n )\n }\n }\n return 1\n}\n\nfunction looksLikeSerializedJson(value: string): boolean {\n return (\n (value.startsWith('{') && value.endsWith('}')) ||\n (value.startsWith('[') && value.endsWith(']')) ||\n (value.startsWith('\"') && value.endsWith('\"'))\n )\n}\n\nexport function codeTraceStepFromEvidence(uri: string): { traceId: string; step: number } | null {\n const match = /^trace:\\/\\/([^/]+)\\/span\\/step-(\\d+)$/.exec(uri)\n if (!match) return null\n try {\n const traceId = decodeURIComponent(match[1]!)\n const step = Number(match[2])\n return traceId && Number.isSafeInteger(step) && step > 0 ? { traceId, step } : null\n } catch {\n return null\n }\n}\n\nexport function codeTraceStepEvidenceUri(traceId: string, step: number): string {\n return `trace://${encodeURIComponent(traceId)}/span/step-${step}`\n}\n\nfunction assertExactActionExcerpt(\n findingId: string,\n evidence: EvidenceRef,\n spanId: string,\n content: unknown,\n): void {\n if (typeof content !== 'string' || content.length === 0) {\n throw new Error(`model finding '${findingId}' cites '${spanId}' without action content`)\n }\n const excerpt = evidence.excerpt?.trim()\n if (!excerpt) {\n throw new Error(`model finding '${findingId}' must quote action content from '${spanId}'`)\n }\n const requiredLength = Math.min(MIN_ACTION_EXCERPT_CHARACTERS, content.trim().length)\n if (excerpt.length < requiredLength) {\n throw new Error(\n `model finding '${findingId}' excerpt for '${spanId}' is too short; expected at least ${requiredLength} characters`,\n )\n }\n if (!content.includes(excerpt)) {\n throw new Error(\n `model finding '${findingId}' excerpt is not present in '${spanId}' action content`,\n )\n }\n}\n","import { z } from 'zod'\n\nexport type VerificationOutcomeStatus = 'passed' | 'failed' | 'unavailable'\n\nexport interface VerificationOutcomeSource {\n path: string\n format: 'terminal-bench' | 'swe-bench' | 'swe-multi'\n status: VerificationOutcomeStatus\n}\n\nexport interface VerificationOutcome {\n status: VerificationOutcomeStatus\n reason?:\n | 'missing-result'\n | 'result-output-unavailable'\n | 'result-parse-error'\n | 'result-label-disagreement'\n parseError?: { class: string; message: string }\n sources: VerificationOutcomeSource[]\n passedCheckCount: number\n failedCheckCount: number\n passedChecks: string[]\n failedChecks: string[]\n}\n\nexport interface VerificationResultFile {\n relativePath: string\n content: string\n}\n\nconst MAX_REPORTED_CHECKS = 20\nconst SWE_MULTI_NO_TEST_RESULTS =\n 'After applying the fix patch, no test results were captured when executing the test command.'\n\nconst checkNameSchema = z.string().min(1)\nconst checkListSchema = z.array(checkNameSchema).superRefine((checks, context) => {\n const seen = new Set<string>()\n for (const [index, check] of checks.entries()) {\n if (seen.has(check)) {\n context.addIssue({\n code: 'custom',\n path: [index],\n message: `duplicate check '${check}'`,\n })\n }\n seen.add(check)\n }\n})\nconst nonNegativeCountSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\nconst terminalBenchSchema = z\n .object({\n is_resolved: z.boolean().nullable(),\n failure_mode: z.string().min(1),\n parser_results: z.record(z.string().min(1), z.enum(['passed', 'failed'])).nullable(),\n })\n .passthrough()\n\nconst directSweBenchSchema = z\n .object({\n resolved: z.boolean(),\n passed_tests: checkListSchema,\n failed_tests: checkListSchema,\n })\n .passthrough()\n\nconst nestedSweBenchCategorySchema = z\n .object({\n success: checkListSchema,\n failure: checkListSchema,\n })\n .passthrough()\n\nconst nestedSweBenchInstanceSchema = z\n .object({\n resolved: z.boolean(),\n tests_status: z\n .record(z.string().min(1), nestedSweBenchCategorySchema)\n .refine((value) => Object.keys(value).length > 0, 'must contain at least one test category'),\n })\n .passthrough()\n\nconst nestedSweBenchSchema = z\n .record(z.string().min(1), nestedSweBenchInstanceSchema)\n .refine((value) => Object.keys(value).length > 0, 'must contain at least one instance')\n\nconst sweMultiCheckResultSchema = z\n .object({\n passed_count: nonNegativeCountSchema,\n failed_count: nonNegativeCountSchema,\n skipped_count: nonNegativeCountSchema,\n passed_tests: checkListSchema,\n failed_tests: checkListSchema,\n skipped_tests: checkListSchema,\n })\n .passthrough()\n\nconst sweMultiSchema = z\n .object({\n valid: z.boolean(),\n error_msg: z.string(),\n fix_patch_result: sweMultiCheckResultSchema,\n })\n .passthrough()\n\nexport function parseVerificationOutcome(\n files: readonly VerificationResultFile[],\n): VerificationOutcome {\n if (files.length === 0) {\n throw new Error('final verification outcome requires at least one result file')\n }\n\n const sources: VerificationOutcomeSource[] = []\n const passedChecks = new Set<string>()\n const failedChecks = new Set<string>()\n const unavailableReasons = new Set<NonNullable<VerificationOutcome['reason']>>()\n\n for (const file of files) {\n let value: unknown\n try {\n value = JSON.parse(file.content)\n } catch (error) {\n throw new TypeError(\n `final verification result is not valid JSON: ${file.relativePath}: ${errorMessage(error)}`,\n )\n }\n const parsed = parseResult(value, file.relativePath)\n sources.push({\n path: file.relativePath,\n format: parsed.format,\n status: parsed.status,\n })\n if (parsed.reason) unavailableReasons.add(parsed.reason)\n for (const check of parsed.passedChecks) passedChecks.add(check)\n for (const check of parsed.failedChecks) failedChecks.add(check)\n }\n\n const statuses = new Set(sources.map((source) => source.status))\n if (statuses.size !== 1) {\n throw new Error(\n `final verification result files disagree: ${sources\n .map((source) => `${source.path}=${source.status}`)\n .join(', ')}`,\n )\n }\n if (unavailableReasons.size > 1) {\n throw new Error(\n `final verification result files disagree on why the outcome is unavailable: ${[\n ...unavailableReasons,\n ].join(', ')}`,\n )\n }\n const [unavailableReason] = unavailableReasons\n\n const passed = [...passedChecks].sort()\n const failed = [...failedChecks].sort()\n assertDisjointChecks(passed, failed, 'final verification result')\n return {\n status: sources[0]!.status,\n ...(unavailableReason ? { reason: unavailableReason } : {}),\n sources,\n passedCheckCount: passed.length,\n failedCheckCount: failed.length,\n passedChecks: passed.slice(0, MAX_REPORTED_CHECKS),\n failedChecks: failed.slice(0, MAX_REPORTED_CHECKS),\n }\n}\n\ninterface ParsedResult {\n format: VerificationOutcomeSource['format']\n status: VerificationOutcomeStatus\n reason?: NonNullable<VerificationOutcome['reason']>\n passedChecks: string[]\n failedChecks: string[]\n}\n\nfunction parseResult(value: unknown, path: string): ParsedResult {\n const record = asRecord(value)\n if (!record) {\n throw unsupported(path)\n }\n\n const discriminators = ['is_resolved', 'resolved', 'valid'].filter((field) =>\n Object.hasOwn(record, field),\n )\n if (discriminators.length > 1) {\n throw new TypeError(\n `final verification result is ambiguous: ${path}: found ${discriminators.join(', ')}`,\n )\n }\n if (discriminators[0] === 'is_resolved') return parseTerminalBench(record, path)\n if (discriminators[0] === 'resolved') return parseDirectSweBench(record, path)\n if (discriminators[0] === 'valid') return parseSweMulti(record, path)\n\n const entries = Object.entries(record)\n const looksNested = entries.some(([, candidate]) => {\n const nested = asRecord(candidate)\n return nested !== null && Object.hasOwn(nested, 'resolved')\n })\n if (looksNested) return parseNestedSweBench(record, path)\n\n throw unsupported(path)\n}\n\nfunction parseTerminalBench(value: unknown, path: string): ParsedResult {\n const record = parseSchema(terminalBenchSchema, value, path, 'Terminal-Bench')\n if (record.is_resolved === null) {\n if (record.parser_results !== null) {\n throw malformed(\n path,\n 'Terminal-Bench',\n 'parser_results must be null when is_resolved is null',\n )\n }\n if (record.failure_mode === 'unset') {\n throw malformed(path, 'Terminal-Bench', \"failure_mode cannot be 'unset' when unresolved\")\n }\n return {\n format: 'terminal-bench',\n status: 'unavailable',\n reason:\n record.failure_mode === 'parse_error' ? 'result-parse-error' : 'result-output-unavailable',\n passedChecks: [],\n failedChecks: [],\n }\n }\n if (record.parser_results === null) {\n throw malformed(\n path,\n 'Terminal-Bench',\n 'parser_results must be an object when is_resolved is boolean',\n )\n }\n const checks = stringStatusChecks(record.parser_results)\n if (checks.passedChecks.length + checks.failedChecks.length === 0) {\n throw malformed(path, 'Terminal-Bench', 'parser_results must contain at least one check')\n }\n assertOutcomeConsistency(record.is_resolved, checks, path, 'Terminal-Bench is_resolved', true)\n return {\n format: 'terminal-bench',\n status: status(record.is_resolved),\n ...checks,\n }\n}\n\nfunction parseDirectSweBench(value: unknown, path: string): ParsedResult {\n const record = parseSchema(directSweBenchSchema, value, path, 'SWE-bench')\n const checks = {\n passedChecks: record.passed_tests,\n failedChecks: record.failed_tests,\n }\n assertOutcomeConsistency(record.resolved, checks, path, 'SWE-bench resolved')\n return {\n format: 'swe-bench',\n status: status(record.resolved),\n ...checks,\n }\n}\n\nfunction parseNestedSweBench(value: unknown, path: string): ParsedResult {\n const record = parseSchema(nestedSweBenchSchema, value, path, 'SWE-bench instance report')\n const instances = Object.entries(record)\n const statuses = new Set(instances.map(([, instance]) => status(instance.resolved)))\n if (statuses.size !== 1) {\n throw new Error(\n `final verification report contains conflicting instance outcomes: ${path}: ${instances\n .map(([id, instance]) => `${id}=${status(instance.resolved)}`)\n .join(', ')}`,\n )\n }\n\n const passedChecks: string[] = []\n const failedChecks: string[] = []\n for (const [instanceId, instance] of instances) {\n const checks = nestedSweBenchChecks(instanceId, instance.tests_status)\n assertOutcomeConsistency(\n instance.resolved,\n checks,\n path,\n `SWE-bench instance '${instanceId}' resolved`,\n )\n passedChecks.push(...checks.passedChecks)\n failedChecks.push(...checks.failedChecks)\n }\n return {\n format: 'swe-bench',\n status: [...statuses][0]!,\n passedChecks,\n failedChecks,\n }\n}\n\nfunction parseSweMulti(value: unknown, path: string): ParsedResult {\n const record = parseSchema(sweMultiSchema, value, path, 'SWE-Multi')\n const fix = record.fix_patch_result\n assertCount(fix.passed_count, fix.passed_tests, 'passed', path)\n assertCount(fix.failed_count, fix.failed_tests, 'failed', path)\n assertCount(fix.skipped_count, fix.skipped_tests, 'skipped', path)\n assertDisjointChecks(fix.passed_tests, fix.failed_tests, `SWE-Multi result ${path}`)\n assertDisjointChecks(fix.passed_tests, fix.skipped_tests, `SWE-Multi result ${path}`)\n assertDisjointChecks(fix.failed_tests, fix.skipped_tests, `SWE-Multi result ${path}`)\n\n const checks = {\n passedChecks: fix.passed_tests,\n failedChecks: fix.failed_tests,\n }\n if (record.valid === false && isSweMultiOutputUnavailable(record)) {\n return {\n format: 'swe-multi',\n status: 'unavailable',\n reason: 'result-output-unavailable',\n ...checks,\n }\n }\n assertOutcomeConsistency(record.valid, checks, path, 'SWE-Multi valid')\n return {\n format: 'swe-multi',\n status: status(record.valid),\n ...checks,\n }\n}\n\nfunction isSweMultiOutputUnavailable(record: z.infer<typeof sweMultiSchema>): boolean {\n const fix = record.fix_patch_result\n return (\n (record.error_msg === SWE_MULTI_NO_TEST_RESULTS ||\n record.error_msg.startsWith(`${SWE_MULTI_NO_TEST_RESULTS} `)) &&\n fix.passed_count === 0 &&\n fix.failed_count === 0 &&\n fix.skipped_count === 0\n )\n}\n\nfunction stringStatusChecks(record: Record<string, 'passed' | 'failed'>): {\n passedChecks: string[]\n failedChecks: string[]\n} {\n const passedChecks: string[] = []\n const failedChecks: string[] = []\n for (const [name, result] of Object.entries(record)) {\n if (result === 'passed') passedChecks.push(name)\n else failedChecks.push(name)\n }\n return { passedChecks, failedChecks }\n}\n\nfunction nestedSweBenchChecks(\n instanceId: string,\n testsStatus: z.infer<typeof nestedSweBenchInstanceSchema>['tests_status'],\n): { passedChecks: string[]; failedChecks: string[] } {\n const passedChecks: string[] = []\n const failedChecks: string[] = []\n for (const [category, result] of Object.entries(testsStatus)) {\n passedChecks.push(...result.success.map((name) => `${instanceId}:${category}:${name}`))\n failedChecks.push(...result.failure.map((name) => `${instanceId}:${category}:${name}`))\n }\n return { passedChecks, failedChecks }\n}\n\nfunction assertOutcomeConsistency(\n passed: boolean,\n checks: { passedChecks: readonly string[]; failedChecks: readonly string[] },\n path: string,\n field: string,\n requireFailedCheck = false,\n): void {\n assertDisjointChecks(checks.passedChecks, checks.failedChecks, `${field} in ${path}`)\n if (passed && checks.failedChecks.length > 0) {\n throw malformed(\n path,\n field,\n `cannot be true while failed checks are reported: ${checks.failedChecks.join(', ')}`,\n )\n }\n if (passed && checks.passedChecks.length === 0) {\n throw malformed(path, field, 'cannot be true without at least one passed check')\n }\n if (!passed && requireFailedCheck && checks.failedChecks.length === 0) {\n throw malformed(path, field, 'cannot be false without at least one failed check')\n }\n}\n\nfunction assertCount(count: number, checks: readonly string[], kind: string, path: string): void {\n if (count !== checks.length) {\n throw malformed(\n path,\n 'SWE-Multi',\n `${kind}_count=${count} does not match ${kind}_tests length ${checks.length}`,\n )\n }\n}\n\nfunction assertDisjointChecks(\n left: readonly string[],\n right: readonly string[],\n source: string,\n): void {\n const rightSet = new Set(right)\n const contradictions = [...new Set(left.filter((check) => rightSet.has(check)))].sort()\n if (contradictions.length > 0) {\n throw new Error(\n `${source} marks checks as both passed and failed: ${contradictions.join(', ')}`,\n )\n }\n}\n\nfunction parseSchema<T>(schema: z.ZodType<T>, value: unknown, path: string, format: string): T {\n const parsed = schema.safeParse(value)\n if (parsed.success) return parsed.data\n const details = parsed.error.issues\n .map((issue) => `${issue.path.join('.') || '<root>'}: ${issue.message}`)\n .join('; ')\n throw malformed(path, format, details)\n}\n\nfunction malformed(path: string, format: string, details: string): TypeError {\n return new TypeError(`malformed ${format} verification result: ${path}: ${details}`)\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | null {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : null\n}\n\nfunction status(value: boolean): VerificationOutcomeStatus {\n return value ? 'passed' : 'failed'\n}\n\nfunction unsupported(path: string): TypeError {\n return new TypeError(\n `final verification result has no supported outcome field: ${path}; expected is_resolved, resolved, valid, or a SWE-bench instance report`,\n )\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n","import { createHash } from 'node:crypto'\nimport { constants, type Stats } from 'node:fs'\nimport { type FileHandle, open, readdir, realpath, stat } from 'node:fs/promises'\nimport { isAbsolute, relative, resolve, sep } from 'node:path'\nimport { TextDecoder } from 'node:util'\nimport type { CodeTraceBenchRow } from './benchmark-datasets'\nimport {\n parseVerificationOutcome,\n type VerificationOutcome,\n} from './benchmark-verification-outcome'\n\nexport const DEFAULT_MAX_VERIFICATION_ARTIFACT_BYTES = 8 * 1024 * 1024\n\nexport type VerificationArtifactRole = 'final-test-output' | 'final-result' | 'final-metrics'\n\nexport interface VerificationArtifactFile {\n role: VerificationArtifactRole\n path: string\n relativePath: string\n sha256: string\n bytes: number\n spanId: string\n}\n\nexport interface VerificationArtifactManifest {\n traceId: string\n status: 'present' | 'missing'\n outcome: VerificationOutcome\n outcomeSpanId: string\n caseDirectory: string\n caseDirectoriesSearched: string[]\n totalBytes: number\n maxBytes: number\n files: VerificationArtifactFile[]\n missingRoles: VerificationArtifactRole[]\n searched: Record<VerificationArtifactRole, string[]>\n}\n\nexport interface LoadedVerificationArtifacts {\n manifest: VerificationArtifactManifest\n outcome: VerificationOutcome\n files: Array<VerificationArtifactFile & { content: string }>\n}\n\nconst SEARCHED_ARTIFACTS: Record<VerificationArtifactRole, string[]> = {\n 'final-test-output': ['panes/post-test.txt', 'sessions/tests.log', 'test_output.txt'],\n 'final-result': ['results.json', 'result.json', 'report.json', '*_result.json'],\n 'final-metrics': ['*_metrics.json'],\n}\n\nconst REQUIRED_ROLES = new Set<VerificationArtifactRole>(['final-result'])\n\nconst UTF8 = new TextDecoder('utf-8', { fatal: true })\n\nexport async function loadCodeTraceVerificationArtifacts(options: {\n artifactDir: string\n row: CodeTraceBenchRow\n maxBytes?: number\n}): Promise<LoadedVerificationArtifacts> {\n const maxBytes = positiveInteger(\n options.maxBytes ?? DEFAULT_MAX_VERIFICATION_ARTIFACT_BYTES,\n 'max verification artifact bytes',\n )\n const sourceRelativePath = nonEmpty(\n options.row.source_relpath,\n `CodeTraceBench '${options.row.traj_id}' source_relpath`,\n )\n const artifactRoot = await realpath(resolve(options.artifactDir))\n const caseDirectoriesSearched = [\n resolve(artifactRoot, options.row.traj_id, sourceRelativePath),\n resolve(artifactRoot, sourceRelativePath),\n ].filter((path, index, paths) => paths.indexOf(path) === index)\n for (const path of caseDirectoriesSearched) {\n assertContained(artifactRoot, path, sourceRelativePath)\n }\n const existingCaseDirectories = new Set<string>()\n for (const path of caseDirectoriesSearched) {\n try {\n const canonicalPath = await realpath(path)\n assertContained(artifactRoot, canonicalPath, sourceRelativePath)\n const metadata = await stat(canonicalPath)\n if (!metadata.isDirectory()) {\n throw new TypeError(\n `CodeTraceBench '${options.row.traj_id}' artifact case path is not a directory: ${canonicalPath}`,\n )\n }\n existingCaseDirectories.add(canonicalPath)\n } catch (error) {\n if (!isMissing(error)) throw error\n }\n }\n if (existingCaseDirectories.size === 0) {\n return missingArtifacts(\n options.row.traj_id,\n caseDirectoriesSearched[0]!,\n caseDirectoriesSearched,\n maxBytes,\n )\n }\n if (existingCaseDirectories.size > 1) {\n throw new Error(\n `CodeTraceBench '${options.row.traj_id}' artifact directory is ambiguous: ${[...existingCaseDirectories].join(', ')}`,\n )\n }\n const [caseDirectory] = existingCaseDirectories\n\n const candidates = await artifactCandidates(caseDirectory!)\n const files: LoadedVerificationArtifacts['files'] = []\n let totalBytes = 0\n for (const candidate of candidates) {\n const snapshot = await readArtifactSnapshot({\n artifactRoot,\n candidatePath: candidate.path,\n relativePath: candidate.relativePath,\n traceId: options.row.traj_id,\n totalBytes,\n maxBytes,\n })\n const { bytes, canonicalPath } = snapshot\n totalBytes += bytes.byteLength\n let content: string\n try {\n content = UTF8.decode(bytes)\n } catch {\n throw new TypeError(\n `CodeTraceBench '${options.row.traj_id}' verification artifact is not UTF-8 text: ${canonicalPath}`,\n )\n }\n if (!content.trim()) {\n throw new Error(\n `CodeTraceBench '${options.row.traj_id}' verification artifact is empty: ${canonicalPath}`,\n )\n }\n const relativePath = candidate.relativePath\n files.push({\n role: candidate.role,\n path: canonicalPath,\n relativePath,\n sha256: sha256Digest(bytes),\n bytes: bytes.byteLength,\n spanId: verificationSpanId(candidate.role, relativePath),\n content,\n })\n }\n\n const roles = new Set(files.map((file) => file.role))\n const missingRoles = (Object.keys(SEARCHED_ARTIFACTS) as VerificationArtifactRole[]).filter(\n (role) => !roles.has(role),\n )\n const hasFinalVerification = [...REQUIRED_ROLES].every((role) => roles.has(role))\n const outcome = hasFinalVerification\n ? loadVerificationOutcome(\n files\n .filter((file) => file.role === 'final-result')\n .map((file) => ({ relativePath: file.relativePath, content: file.content })),\n options.row,\n )\n : unavailableOutcome('missing-result')\n const outcomeSpanId = verificationOutcomeSpanId(options.row.traj_id, outcome)\n return {\n manifest: {\n traceId: options.row.traj_id,\n status: hasFinalVerification ? 'present' : 'missing',\n outcome,\n outcomeSpanId,\n caseDirectory: caseDirectory!,\n caseDirectoriesSearched,\n totalBytes,\n maxBytes,\n files: files.map(({ content: _content, ...file }) => file),\n missingRoles,\n searched: searchedArtifacts(),\n },\n outcome,\n files,\n }\n}\n\nexport function appendVerificationArtifactsToOtlp(\n otlpText: string,\n traceId: string,\n artifacts: LoadedVerificationArtifacts,\n afterTimestamp: string,\n): string {\n if (!otlpText.trim()) throw new Error(`trace '${traceId}' OTLP input is empty`)\n if (artifacts.manifest.traceId !== traceId) {\n throw new Error(\n `verification artifacts for trace '${artifacts.manifest.traceId}' cannot be attached to '${traceId}'`,\n )\n }\n if (!artifacts.outcome || !artifacts.manifest.outcomeSpanId) {\n throw new Error(`trace '${traceId}' has no final verification artifacts to attach`)\n }\n const afterMs = Date.parse(afterTimestamp)\n if (!Number.isFinite(afterMs)) {\n throw new TypeError(`trace '${traceId}' latest timestamp is invalid: ${afterTimestamp}`)\n }\n const outcome = artifacts.outcome\n const outcomeLine = JSON.stringify({\n trace_id: traceId,\n span_id: artifacts.manifest.outcomeSpanId,\n parent_span_id: null,\n name: `final verification outcome: ${outcome.status}`,\n start_time: timestampAfter(afterMs, 1, traceId),\n end_time: timestampAfter(afterMs, 2, traceId),\n status: {\n code:\n outcome.status === 'passed'\n ? 'STATUS_CODE_OK'\n : outcome.status === 'failed'\n ? 'STATUS_CODE_ERROR'\n : 'STATUS_CODE_UNSET',\n },\n resource: {\n attributes: {\n 'service.name': 'agent-eval-public-benchmark',\n },\n },\n attributes: {\n 'openinference.span.kind': 'EVALUATOR',\n 'benchmark.evidence.role': 'final-verification',\n 'benchmark.verification.outcome': outcome.status,\n 'benchmark.verification.passed_check_count': outcome.passedCheckCount,\n 'benchmark.verification.failed_check_count': outcome.failedCheckCount,\n 'benchmark.verification.passed_checks': JSON.stringify(outcome.passedChecks),\n 'benchmark.verification.failed_checks': JSON.stringify(outcome.failedChecks),\n 'benchmark.verification.sources': JSON.stringify(outcome.sources),\n ...(outcome.reason ? { 'benchmark.verification.reason': outcome.reason } : {}),\n ...(outcome.parseError\n ? { 'benchmark.verification.parse_error': JSON.stringify(outcome.parseError) }\n : {}),\n },\n })\n const artifactLines = artifacts.files\n .filter((artifact) => artifact.role === 'final-test-output')\n .map((artifact, index) =>\n JSON.stringify({\n trace_id: traceId,\n span_id: artifact.spanId,\n parent_span_id: null,\n name: `final verification artifact: ${artifact.relativePath}`,\n start_time: timestampAfter(afterMs, index * 2 + 3, traceId),\n end_time: timestampAfter(afterMs, index * 2 + 4, traceId),\n status: { code: 'STATUS_CODE_UNSET' },\n resource: {\n attributes: {\n 'service.name': 'agent-eval-public-benchmark',\n },\n },\n attributes: {\n 'openinference.span.kind': 'EVALUATOR',\n 'benchmark.evidence.role': 'final-verification-artifact',\n 'benchmark.verification.outcome': outcome.status,\n 'artifact.role': artifact.role,\n 'artifact.path': artifact.relativePath,\n 'artifact.sha256': artifact.sha256,\n 'artifact.bytes': artifact.bytes,\n 'artifact.content': artifact.content,\n },\n }),\n )\n return `${otlpText.trimEnd()}\\n${[outcomeLine, ...artifactLines].join('\\n')}\\n`\n}\n\nfunction timestampAfter(afterMs: number, offsetMs: number, traceId: string): string {\n const date = new Date(afterMs + offsetMs)\n if (!Number.isFinite(date.getTime())) {\n throw new RangeError(`trace '${traceId}' cannot place final verification after its latest span`)\n }\n return date.toISOString()\n}\n\nexport function sha256Digest(value: string | NodeJS.ArrayBufferView): string {\n return createHash('sha256').update(value).digest('hex')\n}\n\nasync function readArtifactSnapshot(options: {\n artifactRoot: string\n candidatePath: string\n relativePath: string\n traceId: string\n totalBytes: number\n maxBytes: number\n}): Promise<{ canonicalPath: string; bytes: Buffer }> {\n const safeOpenFlags =\n constants.O_RDONLY |\n (process.platform === 'win32' ? 0 : constants.O_NOFOLLOW | constants.O_NONBLOCK)\n let handle: FileHandle\n try {\n handle = await open(options.candidatePath, safeOpenFlags)\n } catch (error) {\n if (isNodeError(error, 'ELOOP')) {\n throw new Error(\n `CodeTraceBench '${options.traceId}' verification artifact must not be a symbolic link: ${options.relativePath}`,\n )\n }\n throw error\n }\n\n try {\n const before = await handle.stat()\n if (!before.isFile()) {\n throw new TypeError(\n `CodeTraceBench '${options.traceId}' verification artifact is not a regular file: ${options.relativePath}`,\n )\n }\n const bytes = checkedFileSize(before.size, options)\n const descriptorPath = await openedDescriptorPath(handle.fd)\n if (descriptorPath !== null) {\n assertContained(options.artifactRoot, descriptorPath, options.relativePath)\n }\n\n const canonicalPath = await realpath(options.candidatePath)\n assertContained(options.artifactRoot, canonicalPath, options.relativePath)\n const current = await stat(canonicalPath)\n if (!sameFile(before, current)) {\n throw changedArtifact(options.traceId, options.relativePath)\n }\n\n const content = Buffer.allocUnsafe(bytes)\n let offset = 0\n while (offset < content.byteLength) {\n const { bytesRead } = await handle.read(content, offset, content.byteLength - offset, offset)\n if (bytesRead === 0) break\n offset += bytesRead\n }\n const eofProbe = Buffer.allocUnsafe(1)\n const { bytesRead: trailingBytes } = await handle.read(\n eofProbe,\n 0,\n eofProbe.byteLength,\n content.byteLength,\n )\n const after = await handle.stat()\n if (offset !== content.byteLength || trailingBytes !== 0 || !sameSnapshot(before, after)) {\n throw changedArtifact(options.traceId, options.relativePath)\n }\n return { canonicalPath, bytes: content }\n } finally {\n await handle.close()\n }\n}\n\nfunction checkedFileSize(\n bytes: number,\n options: {\n traceId: string\n relativePath: string\n totalBytes: number\n maxBytes: number\n },\n): number {\n if (!Number.isSafeInteger(bytes) || bytes < 0) {\n throw new RangeError(\n `CodeTraceBench '${options.traceId}' verification artifact has an invalid byte size: ${options.relativePath}`,\n )\n }\n if (bytes > options.maxBytes) {\n throw new RangeError(\n `CodeTraceBench '${options.traceId}' verification artifact '${options.relativePath}' requires ${bytes} bytes, over the ${options.maxBytes}-byte per-file limit`,\n )\n }\n if (options.totalBytes > options.maxBytes - bytes) {\n throw new RangeError(\n `CodeTraceBench '${options.traceId}' verification artifacts require ${options.totalBytes + bytes} bytes, over the ${options.maxBytes}-byte cumulative limit`,\n )\n }\n return bytes\n}\n\nasync function openedDescriptorPath(fileDescriptor: number): Promise<string | null> {\n if (process.platform !== 'linux') return null\n try {\n return await realpath(`/proc/self/fd/${fileDescriptor}`)\n } catch (error) {\n if (\n isNodeError(error, 'ENOENT') ||\n isNodeError(error, 'ENOTDIR') ||\n isNodeError(error, 'EACCES')\n ) {\n return null\n }\n throw error\n }\n}\n\nfunction sameFile(left: Stats, right: Stats): boolean {\n return (\n left.isFile() &&\n right.isFile() &&\n left.dev === right.dev &&\n left.ino === right.ino &&\n left.size === right.size\n )\n}\n\nfunction sameSnapshot(left: Stats, right: Stats): boolean {\n return (\n sameFile(left, right) &&\n left.mode === right.mode &&\n left.mtimeMs === right.mtimeMs &&\n left.ctimeMs === right.ctimeMs\n )\n}\n\nfunction changedArtifact(traceId: string, relativePath: string): Error {\n return new Error(\n `CodeTraceBench '${traceId}' verification artifact changed while being read: ${relativePath}`,\n )\n}\n\nasync function artifactCandidates(\n caseDirectory: string,\n): Promise<Array<{ role: VerificationArtifactRole; path: string; relativePath: string }>> {\n const entries = await readdir(caseDirectory, { withFileTypes: true })\n const rootFiles = entries\n .filter((entry) => entry.isFile() || entry.isSymbolicLink())\n .map((entry) => entry.name)\n const testOutput = await firstExisting(caseDirectory, SEARCHED_ARTIFACTS['final-test-output'])\n const finalResults = [\n ...SEARCHED_ARTIFACTS['final-result']\n .filter((name) => !name.includes('*'))\n .map((name) => resolve(caseDirectory, name)),\n ...rootFiles\n .filter((name) => name.endsWith('_result.json'))\n .map((name) => resolve(caseDirectory, name)),\n ]\n const finalMetrics = rootFiles\n .filter((name) => name.endsWith('_metrics.json'))\n .map((name) => resolve(caseDirectory, name))\n\n const candidates = [\n ...testOutput.map((path) => candidate('final-test-output', caseDirectory, path)),\n ...(await existing(finalResults)).map((path) => candidate('final-result', caseDirectory, path)),\n ...(await existing(finalMetrics)).map((path) =>\n candidate('final-metrics', caseDirectory, path),\n ),\n ]\n const seen = new Set<string>()\n return candidates\n .filter((entry) => {\n if (seen.has(entry.path)) return false\n seen.add(entry.path)\n return true\n })\n .sort(\n (left, right) =>\n artifactRoleOrder(left.role) - artifactRoleOrder(right.role) ||\n left.relativePath.localeCompare(right.relativePath),\n )\n}\n\nasync function firstExisting(\n caseDirectory: string,\n candidates: readonly string[],\n): Promise<string[]> {\n for (const relativePath of candidates) {\n const path = resolve(caseDirectory, relativePath)\n if (await isFile(path)) return [path]\n }\n return []\n}\n\nasync function existing(paths: readonly string[]): Promise<string[]> {\n const out: string[] = []\n for (const path of paths) {\n if (await isFile(path)) out.push(path)\n }\n return out\n}\n\nasync function isFile(path: string): Promise<boolean> {\n try {\n return (await stat(path)).isFile()\n } catch (error) {\n if (isMissing(error)) return false\n throw error\n }\n}\n\nfunction candidate(\n role: VerificationArtifactRole,\n caseDirectory: string,\n path: string,\n): { role: VerificationArtifactRole; path: string; relativePath: string } {\n return { role, path, relativePath: slashRelative(caseDirectory, path) }\n}\n\nfunction missingArtifacts(\n traceId: string,\n caseDirectory: string,\n caseDirectoriesSearched: string[],\n maxBytes: number,\n): LoadedVerificationArtifacts {\n const outcome = unavailableOutcome('missing-result')\n return {\n manifest: {\n traceId,\n status: 'missing',\n outcome,\n outcomeSpanId: verificationOutcomeSpanId(traceId, outcome),\n caseDirectory,\n caseDirectoriesSearched,\n totalBytes: 0,\n maxBytes,\n files: [],\n missingRoles: Object.keys(SEARCHED_ARTIFACTS) as VerificationArtifactRole[],\n searched: searchedArtifacts(),\n },\n outcome,\n files: [],\n }\n}\n\nfunction verificationOutcomeSpanId(traceId: string, outcome: VerificationOutcome): string {\n return `benchmark-verification-outcome-${sha256Digest(\n `${traceId}\\u0000${JSON.stringify(outcome.sources)}\\u0000${outcome.status}`,\n ).slice(0, 16)}`\n}\n\nfunction unavailableOutcome(\n reason: NonNullable<VerificationOutcome['reason']>,\n): VerificationOutcome {\n return {\n status: 'unavailable',\n reason,\n sources: [],\n passedCheckCount: 0,\n failedCheckCount: 0,\n passedChecks: [],\n failedChecks: [],\n }\n}\n\nfunction loadVerificationOutcome(\n files: Parameters<typeof parseVerificationOutcome>[0],\n row: CodeTraceBenchRow,\n): VerificationOutcome {\n try {\n const outcome = parseVerificationOutcome(files)\n if (outcome.status === 'unavailable' || typeof row.solved !== 'boolean') {\n return outcome\n }\n const labelStatus = row.solved ? 'passed' : 'failed'\n if (outcome.status === labelStatus) {\n return outcome\n }\n return {\n ...outcome,\n status: 'unavailable',\n reason: 'result-label-disagreement',\n parseError: {\n class: 'ResultLabelDisagreementError',\n message: `CodeTraceBench '${row.traj_id}' solved=${row.solved} disagrees with parsed final verification status '${outcome.status}' from ${outcome.sources\n .map((source) => `${source.path}=${source.status}`)\n .join(', ')}`,\n },\n }\n } catch (error) {\n return {\n ...unavailableOutcome('result-parse-error'),\n parseError: {\n class: error instanceof Error ? error.constructor.name : 'Error',\n message: error instanceof Error ? error.message : String(error),\n },\n }\n }\n}\n\nfunction verificationSpanId(role: VerificationArtifactRole, relativePath: string): string {\n return `benchmark-verification-${sha256Digest(`${role}\\u0000${relativePath}`).slice(0, 16)}`\n}\n\nfunction artifactRoleOrder(role: VerificationArtifactRole): number {\n return role === 'final-test-output' ? 0 : role === 'final-result' ? 1 : 2\n}\n\nfunction assertContained(root: string, candidate: string, source: string): void {\n const rel = relative(root, candidate)\n if (isAbsolute(rel) || rel === '..' || rel.startsWith(`..${sep}`)) {\n throw new Error(`verification artifact path escapes --artifact-dir: ${source}`)\n }\n}\n\nfunction searchedArtifacts(): Record<VerificationArtifactRole, string[]> {\n return {\n 'final-test-output': [...SEARCHED_ARTIFACTS['final-test-output']],\n 'final-result': [...SEARCHED_ARTIFACTS['final-result']],\n 'final-metrics': [...SEARCHED_ARTIFACTS['final-metrics']],\n }\n}\n\nfunction slashRelative(root: string, path: string): string {\n return relative(root, path).split(sep).join('/')\n}\n\nfunction nonEmpty(value: unknown, field: string): string {\n if (typeof value !== 'string' || !value.trim()) {\n throw new TypeError(`${field} must be a non-empty string`)\n }\n return value.trim()\n}\n\nfunction positiveInteger(value: number, field: string): number {\n if (!Number.isSafeInteger(value) || value < 1) {\n throw new RangeError(`${field} must be a positive safe integer`)\n }\n return value\n}\n\nfunction isMissing(error: unknown): boolean {\n return isNodeError(error, 'ENOENT')\n}\n\nfunction isNodeError(error: unknown, code: string): error is NodeJS.ErrnoException {\n return error instanceof Error && 'code' in error && error.code === code\n}\n","import { MAX_ASSISTANT_STEP_EVIDENCE_EXCERPT_CHARACTERS } from './benchmark-evidence-validation'\nimport type { PublicAnalystBenchmarkDataset } from './benchmark-public-types'\nimport { sha256Digest } from './benchmark-verification-artifacts'\n\n/** Widest contiguous failure block a model may report. The published corpus's\n * widest labeled block is 8 steps and its widest stage span is 9, so this bound\n * never binds honest enumeration; it caps how far one over-wide block can push\n * unlabeled steps into the precision denominator. */\nexport const MAX_INCORRECT_BLOCK_STEPS = 12\n\n/** Most blocks a model may report for one trajectory. The published corpus's\n * densest case carries 4 disjoint labeled blocks. Together with the per-block\n * cap this bounds one case at 192 predicted steps without a second ceiling. */\nexport const MAX_INCORRECT_BLOCKS = 16\n\nexport const TRACE_PROJECTION_ATTRIBUTE_BYTE_CAPS = [\n 4_096, 2_048, 1_024, 512, 256, 128, 64,\n] as const\n\nexport const CODE_TRACE_BENCH_ANALYST_PROMPT = `Analyze exactly one coding-agent trajectory and its attached final verification.\nYour task is the CodeTraceBench incorrect-step task: identify every wrong state-changing action, bad hypothesis that drives an action, and regression.\nAn incorrect step remains incorrect when the agent later recovers or the final verification passes; a trajectory that ends in success still contains every mistake the agent made along the way.\nIncorrect steps occur in contiguous failure blocks: one mistake plus every consecutive following step that commits to, compounds, or acts on it.\nReport each failure block as exactly one finding whose first_step is the block's first incorrect step and whose last_step is its last, covering every consecutive step between them.\nSet first_step to the first step that commits the mistake, not the step that planned it and not a later step that repeats it.\nExtend last_step one step at a time, and only while the next step independently satisfies the incorrect-step definition on its own action and its own following observation.\nStop at the first step where the agent detects the problem, inspects it, or begins repairing it: a diagnostic probe, a test run that exposes the defect, or a repair action ends the block and is never inside it.\nA one-step block is a complete and correct answer.\nEvery step inside a block is scored on its own: naming a correct step costs exactly as much as missing an incorrect one, and naming only the first step of a longer block forfeits every unnamed step.\nReport blocks separated by at least one correct step as separate findings, and never let two blocks overlap.\nInspect the complete supplied trace data.\nUse the final-verification outcome as evidence about the final state, not as a rule for whether earlier steps were incorrect.\nFor each candidate block, inspect every assistant action in it and its following observation.\nAdmit a block only when you can point at the specific evidence it produced: name as consequence_step the step number whose action or observation shows the damage — a failing command, a wrong file state, a repeated failure, or rework the agent had to do because of this block. That step is the block's own last step when its observation already shows the damage, and a later step otherwise.\nWhen you cannot name that later step number from the trace you were given, drop the block; a plausible story about why a step looks wrong is not evidence that it was.\nJudge that consequence from the trajectory itself: a passing final verification is not evidence that a block caused nothing, and a failing final verification is not evidence that any particular block caused it.\nFor every block, decide whether the agent escaped the failure.\nMark escape_status \"escaped\" only when you can name the single later step that fully reversed the block, the agent needed no other step to recover, and nothing after that step revisits the same file, command, or hypothesis; write that step number in the rationale.\nMark escape_status \"unescaped\" in every other case, including whenever you are unsure.\nA passing final verification never makes a block escaped: the agent may have made the mistake and repaired it over several steps, and those steps are still incorrect.\nLabel a failed command when the assistant caused it through a wrong action or unsupported hypothesis.\nLabel the later corrective action only when that action is itself wrong.\nDo not label a diagnostic probe merely because it exposes an earlier defect.\nDo not label a redundant but correct read or search; CodeTraceBench scores unuseful steps separately, and this run scores incorrect steps only.\nDo not label a step solely because final verification failed.\nWhen final verification is unavailable, use only directly observed trajectory evidence.\nEvery step in a reported block MUST be the positive integer n from an existing assistant LLM span named step-<n>.\nNever select an EVALUATOR, TOOL, CHAIN, final-verification, benchmark-verification, or message-<n> span.\nBefore emitting a finding, inspect every covered span's attributes.content and describe only the actions shown there.\nReport at most ${MAX_INCORRECT_BLOCKS} blocks and at most ${MAX_INCORRECT_BLOCK_STEPS} steps in one block; when more candidates than that exist, report the ones you can support with the clearest downstream evidence.\nWhen the trajectory has no incorrect steps, return an empty findings array.`\n\nconst AGENT_RX_PROMPT = `Analyze exactly one failed agent trajectory.\nFind the first unrecoverable critical failure, not every later symptom.\nInspect the complete supplied trace data.\nEmit zero findings only when the trace does not contain enough evidence.\nOtherwise emit exactly one finding.\nIts category MUST be exactly one of:\ninstruction-plan-adherence-failure\ninvention-of-new-information\ninvalid-invocation\nmisinterpretation-of-tool-output-handoff-failure\nintent-plan-misalignment\nunderspecified-user-intent\nintent-not-supported\nguardrails-triggered\nsystem-failure\ninconclusive\nIts step is the positive integer n from the first unrecoverable assistant span named step-<n>.`\n\nconst AGENT_RX_JSON_CONTRACT = `Each finding must contain only:\n- \"step\": a positive integer matching an existing assistant LLM span named step-<n>\n- \"severity\": \"critical\", \"high\", \"medium\", \"low\", or \"info\"\n- \"claim\": one sentence\n- \"confidence\": a number from 0 through 1\n- optional \"rationale\" and \"recommended_action\" strings\n- \"category\": one allowed failure category listed above`\n\nconst CODE_TRACE_JSON_CONTRACT = `Each finding is one contiguous failure block and must contain only:\n- \"first_step\": a positive integer, the block's first incorrect step, matching an existing assistant LLM span named step-<n>\n- \"last_step\": a positive integer >= first_step, the block's last incorrect step; every step from first_step through last_step must be an existing assistant LLM span, and a block spans at most ${MAX_INCORRECT_BLOCK_STEPS} steps\n- \"consequence_step\": a positive integer >= first_step, the step whose action or following observation shows the damage this block caused; it may sit inside the block when the damage is already visible there\n- \"escape_status\": \"escaped\" only when one single later step fully reversed the block and nothing afterwards revisits it, \"unescaped\" otherwise and whenever you are unsure\n- \"severity\": \"critical\", \"high\", \"medium\", \"low\", or \"info\"\n- \"claim\": one sentence describing the block's failure\n- \"confidence\": a number from 0 through 1\n- optional \"rationale\" and \"recommended_action\" strings`\n\nconst AGENT_RX_RLM_CONTRACT = `Use the trace tools to inspect the action and its following observation.\nEmit exactly one finding whose subject is exactly one of the allowed failure categories.\nCite exactly one assistant span named step-<n> as trace://<URL-encoded-trace-id>/span/step-<n>.\nThe excerpt must quote the assistant action exactly.`\n\nconst CODE_TRACE_RLM_CONTRACT = `Use the trace tools rather than asking for the whole trajectory in the prompt.\nKeep retrieved trace objects in Python variables.\nNever print an entire trace, full source file, or more than 12000 characters in one iteration.\nBuild a compact table of assistant step ids, actions, following observations, and final verification.\nInspect suspicious steps with viewSpans or searchSpan instead of repeatedly printing the table.\nThis runner emits no JSON fields, so the block is encoded in the finding's subject.\nEmit exactly one finding per contiguous failure block.\nSet the finding's subject to incorrect-steps-<first_step>-<last_step>-<escape_status>-consequence-<consequence_step>, using the same four values the task defines; for a block covering only step 7 that the agent never escaped and whose damage shows at step 9, the subject is incorrect-steps-7-7-unescaped-consequence-9.\nThe runner expands the block to one scored step per member and builds every scored citation itself.\nCite the block's first step and its last step as trace://<URL-encoded-trace-id>/span/step-<n>, each excerpt an exact quote from that step's own action content.\nGive the rationale as the concrete downstream evidence visible at the consequence step.\nSubmit as soon as every candidate failure block has a supported verdict.\nReturn no finding for a clean trajectory.`\n\n/** One-shot JSON transport prompt for the direct runner. */\nexport function publicBenchmarkSystemPrompt(dataset: PublicAnalystBenchmarkDataset): string {\n const fieldContract = dataset === 'agentrx' ? AGENT_RX_JSON_CONTRACT : CODE_TRACE_JSON_CONTRACT\n return `${publicBenchmarkTaskPrompt(dataset)}\n\n${fieldContract}\n\nReturn exactly one JSON object with:\n- \"report\": a concise evidence-based explanation, at most 4000 characters\n- \"findings\": the strict finding array\nUse an empty findings array when the trace does not support a finding.\nDo not return a bare array, markdown, trace URIs, copied excerpts, or fields not listed above.\nThe runner constructs exact trace URIs and action previews from each selected step.`\n}\n\n/** Tool-loop prompt for the recursive runner. Same task, subject-encoded block. */\nexport function publicBenchmarkRlmInstructions(dataset: PublicAnalystBenchmarkDataset): string {\n const outputContract = dataset === 'agentrx' ? AGENT_RX_RLM_CONTRACT : CODE_TRACE_RLM_CONTRACT\n return `${publicBenchmarkTaskPrompt(dataset)}\n${outputContract}`\n}\n\nfunction publicBenchmarkTaskPrompt(dataset: PublicAnalystBenchmarkDataset): string {\n return dataset === 'agentrx' ? AGENT_RX_PROMPT : CODE_TRACE_BENCH_ANALYST_PROMPT\n}\n\n/** Digest of every prompt a runner can send plus the shared transport limits.\n * Both runner contracts are hashed so an edit to either one changes the digest\n * a run records, whichever runner executed. */\nexport function publicBenchmarkProtocolSha256(dataset: PublicAnalystBenchmarkDataset): string {\n return sha256Digest(\n JSON.stringify({\n dataset,\n systemPrompt: publicBenchmarkSystemPrompt(dataset),\n rlmInstructions: publicBenchmarkRlmInstructions(dataset),\n transport: {\n attempts: 1,\n jsonMode: true,\n thinking: 'disabled',\n },\n blockLimits:\n dataset === 'agentrx'\n ? null\n : {\n maxBlocks: MAX_INCORRECT_BLOCKS,\n maxBlockSteps: MAX_INCORRECT_BLOCK_STEPS,\n },\n traceProjectionAttributeByteCaps: TRACE_PROJECTION_ATTRIBUTE_BYTE_CAPS,\n evidence: {\n location: 'model-selected-positive-integer-assistant-step',\n uri: 'deterministic-trace-uri',\n excerpt: `exact-action-prefix-${MAX_ASSISTANT_STEP_EVIDENCE_EXCERPT_CHARACTERS}`,\n },\n }),\n )\n}\n","import type { TraceAnalysisStore } from '../trace-analyst/store'\nimport type { AnalystBenchmarkRunner } from './benchmark'\nimport { agentRxPredictionsToFindings } from './benchmark-datasets'\nimport {\n codeTraceStepFromEvidence,\n resolveAssistantStepEvidence,\n validateCodeTraceFindingEvidence,\n} from './benchmark-evidence-validation'\nimport { MAX_INCORRECT_BLOCK_STEPS, MAX_INCORRECT_BLOCKS } from './benchmark-public-prompt'\nimport type { PublicAnalystBenchmarkDataset } from './benchmark-public-types'\nimport type { AnalystFinding, AnalystRunInputs, AnalystSeverity } from './types'\nimport { makeFinding } from './types'\n\n/**\n * One contiguous run of incorrect assistant steps, in the shape both public\n * benchmark runners produce. The direct runner parses it from JSON fields; the\n * recursive runner parses it from the finding subject. Expansion, evidence\n * resolution and scoring are identical from here on.\n */\nexport interface CodeTraceFailureBlock {\n firstStep: number\n lastStep: number\n /** Later step whose action or observation shows the damage this block caused. */\n consequenceStep: number\n escapeStatus: 'escaped' | 'unescaped'\n severity: AnalystSeverity\n claim: string\n confidence: number\n rationale?: string\n recommendedAction?: string\n metadata?: Record<string, unknown>\n}\n\n/**\n * What the expansion did with the model's blocks.\n *\n * Escaped blocks are scored exactly like unescaped ones — the escape decision\n * is recorded, never applied — so `escapedBlocks` measures the model's own\n * judgement without moving precision, recall, or the trusted-negative rate.\n */\nexport interface CodeTraceBlockDiagnostics {\n reportedBlocks: number\n escapedBlocks: number\n /** Blocks dropped because their consequence step is not a real assistant step. */\n blocksWithoutConsequenceEvidence: CodeTraceFailureBlock[]\n /** Interior steps a block claimed that the trace does not carry as assistant steps. */\n unresolvedBlockInteriorSteps: number[]\n /** Steps claimed by more than one block; the first block keeps the step. */\n overlappingBlockSteps: number[]\n}\n\nexport function emptyPublicBenchmarkRunner(): AnalystBenchmarkRunner<AnalystRunInputs> {\n return {\n id: 'empty',\n analyze() {\n return {\n findings: [],\n usage: {\n calls: 0,\n tokens: { input: 0, output: 0 },\n cost: { kind: 'observed', usd: 0 },\n },\n metadata: { baseline: 'emit-no-findings' },\n }\n },\n }\n}\n\nexport async function adaptPublicBenchmarkFindings(options: {\n dataset: PublicAnalystBenchmarkDataset\n trajectoryId: string\n findings: readonly AnalystFinding[]\n analystId: string\n store: TraceAnalysisStore\n signal?: AbortSignal\n}): Promise<{ findings: AnalystFinding[]; diagnostics: CodeTraceBlockDiagnostics | undefined }> {\n if (options.dataset === 'agentrx') {\n return {\n findings: adaptAgentRxFindings(options.trajectoryId, options.findings, options.analystId),\n diagnostics: undefined,\n }\n }\n return adaptCodeTraceFindings(\n options.trajectoryId,\n options.findings,\n options.analystId,\n options.store,\n options.signal,\n )\n}\n\nfunction adaptAgentRxFindings(\n trajectoryId: string,\n findings: readonly AnalystFinding[],\n analystId: string,\n): AnalystFinding[] {\n if (findings.length === 0) return []\n if (findings.length !== 1) {\n throw new Error(\n `AgentRx model analyst must emit zero or one root cause, received ${findings.length}`,\n )\n }\n const source = findings[0]!\n if (!source.subject) {\n throw new Error('AgentRx model analyst finding is missing its failure-category subject')\n }\n const steps = exactFindingSteps(trajectoryId, source)\n if (steps.length !== 1) {\n throw new Error(\n `AgentRx model analyst must cite exactly one root-cause step, received ${steps.length}`,\n )\n }\n const [adapted] = agentRxPredictionsToFindings(\n trajectoryId,\n [\n {\n failure_case: source.subject,\n step_number: steps[0]!,\n description: source.rationale ?? source.claim,\n },\n ],\n {\n analystId,\n producedAt: source.produced_at,\n confidence: source.confidence,\n },\n )\n if (!adapted) throw new Error('AgentRx output adapter produced no root-cause finding')\n return [\n {\n ...adapted,\n metadata: {\n ...adapted.metadata,\n sourceFindingId: source.finding_id,\n },\n },\n ]\n}\n\nconst CODE_TRACE_BLOCK_SUBJECT =\n /^incorrect-steps-(\\d+)-(\\d+)-(escaped|unescaped)-consequence-(\\d+)$/\n\nasync function adaptCodeTraceFindings(\n trajectoryId: string,\n findings: readonly AnalystFinding[],\n analystId: string,\n store: TraceAnalysisStore,\n signal?: AbortSignal,\n): Promise<{ findings: AnalystFinding[]; diagnostics: CodeTraceBlockDiagnostics }> {\n const clean = findings.filter((finding) => finding.subject === 'clean')\n if (clean.length > 0) {\n if (findings.length !== 1) {\n throw new Error('CodeTraceBench model analyst mixed a clean verdict with incorrect steps')\n }\n exactFindingSteps(trajectoryId, clean[0]!)\n return {\n findings: [],\n diagnostics: emptyCodeTraceBlockDiagnostics(),\n }\n }\n // Check the model's own citations and excerpts here: expansion replaces them\n // with runner-built evidence, so validating the expanded findings instead\n // would prove nothing about what the model quoted.\n await validateCodeTraceFindingEvidence({\n trajectoryId,\n findings,\n store,\n ...(signal ? { signal } : {}),\n })\n const blocks = findings.map((source) => codeTraceBlockFromFinding(trajectoryId, source))\n return expandCodeTraceFailureBlocks({\n trajectoryId,\n blocks,\n store,\n analystId,\n ...(findings[0] ? { producedAt: findings[0].produced_at } : {}),\n ...(signal ? { signal } : {}),\n })\n}\n\nfunction codeTraceBlockFromFinding(\n trajectoryId: string,\n source: AnalystFinding,\n): CodeTraceFailureBlock {\n const parsed = CODE_TRACE_BLOCK_SUBJECT.exec(source.subject ?? '')\n if (!parsed) {\n throw new Error(\n `CodeTraceBench model finding '${source.finding_id}' must set subject to incorrect-steps-<first>-<last>-<escaped|unescaped>-consequence-<step>, received '${source.subject ?? ''}'`,\n )\n }\n const firstStep = Number(parsed[1])\n const lastStep = Number(parsed[2])\n const consequenceStep = Number(parsed[4])\n const cited = exactFindingSteps(trajectoryId, source)\n for (const step of cited) {\n if (step < firstStep || step > lastStep) {\n throw new Error(\n `CodeTraceBench model finding '${source.finding_id}' cites step ${step} outside its block ${firstStep}-${lastStep}`,\n )\n }\n }\n return {\n firstStep,\n lastStep,\n consequenceStep,\n escapeStatus: parsed[3] as 'escaped' | 'unescaped',\n severity: source.severity,\n claim: source.claim,\n confidence: source.confidence,\n ...(source.rationale === undefined ? {} : { rationale: source.rationale }),\n ...(source.recommended_action === undefined\n ? {}\n : { recommendedAction: source.recommended_action }),\n metadata: { sourceFindingId: source.finding_id },\n }\n}\n\n/**\n * Expand contiguous failure blocks into one scored finding per member step.\n *\n * The official scorer matches on area plus the exact step evidence URI, so\n * blocks never reach it: every runner reports blocks, and this function turns\n * them into the per-step findings the benchmark defines.\n */\nexport async function expandCodeTraceFailureBlocks(options: {\n trajectoryId: string\n blocks: readonly CodeTraceFailureBlock[]\n store: TraceAnalysisStore\n analystId: string\n producedAt?: string\n signal?: AbortSignal\n}): Promise<{ findings: AnalystFinding[]; diagnostics: CodeTraceBlockDiagnostics }> {\n const diagnostics = emptyCodeTraceBlockDiagnostics()\n diagnostics.reportedBlocks = options.blocks.length\n if (options.blocks.length === 0) return { findings: [], diagnostics }\n assertCodeTraceBlockShape(options.blocks)\n\n const boundarySteps = options.blocks.flatMap((block) => [block.firstStep, block.lastStep])\n const derivedSteps = options.blocks.flatMap((block) => [\n block.consequenceStep,\n ...interiorSteps(block),\n ])\n const evidenceByStep = await resolveAssistantStepEvidence({\n trajectoryId: options.trajectoryId,\n steps: boundarySteps,\n optionalSteps: derivedSteps,\n store: options.store,\n ...(options.signal ? { signal: options.signal } : {}),\n })\n\n const byStep = new Map<number, CodeTraceFailureBlock>()\n for (const block of options.blocks) {\n if (!evidenceByStep.has(block.consequenceStep)) {\n diagnostics.blocksWithoutConsequenceEvidence.push(block)\n continue\n }\n if (block.escapeStatus === 'escaped') diagnostics.escapedBlocks += 1\n for (let step = block.firstStep; step <= block.lastStep; step += 1) {\n if (!evidenceByStep.has(step)) {\n diagnostics.unresolvedBlockInteriorSteps.push(step)\n continue\n }\n if (byStep.has(step)) {\n diagnostics.overlappingBlockSteps.push(step)\n continue\n }\n byStep.set(step, block)\n }\n }\n\n const findings = [...byStep]\n .sort(([left], [right]) => left - right)\n .map(([step, block]) =>\n makeFinding({\n analyst_id: options.analystId,\n area: 'incorrect',\n subject: `incorrect-step-${step}`,\n claim: `Step ${step} is incorrect. ${block.claim}`,\n rationale: block.rationale,\n severity: block.severity,\n confidence: block.confidence,\n evidence_refs: [evidenceByStep.get(step)!],\n recommended_action: block.recommendedAction,\n metadata: {\n ...block.metadata,\n block_first_step: block.firstStep,\n block_last_step: block.lastStep,\n block_consequence_step: block.consequenceStep,\n escape_status: block.escapeStatus,\n },\n ...(options.producedAt === undefined ? {} : { produced_at: options.producedAt }),\n id_basis: `incorrect-step-${step}`,\n }),\n )\n return { findings, diagnostics }\n}\n\nfunction assertCodeTraceBlockShape(blocks: readonly CodeTraceFailureBlock[]): void {\n if (blocks.length > MAX_INCORRECT_BLOCKS) {\n throw new Error(\n `model reported ${blocks.length} failure blocks; the maximum is ${MAX_INCORRECT_BLOCKS}`,\n )\n }\n for (const block of blocks) {\n if (block.lastStep < block.firstStep) {\n throw new Error(\n `failure block last_step ${block.lastStep} precedes first_step ${block.firstStep}`,\n )\n }\n const length = block.lastStep - block.firstStep + 1\n if (length > MAX_INCORRECT_BLOCK_STEPS) {\n throw new Error(\n `failure block spans ${length} steps; the maximum is ${MAX_INCORRECT_BLOCK_STEPS}`,\n )\n }\n if (block.consequenceStep < block.firstStep) {\n throw new Error(\n `failure block consequence_step ${block.consequenceStep} precedes first_step ${block.firstStep}`,\n )\n }\n }\n}\n\nfunction interiorSteps(block: CodeTraceFailureBlock): number[] {\n const steps: number[] = []\n for (let step = block.firstStep + 1; step < block.lastStep; step += 1) steps.push(step)\n return steps\n}\n\nfunction emptyCodeTraceBlockDiagnostics(): CodeTraceBlockDiagnostics {\n return {\n reportedBlocks: 0,\n escapedBlocks: 0,\n blocksWithoutConsequenceEvidence: [],\n unresolvedBlockInteriorSteps: [],\n overlappingBlockSteps: [],\n }\n}\n\nfunction exactFindingSteps(trajectoryId: string, finding: AnalystFinding): number[] {\n if (finding.evidence_refs.length === 0) {\n throw new Error(`model finding '${finding.finding_id}' has no step evidence`)\n }\n const steps = finding.evidence_refs.map((evidence) => {\n const parsed = codeTraceStepFromEvidence(evidence.uri)\n if (!parsed || parsed.traceId !== trajectoryId) {\n throw new Error(\n `model finding '${finding.finding_id}' cites non-case evidence '${evidence.uri}'`,\n )\n }\n return parsed.step\n })\n return [...new Set(steps)]\n}\n","import type { ExternalOptimizerRunnerCommand } from '../campaign/external-optimizer-contracts'\nimport type { CostLedgerHandle, CustomTokenPricing } from '../cost-ledger'\nimport type { AnalystBenchmarkCase } from './benchmark'\nimport type { VerificationArtifactManifest } from './benchmark-verification-artifacts'\nimport type { AnalystRunInputs } from './types'\n\nexport type PublicAnalystBenchmarkDataset = 'agentrx' | 'codetracebench'\n\nexport interface PublicAnalystBenchmarkModelConfig {\n baseUrl: string\n apiKey: string\n model: string\n maxOutputTokens: number\n timeoutMs: number\n /** Required when the model is absent from agent-eval's pricing table. */\n pricing?: CustomTokenPricing\n /** Independent per-case recursive-engine spend limit. Default: 1 USD. */\n maxCostUsdPerAnalysis?: number\n dspyRlm?: {\n runner?: ExternalOptimizerRunnerCommand\n maxIterations?: number\n maxLlmCalls?: number\n maxToolCalls?: number\n maxOutputChars?: number\n }\n costLedger?: CostLedgerHandle\n durability?: {\n runIdentitySha256: string\n responseCacheDir: string\n }\n /** Test-only transport injection. */\n fetchImpl?: typeof fetch\n}\n\nexport interface PreparedPublicAnalystBenchmark {\n cases: AnalystBenchmarkCase<AnalystRunInputs>[]\n sourceRowCount: number\n selectedCaseIds: string[]\n labelsSha256: string\n traceFiles: Array<{\n traceId: string\n relativePath: string\n sha256: string\n }>\n verificationArtifacts: VerificationArtifactManifest[]\n selection: PublicBenchmarkSelectionReport\n}\n\nexport interface PublicBenchmarkValueDistribution {\n total: number\n missing: number\n counts: Record<string, number>\n}\n\nexport interface PublicBenchmarkDistributions {\n class: PublicBenchmarkValueDistribution\n agent: PublicBenchmarkValueDistribution\n model: PublicBenchmarkValueDistribution\n difficulty: PublicBenchmarkValueDistribution\n solved: PublicBenchmarkValueDistribution\n}\n\nexport interface PublicBenchmarkSelectionReport {\n method: 'census' | 'deterministic-hash'\n seed: number\n sourceCount: number\n selectedCount: number\n stratified: false\n representativeOfInput: boolean\n source: PublicBenchmarkDistributions\n selected: PublicBenchmarkDistributions\n}\n\nexport function requiredString(value: string, field: string): string {\n const trimmed = value.trim()\n if (!trimmed) throw new TypeError(`${field} must be a non-empty string`)\n return trimmed\n}\n\nexport function positiveSafeInteger(value: number, field: string): number {\n if (!Number.isSafeInteger(value) || value < 1) {\n throw new RangeError(`${field} must be a positive safe integer`)\n }\n return value\n}\n\nexport function safeInteger(value: number, field: string): number {\n if (!Number.isSafeInteger(value)) throw new RangeError(`${field} must be a safe integer`)\n return value\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n","import { constants } from 'node:fs'\nimport { type FileHandle, open, readdir } from 'node:fs/promises'\nimport { relative, resolve, sep } from 'node:path'\nimport type { TraceAnalysisStore } from '../trace-analyst/store'\nimport {\n createOtlpBufferTraceStore,\n DEFAULT_MAX_TRACE_FILE_BYTES,\n otlpTextToTraceAnalysisStore,\n} from '../trace-analyst/store-otlp'\nimport { type AnalystBenchmarkCase, traceStoreEvidenceResolver } from './benchmark'\nimport {\n type AgentRxRow,\n agentRxBenchmarkCase,\n type CodeTraceBenchRow,\n codeTraceBenchCase,\n} from './benchmark-datasets'\nimport {\n assertNoBenchmarkLabelsInArtifact,\n assertNoBenchmarkLabelsInTrace,\n} from './benchmark-evidence-validation'\nimport {\n isRecord,\n type PreparedPublicAnalystBenchmark,\n type PublicAnalystBenchmarkDataset,\n type PublicBenchmarkDistributions,\n type PublicBenchmarkSelectionReport,\n type PublicBenchmarkValueDistribution,\n positiveSafeInteger,\n safeInteger,\n} from './benchmark-public-types'\nimport {\n appendVerificationArtifactsToOtlp,\n DEFAULT_MAX_VERIFICATION_ARTIFACT_BYTES,\n loadCodeTraceVerificationArtifacts,\n sha256Digest,\n type VerificationArtifactManifest,\n} from './benchmark-verification-artifacts'\nimport type { AnalystRunInputs } from './types'\n\nconst DEFAULT_MAX_PUBLIC_BENCHMARK_LABEL_BYTES = 256 * 1024 * 1024\nconst INPUT_OPEN_FLAGS = constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0)\n\ninterface ImmutableInputSnapshot {\n bytes: Buffer\n sha256: string\n text: string\n}\n\nexport async function loadPublicBenchmarkRows(\n path: string,\n): Promise<Array<Record<string, unknown>>> {\n const snapshot = await readImmutableInputSnapshot(\n resolve(path),\n DEFAULT_MAX_PUBLIC_BENCHMARK_LABEL_BYTES,\n )\n return parsePublicBenchmarkRows(snapshot.text, path)\n}\n\nfunction parsePublicBenchmarkRows(text: string, path: string): Array<Record<string, unknown>> {\n const trimmed = text.trim()\n if (!trimmed) throw new Error(`public analyst benchmark dataset is empty: ${path}`)\n\n let parsed: unknown\n try {\n parsed = JSON.parse(trimmed)\n } catch {\n return parseJsonl(trimmed, path)\n }\n if (Array.isArray(parsed)) return records(parsed, path)\n if (isRecord(parsed) && Array.isArray(parsed.data)) return records(parsed.data, `${path}.data`)\n if (isRecord(parsed) && Array.isArray(parsed.cases)) {\n return records(parsed.cases, `${path}.cases`)\n }\n if (isRecord(parsed)) return [parsed]\n throw new TypeError(`public analyst benchmark dataset must contain JSON objects: ${path}`)\n}\n\nexport function selectPublicBenchmarkRows(\n dataset: PublicAnalystBenchmarkDataset,\n rows: readonly Record<string, unknown>[],\n options: { limit: number; seed: number },\n): Array<Record<string, unknown>> {\n positiveSafeInteger(options.limit, 'limit')\n safeInteger(options.seed, 'seed')\n if (rows.length === 0) throw new Error('public analyst benchmark dataset has no rows')\n\n const byId = new Map<string, Record<string, unknown>>()\n for (const row of rows) {\n const id = publicBenchmarkRowId(dataset, row)\n if (byId.has(id)) {\n throw new Error(`public analyst benchmark dataset repeats trajectory id '${id}'`)\n }\n byId.set(id, row)\n }\n\n return [...byId]\n .sort(\n ([left], [right]) =>\n selectionKey(options.seed, left).localeCompare(selectionKey(options.seed, right)) ||\n left.localeCompare(right),\n )\n .slice(0, Math.min(options.limit, byId.size))\n .map(([, row]) => row)\n}\n\nexport function publicBenchmarkDistributions(\n dataset: PublicAnalystBenchmarkDataset,\n rows: readonly Record<string, unknown>[],\n): PublicBenchmarkDistributions {\n const values: Record<keyof PublicBenchmarkDistributions, Array<string | undefined>> = {\n class: [],\n agent: [],\n model: [],\n difficulty: [],\n solved: [],\n }\n for (const row of rows) {\n const benchmarkCase =\n dataset === 'agentrx'\n ? agentRxBenchmarkCase(row as unknown as AgentRxRow, undefined)\n : codeTraceBenchCase(row as unknown as CodeTraceBenchRow, undefined)\n values.class.push(\n dataset === 'codetracebench'\n ? benchmarkCase.expectedIssues.length > 0\n ? 'positive'\n : row.solved === true\n ? 'trusted-negative'\n : row.solved === false\n ? 'unlabeled-failure'\n : 'unlabeled-unknown'\n : benchmarkCase.expectedIssues[0]?.areas?.[0],\n )\n values.agent.push(\n scalarDistributionValue(row.agent) ??\n (dataset === 'agentrx' ? rootAgent(row as unknown as AgentRxRow) : undefined),\n )\n values.model.push(scalarDistributionValue(row.model))\n values.difficulty.push(scalarDistributionValue(row.difficulty))\n values.solved.push(scalarDistributionValue(row.solved))\n }\n return {\n class: valueDistribution(values.class),\n agent: valueDistribution(values.agent),\n model: valueDistribution(values.model),\n difficulty: valueDistribution(values.difficulty),\n solved: valueDistribution(values.solved),\n }\n}\n\nexport function publicBenchmarkSelectionReport(\n dataset: PublicAnalystBenchmarkDataset,\n source: readonly Record<string, unknown>[],\n selected: readonly Record<string, unknown>[],\n seed: number,\n): PublicBenchmarkSelectionReport {\n const census = source.length === selected.length\n return {\n method: census ? 'census' : 'deterministic-hash',\n seed,\n sourceCount: source.length,\n selectedCount: selected.length,\n stratified: false,\n representativeOfInput: census,\n source: publicBenchmarkDistributions(dataset, source),\n selected: publicBenchmarkDistributions(dataset, selected),\n }\n}\n\nexport async function preparePublicAnalystBenchmark(options: {\n dataset: PublicAnalystBenchmarkDataset\n labelsPath: string\n traceDir: string\n artifactDir?: string\n maxArtifactBytes?: number\n limit: number\n seed: number\n}): Promise<PreparedPublicAnalystBenchmark> {\n const labelsPath = resolve(options.labelsPath)\n const traceRoot = resolve(options.traceDir)\n const artifactRoot = options.artifactDir ? resolve(options.artifactDir) : undefined\n const labelSnapshot = await readImmutableInputSnapshot(\n labelsPath,\n DEFAULT_MAX_PUBLIC_BENCHMARK_LABEL_BYTES,\n )\n const rows = parsePublicBenchmarkRows(labelSnapshot.text, labelsPath)\n const selected = selectPublicBenchmarkRows(options.dataset, rows, {\n limit: options.limit,\n seed: options.seed,\n })\n const selectedTrajectoryIds = new Set(\n selected.map((row) => publicBenchmarkRowId(options.dataset, row)),\n )\n const stores = await indexSelectedSingleTraceFiles(traceRoot, selectedTrajectoryIds)\n const resolver = traceStoreEvidenceResolver<AnalystRunInputs>((input) => {\n if (!input.traceStore) throw new Error('prepared benchmark case has no trace store')\n return input.traceStore\n })\n const traceFiles: PreparedPublicAnalystBenchmark['traceFiles'] = []\n const verificationArtifacts: VerificationArtifactManifest[] = []\n const cases: AnalystBenchmarkCase<AnalystRunInputs>[] = []\n\n for (const row of selected) {\n const trajectoryId = publicBenchmarkRowId(options.dataset, row)\n const indexed = stores.get(trajectoryId)\n if (!indexed) {\n throw new Error(\n `public analyst benchmark trace directory has no single-trace OTLP JSONL for '${trajectoryId}'`,\n )\n }\n let modelVisibleOtlp = indexed.text\n let traceStore = indexed.store\n let artifactDir: string | undefined\n let verificationManifest: VerificationArtifactManifest | undefined\n if (options.dataset === 'codetracebench') {\n if (!options.artifactDir?.trim()) {\n throw new Error(\n '--artifact-dir is required for CodeTraceBench so final verification evidence is not omitted',\n )\n }\n const artifacts = await loadCodeTraceVerificationArtifacts({\n artifactDir: options.artifactDir,\n row: row as unknown as CodeTraceBenchRow,\n maxBytes: options.maxArtifactBytes ?? DEFAULT_MAX_VERIFICATION_ARTIFACT_BYTES,\n })\n for (const artifact of artifacts.files) {\n assertNoBenchmarkLabelsInArtifact({\n traceId: trajectoryId,\n relativePath: artifact.relativePath,\n content: artifact.content,\n })\n }\n verificationManifest = shareableVerificationManifest(\n artifacts.manifest,\n artifactRoot ?? resolve(options.artifactDir),\n )\n const collisions = await indexed.store.hasSpans({\n trace_id: trajectoryId,\n span_ids: [\n ...artifacts.manifest.files.map((file) => file.spanId),\n artifacts.manifest.outcomeSpanId,\n ],\n })\n if (collisions.length > 0) {\n throw new Error(\n `CodeTraceBench '${trajectoryId}' trace already contains benchmark verification span '${collisions[0]}'`,\n )\n }\n modelVisibleOtlp = appendVerificationArtifactsToOtlp(\n indexed.text,\n trajectoryId,\n artifacts,\n indexed.latestTimestamp,\n )\n traceStore = otlpTextToTraceAnalysisStore(modelVisibleOtlp)\n artifactDir =\n artifacts.manifest.status === 'present' ? artifacts.manifest.caseDirectory : undefined\n verificationArtifacts.push(verificationManifest)\n }\n const labelLeakScan = assertNoBenchmarkLabelsInTrace({\n traceId: trajectoryId,\n otlpText: modelVisibleOtlp,\n })\n\n const input: AnalystRunInputs = { traceStore, artifactDir }\n const benchmarkCase =\n options.dataset === 'agentrx'\n ? agentRxBenchmarkCase(row as unknown as AgentRxRow, input, {\n stepCount: indexed.stepCount,\n })\n : codeTraceBenchCase(row as unknown as CodeTraceBenchRow, input)\n\n for (const evidence of benchmarkCase.labeledEvidence ?? []) {\n const resolved = await resolver({\n caseId: benchmarkCase.id,\n caseInput: input,\n evidence: { kind: evidence.kind ?? 'span', uri: evidence.uri },\n })\n if (!resolved) {\n throw new Error(\n `${benchmarkCase.id}: missing labeled span ${spanIdFromEvidence(evidence.uri) ?? evidence.uri} in ${indexed.path}`,\n )\n }\n }\n\n cases.push({\n ...benchmarkCase,\n metadata: {\n ...benchmarkCase.metadata,\n traceFileRelativePath: slashRelative(traceRoot, indexed.path),\n traceFileSha256: indexed.sha256,\n labelLeakScan,\n ...(verificationManifest ? { verificationArtifacts: verificationManifest } : {}),\n },\n })\n traceFiles.push({\n traceId: trajectoryId,\n relativePath: slashRelative(traceRoot, indexed.path),\n sha256: indexed.sha256,\n })\n }\n\n return {\n cases,\n sourceRowCount: rows.length,\n selectedCaseIds: cases.map((testCase) => testCase.id),\n labelsSha256: labelSnapshot.sha256,\n traceFiles,\n verificationArtifacts,\n selection: publicBenchmarkSelectionReport(options.dataset, rows, selected, options.seed),\n }\n}\n\nasync function indexSelectedSingleTraceFiles(\n traceDir: string,\n selectedTraceIds: ReadonlySet<string>,\n): Promise<\n Map<\n string,\n {\n path: string\n sha256: string\n store: TraceAnalysisStore\n latestTimestamp: string\n text: string\n stepCount: number\n }\n >\n> {\n if (selectedTraceIds.size === 0) {\n throw new Error('public analyst benchmark selected no trace ids')\n }\n const entries = await readdir(traceDir, { withFileTypes: true })\n const files = entries\n .filter((entry) => entry.isFile() && entry.name.endsWith('.jsonl'))\n .map((entry) => resolve(traceDir, entry.name))\n .sort()\n if (files.length === 0) {\n throw new Error(`public analyst benchmark trace directory has no JSONL files: ${traceDir}`)\n }\n\n const indexed = new Map<\n string,\n {\n path: string\n sha256: string\n store: TraceAnalysisStore\n latestTimestamp: string\n text: string\n stepCount: number\n }\n >()\n for (const path of files) {\n const snapshot = await readImmutableInputSnapshot(path, DEFAULT_MAX_TRACE_FILE_BYTES)\n const store = createOtlpBufferTraceStore(snapshot.bytes)\n const overview = await store.getOverview()\n if (overview.total_traces !== 1 || overview.sample_trace_ids.length !== 1) {\n throw new Error(\n `public analyst benchmark trace file must contain exactly one trace: ${path} contains ${overview.total_traces}`,\n )\n }\n if (!overview.time_range) {\n throw new Error(`public analyst benchmark trace file has no valid timestamps: ${path}`)\n }\n const traceId = overview.sample_trace_ids[0]!\n if (!selectedTraceIds.has(traceId)) continue\n if (indexed.has(traceId)) {\n throw new Error(`public analyst benchmark trace id '${traceId}' appears in multiple files`)\n }\n indexed.set(traceId, {\n path,\n sha256: snapshot.sha256,\n store,\n latestTimestamp: overview.time_range.latest,\n text: snapshot.text,\n stepCount: traceStepCount(snapshot.text, path),\n })\n }\n return indexed\n}\n\nasync function readImmutableInputSnapshot(\n path: string,\n maxBytes: number,\n): Promise<ImmutableInputSnapshot> {\n if (!Number.isSafeInteger(maxBytes) || maxBytes < 1) {\n throw new RangeError('benchmark input maxBytes must be a positive safe integer')\n }\n const handle = await open(path, INPUT_OPEN_FLAGS)\n try {\n return await readImmutableInputHandle(handle, path, maxBytes)\n } finally {\n await handle.close()\n }\n}\n\nasync function readImmutableInputHandle(\n handle: FileHandle,\n path: string,\n maxBytes: number,\n): Promise<ImmutableInputSnapshot> {\n const before = await handle.stat({ bigint: true })\n if (!before.isFile()) {\n throw new TypeError(`public analyst benchmark input must be a regular file: ${path}`)\n }\n if (before.size > BigInt(maxBytes)) {\n throw new RangeError(\n `public analyst benchmark input exceeds ${maxBytes} bytes: ${path} has ${before.size}`,\n )\n }\n\n const size = Number(before.size)\n const bytes = Buffer.allocUnsafe(size)\n let offset = 0\n while (offset < size) {\n const result = await handle.read(bytes, offset, size - offset, offset)\n if (result.bytesRead === 0) {\n throw new Error(`public analyst benchmark input changed while being read: ${path}`)\n }\n offset += result.bytesRead\n }\n const overflow = Buffer.allocUnsafe(1)\n const extra = await handle.read(overflow, 0, 1, size)\n const after = await handle.stat({ bigint: true })\n if (\n extra.bytesRead !== 0 ||\n before.dev !== after.dev ||\n before.ino !== after.ino ||\n before.size !== after.size ||\n before.mtimeNs !== after.mtimeNs ||\n before.ctimeNs !== after.ctimeNs\n ) {\n throw new Error(`public analyst benchmark input changed while being read: ${path}`)\n }\n\n let text: string\n try {\n text = new TextDecoder('utf-8', { fatal: true }).decode(bytes)\n } catch (error) {\n throw new TypeError(\n `public analyst benchmark input is not valid UTF-8: ${path}: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n return Object.freeze({\n bytes,\n sha256: sha256Digest(bytes),\n text,\n })\n}\n\nfunction traceStepCount(text: string, path: string): number {\n const steps = parseJsonl(text, path)\n .map((row) => row.span_id)\n .filter((spanId): spanId is string => typeof spanId === 'string')\n .map((spanId) => /^step-(\\d+)$/.exec(spanId)?.[1])\n .filter((step): step is string => step !== undefined)\n .map(Number)\n .filter((step) => Number.isSafeInteger(step) && step > 0)\n if (steps.length === 0) {\n throw new Error(`public analyst benchmark trace has no step-<n> spans: ${path}`)\n }\n return Math.max(...steps)\n}\n\nfunction shareableVerificationManifest(\n manifest: VerificationArtifactManifest,\n artifactRoot: string,\n): VerificationArtifactManifest {\n return {\n ...manifest,\n caseDirectory: slashRelative(artifactRoot, manifest.caseDirectory),\n caseDirectoriesSearched: manifest.caseDirectoriesSearched.map((path) =>\n slashRelative(artifactRoot, path),\n ),\n files: manifest.files.map((file) => ({\n ...file,\n path: slashRelative(artifactRoot, file.path),\n })),\n }\n}\n\nfunction slashRelative(root: string, path: string): string {\n const value = relative(root, path)\n if (!value || value === '..' || value.startsWith(`..${sep}`)) {\n if (!value) return '.'\n throw new Error(`benchmark artifact path escapes its declared root: ${path}`)\n }\n return value.replaceAll('\\\\', '/')\n}\n\nfunction parseJsonl(text: string, path: string): Array<Record<string, unknown>> {\n const rows: Array<Record<string, unknown>> = []\n for (const [index, line] of text.split(/\\r?\\n/).entries()) {\n const trimmed = line.trim()\n if (!trimmed) continue\n let parsed: unknown\n try {\n parsed = JSON.parse(trimmed)\n } catch (error) {\n throw new Error(\n `${path}:${index + 1}: invalid JSON: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n if (!isRecord(parsed)) {\n throw new TypeError(`${path}:${index + 1}: dataset row must be a JSON object`)\n }\n rows.push(parsed)\n }\n if (rows.length === 0) throw new Error(`public analyst benchmark dataset is empty: ${path}`)\n return rows\n}\n\nfunction records(values: readonly unknown[], path: string): Array<Record<string, unknown>> {\n return values.map((value, index) => {\n if (!isRecord(value)) throw new TypeError(`${path}[${index}] must be a JSON object`)\n return value\n })\n}\n\nfunction publicBenchmarkRowId(\n dataset: PublicAnalystBenchmarkDataset,\n row: Record<string, unknown>,\n): string {\n const value = dataset === 'agentrx' ? row.trajectory_id : row.traj_id\n if ((typeof value !== 'string' && typeof value !== 'number') || !String(value).trim()) {\n throw new TypeError(\n `${dataset} dataset row requires a non-empty ${dataset === 'agentrx' ? 'trajectory_id' : 'traj_id'}`,\n )\n }\n return String(value)\n}\n\nfunction spanIdFromEvidence(uri: string): string | null {\n const match = /\\/span\\/([^/]+)$/.exec(uri)\n return match?.[1] ? decodeURIComponent(match[1]) : null\n}\n\nfunction selectionKey(seed: number, id: string): string {\n return sha256Digest(`${seed}\\u0000${id}`)\n}\n\nfunction valueDistribution(\n values: readonly (string | undefined)[],\n): PublicBenchmarkValueDistribution {\n const counts = new Map<string, number>()\n let missing = 0\n for (const value of values) {\n if (value === undefined) {\n missing += 1\n continue\n }\n counts.set(value, (counts.get(value) ?? 0) + 1)\n }\n return {\n total: values.length,\n missing,\n counts: Object.fromEntries([...counts].sort(([left], [right]) => left.localeCompare(right))),\n }\n}\n\nfunction scalarDistributionValue(value: unknown): string | undefined {\n if (typeof value === 'string') return value.trim() || undefined\n if (typeof value === 'number' || typeof value === 'boolean') return String(value)\n return undefined\n}\n\nfunction rootAgent(row: AgentRxRow): string | undefined {\n const rootCauseId = row.root_cause_failure_id ?? row.root_cause?.failure_id\n const root = row.failures.find((failure) => String(failure.failure_id) === String(rootCauseId))\n return scalarDistributionValue(root?.failed_agent)\n}\n","import { z } from 'zod'\nimport {\n CostAccountingIncompleteError,\n CostCeilingReachedError,\n CostReservationExceededError,\n} from '../cost-ledger'\nimport { AgentEvalError } from '../errors'\nimport { LlmCallError, LlmResponseError } from '../llm-client'\nimport type { AnalystBenchmarkError } from './benchmark'\n\nexport function publicBenchmarkError(\n error: unknown,\n secrets: readonly string[] = [],\n): AnalystBenchmarkError {\n if (error instanceof LlmCallError) {\n return {\n class: 'LlmCallError',\n code: error.code,\n status: error.status,\n message: `Provider request failed with HTTP ${error.status}.`,\n }\n }\n if (error instanceof LlmResponseError) {\n return {\n class: 'LlmResponseError',\n code: error.code,\n message: 'Provider response did not satisfy the structured output contract.',\n }\n }\n if (error instanceof z.ZodError) {\n return {\n class: 'ModelOutputValidationError',\n message: 'Provider response did not match the benchmark output schema.',\n }\n }\n if (error instanceof SyntaxError) {\n return {\n class: 'ModelOutputParseError',\n message: 'Provider response was not valid JSON.',\n }\n }\n if (\n error instanceof CostCeilingReachedError ||\n error instanceof CostAccountingIncompleteError ||\n error instanceof CostReservationExceededError\n ) {\n return {\n class: error.constructor.name,\n code: error.code,\n message: redactSensitiveText(error.message, secrets),\n }\n }\n if (error instanceof Error && error.name === 'AbortError') {\n return {\n class: 'ProviderTimeoutError',\n message: 'Provider request timed out.',\n }\n }\n if (\n error instanceof Error &&\n /(?:assistant steps?|finding evidence|selected missing|selected unavailable|no readable spans|requires a trace store)/i.test(\n error.message,\n )\n ) {\n return {\n class: 'BenchmarkEvidenceError',\n message: redactSensitiveText(error.message, secrets),\n }\n }\n if (error instanceof AgentEvalError) {\n return {\n class: error.constructor.name,\n code: error.code,\n message: redactSensitiveText(error.message, secrets),\n }\n }\n if (error instanceof Error) {\n return {\n class: error.constructor.name || 'Error',\n message: redactSensitiveText(error.message, secrets),\n }\n }\n return {\n class: 'Error',\n message: 'Benchmark analyst execution failed.',\n }\n}\n\nfunction redactSensitiveText(value: string, secrets: readonly string[]): string {\n let redacted = value\n for (const secret of secrets) {\n if (secret) redacted = redacted.replaceAll(secret, '[REDACTED]')\n }\n redacted = redacted\n .replace(/\\bBearer\\s+[^\\s\"',;]+/gi, 'Bearer [REDACTED]')\n .replace(\n /\\b(api[_-]?key|access[_-]?token|refresh[_-]?token|password|secret)\\b\\s*[:=]\\s*[^\\s\"',;]+/gi,\n '$1=[REDACTED]',\n )\n if (redacted.length <= 500) return redacted\n const head = redacted.slice(0, 180)\n const omitted = redacted.length - 460\n const marker = `...[${omitted} chars omitted]...`\n return `${head}${marker}${redacted.slice(-(500 - head.length - marker.length))}`\n}\n","import { existsSync, lstatSync, readFileSync } from 'node:fs'\nimport * as nodePath from 'node:path'\nimport { z } from 'zod'\nimport type { CostReceiptInput } from '../cost-ledger'\nimport { ValidationError } from '../errors'\nimport {\n canonicalString,\n hashCanonical,\n withLedgerFileLock,\n writeLedgerFileAtomically,\n} from '../ledger-core'\nimport type { AnalystBenchmarkError } from './benchmark'\n\nconst SHA256 = /^[a-f0-9]{64}$/\n\nconst CostReceiptInputSchema = z\n .object({\n model: z.string().min(1),\n inputTokens: z.number().int().nonnegative(),\n outputTokens: z.number().int().nonnegative(),\n reasoningTokens: z.number().int().nonnegative().optional(),\n cachedTokens: z.number().int().nonnegative().optional(),\n cacheWriteTokens: z.number().int().nonnegative().optional(),\n customTokenPricing: z\n .object({\n inputUsdPerMillion: z.number().nonnegative(),\n cachedInputUsdPerMillion: z.number().nonnegative().optional(),\n cacheWriteUsdPerMillion: z.number().nonnegative().optional(),\n outputUsdPerMillion: z.number().nonnegative(),\n })\n .strict()\n .optional(),\n actualCostUsd: z.number().nonnegative().optional(),\n estimatedCostUsd: z.number().nonnegative().optional(),\n costUnknown: z.boolean().optional(),\n usageUnknown: z.boolean().optional(),\n })\n .strict()\n\nconst BenchmarkErrorSchema = z\n .object({\n class: z.string().min(1),\n message: z.string(),\n code: z.string().min(1).optional(),\n status: z.number().int().min(100).max(599).optional(),\n })\n .strict()\n\nconst ResponseMetadataSchema = z\n .object({\n providerModel: z.string().min(1),\n providerDurationMs: z.number().nonnegative(),\n finishReason: z.string().nullable(),\n producedAt: z.string().datetime(),\n })\n .strict()\n\nconst CacheIdentityShape = {\n kind: z.literal('agent-eval/public-benchmark-model-response'),\n callId: z.string().min(1),\n runIdentitySha256: z.string().regex(SHA256),\n caseId: z.string().min(1),\n repetition: z.number().int().nonnegative(),\n}\n\nconst SuccessCacheEntryWithoutDigestSchema = z\n .object({\n ...CacheIdentityShape,\n status: z.literal('succeeded'),\n response: z.json(),\n metadata: ResponseMetadataSchema,\n receipt: CostReceiptInputSchema,\n })\n .strict()\n\nconst FailureCacheEntryWithoutDigestSchema = z\n .object({\n ...CacheIdentityShape,\n status: z.literal('failed'),\n error: BenchmarkErrorSchema,\n receipt: CostReceiptInputSchema,\n })\n .strict()\n\nconst CacheEntryWithoutDigestSchema = z.discriminatedUnion('status', [\n SuccessCacheEntryWithoutDigestSchema,\n FailureCacheEntryWithoutDigestSchema,\n])\n\nconst CacheEntrySchema = z.discriminatedUnion('status', [\n SuccessCacheEntryWithoutDigestSchema.extend({\n entrySha256: z.string().regex(SHA256),\n }),\n FailureCacheEntryWithoutDigestSchema.extend({\n entrySha256: z.string().regex(SHA256),\n }),\n])\n\ninterface CacheIdentity {\n runIdentitySha256: string\n caseId: string\n repetition: number\n}\n\nexport interface PublicBenchmarkResponseMetadata {\n providerModel: string\n providerDurationMs: number\n finishReason: string | null\n producedAt: string\n}\n\nexport type PublicBenchmarkResponseCacheEntry =\n | (CacheIdentity & {\n kind: 'agent-eval/public-benchmark-model-response'\n callId: string\n status: 'succeeded'\n response: unknown\n metadata: PublicBenchmarkResponseMetadata\n receipt: CostReceiptInput\n entrySha256: string\n })\n | (CacheIdentity & {\n kind: 'agent-eval/public-benchmark-model-response'\n callId: string\n status: 'failed'\n error: AnalystBenchmarkError\n receipt: CostReceiptInput\n entrySha256: string\n })\n\nexport type PublicBenchmarkResponseCacheInput =\n | Omit<Extract<PublicBenchmarkResponseCacheEntry, { status: 'succeeded' }>, 'entrySha256'>\n | Omit<Extract<PublicBenchmarkResponseCacheEntry, { status: 'failed' }>, 'entrySha256'>\n\nexport function publicBenchmarkCallId(identity: CacheIdentity): string {\n assertCacheIdentity(identity)\n const boundIdentity: CacheIdentity = {\n runIdentitySha256: identity.runIdentitySha256,\n caseId: identity.caseId,\n repetition: identity.repetition,\n }\n return `analyst-benchmark-${hashCanonical(boundIdentity).slice('sha256:'.length)}`\n}\n\nexport function readPublicBenchmarkResponseCache(\n cacheDirectory: string,\n identity: CacheIdentity,\n): PublicBenchmarkResponseCacheEntry | undefined {\n const callId = publicBenchmarkCallId(identity)\n const path = responseCachePath(cacheDirectory, callId)\n if (!existsSync(path)) return undefined\n const metadata = lstatSync(path)\n if (!metadata.isFile() || metadata.isSymbolicLink()) {\n throw new ValidationError(`benchmark response cache must be a real file: ${path}`)\n }\n let parsed: unknown\n try {\n parsed = JSON.parse(readFileSync(path, 'utf8'))\n } catch (error) {\n throw new ValidationError(`benchmark response cache contains invalid JSON: ${path}`, {\n cause: error,\n })\n }\n const entry = parseCacheEntry(parsed, path)\n if (\n entry.callId !== callId ||\n entry.runIdentitySha256 !== identity.runIdentitySha256 ||\n entry.caseId !== identity.caseId ||\n entry.repetition !== identity.repetition\n ) {\n throw new ValidationError(`benchmark response cache identity does not match: ${path}`)\n }\n return entry\n}\n\nexport function writePublicBenchmarkResponseCache(\n cacheDirectory: string,\n entry: PublicBenchmarkResponseCacheInput,\n): PublicBenchmarkResponseCacheEntry {\n const expectedCallId = publicBenchmarkCallId(entry)\n if (entry.callId !== expectedCallId) {\n throw new ValidationError('benchmark response cache callId does not match its identity')\n }\n const validated = JSON.parse(\n JSON.stringify(CacheEntryWithoutDigestSchema.parse(entry)),\n ) as z.infer<typeof CacheEntryWithoutDigestSchema>\n const complete = {\n ...validated,\n entrySha256: hashCanonical(validated).slice('sha256:'.length),\n } as PublicBenchmarkResponseCacheEntry\n const path = responseCachePath(cacheDirectory, complete.callId)\n const content = `${canonicalString(complete)}\\n`\n withLedgerFileLock(path, fileContext(), () => {\n if (existsSync(path)) {\n const existing = readPublicBenchmarkResponseCache(cacheDirectory, complete)\n if (!existing || canonicalString(existing) !== canonicalString(complete)) {\n throw new ValidationError(`benchmark response cache conflicts with existing file: ${path}`)\n }\n return\n }\n writeLedgerFileAtomically(path, content, fileContext())\n })\n return complete\n}\n\nfunction parseCacheEntry(value: unknown, path: string): PublicBenchmarkResponseCacheEntry {\n let parsed: z.infer<typeof CacheEntrySchema>\n try {\n parsed = CacheEntrySchema.parse(value)\n } catch (error) {\n throw new ValidationError(`benchmark response cache has an invalid shape: ${path}`, {\n cause: error,\n })\n }\n const { entrySha256, ...withoutDigest } = parsed\n const expected = hashCanonical(withoutDigest).slice('sha256:'.length)\n if (entrySha256 !== expected) {\n throw new ValidationError(`benchmark response cache digest does not match: ${path}`)\n }\n return parsed as PublicBenchmarkResponseCacheEntry\n}\n\nfunction responseCachePath(cacheDirectory: string, callId: string): string {\n const directory = nodePath.resolve(cacheDirectory)\n const path = nodePath.resolve(directory, `${hashCanonical(callId).slice('sha256:'.length)}.json`)\n if (!isPathInsideDirectory(directory, path, nodePath)) {\n throw new ValidationError('benchmark response cache path escapes its directory')\n }\n return path\n}\n\ninterface PathOperations {\n relative(from: string, to: string): string\n isAbsolute(path: string): boolean\n sep: string\n}\n\nexport function isPathInsideDirectory(\n directory: string,\n candidate: string,\n pathOperations: PathOperations = nodePath,\n): boolean {\n const relative = pathOperations.relative(directory, candidate)\n return (\n relative !== '' &&\n relative !== '..' &&\n !relative.startsWith(`..${pathOperations.sep}`) &&\n !pathOperations.isAbsolute(relative)\n )\n}\n\nfunction assertCacheIdentity(identity: CacheIdentity): void {\n if (!SHA256.test(identity.runIdentitySha256)) {\n throw new ValidationError('benchmark response cache requires a SHA-256 run identity')\n }\n if (!identity.caseId.trim()) {\n throw new ValidationError('benchmark response cache requires a case id')\n }\n if (!Number.isSafeInteger(identity.repetition) || identity.repetition < 0) {\n throw new ValidationError('benchmark response cache repetition must be non-negative')\n }\n}\n\nfunction fileContext() {\n return {\n subject: 'benchmark response cache',\n integrityError: (message: string, options?: { cause?: unknown }) =>\n new ValidationError(message, options),\n }\n}\n","import { z } from 'zod'\nimport {\n CostAccountingIncompleteError,\n CostCallConflictError,\n CostCeilingReachedError,\n CostLedger,\n type CostLedgerHandle,\n CostLedgerPersistenceError,\n type CostReceipt,\n CostReceiptCaptureError,\n type CostReceiptInput,\n CostReservationExceededError,\n} from '../cost-ledger'\nimport { ValidationError } from '../errors'\nimport {\n callLlmJson,\n costReceiptFromLlm,\n costReceiptFromLlmError,\n type LlmCallRequest,\n type LlmCallResult,\n type LlmClientOptions,\n maximumChargeForLlmRequest,\n} from '../llm-client'\nimport type { TraceAnalysisStore } from '../trace-analyst/store'\nimport type { AnalystBenchmarkRunner } from './benchmark'\nimport { agentRxPredictionsToFindings } from './benchmark-datasets'\nimport {\n resolveAssistantStepEvidence,\n validateCodeTraceFindingEvidence,\n} from './benchmark-evidence-validation'\nimport {\n type CodeTraceBlockDiagnostics,\n type CodeTraceFailureBlock,\n expandCodeTraceFailureBlocks,\n} from './benchmark-public-adapters'\nimport { publicBenchmarkError } from './benchmark-public-errors'\nimport {\n MAX_INCORRECT_BLOCK_STEPS,\n MAX_INCORRECT_BLOCKS,\n publicBenchmarkProtocolSha256,\n publicBenchmarkSystemPrompt,\n TRACE_PROJECTION_ATTRIBUTE_BYTE_CAPS,\n} from './benchmark-public-prompt'\nimport {\n type PublicAnalystBenchmarkDataset,\n type PublicAnalystBenchmarkModelConfig,\n positiveSafeInteger,\n requiredString,\n} from './benchmark-public-types'\nimport {\n type PublicBenchmarkResponseCacheEntry,\n publicBenchmarkCallId,\n readPublicBenchmarkResponseCache,\n writePublicBenchmarkResponseCache,\n} from './benchmark-response-cache'\nimport type { AnalystFinding, AnalystRunInputs } from './types'\nimport { usageReceiptFromCostLedger } from './usage-receipt'\n\nexport {\n CODE_TRACE_BENCH_ANALYST_PROMPT,\n publicBenchmarkProtocolSha256,\n} from './benchmark-public-prompt'\n\n/** One-shot JSON baseline. This is not a recursive trace analyst. */\nexport function createPublicBenchmarkDirectRunner(\n dataset: PublicAnalystBenchmarkDataset,\n config: PublicAnalystBenchmarkModelConfig,\n): AnalystBenchmarkRunner<AnalystRunInputs> {\n const model = requiredString(config.model, 'model')\n const baseUrl = requiredString(config.baseUrl, 'baseUrl')\n const apiKey = requiredString(config.apiKey, 'apiKey')\n const maxOutputTokens = positiveSafeInteger(config.maxOutputTokens, 'maxOutputTokens')\n const timeoutMs = positiveSafeInteger(config.timeoutMs, 'timeoutMs')\n const costLedger = config.costLedger ?? new CostLedger()\n const durability = config.durability\n ? {\n runIdentitySha256: requiredString(\n config.durability.runIdentitySha256,\n 'durability.runIdentitySha256',\n ),\n responseCacheDir: requiredString(\n config.durability.responseCacheDir,\n 'durability.responseCacheDir',\n ),\n }\n : undefined\n const actor =\n dataset === 'agentrx' ? 'agentrx-root-cause-localizer' : 'codetracebench-step-localizer'\n const outputAdapter =\n dataset === 'agentrx' ? 'agentrx-taxonomy-and-root-step' : 'codetracebench-incorrect-block'\n const llmOptions: LlmClientOptions = {\n baseUrl,\n apiKey,\n maximumAttempts: 1,\n jsonSchemaTransport: 'json-object',\n jsonPayloadMode: 'exact',\n thinking: 'disabled',\n ...(config.fetchImpl ? { fetch: config.fetchImpl } : {}),\n }\n\n return {\n id: 'direct',\n async analyze(input, context) {\n const trajectoryId = trajectoryIdFromCaseId(dataset, context.caseId)\n const costTags = {\n analystId: actor,\n benchmarkCaseId: context.caseId,\n benchmarkRepetition: String(context.repetition),\n }\n let rawPredictions: PublicBenchmarkModelPrediction[] = []\n let rejectedBlocks: string[] = []\n let modelFindings: AnalystFinding[] = []\n let providerModel = model\n let producedAt: string | undefined\n let modelMetadata: Record<string, unknown> = {\n analysisMode: 'direct-baseline',\n outputAdapter,\n protocolSha256: publicBenchmarkProtocolSha256(dataset),\n }\n try {\n if (!input.traceStore) {\n throw new Error(`${dataset} model runner requires a trace store`)\n }\n const preparedContext = await prepareSingleTraceContext(input.traceStore, context)\n if (preparedContext === undefined) {\n throw new Error(`${dataset} trace '${trajectoryId}' has no readable spans`)\n }\n const request: LlmCallRequest = {\n model,\n messages: [\n {\n role: 'system',\n content: publicBenchmarkSystemPrompt(dataset),\n },\n {\n role: 'user',\n content: `TRACE DATA:\\n${preparedContext}\\n\\nReturn the analysis JSON object.`,\n },\n ],\n jsonMode: true,\n thinking: 'disabled',\n maxTokens: maxOutputTokens,\n timeoutMs,\n }\n const cacheIdentity = durability\n ? {\n runIdentitySha256: durability.runIdentitySha256,\n caseId: context.caseId,\n repetition: context.repetition,\n }\n : undefined\n const callId = cacheIdentity ? publicBenchmarkCallId(cacheIdentity) : undefined\n const cached = cacheIdentity\n ? readPublicBenchmarkResponseCache(durability!.responseCacheDir, cacheIdentity)\n : undefined\n if (cached) {\n const receipt = settleCachedResponse(costLedger, cached)\n modelMetadata = {\n ...modelMetadata,\n responseSource: 'durable-cache',\n cost: costReceiptMetadata(receipt),\n }\n if (cached.status === 'failed') {\n return {\n findings: [],\n usage: usageReceiptFromCostLedger(costLedger, {\n channel: 'analyst',\n tags: costTags,\n }),\n error: cached.error,\n metadata: modelMetadata,\n }\n }\n const response = parsePublicBenchmarkModelResponse(dataset, cached.response)\n rawPredictions = response.findings\n rejectedBlocks = response.rejectedBlocks\n providerModel = cached.metadata.providerModel\n producedAt = cached.metadata.producedAt\n modelMetadata = {\n ...modelMetadata,\n report: response.report,\n providerModel: cached.metadata.providerModel,\n providerDurationMs: cached.metadata.providerDurationMs,\n finishReason: cached.metadata.finishReason,\n }\n } else {\n assertNoSettledResponseWithoutCache(costLedger, callId)\n let completedResult: LlmCallResult | undefined\n const paid = await costLedger.runPaidCall({\n ...(callId ? { callId } : {}),\n channel: 'analyst',\n phase: 'analyst.public-benchmark',\n actor,\n model,\n signal: context.signal,\n maximumCharge: maximumChargeForLlmRequest(request, llmOptions),\n tags: costTags,\n execute: async (signal, providerCallId) => {\n try {\n const completed = await callLlmJson<unknown>(request, {\n ...llmOptions,\n signal,\n idempotencyKey: providerCallId,\n })\n completedResult = completed.result\n const response = parsePublicBenchmarkModelResponse(dataset, completed.value)\n const responseProducedAt = new Date().toISOString()\n if (cacheIdentity) {\n writePublicBenchmarkResponseCache(durability!.responseCacheDir, {\n kind: 'agent-eval/public-benchmark-model-response',\n ...cacheIdentity,\n callId: providerCallId,\n status: 'succeeded',\n // Cache the provider's own payload, not the parse result: a\n // resume re-parses this value, so it must stay exactly what\n // the contract accepts.\n response: completed.value,\n metadata: {\n providerModel: completed.result.model,\n providerDurationMs: completed.result.durationMs,\n finishReason: completed.result.finishReason ?? null,\n producedAt: responseProducedAt,\n },\n receipt: costReceiptFromLlm(completed.result),\n })\n }\n return { ...completed, response, producedAt: responseProducedAt }\n } catch (error) {\n if (cacheIdentity) {\n writePublicBenchmarkResponseCache(durability!.responseCacheDir, {\n kind: 'agent-eval/public-benchmark-model-response',\n ...cacheIdentity,\n callId: providerCallId,\n status: 'failed',\n error: publicBenchmarkError(error, [apiKey]),\n receipt: receiptForProviderFailure(error, completedResult, model),\n })\n }\n throw error\n }\n },\n receipt: ({ result }) => costReceiptFromLlm(result),\n receiptFromError: (error) => receiptForProviderFailure(error, completedResult, model),\n })\n if (!paid.succeeded) throw paid.error\n const response = paid.value.response\n rawPredictions = response.findings\n rejectedBlocks = response.rejectedBlocks\n providerModel = paid.value.result.model\n producedAt = paid.value.producedAt\n modelMetadata = {\n ...modelMetadata,\n responseSource: 'provider',\n report: response.report,\n providerModel: paid.value.result.model,\n providerDurationMs: paid.value.result.durationMs,\n finishReason: paid.value.result.finishReason ?? null,\n cost: costReceiptMetadata(paid.receipt),\n }\n }\n\n const converted = await publicBenchmarkPredictionsToFindings({\n dataset,\n trajectoryId,\n predictions: rawPredictions,\n store: input.traceStore,\n analystId: 'direct',\n providerModel,\n producedAt: requiredString(producedAt ?? '', 'finding producedAt'),\n ...(context.signal ? { signal: context.signal } : {}),\n })\n modelFindings = converted.findings\n if (converted.diagnostics) {\n modelMetadata = {\n ...modelMetadata,\n blockDiagnostics: { ...converted.diagnostics, rejectedBlocks },\n }\n }\n if (dataset === 'codetracebench') {\n await validateCodeTraceFindingEvidence({\n trajectoryId,\n findings: modelFindings,\n store: input.traceStore,\n ...(context.signal ? { signal: context.signal } : {}),\n })\n }\n return {\n findings: modelFindings,\n usage: usageReceiptFromCostLedger(costLedger, {\n channel: 'analyst',\n tags: costTags,\n }),\n metadata: modelMetadata,\n }\n } catch (error) {\n if (context.signal?.aborted) throw error\n if (isPaidCallControlError(error)) throw error\n return {\n findings: [],\n usage: usageReceiptFromCostLedger(costLedger, {\n channel: 'analyst',\n tags: costTags,\n }),\n error: publicBenchmarkError(error, [apiKey]),\n metadata: {\n ...modelMetadata,\n rawPredictions,\n acceptedFindings: modelFindings,\n },\n }\n }\n },\n }\n}\n\nfunction settleCachedResponse(\n costLedger: CostLedgerHandle,\n cached: PublicBenchmarkResponseCacheEntry,\n): CostReceipt {\n const settled = costLedger.list().find((receipt) => receipt.callId === cached.callId)\n const pending = costLedger.listPending?.().find((record) => record.callId === cached.callId)\n if (settled && pending) {\n throw new CostCallConflictError(\n `benchmark response '${cached.callId}' is both pending and settled`,\n { callId: cached.callId },\n )\n }\n const receipt = pending\n ? costLedger.reconcile(cached.callId, cached.receipt, {\n ...(cached.status === 'failed' ? { failed: true } : {}),\n })\n : settled\n if (!receipt) {\n throw new CostCallConflictError(\n `benchmark response cache '${cached.callId}' has no matching cost record`,\n { callId: cached.callId },\n )\n }\n assertCacheReceiptMatches(cached, receipt)\n return receipt\n}\n\nfunction assertNoSettledResponseWithoutCache(\n costLedger: CostLedgerHandle,\n callId: string | undefined,\n): void {\n if (!callId) return\n if (costLedger.list().some((receipt) => receipt.callId === callId)) {\n throw new CostCallConflictError(\n `settled benchmark call '${callId}' has no durable response cache`,\n { callId },\n )\n }\n}\n\nfunction assertCacheReceiptMatches(\n cached: PublicBenchmarkResponseCacheEntry,\n receipt: CostReceipt,\n): void {\n const expected = cached.receipt\n const mismatch =\n receipt.callId !== cached.callId ||\n receipt.model !== expected.model ||\n receipt.inputTokens !== expected.inputTokens ||\n receipt.outputTokens !== expected.outputTokens ||\n (receipt.reasoningTokens ?? 0) !== (expected.reasoningTokens ?? 0) ||\n (receipt.cachedTokens ?? 0) !== (expected.cachedTokens ?? 0) ||\n (receipt.cacheWriteTokens ?? 0) !== (expected.cacheWriteTokens ?? 0) ||\n (expected.actualCostUsd !== undefined && receipt.actualCostUsd !== expected.actualCostUsd) ||\n (expected.estimatedCostUsd !== undefined &&\n receipt.estimatedCostUsd !== expected.estimatedCostUsd) ||\n (expected.costUnknown === true && !receipt.costUnknown) ||\n (expected.usageUnknown === true && !receipt.usageUnknown) ||\n (cached.status === 'succeeded' && receipt.error !== undefined) ||\n (cached.status === 'failed' && receipt.error === undefined)\n if (mismatch) {\n throw new CostCallConflictError(\n `benchmark response cache receipt does not match cost record '${cached.callId}'`,\n { callId: cached.callId, receipt },\n )\n }\n}\n\nfunction isPaidCallControlError(error: unknown): boolean {\n return (\n error instanceof CostAccountingIncompleteError ||\n error instanceof CostCallConflictError ||\n error instanceof CostCeilingReachedError ||\n error instanceof CostLedgerPersistenceError ||\n error instanceof CostReceiptCaptureError ||\n error instanceof CostReservationExceededError\n )\n}\n\nfunction receiptForProviderFailure(\n error: unknown,\n completedResult: LlmCallResult | undefined,\n model: string,\n): CostReceiptInput {\n if (completedResult) return costReceiptFromLlm(completedResult)\n if (error instanceof Error) {\n const captured = costReceiptFromLlmError(error)\n if (captured) return captured\n }\n return {\n model,\n inputTokens: 0,\n outputTokens: 0,\n costUnknown: true,\n usageUnknown: true,\n }\n}\n\nfunction costReceiptMetadata(receipt: CostReceipt): Record<string, unknown> {\n if (receipt.actualCostUsd !== undefined) {\n return { source: 'provider', actualCostUsd: receipt.actualCostUsd }\n }\n if (receipt.estimatedCostUsd !== undefined) {\n return { source: 'external-estimate', estimatedCostUsd: receipt.estimatedCostUsd }\n }\n if (receipt.pricing) {\n return {\n source: 'agent-eval-model-pricing',\n estimatedCostUsd: receipt.costUsd,\n ratesPerThousandTokens: receipt.pricing,\n }\n }\n return {\n source: 'unknown',\n estimatedCostUsd: null,\n }\n}\n\nconst ModelSeveritySchema = z.enum(['critical', 'high', 'medium', 'low', 'info'])\nconst AgentRxPredictionSchema = z\n .object({\n step: z.number().int().positive(),\n severity: ModelSeveritySchema,\n claim: z.string().min(1),\n confidence: z.number().min(0).max(1),\n rationale: z.string().min(1).optional(),\n recommended_action: z.string().min(1).optional(),\n })\n .strict()\nconst CodeTraceBlockPredictionSchema = z\n .object({\n first_step: z.number().int().positive(),\n last_step: z.number().int().positive(),\n consequence_step: z.number().int().positive(),\n escape_status: z.enum(['escaped', 'unescaped']),\n severity: ModelSeveritySchema,\n claim: z.string().min(1),\n confidence: z.number().min(0).max(1),\n rationale: z.string().min(1).optional(),\n recommended_action: z.string().min(1).optional(),\n })\n .strict()\n .superRefine((block, ctx) => {\n if (block.last_step < block.first_step) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `failure block last_step ${block.last_step} precedes first_step ${block.first_step}`,\n })\n return\n }\n const length = block.last_step - block.first_step + 1\n if (length > MAX_INCORRECT_BLOCK_STEPS) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `failure block spans ${length} steps; the maximum is ${MAX_INCORRECT_BLOCK_STEPS}`,\n })\n }\n // The damage a block caused can surface anywhere from the block's own first\n // step onward: a step carries both the assistant action and the observation\n // it produced, and a long block often shows its damage mid-block rather than\n // at the end. Only a consequence before the block began is incoherent.\n if (block.consequence_step < block.first_step) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: `failure block consequence_step ${block.consequence_step} precedes first_step ${block.first_step}`,\n })\n }\n })\nconst AgentRxCategorySchema = z.enum([\n 'instruction-plan-adherence-failure',\n 'invention-of-new-information',\n 'invalid-invocation',\n 'misinterpretation-of-tool-output-handoff-failure',\n 'intent-plan-misalignment',\n 'underspecified-user-intent',\n 'intent-not-supported',\n 'guardrails-triggered',\n 'system-failure',\n 'inconclusive',\n])\nconst CodeTraceModelResponseEnvelopeSchema = z\n .object({\n report: z.string().min(1).max(4_000),\n findings: z.array(z.unknown()).max(MAX_INCORRECT_BLOCKS),\n })\n .strict()\nconst AgentRxModelResponseSchema = z\n .object({\n report: z.string().min(1).max(4_000),\n findings: z\n .array(AgentRxPredictionSchema.extend({ category: AgentRxCategorySchema }).strict())\n .max(1),\n })\n .strict()\n\ntype AgentRxModelPrediction = z.infer<typeof AgentRxPredictionSchema> & {\n category?: z.infer<typeof AgentRxCategorySchema>\n}\ntype CodeTraceModelPrediction = z.infer<typeof CodeTraceBlockPredictionSchema>\ntype PublicBenchmarkModelPrediction = AgentRxModelPrediction | CodeTraceModelPrediction\n\nfunction parsePublicBenchmarkModelResponse(\n dataset: PublicAnalystBenchmarkDataset,\n value: unknown,\n): { report: string; findings: PublicBenchmarkModelPrediction[]; rejectedBlocks: string[] } {\n if (dataset === 'agentrx') {\n return { ...AgentRxModelResponseSchema.parse(value), rejectedBlocks: [] }\n }\n // The envelope is the contract and stays strict. Individual blocks are model\n // output: one malformed block must not void a case whose remaining blocks are\n // usable and whose provider call is already paid for. Every rejection is\n // reported so a run cannot silently lose predictions.\n const envelope = CodeTraceModelResponseEnvelopeSchema.parse(value)\n const findings: CodeTraceModelPrediction[] = []\n const rejectedBlocks: string[] = []\n for (const [index, block] of envelope.findings.entries()) {\n const parsed = CodeTraceBlockPredictionSchema.safeParse(block)\n if (parsed.success) {\n findings.push(parsed.data)\n continue\n }\n rejectedBlocks.push(\n `block ${index}: ${parsed.error.issues\n .map((issue) => `${issue.path.join('.') || '<root>'} ${issue.message}`)\n .join('; ')}`,\n )\n }\n if (findings.length === 0 && envelope.findings.length > 0) {\n throw new ValidationError(\n `every reported failure block was malformed: ${rejectedBlocks.join(' | ')}`,\n )\n }\n return { report: envelope.report, findings, rejectedBlocks }\n}\n\nasync function publicBenchmarkPredictionsToFindings(options: {\n dataset: PublicAnalystBenchmarkDataset\n trajectoryId: string\n predictions: readonly PublicBenchmarkModelPrediction[]\n store: TraceAnalysisStore\n analystId: string\n providerModel: string\n producedAt: string\n signal?: AbortSignal\n}): Promise<{ findings: AnalystFinding[]; diagnostics: CodeTraceBlockDiagnostics | undefined }> {\n if (options.predictions.length === 0 && options.dataset === 'agentrx') {\n return { findings: [], diagnostics: undefined }\n }\n if (options.dataset === 'agentrx') {\n const prediction = options.predictions[0]!\n if (!('step' in prediction)) {\n throw new Error('AgentRx model output must name a single root-cause step')\n }\n if (!prediction.category) {\n throw new Error('AgentRx model output is missing its failure category')\n }\n const evidenceByStep = await resolveAssistantStepEvidence({\n trajectoryId: options.trajectoryId,\n steps: [prediction.step],\n store: options.store,\n ...(options.signal ? { signal: options.signal } : {}),\n })\n const [finding] = agentRxPredictionsToFindings(\n options.trajectoryId,\n [\n {\n failure_case: prediction.category,\n step_number: prediction.step,\n description: prediction.rationale ?? prediction.claim,\n },\n ],\n {\n analystId: options.analystId,\n producedAt: options.producedAt,\n confidence: prediction.confidence,\n },\n )\n if (!finding) throw new Error('AgentRx output adapter produced no root-cause finding')\n return {\n findings: [\n {\n ...finding,\n evidence_refs: [evidenceByStep.get(prediction.step)!],\n metadata: {\n ...finding.metadata,\n model: options.providerModel,\n },\n },\n ],\n diagnostics: undefined,\n }\n }\n\n const blocks = options.predictions.map((prediction): CodeTraceFailureBlock => {\n if (!('first_step' in prediction)) {\n throw new Error('CodeTraceBench model output must report first_step/last_step failure blocks')\n }\n return {\n firstStep: prediction.first_step,\n lastStep: prediction.last_step,\n consequenceStep: prediction.consequence_step,\n escapeStatus: prediction.escape_status,\n severity: prediction.severity,\n claim: prediction.claim,\n confidence: prediction.confidence,\n ...(prediction.rationale === undefined ? {} : { rationale: prediction.rationale }),\n ...(prediction.recommended_action === undefined\n ? {}\n : { recommendedAction: prediction.recommended_action }),\n metadata: { analysis_mode: 'direct-baseline', model: options.providerModel },\n }\n })\n return expandCodeTraceFailureBlocks({\n trajectoryId: options.trajectoryId,\n blocks,\n store: options.store,\n analystId: options.analystId,\n producedAt: options.producedAt,\n ...(options.signal ? { signal: options.signal } : {}),\n })\n}\n\nasync function prepareSingleTraceContext(\n store: TraceAnalysisStore,\n context: { signal?: AbortSignal },\n): Promise<string | undefined> {\n const storeContext = context.signal ? { signal: context.signal } : undefined\n const overview = await store.getOverview(undefined, storeContext)\n if (overview.total_traces !== 1 || overview.sample_trace_ids.length !== 1) {\n throw new Error(\n `public model benchmark requires exactly one trace, received ${overview.total_traces}`,\n )\n }\n const traceId = overview.sample_trace_ids[0]!\n for (const perAttributeByteCap of TRACE_PROJECTION_ATTRIBUTE_BYTE_CAPS) {\n const viewed = await store.viewTrace(\n {\n trace_id: traceId,\n per_attribute_byte_cap: perAttributeByteCap,\n },\n storeContext,\n )\n if (!viewed.spans) continue\n return JSON.stringify({\n trace_id: traceId,\n per_attribute_byte_cap: perAttributeByteCap,\n spans: viewed.spans,\n })\n }\n return undefined\n}\n\nfunction trajectoryIdFromCaseId(dataset: PublicAnalystBenchmarkDataset, caseId: string): string {\n const prefix = dataset === 'agentrx' ? 'agentrx:' : 'codetrace:'\n if (!caseId.startsWith(prefix) || caseId.length === prefix.length) {\n throw new Error(`unexpected ${dataset} benchmark case id '${caseId}'`)\n }\n return caseId.slice(prefix.length)\n}\n","import {\n CostAccountingIncompleteError,\n CostCallConflictError,\n CostCeilingReachedError,\n CostLedger,\n CostLedgerPersistenceError,\n CostReceiptCaptureError,\n CostReservationExceededError,\n type CustomTokenPricing,\n} from '../cost-ledger'\nimport { resolveModelPricing } from '../metrics'\nimport type { AnalystBenchmarkRunner } from './benchmark'\nimport { adaptPublicBenchmarkFindings } from './benchmark-public-adapters'\nimport { publicBenchmarkError } from './benchmark-public-errors'\nimport {\n publicBenchmarkProtocolSha256,\n publicBenchmarkRlmInstructions,\n} from './benchmark-public-prompt'\nimport type {\n PublicAnalystBenchmarkDataset,\n PublicAnalystBenchmarkModelConfig,\n} from './benchmark-public-types'\nimport { createDspyRlmTraceEngine, type DspyRlmTraceEngineOptions } from './dspy-rlm-engine'\nimport { evidenceRefsFromRawFinding } from './finding-signature'\nimport { runTraceAnalyst, type TraceAnalystDefinition } from './kind-factory'\nimport type { AnalystFinding, AnalystRunInputs, AnalystUsageReceipt } from './types'\nimport { makeFinding } from './types'\n\n/** Public benchmark candidate that runs the actual recursive trace analyst. */\nexport function createPublicBenchmarkRlmRunner(\n dataset: PublicAnalystBenchmarkDataset,\n config: PublicAnalystBenchmarkModelConfig,\n): AnalystBenchmarkRunner<AnalystRunInputs> {\n const costLedger = config.costLedger ?? new CostLedger()\n const limits = {\n maxIterations: config.dspyRlm?.maxIterations ?? 8,\n maxLlmCalls: config.dspyRlm?.maxLlmCalls ?? 4,\n maxToolCalls: config.dspyRlm?.maxToolCalls ?? 32,\n maxOutputChars: config.dspyRlm?.maxOutputChars ?? 8_000,\n }\n const pricing = config.pricing ?? pricingForModel(config.model)\n const engine = createDspyRlmTraceEngine({\n baseUrl: config.baseUrl,\n apiKey: config.apiKey,\n model: config.model,\n maxOutputTokens: config.maxOutputTokens,\n timeoutMs: config.timeoutMs,\n maxCostUsd: config.maxCostUsdPerAnalysis ?? 1,\n pricing,\n ...(config.dspyRlm?.runner ? { runner: config.dspyRlm.runner } : {}),\n } satisfies DspyRlmTraceEngineOptions)\n const definition = publicBenchmarkDefinition(dataset, limits)\n\n return {\n id: 'dspy-rlm',\n async analyze(input, context) {\n const trajectoryId = trajectoryIdFromCaseId(dataset, context.caseId)\n const tags = {\n benchmarkCaseId: context.caseId,\n benchmarkRepetition: String(context.repetition),\n }\n let usage: AnalystUsageReceipt | undefined\n let rawFindings: AnalystFinding[] = []\n try {\n if (!input.traceStore) {\n throw new Error(`${dataset} DSPy RLM runner requires a trace store`)\n }\n const completed = await runTraceAnalyst({\n definition,\n engine,\n store: input.traceStore,\n context: {\n runId: context.caseId,\n correlationId: `${context.caseId}:${context.repetition}`,\n costLedger,\n costPhase: 'analyst.public-benchmark.dspy-rlm',\n tags,\n recordUsage: (receipt) => {\n usage = receipt\n },\n signal: context.signal,\n },\n })\n const producedAt = new Date().toISOString()\n rawFindings = completed.findings.map((finding) =>\n makeFinding({\n analyst_id: 'dspy-rlm',\n area: dataset === 'agentrx' ? 'root-cause' : 'incorrect',\n subject: finding.subject,\n claim: finding.claim,\n rationale: finding.rationale,\n severity: finding.severity,\n confidence: finding.confidence,\n evidence_refs: evidenceRefsFromRawFinding(finding),\n recommended_action: finding.recommended_action,\n metadata: {\n analysis_mode: 'recursive',\n engine: 'dspy-rlm',\n model: config.model,\n },\n produced_at: producedAt,\n }),\n )\n const adapted = await adaptPublicBenchmarkFindings({\n dataset,\n trajectoryId,\n findings: rawFindings,\n analystId: 'dspy-rlm',\n store: input.traceStore,\n ...(context.signal ? { signal: context.signal } : {}),\n })\n return {\n findings: adapted.findings,\n usage,\n metadata: {\n analysisMode: 'recursive',\n engine: 'dspy-rlm',\n protocolSha256: publicBenchmarkProtocolSha256(dataset),\n ...(adapted.diagnostics ? { blockDiagnostics: adapted.diagnostics } : {}),\n answer: completed.answer,\n trajectory: completed.trajectory,\n modelCalls: completed.modelCalls,\n toolCalls: completed.toolCalls,\n runtime: completed.runtime,\n },\n }\n } catch (error) {\n if (context.signal?.aborted) throw error\n if (isPaidCallControlError(error)) throw error\n return {\n findings: [],\n usage,\n error: publicBenchmarkError(error, [config.apiKey]),\n metadata: {\n analysisMode: 'recursive',\n engine: 'dspy-rlm',\n rawFindings,\n },\n }\n }\n },\n }\n}\n\nfunction publicBenchmarkDefinition(\n dataset: PublicAnalystBenchmarkDataset,\n limits: {\n maxIterations: number\n maxLlmCalls: number\n maxToolCalls: number\n maxOutputChars: number\n },\n): TraceAnalystDefinition {\n return {\n id: dataset === 'agentrx' ? 'agentrx-dspy-rlm' : 'codetracebench-dspy-rlm',\n description:\n dataset === 'agentrx'\n ? 'Localizes the first unrecoverable root-cause step.'\n : 'Localizes every incorrect state-changing assistant step.',\n area: dataset === 'agentrx' ? 'root-cause' : 'incorrect',\n version: '1.0.0',\n question:\n dataset === 'agentrx'\n ? 'What is the first unrecoverable root cause in this failed trajectory?'\n : 'Which assistant steps are incorrect under the CodeTraceBench definition?',\n instructions: publicBenchmarkRlmInstructions(dataset),\n toolGroup: 'singleTrace',\n limits,\n }\n}\n\nfunction pricingForModel(model: string): CustomTokenPricing {\n const pricing = resolveModelPricing(model)\n if (!pricing) {\n throw new Error(\n `no pricing is configured for '${model}'; provide PublicAnalystBenchmarkModelConfig.pricing`,\n )\n }\n return {\n inputUsdPerMillion: pricing.input * 1_000,\n outputUsdPerMillion: pricing.output * 1_000,\n }\n}\n\nfunction trajectoryIdFromCaseId(dataset: PublicAnalystBenchmarkDataset, caseId: string): string {\n const prefix = dataset === 'agentrx' ? 'agentrx:' : 'codetrace:'\n if (!caseId.startsWith(prefix) || caseId.length === prefix.length) {\n throw new Error(`unexpected ${dataset} benchmark case id '${caseId}'`)\n }\n return caseId.slice(prefix.length)\n}\n\nfunction isPaidCallControlError(error: unknown): boolean {\n return (\n error instanceof CostAccountingIncompleteError ||\n error instanceof CostCallConflictError ||\n error instanceof CostCeilingReachedError ||\n error instanceof CostLedgerPersistenceError ||\n error instanceof CostReceiptCaptureError ||\n error instanceof CostReservationExceededError\n )\n}\n","import { randomUUID } from 'node:crypto'\nimport { constants } from 'node:fs'\nimport { link, lstat, mkdir, open, readFile, unlink } from 'node:fs/promises'\nimport { arch, platform } from 'node:os'\nimport { dirname, resolve } from 'node:path'\nimport type { AnalystBenchmarkObservation } from './benchmark'\nimport {\n ANALYST_BENCHMARK_COST_LEDGER_FILE,\n ANALYST_BENCHMARK_LOCAL_RECEIPT_FILE,\n ANALYST_BENCHMARK_MANIFEST_FILE,\n ANALYST_BENCHMARK_OBSERVATIONS_FILE,\n type AnalystBenchmarkLocalRunReceipt,\n type AnalystBenchmarkProgressRow,\n type AnalystBenchmarkRunIdentity,\n type AnalystBenchmarkRunManifest,\n assertAnalystBenchmarkObservation,\n assertExactKeys,\n canonicalJson,\n digestCanonical,\n isRecord,\n isSha256,\n observationKey,\n parseJson,\n} from './benchmark-command-artifact'\nimport {\n ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256,\n ANALYST_BENCHMARK_IMPLEMENTATION_SHA256,\n} from './benchmark-implementation'\nimport {\n type PreparedPublicAnalystBenchmark,\n type PublicAnalystBenchmarkDataset,\n publicBenchmarkProtocolSha256,\n} from './benchmark-real-model'\n\nexport interface AnalystBenchmarkOutputPaths {\n directory: string\n initializationComplete: string\n manifest: string\n observations: string\n costLedger: string\n modelResponses: string\n localReceipt: string\n result: string\n report: string\n}\n\nexport const ANALYST_BENCHMARK_INITIALIZATION_COMPLETE_FILE = 'initialization-complete.json'\n\nexport interface AnalystBenchmarkProgress {\n observations: AnalystBenchmarkObservation[]\n nextSequence: number\n previousRowSha256: string | null\n}\n\ninterface AnalystBenchmarkPersistenceConfig {\n dataset: PublicAnalystBenchmarkDataset\n analyst: string\n labelsPath: string\n traceDir: string\n artifactDir?: string\n revision: string\n split: string\n model: {\n baseUrl: string\n model: string\n maxOutputTokens: number\n timeoutMs: number\n }\n limit: number\n seed: number\n concurrency: number\n repetitions: number\n maxCostUsd: number\n maxArtifactBytes: number\n apiKeyEnv: string\n command: string\n}\n\nexport async function openOutputDirectory(\n outDir: string,\n resume: boolean,\n): Promise<AnalystBenchmarkOutputPaths> {\n const directory = resolve(outDir)\n if (resume) {\n let outputStat: Awaited<ReturnType<typeof lstat>>\n try {\n outputStat = await lstat(directory)\n } catch (error) {\n if (isNodeError(error, 'ENOENT')) {\n throw new Error(`cannot resume missing benchmark output directory: ${directory}`)\n }\n throw error\n }\n if (!outputStat.isDirectory() || outputStat.isSymbolicLink()) {\n throw new Error(`benchmark output must be a real directory: ${directory}`)\n }\n } else {\n await mkdir(dirname(directory), { recursive: true })\n try {\n await mkdir(directory)\n } catch (error) {\n if (isNodeError(error, 'EEXIST')) {\n throw new Error(`refusing to use existing benchmark output directory: ${directory}`)\n }\n throw error\n }\n await syncDirectory(dirname(directory))\n }\n return {\n directory,\n initializationComplete: resolve(directory, ANALYST_BENCHMARK_INITIALIZATION_COMPLETE_FILE),\n manifest: resolve(directory, ANALYST_BENCHMARK_MANIFEST_FILE),\n observations: resolve(directory, ANALYST_BENCHMARK_OBSERVATIONS_FILE),\n costLedger: resolve(directory, ANALYST_BENCHMARK_COST_LEDGER_FILE),\n modelResponses: resolve(directory, 'model-responses'),\n localReceipt: resolve(directory, ANALYST_BENCHMARK_LOCAL_RECEIPT_FILE),\n result: resolve(directory, 'result.json'),\n report: resolve(directory, 'report.md'),\n }\n}\n\nexport async function prepareOutputLockPath(outDir: string): Promise<string> {\n const directory = resolve(outDir)\n await mkdir(dirname(directory), { recursive: true })\n return `${directory}.lock`\n}\n\nexport function createRunIdentity(\n config: AnalystBenchmarkPersistenceConfig,\n prepared: PreparedPublicAnalystBenchmark,\n): AnalystBenchmarkRunIdentity {\n const caseDefinitions = prepared.cases.map((testCase) => ({\n id: testCase.id,\n clusterId: testCase.clusterId,\n labelState: testCase.labelState,\n expectedIssues: testCase.expectedIssues,\n labeledEvidence: testCase.labeledEvidence ?? [],\n tags: testCase.tags ?? [],\n metadata: testCase.metadata ?? {},\n }))\n return {\n config: {\n dataset: config.dataset,\n datasetRevision: config.revision,\n datasetSplit: config.split,\n model: {\n id: config.model.model,\n maxOutputTokens: config.model.maxOutputTokens,\n timeoutMs: config.model.timeoutMs,\n },\n limit: config.limit,\n seed: config.seed,\n concurrency: config.concurrency,\n repetitions: config.repetitions,\n maxCostUsd: config.maxCostUsd,\n maxArtifactBytes: config.maxArtifactBytes,\n analystProtocolSha256: publicBenchmarkProtocolSha256(config.dataset),\n implementationSha256: ANALYST_BENCHMARK_IMPLEMENTATION_SHA256,\n dependencyLockSha256: ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256,\n runnerIds: ['empty', config.analyst] as const,\n },\n inputs: {\n labelsSha256: prepared.labelsSha256,\n sourceRowCount: prepared.sourceRowCount,\n selectedCaseIds: [...prepared.selectedCaseIds],\n traceFiles: prepared.traceFiles.map((traceFile) => ({ ...traceFile })),\n verificationArtifactsSha256: digestCanonical(prepared.verificationArtifacts),\n caseDefinitionsSha256: digestCanonical(caseDefinitions),\n },\n }\n}\n\nexport function createLocalRunReceipt(\n config: AnalystBenchmarkPersistenceConfig,\n paths: AnalystBenchmarkOutputPaths,\n): Omit<AnalystBenchmarkLocalRunReceipt, 'runIdentitySha256' | 'localIdentitySha256'> {\n return {\n kind: 'agent-eval/analyst-benchmark-local-run',\n local: {\n labelsPath: resolve(config.labelsPath),\n traceDir: resolve(config.traceDir),\n ...(config.artifactDir ? { artifactDir: resolve(config.artifactDir) } : {}),\n outputDir: paths.directory,\n baseUrl: config.model.baseUrl,\n apiKeyEnvironment: config.apiKeyEnv,\n },\n command: config.command,\n environment: {\n node: process.version,\n platform: platform(),\n arch: arch(),\n },\n files: {\n manifest: paths.manifest,\n observations: paths.observations,\n costLedger: paths.costLedger,\n modelResponses: paths.modelResponses,\n result: paths.result,\n report: paths.report,\n },\n }\n}\n\nexport async function initializeRunFiles(\n paths: AnalystBenchmarkOutputPaths,\n identity: AnalystBenchmarkRunIdentity,\n identitySha256: string,\n localIdentitySha256: string,\n localReceiptInput: Omit<\n AnalystBenchmarkLocalRunReceipt,\n 'runIdentitySha256' | 'localIdentitySha256'\n >,\n): Promise<AnalystBenchmarkRunManifest> {\n const existingManifest = await readOptionalRegularFile(paths.manifest, 'benchmark run manifest')\n const manifest = existingManifest\n ? await readAndValidateManifestContent(\n paths.manifest,\n existingManifest,\n identity,\n identitySha256,\n localIdentitySha256,\n )\n : {\n kind: 'agent-eval/analyst-benchmark-run' as const,\n createdAt: new Date().toISOString(),\n identitySha256,\n localIdentitySha256,\n identity,\n }\n const localReceipt: AnalystBenchmarkLocalRunReceipt = {\n ...localReceiptInput,\n runIdentitySha256: identitySha256,\n localIdentitySha256,\n }\n const manifestContent = `${JSON.stringify(manifest, null, 2)}\\n`\n const localReceiptContent = `${JSON.stringify(localReceipt, null, 2)}\\n`\n const initializationCompleteContent = renderInitializationComplete(manifest)\n\n await assertAbsentOrExact(paths.observations, '', 'benchmark observation log')\n await assertAbsentOrExact(paths.localReceipt, localReceiptContent, 'benchmark local run receipt')\n await assertAbsentOrExact(paths.manifest, manifestContent, 'benchmark run manifest')\n for (const path of [paths.costLedger, paths.modelResponses, paths.result, paths.report]) {\n if (await regularFileExists(path)) {\n throw new Error(\n `benchmark initialization marker is missing but later run artifact exists: ${path}`,\n )\n }\n }\n if (await regularFileExists(paths.initializationComplete)) {\n throw new Error(\n `benchmark initialization marker already exists during partial initialization: ${paths.initializationComplete}`,\n )\n }\n\n await writeExclusiveOrVerify(paths.observations, '')\n await writeExclusiveOrVerify(paths.localReceipt, localReceiptContent)\n await writeExclusiveOrVerify(paths.manifest, manifestContent)\n await writeExclusiveOrVerify(paths.initializationComplete, initializationCompleteContent)\n return manifest\n}\n\nexport async function readAndValidateResumeFiles(\n paths: AnalystBenchmarkOutputPaths,\n currentIdentity: AnalystBenchmarkRunIdentity,\n currentIdentitySha256: string,\n currentLocalIdentitySha256: string,\n localReceiptInput: Omit<\n AnalystBenchmarkLocalRunReceipt,\n 'runIdentitySha256' | 'localIdentitySha256'\n >,\n): Promise<AnalystBenchmarkRunManifest> {\n if (!(await regularFileExists(paths.initializationComplete))) {\n return initializeRunFiles(\n paths,\n currentIdentity,\n currentIdentitySha256,\n currentLocalIdentitySha256,\n localReceiptInput,\n )\n }\n const manifest = await readAndValidateManifest(\n paths.manifest,\n currentIdentity,\n currentIdentitySha256,\n currentLocalIdentitySha256,\n )\n const localReceiptContent = await readRegularFile(\n paths.localReceipt,\n 'benchmark local run receipt',\n )\n const value = parseJson(localReceiptContent, paths.localReceipt)\n if (!isRecord(value)) {\n throw new TypeError(`benchmark local run receipt must be an object: ${paths.localReceipt}`)\n }\n assertExactKeys(\n value,\n [\n 'kind',\n 'runIdentitySha256',\n 'localIdentitySha256',\n 'local',\n 'command',\n 'environment',\n 'files',\n ],\n 'benchmark local run receipt',\n )\n if (\n value.kind !== 'agent-eval/analyst-benchmark-local-run' ||\n value.runIdentitySha256 !== currentIdentitySha256 ||\n value.localIdentitySha256 !== currentLocalIdentitySha256 ||\n !isRecord(value.local)\n ) {\n throw new Error('benchmark local run receipt does not match the requested resume')\n }\n const expectedLocalReceipt: AnalystBenchmarkLocalRunReceipt = {\n ...localReceiptInput,\n runIdentitySha256: currentIdentitySha256,\n localIdentitySha256: currentLocalIdentitySha256,\n }\n const storedLocalIdentitySha256 = digestCanonical(value.local)\n if (\n storedLocalIdentitySha256 !== currentLocalIdentitySha256 ||\n canonicalJson(value.local) !== canonicalJson(localReceiptInput.local)\n ) {\n throw new Error('benchmark local paths or endpoint do not match the requested resume')\n }\n if (localReceiptContent !== `${JSON.stringify(expectedLocalReceipt, null, 2)}\\n`) {\n throw new Error(`benchmark local run receipt does not exactly match: ${paths.localReceipt}`)\n }\n const initializationCompleteContent = await readRegularFile(\n paths.initializationComplete,\n 'benchmark initialization marker',\n )\n if (initializationCompleteContent !== renderInitializationComplete(manifest)) {\n throw new Error(\n `benchmark initialization marker does not match the run manifest: ${paths.initializationComplete}`,\n )\n }\n return manifest\n}\n\nasync function readAndValidateManifest(\n path: string,\n currentIdentity: AnalystBenchmarkRunIdentity,\n currentIdentitySha256: string,\n currentLocalIdentitySha256: string,\n): Promise<AnalystBenchmarkRunManifest> {\n const content = await readRegularFile(path, 'benchmark run manifest')\n const manifest = await readAndValidateManifestContent(\n path,\n content,\n currentIdentity,\n currentIdentitySha256,\n currentLocalIdentitySha256,\n )\n if (content !== `${JSON.stringify(manifest, null, 2)}\\n`) {\n throw new Error(`benchmark run manifest does not exactly match: ${path}`)\n }\n return manifest\n}\n\nasync function readAndValidateManifestContent(\n path: string,\n content: string,\n currentIdentity: AnalystBenchmarkRunIdentity,\n currentIdentitySha256: string,\n currentLocalIdentitySha256: string,\n): Promise<AnalystBenchmarkRunManifest> {\n const value = parseJson(content, path)\n if (!isRecord(value)) throw new TypeError(`benchmark run manifest must be an object: ${path}`)\n assertExactKeys(\n value,\n ['kind', 'createdAt', 'identitySha256', 'localIdentitySha256', 'identity'],\n 'benchmark run manifest',\n )\n if (value.kind !== 'agent-eval/analyst-benchmark-run') {\n throw new TypeError(`unsupported benchmark run manifest: ${path}`)\n }\n if (typeof value.createdAt !== 'string' || !Number.isFinite(Date.parse(value.createdAt))) {\n throw new TypeError(`benchmark run manifest has an invalid createdAt: ${path}`)\n }\n if (\n !isSha256(value.identitySha256) ||\n !isSha256(value.localIdentitySha256) ||\n !isRecord(value.identity)\n ) {\n throw new TypeError(`benchmark run manifest has an invalid identity: ${path}`)\n }\n const storedIdentitySha256 = digestCanonical(value.identity)\n if (storedIdentitySha256 !== value.identitySha256) {\n throw new Error(`benchmark run manifest identity digest does not match its contents: ${path}`)\n }\n if (\n currentIdentitySha256 !== value.identitySha256 ||\n currentLocalIdentitySha256 !== value.localIdentitySha256 ||\n canonicalJson(currentIdentity) !== canonicalJson(value.identity)\n ) {\n throw new Error(\n `benchmark resume configuration or inputs do not match ${ANALYST_BENCHMARK_MANIFEST_FILE}`,\n )\n }\n return {\n kind: 'agent-eval/analyst-benchmark-run',\n createdAt: value.createdAt,\n identitySha256: currentIdentitySha256,\n localIdentitySha256: currentLocalIdentitySha256,\n identity: currentIdentity,\n }\n}\n\nfunction renderInitializationComplete(manifest: AnalystBenchmarkRunManifest): string {\n return `${JSON.stringify(\n {\n kind: 'agent-eval/analyst-benchmark-initialization-complete',\n runIdentitySha256: manifest.identitySha256,\n localIdentitySha256: manifest.localIdentitySha256,\n createdAt: manifest.createdAt,\n },\n null,\n 2,\n )}\\n`\n}\n\nasync function assertAbsentOrExact(path: string, expected: string, label: string): Promise<void> {\n const existing = await readOptionalRegularFile(path, label)\n if (existing !== undefined && existing !== expected) {\n throw new Error(`${label} does not exactly match interrupted initialization: ${path}`)\n }\n}\n\nasync function readOptionalRegularFile(path: string, label: string): Promise<string | undefined> {\n if (!(await regularFileExists(path))) return undefined\n return readRegularFile(path, label)\n}\n\nexport function createObservationAppender(\n path: string,\n runIdentitySha256: string,\n progress: AnalystBenchmarkProgress,\n): (observation: AnalystBenchmarkObservation) => Promise<void> {\n let writes = Promise.resolve()\n const seen = new Set(progress.observations.map(observationKey))\n return (observation) => {\n const write = writes.then(async () => {\n assertAnalystBenchmarkObservation(observation, 'benchmark observation')\n const key = observationKey(observation)\n if (seen.has(key)) {\n throw new Error(\n `refusing duplicate benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}'`,\n )\n }\n const rowWithoutDigest = {\n sequence: progress.nextSequence,\n runIdentitySha256,\n previousRowSha256: progress.previousRowSha256,\n observation,\n }\n const row: AnalystBenchmarkProgressRow = {\n ...rowWithoutDigest,\n rowSha256: digestCanonical(rowWithoutDigest),\n }\n await appendDurable(path, `${JSON.stringify(row)}\\n`)\n progress.nextSequence += 1\n progress.previousRowSha256 = row.rowSha256\n progress.observations.push(observation)\n seen.add(key)\n })\n writes = write\n return write\n }\n}\n\nexport async function readProgress(\n path: string,\n runIdentitySha256: string,\n caseIds: readonly string[],\n repetitions: number,\n analystRunnerId: string,\n): Promise<AnalystBenchmarkProgress> {\n const text = await readRegularFile(path, 'benchmark observation log')\n const rawLines = text.split('\\n')\n if (rawLines.at(-1) === '') rawLines.pop()\n const observations: AnalystBenchmarkObservation[] = []\n const seen = new Set<string>()\n const executionIndexes = new Set<number>()\n let previousRowSha256: string | null = null\n const allowedCases = new Set(caseIds)\n const plannedObservationCount = caseIds.length * 2 * repetitions\n\n for (const [index, line] of rawLines.entries()) {\n if (!line.trim()) {\n throw new Error(`benchmark observation log contains an empty row at line ${index + 1}`)\n }\n const parsed = parseJson(line, `${path}:${index + 1}`)\n if (!isRecord(parsed)) {\n throw new TypeError(`benchmark observation row ${index + 1} must be an object`)\n }\n assertExactKeys(\n parsed,\n ['sequence', 'runIdentitySha256', 'previousRowSha256', 'observation', 'rowSha256'],\n `benchmark observation row ${index + 1}`,\n )\n assertAnalystBenchmarkObservation(\n parsed.observation,\n `benchmark observation row ${index + 1}.observation`,\n )\n const observation = parsed.observation\n const key = observationKey(observation)\n if (seen.has(key)) {\n throw new Error(\n `duplicate benchmark observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}' at line ${index + 1}`,\n )\n }\n if (parsed.sequence !== index) {\n throw new Error(\n `benchmark observation row ${index + 1} has sequence ${String(parsed.sequence)}; expected ${index}`,\n )\n }\n if (parsed.runIdentitySha256 !== runIdentitySha256) {\n throw new Error(`benchmark observation row ${index + 1} belongs to another run`)\n }\n if (parsed.previousRowSha256 !== previousRowSha256) {\n throw new Error(`benchmark observation row ${index + 1} breaks the digest chain`)\n }\n if (!isSha256(parsed.rowSha256)) {\n throw new TypeError(`benchmark observation row ${index + 1} has an invalid digest`)\n }\n const expectedDigest = digestCanonical({\n sequence: parsed.sequence,\n runIdentitySha256: parsed.runIdentitySha256,\n previousRowSha256: parsed.previousRowSha256,\n observation,\n })\n if (expectedDigest !== parsed.rowSha256) {\n throw new Error(`benchmark observation row ${index + 1} digest does not match its contents`)\n }\n if (\n !allowedCases.has(observation.caseId) ||\n (observation.runnerId !== 'empty' && observation.runnerId !== analystRunnerId) ||\n observation.repetition >= repetitions ||\n observation.executionIndex >= plannedObservationCount\n ) {\n throw new Error(\n `benchmark observation row ${index + 1} does not match a planned case, runner, and repetition`,\n )\n }\n if (executionIndexes.has(observation.executionIndex)) {\n throw new Error(\n `duplicate benchmark executionIndex ${observation.executionIndex} at line ${index + 1}`,\n )\n }\n observations.push(observation)\n seen.add(key)\n executionIndexes.add(observation.executionIndex)\n previousRowSha256 = parsed.rowSha256\n }\n\n return {\n observations,\n nextSequence: observations.length,\n previousRowSha256,\n }\n}\n\nexport async function writeExclusiveOrVerify(path: string, content: string): Promise<void> {\n try {\n await writeExclusive(path, content)\n } catch (error) {\n if (!isNodeError(error, 'EEXIST')) throw error\n const existing = await readRegularFile(path, 'existing benchmark artifact')\n if (existing !== content) {\n throw new Error(`refusing to replace existing benchmark artifact: ${path}`)\n }\n }\n}\n\nexport async function regularFileExists(path: string): Promise<boolean> {\n try {\n const fileStat = await lstat(path)\n if (!fileStat.isFile() || fileStat.isSymbolicLink()) {\n throw new Error(`benchmark artifact path must be a real file: ${path}`)\n }\n return true\n } catch (error) {\n if (isNodeError(error, 'ENOENT')) return false\n throw error\n }\n}\n\nasync function appendDurable(path: string, content: string): Promise<void> {\n const handle = await open(path, constants.O_APPEND | constants.O_WRONLY | constants.O_NOFOLLOW)\n try {\n await handle.writeFile(content, 'utf8')\n await handle.sync()\n } finally {\n await handle.close()\n }\n}\n\nasync function writeExclusive(path: string, content: string): Promise<void> {\n const temporary = `${path}.tmp-${process.pid}-${randomUUID()}`\n let handle: Awaited<ReturnType<typeof open>> | undefined\n try {\n handle = await open(temporary, 'wx')\n await handle.writeFile(content, 'utf8')\n await handle.sync()\n await handle.close()\n handle = undefined\n await link(temporary, path)\n await syncDirectory(dirname(path))\n } finally {\n await handle?.close().catch(() => undefined)\n await unlink(temporary).catch(() => undefined)\n }\n}\n\nexport async function readRegularFile(path: string, label: string): Promise<string> {\n let fileStat: Awaited<ReturnType<typeof lstat>>\n try {\n fileStat = await lstat(path)\n } catch (error) {\n if (isNodeError(error, 'ENOENT')) throw new Error(`${label} is missing: ${path}`)\n throw error\n }\n if (!fileStat.isFile() || fileStat.isSymbolicLink()) {\n throw new Error(`${label} must be a real file: ${path}`)\n }\n return readFile(path, 'utf8')\n}\n\nasync function syncDirectory(path: string): Promise<void> {\n const directory = await open(path, 'r')\n try {\n await directory.sync()\n } finally {\n await directory.close()\n }\n}\n\nfunction isNodeError(error: unknown, code: string): error is NodeJS.ErrnoException {\n return error instanceof Error && 'code' in error && error.code === code\n}\n","import { pairedBootstrap } from '../statistics'\nimport type { AnalystBenchmarkObservation, AnalystBenchmarkResult } from './benchmark'\n\nexport type AnalystComparisonMetric =\n | 'completion'\n | 'issueRecall'\n | 'findingPrecision'\n | 'f1'\n | 'criticalStepAccuracy'\n | 'citationCoverage'\n | 'citationExcerptCoverage'\n | 'citationLabelAgreement'\n | 'citationResolution'\n | 'trustedNegativeAccuracy'\n | 'latencyMs'\n | 'calls'\n | 'inputTokens'\n | 'outputTokens'\n | 'reasoningTokens'\n | 'cachedTokens'\n | 'cacheWriteTokens'\n | 'costUsd'\n\nexport interface AnalystMetricComparison {\n metric: AnalystComparisonMetric\n direction: 'higher' | 'lower'\n /** Trajectories with at least one complete pair for this metric. */\n pairedCases: number\n /** Independent task or incident groups resampled by the interval. */\n pairedClusters: number\n /** Same-run pairs where this metric applies before missing values are removed. */\n eligibleObservations: number\n pairedObservations: number\n baselineMissingObservations: number\n candidateMissingObservations: number\n asymmetricMissingObservations: number\n survivorOnly: boolean\n baselineMean: number | null\n candidateMean: number | null\n meanDelta: number | null\n intervalLow: number | null\n intervalHigh: number | null\n confidence: number\n resamples: number\n minimumSampleMet: boolean\n populationInferenceEligible: boolean\n inferenceLimitations: string[]\n}\n\nexport interface AnalystRunnerComparison {\n baselineRunnerId: string\n candidateRunnerId: string\n metrics: AnalystMetricComparison[]\n}\n\ninterface PairedCaseMetric {\n clusterId: string\n baseline: number\n candidate: number\n}\n\nexport function compareAnalystRunners(\n result: AnalystBenchmarkResult,\n options: {\n baselineRunnerId: string\n candidateRunnerId: string\n confidence?: number\n resamples?: number\n seed?: number\n },\n): AnalystRunnerComparison {\n const confidence = options.confidence ?? 0.95\n const resamples = options.resamples ?? 2000\n assertComparisonControls(confidence, resamples)\n\n const runnerIds = new Set(result.summaries.map((summary) => summary.runnerId))\n if (!runnerIds.has(options.baselineRunnerId)) {\n throw new TypeError(`unknown baseline analyst runner '${options.baselineRunnerId}'`)\n }\n if (!runnerIds.has(options.candidateRunnerId)) {\n throw new TypeError(`unknown candidate analyst runner '${options.candidateRunnerId}'`)\n }\n if (options.baselineRunnerId === options.candidateRunnerId) {\n throw new TypeError('baseline and candidate analyst runners must be different')\n }\n\n const baseline = observationsByCase(result.observations, options.baselineRunnerId)\n const candidate = observationsByCase(result.observations, options.candidateRunnerId)\n const populationRepresentativenessProven =\n result.provenance.metadata?.populationRepresentativenessProven === true\n const metrics = METRICS.map((metric) =>\n compareMetric({\n metric,\n baseline,\n candidate,\n confidence,\n resamples,\n seed: options.seed,\n populationRepresentativenessProven,\n }),\n )\n\n return {\n baselineRunnerId: options.baselineRunnerId,\n candidateRunnerId: options.candidateRunnerId,\n metrics,\n }\n}\n\nfunction compareMetric(options: {\n metric: AnalystComparisonMetric\n baseline: Map<string, AnalystBenchmarkObservation[]>\n candidate: Map<string, AnalystBenchmarkObservation[]>\n confidence: number\n resamples: number\n seed?: number\n populationRepresentativenessProven: boolean\n}): AnalystMetricComparison {\n const pairedCases: PairedCaseMetric[] = []\n let eligibleObservations = 0\n let pairedObservations = 0\n let baselineMissingObservations = 0\n let candidateMissingObservations = 0\n let asymmetricMissingObservations = 0\n\n const caseIds = new Set([...options.baseline.keys(), ...options.candidate.keys()])\n for (const caseId of caseIds) {\n const baselineByRepetition = new Map(\n (options.baseline.get(caseId) ?? []).map((observation) => [\n observation.repetition,\n observation,\n ]),\n )\n const candidateByRepetition = new Map(\n (options.candidate.get(caseId) ?? []).map((observation) => [\n observation.repetition,\n observation,\n ]),\n )\n const caseBefore: number[] = []\n const caseAfter: number[] = []\n let clusterId: string | undefined\n const repetitions = new Set([...baselineByRepetition.keys(), ...candidateByRepetition.keys()])\n for (const repetition of repetitions) {\n const baselineObservation = baselineByRepetition.get(repetition)\n const candidateObservation = candidateByRepetition.get(repetition)\n const identity = baselineObservation ?? candidateObservation\n if (!identity || !metricApplies(identity, options.metric)) continue\n if (baselineObservation && candidateObservation) {\n assertSameCaseIdentity(baselineObservation, candidateObservation)\n }\n eligibleObservations += 1\n clusterId = identity.clusterId\n const baselineValue = baselineObservation\n ? metricValue(baselineObservation, options.metric)\n : null\n const candidateValue = candidateObservation\n ? metricValue(candidateObservation, options.metric)\n : null\n const baselineMissing = baselineValue === null\n const candidateMissing = candidateValue === null\n if (baselineMissing) baselineMissingObservations += 1\n if (candidateMissing) candidateMissingObservations += 1\n if (baselineMissing !== candidateMissing) asymmetricMissingObservations += 1\n if (baselineMissing || candidateMissing) continue\n caseBefore.push(baselineValue)\n caseAfter.push(candidateValue)\n pairedObservations += 1\n }\n if (caseBefore.length === 0 || !clusterId) continue\n pairedCases.push({\n clusterId,\n baseline: mean(caseBefore),\n candidate: mean(caseAfter),\n })\n }\n\n const byCluster = new Map<string, PairedCaseMetric[]>()\n for (const pairedCase of pairedCases) {\n const rows = byCluster.get(pairedCase.clusterId) ?? []\n rows.push(pairedCase)\n byCluster.set(pairedCase.clusterId, rows)\n }\n const before = [...byCluster.values()].map((rows) => mean(rows.map((row) => row.baseline)))\n const after = [...byCluster.values()].map((rows) => mean(rows.map((row) => row.candidate)))\n const interval =\n before.length === 0\n ? null\n : pairedBootstrap(before, after, {\n confidence: options.confidence,\n resamples: options.resamples,\n statistic: 'mean',\n seed: options.seed,\n })\n const survivorOnly = pairedObservations < eligibleObservations\n const limitations: string[] = []\n if (!interval?.gateEligible) limitations.push('fewer-than-20-independent-clusters')\n if (!options.populationRepresentativenessProven) {\n limitations.push('population-representativeness-not-proven')\n }\n if (survivorOnly) limitations.push('missing-observations')\n\n const comparison: AnalystMetricComparison = {\n metric: options.metric,\n direction: LOWER_IS_BETTER.has(options.metric) ? 'lower' : 'higher',\n pairedCases: pairedCases.length,\n pairedClusters: before.length,\n eligibleObservations,\n pairedObservations,\n baselineMissingObservations,\n candidateMissingObservations,\n asymmetricMissingObservations,\n survivorOnly,\n baselineMean: before.length === 0 ? null : mean(before),\n candidateMean: after.length === 0 ? null : mean(after),\n meanDelta: interval?.mean ?? null,\n intervalLow: interval?.low ?? null,\n intervalHigh: interval?.high ?? null,\n confidence: options.confidence,\n resamples: options.resamples,\n minimumSampleMet: interval?.gateEligible ?? false,\n populationInferenceEligible: limitations.length === 0,\n inferenceLimitations: limitations,\n }\n assertValidComparison(comparison)\n return comparison\n}\n\nconst METRICS: readonly AnalystComparisonMetric[] = [\n 'completion',\n 'issueRecall',\n 'findingPrecision',\n 'f1',\n 'criticalStepAccuracy',\n 'citationCoverage',\n 'citationExcerptCoverage',\n 'citationLabelAgreement',\n 'citationResolution',\n 'trustedNegativeAccuracy',\n 'latencyMs',\n 'calls',\n 'inputTokens',\n 'outputTokens',\n 'reasoningTokens',\n 'cachedTokens',\n 'cacheWriteTokens',\n 'costUsd',\n]\n\nconst LOWER_IS_BETTER = new Set<AnalystComparisonMetric>([\n 'latencyMs',\n 'calls',\n 'inputTokens',\n 'outputTokens',\n 'reasoningTokens',\n 'cachedTokens',\n 'cacheWriteTokens',\n 'costUsd',\n])\n\nfunction observationsByCase(\n observations: readonly AnalystBenchmarkObservation[],\n runnerId: string,\n): Map<string, AnalystBenchmarkObservation[]> {\n const byCase = new Map<string, AnalystBenchmarkObservation[]>()\n for (const observation of observations) {\n if (observation.runnerId !== runnerId) continue\n const rows = byCase.get(observation.caseId) ?? []\n rows.push(observation)\n byCase.set(observation.caseId, rows)\n }\n return byCase\n}\n\nfunction assertSameCaseIdentity(\n baseline: AnalystBenchmarkObservation,\n candidate: AnalystBenchmarkObservation,\n): void {\n if (baseline.clusterId !== candidate.clusterId || baseline.labelState !== candidate.labelState) {\n throw new Error(\n `analyst comparison case identity differs for '${baseline.caseId}' repetition ${baseline.repetition}`,\n )\n }\n}\n\nfunction metricApplies(\n observation: AnalystBenchmarkObservation,\n metric: AnalystComparisonMetric,\n): boolean {\n if (metric === 'trustedNegativeAccuracy') {\n return observation.labelState === 'trusted-negative'\n }\n if (metric === 'issueRecall' || metric === 'findingPrecision' || metric === 'f1') {\n return observation.labelState === 'positive'\n }\n if (metric === 'criticalStepAccuracy') {\n return observation.labelState === 'positive' && observation.score.criticalStepAccuracy !== null\n }\n return true\n}\n\nfunction metricValue(\n observation: AnalystBenchmarkObservation,\n metric: AnalystComparisonMetric,\n): number | null {\n if (metric === 'completion') return observation.error ? 0 : 1\n if (metric === 'latencyMs') return observation.latencyMs\n if (metric === 'trustedNegativeAccuracy') {\n if (observation.error) return 0\n return observation.score.predictionOnLabelEmptyCase ? 0 : 1\n }\n if (\n observation.error &&\n (metric === 'issueRecall' ||\n metric === 'findingPrecision' ||\n metric === 'f1' ||\n metric === 'criticalStepAccuracy')\n ) {\n return 0\n }\n if (\n observation.error &&\n (metric === 'citationCoverage' ||\n metric === 'citationExcerptCoverage' ||\n metric === 'citationLabelAgreement' ||\n metric === 'citationResolution')\n ) {\n return null\n }\n if (metric === 'issueRecall') return observation.score.issueRecall\n if (metric === 'findingPrecision') return observation.score.findingPrecision\n if (metric === 'f1') return observation.score.f1\n if (metric === 'criticalStepAccuracy') return observation.score.criticalStepAccuracy\n if (metric === 'citationCoverage') return observation.score.citationCoverage\n if (metric === 'citationExcerptCoverage') return observation.score.citationExcerptCoverage\n if (metric === 'citationLabelAgreement') return observation.score.citationLabelAgreement\n if (metric === 'citationResolution') return observation.evidenceResolution?.validity ?? null\n if (metric === 'calls') return observation.usage?.calls ?? null\n if (metric === 'inputTokens') return observation.usage?.tokens?.input ?? null\n if (metric === 'outputTokens') return observation.usage?.tokens?.output ?? null\n if (metric === 'reasoningTokens') return observation.usage?.tokens?.reasoning ?? null\n if (metric === 'cachedTokens') return observation.usage?.tokens?.cached ?? null\n if (metric === 'cacheWriteTokens') return observation.usage?.tokens?.cacheWrite ?? null\n if (observation.usage?.cost.kind === 'uncaptured') return null\n return observation.usage?.cost.usd ?? null\n}\n\nfunction mean(values: readonly number[]): number {\n return values.reduce((sum, value) => sum + value, 0) / values.length\n}\n\nfunction assertComparisonControls(confidence: number, resamples: number): void {\n if (!Number.isSafeInteger(resamples) || resamples <= 0 || resamples > 1_000_000) {\n throw new Error(\n `compareAnalystRunners: resamples must be a positive safe integer no greater than 1000000, got ${String(resamples)}`,\n )\n }\n if (!Number.isFinite(confidence) || confidence <= 0 || confidence >= 1) {\n throw new Error(\n `compareAnalystRunners: confidence must be a finite number in (0,1), got ${String(confidence)}`,\n )\n }\n}\n\nfunction assertValidComparison(comparison: AnalystMetricComparison): void {\n const numericFields = [\n 'pairedCases',\n 'pairedClusters',\n 'eligibleObservations',\n 'pairedObservations',\n 'baselineMissingObservations',\n 'candidateMissingObservations',\n 'asymmetricMissingObservations',\n 'confidence',\n 'resamples',\n ] as const\n const nullableFields = [\n 'baselineMean',\n 'candidateMean',\n 'meanDelta',\n 'intervalLow',\n 'intervalHigh',\n ] as const\n if (\n numericFields.some((field) => !Number.isFinite(comparison[field])) ||\n nullableFields.some(\n (field) => comparison[field] !== null && !Number.isFinite(comparison[field]),\n )\n ) {\n throw new Error(\n `compareAnalystRunners: ${comparison.metric} produced non-finite comparison output`,\n )\n }\n if (\n comparison.intervalLow !== null &&\n comparison.intervalHigh !== null &&\n comparison.intervalLow > comparison.intervalHigh\n ) {\n throw new Error(\n `compareAnalystRunners: ${comparison.metric} produced an invalid confidence interval`,\n )\n }\n}\n","import type { AnalystBenchmarkObservation, AnalystBenchmarkResult } from './benchmark'\nimport { codeTraceStepFromEvidence } from './benchmark-evidence-validation'\n\nexport interface CodeTraceCalibrationRunnerSummary {\n runnerId: string\n selectedRuns: number\n positiveRuns: number\n trustedNegativeRuns: number\n unlabeledRuns: number\n failedLabelEmptyRuns: number\n unknownLabelEmptyRuns: number\n completedRuns: number\n failedRuns: number\n expectedIncorrectSteps: number\n predictedIncorrectSteps: number\n matchedIncorrectSteps: number\n /** CodeTraceBench's published mean per-row incorrect-step F1 over every row. */\n officialAllRowF1: number | null\n officialAllRowRuns: number\n precision: number | null\n recall: number | null\n f1: number | null\n trustedNegativeFalsePositiveRate: number | null\n trustedNegativeFailureRate: number | null\n unlabeledPredictionRate: number | null\n unlabeledFailureRate: number | null\n}\n\nexport interface CodeTraceCalibrationSummary {\n protocol: 'labeled-positive-and-solved-negative'\n rationale: string\n runners: CodeTraceCalibrationRunnerSummary[]\n}\n\nexport function summarizeCodeTraceCalibration(\n result: AnalystBenchmarkResult,\n): CodeTraceCalibrationSummary {\n return {\n protocol: 'labeled-positive-and-solved-negative',\n rationale:\n 'Uses rows with incorrect-step labels as positives and solved label-empty rows as trusted negatives. Failed label-empty rows remain in the published result but are not treated as clean controls.',\n runners: result.provenance.runnerIds.map((runnerId) =>\n summarizeRunner(\n runnerId,\n result.observations.filter((observation) => observation.runnerId === runnerId),\n ),\n ),\n }\n}\n\nexport function renderCodeTraceCalibrationMarkdown(summary: CodeTraceCalibrationSummary): string {\n return [\n '## CodeTraceBench Calibrated View',\n '',\n summary.rationale,\n '',\n '| Runner | Completed/selected | Failed | Positive runs | Trusted negative runs | Unlabeled runs | Failed label-empty | Unknown label-empty | Matched/expected steps | Predicted steps | Precision | Recall | F1 | Official all-row F1 | Official rows | Trusted-negative false positives | Trusted-negative failures | Unlabeled predictions | Unlabeled failures |',\n '| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |',\n ...summary.runners.map(\n (runner) =>\n `| ${escapeCell(runner.runnerId)} | ${runner.completedRuns}/${runner.selectedRuns} | ${runner.failedRuns} | ${runner.positiveRuns} | ${runner.trustedNegativeRuns} | ${runner.unlabeledRuns} | ${runner.failedLabelEmptyRuns} | ${runner.unknownLabelEmptyRuns} | ${runner.matchedIncorrectSteps}/${runner.expectedIncorrectSteps} | ${runner.predictedIncorrectSteps} | ${rate(runner.precision)} | ${rate(runner.recall)} | ${rate(runner.f1)} | ${rate(runner.officialAllRowF1)} | ${runner.officialAllRowRuns} | ${rate(runner.trustedNegativeFalsePositiveRate)} | ${rate(runner.trustedNegativeFailureRate)} | ${rate(runner.unlabeledPredictionRate)} | ${rate(runner.unlabeledFailureRate)} |`,\n ),\n ].join('\\n')\n}\n\nfunction summarizeRunner(\n runnerId: string,\n observations: readonly AnalystBenchmarkObservation[],\n): CodeTraceCalibrationRunnerSummary {\n const positive = observations.filter((observation) => observation.labelState === 'positive')\n const trustedNegative = observations.filter(\n (observation) => observation.labelState === 'trusted-negative',\n )\n const excluded = observations.filter((observation) => observation.labelState === 'unlabeled')\n const selected = [...positive, ...trustedNegative]\n const expected = sum(positive.map((observation) => observation.score.expectedIssueCount))\n const predicted = sum(\n selected.map((observation) => (observation.error ? 0 : observation.findings.length)),\n )\n const matched = sum(positive.map((observation) => observation.score.matchedIssueIds.length))\n const precision = predicted === 0 ? (expected > 0 ? 0 : null) : matched / predicted\n const recall = ratio(matched, expected)\n const completedTrustedNegative = trustedNegative.filter((observation) => !observation.error)\n const completedExcluded = excluded.filter((observation) => !observation.error)\n const officialRows = observations.map(officialCodeTraceF1)\n\n return {\n runnerId,\n selectedRuns: selected.length,\n positiveRuns: positive.length,\n trustedNegativeRuns: trustedNegative.length,\n unlabeledRuns: excluded.length,\n failedLabelEmptyRuns: excluded.filter(\n (observation) => observation.caseMetadata?.solved === false,\n ).length,\n unknownLabelEmptyRuns: excluded.filter(\n (observation) => observation.caseMetadata?.solved !== false,\n ).length,\n completedRuns: selected.filter((observation) => !observation.error).length,\n failedRuns: selected.filter((observation) => observation.error).length,\n expectedIncorrectSteps: expected,\n predictedIncorrectSteps: predicted,\n matchedIncorrectSteps: matched,\n officialAllRowF1: mean(officialRows),\n officialAllRowRuns: officialRows.length,\n precision,\n recall,\n f1: harmonicMean(precision, recall),\n trustedNegativeFalsePositiveRate: ratio(\n completedTrustedNegative.filter((observation) => observation.score.predictionOnLabelEmptyCase)\n .length,\n completedTrustedNegative.length,\n ),\n trustedNegativeFailureRate: ratio(\n trustedNegative.filter((observation) => observation.error).length,\n trustedNegative.length,\n ),\n unlabeledPredictionRate: ratio(\n completedExcluded.filter((observation) => observation.findings.length > 0).length,\n completedExcluded.length,\n ),\n unlabeledFailureRate: ratio(\n excluded.filter((observation) => Boolean(observation.error)).length,\n excluded.length,\n ),\n }\n}\n\nfunction officialCodeTraceF1(observation: AnalystBenchmarkObservation): number {\n const trajectoryId = observation.caseMetadata?.trajectoryId\n if (typeof trajectoryId !== 'string' || !trajectoryId.trim()) {\n throw new TypeError(`${observation.caseId}: CodeTraceBench trajectoryId metadata is missing`)\n }\n const expected = new Set(\n [...observation.score.matchedIssueIds, ...observation.score.missedIssueIds].map((issueId) => {\n const match = /^incorrect:(\\d+)$/.exec(issueId)\n if (!match) {\n throw new TypeError(`${observation.caseId}: invalid incorrect-step label '${issueId}'`)\n }\n return Number(match[1])\n }),\n )\n const predicted = new Set<number>()\n if (!observation.error) {\n for (const finding of observation.findings) {\n if (finding.area !== 'incorrect') continue\n for (const evidence of finding.evidence_refs) {\n const location = codeTraceStepFromEvidence(evidence.uri)\n if (!location || location.traceId !== trajectoryId) {\n throw new TypeError(\n `${observation.caseId}: invalid CodeTraceBench prediction evidence '${evidence.uri}'`,\n )\n }\n predicted.add(location.step)\n }\n }\n }\n let matched = 0\n for (const step of predicted) if (expected.has(step)) matched += 1\n const precision = predicted.size === 0 ? 0 : matched / predicted.size\n const recall = expected.size === 0 ? 0 : matched / expected.size\n return harmonicMean(precision, recall) ?? 0\n}\n\nfunction sum(values: readonly number[]): number {\n return values.reduce((total, value) => total + value, 0)\n}\n\nfunction ratio(numerator: number, denominator: number): number | null {\n return denominator === 0 ? null : numerator / denominator\n}\n\nfunction mean(values: readonly number[]): number | null {\n return values.length === 0 ? null : sum(values) / values.length\n}\n\nfunction harmonicMean(left: number | null, right: number | null): number | null {\n if (left === null || right === null) return null\n return left + right === 0 ? 0 : (2 * left * right) / (left + right)\n}\n\nfunction rate(value: number | null): string {\n return value === null ? 'n/a' : value.toFixed(3)\n}\n\nfunction escapeCell(value: string): string {\n return value.replaceAll('|', '\\\\|').replaceAll('\\n', ' ')\n}\n","import type { AnalystBenchmarkObservation } from './benchmark'\nimport {\n AGENT_RX_UPSTREAM_REVISION,\n summarizeAgentRxCalibration,\n} from './benchmark-agentrx-calibration'\nimport {\n type AnalystBenchmarkArtifact,\n type AnalystBenchmarkRunManifest,\n canonicalJson,\n observationKey,\n parseJson,\n} from './benchmark-command-artifact'\nimport { readRegularFile } from './benchmark-command-persistence'\nimport { assertAnalystBenchmarkArtifact } from './benchmark-command-validation'\nimport { compareAnalystRunners } from './benchmark-comparison'\nimport { summarizeCodeTraceCalibration } from './benchmark-public-calibration'\nimport type { PreparedPublicAnalystBenchmark } from './benchmark-real-model'\nimport { summarizeAnalystBenchmarkRunner } from './benchmark-summary'\n\nexport async function readAnalystBenchmarkArtifact(\n path: string,\n): Promise<AnalystBenchmarkArtifact> {\n const value = parseJson(await readRegularFile(path, 'analyst benchmark result'), path)\n assertAnalystBenchmarkArtifact(value, 'analyst benchmark result')\n return value\n}\n\nexport function assertCompletedArtifactMatchesRun(\n artifact: AnalystBenchmarkArtifact,\n manifest: AnalystBenchmarkRunManifest,\n observations: readonly AnalystBenchmarkObservation[],\n prepared: PreparedPublicAnalystBenchmark,\n): void {\n if (artifact.runIdentitySha256 !== manifest.identitySha256) {\n throw new Error('completed benchmark result belongs to another run')\n }\n assertSameObservations(artifact.result.observations, observations)\n const expectedCount =\n manifest.identity.inputs.selectedCaseIds.length *\n manifest.identity.config.runnerIds.length *\n manifest.identity.config.repetitions\n if (observations.length !== expectedCount) {\n throw new Error(\n `completed benchmark result has ${observations.length} observations; expected ${expectedCount}`,\n )\n }\n\n const { config, inputs } = manifest.identity\n const verificationAvailability = {\n cases: prepared.verificationArtifacts.length,\n resultFilesPresent: prepared.verificationArtifacts.filter(\n (artifact) => artifact.status === 'present',\n ).length,\n resultFilesMissing: prepared.verificationArtifacts.filter(\n (artifact) => artifact.status === 'missing',\n ).length,\n outcomes: {\n passed: prepared.verificationArtifacts.filter(\n (artifact) => artifact.outcome.status === 'passed',\n ).length,\n failed: prepared.verificationArtifacts.filter(\n (artifact) => artifact.outcome.status === 'failed',\n ).length,\n unavailable: prepared.verificationArtifacts.filter(\n (artifact) => artifact.outcome.status === 'unavailable',\n ).length,\n },\n }\n const expectedInputs: AnalystBenchmarkArtifact['inputs'] = {\n dataset: config.dataset,\n datasetRevision: config.datasetRevision,\n datasetSplit: config.datasetSplit,\n labelsSha256: inputs.labelsSha256,\n sourceRowCount: inputs.sourceRowCount,\n traceFiles: inputs.traceFiles.map((traceFile) => ({ ...traceFile })),\n verificationArtifacts: prepared.verificationArtifacts,\n verificationAvailability,\n selection: {\n limit: config.limit,\n seed: config.seed,\n selectedCaseIds: [...inputs.selectedCaseIds],\n report: prepared.selection,\n },\n execution: {\n repetitions: config.repetitions,\n concurrency: config.concurrency,\n model: config.model.id,\n maxOutputTokens: config.model.maxOutputTokens,\n timeoutMs: config.model.timeoutMs,\n maxCostUsd: config.maxCostUsd,\n maxArtifactBytes: config.maxArtifactBytes,\n analystProtocolSha256: config.analystProtocolSha256,\n implementationSha256: config.implementationSha256,\n dependencyLockSha256: config.dependencyLockSha256,\n },\n }\n if (canonicalJson(artifact.inputs) !== canonicalJson(expectedInputs)) {\n throw new Error('completed benchmark result inputs do not match the run manifest')\n }\n\n const provenance = artifact.result.provenance\n const expectedDatasetId =\n config.dataset === 'agentrx' ? 'microsoft/AgentRx' : 'NJU-LINK/CodeTraceBench'\n const expectedOutputAdapter =\n config.dataset === 'agentrx'\n ? 'agentrx-taxonomy-and-root-step'\n : 'codetracebench-incorrect-block'\n if (\n provenance.id !== `${config.dataset}-real-model-analyst` ||\n provenance.startedAt !== manifest.createdAt ||\n !Number.isFinite(Date.parse(provenance.endedAt)) ||\n Date.parse(provenance.endedAt) < Date.parse(provenance.startedAt) ||\n canonicalJson(provenance.dataset) !==\n canonicalJson({\n id: expectedDatasetId,\n revision: config.datasetRevision,\n split: config.datasetSplit,\n }) ||\n provenance.caseCount !== inputs.selectedCaseIds.length ||\n canonicalJson(provenance.runnerIds) !== canonicalJson(config.runnerIds) ||\n provenance.repetitions !== config.repetitions ||\n provenance.maxConcurrency !== Math.min(config.concurrency, expectedCount) ||\n provenance.runnerOrderSeed !== config.seed ||\n provenance.metadata?.model !== config.model.id ||\n provenance.metadata?.outputAdapter !== expectedOutputAdapter ||\n provenance.metadata?.caseSelection !== prepared.selection.method ||\n provenance.metadata?.caseSelectionSeed !== config.seed ||\n provenance.metadata?.selectionStratified !== prepared.selection.stratified ||\n provenance.metadata?.protocolSha256 !== config.analystProtocolSha256 ||\n provenance.metadata?.implementationSha256 !== config.implementationSha256 ||\n provenance.metadata?.dependencyLockSha256 !== config.dependencyLockSha256 ||\n provenance.metadata?.populationRepresentativenessProven !== false\n ) {\n throw new Error('completed benchmark result provenance does not match the run manifest')\n }\n\n const expectedSummaries = config.runnerIds.map((runnerId) =>\n summarizeAnalystBenchmarkRunner(\n runnerId,\n observations.filter((observation) => observation.runnerId === runnerId),\n ),\n )\n if (canonicalJson(artifact.result.summaries) !== canonicalJson(expectedSummaries)) {\n throw new Error('completed benchmark summaries do not match durable observations')\n }\n\n const expectedComparisons = [\n compareAnalystRunners(artifact.result, {\n baselineRunnerId: 'empty',\n candidateRunnerId: config.runnerIds[1],\n seed: config.seed,\n }),\n ]\n if (canonicalJson(artifact.comparisons) !== canonicalJson(expectedComparisons)) {\n throw new Error('completed benchmark comparisons do not match durable observations')\n }\n\n if (config.dataset === 'codetracebench') {\n if (\n canonicalJson(artifact.codeTraceCalibration) !==\n canonicalJson(summarizeCodeTraceCalibration(artifact.result)) ||\n artifact.agentRxCalibration !== undefined\n ) {\n throw new Error('completed CodeTraceBench calibration does not match durable observations')\n }\n } else if (\n canonicalJson(artifact.agentRxCalibration) !==\n canonicalJson(summarizeAgentRxCalibration(artifact.result, AGENT_RX_UPSTREAM_REVISION)) ||\n artifact.codeTraceCalibration !== undefined\n ) {\n throw new Error('completed AgentRx calibration does not match durable observations')\n }\n}\n\nexport function assertSameObservations(\n expected: readonly AnalystBenchmarkObservation[],\n actual: readonly AnalystBenchmarkObservation[],\n): void {\n if (expected.length !== actual.length) {\n throw new Error(\n `benchmark result has ${expected.length} observations but the durable log has ${actual.length}`,\n )\n }\n const expectedByKey = new Map(\n expected.map((observation) => [observationKey(observation), canonicalJson(observation)]),\n )\n for (const observation of actual) {\n const key = observationKey(observation)\n if (expectedByKey.get(key) !== canonicalJson(observation)) {\n throw new Error(\n `benchmark result does not match durable observation '${observation.runnerId}/${observation.caseId}/${observation.repetition}'`,\n )\n }\n expectedByKey.delete(key)\n }\n if (expectedByKey.size > 0) {\n throw new Error('benchmark result is missing durable observations')\n }\n}\n","import type { AnalystBenchmarkResult } from './benchmark'\nimport type { AnalystRunnerComparison } from './benchmark-comparison'\n\nexport function renderAnalystBenchmarkMarkdown(\n result: AnalystBenchmarkResult,\n comparisons: readonly AnalystRunnerComparison[] = [],\n): string {\n const { provenance } = result\n const lines = [\n '# Trace analyst benchmark',\n '',\n '## Run',\n '',\n '| Field | Value |',\n '| --- | --- |',\n `| Benchmark | ${escapeCell(provenance.id ?? 'unspecified')} |`,\n `| Dataset | ${escapeCell(provenance.dataset?.id ?? 'unspecified')} |`,\n `| Dataset revision | ${escapeCell(provenance.dataset?.revision ?? 'unspecified')} |`,\n `| Dataset split | ${escapeCell(provenance.dataset?.split ?? 'unspecified')} |`,\n `| Started | ${escapeCell(provenance.startedAt)} |`,\n `| Ended | ${escapeCell(provenance.endedAt)} |`,\n `| Cases | ${provenance.caseCount} |`,\n `| Runners | ${escapeCell(provenance.runnerIds.join(', '))} |`,\n `| Repetitions | ${provenance.repetitions} |`,\n `| Maximum concurrency | ${provenance.maxConcurrency} |`,\n `| Runner-order seed | ${provenance.runnerOrderSeed} |`,\n `| Command | ${escapeCell(provenance.command ?? 'uncaptured')} |`,\n `| Environment | ${escapeCell(json(provenance.environment))} |`,\n `| Metadata | ${escapeCell(json(provenance.metadata))} |`,\n '',\n '## Summary',\n '',\n ]\n lines.push(\n '| Runner | Runs | Failed | Issue-bearing | Trusted negatives | Unlabeled | Micro recall | Micro precision | Micro F1 | Macro recall | Macro precision | Macro F1 | Critical step | Citation coverage | Quote coverage | Label-location agreement | Citation resolution | Resolution unknown runs | Unresolved citations | Resolution errors | Trusted-negative false positives | Trusted-negative failures | Unlabeled prediction rate | Unlabeled failures | Prediction repeat | Prediction repeated cases | Matched-label repeat | Matched-label repeated cases | Latency min/mean/p50/p95/max ms | Locally timed runs | Runner-reported latency runs | Unknown latency | Calls | Input tokens | Output tokens | Reasoning tokens | Cached tokens | Cache-write tokens | Known cost USD | Unknown calls | Unknown input/output | Unknown reasoning | Unknown cached | Unknown cache-write | Unknown cost |',\n '| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |',\n )\n for (const summary of result.summaries) {\n lines.push(\n `| ${escapeCell(summary.runnerId)} | ${summary.completedRuns}/${summary.plannedRuns} | ${summary.failedRuns} | ${summary.issueBearingRuns} | ${summary.trustedNegativeRuns} | ${summary.unlabeledRuns} | ${optionalRate(summary.issueRecall)} | ${optionalRate(summary.findingPrecision)} | ${optionalRate(summary.f1)} | ${optionalRate(summary.macroIssueRecall)} | ${optionalRate(summary.macroFindingPrecision)} | ${optionalRate(summary.macroF1)} | ${optionalRate(summary.criticalStepAccuracy)} | ${optionalRate(summary.citationCoverage)} | ${optionalRate(summary.citationExcerptCoverage)} | ${optionalRate(summary.citationLabelAgreement)} | ${optionalRate(summary.citationResolution)} | ${summary.citationResolutionUnknownRuns} | ${summary.unresolvedCitations} | ${summary.citationResolutionErrors} | ${optionalRate(summary.trustedNegativeFalsePositiveRate)} | ${optionalRate(summary.trustedNegativeFailureRate)} | ${optionalRate(summary.unlabeledPredictionRate)} | ${optionalRate(summary.unlabeledFailureRate)} | ${optionalRate(summary.predictionAgreement)} | ${summary.predictionAgreementCases} | ${optionalRate(summary.matchedLabelAgreement)} | ${summary.matchedLabelAgreementCases} | ${latency(summary.latencyMs)} | ${summary.benchmarkClockLatencyRuns} | ${summary.runnerReportedLatencyRuns} | ${summary.latencyUnknownRuns} | ${summary.calls} | ${summary.inputTokens} | ${summary.outputTokens} | ${summary.reasoningTokens} | ${summary.cachedTokens} | ${summary.cacheWriteTokens} | ${summary.knownCostUsd.toFixed(6)} | ${summary.callsUnknownRuns} | ${summary.tokenUsageUnknownRuns} | ${summary.reasoningTokenUsageUnknownRuns} | ${summary.cachedTokenUsageUnknownRuns} | ${summary.cacheWriteTokenUsageUnknownRuns} | ${summary.costUnknownRuns} |`,\n )\n }\n\n for (const comparison of comparisons) {\n lines.push(\n '',\n `## ${escapeCell(comparison.candidateRunnerId)} compared with ${escapeCell(comparison.baselineRunnerId)}`,\n '',\n '| Metric | Better direction | Paired cases | Independent clusters | Eligible observations | Paired observations | Missing baseline | Missing candidate | Missing asymmetry | Survivor-only | Baseline mean | Candidate mean | Delta | Interval | Minimum sample | Population inference | Limits |',\n '| --- | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | --- | ---: | ---: | ---: | --- | --- | --- | --- |',\n )\n for (const metric of comparison.metrics) {\n lines.push(\n `| ${metric.metric} | ${metric.direction} | ${metric.pairedCases} | ${metric.pairedClusters} | ${metric.eligibleObservations} | ${metric.pairedObservations} | ${metric.baselineMissingObservations} | ${metric.candidateMissingObservations} | ${metric.asymmetricMissingObservations} | ${metric.survivorOnly ? 'yes' : 'no'} | ${optionalMetricNumber(metric.baselineMean)} | ${optionalMetricNumber(metric.candidateMean)} | ${optionalSigned(metric.meanDelta)} | ${interval(metric.intervalLow, metric.intervalHigh)} | ${metric.minimumSampleMet ? 'yes' : 'no'} | ${metric.populationInferenceEligible ? 'yes' : 'no'} | ${escapeCell(metric.inferenceLimitations.join(', ') || 'none')} |`,\n )\n }\n }\n\n lines.push(\n '',\n '## Runs',\n '',\n '| Runner | Case | Cluster | Label state | Tags | Case metadata | Runner metadata | Rep | Execution index | Completed | Recall | Precision | F1 | Critical step | Citation coverage | Quote coverage | Label-location agreement | Citation resolution | Prediction on label-empty case | Scored findings | Diagnostic findings | Unlabeled citations | Unresolved citations | Resolution errors | Latency ms | Latency source | Calls | Input tokens | Output tokens | Reasoning tokens | Cached tokens | Cache-write tokens | Cost USD | Known cost USD | Cost source | Error class | Error |',\n '| --- | --- | --- | --- | --- | --- | --- | ---: | ---: | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | --- | ---: | ---: | ---: | ---: | ---: | ---: | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | --- | --- | --- |',\n )\n for (const observation of result.observations) {\n const usage = observation.usage\n const cost = usage?.cost.kind === 'uncaptured' ? null : usage?.cost.usd\n const positive = observation.labelState === 'positive'\n lines.push(\n `| ${escapeCell(observation.runnerId)} | ${escapeCell(observation.caseId)} | ${escapeCell(observation.clusterId)} | ${observation.labelState} | ${escapeCell(observation.caseTags.join(', '))} | ${escapeCell(json(observation.caseMetadata))} | ${escapeCell(json(observation.runnerMetadata))} | ${observation.repetition} | ${observation.executionIndex} | ${observation.error ? 'no' : 'yes'} | ${positive ? rate(observation.score.issueRecall) : 'n/a'} | ${positive ? rate(observation.score.findingPrecision) : 'n/a'} | ${positive ? rate(observation.score.f1) : 'n/a'} | ${optionalRate(observation.score.criticalStepAccuracy)} | ${optionalRate(observation.score.citationCoverage)} | ${optionalRate(observation.score.citationExcerptCoverage)} | ${optionalRate(observation.score.citationLabelAgreement)} | ${optionalRate(observation.evidenceResolution?.validity ?? null)} | ${positive ? 'n/a' : observation.score.predictionOnLabelEmptyCase ? 'yes' : 'no'} | ${observation.score.supportedFindingIndexes.length}/${observation.error ? 0 : observation.findings.length} | ${observation.error ? observation.findings.length : 0} | ${observation.score.unlabeledEvidence.length} | ${observation.evidenceResolution?.unresolvedEvidence.length ?? 'unknown'} | ${observation.evidenceResolution?.errors.length ?? 'unknown'} | ${optionalNumber(observation.latencyMs)} | ${observation.latencySource} | ${usage?.calls ?? 'unknown'} | ${usage?.tokens?.input ?? 'unknown'} | ${usage?.tokens?.output ?? 'unknown'} | ${usage?.tokens?.reasoning ?? 'unknown'} | ${usage?.tokens?.cached ?? 'unknown'} | ${usage?.tokens?.cacheWrite ?? 'unknown'} | ${cost === null || cost === undefined ? 'unknown' : cost.toFixed(6)} | ${usage?.knownCostUsd?.toFixed(6) ?? (cost === null || cost === undefined ? 'unknown' : cost.toFixed(6))} | ${usage?.cost.kind ?? 'unknown'} | ${escapeCell(observation.error?.class ?? '')} | ${escapeCell(observation.error?.message ?? '')} |`,\n )\n }\n return `${lines.join('\\n')}\\n`\n}\n\nfunction rate(value: number): string {\n return `${(value * 100).toFixed(1)}%`\n}\n\nfunction optionalRate(value: number | null): string {\n return value === null ? 'n/a' : rate(value)\n}\n\nfunction number(value: number): string {\n return Number.isInteger(value) ? String(value) : value.toFixed(3)\n}\n\nfunction optionalNumber(value: number | null): string {\n return value === null ? 'unknown' : number(value)\n}\n\nfunction optionalMetricNumber(value: number | null): string {\n return value === null ? 'n/a' : number(value)\n}\n\nfunction signed(value: number): string {\n return `${value >= 0 ? '+' : ''}${number(value)}`\n}\n\nfunction optionalSigned(value: number | null): string {\n return value === null ? 'n/a' : signed(value)\n}\n\nfunction interval(low: number | null, high: number | null): string {\n return low === null || high === null ? 'n/a' : `[${number(low)}, ${number(high)}]`\n}\n\nfunction latency(value: AnalystBenchmarkResult['summaries'][number]['latencyMs']): string {\n if (value === null) return 'unknown'\n return [value.min, value.mean, value.p50, value.p95, value.max].map(number).join('/')\n}\n\nfunction json(value: unknown): string {\n return value === undefined ? 'uncaptured' : JSON.stringify(value)\n}\n\nfunction escapeCell(value: string): string {\n return value.replaceAll('|', '\\\\|').replaceAll('\\n', ' ')\n}\n","import { arch, platform } from 'node:os'\nimport { acquireSingleRunLock } from '../campaign/single-run-lock'\nimport { createRunCostLedger, fsCampaignStorage } from '../campaign/storage'\nimport { CostAccountingIncompleteError, type CostLedger } from '../cost-ledger'\nimport {\n type AnalystBenchmarkObservation,\n type AnalystBenchmarkResult,\n type AnalystBenchmarkRunner,\n runAnalystBenchmark,\n traceStoreEvidenceResolver,\n} from './benchmark'\nimport {\n AGENT_RX_UPSTREAM_REVISION,\n renderAgentRxCalibrationMarkdown,\n summarizeAgentRxCalibration,\n} from './benchmark-agentrx-calibration'\nimport type {\n AnalystBenchmarkArtifact,\n VerificationAvailabilitySummary,\n} from './benchmark-command-artifact'\nimport { digestCanonical } from './benchmark-command-artifact'\nimport {\n type AnalystBenchmarkOutputPaths,\n createLocalRunReceipt,\n createObservationAppender,\n createRunIdentity,\n initializeRunFiles,\n openOutputDirectory,\n prepareOutputLockPath,\n readAndValidateResumeFiles,\n readProgress,\n regularFileExists,\n writeExclusiveOrVerify,\n} from './benchmark-command-persistence'\nimport {\n assertCompletedArtifactMatchesRun,\n assertSameObservations,\n readAnalystBenchmarkArtifact,\n} from './benchmark-command-result'\nimport { compareAnalystRunners } from './benchmark-comparison'\nimport {\n ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256,\n ANALYST_BENCHMARK_IMPLEMENTATION_SHA256,\n} from './benchmark-implementation'\nimport {\n renderCodeTraceCalibrationMarkdown,\n summarizeCodeTraceCalibration,\n} from './benchmark-public-calibration'\nimport { createPublicBenchmarkDirectRunner } from './benchmark-public-model'\nimport { createPublicBenchmarkRlmRunner } from './benchmark-public-rlm'\nimport {\n emptyPublicBenchmarkRunner,\n type PublicAnalystBenchmarkDataset,\n type PublicAnalystBenchmarkModelConfig,\n type PublicBenchmarkSelectionReport,\n preparePublicAnalystBenchmark,\n publicBenchmarkProtocolSha256,\n} from './benchmark-real-model'\nimport { renderAnalystBenchmarkMarkdown } from './benchmark-report'\nimport {\n DEFAULT_MAX_VERIFICATION_ARTIFACT_BYTES,\n type VerificationArtifactManifest,\n} from './benchmark-verification-artifacts'\nimport type { AnalystRunInputs } from './types'\n\nexport {\n ANALYST_BENCHMARK_COST_LEDGER_FILE,\n ANALYST_BENCHMARK_LOCAL_RECEIPT_FILE,\n ANALYST_BENCHMARK_MANIFEST_FILE,\n ANALYST_BENCHMARK_OBSERVATIONS_FILE,\n type AnalystBenchmarkArtifact,\n type AnalystBenchmarkLocalRunReceipt,\n type AnalystBenchmarkProgressRow,\n type AnalystBenchmarkRunIdentity,\n type AnalystBenchmarkRunManifest,\n type VerificationAvailabilitySummary,\n} from './benchmark-command-artifact'\nexport { readAnalystBenchmarkArtifact } from './benchmark-command-result'\n\nexport interface AnalystBenchmarkCommandDependencies {\n createAnalystRunner?: (\n dataset: PublicAnalystBenchmarkDataset,\n config: PublicAnalystBenchmarkModelConfig,\n ) => AnalystBenchmarkRunner<AnalystRunInputs>\n}\n\n/**\n * Which analyst produces the scored arm.\n *\n * `dspy-rlm` is the recursive engine. `direct` is the retired one-shot runner,\n * kept reachable because the published evidence was produced by it: a\n * comparison against those numbers is only sound when the same runner can be\n * re-run over the same inputs.\n */\nexport type AnalystBenchmarkRunnerKind = 'dspy-rlm' | 'direct'\n\nexport interface AnalystBenchmarkCommandConfig {\n dataset: PublicAnalystBenchmarkDataset\n analyst: AnalystBenchmarkRunnerKind\n labelsPath: string\n traceDir: string\n artifactDir?: string\n outDir: string\n revision: string\n split: string\n model: PublicAnalystBenchmarkModelConfig\n limit: number\n seed: number\n concurrency: number\n repetitions: number\n maxCostUsd: number\n maxArtifactBytes: number\n apiKeyEnv: string\n command: string\n resume: boolean\n}\n\nexport { AGENT_RX_UPSTREAM_REVISION } from './benchmark-agentrx-calibration'\n\nexport async function runAnalystBenchmarkCommand(\n argv: readonly string[],\n env: NodeJS.ProcessEnv = process.env,\n dependencies: AnalystBenchmarkCommandDependencies = {},\n): Promise<number> {\n if (argv.includes('--help') || argv.includes('-h')) {\n process.stdout.write(`${ANALYST_BENCHMARK_HELP}\\n`)\n return 0\n }\n const config = parseCommandConfig(argv, env)\n const outputLock = acquireSingleRunLock({\n lockPath: await prepareOutputLockPath(config.outDir),\n })\n try {\n return await executeAnalystBenchmarkCommand(config, dependencies)\n } finally {\n outputLock.release()\n }\n}\n\nasync function executeAnalystBenchmarkCommand(\n config: AnalystBenchmarkCommandConfig,\n dependencies: AnalystBenchmarkCommandDependencies,\n): Promise<number> {\n const paths = await openOutputDirectory(config.outDir, config.resume)\n\n const prepared = await preparePublicAnalystBenchmark({\n dataset: config.dataset,\n labelsPath: config.labelsPath,\n traceDir: config.traceDir,\n artifactDir: config.artifactDir,\n maxArtifactBytes: config.maxArtifactBytes,\n limit: config.limit,\n seed: config.seed,\n })\n const identity = createRunIdentity(config, prepared)\n const localReceipt = createLocalRunReceipt(config, paths)\n const localIdentitySha256 = digestCanonical(localReceipt.local)\n const identitySha256 = digestCanonical(identity)\n const manifest = config.resume\n ? await readAndValidateResumeFiles(\n paths,\n identity,\n identitySha256,\n localIdentitySha256,\n localReceipt,\n )\n : await initializeRunFiles(paths, identity, identitySha256, localIdentitySha256, localReceipt)\n const progress = await readProgress(\n paths.observations,\n manifest.identitySha256,\n prepared.selectedCaseIds,\n config.repetitions,\n config.analyst,\n )\n const costLedger = createRunCostLedger({\n storage: fsCampaignStorage(),\n runDir: paths.directory,\n costCeilingUsd: config.maxCostUsd,\n })\n\n if (await regularFileExists(paths.result)) {\n assertCostLedgerFinalizable(costLedger)\n const artifact = await readAnalystBenchmarkArtifact(paths.result)\n assertCompletedArtifactMatchesRun(artifact, manifest, progress.observations, prepared)\n const markdown = renderArtifactMarkdown(artifact)\n await writeExclusiveOrVerify(paths.report, markdown)\n printSuccessSummary(artifact, paths)\n return benchmarkExitCode(artifact.result, config.analyst)\n }\n if (await regularFileExists(paths.report)) {\n throw new Error(\n `benchmark report exists without a completed result; refusing ambiguous resume: ${paths.report}`,\n )\n }\n\n const createAnalystRunner =\n dependencies.createAnalystRunner ??\n ((dataset: PublicAnalystBenchmarkDataset, model: PublicAnalystBenchmarkModelConfig) =>\n config.analyst === 'direct'\n ? createPublicBenchmarkDirectRunner(dataset, model)\n : createPublicBenchmarkRlmRunner(dataset, model))\n const runners = [\n emptyPublicBenchmarkRunner(),\n createAnalystRunner(config.dataset, {\n ...config.model,\n costLedger,\n durability: {\n runIdentitySha256: manifest.identitySha256,\n responseCacheDir: paths.modelResponses,\n },\n }),\n ]\n const appendObservation = createObservationAppender(\n paths.observations,\n manifest.identitySha256,\n progress,\n )\n const runAbort = new AbortController()\n let result: AnalystBenchmarkResult\n try {\n result = await runAnalystBenchmark({\n cases: prepared.cases,\n runners,\n repetitions: config.repetitions,\n maxConcurrency: config.concurrency,\n runnerOrderSeed: config.seed,\n initialObservations: progress.observations,\n signal: runAbort.signal,\n onObservation: async (observation) => {\n assertObservationAccountingComplete(observation, costLedger, config.analyst)\n await appendObservation(observation)\n },\n resolveEvidence: traceStoreEvidenceResolver((input) => {\n if (!input.traceStore) throw new Error('benchmark case has no trace store')\n return input.traceStore\n }),\n benchmark: {\n id: `${config.dataset}-real-model-analyst`,\n dataset: {\n id: config.dataset === 'agentrx' ? 'microsoft/AgentRx' : 'NJU-LINK/CodeTraceBench',\n revision: config.revision,\n split: config.split,\n },\n environment: {\n node: process.version,\n platform: platform(),\n arch: arch(),\n },\n metadata: {\n model: config.model.model,\n outputAdapter:\n config.dataset === 'agentrx'\n ? 'agentrx-taxonomy-and-root-step'\n : 'codetracebench-incorrect-block',\n caseSelection: prepared.selection.method,\n caseSelectionSeed: config.seed,\n selectionStratified: prepared.selection.stratified,\n protocolSha256: publicBenchmarkProtocolSha256(config.dataset),\n implementationSha256: ANALYST_BENCHMARK_IMPLEMENTATION_SHA256,\n dependencyLockSha256: ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256,\n populationRepresentativenessProven: false,\n },\n },\n })\n } catch (error) {\n runAbort.abort(error)\n const idle = await costLedger.waitForIdle({\n timeoutMs: Math.min(config.model.timeoutMs, 10_000),\n })\n if (!idle) {\n throw accountingError(costLedger, 'provider calls remain unresolved after cancellation')\n }\n throw error\n }\n assertCostLedgerFinalizable(costLedger)\n result.provenance.startedAt = manifest.createdAt\n const persisted = await readProgress(\n paths.observations,\n manifest.identitySha256,\n prepared.selectedCaseIds,\n config.repetitions,\n config.analyst,\n )\n assertSameObservations(result.observations, persisted.observations)\n const comparisons = [\n compareAnalystRunners(result, {\n baselineRunnerId: 'empty',\n candidateRunnerId: config.analyst,\n seed: config.seed,\n }),\n ]\n const codeTraceCalibration =\n config.dataset === 'codetracebench' ? summarizeCodeTraceCalibration(result) : undefined\n const agentRxCalibration =\n config.dataset === 'agentrx'\n ? summarizeAgentRxCalibration(result, AGENT_RX_UPSTREAM_REVISION)\n : undefined\n const artifact: AnalystBenchmarkArtifact = {\n kind: 'agent-eval/analyst-benchmark-result',\n runIdentitySha256: manifest.identitySha256,\n inputs: {\n dataset: config.dataset,\n datasetRevision: config.revision,\n datasetSplit: config.split,\n labelsSha256: prepared.labelsSha256,\n sourceRowCount: prepared.sourceRowCount,\n traceFiles: prepared.traceFiles,\n verificationArtifacts: prepared.verificationArtifacts,\n verificationAvailability: summarizeVerificationAvailability(prepared.verificationArtifacts),\n selection: {\n limit: config.limit,\n seed: config.seed,\n selectedCaseIds: prepared.selectedCaseIds,\n report: prepared.selection,\n },\n execution: {\n repetitions: config.repetitions,\n concurrency: config.concurrency,\n model: config.model.model,\n maxOutputTokens: config.model.maxOutputTokens,\n timeoutMs: config.model.timeoutMs,\n maxCostUsd: config.maxCostUsd,\n maxArtifactBytes: config.maxArtifactBytes,\n analystProtocolSha256: publicBenchmarkProtocolSha256(config.dataset),\n implementationSha256: ANALYST_BENCHMARK_IMPLEMENTATION_SHA256,\n dependencyLockSha256: ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256,\n },\n },\n result,\n comparisons,\n ...(codeTraceCalibration ? { codeTraceCalibration } : {}),\n ...(agentRxCalibration ? { agentRxCalibration } : {}),\n }\n\n const markdown = renderArtifactMarkdown(artifact)\n await writeExclusiveOrVerify(paths.result, `${JSON.stringify(artifact, null, 2)}\\n`)\n await writeExclusiveOrVerify(paths.report, markdown)\n printSuccessSummary(artifact, paths)\n return benchmarkExitCode(result, config.analyst)\n}\n\nconst NON_SCORABLE_COST_ERRORS = new Set([\n 'CostAccountingIncompleteError',\n 'CostCallConflictError',\n 'CostCeilingReachedError',\n 'CostLedgerPersistenceError',\n 'CostReceiptCaptureError',\n 'CostReservationExceededError',\n])\n\nfunction assertObservationAccountingComplete(\n observation: AnalystBenchmarkObservation,\n costLedger: CostLedger,\n analystRunnerId: string,\n): void {\n if (observation.error && NON_SCORABLE_COST_ERRORS.has(observation.error.class)) {\n throw new CostAccountingIncompleteError(\n `Analyst benchmark stopped before scoring: ${observation.error.message}`,\n )\n }\n if (observation.runnerId !== analystRunnerId) return\n const summary = costLedger.summary({\n channel: 'analyst',\n tags: {\n benchmarkCaseId: observation.caseId,\n benchmarkRepetition: String(observation.repetition),\n },\n })\n if (!summary.accountingComplete || summary.pendingCalls > 0 || summary.unresolvedCalls > 0) {\n throw accountingError(costLedger, 'the recursive analyst has incomplete cost accounting', {\n channel: 'analyst',\n tags: {\n benchmarkCaseId: observation.caseId,\n benchmarkRepetition: String(observation.repetition),\n },\n })\n }\n}\n\nfunction assertCostLedgerFinalizable(costLedger: CostLedger): void {\n const summary = costLedger.summary()\n if (!summary.accountingComplete || summary.pendingCalls > 0 || summary.unresolvedCalls > 0) {\n throw accountingError(costLedger, 'the run has pending or incomplete cost entries')\n }\n}\n\nfunction accountingError(\n costLedger: CostLedger,\n reason: string,\n filter?: Parameters<CostLedger['summary']>[0],\n): CostAccountingIncompleteError {\n const summary = costLedger.summary(filter)\n const details = summary.incompleteReasons.slice(0, 3).join('; ')\n return new CostAccountingIncompleteError(\n `Analyst benchmark cannot continue because ${reason}${details ? `: ${details}` : ''}`,\n )\n}\n\nexport const ANALYST_BENCHMARK_HELP = `agent-eval analyst-benchmark\n\nRun the recursive DSPy trace analyst against public AgentRx or CodeTraceBench labels.\n\nRequired:\n --dataset agentrx|codetracebench\n --analyst dspy-rlm|direct Scored analyst. Default: dspy-rlm.\n 'direct' is the retired one-shot runner that\n produced the published evidence.\n --labels <dataset.json|dataset.jsonl>\n --trace-dir <one-trace-per-file OTLP JSONL directory>\n --artifact-dir <extracted artifact root> Required for CodeTraceBench\n --out <new output directory>\n --revision <full 40- or 64-character hex digest>\n --split <dataset split>\n --base-url <OpenAI-compatible /v1 URL>\n --api-key-env <environment variable containing the bearer>\n --model <provider model id>\n --limit <positive case count>\n\nControls:\n --resume Continue an interrupted run in --out\n --seed <integer> Case-selection and comparison seed. Default: 0\n --concurrency <positive integer> Parallel benchmark jobs. Default: 1\n --repetitions <positive integer> Runs per case and runner. Default: 1\n --max-output-tokens <positive> Model output limit per call. Default: 4096\n --python <executable> Python with agent-eval-rpc[dspy]. Default: python\n --timeout-ms <positive> Model analyst deadline per case. Default: 300000\n --max-cost-usd <positive> Run-wide spend limit. Default: 5\n --max-artifact-bytes <positive> Final evidence bytes per case. Default: ${DEFAULT_MAX_VERIFICATION_ARTIFACT_BYTES}\n\nWrites result.json with every observation, metric, usage field, error, comparison,\ninput digest, artifact digest, case distribution, selected case id, and explicit\nunknown cost. Limited deterministic-hash subsets are marked non-representative.\nCompleted observations are fsynced to observations.jsonl. Shareable output is in\nresult.json and report.md. Machine-local paths, endpoint, and command are isolated\nin run.local.json.\nThe key is read from the named environment variable and is never written.`\n\nfunction parseCommandConfig(\n argv: readonly string[],\n env: NodeJS.ProcessEnv,\n): AnalystBenchmarkCommandConfig {\n const flags = parseFlags(argv)\n assertKnownFlags(flags)\n const dataset = requiredFlag(flags, 'dataset')\n if (dataset !== 'agentrx' && dataset !== 'codetracebench') {\n throw new Error(\"--dataset must be 'agentrx' or 'codetracebench'\")\n }\n const artifactDir = flags.get('artifact-dir')?.trim()\n if (dataset === 'codetracebench' && !artifactDir) {\n throw new Error('--artifact-dir is required for CodeTraceBench')\n }\n const apiKeyEnv = requiredFlag(flags, 'api-key-env')\n if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(apiKeyEnv)) {\n throw new Error('--api-key-env must be a valid environment variable name')\n }\n const apiKey = env[apiKeyEnv]?.trim()\n if (!apiKey) {\n throw new Error(`--api-key-env points to an empty or missing variable: ${apiKeyEnv}`)\n }\n\n const maxCostUsd = positiveFiniteFlag(flags, 'max-cost-usd', 5)\n const python = flags.get('python')?.trim()\n const analyst = flags.get('analyst')?.trim() ?? 'dspy-rlm'\n if (analyst !== 'dspy-rlm' && analyst !== 'direct') {\n throw new Error(\"--analyst must be 'dspy-rlm' or 'direct'\")\n }\n return {\n dataset,\n analyst,\n labelsPath: requiredFlag(flags, 'labels'),\n traceDir: requiredFlag(flags, 'trace-dir'),\n ...(artifactDir ? { artifactDir } : {}),\n outDir: requiredFlag(flags, 'out'),\n revision: immutableRevision(requiredFlag(flags, 'revision')),\n split: requiredFlag(flags, 'split'),\n model: {\n baseUrl: openAiCompatibleBaseUrl(requiredFlag(flags, 'base-url')),\n apiKey,\n model: requiredFlag(flags, 'model'),\n maxOutputTokens: positiveFlag(flags, 'max-output-tokens', 4_096),\n timeoutMs: positiveFlag(flags, 'timeout-ms', 300_000),\n maxCostUsdPerAnalysis: maxCostUsd,\n ...(python ? { dspyRlm: { runner: { command: python } } } : {}),\n },\n limit: positiveFlag(flags, 'limit'),\n seed: integerFlag(flags, 'seed', 0),\n concurrency: positiveFlag(flags, 'concurrency', 1),\n repetitions: positiveFlag(flags, 'repetitions', 1),\n maxCostUsd,\n maxArtifactBytes: positiveFlag(\n flags,\n 'max-artifact-bytes',\n DEFAULT_MAX_VERIFICATION_ARTIFACT_BYTES,\n ),\n apiKeyEnv,\n command: `agent-eval analyst-benchmark ${argv\n .filter((argument) => argument !== '--resume')\n .map(shellQuote)\n .join(' ')}`,\n resume: flags.has('resume'),\n }\n}\n\nfunction parseFlags(argv: readonly string[]): Map<string, string> {\n const flags = new Map<string, string>()\n for (let index = 0; index < argv.length; index += 1) {\n const token = argv[index]!\n if (!token.startsWith('--')) throw new Error(`unexpected positional argument: ${token}`)\n const raw = token.slice(2)\n const equalsAt = raw.indexOf('=')\n const name = equalsAt < 0 ? raw : raw.slice(0, equalsAt)\n const inlineValue = equalsAt < 0 ? undefined : raw.slice(equalsAt + 1)\n if (!name || flags.has(name)) throw new Error(`duplicate or empty flag: --${name}`)\n if (BOOLEAN_FLAGS.has(name)) {\n if (inlineValue !== undefined) throw new Error(`--${name} does not accept a value`)\n flags.set(name, 'true')\n continue\n }\n const value = inlineValue ?? argv[++index]\n if (!value || value.startsWith('--')) throw new Error(`--${name} requires a value`)\n flags.set(name, value)\n }\n return flags\n}\n\nconst KNOWN_FLAGS = new Set([\n 'resume',\n 'dataset',\n 'analyst',\n 'labels',\n 'trace-dir',\n 'artifact-dir',\n 'out',\n 'revision',\n 'split',\n 'base-url',\n 'api-key-env',\n 'model',\n 'limit',\n 'seed',\n 'concurrency',\n 'repetitions',\n 'max-output-tokens',\n 'python',\n 'timeout-ms',\n 'max-cost-usd',\n 'max-artifact-bytes',\n])\n\nconst BOOLEAN_FLAGS = new Set(['resume'])\n\nfunction assertKnownFlags(flags: ReadonlyMap<string, string>): void {\n for (const flag of flags.keys()) {\n if (!KNOWN_FLAGS.has(flag)) throw new Error(`unknown analyst-benchmark flag: --${flag}`)\n }\n}\n\nfunction requiredFlag(flags: ReadonlyMap<string, string>, name: string): string {\n const value = flags.get(name)?.trim()\n if (!value) throw new Error(`--${name} is required`)\n return value\n}\n\nfunction positiveFlag(\n flags: ReadonlyMap<string, string>,\n name: string,\n defaultValue?: number,\n): number {\n const raw = flags.get(name)\n if (raw === undefined && defaultValue !== undefined) return defaultValue\n if (raw === undefined) throw new Error(`--${name} is required`)\n const value = Number(raw)\n if (!Number.isSafeInteger(value) || value < 1) {\n throw new Error(`--${name} must be a positive safe integer`)\n }\n return value\n}\n\nfunction integerFlag(\n flags: ReadonlyMap<string, string>,\n name: string,\n defaultValue: number,\n): number {\n const raw = flags.get(name)\n if (raw === undefined) return defaultValue\n const value = Number(raw)\n if (!Number.isSafeInteger(value)) throw new Error(`--${name} must be a safe integer`)\n return value\n}\n\nfunction positiveFiniteFlag(\n flags: ReadonlyMap<string, string>,\n name: string,\n defaultValue: number,\n): number {\n const raw = flags.get(name)\n if (raw === undefined) return defaultValue\n const value = Number(raw)\n if (!Number.isFinite(value) || value <= 0) {\n throw new Error(`--${name} must be a positive finite number`)\n }\n return value\n}\n\nfunction openAiCompatibleBaseUrl(value: string): string {\n let parsed: URL\n try {\n parsed = new URL(value)\n } catch {\n throw new Error('--base-url must be an absolute HTTP or HTTPS URL')\n }\n if (\n (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') ||\n parsed.username ||\n parsed.password ||\n parsed.search ||\n parsed.hash\n ) {\n throw new Error('--base-url must use HTTP or HTTPS without credentials, query, or fragment')\n }\n if (parsed.protocol === 'http:' && !isLoopbackHost(parsed.hostname)) {\n throw new Error('--base-url must use HTTPS unless the endpoint is on the local machine')\n }\n return value\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const normalized = hostname.toLowerCase()\n return (\n normalized === 'localhost' ||\n normalized === '[::1]' ||\n normalized === '::1' ||\n /^127(?:\\.\\d{1,3}){3}$/.test(normalized)\n )\n}\n\nfunction immutableRevision(value: string): string {\n if (!/^(?:[a-fA-F0-9]{40}|[a-fA-F0-9]{64})$/.test(value)) {\n throw new Error('--revision must be a full 40- or 64-character hexadecimal digest')\n }\n return value.toLowerCase()\n}\n\nfunction renderSelectionMarkdown(report: PublicBenchmarkSelectionReport): string {\n const rows = (['class', 'agent', 'model', 'difficulty', 'solved'] as const).map((dimension) => {\n const source = report.source[dimension]\n const selected = report.selected[dimension]\n return `| ${dimension} | ${distributionText(source.counts, source.missing, source.total)} | ${distributionText(selected.counts, selected.missing, selected.total)} |`\n })\n return [\n '## Case Selection',\n '',\n `Method: \\`${report.method}\\`; seed: \\`${report.seed}\\`; selected: ${report.selectedCount}/${report.sourceCount}.`,\n report.representativeOfInput\n ? 'This is a census of the supplied input.'\n : 'This deterministic hash subset is not stratified and must not be presented as representative.',\n '',\n '| Dimension | Supplied input | Selected cases |',\n '| --- | --- | --- |',\n ...rows,\n ].join('\\n')\n}\n\nfunction distributionText(\n counts: Readonly<Record<string, number>>,\n missing: number,\n total: number,\n): string {\n const values = Object.entries(counts).map(([value, count]) => `${value}=${count}`)\n if (missing > 0) values.push(`missing=${missing}`)\n return `${values.join(', ') || 'none'} (n=${total})`\n}\n\nfunction summarizeVerificationAvailability(\n manifests: readonly VerificationArtifactManifest[],\n): VerificationAvailabilitySummary {\n return {\n cases: manifests.length,\n resultFilesPresent: manifests.filter((manifest) => manifest.status === 'present').length,\n resultFilesMissing: manifests.filter((manifest) => manifest.status === 'missing').length,\n outcomes: {\n passed: manifests.filter((manifest) => manifest.outcome.status === 'passed').length,\n failed: manifests.filter((manifest) => manifest.outcome.status === 'failed').length,\n unavailable: manifests.filter((manifest) => manifest.outcome.status === 'unavailable').length,\n },\n }\n}\n\nfunction renderVerificationAvailability(summary: VerificationAvailabilitySummary): string {\n return [\n '## Final Verification Availability',\n '',\n '| Cases | Result files present | Result files missing | Passed | Failed | Unavailable |',\n '| ---: | ---: | ---: | ---: | ---: | ---: |',\n `| ${summary.cases} | ${summary.resultFilesPresent} | ${summary.resultFilesMissing} | ${summary.outcomes.passed} | ${summary.outcomes.failed} | ${summary.outcomes.unavailable} |`,\n ].join('\\n')\n}\n\nfunction renderArtifactMarkdown(artifact: AnalystBenchmarkArtifact): string {\n const calibrationMarkdown = artifact.codeTraceCalibration\n ? `\\n\\n${renderCodeTraceCalibrationMarkdown(artifact.codeTraceCalibration)}`\n : artifact.agentRxCalibration\n ? `\\n\\n${renderAgentRxCalibrationMarkdown(artifact.agentRxCalibration)}`\n : ''\n const verificationMarkdown =\n artifact.inputs.dataset === 'codetracebench'\n ? `\\n\\n${renderVerificationAvailability(artifact.inputs.verificationAvailability)}`\n : ''\n return `${renderAnalystBenchmarkMarkdown(artifact.result, artifact.comparisons).trimEnd()}${calibrationMarkdown}${verificationMarkdown}\\n\\n${renderSelectionMarkdown(artifact.inputs.selection.report)}\\n`\n}\n\nfunction benchmarkExitCode(result: AnalystBenchmarkResult, analystRunnerId: string): number {\n return result.summaries.find((summary) => summary.runnerId === analystRunnerId)?.failedRuns\n ? 2\n : 0\n}\n\nfunction printSuccessSummary(\n artifact: AnalystBenchmarkArtifact,\n paths: AnalystBenchmarkOutputPaths,\n): void {\n const failures = artifact.result.summaries.reduce(\n (total, summary) => total + summary.failedRuns,\n 0,\n )\n const knownCostUsd = artifact.result.summaries.reduce(\n (total, summary) => total + summary.knownCostUsd,\n 0,\n )\n const unknownCostRuns = artifact.result.summaries.reduce(\n (total, summary) => total + summary.costUnknownRuns,\n 0,\n )\n process.stdout.write(\n `Analyst benchmark complete: cases=${artifact.result.provenance.caseCount} failures=${failures} known_cost_usd=${knownCostUsd.toFixed(6)} unknown_cost_runs=${unknownCostRuns}\\nresult=${paths.result}\\nreport=${paths.report}\\n`,\n )\n}\n\nfunction shellQuote(value: string): string {\n return /^[a-zA-Z0-9_./:@%+=,-]+$/.test(value) ? value : `'${value.replaceAll(\"'\", \"'\\\\''\")}'`\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,SAAgB,wBAAwB,OAAuB;CAC7D,MAAM,aAAaA,WAAS,OAAO,iBAAiB,CAAC,CAClD,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,UAAU,EAAE;CACvB,IAAI,CAAC,YAAY,MAAM,IAAI,UAAU,gDAAgD;CACrF,OAAO;AACT;AAEA,SAAgB,qBAAqB,OAAmC;CACtE,MAAM,aAAa,SAAS;CAC5B,IAAI,CAAC,OAAO,SAAS,UAAU,KAAK,aAAa,KAAK,aAAa,GACjE,MAAM,IAAI,WAAW,wDAAwD;CAE/E,OAAO;AACT;AAEA,SAAgB,sBACd,MAC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