pi-better-server 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/package.json +7 -3
  2. package/scripts/copy-pi-test-providers.mjs +10 -0
  3. package/scripts/event-publication/README.md +26 -0
  4. package/scripts/event-publication/commit.mjs +21 -0
  5. package/scripts/event-publication/measure.mjs +37 -5
  6. package/scripts/event-publication/writer.mjs +3 -8
  7. package/scripts/measure-full-runtime/frontend.ts +10 -2
  8. package/scripts/measure-full-runtime/probe.mjs +4 -2
  9. package/scripts/measure-full-runtime/recovery-trace-loader.mjs +51 -0
  10. package/scripts/measure-full-runtime/recovery-trace.mjs +16 -0
  11. package/scripts/measure-full-runtime.mjs +2 -0
  12. package/scripts/measure-shared-reads.mjs +2 -1
  13. package/scripts/private-runtime/package-lock.json +18 -0
  14. package/scripts/private-runtime/package.json +4 -1
  15. package/scripts/source-provenance.mjs +2 -2
  16. package/scripts/test-on-pi.sh +2 -9
  17. package/src/handshake.ts +1 -1
  18. package/src/hosted-session.ts +32 -4
  19. package/src/maintenance.ts +35 -7
  20. package/src/registry.ts +28 -4
  21. package/src/runtime/attempt-invalidation.ts +54 -0
  22. package/src/runtime/background-history.ts +151 -45
  23. package/src/runtime/background-policy.ts +9 -4
  24. package/src/runtime/background-tools.ts +181 -27
  25. package/src/runtime/background.ts +365 -70
  26. package/src/runtime/cancellation.ts +28 -7
  27. package/src/runtime/catalog-sources.ts +199 -0
  28. package/src/runtime/catalog.ts +53 -21
  29. package/src/runtime/client.ts +22 -2
  30. package/src/runtime/domain/assignment-inbox.mjs +119 -0
  31. package/src/runtime/domain/assignment-observation.d.mts +1 -1
  32. package/src/runtime/domain/assignment-observation.mjs +43 -35
  33. package/src/runtime/domain/background/process-identity.mjs +20 -2
  34. package/src/runtime/domain/background/process.mjs +52 -14
  35. package/src/runtime/domain/background/registry.mjs +61 -3
  36. package/src/runtime/domain/background/supervisor/store.mjs +3 -3
  37. package/src/runtime/domain/background/supervisor/supervisor.mjs +9 -3
  38. package/src/runtime/domain/background/types.mjs +1 -0
  39. package/src/runtime/domain/background-service/adapter-contract.domain.mjs +1 -1
  40. package/src/runtime/domain/background-service/adapter-contract.ts +1 -1
  41. package/src/runtime/domain/background-service/goal-provider.domain.mjs +35 -16
  42. package/src/runtime/domain/background-service/goal-provider.ts +31 -16
  43. package/src/runtime/domain/background-service/index.domain.mjs +25 -9
  44. package/src/runtime/domain/background-service/index.ts +25 -9
  45. package/src/runtime/domain/background-service/managed-authority.domain.mjs +6 -3
  46. package/src/runtime/domain/background-service/managed-authority.ts +5 -3
  47. package/src/runtime/domain/background-service/managed-client.domain.mjs +21 -7
  48. package/src/runtime/domain/background-service/managed-client.ts +20 -7
  49. package/src/runtime/domain/background-service/managed-frontend.domain.mjs +159 -19
  50. package/src/runtime/domain/background-service/managed-frontend.ts +135 -19
  51. package/src/runtime/domain/background-service/navigator-provider.domain.mjs +21 -5
  52. package/src/runtime/domain/background-service/navigator-provider.ts +19 -5
  53. package/src/runtime/domain/background-service/observed-wait-client.domain.mjs +6 -0
  54. package/src/runtime/domain/background-service/observed-wait-client.ts +10 -0
  55. package/src/runtime/domain/background-service/observed-waits.domain.mjs +372 -57
  56. package/src/runtime/domain/background-service/observed-waits.ts +321 -53
  57. package/src/runtime/domain/background-service/process-identity.domain.mjs +20 -2
  58. package/src/runtime/domain/background-service/process-identity.ts +18 -2
  59. package/src/runtime/domain/background-service/process.domain.mjs +52 -14
  60. package/src/runtime/domain/background-service/process.ts +48 -14
  61. package/src/runtime/domain/background-service/registry.domain.mjs +61 -3
  62. package/src/runtime/domain/background-service/registry.ts +53 -5
  63. package/src/runtime/domain/background-service/review-settings.domain.mjs +16 -0
  64. package/src/runtime/domain/background-service/review-settings.ts +18 -0
  65. package/src/runtime/domain/background-service/runtime.domain.mjs +40 -86
  66. package/src/runtime/domain/background-service/runtime.ts +27 -82
  67. package/src/runtime/domain/background-service/sandbox.domain.mjs +14 -15
  68. package/src/runtime/domain/background-service/sandbox.ts +14 -11
  69. package/src/runtime/domain/background-service/shared-callback-batcher.domain.mjs +8 -1
  70. package/src/runtime/domain/background-service/shared-callback-batcher.ts +11 -2
  71. package/src/runtime/domain/background-service/shared-navigator-panels.domain.mjs +24 -2
  72. package/src/runtime/domain/background-service/shared-navigator-panels.ts +26 -4
  73. package/src/runtime/domain/background-service/shared-navigator.domain.mjs +273 -41
  74. package/src/runtime/domain/background-service/shared-navigator.ts +244 -40
  75. package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-inbox.mjs +144 -0
  76. package/src/runtime/domain/background-service/shared-operation-coordinator/assignment-observation.mjs +53 -41
  77. package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
  78. package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-changes.ts +73 -0
  79. package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +2 -0
  80. package/src/runtime/domain/background-service/shared-operation-coordinator/src/assignment-outcomes.ts +2 -0
  81. package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.domain.mjs +11 -2
  82. package/src/runtime/domain/background-service/shared-operation-coordinator/src/background-requests.ts +14 -3
  83. package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.domain.mjs +4 -2
  84. package/src/runtime/domain/background-service/shared-operation-coordinator/src/discovery.ts +5 -3
  85. package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.domain.mjs +44 -4
  86. package/src/runtime/domain/background-service/shared-operation-coordinator/src/operations.ts +50 -2
  87. package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.domain.mjs +7 -0
  88. package/src/runtime/domain/background-service/shared-operation-coordinator/src/outbox.ts +9 -0
  89. package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.domain.mjs +12 -0
  90. package/src/runtime/domain/background-service/shared-operation-coordinator/src/result-supervision.ts +12 -0
  91. package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.domain.mjs +2 -0
  92. package/src/runtime/domain/background-service/shared-operation-coordinator/src/rows.ts +2 -0
  93. package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.domain.mjs +42 -21
  94. package/src/runtime/domain/background-service/shared-operation-coordinator/src/schema.ts +40 -24
  95. package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.domain.mjs +26 -4
  96. package/src/runtime/domain/background-service/shared-operation-coordinator/src/store.ts +40 -8
  97. package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.domain.mjs +23 -1
  98. package/src/runtime/domain/background-service/shared-operation-coordinator/src/subagent-launch.ts +24 -1
  99. package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.domain.mjs +1 -1
  100. package/src/runtime/domain/background-service/shared-operation-coordinator/src/types.ts +5 -1
  101. package/src/runtime/domain/background-service/shared-sandbox-core.ts +1 -1
  102. package/src/runtime/domain/background-service/shared-work-client.mjs +174 -7
  103. package/src/runtime/domain/background-service/stall.domain.mjs +5 -3
  104. package/src/runtime/domain/background-service/stall.ts +7 -4
  105. package/src/runtime/domain/background-service/supervised-progress.domain.mjs +42 -0
  106. package/src/runtime/domain/background-service/supervised-progress.ts +43 -0
  107. package/src/runtime/domain/background-service/supervisor/README.md +1 -4
  108. package/src/runtime/domain/background-service/supervisor/emit-runner.mjs +1 -0
  109. package/src/runtime/domain/background-service/supervisor/generated/process-identity.mjs +20 -2
  110. package/src/runtime/domain/background-service/supervisor/generated/process.mjs +52 -14
  111. package/src/runtime/domain/background-service/supervisor/generated/runner.mjs +47 -4
  112. package/src/runtime/domain/background-service/supervisor/generated/store.mjs +3 -3
  113. package/src/runtime/domain/background-service/supervisor/generated/watch-fingerprint.mjs +69 -0
  114. package/src/runtime/domain/background-service/supervisor/runner.domain.mjs +47 -4
  115. package/src/runtime/domain/background-service/supervisor/runner.ts +38 -3
  116. package/src/runtime/domain/background-service/supervisor/store.domain.mjs +3 -3
  117. package/src/runtime/domain/background-service/supervisor/store.ts +3 -3
  118. package/src/runtime/domain/background-service/supervisor/supervisor.domain.mjs +9 -3
  119. package/src/runtime/domain/background-service/supervisor/supervisor.ts +6 -3
  120. package/src/runtime/domain/background-service/task-diagnostics.domain.mjs +1 -1
  121. package/src/runtime/domain/background-service/task-diagnostics.ts +1 -1
  122. package/src/runtime/domain/background-service/tools.domain.mjs +53 -40
  123. package/src/runtime/domain/background-service/tools.ts +67 -54
  124. package/src/runtime/domain/background-service/types.domain.mjs +1 -0
  125. package/src/runtime/domain/background-service/types.ts +7 -3
  126. package/src/runtime/domain/background-service/watch-fingerprint.domain.mjs +67 -0
  127. package/src/runtime/domain/background-service/watch-fingerprint.ts +70 -0
  128. package/src/runtime/domain/background-service/work-observation.domain.mjs +46 -20
  129. package/src/runtime/domain/background-service/work-observation.ts +46 -19
  130. package/src/runtime/domain/catalog/catalog-store.d.mts +9 -1
  131. package/src/runtime/domain/catalog/catalog-store.mjs +20 -22
  132. package/src/runtime/domain/coordinator/src/assignment-changes.mjs +75 -0
  133. package/src/runtime/domain/coordinator/src/assignment-outcomes.mjs +2 -0
  134. package/src/runtime/domain/coordinator/src/background-requests.mjs +11 -2
  135. package/src/runtime/domain/coordinator/src/discovery.mjs +4 -2
  136. package/src/runtime/domain/coordinator/src/operations.mjs +44 -4
  137. package/src/runtime/domain/coordinator/src/outbox.mjs +7 -0
  138. package/src/runtime/domain/coordinator/src/result-supervision.mjs +12 -0
  139. package/src/runtime/domain/coordinator/src/rows.mjs +2 -0
  140. package/src/runtime/domain/coordinator/src/schema.mjs +42 -21
  141. package/src/runtime/domain/coordinator/src/store.mjs +26 -4
  142. package/src/runtime/domain/coordinator/src/subagent-launch.mjs +23 -1
  143. package/src/runtime/domain/coordinator/src/types.mjs +1 -1
  144. package/src/runtime/domain/health-observation.d.mts +3 -1
  145. package/src/runtime/domain/health-observation.mjs +189 -190
  146. package/src/runtime/domain/log-cursor.d.mts +2 -0
  147. package/src/runtime/domain/log-cursor.mjs +85 -16
  148. package/src/runtime/domain/log-paths.mjs +8 -1
  149. package/src/runtime/domain/parse.d.mts +4 -1
  150. package/src/runtime/domain/parse.mjs +58 -9
  151. package/src/runtime/domain/sandbox-policy/README.md +63 -65
  152. package/src/runtime/domain/sandbox-policy/commands.domain.mjs +11 -8
  153. package/src/runtime/domain/sandbox-policy/commands.ts +12 -7
  154. package/src/runtime/domain/sandbox-policy/index.domain.mjs +53 -9
  155. package/src/runtime/domain/sandbox-policy/index.ts +52 -9
  156. package/src/runtime/domain/sandbox-policy/package.json +1 -1
  157. package/src/runtime/domain/sandbox-policy/permission-settings.domain.mjs +5 -2
  158. package/src/runtime/domain/sandbox-policy/permission-settings.ts +9 -2
  159. package/src/runtime/domain/sandbox-policy/permissions-page.domain.mjs +56 -137
  160. package/src/runtime/domain/sandbox-policy/permissions-page.ts +52 -130
  161. package/src/runtime/domain/sandbox-policy/permissions.domain.mjs +1 -6
  162. package/src/runtime/domain/sandbox-policy/permissions.ts +1 -6
  163. package/src/runtime/domain/sandbox-policy/shared-sandbox-core.ts +1 -1
  164. package/src/runtime/domain/sandbox-policy/shared-task-exec.domain.mjs +14 -1
  165. package/src/runtime/domain/sandbox-policy/shared-task-exec.ts +12 -1
  166. package/src/runtime/domain/sandbox-policy/shared-task-process-identity.domain.mjs +140 -0
  167. package/src/runtime/domain/sandbox-policy/shared-task-process-identity.ts +126 -0
  168. package/src/runtime/domain/sandbox-policy/shared-task-process-list.domain.mjs +3 -2
  169. package/src/runtime/domain/sandbox-policy/shared-task-process-list.ts +8 -2
  170. package/src/runtime/domain/sandbox-policy/shared-task-sandbox.domain.mjs +4 -3
  171. package/src/runtime/domain/sandbox-policy/shared-task-sandbox.ts +5 -3
  172. package/src/runtime/domain/sandbox-policy/shared-task-tools.domain.mjs +8 -5
  173. package/src/runtime/domain/sandbox-policy/shared-task-tools.ts +8 -5
  174. package/src/runtime/domain/session-store.mjs +7 -0
  175. package/src/runtime/domain/subagents/README.md +13 -11
  176. package/src/runtime/domain/subagents/assignment-outcomes.domain.mjs +10 -7
  177. package/src/runtime/domain/subagents/assignment-outcomes.ts +9 -6
  178. package/src/runtime/domain/subagents/assignment-report.domain.mjs +109 -24
  179. package/src/runtime/domain/subagents/assignment-report.ts +103 -19
  180. package/src/runtime/domain/subagents/batch.mjs +13 -5
  181. package/src/runtime/domain/subagents/catalog-host-admission.domain.mjs +21 -3
  182. package/src/runtime/domain/subagents/catalog-host-admission.ts +19 -3
  183. package/src/runtime/domain/subagents/catalog-preferences.ts +1 -1
  184. package/src/runtime/domain/subagents/catalog-resolver.domain.mjs +35 -1
  185. package/src/runtime/domain/subagents/catalog-resolver.ts +35 -1
  186. package/src/runtime/domain/subagents/catalog-store.domain.mjs +20 -22
  187. package/src/runtime/domain/subagents/catalog-store.ts +27 -20
  188. package/src/runtime/domain/subagents/child-apply-patch.domain.mjs +13 -0
  189. package/src/runtime/domain/subagents/child-apply-patch.ts +13 -0
  190. package/src/runtime/domain/subagents/child-dependencies.mjs +27 -15
  191. package/src/runtime/domain/subagents/child-operations.domain.mjs +80 -2
  192. package/src/runtime/domain/subagents/child-operations.ts +80 -1
  193. package/src/runtime/domain/subagents/child-preflight.mjs +9 -2
  194. package/src/runtime/domain/subagents/child-process-list.domain.mjs +7 -0
  195. package/src/runtime/domain/subagents/child-process-list.ts +8 -0
  196. package/src/runtime/domain/subagents/cleanup.domain.mjs +11 -2
  197. package/src/runtime/domain/subagents/cleanup.ts +10 -2
  198. package/src/runtime/domain/subagents/config.domain.mjs +54 -2
  199. package/src/runtime/domain/subagents/config.ts +53 -3
  200. package/src/runtime/domain/subagents/continuation-authority.domain.mjs +5 -1
  201. package/src/runtime/domain/subagents/continuation-authority.ts +3 -1
  202. package/src/runtime/domain/subagents/continuation-runtime.domain.mjs +89 -0
  203. package/src/runtime/domain/subagents/continuation-runtime.ts +88 -0
  204. package/src/runtime/domain/subagents/continuation.domain.mjs +4 -2
  205. package/src/runtime/domain/subagents/continuation.ts +4 -2
  206. package/src/runtime/domain/subagents/extensions.mjs +11 -13
  207. package/src/runtime/domain/subagents/failures.domain.mjs +11 -2
  208. package/src/runtime/domain/subagents/failures.ts +10 -2
  209. package/src/runtime/domain/subagents/finalization.domain.mjs +16 -1
  210. package/src/runtime/domain/subagents/finalization.ts +21 -1
  211. package/src/runtime/domain/subagents/goal-provider.domain.mjs +44 -2
  212. package/src/runtime/domain/subagents/goal-provider.ts +44 -2
  213. package/src/runtime/domain/subagents/health-observation.domain.mjs +189 -190
  214. package/src/runtime/domain/subagents/health-observation.ts +43 -48
  215. package/src/runtime/domain/subagents/index.domain.mjs +457 -182
  216. package/src/runtime/domain/subagents/index.ts +417 -155
  217. package/src/runtime/domain/subagents/isolated-workspace.domain.mjs +515 -0
  218. package/src/runtime/domain/subagents/isolated-workspace.ts +557 -0
  219. package/src/runtime/domain/subagents/launch-context.domain.mjs +24 -0
  220. package/src/runtime/domain/subagents/launch-context.ts +23 -0
  221. package/src/runtime/domain/subagents/launch-digest.mjs +6 -0
  222. package/src/runtime/domain/subagents/list.mjs +2 -2
  223. package/src/runtime/domain/subagents/log-cursor.domain.mjs +85 -16
  224. package/src/runtime/domain/subagents/log-cursor.ts +91 -15
  225. package/src/runtime/domain/subagents/managed-launch-bootstrap.mjs +2 -2
  226. package/src/runtime/domain/subagents/managed-launch-client.domain.mjs +27 -7
  227. package/src/runtime/domain/subagents/managed-launch-client.ts +28 -8
  228. package/src/runtime/domain/subagents/managed-launch-host.domain.mjs +222 -14
  229. package/src/runtime/domain/subagents/managed-launch-host.ts +168 -15
  230. package/src/runtime/domain/subagents/managed-launch-journal.mjs +1 -5
  231. package/src/runtime/domain/subagents/managed-launch-port.ts +4 -0
  232. package/src/runtime/domain/subagents/operation-bridge-types.domain.mjs +27 -2
  233. package/src/runtime/domain/subagents/operation-bridge-types.ts +27 -2
  234. package/src/runtime/domain/subagents/output-payload.domain.mjs +24 -9
  235. package/src/runtime/domain/subagents/output-payload.ts +26 -12
  236. package/src/runtime/domain/subagents/owned-exit.domain.mjs +12 -0
  237. package/src/runtime/domain/subagents/owned-exit.ts +12 -0
  238. package/src/runtime/domain/subagents/package.json +4 -2
  239. package/src/runtime/domain/subagents/parse.domain.mjs +58 -9
  240. package/src/runtime/domain/subagents/parse.ts +57 -10
  241. package/src/runtime/domain/subagents/permission-policy.domain.mjs +32 -8
  242. package/src/runtime/domain/subagents/permission-policy.ts +41 -8
  243. package/src/runtime/domain/subagents/process-identity.mjs +33 -0
  244. package/src/runtime/domain/subagents/registry.domain.mjs +71 -51
  245. package/src/runtime/domain/subagents/registry.ts +77 -38
  246. package/src/runtime/domain/subagents/retained-result.domain.mjs +56 -0
  247. package/src/runtime/domain/subagents/retained-result.ts +65 -0
  248. package/src/runtime/domain/subagents/session-selection.domain.mjs +3 -1
  249. package/src/runtime/domain/subagents/session-selection.ts +2 -1
  250. package/src/runtime/domain/subagents/session-store.domain.mjs +7 -0
  251. package/src/runtime/domain/subagents/session-store.ts +9 -0
  252. package/src/runtime/domain/subagents/settings-page.domain.mjs +151 -107
  253. package/src/runtime/domain/subagents/settings-page.ts +147 -108
  254. package/src/runtime/domain/subagents/shared-callback-batcher.domain.mjs +8 -1
  255. package/src/runtime/domain/subagents/shared-callback-batcher.ts +11 -2
  256. package/src/runtime/domain/subagents/shared-catalog.domain.mjs +28 -29
  257. package/src/runtime/domain/subagents/shared-catalog.ts +29 -21
  258. package/src/runtime/domain/subagents/shared-navigator-panels.domain.mjs +24 -2
  259. package/src/runtime/domain/subagents/shared-navigator-panels.ts +26 -4
  260. package/src/runtime/domain/subagents/shared-navigator.domain.mjs +273 -41
  261. package/src/runtime/domain/subagents/shared-navigator.ts +244 -40
  262. package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-inbox.mjs +144 -0
  263. package/src/runtime/domain/subagents/shared-operation-coordinator/assignment-observation.mjs +53 -41
  264. package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.domain.mjs +75 -0
  265. package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-changes.ts +73 -0
  266. package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.domain.mjs +2 -0
  267. package/src/runtime/domain/subagents/shared-operation-coordinator/src/assignment-outcomes.ts +2 -0
  268. package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.domain.mjs +11 -2
  269. package/src/runtime/domain/subagents/shared-operation-coordinator/src/background-requests.ts +14 -3
  270. package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.domain.mjs +4 -2
  271. package/src/runtime/domain/subagents/shared-operation-coordinator/src/discovery.ts +5 -3
  272. package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.domain.mjs +44 -4
  273. package/src/runtime/domain/subagents/shared-operation-coordinator/src/operations.ts +50 -2
  274. package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.domain.mjs +7 -0
  275. package/src/runtime/domain/subagents/shared-operation-coordinator/src/outbox.ts +9 -0
  276. package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.domain.mjs +12 -0
  277. package/src/runtime/domain/subagents/shared-operation-coordinator/src/result-supervision.ts +12 -0
  278. package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.domain.mjs +2 -0
  279. package/src/runtime/domain/subagents/shared-operation-coordinator/src/rows.ts +2 -0
  280. package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.domain.mjs +42 -21
  281. package/src/runtime/domain/subagents/shared-operation-coordinator/src/schema.ts +40 -24
  282. package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.domain.mjs +26 -4
  283. package/src/runtime/domain/subagents/shared-operation-coordinator/src/store.ts +40 -8
  284. package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.domain.mjs +23 -1
  285. package/src/runtime/domain/subagents/shared-operation-coordinator/src/subagent-launch.ts +24 -1
  286. package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.domain.mjs +1 -1
  287. package/src/runtime/domain/subagents/shared-operation-coordinator/src/types.ts +5 -1
  288. package/src/runtime/domain/subagents/shared-sandbox-core.ts +1 -1
  289. package/src/runtime/domain/subagents/shared-task-exec.domain.mjs +14 -1
  290. package/src/runtime/domain/subagents/shared-task-exec.ts +12 -1
  291. package/src/runtime/domain/subagents/shared-task-process-identity.domain.mjs +140 -0
  292. package/src/runtime/domain/subagents/shared-task-process-identity.ts +126 -0
  293. package/src/runtime/domain/subagents/shared-task-process-list.domain.mjs +3 -2
  294. package/src/runtime/domain/subagents/shared-task-process-list.ts +8 -2
  295. package/src/runtime/domain/subagents/shared-task-sandbox.domain.mjs +4 -3
  296. package/src/runtime/domain/subagents/shared-task-sandbox.ts +5 -3
  297. package/src/runtime/domain/subagents/shared-task-tools.domain.mjs +8 -5
  298. package/src/runtime/domain/subagents/shared-task-tools.ts +8 -5
  299. package/src/runtime/domain/subagents/shared-work-client.mjs +174 -7
  300. package/src/runtime/domain/subagents/subagent-tools.domain.mjs +22 -38
  301. package/src/runtime/domain/subagents/subagent-tools.ts +28 -34
  302. package/src/runtime/domain/subagents/task-guard.domain.mjs +14 -1
  303. package/src/runtime/domain/subagents/task-guard.ts +13 -1
  304. package/src/runtime/domain/subagents/task-policy.domain.mjs +3 -2
  305. package/src/runtime/domain/subagents/task-policy.ts +8 -2
  306. package/src/runtime/domain/subagents/timing.domain.mjs +10 -1
  307. package/src/runtime/domain/subagents/timing.ts +10 -1
  308. package/src/runtime/domain/subagents/tools.domain.mjs +4 -8
  309. package/src/runtime/domain/subagents/tools.ts +4 -7
  310. package/src/runtime/domain/subagents/work-observation.domain.mjs +102 -17
  311. package/src/runtime/domain/subagents/work-observation.ts +91 -17
  312. package/src/runtime/domain/subagents/worker-operations-host.domain.mjs +9 -4
  313. package/src/runtime/domain/subagents/worker-operations-host.ts +12 -4
  314. package/src/runtime/domain/subagents/worker-waits.domain.mjs +89 -35
  315. package/src/runtime/domain/subagents/worker-waits.ts +93 -34
  316. package/src/runtime/domain/subagents/workspace-files.domain.mjs +103 -0
  317. package/src/runtime/domain/subagents/workspace-files.ts +114 -0
  318. package/src/runtime/domain/subagents/workspace-scope.domain.d.mts +38 -0
  319. package/src/runtime/domain/subagents/workspace-scope.domain.mjs +5 -0
  320. package/src/runtime/domain/subagents/workspace-scope.ts +6 -0
  321. package/src/runtime/domain/subagents/worktree-feedback.domain.mjs +55 -0
  322. package/src/runtime/domain/subagents/worktree-feedback.ts +77 -0
  323. package/src/runtime/health-config.ts +27 -11
  324. package/src/runtime/log-checkpoints.ts +117 -0
  325. package/src/runtime/mutation-store.ts +5 -4
  326. package/src/runtime/queries.ts +25 -2
  327. package/src/runtime/query-executor.ts +149 -28
  328. package/src/runtime/query-worker.mjs +106 -21
  329. package/src/runtime/read-model.ts +849 -121
  330. package/src/runtime/read-watchdog-probe.ts +4 -0
  331. package/src/runtime/result-supervision.ts +188 -16
  332. package/src/runtime/root.ts +5 -2
  333. package/src/runtime/source-watch.ts +175 -0
  334. package/src/runtime/subagent-launch.ts +11 -4
  335. package/src/runtime/work-budget.ts +130 -0
  336. package/src/runtime/work-client.d.mts +8 -0
  337. package/src/runtime/work-client.mjs +150 -7
  338. package/src/server.ts +104 -23
  339. package/src/session-activity.ts +26 -4
  340. package/src/version.ts +1 -1
@@ -0,0 +1,75 @@
1
+ // Generated canonical coordinator. Do not edit directly.
2
+ /** Additive observation journal. Triggers also cover already-running old writers. */
3
+ export function ensureAssignmentChanges(ctx) {
4
+ ctx.transaction(() => {
5
+ ctx.db.exec(`CREATE TABLE IF NOT EXISTS assignment_change_source (
6
+ singleton INTEGER PRIMARY KEY CHECK(singleton=1), generation TEXT NOT NULL);
7
+ INSERT OR IGNORE INTO assignment_change_source VALUES(1, lower(hex(randomblob(16))));
8
+ CREATE TABLE IF NOT EXISTS assignment_changes (
9
+ seq INTEGER PRIMARY KEY AUTOINCREMENT, entity TEXT NOT NULL, entity_id TEXT NOT NULL DEFAULT '',
10
+ assignment_id TEXT, session_id TEXT NOT NULL, workspace TEXT NOT NULL,
11
+ changed_at INTEGER NOT NULL DEFAULT (unixepoch()*1000));
12
+ CREATE INDEX IF NOT EXISTS waits_assignment_observation ON waits
13
+ (owner_kind,owner_session_id,owner_workspace,json_extract(origin_json,'$.assignmentRef'),created_at DESC,generation DESC);
14
+ CREATE INDEX IF NOT EXISTS resume_claims_wait_observation ON resume_claims(wait_id,generation,attempt_id);
15
+ CREATE TABLE IF NOT EXISTS background_input_versions (
16
+ operation_id TEXT PRIMARY KEY, revision INTEGER NOT NULL);
17
+ CREATE TRIGGER IF NOT EXISTS assignment_changes_retention AFTER INSERT ON assignment_changes
18
+ BEGIN DELETE FROM assignment_changes WHERE seq <= NEW.seq - 4096; END;`);
19
+ // Repair is an operation-ID keyset, not an observer equality lookup.
20
+ // A leading observer column competes with the ordered recent-terminal index.
21
+ if (ctx.db.prepare("PRAGMA index_info(background_operation_repair)").all().length > 1)
22
+ ctx.db.exec("DROP INDEX background_operation_repair");
23
+ ctx.db.exec("CREATE INDEX IF NOT EXISTS background_operation_repair ON operations(operation_id) WHERE observer_kind='local-supervisor'");
24
+ const sources = [
25
+ { table: "waits", select: (r) => `SELECT 'wait', ${r}.wait_id || ':' || ${r}.generation, json_extract(${r}.origin_json,'$.assignmentRef'), ${r}.owner_session_id, ${r}.owner_workspace WHERE ${r}.owner_kind='worker-conversation'` },
26
+ { table: "resume_claims", select: (r) => `SELECT 'claim', ${r}.claim_id, json_extract(w.origin_json,'$.assignmentRef'), w.owner_session_id, w.owner_workspace FROM waits w WHERE w.wait_id=${r}.wait_id AND w.generation=${r}.generation AND w.owner_kind='worker-conversation'` },
27
+ { table: "assignment_bindings", select: (r) => `SELECT 'binding', ${r}.assignment_id, ${r}.assignment_id, json_extract(${r}.owner_json,'$.sessionId'), json_extract(${r}.owner_json,'$.workspace')` },
28
+ { table: "assignment_attempts", select: (r) => `SELECT 'attempt', ${r}.attempt_id, b.assignment_id, json_extract(b.owner_json,'$.sessionId'), json_extract(b.owner_json,'$.workspace') FROM assignment_bindings b WHERE b.assignment_id=${r}.assignment_id` },
29
+ { table: "assignment_outcomes", select: (r) => `SELECT 'outcome', ${r}.assignment_id, ${r}.assignment_id, json_extract(${r}.record_json,'$.owner.sessionId'), json_extract(${r}.record_json,'$.owner.workspace')` },
30
+ { table: "outbox_events", select: (r) => `SELECT 'receipt', ${r}.event_id, b.assignment_id, json_extract(b.owner_json,'$.sessionId'), json_extract(b.owner_json,'$.workspace') FROM assignment_bindings b WHERE b.assignment_id=${r}.operation_id UNION ALL SELECT 'receipt', ${r}.event_id, json_extract(w.origin_json,'$.assignmentRef'), w.owner_session_id, w.owner_workspace FROM waits w WHERE w.wait_id=${r}.wait_id AND w.generation=${r}.generation AND w.owner_kind='worker-conversation'` },
31
+ ];
32
+ for (const { table, select } of sources)
33
+ for (const action of ["INSERT", "UPDATE", "DELETE"]) {
34
+ const records = action === "UPDATE" ? ["OLD", "NEW"] : [action === "DELETE" ? "OLD" : "NEW"];
35
+ ctx.db.exec(`CREATE TRIGGER IF NOT EXISTS assignment_change_${table}_${action.toLowerCase()} AFTER ${action} ON ${table} BEGIN ${records.map(r => `INSERT INTO assignment_changes(entity,entity_id,assignment_id,session_id,workspace) ${select(r)};`).join(" ")} END;`);
36
+ }
37
+ // These are observation inputs, not execution or delivery authority. Old
38
+ // cooperative SQL writers inherit the same atomic invalidation triggers.
39
+ const backgroundSources = [
40
+ { table: "operations", select: (r) => `SELECT ${r}.operation_id, 1 WHERE ${r}.observer_kind='local-supervisor'` },
41
+ { table: "waits", select: (r) => `SELECT d.operation_id, 1 FROM wait_dependencies d JOIN operations o ON o.operation_id=d.operation_id WHERE d.wait_id=${r}.wait_id AND d.generation=${r}.generation AND o.observer_kind='local-supervisor'` },
42
+ { table: "wait_dependencies", select: (r) => `SELECT ${r}.operation_id, 1 WHERE EXISTS(SELECT 1 FROM operations o WHERE o.operation_id=${r}.operation_id AND o.observer_kind='local-supervisor')` },
43
+ { table: "background_parent_callbacks", select: (r) => `SELECT ${r}.operation_id, 1 WHERE 1` },
44
+ { table: "coordinator_state", select: (r) => `SELECT o.operation_id, 1 FROM operations o WHERE ${r}.key LIKE 'result-supervision-v1:%' AND o.operation_id=substr(${r}.key,length('result-supervision-v1:')+1) AND o.observer_kind='local-supervisor'` },
45
+ ];
46
+ // Version 1 installed one-column SELECTs into a two-column INSERT. Replace
47
+ // only these owned triggers, atomically, without resetting source positions.
48
+ const replaceBackgroundTriggers = ctx.db.prepare("SELECT value FROM schema_meta WHERE key='background_input_triggers_version'").get()?.value !== "2";
49
+ for (const { table, select } of backgroundSources)
50
+ for (const action of ["INSERT", "UPDATE", "DELETE"]) {
51
+ if (replaceBackgroundTriggers)
52
+ ctx.db.exec(`DROP TRIGGER IF EXISTS background_input_${table}_${action.toLowerCase()}`);
53
+ const records = action === "UPDATE" ? ["OLD", "NEW"] : [action === "DELETE" ? "OLD" : "NEW"];
54
+ ctx.db.exec(`CREATE TRIGGER IF NOT EXISTS background_input_${table}_${action.toLowerCase()}
55
+ ${action === "DELETE" ? "BEFORE" : "AFTER"} ${action} ON ${table} BEGIN
56
+ ${records.map(r => `INSERT INTO background_input_versions(operation_id,revision) ${select(r)}
57
+ ON CONFLICT(operation_id) DO UPDATE SET revision=revision+1;`).join(" ")}
58
+ END;`);
59
+ }
60
+ if (replaceBackgroundTriggers)
61
+ ctx.db.prepare("INSERT OR REPLACE INTO schema_meta(key,value) VALUES('background_input_triggers_version','2')").run();
62
+ ctx.db.exec(`CREATE TRIGGER IF NOT EXISTS background_journal_insert AFTER INSERT ON background_input_versions BEGIN
63
+ INSERT INTO assignment_changes(entity,entity_id,assignment_id,session_id,workspace)
64
+ SELECT 'background:operation', NEW.operation_id, NEW.operation_id, owner_session_id, owner_workspace FROM operations WHERE operation_id=NEW.operation_id;
65
+ END;
66
+ CREATE TRIGGER IF NOT EXISTS background_journal_update AFTER UPDATE ON background_input_versions BEGIN
67
+ INSERT INTO assignment_changes(entity,entity_id,assignment_id,session_id,workspace)
68
+ SELECT 'background:operation', NEW.operation_id, NEW.operation_id, owner_session_id, owner_workspace FROM operations WHERE operation_id=NEW.operation_id;
69
+ END;
70
+ CREATE TRIGGER IF NOT EXISTS background_journal_previous_scope AFTER UPDATE ON operations
71
+ WHEN OLD.observer_kind='local-supervisor' AND (OLD.owner_session_id<>NEW.owner_session_id OR OLD.owner_workspace<>NEW.owner_workspace OR OLD.owner_kind<>NEW.owner_kind)
72
+ BEGIN INSERT INTO assignment_changes(entity,entity_id,assignment_id,session_id,workspace)
73
+ VALUES('background:operation',OLD.operation_id,OLD.operation_id,OLD.owner_session_id,OLD.owner_workspace); END;`);
74
+ });
75
+ }
@@ -1,5 +1,6 @@
1
1
  // Generated canonical coordinator. Do not edit directly.
2
2
  import { createHash, randomUUID } from "node:crypto";
3
+ import { bumpChangeRevision } from "./discovery.mjs";
3
4
  import { StoreError } from "./errors.mjs";
4
5
  import { columnText, getRow, getRows, run } from "./sqlite.mjs";
5
6
  import { requireWait, readPins } from "./rows.mjs";
@@ -107,6 +108,7 @@ export function recordAssignmentOutcome(ctx, input) {
107
108
  for (const e of retained)
108
109
  run(ctx, `INSERT OR IGNORE INTO evidence_pins (pin_id, wait_id, generation, operation_id, terminal_revision, kind, ref, summary, detail_lost, bytes, pinned_at) VALUES (?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?)`, `pin_${randomUUID()}`, eventId, e.operationId, e.terminalRevision, e.kind, e.ref, e.summary ?? null, e.detailLost ? 1 : 0, e.bytes ?? null, at);
109
110
  run(ctx, `INSERT INTO outbox_events (event_id, event_type, operation_id, terminal_revision, wait_id, generation, recipient_kind, recipient_session_id, recipient_workspace, recipient_branch_id, recipient_goal_id, state, created_at) VALUES (?, 'assignment-outcome', ?, ?, ?, 1, ?, ?, ?, ?, ?, 'pending', ?)`, eventId, assignmentId, revision, eventId, recipient.kind, recipient.sessionId, recipient.workspace, recipient.branchId ?? null, recipient.goalId ?? null, at);
111
+ bumpChangeRevision(ctx);
110
112
  return record;
111
113
  });
112
114
  }
@@ -23,7 +23,7 @@ export class BackgroundRequests {
23
23
  write(value) {
24
24
  this.context.db.prepare('INSERT OR REPLACE INTO coordinator_state (key,value) VALUES (?,?)').run(storageKey(value.owner, value.key), JSON.stringify(value));
25
25
  }
26
- accept(owner, key, digest) {
26
+ accept(owner, key, digest, writerFence) {
27
27
  this.alive();
28
28
  return this.context.transaction(() => {
29
29
  const prior = this.read(owner, key);
@@ -32,7 +32,7 @@ export class BackgroundRequests {
32
32
  throw new Error('request-conflict: Background request key changed content');
33
33
  return { prior: true, record: prior };
34
34
  }
35
- const record = { owner, key, digest, state: 'accepted', operations: [] };
35
+ const record = { owner, key, digest, state: 'accepted', operations: [], acceptedAt: Date.now(), lastProgressAt: Date.now(), writerFence };
36
36
  this.write(record);
37
37
  return { prior: false, record };
38
38
  });
@@ -61,9 +61,18 @@ export class BackgroundRequests {
61
61
  if (!value)
62
62
  throw new Error('Background request not admitted');
63
63
  change(value);
64
+ value.lastProgressAt = Date.now();
64
65
  this.write(value);
65
66
  });
66
67
  }
68
+ lifecycleReasons() {
69
+ return this.pending().map(record => ({ kind: 'task', id: storageKey(record.owner, record.key),
70
+ owner: record.owner, state: record.state, acceptedAt: record.acceptedAt ?? null,
71
+ writerFence: record.writerFence ?? null,
72
+ lastProgressAt: record.lastProgressAt ?? null, executionDeadline: null, nextDeadline: null,
73
+ operations: record.operations.map(({ operationId, taskId }) => ({ operationId, taskId })),
74
+ recovery: 'drain-accepted-background-request-until-journal-return-or-authoritative-handoff' }));
75
+ }
67
76
  hasPending() {
68
77
  this.alive();
69
78
  return Boolean(this.context.db.prepare(`SELECT 1 FROM coordinator_state INDEXED BY background_requests_pending WHERE ${pendingPredicate} LIMIT 1`).get());
@@ -35,9 +35,11 @@ export function readDiscoveryClaim(ctx, scope) {
35
35
  /** Read scope transfer and its discovery claim from one SQLite snapshot. */
36
36
  export function readDiscoveryState(ctx, scope) {
37
37
  scope = requireId("scope", scope);
38
- const row = getRow(ctx, `SELECT d.*, EXISTS(SELECT 1 FROM coordinator_state WHERE key = ?) AS managed
38
+ const row = getRow(ctx, `SELECT d.*, EXISTS(SELECT 1 FROM coordinator_state WHERE key = ?) AS managed,
39
+ EXISTS(SELECT 1 FROM operations INDEXED BY operations_assignment_cleanup
40
+ WHERE assignment_attempt_id IS NOT NULL) AS has_assignment_tasks
39
41
  FROM (SELECT 1) LEFT JOIN discovery_claims d ON d.scope = ?`, "result-scope-v1:" + scope, scope);
40
- return { managed: Number(row.managed) === 1, claim: row.scope == null ? null : mapClaim(row) };
42
+ return { managed: Number(row.managed) === 1, claim: row.scope == null ? null : mapClaim(row), hasAssignmentTasks: Number(row.has_assignment_tasks) === 1 };
41
43
  }
42
44
  export function tryClaimDiscovery(ctx, input) {
43
45
  const scope = requireId("scope", input.scope);
@@ -13,13 +13,14 @@
13
13
  */
14
14
  import { StoreError } from "./errors.mjs";
15
15
  import { mapOperation, ownerFromRow, readOperation, requireOperation } from "./rows.mjs";
16
- import { columnText, getRows, isUniqueViolation, run, } from "./sqlite.mjs";
17
- import { describeOwnerDiff, normalizeOwner, optionalText, requireBoolean, requireEnum, requireEvidenceKind, requireId, requireObserver, requireOptionalCounter, requireText, sameOwner, } from "./validate.mjs";
16
+ import { columnJson, columnText, getRow, getRows, isUniqueViolation, run, } from "./sqlite.mjs";
17
+ import { describeOwnerDiff, normalizeOwner, optionalText, requireBoolean, requireCounter, requireEnum, requireEvidenceKind, requireId, requireObserver, requireOptionalCounter, requireText, sameOwner, } from "./validate.mjs";
18
18
  import { mapOutbox } from "./rows.mjs";
19
19
  import { settleWaitsForOperation } from "./waits.mjs";
20
20
  import { bumpChangeRevision } from "./discovery.mjs";
21
21
  const HEALTH_VALUES = ["active", "unmonitored", "lost"];
22
22
  const OUTCOME_VALUES = ["succeeded", "failed", "cancelled", "lost"];
23
+ const ASSIGNMENT_CLEANUP_PAGE_MAX = 256;
23
24
  function normalizeSupervision(value) {
24
25
  if (value === undefined || value === null)
25
26
  return null;
@@ -69,6 +70,9 @@ export function registerOperation(ctx, input) {
69
70
  const taskId = requireId("taskId", input.taskId);
70
71
  const launchToken = requireId("launchToken", input.launchToken);
71
72
  const owner = normalizeOwner("owner", input.owner);
73
+ const assignmentAttemptId = input.assignmentAttemptId === undefined
74
+ ? undefined
75
+ : requireId("assignmentAttemptId", input.assignmentAttemptId);
72
76
  const observer = requireObserver("observer", input.observer);
73
77
  const supervision = normalizeSupervision(input.supervision);
74
78
  const authorityRef = optionalText("authorityRef", input.authorityRef, 512);
@@ -89,6 +93,8 @@ export function registerOperation(ctx, input) {
89
93
  differences.push("taskId");
90
94
  if (existing.launchToken !== launchToken)
91
95
  differences.push("launchToken");
96
+ if (existing.assignmentAttemptId !== assignmentAttemptId)
97
+ differences.push("assignmentAttemptId");
92
98
  if (!sameOwner(existing.owner, owner)) {
93
99
  differences.push(`owner (${describeOwnerDiff(existing.owner, owner)})`);
94
100
  }
@@ -106,14 +112,28 @@ export function registerOperation(ctx, input) {
106
112
  return { operation: existing, created: false };
107
113
  }
108
114
  assertTaskAvailable();
115
+ if (assignmentAttemptId !== undefined) {
116
+ const binding = getRow(ctx, `SELECT b.owner_json, o.assignment_id AS terminal_assignment_id
117
+ FROM assignment_attempts a
118
+ JOIN assignment_bindings b ON b.assignment_id = a.assignment_id
119
+ LEFT JOIN assignment_outcomes o ON o.assignment_id = a.assignment_id
120
+ WHERE a.attempt_id = ?`, assignmentAttemptId);
121
+ const capturedOwner = binding && columnJson(binding, "owner_json");
122
+ if (!binding || !capturedOwner || !sameOwner(capturedOwner, owner)) {
123
+ throw new StoreError("foreign-owner", "Operation owner must match the captured owner of a registered assignment attempt.");
124
+ }
125
+ if (binding.terminal_assignment_id !== null) {
126
+ throw new StoreError("validation", "A terminal assignment cannot register a new operation.");
127
+ }
128
+ }
109
129
  const at = ctx.now();
110
130
  try {
111
131
  run(ctx, `INSERT INTO operations (
112
132
  operation_id, task_id, launch_token,
113
- owner_kind, owner_session_id, owner_workspace, owner_branch_id, owner_goal_id,
133
+ owner_kind, owner_session_id, owner_workspace, owner_branch_id, owner_goal_id, assignment_attempt_id,
114
134
  observer_kind, observer_version, supervision_json, supervision_host_id, authority_ref, intent_ref,
115
135
  phase, health, health_reason, terminal_revision, created_at, updated_at
116
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'running', 'active', NULL, 0, ?, ?)`, operationId, taskId, launchToken, owner.kind, owner.sessionId, owner.workspace, owner.branchId ?? null, owner.goalId ?? null, observer.kind, observer.version, supervision ? JSON.stringify(supervision) : null, supervision?.hostId ?? null, authorityRef, intentRef, at, at);
136
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'running', 'active', NULL, 0, ?, ?)`, operationId, taskId, launchToken, owner.kind, owner.sessionId, owner.workspace, owner.branchId ?? null, owner.goalId ?? null, assignmentAttemptId ?? null, observer.kind, observer.version, supervision ? JSON.stringify(supervision) : null, supervision?.hostId ?? null, authorityRef, intentRef, at, at);
117
137
  }
118
138
  catch (error) {
119
139
  // Another process may have registered the same launch (or the same task)
@@ -292,6 +312,26 @@ export function listOperations(ctx, filter = {}) {
292
312
  return getRows(ctx, `SELECT *, EXISTS(SELECT 1 FROM coordinator_state s WHERE s.key = 'result-supervision-v1:' || operations.operation_id) AS result_managed FROM operations ${where} ORDER BY created_at, operation_id`, ...params)
293
313
  .map(row => ({ ...mapOperation(row), resultManaged: Number(row.result_managed) === 1 }));
294
314
  }
315
+ export function listAssignmentCleanupOperations(ctx, limit, afterOperationId) {
316
+ const requested = requireCounter("limit", limit);
317
+ if (requested === 0)
318
+ throw new StoreError("validation", "Invalid limit: must be at least 1");
319
+ const cursor = afterOperationId === undefined ? "" : requireId("afterOperationId", afterOperationId);
320
+ // Seek the partial index in cursor order rather than sorting all running operations.
321
+ return getRows(ctx, `SELECT op.*, EXISTS(SELECT 1 FROM coordinator_state s
322
+ WHERE s.key = 'result-supervision-v1:' || op.operation_id) AS result_managed
323
+ FROM operations op INDEXED BY operations_assignment_cleanup
324
+ JOIN assignment_attempts a ON a.attempt_id = op.assignment_attempt_id
325
+ JOIN assignment_outcomes o ON o.assignment_id = a.assignment_id
326
+ WHERE op.assignment_attempt_id IS NOT NULL AND op.operation_id > ?
327
+ AND (op.terminal_revision = 0 OR op.terminal_outcome = 'lost'
328
+ OR EXISTS (SELECT 1 FROM operation_evidence e WHERE e.operation_id = op.operation_id
329
+ AND e.terminal_revision = op.terminal_revision AND e.kind = 'terminal-record'
330
+ AND e.summary LIKE '%groupCleanup=unproven%'))
331
+ AND NOT EXISTS (SELECT 1 FROM coordinator_state s WHERE s.key = 'assignment-cleanup-verified:' || op.operation_id)
332
+ ORDER BY op.operation_id LIMIT ?`, cursor, Math.min(requested, ASSIGNMENT_CLEANUP_PAGE_MAX))
333
+ .map(row => ({ ...mapOperation(row), resultManaged: Number(row.result_managed) === 1 }));
334
+ }
295
335
  /** Running operations assigned to one supervising host, using the phase/host index. */
296
336
  export function listRunningSupervisedBy(ctx, hostId) {
297
337
  return getRows(ctx, "SELECT *, EXISTS(SELECT 1 FROM coordinator_state s WHERE s.key = 'result-supervision-v1:' || operations.operation_id) AS result_managed FROM operations WHERE phase = 'running' AND supervision_host_id = ? ORDER BY created_at, operation_id", requireId("hostId", hostId)).map(row => ({ ...mapOperation(row), resultManaged: Number(row.result_managed) === 1 }));
@@ -155,6 +155,13 @@ export function listOutbox(ctx, filter = {}) {
155
155
  const where = clauses.length > 0 ? `WHERE ${clauses.join(" AND ")}` : "";
156
156
  return getRows(ctx, `SELECT * FROM outbox_events ${where} ORDER BY created_at, event_id`, ...params).map((row) => mapOutbox(ctx, row));
157
157
  }
158
+ /** Check a wait handoff without loading the retained evidence for its generations. */
159
+ export function hasDeliveredWaitDependency(ctx, operationId, terminalRevision, recipient) {
160
+ const owner = ownerClause("recipient", recipient);
161
+ return getRows(ctx, `SELECT 1 FROM outbox_events
162
+ WHERE operation_id = ? AND terminal_revision = ? AND event_type = 'dependency-ready'
163
+ AND delivered_at IS NOT NULL AND ${owner.sql} LIMIT 1`, requireId("operationId", operationId), requireCounter("terminalRevision", terminalRevision), ...owner.params).length > 0;
164
+ }
158
165
  /** Find recipients with deliverable dependencies without loading each event's evidence. */
159
166
  export function listDispatchableOutboxRecipients(ctx) {
160
167
  return getRows(ctx, `SELECT recipient_kind, recipient_session_id, recipient_workspace, recipient_branch_id, recipient_goal_id,
@@ -4,6 +4,18 @@ import { getRow, run } from "./sqlite.mjs";
4
4
  import { getOperation, recordSupervision, recordTerminalOutcome } from "./operations.mjs";
5
5
  import { requireId, requirePath } from "./validate.mjs";
6
6
  const PREFIX = "result-supervision-v1:";
7
+ /** A bounded observation page. A gap requires restoring active authority, not history. */
8
+ export function resultSupervisionChanges(ctx, after) {
9
+ const generation = String(ctx.db.prepare("SELECT generation FROM assignment_change_source WHERE singleton=1").get().generation);
10
+ const bounds = ctx.db.prepare("SELECT min(seq) AS first, max(seq) AS last FROM assignment_changes").get();
11
+ const last = Number(bounds.last ?? 0);
12
+ const reset = !after || after.generation !== generation || after.seq > last
13
+ || (bounds.first !== null && after.seq < Number(bounds.first) - 1);
14
+ const rows = reset ? [] : ctx.db.prepare("SELECT seq, entity, entity_id FROM assignment_changes WHERE seq>? ORDER BY seq LIMIT 128").all(after.seq);
15
+ const seq = reset ? last : Number(rows.at(-1)?.seq ?? after.seq);
16
+ return { generation, seq, reset, more: seq < last,
17
+ operationIds: [...new Set(rows.filter(row => row.entity === "background:operation").map(row => String(row.entity_id)))] };
18
+ }
7
19
  export function resultSupervisions(ctx, activeOnly = false) {
8
20
  const rows = activeOnly
9
21
  ? ctx.db.prepare("SELECT s.value FROM operations o JOIN coordinator_state s ON s.key = ? || o.operation_id WHERE o.phase = 'running'").all(PREFIX)
@@ -27,11 +27,13 @@ export function getOperationRowByTask(ctx, taskId) {
27
27
  return getRow(ctx, "SELECT * FROM operations WHERE task_id = ?", taskId);
28
28
  }
29
29
  export function mapOperation(row) {
30
+ const assignmentAttemptId = columnNullableText(row, "assignment_attempt_id");
30
31
  return {
31
32
  operationId: columnText(row, "operation_id"),
32
33
  taskId: columnText(row, "task_id"),
33
34
  launchToken: columnText(row, "launch_token"),
34
35
  owner: ownerFromRow(row),
36
+ ...(assignmentAttemptId === null ? {} : { assignmentAttemptId }),
35
37
  observer: {
36
38
  kind: columnText(row, "observer_kind"),
37
39
  version: columnText(row, "observer_version"),
@@ -1,6 +1,6 @@
1
1
  // Generated canonical coordinator. Do not edit directly.
2
2
  /**
3
- * Schema v4 for the durable operation coordinator.
3
+ * Schema v5 for the durable operation coordinator.
4
4
  *
5
5
  * The store refuses to open a database whose recorded version it does not
6
6
  * understand, and leaves the file untouched. An unreadable or newer database
@@ -54,6 +54,14 @@ const BACKGROUND_CALLBACK_DDL = [
54
54
  SELECT 1,'',COALESCE(MAX(operation_id),''),CASE WHEN MAX(operation_id) IS NULL THEN 1 ELSE 0 END
55
55
  FROM operations WHERE owner_kind='parent-session' AND observer_kind='local-supervisor'`,
56
56
  ];
57
+ const ASSIGNMENT_ATTEMPTS_DDL = `CREATE TABLE IF NOT EXISTS assignment_attempts (
58
+ attempt_id TEXT PRIMARY KEY,
59
+ assignment_id TEXT NOT NULL REFERENCES assignment_bindings (assignment_id)
60
+ )`;
61
+ const ASSIGNMENT_ATTEMPT_COLUMN = `assignment_attempt_id TEXT REFERENCES assignment_attempts (attempt_id)`;
62
+ const ASSIGNMENT_CLEANUP_INDEX = `CREATE INDEX IF NOT EXISTS operations_assignment_cleanup
63
+ ON operations (operation_id, assignment_attempt_id)
64
+ WHERE assignment_attempt_id IS NOT NULL`;
57
65
  const DDL = [
58
66
  `CREATE TABLE task_cancellation_authorities (
59
67
  credential_hash TEXT PRIMARY KEY,
@@ -90,6 +98,7 @@ const DDL = [
90
98
  owner_workspace TEXT NOT NULL,
91
99
  owner_branch_id TEXT,
92
100
  owner_goal_id TEXT,
101
+ ${ASSIGNMENT_ATTEMPT_COLUMN},
93
102
  observer_kind TEXT NOT NULL,
94
103
  observer_version TEXT NOT NULL,
95
104
  supervision_json TEXT,
@@ -112,6 +121,7 @@ const DDL = [
112
121
  `CREATE INDEX operations_owner ON operations (owner_kind, owner_session_id)`,
113
122
  `CREATE INDEX operations_phase ON operations (phase)`,
114
123
  `CREATE INDEX operations_running_supervisor ON operations (phase, supervision_host_id)`,
124
+ ASSIGNMENT_CLEANUP_INDEX,
115
125
  // Discovery leadership is separate from per-operation supervision. The token
116
126
  // fences stale acquisition and release; the host id is checked with process
117
127
  // identity before a replacement.
@@ -265,10 +275,7 @@ const DDL = [
265
275
  owner_json TEXT NOT NULL,
266
276
  recipient_json TEXT NOT NULL
267
277
  )`,
268
- `CREATE TABLE assignment_attempts (
269
- attempt_id TEXT PRIMARY KEY,
270
- assignment_id TEXT NOT NULL REFERENCES assignment_bindings (assignment_id)
271
- )`,
278
+ ASSIGNMENT_ATTEMPTS_DDL,
272
279
  `CREATE TABLE assignment_outcome_waits (
273
280
  assignment_id TEXT NOT NULL REFERENCES assignment_outcomes (assignment_id),
274
281
  wait_id TEXT NOT NULL,
@@ -312,17 +319,16 @@ export function ensureSchema(ctx) {
312
319
  throw new StoreError("schema-version", `The database was written by schema version ${recorded}; this build understands version ${SCHEMA_VERSION}. Upgrade the harness instead of downgrading the records.`);
313
320
  }
314
321
  if (recorded < SCHEMA_VERSION) {
315
- if (recorded === 3) {
316
- ctx.transaction(() => {
317
- ensureAdditiveSchema(ctx);
318
- ctx.db.exec(DDL.find((sql) => sql.startsWith("CREATE TABLE assignment_repairs")));
319
- run(ctx, "UPDATE schema_meta SET value = ? WHERE key = ?", String(SCHEMA_VERSION), SCHEMA_VERSION_KEY);
320
- });
321
- return;
322
- }
323
- if (recorded === 1 || recorded === 2) {
322
+ ctx.transaction(() => {
323
+ // Another opener may have finished the upgrade before we acquired the write lock.
324
+ const current = readSchemaVersion(ctx);
325
+ if (current === SCHEMA_VERSION)
326
+ return;
327
+ if (current !== recorded) {
328
+ throw new StoreError("schema-version", "The coordinator schema changed during opening. Reopen the store to verify it.");
329
+ }
324
330
  ensureAdditiveSchema(ctx);
325
- ctx.transaction(() => {
331
+ if (recorded <= 2) {
326
332
  if (recorded === 1)
327
333
  ctx.db.exec("ALTER TABLE outbox_events ADD COLUMN event_type TEXT NOT NULL DEFAULT 'dependency-ready'");
328
334
  for (const statement of DDL.filter((sql) => sql.startsWith("CREATE TABLE assignment_")))
@@ -331,14 +337,29 @@ export function ensureSchema(ctx) {
331
337
  ctx.db.exec("UPDATE waits SET dispatch_disarmed = 1 WHERE EXISTS (SELECT 1 FROM assignment_outcome_waits aw WHERE aw.wait_id = waits.wait_id AND aw.generation = waits.generation)");
332
338
  ctx.db.exec("DROP INDEX waits_one_pending_per_owner");
333
339
  ctx.db.exec(DDL.find((sql) => sql.startsWith("CREATE UNIQUE INDEX waits_one_pending_per_owner")));
334
- run(ctx, "UPDATE schema_meta SET value = ? WHERE key = ?", String(SCHEMA_VERSION), SCHEMA_VERSION_KEY);
335
- });
336
- return;
337
- }
338
- throw new StoreError("schema-version", `The database is at schema version ${recorded}; this build needs version ${SCHEMA_VERSION}. No migration is provided for this pair; records are left in place.`);
340
+ }
341
+ else if (recorded === 3) {
342
+ ctx.db.exec(DDL.find((sql) => sql.startsWith("CREATE TABLE assignment_repairs")));
343
+ }
344
+ ensureAssignmentCleanupSchema(ctx);
345
+ run(ctx, "UPDATE schema_meta SET value = ? WHERE key = ?", String(SCHEMA_VERSION), SCHEMA_VERSION_KEY);
346
+ });
347
+ return;
339
348
  }
340
349
  ensureAdditiveSchema(ctx);
341
- ctx.db.exec(DDL.find((sql) => sql.startsWith("CREATE TABLE assignment_attempts")).replace("CREATE TABLE", "CREATE TABLE IF NOT EXISTS"));
350
+ ensureAssignmentCleanupSchema(ctx);
351
+ }
352
+ function ensureAssignmentCleanupSchema(ctx) {
353
+ const hasColumn = () => getRows(ctx, "PRAGMA table_info(operations)").some(row => row.name === "assignment_attempt_id");
354
+ if (hasColumn() && getRow(ctx, "SELECT 1 FROM sqlite_master WHERE name = 'operations_assignment_cleanup'"))
355
+ return;
356
+ ctx.transaction(() => {
357
+ ctx.db.exec(ASSIGNMENT_ATTEMPTS_DDL);
358
+ // Legacy writers leave the nullable provenance unset.
359
+ if (!hasColumn())
360
+ ctx.db.exec(`ALTER TABLE operations ADD COLUMN ${ASSIGNMENT_ATTEMPT_COLUMN}`);
361
+ ctx.db.exec(ASSIGNMENT_CLEANUP_INDEX);
362
+ });
342
363
  }
343
364
  /**
344
365
  * Schema version 1 is extended additively: older readers ignore the new column,
@@ -12,17 +12,18 @@ import { setParentCallbackPending, listPendingParentCallbacks, listRecentBackgro
12
12
  import { BackgroundRequests } from "./background-requests.mjs";
13
13
  import { StoreError } from "./errors.mjs";
14
14
  import { SubagentLaunchJournal } from "./subagent-launch.mjs";
15
- import { resultSupervision, resultSupervisions, resultScopeManaged, handoffResultScope, handoffResultSupervision, handoffResultSupervisions, recoverResultSupervision, publishSupervisedResult } from "./result-supervision.mjs";
15
+ import { resultSupervisionChanges, resultSupervision, resultSupervisions, resultScopeManaged, handoffResultScope, handoffResultSupervision, handoffResultSupervisions, recoverResultSupervision, publishSupervisedResult } from "./result-supervision.mjs";
16
16
  import { acceptTaskCancellation, getTaskCancellation, recordTaskStopRequested, admitTaskCancellation, authorizedTaskCancellation, finishTaskCancellation, cancellationRuntimeEpoch, acceptAuthorizedTaskCancellation, taskCancellationManaged, pendingTaskCancellations, finishTaskCancellationIntent, unknownTaskCancellation } from "./task-cancellation.mjs";
17
17
  import { repairFailedResume } from "./recovery.mjs";
18
18
  import { recordAssignmentOutcome, getAssignmentOutcome, inspectAssignmentOutcome, consumeAssignmentOutcome, registerAssignment, receiptAssignmentOutcome } from "./assignment-outcomes.mjs";
19
19
  import { describeOwnerDiff, normalizeOwner, requireCounter, requireId, requirePath, } from "./validate.mjs";
20
20
  import { ensureSchema } from "./schema.mjs";
21
- import { createContext, openDatabase } from "./sqlite.mjs";
22
- import { getOperation as readOperationRecord, listOperations as readOperationRecords, listRunningSupervisedBy as readRunningSupervisedBy, releaseSupervision as writeSupervisionRelease, recordSupervision as writeSupervision, recordTerminalOutcome as writeTerminalOutcome, registerOperation as writeOperation, } from "./operations.mjs";
21
+ import { ensureAssignmentChanges } from "./assignment-changes.mjs";
22
+ import { createContext, openDatabase, run } from "./sqlite.mjs";
23
+ import { getOperation as readOperationRecord, listAssignmentCleanupOperations as readAssignmentCleanupOperations, listOperations as readOperationRecords, listRunningSupervisedBy as readRunningSupervisedBy, releaseSupervision as writeSupervisionRelease, recordSupervision as writeSupervision, recordTerminalOutcome as writeTerminalOutcome, registerOperation as writeOperation, } from "./operations.mjs";
23
24
  import { getChangeRevision as readChangeRevision, readDiscoveryClaim as readClaim, readDiscoveryState, releaseDiscoveryClaim as deleteDiscoveryClaim, tryClaimDiscovery as writeDiscoveryClaim, } from "./discovery.mjs";
24
25
  import { acknowledgeResult as writeAcknowledgement, cancelWait as writeCancellation, claimResume as writeClaim, findPendingWaitForOwner, getWait as readWait, listDependencies as readDependencies, listEvidencePins as readPins, listEvidenceReads as readReads, listResumeClaims as readClaims, listUnreconciledClaims, listWaits as readWaits, publishResumeAttempt as writeAttemptPublication, recordEvidencePin as writePin, recordEvidenceRead as writeRead, registerWait as writeWait, releaseEvidencePins as writePinRelease, holdFailedResume as writeHoldFailedResume, releaseResumeClaim as writeClaimRelease, transitionWaitPhase as writePhase, } from "./waits.mjs";
25
- import { claimOutbox as writeOutboxClaim, listDispatchableOutboxRecipients as readDispatchableOutboxRecipients, listOutbox as readOutbox, markOutboxDelivered as writeOutboxDelivery, releaseOutbox as writeOutboxRelease, } from "./outbox.mjs";
26
+ import { claimOutbox as writeOutboxClaim, hasDeliveredWaitDependency as readDeliveredWaitDependency, listDispatchableOutboxRecipients as readDispatchableOutboxRecipients, listOutbox as readOutbox, markOutboxDelivered as writeOutboxDelivery, releaseOutbox as writeOutboxRelease, } from "./outbox.mjs";
26
27
  import { readOperationEvidence } from "./rows.mjs";
27
28
  import { SCHEMA_VERSION, } from "./types.mjs";
28
29
  export function openStore(options) {
@@ -31,6 +32,7 @@ export function openStore(options) {
31
32
  const ctx = createContext(db, options.now ? { now: options.now } : {});
32
33
  try {
33
34
  ensureSchema(ctx);
35
+ ensureAssignmentChanges(ctx);
34
36
  }
35
37
  catch (error) {
36
38
  try {
@@ -52,6 +54,8 @@ export function openStore(options) {
52
54
  resultScopeManaged(scope) { alive(); return resultScopeManaged(ctx, scope); },
53
55
  handoffResultScope(input) { alive(); return handoffResultScope(ctx, input); },
54
56
  resultSupervision(id) { alive(); return resultSupervision(ctx, id); },
57
+ hasSubagentManagement() { alive(); return Boolean(ctx.db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='subagent_management'").get()); },
58
+ resultSupervisionChanges(after) { alive(); return resultSupervisionChanges(ctx, after); },
55
59
  resultSupervisions(activeOnly) { alive(); return resultSupervisions(ctx, activeOnly); },
56
60
  handoffResultSupervision(input) { alive(); return handoffResultSupervision(ctx, input); },
57
61
  handoffResultSupervisions(input) { alive(); return handoffResultSupervisions(ctx, input); },
@@ -110,6 +114,20 @@ export function openStore(options) {
110
114
  alive();
111
115
  return readOperationRecords(ctx, filter);
112
116
  },
117
+ listAssignmentCleanupOperations(limit, afterOperationId) {
118
+ alive();
119
+ return readAssignmentCleanupOperations(ctx, limit, afterOperationId);
120
+ },
121
+ verifyAssignmentCleanup(operationId, launchToken, terminalRevision) {
122
+ alive();
123
+ if (!Number.isSafeInteger(terminalRevision) || terminalRevision < 1)
124
+ return false;
125
+ return run(ctx, `INSERT OR IGNORE INTO coordinator_state (key, value)
126
+ SELECT 'assignment-cleanup-verified:' || op.operation_id, op.launch_token
127
+ FROM operations op JOIN assignment_attempts a ON a.attempt_id = op.assignment_attempt_id
128
+ JOIN assignment_outcomes o ON o.assignment_id = a.assignment_id
129
+ WHERE op.operation_id = ? AND op.launch_token = ? AND op.terminal_revision = ?`, operationId, launchToken, terminalRevision) > 0;
130
+ },
113
131
  listRunningSupervisedBy(hostId) {
114
132
  alive();
115
133
  return readRunningSupervisedBy(ctx, hostId);
@@ -231,6 +249,10 @@ export function openStore(options) {
231
249
  alive();
232
250
  return readOutbox(ctx, filter);
233
251
  },
252
+ hasDeliveredWaitDependency(operationId, terminalRevision, recipient) {
253
+ alive();
254
+ return readDeliveredWaitDependency(ctx, operationId, terminalRevision, recipient);
255
+ },
234
256
  listDispatchableOutboxRecipients() {
235
257
  alive();
236
258
  return readDispatchableOutboxRecipients(ctx);
@@ -1,5 +1,5 @@
1
1
  // Generated canonical coordinator. Do not edit directly.
2
- import { randomBytes } from "node:crypto";
2
+ import { createHash, randomBytes } from "node:crypto";
3
3
  /** Fixed launch journal on the coordinator's existing connection and transaction. */
4
4
  export class SubagentLaunchJournal {
5
5
  context;
@@ -40,6 +40,25 @@ export class SubagentLaunchJournal {
40
40
  pendingIntents() {
41
41
  return this.db.prepare("SELECT * FROM subagent_launch_intents WHERE state='accepted'").all();
42
42
  }
43
+ progressKey(owner, key) { return `launch-progress:${createHash('sha256').update(JSON.stringify([owner, key])).digest('hex')}`; }
44
+ progress(owner, key) {
45
+ const row = this.db.prepare('SELECT value FROM coordinator_state WHERE key=?').get(this.progressKey(owner, key));
46
+ return row ? JSON.parse(String(row.value)) : undefined;
47
+ }
48
+ noteProgress(owner, key) {
49
+ const previous = this.progress(owner, key), now = Date.now();
50
+ this.db.prepare('INSERT OR REPLACE INTO coordinator_state (key,value) VALUES (?,?)').run(this.progressKey(owner, key), JSON.stringify({ acceptedAt: previous?.acceptedAt ?? now, lastProgressAt: now }));
51
+ }
52
+ lifecycleReasons(owner, key) {
53
+ const exact = owner !== undefined && key !== undefined ? this.read(owner, key) : undefined;
54
+ const intents = owner !== undefined ? exact?.state === 'accepted' ? [exact] : [] : this.pendingIntents();
55
+ return intents.map(intent => ({ kind: 'task', id: this.progressKey(intent.owner, intent.request_key),
56
+ owner: intent.owner, management: { epoch: intent.epoch }, acceptedAt: this.progress(intent.owner, intent.request_key)?.acceptedAt ?? null,
57
+ lastProgressAt: this.progress(intent.owner, intent.request_key)?.lastProgressAt ?? null, executionDeadline: null, nextDeadline: null,
58
+ attempts: JSON.parse(intent.attempts).map(attempt => ({ id: attempt.id, sessionId: attempt.sessionId,
59
+ state: attempt.state, writer: { pid: attempt.writerPid ?? attempt.pid, start: attempt.writerStartTime ?? attempt.pidStartTime } })),
60
+ recovery: 'drain-accepted-launch-until-journal-return-or-authoritative-handoff' }));
61
+ }
43
62
  finishRecovery(owner, key, epoch, result) {
44
63
  this.transaction(() => {
45
64
  this.current(epoch);
@@ -57,6 +76,7 @@ export class SubagentLaunchJournal {
57
76
  return { prior: true, ...prior };
58
77
  }
59
78
  this.db.prepare("INSERT INTO subagent_launch_intents VALUES (?, ?, ?, ?, 'accepted', '[]', NULL)").run(owner, key, digest, epoch);
79
+ this.noteProgress(owner, key);
60
80
  return this.read(owner, key);
61
81
  });
62
82
  }
@@ -72,6 +92,7 @@ export class SubagentLaunchJournal {
72
92
  const attempt = { ...input, token: randomBytes(32).toString("hex"), state: "prepared" };
73
93
  attempts.push(attempt);
74
94
  this.db.prepare("UPDATE subagent_launch_intents SET attempts=? WHERE owner=? AND request_key=?").run(JSON.stringify(attempts), owner, key);
95
+ this.noteProgress(owner, key);
75
96
  return attempt;
76
97
  });
77
98
  }
@@ -86,6 +107,7 @@ export class SubagentLaunchJournal {
86
107
  throw new Error("Launch writer does not match spawned process");
87
108
  Object.assign(attempt, { state: "spawned", pid, pidStartTime });
88
109
  this.db.prepare("UPDATE subagent_launch_intents SET attempts=? WHERE owner=? AND request_key=?").run(JSON.stringify(attempts), owner, key);
110
+ this.noteProgress(owner, key);
89
111
  });
90
112
  }
91
113
  finish(owner, key, epoch, result) {
@@ -18,7 +18,7 @@
18
18
  * - a resume attempt id and launch token are persisted before the attempt is
19
19
  * spawned, so a crash is reconciled instead of relaunched.
20
20
  */
21
- /** Schema version this build writes and accepts. Any other version is refused. */
21
+ /** Schema version this build writes after creating or migrating a store. */
22
22
  export const SCHEMA_VERSION = 4;
23
23
  /** Phases that no longer accept automatic continuation. */
24
24
  export const TERMINAL_WAIT_PHASES = ["consumed", "cancelled"];
@@ -1,3 +1,5 @@
1
1
  export function resolveHealthThresholds(config?: any): any;
2
+ export function encodeHealthLogState(state: any): any;
3
+ export function decodeHealthLogState(state: any): any;
2
4
  export function healthThresholdsForConfig(config: any): any;
3
- export function extractChildEventFactsFromLog(id: string, options?: { logPath?: string }): { facts: any; rawLog: any };
5
+ export function extractChildEventFactsFromLog(id: string, options?: { logPath?: string; states?: Map<any, any> }): { facts: any; rawLog: any };