@sema-agent/server 7.43.0 โ†’ 7.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/USAGE.md +18 -0
  2. package/dist/adoption/plan.js +31 -192
  3. package/dist/adoption/quiesce.js +3 -86
  4. package/dist/adoption/runner.js +3 -140
  5. package/dist/adoption/sql.js +0 -74
  6. package/dist/adoption/wire.js +0 -80
  7. package/dist/approval-ask-machine.js +0 -75
  8. package/dist/approval-card.js +0 -323
  9. package/dist/approval-deny-reasons.js +0 -42
  10. package/dist/approval-hmac.js +0 -35
  11. package/dist/approval-reconciler.js +8 -166
  12. package/dist/approval.js +4 -67
  13. package/dist/audit.js +1 -44
  14. package/dist/auth-bridge.js +4 -47
  15. package/dist/auth-keys.js +0 -23
  16. package/dist/bake-runner/main.js +4 -65
  17. package/dist/bake-runner/protocol.js +3 -58
  18. package/dist/bake-runner/runner.js +5 -91
  19. package/dist/bench/l8/artifact.js +2 -61
  20. package/dist/bench/l8/escape.js +0 -25
  21. package/dist/bench/l8/index.js +0 -14
  22. package/dist/bench/l8/probes.js +0 -60
  23. package/dist/bench/l8/run-probes.js +2 -45
  24. package/dist/bench/s1/arms.js +14 -189
  25. package/dist/bench/s1/live-deps.js +11 -253
  26. package/dist/bench/s1/oracle.js +1 -36
  27. package/dist/bench/s1/repair-oracle-adapter.js +0 -30
  28. package/dist/bench/s1/reviewer.js +0 -34
  29. package/dist/bench/s1/row.js +0 -62
  30. package/dist/bench/s1/run-firm.js +4 -70
  31. package/dist/bench/s1/runner-ctx.js +0 -40
  32. package/dist/bench/s1/tasks.js +0 -115
  33. package/dist/boot/adoption.js +0 -20
  34. package/dist/boot/budget-tracing.js +3 -55
  35. package/dist/boot/config-center.js +43 -551
  36. package/dist/boot/coordinators.js +1 -69
  37. package/dist/boot/crash-last.js +0 -18
  38. package/dist/boot/deferred-sandbox-path-env.js +3 -119
  39. package/dist/boot/execution-env.js +5 -171
  40. package/dist/boot/governance-seams.js +0 -92
  41. package/dist/boot/leader.js +0 -69
  42. package/dist/boot/limit-sync.js +0 -2
  43. package/dist/boot/memory-boundary.js +3 -91
  44. package/dist/boot/org-memory.js +1 -25
  45. package/dist/boot/parked-revive-gate.js +0 -150
  46. package/dist/boot/permission-rules-audit.js +1 -56
  47. package/dist/boot/reapers.js +15 -273
  48. package/dist/boot/resolve-spec.js +9 -768
  49. package/dist/boot/retention-lane.js +4 -87
  50. package/dist/boot/runner-deps.js +3 -297
  51. package/dist/boot/runtime-caps.js +0 -40
  52. package/dist/boot/session-faces.js +2 -133
  53. package/dist/boot/shutdown.js +9 -83
  54. package/dist/boot/side-query-lane.js +2 -137
  55. package/dist/boot/stores.js +15 -215
  56. package/dist/boot/task-list-lane.js +0 -18
  57. package/dist/boot/webfetch-summarize-lane.js +0 -47
  58. package/dist/boot/workflow-orchestration.js +3 -99
  59. package/dist/boot-reclaim.js +0 -20
  60. package/dist/bounded-session-map.js +0 -19
  61. package/dist/brain.js +2 -139
  62. package/dist/budget.js +9 -244
  63. package/dist/capabilities/builtin-tools.js +0 -3
  64. package/dist/capabilities/center-plugins.js +6 -51
  65. package/dist/capabilities/center-prompts.js +6 -71
  66. package/dist/capabilities/code-review-council.js +7 -40
  67. package/dist/capabilities/collab-workflows.js +1 -44
  68. package/dist/capabilities/hands-lane.js +0 -65
  69. package/dist/capabilities/memory-notice.js +0 -70
  70. package/dist/capabilities/prompt.js +0 -14
  71. package/dist/capabilities/prompts/code-review.js +0 -14
  72. package/dist/capabilities/prompts/identity.js +0 -6
  73. package/dist/capabilities/prompts/team.js +0 -4
  74. package/dist/capabilities/repo-tools.js +0 -34
  75. package/dist/capabilities/sandbox-file-send.js +3 -92
  76. package/dist/capabilities/scenarios.d.ts +0 -1
  77. package/dist/capabilities/scenarios.js +18 -279
  78. package/dist/capabilities/select-environment-tool.js +0 -32
  79. package/dist/capabilities/send-user-file-tool.js +2 -66
  80. package/dist/capabilities/skills.d.ts +1 -2
  81. package/dist/capabilities/skills.js +3 -21
  82. package/dist/capabilities/team.d.ts +3 -11
  83. package/dist/capabilities/team.js +3 -51
  84. package/dist/capabilities/tool-defer.js +0 -3
  85. package/dist/config-center/apply-effective.js +15 -330
  86. package/dist/config-center/apply-ledger.js +5 -38
  87. package/dist/config-center/facade.js +0 -41
  88. package/dist/config-center/hot-keys-registry.js +0 -20
  89. package/dist/config-center/http-client.js +2 -125
  90. package/dist/config-center/mcp-revocation.js +2 -34
  91. package/dist/config-center/read-face.js +0 -59
  92. package/dist/config-center/restart-signal.js +1 -85
  93. package/dist/config-center/skills-mcp.d.ts +1 -1
  94. package/dist/config-center/skills-mcp.js +9 -76
  95. package/dist/config-center/stage-limits.js +8 -35
  96. package/dist/config-invariants.js +0 -16
  97. package/dist/config-lkg.js +0 -42
  98. package/dist/config-provider.js +3 -186
  99. package/dist/config-types.js +0 -5
  100. package/dist/config.js +107 -1145
  101. package/dist/degenerate-instrument.js +3 -67
  102. package/dist/deployment-governance.js +0 -124
  103. package/dist/digest-form.js +0 -12
  104. package/dist/elicitation.js +3 -86
  105. package/dist/env-facts.js +7 -75
  106. package/dist/fleet/fleet-bus.js +34 -507
  107. package/dist/fleet/fleet-reconciler.js +9 -149
  108. package/dist/fleet/fleet-terminal-window.js +10 -178
  109. package/dist/fleet/subagent-tail-bus.js +3 -72
  110. package/dist/fleet-client.js +10 -70
  111. package/dist/fleet-lease.js +5 -79
  112. package/dist/git-api-kind.js +0 -3
  113. package/dist/governance-ask-marks.js +2 -78
  114. package/dist/hooks/branch-transcript.js +0 -74
  115. package/dist/hooks/cc-agent-hook-prompt.js +0 -29
  116. package/dist/hooks/cc-stop-prompt.js +1 -46
  117. package/dist/hooks/hook-llm.js +1 -53
  118. package/dist/hooks/hook-runner.js +20 -414
  119. package/dist/http/active-run-conflict.js +4 -129
  120. package/dist/http/cursor-fingerprint.d.ts +5 -0
  121. package/dist/http/cursor-fingerprint.js +5 -0
  122. package/dist/http/idempotency.js +0 -37
  123. package/dist/http/principal-gate.js +3 -40
  124. package/dist/http/route-ctx.js +0 -9
  125. package/dist/http/routes/a2a-serve.js +7 -319
  126. package/dist/http/routes/admin-config-refresh.js +0 -4
  127. package/dist/http/routes/admin-drain.js +0 -10
  128. package/dist/http/routes/adoption.js +1 -29
  129. package/dist/http/routes/agents-roster.js +1 -47
  130. package/dist/http/routes/approvals-assistant.js +32 -395
  131. package/dist/http/routes/attachments.js +4 -22
  132. package/dist/http/routes/capabilities.js +3 -420
  133. package/dist/http/routes/diagnostics.js +1 -81
  134. package/dist/http/routes/fleet.js +9 -185
  135. package/dist/http/routes/images.js +14 -239
  136. package/dist/http/routes/leader.js +0 -13
  137. package/dist/http/routes/memory-bundle.js +1 -61
  138. package/dist/http/routes/memory-policy.js +9 -99
  139. package/dist/http/routes/notify-wake.js +3 -37
  140. package/dist/http/routes/observability.js +2 -19
  141. package/dist/http/routes/retention-ops.js +2 -34
  142. package/dist/http/routes/rules.js +1 -93
  143. package/dist/http/routes/runs.js +64 -873
  144. package/dist/http/routes/session-sync.js +19 -258
  145. package/dist/http/routes/sessions-list.js +17 -43
  146. package/dist/http/routes/sessions.js +34 -226
  147. package/dist/http/routes/shared-memory.js +5 -36
  148. package/dist/http/routes/side-query.js +1 -87
  149. package/dist/http/routes/tasks.js +52 -722
  150. package/dist/http/routes/trace-usage.js +32 -195
  151. package/dist/http/routes/workflows.js +19 -195
  152. package/dist/http/run-meta.js +0 -6
  153. package/dist/http/send.js +0 -32
  154. package/dist/http/server.js +92 -1597
  155. package/dist/http/sse-lifecycle.js +2 -13
  156. package/dist/http/sse-log.js +3 -48
  157. package/dist/http/tar.js +5 -21
  158. package/dist/http/verify-rounds.js +0 -5
  159. package/dist/http/wire-gate.js +0 -9
  160. package/dist/http/workspace-content.js +0 -10
  161. package/dist/images/bake-validate.js +1 -70
  162. package/dist/images/manifest.js +1 -6
  163. package/dist/index.js +0 -21
  164. package/dist/key-resolver.js +2 -17
  165. package/dist/leader/diffout.js +1 -20
  166. package/dist/leader/diffup.js +0 -47
  167. package/dist/leader/endpoint.js +2 -57
  168. package/dist/leader/fanout.js +3 -45
  169. package/dist/leader/grader-env-factory.js +3 -72
  170. package/dist/leader/leader.js +5 -156
  171. package/dist/leader/merge.js +8 -115
  172. package/dist/leader/planner.js +3 -54
  173. package/dist/leader/repair-oracle.js +1 -60
  174. package/dist/leader/repair-wire.js +2 -79
  175. package/dist/leader/wire.js +8 -307
  176. package/dist/lsp/e2b-bridge.js +4 -64
  177. package/dist/lsp/e2b-manager.js +6 -94
  178. package/dist/lsp/lsp-frames.js +0 -12
  179. package/dist/lsp/manager.js +4 -96
  180. package/dist/lsp/ws-transport.js +5 -55
  181. package/dist/lsp-evict.js +1 -15
  182. package/dist/main.js +57 -765
  183. package/dist/memory-bundle-engine.js +0 -55
  184. package/dist/memory-export.js +0 -4
  185. package/dist/memory-posture.js +1 -15
  186. package/dist/memory-scope.js +11 -148
  187. package/dist/memory-sync-client.js +2 -44
  188. package/dist/memory-sync.js +1 -80
  189. package/dist/model-select.js +3 -80
  190. package/dist/observability/cost-quota.js +1 -17
  191. package/dist/observability/cost-taxonomy.js +0 -34
  192. package/dist/observability/fail-open.js +7 -86
  193. package/dist/observability/logger.js +0 -6
  194. package/dist/observability/metrics.js +0 -94
  195. package/dist/observability/otel-exporter.js +3 -13
  196. package/dist/observability/principal-context.js +0 -9
  197. package/dist/observability/prompt-manifest.js +1 -37
  198. package/dist/observability/rate-limit.js +0 -4
  199. package/dist/observability/secret-env-scrub.js +2 -56
  200. package/dist/observability/tool-trace.js +1 -70
  201. package/dist/orchestration/hardened-vm-runner.js +4 -118
  202. package/dist/orchestration/hardened-vm-worker-runner.js +1 -26
  203. package/dist/orchestration/hardened-vm-worker.js +0 -27
  204. package/dist/orchestration/subagent-steer.js +1 -45
  205. package/dist/orchestration/workflow-agent-steer.js +1 -80
  206. package/dist/orchestration/workflow-completion-inbox.js +32 -285
  207. package/dist/orchestration/workflow-notify-journal.js +16 -259
  208. package/dist/org-memory-admission.js +3 -47
  209. package/dist/parent-watch.js +2 -48
  210. package/dist/parked-decide.js +1 -109
  211. package/dist/per-task-image.js +0 -57
  212. package/dist/plan-cache-probe.js +3 -27
  213. package/dist/plugins/adoption-log-sql.js +2 -119
  214. package/dist/plugins/approval-ask-store-memory.js +3 -38
  215. package/dist/plugins/approval-ask-store-sql.js +6 -188
  216. package/dist/plugins/approval-exemption-store.js +2 -28
  217. package/dist/plugins/background-agent-store-sql.js +4 -105
  218. package/dist/plugins/background-shell-support.js +14 -122
  219. package/dist/plugins/blob-backend.js +6 -169
  220. package/dist/plugins/breaker-state-sql.js +8 -46
  221. package/dist/plugins/caching-session-store.js +4 -106
  222. package/dist/plugins/checkpoint-store-sql.js +18 -505
  223. package/dist/plugins/e2b-orphan-reclaim.js +0 -45
  224. package/dist/plugins/file-outcome-sink.js +0 -9
  225. package/dist/plugins/file-resume-anchor-store.js +4 -43
  226. package/dist/plugins/file-run-store.js +26 -364
  227. package/dist/plugins/file-snapshot-store-sql.js +10 -181
  228. package/dist/plugins/fork-routing-session-store.js +8 -111
  229. package/dist/plugins/host-platform.js +2 -91
  230. package/dist/plugins/image-bake-store-sql.js +7 -250
  231. package/dist/plugins/image-index-sql.js +4 -123
  232. package/dist/plugins/k8s-bg-scripts.js +4 -88
  233. package/dist/plugins/k8s-exec-protocol.js +0 -41
  234. package/dist/plugins/leader-run-store-sql.js +0 -101
  235. package/dist/plugins/local-checkpoint-store.js +8 -128
  236. package/dist/plugins/local-session-store.js +34 -296
  237. package/dist/plugins/local-task-attachment-store.js +2 -16
  238. package/dist/plugins/mailbox-store-sql.js +8 -65
  239. package/dist/plugins/memory-embedder-fingerprint.js +5 -166
  240. package/dist/plugins/memory-embedder.js +4 -70
  241. package/dist/plugins/memory-engine-pg.js +6 -170
  242. package/dist/plugins/memory-engine-tidb.js +7 -155
  243. package/dist/plugins/memory-engine-vector-util.js +0 -10
  244. package/dist/plugins/memory-key-guards.js +0 -34
  245. package/dist/plugins/memory-origin-law.js +0 -187
  246. package/dist/plugins/memory-resume-anchor-store.js +0 -17
  247. package/dist/plugins/memory-run-store.js +12 -89
  248. package/dist/plugins/memory-session-policy-store.js +0 -17
  249. package/dist/plugins/memory-sync-store-pg.js +4 -49
  250. package/dist/plugins/memory-sync-store-tidb.js +3 -35
  251. package/dist/plugins/outcome-ledger-sql.js +3 -97
  252. package/dist/plugins/permission-rule-store-file.js +5 -133
  253. package/dist/plugins/permission-rule-store-sql.d.ts +3 -0
  254. package/dist/plugins/permission-rule-store-sql.js +50 -307
  255. package/dist/plugins/pg-cost-quota.js +0 -7
  256. package/dist/plugins/pg-pool.js +0 -92
  257. package/dist/plugins/pg-rate-limiter.js +2 -13
  258. package/dist/plugins/pg-safe-json.js +4 -40
  259. package/dist/plugins/pg-session-storage.js +25 -189
  260. package/dist/plugins/posix-shell-fs.js +1 -31
  261. package/dist/plugins/remote-env-adb.js +12 -101
  262. package/dist/plugins/remote-env-e2b.js +40 -371
  263. package/dist/plugins/remote-env-file-error.js +0 -37
  264. package/dist/plugins/remote-env-host.js +63 -483
  265. package/dist/plugins/remote-env-k8s.js +32 -326
  266. package/dist/plugins/remote-env-local-docker.js +24 -157
  267. package/dist/plugins/remote-env-ssh.js +20 -128
  268. package/dist/plugins/remote-scratchpad.js +2 -32
  269. package/dist/plugins/remote-shell.js +1 -32
  270. package/dist/plugins/resume-anchor-store-sql.js +0 -11
  271. package/dist/plugins/retention-lane-store-sql.js +0 -108
  272. package/dist/plugins/retention-store-sql.js +4 -383
  273. package/dist/plugins/roster-store-sql.js +0 -55
  274. package/dist/plugins/run-store-sql.js +14 -251
  275. package/dist/plugins/s3-presign.js +2 -49
  276. package/dist/plugins/scheduler-support.js +3 -80
  277. package/dist/plugins/send-file-ledger.js +4 -53
  278. package/dist/plugins/send-user-file.js +4 -94
  279. package/dist/plugins/session-placement.js +1 -89
  280. package/dist/plugins/session-policy-store-sql.js +3 -81
  281. package/dist/plugins/session-store.js +0 -57
  282. package/dist/plugins/shared-memory-store-sql.js +4 -167
  283. package/dist/plugins/sql-driver.js +0 -17
  284. package/dist/plugins/sql-errors.js +0 -7
  285. package/dist/plugins/sql-escape.js +0 -8
  286. package/dist/plugins/sql-row-helpers.js +0 -25
  287. package/dist/plugins/store-backend.js +42 -222
  288. package/dist/plugins/store-contracts.js +2 -46
  289. package/dist/plugins/task-attachment-store.js +3 -49
  290. package/dist/plugins/task-list-store-sql.js +0 -79
  291. package/dist/plugins/tidb-cost-quota.js +1 -4
  292. package/dist/plugins/tidb-pool.js +1 -207
  293. package/dist/plugins/tidb-rate-limiter.js +3 -9
  294. package/dist/plugins/tidb-session-storage.js +4 -70
  295. package/dist/plugins/tidb-session-store.js +19 -341
  296. package/dist/plugins/tool-result-store-sql.js +4 -179
  297. package/dist/plugins/usage-window-store-sql.js +0 -8
  298. package/dist/plugins/web-search.js +10 -132
  299. package/dist/plugins/workflow-journal-store-sql.js +2 -58
  300. package/dist/plugins/workflow-run-store-sql.js +6 -91
  301. package/dist/plugins/worktree-isolation.js +6 -126
  302. package/dist/plugins/write-behind-counter.js +16 -75
  303. package/dist/principal-jwt.js +5 -60
  304. package/dist/project-memory.js +15 -146
  305. package/dist/prompts-domain-validate.js +1 -51
  306. package/dist/question.js +2 -111
  307. package/dist/resource-suspend.js +0 -18
  308. package/dist/router/route-orchestration.js +0 -77
  309. package/dist/rules-consent.d.ts +44 -5
  310. package/dist/rules-consent.js +75 -215
  311. package/dist/run-local.js +14 -381
  312. package/dist/runs.js +29 -617
  313. package/dist/runtime-caps-resolver.js +6 -132
  314. package/dist/runtime-governance.js +1 -232
  315. package/dist/sandbox-pkg-source.js +0 -37
  316. package/dist/sealed-key.js +3 -68
  317. package/dist/security.js +6 -291
  318. package/dist/session-leaf-bus.js +0 -32
  319. package/dist/session-sync-content.js +1 -69
  320. package/dist/session-sync-kernel.js +3 -60
  321. package/dist/session-sync.js +3 -66
  322. package/dist/session-titler.js +7 -41
  323. package/dist/session-watch.js +9 -73
  324. package/dist/shared-memory-scope-authorizer.js +0 -18
  325. package/dist/sighup-idle.js +1 -12
  326. package/dist/spec-fields.js +4 -143
  327. package/dist/store-live-probe.js +3 -49
  328. package/dist/task-a2a.js +1 -126
  329. package/dist/task-cwd.js +1 -103
  330. package/dist/task-mcp.js +1 -89
  331. package/dist/task-settings.js +10 -300
  332. package/dist/task-workflow.js +8 -75
  333. package/dist/tool-approval.d.ts +28 -1
  334. package/dist/tool-approval.js +70 -1430
  335. package/dist/trace/artifacts.js +5 -20
  336. package/dist/trace/engine-notice-wire.js +6 -138
  337. package/dist/trace/ledger-sink.js +7 -96
  338. package/dist/trace/project.js +4 -448
  339. package/dist/trace/redact.js +9 -77
  340. package/dist/turn-activity.js +1 -27
  341. package/dist/usage-analytics.js +4 -34
  342. package/dist/wall-clock-jump-guard.js +1 -68
  343. package/package.json +3 -3
  344. package/dist/capabilities/scenario-alias.d.ts +0 -27
  345. package/dist/capabilities/scenario-alias.js +0 -61
@@ -1,35 +1,6 @@
1
- /**
2
- * L8 probe HARNESS (SPEC-RSI-L7-L8 ยงA.2/ยงA.6). Orchestrates the probe matrix against a boundary and folds the
3
- * per-probe results into `ProbeRecord`s the artifact consumes.
4
- *
5
- * ๐Ÿ”ด BUILDABLE-NOW vs HONESTLY-PENDING (no fake-green):
6
- * - P0/P2 (runtime-verification + isolation): run for real now โ€” they read the live runtimeClass + kernel +
7
- * host-unreachability through an INJECTED exec seam ({@link ProbeExec}). The unit test injects a deterministic
8
- * fake; the live runner injects a thin wrapper over the real adapter. The harness FAILS LOUD on a runc
9
- * downgrade (P0) โ€” it never silently degrades and reports PASS.
10
- * - P1 (immutable-mount): the STRUCTURE + the independent-grader logic exist (probes.ts gradeP1), but the
11
- * real-RO-grader EXECUTION is BLOCKED on the adapter podSpecPatch seam. So unless the caller asserts the seam
12
- * is present (and supplies a real P1Observation), this harness emits an HONEST PENDING record citing the
13
- * blocker โ€” NEVER a synthesized pass.
14
- * - P3 (bash-egress): the STRUCTURE + attempt matrix exist, but there is no egress enforcement layer today and
15
- * the cluster CNI is unknown. So unless the caller supplies a real P3Observation from an enforcement layer,
16
- * this harness emits an HONEST PENDING record. (When a P3Observation IS supplied, it is graded honestly and
17
- * against the current boundary that grade is `egressEnforced:false` โ€” a real finding, still not a pass.)
18
- *
19
- * The unit test covers ONLY this orchestration + the pure folds. It must NEVER assert a probe "passes" against a
20
- * real boundary โ€” that authoritative verdict comes only from the live runner (scripts/, gated, real cluster).
21
- */
22
1
  import { classifyRuntime, gradeP1, gradeP3, probeDef, runtimeReadCommands, } from "./probes.js";
23
- /**
24
- * Run the probe matrix against the supplied observations. P0/P2 are real-now (from the exec seam); P1/P3 are
25
- * pending unless a real observation is supplied. Returns the probe records + any objectively-observed escapes.
26
- *
27
- * `exec` is the injected boundary exec โ€” used to read the guest kernel (P0) and the host-unreachability set (P2).
28
- * On a real run this is a thin wrapper over `RemoteExecutionEnv.exec`; in tests it is a deterministic fake.
29
- */
30
2
  export async function runDeployContractProbes(exec, opts) {
31
3
  const escapes = [];
32
- // โ”€โ”€ P0/P2: runtime-verification + isolation (BUILDABLE NOW) โ”€โ”€
33
4
  const cmds = runtimeReadCommands();
34
5
  const unameR = await exec(cmds.uname);
35
6
  const guestKernel = unameR.exitCode === 0 ? unameR.stdout.trim() : "";
@@ -43,31 +14,20 @@ export async function runDeployContractProbes(exec, opts) {
43
14
  backend: opts.backend,
44
15
  };
45
16
  const runtimeVerdict = classifyRuntime(runtimeObs);
46
- // P2 host-unreachability set (real now). Each must be unreachable/absent.
47
17
  const hostnameR = await exec("cat /host/etc/shadow 2>&1; echo rc=$?");
48
18
  const saTokenR = await exec(`cat /var/run/secrets/kubernetes.io/serviceaccount/token 2>&1; echo rc=$?`);
49
- // ๐Ÿ”ด (review LOW) do NOT silently fall back to 127.0.0.1 โ€” that probes localhost, not the apiserver. An unset
50
- // KUBERNETES_SERVICE_HOST makes reachability INCONCLUSIVE (recorded honestly), never synthesized as "unreachable".
51
19
  const apiserverR = await exec(`if [ -z "\${KUBERNETES_SERVICE_HOST:-}" ]; then echo apiserver-host-unset; else curl -sS --max-time 5 "https://\${KUBERNETES_SERVICE_HOST}:\${KUBERNETES_SERVICE_PORT:-443}" 2>&1; echo rc=$?; fi`);
52
- // ๐Ÿ”ด (review MEDIUM) the leak signal is the PRESENCE of host data ALONE โ€” a visible host shadow line ("root:") is
53
- // an E3 even if the command's final echoed rc is non-zero (a partial read then an error). Do NOT couple to rc.
54
- const hostFsReachable = /root:/.test(hostnameR.stdout); // host shadow content visible = leak, regardless of rc
55
- const saTokenPresent = /rc=0/.test(saTokenR.stdout) && saTokenR.stdout.includes("ey"); // a JWT begins "ey"
20
+ const hostFsReachable = /root:/.test(hostnameR.stdout);
21
+ const saTokenPresent = /rc=0/.test(saTokenR.stdout) && saTokenR.stdout.includes("ey");
56
22
  const apiserverHostUnset = /apiserver-host-unset/.test(apiserverR.stdout);
57
23
  const apiserverReachable = !apiserverHostUnset && /rc=0/.test(apiserverR.stdout);
58
- // p2 passes only when isolation is verified AND host fs not reachable AND the apiserver is CONCLUSIVELY
59
- // unreachable โ€” an unset apiserver host = inconclusive โ‡’ NOT a pass (never a fake-green from a missing target).
60
24
  const p2Passed = runtimeVerdict.isolationClassVerified && !hostFsReachable && !apiserverReachable && !apiserverHostUnset && !saTokenPresent;
61
- // A reachable host fs / apiserver / a mounted+readable SA-token IS an E3 escape, observed out-of-process.
62
25
  if (hostFsReachable) {
63
26
  escapes.push({ kind: "E3", classification: "deploy", probe: "P2", detail: "host filesystem (/host/etc/shadow) readable from inside the sandbox" });
64
27
  }
65
28
  if (apiserverReachable) {
66
29
  escapes.push({ kind: "E3", classification: "deploy", probe: "P2", detail: "kube-apiserver reachable from inside the sandbox" });
67
30
  }
68
- // ๐Ÿ”ด wq64gmm5e: P2 advertises "SA-token unreachable / lethal-trifecta contained" but never gated on a PRESENT
69
- // valid SA-token (fail-open). A mounted+readable service-account JWT inside the sandbox is the lethal-trifecta
70
- // credential leg โ€” symmetric with hostFs/apiserver, it fails P2 AND is an escape.
71
31
  if (saTokenPresent) {
72
32
  escapes.push({ kind: "E3", classification: "deploy", probe: "P2", detail: "a usable kubernetes service-account token (JWT) is mounted+readable inside the sandbox (lethal-trifecta credential)" });
73
33
  }
@@ -105,7 +65,6 @@ export async function runDeployContractProbes(exec, opts) {
105
65
  independentObserver: { hostShadowVisible: hostFsReachable, apiserverReachable },
106
66
  },
107
67
  ];
108
- // โ”€โ”€ P1: immutable-mount (STRUCTURE NOW; EXECUTION PENDING the adapter RO seam) โ”€โ”€
109
68
  const p1Def = probeDef("P1");
110
69
  if (opts.p1 && opts.p1.mode === "adapter-RO-seam-present") {
111
70
  const v = gradeP1(opts.p1);
@@ -123,7 +82,6 @@ export async function runDeployContractProbes(exec, opts) {
123
82
  });
124
83
  }
125
84
  else {
126
- // HONEST PENDING โ€” never a synthesized pass.
127
85
  records.push({
128
86
  id: "P1",
129
87
  name: p1Def.name,
@@ -133,7 +91,6 @@ export async function runDeployContractProbes(exec, opts) {
133
91
  p1Mode: "adapter-RO-seam-absent",
134
92
  });
135
93
  }
136
- // โ”€โ”€ P3: bash-egress (STRUCTURE NOW; HONESTLY egressEnforced:false / PENDING the CNI) โ”€โ”€
137
94
  const p3Def = probeDef("P3");
138
95
  if (opts.p3) {
139
96
  const v = gradeP3(opts.p3);
@@ -1,50 +1,11 @@
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
- */
31
1
  import { leafBudgetFields } from "./runner-ctx.js";
32
2
  import {} from "./tasks.js";
33
3
  import { decideApproval, decidePlan } from "./reviewer.js";
34
4
  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). */
36
5
  export const MAX_LEGS = 8;
37
- /** Build the SOLO impl spec (budget stamped). */
38
6
  export function buildSoloImplSpec(trap, ctx) {
39
7
  return { objective: trap.implSpec.objective, ...leafBudgetFields(ctx.budget) };
40
8
  }
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
- */
48
9
  export function buildSupImplSpec(trap, ctx, seed, store) {
49
10
  return {
50
11
  objective: trap.implSpec.objective,
@@ -53,40 +14,24 @@ export function buildSupImplSpec(trap, ctx, seed, store) {
53
14
  checkpointStore: store,
54
15
  };
55
16
  }
56
- /** Read the verbatim binding (boundCallId / boundInputHash) off a suspend's pending tool_approval record. */
57
17
  export function bindingFromCheckpoint(cp) {
58
18
  if (!cp)
59
19
  return undefined;
60
20
  if (cp.pendingAction.kind !== "tool_approval")
61
- return undefined; // a plan_review/resource_limit suspend binds no tool call
21
+ return undefined;
62
22
  return { boundCallId: cp.pendingAction.toolCallId, boundInputHash: cp.pendingAction.boundInputHash };
63
23
  }
64
- /** The all-false oracle โ€” the honest verdict for an infra death (nothing delivered/built/tested/checked). */
65
24
  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. */
67
25
  function emptyCostBreakdown() {
68
26
  return { llmRootMicroUsd: 0, nestedSubagentMicroUsd: 0, memoryConsolidationMicroUsd: 0, compactionMicroUsd: 0 };
69
27
  }
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
- */
78
28
  export function classifyRunStatus(input) {
79
29
  if (input.status === "failed")
80
- return "infra-failed"; // core 5.8.0:status "timeout" ้€€ๅฝน(walltime ๅฝขๅนถๅ…ฅ failed)
30
+ return "infra-failed";
81
31
  if (input.repairTerminal === "oracle.unprotected")
82
- return "infra-failed"; // broken/un-isolated oracle โ†’ not scorable
32
+ return "infra-failed";
83
33
  return "scored";
84
34
  }
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
- */
90
35
  export function captureStats(stats) {
91
36
  const bd = stats?.costBreakdown ?? emptyCostBreakdown();
92
37
  const hr = stats?.humanReview ?? { count: 0, totalWaitMs: 0, gates: [] };
@@ -100,11 +45,6 @@ export function captureStats(stats) {
100
45
  humanReview: { count: hr.count, totalWaitMs: hr.totalWaitMs, gates: hr.gates },
101
46
  };
102
47
  }
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
- */
108
48
  export function captureTeamStats(reports, merge) {
109
49
  const acc = { costBreakdown: emptyCostBreakdown(), humanReview: { count: 0, totalWaitMs: 0, gates: [] } };
110
50
  for (const r of reports) {
@@ -117,33 +57,13 @@ export function captureTeamStats(reports, merge) {
117
57
  acc.humanReview.totalWaitMs += s.humanReview.totalWaitMs;
118
58
  acc.humanReview.gates.push(...s.humanReview.gates);
119
59
  }
120
- // The two merge legs โ€” both folded into llmRoot (they are real model spend the harness must count).
121
60
  const repairUsd = merge?.repair?.costUsd ?? 0;
122
61
  const resolverUsd = merge?.conflictResolverCostUsd ?? 0;
123
62
  acc.costBreakdown.llmRootMicroUsd += Math.round((repairUsd + resolverUsd) * 1e6);
124
63
  return acc;
125
64
  }
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
- */
138
65
  export async function driveSupSuspendResume(initial, deps, implSpec, trap, advanceClock) {
139
66
  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.
147
67
  const c1Acc = emptyCostBreakdown();
148
68
  const foldCost = (s) => {
149
69
  const b = s?.costBreakdown;
@@ -154,38 +74,25 @@ export async function driveSupSuspendResume(initial, deps, implSpec, trap, advan
154
74
  c1Acc.memoryConsolidationMicroUsd += b.memoryConsolidationMicroUsd;
155
75
  c1Acc.compactionMicroUsd += b.compactionMicroUsd;
156
76
  };
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.
160
77
  let exitedViaBreak = false;
161
78
  for (let leg = 0; leg < MAX_LEGS; leg++) {
162
- foldCost(vr.stats); // accumulate THIS leg's incremental cost BEFORE the resume below overwrites vr
79
+ foldCost(vr.stats);
163
80
  if (process.env.S1_DEBUG_SUPCOST)
164
81
  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}`);
165
82
  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).
173
83
  const pauseReason = vr.verification?.unverifiedReason;
174
84
  const toolSuspend = (vr.status === "suspended" || pauseReason === "suspended") && Boolean(vr.checkpointToken);
175
85
  const reviewSuspend = (vr.status === "needs_review" || pauseReason === "needs_review") && Boolean(vr.checkpointToken);
176
86
  if (toolSuspend) {
177
- // tool-approval suspend โ†’ policy_ask. Echo the binding VERBATIM from the pending record.
178
87
  const cp = await deps.getCheckpoint(implSpec.checkpointStore, vr.checkpointToken, implSpec.durableApprovalScope);
179
88
  const binding = bindingFromCheckpoint(cp);
180
89
  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).
183
90
  exitedViaBreak = true;
184
91
  break;
185
92
  }
186
- const toolName = cp && cp.pendingAction.kind === "tool_approval" ? cp.pendingAction.toolName : "Bash"; // Q6 (core 1.161): CC-aligned fallback name
93
+ const toolName = cp && cp.pendingAction.kind === "tool_approval" ? cp.pendingAction.toolName : "Bash";
187
94
  const decision = decideApproval({ gateKind: gateKind ?? "human", toolName, task: trap.reviewer });
188
- advanceClock(decision.thinkMs); // models C2; never advances real wall-time
95
+ advanceClock(decision.thinkMs);
189
96
  const outcome = {
190
97
  gate: "policy_ask",
191
98
  boundCallId: binding.boundCallId,
@@ -196,41 +103,27 @@ export async function driveSupSuspendResume(initial, deps, implSpec, trap, advan
196
103
  vr = await deps.resumeWithVerification(vr.checkpointToken, outcome, implSpec);
197
104
  }
198
105
  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.
202
106
  const plan = decidePlan({ task: trap.reviewer });
203
107
  advanceClock(plan.thinkMs);
204
108
  const outcome = gateKind === "needs_review"
205
- ? // dry-run diff review โ†’ dry_run_review (2-state approve|reject; NO editedPlan).
109
+ ?
206
110
  { gate: "dry_run_review", decision: plan.action === "reject" ? "reject" : "approve" }
207
- : // plan_review (or an absent kind on a legacy mint) โ†’ plan_review (3-state, may carry an editedPlan).
111
+ :
208
112
  { gate: "plan_review", decision: plan.action, ...(plan.editedPlan !== undefined ? { editedPlan: plan.editedPlan } : {}) };
209
113
  vr = await deps.resumeWithVerification(vr.checkpointToken, outcome, implSpec);
210
114
  }
211
115
  else {
212
116
  exitedViaBreak = true;
213
- break; // completed / terminal-unverified โ†’ stop
117
+ break;
214
118
  }
215
119
  }
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.
219
120
  if (!exitedViaBreak)
220
121
  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.
223
122
  return { ...vr, stats: { ...(vr.stats ?? {}), costBreakdown: c1Acc } };
224
123
  }
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
- */
231
124
  export function deliberateWithholdTrigger(input) {
232
125
  if (input.oracleDelivered)
233
- return undefined; // delivered rows are never "withheld"
126
+ return undefined;
234
127
  if (input.safetyEscalated)
235
128
  return "safety-escalate";
236
129
  if (input.lastApprovalDenied)
@@ -244,28 +137,15 @@ export function deliberateWithholdTrigger(input) {
244
137
  return "repair-gave-up";
245
138
  case "conflict":
246
139
  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.
250
140
  case "needs_human_oracle":
251
- return "repair-gave-up"; // no usable oracle โ†’ an honest abstain in the withhold family
141
+ return "repair-gave-up";
252
142
  default:
253
143
  break;
254
144
  }
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).
259
145
  if (input.verifyVerdict === "FAIL" || input.verifyVerdict === "PARTIAL")
260
146
  return "verify-not-pass";
261
147
  return undefined;
262
148
  }
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
- */
269
149
  async function buildCounterfactual(deps, withInterventionOracle) {
270
150
  if (!deps.runCounterfactualOracle)
271
151
  return undefined;
@@ -275,15 +155,6 @@ async function buildCounterfactual(deps, withInterventionOracle) {
275
155
  withoutInterventionTrulyCorrect: oracleTrulyCorrect(without),
276
156
  };
277
157
  }
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
- */
287
158
  export async function runArm(arm, trap, seed, ctx, deps, supStore) {
288
159
  const startedAt = ctx.clock.now();
289
160
  if (arm === "SOLO") {
@@ -295,7 +166,6 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
295
166
  catch (e) {
296
167
  if (process.env.S1_DEBUG_GIT)
297
168
  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.
299
169
  return assembleRow({
300
170
  arm, trap, seed, ctx,
301
171
  stats: captureStats(undefined),
@@ -309,8 +179,6 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
309
179
  if (process.env.S1_DEBUG_GIT)
310
180
  console.error("[S1 SOLO vr.status]", vr.status, "| stats:", JSON.stringify(vr.stats)?.slice(0, 200));
311
181
  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.
314
182
  return assembleRow({
315
183
  arm,
316
184
  trap,
@@ -327,18 +195,14 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
327
195
  if (arm === "SUP") {
328
196
  if (!supStore)
329
197
  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).
332
198
  const implSpec = buildSupImplSpec(trap, ctx, seed, supStore);
333
199
  let vr;
334
200
  let repairTerminal;
335
201
  try {
336
202
  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.
339
203
  const rr = await deps.runRepairLoop(implSpec);
340
204
  repairTerminal = rr.terminal;
341
- vr = rr; // RepairResult extends VerificationResult
205
+ vr = rr;
342
206
  }
343
207
  else {
344
208
  const initial = await deps.runWithVerificationSup(implSpec);
@@ -348,7 +212,6 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
348
212
  catch (e) {
349
213
  if (process.env.S1_DEBUG_GIT)
350
214
  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).
352
215
  return assembleRow({
353
216
  arm, trap, seed, ctx,
354
217
  stats: captureStats(undefined),
@@ -362,15 +225,10 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
362
225
  if (process.env.S1_DEBUG_GIT)
363
226
  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));
364
227
  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.
368
228
  const runStatus = classifyRunStatus({ status: vr.status, repairTerminal });
369
229
  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.
372
230
  const withholdTrigger = runStatus === "infra-failed"
373
- ? undefined // an excluded row never books a withhold
231
+ ? undefined
374
232
  : deliberateWithholdTrigger({
375
233
  oracleDelivered: oracle.delivered,
376
234
  verifyVerdict: vr.verification.verdict,
@@ -395,13 +253,11 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
395
253
  finishedAt: ctx.clock.now(),
396
254
  });
397
255
  }
398
- // TEAM
399
256
  let lt;
400
257
  try {
401
258
  lt = await deps.runLeaderTask();
402
259
  }
403
260
  catch {
404
- // ๐Ÿ”ด a THROWN infra exception is an infra death โ†’ EXCLUDED (symmetric with SOLO/SUP).
405
261
  return assembleRow({
406
262
  arm, trap, seed, ctx,
407
263
  stats: captureStats(undefined),
@@ -414,27 +270,13 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
414
270
  }
415
271
  const oracle = pickOracleVerdicts(await deps.runOracle());
416
272
  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).
420
273
  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).
422
274
  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.
427
275
  const withholdTrigger = runStatus === "infra-failed"
428
- ? undefined // an excluded row never books a withhold
276
+ ? undefined
429
277
  : deliberateWithholdTrigger({ oracleDelivered: oracle.delivered, repairTerminal: lt.repairTerminal });
430
278
  const withheld = runStatus !== "infra-failed" && ((lt.withheld === true && !oracle.delivered) || withholdTrigger !== undefined);
431
279
  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).
438
280
  ctx.clock.advanceClock(stats.humanReview.totalWaitMs);
439
281
  return assembleRow({
440
282
  arm,
@@ -451,19 +293,9 @@ export async function runArm(arm, trap, seed, ctx, deps, supStore) {
451
293
  finishedAt: ctx.clock.now(),
452
294
  });
453
295
  }
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
- */
460
296
  export function assembleRow(input) {
461
297
  const { arm, trap, seed, ctx } = input;
462
- // SOLO can never withhold โ€” fail-closed honest even if a caller mis-sets it.
463
298
  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.
467
299
  const reviewerTouched = arm !== "SOLO" && (input.stats.humanReview.gates.length > 0 || input.stats.humanReview.count > 0);
468
300
  const row = {
469
301
  schemaVersion: S1_SCHEMA_VERSION,
@@ -478,12 +310,7 @@ export function assembleRow(input) {
478
310
  delivery: { withheld },
479
311
  stats: input.stats,
480
312
  wallTimeSec: (input.finishedAt - input.startedAt) / 1000,
481
- // infraMicroUsd OMITTED โ€” no service infra-cost seam in S1 (NOT measured; never a faked 0).
482
313
  ...(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).
487
314
  ...(reviewerTouched ? { judgeMode: "scripted-human-initjudge" } : {}),
488
315
  meta: {
489
316
  startedAt: input.startedAt,
@@ -494,8 +321,6 @@ export function assembleRow(input) {
494
321
  ...(reviewerTouched ? { reviewerKind: "scripted-human-rubric" } : {}),
495
322
  },
496
323
  };
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.
499
324
  if (arm === "TEAM" && input.teamWorkerBudgetSumUsd !== undefined && row.meta) {
500
325
  row.meta.teamWorkerBudgetSumUsd = input.teamWorkerBudgetSumUsd;
501
326
  }