@tangle-network/agent-eval 0.126.7 → 0.127.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 +44 -0
- package/README.md +2 -2
- package/dist/analyst/index.d.ts +51 -39
- package/dist/analyst/index.js +4 -4
- package/dist/belief-state/index.d.ts +34 -36
- package/dist/belief-state/index.js +2 -2
- package/dist/benchmarks/index.d.ts +30 -12
- package/dist/benchmarks/index.js +12 -10
- package/dist/builder-eval/index.js +1 -1
- package/dist/campaign/index.d.ts +432 -146
- package/dist/campaign/index.js +11 -9
- package/dist/{chunk-ARU2PZFM.js → chunk-424XHVKV.js} +43 -23
- package/dist/chunk-424XHVKV.js.map +1 -0
- package/dist/{chunk-NUKSVU3W.js → chunk-5DTSBUL2.js} +2 -2
- package/dist/{chunk-BTACVO2W.js → chunk-65QETEKG.js} +542 -258
- package/dist/chunk-65QETEKG.js.map +1 -0
- package/dist/{chunk-CGG5SLH3.js → chunk-ARCFIY7U.js} +2 -2
- package/dist/{chunk-P22LJ3Y2.js → chunk-CLELFRQG.js} +6 -4
- package/dist/chunk-CLELFRQG.js.map +1 -0
- package/dist/{chunk-LUNF2SEL.js → chunk-DJKY2TSY.js} +3 -3
- package/dist/chunk-DPUHNQLN.js +232 -0
- package/dist/chunk-DPUHNQLN.js.map +1 -0
- package/dist/{chunk-IPYXE555.js → chunk-EJGRPCO3.js} +36 -13
- package/dist/chunk-EJGRPCO3.js.map +1 -0
- package/dist/{chunk-K6IAZZ6L.js → chunk-FA3MFYNA.js} +132 -110
- package/dist/chunk-FA3MFYNA.js.map +1 -0
- package/dist/chunk-IG35YDN3.js +614 -0
- package/dist/chunk-IG35YDN3.js.map +1 -0
- package/dist/{chunk-DPZAEKA6.js → chunk-IMGJZBFG.js} +84 -56
- package/dist/chunk-IMGJZBFG.js.map +1 -0
- package/dist/{chunk-H5UD2323.js → chunk-IN455XKS.js} +53 -1
- package/dist/chunk-IN455XKS.js.map +1 -0
- package/dist/{chunk-PJQFMIOX.js → chunk-MHELPNRP.js} +31 -1
- package/dist/chunk-MHELPNRP.js.map +1 -0
- package/dist/{chunk-IILEIWGW.js → chunk-NL33OXEP.js} +41 -36
- package/dist/chunk-NL33OXEP.js.map +1 -0
- package/dist/{chunk-474LBSOX.js → chunk-OD5NQ2CS.js} +41 -16
- package/dist/chunk-OD5NQ2CS.js.map +1 -0
- package/dist/{chunk-QOTFXW5L.js → chunk-P5W7RQKK.js} +2 -2
- package/dist/{chunk-IR3KBHOY.js → chunk-P6FYH6K4.js} +39 -3
- package/dist/chunk-P6FYH6K4.js.map +1 -0
- package/dist/{chunk-J5SQWP6Y.js → chunk-PBE2LOSS.js} +18 -2
- package/dist/chunk-PBE2LOSS.js.map +1 -0
- package/dist/{chunk-E3IADPLG.js → chunk-PRB53E3J.js} +50 -224
- package/dist/chunk-PRB53E3J.js.map +1 -0
- package/dist/{chunk-X4UCIOTZ.js → chunk-S5YLIBFX.js} +2 -2
- package/dist/{chunk-7VYEGHWF.js → chunk-SZLVEKMJ.js} +41 -20
- package/dist/chunk-SZLVEKMJ.js.map +1 -0
- package/dist/{chunk-LKKT3IVV.js → chunk-TSN7JT6D.js} +6 -4
- package/dist/{chunk-LKKT3IVV.js.map → chunk-TSN7JT6D.js.map} +1 -1
- package/dist/{chunk-M7AH34KV.js → chunk-UTA2TGC4.js} +32 -16
- package/dist/chunk-UTA2TGC4.js.map +1 -0
- package/dist/{chunk-MAX3TN3C.js → chunk-UWZZKKU7.js} +7 -19
- package/dist/chunk-UWZZKKU7.js.map +1 -0
- package/dist/{chunk-ZVCHKKOP.js → chunk-WED5KLZQ.js} +39 -15
- package/dist/chunk-WED5KLZQ.js.map +1 -0
- package/dist/{chunk-OCFJACJU.js → chunk-X6VOPMLD.js} +74 -14
- package/dist/chunk-X6VOPMLD.js.map +1 -0
- package/dist/{chunk-MOXWMGPC.js → chunk-Y5CYOL42.js} +159 -70
- package/dist/chunk-Y5CYOL42.js.map +1 -0
- package/dist/{chunk-FO7HEH76.js → chunk-YJBNWCAA.js} +2 -2
- package/dist/chunk-ZPUEEM5U.js +179 -0
- package/dist/chunk-ZPUEEM5U.js.map +1 -0
- package/dist/{chunk-KE2VWPZX.js → chunk-ZUUWPZCV.js} +3 -3
- package/dist/cli.js +4 -4
- package/dist/contract/index.d.ts +421 -124
- package/dist/contract/index.js +242 -115
- package/dist/contract/index.js.map +1 -1
- package/dist/control.d.ts +34 -32
- package/dist/control.js +2 -2
- package/dist/hosted/index.d.ts +142 -41
- package/dist/hosted/index.js +23 -1
- package/dist/index.d.ts +364 -255
- package/dist/index.js +315 -226
- package/dist/index.js.map +1 -1
- package/dist/meta-eval/index.d.ts +32 -32
- package/dist/meta-eval/index.js +2 -2
- package/dist/multishot/index.d.ts +1 -0
- package/dist/openapi.json +1 -1
- package/dist/pipelines/index.js +2 -2
- package/dist/reporting.d.ts +97 -74
- package/dist/reporting.js +5 -4
- package/dist/rl.d.ts +177 -131
- package/dist/rl.js +232 -126
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +53 -63
- package/dist/rollout/index.js +7 -5
- package/dist/{run-campaign-FFRM3RH5.js → run-campaign-3A2EBYBE.js} +4 -3
- package/dist/supervisor-run/index.d.ts +7 -15
- package/dist/supervisor-run/index.js +2 -2
- package/dist/traces.d.ts +66 -41
- package/dist/traces.js +9 -5
- package/dist/wire/index.d.ts +1 -0
- package/dist/wire/index.js +2 -2
- package/docs/concepts.md +18 -1
- package/docs/hosted-ingest-spec.md +37 -40
- package/docs/insight-report.md +57 -7
- package/docs/research-report-methodology.md +20 -21
- package/docs/rollout.md +13 -8
- package/package.json +4 -3
- package/dist/chunk-474LBSOX.js.map +0 -1
- package/dist/chunk-7VYEGHWF.js.map +0 -1
- package/dist/chunk-ARU2PZFM.js.map +0 -1
- package/dist/chunk-BTACVO2W.js.map +0 -1
- package/dist/chunk-DPZAEKA6.js.map +0 -1
- package/dist/chunk-E3IADPLG.js.map +0 -1
- package/dist/chunk-H5UD2323.js.map +0 -1
- package/dist/chunk-IILEIWGW.js.map +0 -1
- package/dist/chunk-IPYXE555.js.map +0 -1
- package/dist/chunk-IR3KBHOY.js.map +0 -1
- package/dist/chunk-J5SQWP6Y.js.map +0 -1
- package/dist/chunk-K6IAZZ6L.js.map +0 -1
- package/dist/chunk-M7AH34KV.js.map +0 -1
- package/dist/chunk-MAX3TN3C.js.map +0 -1
- package/dist/chunk-MOXWMGPC.js.map +0 -1
- package/dist/chunk-OCFJACJU.js.map +0 -1
- package/dist/chunk-P22LJ3Y2.js.map +0 -1
- package/dist/chunk-PJQFMIOX.js.map +0 -1
- package/dist/chunk-ZVCHKKOP.js.map +0 -1
- package/dist/chunk-ZZUXHH3R.js +0 -99
- package/dist/chunk-ZZUXHH3R.js.map +0 -1
- /package/dist/{chunk-NUKSVU3W.js.map → chunk-5DTSBUL2.js.map} +0 -0
- /package/dist/{chunk-CGG5SLH3.js.map → chunk-ARCFIY7U.js.map} +0 -0
- /package/dist/{chunk-LUNF2SEL.js.map → chunk-DJKY2TSY.js.map} +0 -0
- /package/dist/{chunk-QOTFXW5L.js.map → chunk-P5W7RQKK.js.map} +0 -0
- /package/dist/{chunk-X4UCIOTZ.js.map → chunk-S5YLIBFX.js.map} +0 -0
- /package/dist/{chunk-FO7HEH76.js.map → chunk-YJBNWCAA.js.map} +0 -0
- /package/dist/{chunk-KE2VWPZX.js.map → chunk-ZUUWPZCV.js.map} +0 -0
- /package/dist/{run-campaign-FFRM3RH5.js.map → run-campaign-3A2EBYBE.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rollout/exporters.ts","../src/rollout/ledger.ts","../src/rollout/release/card.ts","../src/rollout/release/scrub.ts","../src/rollout/release/hf-dataset.ts"],"sourcesContent":["/**\n * Pure exporters over `tangle.rollout.v1` lines → the training-data shapes\n * the improvement loops feed:\n * - SFT chat JSONL (clean trainable successes, {messages, metadata})\n * - reward rows (every scored line, success or failure, with steps)\n * - Prime Intellect verifiers RolloutOutput (prompt/completion split + reward)\n * - OpenAI RFT items (prompt turns + verdict reference fields)\n *\n * All exporters are pure functions of the lines — filtering (never train on\n * holdout, reward thresholds, the realness gate) happens HERE, on inline\n * labels, no joins.\n */\n\nimport type { ChatMessage, RolloutLine, RolloutSplit, RolloutStep, ToolDef } from './schema'\n\n// ---------------------------------------------------------------------------\n// (a) SFT chat JSONL\n// ---------------------------------------------------------------------------\n\nexport interface TrainingExportOptions {\n /** Include held-out evaluation data in training output. Default false. */\n allowHeldOutTrainingData?: boolean\n /** Require reward to be strictly greater than this value. Default 0. */\n minimumQualityExclusive?: number\n}\n\nexport type SftExportOptions = TrainingExportOptions\n\nexport interface SftRow {\n messages: ChatMessage[]\n metadata: {\n rollout_id: string\n run_id: string\n candidate_id: string | null\n instance_id: string\n reward: number\n }\n}\n\n/**\n * Supervised fine-tune rows: the completed conversation of each qualifying\n * line. Fail-closed filters: trainable split only (never holdout/canary),\n * positive reward, realness-gated lines never qualify, gap lines carry\n * no trainable content.\n */\nexport function toSftRows(lines: RolloutLine[], options: SftExportOptions = {}): SftRow[] {\n return lines\n .filter((line) => isTrainingLineEligible(line, options) && line.messages.length > 0)\n .map((line) => ({\n messages: line.messages,\n metadata: {\n rollout_id: line.rollout_id,\n run_id: line.run_id,\n candidate_id: line.candidate_id ?? null,\n instance_id: line.task.instance_id,\n reward: line.outcome.reward as number,\n },\n }))\n}\n\n// ---------------------------------------------------------------------------\n// (b) Reward rows\n// ---------------------------------------------------------------------------\n\nexport interface RewardRow {\n /** First user turn — the task prompt. */\n prompt: string\n steps: RolloutStep[]\n reward: number\n metadata: {\n rollout_id: string\n run_id: string\n candidate_id: string | null\n instance_id: string\n split: RolloutSplit\n }\n}\n\n/**\n * Reward-labeled rows for completed, positive-quality training runs.\n */\nexport function toRewardRows(\n lines: RolloutLine[],\n options: TrainingExportOptions = {},\n): RewardRow[] {\n return lines\n .filter(\n (line) =>\n isTrainingLineEligible(line, options) &&\n line.messages.some(\n (message) =>\n message.role === 'user' &&\n typeof message.content === 'string' &&\n message.content.length > 0,\n ),\n )\n .map((line) => ({\n prompt: line.messages.find((m) => m.role === 'user')?.content ?? '',\n steps: line.steps ?? [],\n reward: line.outcome.reward as number,\n metadata: {\n rollout_id: line.rollout_id,\n run_id: line.run_id,\n candidate_id: line.candidate_id ?? null,\n instance_id: line.task.instance_id,\n split: line.task.split,\n },\n }))\n}\n\n// ---------------------------------------------------------------------------\n// (c) Prime Intellect verifiers RolloutOutput\n// ---------------------------------------------------------------------------\n\nexport interface VerifiersTokenUsage {\n input_tokens: number | null\n output_tokens: number | null\n reasoning_tokens: number | null\n cache_read_tokens: number | null\n cache_write_tokens: number | null\n}\n\nexport interface VerifiersRolloutOutput {\n /** Messages through the last turn BEFORE the first assistant turn. */\n prompt: ChatMessage[]\n /** The first assistant turn onward — what the policy produced. */\n completion: ChatMessage[]\n reward: number | null\n metrics: Record<string, unknown>\n tool_defs: ToolDef[]\n token_usage: VerifiersTokenUsage\n info: {\n task: RolloutLine['task']\n policy: RolloutLine['policy']\n rollout_id: string\n run_id: string\n experiment_id: string | null\n candidate_id: string | null\n generation: number | null\n candidate_index: number | null\n role: RolloutLine['role']\n }\n}\n\n/** Index of the first assistant turn; messages.length when none exists. */\nfunction firstAssistantIndex(messages: ChatMessage[]): number {\n const index = messages.findIndex((m) => m.role === 'assistant')\n return index === -1 ? messages.length : index\n}\n\nexport function toVerifiersRolloutOutput(line: RolloutLine): VerifiersRolloutOutput {\n const split = firstAssistantIndex(line.messages)\n return {\n prompt: line.messages.slice(0, split),\n completion: line.messages.slice(split),\n reward: line.outcome.reward,\n metrics: line.outcome.metrics,\n tool_defs: line.tool_defs,\n token_usage: {\n input_tokens: line.cost.tokens_in,\n output_tokens: line.cost.tokens_out,\n reasoning_tokens: line.cost.tokens_reasoning,\n cache_read_tokens: line.cost.cache_read,\n cache_write_tokens: line.cost.cache_write,\n },\n info: {\n task: line.task,\n policy: line.policy,\n rollout_id: line.rollout_id,\n run_id: line.run_id,\n experiment_id: line.experiment_id ?? null,\n candidate_id: line.candidate_id ?? null,\n generation: line.generation,\n candidate_index: line.candidate_index,\n role: line.role,\n },\n }\n}\n\nexport function toVerifiersRolloutOutputs(\n lines: RolloutLine[],\n options: TrainingExportOptions = {},\n): VerifiersRolloutOutput[] {\n return lines\n .filter(\n (line) =>\n isTrainingLineEligible(line, options) &&\n firstAssistantIndex(line.messages) > 0 &&\n firstAssistantIndex(line.messages) < line.messages.length,\n )\n .map(toVerifiersRolloutOutput)\n}\n\n// ---------------------------------------------------------------------------\n// (d) OpenAI RFT items\n// ---------------------------------------------------------------------------\n\nexport interface RftItem {\n /** Prompt turns only — the graded completion is re-sampled during RFT. */\n messages: ChatMessage[]\n /** Verdict/label fields the grader references as item.reference.* */\n reference: {\n reward: number | null\n reward_source: string | null\n verdict: unknown\n instance_id: string\n suite: string\n split: RolloutSplit\n rollout_id: string\n }\n}\n\nexport function toRftItem(line: RolloutLine): RftItem {\n const split = firstAssistantIndex(line.messages)\n return {\n messages: line.messages.slice(0, split),\n reference: {\n reward: line.outcome.reward,\n reward_source: line.outcome.reward_source,\n verdict: line.outcome.verdict,\n instance_id: line.task.instance_id,\n suite: line.task.suite,\n split: line.task.split,\n rollout_id: line.rollout_id,\n },\n }\n}\n\n/** RFT needs a real prompt: lines whose transcript starts with prompt turns. */\nexport function toRftItems(lines: RolloutLine[], options: TrainingExportOptions = {}): RftItem[] {\n return lines\n .filter(\n (line) =>\n isTrainingLineEligible(line, options) &&\n line.messages.length > 0 &&\n firstAssistantIndex(line.messages) > 0,\n )\n .map(toRftItem)\n}\n\n// ---------------------------------------------------------------------------\n// Serialization — one JSON object per line, the interchange format for\n// every export. `tangle.rollout.v1` lines and export rows alike.\n// ---------------------------------------------------------------------------\n\nexport function toJsonl(rows: ReadonlyArray<unknown>): string {\n return rows.map((r) => JSON.stringify(r)).join('\\n') + (rows.length ? '\\n' : '')\n}\n\nfunction isTrainingLineEligible(\n line: RolloutLine,\n options: TrainingExportOptions,\n): line is RolloutLine & { outcome: RolloutLine['outcome'] & { reward: number } } {\n const minimumQualityExclusive = options.minimumQualityExclusive ?? 0\n if (!Number.isFinite(minimumQualityExclusive)) {\n throw new Error('minimumQualityExclusive must be finite')\n }\n\n const reward = line.outcome.reward\n if (reward === null) return false\n if (!Number.isFinite(reward)) {\n throw new Error(`training reward for rollout \"${line.rollout_id}\" must be finite`)\n }\n if (reward <= minimumQualityExclusive) return false\n if (!line.outcome.is_completed || line.outcome.is_truncated || line.outcome.error !== null) {\n return false\n }\n if (line.outcome.realness_gated === true) return false\n if (line.task.split === 'search') return true\n return line.task.split === 'holdout' && options.allowHeldOutTrainingData === true\n}\n","/**\n * Rollout-ledger file API — append-only JSONL of validated `tangle.rollout.v1`\n * lines. Writes validate BEFORE touching disk (a bad line never lands);\n * reads validate line-by-line and fail loud with the line number, because a\n * silently-skipped rollout is a corrupted dataset.\n */\n\nimport { appendFile, mkdir, readFile, writeFile } from 'node:fs/promises'\nimport { dirname } from 'node:path'\nimport { assertRolloutLine, type RolloutLine } from './schema'\n\nfunction serialize(lines: RolloutLine[]): string {\n for (const [i, line] of lines.entries()) assertRolloutLine(line, `rollout line [${i}]`)\n return lines.map((line) => JSON.stringify(line)).join('\\n') + (lines.length > 0 ? '\\n' : '')\n}\n\n/** Replace the ledger file with exactly `lines`. */\nexport async function writeRolloutLedger(path: string, lines: RolloutLine[]): Promise<void> {\n const payload = serialize(lines)\n await mkdir(dirname(path), { recursive: true })\n await writeFile(path, payload)\n}\n\n/** Append `lines` to the ledger file (created if absent). */\nexport async function appendRolloutLines(path: string, lines: RolloutLine[]): Promise<void> {\n if (lines.length === 0) return\n const payload = serialize(lines)\n await mkdir(dirname(path), { recursive: true })\n await appendFile(path, payload)\n}\n\n/**\n * Read and validate every line. Throws on the first malformed/invalid line\n * (with its 1-based line number) — fail-closed, never a silent drop.\n */\nexport async function readRolloutLedger(path: string): Promise<RolloutLine[]> {\n const raw = await readFile(path, 'utf8')\n const lines: RolloutLine[] = []\n const rawLines = raw.split('\\n')\n for (let i = 0; i < rawLines.length; i++) {\n const text = rawLines[i]\n if (!text?.trim()) continue\n let parsed: unknown\n try {\n parsed = JSON.parse(text)\n } catch (error) {\n throw new Error(\n `${path}:${i + 1}: malformed JSON — ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n assertRolloutLine(parsed, `${path}:${i + 1}`)\n lines.push(parsed)\n }\n return lines\n}\n","/**\n * HuggingFace dataset-card (README.md) generation for a rollout-ledger release.\n *\n * The card is a pure function of the SCRUBBED lines plus the release options —\n * no timestamps, no environment reads — so rebuilding from the same ledger\n * yields byte-identical output. It documents the schema, provenance (run ids,\n * generations, the official judge), per-role reward semantics including the\n * inherited/contribution caveat, and a role × reward counts table.\n */\n\nimport { ROLLOUT_ROLES, ROLLOUT_SCHEMA, type RolloutLine, type RolloutRole } from '../schema'\nimport type { ScrubCounts } from './scrub'\n\nexport const RELEASE_FORMATS = ['sft', 'verifiers', 'rft', 'raw'] as const\nexport type ReleaseFormat = (typeof RELEASE_FORMATS)[number]\n\n/** Format → data file path inside the dataset dir (train split only). */\nexport const FORMAT_FILES: Record<ReleaseFormat, string> = {\n sft: 'sft/train.jsonl',\n verifiers: 'verifiers/train.jsonl',\n rft: 'rft/train.jsonl',\n raw: 'raw/train.jsonl',\n}\n\nconst FORMAT_DESCRIPTIONS: Record<ReleaseFormat, string> = {\n sft: 'Successful trainable-split transcripts (`reward >= 1`, never realness-gated) as `{messages, metadata}` chat JSONL.',\n verifiers:\n 'Prime Intellect verifiers `RolloutOutput`: prompt/completion split at the first assistant turn, plus reward, metrics, tool defs, and token usage.',\n rft: 'OpenAI RFT items: prompt turns plus `reference.*` verdict fields for a grader (completions are re-sampled during RFT).',\n raw: `Full \\`${ROLLOUT_SCHEMA}\\` ledger lines (scrubbed), one per agent invocation.`,\n}\n\nexport interface DatasetCardInputs {\n /** Scrubbed, release-filtered lines (what actually ships). */\n lines: RolloutLine[]\n formats: ReleaseFormat[]\n includeProposers: boolean\n /** Source ledger basenames, for provenance. */\n sourceFiles: string[]\n scrubTotals: ScrubCounts\n excluded: { proposers: number; nonTrain: number }\n formatCounts: Partial<Record<ReleaseFormat, number>>\n}\n\nfunction unique(values: Array<string | null>): string[] {\n return [...new Set(values.filter((v): v is string => v !== null))].sort()\n}\n\nfunction formatReward(reward: number | null): string {\n if (reward === null) return 'null'\n return Number.isInteger(reward) ? String(reward) : reward.toFixed(4)\n}\n\nfunction markdownTable(header: string[], rows: string[][]): string {\n return [\n `| ${header.join(' | ')} |`,\n `| ${header.map(() => '---').join(' | ')} |`,\n ...rows.map((row) => `| ${row.join(' | ')} |`),\n ].join('\\n')\n}\n\nfunction roleRewardRows(lines: RolloutLine[]): string[][] {\n const counts = new Map<RolloutRole, Map<string, number>>()\n for (const line of lines) {\n const byReward = counts.get(line.role) ?? new Map<string, number>()\n const key = formatReward(line.outcome.reward)\n byReward.set(key, (byReward.get(key) ?? 0) + 1)\n counts.set(line.role, byReward)\n }\n const rows: string[][] = []\n for (const role of ROLLOUT_ROLES) {\n const byReward = counts.get(role)\n if (!byReward) continue\n const keys = [...byReward.keys()].sort((a, b) => {\n if (a === 'null') return 1\n if (b === 'null') return -1\n return Number(b) - Number(a)\n })\n for (const key of keys) rows.push([role, key, String(byReward.get(key))])\n }\n return rows\n}\n\nexport function buildDatasetCard(inputs: DatasetCardInputs): string {\n const { lines, formats, includeProposers, sourceFiles, scrubTotals, excluded, formatCounts } =\n inputs\n\n const runIds = unique(lines.map((line) => line.run_id))\n const generations = [...new Set(lines.map((line) => line.generation))]\n .filter((g): g is number => g !== null)\n .sort((a, b) => a - b)\n const models = unique(lines.map((line) => line.policy.model))\n const harnesses = unique(lines.map((line) => line.policy.harness))\n const captures = unique(lines.map((line) => line.provenance.capture))\n const rewardSources = unique(lines.map((line) => line.outcome.reward_source))\n const gapLines = lines.filter((line) => line.messages.length === 0).length\n\n const configs = formats\n .map((format) =>\n [\n ` - config_name: ${format}`,\n ' data_files:',\n ' - split: train',\n ` path: ${FORMAT_FILES[format]}`,\n ].join('\\n'),\n )\n .join('\\n')\n\n const frontmatter = [\n '---',\n 'license: unknown',\n 'pretty_name: Tangle rollout ledger — agent trajectories',\n 'configs:',\n configs,\n '---',\n ].join('\\n')\n\n const formatsTable = markdownTable(\n ['config', 'path', 'rows', 'contents'],\n formats.map((format) => [\n format,\n `\\`${FORMAT_FILES[format]}\\``,\n String(formatCounts[format] ?? 0),\n FORMAT_DESCRIPTIONS[format],\n ]),\n )\n\n const countsTable = markdownTable(['role', 'reward', 'lines'], roleRewardRows(lines))\n\n const scrubTable = markdownTable(\n ['rule', 'rewrites'],\n Object.entries(scrubTotals).map(([rule, count]) => [rule, String(count)]),\n )\n\n const proposerNote = includeProposers\n ? 'Proposer sessions are INCLUDED (`--include-proposers`); their transcripts contain improvement-loop harness source.'\n : `Proposer sessions are excluded by default (${excluded.proposers} lines dropped); they contain improvement-loop harness source. Rebuild with \\`--include-proposers\\` to keep them.`\n\n return `${frontmatter}\n\n# Tangle rollout ledger — agent trajectories\n\nOne line per agent invocation (supervisor episode, worker session, proposer shot, judge call, analyst pass) captured by the \\`${ROLLOUT_SCHEMA}\\` rollout ledger, labeled with improvement-loop coordinates and the official-judge reward, with the full message transcript inline.\n\nThis release contains the **trainable split only** (\\`search\\`). Holdout, dev, and canary splits are structurally excluded at build time, and the build additionally drops any non-trainable line as a fail-closed filter (${excluded.nonTrain} dropped here).\n\n## Formats\n\n${formatsTable}\n\n## Schema (\\`${ROLLOUT_SCHEMA}\\`)\n\nEach raw line carries:\n\n- \\`rollout_id\\` / \\`parent_rollout_id\\` — invocation identity; workers point at their spawning supervisor episode.\n- \\`run_id\\`, \\`experiment_id\\`, \\`candidate_id\\` — run/experiment/candidate identity from the producing RunRecord, when present.\n- \\`generation\\`, \\`candidate_index\\` — improvement-loop coordinates (\\`-1\\` = baseline campaign; \\`null\\` = not an improvement loop).\n- \\`role\\` — one of ${ROLLOUT_ROLES.map((role) => `\\`${role}\\``).join(', ')}.\n- \\`task\\` — suite, instance id, split, seed, replicate index.\n- \\`policy\\` — harness, model, provider, profile commit, prompt/config hashes, sampling params.\n- \\`messages\\` / \\`tool_defs\\` — full transcript in canonical OpenAI chat-with-tools form (including \\`reasoning_content\\`). An empty \\`messages\\` array is a labeled gap line; \\`provenance.gap\\` says why the transcript could not be recovered (${gapLines} gap lines in this release).\n- \\`outcome\\` — \\`reward\\` (the single scalar), \\`reward_source\\`, the verbatim judge \\`verdict\\`, non-scalar \\`metrics\\`, and \\`realness_gated\\` (anti-Goodhart flag: reward forced to 0, never SFT-eligible).\n- \\`cost\\` — usd, token counts, wall time.\n- \\`artifacts\\` / \\`provenance\\` — patch/run-dir/transcript pointers (scrubbed) and capture metadata.\n\n## Provenance\n\n- Source ledgers: ${sourceFiles.map((file) => `\\`${file}\\``).join(', ')}\n- Run ids: ${runIds.map((id) => `\\`${id}\\``).join(', ')}\n- Generations: ${generations.join(', ')} (\\`-1\\` = baseline campaign)\n- Models: ${models.map((m) => `\\`${m}\\``).join(', ')}\n- Harnesses: ${harnesses.map((h) => `\\`${h}\\``).join(', ')}\n- Capture modes: ${captures.join(', ')}\n- Every reward traces to a named source (reward sources in this release: ${rewardSources.map((s) => `\\`${s}\\``).join(', ')}).\n\n${proposerNote}\n\n## Reward semantics per role\n\n- **agent** — the producing RunRecord's holdout/search score, with the realness gate forcing gamed successes to 0.\n- **supervisor** — the official-judge verdict on the episode's delivered artifact (1 = resolved, 0 = not).\n- **worker** — INHERITED from the parent supervisor episode (\\`…/inherited\\`). Caveat: reward 1 does not establish this worker's individual contribution (sibling workers in the same episode share the episode outcome), and reward 0 does not prove this worker failed.\n- **proposer** — the fraction of improvement-set instances the proposed candidate resolved (\\`…/candidate-resolved-fraction\\`); a scalar in [0, 1], not a binary verdict.\n- **judge / analyst** — carry the episode verdict where one applies; otherwise \\`reward: null\\` (a labeled gap, never 0).\n\n## Counts\n\n${countsTable}\n\nTotal lines: ${lines.length}\n\n## Scrubbing\n\nAbsolute home paths were rewritten to \\`$WORK\\`, credential-shaped strings were replaced with \\`[REDACTED:<kind>]\\` markers, internal hostnames were normalized to \\`*.internal.example\\`, and username-bearing incidentals (\\`ls -l\\` owner columns, per-user pytest tmpdirs) were normalized to \\`user\\` / \\`$USER\\`. Rewrite counts for this release (full per-file breakdown in \\`scrub-report.json\\`):\n\n${scrubTable}\n\n## License\n\n\\`license: unknown\\` is a placeholder — the releasing operator must set the real SPDX license id in the frontmatter above before publishing.\n\n## Citation\n\n\\`\\`\\`bibtex\n@misc{tangle_rollout_ledger,\n title = {Tangle rollout ledger — agent trajectories},\n author = {{Tangle Network}},\n howpublished = {HuggingFace Datasets},\n note = {Operator: fill in the repository URL, authors, and year before publishing}\n}\n\\`\\`\\`\n`\n}\n","/**\n * Deterministic scrubbing pass over rollout-ledger lines before public release.\n *\n * Every rule is a pure regex rewrite applied to every string value in a line\n * (messages, artifacts, run ids, tool arguments — everywhere), so the scrubbed\n * line is still a valid `tangle.rollout.v1` line. Rules are idempotent:\n * scrub(scrub(x)) === scrub(x), and a second pass counts zero hits — that is\n * the property the release pipeline relies on to prove nothing half-scrubbed\n * ships. Rule order matters: whole `KEY=value` env pairs are redacted before\n * the bare-key rule so one secret is never counted twice.\n */\n\nimport type { RolloutLine } from '../schema'\n\nexport interface ScrubRule {\n name: string\n pattern: RegExp\n /** Rewrite for one match; `g1` is the first capture group when present. */\n rewrite: (match: string, g1?: string) => string\n}\n\nexport const SCRUB_RULES: readonly ScrubRule[] = [\n {\n // /home/<user> and /Users/<user> prefixes → $WORK ($HOME-derived paths).\n name: 'home-path',\n pattern: /\\/(?:home|Users)\\/[A-Za-z0-9._-]+/g,\n rewrite: () => '$WORK',\n },\n {\n // Harness stores encode cwd as a dashed path segment (-home-drew-…);\n // strip the leading -home-<user> so the username never ships.\n name: 'home-path-encoded',\n pattern: /(?<=\\/)-(?:home|Users)-[A-Za-z0-9_.]+/g,\n rewrite: () => '$WORK',\n },\n {\n // pytest names its tmpdir after the invoking user (/tmp/pytest-of-drew).\n name: 'tmp-user-dir',\n pattern: /\\/tmp\\/pytest-of-[A-Za-z0-9._-]+/g,\n rewrite: () => '/tmp/pytest-of-$USER',\n },\n {\n // `ls -l` owner/group columns leak the username in captured tool output.\n // The `(?!user user…)` guard keeps a second pass at zero rewrites.\n name: 'ls-owner',\n pattern:\n /([-bcdlps][-rwxsStT]{9}[.+@]?\\s+\\d+\\s+)(?!user user(?=\\s))[A-Za-z0-9._-]+\\s+[A-Za-z0-9._-]+(?=\\s)/g,\n rewrite: (_match, prefix) => `${prefix}user user`,\n },\n {\n // Env-var-shaped secrets: NAME=value where NAME looks credential-bearing.\n // The (?!\\[REDACTED:) guard keeps the rule idempotent on its own output.\n name: 'env-secret',\n pattern:\n /\\b([A-Z][A-Z0-9_]*(?:KEY|TOKEN|SECRET|PASSWORD|PASSWD|CREDENTIALS?))=(?!\\[REDACTED:)(\"[^\"]*\"|'[^']*'|[^\\s\"']+)/g,\n rewrite: (_match, name) => `${name}=[REDACTED:env]`,\n },\n {\n name: 'bearer-token',\n pattern: /\\b(Bearer|Basic)\\s+(?!\\[REDACTED:)[A-Za-z0-9\\-._~+/=]{8,}/g,\n rewrite: (_match, scheme) => `${scheme} [REDACTED:bearer]`,\n },\n {\n // Bare provider-prefixed keys (OpenAI/Anthropic sk-, GitHub ghp_/gho_/…,\n // fine-grained PATs, HuggingFace hf_, Slack xox*, AWS AKIA).\n name: 'api-key',\n pattern:\n /\\b(?:sk-[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{16,}|github_pat_[A-Za-z0-9_]{20,}|hf_[A-Za-z0-9]{16,}|xox[baprs]-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16})\\b/g,\n rewrite: () => '[REDACTED:api-key]',\n },\n {\n // Our infra hostnames → placeholder domain, subdomain preserved\n // (router.tangle.tools → router.internal.example).\n name: 'infra-host',\n pattern: /(?<![A-Za-z0-9.-])((?:[A-Za-z0-9-]+\\.)*)tangle\\.(?:tools|network)(?![A-Za-z0-9-])/g,\n rewrite: (_match, prefix) => `${prefix ?? ''}internal.example`,\n },\n {\n // Known workstation hostnames leak through email Message-IDs and fqdn\n // lookups inside captured test output; extend the list as machines join.\n name: 'machine-host',\n pattern: /\\b[A-Za-z0-9]+-GTR-Pro\\b/g,\n rewrite: () => 'workstation',\n },\n]\n\n/** Rule name → number of matches rewritten. Always carries every rule (0 is data). */\nexport type ScrubCounts = Record<string, number>\n\nexport function emptyScrubCounts(): ScrubCounts {\n return Object.fromEntries(SCRUB_RULES.map((rule) => [rule.name, 0]))\n}\n\nexport function addScrubCounts(into: ScrubCounts, from: ScrubCounts): ScrubCounts {\n for (const [name, count] of Object.entries(from)) into[name] = (into[name] ?? 0) + count\n return into\n}\n\nexport function scrubText(text: string, counts: ScrubCounts): string {\n let out = text\n for (const rule of SCRUB_RULES) {\n out = out.replace(rule.pattern, (match: string, ...rest: unknown[]) => {\n counts[rule.name] = (counts[rule.name] ?? 0) + 1\n return rule.rewrite(match, typeof rest[0] === 'string' ? rest[0] : undefined)\n })\n }\n return out\n}\n\nfunction scrubValue(value: unknown, counts: ScrubCounts): unknown {\n if (typeof value === 'string') return scrubText(value, counts)\n if (Array.isArray(value)) return value.map((item) => scrubValue(item, counts))\n if (value !== null && typeof value === 'object') {\n const out: Record<string, unknown> = {}\n for (const [key, item] of Object.entries(value)) out[key] = scrubValue(item, counts)\n return out\n }\n return value\n}\n\n/** Scrub every string value in a line; structure and key order are preserved. */\nexport function scrubRolloutLine(line: RolloutLine, counts: ScrubCounts): RolloutLine {\n return scrubValue(line, counts) as RolloutLine\n}\n\nexport function scrubLines(lines: RolloutLine[]): { lines: RolloutLine[]; counts: ScrubCounts } {\n const counts = emptyScrubCounts()\n return { lines: lines.map((line) => scrubRolloutLine(line, counts)), counts }\n}\n\n/**\n * A `RolloutScrubber` (text → text) applying the full rule set — the\n * default hook to pass to `mintRolloutRows({ scrub })` so lines are\n * scrubbed at mint time, before they ever reach a ledger file. Release\n * builds re-run `scrubLines` regardless (idempotent), so double-scrubbing\n * is safe and counted as zero.\n */\nexport function defaultRolloutScrubber(text: string): string {\n return scrubText(text, emptyScrubCounts())\n}\n","/**\n * One-command HuggingFace dataset release from rollout ledgers:\n *\n * agent-eval rollout-release <ledger.jsonl...> --out <dir> \\\n * [--formats sft,verifiers,rft,raw] [--include-proposers] [--push <org/name>]\n *\n * Pipeline per input ledger: read + validate → fail-closed filters\n * (trainable split only; proposer sessions dropped unless\n * --include-proposers, they contain improvement-loop harness source) →\n * deterministic scrub → export the requested formats + scrub-report.json +\n * auto-generated README.md card. Deterministic: same inputs and flags →\n * byte-identical output dir.\n *\n * --push uploads the built dir with `huggingface-cli upload` only when the\n * CLI exists on PATH and HF_TOKEN is present in the env; the token is\n * never printed. Everything else runs fully offline.\n */\n\nimport { spawnSync } from 'node:child_process'\nimport { mkdir, writeFile } from 'node:fs/promises'\nimport { basename, dirname, join } from 'node:path'\nimport { toJsonl, toRftItems, toSftRows, toVerifiersRolloutOutputs } from '../exporters'\nimport { readRolloutLedger, writeRolloutLedger } from '../ledger'\nimport { isTrainableSplit, type RolloutLine } from '../schema'\nimport { buildDatasetCard, FORMAT_FILES, RELEASE_FORMATS, type ReleaseFormat } from './card'\nimport { addScrubCounts, emptyScrubCounts, type ScrubCounts, scrubLines } from './scrub'\n\nexport interface BuildOptions {\n out: string\n formats: ReleaseFormat[]\n includeProposers: boolean\n}\n\nexport interface ScrubReport {\n /** Input ledger path → rule → rewrite count (only shipped lines are scrubbed). */\n files: Record<string, ScrubCounts>\n totals: ScrubCounts\n excluded: { proposers: number; nonTrain: number }\n}\n\nexport interface BuildSummary {\n inputs: string[]\n read: number\n kept: number\n scrub: ScrubReport\n formatCounts: Partial<Record<ReleaseFormat, number>>\n files: string[]\n}\n\nexport async function buildHfDataset(\n inputs: string[],\n options: BuildOptions,\n): Promise<BuildSummary> {\n if (inputs.length === 0) throw new Error('no input ledgers given')\n if (options.formats.length === 0) throw new Error('no formats selected')\n\n const report: ScrubReport = {\n files: {},\n totals: emptyScrubCounts(),\n excluded: { proposers: 0, nonTrain: 0 },\n }\n const kept: RolloutLine[] = []\n let read = 0\n\n for (const input of inputs) {\n const lines = await readRolloutLedger(input)\n read += lines.length\n const shippable = lines.filter((line) => {\n if (!isTrainableSplit(line.task.split)) {\n report.excluded.nonTrain += 1\n return false\n }\n if (!options.includeProposers && line.role === 'proposer') {\n report.excluded.proposers += 1\n return false\n }\n return true\n })\n const scrubbed = scrubLines(shippable)\n report.files[input] = scrubbed.counts\n addScrubCounts(report.totals, scrubbed.counts)\n kept.push(...scrubbed.lines)\n }\n\n const formatCounts: Partial<Record<ReleaseFormat, number>> = {}\n const files: string[] = []\n\n for (const format of options.formats) {\n const path = join(options.out, FORMAT_FILES[format])\n await mkdir(dirname(path), { recursive: true })\n if (format === 'raw') {\n // writeRolloutLedger re-validates every scrubbed line before it lands.\n await writeRolloutLedger(path, kept)\n formatCounts.raw = kept.length\n } else if (format === 'sft') {\n const rows = toSftRows(kept)\n await writeFile(path, toJsonl(rows))\n formatCounts.sft = rows.length\n } else if (format === 'verifiers') {\n const outputs = toVerifiersRolloutOutputs(kept)\n await writeFile(path, toJsonl(outputs))\n formatCounts.verifiers = outputs.length\n } else {\n const items = toRftItems(kept)\n await writeFile(path, toJsonl(items))\n formatCounts.rft = items.length\n }\n files.push(path)\n }\n\n const reportPath = join(options.out, 'scrub-report.json')\n await writeFile(reportPath, `${JSON.stringify(report, null, 2)}\\n`)\n files.push(reportPath)\n\n const cardPath = join(options.out, 'README.md')\n await writeFile(\n cardPath,\n buildDatasetCard({\n lines: kept,\n formats: options.formats,\n includeProposers: options.includeProposers,\n sourceFiles: inputs.map((input) => basename(input)),\n scrubTotals: report.totals,\n excluded: report.excluded,\n formatCounts,\n }),\n )\n files.push(cardPath)\n\n return { inputs, read, kept: kept.length, scrub: report, formatCounts, files }\n}\n\nexport function planPushCommand(repo: string, outDir: string): string[] {\n return ['huggingface-cli', 'upload', repo, outDir, '.', '--repo-type', 'dataset']\n}\n\nexport function pushDataset(repo: string, outDir: string): void {\n const found = spawnSync('which', ['huggingface-cli'], { stdio: 'ignore' })\n if (found.status !== 0) {\n throw new Error(\n 'huggingface-cli not found on PATH — install huggingface_hub[cli] before --push',\n )\n }\n if (!process.env.HF_TOKEN) {\n throw new Error('HF_TOKEN not present in env — refusing to push')\n }\n const [command, ...args] = planPushCommand(repo, outDir) as [string, ...string[]]\n // Token stays in the inherited env; it is never echoed or interpolated.\n const run = spawnSync(command, args, { stdio: 'inherit' })\n if (run.status !== 0) throw new Error(`huggingface-cli upload exited ${String(run.status)}`)\n}\n\nexport interface RolloutReleaseCliArgs extends BuildOptions {\n inputs: string[]\n push: string | null\n}\n\nexport const ROLLOUT_RELEASE_USAGE =\n 'usage: agent-eval rollout-release <ledger.jsonl...> --out <dir> [--formats sft,verifiers,rft,raw] [--include-proposers] [--push <org/name>]'\n\nexport function parseRolloutReleaseArgs(argv: string[]): RolloutReleaseCliArgs {\n const args: RolloutReleaseCliArgs = {\n inputs: [],\n out: '',\n formats: [...RELEASE_FORMATS],\n includeProposers: false,\n push: null,\n }\n for (let i = 0; i < argv.length; i++) {\n const arg = argv[i]!\n if (arg === '--out') {\n args.out = argv[++i] ?? ''\n } else if (arg === '--formats') {\n const raw = (argv[++i] ?? '').split(',').filter(Boolean)\n for (const format of raw) {\n if (!RELEASE_FORMATS.includes(format as ReleaseFormat)) {\n throw new Error(\n `unknown format \"${format}\" — expected one of ${RELEASE_FORMATS.join(',')}`,\n )\n }\n }\n args.formats = raw as ReleaseFormat[]\n } else if (arg === '--include-proposers') {\n args.includeProposers = true\n } else if (arg === '--push') {\n args.push = argv[++i] ?? null\n } else if (arg.startsWith('--')) {\n throw new Error(`unknown flag \"${arg}\"`)\n } else {\n args.inputs.push(arg)\n }\n }\n if (args.inputs.length === 0 || !args.out) {\n throw new Error(ROLLOUT_RELEASE_USAGE)\n }\n if (args.push !== null && !/^[\\w.-]+\\/[\\w.-]+$/.test(args.push)) {\n throw new Error(`--push expects <org/name>, got \"${args.push}\"`)\n }\n return args\n}\n\n/** CLI driver for `agent-eval rollout-release`. Returns the process exit code. */\nexport async function runRolloutReleaseCli(argv: string[]): Promise<number> {\n let args: RolloutReleaseCliArgs\n try {\n args = parseRolloutReleaseArgs(argv)\n } catch (error) {\n process.stderr.write(`${error instanceof Error ? error.message : String(error)}\\n`)\n return 2\n }\n const summary = await buildHfDataset(args.inputs, args)\n process.stdout.write(\n `${JSON.stringify(\n {\n read: summary.read,\n kept: summary.kept,\n formatCounts: summary.formatCounts,\n scrub: summary.scrub,\n },\n null,\n 2,\n )}\\n`,\n )\n process.stdout.write(`dataset → ${args.out} (${summary.files.length} files)\\n`)\n if (args.push !== null) {\n pushDataset(args.push, args.out)\n process.stdout.write(`pushed → ${args.push}\\n`)\n }\n return 0\n}\n"],"mappings":";;;;;;;;AA6CO,SAAS,UAAU,OAAsB,UAA4B,CAAC,GAAa;AACxF,SAAO,MACJ,OAAO,CAAC,SAAS,uBAAuB,MAAM,OAAO,KAAK,KAAK,SAAS,SAAS,CAAC,EAClF,IAAI,CAAC,UAAU;AAAA,IACd,UAAU,KAAK;AAAA,IACf,UAAU;AAAA,MACR,YAAY,KAAK;AAAA,MACjB,QAAQ,KAAK;AAAA,MACb,cAAc,KAAK,gBAAgB;AAAA,MACnC,aAAa,KAAK,KAAK;AAAA,MACvB,QAAQ,KAAK,QAAQ;AAAA,IACvB;AAAA,EACF,EAAE;AACN;AAuBO,SAAS,aACd,OACA,UAAiC,CAAC,GACrB;AACb,SAAO,MACJ;AAAA,IACC,CAAC,SACC,uBAAuB,MAAM,OAAO,KACpC,KAAK,SAAS;AAAA,MACZ,CAAC,YACC,QAAQ,SAAS,UACjB,OAAO,QAAQ,YAAY,YAC3B,QAAQ,QAAQ,SAAS;AAAA,IAC7B;AAAA,EACJ,EACC,IAAI,CAAC,UAAU;AAAA,IACd,QAAQ,KAAK,SAAS,KAAK,CAA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;AAAA,MACA;AAAA,IACF,CAAC;AAAA;AAAA,EACH;AACA,UAAQ,OAAO,MAAM,kBAAa,KAAK,GAAG,KAAK,QAAQ,MAAM,MAAM;AAAA,CAAW;AAC9E,MAAI,KAAK,SAAS,MAAM;AACtB,gBAAY,KAAK,MAAM,KAAK,GAAG;AAC/B,YAAQ,OAAO,MAAM,iBAAY,KAAK,IAAI;AAAA,CAAI;AAAA,EAChD;AACA,SAAO;AACT;","names":["mkdir","writeFile","dirname","mkdir","dirname","writeFile"]}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
summarizeBackendIntegrity
|
|
3
|
-
} from "./chunk-ZVCHKKOP.js";
|
|
4
1
|
import {
|
|
5
2
|
paretoChart
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IMGJZBFG.js";
|
|
4
|
+
import {
|
|
5
|
+
pairRunRecords
|
|
6
|
+
} from "./chunk-DPUHNQLN.js";
|
|
7
7
|
import {
|
|
8
|
-
cohensD,
|
|
9
8
|
continuousAgreement,
|
|
10
9
|
pairedBootstrap,
|
|
10
|
+
pairedCohensDz,
|
|
11
11
|
pairedMde,
|
|
12
12
|
pairedTTest,
|
|
13
13
|
pearsonR,
|
|
14
|
-
|
|
14
|
+
requiredPairedSampleSize,
|
|
15
15
|
spearmanR
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-MHELPNRP.js";
|
|
17
17
|
import {
|
|
18
18
|
llmSpans
|
|
19
19
|
} from "./chunk-ZET2UAYW.js";
|
|
20
|
-
import {
|
|
21
|
-
resolveRunCostProvenance
|
|
22
|
-
} from "./chunk-IILEIWGW.js";
|
|
23
20
|
|
|
24
21
|
// src/contamination-guard.ts
|
|
25
22
|
function checkCanaries(output, scenarios) {
|
|
@@ -146,15 +143,15 @@ async function analyzeRuns(opts) {
|
|
|
146
143
|
runs,
|
|
147
144
|
histogramBins: bins
|
|
148
145
|
});
|
|
149
|
-
const knownCostRuns = runs.filter((run) =>
|
|
150
|
-
const costs = knownCostRuns.map((r) => r.costUsd).filter(
|
|
146
|
+
const knownCostRuns = runs.filter((run) => run.costProvenance.kind !== "uncaptured");
|
|
147
|
+
const costs = knownCostRuns.map((r) => r.costUsd).filter(isFiniteNumber);
|
|
151
148
|
const costDist = distributionOf(costs, bins);
|
|
152
149
|
const pareto = paretoChart(knownCostRuns, { split });
|
|
153
150
|
const degraded = {};
|
|
154
151
|
if (provenance.uncaptured.n > 0) {
|
|
155
152
|
degraded.cost = diagnoseCostCoverage(runs, provenance);
|
|
156
153
|
} else if (costs.length === 0 || costs.every((c) => c === 0)) {
|
|
157
|
-
degraded.cost =
|
|
154
|
+
degraded.cost = `all ${runs.length} explicitly observed or estimated USD values are $0`;
|
|
158
155
|
}
|
|
159
156
|
if (pareto.points.length < 2) {
|
|
160
157
|
degraded.pareto = pareto.points.length === 0 ? "no candidates \u2014 Pareto unavailable" : "single candidate \u2014 Pareto is a single point, not a frontier";
|
|
@@ -169,7 +166,7 @@ async function analyzeRuns(opts) {
|
|
|
169
166
|
const interRater = opts.raterScores ? computeInterRater(opts.raterScores) : void 0;
|
|
170
167
|
const lift = computeLift(runs, opts.baselineCandidateId, opts.candidateCandidateId, split);
|
|
171
168
|
const failureClusters = opts.analyst ? await computeFailureClusters(runs, opts.analyst, split) : void 0;
|
|
172
|
-
const failureModes = computeFailureModes(runs);
|
|
169
|
+
const failureModes = computeFailureModes(runs, split);
|
|
173
170
|
const contamination = opts.canaryScenarios ? computeContamination(runs, opts.canaryScenarios) : void 0;
|
|
174
171
|
const outcomeCorrelation = opts.outcomeSignal ? computeOutcomeCorrelation(runs, opts.outcomeSignal, split) : void 0;
|
|
175
172
|
const release = buildReleaseScorecard(composite, lift, contamination);
|
|
@@ -213,16 +210,34 @@ function computeExecutionInsight(runs, bins) {
|
|
|
213
210
|
(row) => row.costUsd !== void 0 ? [row.costUsd] : []
|
|
214
211
|
);
|
|
215
212
|
const modelCounts = /* @__PURE__ */ new Map();
|
|
216
|
-
let
|
|
217
|
-
let
|
|
213
|
+
let executionErrorRuns = 0;
|
|
214
|
+
let executionErrorEvents = 0;
|
|
218
215
|
let errorReportingRuns = 0;
|
|
216
|
+
let errorSpanEvents = 0;
|
|
217
|
+
let errorSpanReportingRuns = 0;
|
|
218
|
+
const terminalOutcomes = {
|
|
219
|
+
succeeded: 0,
|
|
220
|
+
failed: 0,
|
|
221
|
+
cancelled: 0,
|
|
222
|
+
incomplete: 0,
|
|
223
|
+
unknown: 0
|
|
224
|
+
};
|
|
225
|
+
const errorsByTerminalOutcome = {
|
|
226
|
+
succeeded: { withErrors: 0, withoutErrors: 0, unreported: 0 },
|
|
227
|
+
failed: { withErrors: 0, withoutErrors: 0, unreported: 0 },
|
|
228
|
+
cancelled: { withErrors: 0, withoutErrors: 0, unreported: 0 },
|
|
229
|
+
incomplete: { withErrors: 0, withoutErrors: 0, unreported: 0 },
|
|
230
|
+
unknown: { withErrors: 0, withoutErrors: 0, unreported: 0 }
|
|
231
|
+
};
|
|
219
232
|
let modelCallRuns = 0;
|
|
220
233
|
let modelCallEvents = 0;
|
|
221
234
|
let modelCallReportingRuns = 0;
|
|
222
235
|
for (const run of runs) {
|
|
223
236
|
modelCounts.set(run.model, (modelCounts.get(run.model) ?? 0) + 1);
|
|
224
|
-
const
|
|
225
|
-
|
|
237
|
+
const terminalOutcome = run.terminalOutcome;
|
|
238
|
+
terminalOutcomes[terminalOutcome] += 1;
|
|
239
|
+
const modelCalls = nonNegativeCountRaw(run, "llm_span_count");
|
|
240
|
+
if (modelCalls !== void 0) {
|
|
226
241
|
modelCallEvents += modelCalls;
|
|
227
242
|
modelCallReportingRuns += 1;
|
|
228
243
|
}
|
|
@@ -230,13 +245,19 @@ function computeExecutionInsight(runs, bins) {
|
|
|
230
245
|
if ((modelCalls ?? 0) > 0 || usage.input > 0 || usage.output > 0 || (usage.cached ?? 0) > 0 || (usage.cacheWrite ?? 0) > 0) {
|
|
231
246
|
modelCallRuns += 1;
|
|
232
247
|
}
|
|
233
|
-
const errorEvents = run
|
|
234
|
-
if (
|
|
235
|
-
|
|
248
|
+
const errorEvents = reportedExecutionErrorEvents(run);
|
|
249
|
+
if (errorEvents !== void 0) {
|
|
250
|
+
executionErrorEvents += errorEvents;
|
|
236
251
|
errorReportingRuns += 1;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
252
|
+
if (errorEvents > 0) {
|
|
253
|
+
executionErrorRuns += 1;
|
|
254
|
+
errorsByTerminalOutcome[terminalOutcome].withErrors += 1;
|
|
255
|
+
} else errorsByTerminalOutcome[terminalOutcome].withoutErrors += 1;
|
|
256
|
+
} else errorsByTerminalOutcome[terminalOutcome].unreported += 1;
|
|
257
|
+
const reportedErrorSpans = nonNegativeCountRaw(run, "error_span_count");
|
|
258
|
+
if (reportedErrorSpans !== void 0) {
|
|
259
|
+
errorSpanEvents += reportedErrorSpans;
|
|
260
|
+
errorSpanReportingRuns += 1;
|
|
240
261
|
}
|
|
241
262
|
}
|
|
242
263
|
return {
|
|
@@ -267,14 +288,28 @@ function computeExecutionInsight(runs, bins) {
|
|
|
267
288
|
events: modelCallEvents,
|
|
268
289
|
reportingRuns: modelCallReportingRuns
|
|
269
290
|
},
|
|
270
|
-
|
|
271
|
-
runs:
|
|
272
|
-
fraction:
|
|
273
|
-
|
|
274
|
-
reportingRuns: errorReportingRuns
|
|
275
|
-
|
|
291
|
+
executionErrors: {
|
|
292
|
+
runs: executionErrorRuns,
|
|
293
|
+
fraction: errorReportingRuns > 0 ? executionErrorRuns / errorReportingRuns : null,
|
|
294
|
+
events: executionErrorEvents,
|
|
295
|
+
reportingRuns: errorReportingRuns,
|
|
296
|
+
errorSpanEvents,
|
|
297
|
+
errorSpanReportingRuns,
|
|
298
|
+
byTerminalOutcome: errorsByTerminalOutcome
|
|
299
|
+
},
|
|
300
|
+
terminalOutcomes
|
|
276
301
|
};
|
|
277
302
|
}
|
|
303
|
+
function reportedExecutionErrorEvents(run) {
|
|
304
|
+
const canonical = nonNegativeCountRaw(run, "execution_error_count");
|
|
305
|
+
if (canonical !== void 0) return canonical;
|
|
306
|
+
const toolErrors = nonNegativeCountRaw(run, "tool_errors");
|
|
307
|
+
return toolErrors;
|
|
308
|
+
}
|
|
309
|
+
function nonNegativeCountRaw(run, key) {
|
|
310
|
+
const value = finiteRaw(run, key);
|
|
311
|
+
return value !== void 0 && Number.isInteger(value) && value >= 0 ? value : void 0;
|
|
312
|
+
}
|
|
278
313
|
function summarizeTokenUsage(usages, bins) {
|
|
279
314
|
const reasoning = usages.flatMap(
|
|
280
315
|
(usage) => usage.reasoning !== void 0 ? [usage.reasoning] : []
|
|
@@ -332,7 +367,7 @@ function summarizeCostProvenance(runs) {
|
|
|
332
367
|
knownFraction: 0
|
|
333
368
|
};
|
|
334
369
|
for (const run of runs) {
|
|
335
|
-
const cost =
|
|
370
|
+
const cost = run.costProvenance;
|
|
336
371
|
if (cost.kind === "uncaptured") {
|
|
337
372
|
summary.uncaptured.n += 1;
|
|
338
373
|
} else {
|
|
@@ -347,30 +382,15 @@ function summarizeCostProvenance(runs) {
|
|
|
347
382
|
function diagnoseCostCoverage(runs, provenance) {
|
|
348
383
|
const uncaptured = provenance.uncaptured.n;
|
|
349
384
|
const known = provenance.observed.n + provenance.estimated.n;
|
|
350
|
-
const explicitUncaptured = runs.some((run) => run.costProvenance?.kind === "uncaptured");
|
|
351
|
-
if (uncaptured === runs.length && !explicitUncaptured) return diagnoseZeroCost(runs);
|
|
352
385
|
if (uncaptured === runs.length) {
|
|
353
386
|
return `USD cost uncaptured for all ${runs.length} runs \u2014 no observed or estimated USD values; token and wall-time metrics remain available.`;
|
|
354
387
|
}
|
|
355
388
|
return `USD cost uncaptured for ${uncaptured}/${runs.length} runs; excluded those rows from cost statistics (${known}/${runs.length} retained: ${provenance.observed.n} observed, ${provenance.estimated.n} estimated).`;
|
|
356
389
|
}
|
|
357
|
-
function
|
|
358
|
-
const integrity = summarizeBackendIntegrity(runs);
|
|
359
|
-
const { totalRecords, stubRecords, uncostedRecords } = integrity;
|
|
360
|
-
if (totalRecords > 0 && stubRecords === totalRecords) {
|
|
361
|
-
return `no costUsd values recorded \u2014 all ${totalRecords} records are stub-mode (zero token usage). The backend never reported real LLM activity, so cost cannot be computed; verify the backend actually ran before trusting this corpus.`;
|
|
362
|
-
}
|
|
363
|
-
if (uncostedRecords > 0) {
|
|
364
|
-
return `no costUsd values recorded \u2014 ${uncostedRecords}/${totalRecords} records have token usage but $0 cost (unpriced model). Check isModelPriced(model) for the run's model id and add it to FAMILY_PRICING.`;
|
|
365
|
-
}
|
|
366
|
-
if (stubRecords > 0) {
|
|
367
|
-
return `no costUsd values recorded \u2014 ${stubRecords}/${totalRecords} records are stub-mode (zero token usage); the remainder reported neither tokens nor cost. Cost axis carries no signal.`;
|
|
368
|
-
}
|
|
369
|
-
return "no costUsd values recorded \u2014 cost axis carries no signal";
|
|
370
|
-
}
|
|
371
|
-
function computeFailureModes(runs) {
|
|
390
|
+
function computeFailureModes(runs, split) {
|
|
372
391
|
const counts = /* @__PURE__ */ new Map();
|
|
373
392
|
for (const r of runs) {
|
|
393
|
+
if (!isTaskFailure(r, split)) continue;
|
|
374
394
|
const key = r.failureClass ?? r.failureMode;
|
|
375
395
|
if (key) counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
376
396
|
}
|
|
@@ -434,7 +454,10 @@ function computePriorPeriodComparison(current, baseline, split, windowLabel) {
|
|
|
434
454
|
};
|
|
435
455
|
}
|
|
436
456
|
function knownCostValues(runs) {
|
|
437
|
-
return runs.filter((run) =>
|
|
457
|
+
return runs.filter((run) => run.costProvenance.kind !== "uncaptured").map((run) => run.costUsd).filter(isFiniteNumber);
|
|
458
|
+
}
|
|
459
|
+
function isFiniteNumber(value) {
|
|
460
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
438
461
|
}
|
|
439
462
|
function collectPerDimension(runs) {
|
|
440
463
|
const out = {};
|
|
@@ -465,15 +488,15 @@ function welchCompare(baseline, current) {
|
|
|
465
488
|
const pooledStddev = Math.sqrt(
|
|
466
489
|
((baselineN - 1) * baselineVar + (currentN - 1) * currentVar) / Math.max(1, baselineN + currentN - 2)
|
|
467
490
|
);
|
|
468
|
-
const
|
|
469
|
-
const significant = pValue < 0.05 && Math.abs(
|
|
491
|
+
const cohensD = pooledStddev > 0 ? delta / pooledStddev : 0;
|
|
492
|
+
const significant = pValue < 0.05 && Math.abs(cohensD) >= 0.2;
|
|
470
493
|
return {
|
|
471
494
|
current: currentMean,
|
|
472
495
|
baseline: baselineMean,
|
|
473
496
|
delta,
|
|
474
497
|
ci95,
|
|
475
498
|
pValue,
|
|
476
|
-
cohensD
|
|
499
|
+
cohensD,
|
|
477
500
|
baselineN,
|
|
478
501
|
currentN,
|
|
479
502
|
significant
|
|
@@ -504,21 +527,19 @@ function resolveSplit(runs, pref) {
|
|
|
504
527
|
return hasHoldout ? "holdout" : "search";
|
|
505
528
|
}
|
|
506
529
|
function compositeOf(run, split) {
|
|
507
|
-
const
|
|
508
|
-
|
|
509
|
-
const alt = split === "holdout" ? run.outcome.searchScore : run.outcome.holdoutScore;
|
|
510
|
-
return Number.isFinite(alt) ? alt : Number.NaN;
|
|
530
|
+
const score = split === "holdout" ? run.outcome.holdoutScore : run.outcome.searchScore;
|
|
531
|
+
return Number.isFinite(score) ? score : Number.NaN;
|
|
511
532
|
}
|
|
512
533
|
function distributionOf(values, bins, withIds) {
|
|
513
534
|
if (values.length === 0) {
|
|
514
535
|
return {
|
|
515
536
|
n: 0,
|
|
516
|
-
mean:
|
|
517
|
-
p50:
|
|
518
|
-
p95:
|
|
519
|
-
stddev:
|
|
520
|
-
min:
|
|
521
|
-
max:
|
|
537
|
+
mean: null,
|
|
538
|
+
p50: null,
|
|
539
|
+
p95: null,
|
|
540
|
+
stddev: null,
|
|
541
|
+
min: null,
|
|
542
|
+
max: null,
|
|
522
543
|
histogram: []
|
|
523
544
|
};
|
|
524
545
|
}
|
|
@@ -677,41 +698,28 @@ function computeLift(runs, baselineId, candidateId, split) {
|
|
|
677
698
|
const ids = [...new Set(runs.map((r) => r.candidateId))];
|
|
678
699
|
if (ids.length !== 2) return void 0;
|
|
679
700
|
const [idA, idB] = ids;
|
|
680
|
-
const
|
|
681
|
-
|
|
701
|
+
const scoresA = finiteCompositeScores(
|
|
702
|
+
runs.filter((run) => run.candidateId === idA),
|
|
703
|
+
split
|
|
704
|
+
);
|
|
705
|
+
const scoresB = finiteCompositeScores(
|
|
706
|
+
runs.filter((run) => run.candidateId === idB),
|
|
707
|
+
split
|
|
708
|
+
);
|
|
709
|
+
if (scoresA.length === 0 || scoresB.length === 0) return void 0;
|
|
710
|
+
const meanA = mean(scoresA);
|
|
711
|
+
const meanB = mean(scoresB);
|
|
682
712
|
bId = meanA <= meanB ? idA : idB;
|
|
683
713
|
cId = meanA <= meanB ? idB : idA;
|
|
684
714
|
}
|
|
685
715
|
const baseline = runs.filter((r) => r.candidateId === bId);
|
|
686
716
|
const candidate = runs.filter((r) => r.candidateId === cId);
|
|
687
717
|
if (baseline.length === 0 || candidate.length === 0) return void 0;
|
|
688
|
-
const
|
|
689
|
-
const
|
|
690
|
-
const
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
const b = baselineByKey.get(pairingKey(cand));
|
|
694
|
-
if (b) {
|
|
695
|
-
const bC = compositeOf(b, split);
|
|
696
|
-
const cC = compositeOf(cand, split);
|
|
697
|
-
if (Number.isFinite(bC) && Number.isFinite(cC)) {
|
|
698
|
-
pairedBaseline.push(bC);
|
|
699
|
-
pairedCandidate.push(cC);
|
|
700
|
-
usedKeyPairing = true;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
if (!usedKeyPairing) {
|
|
705
|
-
const n = Math.min(baseline.length, candidate.length);
|
|
706
|
-
for (let i = 0; i < n; i++) {
|
|
707
|
-
const bC = compositeOf(baseline[i], split);
|
|
708
|
-
const cC = compositeOf(candidate[i], split);
|
|
709
|
-
if (Number.isFinite(bC) && Number.isFinite(cC)) {
|
|
710
|
-
pairedBaseline.push(bC);
|
|
711
|
-
pairedCandidate.push(cC);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
}
|
|
718
|
+
const scoredBaseline = baseline.filter((run) => Number.isFinite(compositeOf(run, split)));
|
|
719
|
+
const scoredCandidate = candidate.filter((run) => Number.isFinite(compositeOf(run, split)));
|
|
720
|
+
const pairing = pairRunRecords(scoredBaseline, scoredCandidate);
|
|
721
|
+
const pairedBaseline = pairing.pairs.map((pair) => compositeOf(pair.baseline, split));
|
|
722
|
+
const pairedCandidate = pairing.pairs.map((pair) => compositeOf(pair.treatment, split));
|
|
715
723
|
if (pairedBaseline.length === 0) return void 0;
|
|
716
724
|
const baselineMean = mean(pairedBaseline);
|
|
717
725
|
const candidateMean = mean(pairedCandidate);
|
|
@@ -722,10 +730,10 @@ function computeLift(runs, baselineId, candidateId, split) {
|
|
|
722
730
|
statistic: "mean"
|
|
723
731
|
});
|
|
724
732
|
const tTest = pairedTTest(pairedBaseline, pairedCandidate);
|
|
725
|
-
const d =
|
|
733
|
+
const d = pairedCohensDz(pairedBaseline, pairedCandidate);
|
|
726
734
|
const mde = pairedMde({ nPaired: pairedBaseline.length, power: 0.8, alpha: 0.05 });
|
|
727
|
-
const requiredN =
|
|
728
|
-
effect: Math.
|
|
735
|
+
const requiredN = d === null || d === 0 ? null : requiredPairedSampleSize({
|
|
736
|
+
effect: Math.abs(d),
|
|
729
737
|
power: 0.8,
|
|
730
738
|
alpha: 0.05
|
|
731
739
|
});
|
|
@@ -736,19 +744,18 @@ function computeLift(runs, baselineId, candidateId, split) {
|
|
|
736
744
|
ci95: [bootstrap.low, bootstrap.high],
|
|
737
745
|
pValue: tTest.p,
|
|
738
746
|
n: pairedBaseline.length,
|
|
747
|
+
unpairedBaseline: pairing.unpairedBaseline.length,
|
|
748
|
+
unpairedCandidate: pairing.unpairedTreatment.length,
|
|
739
749
|
cohensD: d,
|
|
740
750
|
mde,
|
|
741
751
|
requiredN
|
|
742
752
|
};
|
|
743
753
|
}
|
|
744
|
-
function pairingKey(r) {
|
|
745
|
-
return `${r.experimentId}::${r.seed}`;
|
|
746
|
-
}
|
|
747
754
|
function mean(arr) {
|
|
748
755
|
return arr.length === 0 ? 0 : arr.reduce((s, v) => s + v, 0) / arr.length;
|
|
749
756
|
}
|
|
750
757
|
async function computeFailureClusters(runs, analyst, split) {
|
|
751
|
-
const failed = runs.filter((
|
|
758
|
+
const failed = runs.filter((run) => isTaskFailure(run, split));
|
|
752
759
|
if (failed.length === 0) return { clusters: [], totalFailures: 0 };
|
|
753
760
|
const clusters = /* @__PURE__ */ new Map();
|
|
754
761
|
for (const run of failed) {
|
|
@@ -775,6 +782,13 @@ async function computeFailureClusters(runs, analyst, split) {
|
|
|
775
782
|
clusterList.sort((a, b) => b.share - a.share);
|
|
776
783
|
return { clusters: clusterList, totalFailures: failed.length };
|
|
777
784
|
}
|
|
785
|
+
function finiteCompositeScores(runs, split) {
|
|
786
|
+
return runs.map((run) => compositeOf(run, split)).filter(Number.isFinite);
|
|
787
|
+
}
|
|
788
|
+
function isTaskFailure(run, split) {
|
|
789
|
+
const score = compositeOf(run, split);
|
|
790
|
+
return Number.isFinite(score) && score < 0.5;
|
|
791
|
+
}
|
|
778
792
|
function computeContamination(runs, canaries) {
|
|
779
793
|
let leaks = 0;
|
|
780
794
|
const details = [];
|
|
@@ -832,24 +846,30 @@ function computeOutcomeCorrelation(runs, outcome, split) {
|
|
|
832
846
|
}
|
|
833
847
|
function buildReleaseScorecard(composite, lift, contamination) {
|
|
834
848
|
const axes = [];
|
|
835
|
-
const liftPass = lift === void 0
|
|
849
|
+
const liftPass = lift === void 0 ? "not_evaluated" : lift.ci95[0] > 0 ? "pass" : lift.delta > 0 ? "warn" : "fail";
|
|
836
850
|
axes.push({
|
|
837
851
|
name: "quality-lift",
|
|
838
852
|
status: liftPass,
|
|
839
853
|
detail: lift ? `delta=${lift.delta.toFixed(3)}, CI95=[${lift.ci95[0].toFixed(3)}, ${lift.ci95[1].toFixed(3)}], n=${lift.n}` : "no baseline/candidate pair available"
|
|
840
854
|
});
|
|
841
|
-
const contamPass = contamination === void 0
|
|
855
|
+
const contamPass = contamination === void 0 ? "not_evaluated" : contamination.leaks === 0 ? "pass" : "fail";
|
|
842
856
|
axes.push({
|
|
843
857
|
name: "contamination",
|
|
844
858
|
status: contamPass,
|
|
845
859
|
detail: contamination ? `${contamination.leaks} canary leak(s)` : "no canaries supplied"
|
|
846
860
|
});
|
|
847
|
-
axes.push(
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
861
|
+
axes.push(
|
|
862
|
+
composite.n === 0 ? {
|
|
863
|
+
name: "composite-distribution",
|
|
864
|
+
status: "not_evaluated",
|
|
865
|
+
detail: "no task-quality scores available"
|
|
866
|
+
} : {
|
|
867
|
+
name: "composite-distribution",
|
|
868
|
+
status: composite.mean !== null && composite.mean >= 0.5 ? "pass" : composite.mean !== null && composite.mean >= 0.3 ? "warn" : "fail",
|
|
869
|
+
detail: composite.mean === null || composite.p50 === null || composite.p95 === null ? "task-quality distribution is internally incomplete" : `mean=${composite.mean.toFixed(3)}, p50=${composite.p50.toFixed(3)}, p95=${composite.p95.toFixed(3)} over n=${composite.n}`
|
|
870
|
+
}
|
|
871
|
+
);
|
|
872
|
+
const status = axes.some((a) => a.status === "fail") ? "fail" : axes.some((a) => a.status === "warn" || a.status === "not_evaluated") ? "warn" : "pass";
|
|
853
873
|
return {
|
|
854
874
|
status,
|
|
855
875
|
axes,
|
|
@@ -884,7 +904,7 @@ function buildRecommendations(ctx) {
|
|
|
884
904
|
});
|
|
885
905
|
}
|
|
886
906
|
}
|
|
887
|
-
if (ctx.composite.n > 0) {
|
|
907
|
+
if (ctx.composite.n > 0 && ctx.composite.mean !== null && ctx.composite.p50 !== null && ctx.composite.p95 !== null) {
|
|
888
908
|
if (ctx.composite.mean < 0.3) {
|
|
889
909
|
const tail = ctx.composite.tailRuns ?? [];
|
|
890
910
|
const names = tail.slice(0, 5).map((t) => `${t.runId}=${t.score.toFixed(3)}`).join(", ");
|
|
@@ -929,6 +949,8 @@ function buildRecommendations(ctx) {
|
|
|
929
949
|
});
|
|
930
950
|
}
|
|
931
951
|
if (ctx.lift) {
|
|
952
|
+
const pairedEffect = ctx.lift.cohensD === null ? "undefined (zero delta variance)" : ctx.lift.cohensD.toFixed(2);
|
|
953
|
+
const requiredRuns = ctx.lift.requiredN === null ? "not estimable" : `~${ctx.lift.requiredN} paired runs`;
|
|
932
954
|
const decisive = ctx.lift.ci95[0] > ctx.threshold;
|
|
933
955
|
const inconclusive = ctx.lift.ci95[0] <= ctx.threshold && ctx.lift.ci95[1] > ctx.threshold;
|
|
934
956
|
if (decisive) {
|
|
@@ -936,14 +958,14 @@ function buildRecommendations(ctx) {
|
|
|
936
958
|
priority: "critical",
|
|
937
959
|
kind: "ship",
|
|
938
960
|
title: `Ship \u2014 lift ${ctx.lift.delta.toFixed(3)} (95% CI ${ctx.lift.ci95[0].toFixed(3)}..${ctx.lift.ci95[1].toFixed(3)})`,
|
|
939
|
-
detail: `Holdout lift exceeds threshold ${ctx.threshold} with 95% bootstrap confidence (n=${ctx.lift.n}, p=${ctx.lift.pValue.toFixed(4)}, d=${
|
|
961
|
+
detail: `Holdout lift exceeds threshold ${ctx.threshold} with 95% bootstrap confidence (n=${ctx.lift.n}, p=${ctx.lift.pValue.toFixed(4)}, paired d=${pairedEffect}).`,
|
|
940
962
|
evidencePath: "lift"
|
|
941
963
|
});
|
|
942
964
|
} else if (inconclusive) {
|
|
943
965
|
out.push({
|
|
944
966
|
priority: "high",
|
|
945
967
|
kind: "expand-corpus",
|
|
946
|
-
title: `Inconclusive \u2014
|
|
968
|
+
title: `Inconclusive \u2014 required sample is ${requiredRuns} (have ${ctx.lift.n}) at current effect size`,
|
|
947
969
|
detail: `CI straddles threshold. Current MDE at 80% power is ${ctx.lift.mde.toFixed(3)}; observed delta is ${ctx.lift.delta.toFixed(3)}.`,
|
|
948
970
|
evidencePath: "lift"
|
|
949
971
|
});
|
|
@@ -1006,4 +1028,4 @@ export {
|
|
|
1006
1028
|
summarizeExecution,
|
|
1007
1029
|
analyzeRuns
|
|
1008
1030
|
};
|
|
1009
|
-
//# sourceMappingURL=chunk-
|
|
1031
|
+
//# sourceMappingURL=chunk-FA3MFYNA.js.map
|