@tangle-network/agent-eval 0.179.0 → 0.181.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 +66 -0
- package/README.md +119 -146
- package/dist/adapters/http.d.ts +2 -2
- package/dist/{agent-profile-B7yErX0q.d.ts → agent-profile-CivaSsSy.d.ts} +4 -4
- package/dist/{agent-profile-B7yErX0q.d.ts.map → agent-profile-CivaSsSy.d.ts.map} +1 -1
- package/dist/{agent-profile-cell-0gSi5ffD.js → agent-profile-cell-Cv6UA-W_.js} +20 -57
- package/dist/agent-profile-cell-Cv6UA-W_.js.map +1 -0
- package/dist/{agent-profile-cell-CTOZJUuE.d.ts → agent-profile-cell-s__adRnK.d.ts} +3 -3
- package/dist/agent-profile-cell-s__adRnK.d.ts.map +1 -0
- package/dist/analyst/index.d.ts +10 -10
- package/dist/analyst/index.js +4 -4
- package/dist/ast-CP9ae9B0.js +557 -0
- package/dist/ast-CP9ae9B0.js.map +1 -0
- package/dist/ast-hI-vjW6J.d.ts +457 -0
- package/dist/ast-hI-vjW6J.d.ts.map +1 -0
- package/dist/{benchmark-command-CY6Dg5t5.js → benchmark-command-B57n9vjz.js} +7 -6
- package/dist/{benchmark-command-CY6Dg5t5.js.map → benchmark-command-B57n9vjz.js.map} +1 -1
- package/dist/benchmarks/index.d.ts +4 -4
- package/dist/benchmarks/index.js +3 -3
- package/dist/campaign/index.d.ts +6 -6
- package/dist/campaign/index.js +8 -8
- package/dist/{campaign-BGEurASO.js → campaign-4_ppJW5X.js} +12 -12
- package/dist/{campaign-BGEurASO.js.map → campaign-4_ppJW5X.js.map} +1 -1
- package/dist/{campaign-evidence-D8DBLqLI.js → campaign-evidence-B8oF9xQ6.js} +515 -471
- package/dist/campaign-evidence-B8oF9xQ6.js.map +1 -0
- package/dist/cli.js +5 -8
- package/dist/cli.js.map +1 -1
- package/dist/{client-BlLY6o2w.js → client-CXE-U1SA.js} +3 -1
- package/dist/client-CXE-U1SA.js.map +1 -0
- package/dist/{client-CuQgX33c.d.ts → client-kh2jOjTK.d.ts} +4 -4
- package/dist/{client-CuQgX33c.d.ts.map → client-kh2jOjTK.d.ts.map} +1 -1
- package/dist/contract/index.d.ts +13 -13
- package/dist/contract/index.js +11 -10
- package/dist/contract/index.js.map +1 -1
- package/dist/{default-registry-IGDE9XIC.d.ts → default-registry-BwDSWVzg.d.ts} +6 -6
- package/dist/{default-registry-IGDE9XIC.d.ts.map → default-registry-BwDSWVzg.d.ts.map} +1 -1
- package/dist/{default-registry-BryMEmr8.js → default-registry-aL7xUrUz.js} +2 -2
- package/dist/{default-registry-BryMEmr8.js.map → default-registry-aL7xUrUz.js.map} +1 -1
- package/dist/{define-agent-eval-Cx4Ls9ta.d.ts → define-agent-eval-CwOWWQt_.d.ts} +33 -12
- package/dist/define-agent-eval-CwOWWQt_.d.ts.map +1 -0
- package/dist/{define-agent-eval-Dzidv34q.js → define-agent-eval-Ddu33JH9.js} +134 -67
- package/dist/define-agent-eval-Ddu33JH9.js.map +1 -0
- package/dist/{dspy-rlm-engine-xKiWmj_G.js → dspy-rlm-engine-S53V0HhE.js} +2 -2
- package/dist/{dspy-rlm-engine-xKiWmj_G.js.map → dspy-rlm-engine-S53V0HhE.js.map} +1 -1
- package/dist/{engine-CX8ReXkn.d.ts → engine-DS1cysJy.d.ts} +10 -7
- package/dist/engine-DS1cysJy.d.ts.map +1 -0
- package/dist/{eval-campaign-Cs-7MiCs.js → eval-campaign-aYdtjtJR.js} +4 -4
- package/dist/{eval-campaign-Cs-7MiCs.js.map → eval-campaign-aYdtjtJR.js.map} +1 -1
- package/dist/{exact-types-B7LC1EyX.d.ts → exact-types-BZDe0W2D.d.ts} +2 -2
- package/dist/{exact-types-B7LC1EyX.d.ts.map → exact-types-BZDe0W2D.d.ts.map} +1 -1
- package/dist/experiment/index.d.ts +27 -477
- package/dist/experiment/index.d.ts.map +1 -1
- package/dist/experiment/index.js +95 -559
- package/dist/experiment/index.js.map +1 -1
- package/dist/{experiment-tracker-B3TiF5-u.d.ts → experiment-tracker-C7PfnF4b.d.ts} +2 -2
- package/dist/{experiment-tracker-B3TiF5-u.d.ts.map → experiment-tracker-C7PfnF4b.d.ts.map} +1 -1
- package/dist/{external-optimizer-process-Dlz8YxrT.js → external-optimizer-process-QDRURJAM.js} +3 -3
- package/dist/{external-optimizer-process-Dlz8YxrT.js.map → external-optimizer-process-QDRURJAM.js.map} +1 -1
- package/dist/{external-optimizer-subprocess-q3VzlGAO.js → external-optimizer-subprocess-D4dzUBZI.js} +3 -2
- package/dist/{external-optimizer-subprocess-q3VzlGAO.js.map → external-optimizer-subprocess-D4dzUBZI.js.map} +1 -1
- package/dist/{feedback-trajectory-eHWNv5Aj.d.ts → feedback-trajectory-CXmtITBo.d.ts} +3 -3
- package/dist/{feedback-trajectory-eHWNv5Aj.d.ts.map → feedback-trajectory-CXmtITBo.d.ts.map} +1 -1
- package/dist/hosted/index.d.ts +2 -2
- package/dist/hosted/index.d.ts.map +1 -1
- package/dist/hosted/index.js +1 -1
- package/dist/{index-BxWvILU8.d.ts → index-Bp_6sj3x.d.ts} +109 -56
- package/dist/index-Bp_6sj3x.d.ts.map +1 -0
- package/dist/{index-e7LXeRVa.d.ts → index-CJ3LhKIX.d.ts} +2 -2
- package/dist/{index-e7LXeRVa.d.ts.map → index-CJ3LhKIX.d.ts.map} +1 -1
- package/dist/{index-CbLmrWCa.d.ts → index-DNntP4ch.d.ts} +8 -8
- package/dist/{index-CbLmrWCa.d.ts.map → index-DNntP4ch.d.ts.map} +1 -1
- package/dist/{index-DxNYmx4a.d.ts → index-DoykkxW0.d.ts} +11 -11
- package/dist/{index-DxNYmx4a.d.ts.map → index-DoykkxW0.d.ts.map} +1 -1
- package/dist/index.d.ts +28 -28
- package/dist/index.js +25 -16
- package/dist/index.js.map +1 -1
- package/dist/{insight-report-DETqPc_A.d.ts → insight-report-D1qa0HWs.d.ts} +9 -5
- package/dist/{insight-report-DETqPc_A.d.ts.map → insight-report-D1qa0HWs.d.ts.map} +1 -1
- package/dist/{integrity-DsHWCebQ.js → integrity-DH5ng72x.js} +2 -2
- package/dist/{integrity-DsHWCebQ.js.map → integrity-DH5ng72x.js.map} +1 -1
- package/dist/{integrity-BKTcA-HP.d.ts → integrity-rGOfSUle.d.ts} +2 -2
- package/dist/{integrity-BKTcA-HP.d.ts.map → integrity-rGOfSUle.d.ts.map} +1 -1
- package/dist/{ledger-core-Cs9f7385.js → journal-Cs9f7385.js} +1 -1
- package/dist/journal-Cs9f7385.js.map +1 -0
- package/dist/{judge-calibration-C5CbMYce.d.ts → judge-calibration-DFtEMlde.d.ts} +31 -2
- package/dist/judge-calibration-DFtEMlde.d.ts.map +1 -0
- package/dist/{judge-calibration-BnpVKtnb.js → judge-calibration-DYmaBtJr.js} +48 -2
- package/dist/{judge-calibration-BnpVKtnb.js.map → judge-calibration-DYmaBtJr.js.map} +1 -1
- package/dist/ledger-core/index.d.ts +1 -1
- package/dist/ledger-core/index.js +1 -1
- package/dist/{llm-judge-v80Kmu9g.js → llm-judge-DEFZeSiu.js} +645 -456
- package/dist/llm-judge-DEFZeSiu.js.map +1 -0
- package/dist/{matrix-DeMmnWrP.d.ts → matrix-CyhW-vgJ.d.ts} +2 -2
- package/dist/{matrix-DeMmnWrP.d.ts.map → matrix-CyhW-vgJ.d.ts.map} +1 -1
- package/dist/meta-eval/index.d.ts +138 -7
- package/dist/meta-eval/index.d.ts.map +1 -1
- package/dist/meta-eval/index.js +245 -97
- package/dist/meta-eval/index.js.map +1 -1
- package/dist/{mint-Cc1_zwRQ.js → mint-ySIIkKlV.js} +2 -2
- package/dist/{mint-Cc1_zwRQ.js.map → mint-ySIIkKlV.js.map} +1 -1
- package/dist/multishot/golden/index.d.ts +1 -1
- package/dist/multishot/index.d.ts +2 -2
- package/dist/openapi.json +1 -1
- package/dist/outcome-store-BXlkwMPR.js +131 -0
- package/dist/outcome-store-BXlkwMPR.js.map +1 -0
- package/dist/{outcome-store-BYHIuO0e.d.ts → outcome-store-CNt4iZ67.d.ts} +18 -25
- package/dist/outcome-store-CNt4iZ67.d.ts.map +1 -0
- package/dist/{paired-promotion-decision-CGzg0cI_.d.ts → paired-promotion-decision-DPsMQm-0.d.ts} +13 -7
- package/dist/{paired-promotion-decision-CGzg0cI_.d.ts.map → paired-promotion-decision-DPsMQm-0.d.ts.map} +1 -1
- package/dist/pipelines/index.js +1 -1
- package/dist/{produced-state-Cv0kJJuP.js → produced-state-BHboMaab.js} +3 -3
- package/dist/{produced-state-Cv0kJJuP.js.map → produced-state-BHboMaab.js.map} +1 -1
- package/dist/profile-cell.d.ts +1 -1
- package/dist/profile-cell.js +1 -1
- package/dist/{promotion-policy-DWOm70gx.js → promotion-policy-CDMMxzb6.js} +28 -40
- package/dist/promotion-policy-CDMMxzb6.js.map +1 -0
- package/dist/{registry-ByVld1-5.d.ts → registry-BRbB6Y0v.d.ts} +4 -4
- package/dist/{registry-ByVld1-5.d.ts.map → registry-BRbB6Y0v.d.ts.map} +1 -1
- package/dist/{release-confidence-BAcNYOf1.d.ts → release-confidence-BcqeQTHW.d.ts} +3 -3
- package/dist/{release-confidence-BAcNYOf1.d.ts.map → release-confidence-BcqeQTHW.d.ts.map} +1 -1
- package/dist/{release-confidence-BcGCclTB.js → release-confidence-DMg8n18l.js} +2 -2
- package/dist/{release-confidence-BcGCclTB.js.map → release-confidence-DMg8n18l.js.map} +1 -1
- package/dist/{report-command-DKlXfU5r.js → report-command-V1ecVgAv.js} +27 -3
- package/dist/report-command-V1ecVgAv.js.map +1 -0
- package/dist/reporting.d.ts +4 -4
- package/dist/reporting.js +3 -3
- package/dist/{researcher-jsW1X94L.d.ts → researcher-64T49THL.d.ts} +6 -6
- package/dist/{researcher-jsW1X94L.d.ts.map → researcher-64T49THL.d.ts.map} +1 -1
- package/dist/{reward-hacking-ZXEi9VCq.d.ts → reward-hacking-uzO_ihep.d.ts} +2 -2
- package/dist/{reward-hacking-ZXEi9VCq.d.ts.map → reward-hacking-uzO_ihep.d.ts.map} +1 -1
- package/dist/rl.d.ts +53 -99
- package/dist/rl.d.ts.map +1 -1
- package/dist/rl.js +182 -169
- package/dist/rl.js.map +1 -1
- package/dist/rollout/index.d.ts +1 -1
- package/dist/rollout/index.js +2 -2
- package/dist/{rollout-DmoJVqrF.js → rollout-B-UF5R6w.js} +2 -2
- package/dist/{rollout-DmoJVqrF.js.map → rollout-B-UF5R6w.js.map} +1 -1
- package/dist/rubric-predictive-validity-Bmj2_cll.d.ts +79 -0
- package/dist/rubric-predictive-validity-Bmj2_cll.d.ts.map +1 -0
- package/dist/rubric-predictive-validity-CCK-1B7w.js +178 -0
- package/dist/rubric-predictive-validity-CCK-1B7w.js.map +1 -0
- package/dist/{run-record-DTv1MdjK.d.ts → run-record-BiTWauyO.d.ts} +2 -2
- package/dist/{run-record-DTv1MdjK.d.ts.map → run-record-BiTWauyO.d.ts.map} +1 -1
- package/dist/run-record-Br-Yzt_k.js +464 -0
- package/dist/run-record-Br-Yzt_k.js.map +1 -0
- package/dist/{run-record-DQpSf7t-.js → run-record-DualPTn2.js} +2 -2
- package/dist/{run-record-DQpSf7t-.js.map → run-record-DualPTn2.js.map} +1 -1
- package/dist/{semantic-concept-judge-Bi6_iGqg.js → semantic-concept-judge-Bm5JDEKO.js} +3 -3
- package/dist/{semantic-concept-judge-Bi6_iGqg.js.map → semantic-concept-judge-Bm5JDEKO.js.map} +1 -1
- package/dist/{sequential-B5gXgcyp.js → sequential-DAsyV2T9.js} +42 -25
- package/dist/sequential-DAsyV2T9.js.map +1 -0
- package/dist/{series-convergence-DeG33RpC.d.ts → series-convergence-BnMs_uAr.d.ts} +3 -3
- package/dist/{series-convergence-DeG33RpC.d.ts.map → series-convergence-BnMs_uAr.d.ts.map} +1 -1
- package/dist/{skillopt-optimization-method-C3oYul8v.js → skillopt-optimization-method-CL_0aArC.js} +5 -5
- package/dist/{skillopt-optimization-method-C3oYul8v.js.map → skillopt-optimization-method-CL_0aArC.js.map} +1 -1
- package/dist/{statistical-heldout-0La5ZTlv.d.ts → statistical-heldout-CpVd6FmY.d.ts} +207 -144
- package/dist/statistical-heldout-CpVd6FmY.d.ts.map +1 -0
- package/dist/{store-tool-spans-4J1EDElP.d.ts → store-tool-spans-Dt-YdAuE.d.ts} +6 -6
- package/dist/{store-tool-spans-4J1EDElP.d.ts.map → store-tool-spans-Dt-YdAuE.d.ts.map} +1 -1
- package/dist/{summary-report-gMrbYawB.d.ts → summary-report-D1h4dlrK.d.ts} +3 -3
- package/dist/{summary-report-gMrbYawB.d.ts.map → summary-report-D1h4dlrK.d.ts.map} +1 -1
- package/dist/{summary-report-B16xy9Kd.js → summary-report-e-MaOAHV.js} +2 -2
- package/dist/{summary-report-B16xy9Kd.js.map → summary-report-e-MaOAHV.js.map} +1 -1
- package/dist/supervisor-run/index.d.ts +4 -2
- package/dist/supervisor-run/index.d.ts.map +1 -1
- package/dist/supervisor-run/index.js +3 -3
- package/dist/{terminal-record-Ce9_UjRz.js → terminal-record-BtPwKTSr.js} +58 -26
- package/dist/terminal-record-BtPwKTSr.js.map +1 -0
- package/dist/{tool-groups-2QA0S7dK.d.ts → tool-groups-B2bSNaJB.d.ts} +3 -3
- package/dist/tool-groups-B2bSNaJB.d.ts.map +1 -0
- package/dist/{tool-waste-B9tdWV6g.js → tool-waste-C7MU9u1e.js} +2 -2
- package/dist/{tool-waste-B9tdWV6g.js.map → tool-waste-C7MU9u1e.js.map} +1 -1
- package/dist/trace-repair/index.d.ts +2 -2
- package/dist/traces.d.ts +6 -6
- package/dist/traces.js +1 -1
- package/dist/{types-BmlkCrg0.d.ts → types-BvZoPTGa.d.ts} +3 -3
- package/dist/{types-BmlkCrg0.d.ts.map → types-BvZoPTGa.d.ts.map} +1 -1
- package/dist/{types-gvRsyJLh.d.ts → types-CBbLtr2J.d.ts} +38 -3
- package/dist/{types-gvRsyJLh.d.ts.map → types-CBbLtr2J.d.ts.map} +1 -1
- package/dist/{types-C34V4Vto.d.ts → types-CS0qk_Yp.d.ts} +4 -4
- package/dist/{types-C34V4Vto.d.ts.map → types-CS0qk_Yp.d.ts.map} +1 -1
- package/dist/{types-DzuaM493.d.ts → types-D7gEdPoQ.d.ts} +3 -3
- package/dist/{types-DzuaM493.d.ts.map → types-D7gEdPoQ.d.ts.map} +1 -1
- package/dist/{types-vUdAx2Cj.d.ts → types-lPkDQNqJ.d.ts} +20 -2
- package/dist/{types-vUdAx2Cj.d.ts.map → types-lPkDQNqJ.d.ts.map} +1 -1
- package/dist/wire/index.d.ts +2 -2
- package/docs/adapters-observability.md +14 -0
- package/docs/campaign-proposers.md +86 -128
- package/docs/charter.md +108 -112
- package/docs/concepts.md +157 -69
- package/docs/design/mlbenchmarks-book-review.md +440 -0
- package/docs/design/mlbenchmarks-review/observations.json +713 -0
- package/docs/design/mlbenchmarks-review/probes.mts +476 -0
- package/docs/design/mlbenchmarks-review/sources.json +200 -0
- package/docs/design/self-improvement-evidence-audit.md +263 -0
- package/docs/design.md +2 -1
- package/docs/eval-surface-map.md +95 -42
- package/docs/evaluation-integrity.md +220 -0
- package/docs/experiment.md +111 -55
- package/docs/feature-guide.md +5 -6
- package/docs/hosted-ingest-spec.md +4 -11
- package/docs/insight-report.md +187 -455
- package/docs/outcome-validity.md +182 -0
- package/docs/product-eval-adoption.md +1 -2
- package/docs/research-report-methodology.md +7 -7
- package/docs/search-history-receipts.md +8 -0
- package/docs/statistical-evidence.md +129 -0
- package/docs/verdicts.md +76 -49
- package/package.json +1 -1
- package/dist/agent-profile-cell-0gSi5ffD.js.map +0 -1
- package/dist/agent-profile-cell-CTOZJUuE.d.ts.map +0 -1
- package/dist/campaign-evidence-D8DBLqLI.js.map +0 -1
- package/dist/client-BlLY6o2w.js.map +0 -1
- package/dist/define-agent-eval-Cx4Ls9ta.d.ts.map +0 -1
- package/dist/define-agent-eval-Dzidv34q.js.map +0 -1
- package/dist/engine-CX8ReXkn.d.ts.map +0 -1
- package/dist/index-BxWvILU8.d.ts.map +0 -1
- package/dist/judge-calibration-C5CbMYce.d.ts.map +0 -1
- package/dist/ledger-core-Cs9f7385.js.map +0 -1
- package/dist/llm-judge-v80Kmu9g.js.map +0 -1
- package/dist/outcome-store-BYHIuO0e.d.ts.map +0 -1
- package/dist/outcome-store-ChBKlTd_.js +0 -75
- package/dist/outcome-store-ChBKlTd_.js.map +0 -1
- package/dist/promotion-policy-DWOm70gx.js.map +0 -1
- package/dist/report-command-DKlXfU5r.js.map +0 -1
- package/dist/rubric-predictive-validity-2D5Gw9z9.js +0 -131
- package/dist/rubric-predictive-validity-2D5Gw9z9.js.map +0 -1
- package/dist/rubric-predictive-validity-Dl1dvKCv.d.ts +0 -75
- package/dist/rubric-predictive-validity-Dl1dvKCv.d.ts.map +0 -1
- package/dist/run-record-CR63CpHK.js +0 -216
- package/dist/run-record-CR63CpHK.js.map +0 -1
- package/dist/sequential-B5gXgcyp.js.map +0 -1
- package/dist/statistical-heldout-0La5ZTlv.d.ts.map +0 -1
- package/dist/terminal-record-Ce9_UjRz.js.map +0 -1
- package/dist/tool-groups-2QA0S7dK.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-CP9ae9B0.js","names":[],"sources":["../src/experiment/ast.ts"],"sourcesContent":["/**\n * The registered-rule AST: every rule an experiment registers is DATA.\n *\n * A closure cannot be canonicalized or hashed; a node tree can. `sealExperiment`\n * hashes the whole tree, and every interpreter in this file takes only a node\n * plus evidence records — no parameter for alpha, threshold, metric, or\n * stopping rule exists on any executable surface. The registered object and\n * the executed object are therefore the same object, and registered-vs-ran\n * drift is unrepresentable rather than checked.\n *\n * Node families:\n * Predicate closed-key comparisons — the only leaf\n * AdmissionRule monotone funnel stages with registered waivers\n * SelectionRule deterministic subsets over a closed field set\n * Estimand what the experiment measures\n * IntervalSpec how uncertainty is computed, seed included\n * Condition decision guards over named derived quantities\n * DecisionRule ordered verdict table, or a registered absence of one\n * Obligation a control that must exist before a verdict class is read\n * ValidityGate pre-spend design checks\n * HaltRule gates as prerequisites — failure refuses the spend\n * BudgetRule spend schedules with a named ledger\n * MatchedBudgetRule arm budget matching as a refusal\n * ReissuePolicy carrier faults are reissued; model outcomes stand\n */\n\nimport { ValidationError } from '../errors'\nimport { mulberry32 } from '../statistics'\n\n/** JSON-serializable value — everything a sealed node may carry. */\nexport type JsonValue = string | number | boolean | null | JsonValue[] | { [k: string]: JsonValue }\n\n/** Evidence row shape. Fields are addressed by dot-separated paths. */\nexport type EvidenceRecord = Record<string, unknown>\n\n/** A decision rule's branches did not cover the evidence. */\nclass DecisionTableNotTotalError extends ValidationError {}\n\n// ── Predicate ────────────────────────────────────────────────────────\n\n/**\n * Closed-key comparison over a declared record schema. The only leaf node.\n * `field` is a dot-separated path into an evidence record.\n */\nexport type Predicate =\n | {\n kind: 'compare'\n field: string\n op: 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte'\n value: JsonValue\n }\n | { kind: 'in'; field: string; values: JsonValue[] }\n | { kind: 'all'; of: Predicate[] }\n | { kind: 'any'; of: Predicate[] }\n | { kind: 'not'; of: Predicate }\n\n/** Read a dot-separated field path. Missing segments yield `undefined`. */\nexport function readField(record: EvidenceRecord, path: string): unknown {\n let current: unknown = record\n for (const key of path.split('.')) {\n if (current === null || typeof current !== 'object') return undefined\n current = (current as Record<string, unknown>)[key]\n }\n return current\n}\n\n/** Evaluate a predicate against one evidence record. */\nexport function evaluatePredicate(predicate: Predicate, record: EvidenceRecord): boolean {\n switch (predicate.kind) {\n case 'compare':\n return compareValues(readField(record, predicate.field), predicate.op, predicate.value)\n case 'in':\n return predicate.values.includes(readField(record, predicate.field) as JsonValue)\n case 'all':\n return predicate.of.every((p) => evaluatePredicate(p, record))\n case 'any':\n return predicate.of.some((p) => evaluatePredicate(p, record))\n case 'not':\n return !evaluatePredicate(predicate.of, record)\n }\n}\n\n/** Numbers compare numerically; everything else compares as strings. */\nfunction compareValues(\n value: unknown,\n op: 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte',\n target: JsonValue,\n): boolean {\n if (op === 'eq') return value === target\n if (op === 'ne') return value !== target\n const numeric = typeof value === 'number' && typeof target === 'number'\n const left = numeric ? (value as number) : String(value)\n const right = numeric ? (target as number) : String(target)\n switch (op) {\n case 'lt':\n return left < right\n case 'lte':\n return left <= right\n case 'gt':\n return left > right\n case 'gte':\n return left >= right\n }\n}\n\n// ── Admission ────────────────────────────────────────────────────────\n\n/**\n * One monotone funnel stage. `waives` names substrate admission conditions\n * deliberately NOT applied, so a waiver is registered, never implicit.\n */\nexport interface AdmissionStage {\n id: string\n keep: Predicate\n waives?: string[]\n}\n\n/** A partition is a set reported separately and never pooled. */\nexport interface AdmissionPartition {\n id: string\n /** Stage whose dropped rows this partition draws from. */\n from: string\n keep: Predicate\n pooling: 'never'\n}\n\n/** Declarative row-admission funnel. Stages only remove rows. */\nexport interface AdmissionRule {\n population: string\n stages: AdmissionStage[]\n partitions?: AdmissionPartition[]\n}\n\n// ── Selection ────────────────────────────────────────────────────────\n\n/**\n * Deterministic subset selection. `reads` is the closed field set the rule\n * may touch — outcome-contaminated selection is unrepresentable because an\n * outcome field is simply not in the list.\n */\nexport type SelectionRule =\n | {\n kind: 'round-robin'\n groupBy: string\n groupOrder: 'lex-asc'\n withinOrder: { field: string; dir: 'asc' | 'desc' }\n take: number\n reads: string[]\n }\n | {\n kind: 'filter-of'\n /** Name of the sealed subset or selection this rule filters. */\n base: string\n keep: Predicate\n order: { field: string; dir: 'asc' | 'desc' }\n }\n\n/**\n * Execute a selection rule.\n *\n * Round-robin walks groups in lexicographic order and takes ids in\n * within-group order until `take` ids are chosen. Filter-of keeps the ids of\n * `bases[rule.base]` whose record satisfies the predicate, in the registered\n * order. Ids absent from `records` are evaluated on their id alone (fields\n * derived from the id via `idFields`), so a sealed base outlives its source\n * records.\n */\nexport function runSelectionRule(\n rule: SelectionRule,\n records: readonly EvidenceRecord[],\n options: {\n /** Field carrying a row's identity. */\n idField: string\n /** Sealed or previously-computed subsets, by name. */\n bases?: Record<string, readonly string[]>\n /** Derive predicate-readable fields from a bare id when its record is absent. */\n idFields?: (id: string) => EvidenceRecord\n },\n): string[] {\n if (rule.kind === 'round-robin') {\n const allowed = new Set(rule.reads)\n for (const field of [rule.groupBy, rule.withinOrder.field]) {\n if (!allowed.has(field)) {\n throw new ValidationError(\n `runSelectionRule: round-robin reads '${field}' but its closed read set is [${rule.reads.join(', ')}]`,\n )\n }\n }\n const byGroup = new Map<string, string[]>()\n for (const record of records) {\n const group = String(readField(record, rule.groupBy))\n const id = String(readField(record, rule.withinOrder.field))\n const bucket = byGroup.get(group)\n if (bucket) bucket.push(id)\n else byGroup.set(group, [id])\n }\n for (const ids of byGroup.values()) {\n ids.sort()\n if (rule.withinOrder.dir === 'desc') ids.reverse()\n }\n const groups = [...byGroup.keys()].sort()\n const chosen: string[] = []\n let cursor = 0\n while (chosen.length < rule.take && groups.some((g) => byGroup.get(g)!.length > 0)) {\n const group = groups[cursor % groups.length]!\n const ids = byGroup.get(group)!\n if (ids.length > 0) chosen.push(ids.shift()!)\n cursor += 1\n }\n return chosen\n }\n\n const base = options.bases?.[rule.base]\n if (!base) {\n throw new ValidationError(`runSelectionRule: filter-of base '${rule.base}' was not provided`)\n }\n const index = new Map(records.map((r) => [String(readField(r, options.idField)), r]))\n const kept = base.filter((id) => {\n const record = index.get(id) ?? options.idFields?.(id)\n if (!record) {\n throw new ValidationError(\n `runSelectionRule: base id '${id}' has no record and no idFields derivation`,\n )\n }\n return evaluatePredicate(rule.keep, record)\n })\n const sorted = [...kept].sort()\n if (rule.order.dir === 'desc') sorted.reverse()\n return sorted\n}\n\n// ── Estimands ────────────────────────────────────────────────────────\n\n/** A named set of row identities, built from arm rows and an event predicate. */\nexport type SetExpr =\n | { kind: 'rows-where'; arm: string; event: Predicate }\n | { kind: 'intersect'; of: SetExpr[] }\n\n/**\n * What the experiment measures. Every estimand names the fields it reads, so\n * the sealed tree records the full data dependency of the number.\n */\nexport type Estimand =\n | { kind: 'rate'; event: Predicate; over: 'rollouts' }\n | { kind: 'rate-at-least-once'; event: Predicate; groupBy: string }\n | {\n kind: 'paired-mean-diff'\n armField: string\n treatment: string\n control: string\n pairBy: string\n /**\n * Field path to the per-row outcome. A boolean reads as 1 or 0, so a\n * binary pass/fail outcome gives the risk difference directly.\n */\n value: string\n /** A pair one arm did not answer contributes a difference of exactly zero. */\n missing: 'zero-diff'\n }\n | {\n kind: 'set-ratio'\n armField: string\n idField: string\n numerator: SetExpr\n denominator: SetExpr\n }\n\nexport interface EstimandResult {\n value: number\n numerator: number\n denominator: number\n}\n\nfunction evaluateSetExpr(\n expr: SetExpr,\n rows: readonly EvidenceRecord[],\n armField: string,\n idField: string,\n): Set<string> {\n if (expr.kind === 'rows-where') {\n const ids = new Set<string>()\n for (const row of rows) {\n if (String(readField(row, armField)) !== expr.arm) continue\n if (evaluatePredicate(expr.event, row)) ids.add(String(readField(row, idField)))\n }\n return ids\n }\n if (expr.of.length === 0) throw new ValidationError('computeEstimand: empty intersect')\n const sets = expr.of.map((e) => evaluateSetExpr(e, rows, armField, idField))\n const [first, ...rest] = sets\n const out = new Set<string>()\n for (const id of first!) {\n if (rest.every((s) => s.has(id))) out.add(id)\n }\n return out\n}\n\n/**\n * Read one registered outcome field as a number.\n *\n * A binary outcome reaches evidence as `true` or `false`. Its mean is the pass\n * rate and the mean of its paired differences is the risk difference, so\n * `true` reads as 1 and `false` as 0 — the same quantity a caller would\n * otherwise encode by hand, and the same reading in every interpreter here.\n * Every other type, and a non-finite number, is a measurement defect: it\n * rejects instead of poisoning the mean with `NaN` or a coerced zero.\n */\nfunction readNumericOutcome(raw: unknown, context: string, field: string, where: string): number {\n if (typeof raw === 'boolean') return raw ? 1 : 0\n if (typeof raw === 'number' && Number.isFinite(raw)) return raw\n throw new ValidationError(\n `${context}: value field '${field}' is not a finite number or a boolean on ${where}`,\n )\n}\n\n/** Compute an estimand over evidence rows. Pure; reads only registered fields. */\nexport function computeEstimand(\n estimand: Estimand,\n rows: readonly EvidenceRecord[],\n): EstimandResult {\n switch (estimand.kind) {\n case 'rate': {\n const numerator = rows.filter((r) => evaluatePredicate(estimand.event, r)).length\n if (rows.length === 0) throw new ValidationError('computeEstimand: rate over zero rows')\n return { value: numerator / rows.length, numerator, denominator: rows.length }\n }\n case 'rate-at-least-once': {\n const byGroup = new Map<string, boolean>()\n for (const row of rows) {\n const group = String(readField(row, estimand.groupBy))\n const hit = evaluatePredicate(estimand.event, row)\n byGroup.set(group, (byGroup.get(group) ?? false) || hit)\n }\n if (byGroup.size === 0) {\n throw new ValidationError('computeEstimand: rate-at-least-once over zero groups')\n }\n const numerator = [...byGroup.values()].filter(Boolean).length\n return { value: numerator / byGroup.size, numerator, denominator: byGroup.size }\n }\n case 'paired-mean-diff': {\n const byPair = new Map<string, { treatment?: number; control?: number }>()\n for (const row of rows) {\n const arm = String(readField(row, estimand.armField))\n if (arm !== estimand.treatment && arm !== estimand.control) continue\n const pair = String(readField(row, estimand.pairBy))\n const value = readNumericOutcome(\n readField(row, estimand.value),\n 'computeEstimand paired-mean-diff',\n estimand.value,\n `pair '${pair}'`,\n )\n const slot = byPair.get(pair) ?? {}\n if (arm === estimand.treatment) slot.treatment = value\n else slot.control = value\n byPair.set(pair, slot)\n }\n if (byPair.size === 0) {\n throw new ValidationError('computeEstimand: paired-mean-diff over zero pairs')\n }\n let sum = 0\n for (const slot of byPair.values()) {\n // missing: 'zero-diff' — an unanswered side contributes zero, never a drop\n sum += (slot.treatment ?? 0) - (slot.control ?? 0)\n }\n return { value: sum / byPair.size, numerator: sum, denominator: byPair.size }\n }\n case 'set-ratio': {\n const numeratorSet = evaluateSetExpr(\n estimand.numerator,\n rows,\n estimand.armField,\n estimand.idField,\n )\n const denominatorSet = evaluateSetExpr(\n estimand.denominator,\n rows,\n estimand.armField,\n estimand.idField,\n )\n if (denominatorSet.size === 0) {\n throw new ValidationError('computeEstimand: set-ratio denominator set is empty')\n }\n return {\n value: numeratorSet.size / denominatorSet.size,\n numerator: numeratorSet.size,\n denominator: denominatorSet.size,\n }\n }\n }\n}\n\n// ── Intervals ────────────────────────────────────────────────────────\n\n/** How uncertainty is computed. The seed is part of the registration. */\nexport type IntervalSpec =\n | {\n kind: 'cluster-bootstrap'\n clusterBy: string\n /** Registered numeric or boolean outcome field, including a prepared paired difference. */\n value: string\n resamples: number\n seed: number\n level: number\n method: 'percentile'\n }\n | { kind: 'clopper-pearson'; level: number }\n\nexport interface ComputedInterval {\n lower: number\n upper: number\n level: number\n}\n\n/** Shared by registration and direct execution so malformed intervals cannot produce evidence. */\nexport function intervalSpecProblems(spec: IntervalSpec): string[] {\n if (spec === null || typeof spec !== 'object' || Array.isArray(spec)) {\n return ['interval must be an object']\n }\n if (spec.kind !== 'cluster-bootstrap' && spec.kind !== 'clopper-pearson') {\n return ['interval kind must be cluster-bootstrap or clopper-pearson']\n }\n const problems: string[] = []\n if (!Number.isFinite(spec.level) || spec.level <= 0 || spec.level >= 1) {\n problems.push('level must be a finite number between zero and one')\n }\n if (spec.kind === 'cluster-bootstrap') {\n for (const field of ['clusterBy', 'value'] as const) {\n const path = spec[field]\n if (\n typeof path !== 'string' ||\n path.split('.').some((segment) => segment.length === 0 || segment.trim() !== segment)\n ) {\n problems.push(`${field} must be a nonempty dot-separated field path`)\n }\n }\n if (\n !Number.isSafeInteger(spec.resamples) ||\n spec.resamples < 1 ||\n spec.resamples > 0xffff_ffff\n ) {\n problems.push('resamples must be a positive integer within the supported array length')\n }\n if (!Number.isSafeInteger(spec.seed)) problems.push('seed must be a safe integer')\n if (spec.method !== 'percentile') problems.push('method must be percentile')\n }\n return problems\n}\n\n/**\n * Execute an interval spec.\n *\n * Cluster-bootstrap resamples whole clusters of its registered `value` field and\n * takes percentile bounds of the pooled mean. Clopper-Pearson computes the\n * exact binomial interval and requires `successes`/`trials` evidence instead\n * of rows.\n */\nexport function computeInterval(\n spec: IntervalSpec,\n evidence:\n | { kind: 'rows'; rows: readonly EvidenceRecord[] }\n | { kind: 'binomial'; successes: number; trials: number },\n): ComputedInterval {\n const problems = intervalSpecProblems(spec)\n if (problems.length > 0) throw new ValidationError(`computeInterval: ${problems.join('; ')}`)\n if (evidence === null || typeof evidence !== 'object' || Array.isArray(evidence)) {\n throw new ValidationError('computeInterval: evidence must be an object')\n }\n if (spec.kind === 'cluster-bootstrap') {\n if (evidence.kind !== 'rows') {\n throw new ValidationError('computeInterval: cluster-bootstrap requires row evidence')\n }\n if ('value' in evidence) {\n throw new ValidationError(\n 'computeInterval: register value in the interval spec, not row evidence',\n )\n }\n if (!Array.isArray(evidence.rows))\n throw new ValidationError('computeInterval: rows must be an array')\n const clusters = new Map<string, number[]>()\n for (const [index, row] of evidence.rows.entries()) {\n if (row === null || typeof row !== 'object' || Array.isArray(row)) {\n throw new ValidationError(`computeInterval: row ${index} must be an object`)\n }\n const cluster = readField(row, spec.clusterBy)\n if (\n !(typeof cluster === 'string' && cluster.length > 0 && cluster.trim() === cluster) &&\n !(typeof cluster === 'number' && Number.isFinite(cluster))\n ) {\n throw new ValidationError(\n `computeInterval: cluster field '${spec.clusterBy}' must be a nonempty string or finite number on row ${index}`,\n )\n }\n const clusterKey = `${typeof cluster}:${cluster}`\n const value = readNumericOutcome(\n readField(row, spec.value),\n 'computeInterval cluster-bootstrap',\n spec.value,\n `cluster '${cluster}'`,\n )\n const bucket = clusters.get(clusterKey)\n if (bucket) bucket.push(value)\n else clusters.set(clusterKey, [value])\n }\n const clusterValues = [...clusters.entries()]\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([, values]) => values)\n if (clusterValues.length < 2) {\n throw new ValidationError(\n `computeInterval: cluster-bootstrap needs >= 2 clusters, got ${clusterValues.length}`,\n )\n }\n const rng = mulberry32(spec.seed)\n const means = new Array<number>(spec.resamples)\n for (let draw = 0; draw < spec.resamples; draw++) {\n let sum = 0\n let count = 0\n for (let pick = 0; pick < clusterValues.length; pick++) {\n const cluster = clusterValues[Math.floor(rng() * clusterValues.length)]!\n for (const value of cluster) sum += value\n count += cluster.length\n }\n means[draw] = sum / count\n if (!Number.isFinite(means[draw])) {\n throw new ValidationError(\n 'computeInterval: cluster mean overflowed the finite numeric range',\n )\n }\n }\n means.sort((a, b) => a - b)\n const alpha = 1 - spec.level\n const lowerIndex = Math.floor((alpha / 2) * spec.resamples)\n const upperIndex = Math.min(spec.resamples - 1, Math.ceil((1 - alpha / 2) * spec.resamples) - 1)\n return {\n lower: means[lowerIndex]!,\n upper: means[Math.max(lowerIndex, upperIndex)]!,\n level: spec.level,\n }\n }\n\n if (evidence.kind !== 'binomial') {\n throw new ValidationError('computeInterval: clopper-pearson requires binomial evidence')\n }\n const { successes, trials } = evidence\n if (\n !Number.isSafeInteger(successes) ||\n !Number.isSafeInteger(trials) ||\n trials <= 0 ||\n successes < 0\n ) {\n throw new ValidationError(\n `computeInterval: clopper-pearson needs 0 <= successes <= trials, got ${successes}/${trials}`,\n )\n }\n if (successes > trials) {\n throw new ValidationError(\n `computeInterval: clopper-pearson successes ${successes} exceed trials ${trials}`,\n )\n }\n const alpha = 1 - spec.level\n const lower = successes === 0 ? 0 : binomialQuantile(successes, trials, alpha / 2, 'lower')\n const upper = successes === trials ? 1 : binomialQuantile(successes, trials, alpha / 2, 'upper')\n return { lower, upper, level: spec.level }\n}\n\n/**\n * Clopper-Pearson bound by bisection on the binomial tail. The lower bound is\n * the p with P(X >= successes | p) = alpha; the upper is the p with\n * P(X <= successes | p) = alpha. Deterministic, no special functions.\n */\nfunction binomialQuantile(\n successes: number,\n trials: number,\n alpha: number,\n side: 'lower' | 'upper',\n): number {\n const tail = (p: number): number => {\n // log-space binomial pmf accumulation for numeric stability\n let sum = 0\n for (let k = 0; k <= trials; k++) {\n const inTail = side === 'lower' ? k >= successes : k <= successes\n if (!inTail) continue\n sum += Math.exp(logBinomialPmf(k, trials, p))\n }\n return sum\n }\n let lo = 0\n let hi = 1\n for (let iter = 0; iter < 100; iter++) {\n const mid = (lo + hi) / 2\n if (tail(mid) < alpha) {\n if (side === 'lower') lo = mid\n else hi = mid\n } else {\n if (side === 'lower') hi = mid\n else lo = mid\n }\n }\n return (lo + hi) / 2\n}\n\nfunction logBinomialPmf(k: number, n: number, p: number): number {\n if (p <= 0) return k === 0 ? 0 : Number.NEGATIVE_INFINITY\n if (p >= 1) return k === n ? 0 : Number.NEGATIVE_INFINITY\n return logChoose(n, k) + k * Math.log(p) + (n - k) * Math.log(1 - p)\n}\n\nfunction logChoose(n: number, k: number): number {\n return logFactorial(n) - logFactorial(k) - logFactorial(n - k)\n}\n\nconst LOG_FACTORIAL_CACHE: number[] = [0]\nfunction logFactorial(n: number): number {\n for (let i = LOG_FACTORIAL_CACHE.length; i <= n; i++) {\n LOG_FACTORIAL_CACHE[i] = LOG_FACTORIAL_CACHE[i - 1]! + Math.log(i)\n }\n return LOG_FACTORIAL_CACHE[n]!\n}\n\n// ── Conditions and decisions ─────────────────────────────────────────\n\n/** Decision guards read only named derived quantities — never raw rows. */\nexport type Condition =\n | { kind: 'interval-excludes-zero'; interval: string; sign: 'positive' | 'negative' }\n | { kind: 'interval-includes-zero'; interval: string }\n | { kind: 'quantity-threshold'; quantity: string; op: 'gte' | 'lte' | 'gt' | 'lt'; value: number }\n | { kind: 'obligation-met'; obligation: string }\n | { kind: 'all'; of: Condition[] }\n | { kind: 'any'; of: Condition[] }\n | { kind: 'not'; of: Condition }\n\n/** The named quantities a decision rule may read. Nothing else reaches it. */\nexport interface DerivedQuantities {\n intervals: Record<string, { lower: number; upper: number }>\n quantities: Record<string, number>\n obligationsMet: Record<string, boolean>\n}\n\nexport function evaluateCondition(condition: Condition, evidence: DerivedQuantities): boolean {\n switch (condition.kind) {\n case 'interval-excludes-zero': {\n const interval = evidence.intervals[condition.interval]\n if (!interval) {\n throw new ValidationError(\n `evaluateCondition: interval '${condition.interval}' is not in the evidence`,\n )\n }\n const excludes = interval.lower > 0 || interval.upper < 0\n return excludes && (condition.sign === 'positive' ? interval.lower > 0 : interval.upper < 0)\n }\n case 'interval-includes-zero': {\n const interval = evidence.intervals[condition.interval]\n if (!interval) {\n throw new ValidationError(\n `evaluateCondition: interval '${condition.interval}' is not in the evidence`,\n )\n }\n return interval.lower <= 0 && interval.upper >= 0\n }\n case 'quantity-threshold': {\n const value = evidence.quantities[condition.quantity]\n if (value === undefined) {\n throw new ValidationError(\n `evaluateCondition: quantity '${condition.quantity}' is not in the evidence`,\n )\n }\n return compareValues(value, condition.op, condition.value)\n }\n case 'obligation-met':\n return evidence.obligationsMet[condition.obligation] === true\n case 'all':\n return condition.of.every((c) => evaluateCondition(c, evidence))\n case 'any':\n return condition.of.some((c) => evaluateCondition(c, evidence))\n case 'not':\n return !evaluateCondition(condition.of, evidence)\n }\n}\n\nexport interface DecisionBranch {\n when: Condition\n verdict: string\n report: string[]\n}\n\n/**\n * Ordered decision table: the first branch whose condition holds fires, and a\n * table no branch matches throws — a non-total registration is a defect, not\n * an implicit verdict. `report-only` registers the ABSENCE of a verdict\n * branch: the estimate and the per-row table are the finding, and the\n * registered meaning prose rides as non-executable interpretation data.\n */\nexport type DecisionRule =\n | { kind: 'table'; branches: DecisionBranch[] }\n | {\n kind: 'report-only'\n estimands: string[]\n intervals: string[]\n perRow: string[]\n interpretation?: { onQualitative: string; consequence: string }[]\n }\n\nexport interface DecisionOutcome {\n verdict: string\n report: string[]\n}\n\nexport function executeDecisionRule(\n rule: DecisionRule,\n evidence: DerivedQuantities,\n): DecisionOutcome {\n if (rule.kind === 'report-only') {\n return { verdict: 'report-only', report: [...rule.estimands, ...rule.intervals] }\n }\n for (const branch of rule.branches) {\n if (evaluateCondition(branch.when, evidence)) {\n return { verdict: branch.verdict, report: branch.report }\n }\n }\n throw new DecisionTableNotTotalError(\n 'executeDecisionRule: decision table is not total — no branch matched the evidence',\n )\n}\n\n/** A registered control that must exist before a class of verdicts is read. */\nexport interface Obligation {\n id: string\n appliesToVerdicts: string[]\n control: string\n}\n\n// ── Validity gates and halt ──────────────────────────────────────────\n\n/** Pre-spend design checks. Each returns pass/fail plus its evidence. */\nexport type ValidityGate =\n | {\n kind: 'oracle-determinism'\n unit: 'suite' | 'assertion'\n replicates: number\n maxFlipRate: number\n }\n | {\n kind: 'population-reproducibility'\n joinOn: string\n compare: string[]\n maxChangedRows: number\n }\n | { kind: 'provenance-assertion'; claim: Predicate }\n | {\n kind: 'power-floor'\n target: number\n /** Minimum worthwhile effect; must be represented exactly in effectGrid. */\n minimumEffect: number\n effectGrid: number[]\n sim: { trials: number; resamples: number; seed: number }\n }\n | { kind: 'identity'; field: 'served-model'; op: 'basename-eq'; onFail: 'abort' }\n\nexport interface GateResult {\n id: string\n passed: boolean\n evidence: JsonValue\n}\n\n/**\n * Replicate-flip counting over graded states. A state whose replicates split\n * between pass and fail is flipping; its flip rate is the minority share.\n */\nexport function evaluateOracleDeterminismGate(\n id: string,\n gate: Extract<ValidityGate, { kind: 'oracle-determinism' }>,\n repsByState: Record<string, readonly boolean[]>,\n): GateResult {\n const evidence: Record<string, JsonValue> = {}\n let passed = true\n for (const [state, reps] of Object.entries(repsByState)) {\n const passes = reps.filter(Boolean).length\n const flipRate = reps.length === 0 ? 0 : Math.min(passes, reps.length - passes) / reps.length\n evidence[state] = { passes, replicates: reps.length, flipRate }\n if (flipRate > gate.maxFlipRate) passed = false\n }\n return { id, passed, evidence }\n}\n\n/**\n * Join two population snapshots on `joinOn` and compare the registered fields.\n * Only rows present in both snapshots are compared; a presence change is a\n * different failure and needs its own gate.\n */\nexport function evaluatePopulationReproducibilityGate(\n id: string,\n gate: Extract<ValidityGate, { kind: 'population-reproducibility' }>,\n populations: { left: readonly EvidenceRecord[]; right: readonly EvidenceRecord[] },\n): GateResult {\n const rightByKey = new Map(populations.right.map((r) => [String(readField(r, gate.joinOn)), r]))\n const changed: string[] = []\n for (const left of populations.left) {\n const key = String(readField(left, gate.joinOn))\n const right = rightByKey.get(key)\n if (!right) continue\n const moved = gate.compare.filter((f) => readField(left, f) !== readField(right, f))\n if (moved.length > 0) {\n changed.push(\n `${key} ${moved.map((f) => `${f}:${String(readField(left, f))}->${String(readField(right, f))}`).join(' ')}`,\n )\n }\n }\n return { id, passed: changed.length <= gate.maxChangedRows, evidence: changed }\n}\n\n/** The registered claim about provenance must hold on the provenance record. */\nexport function evaluateProvenanceGate(\n id: string,\n gate: Extract<ValidityGate, { kind: 'provenance-assertion' }>,\n provenance: EvidenceRecord,\n): GateResult {\n const passed = evaluatePredicate(gate.claim, provenance)\n return { id, passed, evidence: { claimHolds: passed } }\n}\n\n/** Final path segment equality between the pinned and the served identity. */\nexport function evaluateIdentityGate(\n id: string,\n _gate: Extract<ValidityGate, { kind: 'identity' }>,\n identities: { pinned: string; served: string },\n): GateResult {\n const basename = (s: string): string => s.split('/').pop() ?? s\n const passed = basename(identities.pinned) === basename(identities.served)\n return {\n id,\n passed,\n evidence: { pinned: identities.pinned, served: identities.served, matched: passed },\n }\n}\n\n/**\n * The design's power at minimumEffect must reach the registered target.\n * The curve must cover the registered effect grid exactly — a curve\n * computed on a different grid is different evidence and is refused.\n */\nexport function evaluatePowerFloorGate(\n id: string,\n gate: Extract<ValidityGate, { kind: 'power-floor' }>,\n curve: readonly { effect: number; power: number }[],\n): GateResult {\n const problems = powerFloorProblems(gate)\n if (problems.length > 0) {\n throw new ValidationError(`evaluatePowerFloorGate: ${problems.join('; ')}`)\n }\n if (curve.some((point) => !Number.isFinite(point.power) || point.power < 0 || point.power > 1)) {\n throw new ValidationError('evaluatePowerFloorGate: powers must be finite and in [0,1]')\n }\n const byEffect = new Map(curve.map((point) => [point.effect, point.power]))\n if (byEffect.size !== curve.length) {\n throw new ValidationError('evaluatePowerFloorGate: curve contains duplicate effects')\n }\n const missing = gate.effectGrid.filter((effect) => !byEffect.has(effect))\n if (missing.length > 0) {\n throw new ValidationError(\n `evaluatePowerFloorGate: curve does not cover registered effects [${missing.join(', ')}]`,\n )\n }\n const extra = curve.filter((point) => !gate.effectGrid.includes(point.effect))\n if (extra.length > 0) {\n throw new ValidationError(\n `evaluatePowerFloorGate: curve contains unregistered effects [${extra.map((point) => point.effect).join(', ')}]`,\n )\n }\n const powers = gate.effectGrid.map((effect) => byEffect.get(effect)!)\n const maxPower = Math.max(...powers)\n const powerAtMinimumEffect = byEffect.get(gate.minimumEffect)!\n return {\n id,\n passed: powerAtMinimumEffect >= gate.target,\n evidence: {\n target: gate.target,\n minimumEffect: gate.minimumEffect,\n powerAtMinimumEffect,\n maxPower,\n curve: gate.effectGrid.map((effect) => ({ effect, power: byEffect.get(effect)! })),\n },\n }\n}\n\n/** Shared by seal validation and direct execution; malformed designs never pass. */\nexport function powerFloorProblems(gate: Extract<ValidityGate, { kind: 'power-floor' }>): string[] {\n const problems: string[] = []\n if (!Number.isFinite(gate.target) || gate.target <= 0 || gate.target > 1) {\n problems.push('power target must be in (0,1]')\n }\n if (!Number.isFinite(gate.minimumEffect) || gate.minimumEffect <= 0) {\n problems.push('minimumEffect must be positive and finite')\n }\n if (gate.effectGrid.length === 0 || gate.effectGrid.some((effect) => !Number.isFinite(effect))) {\n problems.push('effectGrid must contain finite effects')\n }\n if (new Set(gate.effectGrid).size !== gate.effectGrid.length) {\n problems.push('effectGrid contains duplicate effects')\n }\n if (!gate.effectGrid.includes(gate.minimumEffect)) {\n problems.push('effectGrid must contain minimumEffect exactly; no interpolation is assumed')\n }\n for (const field of ['trials', 'resamples'] as const) {\n if (!Number.isInteger(gate.sim[field]) || gate.sim[field] <= 0) {\n problems.push(`power simulation ${field} must be a positive integer`)\n }\n }\n if (!Number.isInteger(gate.sim.seed)) problems.push('power simulation seed must be an integer')\n return problems\n}\n\n/** Checks as prerequisites: any named gate failing refuses the spend. */\nexport interface HaltRule {\n when: { kind: 'any-gate-failed'; gates: string[] }\n action: 'refuse-spend'\n report: 'settling-n'\n}\n\nexport interface HaltOutcome {\n fired: boolean\n action: 'refuse-spend' | null\n failedGates: string[]\n}\n\nexport function evaluateHaltRule(halt: HaltRule, gates: readonly GateResult[]): HaltOutcome {\n const seen = new Map(gates.map((g) => [g.id, g]))\n const missing = halt.when.gates.filter((id) => !seen.has(id))\n if (missing.length > 0) {\n throw new ValidationError(\n `evaluateHaltRule: halt references gates that were not evaluated: [${missing.join(', ')}]`,\n )\n }\n const failed = halt.when.gates.filter((id) => !seen.get(id)!.passed)\n return failed.length > 0\n ? { fired: true, action: halt.action, failedGates: failed }\n : { fired: false, action: null, failedGates: [] }\n}\n\n// ── Budget rules ─────────────────────────────────────────────────────\n\n/**\n * Spend schedules as data. `ledger` names every entry the ceiling counts, so\n * what the gate reads is registered, not improvised at gate time.\n */\nexport type BudgetRule =\n | {\n kind: 'uniform-pass'\n ceilingUsd: number\n maxPasses: number\n projection: 'last-pass-cost'\n costSource: 'priced-per-call'\n ledger: { id: string; usd: number }[]\n partialPass: 'report-never-lift'\n }\n | {\n kind: 'n-ladder'\n steps: number[]\n ceilingUsd: number\n projection: 'unit-cost-times-rows-times-n'\n onExhaust: 'refuse-report-projection'\n }\n\nexport interface UniformPassDecision {\n pass: number\n cumulativeBefore: number\n projected: number\n go: boolean\n}\n\nexport interface UniformPassSchedule {\n decisions: UniformPassDecision[]\n uniformN: number\n}\n\n/**\n * Execute the uniform-pass schedule against measured pass costs. Pass 1 always\n * runs; each later pass runs only when the cumulative spend plus the last\n * measured pass cost stays at or under the registered ceiling. The registered\n * ledger is the pre-spend the ceiling counts.\n */\nexport function runUniformPassBudget(\n rule: Extract<BudgetRule, { kind: 'uniform-pass' }>,\n measuredPassCosts: readonly number[],\n): UniformPassSchedule {\n const preSpend = rule.ledger.reduce((sum, entry) => sum + entry.usd, 0)\n let cumulative = preSpend\n const decisions: UniformPassDecision[] = []\n let uniformN = 0\n for (let pass = 1; pass <= rule.maxPasses; pass++) {\n if (pass === 1) {\n if (measuredPassCosts[0] === undefined) break\n cumulative += measuredPassCosts[0]\n uniformN = 1\n continue\n }\n const projected = measuredPassCosts[pass - 2]\n if (projected === undefined) break\n const go = cumulative + projected <= rule.ceilingUsd\n decisions.push({ pass, cumulativeBefore: cumulative, projected, go })\n if (!go || measuredPassCosts[pass - 1] === undefined) break\n cumulative += measuredPassCosts[pass - 1]!\n uniformN = pass\n }\n return { decisions, uniformN }\n}\n\nexport interface NLadderProjection {\n chosenN: number | null\n projections: { n: number; projectedUsd: number; affordable: boolean }[]\n refusal: null | { onExhaust: 'refuse-report-projection'; reason: string }\n}\n\n/**\n * Walk the registered n-ladder and pick the first affordable step. When no\n * step fits the ceiling, the rule refuses and reports the projection instead\n * of shrinking the row set — \"never subset rows\" is the registered invariant.\n */\nexport function projectNLadderBudget(\n rule: Extract<BudgetRule, { kind: 'n-ladder' }>,\n measured: { unitCostUsd: number; rows: number },\n): NLadderProjection {\n const projections = rule.steps.map((n) => {\n const projectedUsd = measured.unitCostUsd * measured.rows * n\n return { n, projectedUsd, affordable: projectedUsd <= rule.ceilingUsd }\n })\n const first = projections.find((p) => p.affordable)\n if (first) return { chosenN: first.n, projections, refusal: null }\n return {\n chosenN: null,\n projections,\n refusal: {\n onExhaust: rule.onExhaust,\n reason: `no ladder step fits the ${rule.ceilingUsd} USD ceiling at ${measured.rows} rows x ${measured.unitCostUsd} USD per unit`,\n },\n }\n}\n\n// ── Matched budget and reissue ───────────────────────────────────────\n\n/** Arm budget matching as a refusal, not prose. Verified by `verifyMatchedBudgets`. */\nexport interface MatchedBudgetRule {\n measure: 'realized-tokens'\n tolerance: number\n onFail: 'refuse-contrast'\n}\n\n/** Carrier faults are reissued; model outcomes stand. Closed enumeration. */\nexport interface ReissuePolicy {\n carrierEvents: ('http-status' | 'transport-error' | 'deadline' | 'empty-content')[]\n modelOutcomesStand: true\n maxIssues: number\n}\n\nexport type ReissueVerdict = 'reissue' | 'stands' | 'exhausted'\n\n/**\n * Classify one rollout event under the registered reissue policy. A carrier\n * event within the issue budget is reissued; a model outcome always stands;\n * a carrier event past `maxIssues` is exhausted and reported, never retried.\n */\nexport function classifyReissue(\n policy: ReissuePolicy,\n event: string,\n issuesSoFar: number,\n): ReissueVerdict {\n if (!(policy.carrierEvents as string[]).includes(event)) return 'stands'\n return issuesSoFar < policy.maxIss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B;;;;;;AAaA,SAAgB,qBACd,MACA,UACmB;CACnB,MAAM,cAAc,KAAK,MAAM,KAAK,MAAM;EACxC,MAAM,eAAe,SAAS,cAAc,SAAS,OAAO;EAC5D,OAAO;GAAE;GAAG;GAAc,YAAY,gBAAgB,KAAK;EAAW;CACxE,CAAC;CACD,MAAM,QAAQ,YAAY,MAAM,MAAM,EAAE,UAAU;CAClD,IAAI,OAAO,OAAO;EAAE,SAAS,MAAM;EAAG;EAAa,SAAS;CAAK;CACjE,OAAO;EACL,SAAS;EACT;EACA,SAAS;GACP,WAAW,KAAK;GAChB,QAAQ,2BAA2B,KAAK,WAAW,kBAAkB,SAAS,KAAK,UAAU,SAAS,YAAY;EACpH;CACF;AACF;;;;;;AAyBA,SAAgB,gBACd,QACA,OACA,aACgB;CAChB,IAAI,CAAE,OAAO,cAA2B,SAAS,KAAK,GAAG,OAAO;CAChE,OAAO,cAAc,OAAO,YAAY,YAAY;AACtD"}
|
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
//#region src/experiment/ast.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* The registered-rule AST: every rule an experiment registers is DATA.
|
|
4
|
+
*
|
|
5
|
+
* A closure cannot be canonicalized or hashed; a node tree can. `sealExperiment`
|
|
6
|
+
* hashes the whole tree, and every interpreter in this file takes only a node
|
|
7
|
+
* plus evidence records — no parameter for alpha, threshold, metric, or
|
|
8
|
+
* stopping rule exists on any executable surface. The registered object and
|
|
9
|
+
* the executed object are therefore the same object, and registered-vs-ran
|
|
10
|
+
* drift is unrepresentable rather than checked.
|
|
11
|
+
*
|
|
12
|
+
* Node families:
|
|
13
|
+
* Predicate closed-key comparisons — the only leaf
|
|
14
|
+
* AdmissionRule monotone funnel stages with registered waivers
|
|
15
|
+
* SelectionRule deterministic subsets over a closed field set
|
|
16
|
+
* Estimand what the experiment measures
|
|
17
|
+
* IntervalSpec how uncertainty is computed, seed included
|
|
18
|
+
* Condition decision guards over named derived quantities
|
|
19
|
+
* DecisionRule ordered verdict table, or a registered absence of one
|
|
20
|
+
* Obligation a control that must exist before a verdict class is read
|
|
21
|
+
* ValidityGate pre-spend design checks
|
|
22
|
+
* HaltRule gates as prerequisites — failure refuses the spend
|
|
23
|
+
* BudgetRule spend schedules with a named ledger
|
|
24
|
+
* MatchedBudgetRule arm budget matching as a refusal
|
|
25
|
+
* ReissuePolicy carrier faults are reissued; model outcomes stand
|
|
26
|
+
*/
|
|
27
|
+
/** JSON-serializable value — everything a sealed node may carry. */
|
|
28
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
29
|
+
[k: string]: JsonValue;
|
|
30
|
+
};
|
|
31
|
+
/** Evidence row shape. Fields are addressed by dot-separated paths. */
|
|
32
|
+
type EvidenceRecord = Record<string, unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* Closed-key comparison over a declared record schema. The only leaf node.
|
|
35
|
+
* `field` is a dot-separated path into an evidence record.
|
|
36
|
+
*/
|
|
37
|
+
type Predicate = {
|
|
38
|
+
kind: 'compare';
|
|
39
|
+
field: string;
|
|
40
|
+
op: 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte';
|
|
41
|
+
value: JsonValue;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'in';
|
|
44
|
+
field: string;
|
|
45
|
+
values: JsonValue[];
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'all';
|
|
48
|
+
of: Predicate[];
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'any';
|
|
51
|
+
of: Predicate[];
|
|
52
|
+
} | {
|
|
53
|
+
kind: 'not';
|
|
54
|
+
of: Predicate;
|
|
55
|
+
};
|
|
56
|
+
/** Read a dot-separated field path. Missing segments yield `undefined`. */
|
|
57
|
+
declare function readField(record: EvidenceRecord, path: string): unknown;
|
|
58
|
+
/** Evaluate a predicate against one evidence record. */
|
|
59
|
+
declare function evaluatePredicate(predicate: Predicate, record: EvidenceRecord): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* One monotone funnel stage. `waives` names substrate admission conditions
|
|
62
|
+
* deliberately NOT applied, so a waiver is registered, never implicit.
|
|
63
|
+
*/
|
|
64
|
+
interface AdmissionStage {
|
|
65
|
+
id: string;
|
|
66
|
+
keep: Predicate;
|
|
67
|
+
waives?: string[];
|
|
68
|
+
}
|
|
69
|
+
/** A partition is a set reported separately and never pooled. */
|
|
70
|
+
interface AdmissionPartition {
|
|
71
|
+
id: string;
|
|
72
|
+
/** Stage whose dropped rows this partition draws from. */
|
|
73
|
+
from: string;
|
|
74
|
+
keep: Predicate;
|
|
75
|
+
pooling: 'never';
|
|
76
|
+
}
|
|
77
|
+
/** Declarative row-admission funnel. Stages only remove rows. */
|
|
78
|
+
interface AdmissionRule {
|
|
79
|
+
population: string;
|
|
80
|
+
stages: AdmissionStage[];
|
|
81
|
+
partitions?: AdmissionPartition[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Deterministic subset selection. `reads` is the closed field set the rule
|
|
85
|
+
* may touch — outcome-contaminated selection is unrepresentable because an
|
|
86
|
+
* outcome field is simply not in the list.
|
|
87
|
+
*/
|
|
88
|
+
type SelectionRule = {
|
|
89
|
+
kind: 'round-robin';
|
|
90
|
+
groupBy: string;
|
|
91
|
+
groupOrder: 'lex-asc';
|
|
92
|
+
withinOrder: {
|
|
93
|
+
field: string;
|
|
94
|
+
dir: 'asc' | 'desc';
|
|
95
|
+
};
|
|
96
|
+
take: number;
|
|
97
|
+
reads: string[];
|
|
98
|
+
} | {
|
|
99
|
+
kind: 'filter-of';
|
|
100
|
+
/** Name of the sealed subset or selection this rule filters. */
|
|
101
|
+
base: string;
|
|
102
|
+
keep: Predicate;
|
|
103
|
+
order: {
|
|
104
|
+
field: string;
|
|
105
|
+
dir: 'asc' | 'desc';
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Execute a selection rule.
|
|
110
|
+
*
|
|
111
|
+
* Round-robin walks groups in lexicographic order and takes ids in
|
|
112
|
+
* within-group order until `take` ids are chosen. Filter-of keeps the ids of
|
|
113
|
+
* `bases[rule.base]` whose record satisfies the predicate, in the registered
|
|
114
|
+
* order. Ids absent from `records` are evaluated on their id alone (fields
|
|
115
|
+
* derived from the id via `idFields`), so a sealed base outlives its source
|
|
116
|
+
* records.
|
|
117
|
+
*/
|
|
118
|
+
declare function runSelectionRule(rule: SelectionRule, records: readonly EvidenceRecord[], options: {
|
|
119
|
+
/** Field carrying a row's identity. */
|
|
120
|
+
idField: string;
|
|
121
|
+
/** Sealed or previously-computed subsets, by name. */
|
|
122
|
+
bases?: Record<string, readonly string[]>;
|
|
123
|
+
/** Derive predicate-readable fields from a bare id when its record is absent. */
|
|
124
|
+
idFields?: (id: string) => EvidenceRecord;
|
|
125
|
+
}): string[];
|
|
126
|
+
/** A named set of row identities, built from arm rows and an event predicate. */
|
|
127
|
+
type SetExpr = {
|
|
128
|
+
kind: 'rows-where';
|
|
129
|
+
arm: string;
|
|
130
|
+
event: Predicate;
|
|
131
|
+
} | {
|
|
132
|
+
kind: 'intersect';
|
|
133
|
+
of: SetExpr[];
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* What the experiment measures. Every estimand names the fields it reads, so
|
|
137
|
+
* the sealed tree records the full data dependency of the number.
|
|
138
|
+
*/
|
|
139
|
+
type Estimand = {
|
|
140
|
+
kind: 'rate';
|
|
141
|
+
event: Predicate;
|
|
142
|
+
over: 'rollouts';
|
|
143
|
+
} | {
|
|
144
|
+
kind: 'rate-at-least-once';
|
|
145
|
+
event: Predicate;
|
|
146
|
+
groupBy: string;
|
|
147
|
+
} | {
|
|
148
|
+
kind: 'paired-mean-diff';
|
|
149
|
+
armField: string;
|
|
150
|
+
treatment: string;
|
|
151
|
+
control: string;
|
|
152
|
+
pairBy: string;
|
|
153
|
+
/**
|
|
154
|
+
* Field path to the per-row outcome. A boolean reads as 1 or 0, so a
|
|
155
|
+
* binary pass/fail outcome gives the risk difference directly.
|
|
156
|
+
*/
|
|
157
|
+
value: string;
|
|
158
|
+
/** A pair one arm did not answer contributes a difference of exactly zero. */
|
|
159
|
+
missing: 'zero-diff';
|
|
160
|
+
} | {
|
|
161
|
+
kind: 'set-ratio';
|
|
162
|
+
armField: string;
|
|
163
|
+
idField: string;
|
|
164
|
+
numerator: SetExpr;
|
|
165
|
+
denominator: SetExpr;
|
|
166
|
+
};
|
|
167
|
+
interface EstimandResult {
|
|
168
|
+
value: number;
|
|
169
|
+
numerator: number;
|
|
170
|
+
denominator: number;
|
|
171
|
+
}
|
|
172
|
+
/** Compute an estimand over evidence rows. Pure; reads only registered fields. */
|
|
173
|
+
declare function computeEstimand(estimand: Estimand, rows: readonly EvidenceRecord[]): EstimandResult;
|
|
174
|
+
/** How uncertainty is computed. The seed is part of the registration. */
|
|
175
|
+
type IntervalSpec = {
|
|
176
|
+
kind: 'cluster-bootstrap';
|
|
177
|
+
clusterBy: string;
|
|
178
|
+
/** Registered numeric or boolean outcome field, including a prepared paired difference. */
|
|
179
|
+
value: string;
|
|
180
|
+
resamples: number;
|
|
181
|
+
seed: number;
|
|
182
|
+
level: number;
|
|
183
|
+
method: 'percentile';
|
|
184
|
+
} | {
|
|
185
|
+
kind: 'clopper-pearson';
|
|
186
|
+
level: number;
|
|
187
|
+
};
|
|
188
|
+
interface ComputedInterval {
|
|
189
|
+
lower: number;
|
|
190
|
+
upper: number;
|
|
191
|
+
level: number;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Execute an interval spec.
|
|
195
|
+
*
|
|
196
|
+
* Cluster-bootstrap resamples whole clusters of its registered `value` field and
|
|
197
|
+
* takes percentile bounds of the pooled mean. Clopper-Pearson computes the
|
|
198
|
+
* exact binomial interval and requires `successes`/`trials` evidence instead
|
|
199
|
+
* of rows.
|
|
200
|
+
*/
|
|
201
|
+
declare function computeInterval(spec: IntervalSpec, evidence: {
|
|
202
|
+
kind: 'rows';
|
|
203
|
+
rows: readonly EvidenceRecord[];
|
|
204
|
+
} | {
|
|
205
|
+
kind: 'binomial';
|
|
206
|
+
successes: number;
|
|
207
|
+
trials: number;
|
|
208
|
+
}): ComputedInterval;
|
|
209
|
+
/** Decision guards read only named derived quantities — never raw rows. */
|
|
210
|
+
type Condition = {
|
|
211
|
+
kind: 'interval-excludes-zero';
|
|
212
|
+
interval: string;
|
|
213
|
+
sign: 'positive' | 'negative';
|
|
214
|
+
} | {
|
|
215
|
+
kind: 'interval-includes-zero';
|
|
216
|
+
interval: string;
|
|
217
|
+
} | {
|
|
218
|
+
kind: 'quantity-threshold';
|
|
219
|
+
quantity: string;
|
|
220
|
+
op: 'gte' | 'lte' | 'gt' | 'lt';
|
|
221
|
+
value: number;
|
|
222
|
+
} | {
|
|
223
|
+
kind: 'obligation-met';
|
|
224
|
+
obligation: string;
|
|
225
|
+
} | {
|
|
226
|
+
kind: 'all';
|
|
227
|
+
of: Condition[];
|
|
228
|
+
} | {
|
|
229
|
+
kind: 'any';
|
|
230
|
+
of: Condition[];
|
|
231
|
+
} | {
|
|
232
|
+
kind: 'not';
|
|
233
|
+
of: Condition;
|
|
234
|
+
};
|
|
235
|
+
/** The named quantities a decision rule may read. Nothing else reaches it. */
|
|
236
|
+
interface DerivedQuantities {
|
|
237
|
+
intervals: Record<string, {
|
|
238
|
+
lower: number;
|
|
239
|
+
upper: number;
|
|
240
|
+
}>;
|
|
241
|
+
quantities: Record<string, number>;
|
|
242
|
+
obligationsMet: Record<string, boolean>;
|
|
243
|
+
}
|
|
244
|
+
declare function evaluateCondition(condition: Condition, evidence: DerivedQuantities): boolean;
|
|
245
|
+
interface DecisionBranch {
|
|
246
|
+
when: Condition;
|
|
247
|
+
verdict: string;
|
|
248
|
+
report: string[];
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Ordered decision table: the first branch whose condition holds fires, and a
|
|
252
|
+
* table no branch matches throws — a non-total registration is a defect, not
|
|
253
|
+
* an implicit verdict. `report-only` registers the ABSENCE of a verdict
|
|
254
|
+
* branch: the estimate and the per-row table are the finding, and the
|
|
255
|
+
* registered meaning prose rides as non-executable interpretation data.
|
|
256
|
+
*/
|
|
257
|
+
type DecisionRule = {
|
|
258
|
+
kind: 'table';
|
|
259
|
+
branches: DecisionBranch[];
|
|
260
|
+
} | {
|
|
261
|
+
kind: 'report-only';
|
|
262
|
+
estimands: string[];
|
|
263
|
+
intervals: string[];
|
|
264
|
+
perRow: string[];
|
|
265
|
+
interpretation?: {
|
|
266
|
+
onQualitative: string;
|
|
267
|
+
consequence: string;
|
|
268
|
+
}[];
|
|
269
|
+
};
|
|
270
|
+
interface DecisionOutcome {
|
|
271
|
+
verdict: string;
|
|
272
|
+
report: string[];
|
|
273
|
+
}
|
|
274
|
+
declare function executeDecisionRule(rule: DecisionRule, evidence: DerivedQuantities): DecisionOutcome;
|
|
275
|
+
/** A registered control that must exist before a class of verdicts is read. */
|
|
276
|
+
interface Obligation {
|
|
277
|
+
id: string;
|
|
278
|
+
appliesToVerdicts: string[];
|
|
279
|
+
control: string;
|
|
280
|
+
}
|
|
281
|
+
/** Pre-spend design checks. Each returns pass/fail plus its evidence. */
|
|
282
|
+
type ValidityGate = {
|
|
283
|
+
kind: 'oracle-determinism';
|
|
284
|
+
unit: 'suite' | 'assertion';
|
|
285
|
+
replicates: number;
|
|
286
|
+
maxFlipRate: number;
|
|
287
|
+
} | {
|
|
288
|
+
kind: 'population-reproducibility';
|
|
289
|
+
joinOn: string;
|
|
290
|
+
compare: string[];
|
|
291
|
+
maxChangedRows: number;
|
|
292
|
+
} | {
|
|
293
|
+
kind: 'provenance-assertion';
|
|
294
|
+
claim: Predicate;
|
|
295
|
+
} | {
|
|
296
|
+
kind: 'power-floor';
|
|
297
|
+
target: number;
|
|
298
|
+
/** Minimum worthwhile effect; must be represented exactly in effectGrid. */
|
|
299
|
+
minimumEffect: number;
|
|
300
|
+
effectGrid: number[];
|
|
301
|
+
sim: {
|
|
302
|
+
trials: number;
|
|
303
|
+
resamples: number;
|
|
304
|
+
seed: number;
|
|
305
|
+
};
|
|
306
|
+
} | {
|
|
307
|
+
kind: 'identity';
|
|
308
|
+
field: 'served-model';
|
|
309
|
+
op: 'basename-eq';
|
|
310
|
+
onFail: 'abort';
|
|
311
|
+
};
|
|
312
|
+
interface GateResult {
|
|
313
|
+
id: string;
|
|
314
|
+
passed: boolean;
|
|
315
|
+
evidence: JsonValue;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Replicate-flip counting over graded states. A state whose replicates split
|
|
319
|
+
* between pass and fail is flipping; its flip rate is the minority share.
|
|
320
|
+
*/
|
|
321
|
+
declare function evaluateOracleDeterminismGate(id: string, gate: Extract<ValidityGate, {
|
|
322
|
+
kind: 'oracle-determinism';
|
|
323
|
+
}>, repsByState: Record<string, readonly boolean[]>): GateResult;
|
|
324
|
+
/**
|
|
325
|
+
* Join two population snapshots on `joinOn` and compare the registered fields.
|
|
326
|
+
* Only rows present in both snapshots are compared; a presence change is a
|
|
327
|
+
* different failure and needs its own gate.
|
|
328
|
+
*/
|
|
329
|
+
declare function evaluatePopulationReproducibilityGate(id: string, gate: Extract<ValidityGate, {
|
|
330
|
+
kind: 'population-reproducibility';
|
|
331
|
+
}>, populations: {
|
|
332
|
+
left: readonly EvidenceRecord[];
|
|
333
|
+
right: readonly EvidenceRecord[];
|
|
334
|
+
}): GateResult;
|
|
335
|
+
/** The registered claim about provenance must hold on the provenance record. */
|
|
336
|
+
declare function evaluateProvenanceGate(id: string, gate: Extract<ValidityGate, {
|
|
337
|
+
kind: 'provenance-assertion';
|
|
338
|
+
}>, provenance: EvidenceRecord): GateResult;
|
|
339
|
+
/** Final path segment equality between the pinned and the served identity. */
|
|
340
|
+
declare function evaluateIdentityGate(id: string, _gate: Extract<ValidityGate, {
|
|
341
|
+
kind: 'identity';
|
|
342
|
+
}>, identities: {
|
|
343
|
+
pinned: string;
|
|
344
|
+
served: string;
|
|
345
|
+
}): GateResult;
|
|
346
|
+
/**
|
|
347
|
+
* The design's power at minimumEffect must reach the registered target.
|
|
348
|
+
* The curve must cover the registered effect grid exactly — a curve
|
|
349
|
+
* computed on a different grid is different evidence and is refused.
|
|
350
|
+
*/
|
|
351
|
+
declare function evaluatePowerFloorGate(id: string, gate: Extract<ValidityGate, {
|
|
352
|
+
kind: 'power-floor';
|
|
353
|
+
}>, curve: readonly {
|
|
354
|
+
effect: number;
|
|
355
|
+
power: number;
|
|
356
|
+
}[]): GateResult;
|
|
357
|
+
/** Checks as prerequisites: any named gate failing refuses the spend. */
|
|
358
|
+
interface HaltRule {
|
|
359
|
+
when: {
|
|
360
|
+
kind: 'any-gate-failed';
|
|
361
|
+
gates: string[];
|
|
362
|
+
};
|
|
363
|
+
action: 'refuse-spend';
|
|
364
|
+
report: 'settling-n';
|
|
365
|
+
}
|
|
366
|
+
interface HaltOutcome {
|
|
367
|
+
fired: boolean;
|
|
368
|
+
action: 'refuse-spend' | null;
|
|
369
|
+
failedGates: string[];
|
|
370
|
+
}
|
|
371
|
+
declare function evaluateHaltRule(halt: HaltRule, gates: readonly GateResult[]): HaltOutcome;
|
|
372
|
+
/**
|
|
373
|
+
* Spend schedules as data. `ledger` names every entry the ceiling counts, so
|
|
374
|
+
* what the gate reads is registered, not improvised at gate time.
|
|
375
|
+
*/
|
|
376
|
+
type BudgetRule = {
|
|
377
|
+
kind: 'uniform-pass';
|
|
378
|
+
ceilingUsd: number;
|
|
379
|
+
maxPasses: number;
|
|
380
|
+
projection: 'last-pass-cost';
|
|
381
|
+
costSource: 'priced-per-call';
|
|
382
|
+
ledger: {
|
|
383
|
+
id: string;
|
|
384
|
+
usd: number;
|
|
385
|
+
}[];
|
|
386
|
+
partialPass: 'report-never-lift';
|
|
387
|
+
} | {
|
|
388
|
+
kind: 'n-ladder';
|
|
389
|
+
steps: number[];
|
|
390
|
+
ceilingUsd: number;
|
|
391
|
+
projection: 'unit-cost-times-rows-times-n';
|
|
392
|
+
onExhaust: 'refuse-report-projection';
|
|
393
|
+
};
|
|
394
|
+
interface UniformPassDecision {
|
|
395
|
+
pass: number;
|
|
396
|
+
cumulativeBefore: number;
|
|
397
|
+
projected: number;
|
|
398
|
+
go: boolean;
|
|
399
|
+
}
|
|
400
|
+
interface UniformPassSchedule {
|
|
401
|
+
decisions: UniformPassDecision[];
|
|
402
|
+
uniformN: number;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Execute the uniform-pass schedule against measured pass costs. Pass 1 always
|
|
406
|
+
* runs; each later pass runs only when the cumulative spend plus the last
|
|
407
|
+
* measured pass cost stays at or under the registered ceiling. The registered
|
|
408
|
+
* ledger is the pre-spend the ceiling counts.
|
|
409
|
+
*/
|
|
410
|
+
declare function runUniformPassBudget(rule: Extract<BudgetRule, {
|
|
411
|
+
kind: 'uniform-pass';
|
|
412
|
+
}>, measuredPassCosts: readonly number[]): UniformPassSchedule;
|
|
413
|
+
interface NLadderProjection {
|
|
414
|
+
chosenN: number | null;
|
|
415
|
+
projections: {
|
|
416
|
+
n: number;
|
|
417
|
+
projectedUsd: number;
|
|
418
|
+
affordable: boolean;
|
|
419
|
+
}[];
|
|
420
|
+
refusal: null | {
|
|
421
|
+
onExhaust: 'refuse-report-projection';
|
|
422
|
+
reason: string;
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Walk the registered n-ladder and pick the first affordable step. When no
|
|
427
|
+
* step fits the ceiling, the rule refuses and reports the projection instead
|
|
428
|
+
* of shrinking the row set — "never subset rows" is the registered invariant.
|
|
429
|
+
*/
|
|
430
|
+
declare function projectNLadderBudget(rule: Extract<BudgetRule, {
|
|
431
|
+
kind: 'n-ladder';
|
|
432
|
+
}>, measured: {
|
|
433
|
+
unitCostUsd: number;
|
|
434
|
+
rows: number;
|
|
435
|
+
}): NLadderProjection;
|
|
436
|
+
/** Arm budget matching as a refusal, not prose. Verified by `verifyMatchedBudgets`. */
|
|
437
|
+
interface MatchedBudgetRule {
|
|
438
|
+
measure: 'realized-tokens';
|
|
439
|
+
tolerance: number;
|
|
440
|
+
onFail: 'refuse-contrast';
|
|
441
|
+
}
|
|
442
|
+
/** Carrier faults are reissued; model outcomes stand. Closed enumeration. */
|
|
443
|
+
interface ReissuePolicy {
|
|
444
|
+
carrierEvents: ('http-status' | 'transport-error' | 'deadline' | 'empty-content')[];
|
|
445
|
+
modelOutcomesStand: true;
|
|
446
|
+
maxIssues: number;
|
|
447
|
+
}
|
|
448
|
+
type ReissueVerdict = 'reissue' | 'stands' | 'exhausted';
|
|
449
|
+
/**
|
|
450
|
+
* Classify one rollout event under the registered reissue policy. A carrier
|
|
451
|
+
* event within the issue budget is reissued; a model outcome always stands;
|
|
452
|
+
* a carrier event past `maxIssues` is exhausted and reported, never retried.
|
|
453
|
+
*/
|
|
454
|
+
declare function classifyReissue(policy: ReissuePolicy, event: string, issuesSoFar: number): ReissueVerdict;
|
|
455
|
+
//#endregion
|
|
456
|
+
export { classifyReissue as A, evaluateProvenanceGate as B, ReissuePolicy as C, UniformPassDecision as D, SetExpr as E, evaluateIdentityGate as F, runUniformPassBudget as G, projectNLadderBudget as H, evaluateOracleDeterminismGate as I, evaluatePopulationReproducibilityGate as L, computeInterval as M, evaluateCondition as N, UniformPassSchedule as O, evaluateHaltRule as P, evaluatePowerFloorGate as R, Predicate as S, SelectionRule as T, readField as U, executeDecisionRule as V, runSelectionRule as W, IntervalSpec as _, ComputedInterval as a, NLadderProjection as b, DecisionOutcome as c, Estimand as d, EstimandResult as f, HaltRule as g, HaltOutcome as h, BudgetRule as i, computeEstimand as j, ValidityGate as k, DecisionRule as l, GateResult as m, AdmissionRule as n, Condition as o, EvidenceRecord as p, AdmissionStage as r, DecisionBranch as s, AdmissionPartition as t, DerivedQuantities as u, JsonValue as v, ReissueVerdict as w, Obligation as x, MatchedBudgetRule as y, evaluatePredicate as z };
|
|
457
|
+
//# sourceMappingURL=ast-hI-vjW6J.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-hI-vjW6J.d.ts","names":[],"sources":["../src/experiment/ast.ts"],"mappings":";;;;;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C"}
|
|
@@ -3,15 +3,16 @@ import { a as hashCanonical, i as compareCodeUnits, o as jsonDocument, r as cano
|
|
|
3
3
|
import { r as pairedBootstrap } from "./paired-tests-C8iCsioC.js";
|
|
4
4
|
import { a as resolveModelPricing } from "./metrics-Qv-cpptD.js";
|
|
5
5
|
import { a as CostLedgerPersistenceError, i as CostLedger, n as CostCallConflictError, o as CostReceiptCaptureError, r as CostCeilingReachedError, s as CostReservationExceededError, t as CostAccountingIncompleteError } from "./cost-ledger-B1qx30B4.js";
|
|
6
|
-
import { c as withLedgerFileLock, l as writeLedgerFileAtomically } from "./
|
|
7
|
-
import
|
|
6
|
+
import { c as withLedgerFileLock, l as writeLedgerFileAtomically } from "./journal-Cs9f7385.js";
|
|
7
|
+
import "./ledger-core/index.js";
|
|
8
|
+
import { S as fsCampaignStorage, i as startExternalOptimizerModelProxy, r as runWithCleanup, x as createRunCostLedger, y as resolveExternalOptimizerProcessLimits } from "./external-optimizer-subprocess-D4dzUBZI.js";
|
|
8
9
|
import { r as makeFinding, s as usageReceiptFromCostLedger } from "./types-DQ0e2E7y.js";
|
|
9
10
|
import { M as RawAnalystFindingSchema, N as evidenceRefsFromRawFinding, h as TRACE_ANALYSIS_LIMITS, j as RAW_FINDING_SCHEMA_PROMPT, r as runTraceAnalyst } from "./kind-factory-D5HOW3R0.js";
|
|
10
11
|
import { a as callLlmJson, r as LlmResponseError, t as LlmCallError } from "./llm-client-CGlSi8sb.js";
|
|
11
|
-
import { t as createDspyRlmTraceEngine } from "./dspy-rlm-engine-
|
|
12
|
+
import { t as createDspyRlmTraceEngine } from "./dspy-rlm-engine-S53V0HhE.js";
|
|
12
13
|
import { i as otlpTextToTraceAnalysisStore, r as createOtlpBufferTraceStore, t as DEFAULT_MAX_TRACE_FILE_BYTES } from "./store-otlp-DWGUwlyj.js";
|
|
13
14
|
import { i as summarizeAnalystBenchmarkRunner, n as runAnalystBenchmark, r as traceStoreEvidenceResolver } from "./benchmark-DQKzykkO.js";
|
|
14
|
-
import { n as acquireSingleRunLock } from "./external-optimizer-process-
|
|
15
|
+
import { n as acquireSingleRunLock } from "./external-optimizer-process-QDRURJAM.js";
|
|
15
16
|
import { c as primeProtocolSha256, d as runPrimeExchange, f as decodeReplyRows, n as buildPrimePrompt, p as assertEqualDeclarativeTerms, t as analystUsageReceiptFromPrimeUsage, u as projectPrimeTrajectory } from "./prime-protocol-6tZTVsWm.js";
|
|
16
17
|
import { createHash, randomUUID } from "node:crypto";
|
|
17
18
|
import { constants, existsSync, lstatSync, readFileSync } from "node:fs";
|
|
@@ -1412,7 +1413,7 @@ const ANALYST_BENCHMARK_DEPENDENCY_LOCK_FILES = Object.freeze([
|
|
|
1412
1413
|
"package.json",
|
|
1413
1414
|
"pnpm-lock.yaml"
|
|
1414
1415
|
]);
|
|
1415
|
-
const ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256 = "
|
|
1416
|
+
const ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256 = "39632afc0f02da9333079d4c6323bab101d1bd0eb47a0ea06fa910ae181b4b40";
|
|
1416
1417
|
const ANALYST_BENCHMARK_EVIDENCE_DEPENDENCY_LOCK_SHA256 = "1e03f2daed356d60316aabefb407ec1e437ac94d408d61eea4ae096e9c6fbb5b";
|
|
1417
1418
|
const ANALYST_BENCHMARK_EVIDENCE_IMPLEMENTATION_SHA256 = "4dba263b6256a30d56c7fdb2d992d3a953c0035d731f359b704db806f68f75ac";
|
|
1418
1419
|
const ANALYST_BENCHMARK_IMPLEMENTATION_FILES = Object.freeze([
|
|
@@ -6351,4 +6352,4 @@ function shellQuote(value) {
|
|
|
6351
6352
|
//#endregion
|
|
6352
6353
|
export { ANALYST_BENCHMARK_LOCAL_RECEIPT_FILE as $, effectiveAnalystProtocolSha256 as A, loadCodeTraceVerificationArtifacts as B, adaptPublicBenchmarkFindings as C, renderCodeTraceCalibrationMarkdown as D, readAnalystBenchmarkArtifact as E, publicBenchmarkProtocolSha256 as F, ANALYST_BENCHMARK_EVIDENCE_DEPENDENCY_LOCK_SHA256 as G, ANALYST_BENCHMARK_DEPENDENCY_LOCK_DIGEST_ALGORITHM as H, publicBenchmarkRlmInstructions as I, ANALYST_BENCHMARK_IMPLEMENTATION_FILES as J, ANALYST_BENCHMARK_EVIDENCE_IMPLEMENTATION_SHA256 as K, publicBenchmarkSystemPrompt as L, CODE_TRACE_BENCH_ANALYST_PROMPT as M, MAX_INCORRECT_BLOCKS as N, summarizeCodeTraceCalibration as O, MAX_INCORRECT_BLOCK_STEPS as P, ANALYST_BENCHMARK_COST_LEDGER_FILE as Q, DEFAULT_MAX_VERIFICATION_ARTIFACT_BYTES as R, analystDefinitionProtocolSha256 as S, expandCodeTraceFailureBlocks as T, ANALYST_BENCHMARK_DEPENDENCY_LOCK_FILES as U, parseVerificationOutcome as V, ANALYST_BENCHMARK_DEPENDENCY_LOCK_SHA256 as W, analystBenchmarkDependencyLockDigest as X, ANALYST_BENCHMARK_IMPLEMENTATION_SHA256 as Y, analystBenchmarkImplementationDigest as Z, createPublicBenchmarkDirectRunner as _, primeCodeTraceAnalystDefinition as a, summarizeAgentRxCalibration as at, AnalystExpressivenessError as b, loadPublicBenchmarkRows as c, agentRxBenchmarkCase as ct, publicBenchmarkSelectionReport as d, roundAgentRxStep as dt, ANALYST_BENCHMARK_MANIFEST_FILE as et, selectPublicBenchmarkRows as f, normalizeBenchmarkLabel as ft, runReplVariableAnalystDefinition as g, rlmEngineLimits as h, primeAnalystProtocolSha256 as i, renderAgentRxCalibrationMarkdown as it, readAnalystInstructionsOverride as j, analystInstructionsOverrideFromText as k, preparePublicAnalystBenchmark as l, agentRxPredictionsToFindings as lt, publicRlmAnalystDefinition as m, renderAnalystBenchmarkMarkdown as n, compareAnalystRunners as nt, runInlineAnalystDefinition as o, codeTraceBenchCase as ot, createPublicBenchmarkRlmRunner as p, ANALYST_BENCHMARK_IMPLEMENTATION_DIGEST_ALGORITHM as q, createPrimeBenchmarkRunner as r, AGENT_RX_UPSTREAM_REVISION as rt, nodeHttpPrimeBridgeTransport as s, codeTracerPredictionsToFindings as st, runAnalystBenchmarkCommand as t, ANALYST_BENCHMARK_OBSERVATIONS_FILE as tt, publicBenchmarkDistributions as u, normalizeAgentRxCategory as ut, publicDirectAnalystDefinition as v, emptyPublicBenchmarkRunner as w, analystDefinitionAsymmetries as x, runChunkedAnalystDefinition as y, appendVerificationArtifactsToOtlp as z };
|
|
6353
6354
|
|
|
6354
|
-
//# sourceMappingURL=benchmark-command-
|
|
6355
|
+
//# sourceMappingURL=benchmark-command-B57n9vjz.js.map
|