@sema-agent/server 1.323.0 โ†’ 2.0.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 (565) hide show
  1. package/dist/approval-hmac.d.ts +40 -0
  2. package/dist/approval-hmac.js +67 -0
  3. package/dist/approval.d.ts +31 -0
  4. package/dist/approval.js +72 -4
  5. package/dist/audit.d.ts +26 -0
  6. package/dist/audit.js +40 -1
  7. package/dist/auth-bridge.d.ts +10 -0
  8. package/dist/auth-bridge.js +47 -4
  9. package/dist/auth-keys.d.ts +19 -0
  10. package/dist/auth-keys.js +13 -0
  11. package/dist/bake-runner/main.d.ts +5 -0
  12. package/dist/bake-runner/main.js +43 -4
  13. package/dist/bake-runner/protocol.d.ts +57 -0
  14. package/dist/bake-runner/protocol.js +58 -3
  15. package/dist/bake-runner/runner.d.ts +54 -0
  16. package/dist/bake-runner/runner.js +87 -5
  17. package/dist/bench/l8/artifact.d.ts +63 -0
  18. package/dist/bench/l8/artifact.js +61 -2
  19. package/dist/bench/l8/escape.d.ts +36 -0
  20. package/dist/bench/l8/escape.js +25 -0
  21. package/dist/bench/l8/index.d.ts +14 -0
  22. package/dist/bench/l8/index.js +14 -0
  23. package/dist/bench/l8/probes.d.ts +74 -0
  24. package/dist/bench/l8/probes.js +60 -0
  25. package/dist/bench/l8/run-probes.d.ts +43 -0
  26. package/dist/bench/l8/run-probes.js +45 -2
  27. package/dist/bench/s1/arms.d.ts +126 -0
  28. package/dist/bench/s1/arms.js +188 -13
  29. package/dist/bench/s1/live-deps.d.ts +66 -0
  30. package/dist/bench/s1/live-deps.js +249 -11
  31. package/dist/bench/s1/oracle.d.ts +49 -0
  32. package/dist/bench/s1/oracle.js +36 -1
  33. package/dist/bench/s1/repair-oracle-adapter.d.ts +33 -0
  34. package/dist/bench/s1/repair-oracle-adapter.js +30 -0
  35. package/dist/bench/s1/reviewer.d.ts +38 -0
  36. package/dist/bench/s1/reviewer.js +34 -0
  37. package/dist/bench/s1/row.d.ts +77 -0
  38. package/dist/bench/s1/row.js +62 -0
  39. package/dist/bench/s1/run-firm.d.ts +47 -0
  40. package/dist/bench/s1/run-firm.js +70 -4
  41. package/dist/bench/s1/runner-ctx.d.ts +71 -0
  42. package/dist/bench/s1/runner-ctx.js +36 -0
  43. package/dist/bench/s1/tasks.d.ts +108 -0
  44. package/dist/bench/s1/tasks.js +115 -0
  45. package/dist/boot/budget-tracing.d.ts +48 -0
  46. package/dist/boot/budget-tracing.js +86 -0
  47. package/dist/boot/config-center.d.ts +62 -0
  48. package/dist/boot/config-center.js +995 -0
  49. package/dist/boot/coordinators.d.ts +33 -0
  50. package/dist/boot/coordinators.js +97 -0
  51. package/dist/boot/execution-env.d.ts +26 -0
  52. package/dist/boot/execution-env.js +370 -0
  53. package/dist/boot/leader.d.ts +27 -0
  54. package/dist/boot/leader.js +81 -0
  55. package/dist/boot/reapers.d.ts +53 -0
  56. package/dist/boot/reapers.js +252 -0
  57. package/dist/boot/resolve-spec.d.ts +70 -0
  58. package/dist/boot/resolve-spec.js +1072 -0
  59. package/dist/boot/runner-deps.d.ts +101 -0
  60. package/dist/boot/runner-deps.js +343 -0
  61. package/dist/boot/runtime-caps.d.ts +21 -0
  62. package/dist/boot/runtime-caps.js +62 -0
  63. package/dist/boot/session-faces.d.ts +57 -0
  64. package/dist/boot/session-faces.js +157 -0
  65. package/dist/boot/shutdown.d.ts +50 -0
  66. package/dist/boot/shutdown.js +129 -0
  67. package/dist/boot/stores.d.ts +32 -0
  68. package/dist/boot/stores.js +361 -0
  69. package/dist/boot/workflow-orchestration.d.ts +46 -0
  70. package/dist/boot/workflow-orchestration.js +150 -0
  71. package/dist/boot-reclaim.d.ts +19 -0
  72. package/dist/boot-reclaim.js +20 -0
  73. package/dist/brain.d.ts +25 -0
  74. package/dist/brain.js +61 -1
  75. package/dist/budget.d.ts +66 -0
  76. package/dist/budget.js +128 -4
  77. package/dist/capabilities/builtin-tools.d.ts +3 -0
  78. package/dist/capabilities/builtin-tools.js +3 -0
  79. package/dist/capabilities/center-plugins.d.ts +17 -1
  80. package/dist/capabilities/center-plugins.js +45 -4
  81. package/dist/capabilities/center-prompts.d.ts +46 -0
  82. package/dist/capabilities/center-prompts.js +57 -3
  83. package/dist/capabilities/code-review-council.d.ts +28 -0
  84. package/dist/capabilities/code-review-council.js +40 -7
  85. package/dist/capabilities/collab-wire.d.ts +2 -0
  86. package/dist/capabilities/collab-workflows.d.ts +7 -0
  87. package/dist/capabilities/collab-workflows.js +44 -1
  88. package/dist/capabilities/oa-tools.d.ts +6 -0
  89. package/dist/capabilities/oa-tools.js +10 -0
  90. package/dist/capabilities/prompt.d.ts +14 -0
  91. package/dist/capabilities/prompt.js +14 -0
  92. package/dist/capabilities/prompts/code-review.d.ts +14 -0
  93. package/dist/capabilities/prompts/code-review.js +14 -0
  94. package/dist/capabilities/prompts/identity.d.ts +6 -0
  95. package/dist/capabilities/prompts/identity.js +6 -0
  96. package/dist/capabilities/prompts/team.d.ts +4 -0
  97. package/dist/capabilities/prompts/team.js +4 -0
  98. package/dist/capabilities/repo-tools.d.ts +11 -0
  99. package/dist/capabilities/repo-tools.js +8 -0
  100. package/dist/capabilities/sandbox-file-send.d.ts +95 -0
  101. package/dist/capabilities/sandbox-file-send.js +91 -3
  102. package/dist/capabilities/scenarios.d.ts +130 -0
  103. package/dist/capabilities/scenarios.js +180 -7
  104. package/dist/capabilities/select-environment-tool.d.ts +7 -0
  105. package/dist/capabilities/select-environment-tool.js +30 -0
  106. package/dist/capabilities/send-user-file-tool.d.ts +33 -0
  107. package/dist/capabilities/send-user-file-tool.js +65 -1
  108. package/dist/capabilities/skills.d.ts +29 -0
  109. package/dist/capabilities/skills.js +13 -2
  110. package/dist/capabilities/team.d.ts +22 -0
  111. package/dist/capabilities/team.js +22 -2
  112. package/dist/capabilities/tool-defer.d.ts +26 -0
  113. package/dist/capabilities/tool-defer.js +3 -0
  114. package/dist/config-center/apply-effective.d.ts +65 -0
  115. package/dist/config-center/apply-effective.js +204 -12
  116. package/dist/config-center/http-client.d.ts +34 -0
  117. package/dist/config-center/http-client.js +68 -0
  118. package/dist/config-center/restart-signal.d.ts +22 -0
  119. package/dist/config-center/restart-signal.js +39 -0
  120. package/dist/config-center/skills-mcp.d.ts +20 -1
  121. package/dist/config-center/skills-mcp.js +42 -7
  122. package/dist/config-center/types.d.ts +92 -1
  123. package/dist/config-lkg.d.ts +12 -0
  124. package/dist/config-lkg.js +41 -0
  125. package/dist/config-provider.d.ts +78 -0
  126. package/dist/config-provider.js +165 -2
  127. package/dist/config-types.d.ts +585 -1
  128. package/dist/config.d.ts +78 -2
  129. package/dist/config.js +874 -301
  130. package/dist/degenerate-instrument.d.ts +38 -0
  131. package/dist/degenerate-instrument.js +55 -3
  132. package/dist/elicitation.d.ts +39 -0
  133. package/dist/elicitation.js +87 -3
  134. package/dist/env-facts.d.ts +61 -0
  135. package/dist/env-facts.js +73 -7
  136. package/dist/fleet/fleet-bus.d.ts +185 -0
  137. package/dist/fleet/fleet-bus.js +333 -27
  138. package/dist/fleet/subagent-tail-bus.d.ts +11 -0
  139. package/dist/fleet/subagent-tail-bus.js +33 -2
  140. package/dist/fleet-client.d.ts +38 -0
  141. package/dist/fleet-client.js +44 -9
  142. package/dist/fleet-lease.d.ts +46 -0
  143. package/dist/fleet-lease.js +73 -5
  144. package/dist/hooks/branch-transcript.d.ts +8 -0
  145. package/dist/hooks/branch-transcript.js +33 -0
  146. package/dist/hooks/cc-stop-prompt.d.ts +42 -0
  147. package/dist/hooks/cc-stop-prompt.js +43 -1
  148. package/dist/hooks/hook-llm.d.ts +15 -0
  149. package/dist/hooks/hook-llm.js +47 -0
  150. package/dist/hooks/hook-runner.d.ts +89 -0
  151. package/dist/hooks/hook-runner.js +327 -18
  152. package/dist/http/idempotency.d.ts +31 -0
  153. package/dist/http/idempotency.js +34 -0
  154. package/dist/http/principal-gate.d.ts +17 -0
  155. package/dist/http/principal-gate.js +35 -3
  156. package/dist/http/route-ctx.d.ts +36 -0
  157. package/dist/http/routes/approvals-assistant.d.ts +25 -0
  158. package/dist/http/routes/approvals-assistant.js +253 -23
  159. package/dist/http/routes/attachments.js +22 -4
  160. package/dist/http/routes/capabilities.d.ts +7 -0
  161. package/dist/http/routes/capabilities.js +202 -1
  162. package/dist/http/routes/fleet.d.ts +6 -0
  163. package/dist/http/routes/fleet.js +94 -5
  164. package/dist/http/routes/images.d.ts +17 -0
  165. package/dist/http/routes/images.js +222 -14
  166. package/dist/http/routes/leader.d.ts +7 -0
  167. package/dist/http/routes/leader.js +10 -0
  168. package/dist/http/routes/memory-policy.d.ts +6 -0
  169. package/dist/http/routes/memory-policy.js +38 -6
  170. package/dist/http/routes/notify-wake.d.ts +10 -0
  171. package/dist/http/routes/notify-wake.js +19 -3
  172. package/dist/http/routes/observability.d.ts +6 -0
  173. package/dist/http/routes/observability.js +19 -2
  174. package/dist/http/routes/runs.d.ts +15 -0
  175. package/dist/http/routes/runs.js +464 -41
  176. package/dist/http/routes/session-sync.d.ts +15 -0
  177. package/dist/http/routes/session-sync.js +229 -19
  178. package/dist/http/routes/sessions-list.d.ts +6 -0
  179. package/dist/http/routes/sessions-list.js +35 -4
  180. package/dist/http/routes/sessions.d.ts +14 -0
  181. package/dist/http/routes/sessions.js +176 -31
  182. package/dist/http/routes/side-query.d.ts +8 -0
  183. package/dist/http/routes/side-query.js +26 -1
  184. package/dist/http/routes/tasks.d.ts +18 -0
  185. package/dist/http/routes/tasks.js +501 -38
  186. package/dist/http/routes/trace-usage.d.ts +10 -0
  187. package/dist/http/routes/trace-usage.js +66 -14
  188. package/dist/http/routes/workflows.d.ts +12 -0
  189. package/dist/http/routes/workflows.js +180 -19
  190. package/dist/http/run-meta.d.ts +11 -0
  191. package/dist/http/run-meta.js +6 -0
  192. package/dist/http/send.d.ts +19 -0
  193. package/dist/http/send.js +11 -0
  194. package/dist/http/server.d.ts +255 -0
  195. package/dist/http/server.js +921 -75
  196. package/dist/http/sse-log.d.ts +15 -0
  197. package/dist/http/sse-log.js +16 -0
  198. package/dist/http/tar.d.ts +9 -0
  199. package/dist/http/tar.js +21 -5
  200. package/dist/http/wire-gate.d.ts +9 -0
  201. package/dist/http/wire-gate.js +9 -0
  202. package/dist/http/wire-types.d.ts +187 -0
  203. package/dist/http/workspace-content.d.ts +8 -0
  204. package/dist/http/workspace-content.js +10 -0
  205. package/dist/images/bake-validate.d.ts +63 -0
  206. package/dist/images/bake-validate.js +71 -1
  207. package/dist/images/manifest.d.ts +19 -0
  208. package/dist/images/manifest.js +6 -1
  209. package/dist/index.d.ts +1 -5
  210. package/dist/index.js +10 -5
  211. package/dist/key-resolver.d.ts +23 -0
  212. package/dist/key-resolver.js +27 -2
  213. package/dist/leader/diffout.d.ts +23 -0
  214. package/dist/leader/diffout.js +8 -1
  215. package/dist/leader/diffup.d.ts +32 -0
  216. package/dist/leader/diffup.js +43 -0
  217. package/dist/leader/endpoint.d.ts +20 -0
  218. package/dist/leader/endpoint.js +25 -2
  219. package/dist/leader/fanout.d.ts +60 -0
  220. package/dist/leader/fanout.js +29 -3
  221. package/dist/leader/grader-env-factory.d.ts +74 -0
  222. package/dist/leader/grader-env-factory.js +62 -3
  223. package/dist/leader/leader.d.ts +97 -0
  224. package/dist/leader/leader.js +151 -4
  225. package/dist/leader/merge.d.ts +94 -0
  226. package/dist/leader/merge.js +112 -9
  227. package/dist/leader/planner.d.ts +52 -0
  228. package/dist/leader/planner.js +47 -3
  229. package/dist/leader/repair-oracle.d.ts +61 -0
  230. package/dist/leader/repair-oracle.js +59 -1
  231. package/dist/leader/repair-wire.d.ts +78 -0
  232. package/dist/leader/repair-wire.js +79 -2
  233. package/dist/leader/wire.d.ts +79 -0
  234. package/dist/leader/wire.js +255 -8
  235. package/dist/lsp/e2b-bridge.d.ts +16 -0
  236. package/dist/lsp/e2b-bridge.js +32 -4
  237. package/dist/lsp/e2b-manager.d.ts +10 -0
  238. package/dist/lsp/e2b-manager.js +18 -2
  239. package/dist/lsp/lsp-frames.d.ts +12 -0
  240. package/dist/lsp/lsp-frames.js +12 -0
  241. package/dist/lsp/manager.d.ts +12 -0
  242. package/dist/lsp/manager.js +35 -2
  243. package/dist/lsp/types.d.ts +10 -0
  244. package/dist/lsp/ws-transport.d.ts +12 -0
  245. package/dist/lsp/ws-transport.js +53 -5
  246. package/dist/lsp-evict.d.ts +14 -0
  247. package/dist/lsp-evict.js +15 -1
  248. package/dist/main.js +530 -2129
  249. package/dist/memory-export.d.ts +1 -0
  250. package/dist/memory-export.js +4 -0
  251. package/dist/memory-scope.d.ts +49 -0
  252. package/dist/memory-scope.js +87 -4
  253. package/dist/memory-sync-client.d.ts +24 -0
  254. package/dist/memory-sync-client.js +41 -2
  255. package/dist/memory-sync.d.ts +23 -0
  256. package/dist/memory-sync.js +70 -1
  257. package/dist/model-select.d.ts +39 -0
  258. package/dist/model-select.js +42 -1
  259. package/dist/observability/cost-quota.d.ts +20 -0
  260. package/dist/observability/cost-quota.js +4 -0
  261. package/dist/observability/cost-taxonomy.d.ts +45 -0
  262. package/dist/observability/cost-taxonomy.js +34 -0
  263. package/dist/observability/logger.d.ts +1 -0
  264. package/dist/observability/logger.js +6 -0
  265. package/dist/observability/metrics.d.ts +13 -0
  266. package/dist/observability/metrics.js +63 -0
  267. package/dist/observability/otel-exporter.d.ts +9 -0
  268. package/dist/observability/otel-exporter.js +11 -3
  269. package/dist/observability/principal-context.d.ts +9 -0
  270. package/dist/observability/principal-context.js +9 -0
  271. package/dist/observability/prompt-manifest.d.ts +37 -0
  272. package/dist/observability/prompt-manifest.js +35 -1
  273. package/dist/observability/rate-limit.d.ts +10 -0
  274. package/dist/observability/rate-limit.js +1 -0
  275. package/dist/observability/tool-trace.d.ts +24 -0
  276. package/dist/observability/tool-trace.js +41 -1
  277. package/dist/orchestration/hardened-vm-runner.d.ts +107 -0
  278. package/dist/orchestration/hardened-vm-runner.js +119 -4
  279. package/dist/orchestration/hardened-vm-worker-runner.d.ts +14 -0
  280. package/dist/orchestration/hardened-vm-worker-runner.js +26 -1
  281. package/dist/orchestration/hardened-vm-worker.js +27 -0
  282. package/dist/orchestration/subagent-steer.d.ts +44 -0
  283. package/dist/orchestration/subagent-steer.js +45 -1
  284. package/dist/orchestration/workflow-agent-steer.d.ts +54 -0
  285. package/dist/orchestration/workflow-agent-steer.js +80 -1
  286. package/dist/orchestration/workflow-completion-inbox.d.ts +189 -2
  287. package/dist/orchestration/workflow-completion-inbox.js +283 -32
  288. package/dist/orchestration/workflow-notify-journal.d.ts +132 -1
  289. package/dist/orchestration/workflow-notify-journal.js +187 -13
  290. package/dist/parked-decide.d.ts +61 -0
  291. package/dist/parked-decide.js +58 -1
  292. package/dist/per-task-image.d.ts +54 -0
  293. package/dist/per-task-image.js +41 -0
  294. package/dist/plan-cache-probe.d.ts +35 -0
  295. package/dist/plan-cache-probe.js +18 -3
  296. package/dist/plugins/approval-exemption-store.d.ts +7 -0
  297. package/dist/plugins/approval-exemption-store.js +28 -2
  298. package/dist/plugins/approval-store-sql.d.ts +64 -0
  299. package/dist/plugins/approval-store-sql.js +32 -0
  300. package/dist/plugins/background-agent-store-sql.d.ts +55 -0
  301. package/dist/plugins/background-agent-store-sql.js +91 -4
  302. package/dist/plugins/background-shell-support.d.ts +98 -0
  303. package/dist/plugins/background-shell-support.js +117 -13
  304. package/dist/plugins/blob-backend.d.ts +104 -0
  305. package/dist/plugins/blob-backend.js +163 -6
  306. package/dist/plugins/breaker-state-sql.d.ts +65 -1
  307. package/dist/plugins/breaker-state-sql.js +46 -8
  308. package/dist/plugins/caching-session-store.d.ts +42 -0
  309. package/dist/plugins/caching-session-store.js +63 -3
  310. package/dist/plugins/checkpoint-store-sql.d.ts +179 -0
  311. package/dist/plugins/checkpoint-store-sql.js +239 -11
  312. package/dist/plugins/file-outcome-sink.d.ts +4 -0
  313. package/dist/plugins/file-outcome-sink.js +9 -0
  314. package/dist/plugins/file-resume-anchor-store.d.ts +20 -0
  315. package/dist/plugins/file-resume-anchor-store.js +43 -4
  316. package/dist/plugins/file-run-store.d.ts +90 -0
  317. package/dist/plugins/file-run-store.js +145 -13
  318. package/dist/plugins/file-snapshot-store-sql.d.ts +133 -1
  319. package/dist/plugins/file-snapshot-store-sql.js +178 -10
  320. package/dist/plugins/file-workflow-journal-store.d.ts +10 -0
  321. package/dist/plugins/file-workflow-journal-store.js +10 -0
  322. package/dist/plugins/fork-routing-session-store.d.ts +47 -0
  323. package/dist/plugins/fork-routing-session-store.js +51 -3
  324. package/dist/plugins/host-platform.d.ts +69 -0
  325. package/dist/plugins/host-platform.js +81 -2
  326. package/dist/plugins/image-bake-store-sql.d.ts +136 -1
  327. package/dist/plugins/image-bake-store-sql.js +241 -7
  328. package/dist/plugins/image-index-sql.d.ts +46 -0
  329. package/dist/plugins/image-index-sql.js +113 -4
  330. package/dist/plugins/k8s-bg-scripts.d.ts +34 -0
  331. package/dist/plugins/k8s-bg-scripts.js +88 -4
  332. package/dist/plugins/k8s-exec-protocol.d.ts +33 -0
  333. package/dist/plugins/k8s-exec-protocol.js +41 -0
  334. package/dist/plugins/local-checkpoint-store.d.ts +40 -0
  335. package/dist/plugins/local-checkpoint-store.js +86 -7
  336. package/dist/plugins/local-session-store.d.ts +157 -0
  337. package/dist/plugins/local-session-store.js +289 -34
  338. package/dist/plugins/local-task-attachment-store.js +14 -2
  339. package/dist/plugins/mailbox-store-sql.d.ts +38 -0
  340. package/dist/plugins/mailbox-store-sql.js +39 -6
  341. package/dist/plugins/memory-engine-pg.d.ts +30 -0
  342. package/dist/plugins/memory-engine-pg.js +122 -4
  343. package/dist/plugins/memory-engine-tidb.d.ts +26 -0
  344. package/dist/plugins/memory-engine-tidb.js +115 -5
  345. package/dist/plugins/memory-engine-vector-util.d.ts +5 -0
  346. package/dist/plugins/memory-engine-vector-util.js +5 -0
  347. package/dist/plugins/memory-resume-anchor-store.d.ts +8 -0
  348. package/dist/plugins/memory-resume-anchor-store.js +17 -0
  349. package/dist/plugins/memory-run-store.d.ts +63 -0
  350. package/dist/plugins/memory-run-store.js +73 -8
  351. package/dist/plugins/memory-session-policy-store.d.ts +17 -0
  352. package/dist/plugins/memory-session-policy-store.js +17 -0
  353. package/dist/plugins/memory-sync-store-pg.d.ts +42 -0
  354. package/dist/plugins/memory-sync-store-pg.js +45 -2
  355. package/dist/plugins/memory-sync-store-tidb.d.ts +9 -0
  356. package/dist/plugins/memory-sync-store-tidb.js +31 -1
  357. package/dist/plugins/outcome-ledger-sql.d.ts +63 -0
  358. package/dist/plugins/outcome-ledger-sql.js +97 -3
  359. package/dist/plugins/pg-approval-store.d.ts +7 -0
  360. package/dist/plugins/pg-approval-store.js +7 -0
  361. package/dist/plugins/pg-breaker-state.d.ts +6 -0
  362. package/dist/plugins/pg-breaker-state.js +6 -0
  363. package/dist/plugins/pg-checkpoint-store.d.ts +8 -0
  364. package/dist/plugins/pg-checkpoint-store.js +8 -0
  365. package/dist/plugins/pg-cost-quota.d.ts +17 -0
  366. package/dist/plugins/pg-cost-quota.js +6 -0
  367. package/dist/plugins/pg-file-snapshot-store.d.ts +6 -0
  368. package/dist/plugins/pg-file-snapshot-store.js +6 -0
  369. package/dist/plugins/pg-image-bake.d.ts +9 -0
  370. package/dist/plugins/pg-image-bake.js +9 -0
  371. package/dist/plugins/pg-image-index.d.ts +9 -0
  372. package/dist/plugins/pg-image-index.js +9 -0
  373. package/dist/plugins/pg-outcome-ledger.d.ts +9 -0
  374. package/dist/plugins/pg-outcome-ledger.js +9 -0
  375. package/dist/plugins/pg-pool.d.ts +50 -0
  376. package/dist/plugins/pg-pool.js +78 -0
  377. package/dist/plugins/pg-query.d.ts +11 -0
  378. package/dist/plugins/pg-rate-limiter.d.ts +23 -0
  379. package/dist/plugins/pg-rate-limiter.js +12 -2
  380. package/dist/plugins/pg-resume-anchor-store.d.ts +5 -0
  381. package/dist/plugins/pg-resume-anchor-store.js +5 -0
  382. package/dist/plugins/pg-run-store.d.ts +7 -0
  383. package/dist/plugins/pg-run-store.js +7 -0
  384. package/dist/plugins/pg-safe-json.d.ts +13 -0
  385. package/dist/plugins/pg-safe-json.js +40 -4
  386. package/dist/plugins/pg-session-policy-store.d.ts +5 -0
  387. package/dist/plugins/pg-session-policy-store.js +5 -0
  388. package/dist/plugins/pg-session-storage.d.ts +72 -0
  389. package/dist/plugins/pg-session-storage.js +152 -20
  390. package/dist/plugins/pg-session-store.d.ts +10 -0
  391. package/dist/plugins/pg-session-store.js +10 -0
  392. package/dist/plugins/pg-tool-result-store.d.ts +7 -0
  393. package/dist/plugins/pg-tool-result-store.js +7 -0
  394. package/dist/plugins/pg-workflow-journal-store.d.ts +7 -0
  395. package/dist/plugins/pg-workflow-journal-store.js +7 -0
  396. package/dist/plugins/pg-workflow-run-store.d.ts +7 -0
  397. package/dist/plugins/pg-workflow-run-store.js +7 -0
  398. package/dist/plugins/posix-shell-fs.d.ts +3 -0
  399. package/dist/plugins/posix-shell-fs.js +31 -1
  400. package/dist/plugins/remote-env-adb.d.ts +25 -0
  401. package/dist/plugins/remote-env-adb.js +95 -12
  402. package/dist/plugins/remote-env-e2b.d.ts +146 -0
  403. package/dist/plugins/remote-env-e2b.js +371 -40
  404. package/dist/plugins/remote-env-file-error.d.ts +34 -0
  405. package/dist/plugins/remote-env-file-error.js +37 -0
  406. package/dist/plugins/remote-env-host.d.ts +151 -0
  407. package/dist/plugins/remote-env-host.js +468 -70
  408. package/dist/plugins/remote-env-k8s.d.ts +135 -0
  409. package/dist/plugins/remote-env-k8s.js +318 -32
  410. package/dist/plugins/remote-env-local-docker.d.ts +65 -0
  411. package/dist/plugins/remote-env-local-docker.js +149 -24
  412. package/dist/plugins/remote-env-ssh.d.ts +35 -0
  413. package/dist/plugins/remote-env-ssh.js +117 -20
  414. package/dist/plugins/remote-scratchpad.d.ts +38 -0
  415. package/dist/plugins/remote-scratchpad.js +32 -2
  416. package/dist/plugins/remote-shell.d.ts +22 -0
  417. package/dist/plugins/remote-shell.js +27 -1
  418. package/dist/plugins/resume-anchor-store-sql.d.ts +28 -0
  419. package/dist/plugins/resume-anchor-store-sql.js +11 -0
  420. package/dist/plugins/roster-store-sql.d.ts +27 -0
  421. package/dist/plugins/roster-store-sql.js +54 -0
  422. package/dist/plugins/run-store-sql.d.ts +194 -0
  423. package/dist/plugins/run-store-sql.js +210 -9
  424. package/dist/plugins/s3-presign.d.ts +20 -0
  425. package/dist/plugins/s3-presign.js +49 -2
  426. package/dist/plugins/scheduler-support.d.ts +12 -0
  427. package/dist/plugins/scheduler-support.js +75 -3
  428. package/dist/plugins/send-file-ledger.d.ts +15 -0
  429. package/dist/plugins/send-file-ledger.js +53 -4
  430. package/dist/plugins/send-user-file.d.ts +77 -0
  431. package/dist/plugins/send-user-file.js +92 -4
  432. package/dist/plugins/session-policy-store-sql.d.ts +15 -0
  433. package/dist/plugins/session-policy-store-sql.js +75 -3
  434. package/dist/plugins/session-store.d.ts +45 -0
  435. package/dist/plugins/session-store.js +51 -0
  436. package/dist/plugins/sql-driver.d.ts +77 -0
  437. package/dist/plugins/sql-driver.js +4 -0
  438. package/dist/plugins/sql-escape.d.ts +8 -0
  439. package/dist/plugins/sql-escape.js +8 -0
  440. package/dist/plugins/sql-row-helpers.d.ts +25 -0
  441. package/dist/plugins/sql-row-helpers.js +25 -0
  442. package/dist/plugins/store-backend.d.ts +103 -0
  443. package/dist/plugins/store-backend.js +120 -27
  444. package/dist/plugins/store-contracts.d.ts +62 -0
  445. package/dist/plugins/store-contracts.js +3 -0
  446. package/dist/plugins/task-attachment-store.d.ts +60 -0
  447. package/dist/plugins/task-attachment-store.js +49 -3
  448. package/dist/plugins/task-list-store-sql.d.ts +25 -0
  449. package/dist/plugins/task-list-store-sql.js +21 -0
  450. package/dist/plugins/tidb-approval-store.d.ts +6 -0
  451. package/dist/plugins/tidb-approval-store.js +6 -0
  452. package/dist/plugins/tidb-breaker-state.d.ts +5 -0
  453. package/dist/plugins/tidb-breaker-state.js +5 -0
  454. package/dist/plugins/tidb-checkpoint-store.d.ts +7 -0
  455. package/dist/plugins/tidb-checkpoint-store.js +7 -0
  456. package/dist/plugins/tidb-cost-quota.d.ts +6 -0
  457. package/dist/plugins/tidb-cost-quota.js +1 -0
  458. package/dist/plugins/tidb-file-snapshot-store.d.ts +6 -0
  459. package/dist/plugins/tidb-file-snapshot-store.js +6 -0
  460. package/dist/plugins/tidb-image-bake.d.ts +8 -0
  461. package/dist/plugins/tidb-image-bake.js +8 -0
  462. package/dist/plugins/tidb-image-index.d.ts +8 -0
  463. package/dist/plugins/tidb-image-index.js +8 -0
  464. package/dist/plugins/tidb-outcome-ledger.d.ts +10 -0
  465. package/dist/plugins/tidb-outcome-ledger.js +10 -0
  466. package/dist/plugins/tidb-pool.d.ts +56 -0
  467. package/dist/plugins/tidb-pool.js +181 -1
  468. package/dist/plugins/tidb-rate-limiter.d.ts +11 -0
  469. package/dist/plugins/tidb-rate-limiter.js +5 -2
  470. package/dist/plugins/tidb-resume-anchor-store.d.ts +5 -0
  471. package/dist/plugins/tidb-resume-anchor-store.js +5 -0
  472. package/dist/plugins/tidb-run-store.d.ts +7 -0
  473. package/dist/plugins/tidb-run-store.js +7 -0
  474. package/dist/plugins/tidb-session-policy-store.d.ts +5 -0
  475. package/dist/plugins/tidb-session-policy-store.js +5 -0
  476. package/dist/plugins/tidb-session-storage.d.ts +43 -0
  477. package/dist/plugins/tidb-session-storage.js +62 -3
  478. package/dist/plugins/tidb-session-store.d.ts +142 -0
  479. package/dist/plugins/tidb-session-store.js +264 -16
  480. package/dist/plugins/tidb-tool-result-store.d.ts +5 -0
  481. package/dist/plugins/tidb-tool-result-store.js +7 -0
  482. package/dist/plugins/tidb-workflow-journal-store.d.ts +7 -0
  483. package/dist/plugins/tidb-workflow-journal-store.js +7 -0
  484. package/dist/plugins/tidb-workflow-run-store.d.ts +8 -0
  485. package/dist/plugins/tidb-workflow-run-store.js +8 -0
  486. package/dist/plugins/tool-result-store-sql.d.ts +58 -0
  487. package/dist/plugins/tool-result-store-sql.js +38 -2
  488. package/dist/plugins/web-search.d.ts +35 -0
  489. package/dist/plugins/web-search.js +45 -9
  490. package/dist/plugins/workflow-journal-limits.d.ts +10 -0
  491. package/dist/plugins/workflow-journal-limits.js +10 -0
  492. package/dist/plugins/workflow-journal-store-sql.d.ts +78 -0
  493. package/dist/plugins/workflow-journal-store-sql.js +58 -2
  494. package/dist/plugins/workflow-run-store-sql.d.ts +84 -0
  495. package/dist/plugins/workflow-run-store-sql.js +84 -6
  496. package/dist/plugins/worktree-isolation.d.ts +45 -0
  497. package/dist/plugins/worktree-isolation.js +105 -6
  498. package/dist/plugins/write-behind-counter.d.ts +56 -1
  499. package/dist/plugins/write-behind-counter.js +53 -14
  500. package/dist/principal-jwt.d.ts +24 -0
  501. package/dist/principal-jwt.js +60 -5
  502. package/dist/project-memory.d.ts +22 -0
  503. package/dist/project-memory.js +144 -15
  504. package/dist/prompts-domain-validate.d.ts +28 -0
  505. package/dist/prompts-domain-validate.js +42 -1
  506. package/dist/question.d.ts +33 -0
  507. package/dist/question.js +69 -2
  508. package/dist/resource-suspend.d.ts +21 -0
  509. package/dist/resource-suspend.js +16 -0
  510. package/dist/router/route-orchestration.d.ts +78 -0
  511. package/dist/router/route-orchestration.js +77 -0
  512. package/dist/run-local.d.ts +32 -0
  513. package/dist/run-local.js +172 -8
  514. package/dist/runs.d.ts +189 -4
  515. package/dist/runs.js +465 -24
  516. package/dist/runtime-caps-resolver.d.ts +106 -0
  517. package/dist/runtime-caps-resolver.js +89 -4
  518. package/dist/runtime-governance.d.ts +84 -0
  519. package/dist/runtime-governance.js +127 -1
  520. package/dist/sandbox-pkg-source.d.ts +23 -0
  521. package/dist/sandbox-pkg-source.js +37 -0
  522. package/dist/sealed-key.d.ts +54 -0
  523. package/dist/sealed-key.js +68 -3
  524. package/dist/security.d.ts +108 -0
  525. package/dist/security.js +145 -6
  526. package/dist/sema-registry.d.ts +21 -0
  527. package/dist/sema-registry.js +21 -0
  528. package/dist/session-leaf-bus.d.ts +31 -0
  529. package/dist/session-leaf-bus.js +32 -0
  530. package/dist/session-sync-content.d.ts +46 -0
  531. package/dist/session-sync-content.js +47 -1
  532. package/dist/session-sync-kernel.d.ts +89 -0
  533. package/dist/session-sync-kernel.js +48 -3
  534. package/dist/session-sync.d.ts +125 -0
  535. package/dist/session-sync.js +181 -8
  536. package/dist/session-titler.d.ts +26 -0
  537. package/dist/session-titler.js +41 -7
  538. package/dist/session-watch.d.ts +53 -1
  539. package/dist/session-watch.js +73 -9
  540. package/dist/sighup-idle.d.ts +30 -0
  541. package/dist/sighup-idle.js +12 -1
  542. package/dist/spec-fields.d.ts +91 -3
  543. package/dist/spec-fields.js +116 -4
  544. package/dist/task-cwd.d.ts +50 -0
  545. package/dist/task-cwd.js +68 -1
  546. package/dist/task-mcp.d.ts +47 -0
  547. package/dist/task-mcp.js +29 -0
  548. package/dist/task-settings.d.ts +175 -0
  549. package/dist/task-settings.js +226 -11
  550. package/dist/task-workflow.d.ts +67 -0
  551. package/dist/task-workflow.js +75 -8
  552. package/dist/tool-approval.d.ts +91 -0
  553. package/dist/tool-approval.js +215 -0
  554. package/dist/trace/artifacts.d.ts +9 -0
  555. package/dist/trace/artifacts.js +30 -5
  556. package/dist/trace/core-keyset-guard.d.ts +18 -0
  557. package/dist/trace/ledger-sink.d.ts +43 -0
  558. package/dist/trace/ledger-sink.js +64 -5
  559. package/dist/trace/project.d.ts +133 -0
  560. package/dist/trace/project.js +189 -2
  561. package/dist/trace/redact.d.ts +19 -0
  562. package/dist/trace/redact.js +66 -9
  563. package/dist/usage-analytics.d.ts +26 -0
  564. package/dist/usage-analytics.js +26 -3
  565. package/package.json +1 -1
@@ -1,3 +1,33 @@
1
+ /**
2
+ * S1 value-verdict harness โ€” the 3-ARM RUNNER + PRODUCER. SPEC-S1-value-harness.md ยง3. ONE shared Runner + ONE
3
+ * hidden objective oracle; ONLY the profile differs (SOLO = runWithVerification; SUP = durable suspend/resume +
4
+ * repair + steering + plan_review; TEAM = runLeaderTask). Each arm emits ONE conformant s1.v1 RawRow per
5
+ * (task ร— arm ร— seed) โ€” RawRow === core RunRecord (row.ts).
6
+ *
7
+ * ๐Ÿ”ด THE s1.v1 PRODUCER OBLIGATIONS (design/95):
8
+ * - `arm` is the LOWERCASE wire tag (armTag). `runStatus` is HONEST โ€” an infra death (OOM/passthrough/
9
+ * nested-root crash) is "infra-failed" and EXCLUDED from scoring (the metric tool drops it); default "scored".
10
+ * - `oracle` = the 4 OBJECTIVE booleans (the measure). `delivery.withheld` is ONLY ever true for SUP/TEAM โ€”
11
+ * SOLO is ALWAYS false (a lone agent has no gate to intercept it).
12
+ * - `stats` = a SUBSET of core TaskResult.stats (costBreakdown C1 + humanReview C2), assigned directly.
13
+ * - ๐Ÿ”ด WHENEVER a row withholds (delivery.withheld===true), it MUST carry a `counterfactual` (the metric tool
14
+ * gives NO withhold-credit without `withoutInterventionTrulyCorrect===false`). The producer attaches it; the
15
+ * numerator (DELIVERED-CORRECT) is the metric's, NEVER decided here. An LLM-judge is never the measure.
16
+ *
17
+ * ๐Ÿ”ด THE FIVE HIGH REVIEW CORRECTIONS APPLIED HERE (do NOT reproduce the bugs):
18
+ * 1. BUDGET-MATCH: every arm carries the SAME budget; TEAM ฮฃworker โ‰ค solo (`assertBudgetMatch`, runner-ctx.ts).
19
+ * 2. SUP RESUME GATING: gate PRECISELY on `status==="suspended" && checkpointToken` (โ†’ policy_ask) vs
20
+ * `status==="needs_review" && checkpointToken` (โ†’ plan_review/dry_run_review by gate KIND). NEVER on
21
+ * `verification.verdict==="unverified"`. The token is read off the TaskResult (`checkpointToken`).
22
+ * 3. WORKER-ENV: the repair leg ALWAYS passes `workerEnv` so runRepairLoop's ยง5.1 isolation identity check is LIVE.
23
+ * 4. PAIRED-SEED: `seed` is best-effort N-repeat replicate, NEVER a GO criterion; rows are distributional.
24
+ * 5. COMPLETE TEAM COST: TEAM stats = ฮฃ(worker stats.costBreakdown) + (merge.repair?.costUsd) +
25
+ * (merge.conflictResolverCostUsd) โ€” all three legs (the resolver cost was just un-dropped, merge.ts).
26
+ *
27
+ * ๐Ÿ”ด BLOCKED-but-honest structure: the REAL firm run is clay-gated (expensive E2B+DeepSeek). This file builds the
28
+ * REAL arm logic against INJECTABLE profile seams (`ProfileDeps`) so the deterministic smoke drives it with a MOCK
29
+ * (no real E2B/DeepSeek/TiDB). The live make-real proof injects the real core entrypoints.
30
+ */
1
31
  import type { TaskResult, VerificationResult, RepairResult, CheckpointToken, ResumeOutcome, Checkpoint, CheckpointStore } from "@sema-agent/core";
2
32
  import type { MergeResult } from "../../leader/merge.js";
3
33
  import type { WorkerReport } from "../../leader/fanout.js";
@@ -5,18 +35,39 @@ import { type RunnerCtx } from "./runner-ctx.js";
5
35
  import { type TrapSpec } from "./tasks.js";
6
36
  import { type RawRow, type CoreStatsSubset, type OracleVerdicts, type InterceptCounterfactual, type RunStatus } from "./row.js";
7
37
  export type Arm = "SOLO" | "SUP" | "TEAM";
38
+ /** Cap on SUP suspendโ†’resume legs (a belt โ€” core's suspendLoopCap is the primary bound). */
8
39
  export declare const MAX_LEGS = 8;
40
+ /** Why a row WITHHELD (deliberate, recorded; provenance for the metric tool's CORRECTLY/INCORRECTLY JOIN). */
9
41
  export type WithholdTrigger = "reviewer-deny" | "repair-candidate-only" | "repair-gave-up" | "repair-conflict" | "plan-reject" | "verify-not-pass" | "safety-escalate";
42
+ /**
43
+ * The injectable profile seams. The REAL make-real proof injects the core entrypoints (runWithVerification,
44
+ * resumeWithVerification, runRepairLoop) bound to a real Runner + real E2B envs; the deterministic smoke injects
45
+ * a mock. The SUP gating / budget-application / cost-aggregation in this file is the SAME on both paths.
46
+ */
10
47
  export interface ProfileDeps {
48
+ /** SOLO: run the impl behind the verifyโ†’fix gate. */
11
49
  runWithVerification: (implSpec: SoloImplSpec) => Promise<VerificationResult>;
50
+ /** SUP verify/durable path: same entry, but the impl carries the durable-approval + checkpointStore wiring. */
12
51
  runWithVerificationSup: (implSpec: SupImplSpec) => Promise<VerificationResult>;
52
+ /** SUP: resume a durable-suspended impl AND verify on completion. */
13
53
  resumeWithVerification: (token: CheckpointToken, outcome: ResumeOutcome, implSpec: SupImplSpec) => Promise<VerificationResult>;
54
+ /** SUP repair leg: the SAFE-tier self-repair loop (workerEnv MUST be wired by the caller โ€” corr #3). */
14
55
  runRepairLoop: (implSpec: SupImplSpec) => Promise<RepairResult>;
56
+ /** SUP: read the suspend's pending record so boundCallId/boundInputHash are echoed VERBATIM (corr #2 / TOCTOU). */
15
57
  getCheckpoint: (store: CheckpointStore, token: CheckpointToken, scope: string) => Promise<Checkpoint | null>;
58
+ /** TEAM: run the leader orchestrator (its deps are wired by the caller with budget-stamped worker specs). */
16
59
  runLeaderTask: () => Promise<LeaderTaskOutcome>;
60
+ /** The hidden objective oracle (the measure) โ€” the 4 s1.v1 booleans, graded in a DISTINCT grader env. */
17
61
  runOracle: () => Promise<OracleVerdicts>;
62
+ /**
63
+ * ๐Ÿ”ด The COUNTERFACTUAL oracle โ€” REQUIRED for the withhold-credit JOIN. When a SUP/TEAM gate WITHHELD a
64
+ * delivery, this grades the UN-INTERCEPTED run (what would have shipped had the gate not fired) in the distinct
65
+ * grader env, yielding `withoutInterventionTrulyCorrect`. Absent โ‡’ the producer attaches NO counterfactual and
66
+ * the metric tool treats the withhold as UNVERIFIED (no credit) โ€” an honest "not measured", never a faked credit.
67
+ */
18
68
  runCounterfactualOracle?: () => Promise<OracleVerdicts>;
19
69
  }
70
+ /** A leaf impl spec โ€” budget already stamped by the harness (the ยง3.2 red line). */
20
71
  export interface SoloImplSpec {
21
72
  objective: string;
22
73
  maxTokens: number;
@@ -25,47 +76,122 @@ export interface SoloImplSpec {
25
76
  maxTurns: number;
26
77
  };
27
78
  }
79
+ /** A SUP impl spec โ€” the leaf budget PLUS the durable wiring (checkpointStore + durableApproval + toolPolicy). */
28
80
  export interface SupImplSpec extends SoloImplSpec {
81
+ /** The durable-approval scope (== the resolve scope read on getCheckpoint). */
29
82
  durableApprovalScope: string;
83
+ /** The process-local checkpoint store (InMemoryCheckpointStore for S1 โ€” see SPEC Risk LOW / README). */
30
84
  checkpointStore: CheckpointStore;
31
85
  }
86
+ /** What the harness needs back from the leader run for the COMPLETE TEAM cost (corr #5) + outcome. */
32
87
  export interface LeaderTaskOutcome {
33
88
  ok: boolean;
34
89
  reports: WorkerReport[];
35
90
  merge?: MergeResult;
36
91
  repairTerminal?: string;
92
+ /** ๐Ÿ”ด (review MEDIUM) the ACTUAL per-worker stamped budget (maxCostUsd) the leader ran each worker with โ€” the
93
+ * bigger-pie guard input. Summed (NOT the algebraic maxCostUsd/Nร—N tautology) so a stamping drift above the
94
+ * arm budget is actually caught. Absent โ‡’ `teamWorkerBudgetSumUsd` is undefined (honest "not measured"). */
37
95
  workerBudgetsUsd?: number[];
96
+ /** ๐Ÿ”ด INFRA death (OOM / passthrough / nested-root crash) โ€” when true the row is `runStatus:"infra-failed"`
97
+ * (EXCLUDED from scoring), NOT a scored loss. Default false. The live leader wiring sets this on a crash. */
38
98
  infraFailed?: boolean;
99
+ /** TEAM delivery interception (a merge gate / human held the merge) โ€” drives `delivery.withheld` for TEAM. */
39
100
  withheld?: boolean;
40
101
  }
102
+ /** Build the SOLO impl spec (budget stamped). */
41
103
  export declare function buildSoloImplSpec(trap: TrapSpec, ctx: RunnerCtx): SoloImplSpec;
104
+ /**
105
+ * Build the SUP impl spec (budget stamped + durable wiring). ๐Ÿ”ด The durable-approval `scope` is the resolve key the
106
+ * suspend/resume loop reads back via getCheckpoint, so it MUST be unique per (runId, task, seed) โ€” derive it from
107
+ * the FULL raw seed (NOT a repeatIdx that coerces every distinct string seed to 0, which would alias two SUP cells
108
+ * onto one scope and let cell B read cell A's pending record on a shared store), and include ctx.runId so
109
+ * concurrent runs can never alias either.
110
+ */
42
111
  export declare function buildSupImplSpec(trap: TrapSpec, ctx: RunnerCtx, seed: number | string, store: CheckpointStore): SupImplSpec;
112
+ /** Read the verbatim binding (boundCallId / boundInputHash) off a suspend's pending tool_approval record. */
43
113
  export declare function bindingFromCheckpoint(cp: Checkpoint | null): {
44
114
  boundCallId: string;
45
115
  boundInputHash: string;
46
116
  } | undefined;
117
+ /** The non-optional C1 finance taxonomy the harness always emits (core's `CoreStatsSubset.costBreakdown` is
118
+ * OPTIONAL for back-compat, but the producer ALWAYS fills all four lines โ€” this is that concrete shape). */
47
119
  type CostBreakdown = NonNullable<CoreStatsSubset["costBreakdown"]>;
120
+ /** The s1.v1 `stats` the producer emits โ€” a `CoreStatsSubset` with `costBreakdown` + `humanReview` ALWAYS present
121
+ * (core types them optional; the harness never omits them, so it works with concrete, non-undefined locals). */
48
122
  type EmittedStats = CoreStatsSubset & {
49
123
  costBreakdown: CostBreakdown;
50
124
  humanReview: NonNullable<CoreStatsSubset["humanReview"]>;
51
125
  };
126
+ /**
127
+ * ๐Ÿ”ด THE ๅ‘ฝ้—จ โ€” classify a SOLO/SUP cell's honest scoring eligibility from the engine result. An INFRA death
128
+ * (OOM / passthrough / sandbox/env crash) surfaces as a terminal `status` of `"failed"` or `"timeout"` on the
129
+ * VerificationResult (core TaskStatus) โ€” it MUST be `"infra-failed"` (EXCLUDED from scoring), NOT scored as a
130
+ * legitimate agent loss. An honest agent abandon (`"blocked"` = ran out of turns / gave up) is a SCORED loss, not
131
+ * infra-failed. The repair-terminal `oracle.unprotected` (the ยง5.1 grader/worker identity check failed โ€” the
132
+ * measurement was reward-hackable and never trustworthy) is ALSO non-scorable โ†’ excluded, never a withhold-credit.
133
+ */
52
134
  export declare function classifyRunStatus(input: {
53
135
  status?: VerificationResult["status"];
54
136
  repairTerminal?: string;
55
137
  }): RunStatus;
138
+ /**
139
+ * Capture the s1.v1 `stats` subset directly off a core `TaskResult.stats` (costBreakdown C1 + humanReview C2).
140
+ * Assign-direct: the field names/shapes match core's bench subpath contract(1.110.0 ้ฆ–ๅ‘;็Žฐ่กŒ core ๅทฒๆ‰ฉ humanReview.gates[toolName?/toolArg?],service ๅช่ฏปๅญ้›†ๅ‘ๅŽๅ…ผๅฎนโ€”โ€”L17)โ€” no transformation, no pre-composed scalar.
141
+ * C2 (human seconds) is NEVER folded into C1 (token ยตUSD) โ€” three separate axes (design/89 ยง2.1).
142
+ */
56
143
  export declare function captureStats(stats: TaskResult["stats"] | undefined): EmittedStats;
144
+ /**
145
+ * ๐Ÿ”ด Corr #5 โ€” the COMPLETE TEAM `stats`. ฮฃ(worker stats.costBreakdown + humanReview) PLUS the merge legs:
146
+ * `repair?.costUsd` and `conflictResolverCostUsd` (the resolver cost was just un-dropped in merge.ts). All three
147
+ * legs, or TEAM C1 is undercounted (design/89's #1 confound). costUsd (float USD) โ†’ ยตUSD into llmRoot.
148
+ */
57
149
  export declare function captureTeamStats(reports: WorkerReport[], merge: MergeResult | undefined): EmittedStats;
150
+ /**
151
+ * ๐Ÿ”ด Corr #2 โ€” the SUP suspendโ†’resume drive loop, with PRECISE gating. Returns the FINAL VerificationResult (C2
152
+ * accumulates across legs in stats.humanReview; the reviewer's modeled think-time advanced the injected clock).
153
+ *
154
+ * The loop distinguishes the cases by `status` + `checkpointGate.kind`:
155
+ * - status==="suspended" && checkpointToken โ†’ a tool-approval pause โ†’ resume with a `policy_ask` outcome,
156
+ * echoing boundCallId/boundInputHash VERBATIM from the pending record (TOCTOU fail-closed otherwise).
157
+ * - status==="needs_review" && checkpointToken โ†’ a plan-review / dry-run-diff pause โ†’ resume with the matching
158
+ * outcome by gate KIND (a DIFFERENT discriminant โ€” binds no tool call).
159
+ * - else (completed / terminal-unverified) โ†’ stop.
160
+ * It NEVER gates on `verification.verdict==="unverified"`.
161
+ */
58
162
  export declare function driveSupSuspendResume(initial: VerificationResult, deps: ProfileDeps, implSpec: SupImplSpec, trap: TrapSpec, advanceClock: (ms: number) => void): Promise<VerificationResult>;
163
+ /**
164
+ * Map a SUP/SOLO verification result + the oracle verdict to a deliberate-withhold trigger (or undefined). A
165
+ * withhold is only "deliberate" when the engine ESCALATED honestly (verify not-PASS, reviewer deny, repair
166
+ * non-accepting terminal, plan reject, safety escalate) โ€” NOT a crash/ran-out-of-turns (that is an abandon, NOT a
167
+ * withhold). ๐Ÿ”ด SOLO can NEVER produce a deliberate withhold (it has no gate) โ€” the caller never feeds SOLO here.
168
+ */
59
169
  export declare function deliberateWithholdTrigger(input: {
60
170
  oracleDelivered: boolean;
61
171
  verifyVerdict?: string;
172
+ /** Set iff verifyVerdict==="unverified" โ€” disambiguates crash/no_verdict/opted_out (NOT an honest withhold). */
62
173
  unverifiedReason?: string;
63
174
  repairTerminal?: string;
64
175
  lastApprovalDenied?: boolean;
65
176
  planRejected?: boolean;
66
177
  safetyEscalated?: boolean;
67
178
  }): WithholdTrigger | undefined;
179
+ /**
180
+ * Run ONE (arm, trap, seed) cell to a RawRow, via the injected profile seams. This is the SPEC ยง3 entry
181
+ * (`runArm`). The SUP gating / budget / cost-aggregation logic is REAL and exercised by the deterministic smoke;
182
+ * the live make-real proof injects real core entrypoints + real E2B envs.
183
+ *
184
+ * ๐Ÿ”ด The hidden oracle (`deps.runOracle`) is ALWAYS the measure. `delivery.withheld` is ONLY ever true for
185
+ * SUP/TEAM; SOLO is ALWAYS false. A withheld row ALWAYS carries a `counterfactual` when the counterfactual oracle
186
+ * is wired (else none โ†’ the metric gives no credit).
187
+ */
68
188
  export declare function runArm(arm: Arm, trap: TrapSpec, seed: number | string, ctx: RunnerCtx, deps: ProfileDeps, supStore?: CheckpointStore): Promise<RawRow>;
189
+ /**
190
+ * Assemble a conformant s1.v1 RawRow from the captured pieces. Stamps the honest defaults (runStatus "scored",
191
+ * arm โ†’ lowercase tag, infraMicroUsd OMITTED = not measured). The Simpson grouping coords (suiteVersion /
192
+ * archetype / valueDimension) come off the trap. ๐Ÿ”ด A withheld row MUST carry a counterfactual to earn credit;
193
+ * if `withheld && !counterfactual` the row is emitted WITHOUT one (honest UNVERIFIED-WITHHELD โ†’ no credit).
194
+ */
69
195
  export declare function assembleRow(input: {
70
196
  arm: Arm;
71
197
  trap: TrapSpec;
@@ -1,11 +1,50 @@
1
+ /**
2
+ * S1 value-verdict harness โ€” the 3-ARM RUNNER + PRODUCER. SPEC-S1-value-harness.md ยง3. ONE shared Runner + ONE
3
+ * hidden objective oracle; ONLY the profile differs (SOLO = runWithVerification; SUP = durable suspend/resume +
4
+ * repair + steering + plan_review; TEAM = runLeaderTask). Each arm emits ONE conformant s1.v1 RawRow per
5
+ * (task ร— arm ร— seed) โ€” RawRow === core RunRecord (row.ts).
6
+ *
7
+ * ๐Ÿ”ด THE s1.v1 PRODUCER OBLIGATIONS (design/95):
8
+ * - `arm` is the LOWERCASE wire tag (armTag). `runStatus` is HONEST โ€” an infra death (OOM/passthrough/
9
+ * nested-root crash) is "infra-failed" and EXCLUDED from scoring (the metric tool drops it); default "scored".
10
+ * - `oracle` = the 4 OBJECTIVE booleans (the measure). `delivery.withheld` is ONLY ever true for SUP/TEAM โ€”
11
+ * SOLO is ALWAYS false (a lone agent has no gate to intercept it).
12
+ * - `stats` = a SUBSET of core TaskResult.stats (costBreakdown C1 + humanReview C2), assigned directly.
13
+ * - ๐Ÿ”ด WHENEVER a row withholds (delivery.withheld===true), it MUST carry a `counterfactual` (the metric tool
14
+ * gives NO withhold-credit without `withoutInterventionTrulyCorrect===false`). The producer attaches it; the
15
+ * numerator (DELIVERED-CORRECT) is the metric's, NEVER decided here. An LLM-judge is never the measure.
16
+ *
17
+ * ๐Ÿ”ด THE FIVE HIGH REVIEW CORRECTIONS APPLIED HERE (do NOT reproduce the bugs):
18
+ * 1. BUDGET-MATCH: every arm carries the SAME budget; TEAM ฮฃworker โ‰ค solo (`assertBudgetMatch`, runner-ctx.ts).
19
+ * 2. SUP RESUME GATING: gate PRECISELY on `status==="suspended" && checkpointToken` (โ†’ policy_ask) vs
20
+ * `status==="needs_review" && checkpointToken` (โ†’ plan_review/dry_run_review by gate KIND). NEVER on
21
+ * `verification.verdict==="unverified"`. The token is read off the TaskResult (`checkpointToken`).
22
+ * 3. WORKER-ENV: the repair leg ALWAYS passes `workerEnv` so runRepairLoop's ยง5.1 isolation identity check is LIVE.
23
+ * 4. PAIRED-SEED: `seed` is best-effort N-repeat replicate, NEVER a GO criterion; rows are distributional.
24
+ * 5. COMPLETE TEAM COST: TEAM stats = ฮฃ(worker stats.costBreakdown) + (merge.repair?.costUsd) +
25
+ * (merge.conflictResolverCostUsd) โ€” all three legs (the resolver cost was just un-dropped, merge.ts).
26
+ *
27
+ * ๐Ÿ”ด BLOCKED-but-honest structure: the REAL firm run is clay-gated (expensive E2B+DeepSeek). This file builds the
28
+ * REAL arm logic against INJECTABLE profile seams (`ProfileDeps`) so the deterministic smoke drives it with a MOCK
29
+ * (no real E2B/DeepSeek/TiDB). The live make-real proof injects the real core entrypoints.
30
+ */
1
31
  import { leafBudgetFields } from "./runner-ctx.js";
2
32
  import {} from "./tasks.js";
3
33
  import { decideApproval, decidePlan } from "./reviewer.js";
4
34
  import { oracleTrulyCorrect, pickOracleVerdicts, armTag, S1_SCHEMA_VERSION, S1_CORE_VERSION, } from "./row.js";
35
+ /** Cap on SUP suspendโ†’resume legs (a belt โ€” core's suspendLoopCap is the primary bound). */
5
36
  export const MAX_LEGS = 8;
37
+ /** Build the SOLO impl spec (budget stamped). */
6
38
  export function buildSoloImplSpec(trap, ctx) {
7
39
  return { objective: trap.implSpec.objective, ...leafBudgetFields(ctx.budget) };
8
40
  }
41
+ /**
42
+ * Build the SUP impl spec (budget stamped + durable wiring). ๐Ÿ”ด The durable-approval `scope` is the resolve key the
43
+ * suspend/resume loop reads back via getCheckpoint, so it MUST be unique per (runId, task, seed) โ€” derive it from
44
+ * the FULL raw seed (NOT a repeatIdx that coerces every distinct string seed to 0, which would alias two SUP cells
45
+ * onto one scope and let cell B read cell A's pending record on a shared store), and include ctx.runId so
46
+ * concurrent runs can never alias either.
47
+ */
9
48
  export function buildSupImplSpec(trap, ctx, seed, store) {
10
49
  return {
11
50
  objective: trap.implSpec.objective,
@@ -14,24 +53,40 @@ export function buildSupImplSpec(trap, ctx, seed, store) {
14
53
  checkpointStore: store,
15
54
  };
16
55
  }
56
+ /** Read the verbatim binding (boundCallId / boundInputHash) off a suspend's pending tool_approval record. */
17
57
  export function bindingFromCheckpoint(cp) {
18
58
  if (!cp)
19
59
  return undefined;
20
60
  if (cp.pendingAction.kind !== "tool_approval")
21
- return undefined;
61
+ return undefined; // a plan_review/resource_limit suspend binds no tool call
22
62
  return { boundCallId: cp.pendingAction.toolCallId, boundInputHash: cp.pendingAction.boundInputHash };
23
63
  }
64
+ /** The all-false oracle โ€” the honest verdict for an infra death (nothing delivered/built/tested/checked). */
24
65
  const ORACLE_UNDELIVERED = { delivered: false, hiddenTestsGreen: false, buildPassed: false, invariantsOk: false };
66
+ /** An empty C1 finance taxonomy (all zeros) โ€” the assign-direct default when a TaskResult has no stats. */
25
67
  function emptyCostBreakdown() {
26
68
  return { llmRootMicroUsd: 0, nestedSubagentMicroUsd: 0, memoryConsolidationMicroUsd: 0, compactionMicroUsd: 0 };
27
69
  }
70
+ /**
71
+ * ๐Ÿ”ด THE ๅ‘ฝ้—จ โ€” classify a SOLO/SUP cell's honest scoring eligibility from the engine result. An INFRA death
72
+ * (OOM / passthrough / sandbox/env crash) surfaces as a terminal `status` of `"failed"` or `"timeout"` on the
73
+ * VerificationResult (core TaskStatus) โ€” it MUST be `"infra-failed"` (EXCLUDED from scoring), NOT scored as a
74
+ * legitimate agent loss. An honest agent abandon (`"blocked"` = ran out of turns / gave up) is a SCORED loss, not
75
+ * infra-failed. The repair-terminal `oracle.unprotected` (the ยง5.1 grader/worker identity check failed โ€” the
76
+ * measurement was reward-hackable and never trustworthy) is ALSO non-scorable โ†’ excluded, never a withhold-credit.
77
+ */
28
78
  export function classifyRunStatus(input) {
29
79
  if (input.status === "failed" || input.status === "timeout")
30
80
  return "infra-failed";
31
81
  if (input.repairTerminal === "oracle.unprotected")
32
- return "infra-failed";
82
+ return "infra-failed"; // broken/un-isolated oracle โ†’ not scorable
33
83
  return "scored";
34
84
  }
85
+ /**
86
+ * Capture the s1.v1 `stats` subset directly off a core `TaskResult.stats` (costBreakdown C1 + humanReview C2).
87
+ * Assign-direct: the field names/shapes match core's bench subpath contract(1.110.0 ้ฆ–ๅ‘;็Žฐ่กŒ core ๅทฒๆ‰ฉ humanReview.gates[toolName?/toolArg?],service ๅช่ฏปๅญ้›†ๅ‘ๅŽๅ…ผๅฎนโ€”โ€”L17)โ€” no transformation, no pre-composed scalar.
88
+ * C2 (human seconds) is NEVER folded into C1 (token ยตUSD) โ€” three separate axes (design/89 ยง2.1).
89
+ */
35
90
  export function captureStats(stats) {
36
91
  const bd = stats?.costBreakdown ?? emptyCostBreakdown();
37
92
  const hr = stats?.humanReview ?? { count: 0, totalWaitMs: 0, gates: [] };
@@ -45,6 +100,11 @@ export function captureStats(stats) {
45
100
  humanReview: { count: hr.count, totalWaitMs: hr.totalWaitMs, gates: hr.gates },
46
101
  };
47
102
  }
103
+ /**
104
+ * ๐Ÿ”ด Corr #5 โ€” the COMPLETE TEAM `stats`. ฮฃ(worker stats.costBreakdown + humanReview) PLUS the merge legs:
105
+ * `repair?.costUsd` and `conflictResolverCostUsd` (the resolver cost was just un-dropped in merge.ts). All three
106
+ * legs, or TEAM C1 is undercounted (design/89's #1 confound). costUsd (float USD) โ†’ ยตUSD into llmRoot.
107
+ */
48
108
  export function captureTeamStats(reports, merge) {
49
109
  const acc = { costBreakdown: emptyCostBreakdown(), humanReview: { count: 0, totalWaitMs: 0, gates: [] } };
50
110
  for (const r of reports) {
@@ -57,13 +117,33 @@ export function captureTeamStats(reports, merge) {
57
117
  acc.humanReview.totalWaitMs += s.humanReview.totalWaitMs;
58
118
  acc.humanReview.gates.push(...s.humanReview.gates);
59
119
  }
120
+ // The two merge legs โ€” both folded into llmRoot (they are real model spend the harness must count).
60
121
  const repairUsd = merge?.repair?.costUsd ?? 0;
61
122
  const resolverUsd = merge?.conflictResolverCostUsd ?? 0;
62
123
  acc.costBreakdown.llmRootMicroUsd += Math.round((repairUsd + resolverUsd) * 1e6);
63
124
  return acc;
64
125
  }
126
+ /**
127
+ * ๐Ÿ”ด Corr #2 โ€” the SUP suspendโ†’resume drive loop, with PRECISE gating. Returns the FINAL VerificationResult (C2
128
+ * accumulates across legs in stats.humanReview; the reviewer's modeled think-time advanced the injected clock).
129
+ *
130
+ * The loop distinguishes the cases by `status` + `checkpointGate.kind`:
131
+ * - status==="suspended" && checkpointToken โ†’ a tool-approval pause โ†’ resume with a `policy_ask` outcome,
132
+ * echoing boundCallId/boundInputHash VERBATIM from the pending record (TOCTOU fail-closed otherwise).
133
+ * - status==="needs_review" && checkpointToken โ†’ a plan-review / dry-run-diff pause โ†’ resume with the matching
134
+ * outcome by gate KIND (a DIFFERENT discriminant โ€” binds no tool call).
135
+ * - else (completed / terminal-unverified) โ†’ stop.
136
+ * It NEVER gates on `verification.verdict==="unverified"`.
137
+ */
65
138
  export async function driveSupSuspendResume(initial, deps, implSpec, trap, advanceClock) {
66
139
  let vr = initial;
140
+ // ๐Ÿ”ด (firm-tar live-caught via S1_DEBUG_SUPCOST) core's resumeWithVerification returns INCREMENTAL costBreakdown โ€”
141
+ // ONLY this resume leg's model spend โ€” but CUMULATIVE humanReview (gates persist through the checkpoint). Live
142
+ // proof: leg0 c1ยต=1361 (initialโ†’suspend), leg1 c1ยต=218 (resume), leg2 c1ยต=221 (resumeโ†’complete); the final leg's
143
+ // vr.stats held ONLY 221ยต, DROPPING 1361+218=1579ยต (~8ร— undercount) โ†’ a FALSE pareto frontier (SUP looked CHEAPER
144
+ // than SOLO, contradicting search S1a/S1b "competent task โ‡’ SUP dominated"). FIX: SUM costBreakdown across EVERY
145
+ // leg (initial + each resume); humanReview is already cumulative so the final leg's value is correct. This is
146
+ // design/89's #1 confound (C1 undercount), SUP variant โ€” the TEAM variant is captureTeamStats.
67
147
  const c1Acc = emptyCostBreakdown();
68
148
  const foldCost = (s) => {
69
149
  const b = s?.costBreakdown;
@@ -74,25 +154,38 @@ export async function driveSupSuspendResume(initial, deps, implSpec, trap, advan
74
154
  c1Acc.memoryConsolidationMicroUsd += b.memoryConsolidationMicroUsd;
75
155
  c1Acc.compactionMicroUsd += b.compactionMicroUsd;
76
156
  };
157
+ // ๐Ÿ”ด (review MEDIUM finding) track break vs MAX_LEGS-exhaustion: a break already folded the current vr at the top of
158
+ // its iteration; exhausting MAX_LEGS via a final resume leaves that last resumed vr UNfolded โ†’ undercount. Fold it
159
+ // after the loop iff we did NOT break.
77
160
  let exitedViaBreak = false;
78
161
  for (let leg = 0; leg < MAX_LEGS; leg++) {
79
- foldCost(vr.stats);
162
+ foldCost(vr.stats); // accumulate THIS leg's incremental cost BEFORE the resume below overwrites vr
80
163
  if (process.env.S1_DEBUG_SUPCOST)
81
164
  console.error(`[SUPCOST leg=${leg}] status=${vr.status} reason=${vr.verification?.unverifiedReason} c1ยต=${vr.stats?.costBreakdown?.llmRootMicroUsd} accC1ยต=${c1Acc.llmRootMicroUsd} hrGates=${vr.stats?.humanReview?.gates?.length}`);
82
165
  const gateKind = vr.checkpointGate?.kind;
166
+ // ๐Ÿ”ด core's verify wrappers (runWithVerification / resumeWithVerification) MAP a durable pause to status:"failed"
167
+ // via mapNestedSuspend (design/45 ยง11 Q6 / design/80 D-B: durable suspend/resume is a top-level-runTask boundary;
168
+ // the verify wrapper can't adjudicate a mid-run pause). The map carries checkpointToken + checkpointGate UP and
169
+ // stamps verification.unverifiedReason = "suspended" | "needs_review". So a re-suspend on a LATER gate (e.g. the
170
+ // worker's 2nd gated bash: git add THEN git commit) arrives as status:"failed", NOT "suspended" โ€” detect the pause
171
+ // via (raw status) OR (the mapped unverifiedReason), or the driver breaks after the FIRST gate and the whole SUP
172
+ // run is lost as infra-failed (firm-v1 N=1 caught exactly this: C1/C2-SUP died at the 2nd gate).
83
173
  const pauseReason = vr.verification?.unverifiedReason;
84
174
  const toolSuspend = (vr.status === "suspended" || pauseReason === "suspended") && Boolean(vr.checkpointToken);
85
175
  const reviewSuspend = (vr.status === "needs_review" || pauseReason === "needs_review") && Boolean(vr.checkpointToken);
86
176
  if (toolSuspend) {
177
+ // tool-approval suspend โ†’ policy_ask. Echo the binding VERBATIM from the pending record.
87
178
  const cp = await deps.getCheckpoint(implSpec.checkpointStore, vr.checkpointToken, implSpec.durableApprovalScope);
88
179
  const binding = bindingFromCheckpoint(cp);
89
180
  if (!binding) {
181
+ // No tool_approval pending record (or none readable) โ€” we cannot mint a safe policy_ask binding without it
182
+ // (recomputing would risk a TOCTOU fail-closed). Stop honestly rather than mis-resume (no fake datapoint).
90
183
  exitedViaBreak = true;
91
184
  break;
92
185
  }
93
- const toolName = cp && cp.pendingAction.kind === "tool_approval" ? cp.pendingAction.toolName : "Bash";
186
+ const toolName = cp && cp.pendingAction.kind === "tool_approval" ? cp.pendingAction.toolName : "Bash"; // Q6 (core 1.161): CC-aligned fallback name
94
187
  const decision = decideApproval({ gateKind: gateKind ?? "human", toolName, task: trap.reviewer });
95
- advanceClock(decision.thinkMs);
188
+ advanceClock(decision.thinkMs); // models C2; never advances real wall-time
96
189
  const outcome = {
97
190
  gate: "policy_ask",
98
191
  boundCallId: binding.boundCallId,
@@ -103,27 +196,41 @@ export async function driveSupSuspendResume(initial, deps, implSpec, trap, advan
103
196
  vr = await deps.resumeWithVerification(vr.checkpointToken, outcome, implSpec);
104
197
  }
105
198
  else if (reviewSuspend) {
199
+ // ๐Ÿ”ด (review HIGH) a `needs_review` STATUS covers TWO gate KINDS (core): a PRE-ACTION plan review
200
+ // (`plan_review`) and a dry-run DIFF review (`needs_review`). They take DIFFERENT resume outcomes โ€” emitting a
201
+ // `plan_review` outcome for a dry-run `needs_review` gate trips core's gateMatch โ†’ checkpoint.gate_mismatch.
106
202
  const plan = decidePlan({ task: trap.reviewer });
107
203
  advanceClock(plan.thinkMs);
108
204
  const outcome = gateKind === "needs_review"
109
- ?
205
+ ? // dry-run diff review โ†’ dry_run_review (2-state approve|reject; NO editedPlan).
110
206
  { gate: "dry_run_review", decision: plan.action === "reject" ? "reject" : "approve" }
111
- :
207
+ : // plan_review (or an absent kind on a legacy mint) โ†’ plan_review (3-state, may carry an editedPlan).
112
208
  { gate: "plan_review", decision: plan.action, ...(plan.editedPlan !== undefined ? { editedPlan: plan.editedPlan } : {}) };
113
209
  vr = await deps.resumeWithVerification(vr.checkpointToken, outcome, implSpec);
114
210
  }
115
211
  else {
116
212
  exitedViaBreak = true;
117
- break;
213
+ break; // completed / terminal-unverified โ†’ stop
118
214
  }
119
215
  }
216
+ // ๐Ÿ”ด (review MEDIUM finding) MAX_LEGS exhausted via a resume (not a break) โ‡’ the last resumed vr's incremental cost
217
+ // was never folded (the loop exits before the next iteration's top-of-loop foldCost). Fold it now. No double-count:
218
+ // every break path already folded the current vr at the top of its iteration.
120
219
  if (!exitedViaBreak)
121
220
  foldCost(vr.stats);
221
+ // ๐Ÿ”ด Overwrite the final leg's INCREMENTAL costBreakdown with the SUMMED-across-legs cost (the bug fix above);
222
+ // humanReview is already cumulative (gates persist through the checkpoint) so the final leg's value is kept.
122
223
  return { ...vr, stats: { ...(vr.stats ?? {}), costBreakdown: c1Acc } };
123
224
  }
225
+ /**
226
+ * Map a SUP/SOLO verification result + the oracle verdict to a deliberate-withhold trigger (or undefined). A
227
+ * withhold is only "deliberate" when the engine ESCALATED honestly (verify not-PASS, reviewer deny, repair
228
+ * non-accepting terminal, plan reject, safety escalate) โ€” NOT a crash/ran-out-of-turns (that is an abandon, NOT a
229
+ * withhold). ๐Ÿ”ด SOLO can NEVER produce a deliberate withhold (it has no gate) โ€” the caller never feeds SOLO here.
230
+ */
124
231
  export function deliberateWithholdTrigger(input) {
125
232
  if (input.oracleDelivered)
126
- return undefined;
233
+ return undefined; // delivered rows are never "withheld"
127
234
  if (input.safetyEscalated)
128
235
  return "safety-escalate";
129
236
  if (input.lastApprovalDenied)
@@ -137,15 +244,28 @@ export function deliberateWithholdTrigger(input) {
137
244
  return "repair-gave-up";
138
245
  case "conflict":
139
246
  return "repair-conflict";
247
+ // ๐Ÿ”ด `oracle.unprotected` is NOT a withhold โ€” it is a ยง5.1 isolation FAILURE (the grader env was not isolated
248
+ // from the worker env, so the oracle was reward-hackable and never trustworthy). It is classified
249
+ // runStatus:"infra-failed" (EXCLUDED, classifyRunStatus) and must NEVER earn withhold-credit. Not mapped here.
140
250
  case "needs_human_oracle":
141
- return "repair-gave-up";
251
+ return "repair-gave-up"; // no usable oracle โ†’ an honest abstain in the withhold family
142
252
  default:
143
253
  break;
144
254
  }
255
+ // ๐Ÿ”ด ONLY an HONEST ADVERSARIAL verdict (FAIL / PARTIAL) is a deliberate verify-not-pass withhold. verdict
256
+ // ==="unverified" is NOT a withhold: it covers a crash/ran-out-of-turns (an abandon) AND the documented
257
+ // no_verdict (broken/flaky verifier โ€” work done, NOT gated) / opted_out (verification disabled) reasons โ€”
258
+ // coupling any of those to gating would book a phantom scored withhold (README ยง2 lesson).
145
259
  if (input.verifyVerdict === "FAIL" || input.verifyVerdict === "PARTIAL")
146
260
  return "verify-not-pass";
147
261
  return undefined;
148
262
  }
263
+ /**
264
+ * Build the counterfactual block for a WITHHELD row. `withInterventionTrulyCorrect` = the actual (post-gate)
265
+ * oracle verdict's truth; `withoutInterventionTrulyCorrect` = the un-intercepted run's truth, from the
266
+ * counterfactual oracle. Returns undefined when no counterfactual oracle is wired (โ†’ UNVERIFIED-WITHHELD, no
267
+ * credit โ€” an honest "not measured", never a faked credit).
268
+ */
149
269
  async function buildCounterfactual(deps, withInterventionOracle) {
150
270
  if (!deps.runCounterfactualOracle)
151
271
  return undefined;
@@ -155,6 +275,15 @@ async function buildCounterfactual(deps, withInterventionOracle) {
155
275
  withoutInterventionTrulyCorrect: oracleTrulyCorrect(without),
156
276
  };
157
277
  }
278
+ /**
279
+ * Run ONE (arm, trap, seed) cell to a RawRow, via the injected profile seams. This is the SPEC ยง3 entry
280
+ * (`runArm`). The SUP gating / budget / cost-aggregation logic is REAL and exercised by the deterministic smoke;
281
+ * the live make-real proof injects real core entrypoints + real E2B envs.
282
+ *
283
+ * ๐Ÿ”ด The hidden oracle (`deps.runOracle`) is ALWAYS the measure. `delivery.withheld` is ONLY ever true for
284
+ * SUP/TEAM; SOLO is ALWAYS false. A withheld row ALWAYS carries a `counterfactual` when the counterfactual oracle
285
+ * is wired (else none โ†’ the metric gives no credit).
286
+ */
158
287
  export async function runArm(arm, trap, seed, ctx, deps, supStore) {
159
288
  const startedAt = ctx.clock.now();
160
289
  if (arm === "SOLO") {
@@ -166,6 +295,7 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
166
295
  catch (e) {
167
296
  if (process.env.S1_DEBUG_GIT)
168
297
  console.error("[S1 SOLO infra throw]", e instanceof Error ? (e.stack ?? e.message) : String(e));
298
+ // ๐Ÿ”ด a THROWN infra exception (OOM/passthrough/sandbox crash) is an infra death โ†’ EXCLUDED, not a scored loss.
169
299
  return assembleRow({
170
300
  arm, trap, seed, ctx,
171
301
  stats: captureStats(undefined),
@@ -179,6 +309,8 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
179
309
  if (process.env.S1_DEBUG_GIT)
180
310
  console.error("[S1 SOLO vr.status]", vr.status, "| stats:", JSON.stringify(vr.stats)?.slice(0, 200));
181
311
  const oracle = pickOracleVerdicts(await deps.runOracle());
312
+ // ๐Ÿ”ด SOLO can NEVER withhold (no gate to intercept) โ€” delivery.withheld is ALWAYS false, no counterfactual.
313
+ // ๐Ÿ”ด the ๅ‘ฝ้—จ: a terminal status of failed/timeout is an infra death (EXCLUDED), not a scored agent loss.
182
314
  return assembleRow({
183
315
  arm,
184
316
  trap,
@@ -195,14 +327,18 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
195
327
  if (arm === "SUP") {
196
328
  if (!supStore)
197
329
  throw new Error("runArm SUP: a CheckpointStore is required (process-local InMemoryCheckpointStore for S1)");
330
+ // ๐Ÿ”ด (review HIGH #9) scope is derived from the FULL seed (+ runId), NOT a coerced repeatIdx โ€” distinct string
331
+ // seeds must NOT alias onto one durable-approval scope (cross-cell resume on a shared store).
198
332
  const implSpec = buildSupImplSpec(trap, ctx, seed, supStore);
199
333
  let vr;
200
334
  let repairTerminal;
201
335
  try {
202
336
  if (trap.supDriver === "repair") {
337
+ // ๐Ÿ”ด corr #3 โ€” the repair seam MUST be wired with workerEnv (asserted at the seam) so the ยง5.1 identity
338
+ // check is live. We read the repair result's terminal + stats here.
203
339
  const rr = await deps.runRepairLoop(implSpec);
204
340
  repairTerminal = rr.terminal;
205
- vr = rr;
341
+ vr = rr; // RepairResult extends VerificationResult
206
342
  }
207
343
  else {
208
344
  const initial = await deps.runWithVerificationSup(implSpec);
@@ -212,6 +348,7 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
212
348
  catch (e) {
213
349
  if (process.env.S1_DEBUG_GIT)
214
350
  console.error(`[S1 SUP infra throw driver=${trap.supDriver}]`, e instanceof Error ? (e.stack ?? e.message) : String(e));
351
+ // ๐Ÿ”ด a THROWN infra exception is an infra death โ†’ EXCLUDED (the ๅ‘ฝ้—จ โ€” symmetric with SOLO/TEAM).
215
352
  return assembleRow({
216
353
  arm, trap, seed, ctx,
217
354
  stats: captureStats(undefined),
@@ -225,10 +362,15 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
225
362
  if (process.env.S1_DEBUG_GIT)
226
363
  console.error(`[S1 SUP vr.status driver=${trap.supDriver}]`, vr.status, "| repairTerminal:", repairTerminal, "| verdict:", vr.verification?.verdict, "| unverifiedReason:", vr.verification?.unverifiedReason, "| checkpointGate:", JSON.stringify(vr.checkpointGate), "| error:", vr.error, "| stats:", JSON.stringify(vr.stats)?.slice(0, 180));
227
364
  const oracle = pickOracleVerdicts(await deps.runOracle());
365
+ // ๐Ÿ”ด the ๅ‘ฝ้—จ (review HIGH #1/#5/#8): a terminal status of failed/timeout OR an `oracle.unprotected` repair
366
+ // terminal (broken/un-isolated oracle) is non-scorable โ†’ "infra-failed" (EXCLUDED), NOT a scored loss and
367
+ // NEVER a withhold-credit. Symmetric with TEAM.
228
368
  const runStatus = classifyRunStatus({ status: vr.status, repairTerminal });
229
369
  const lastGate = vr.stats?.humanReview?.gates?.at(-1);
370
+ // ๐Ÿ”ด (review HIGH #2) verdict==="unverified" (crash/no_verdict/opted_out) is NOT a withhold โ€” pass the reason
371
+ // through so deliberateWithholdTrigger only fires verify-not-pass on an HONEST FAIL/PARTIAL verdict.
230
372
  const withholdTrigger = runStatus === "infra-failed"
231
- ? undefined
373
+ ? undefined // an excluded row never books a withhold
232
374
  : deliberateWithholdTrigger({
233
375
  oracleDelivered: oracle.delivered,
234
376
  verifyVerdict: vr.verification.verdict,
@@ -253,11 +395,13 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
253
395
  finishedAt: ctx.clock.now(),
254
396
  });
255
397
  }
398
+ // TEAM
256
399
  let lt;
257
400
  try {
258
401
  lt = await deps.runLeaderTask();
259
402
  }
260
403
  catch {
404
+ // ๐Ÿ”ด a THROWN infra exception is an infra death โ†’ EXCLUDED (symmetric with SOLO/SUP).
261
405
  return assembleRow({
262
406
  arm, trap, seed, ctx,
263
407
  stats: captureStats(undefined),
@@ -270,13 +414,27 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
270
414
  }
271
415
  const oracle = pickOracleVerdicts(await deps.runOracle());
272
416
  const stats = captureTeamStats(lt.reports, lt.merge);
417
+ // ๐Ÿ”ด INFRA death โ†’ runStatus:"infra-failed" (EXCLUDED from scoring), not a scored loss. The leader's explicit
418
+ // infraFailed flag OR an `oracle.unprotected` repair terminal (broken/un-isolated oracle, never trustworthy)
419
+ // both exclude the row (the latter must NEVER earn withhold-credit โ€” review #8).
273
420
  const runStatus = lt.infraFailed ? "infra-failed" : classifyRunStatus({ repairTerminal: lt.repairTerminal });
421
+ // ๐Ÿ”ด (review MEDIUM) ฮฃ the ACTUAL stamped per-worker budgets (not the maxCostUsd/Nร—N tautology).
274
422
  const teamWorkerBudgetSumUsd = lt.workerBudgetsUsd !== undefined ? lt.workerBudgetsUsd.reduce((a, b) => a + b, 0) : undefined;
423
+ // A TEAM withhold = an explicit merge interception OR a non-accepting repair terminal on an undelivered run.
424
+ // ๐Ÿ”ด (review #4) the lt.withheld merge-gate self-report is gated behind !oracle.delivered: a merge gate that
425
+ // "held" yet a CORRECT tree nevertheless shipped (the grader oracle independently observes delivered) is NOT
426
+ // a withhold of THIS delivery โ€” emitting withheld+delivered-correct is a self-contradictory provenance row.
275
427
  const withholdTrigger = runStatus === "infra-failed"
276
- ? undefined
428
+ ? undefined // an excluded row never books a withhold
277
429
  : deliberateWithholdTrigger({ oracleDelivered: oracle.delivered, repairTerminal: lt.repairTerminal });
278
430
  const withheld = runStatus !== "infra-failed" && ((lt.withheld === true && !oracle.delivered) || withholdTrigger !== undefined);
279
431
  const counterfactual = withheld ? await buildCounterfactual(deps, oracle) : undefined;
432
+ // ๐Ÿ”ด wq64gmm5e + (review #10) CLOCK-ADVANCE OWNERSHIP (harness-owns-clock, mirrors SUP): the harness folds the
433
+ // TEAM worker review wait into the injected clock HERE, as the SINGLE fold point, so C2 (stats.humanReview)
434
+ // and C3 (wallTimeSec) stay consistent across arms (SUP folds its review wait the same way in
435
+ // driveSupSuspendResume). ๐Ÿ”ด The live leader's workers MUST NOT advance ctx.clock themselves (give them a
436
+ // child/frozen clock) โ€” if they shared ctx.now, a worker hitting a modeled review gate would advance the
437
+ // clock and this line would DOUBLE-COUNT the same totalWaitMs (see runner-ctx.ts clock-ownership note).
280
438
  ctx.clock.advanceClock(stats.humanReview.totalWaitMs);
281
439
  return assembleRow({
282
440
  arm,
@@ -293,9 +451,19 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
293
451
  finishedAt: ctx.clock.now(),
294
452
  });
295
453
  }
454
+ /**
455
+ * Assemble a conformant s1.v1 RawRow from the captured pieces. Stamps the honest defaults (runStatus "scored",
456
+ * arm โ†’ lowercase tag, infraMicroUsd OMITTED = not measured). The Simpson grouping coords (suiteVersion /
457
+ * archetype / valueDimension) come off the trap. ๐Ÿ”ด A withheld row MUST carry a counterfactual to earn credit;
458
+ * if `withheld && !counterfactual` the row is emitted WITHOUT one (honest UNVERIFIED-WITHHELD โ†’ no credit).
459
+ */
296
460
  export function assembleRow(input) {
297
461
  const { arm, trap, seed, ctx } = input;
462
+ // SOLO can never withhold โ€” fail-closed honest even if a caller mis-sets it.
298
463
  const withheld = arm === "SOLO" ? false : input.withheld;
464
+ // ๐Ÿ”ด (review #6) HONESTY-ON-THE-WIRE: stamp reviewerKind when a modeled (NOT real-human) review touched the row โ€”
465
+ // i.e. a SUP/TEAM row whose stats carry a humanReview gate (the deterministic reviewer.ts rubric produced its
466
+ // C2). SOLO never gates โ†’ never stamped. A downstream reader can then tell the C2 seconds are modeled.
299
467
  const reviewerTouched = arm !== "SOLO" && (input.stats.humanReview.gates.length > 0 || input.stats.humanReview.count > 0);
300
468
  const row = {
301
469
  schemaVersion: S1_SCHEMA_VERSION,
@@ -310,7 +478,12 @@ export function assembleRow(input) {
310
478
  delivery: { withheld },
311
479
  stats: input.stats,
312
480
  wallTimeSec: (input.finishedAt - input.startedAt) / 1000,
481
+ // infraMicroUsd OMITTED โ€” no service infra-cost seam in S1 (NOT measured; never a faked 0).
313
482
  ...(withheld && input.counterfactual !== undefined ? { counterfactual: input.counterfactual } : {}),
483
+ // ๐Ÿ”ด RECORD-LEVEL honesty (core 1.111.0 RunRecord.judgeMode): a SUP/TEAM value rides on a SCRIPTED approver
484
+ // (NOT a real human review), so its judgment is an INITIAL judgment, never firm. Stamped on the RECORD so a
485
+ // record-level filter/re-aggregation cannot silently lose the "scripted-human, not firm" caveat. SOLO has no
486
+ // approver โ‡’ omitted (a pure objective-oracle run). Mirrors `meta.reviewerKind` (the search-side provenance copy).
314
487
  ...(reviewerTouched ? { judgeMode: "scripted-human-initjudge" } : {}),
315
488
  meta: {
316
489
  startedAt: input.startedAt,
@@ -321,6 +494,8 @@ export function assembleRow(input) {
321
494
  ...(reviewerTouched ? { reviewerKind: "scripted-human-rubric" } : {}),
322
495
  },
323
496
  };
497
+ // teamWorkerBudgetSumUsd is the bigger-pie guard input โ€” kept on meta so assertBudgetMatch can read it (it is
498
+ // NOT a RunRecord scoring field). Stamped only for TEAM when the leader reported the real stamped split.
324
499
  if (arm === "TEAM" && input.teamWorkerBudgetSumUsd !== undefined && row.meta) {
325
500
  row.meta.teamWorkerBudgetSumUsd = input.teamWorkerBudgetSumUsd;
326
501
  }