open-multi-agent-kit 0.98.4 → 0.98.5

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 (252) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +3 -2
  3. package/dist/commands/run-command.d.ts +2 -1
  4. package/dist/commands/run-command.d.ts.map +1 -1
  5. package/dist/commands/run-command.js +9 -1
  6. package/dist/commands/run-command.js.map +1 -1
  7. package/dist/commands/verified-run-cli.d.ts +6 -0
  8. package/dist/commands/verified-run-cli.d.ts.map +1 -0
  9. package/dist/commands/verified-run-cli.js +190 -0
  10. package/dist/commands/verified-run-cli.js.map +1 -0
  11. package/dist/core/agent-session-services.d.ts +8 -1
  12. package/dist/core/agent-session-services.d.ts.map +1 -1
  13. package/dist/core/agent-session-services.js +41 -0
  14. package/dist/core/agent-session-services.js.map +1 -1
  15. package/dist/core/agent-session.d.ts +7 -8
  16. package/dist/core/agent-session.d.ts.map +1 -1
  17. package/dist/core/agent-session.js +61 -41
  18. package/dist/core/agent-session.js.map +1 -1
  19. package/dist/core/prompt-settlement.d.ts +4 -3
  20. package/dist/core/prompt-settlement.d.ts.map +1 -1
  21. package/dist/core/prompt-settlement.js.map +1 -1
  22. package/dist/core/run-budget-policy.d.ts +18 -0
  23. package/dist/core/run-budget-policy.d.ts.map +1 -0
  24. package/dist/core/run-budget-policy.js +52 -0
  25. package/dist/core/run-budget-policy.js.map +1 -0
  26. package/dist/core/run-budget.d.ts +33 -0
  27. package/dist/core/run-budget.d.ts.map +1 -0
  28. package/dist/core/run-budget.js +89 -0
  29. package/dist/core/run-budget.js.map +1 -0
  30. package/dist/core/run-execution-api.d.ts +15 -0
  31. package/dist/core/run-execution-api.d.ts.map +1 -0
  32. package/dist/core/run-execution-api.js +7 -0
  33. package/dist/core/run-execution-api.js.map +1 -0
  34. package/dist/core/run-journal.d.ts.map +1 -1
  35. package/dist/core/run-journal.js +30 -208
  36. package/dist/core/run-journal.js.map +1 -1
  37. package/dist/core/session-bash-service.d.ts +2 -2
  38. package/dist/core/session-bash-service.d.ts.map +1 -1
  39. package/dist/core/session-bash-service.js +21 -9
  40. package/dist/core/session-bash-service.js.map +1 -1
  41. package/dist/core/session-failure-cause.d.ts.map +1 -1
  42. package/dist/core/session-failure-cause.js +5 -0
  43. package/dist/core/session-failure-cause.js.map +1 -1
  44. package/dist/core/session-prompt-lifecycle.d.ts +25 -0
  45. package/dist/core/session-prompt-lifecycle.d.ts.map +1 -0
  46. package/dist/core/session-prompt-lifecycle.js +87 -0
  47. package/dist/core/session-prompt-lifecycle.js.map +1 -0
  48. package/dist/core/session-run-budget.d.ts +28 -0
  49. package/dist/core/session-run-budget.d.ts.map +1 -0
  50. package/dist/core/session-run-budget.js +127 -0
  51. package/dist/core/session-run-budget.js.map +1 -0
  52. package/dist/core/session-run-termination.d.ts.map +1 -1
  53. package/dist/core/session-run-termination.js +14 -3
  54. package/dist/core/session-run-termination.js.map +1 -1
  55. package/dist/core/session-termination-types.d.ts +97 -0
  56. package/dist/core/session-termination-types.d.ts.map +1 -0
  57. package/dist/core/session-termination-types.js +26 -0
  58. package/dist/core/session-termination-types.js.map +1 -0
  59. package/dist/core/session-termination.d.ts +3 -97
  60. package/dist/core/session-termination.d.ts.map +1 -1
  61. package/dist/core/session-termination.js +24 -28
  62. package/dist/core/session-termination.js.map +1 -1
  63. package/dist/core/slash-commands.d.ts.map +1 -1
  64. package/dist/core/slash-commands.js +1 -0
  65. package/dist/core/slash-commands.js.map +1 -1
  66. package/dist/core/subagent-lane-launcher.d.ts +3 -2
  67. package/dist/core/subagent-lane-launcher.d.ts.map +1 -1
  68. package/dist/core/subagent-lane-launcher.js +24 -13
  69. package/dist/core/subagent-lane-launcher.js.map +1 -1
  70. package/dist/core/verified-run/broker.d.ts +26 -0
  71. package/dist/core/verified-run/broker.d.ts.map +1 -0
  72. package/dist/core/verified-run/broker.js +210 -0
  73. package/dist/core/verified-run/broker.js.map +1 -0
  74. package/dist/core/verified-run/candidate.d.ts +24 -0
  75. package/dist/core/verified-run/candidate.d.ts.map +1 -0
  76. package/dist/core/verified-run/candidate.js +167 -0
  77. package/dist/core/verified-run/candidate.js.map +1 -0
  78. package/dist/core/verified-run/check-receipt.d.ts +18 -0
  79. package/dist/core/verified-run/check-receipt.d.ts.map +1 -0
  80. package/dist/core/verified-run/check-receipt.js +92 -0
  81. package/dist/core/verified-run/check-receipt.js.map +1 -0
  82. package/dist/core/verified-run/coordinator.d.ts +39 -0
  83. package/dist/core/verified-run/coordinator.d.ts.map +1 -0
  84. package/dist/core/verified-run/coordinator.js +190 -0
  85. package/dist/core/verified-run/coordinator.js.map +1 -0
  86. package/dist/core/verified-run/dag-candidates.d.ts +8 -0
  87. package/dist/core/verified-run/dag-candidates.d.ts.map +1 -0
  88. package/dist/core/verified-run/dag-candidates.js +65 -0
  89. package/dist/core/verified-run/dag-candidates.js.map +1 -0
  90. package/dist/core/verified-run/dag-phase.d.ts +7 -0
  91. package/dist/core/verified-run/dag-phase.d.ts.map +1 -0
  92. package/dist/core/verified-run/dag-phase.js +92 -0
  93. package/dist/core/verified-run/dag-phase.js.map +1 -0
  94. package/dist/core/verified-run/dag-projection.d.ts +7 -0
  95. package/dist/core/verified-run/dag-projection.d.ts.map +1 -0
  96. package/dist/core/verified-run/dag-projection.js +90 -0
  97. package/dist/core/verified-run/dag-projection.js.map +1 -0
  98. package/dist/core/verified-run/dag-recovery.d.ts +13 -0
  99. package/dist/core/verified-run/dag-recovery.d.ts.map +1 -0
  100. package/dist/core/verified-run/dag-recovery.js +98 -0
  101. package/dist/core/verified-run/dag-recovery.js.map +1 -0
  102. package/dist/core/verified-run/dag-retry-projection.d.ts +9 -0
  103. package/dist/core/verified-run/dag-retry-projection.d.ts.map +1 -0
  104. package/dist/core/verified-run/dag-retry-projection.js +43 -0
  105. package/dist/core/verified-run/dag-retry-projection.js.map +1 -0
  106. package/dist/core/verified-run/dag-types.d.ts +47 -0
  107. package/dist/core/verified-run/dag-types.d.ts.map +1 -0
  108. package/dist/core/verified-run/dag-types.js +2 -0
  109. package/dist/core/verified-run/dag-types.js.map +1 -0
  110. package/dist/core/verified-run/event-parser.d.ts +3 -0
  111. package/dist/core/verified-run/event-parser.d.ts.map +1 -0
  112. package/dist/core/verified-run/event-parser.js +153 -0
  113. package/dist/core/verified-run/event-parser.js.map +1 -0
  114. package/dist/core/verified-run/events.d.ts +4 -0
  115. package/dist/core/verified-run/events.d.ts.map +1 -0
  116. package/dist/core/verified-run/events.js +3 -0
  117. package/dist/core/verified-run/events.js.map +1 -0
  118. package/dist/core/verified-run/evidence-binding.d.ts +18 -0
  119. package/dist/core/verified-run/evidence-binding.d.ts.map +1 -0
  120. package/dist/core/verified-run/evidence-binding.js +81 -0
  121. package/dist/core/verified-run/evidence-binding.js.map +1 -0
  122. package/dist/core/verified-run/evidence.d.ts +27 -0
  123. package/dist/core/verified-run/evidence.d.ts.map +1 -0
  124. package/dist/core/verified-run/evidence.js +100 -0
  125. package/dist/core/verified-run/evidence.js.map +1 -0
  126. package/dist/core/verified-run/journal.d.ts +32 -0
  127. package/dist/core/verified-run/journal.d.ts.map +1 -0
  128. package/dist/core/verified-run/journal.js +103 -0
  129. package/dist/core/verified-run/journal.js.map +1 -0
  130. package/dist/core/verified-run/namespace-identity.d.ts +11 -0
  131. package/dist/core/verified-run/namespace-identity.d.ts.map +1 -0
  132. package/dist/core/verified-run/namespace-identity.js +77 -0
  133. package/dist/core/verified-run/namespace-identity.js.map +1 -0
  134. package/dist/core/verified-run/owned-execution.d.ts +21 -0
  135. package/dist/core/verified-run/owned-execution.d.ts.map +1 -0
  136. package/dist/core/verified-run/owned-execution.js +43 -0
  137. package/dist/core/verified-run/owned-execution.js.map +1 -0
  138. package/dist/core/verified-run/phase-context.d.ts +9 -0
  139. package/dist/core/verified-run/phase-context.d.ts.map +1 -0
  140. package/dist/core/verified-run/phase-context.js +2 -0
  141. package/dist/core/verified-run/phase-context.js.map +1 -0
  142. package/dist/core/verified-run/process-gate.d.ts +5 -0
  143. package/dist/core/verified-run/process-gate.d.ts.map +1 -0
  144. package/dist/core/verified-run/process-gate.js +31 -0
  145. package/dist/core/verified-run/process-gate.js.map +1 -0
  146. package/dist/core/verified-run/projection.d.ts +4 -0
  147. package/dist/core/verified-run/projection.d.ts.map +1 -0
  148. package/dist/core/verified-run/projection.js +219 -0
  149. package/dist/core/verified-run/projection.js.map +1 -0
  150. package/dist/core/verified-run/recovery-clock.d.ts +19 -0
  151. package/dist/core/verified-run/recovery-clock.d.ts.map +1 -0
  152. package/dist/core/verified-run/recovery-clock.js +69 -0
  153. package/dist/core/verified-run/recovery-clock.js.map +1 -0
  154. package/dist/core/verified-run/recovery-command.d.ts +11 -0
  155. package/dist/core/verified-run/recovery-command.d.ts.map +1 -0
  156. package/dist/core/verified-run/recovery-command.js +73 -0
  157. package/dist/core/verified-run/recovery-command.js.map +1 -0
  158. package/dist/core/verified-run/recovery-projection.d.ts +12 -0
  159. package/dist/core/verified-run/recovery-projection.d.ts.map +1 -0
  160. package/dist/core/verified-run/recovery-projection.js +88 -0
  161. package/dist/core/verified-run/recovery-projection.js.map +1 -0
  162. package/dist/core/verified-run/recovery.d.ts +12 -0
  163. package/dist/core/verified-run/recovery.d.ts.map +1 -0
  164. package/dist/core/verified-run/recovery.js +115 -0
  165. package/dist/core/verified-run/recovery.js.map +1 -0
  166. package/dist/core/verified-run/run-types.d.ts +103 -0
  167. package/dist/core/verified-run/run-types.d.ts.map +1 -0
  168. package/dist/core/verified-run/run-types.js +2 -0
  169. package/dist/core/verified-run/run-types.js.map +1 -0
  170. package/dist/core/verified-run/scripted-writer.d.ts +15 -0
  171. package/dist/core/verified-run/scripted-writer.d.ts.map +1 -0
  172. package/dist/core/verified-run/scripted-writer.js +94 -0
  173. package/dist/core/verified-run/scripted-writer.js.map +1 -0
  174. package/dist/core/verified-run/session-port.d.ts +27 -0
  175. package/dist/core/verified-run/session-port.d.ts.map +1 -0
  176. package/dist/core/verified-run/session-port.js +2 -0
  177. package/dist/core/verified-run/session-port.js.map +1 -0
  178. package/dist/core/verified-run/storage.d.ts +15 -0
  179. package/dist/core/verified-run/storage.d.ts.map +1 -0
  180. package/dist/core/verified-run/storage.js +96 -0
  181. package/dist/core/verified-run/storage.js.map +1 -0
  182. package/dist/core/verified-run/verification-phase.d.ts +5 -0
  183. package/dist/core/verified-run/verification-phase.d.ts.map +1 -0
  184. package/dist/core/verified-run/verification-phase.js +56 -0
  185. package/dist/core/verified-run/verification-phase.js.map +1 -0
  186. package/dist/core/verified-run/work-recovery.d.ts +8 -0
  187. package/dist/core/verified-run/work-recovery.d.ts.map +1 -0
  188. package/dist/core/verified-run/work-recovery.js +44 -0
  189. package/dist/core/verified-run/work-recovery.js.map +1 -0
  190. package/dist/core/verified-run/writer-completion.d.ts +4 -0
  191. package/dist/core/verified-run/writer-completion.d.ts.map +1 -0
  192. package/dist/core/verified-run/writer-completion.js +27 -0
  193. package/dist/core/verified-run/writer-completion.js.map +1 -0
  194. package/dist/core/verified-run/writer-phase.d.ts +8 -0
  195. package/dist/core/verified-run/writer-phase.d.ts.map +1 -0
  196. package/dist/core/verified-run/writer-phase.js +76 -0
  197. package/dist/core/verified-run/writer-phase.js.map +1 -0
  198. package/dist/core/verified-run/writer-projection.d.ts +11 -0
  199. package/dist/core/verified-run/writer-projection.d.ts.map +1 -0
  200. package/dist/core/verified-run/writer-projection.js +70 -0
  201. package/dist/core/verified-run/writer-projection.js.map +1 -0
  202. package/dist/core/verified-run/writer-recovery.d.ts +16 -0
  203. package/dist/core/verified-run/writer-recovery.d.ts.map +1 -0
  204. package/dist/core/verified-run/writer-recovery.js +107 -0
  205. package/dist/core/verified-run/writer-recovery.js.map +1 -0
  206. package/dist/core/workload-permit-pool.d.ts +1 -3
  207. package/dist/core/workload-permit-pool.d.ts.map +1 -1
  208. package/dist/core/workload-permit-pool.js +11 -11
  209. package/dist/core/workload-permit-pool.js.map +1 -1
  210. package/dist/index.d.ts +3 -2
  211. package/dist/index.d.ts.map +1 -1
  212. package/dist/index.js +2 -2
  213. package/dist/index.js.map +1 -1
  214. package/dist/main.d.ts.map +1 -1
  215. package/dist/main.js +2 -8
  216. package/dist/main.js.map +1 -1
  217. package/dist/modes/interactive/components/session-failure.d.ts +13 -0
  218. package/dist/modes/interactive/components/session-failure.d.ts.map +1 -0
  219. package/dist/modes/interactive/components/session-failure.js +81 -0
  220. package/dist/modes/interactive/components/session-failure.js.map +1 -0
  221. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  222. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  223. package/dist/modes/interactive/interactive-mode.js +45 -31
  224. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  225. package/dist/modes/interactive/tui-diagnostics.d.ts +36 -0
  226. package/dist/modes/interactive/tui-diagnostics.d.ts.map +1 -0
  227. package/dist/modes/interactive/tui-diagnostics.js +105 -0
  228. package/dist/modes/interactive/tui-diagnostics.js.map +1 -0
  229. package/dist/modes/interactive/tui-runtime-info.d.ts +20 -0
  230. package/dist/modes/interactive/tui-runtime-info.d.ts.map +1 -0
  231. package/dist/modes/interactive/tui-runtime-info.js +76 -0
  232. package/dist/modes/interactive/tui-runtime-info.js.map +1 -0
  233. package/docs/development.md +10 -0
  234. package/docs/keybindings.md +1 -1
  235. package/docs/release-audit-0.98.5.md +84 -0
  236. package/docs/run-protocol.md +33 -1
  237. package/docs/runtime-algorithms.md +26 -0
  238. package/docs/sdk.md +193 -0
  239. package/docs/usage.md +54 -0
  240. package/docs/verified-run-testing.md +417 -0
  241. package/docs/verified-run.md +388 -0
  242. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  243. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  244. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  245. package/examples/extensions/gondolin/package-lock.json +2 -2
  246. package/examples/extensions/gondolin/package.json +1 -1
  247. package/examples/extensions/sandbox/package-lock.json +2 -2
  248. package/examples/extensions/sandbox/package.json +1 -1
  249. package/examples/extensions/with-deps/package-lock.json +2 -2
  250. package/examples/extensions/with-deps/package.json +1 -1
  251. package/npm-shrinkwrap.json +18 -18
  252. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"session-termination.js","sourceRoot":"","sources":["../../src/core/session-termination.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAU,CAAC;AAC7D,MAAM,CAAC,MAAM,sCAAsC,GAAG,GAAG,CAAC;AAE1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,WAAW;IACX,YAAY;IACZ,gBAAgB;IAChB,eAAe;IACf,qBAAqB;IACrB,kBAAkB;IAClB,mBAAmB;IACnB,kBAAkB;IAClB,kBAAkB;IAClB,oBAAoB;IACpB,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,eAAe;IACf,eAAe;IACf,gBAAgB;IAChB,mBAAmB;CACV,CAAC;AAoHX,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACxC,WAAW,CAAqB;IAEzC,YAAY,OAAe,EAAE,WAA+B,EAAE;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IAAA,CAC/B;CACD;AAWD,MAAM,iBAAiB,GAAG;IACzB,qCAAqC;IACrC,qIAAqI;IACrI,2CAA2C;IAC3C,gEAAgE;IAChE,kKAAkK;CACzJ,CAAC;AAEX,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC9B,WAAW;IACX,OAAO;IACP,WAAW;IACX,QAAQ;IACR,SAAS;IACT,OAAO;IACP,aAAa;IACb,cAAc;IACd,UAAU;IACV,OAAO;IACP,YAAY;IACZ,UAAU;CACV,CAAC,CAAC;AACH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAA+B;IAClE,OAAO;IACP,MAAM;IACN,YAAY;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KAAK,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;QACrE,GAAG,CAAC,cAAc,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,cAAc,CAAC,aAAa,EAAE,CAAC;QACtG,GAAG,CAAC,cAAc,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,cAAc,CAAC,eAAe,EAAE,CAAC;KAC5G,CAAC,CAAC;AAAA,CACH","sourcesContent":["export const SESSION_TERMINATION_SCHEMA_VERSION = 1 as const;\nexport const MAX_SESSION_TERMINATION_MESSAGE_LENGTH = 512;\n\n/**\n * Canonical list of termination kinds. The run-journal validator derives its\n * runtime bounds from this tuple so a newly added kind can never crash\n * journaling with \"termination kind is out of bounds\" again.\n */\nexport const SESSION_TERMINATION_KIND_VALUES = [\n\t\"completed\",\n\t\"user_abort\",\n\t\"provider_abort\",\n\t\"provider_auth\",\n\t\"provider_rate_limit\",\n\t\"provider_network\",\n\t\"provider_protocol\",\n\t\"provider_refusal\",\n\t\"context_overflow\",\n\t\"transcript_invalid\",\n\t\"tool_timeout\",\n\t\"tool_fatal\",\n\t\"compaction\",\n\t\"persistence\",\n\t\"process_signal\",\n\t\"process_crash\",\n\t\"configuration\",\n\t\"internal_error\",\n\t\"resource_pressure\",\n] as const;\n\nexport type SessionTerminationKind = (typeof SESSION_TERMINATION_KIND_VALUES)[number];\n\nexport type SessionTerminationPhase =\n\t| \"completed\"\n\t| \"control\"\n\t| \"preflight\"\n\t| \"provider\"\n\t| \"tool\"\n\t| \"compaction\"\n\t| \"persistence\"\n\t| \"process\"\n\t| \"resume\";\n\nexport type SessionTerminationSource = \"observed\" | \"inferred_on_resume\";\nexport type SessionSideEffects = \"none\" | \"possible\" | \"confirmed\";\nexport type SessionProcessSignal = \"SIGINT\" | \"SIGTERM\" | \"SIGHUP\" | \"SIGQUIT\";\n\nexport type ProviderTerminationCauseCode =\n\t| \"abort\"\n\t| \"auth\"\n\t| \"rate_limit\"\n\t| \"network\"\n\t| \"protocol\"\n\t| \"refusal\"\n\t| \"context_overflow\";\nexport type ToolTerminationCauseCode = \"timeout\" | \"fatal\";\n/** §15.4 resource-aware runtime roadmap: host-pressure termination causes. */\nexport type ResourceTerminationCauseCode = \"memory\" | \"disk\" | \"cpu\" | \"heap\" | \"probe_unavailable\" | \"queue_overflow\";\nexport type CompactionTerminationCauseCode = \"aborted\" | \"failed\" | \"stale\" | \"quota_exhausted\";\nexport type PersistenceTerminationCauseCode =\n\t| \"read_failed\"\n\t| \"append_failed\"\n\t| \"replace_failed\"\n\t| \"fsync_failed\"\n\t| \"lock_failed\";\nexport type TranscriptTerminationCauseCode =\n\t| \"missing_result\"\n\t| \"duplicate_result\"\n\t| \"orphan_result\"\n\t| \"duplicate_call_id\"\n\t| \"interleaved_non_result\"\n\t| \"invalid_jsonl\"\n\t| \"invalid_tree\"\n\t| \"unsupported_version\"\n\t| \"trailing_fragment\";\nexport type SessionTerminationCauseCode =\n\t| \"session.completed\"\n\t| \"session.user_abort\"\n\t| `provider.${ProviderTerminationCauseCode}`\n\t| `tool.${ToolTerminationCauseCode}`\n\t| `compaction.${CompactionTerminationCauseCode}`\n\t| `persistence.${PersistenceTerminationCauseCode}`\n\t| \"process.signal\"\n\t| \"process.crash\"\n\t| `transcript.${TranscriptTerminationCauseCode}`\n\t| \"configuration.invalid\"\n\t| \"internal.unclassified\"\n\t| `resource.${ResourceTerminationCauseCode}`;\n\nexport type SessionTerminationCause =\n\t| { readonly area: \"completed\" }\n\t| { readonly area: \"user\"; readonly code: \"abort\" }\n\t| { readonly area: \"provider\"; readonly code: ProviderTerminationCauseCode }\n\t| { readonly area: \"tool\"; readonly code: ToolTerminationCauseCode }\n\t| { readonly area: \"compaction\"; readonly code: CompactionTerminationCauseCode }\n\t| { readonly area: \"persistence\"; readonly code: PersistenceTerminationCauseCode }\n\t| { readonly area: \"process\"; readonly code: \"signal\"; readonly signal: SessionProcessSignal }\n\t| { readonly area: \"process\"; readonly code: \"crash\" }\n\t| { readonly area: \"transcript\"; readonly code: TranscriptTerminationCauseCode }\n\t| { readonly area: \"configuration\"; readonly code: \"invalid\" }\n\t| { readonly area: \"internal\"; readonly code: \"unclassified\" }\n\t| { readonly area: \"resource\"; readonly code: ResourceTerminationCauseCode };\n\nexport interface ClassifySessionTerminationInput {\n\treadonly sessionId: string;\n\treadonly runId: string;\n\t/** Deterministic caller-provided ISO-8601 timestamp. */\n\treadonly timestamp: string;\n\treadonly source: SessionTerminationSource;\n\t/** Caller-supplied, pre-redacted diagnostic text. */\n\treadonly message: string;\n\treadonly cause: SessionTerminationCause;\n\treadonly sideEffects: SessionSideEffects;\n\treadonly retryAfterMs?: number;\n\treadonly provider?: string;\n\treadonly model?: string;\n\treadonly toolCallId?: string;\n\treadonly toolName?: string;\n}\n\nexport interface SessionTermination {\n\treadonly schemaVersion: typeof SESSION_TERMINATION_SCHEMA_VERSION;\n\treadonly sessionId: string;\n\treadonly runId: string;\n\treadonly kind: SessionTerminationKind;\n\treadonly phase: SessionTerminationPhase;\n\treadonly source: SessionTerminationSource;\n\treadonly message: string;\n\treadonly causeCode: SessionTerminationCauseCode;\n\t/** Stable operator guidance suitable for print, JSON, RPC, and TUI surfaces. */\n\treadonly nextAction: string;\n\treadonly retryable: boolean;\n\treadonly safeToAutoRetry: boolean;\n\treadonly sideEffects: SessionSideEffects;\n\treadonly timestamp: string;\n\treadonly retryAfterMs?: number;\n\treadonly provider?: string;\n\treadonly model?: string;\n\treadonly toolCallId?: string;\n\treadonly toolName?: string;\n\treadonly processSignal?: SessionProcessSignal;\n\treadonly transcriptIssue?: TranscriptTerminationCauseCode;\n}\n\nexport class SessionTerminationError extends Error {\n\treadonly termination: SessionTermination;\n\n\tconstructor(message: string, termination: SessionTermination) {\n\t\tsuper(message);\n\t\tthis.name = \"SessionTerminationError\";\n\t\tthis.termination = termination;\n\t}\n}\n\ninterface Classification {\n\treadonly kind: SessionTerminationKind;\n\treadonly phase: SessionTerminationPhase;\n\treadonly causeCode: SessionTerminationCauseCode;\n\treadonly retryable: boolean;\n\treadonly processSignal?: SessionProcessSignal;\n\treadonly transcriptIssue?: TranscriptTerminationCauseCode;\n}\n\nconst CREDENTIAL_SHAPES = [\n\t/-----BEGIN [A-Z ]*PRIVATE KEY-----/i,\n\t/\\b(?:sk-[A-Za-z0-9_-]{16,}|github_pat_[A-Za-z0-9_]{16,}|gh[pousr]_[A-Za-z0-9]{16,}|xox[baprs]-[A-Za-z0-9-]{16,}|AKIA[A-Z0-9]{16})\\b/,\n\t/\\bBearer\\s+[A-Za-z0-9._~+/-]{8,}={0,2}\\b/i,\n\t/\\beyJ[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}\\b/,\n\t/(?:^|[^A-Za-z0-9])(?:[A-Za-z0-9]+[_-])*(?:authorization|api[-_ ]?key|access[-_ ]?token|token|password|secret(?:[-_ ]?key)?|private[-_ ]?key|cookie)[\"']?\\s*[:=]/i,\n] as const;\n\nconst TOP_LEVEL_KEYS = new Set([\n\t\"sessionId\",\n\t\"runId\",\n\t\"timestamp\",\n\t\"source\",\n\t\"message\",\n\t\"cause\",\n\t\"sideEffects\",\n\t\"retryAfterMs\",\n\t\"provider\",\n\t\"model\",\n\t\"toolCallId\",\n\t\"toolName\",\n]);\nconst PROVIDER_CAUSE_CODES = new Set<ProviderTerminationCauseCode>([\n\t\"abort\",\n\t\"auth\",\n\t\"rate_limit\",\n\t\"network\",\n\t\"protocol\",\n\t\"refusal\",\n\t\"context_overflow\",\n]);\nconst TOOL_CAUSE_CODES = new Set<ToolTerminationCauseCode>([\"timeout\", \"fatal\"]);\nconst RESOURCE_CAUSE_CODES = new Set<ResourceTerminationCauseCode>([\n\t\"memory\",\n\t\"disk\",\n\t\"cpu\",\n\t\"heap\",\n\t\"probe_unavailable\",\n\t\"queue_overflow\",\n]);\nconst COMPACTION_CAUSE_CODES = new Set<CompactionTerminationCauseCode>([\n\t\"aborted\",\n\t\"failed\",\n\t\"stale\",\n\t\"quota_exhausted\",\n]);\nconst PERSISTENCE_CAUSE_CODES = new Set<PersistenceTerminationCauseCode>([\n\t\"read_failed\",\n\t\"append_failed\",\n\t\"replace_failed\",\n\t\"fsync_failed\",\n\t\"lock_failed\",\n]);\nconst TRANSCRIPT_CAUSE_CODES = new Set<TranscriptTerminationCauseCode>([\n\t\"missing_result\",\n\t\"duplicate_result\",\n\t\"orphan_result\",\n\t\"duplicate_call_id\",\n\t\"interleaved_non_result\",\n\t\"invalid_jsonl\",\n\t\"invalid_tree\",\n\t\"unsupported_version\",\n\t\"trailing_fragment\",\n]);\nconst PROCESS_SIGNALS = new Set<SessionProcessSignal>([\"SIGINT\", \"SIGTERM\", \"SIGHUP\", \"SIGQUIT\"]);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction hasOnlyKeys(value: Record<string, unknown>, keys: readonly string[]): boolean {\n\tconst allowed = new Set(keys);\n\treturn Object.keys(value).every((key) => allowed.has(key));\n}\n\nfunction assertCause(cause: unknown): asserts cause is SessionTerminationCause {\n\tif (!isRecord(cause) || typeof cause.area !== \"string\") {\n\t\tthrow new TypeError(\"cause must be a bounded structured termination cause\");\n\t}\n\tconst code = cause.code;\n\tlet valid = false;\n\tswitch (cause.area) {\n\t\tcase \"completed\":\n\t\t\tvalid = hasOnlyKeys(cause, [\"area\"]);\n\t\t\tbreak;\n\t\tcase \"user\":\n\t\t\tvalid = code === \"abort\" && hasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"provider\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tPROVIDER_CAUSE_CODES.has(code as ProviderTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"tool\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tTOOL_CAUSE_CODES.has(code as ToolTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"compaction\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tCOMPACTION_CAUSE_CODES.has(code as CompactionTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"persistence\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tPERSISTENCE_CAUSE_CODES.has(code as PersistenceTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"process\":\n\t\t\tvalid =\n\t\t\t\t(code === \"crash\" && hasOnlyKeys(cause, [\"area\", \"code\"])) ||\n\t\t\t\t(code === \"signal\" &&\n\t\t\t\t\ttypeof cause.signal === \"string\" &&\n\t\t\t\t\tPROCESS_SIGNALS.has(cause.signal as SessionProcessSignal) &&\n\t\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\", \"signal\"]));\n\t\t\tbreak;\n\t\tcase \"transcript\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tTRANSCRIPT_CAUSE_CODES.has(code as TranscriptTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"configuration\":\n\t\t\tvalid = code === \"invalid\" && hasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"internal\":\n\t\t\tvalid = code === \"unclassified\" && hasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"resource\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tRESOURCE_CAUSE_CODES.has(code as ResourceTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t}\n\tif (!valid) throw new TypeError(\"cause must be a bounded structured termination cause\");\n}\n\nfunction assertClassifierInput(input: unknown): asserts input is ClassifySessionTerminationInput {\n\tif (!isRecord(input) || Object.keys(input).some((key) => !TOP_LEVEL_KEYS.has(key))) {\n\t\tthrow new TypeError(\"input must contain only bounded structured termination fields\");\n\t}\n\tif (\n\t\ttypeof input.sessionId !== \"string\" ||\n\t\ttypeof input.runId !== \"string\" ||\n\t\ttypeof input.timestamp !== \"string\" ||\n\t\ttypeof input.message !== \"string\" ||\n\t\t(input.source !== \"observed\" && input.source !== \"inferred_on_resume\") ||\n\t\t(input.sideEffects !== \"none\" && input.sideEffects !== \"possible\" && input.sideEffects !== \"confirmed\") ||\n\t\t(input.retryAfterMs !== undefined && typeof input.retryAfterMs !== \"number\") ||\n\t\t(input.provider !== undefined && typeof input.provider !== \"string\") ||\n\t\t(input.model !== undefined && typeof input.model !== \"string\") ||\n\t\t(input.toolCallId !== undefined && typeof input.toolCallId !== \"string\") ||\n\t\t(input.toolName !== undefined && typeof input.toolName !== \"string\")\n\t) {\n\t\tthrow new TypeError(\"input must contain only bounded structured termination fields\");\n\t}\n\tassertCause(input.cause);\n}\n\nfunction assertIdentifier(value: string, name: string, maxLength: number): void {\n\tif (value.length === 0 || value.length > maxLength || /[\\u0000-\\u001f\\u007f]/.test(value)) {\n\t\tthrow new TypeError(`${name} must be non-empty bounded text without C0 or DEL control characters`);\n\t}\n}\n\n/** Validate text at the termination trust boundary without attempting redaction. */\nexport function assertPreRedactedTerminationMessage(message: string): void {\n\tif (message.length === 0 || message.length > MAX_SESSION_TERMINATION_MESSAGE_LENGTH) {\n\t\tthrow new TypeError(\n\t\t\t`message must contain 1-${MAX_SESSION_TERMINATION_MESSAGE_LENGTH} characters of pre-redacted text`,\n\t\t);\n\t}\n\tif (message.includes(\"\\0\")) {\n\t\tthrow new TypeError(\"message must not contain NUL\");\n\t}\n\tif (CREDENTIAL_SHAPES.some((pattern) => pattern.test(message))) {\n\t\tthrow new TypeError(\"message contains a credential-shaped literal; redact it before classification\");\n\t}\n}\n\nfunction assertTimestamp(timestamp: string): void {\n\tconst parsed = new Date(timestamp);\n\tif (!Number.isFinite(parsed.getTime()) || parsed.toISOString() !== timestamp) {\n\t\tthrow new TypeError(\"timestamp must be a canonical ISO-8601 UTC instant\");\n\t}\n}\n\nfunction classifyProvider(code: ProviderTerminationCauseCode): Classification {\n\tswitch (code) {\n\t\tcase \"abort\":\n\t\t\treturn {\n\t\t\t\tkind: \"provider_abort\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.abort\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"auth\":\n\t\t\treturn {\n\t\t\t\tkind: \"provider_auth\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.auth\",\n\t\t\t\tretryable: false,\n\t\t\t};\n\t\tcase \"rate_limit\":\n\t\t\treturn {\n\t\t\t\tkind: \"provider_rate_limit\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.rate_limit\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"network\":\n\t\t\treturn {\n\t\t\t\tkind: \"provider_network\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.network\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"protocol\":\n\t\t\t// Many \"protocol\" stops are sticky transcript shape bugs (orphan tool_call_id)\n\t\t\t// that succeed after transform-messages sanitizes and the turn is retried.\n\t\t\t// Mark retryable so auto-retry can heal; safeToAutoRetry stays false (needs sanitize path).\n\t\t\treturn {\n\t\t\t\tkind: \"provider_protocol\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.protocol\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"context_overflow\":\n\t\t\treturn {\n\t\t\t\tkind: \"context_overflow\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.context_overflow\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"refusal\":\n\t\t\treturn {\n\t\t\t\tkind: \"provider_refusal\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.refusal\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t}\n}\n\nfunction classifyCause(cause: SessionTerminationCause, source: SessionTerminationSource): Classification {\n\tswitch (cause.area) {\n\t\tcase \"completed\":\n\t\t\treturn {\n\t\t\t\tkind: \"completed\",\n\t\t\t\tphase: \"completed\",\n\t\t\t\tcauseCode: \"session.completed\",\n\t\t\t\tretryable: false,\n\t\t\t};\n\t\tcase \"user\":\n\t\t\treturn {\n\t\t\t\tkind: \"user_abort\",\n\t\t\t\tphase: \"control\",\n\t\t\t\tcauseCode: \"session.user_abort\",\n\t\t\t\tretryable: false,\n\t\t\t};\n\t\tcase \"provider\":\n\t\t\treturn classifyProvider(cause.code);\n\t\tcase \"tool\":\n\t\t\treturn cause.code === \"timeout\"\n\t\t\t\t? { kind: \"tool_timeout\", phase: \"tool\", causeCode: \"tool.timeout\", retryable: true }\n\t\t\t\t: { kind: \"tool_fatal\", phase: \"tool\", causeCode: \"tool.fatal\", retryable: false };\n\t\tcase \"compaction\":\n\t\t\treturn {\n\t\t\t\tkind: \"compaction\",\n\t\t\t\tphase: \"compaction\",\n\t\t\t\tcauseCode: `compaction.${cause.code}`,\n\t\t\t\t// Quota exhaustion does not heal by retrying: same-model retries\n\t\t\t\t// keep failing until the provider cycle resets or the model changes.\n\t\t\t\tretryable: cause.code !== \"quota_exhausted\",\n\t\t\t};\n\t\tcase \"persistence\":\n\t\t\treturn {\n\t\t\t\tkind: \"persistence\",\n\t\t\t\tphase: \"persistence\",\n\t\t\t\tcauseCode: `persistence.${cause.code}`,\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"process\":\n\t\t\tif (cause.code === \"signal\") {\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"process_signal\",\n\t\t\t\t\tphase: \"process\",\n\t\t\t\t\tcauseCode: \"process.signal\",\n\t\t\t\t\tretryable: false,\n\t\t\t\t\tprocessSignal: cause.signal,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: \"process_crash\",\n\t\t\t\tphase: \"resume\",\n\t\t\t\tcauseCode: \"process.crash\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"transcript\":\n\t\t\treturn {\n\t\t\t\tkind: \"transcript_invalid\",\n\t\t\t\tphase: source === \"inferred_on_resume\" ? \"resume\" : \"preflight\",\n\t\t\t\tcauseCode: `transcript.${cause.code}`,\n\t\t\t\tretryable: false,\n\t\t\t\ttranscriptIssue: cause.code,\n\t\t\t};\n\t\tcase \"configuration\":\n\t\t\treturn {\n\t\t\t\tkind: \"configuration\",\n\t\t\t\tphase: \"preflight\",\n\t\t\t\tcauseCode: \"configuration.invalid\",\n\t\t\t\tretryable: false,\n\t\t\t};\n\t\tcase \"internal\":\n\t\t\treturn {\n\t\t\t\tkind: \"internal_error\",\n\t\t\t\tphase: \"preflight\",\n\t\t\t\tcauseCode: \"internal.unclassified\",\n\t\t\t\tretryable: false,\n\t\t\t};\n\t\tcase \"resource\":\n\t\t\t// §15.4: every resource cause is retryable; queue overflow surfaces at\n\t\t\t// the tool boundary, everything else at preflight admission.\n\t\t\treturn {\n\t\t\t\tkind: \"resource_pressure\",\n\t\t\t\tphase: cause.code === \"queue_overflow\" ? \"tool\" : \"preflight\",\n\t\t\t\tcauseCode: `resource.${cause.code}`,\n\t\t\t\tretryable: true,\n\t\t\t};\n\t}\n}\n\nfunction isSafeToAutoRetry(classification: Classification, input: ClassifySessionTerminationInput): boolean {\n\t// provider_refusal: Fable/Claude often false-positive on benign turns. Safe to auto-retry once\n\t// when no tool side effects occurred (same class of recovery as rate_limit/network).\n\treturn (\n\t\tclassification.retryable &&\n\t\tinput.source === \"observed\" &&\n\t\tinput.sideEffects === \"none\" &&\n\t\t(classification.kind === \"provider_rate_limit\" ||\n\t\t\tclassification.kind === \"provider_network\" ||\n\t\t\tclassification.kind === \"provider_refusal\" ||\n\t\t\t// §15.4 mapping: only cpu pressure is safe to auto-retry (with delay).\n\t\t\tclassification.causeCode === \"resource.cpu\")\n\t);\n}\n\nfunction nextActionFor(classification: Classification, input: ClassifySessionTerminationInput): string {\n\tswitch (classification.kind) {\n\t\tcase \"completed\":\n\t\t\treturn \"No recovery action is required; continue with the next prompt.\";\n\t\tcase \"user_abort\":\n\t\t\treturn \"Review possible partial side effects, then retry only if intended.\";\n\t\tcase \"resource_pressure\":\n\t\t\treturn \"Host resources are constrained; reduce load or wait for recovery, then retry.\";\n\t\tcase \"provider_abort\":\n\t\t\treturn \"Confirm provider availability, then retry the request.\";\n\t\tcase \"provider_auth\":\n\t\t\t// A credential-less install resolves a placeholder model whose provider is\n\t\t\t// literally \"unknown\"; never echo that back as a login target.\n\t\t\treturn `Run /login${input.provider && input.provider !== \"unknown\" ? ` ${input.provider}` : \"\"} in an interactive session, or set the provider's API key environment variable, then retry.`;\n\t\tcase \"provider_rate_limit\":\n\t\t\treturn \"Wait for the provider retry window or choose another model, then retry.\";\n\t\tcase \"provider_network\":\n\t\t\treturn \"Check network and provider connectivity, then retry.\";\n\t\tcase \"provider_protocol\":\n\t\t\treturn \"Often an orphan tool_call_id / sticky transcript after a dropped error turn — auto-retry after sanitize, or /new session if it persists.\";\n\t\tcase \"provider_refusal\":\n\t\t\treturn \"Model declined this turn (content/safety stop). Usually a false positive on Fable/Claude — auto-retry once, or switch model (k3/qwen3.8-max/grok-4.5/deepseek) / rephrase as a pure coding task.\";\n\t\tcase \"context_overflow\":\n\t\t\treturn \"Compact or reduce context, or switch to a larger-context model.\";\n\t\tcase \"tool_timeout\":\n\t\t\treturn \"Inspect possible tool side effects and increase the tool timeout only if safe.\";\n\t\tcase \"tool_fatal\":\n\t\t\treturn \"Inspect the failed tool result and repair its configuration before retrying.\";\n\t\tcase \"compaction\":\n\t\t\tswitch (classification.causeCode) {\n\t\t\t\tcase \"compaction.aborted\":\n\t\t\t\t\treturn \"Retry /compact if cancellation was unintended; avoid Escape while compaction is running.\";\n\t\t\t\tcase \"compaction.stale\":\n\t\t\t\t\treturn \"Retry /compact after pending session changes settle.\";\n\t\t\t\tcase \"compaction.quota_exhausted\":\n\t\t\t\t\treturn \"The summarization model's quota is exhausted — retrying cannot help yet. Switch model (/model), set compaction.model in settings, or wait for the quota reset, then retry /compact. OMK already tried the failover chain automatically.\";\n\t\t\t\tdefault:\n\t\t\t\t\treturn \"Resolve the reported compaction error, then retry /compact.\";\n\t\t\t}\n\t\tcase \"persistence\":\n\t\t\treturn `Run omk session doctor --session ${input.sessionId} before resuming.`;\n\t\tcase \"process_signal\":\n\t\t\treturn \"Review possible partial side effects before resuming the session.\";\n\t\tcase \"process_crash\":\n\t\t\treturn `Run omk session doctor --session ${input.sessionId} and review partial side effects.`;\n\t\tcase \"transcript_invalid\":\n\t\t\treturn `Run omk session doctor --session ${input.sessionId}; do not resume until integrity passes.`;\n\t\tcase \"configuration\":\n\t\t\treturn \"This model or client is not valid for the current login. Switch with /model or fix provider/client settings; /new session will not grant access.\";\n\t\tcase \"internal_error\":\n\t\t\treturn `Inspect run ${input.runId} diagnostics and the run journal before retrying.`;\n\t}\n}\n\n/** Concise actionable rendering shared by non-JSON and TUI surfaces. */\nexport function formatSessionTermination(termination: SessionTermination): string {\n\tconst route =\n\t\ttermination.provider || termination.model\n\t\t\t? `${termination.provider ?? \"unknown\"}/${termination.model ?? \"unknown\"}`\n\t\t\t: \"n/a\";\n\treturn [\n\t\t`kind=${termination.kind}`,\n\t\t`provider/model=${route}`,\n\t\t`retryable=${termination.retryable}`,\n\t\t`cause=${termination.causeCode}`,\n\t\t`message=${termination.message}`,\n\t\t`run=${termination.runId}`,\n\t\t`next=${termination.nextAction}`,\n\t].join(\" \");\n}\n\n/**\n * Classify a bounded, structured termination cause. This intentionally accepts\n * no raw Error value, stack, provider body, or arbitrary cause code.\n */\nexport function classifySessionTermination(input: ClassifySessionTerminationInput): SessionTermination {\n\tassertClassifierInput(input);\n\tassertIdentifier(input.sessionId, \"sessionId\", 128);\n\tassertIdentifier(input.runId, \"runId\", 128);\n\tassertTimestamp(input.timestamp);\n\tassertPreRedactedTerminationMessage(input.message);\n\tif (input.provider !== undefined) assertIdentifier(input.provider, \"provider\", 128);\n\tif (input.model !== undefined) assertIdentifier(input.model, \"model\", 256);\n\tif (input.toolCallId !== undefined) assertIdentifier(input.toolCallId, \"toolCallId\", 512);\n\tif (input.toolName !== undefined) assertIdentifier(input.toolName, \"toolName\", 128);\n\tif (input.retryAfterMs !== undefined && (!Number.isSafeInteger(input.retryAfterMs) || input.retryAfterMs < 0)) {\n\t\tthrow new TypeError(\"retryAfterMs must be a non-negative safe integer\");\n\t}\n\tif (input.cause.area === \"process\" && input.cause.code === \"crash\" && input.source !== \"inferred_on_resume\") {\n\t\tthrow new TypeError(\"process crashes may only be classified as inferred_on_resume\");\n\t}\n\tif (input.cause.area === \"process\" && input.cause.code === \"signal\" && input.source !== \"observed\") {\n\t\tthrow new TypeError(\"process signals must be observed\");\n\t}\n\n\tconst classification = classifyCause(input.cause, input.source);\n\treturn Object.freeze({\n\t\tschemaVersion: SESSION_TERMINATION_SCHEMA_VERSION,\n\t\tsessionId: input.sessionId,\n\t\trunId: input.runId,\n\t\tkind: classification.kind,\n\t\tphase: classification.phase,\n\t\tsource: input.source,\n\t\tmessage: input.message,\n\t\tcauseCode: classification.causeCode,\n\t\tnextAction: nextActionFor(classification, input),\n\t\tretryable: classification.retryable,\n\t\tsafeToAutoRetry: isSafeToAutoRetry(classification, input),\n\t\tsideEffects: input.sideEffects,\n\t\ttimestamp: input.timestamp,\n\t\t...(input.retryAfterMs === undefined ? {} : { retryAfterMs: input.retryAfterMs }),\n\t\t...(input.provider === undefined ? {} : { provider: input.provider }),\n\t\t...(input.model === undefined ? {} : { model: input.model }),\n\t\t...(input.toolCallId === undefined ? {} : { toolCallId: input.toolCallId }),\n\t\t...(input.toolName === undefined ? {} : { toolName: input.toolName }),\n\t\t...(classification.processSignal === undefined ? {} : { processSignal: classification.processSignal }),\n\t\t...(classification.transcriptIssue === undefined ? {} : { transcriptIssue: classification.transcriptIssue }),\n\t});\n}\n"]}
1
+ {"version":3,"file":"session-termination.js","sourceRoot":"","sources":["../../src/core/session-termination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAGN,sCAAsC,EAItC,kCAAkC,GAUlC,MAAM,gCAAgC,CAAC;AAExC,cAAc,gCAAgC,CAAC;AAE/C,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACxC,WAAW,CAAqB;IAEzC,YAAY,OAAe,EAAE,WAA+B,EAAE;QAC7D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IAAA,CAC/B;CACD;AAWD,MAAM,iBAAiB,GAAG;IACzB,qCAAqC;IACrC,qIAAqI;IACrI,2CAA2C;IAC3C,gEAAgE;IAChE,kKAAkK;CACzJ,CAAC;AAEX,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC9B,WAAW;IACX,OAAO;IACP,WAAW;IACX,QAAQ;IACR,SAAS;IACT,OAAO;IACP,aAAa;IACb,cAAc;IACd,UAAU;IACV,OAAO;IACP,YAAY;IACZ,UAAU;CACV,CAAC,CAAC;AACH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAA+B;IAClE,OAAO;IACP,MAAM;IACN,YAAY;IACZ,SAAS;IACT,UAAU;IACV,SAAS;IACT,kBAAkB;CAClB,CAAC,CAAC;AACH,MAAM,gBAAgB,GAA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a,EAAE,CAAC;QACtG,GAAG,CAAC,cAAc,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,cAAc,CAAC,eAAe,EAAE,CAAC;KAC5G,CAAC,CAAC;AAAA,CACH","sourcesContent":["import { RUN_BUDGET_STOP_CODES } from \"./run-budget-policy.ts\";\nimport {\n\ttype ClassifySessionTerminationInput,\n\ttype CompactionTerminationCauseCode,\n\tMAX_SESSION_TERMINATION_MESSAGE_LENGTH,\n\ttype PersistenceTerminationCauseCode,\n\ttype ProviderTerminationCauseCode,\n\ttype ResourceTerminationCauseCode,\n\tSESSION_TERMINATION_SCHEMA_VERSION,\n\ttype SessionProcessSignal,\n\ttype SessionTermination,\n\ttype SessionTerminationCause,\n\ttype SessionTerminationCauseCode,\n\ttype SessionTerminationKind,\n\ttype SessionTerminationPhase,\n\ttype SessionTerminationSource,\n\ttype ToolTerminationCauseCode,\n\ttype TranscriptTerminationCauseCode,\n} from \"./session-termination-types.ts\";\n\nexport * from \"./session-termination-types.ts\";\n\nexport class SessionTerminationError extends Error {\n\treadonly termination: SessionTermination;\n\n\tconstructor(message: string, termination: SessionTermination) {\n\t\tsuper(message);\n\t\tthis.name = \"SessionTerminationError\";\n\t\tthis.termination = termination;\n\t}\n}\n\ninterface Classification {\n\treadonly kind: SessionTerminationKind;\n\treadonly phase: SessionTerminationPhase;\n\treadonly causeCode: SessionTerminationCauseCode;\n\treadonly retryable: boolean;\n\treadonly processSignal?: SessionProcessSignal;\n\treadonly transcriptIssue?: TranscriptTerminationCauseCode;\n}\n\nconst CREDENTIAL_SHAPES = [\n\t/-----BEGIN [A-Z ]*PRIVATE KEY-----/i,\n\t/\\b(?:sk-[A-Za-z0-9_-]{16,}|github_pat_[A-Za-z0-9_]{16,}|gh[pousr]_[A-Za-z0-9]{16,}|xox[baprs]-[A-Za-z0-9-]{16,}|AKIA[A-Z0-9]{16})\\b/,\n\t/\\bBearer\\s+[A-Za-z0-9._~+/-]{8,}={0,2}\\b/i,\n\t/\\beyJ[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}\\b/,\n\t/(?:^|[^A-Za-z0-9])(?:[A-Za-z0-9]+[_-])*(?:authorization|api[-_ ]?key|access[-_ ]?token|token|password|secret(?:[-_ ]?key)?|private[-_ ]?key|cookie)[\"']?\\s*[:=]/i,\n] as const;\n\nconst TOP_LEVEL_KEYS = new Set([\n\t\"sessionId\",\n\t\"runId\",\n\t\"timestamp\",\n\t\"source\",\n\t\"message\",\n\t\"cause\",\n\t\"sideEffects\",\n\t\"retryAfterMs\",\n\t\"provider\",\n\t\"model\",\n\t\"toolCallId\",\n\t\"toolName\",\n]);\nconst PROVIDER_CAUSE_CODES = new Set<ProviderTerminationCauseCode>([\n\t\"abort\",\n\t\"auth\",\n\t\"rate_limit\",\n\t\"network\",\n\t\"protocol\",\n\t\"refusal\",\n\t\"context_overflow\",\n]);\nconst TOOL_CAUSE_CODES = new Set<ToolTerminationCauseCode>([\"timeout\", \"fatal\"]);\nconst RESOURCE_CAUSE_CODES = new Set<ResourceTerminationCauseCode>([\n\t\"memory\",\n\t\"disk\",\n\t\"cpu\",\n\t\"heap\",\n\t\"probe_unavailable\",\n\t\"queue_overflow\",\n]);\nconst COMPACTION_CAUSE_CODES = new Set<CompactionTerminationCauseCode>([\n\t\"aborted\",\n\t\"failed\",\n\t\"stale\",\n\t\"quota_exhausted\",\n]);\nconst PERSISTENCE_CAUSE_CODES = new Set<PersistenceTerminationCauseCode>([\n\t\"read_failed\",\n\t\"append_failed\",\n\t\"replace_failed\",\n\t\"fsync_failed\",\n\t\"lock_failed\",\n]);\nconst TRANSCRIPT_CAUSE_CODES = new Set<TranscriptTerminationCauseCode>([\n\t\"missing_result\",\n\t\"duplicate_result\",\n\t\"orphan_result\",\n\t\"duplicate_call_id\",\n\t\"interleaved_non_result\",\n\t\"invalid_jsonl\",\n\t\"invalid_tree\",\n\t\"unsupported_version\",\n\t\"trailing_fragment\",\n]);\nconst PROCESS_SIGNALS = new Set<SessionProcessSignal>([\"SIGINT\", \"SIGTERM\", \"SIGHUP\", \"SIGQUIT\"]);\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction hasOnlyKeys(value: Record<string, unknown>, keys: readonly string[]): boolean {\n\tconst allowed = new Set(keys);\n\treturn Object.keys(value).every((key) => allowed.has(key));\n}\n\nfunction assertCause(cause: unknown): asserts cause is SessionTerminationCause {\n\tif (!isRecord(cause) || typeof cause.area !== \"string\") {\n\t\tthrow new TypeError(\"cause must be a bounded structured termination cause\");\n\t}\n\tconst code = cause.code;\n\tlet valid = false;\n\tswitch (cause.area) {\n\t\tcase \"completed\":\n\t\t\tvalid = hasOnlyKeys(cause, [\"area\"]);\n\t\t\tbreak;\n\t\tcase \"user\":\n\t\t\tvalid = code === \"abort\" && hasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"provider\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tPROVIDER_CAUSE_CODES.has(code as ProviderTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"tool\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tTOOL_CAUSE_CODES.has(code as ToolTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"compaction\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tCOMPACTION_CAUSE_CODES.has(code as CompactionTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"persistence\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tPERSISTENCE_CAUSE_CODES.has(code as PersistenceTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"process\":\n\t\t\tvalid =\n\t\t\t\t(code === \"crash\" && hasOnlyKeys(cause, [\"area\", \"code\"])) ||\n\t\t\t\t(code === \"signal\" &&\n\t\t\t\t\ttypeof cause.signal === \"string\" &&\n\t\t\t\t\tPROCESS_SIGNALS.has(cause.signal as SessionProcessSignal) &&\n\t\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\", \"signal\"]));\n\t\t\tbreak;\n\t\tcase \"transcript\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tTRANSCRIPT_CAUSE_CODES.has(code as TranscriptTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"configuration\":\n\t\t\tvalid = code === \"invalid\" && hasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"internal\":\n\t\t\tvalid = code === \"unclassified\" && hasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"budget\":\n\t\t\tvalid = RUN_BUDGET_STOP_CODES.some((allowed) => allowed === code) && hasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t\tcase \"resource\":\n\t\t\tvalid =\n\t\t\t\ttypeof code === \"string\" &&\n\t\t\t\tRESOURCE_CAUSE_CODES.has(code as ResourceTerminationCauseCode) &&\n\t\t\t\thasOnlyKeys(cause, [\"area\", \"code\"]);\n\t\t\tbreak;\n\t}\n\tif (!valid) throw new TypeError(\"cause must be a bounded structured termination cause\");\n}\n\nexport function parseSessionTerminationCauseCode(code: string, signal?: SessionProcessSignal): SessionTerminationCause {\n\tif (code === \"session.completed\") return { area: \"completed\" };\n\tif (code === \"session.user_abort\") return { area: \"user\", code: \"abort\" };\n\tconst dot = code.indexOf(\".\");\n\tconst cause = {\n\t\tarea: code.slice(0, dot),\n\t\tcode: code.slice(dot + 1),\n\t\t...(code === \"process.signal\" ? { signal } : {}),\n\t};\n\tassertCause(cause);\n\treturn cause;\n}\n\nfunction assertClassifierInput(input: unknown): asserts input is ClassifySessionTerminationInput {\n\tif (!isRecord(input) || Object.keys(input).some((key) => !TOP_LEVEL_KEYS.has(key))) {\n\t\tthrow new TypeError(\"input must contain only bounded structured termination fields\");\n\t}\n\tif (\n\t\ttypeof input.sessionId !== \"string\" ||\n\t\ttypeof input.runId !== \"string\" ||\n\t\ttypeof input.timestamp !== \"string\" ||\n\t\ttypeof input.message !== \"string\" ||\n\t\t(input.source !== \"observed\" && input.source !== \"inferred_on_resume\") ||\n\t\t(input.sideEffects !== \"none\" && input.sideEffects !== \"possible\" && input.sideEffects !== \"confirmed\") ||\n\t\t(input.retryAfterMs !== undefined && typeof input.retryAfterMs !== \"number\") ||\n\t\t(input.provider !== undefined && typeof input.provider !== \"string\") ||\n\t\t(input.model !== undefined && typeof input.model !== \"string\") ||\n\t\t(input.toolCallId !== undefined && typeof input.toolCallId !== \"string\") ||\n\t\t(input.toolName !== undefined && typeof input.toolName !== \"string\")\n\t) {\n\t\tthrow new TypeError(\"input must contain only bounded structured termination fields\");\n\t}\n\tassertCause(input.cause);\n}\n\nfunction assertIdentifier(value: string, name: string, maxLength: number): void {\n\tif (value.length === 0 || value.length > maxLength || /[\\u0000-\\u001f\\u007f]/.test(value)) {\n\t\tthrow new TypeError(`${name} must be non-empty bounded text without C0 or DEL control characters`);\n\t}\n}\n\n/** Validate text at the termination trust boundary without attempting redaction. */\nexport function assertPreRedactedTerminationMessage(message: string): void {\n\tif (message.length === 0 || message.length > MAX_SESSION_TERMINATION_MESSAGE_LENGTH) {\n\t\tthrow new TypeError(\n\t\t\t`message must contain 1-${MAX_SESSION_TERMINATION_MESSAGE_LENGTH} characters of pre-redacted text`,\n\t\t);\n\t}\n\tif (message.includes(\"\\0\")) {\n\t\tthrow new TypeError(\"message must not contain NUL\");\n\t}\n\tif (CREDENTIAL_SHAPES.some((pattern) => pattern.test(message))) {\n\t\tthrow new TypeError(\"message contains a credential-shaped literal; redact it before classification\");\n\t}\n}\n\nfunction assertTimestamp(timestamp: string): void {\n\tconst parsed = new Date(timestamp);\n\tif (!Number.isFinite(parsed.getTime()) || parsed.toISOString() !== timestamp) {\n\t\tthrow new TypeError(\"timestamp must be a canonical ISO-8601 UTC instant\");\n\t}\n}\n\nfunction classifyProvider(code: ProviderTerminationCauseCode): Classification {\n\tswitch (code) {\n\t\tcase \"abort\":\n\t\t\treturn {\n\t\t\t\tkind: \"provider_abort\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.abort\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"auth\":\n\t\t\treturn {\n\t\t\t\tkind: \"provider_auth\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.auth\",\n\t\t\t\tretryable: false,\n\t\t\t};\n\t\tcase \"rate_limit\":\n\t\t\treturn {\n\t\t\t\tkind: \"provider_rate_limit\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.rate_limit\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"network\":\n\t\t\treturn {\n\t\t\t\tkind: \"provider_network\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.network\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"protocol\":\n\t\t\t// Many \"protocol\" stops are sticky transcript shape bugs (orphan tool_call_id)\n\t\t\t// that succeed after transform-messages sanitizes and the turn is retried.\n\t\t\t// Mark retryable so auto-retry can heal; safeToAutoRetry stays false (needs sanitize path).\n\t\t\treturn {\n\t\t\t\tkind: \"provider_protocol\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.protocol\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"context_overflow\":\n\t\t\treturn {\n\t\t\t\tkind: \"context_overflow\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.context_overflow\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"refusal\":\n\t\t\treturn {\n\t\t\t\tkind: \"provider_refusal\",\n\t\t\t\tphase: \"provider\",\n\t\t\t\tcauseCode: \"provider.refusal\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t}\n}\n\nfunction classifyCause(cause: SessionTerminationCause, source: SessionTerminationSource): Classification {\n\tswitch (cause.area) {\n\t\tcase \"completed\":\n\t\t\treturn {\n\t\t\t\tkind: \"completed\",\n\t\t\t\tphase: \"completed\",\n\t\t\t\tcauseCode: \"session.completed\",\n\t\t\t\tretryable: false,\n\t\t\t};\n\t\tcase \"user\":\n\t\t\treturn {\n\t\t\t\tkind: \"user_abort\",\n\t\t\t\tphase: \"control\",\n\t\t\t\tcauseCode: \"session.user_abort\",\n\t\t\t\tretryable: false,\n\t\t\t};\n\t\tcase \"provider\":\n\t\t\treturn classifyProvider(cause.code);\n\t\tcase \"tool\":\n\t\t\treturn cause.code === \"timeout\"\n\t\t\t\t? { kind: \"tool_timeout\", phase: \"tool\", causeCode: \"tool.timeout\", retryable: true }\n\t\t\t\t: { kind: \"tool_fatal\", phase: \"tool\", causeCode: \"tool.fatal\", retryable: false };\n\t\tcase \"compaction\":\n\t\t\treturn {\n\t\t\t\tkind: \"compaction\",\n\t\t\t\tphase: \"compaction\",\n\t\t\t\tcauseCode: `compaction.${cause.code}`,\n\t\t\t\t// Quota exhaustion does not heal by retrying: same-model retries\n\t\t\t\t// keep failing until the provider cycle resets or the model changes.\n\t\t\t\tretryable: cause.code !== \"quota_exhausted\",\n\t\t\t};\n\t\tcase \"persistence\":\n\t\t\treturn {\n\t\t\t\tkind: \"persistence\",\n\t\t\t\tphase: \"persistence\",\n\t\t\t\tcauseCode: `persistence.${cause.code}`,\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"process\":\n\t\t\tif (cause.code === \"signal\") {\n\t\t\t\treturn {\n\t\t\t\t\tkind: \"process_signal\",\n\t\t\t\t\tphase: \"process\",\n\t\t\t\t\tcauseCode: \"process.signal\",\n\t\t\t\t\tretryable: false,\n\t\t\t\t\tprocessSignal: cause.signal,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tkind: \"process_crash\",\n\t\t\t\tphase: \"resume\",\n\t\t\t\tcauseCode: \"process.crash\",\n\t\t\t\tretryable: true,\n\t\t\t};\n\t\tcase \"transcript\":\n\t\t\treturn {\n\t\t\t\tkind: \"transcript_invalid\",\n\t\t\t\tphase: source === \"inferred_on_resume\" ? \"resume\" : \"preflight\",\n\t\t\t\tcauseCode: `transcript.${cause.code}`,\n\t\t\t\tretryable: false,\n\t\t\t\ttranscriptIssue: cause.code,\n\t\t\t};\n\t\tcase \"configuration\":\n\t\t\treturn {\n\t\t\t\tkind: \"configuration\",\n\t\t\t\tphase: \"preflight\",\n\t\t\t\tcauseCode: \"configuration.invalid\",\n\t\t\t\tretryable: false,\n\t\t\t};\n\t\tcase \"internal\":\n\t\t\treturn {\n\t\t\t\tkind: \"internal_error\",\n\t\t\t\tphase: \"preflight\",\n\t\t\t\tcauseCode: \"internal.unclassified\",\n\t\t\t\tretryable: false,\n\t\t\t};\n\t\tcase \"budget\":\n\t\t\treturn { kind: \"budget_exhausted\", phase: \"control\", causeCode: `budget.${cause.code}`, retryable: false };\n\t\tcase \"resource\":\n\t\t\t// §15.4: every resource cause is retryable; queue overflow surfaces at\n\t\t\t// the tool boundary, everything else at preflight admission.\n\t\t\treturn {\n\t\t\t\tkind: \"resource_pressure\",\n\t\t\t\tphase: cause.code === \"queue_overflow\" ? \"tool\" : \"preflight\",\n\t\t\t\tcauseCode: `resource.${cause.code}`,\n\t\t\t\tretryable: true,\n\t\t\t};\n\t}\n}\n\nfunction isSafeToAutoRetry(classification: Classification, input: ClassifySessionTerminationInput): boolean {\n\t// provider_refusal: Fable/Claude often false-positive on benign turns. Safe to auto-retry once\n\t// when no tool side effects occurred (same class of recovery as rate_limit/network).\n\treturn (\n\t\tclassification.retryable &&\n\t\tinput.source === \"observed\" &&\n\t\tinput.sideEffects === \"none\" &&\n\t\t(classification.kind === \"provider_rate_limit\" ||\n\t\t\tclassification.kind === \"provider_network\" ||\n\t\t\tclassification.kind === \"provider_refusal\" ||\n\t\t\t// §15.4 mapping: only cpu pressure is safe to auto-retry (with delay).\n\t\t\tclassification.causeCode === \"resource.cpu\")\n\t);\n}\n\nfunction nextActionFor(classification: Classification, input: ClassifySessionTerminationInput): string {\n\tswitch (classification.kind) {\n\t\tcase \"completed\":\n\t\t\treturn \"No recovery action is required; continue with the next prompt.\";\n\t\tcase \"user_abort\":\n\t\t\treturn \"Review possible partial side effects, then retry only if intended.\";\n\t\tcase \"budget_exhausted\":\n\t\t\treturn \"Review partial work and remaining requests; start a new run only with an explicitly approved budget.\";\n\t\tcase \"resource_pressure\":\n\t\t\treturn \"Host resources are constrained; reduce load or wait for recovery, then retry.\";\n\t\tcase \"provider_abort\":\n\t\t\treturn \"Confirm provider availability, then retry the request.\";\n\t\tcase \"provider_auth\":\n\t\t\t// A credential-less install resolves a placeholder model whose provider is\n\t\t\t// literally \"unknown\"; never echo that back as a login target.\n\t\t\treturn `Run /login${input.provider && input.provider !== \"unknown\" ? ` ${input.provider}` : \"\"} in an interactive session, or set the provider's API key environment variable, then retry.`;\n\t\tcase \"provider_rate_limit\":\n\t\t\treturn \"Wait for the provider retry window or choose another model, then retry.\";\n\t\tcase \"provider_network\":\n\t\t\treturn \"Check network and provider connectivity, then retry.\";\n\t\tcase \"provider_protocol\":\n\t\t\treturn \"Often an orphan tool_call_id / sticky transcript after a dropped error turn — auto-retry after sanitize, or /new session if it persists.\";\n\t\tcase \"provider_refusal\":\n\t\t\treturn \"Model declined this turn (content/safety stop). Usually a false positive on Fable/Claude — auto-retry once, or switch model (k3/qwen3.8-max/grok-4.5/deepseek) / rephrase as a pure coding task.\";\n\t\tcase \"context_overflow\":\n\t\t\treturn \"Compact or reduce context, or switch to a larger-context model.\";\n\t\tcase \"tool_timeout\":\n\t\t\treturn \"Inspect possible tool side effects and increase the tool timeout only if safe.\";\n\t\tcase \"tool_fatal\":\n\t\t\treturn \"Inspect the failed tool result and repair its configuration before retrying.\";\n\t\tcase \"compaction\":\n\t\t\tswitch (classification.causeCode) {\n\t\t\t\tcase \"compaction.aborted\":\n\t\t\t\t\treturn \"Retry /compact if cancellation was unintended; avoid Escape while compaction is running.\";\n\t\t\t\tcase \"compaction.stale\":\n\t\t\t\t\treturn \"Retry /compact after pending session changes settle.\";\n\t\t\t\tcase \"compaction.quota_exhausted\":\n\t\t\t\t\treturn \"The summarization model's quota is exhausted — retrying cannot help yet. Switch model (/model), set compaction.model in settings, or wait for the quota reset, then retry /compact. OMK already tried the failover chain automatically.\";\n\t\t\t\tdefault:\n\t\t\t\t\treturn \"Resolve the reported compaction error, then retry /compact.\";\n\t\t\t}\n\t\tcase \"persistence\":\n\t\t\treturn `Run omk session doctor --session ${input.sessionId} before resuming.`;\n\t\tcase \"process_signal\":\n\t\t\treturn \"Review possible partial side effects before resuming the session.\";\n\t\tcase \"process_crash\":\n\t\t\treturn `Run omk session doctor --session ${input.sessionId} and review partial side effects.`;\n\t\tcase \"transcript_invalid\":\n\t\t\treturn `Run omk session doctor --session ${input.sessionId}; do not resume until integrity passes.`;\n\t\tcase \"configuration\":\n\t\t\treturn \"This model or client is not valid for the current login. Switch with /model or fix provider/client settings; /new session will not grant access.\";\n\t\tcase \"internal_error\":\n\t\t\treturn `Inspect run ${input.runId} diagnostics and the run journal before retrying.`;\n\t}\n}\n\n/** Concise actionable rendering shared by non-JSON and TUI surfaces. */\nexport function formatSessionTermination(termination: SessionTermination): string {\n\tconst route =\n\t\ttermination.provider || termination.model\n\t\t\t? `${termination.provider ?? \"unknown\"}/${termination.model ?? \"unknown\"}`\n\t\t\t: \"n/a\";\n\treturn [\n\t\t`kind=${termination.kind}`,\n\t\t`provider/model=${route}`,\n\t\t`retryable=${termination.retryable}`,\n\t\t`cause=${termination.causeCode}`,\n\t\t`message=${termination.message}`,\n\t\t`run=${termination.runId}`,\n\t\t`next=${termination.nextAction}`,\n\t].join(\" \");\n}\n\n/**\n * Classify a bounded, structured termination cause. This intentionally accepts\n * no raw Error value, stack, provider body, or arbitrary cause code.\n */\nexport function classifySessionTermination(input: ClassifySessionTerminationInput): SessionTermination {\n\tassertClassifierInput(input);\n\tassertIdentifier(input.sessionId, \"sessionId\", 128);\n\tassertIdentifier(input.runId, \"runId\", 128);\n\tassertTimestamp(input.timestamp);\n\tassertPreRedactedTerminationMessage(input.message);\n\tif (input.provider !== undefined) assertIdentifier(input.provider, \"provider\", 128);\n\tif (input.model !== undefined) assertIdentifier(input.model, \"model\", 256);\n\tif (input.toolCallId !== undefined) assertIdentifier(input.toolCallId, \"toolCallId\", 512);\n\tif (input.toolName !== undefined) assertIdentifier(input.toolName, \"toolName\", 128);\n\tif (input.retryAfterMs !== undefined && (!Number.isSafeInteger(input.retryAfterMs) || input.retryAfterMs < 0)) {\n\t\tthrow new TypeError(\"retryAfterMs must be a non-negative safe integer\");\n\t}\n\tif (input.cause.area === \"process\" && input.cause.code === \"crash\" && input.source !== \"inferred_on_resume\") {\n\t\tthrow new TypeError(\"process crashes may only be classified as inferred_on_resume\");\n\t}\n\tif (input.cause.area === \"process\" && input.cause.code === \"signal\" && input.source !== \"observed\") {\n\t\tthrow new TypeError(\"process signals must be observed\");\n\t}\n\n\tconst classification = classifyCause(input.cause, input.source);\n\treturn Object.freeze({\n\t\tschemaVersion: SESSION_TERMINATION_SCHEMA_VERSION,\n\t\tsessionId: input.sessionId,\n\t\trunId: input.runId,\n\t\tkind: classification.kind,\n\t\tphase: classification.phase,\n\t\tsource: input.source,\n\t\tmessage: input.message,\n\t\tcauseCode: classification.causeCode,\n\t\tnextAction: nextActionFor(classification, input),\n\t\tretryable: classification.retryable,\n\t\tsafeToAutoRetry: isSafeToAutoRetry(classification, input),\n\t\tsideEffects: input.sideEffects,\n\t\ttimestamp: input.timestamp,\n\t\t...(input.retryAfterMs === undefined ? {} : { retryAfterMs: input.retryAfterMs }),\n\t\t...(input.provider === undefined ? {} : { provider: input.provider }),\n\t\t...(input.model === undefined ? {} : { model: input.model }),\n\t\t...(input.toolCallId === undefined ? {} : { toolCallId: input.toolCallId }),\n\t\t...(input.toolName === undefined ? {} : { toolName: input.toolName }),\n\t\t...(classification.processSignal === undefined ? {} : { processSignal: classification.processSignal }),\n\t\t...(classification.transcriptIssue === undefined ? {} : { transcriptIssue: classification.transcriptIssue }),\n\t});\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"slash-commands.d.ts","sourceRoot":"","sources":["../../src/core/slash-commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAElE,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,UAAU,EAAE,UAAU,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,mBAAmB,CA4BrE,CAAC","sourcesContent":["import { APP_NAME } from \"../config.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\n\nexport type SlashCommandSource = \"extension\" | \"prompt\" | \"skill\";\n\nexport interface SlashCommandInfo {\n\tname: string;\n\tdescription?: string;\n\tsource: SlashCommandSource;\n\tsourceInfo: SourceInfo;\n}\n\nexport interface BuiltinSlashCommand {\n\tname: string;\n\tdescription: string;\n}\n\nexport const BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{ name: \"settings\", description: \"Open settings menu\" },\n\t{\n\t\tname: \"think\",\n\t\tdescription: \"Select thinking level (auto routes per task through v4)\",\n\t},\n\t{ name: \"model\", description: \"Select model (opens selector UI, then thinking selector)\" },\n\t{ name: \"scoped-models\", description: \"Enable/disable models for Ctrl+P cycling\" },\n\t{ name: \"export\", description: \"Export session (HTML default, or specify path: .html/.jsonl)\" },\n\t{ name: \"import\", description: \"Import and resume a session from a JSONL file\" },\n\t{ name: \"share\", description: \"Share session as a secret GitHub gist\" },\n\t{ name: \"copy\", description: \"Copy last agent message to clipboard\" },\n\t{ name: \"name\", description: \"Set session display name\" },\n\t{ name: \"session\", description: \"Show session info and stats\" },\n\t{ name: \"resource\", description: \"Show resource pressure and effective concurrency (probe|policy)\" },\n\t{ name: \"changelog\", description: \"Show changelog entries\" },\n\t{ name: \"star\", description: \"Open the OMK GitHub repository\" },\n\t{ name: \"hotkeys\", description: \"Show all keyboard shortcuts\" },\n\t{ name: \"fork\", description: \"Create a new fork from a previous user message\" },\n\t{ name: \"clone\", description: \"Duplicate the current session at the current position\" },\n\t{ name: \"tree\", description: \"Navigate session tree (switch branches)\" },\n\t{ name: \"login\", description: \"Configure provider authentication\" },\n\t{ name: \"logout\", description: \"Remove provider authentication\" },\n\t{ name: \"new\", description: \"Start a new session\" },\n\t{ name: \"compact\", description: \"Manually compact the session context\" },\n\t{ name: \"resume\", description: \"Resume a different session\" },\n\t{ name: \"reload\", description: \"Reload keybindings, extensions, skills, prompts, and themes\" },\n\t{ name: \"quit\", description: `Quit ${APP_NAME}` },\n];\n"]}
1
+ {"version":3,"file":"slash-commands.d.ts","sourceRoot":"","sources":["../../src/core/slash-commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;AAElE,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,UAAU,EAAE,UAAU,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,mBAAmB,CA6BrE,CAAC","sourcesContent":["import { APP_NAME } from \"../config.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\n\nexport type SlashCommandSource = \"extension\" | \"prompt\" | \"skill\";\n\nexport interface SlashCommandInfo {\n\tname: string;\n\tdescription?: string;\n\tsource: SlashCommandSource;\n\tsourceInfo: SourceInfo;\n}\n\nexport interface BuiltinSlashCommand {\n\tname: string;\n\tdescription: string;\n}\n\nexport const BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{ name: \"settings\", description: \"Open settings menu\" },\n\t{\n\t\tname: \"think\",\n\t\tdescription: \"Select thinking level (auto routes per task through v4)\",\n\t},\n\t{ name: \"model\", description: \"Select model (opens selector UI, then thinking selector)\" },\n\t{ name: \"scoped-models\", description: \"Enable/disable models for Ctrl+P cycling\" },\n\t{ name: \"export\", description: \"Export session (HTML default, or specify path: .html/.jsonl)\" },\n\t{ name: \"import\", description: \"Import and resume a session from a JSONL file\" },\n\t{ name: \"share\", description: \"Share session as a secret GitHub gist\" },\n\t{ name: \"copy\", description: \"Copy last agent message to clipboard\" },\n\t{ name: \"name\", description: \"Set session display name\" },\n\t{ name: \"session\", description: \"Show session info and stats\" },\n\t{ name: \"resource\", description: \"Show resource pressure and effective concurrency (probe|policy)\" },\n\t{ name: \"debug\", description: \"Preview local runtime diagnostics; save a metadata-only report with /debug save\" },\n\t{ name: \"changelog\", description: \"Show changelog entries\" },\n\t{ name: \"star\", description: \"Open the OMK GitHub repository\" },\n\t{ name: \"hotkeys\", description: \"Show all keyboard shortcuts\" },\n\t{ name: \"fork\", description: \"Create a new fork from a previous user message\" },\n\t{ name: \"clone\", description: \"Duplicate the current session at the current position\" },\n\t{ name: \"tree\", description: \"Navigate session tree (switch branches)\" },\n\t{ name: \"login\", description: \"Configure provider authentication\" },\n\t{ name: \"logout\", description: \"Remove provider authentication\" },\n\t{ name: \"new\", description: \"Start a new session\" },\n\t{ name: \"compact\", description: \"Manually compact the session context\" },\n\t{ name: \"resume\", description: \"Resume a different session\" },\n\t{ name: \"reload\", description: \"Reload keybindings, extensions, skills, prompts, and themes\" },\n\t{ name: \"quit\", description: `Quit ${APP_NAME}` },\n];\n"]}
@@ -14,6 +14,7 @@ export const BUILTIN_SLASH_COMMANDS = [
14
14
  { name: "name", description: "Set session display name" },
15
15
  { name: "session", description: "Show session info and stats" },
16
16
  { name: "resource", description: "Show resource pressure and effective concurrency (probe|policy)" },
17
+ { name: "debug", description: "Preview local runtime diagnostics; save a metadata-only report with /debug save" },
17
18
  { name: "changelog", description: "Show changelog entries" },
18
19
  { name: "star", description: "Open the OMK GitHub repository" },
19
20
  { name: "hotkeys", description: "Show all keyboard shortcuts" },
@@ -1 +1 @@
1
- {"version":3,"file":"slash-commands.js","sourceRoot":"","sources":["../../src/core/slash-commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAiBxC,MAAM,CAAC,MAAM,sBAAsB,GAAuC;IACzE,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,oBAAoB,EAAE;IACvD;QACC,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,yDAAyD;KACtE;IACD,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,0DAA0D,EAAE;IAC1F,EAAE,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,0CAA0C,EAAE;IAClF,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8DAA8D,EAAE;IAC/F,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+CAA+C,EAAE;IAChF,EAAE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= \"extension\" | \"prompt\" | \"skill\";\n\nexport interface SlashCommandInfo {\n\tname: string;\n\tdescription?: string;\n\tsource: SlashCommandSource;\n\tsourceInfo: SourceInfo;\n}\n\nexport interface BuiltinSlashCommand {\n\tname: string;\n\tdescription: string;\n}\n\nexport const BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{ name: \"settings\", description: \"Open settings menu\" },\n\t{\n\t\tname: \"think\",\n\t\tdescription: \"Select thinking level (auto routes per task through v4)\",\n\t},\n\t{ name: \"model\", description: \"Select model (opens selector UI, then thinking selector)\" },\n\t{ name: \"scoped-models\", description: \"Enable/disable models for Ctrl+P cycling\" },\n\t{ name: \"export\", description: \"Export session (HTML default, or specify path: .html/.jsonl)\" },\n\t{ name: \"import\", description: \"Import and resume a session from a JSONL file\" },\n\t{ name: \"share\", description: \"Share session as a secret GitHub gist\" },\n\t{ name: \"copy\", description: \"Copy last agent message to clipboard\" },\n\t{ name: \"name\", description: \"Set session display name\" },\n\t{ name: \"session\", description: \"Show session info and stats\" },\n\t{ name: \"resource\", description: \"Show resource pressure and effective concurrency (probe|policy)\" },\n\t{ name: \"changelog\", description: \"Show changelog entries\" },\n\t{ name: \"star\", description: \"Open the OMK GitHub repository\" },\n\t{ name: \"hotkeys\", description: \"Show all keyboard shortcuts\" },\n\t{ name: \"fork\", description: \"Create a new fork from a previous user message\" },\n\t{ name: \"clone\", description: \"Duplicate the current session at the current position\" },\n\t{ name: \"tree\", description: \"Navigate session tree (switch branches)\" },\n\t{ name: \"login\", description: \"Configure provider authentication\" },\n\t{ name: \"logout\", description: \"Remove provider authentication\" },\n\t{ name: \"new\", description: \"Start a new session\" },\n\t{ name: \"compact\", description: \"Manually compact the session context\" },\n\t{ name: \"resume\", description: \"Resume a different session\" },\n\t{ name: \"reload\", description: \"Reload keybindings, extensions, skills, prompts, and themes\" },\n\t{ name: \"quit\", description: `Quit ${APP_NAME}` },\n];\n"]}
1
+ {"version":3,"file":"slash-commands.js","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E,MAAM,EAAE,WAAW,EAAE,yCAAyC,EAAE;IACxE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,mCAAmC,EAAE;IACnE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gCAAgC,EAAE;IACjE,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE;IACnD,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,sCAAsC,EAAE;IACxE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,4BAA4B,EAAE;IAC7D,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6DAA6D,EAAE;IAC9F,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,QAAQ,EAAE,EAAE;CACjD,CAAC","sourcesContent":["import { APP_NAME } from \"../config.ts\";\nimport type { SourceInfo } from \"./source-info.ts\";\n\nexport type SlashCommandSource = \"extension\" | \"prompt\" | \"skill\";\n\nexport interface SlashCommandInfo {\n\tname: string;\n\tdescription?: string;\n\tsource: SlashCommandSource;\n\tsourceInfo: SourceInfo;\n}\n\nexport interface BuiltinSlashCommand {\n\tname: string;\n\tdescription: string;\n}\n\nexport const BUILTIN_SLASH_COMMANDS: ReadonlyArray<BuiltinSlashCommand> = [\n\t{ name: \"settings\", description: \"Open settings menu\" },\n\t{\n\t\tname: \"think\",\n\t\tdescription: \"Select thinking level (auto routes per task through v4)\",\n\t},\n\t{ name: \"model\", description: \"Select model (opens selector UI, then thinking selector)\" },\n\t{ name: \"scoped-models\", description: \"Enable/disable models for Ctrl+P cycling\" },\n\t{ name: \"export\", description: \"Export session (HTML default, or specify path: .html/.jsonl)\" },\n\t{ name: \"import\", description: \"Import and resume a session from a JSONL file\" },\n\t{ name: \"share\", description: \"Share session as a secret GitHub gist\" },\n\t{ name: \"copy\", description: \"Copy last agent message to clipboard\" },\n\t{ name: \"name\", description: \"Set session display name\" },\n\t{ name: \"session\", description: \"Show session info and stats\" },\n\t{ name: \"resource\", description: \"Show resource pressure and effective concurrency (probe|policy)\" },\n\t{ name: \"debug\", description: \"Preview local runtime diagnostics; save a metadata-only report with /debug save\" },\n\t{ name: \"changelog\", description: \"Show changelog entries\" },\n\t{ name: \"star\", description: \"Open the OMK GitHub repository\" },\n\t{ name: \"hotkeys\", description: \"Show all keyboard shortcuts\" },\n\t{ name: \"fork\", description: \"Create a new fork from a previous user message\" },\n\t{ name: \"clone\", description: \"Duplicate the current session at the current position\" },\n\t{ name: \"tree\", description: \"Navigate session tree (switch branches)\" },\n\t{ name: \"login\", description: \"Configure provider authentication\" },\n\t{ name: \"logout\", description: \"Remove provider authentication\" },\n\t{ name: \"new\", description: \"Start a new session\" },\n\t{ name: \"compact\", description: \"Manually compact the session context\" },\n\t{ name: \"resume\", description: \"Resume a different session\" },\n\t{ name: \"reload\", description: \"Reload keybindings, extensions, skills, prompts, and themes\" },\n\t{ name: \"quit\", description: `Quit ${APP_NAME}` },\n];\n"]}
@@ -24,18 +24,19 @@ export interface EffectiveLaneWidthInput {
24
24
  /** Widest conflict-free batch; the plan's batching already serializes writers. */
25
25
  readonly pathConflictFreeWidth: number;
26
26
  }
27
- /** §14.2: `min(plan, configured, admission, availableHeavyPermits, conflictFree)`, floor 1. */
27
+ /** Zero authority defers execution; configured zero retains its legacy unlimited meaning. */
28
28
  export declare function computeEffectiveLaneWidth(input: EffectiveLaneWidthInput): number;
29
29
  /** Read-only budget handed to every child (§14.1). Nothing here can raise a cap. */
30
30
  export interface SubagentLaneContext {
31
31
  readonly laneId: string;
32
32
  readonly promptRunId: string;
33
+ readonly signal?: AbortSignal;
33
34
  readonly decision: ResourceAdmissionDecision;
34
35
  readonly effectiveLaneWidth: number;
35
36
  }
36
37
  export interface LaneOutcome {
37
38
  readonly laneId: string;
38
- readonly status: "completed" | "failed" | "skipped-abort" | "permit-rejected";
39
+ readonly status: "completed" | "failed" | "cancelled" | "skipped-abort" | "permit-rejected" | "admission-deferred";
39
40
  readonly diagnostic?: string;
40
41
  }
41
42
  export interface LaunchSubagentLanesInput {
@@ -1 +1 @@
1
- {"version":3,"file":"subagent-lane-launcher.d.ts","sourceRoot":"","sources":["../../src/core/subagent-lane-launcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEzF;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IAC7C,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAC3C,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,kFAAkF;IAClF,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACvC;AAED,gGAA+F;AAC/F,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAahF;AAED,qFAAoF;AACpF,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;IAC7C,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,eAAe,GAAG,iBAAiB,CAAC;IAC9E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,2EAA0E;IAC1E,QAAQ,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;CACxC;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAsD7G","sourcesContent":["import type { ResourceAdmissionDecision } from \"./resource-admission.ts\";\nimport type { SubagentOrchestrationPlan } from \"./subagent-orchestration.ts\";\nimport { WorkloadPermitError, type WorkloadPermitPool } from \"./workload-permit-pool.ts\";\n\n/**\n * Subagent lane launch authority (OMK v0.97.x roadmap §14, M6/PR10).\n *\n * Turns `buildSubagentOrchestrationPlan()` output into enforced execution:\n * the §14.2 effective width is a hard cap on concurrently active children,\n * batches run in order (writer serialization / path conflicts are encoded in\n * the plan's batches, which supplies the `pathConflictFreeWidth` term), and\n * heavy lanes draw permits from the PARENT's shared pool (§14.1 — a child\n * never constructs its own pool here; it receives this launcher's budget).\n *\n * §14.3 guarantees: child failure releases its permit (leak 0), parent\n * abort aborts queued permit waits and never launches unstarted lanes, and\n * the child context carries the parent decision with a width the child\n * cannot raise (§14.4: no API exists to widen — the context is read-only).\n */\n\nexport interface EffectiveLaneWidthInput {\n\treadonly planWidth: number;\n\treadonly configuredMaxParallelLanes?: number;\n\treadonly admissionMaxParallelLanes: number;\n\treadonly availableHeavyPermits: number;\n\t/** Widest conflict-free batch; the plan's batching already serializes writers. */\n\treadonly pathConflictFreeWidth: number;\n}\n\n/** §14.2: `min(plan, configured, admission, availableHeavyPermits, conflictFree)`, floor 1. */\nexport function computeEffectiveLaneWidth(input: EffectiveLaneWidthInput): number {\n\tconst configured =\n\t\tinput.configuredMaxParallelLanes !== undefined && input.configuredMaxParallelLanes > 0\n\t\t\t? input.configuredMaxParallelLanes\n\t\t\t: Number.POSITIVE_INFINITY;\n\tconst width = Math.min(\n\t\tinput.planWidth,\n\t\tconfigured,\n\t\tinput.admissionMaxParallelLanes,\n\t\tMath.max(1, input.availableHeavyPermits),\n\t\tinput.pathConflictFreeWidth,\n\t);\n\treturn Math.max(1, Math.floor(width));\n}\n\n/** Read-only budget handed to every child (§14.1). Nothing here can raise a cap. */\nexport interface SubagentLaneContext {\n\treadonly laneId: string;\n\treadonly promptRunId: string;\n\treadonly decision: ResourceAdmissionDecision;\n\treadonly effectiveLaneWidth: number;\n}\n\nexport interface LaneOutcome {\n\treadonly laneId: string;\n\treadonly status: \"completed\" | \"failed\" | \"skipped-abort\" | \"permit-rejected\";\n\treadonly diagnostic?: string;\n}\n\nexport interface LaunchSubagentLanesInput {\n\treadonly plan: SubagentOrchestrationPlan;\n\treadonly promptRunId: string;\n\treadonly decision: ResourceAdmissionDecision;\n\treadonly permitPool: WorkloadPermitPool;\n\treadonly configuredMaxParallelLanes?: number;\n\treadonly signal?: AbortSignal;\n\t/** Lane ids that run heavy work and must hold a shared permit (§14.3). */\n\treadonly heavyLaneIds?: ReadonlySet<string>;\n\t/** The actual child launcher (process spawn, SDK session, or test double). */\n\treadonly launchLane: (context: SubagentLaneContext) => Promise<void>;\n\treadonly permitWaitTimeoutMs?: number;\n}\n\nexport interface LaunchSubagentLanesResult {\n\treadonly outcomes: readonly LaneOutcome[];\n\treadonly effectiveLaneWidth: number;\n\treadonly maxObservedConcurrency: number;\n}\n\n/**\n * Execute a plan's batches with the §14.2 width as launcher authority.\n * Never throws for lane failures; the caller reads per-lane outcomes.\n */\nexport async function launchSubagentLanes(input: LaunchSubagentLanesInput): Promise<LaunchSubagentLanesResult> {\n\tconst poolSnapshot = input.permitPool.snapshot();\n\tconst effectiveLaneWidth = computeEffectiveLaneWidth({\n\t\tplanWidth: Math.max(1, input.plan.route.width),\n\t\tconfiguredMaxParallelLanes: input.configuredMaxParallelLanes,\n\t\tadmissionMaxParallelLanes: input.decision.maxParallelLanes,\n\t\tavailableHeavyPermits: Math.max(0, poolSnapshot.capacity - poolSnapshot.activeWeight),\n\t\tpathConflictFreeWidth: Math.max(1, ...input.plan.batches.map((batch) => batch.laneIds.length)),\n\t});\n\n\tconst outcomes: LaneOutcome[] = [];\n\tlet active = 0;\n\tlet maxObservedConcurrency = 0;\n\n\tfor (const batch of input.plan.batches) {\n\t\tif (input.signal?.aborted) {\n\t\t\t// Parent abort: unstarted lanes are never launched (§14.3).\n\t\t\tfor (const laneId of batch.laneIds) {\n\t\t\t\toutcomes.push({ laneId, status: \"skipped-abort\" });\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\t// Batches execute sequentially (dependency + writer serialization);\n\t\t// inside one batch, the effective width bounds the running children.\n\t\tlet cursor = 0;\n\t\tconst runners: Promise<void>[] = [];\n\t\tconst runNext = async (): Promise<void> => {\n\t\t\twhile (cursor < batch.laneIds.length) {\n\t\t\t\tconst laneId = batch.laneIds[cursor];\n\t\t\t\tcursor += 1;\n\t\t\t\tif (input.signal?.aborted) {\n\t\t\t\t\toutcomes.push({ laneId, status: \"skipped-abort\" });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\toutcomes.push(\n\t\t\t\t\tawait runLane(input, laneId, effectiveLaneWidth, {\n\t\t\t\t\t\tenter: () => {\n\t\t\t\t\t\t\tactive += 1;\n\t\t\t\t\t\t\tmaxObservedConcurrency = Math.max(maxObservedConcurrency, active);\n\t\t\t\t\t\t},\n\t\t\t\t\t\texit: () => {\n\t\t\t\t\t\t\tactive -= 1;\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\tconst workers = Math.min(effectiveLaneWidth, batch.laneIds.length);\n\t\tfor (let i = 0; i < workers; i++) {\n\t\t\trunners.push(runNext());\n\t\t}\n\t\tawait Promise.all(runners);\n\t}\n\treturn { outcomes, effectiveLaneWidth, maxObservedConcurrency };\n}\n\nasync function runLane(\n\tinput: LaunchSubagentLanesInput,\n\tlaneId: string,\n\teffectiveLaneWidth: number,\n\tgauge: { readonly enter: () => void; readonly exit: () => void },\n): Promise<LaneOutcome> {\n\tlet releasePermit: (() => void) | undefined;\n\tif (input.heavyLaneIds?.has(laneId)) {\n\t\ttry {\n\t\t\tconst permit = await input.permitPool.acquire({\n\t\t\t\trequestId: `lane-${laneId}`,\n\t\t\t\tpromptRunId: input.promptRunId,\n\t\t\t\tworkloadClass: \"heavy\",\n\t\t\t\tweight: 1,\n\t\t\t\tsignal: input.signal,\n\t\t\t\ttimeoutMs: input.permitWaitTimeoutMs ?? 60_000,\n\t\t\t});\n\t\t\treleasePermit = () => permit.release();\n\t\t} catch (error) {\n\t\t\tconst code = error instanceof WorkloadPermitError ? error.code : \"unknown\";\n\t\t\treturn {\n\t\t\t\tlaneId,\n\t\t\t\tstatus: code === \"aborted\" ? \"skipped-abort\" : \"permit-rejected\",\n\t\t\t\tdiagnostic: `permit.${code}`,\n\t\t\t};\n\t\t}\n\t}\n\tgauge.enter();\n\ttry {\n\t\tawait input.launchLane({\n\t\t\tlaneId,\n\t\t\tpromptRunId: input.promptRunId,\n\t\t\tdecision: input.decision,\n\t\t\teffectiveLaneWidth,\n\t\t});\n\t\treturn { laneId, status: \"completed\" };\n\t} catch (error) {\n\t\t// §14.3: a failing child must not leak its permit; release below.\n\t\treturn { laneId, status: \"failed\", diagnostic: String(error).slice(0, 200) };\n\t} finally {\n\t\tgauge.exit();\n\t\treleasePermit?.();\n\t}\n}\n"]}
1
+ {"version":3,"file":"subagent-lane-launcher.d.ts","sourceRoot":"","sources":["../../src/core/subagent-lane-launcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAC7E,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEzF;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IAC7C,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC;IAC3C,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,kFAAkF;IAClF,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACvC;AAED,6FAA6F;AAC7F,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,uBAAuB,GAAG,MAAM,CAahF;AAED,qFAAoF;AACpF,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;IAC7C,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,eAAe,GAAG,iBAAiB,GAAG,oBAAoB,CAAC;IACnH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,wBAAwB;IACxC,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,2EAA0E;IAC1E,QAAQ,CAAC,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC;CACxC;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAwD7G","sourcesContent":["import type { ResourceAdmissionDecision } from \"./resource-admission.ts\";\nimport type { SubagentOrchestrationPlan } from \"./subagent-orchestration.ts\";\nimport { WorkloadPermitError, type WorkloadPermitPool } from \"./workload-permit-pool.ts\";\n\n/**\n * Subagent lane launch authority (OMK v0.97.x roadmap §14, M6/PR10).\n *\n * Turns `buildSubagentOrchestrationPlan()` output into enforced execution:\n * the §14.2 effective width is a hard cap on concurrently active children,\n * batches run in order (writer serialization / path conflicts are encoded in\n * the plan's batches, which supplies the `pathConflictFreeWidth` term), and\n * heavy lanes draw permits from the PARENT's shared pool (§14.1 — a child\n * never constructs its own pool here; it receives this launcher's budget).\n *\n * §14.3 guarantees: child failure releases its permit (leak 0), parent\n * abort aborts queued permit waits and never launches unstarted lanes, and\n * the child context carries the parent decision with a width the child\n * cannot raise (§14.4: no API exists to widen — the context is read-only).\n */\n\nexport interface EffectiveLaneWidthInput {\n\treadonly planWidth: number;\n\treadonly configuredMaxParallelLanes?: number;\n\treadonly admissionMaxParallelLanes: number;\n\treadonly availableHeavyPermits: number;\n\t/** Widest conflict-free batch; the plan's batching already serializes writers. */\n\treadonly pathConflictFreeWidth: number;\n}\n\n/** Zero authority defers execution; configured zero retains its legacy unlimited meaning. */\nexport function computeEffectiveLaneWidth(input: EffectiveLaneWidthInput): number {\n\tconst configured =\n\t\tinput.configuredMaxParallelLanes !== undefined && input.configuredMaxParallelLanes > 0\n\t\t\t? input.configuredMaxParallelLanes\n\t\t\t: Number.POSITIVE_INFINITY;\n\tconst width = Math.min(\n\t\tinput.planWidth,\n\t\tconfigured,\n\t\tinput.admissionMaxParallelLanes,\n\t\tinput.availableHeavyPermits,\n\t\tinput.pathConflictFreeWidth,\n\t);\n\treturn Number.isFinite(width) ? Math.max(0, Math.floor(width)) : 0;\n}\n\n/** Read-only budget handed to every child (§14.1). Nothing here can raise a cap. */\nexport interface SubagentLaneContext {\n\treadonly laneId: string;\n\treadonly promptRunId: string;\n\treadonly signal?: AbortSignal;\n\treadonly decision: ResourceAdmissionDecision;\n\treadonly effectiveLaneWidth: number;\n}\n\nexport interface LaneOutcome {\n\treadonly laneId: string;\n\treadonly status: \"completed\" | \"failed\" | \"cancelled\" | \"skipped-abort\" | \"permit-rejected\" | \"admission-deferred\";\n\treadonly diagnostic?: string;\n}\n\nexport interface LaunchSubagentLanesInput {\n\treadonly plan: SubagentOrchestrationPlan;\n\treadonly promptRunId: string;\n\treadonly decision: ResourceAdmissionDecision;\n\treadonly permitPool: WorkloadPermitPool;\n\treadonly configuredMaxParallelLanes?: number;\n\treadonly signal?: AbortSignal;\n\t/** Lane ids that run heavy work and must hold a shared permit (§14.3). */\n\treadonly heavyLaneIds?: ReadonlySet<string>;\n\t/** The actual child launcher (process spawn, SDK session, or test double). */\n\treadonly launchLane: (context: SubagentLaneContext) => Promise<void>;\n\treadonly permitWaitTimeoutMs?: number;\n}\n\nexport interface LaunchSubagentLanesResult {\n\treadonly outcomes: readonly LaneOutcome[];\n\treadonly effectiveLaneWidth: number;\n\treadonly maxObservedConcurrency: number;\n}\n\n/**\n * Execute a plan's batches with the §14.2 width as launcher authority.\n * Never throws for lane failures; the caller reads per-lane outcomes.\n */\nexport async function launchSubagentLanes(input: LaunchSubagentLanesInput): Promise<LaunchSubagentLanesResult> {\n\tconst poolSnapshot = input.permitPool.snapshot();\n\tconst effectiveLaneWidth = computeEffectiveLaneWidth({\n\t\tplanWidth: input.plan.route.width,\n\t\tconfiguredMaxParallelLanes: input.configuredMaxParallelLanes,\n\t\tadmissionMaxParallelLanes: input.decision.maxParallelLanes,\n\t\tavailableHeavyPermits: Math.min(\n\t\t\tMath.max(0, poolSnapshot.capacity - poolSnapshot.activeWeight),\n\t\t\tinput.heavyLaneIds?.size ? input.decision.maxHeavyProcesses : Number.POSITIVE_INFINITY,\n\t\t),\n\t\tpathConflictFreeWidth: Math.max(0, ...input.plan.batches.map((batch) => batch.laneIds.length)),\n\t});\n\n\tconst outcomes: LaneOutcome[] = [];\n\tlet active = 0;\n\tlet maxObservedConcurrency = 0;\n\n\tfor (const batch of input.plan.batches) {\n\t\tif (input.signal?.aborted || effectiveLaneWidth === 0) {\n\t\t\tfor (const laneId of batch.laneIds) {\n\t\t\t\toutcomes.push({ laneId, status: input.signal?.aborted ? \"skipped-abort\" : \"admission-deferred\" });\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\t// Batches execute sequentially (dependency + writer serialization);\n\t\t// inside one batch, the effective width bounds the running children.\n\t\tlet cursor = 0;\n\t\tconst runners: Promise<void>[] = [];\n\t\tconst runNext = async (): Promise<void> => {\n\t\t\twhile (cursor < batch.laneIds.length) {\n\t\t\t\tconst laneId = batch.laneIds[cursor];\n\t\t\t\tcursor += 1;\n\t\t\t\tif (input.signal?.aborted) {\n\t\t\t\t\toutcomes.push({ laneId, status: \"skipped-abort\" });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\toutcomes.push(\n\t\t\t\t\tawait runLane(input, laneId, effectiveLaneWidth, {\n\t\t\t\t\t\tenter: () => {\n\t\t\t\t\t\t\tactive += 1;\n\t\t\t\t\t\t\tmaxObservedConcurrency = Math.max(maxObservedConcurrency, active);\n\t\t\t\t\t\t},\n\t\t\t\t\t\texit: () => {\n\t\t\t\t\t\t\tactive -= 1;\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\tconst workers = Math.min(effectiveLaneWidth, batch.laneIds.length);\n\t\tfor (let i = 0; i < workers; i++) {\n\t\t\trunners.push(runNext());\n\t\t}\n\t\tawait Promise.all(runners);\n\t}\n\treturn { outcomes, effectiveLaneWidth, maxObservedConcurrency };\n}\n\nasync function runLane(\n\tinput: LaunchSubagentLanesInput,\n\tlaneId: string,\n\teffectiveLaneWidth: number,\n\tgauge: { readonly enter: () => void; readonly exit: () => void },\n): Promise<LaneOutcome> {\n\tlet releasePermit: (() => void) | undefined;\n\tif (input.heavyLaneIds?.has(laneId)) {\n\t\tif (input.decision.action === \"defer-heavy\" || input.decision.maxHeavyProcesses === 0) {\n\t\t\treturn { laneId, status: \"admission-deferred\" };\n\t\t}\n\t\ttry {\n\t\t\tconst permit = await input.permitPool.acquire({\n\t\t\t\trequestId: `lane-${laneId}`,\n\t\t\t\tpromptRunId: input.promptRunId,\n\t\t\t\tworkloadClass: \"heavy\",\n\t\t\t\tweight: 1,\n\t\t\t\tsignal: input.signal,\n\t\t\t\ttimeoutMs: input.permitWaitTimeoutMs ?? 60_000,\n\t\t\t});\n\t\t\treleasePermit = () => permit.release();\n\t\t} catch (error) {\n\t\t\tconst code = error instanceof WorkloadPermitError ? error.code : \"unknown\";\n\t\t\treturn {\n\t\t\t\tlaneId,\n\t\t\t\tstatus: code === \"aborted\" ? \"skipped-abort\" : \"permit-rejected\",\n\t\t\t\tdiagnostic: `permit.${code}`,\n\t\t\t};\n\t\t}\n\t}\n\tif (input.signal?.aborted) {\n\t\treleasePermit?.();\n\t\treturn { laneId, status: \"skipped-abort\" };\n\t}\n\tgauge.enter();\n\ttry {\n\t\tawait input.launchLane({\n\t\t\tlaneId,\n\t\t\tpromptRunId: input.promptRunId,\n\t\t\tsignal: input.signal,\n\t\t\tdecision: input.decision,\n\t\t\teffectiveLaneWidth,\n\t\t});\n\t\treturn { laneId, status: input.signal?.aborted ? \"cancelled\" : \"completed\" };\n\t} catch {\n\t\t// Child error text is untrusted and may contain credentials.\n\t\treturn {\n\t\t\tlaneId,\n\t\t\tstatus: input.signal?.aborted ? \"cancelled\" : \"failed\",\n\t\t\tdiagnostic: \"lane.execution_failed\",\n\t\t};\n\t} finally {\n\t\tgauge.exit();\n\t\treleasePermit?.();\n\t}\n}\n"]}
@@ -1,11 +1,11 @@
1
1
  import { WorkloadPermitError } from "./workload-permit-pool.js";
2
- /** §14.2: `min(plan, configured, admission, availableHeavyPermits, conflictFree)`, floor 1. */
2
+ /** Zero authority defers execution; configured zero retains its legacy unlimited meaning. */
3
3
  export function computeEffectiveLaneWidth(input) {
4
4
  const configured = input.configuredMaxParallelLanes !== undefined && input.configuredMaxParallelLanes > 0
5
5
  ? input.configuredMaxParallelLanes
6
6
  : Number.POSITIVE_INFINITY;
7
- const width = Math.min(input.planWidth, configured, input.admissionMaxParallelLanes, Math.max(1, input.availableHeavyPermits), input.pathConflictFreeWidth);
8
- return Math.max(1, Math.floor(width));
7
+ const width = Math.min(input.planWidth, configured, input.admissionMaxParallelLanes, input.availableHeavyPermits, input.pathConflictFreeWidth);
8
+ return Number.isFinite(width) ? Math.max(0, Math.floor(width)) : 0;
9
9
  }
10
10
  /**
11
11
  * Execute a plan's batches with the §14.2 width as launcher authority.
@@ -14,20 +14,19 @@ export function computeEffectiveLaneWidth(input) {
14
14
  export async function launchSubagentLanes(input) {
15
15
  const poolSnapshot = input.permitPool.snapshot();
16
16
  const effectiveLaneWidth = computeEffectiveLaneWidth({
17
- planWidth: Math.max(1, input.plan.route.width),
17
+ planWidth: input.plan.route.width,
18
18
  configuredMaxParallelLanes: input.configuredMaxParallelLanes,
19
19
  admissionMaxParallelLanes: input.decision.maxParallelLanes,
20
- availableHeavyPermits: Math.max(0, poolSnapshot.capacity - poolSnapshot.activeWeight),
21
- pathConflictFreeWidth: Math.max(1, ...input.plan.batches.map((batch) => batch.laneIds.length)),
20
+ availableHeavyPermits: Math.min(Math.max(0, poolSnapshot.capacity - poolSnapshot.activeWeight), input.heavyLaneIds?.size ? input.decision.maxHeavyProcesses : Number.POSITIVE_INFINITY),
21
+ pathConflictFreeWidth: Math.max(0, ...input.plan.batches.map((batch) => batch.laneIds.length)),
22
22
  });
23
23
  const outcomes = [];
24
24
  let active = 0;
25
25
  let maxObservedConcurrency = 0;
26
26
  for (const batch of input.plan.batches) {
27
- if (input.signal?.aborted) {
28
- // Parent abort: unstarted lanes are never launched (§14.3).
27
+ if (input.signal?.aborted || effectiveLaneWidth === 0) {
29
28
  for (const laneId of batch.laneIds) {
30
- outcomes.push({ laneId, status: "skipped-abort" });
29
+ outcomes.push({ laneId, status: input.signal?.aborted ? "skipped-abort" : "admission-deferred" });
31
30
  }
32
31
  continue;
33
32
  }
@@ -65,6 +64,9 @@ export async function launchSubagentLanes(input) {
65
64
  async function runLane(input, laneId, effectiveLaneWidth, gauge) {
66
65
  let releasePermit;
67
66
  if (input.heavyLaneIds?.has(laneId)) {
67
+ if (input.decision.action === "defer-heavy" || input.decision.maxHeavyProcesses === 0) {
68
+ return { laneId, status: "admission-deferred" };
69
+ }
68
70
  try {
69
71
  const permit = await input.permitPool.acquire({
70
72
  requestId: `lane-${laneId}`,
@@ -85,19 +87,28 @@ async function runLane(input, laneId, effectiveLaneWidth, gauge) {
85
87
  };
86
88
  }
87
89
  }
90
+ if (input.signal?.aborted) {
91
+ releasePermit?.();
92
+ return { laneId, status: "skipped-abort" };
93
+ }
88
94
  gauge.enter();
89
95
  try {
90
96
  await input.launchLane({
91
97
  laneId,
92
98
  promptRunId: input.promptRunId,
99
+ signal: input.signal,
93
100
  decision: input.decision,
94
101
  effectiveLaneWidth,
95
102
  });
96
- return { laneId, status: "completed" };
103
+ return { laneId, status: input.signal?.aborted ? "cancelled" : "completed" };
97
104
  }
98
- catch (error) {
99
- // §14.3: a failing child must not leak its permit; release below.
100
- return { laneId, status: "failed", diagnostic: String(error).slice(0, 200) };
105
+ catch {
106
+ // Child error text is untrusted and may contain credentials.
107
+ return {
108
+ laneId,
109
+ status: input.signal?.aborted ? "cancelled" : "failed",
110
+ diagnostic: "lane.execution_failed",
111
+ };
101
112
  }
102
113
  finally {
103
114
  gauge.exit();
@@ -1 +1 @@
1
- {"version":3,"file":"subagent-lane-launcher.js","sourceRoot":"","sources":["../../src/core/subagent-lane-launcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAA2B,MAAM,2BAA2B,CAAC;AA2BzF,gGAA+F;AAC/F,MAAM,UAAU,yBAAyB,CAAC,KAA8B,EAAU;IACjF,MAAM,UAAU,GACf,KAAK,CAAC,0BAA0B,KAAK,SAAS,IAAI,KAAK,CAAC,0BAA0B,GAAG,CAAC;QACrF,CAAC,CAAC,KAAK,CAAC,0BAA0B;QAClC,CAAC,CAAC,MAAM,CAAC,iBAAiB,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CACrB,KAAK,CAAC,SAAS,EACf,UAAU,EACV,KAAK,CAAC,yBAAyB,EAC/B,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,qBAAqB,CAAC,EACxC,KAAK,CAAC,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C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,mEAAkE;QAClE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;IAC9E,CAAC;YAAS,CAAC;QACV,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,aAAa,EAAE,EAAE,CAAC;IACnB,CAAC;AAAA,CACD","sourcesContent":["import type { ResourceAdmissionDecision } from \"./resource-admission.ts\";\nimport type { SubagentOrchestrationPlan } from \"./subagent-orchestration.ts\";\nimport { WorkloadPermitError, type WorkloadPermitPool } from \"./workload-permit-pool.ts\";\n\n/**\n * Subagent lane launch authority (OMK v0.97.x roadmap §14, M6/PR10).\n *\n * Turns `buildSubagentOrchestrationPlan()` output into enforced execution:\n * the §14.2 effective width is a hard cap on concurrently active children,\n * batches run in order (writer serialization / path conflicts are encoded in\n * the plan's batches, which supplies the `pathConflictFreeWidth` term), and\n * heavy lanes draw permits from the PARENT's shared pool (§14.1 — a child\n * never constructs its own pool here; it receives this launcher's budget).\n *\n * §14.3 guarantees: child failure releases its permit (leak 0), parent\n * abort aborts queued permit waits and never launches unstarted lanes, and\n * the child context carries the parent decision with a width the child\n * cannot raise (§14.4: no API exists to widen — the context is read-only).\n */\n\nexport interface EffectiveLaneWidthInput {\n\treadonly planWidth: number;\n\treadonly configuredMaxParallelLanes?: number;\n\treadonly admissionMaxParallelLanes: number;\n\treadonly availableHeavyPermits: number;\n\t/** Widest conflict-free batch; the plan's batching already serializes writers. */\n\treadonly pathConflictFreeWidth: number;\n}\n\n/** §14.2: `min(plan, configured, admission, availableHeavyPermits, conflictFree)`, floor 1. */\nexport function computeEffectiveLaneWidth(input: EffectiveLaneWidthInput): number {\n\tconst configured =\n\t\tinput.configuredMaxParallelLanes !== undefined && input.configuredMaxParallelLanes > 0\n\t\t\t? input.configuredMaxParallelLanes\n\t\t\t: Number.POSITIVE_INFINITY;\n\tconst width = Math.min(\n\t\tinput.planWidth,\n\t\tconfigured,\n\t\tinput.admissionMaxParallelLanes,\n\t\tMath.max(1, input.availableHeavyPermits),\n\t\tinput.pathConflictFreeWidth,\n\t);\n\treturn Math.max(1, Math.floor(width));\n}\n\n/** Read-only budget handed to every child (§14.1). Nothing here can raise a cap. */\nexport interface SubagentLaneContext {\n\treadonly laneId: string;\n\treadonly promptRunId: string;\n\treadonly decision: ResourceAdmissionDecision;\n\treadonly effectiveLaneWidth: number;\n}\n\nexport interface LaneOutcome {\n\treadonly laneId: string;\n\treadonly status: \"completed\" | \"failed\" | \"skipped-abort\" | \"permit-rejected\";\n\treadonly diagnostic?: string;\n}\n\nexport interface LaunchSubagentLanesInput {\n\treadonly plan: SubagentOrchestrationPlan;\n\treadonly promptRunId: string;\n\treadonly decision: ResourceAdmissionDecision;\n\treadonly permitPool: WorkloadPermitPool;\n\treadonly configuredMaxParallelLanes?: number;\n\treadonly signal?: AbortSignal;\n\t/** Lane ids that run heavy work and must hold a shared permit (§14.3). */\n\treadonly heavyLaneIds?: ReadonlySet<string>;\n\t/** The actual child launcher (process spawn, SDK session, or test double). */\n\treadonly launchLane: (context: SubagentLaneContext) => Promise<void>;\n\treadonly permitWaitTimeoutMs?: number;\n}\n\nexport interface LaunchSubagentLanesResult {\n\treadonly outcomes: readonly LaneOutcome[];\n\treadonly effectiveLaneWidth: number;\n\treadonly maxObservedConcurrency: number;\n}\n\n/**\n * Execute a plan's batches with the §14.2 width as launcher authority.\n * Never throws for lane failures; the caller reads per-lane outcomes.\n */\nexport async function launchSubagentLanes(input: LaunchSubagentLanesInput): Promise<LaunchSubagentLanesResult> {\n\tconst poolSnapshot = input.permitPool.snapshot();\n\tconst effectiveLaneWidth = computeEffectiveLaneWidth({\n\t\tplanWidth: Math.max(1, input.plan.route.width),\n\t\tconfiguredMaxParallelLanes: input.configuredMaxParallelLanes,\n\t\tadmissionMaxParallelLanes: input.decision.maxParallelLanes,\n\t\tavailableHeavyPermits: Math.max(0, poolSnapshot.capacity - poolSnapshot.activeWeight),\n\t\tpathConflictFreeWidth: Math.max(1, ...input.plan.batches.map((batch) => batch.laneIds.length)),\n\t});\n\n\tconst outcomes: LaneOutcome[] = [];\n\tlet active = 0;\n\tlet maxObservedConcurrency = 0;\n\n\tfor (const batch of input.plan.batches) {\n\t\tif (input.signal?.aborted) {\n\t\t\t// Parent abort: unstarted lanes are never launched (§14.3).\n\t\t\tfor (const laneId of batch.laneIds) {\n\t\t\t\toutcomes.push({ laneId, status: \"skipped-abort\" });\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\t// Batches execute sequentially (dependency + writer serialization);\n\t\t// inside one batch, the effective width bounds the running children.\n\t\tlet cursor = 0;\n\t\tconst runners: Promise<void>[] = [];\n\t\tconst runNext = async (): Promise<void> => {\n\t\t\twhile (cursor < batch.laneIds.length) {\n\t\t\t\tconst laneId = batch.laneIds[cursor];\n\t\t\t\tcursor += 1;\n\t\t\t\tif (input.signal?.aborted) {\n\t\t\t\t\toutcomes.push({ laneId, status: \"skipped-abort\" });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\toutcomes.push(\n\t\t\t\t\tawait runLane(input, laneId, effectiveLaneWidth, {\n\t\t\t\t\t\tenter: () => {\n\t\t\t\t\t\t\tactive += 1;\n\t\t\t\t\t\t\tmaxObservedConcurrency = Math.max(maxObservedConcurrency, active);\n\t\t\t\t\t\t},\n\t\t\t\t\t\texit: () => {\n\t\t\t\t\t\t\tactive -= 1;\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\tconst workers = Math.min(effectiveLaneWidth, batch.laneIds.length);\n\t\tfor (let i = 0; i < workers; i++) {\n\t\t\trunners.push(runNext());\n\t\t}\n\t\tawait Promise.all(runners);\n\t}\n\treturn { outcomes, effectiveLaneWidth, maxObservedConcurrency };\n}\n\nasync function runLane(\n\tinput: LaunchSubagentLanesInput,\n\tlaneId: string,\n\teffectiveLaneWidth: number,\n\tgauge: { readonly enter: () => void; readonly exit: () => void },\n): Promise<LaneOutcome> {\n\tlet releasePermit: (() => void) | undefined;\n\tif (input.heavyLaneIds?.has(laneId)) {\n\t\ttry {\n\t\t\tconst permit = await input.permitPool.acquire({\n\t\t\t\trequestId: `lane-${laneId}`,\n\t\t\t\tpromptRunId: input.promptRunId,\n\t\t\t\tworkloadClass: \"heavy\",\n\t\t\t\tweight: 1,\n\t\t\t\tsignal: input.signal,\n\t\t\t\ttimeoutMs: input.permitWaitTimeoutMs ?? 60_000,\n\t\t\t});\n\t\t\treleasePermit = () => permit.release();\n\t\t} catch (error) {\n\t\t\tconst code = error instanceof WorkloadPermitError ? error.code : \"unknown\";\n\t\t\treturn {\n\t\t\t\tlaneId,\n\t\t\t\tstatus: code === \"aborted\" ? \"skipped-abort\" : \"permit-rejected\",\n\t\t\t\tdiagnostic: `permit.${code}`,\n\t\t\t};\n\t\t}\n\t}\n\tgauge.enter();\n\ttry {\n\t\tawait input.launchLane({\n\t\t\tlaneId,\n\t\t\tpromptRunId: input.promptRunId,\n\t\t\tdecision: input.decision,\n\t\t\teffectiveLaneWidth,\n\t\t});\n\t\treturn { laneId, status: \"completed\" };\n\t} catch (error) {\n\t\t// §14.3: a failing child must not leak its permit; release below.\n\t\treturn { laneId, status: \"failed\", diagnostic: String(error).slice(0, 200) };\n\t} finally {\n\t\tgauge.exit();\n\t\treleasePermit?.();\n\t}\n}\n"]}
1
+ {"version":3,"file":"subagent-lane-launcher.js","sourceRoot":"","sources":["../../src/core/subagent-lane-launcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAA2B,MAAM,2BAA2B,CAAC;AA2BzF,6FAA6F;AAC7F,MAAM,UAAU,yBAAyB,CAAC,KAA8B,EAAU;IACjF,MAAM,UAAU,GACf,KAAK,CAAC,0BAA0B,KAAK,SAAS,IAAI,KAAK,CAAC,0BAA0B,GAAG,CAAC;QACrF,C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AAE,EAAE,CAAC;IACnB,CAAC;AAAA,CACD","sourcesContent":["import type { ResourceAdmissionDecision } from \"./resource-admission.ts\";\nimport type { SubagentOrchestrationPlan } from \"./subagent-orchestration.ts\";\nimport { WorkloadPermitError, type WorkloadPermitPool } from \"./workload-permit-pool.ts\";\n\n/**\n * Subagent lane launch authority (OMK v0.97.x roadmap §14, M6/PR10).\n *\n * Turns `buildSubagentOrchestrationPlan()` output into enforced execution:\n * the §14.2 effective width is a hard cap on concurrently active children,\n * batches run in order (writer serialization / path conflicts are encoded in\n * the plan's batches, which supplies the `pathConflictFreeWidth` term), and\n * heavy lanes draw permits from the PARENT's shared pool (§14.1 — a child\n * never constructs its own pool here; it receives this launcher's budget).\n *\n * §14.3 guarantees: child failure releases its permit (leak 0), parent\n * abort aborts queued permit waits and never launches unstarted lanes, and\n * the child context carries the parent decision with a width the child\n * cannot raise (§14.4: no API exists to widen — the context is read-only).\n */\n\nexport interface EffectiveLaneWidthInput {\n\treadonly planWidth: number;\n\treadonly configuredMaxParallelLanes?: number;\n\treadonly admissionMaxParallelLanes: number;\n\treadonly availableHeavyPermits: number;\n\t/** Widest conflict-free batch; the plan's batching already serializes writers. */\n\treadonly pathConflictFreeWidth: number;\n}\n\n/** Zero authority defers execution; configured zero retains its legacy unlimited meaning. */\nexport function computeEffectiveLaneWidth(input: EffectiveLaneWidthInput): number {\n\tconst configured =\n\t\tinput.configuredMaxParallelLanes !== undefined && input.configuredMaxParallelLanes > 0\n\t\t\t? input.configuredMaxParallelLanes\n\t\t\t: Number.POSITIVE_INFINITY;\n\tconst width = Math.min(\n\t\tinput.planWidth,\n\t\tconfigured,\n\t\tinput.admissionMaxParallelLanes,\n\t\tinput.availableHeavyPermits,\n\t\tinput.pathConflictFreeWidth,\n\t);\n\treturn Number.isFinite(width) ? Math.max(0, Math.floor(width)) : 0;\n}\n\n/** Read-only budget handed to every child (§14.1). Nothing here can raise a cap. */\nexport interface SubagentLaneContext {\n\treadonly laneId: string;\n\treadonly promptRunId: string;\n\treadonly signal?: AbortSignal;\n\treadonly decision: ResourceAdmissionDecision;\n\treadonly effectiveLaneWidth: number;\n}\n\nexport interface LaneOutcome {\n\treadonly laneId: string;\n\treadonly status: \"completed\" | \"failed\" | \"cancelled\" | \"skipped-abort\" | \"permit-rejected\" | \"admission-deferred\";\n\treadonly diagnostic?: string;\n}\n\nexport interface LaunchSubagentLanesInput {\n\treadonly plan: SubagentOrchestrationPlan;\n\treadonly promptRunId: string;\n\treadonly decision: ResourceAdmissionDecision;\n\treadonly permitPool: WorkloadPermitPool;\n\treadonly configuredMaxParallelLanes?: number;\n\treadonly signal?: AbortSignal;\n\t/** Lane ids that run heavy work and must hold a shared permit (§14.3). */\n\treadonly heavyLaneIds?: ReadonlySet<string>;\n\t/** The actual child launcher (process spawn, SDK session, or test double). */\n\treadonly launchLane: (context: SubagentLaneContext) => Promise<void>;\n\treadonly permitWaitTimeoutMs?: number;\n}\n\nexport interface LaunchSubagentLanesResult {\n\treadonly outcomes: readonly LaneOutcome[];\n\treadonly effectiveLaneWidth: number;\n\treadonly maxObservedConcurrency: number;\n}\n\n/**\n * Execute a plan's batches with the §14.2 width as launcher authority.\n * Never throws for lane failures; the caller reads per-lane outcomes.\n */\nexport async function launchSubagentLanes(input: LaunchSubagentLanesInput): Promise<LaunchSubagentLanesResult> {\n\tconst poolSnapshot = input.permitPool.snapshot();\n\tconst effectiveLaneWidth = computeEffectiveLaneWidth({\n\t\tplanWidth: input.plan.route.width,\n\t\tconfiguredMaxParallelLanes: input.configuredMaxParallelLanes,\n\t\tadmissionMaxParallelLanes: input.decision.maxParallelLanes,\n\t\tavailableHeavyPermits: Math.min(\n\t\t\tMath.max(0, poolSnapshot.capacity - poolSnapshot.activeWeight),\n\t\t\tinput.heavyLaneIds?.size ? input.decision.maxHeavyProcesses : Number.POSITIVE_INFINITY,\n\t\t),\n\t\tpathConflictFreeWidth: Math.max(0, ...input.plan.batches.map((batch) => batch.laneIds.length)),\n\t});\n\n\tconst outcomes: LaneOutcome[] = [];\n\tlet active = 0;\n\tlet maxObservedConcurrency = 0;\n\n\tfor (const batch of input.plan.batches) {\n\t\tif (input.signal?.aborted || effectiveLaneWidth === 0) {\n\t\t\tfor (const laneId of batch.laneIds) {\n\t\t\t\toutcomes.push({ laneId, status: input.signal?.aborted ? \"skipped-abort\" : \"admission-deferred\" });\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\t// Batches execute sequentially (dependency + writer serialization);\n\t\t// inside one batch, the effective width bounds the running children.\n\t\tlet cursor = 0;\n\t\tconst runners: Promise<void>[] = [];\n\t\tconst runNext = async (): Promise<void> => {\n\t\t\twhile (cursor < batch.laneIds.length) {\n\t\t\t\tconst laneId = batch.laneIds[cursor];\n\t\t\t\tcursor += 1;\n\t\t\t\tif (input.signal?.aborted) {\n\t\t\t\t\toutcomes.push({ laneId, status: \"skipped-abort\" });\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\toutcomes.push(\n\t\t\t\t\tawait runLane(input, laneId, effectiveLaneWidth, {\n\t\t\t\t\t\tenter: () => {\n\t\t\t\t\t\t\tactive += 1;\n\t\t\t\t\t\t\tmaxObservedConcurrency = Math.max(maxObservedConcurrency, active);\n\t\t\t\t\t\t},\n\t\t\t\t\t\texit: () => {\n\t\t\t\t\t\t\tactive -= 1;\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\tconst workers = Math.min(effectiveLaneWidth, batch.laneIds.length);\n\t\tfor (let i = 0; i < workers; i++) {\n\t\t\trunners.push(runNext());\n\t\t}\n\t\tawait Promise.all(runners);\n\t}\n\treturn { outcomes, effectiveLaneWidth, maxObservedConcurrency };\n}\n\nasync function runLane(\n\tinput: LaunchSubagentLanesInput,\n\tlaneId: string,\n\teffectiveLaneWidth: number,\n\tgauge: { readonly enter: () => void; readonly exit: () => void },\n): Promise<LaneOutcome> {\n\tlet releasePermit: (() => void) | undefined;\n\tif (input.heavyLaneIds?.has(laneId)) {\n\t\tif (input.decision.action === \"defer-heavy\" || input.decision.maxHeavyProcesses === 0) {\n\t\t\treturn { laneId, status: \"admission-deferred\" };\n\t\t}\n\t\ttry {\n\t\t\tconst permit = await input.permitPool.acquire({\n\t\t\t\trequestId: `lane-${laneId}`,\n\t\t\t\tpromptRunId: input.promptRunId,\n\t\t\t\tworkloadClass: \"heavy\",\n\t\t\t\tweight: 1,\n\t\t\t\tsignal: input.signal,\n\t\t\t\ttimeoutMs: input.permitWaitTimeoutMs ?? 60_000,\n\t\t\t});\n\t\t\treleasePermit = () => permit.release();\n\t\t} catch (error) {\n\t\t\tconst code = error instanceof WorkloadPermitError ? error.code : \"unknown\";\n\t\t\treturn {\n\t\t\t\tlaneId,\n\t\t\t\tstatus: code === \"aborted\" ? \"skipped-abort\" : \"permit-rejected\",\n\t\t\t\tdiagnostic: `permit.${code}`,\n\t\t\t};\n\t\t}\n\t}\n\tif (input.signal?.aborted) {\n\t\treleasePermit?.();\n\t\treturn { laneId, status: \"skipped-abort\" };\n\t}\n\tgauge.enter();\n\ttry {\n\t\tawait input.launchLane({\n\t\t\tlaneId,\n\t\t\tpromptRunId: input.promptRunId,\n\t\t\tsignal: input.signal,\n\t\t\tdecision: input.decision,\n\t\t\teffectiveLaneWidth,\n\t\t});\n\t\treturn { laneId, status: input.signal?.aborted ? \"cancelled\" : \"completed\" };\n\t} catch {\n\t\t// Child error text is untrusted and may contain credentials.\n\t\treturn {\n\t\t\tlaneId,\n\t\t\tstatus: input.signal?.aborted ? \"cancelled\" : \"failed\",\n\t\t\tdiagnostic: \"lane.execution_failed\",\n\t\t};\n\t} finally {\n\t\tgauge.exit();\n\t\treleasePermit?.();\n\t}\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import type { RunContract } from "omk-protocol";
2
+ import type { NamespaceIdentity } from "./namespace-identity.ts";
3
+ export interface SandboxExecution {
4
+ readonly workspace: string;
5
+ readonly argv: readonly string[];
6
+ readonly writable: boolean;
7
+ readonly timeoutMs: number;
8
+ readonly cleanupMs: number;
9
+ readonly maxOutputBytes: number;
10
+ readonly signal?: AbortSignal;
11
+ readonly onReady?: (identity: NamespaceIdentity) => void | Promise<void>;
12
+ }
13
+ export interface SandboxOutcome {
14
+ readonly stdout: Buffer;
15
+ readonly stderr: Buffer;
16
+ readonly exitCode: number | null;
17
+ readonly failure: string | null;
18
+ readonly startedAt: string;
19
+ readonly finishedAt: string;
20
+ readonly durationMs: number;
21
+ }
22
+ export declare function commandEnvironmentDigest(contract: RunContract, driver?: "legacy" | "gated-v1"): string;
23
+ export declare function probeVerifiedSandbox(): void;
24
+ /** The only process dispatch port; close means the PID namespace and its inherited pipes have drained. */
25
+ export declare function executeSandbox(request: SandboxExecution): Promise<SandboxOutcome>;
26
+ //# sourceMappingURL=broker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broker.d.ts","sourceRoot":"","sources":["../../../src/core/verified-run/broker.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAsCjE,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzE;AACD,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAE,QAAQ,GAAG,UAAqB,GAAG,MAAM,CA0ChH;AAED,wBAAgB,oBAAoB,IAAI,IAAI,CAS3C;AAED,0GAA0G;AAC1G,wBAAsB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,CAqGvF","sourcesContent":["import { spawn, spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync, realpathSync } from \"node:fs\";\nimport { release } from \"node:os\";\nimport { performance } from \"node:perf_hooks\";\nimport type { RunContract } from \"omk-protocol\";\nimport type { NamespaceIdentity } from \"./namespace-identity.ts\";\nimport { identityFromSandboxInfo, PROCESS_GATE_ARGV } from \"./process-gate.ts\";\nimport { digestBytes, digestObject, VerifiedRunError } from \"./storage.ts\";\n\nconst BWRAP = \"/usr/bin/bwrap\";\nconst SYSTEM_ARGS = [\n\t\"--unshare-all\",\n\t\"--die-with-parent\",\n\t\"--new-session\",\n\t\"--cap-drop\",\n\t\"ALL\",\n\t\"--clearenv\",\n\t\"--ro-bind\",\n\t\"/usr\",\n\t\"/usr\",\n\t\"--symlink\",\n\t\"usr/bin\",\n\t\"/bin\",\n\t\"--symlink\",\n\t\"usr/lib\",\n\t\"/lib\",\n\t\"--symlink\",\n\t\"usr/lib64\",\n\t\"/lib64\",\n\t\"--proc\",\n\t\"/proc\",\n\t\"--dev\",\n\t\"/dev\",\n\t\"--tmpfs\",\n\t\"/tmp\",\n\t\"--setenv\",\n\t\"PATH\",\n\t\"/usr/bin:/bin\",\n\t\"--setenv\",\n\t\"LANG\",\n\t\"C.UTF-8\",\n] as const;\n\nexport interface SandboxExecution {\n\treadonly workspace: string;\n\treadonly argv: readonly string[];\n\treadonly writable: boolean;\n\treadonly timeoutMs: number;\n\treadonly cleanupMs: number;\n\treadonly maxOutputBytes: number;\n\treadonly signal?: AbortSignal;\n\treadonly onReady?: (identity: NamespaceIdentity) => void | Promise<void>;\n}\nexport interface SandboxOutcome {\n\treadonly stdout: Buffer;\n\treadonly stderr: Buffer;\n\treadonly exitCode: number | null;\n\treadonly failure: string | null;\n\treadonly startedAt: string;\n\treadonly finishedAt: string;\n\treadonly durationMs: number;\n}\n\nexport function commandEnvironmentDigest(contract: RunContract, driver: \"legacy\" | \"gated-v1\" = \"legacy\"): string {\n\tif (process.platform !== \"linux\" || !existsSync(BWRAP)) throw new VerifiedRunError(\"unsupported\");\n\tlet writers: readonly (readonly string[])[];\n\tswitch (contract.profile) {\n\t\tcase \"linux-command-v1\":\n\t\t\twriters = [contract.writer];\n\t\t\tbreak;\n\t\tcase \"linux-scripted-agent-v1\":\n\t\t\twriters = contract.writer.steps;\n\t\t\tbreak;\n\t\tcase \"linux-command-dag-v1\":\n\t\t\twriters = contract.writer.tasks.flatMap((task) => task.attempts);\n\t\t\tbreak;\n\t\tdefault: {\n\t\t\tconst exhaustive: never = contract;\n\t\t\tthrow new VerifiedRunError(String(exhaustive));\n\t\t}\n\t}\n\tconst binaries = [\n\t\t...new Set([\n\t\t\tBWRAP,\n\t\t\t...writers.map((argv) => argv[0]),\n\t\t\t...contract.checks.map((check) => check.argv[0]),\n\t\t\t...(driver === \"gated-v1\" ? [PROCESS_GATE_ARGV[0]] : []),\n\t\t]),\n\t];\n\tconst materials = binaries.map((binary) => {\n\t\tif (!binary || (!binary.startsWith(\"/usr/bin/\") && !binary.startsWith(\"/bin/\")))\n\t\t\tthrow new VerifiedRunError(\"unsupported_executable\");\n\t\tconst path = realpathSync(binary);\n\t\tif (!path.startsWith(\"/usr/\")) throw new VerifiedRunError(\"unsupported_executable\");\n\t\treturn { path, digest: digestBytes(readFileSync(path)) };\n\t});\n\treturn digestObject({\n\t\tprofile: contract.profile,\n\t\tplatform: process.platform,\n\t\tarchitecture: process.arch,\n\t\tkernel: release(),\n\t\tsandbox: SYSTEM_ARGS,\n\t\t...(driver === \"gated-v1\" ? { gate: PROCESS_GATE_ARGV, infoFd: 3 } : {}),\n\t\tbinaries: materials,\n\t});\n}\n\nexport function probeVerifiedSandbox(): void {\n\tif (process.platform !== \"linux\" || !existsSync(BWRAP)) throw new VerifiedRunError(\"unsupported\");\n\tconst probe = spawnSync(BWRAP, [...SYSTEM_ARGS, \"--\", \"/bin/true\"], {\n\t\tenv: {},\n\t\ttimeout: 3000,\n\t\tmaxBuffer: 4096,\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t});\n\tif (probe.error || probe.status !== 0) throw new VerifiedRunError(\"unsupported\");\n}\n\n/** The only process dispatch port; close means the PID namespace and its inherited pipes have drained. */\nexport async function executeSandbox(request: SandboxExecution): Promise<SandboxOutcome> {\n\tif (request.signal?.aborted) throw new VerifiedRunError(\"cancelled\");\n\tif (request.timeoutMs <= 0) throw new VerifiedRunError(\"deadline\");\n\tconst started = performance.now();\n\tconst startedAt = new Date().toISOString();\n\tconst argv = [\n\t\t...SYSTEM_ARGS,\n\t\trequest.writable ? \"--bind\" : \"--ro-bind\",\n\t\trequest.workspace,\n\t\t\"/workspace\",\n\t\t\"--chdir\",\n\t\t\"/workspace\",\n\t\t...(request.onReady ? [\"--info-fd\", \"3\", \"--\", ...PROCESS_GATE_ARGV] : [\"--\"]),\n\t\t...request.argv,\n\t];\n\treturn new Promise((resolve, reject) => {\n\t\tconst child = request.onReady\n\t\t\t? spawn(BWRAP, argv, { env: {}, stdio: [\"pipe\", \"pipe\", \"pipe\", \"pipe\"] })\n\t\t\t: spawn(BWRAP, argv, { env: {}, stdio: [\"ignore\", \"pipe\", \"pipe\"] });\n\t\tlet gateFailed = false;\n\t\tlet gateError: unknown;\n\t\tconst stdout: Buffer[] = [];\n\t\tconst stderr: Buffer[] = [];\n\t\tlet size = 0;\n\t\tlet failure: string | null = null;\n\t\tlet cleanup: ReturnType<typeof setTimeout> | undefined;\n\t\tlet finished = false;\n\t\tconst stop = (reason: string): void => {\n\t\t\tif (finished || failure) return;\n\t\t\tfailure = reason;\n\t\t\tchild.kill(\"SIGKILL\");\n\t\t\tcleanup = setTimeout(() => reject(new VerifiedRunError(\"unsettled\")), request.cleanupMs);\n\t\t};\n\t\tconst deadline = setTimeout(() => stop(\"deadline\"), request.timeoutMs);\n\t\tconst abort = (): void => stop(\"cancelled\");\n\t\trequest.signal?.addEventListener(\"abort\", abort, { once: true });\n\t\tif (request.signal?.aborted) abort();\n\t\tconst collect = (target: Buffer[], chunk: Buffer): void => {\n\t\t\tif (failure) return;\n\t\t\tsize += chunk.length;\n\t\t\tif (size > request.maxOutputBytes) {\n\t\t\t\tstop(\"output_limit\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttarget.push(chunk);\n\t\t};\n\t\tchild.stdout?.on(\"data\", (chunk: Buffer) => collect(stdout, chunk));\n\t\tchild.stderr?.on(\"data\", (chunk: Buffer) => collect(stderr, chunk));\n\t\tif (request.onReady) {\n\t\t\tconst info = child.stdio[3];\n\t\t\tlet metadata = \"\";\n\t\t\tif (!info || !child.stdin) {\n\t\t\t\tgateFailed = true;\n\t\t\t\tgateError = new VerifiedRunError(\"process_identity\");\n\t\t\t\tstop(\"process_identity\");\n\t\t\t} else {\n\t\t\t\tchild.stdin.on(\"error\", () => stop(\"execution_failed\"));\n\t\t\t\tinfo.on(\"data\", (chunk: Buffer) => {\n\t\t\t\t\tmetadata += chunk.toString(\"utf8\");\n\t\t\t\t\tif (metadata.length > 4096) stop(\"process_identity\");\n\t\t\t\t});\n\t\t\t\tinfo.once(\"end\", async () => {\n\t\t\t\t\tif (finished || failure) return;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait request.onReady?.(identityFromSandboxInfo(metadata));\n\t\t\t\t\t\tif (performance.now() - started >= request.timeoutMs || request.signal?.aborted)\n\t\t\t\t\t\t\tstop(request.signal?.aborted ? \"cancelled\" : \"deadline\");\n\t\t\t\t\t\tif (!finished && !failure) child.stdin?.end(\"go\\n\");\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tgateFailed = true;\n\t\t\t\t\t\tgateError = error;\n\t\t\t\t\t\tstop(\"process_identity\");\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tchild.once(\"error\", () => {\n\t\t\tfailure = \"execution_failed\";\n\t\t});\n\t\tchild.once(\"close\", (exitCode) => {\n\t\t\tfinished = true;\n\t\t\tclearTimeout(deadline);\n\t\t\tclearTimeout(cleanup);\n\t\t\trequest.signal?.removeEventListener(\"abort\", abort);\n\t\t\tif (gateFailed) {\n\t\t\t\treject(gateError);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst durationMs = Math.max(0, Math.round(performance.now() - started));\n\t\t\tresolve({\n\t\t\t\tstdout: Buffer.concat(stdout),\n\t\t\t\tstderr: Buffer.concat(stderr),\n\t\t\t\texitCode,\n\t\t\t\tfailure: failure ?? (exitCode === 0 ? null : \"execution_failed\"),\n\t\t\t\tstartedAt,\n\t\t\t\t// Project the finish instant from the start's wall reference and monotonic elapsed time.\n\t\t\t\tfinishedAt: new Date(Date.parse(startedAt) + durationMs).toISOString(),\n\t\t\t\tdurationMs,\n\t\t\t});\n\t\t});\n\t});\n}\n"]}