@sema-agent/core 5.20.0 → 5.21.1

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.
Files changed (313) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/agents/agent-definition.d.ts +7 -0
  3. package/dist/agents/agent-transcript-tool.d.ts +30 -0
  4. package/dist/agents/builtin-agents.d.ts +60 -0
  5. package/dist/agents/cascade.d.ts +107 -0
  6. package/dist/agents/cumulative-stats.d.ts +56 -0
  7. package/dist/agents/observer.d.ts +162 -0
  8. package/dist/agents/peer-admission.d.ts +95 -0
  9. package/dist/agents/repair-loop.d.ts +226 -0
  10. package/dist/agents/retain-ledger.d.ts +141 -0
  11. package/dist/agents/roster-store.d.ts +105 -0
  12. package/dist/agents/send-message-tool.d.ts +92 -0
  13. package/dist/agents/session-util.d.ts +5 -0
  14. package/dist/agents/subagent-steps.d.ts +66 -0
  15. package/dist/agents/subagent.d.ts +600 -0
  16. package/dist/agents/suspend-guard.d.ts +29 -0
  17. package/dist/agents/teacher.d.ts +75 -0
  18. package/dist/agents/team.d.ts +120 -1
  19. package/dist/agents/tool-filter.d.ts +34 -0
  20. package/dist/agents/verify.d.ts +198 -0
  21. package/dist/bench/metrics.d.ts +455 -0
  22. package/dist/brain/anthropic.d.ts +30 -0
  23. package/dist/brain/circuit-breaker.d.ts +33 -0
  24. package/dist/brain/context-overflow.d.ts +60 -3
  25. package/dist/brain/degrading.d.ts +67 -0
  26. package/dist/brain/errors.d.ts +42 -0
  27. package/dist/brain/failover.d.ts +15 -0
  28. package/dist/brain/media-degrade.d.ts +39 -0
  29. package/dist/brain/model-presets.d.ts +31 -0
  30. package/dist/brain/open-responses.d.ts +19 -0
  31. package/dist/brain/openai.d.ts +46 -0
  32. package/dist/brain/reasoning.d.ts +106 -1
  33. package/dist/brain/repetition.d.ts +83 -0
  34. package/dist/brain/request-params.d.ts +56 -0
  35. package/dist/brain/retry.d.ts +46 -0
  36. package/dist/brain/routing.d.ts +12 -0
  37. package/dist/brain/status-sink.d.ts +30 -1
  38. package/dist/brain/stream-engine.d.ts +147 -0
  39. package/dist/brain/stream-shared.d.ts +34 -0
  40. package/dist/brain/terminal-cause.d.ts +31 -0
  41. package/dist/brain/timeout.d.ts +107 -0
  42. package/dist/brain/tool-call-id.d.ts +20 -0
  43. package/dist/brain/tool-call-repair.d.ts +13 -0
  44. package/dist/config/catalog.d.ts +47 -0
  45. package/dist/config/defaults.d.ts +33 -0
  46. package/dist/core/a2a-task-state.d.ts +53 -0
  47. package/dist/core/a2a.d.ts +51 -0
  48. package/dist/core/arg-summary.d.ts +62 -0
  49. package/dist/core/ask-question.d.ts +272 -2
  50. package/dist/core/auto-compaction.d.ts +467 -0
  51. package/dist/core/auto-compaction.js +20 -6
  52. package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
  53. package/dist/core/auto-mode-prompt.d.ts +27 -0
  54. package/dist/core/auto-mode.d.ts +54 -3
  55. package/dist/core/auto-promote.d.ts +100 -0
  56. package/dist/core/background-agent-store.d.ts +292 -0
  57. package/dist/core/background-shell.d.ts +110 -0
  58. package/dist/core/cache-break-detector.d.ts +34 -0
  59. package/dist/core/canonical-json.d.ts +57 -0
  60. package/dist/core/checkpoint-store.d.ts +1574 -16
  61. package/dist/core/compliance.d.ts +30 -0
  62. package/dist/core/consolidate-scope.d.ts +75 -0
  63. package/dist/core/context-edit.d.ts +99 -0
  64. package/dist/core/context-guard.d.ts +46 -0
  65. package/dist/core/exec-gate.d.ts +44 -0
  66. package/dist/core/exec-output-tail.d.ts +61 -0
  67. package/dist/core/file-snapshot-store.d.ts +104 -0
  68. package/dist/core/fs-write-gate-policy.d.ts +36 -0
  69. package/dist/core/git-worktree-env.d.ts +31 -0
  70. package/dist/core/governance-codes.d.ts +19 -0
  71. package/dist/core/hooks.d.ts +608 -1
  72. package/dist/core/human-input-projection.d.ts +37 -0
  73. package/dist/core/human-input-projection.js +13 -0
  74. package/dist/core/image-downsample.d.ts +74 -0
  75. package/dist/core/locked-config.d.ts +37 -0
  76. package/dist/core/lsp-diagnostics.d.ts +77 -0
  77. package/dist/core/lsp-protocol.d.ts +29 -0
  78. package/dist/core/lsp-session.d.ts +60 -1
  79. package/dist/core/lsp.d.ts +150 -1
  80. package/dist/core/mailbox-store.d.ts +57 -0
  81. package/dist/core/mcp.d.ts +381 -0
  82. package/dist/core/media-byte-cap.d.ts +21 -0
  83. package/dist/core/memory-admission.d.ts +71 -0
  84. package/dist/core/memory-engine/content-origin.d.ts +64 -0
  85. package/dist/core/memory-engine/data-plane.d.ts +43 -0
  86. package/dist/core/memory-engine/dual-root.d.ts +24 -0
  87. package/dist/core/memory-engine/engine.d.ts +230 -0
  88. package/dist/core/memory-engine/engine.js +103 -35
  89. package/dist/core/memory-engine/file-backend.d.ts +155 -0
  90. package/dist/core/memory-engine/frontmatter.d.ts +16 -0
  91. package/dist/core/memory-engine/layout.d.ts +217 -0
  92. package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
  93. package/dist/core/memory-engine/migrate.d.ts +9 -0
  94. package/dist/core/memory-engine/scan.d.ts +12 -0
  95. package/dist/core/memory-engine/scope-contract.d.ts +61 -1
  96. package/dist/core/memory-engine/sync-client.d.ts +87 -0
  97. package/dist/core/memory-engine/sync.d.ts +60 -0
  98. package/dist/core/memory-engine/tools.d.ts +41 -0
  99. package/dist/core/memory-engine/types.d.ts +188 -0
  100. package/dist/core/memory-recall.d.ts +141 -0
  101. package/dist/core/memory-vector.d.ts +20 -0
  102. package/dist/core/memory.d.ts +458 -0
  103. package/dist/core/message-utils.d.ts +6 -0
  104. package/dist/core/oracle-isolation.d.ts +69 -0
  105. package/dist/core/permission-rule-consent.d.ts +138 -0
  106. package/dist/core/permission-rule-model.d.ts +122 -0
  107. package/dist/core/permission-rule-store.d.ts +119 -3
  108. package/dist/core/permission-rules.d.ts +87 -1
  109. package/dist/core/present-plan-tool.d.ts +20 -0
  110. package/dist/core/pricing.d.ts +26 -0
  111. package/dist/core/property-harness.d.ts +86 -0
  112. package/dist/core/protocol-naming.d.ts +38 -0
  113. package/dist/core/protocol-table.d.ts +61 -0
  114. package/dist/core/push-queue.d.ts +1 -0
  115. package/dist/core/remote-env.d.ts +383 -1
  116. package/dist/core/retention-policy.d.ts +33 -0
  117. package/dist/core/retention.d.ts +51 -0
  118. package/dist/core/roles.d.ts +59 -0
  119. package/dist/core/runner/active-skill-scope.d.ts +34 -0
  120. package/dist/core/runner/assemble-result.d.ts +134 -0
  121. package/dist/core/runner/compaction-call-options.d.ts +97 -1
  122. package/dist/core/runner/grounding-signal.d.ts +10 -0
  123. package/dist/core/runner/image.d.ts +17 -0
  124. package/dist/core/runner/image.js +29 -15
  125. package/dist/core/runner/memory-consolidation.d.ts +60 -0
  126. package/dist/core/runner/prepare-memory.d.ts +59 -0
  127. package/dist/core/runner/prepare-task.d.ts +1011 -2
  128. package/dist/core/runner/prepare-task.js +12 -11
  129. package/dist/core/runner/prompt-suggestions.d.ts +7 -0
  130. package/dist/core/runner/runtask.d.ts +304 -3
  131. package/dist/core/runner/session-file-state-replay.d.ts +49 -0
  132. package/dist/core/runner/session-rule-policy.d.ts +58 -0
  133. package/dist/core/runner/strict-output-schema.d.ts +18 -3
  134. package/dist/core/runner/synthetic-tools.d.ts +113 -0
  135. package/dist/core/runner/teardown-bounded.d.ts +34 -0
  136. package/dist/core/runner/tool-disclosure.d.ts +227 -0
  137. package/dist/core/runner/tool-output-projection.d.ts +6 -0
  138. package/dist/core/runner/turn-attachments.d.ts +634 -0
  139. package/dist/core/runner/usage-accounting.d.ts +32 -0
  140. package/dist/core/runtime.d.ts +9 -0
  141. package/dist/core/safe-notify.d.ts +64 -0
  142. package/dist/core/safety-axis-vocab.d.ts +23 -0
  143. package/dist/core/safety-merge-corpus.d.ts +37 -0
  144. package/dist/core/scheduler.d.ts +121 -0
  145. package/dist/core/secret-env.d.ts +32 -0
  146. package/dist/core/select-model.d.ts +15 -0
  147. package/dist/core/sensitive-path-policy.d.ts +42 -0
  148. package/dist/core/session-policy-store.d.ts +94 -0
  149. package/dist/core/session-reconcile.d.ts +80 -0
  150. package/dist/core/session-store.d.ts +85 -0
  151. package/dist/core/session.d.ts +153 -0
  152. package/dist/core/shared-memory/contract.d.ts +22 -0
  153. package/dist/core/shared-memory/normalize.d.ts +123 -2
  154. package/dist/core/shared-memory/tools.d.ts +14 -0
  155. package/dist/core/shared-memory/types.d.ts +105 -0
  156. package/dist/core/shutdown-debug.d.ts +6 -0
  157. package/dist/core/side-query.d.ts +38 -0
  158. package/dist/core/side-query.js +6 -1
  159. package/dist/core/skill-tool-specifier.d.ts +72 -0
  160. package/dist/core/skills-directory.d.ts +100 -1
  161. package/dist/core/spec-contract.d.ts +89 -0
  162. package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
  163. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
  164. package/dist/core/store-contracts/contract-harness.d.ts +20 -0
  165. package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
  166. package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
  167. package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
  168. package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
  169. package/dist/core/strategy-store.d.ts +37 -0
  170. package/dist/core/stub-env.d.ts +7 -0
  171. package/dist/core/surrogate-safe-slice.d.ts +35 -0
  172. package/dist/core/task-notification.d.ts +202 -0
  173. package/dist/core/task-outcome.d.ts +53 -0
  174. package/dist/core/task-registry-agent.d.ts +337 -1
  175. package/dist/core/task-registry-monitor.d.ts +12 -0
  176. package/dist/core/task-registry-shared.d.ts +540 -0
  177. package/dist/core/task-registry.d.ts +343 -0
  178. package/dist/core/task-registry.js +13 -2
  179. package/dist/core/task-tool-shape.d.ts +44 -0
  180. package/dist/core/tighten-task-spec.d.ts +21 -0
  181. package/dist/core/tool-detach.d.ts +21 -0
  182. package/dist/core/tool-errors.d.ts +131 -0
  183. package/dist/core/tool-errors.js +4 -0
  184. package/dist/core/tool-name-aliases.d.ts +27 -0
  185. package/dist/core/tool-policy.d.ts +555 -0
  186. package/dist/core/tool-result-budget.d.ts +32 -0
  187. package/dist/core/tool-result-store.d.ts +174 -1
  188. package/dist/core/tools.d.ts +45 -0
  189. package/dist/core/trace.d.ts +323 -0
  190. package/dist/core/types.d.ts +3859 -2
  191. package/dist/core/untrusted-egress.d.ts +8 -0
  192. package/dist/core/untrusted-text.d.ts +156 -0
  193. package/dist/core/usage-window-store.d.ts +95 -0
  194. package/dist/core/version.d.ts +1 -0
  195. package/dist/core/warm-resume.d.ts +17 -0
  196. package/dist/core/wiring-manifest.d.ts +169 -0
  197. package/dist/core/with-retry.d.ts +24 -0
  198. package/dist/core/workflow-journal-store.d.ts +160 -0
  199. package/dist/core/workflow-run-store-contract.d.ts +25 -0
  200. package/dist/core/workflow-run-store.d.ts +119 -0
  201. package/dist/engine/compaction/compaction.d.ts +256 -1
  202. package/dist/engine/compaction/utils.d.ts +94 -0
  203. package/dist/engine/execution-env/kill-tree.d.ts +29 -0
  204. package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
  205. package/dist/engine/harness/agent-harness.d.ts +116 -0
  206. package/dist/engine/harness/agent-harness.js +3 -14
  207. package/dist/engine/harness/messages.d.ts +15 -0
  208. package/dist/engine/harness/types.d.ts +464 -2
  209. package/dist/engine/llm/diagnostics.d.ts +4 -0
  210. package/dist/engine/llm/event-stream.d.ts +3 -0
  211. package/dist/engine/llm/index.d.ts +7 -0
  212. package/dist/engine/llm/types.d.ts +500 -3
  213. package/dist/engine/llm/validation.d.ts +3 -0
  214. package/dist/engine/loop/agent-loop.d.ts +87 -2
  215. package/dist/engine/loop/runtime-deps.d.ts +7 -0
  216. package/dist/engine/loop/types.d.ts +424 -0
  217. package/dist/engine/lsp/frame-decoder.d.ts +13 -0
  218. package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
  219. package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
  220. package/dist/engine/session/import-validate.d.ts +27 -0
  221. package/dist/engine/session/log-digest.d.ts +93 -0
  222. package/dist/engine/session/memory-repo.d.ts +6 -0
  223. package/dist/engine/session/memory-storage.d.ts +2 -0
  224. package/dist/engine/session/session.d.ts +75 -0
  225. package/dist/engine/session/storage-base.d.ts +8 -0
  226. package/dist/fixtures/index.d.ts +36 -0
  227. package/dist/index.d.ts +16 -1
  228. package/dist/index.js +0 -1
  229. package/dist/internal/harness-types.d.ts +6 -0
  230. package/dist/internal/harness.d.ts +11 -0
  231. package/dist/internal/llm.d.ts +6 -0
  232. package/dist/orchestration/builtin-workflows.d.ts +53 -0
  233. package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
  234. package/dist/orchestration/goal.d.ts +57 -0
  235. package/dist/orchestration/goal.js +3 -0
  236. package/dist/orchestration/run-spec.d.ts +42 -0
  237. package/dist/orchestration/run-workflow-tool.d.ts +169 -0
  238. package/dist/orchestration/workflow-governance.d.ts +61 -0
  239. package/dist/orchestration/workflow-meta.d.ts +28 -0
  240. package/dist/orchestration/workflow-observe.d.ts +60 -0
  241. package/dist/orchestration/workflow-primitives.d.ts +23 -1
  242. package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
  243. package/dist/orchestration/workflow-script-runner.d.ts +88 -0
  244. package/dist/orchestration/workflow-script-store.d.ts +98 -0
  245. package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
  246. package/dist/orchestration/workflow-types.d.ts +169 -2
  247. package/dist/orchestration/workflow.d.ts +358 -0
  248. package/dist/prompt-assembly/artifact-store.d.ts +33 -0
  249. package/dist/prompt-assembly/artifact.d.ts +25 -0
  250. package/dist/prompt-assembly/assemble.d.ts +20 -0
  251. package/dist/prompt-assembly/composer.d.ts +29 -0
  252. package/dist/prompt-assembly/epoch.d.ts +55 -1
  253. package/dist/prompt-assembly/event-registry.d.ts +35 -0
  254. package/dist/prompt-assembly/explain.d.ts +12 -0
  255. package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
  256. package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
  257. package/dist/prompt-assembly/types.d.ts +115 -0
  258. package/dist/prompts/coordinator.d.ts +27 -0
  259. package/dist/prompts/default.d.ts +539 -0
  260. package/dist/prompts/simple-sections.d.ts +45 -0
  261. package/dist/prompts/supervisor.d.ts +66 -0
  262. package/dist/scenarios/env.d.ts +28 -0
  263. package/dist/scenarios/full-body.d.ts +50 -0
  264. package/dist/scenarios/scenario-registry.d.ts +60 -0
  265. package/dist/scenarios/teacher-quickstart.d.ts +27 -0
  266. package/dist/server/http.d.ts +17 -0
  267. package/dist/stores/cc/lockfile.d.ts +6 -0
  268. package/dist/stores/cc/mailbox-store.d.ts +8 -0
  269. package/dist/stores/cc/roster-adapter.d.ts +4 -0
  270. package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
  271. package/dist/stores/file/background-agent-store.d.ts +24 -0
  272. package/dist/stores/file/checkpoint-store.d.ts +38 -0
  273. package/dist/stores/file/file-snapshot-store.d.ts +25 -0
  274. package/dist/stores/file/fs-atomic.d.ts +155 -0
  275. package/dist/stores/file/index.d.ts +89 -0
  276. package/dist/stores/file/mailbox-store.d.ts +36 -0
  277. package/dist/stores/file/memory-store.d.ts +82 -0
  278. package/dist/stores/file/permission-rule-store.d.ts +79 -0
  279. package/dist/stores/file/session-policy-store.d.ts +28 -0
  280. package/dist/stores/file/session-store.d.ts +40 -0
  281. package/dist/stores/file/shared-ledger.d.ts +83 -0
  282. package/dist/stores/file/tool-result-store.d.ts +11 -0
  283. package/dist/stores/file/usage-window-store.d.ts +18 -0
  284. package/dist/stores/file/workflow-journal-store.d.ts +100 -0
  285. package/dist/stores/file/workflow-run-store.d.ts +11 -0
  286. package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
  287. package/dist/tools/fs/encoding.d.ts +60 -0
  288. package/dist/tools/fs/fs-bash.d.ts +133 -0
  289. package/dist/tools/fs/fs-pdf.d.ts +28 -0
  290. package/dist/tools/fs/fs-search-tools.d.ts +5 -0
  291. package/dist/tools/fs/fs-search-tools.js +0 -1
  292. package/dist/tools/fs/fs-shared.d.ts +360 -0
  293. package/dist/tools/fs/fs-write.d.ts +16 -0
  294. package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
  295. package/dist/tools/fs/index.d.ts +79 -0
  296. package/dist/tools/fs/notebook.d.ts +56 -0
  297. package/dist/tools/fs/pdf.d.ts +70 -0
  298. package/dist/tools/fs/pdf.js +8 -2
  299. package/dist/tools/fs/repo-map.d.ts +10 -0
  300. package/dist/tools/fs/safety.d.ts +376 -0
  301. package/dist/tools/fs/search.d.ts +131 -0
  302. package/dist/tools/loop-tick.d.ts +24 -0
  303. package/dist/tools/monitor.d.ts +55 -0
  304. package/dist/tools/scheduler-tools.d.ts +51 -0
  305. package/dist/tools/sql-adapters.d.ts +18 -0
  306. package/dist/tools/sql.d.ts +25 -0
  307. package/dist/tools/task-list.d.ts +77 -0
  308. package/dist/tools/todo.d.ts +8 -0
  309. package/dist/tools/web.d.ts +184 -0
  310. package/dist/tools/worktree.d.ts +81 -0
  311. package/package.json +2 -2
  312. package/dist/tools/gitea-issue.d.ts +0 -13
  313. package/dist/tools/gitea-issue.js +0 -75
@@ -1,32 +1,159 @@
1
+ /**
2
+ * design/89 §2 — VALUE-JUDGMENT METRICS (the cost-per-truly-correct measurement tool).
3
+ *
4
+ * Pure, deterministic measurement logic for the value-judgment benchmark (design/89, milestone-gap
5
+ * ❓-未判项: "supervisor / multi-agent vs solo 到底值不值?"). The service three-arm harness feeds REAL
6
+ * runs in; this module computes truly-correct / three-class outcomes / cost four-components / Pareto.
7
+ *
8
+ * IRON LAWS (design/89 §2, blood-bought red lines — DO NOT relax):
9
+ * 1. The numerator counts ONLY objective oracles (exec-gate exit-code, build, property-harness, and
10
+ * actual-delivery). LLM-judge is NEVER counted into truly-correct (it is a runtime GATE, not a
11
+ * measurement; §2.2). It burns cost (C1/C2) but never the numerator.
12
+ * 2. NEVER synthesize a single scalar. Cost is FOUR separate components (§2.3); C1 (token µUSD) and
13
+ * C2 (human seconds) are apples + oranges (§2.1) and are NEVER added. The verdict is a 3-D Pareto
14
+ * frontier over (C1, C2.sec, P). A µUSD/tc ratio may be reported ONLY as a per-axis diagnostic.
15
+ * 3. THREE outcome classes (§2.2.1): DELIVERED-CORRECT / DELIVERED-WRONG / CORRECTLY-WITHHELD. A
16
+ * correctly-withheld task (human/gate stopped a would-be DELIVERED-WRONG) is the supervisor's
17
+ * avoided-loss value — it is NOT a failure and NOT in the numerator.
18
+ * 4. Deterministic + testable: this file has zero model/network dependency. Synthetic-run fixtures
19
+ * validate the measurement logic without a real model (see metrics.test.ts).
20
+ *
21
+ * This is a SHADOW-LAB experiment tool (not the core engine). Run via `npx tsx`.
22
+ */
23
+ /**
24
+ * The orchestration arms.
25
+ * - "solo" — no supervision profile (the cost floor / quality-risk baseline).
26
+ * - "sup" — SUP-per-step (S1a): the scripted human gate fires UNCONDITIONALLY at every plan_review +
27
+ * risky tool ask (C2 paid every time). S1a proved this is `dominated` on coding tasks (same P
28
+ * as solo, but pays C2 for nothing the model couldn't get right alone).
29
+ * - "sup-vf" — SUP verifier-first (S1b): the SAME supervision profile, but the scripted human gate is only
30
+ * ESCALATED (C2 paid) when ① a deterministic verifier (the mechanical hidden oracle / RepairOracle
31
+ * / shellGate hazard list) is RED or ② the action hits the danger list (destructive-fs / secret /
32
+ * pipe-to-shell). Otherwise the gate AUTO-ALLOWS with C2=0 (steals reflection/actor-critic + CRITIC:
33
+ * an external deterministic verifier is the critic; the human is the escalation tier only). Hypothesis:
34
+ * on coding tasks where the verifier goes green, SUP-vf collapses C2→~0 and stops being dominated by
35
+ * solo, WHILE keeping the trap-safety CORRECTLY-WITHHELD (the danger list still escalates `rm -rf data`).
36
+ * - "team" — service-deferred (runLeaderTask).
37
+ */
1
38
  export type Arm = "solo" | "sup" | "sup-vf" | "team";
39
+ /**
40
+ * The OBJECTIVE oracle verdicts for one run (design/89 §2.2). These are the four AND criteria.
41
+ * Every field is produced by an external, deterministic oracle run AFTER the agent finishes — never
42
+ * by an LLM-judge. Each is computed by the service harness (it owns exec-gate / build / git) and
43
+ * recorded verbatim; this module only ANDs them.
44
+ */
2
45
  export interface OracleVerdicts {
46
+ /** §2.2 criterion ① — hidden objective test suite all green: `runExecGate` exit==0 over a NON-EMPTY
47
+ * suite. Encode "empty suite / null exit" as `false` (exec-gate never passes those). */
3
48
  hiddenTestsGreen: boolean;
49
+ /** §2.2 criterion ② — build/compile passed (APK assembleOfflineDebug / tsc / gradle build). Guards
50
+ * the "tests green but compile broke" false-positive. */
4
51
  buildPassed: boolean;
52
+ /** §2.2 criterion ③ — mechanical invariants un-violated (property-harness). `true` when no violation
53
+ * OR property-harness is not applicable to this task (the AND must not penalize an N/A task). The
54
+ * harness sets this to `propertyHarnessApplicable ? noViolations : true`. */
5
55
  invariantsOk: boolean;
56
+ /** §2.2 criterion ④ — ACTUALLY DELIVERED: a git commit exists AND the merge does not roll back.
57
+ * "ran but didn't deliver" (run 019ec5d1 触顶蒸发: 104 lines all lost) MUST count 0, else solo is
58
+ * systematically over-estimated. */
6
59
  delivered: boolean;
7
60
  }
61
+ /**
62
+ * Whether the human/gate WITHHELD this run's delivery (design/89 §2.2.1). When `true`, the agent
63
+ * (or a human at an approval gate) correctly DID NOT deliver — the §2.2.1 supervisor-fairness fix:
64
+ * a withheld run that WOULD have been DELIVERED-WRONG is avoided-loss value, not a failure, and is
65
+ * single-listed (not in the numerator, not a failure). Only the SUP/TEAM arms can withhold; for SOLO
66
+ * this is always `false` (no human/gate).
67
+ */
8
68
  export interface DeliveryDecision {
69
+ /** The human/gate stopped/aborted/refused-to-deliver this run. */
9
70
  withheld: boolean;
10
71
  }
72
+ /**
73
+ * design/95 §3.2 — the lifecycle status of a run, so INFRA noise never poisons the mode signal
74
+ * (codex BLOCKER B4 / design/89 §3.3 Beatsep red line). The Beatsep task#2b 9% pass-rate was infra
75
+ * death (OOM / K8S passthrough / nested-root), NOT a mode signal — feeding such runs into the
76
+ * numerator turns them into spurious DELIVERED-WRONG / zero datapoints and reproduces the very noise
77
+ * the design claims to have isolated. `buildReport` SCORES only `scored`; `infra-failed` / `excluded`
78
+ * runs are dropped from every cell/Pareto computation and surfaced as an exclusion ledger.
79
+ *
80
+ * - "scored" — a clean run whose oracle verdict is a real mode signal. The ONLY status scored.
81
+ * - "infra-failed" — OOM / sandbox / passthrough / nested-root death; the agent never got a fair
82
+ * attempt. Excluded; counted in the exclusion ledger with reason "infra-failed".
83
+ * - "excluded" — manually quarantined (e.g. corpusHash drift, approver-policy change mid-batch,
84
+ * a known-bad fixture). Excluded; counted with reason "excluded".
85
+ *
86
+ * ABSENT ⇒ treated as "scored" (back-compat: older RunRecord arrays predate this field).
87
+ */
11
88
  export type RunStatus = "scored" | "infra-failed" | "excluded";
89
+ /** A single run fed in by the service three-arm harness. */
12
90
  export interface RunRecord {
13
91
  arm: Arm;
92
+ /** Task id (for paired-seed grouping / cell folding). */
14
93
  taskId: string;
94
+ /** Repeat/seed index within the cell (design/89 §3.4 N-repeat). */
15
95
  seed?: number | string;
96
+ /**
97
+ * design/95 §3.2 / codex B4 — lifecycle status. Only "scored" runs reach the numerator / cost /
98
+ * Pareto. Absent ⇒ "scored" (back-compat). See {@link RunStatus}.
99
+ */
16
100
  runStatus?: RunStatus;
101
+ /**
102
+ * design/95 §2 (B1 / Simpson's-paradox guard) — the heterogeneity coordinates a run belongs to. The
103
+ * suite is heterogeneous (different archetypes / value-dimensions / difficulties); folding everything
104
+ * into an arm mean can flip a per-cell conclusion (Simpson's paradox), making J1-J5 / JV1-JV4
105
+ * UN-evaluable. `buildReport` groups by `(suiteVersion, taskId, archetype, valueDimension, arm)` and
106
+ * keeps the seed-paired rows; the suite-level rollup is a WEIGHTED summary of scored cells only and is
107
+ * NOT a decision surface. All fields optional for back-compat (a run with none falls into a single
108
+ * "ungrouped" cell, preserving the old single-arm-mean behavior for legacy fixtures).
109
+ */
17
110
  suiteVersion?: string;
18
111
  archetype?: string;
19
112
  valueDimension?: string;
113
+ /** The four objective oracle verdicts (§2.2). */
20
114
  oracle: OracleVerdicts;
115
+ /** Whether delivery was correctly withheld (§2.2.1). */
21
116
  delivery: DeliveryDecision;
117
+ /**
118
+ * The engine-produced `TaskResult.stats` (or the relevant subset). C1 is derived from
119
+ * `stats.costBreakdown` (design/80 D-E-core); C2 from `stats.humanReview` (design/91, 1.110.0 ship).
120
+ * Shape mirrors @sema-agent/core `TaskResult["stats"]` — see {@link CoreStatsSubset}.
121
+ */
22
122
  stats: CoreStatsSubset;
123
+ /** Wall-clock seconds for the whole run (task start→done). The C3 source. */
23
124
  wallTimeSec?: number;
125
+ /** Infra cost in µUSD (E2B vCPU-hr / egress / k8s) — owned & filled by the SERVICE (core never has
126
+ * this). The C4 source. Absent for solo-local / when the service did not measure it. */
24
127
  infraMicroUsd?: number;
128
+ /**
129
+ * §2.4#2 intercept-value counterfactual: for each human intervention on a SUP run, the harness
130
+ * re-runs the same brief + fixed seed with that intervention DISABLED and records whether the final
131
+ * truly-correct flipped. Absent for SOLO (no intervention) and when the counterfactual was not run.
132
+ *
133
+ * CRITICAL (design/89 §2.2.1 line 96): for a WITHHELD run this is REQUIRED to decide whether the
134
+ * withhold was CORRECT. A withhold is avoided-loss ONLY if disabling the intervention would have
135
+ * produced a DELIVERED-WRONG (`withoutInterventionTrulyCorrect===false`). When this is absent on a
136
+ * withheld run, the withhold is UNVERIFIED — it is NOT credited as avoided-loss.
137
+ */
25
138
  counterfactual?: InterceptCounterfactual;
139
+ /**
140
+ * R2 (MINOR) — the HONESTY provenance of this run's judgment, stamped at the RECORD level (not only in the
141
+ * report/stamp layer). A SUP/TEAM run's value rides on a SCRIPTED approver (NOT a real human review), so it is
142
+ * an INITIAL judgment, never a firm verdict (design/95 §6.1.bis / §6.1). Carrying it on the record means a
143
+ * record-level filter / re-aggregation / persisted run cannot silently lose the "scripted-human, not firm"
144
+ * semantics (before this, filtering RunRecords dropped the label that lived only on `BatchStamp`). SOLO has no
145
+ * human/approver ⇒ undefined (a pure objective-oracle run — no scripted-human judgment to caveat).
146
+ */
26
147
  judgeMode?: "scripted-human-initjudge";
27
148
  }
149
+ /**
150
+ * The subset of @sema-agent/core `TaskResult["stats"]` this tool reads. Kept structurally
151
+ * compatible (all optional, same field names/shapes) so a real `TaskResult.stats` is assignable here
152
+ * with no adaptation — verified against src/core/types.ts (1.110.0).
153
+ */
28
154
  export interface CoreStatsSubset {
29
155
  costMicroUsd?: number;
156
+ /** design/80 D-E-core finance taxonomy. C1 is the SUM of its LLM-derived lines. */
30
157
  costBreakdown?: {
31
158
  llmRootMicroUsd: number;
32
159
  nestedSubagentMicroUsd: number;
@@ -36,6 +163,7 @@ export interface CoreStatsSubset {
36
163
  nested?: {
37
164
  costMicroUsd?: number;
38
165
  };
166
+ /** design/91 human-review burden (the C2 source). Absent ⇒ no approval gate was hit. */
39
167
  humanReview?: {
40
168
  count: number;
41
169
  totalWaitMs: number;
@@ -46,85 +174,242 @@ export interface CoreStatsSubset {
46
174
  }>;
47
175
  };
48
176
  }
177
+ /**
178
+ * §2.2 — `truly-correct(run)` = AND of the four objective criteria (any false ⇒ 0). The numerator of
179
+ * P. By construction this takes ONLY {@link OracleVerdicts} (objective oracles); there is no parameter
180
+ * by which an LLM-judge could enter — that is the type-level enforcement of iron law #1.
181
+ */
49
182
  export declare function trulyCorrect(o: OracleVerdicts): boolean;
50
183
  export type Outcome = "DELIVERED-CORRECT" | "DELIVERED-WRONG" | "CORRECTLY-WITHHELD" | "INCORRECTLY-WITHHELD" | "UNVERIFIED-WITHHELD";
184
+ /**
185
+ * §2.2.1 — classify a run into one of the outcome classes. The withheld bucket is SPLIT by the §2.1
186
+ * intercept-value counterfactual (design/89 §2.2.1 line 96 — a withhold is only avoided-loss if it
187
+ * stopped a would-be DELIVERED-WRONG):
188
+ * - DELIVERED-CORRECT: not withheld AND truly-correct → the numerator.
189
+ * - DELIVERED-WRONG: not withheld AND not truly-correct → the true negative (solo hard-committing a
190
+ * buggy artifact, OR 触顶蒸发 with delivered=false). §2.2 criterion ④ folds "ran-but-didn't-
191
+ * deliver" into DELIVERED-WRONG, not into a withheld bucket — withheld requires an EXPLICIT
192
+ * human/gate decision, vaporized-on-overflow is a failure.
193
+ * - CORRECTLY-WITHHELD: withheld AND the counterfactual proves the task WOULD have been DELIVERED-
194
+ * WRONG (`withoutInterventionTrulyCorrect===false`). The supervisor's avoided-loss value — NOT in
195
+ * the numerator, NOT a failure.
196
+ * - INCORRECTLY-WITHHELD: withheld BUT the counterfactual shows the task would have been DELIVERED-
197
+ * CORRECT (`withoutInterventionTrulyCorrect===true`). A value-DESTROYING over-cautious intervention
198
+ * (a false-positive withhold). This is a COST/mistake, NEVER laundered into avoided-loss (the
199
+ * focus-item-② failure mode the review caught).
200
+ * - UNVERIFIED-WITHHELD: withheld but NO counterfactual was recorded → correctness unknown. Excluded
201
+ * from the avoided-loss credit (NOT defaulted to CORRECTLY-WITHHELD) and flagged (design/89 §2.2.1
202
+ * line 96: withheld MUST be counterfactual-verified).
203
+ */
51
204
  export declare function classifyOutcome(run: {
52
205
  oracle: OracleVerdicts;
53
206
  delivery: DeliveryDecision;
54
207
  counterfactual?: InterceptCounterfactual;
55
208
  }): Outcome;
209
+ /**
210
+ * §2.3 — the four cost components for one run. EACH single-listed; C1 and C2 are different units
211
+ * (µUSD vs seconds) and are NEVER added (that is the §2.1 apples+oranges trap). There is deliberately
212
+ * NO field that combines them.
213
+ */
56
214
  export interface CostComponents {
215
+ /** C1 — model (LLM-token) cost in µUSD. Derived from `stats.costBreakdown` (design/80 D-E-core):
216
+ * the sum of the LLM-derived lines. */
57
217
  c1ModelMicroUsd: number;
218
+ /** C2 — human-review burden: (count, seconds). From `stats.humanReview` (design/91). Seconds, not
219
+ * µUSD — never folded into C1. */
58
220
  c2HumanCount: number;
59
221
  c2HumanSec: number;
222
+ /** C3 — wall-clock seconds (the speed axis; fan-out's true value場之一). */
60
223
  c3WallSec: number;
224
+ /** C4 — infra µUSD (E2B vCPU-hr / egress / k8s), service-owned. 0 when not measured. */
61
225
  c4InfraMicroUsd: number;
62
226
  }
227
+ /**
228
+ * §2.3 — derive C1 from `stats.costBreakdown` (design/80 D-E-core). C1 is the LLM-token-derived total:
229
+ * the sum of the four breakdown lines. Falls back to `costMicroUsd` (+ nested) when `costBreakdown`
230
+ * is absent (older runs), then 0. This is the ONLY composition done — and it is WITHIN C1 (all µUSD,
231
+ * same unit); it never reaches across to C2.
232
+ */
63
233
  export declare function deriveC1(stats: CoreStatsSubset): number;
234
+ /** §2.4 — derive C2 (count, seconds) from `stats.humanReview` (design/91). Absent ⇒ no gate ⇒ (0,0). */
64
235
  export declare function deriveC2(stats: CoreStatsSubset): {
65
236
  count: number;
66
237
  sec: number;
67
238
  };
239
+ /** §2.3 — assemble all four cost components for a run. They stay separate by construction. */
68
240
  export declare function costComponents(run: RunRecord): CostComponents;
241
+ /**
242
+ * §2.4#2 — the result of the intercept-value counterfactual for ONE human intervention: re-run the
243
+ * same brief + fixed seed with that intervention DISABLED and observe how the final OUTCOME CLASS
244
+ * changed. The intervention has intercept value when the class IMPROVED — including the avoided-loss
245
+ * case (CORRECTLY-WITHHELD vs would-be DELIVERED-WRONG), which truly-correct alone CANNOT see
246
+ * (a withheld run's `withInterventionTrulyCorrect` is trivially false — nothing was delivered).
247
+ * This is what gives J3's "human-review is quality not only cost" a measurement.
248
+ */
69
249
  export interface InterceptCounterfactual {
250
+ /** truly-correct WITH the intervention (the actual SUP run). For a WITHHELD run this is trivially
251
+ * false (nothing delivered) — do NOT infer intercept value from it; use the class comparison. */
70
252
  withInterventionTrulyCorrect: boolean;
253
+ /** truly-correct WITHOUT it (the re-run with the intervention disabled). For a withhold this is the
254
+ * load-bearing field: `false` ⇒ the withhold prevented a DELIVERED-WRONG (avoided-loss). */
71
255
  withoutInterventionTrulyCorrect: boolean;
256
+ /** Optional explicit override. When set, {@link interceptHadValue} uses it verbatim. Prefer leaving
257
+ * it unset so the predicate derives value from the outcome classes (which handles withholds). */
72
258
  changedOutcome?: boolean;
73
259
  }
260
+ /**
261
+ * §2.4#2 — did a human intervention have intercept VALUE? Outcome-CLASS-aware (NOT truly-correct-binary
262
+ * -aware), so it correctly credits the supervisor's #1 value — an avoided-loss withhold — which a
263
+ * truly-correct XOR cannot see (design/89 §2.2.1: a withheld run's truly-correct is always false).
264
+ *
265
+ * Value exists when disabling the intervention would have WORSENED the outcome class:
266
+ * - DELIVER-correcting intervention: WITH delivers correct, WITHOUT delivers wrong
267
+ * (`withInterventionTrulyCorrect===true && withoutInterventionTrulyCorrect===false`).
268
+ * - AVOIDED-LOSS withhold: the run was correctly withheld (CORRECTLY-WITHHELD) and WITHOUT the
269
+ * intervention it would have been DELIVERED-WRONG (`withoutInterventionTrulyCorrect===false`).
270
+ *
271
+ * An INCORRECTLY-WITHHELD intervention (would-be correct, killed by an over-cautious human) has
272
+ * NEGATIVE value and returns `false` here — it is never counted as intercept value.
273
+ *
274
+ * Pass the run's outcome class so the predicate knows whether this was a withhold; the explicit
275
+ * `changedOutcome` override still wins when the harness sets it.
276
+ */
74
277
  export declare function interceptHadValue(cf: InterceptCounterfactual, outcome: Outcome): boolean;
278
+ /**
279
+ * §2.4 — the intercept-value seam the service three-arm harness implements: given a SUP run, clone the
280
+ * brief + fix the seed, disable ONE human intervention, re-run, and return its truly-correct. This is
281
+ * a SEAM (not implemented here — it needs the real Runner/model). The metrics tool consumes its result
282
+ * via `RunRecord.counterfactual`; this type pins the contract so service implements it correctly.
283
+ */
75
284
  export type InterceptValueCounterfactualSeam = (args: {
285
+ /** The original SUP run whose intervention is being ablated. */
76
286
  run: RunRecord;
287
+ /** Which intervention to disable (index into `stats.humanReview.gates`). */
77
288
  interventionIndex: number;
78
289
  }) => Promise<InterceptCounterfactual>;
290
+ /**
291
+ * §2.3 output-form — one arm's per-cell vector: `(C1, C2.sec, C3, C4, P=truly-correct rate, intercept
292
+ * value, CORRECTLY-WITHHELD count)` + the raw outcome tallies. Reported WITH n (and a CI when n large
293
+ * enough). NO single µUSD/tc headline (iron law #2).
294
+ */
79
295
  export interface ArmCell {
80
296
  arm: Arm;
81
297
  n: number;
298
+ /** Outcome tallies. The withheld bucket is SPLIT (§2.2.1 line 96): only counterfactual-verified
299
+ * avoided-loss is `correctlyWithheld`; an over-cautious would-be-correct kill is
300
+ * `incorrectlyWithheld` (a cost); a withhold with no counterfactual is `unverifiedWithheld`. */
82
301
  deliveredCorrect: number;
83
302
  deliveredWrong: number;
84
303
  correctlyWithheld: number;
85
304
  incorrectlyWithheld: number;
86
305
  unverifiedWithheld: number;
306
+ /**
307
+ * P = truly-correct RATE. design/89 §2.2.1: CORRECTLY-WITHHELD is neither numerator nor failure, so
308
+ * it is EXCLUDED from the denominator (it is not an attempt that produced a delivered artifact). P =
309
+ * DELIVERED-CORRECT / (DELIVERED-CORRECT + DELIVERED-WRONG). When all runs were withheld the rate is
310
+ * undefined (no delivery attempt to score).
311
+ */
87
312
  trulyCorrectRate: number | undefined;
313
+ /** Avoided-loss rate = CORRECTLY-WITHHELD / n. The supervisor's §2.2.1 value, single-listed. */
88
314
  correctlyWithheldRate: number;
315
+ /**
316
+ * codex MINOR / design/95 M10 — withhold treated as a binary detector of would-be-wrong delivery
317
+ * (positive = withheld; ground truth = would-be-wrong, established by the §2.4 counterfactual). Reported
318
+ * as precision/recall — NOT just the raw correctly-withheld count — so an arm cannot look good by
319
+ * withholding indiscriminately (high count, low precision) or by rarely withholding (high precision,
320
+ * low recall). Both undefined when their denominator is 0.
321
+ * withholdPrecision = correctlyWithheld / (correctlyWithheld + incorrectlyWithheld)
322
+ * — of the VERIFIED withhold decisions, the fraction that avoided a real wrong delivery. UNVERIFIED
323
+ * withholds are EXCLUDED (no counterfactual ⇒ TP/FP unknown; the honest, anti-over-claim choice).
324
+ * withholdRecall = correctlyWithheld / (correctlyWithheld + deliveredWrong)
325
+ * — of the wrong-delivery opportunities, the fraction the withhold caught (deliveredWrong = the FN:
326
+ * a wrong artifact was delivered that a withhold would have avoided).
327
+ */
89
328
  withholdPrecision: number | undefined;
90
329
  withholdRecall: number | undefined;
330
+ /** Mean C1 (µUSD), C2 (count, sec), C3 (sec), C4 (µUSD) across the cell. Each single-listed. */
91
331
  c1ModelMicroUsdMean: number;
92
332
  c2HumanCountMean: number;
93
333
  c2HumanSecMean: number;
94
334
  c3WallSecMean: number;
95
335
  c4InfraMicroUsdMean: number;
336
+ /** §2.4 intercept value: how many interventions changed the outcome / how many were measured. */
96
337
  interceptValueChanged: number;
97
338
  interceptValueMeasured: number;
339
+ /**
340
+ * Per-axis DIAGNOSTIC only (iron law #2): mean-C1 µUSD per DELIVERED-CORRECT. Undefined when 0
341
+ * delivered-correct. NEVER combines C2 — it is C1-only, labeled a diagnostic, and never the verdict.
342
+ */
98
343
  c1PerTrulyCorrectDiag: number | undefined;
99
344
  }
345
+ /** Fold a cell's runs (all same arm) into the per-arm vector. */
100
346
  export declare function foldCell(runs: RunRecord[]): ArmCell;
347
+ /**
348
+ * §2.1 — the three Pareto axes for one arm. Lower is better for cost (C1, C2.sec); higher is better
349
+ * for correctness (P). NOTE: an arm with undefined P (all-withheld) cannot be placed on the frontier
350
+ * — it is excluded from domination judgment and flagged.
351
+ */
101
352
  export interface ParetoPoint {
102
353
  arm: Arm;
103
354
  c1ModelMicroUsd: number;
104
355
  c2HumanSec: number;
105
356
  trulyCorrectRate: number;
106
357
  }
358
+ /**
359
+ * §2.1 — does point `a` Pareto-DOMINATE point `b`? `a` dominates `b` iff `a` is no worse on ALL three
360
+ * axes (≤ C1, ≤ C2.sec, ≥ P) AND strictly better on at least one. Domination means b is provably
361
+ * inferior. NOT dominated ⇒ both are on the frontier (a real trade-off — exactly the §2.1 outcome we
362
+ * refuse to collapse into one scalar).
363
+ */
107
364
  export declare function dominates(a: ParetoPoint, b: ParetoPoint): boolean;
108
365
  export interface ParetoResult {
366
+ /** The input points that could be placed (P defined). */
109
367
  points: ParetoPoint[];
368
+ /** Arms on the Pareto frontier (NOT dominated by any other) — the real trade-offs. */
110
369
  frontier: Arm[];
370
+ /** Arms dominated by ≥1 other arm, each with WHO dominates it. A dominated arm is provably inferior
371
+ * (the only kind of verdict §2.1 permits — no scalar ranking of frontier members). */
111
372
  dominated: Array<{
112
373
  arm: Arm;
113
374
  dominatedBy: Arm[];
114
375
  }>;
376
+ /**
377
+ * Arms excluded from the frontier because P was undefined (all-withheld) — flagged, not silently
378
+ * dropped, and CARRYING their avoided-loss so a consumer that reads `frontier` cannot miss the
379
+ * withheld arm's value (design/89 §2.2.1: an all-withheld supervisor must not vanish, leaving a
380
+ * wrong-shipping solo as the sole "winner").
381
+ */
115
382
  excludedUndefinedP: Array<{
116
383
  arm: Arm;
117
384
  correctlyWithheldRate: number;
118
385
  correctlyWithheld: number;
119
386
  deliveredWrong: number;
120
387
  }>;
388
+ /**
389
+ * HARD COUNTERWEIGHT (design/89 §2.1/§2.2.1): set when the frontier is NOT a clean winner declaration
390
+ * — an arm with avoided-loss (correctlyWithheld>0) was excluded for undefined P WHILE a frontier arm
391
+ * ships real negatives (deliveredWrong>0). A downstream consumer keying on `frontier` MUST read this
392
+ * before concluding "X won": the excluded arm avoided loss the frontier arm did not.
393
+ */
121
394
  frontierNotAWinnerDeclaration?: {
122
395
  reason: string;
123
396
  excludedAvoidedLossArms: Arm[];
124
397
  frontierArmsShippingWrong: Arm[];
125
398
  };
126
399
  }
400
+ /**
401
+ * §2.1 — compute the 3-D Pareto frontier over the per-arm cells. Each arm contributes ONE point
402
+ * `(C1 mean, C2.sec mean, P)`. Arms with undefined P (all-withheld) are flagged and excluded from
403
+ * domination. The output is the frontier + dominated-by map — NEVER a single ranked scalar.
404
+ */
127
405
  export declare function paretoFrontier(cells: ArmCell[]): ParetoResult;
406
+ /**
407
+ * §2.1 — the risk-transfer disclosure: solo having no C2 does NOT mean solo is cheaper — it transfers
408
+ * quality risk downstream (single-agent 3-runs-all-failed 0-commit = the cost of no human safety net;
409
+ * METR -19% / DORA more-code≠more-delivered / 31% PR zero-review). The report MUST emit this verbatim
410
+ * whenever a solo arm is present so a low solo C2 is never read as "solo cheaper". Returns the text +
411
+ * the supporting numbers from this run so it is not boilerplate but grounded.
412
+ */
128
413
  export declare function riskTransferDisclosure(cells: ArmCell[]): {
129
414
  applies: boolean;
130
415
  text: string;
@@ -134,35 +419,94 @@ export declare function riskTransferDisclosure(cells: ArmCell[]): {
134
419
  supCorrectlyWithheld: number;
135
420
  };
136
421
  };
422
+ /**
423
+ * codex B2 — a paired-binary comparison of two arms on the SAME tasks/seeds. The two arms' truly-
424
+ * correct flags are paired row-by-row (paired-seed, design/89 §3.4). For binary paired data the
425
+ * RIGHT tests are McNemar (discordant pairs) and a paired-bootstrap difference interval — NOT two
426
+ * independent proportions with "CI non-overlap" (that ignores the pairing and is under-powered, codex B2).
427
+ */
137
428
  export interface PairedBinaryComparison {
429
+ /** Arm A (e.g. "sup") vs arm B (e.g. "solo"). pDiff = P(A) − P(B). */
138
430
  armA: Arm;
139
431
  armB: Arm;
432
+ /** Number of PAIRED rows actually compared (only rows where both arms produced a delivery attempt). */
140
433
  nPairs: number;
434
+ /** Discordant pair counts: b = A-correct & B-wrong; c = A-wrong & B-correct (McNemar's b,c). */
141
435
  bAonly: number;
142
436
  cBonly: number;
437
+ /** Point estimate of the paired proportion difference P(A) − P(B). */
143
438
  pDiff: number;
439
+ /** McNemar exact-ish two-sided p-value over discordant pairs (binomial, continuity-corrected χ² when
440
+ * b+c large). */
144
441
  mcnemarP: number;
442
+ /** Bootstrap percentile 95% CI for the paired difference (lo, hi) — a percentile CI on the seeded
443
+ * paired-bootstrap distribution, NOT Newcombe's analytic interval (codex MAJOR-B). Crosses 0 ⇒ not significant. */
145
444
  ci95: [number, number];
445
+ /** TRUE iff the difference is statistically significant at α=0.05 (CI excludes 0 AND McNemar p<0.05). */
146
446
  significant: boolean;
447
+ /**
448
+ * codex B2 — pre-registered Minimum Detectable Effect at the observed nPairs (the difference this
449
+ * comparison COULD have detected at 80% power). When |pDiff| is below this AND not significant, the
450
+ * verdict is "not powered" — NOT "no difference". This is the field that stops "N≥15 is an assertion".
451
+ */
147
452
  mdeAt80Power: number;
453
+ /** "powered" iff nPairs ≥ the n needed to detect the pre-registered MDE; else "not-powered". */
148
454
  power: "powered" | "not-powered";
455
+ /** Human-readable verdict that NEVER over-claims a null result from an under-powered comparison. */
149
456
  verdict: "A-better" | "B-better" | "no-detectable-difference" | "not-powered";
150
457
  }
458
+ /**
459
+ * codex B2 — compare two arms' delivered truly-correct as PAIRED binary. Pairs runs by the COMPOSITE
460
+ * `(taskId, seed)` key (codex MAJOR-A: a bare `seed` collides across tasks — the same repeat index
461
+ * recurs per task — so cross-task input would overwrite pairs and poison the McNemar sample);
462
+ * only rows where BOTH arms delivered (not withheld, both scored) form a pair — a
463
+ * withheld run has no delivered binary to pair (it is scored in the withhold/avoided-loss axis, not
464
+ * here). `mde` is the pre-registered minimum detectable effect (default 0.20 absolute = a 20pp swing).
465
+ */
151
466
  export declare function pairedBinaryCompare(scoredRuns: RunRecord[], armA: Arm, armB: Arm, opts?: {
152
467
  mde?: number;
153
468
  bootstrapSeed?: number;
154
469
  bootstrapIters?: number;
155
470
  }): PairedBinaryComparison;
471
+ /**
472
+ * codex B3 — the pre-registered C2 exchange rate(s): how many human-review SECONDS we are willing to
473
+ * pay to buy one unit of supervisor value. Without these, "higher P / more withholds ⇒ worth it" is
474
+ * unfalsifiable (the "helpful but too expensive" counter-thesis cannot be observed). Declared BEFORE
475
+ * the run (design/95 §9), not fit after.
476
+ */
156
477
  export interface C2Thresholds {
478
+ /** Max human-review seconds we will pay to avoid ONE DELIVERED-WRONG (per CORRECTLY-WITHHELD). */
157
479
  secPerAvoidedWrong: number;
480
+ /** Max human-review seconds we will pay to save ONE repeated decision (V1). */
158
481
  secPerSavedDecision: number;
159
482
  }
160
483
  export interface ParetoVerdict {
161
484
  arm: Arm;
485
+ /** Non-dominated on (C1, C2.sec, P) — necessary condition to be considered at all (codex B3). */
162
486
  nonDominated: boolean;
487
+ /** The pre-registered exchange-rate check: does the arm's extra C2 buy enough avoided-loss / saved
488
+ * decisions to clear the declared threshold? Undefined when the arm has no extra C2 over baseline. */
163
489
  clearsC2Threshold?: boolean;
490
+ /**
491
+ * codex B3 — the label. An arm may ONLY be "worth-it" when it is non-dominated AND clears the C2
492
+ * threshold. A non-dominated but threshold-failing arm is "quality-tradeoff" (higher quality, but the
493
+ * cost is not bought back) — NEVER "worth-it". A dominated arm is "dominated".
494
+ */
164
495
  label: "worth-it" | "quality-tradeoff" | "dominated";
165
496
  }
497
+ /**
498
+ * codex B3 — classify each arm against the SUP/TEAM-vs-baseline value question with a pre-registered
499
+ * exchange rate. `baselineArm` is the cost floor to compare extra C2 against (default "solo").
500
+ * `avoidedWrong` / `savedDecisions` per arm come from the cells / campaign report.
501
+ *
502
+ * 🔴 ADVERSARIAL-REVIEW DISCIPLINE (B1 partial false-close, design/95 §2.3): `cells` MUST be a
503
+ * HOMOGENEOUS cross-arm set — feed `report.comparisons[*].arms` (one `(suiteVersion,taskId,archetype,
504
+ * valueDimension)` comparison at a time), NEVER `report.cells` (the suite-wide ARM MEAN). The arm mean
505
+ * folds heterogeneous tasks → the value LABEL itself flips (Simpson): a cell that is "quality-tradeoff"
506
+ * (extra human seconds NOT bought back) gets averaged with a "worth-it" cell into a single misleading
507
+ * "worth-it", hiding the "helpful but too expensive" anti-thesis. The frontier folds too (§11 / B1).
508
+ * Regression: metrics.test §13b proves per-cell {worth-it, quality-tradeoff} ≠ arm-mean {worth-it}.
509
+ */
166
510
  export declare function paretoValueVerdict(cells: ArmCell[], thresholds: C2Thresholds, perArmValue: Partial<Record<Arm, {
167
511
  avoidedWrong: number;
168
512
  savedDecisions: number;
@@ -170,27 +514,60 @@ export declare function paretoValueVerdict(cells: ArmCell[], thresholds: C2Thres
170
514
  pareto: ParetoResult;
171
515
  verdicts: ParetoVerdict[];
172
516
  };
517
+ /**
518
+ * design/95 §7.1 — V1 (免重复劳动): campaign-level human-decision delta. The ONLY authoritative V1
519
+ * mechanism (design/95 reconcile, MAJOR#2): cross-task reuse of a decided strategy. Semantics:
520
+ * - `soloHumanDecisions` is the V1 BASELINE — the operator's actual up-front decision count when
521
+ * running solo across the campaign (codex M7: NOT 0, NOT synthetic — measured from real operator
522
+ * prep across runs). `0` is only valid when the campaign genuinely needed no human decision.
523
+ * - `repeatedDecisionsSaved = soloHumanDecisions − supHumanDecisions` (may be negative = SUP cost
524
+ * MORE human decisions; reported honestly, not floored).
525
+ */
173
526
  export interface CampaignV1Saved {
174
527
  decisionKind: string;
528
+ /** V1 baseline (codex M7): operator's measured up-front decisions when running SOLO. Provenance MUST
529
+ * be recorded in the stamp (real prep, not 0/synthetic). */
175
530
  soloHumanDecisions: number;
531
+ /** SUP arm's actual human-review decision count for this decision kind. */
176
532
  supHumanDecisions: number;
533
+ /** = soloHumanDecisions − supHumanDecisions. Positive ⇒ SUP saved repeated labour (V1 evidence). */
177
534
  repeatedDecisionsSaved: number;
535
+ /** Whether the baseline is a real measurement vs absent (codex M7 honesty gate). */
178
536
  baselineProvenance: "measured-operator-baseline" | "absent-not-claimable";
179
537
  }
538
+ /**
539
+ * design/95 §7.2 — V2 (蓝图清晰度) THREE-arm ablation (codex BLOCKER#1 + MAJOR#3 / M8). All three are
540
+ * paired on the SAME seeds (paired===true ⇒ the three pX arrays/values are over the same n seeds).
541
+ * INVARIANT: `n` is the paired-seed count common to all three sub-arms; the three deltas are computed
542
+ * over those n pairs.
543
+ * - pSoloRaw — only the original brief (no blueprint baseline).
544
+ * - pSoloSupGenerated — the SUP-arm-GENERATED blueprint (attributable to supervisor; gen cost charged).
545
+ * - pSoloExperimenterIdeal — the experimenter "ideal" blueprint. codex M8: this is a CONSTRAINED upper
546
+ * bound on "better-prompt help", NOT "supervisor's mechanistic ceiling", UNLESS the ideal blueprint
547
+ * was generated under the {@link IdealBlueprintConstraints} (run-time, visible-brief-only, no oracle
548
+ * access, same info budget, leak-reviewed). `idealConstraintsSatisfied` records which it is.
549
+ */
180
550
  export interface BlueprintAblationTriple {
181
551
  subgoalId: string;
182
552
  paired: boolean;
553
+ /** Paired-seed count common to all three sub-arms (array/Δ invariant base). */
183
554
  n: number;
184
555
  pSoloRaw: number;
185
556
  pSoloSupGenerated: number;
186
557
  pSoloExperimenterIdeal: number;
558
+ /** = pSoloSupGenerated − pSoloRaw (supervisor blueprint's real net value). */
187
559
  deltaSupVsRaw: number;
560
+ /** = pSoloExperimenterIdeal − pSoloRaw. LABELLED per `idealConstraintsSatisfied` (codex M8). */
188
561
  deltaIdealVsRaw: number;
562
+ /** codex M8 — when false, deltaIdealVsRaw is "manual-prompt upper bound", NOT "supervisor potential". */
189
563
  idealConstraintsSatisfied: boolean;
564
+ /** codex M3 — blueprint generation cost charged to the sup-generated arm (budget-match red line). */
190
565
  blueprintGenC1MicroUsd: number;
191
566
  blueprintGenC2Count: number;
192
567
  blueprintGenC2Sec: number;
193
568
  }
569
+ /** codex M8 — the constraints under which an "ideal" blueprint may be read as a supervisor-mechanism
570
+ * upper bound rather than a generic "better prompt helps" result. Recorded per ablation. */
194
571
  export interface IdealBlueprintConstraints {
195
572
  generatedBeforeRun: boolean;
196
573
  fromVisibleBriefOnly: boolean;
@@ -198,16 +575,37 @@ export interface IdealBlueprintConstraints {
198
575
  sameInfoBudget: boolean;
199
576
  solutionLeakReviewed: boolean;
200
577
  }
578
+ /** True iff ALL ideal-blueprint constraints hold (codex M8 gate). */
201
579
  export declare function idealConstraintsSatisfied(c: IdealBlueprintConstraints): boolean;
580
+ /**
581
+ * design/95 §7.3 — V3 (无关性隔离) contamination probe (canary, mechanical, zero LLM-judge). codex M9:
582
+ * the isolated-vs-shared P delta CONFOUNDS execution order / context size / worker count / budget; the
583
+ * PRIMARY signal must be per-subgoal oracle failure + explicit wrong-use of a sibling artifact (the
584
+ * canary leak), with the P delta kept as a DIAGNOSTIC only.
585
+ * INVARIANT: `isolatedSubgoalP.length === sharedSubgoalP.length === factorCount`.
586
+ */
202
587
  export interface IsolationContamination {
203
588
  factorCount: number;
589
+ /** Per-factor P under isolation. length === factorCount. */
204
590
  isolatedSubgoalP: number[];
591
+ /** Per-factor P under shared context. length === factorCount. */
205
592
  sharedSubgoalP: number[];
593
+ /** PRIMARY mechanical signal (codex M9): cross-factor canary leak rate (explicit token bleed). */
206
594
  canaryLeakRate: number;
595
+ /** PRIMARY mechanical signal (codex M9): count of factors that failed their oracle AND demonstrably
596
+ * used a sibling factor's artifact (the controlled-ablation harm signal). */
207
597
  wrongSiblingArtifactUses: number;
598
+ /** DIAGNOSTIC ONLY (codex M9 confound): mean(isolated P) − mean(shared P). Not the primary signal. */
208
599
  contaminationRateDiag: number;
600
+ /** Extra C1 the isolation cost (multi-worker / repeated context load). */
209
601
  isolationOverheadC1: number;
210
602
  }
603
+ /**
604
+ * design/95 §7 — the CAMPAIGN-level wrapper (V1 is campaign-scoped, design/95 reconcile MAJOR#2). Built
605
+ * ON TOP of per-task {@link ValueJudgmentReport}s; does NOT re-derive their numerator/Pareto red lines.
606
+ * V2/V3 attach optionally per the §7.2/§7.3 structures. All §7 fields are populated by the harness
607
+ * (the producer), not synthesized in `buildReport` — `implementedAxes` declares which were filled.
608
+ */
211
609
  export interface CampaignReport {
212
610
  perTask: ValueJudgmentReport[];
213
611
  campaignV1?: CampaignV1Saved;
@@ -215,6 +613,11 @@ export interface CampaignReport {
215
613
  contaminationProbe?: IsolationContamination;
216
614
  implementedAxes: ImplementedAxes;
217
615
  }
616
+ /**
617
+ * design/95 §2 / codex B1 — one heterogeneity CELL: a `(suiteVersion, taskId, archetype, valueDimension,
618
+ * arm)` group with its folded {@link ArmCell}. The decision surface is the per-cell vector — NOT the
619
+ * arm mean (the Simpson's-paradox guard). `groupKey` is the stable join key.
620
+ */
218
621
  export interface GroupedCell {
219
622
  groupKey: string;
220
623
  suiteVersion?: string;
@@ -223,15 +626,33 @@ export interface GroupedCell {
223
626
  valueDimension?: string;
224
627
  cell: ArmCell;
225
628
  }
629
+ /**
630
+ * 🔴 ADVERSARIAL-REVIEW FIX (B1 partial false-close): the cross-arm decision surface. A {@link
631
+ * GroupedCell} keys on `arm`, so each is SINGLE-ARM — you cannot run a cross-arm Pareto / value verdict
632
+ * (J2/J3/B3) from one. The prior `buildReport` exposed only `report.pareto`, computed on the suite-wide
633
+ * `cells` ARM MEAN — the very Simpson's-prone surface B1 demotes to "NOT a decision surface". A consumer
634
+ * reading the obvious `report.pareto` got the folded-across-heterogeneity frontier = exactly what B1
635
+ * claims to prevent. This is the CORRECT decision surface: one entry per `(suiteVersion, taskId,
636
+ * archetype, valueDimension)` (NO arm), carrying all arms' cells + their per-cell Pareto. J2/J3/B3 MUST
637
+ * read these, never `report.pareto`.
638
+ */
226
639
  export interface ComparisonCell {
227
640
  comparisonKey: string;
228
641
  suiteVersion?: string;
229
642
  taskId: string;
230
643
  archetype?: string;
231
644
  valueDimension?: string;
645
+ /** All arms' folded cells WITHIN this homogeneous comparison (same task/archetype/dimension). */
232
646
  arms: ArmCell[];
647
+ /** The per-comparison Pareto over `arms` — the decision surface, NOT the suite arm mean. */
233
648
  pareto: ParetoResult;
234
649
  }
650
+ /**
651
+ * codex MINOR11 / council Q1 — capability metadata: which of the four §7/Pareto value axes are actually
652
+ * IMPLEMENTED in this report. Consumers must read this before claiming a V1/V2/V3 result; an unset axis
653
+ * is NOT a null result, it is "not measured here". (The T1 structures above are types + pure helpers;
654
+ * the report-level V1/V2/V3 fields are populated by the harness, not synthesized in `buildReport`.)
655
+ */
235
656
  export interface ImplementedAxes {
236
657
  pareto: boolean;
237
658
  v1: boolean;
@@ -239,20 +660,54 @@ export interface ImplementedAxes {
239
660
  v3: boolean;
240
661
  }
241
662
  export interface ValueJudgmentReport {
663
+ /** codex B1 — per-arm cells grouped by full heterogeneity key (incl. arm). Single-arm; use for cell
664
+ * inspection / `pairedBinaryCompare` inputs. NOT directly a cross-arm verdict surface (each is one arm). */
242
665
  groupedCells: GroupedCell[];
666
+ /**
667
+ * 🔴 ADVERSARIAL-REVIEW FIX (B1): the CROSS-ARM decision surface — one per `(suiteVersion, taskId,
668
+ * archetype, valueDimension)` (NO arm), each carrying all arms + a per-comparison Pareto over a
669
+ * HOMOGENEOUS set of runs. J2/J3/B3 (`paretoValueVerdict`) MUST read `comparisons[*].pareto` /
670
+ * `comparisons[*].arms`, NEVER the suite-wide `pareto`/`cells` (which fold heterogeneous tasks → Simpson).
671
+ */
243
672
  comparisons: ComparisonCell[];
673
+ /**
674
+ * codex B1 — suite-level rollup: per-arm cells folded over ALL scored runs. A WEIGHTED summary for
675
+ * dashboards ONLY — NOT a decision surface (folding heterogeneous tasks can flip a verdict, Simpson).
676
+ * Consumers MUST decide on `comparisons`; this is convenience aggregation.
677
+ */
244
678
  cells: ArmCell[];
679
+ /**
680
+ * 🔴 DASHBOARD ONLY — the Pareto over the suite-wide ARM MEAN (`cells`). This folds heterogeneous
681
+ * tasks into one frontier (Simpson's paradox) and is NOT a verdict surface. The verdict surface is
682
+ * `comparisons[*].pareto`. Kept only for a single-number dashboard glance; flagged so a consumer
683
+ * cannot mistake it for the decision (the B1 false-close: prior code wired the verdict to this).
684
+ */
245
685
  pareto: ParetoResult;
246
686
  riskTransfer: ReturnType<typeof riskTransferDisclosure>;
687
+ /** design/89 §3.4: cells with n<8 are directional-only, not verdict-grade. Flagged, not dropped. */
247
688
  directionalOnly: Arm[];
689
+ /**
690
+ * codex B4 — the exclusion ledger: runs dropped from scoring (infra-failed / excluded) with reasons.
691
+ * A regression-grade invariant: these never reach `cells` / `pareto` (no infra noise in the verdict).
692
+ */
248
693
  excluded: Array<{
249
694
  taskId: string;
250
695
  arm: Arm;
251
696
  seed?: number | string;
252
697
  reason: RunStatus;
253
698
  }>;
699
+ /** codex MINOR11 — which value axes this report actually measured. */
254
700
  implementedAxes: ImplementedAxes;
255
701
  }
702
+ /**
703
+ * Top-level (codex B1+B4): SCORE only `scored` runs (B4 — drop infra-failed/excluded with reasons),
704
+ * group by `(suiteVersion, taskId, archetype, valueDimension, arm)` (B1 — the per-cell decision surface,
705
+ * Simpson's-paradox guard), fold each group, AND provide a suite-level per-arm rollup for dashboards
706
+ * (explicitly NOT a decision surface). Deterministic; no model.
707
+ *
708
+ * `opts.implementedAxes` lets the harness declare which §7 axes it populated (codex MINOR11); default
709
+ * = only Pareto (the V1/V2/V3 structures are T1 net-new, not synthesized here).
710
+ */
256
711
  export declare function buildReport(runs: RunRecord[], opts?: {
257
712
  implementedAxes?: Partial<ImplementedAxes>;
258
713
  }): ValueJudgmentReport;