@cleocode/core 2026.10.1 → 2026.10.2

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 (385) hide show
  1. package/dist/build-provenance.json +2 -2
  2. package/dist/cloud/journal.d.ts +9 -5
  3. package/dist/cloud/journal.d.ts.map +1 -1
  4. package/dist/cloud/journal.js +29 -8
  5. package/dist/cloud/journal.js.map +1 -1
  6. package/dist/cloud/manifest-check.d.ts +140 -4
  7. package/dist/cloud/manifest-check.d.ts.map +1 -1
  8. package/dist/cloud/manifest-check.js +309 -10
  9. package/dist/cloud/manifest-check.js.map +1 -1
  10. package/dist/cloud/nexus-attach.d.ts +25 -0
  11. package/dist/cloud/nexus-attach.d.ts.map +1 -1
  12. package/dist/cloud/nexus-attach.js +81 -6
  13. package/dist/cloud/nexus-attach.js.map +1 -1
  14. package/dist/cloud/nexus-cloud-activity.d.ts +37 -0
  15. package/dist/cloud/nexus-cloud-activity.d.ts.map +1 -0
  16. package/dist/cloud/nexus-cloud-activity.js +79 -0
  17. package/dist/cloud/nexus-cloud-activity.js.map +1 -0
  18. package/dist/cloud/nexus-cloud-status.d.ts.map +1 -1
  19. package/dist/cloud/nexus-cloud-status.js +36 -0
  20. package/dist/cloud/nexus-cloud-status.js.map +1 -1
  21. package/dist/cloud/nexus-device.d.ts +1 -1
  22. package/dist/cloud/nexus-enrol.d.ts.map +1 -1
  23. package/dist/cloud/nexus-enrol.js +5 -0
  24. package/dist/cloud/nexus-enrol.js.map +1 -1
  25. package/dist/cloud/nexus-home.d.ts +74 -0
  26. package/dist/cloud/nexus-home.d.ts.map +1 -0
  27. package/dist/cloud/nexus-home.js +97 -0
  28. package/dist/cloud/nexus-home.js.map +1 -0
  29. package/dist/cloud/nexus-vault-keys.d.ts +129 -0
  30. package/dist/cloud/nexus-vault-keys.d.ts.map +1 -0
  31. package/dist/cloud/nexus-vault-keys.js +277 -0
  32. package/dist/cloud/nexus-vault-keys.js.map +1 -0
  33. package/dist/cloud/nexus-vault-state.d.ts +121 -0
  34. package/dist/cloud/nexus-vault-state.d.ts.map +1 -0
  35. package/dist/cloud/nexus-vault-state.js +274 -0
  36. package/dist/cloud/nexus-vault-state.js.map +1 -0
  37. package/dist/cloud/nexus-vault.d.ts +160 -0
  38. package/dist/cloud/nexus-vault.d.ts.map +1 -0
  39. package/dist/cloud/nexus-vault.js +1733 -0
  40. package/dist/cloud/nexus-vault.js.map +1 -0
  41. package/dist/cloud/signing.d.ts +24 -8
  42. package/dist/cloud/signing.d.ts.map +1 -1
  43. package/dist/cloud/signing.js +61 -15
  44. package/dist/cloud/signing.js.map +1 -1
  45. package/dist/docs/export-document.js +8137 -3318
  46. package/dist/docs/export-document.js.map +3 -3
  47. package/dist/doctor/migrations.d.ts +75 -0
  48. package/dist/doctor/migrations.d.ts.map +1 -0
  49. package/dist/doctor/migrations.js +136 -0
  50. package/dist/doctor/migrations.js.map +1 -0
  51. package/dist/doctor/sync-sealer.d.ts +48 -0
  52. package/dist/doctor/sync-sealer.d.ts.map +1 -0
  53. package/dist/doctor/sync-sealer.js +109 -0
  54. package/dist/doctor/sync-sealer.js.map +1 -0
  55. package/dist/doctor/sync-triggers.d.ts +53 -0
  56. package/dist/doctor/sync-triggers.d.ts.map +1 -0
  57. package/dist/doctor/sync-triggers.js +157 -0
  58. package/dist/doctor/sync-triggers.js.map +1 -0
  59. package/dist/init.d.ts.map +1 -1
  60. package/dist/init.js +5 -1
  61. package/dist/init.js.map +1 -1
  62. package/dist/internal.d.ts +1 -1
  63. package/dist/internal.d.ts.map +1 -1
  64. package/dist/internal.js +1 -1
  65. package/dist/internal.js.map +1 -1
  66. package/dist/llm/plugin-facade.js +8442 -3623
  67. package/dist/llm/plugin-facade.js.map +3 -3
  68. package/dist/nexus/projects-clean.d.ts +3 -0
  69. package/dist/nexus/projects-clean.d.ts.map +1 -1
  70. package/dist/nexus/projects-clean.js +9 -3
  71. package/dist/nexus/projects-clean.js.map +1 -1
  72. package/dist/nexus/registry-roots.d.ts +3 -1
  73. package/dist/nexus/registry-roots.d.ts.map +1 -1
  74. package/dist/nexus/registry-roots.js +5 -2
  75. package/dist/nexus/registry-roots.js.map +1 -1
  76. package/dist/nexus/registry.d.ts +8 -1
  77. package/dist/nexus/registry.d.ts.map +1 -1
  78. package/dist/nexus/registry.js +24 -10
  79. package/dist/nexus/registry.js.map +1 -1
  80. package/dist/nexus/workspace.d.ts +4 -1
  81. package/dist/nexus/workspace.d.ts.map +1 -1
  82. package/dist/nexus/workspace.js +10 -4
  83. package/dist/nexus/workspace.js.map +1 -1
  84. package/dist/orchestrate/spawn-ops.d.ts.map +1 -1
  85. package/dist/orchestrate/spawn-ops.js +7 -2
  86. package/dist/orchestrate/spawn-ops.js.map +1 -1
  87. package/dist/orchestrate/worker-verify.d.ts +121 -12
  88. package/dist/orchestrate/worker-verify.d.ts.map +1 -1
  89. package/dist/orchestrate/worker-verify.js +172 -21
  90. package/dist/orchestrate/worker-verify.js.map +1 -1
  91. package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
  92. package/dist/orchestration/spawn-prompt.js +15 -9
  93. package/dist/orchestration/spawn-prompt.js.map +1 -1
  94. package/dist/release/ci-evidence.d.ts +9 -0
  95. package/dist/release/ci-evidence.d.ts.map +1 -1
  96. package/dist/release/ci-evidence.js +9 -2
  97. package/dist/release/ci-evidence.js.map +1 -1
  98. package/dist/resources/backend.d.ts +15 -3
  99. package/dist/resources/backend.d.ts.map +1 -1
  100. package/dist/resources/backend.js +7 -3
  101. package/dist/resources/backend.js.map +1 -1
  102. package/dist/resources/darwin-backend.d.ts +142 -0
  103. package/dist/resources/darwin-backend.d.ts.map +1 -0
  104. package/dist/resources/darwin-backend.js +288 -0
  105. package/dist/resources/darwin-backend.js.map +1 -0
  106. package/dist/resources/governor.d.ts +44 -1
  107. package/dist/resources/governor.d.ts.map +1 -1
  108. package/dist/resources/governor.js +100 -36
  109. package/dist/resources/governor.js.map +1 -1
  110. package/dist/resources/heavy-command.d.ts +132 -0
  111. package/dist/resources/heavy-command.d.ts.map +1 -0
  112. package/dist/resources/heavy-command.js +768 -0
  113. package/dist/resources/heavy-command.js.map +1 -0
  114. package/dist/resources/monitor.d.ts +50 -1
  115. package/dist/resources/monitor.d.ts.map +1 -1
  116. package/dist/resources/monitor.js +83 -1
  117. package/dist/resources/monitor.js.map +1 -1
  118. package/dist/resources/run-admission.d.ts +303 -0
  119. package/dist/resources/run-admission.d.ts.map +1 -0
  120. package/dist/resources/run-admission.js +648 -0
  121. package/dist/resources/run-admission.js.map +1 -0
  122. package/dist/resources/run-class.d.ts +111 -0
  123. package/dist/resources/run-class.d.ts.map +1 -0
  124. package/dist/resources/run-class.js +658 -0
  125. package/dist/resources/run-class.js.map +1 -0
  126. package/dist/resources/run-governed.d.ts +158 -0
  127. package/dist/resources/run-governed.d.ts.map +1 -0
  128. package/dist/resources/run-governed.js +406 -0
  129. package/dist/resources/run-governed.js.map +1 -0
  130. package/dist/resources/slot-holder.d.ts +267 -0
  131. package/dist/resources/slot-holder.d.ts.map +1 -0
  132. package/dist/resources/slot-holder.js +505 -0
  133. package/dist/resources/slot-holder.js.map +1 -0
  134. package/dist/resources/tool-groups.d.ts +74 -0
  135. package/dist/resources/tool-groups.d.ts.map +1 -0
  136. package/dist/resources/tool-groups.js +118 -0
  137. package/dist/resources/tool-groups.js.map +1 -0
  138. package/dist/routing/build-command-groups.d.ts.map +1 -1
  139. package/dist/routing/build-command-groups.js +1 -0
  140. package/dist/routing/build-command-groups.js.map +1 -1
  141. package/dist/selfimprove/fix-gen.js +8446 -3627
  142. package/dist/selfimprove/fix-gen.js.map +3 -3
  143. package/dist/sentient/cross-project-hygiene.d.ts +3 -2
  144. package/dist/sentient/cross-project-hygiene.d.ts.map +1 -1
  145. package/dist/sentient/cross-project-hygiene.js +5 -2
  146. package/dist/sentient/cross-project-hygiene.js.map +1 -1
  147. package/dist/sentient/state.d.ts +7 -0
  148. package/dist/sentient/state.d.ts.map +1 -1
  149. package/dist/sentient/state.js.map +1 -1
  150. package/dist/sentient/tick.d.ts +14 -2
  151. package/dist/sentient/tick.d.ts.map +1 -1
  152. package/dist/sentient/tick.js +63 -4
  153. package/dist/sentient/tick.js.map +1 -1
  154. package/dist/store/backup-recover.d.ts.map +1 -1
  155. package/dist/store/backup-recover.js +5 -0
  156. package/dist/store/backup-recover.js.map +1 -1
  157. package/dist/store/data-accessor.d.ts +1 -0
  158. package/dist/store/data-accessor.d.ts.map +1 -1
  159. package/dist/store/data-accessor.js +7 -0
  160. package/dist/store/data-accessor.js.map +1 -1
  161. package/dist/store/dual-scope-db.d.ts +23 -1
  162. package/dist/store/dual-scope-db.d.ts.map +1 -1
  163. package/dist/store/dual-scope-db.js +126 -36
  164. package/dist/store/dual-scope-db.js.map +1 -1
  165. package/dist/store/exodus/recovery.d.ts.map +1 -1
  166. package/dist/store/exodus/recovery.js +15 -0
  167. package/dist/store/exodus/recovery.js.map +1 -1
  168. package/dist/store/legacy-tasks-lineage.d.ts.map +1 -1
  169. package/dist/store/legacy-tasks-lineage.js +5 -0
  170. package/dist/store/legacy-tasks-lineage.js.map +1 -1
  171. package/dist/store/lock.d.ts +8 -1
  172. package/dist/store/lock.d.ts.map +1 -1
  173. package/dist/store/lock.js +10 -2
  174. package/dist/store/lock.js.map +1 -1
  175. package/dist/store/migration-manager.d.ts +5 -0
  176. package/dist/store/migration-manager.d.ts.map +1 -1
  177. package/dist/store/migration-manager.js +11 -0
  178. package/dist/store/migration-manager.js.map +1 -1
  179. package/dist/store/migration-runner.d.ts +158 -0
  180. package/dist/store/migration-runner.d.ts.map +1 -0
  181. package/dist/store/migration-runner.js +493 -0
  182. package/dist/store/migration-runner.js.map +1 -0
  183. package/dist/store/portable-bundle-import.d.ts +15 -1
  184. package/dist/store/portable-bundle-import.d.ts.map +1 -1
  185. package/dist/store/portable-bundle-import.js +24 -4
  186. package/dist/store/portable-bundle-import.js.map +1 -1
  187. package/dist/store/portable-bundle-relocate.d.ts +43 -0
  188. package/dist/store/portable-bundle-relocate.d.ts.map +1 -1
  189. package/dist/store/portable-bundle-relocate.js +79 -5
  190. package/dist/store/portable-bundle-relocate.js.map +1 -1
  191. package/dist/store/portable-bundle-scan.d.ts +20 -0
  192. package/dist/store/portable-bundle-scan.d.ts.map +1 -1
  193. package/dist/store/portable-bundle-scan.js +38 -3
  194. package/dist/store/portable-bundle-scan.js.map +1 -1
  195. package/dist/store/portable-bundle.d.ts +33 -0
  196. package/dist/store/portable-bundle.d.ts.map +1 -1
  197. package/dist/store/portable-bundle.js +34 -7
  198. package/dist/store/portable-bundle.js.map +1 -1
  199. package/dist/store/row-identity-registry.d.ts +137 -7
  200. package/dist/store/row-identity-registry.d.ts.map +1 -1
  201. package/dist/store/row-identity-registry.js +364 -9
  202. package/dist/store/row-identity-registry.js.map +1 -1
  203. package/dist/store/row-identity.d.ts.map +1 -1
  204. package/dist/store/row-identity.js +9 -10
  205. package/dist/store/row-identity.js.map +1 -1
  206. package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
  207. package/dist/store/sqlite-data-accessor.js +10 -0
  208. package/dist/store/sqlite-data-accessor.js.map +1 -1
  209. package/dist/store/sqlite.d.ts +31 -0
  210. package/dist/store/sqlite.d.ts.map +1 -1
  211. package/dist/store/sqlite.js +5 -1
  212. package/dist/store/sqlite.js.map +1 -1
  213. package/dist/store/sync/capture.d.ts +203 -0
  214. package/dist/store/sync/capture.d.ts.map +1 -0
  215. package/dist/store/sync/capture.js +562 -0
  216. package/dist/store/sync/capture.js.map +1 -0
  217. package/dist/store/sync/clock-store.d.ts.map +1 -1
  218. package/dist/store/sync/clock-store.js +2 -0
  219. package/dist/store/sync/clock-store.js.map +1 -1
  220. package/dist/store/sync/fk-orphans.d.ts +133 -0
  221. package/dist/store/sync/fk-orphans.d.ts.map +1 -0
  222. package/dist/store/sync/fk-orphans.js +265 -0
  223. package/dist/store/sync/fk-orphans.js.map +1 -0
  224. package/dist/store/sync/flags.d.ts +7 -0
  225. package/dist/store/sync/flags.d.ts.map +1 -1
  226. package/dist/store/sync/flags.js +16 -0
  227. package/dist/store/sync/flags.js.map +1 -1
  228. package/dist/store/sync/hlc.d.ts.map +1 -1
  229. package/dist/store/sync/hlc.js +4 -0
  230. package/dist/store/sync/hlc.js.map +1 -1
  231. package/dist/store/sync/identity-fill.d.ts +45 -0
  232. package/dist/store/sync/identity-fill.d.ts.map +1 -0
  233. package/dist/store/sync/identity-fill.js +85 -0
  234. package/dist/store/sync/identity-fill.js.map +1 -0
  235. package/dist/store/sync/machinery.d.ts +27 -0
  236. package/dist/store/sync/machinery.d.ts.map +1 -0
  237. package/dist/store/sync/machinery.js +44 -0
  238. package/dist/store/sync/machinery.js.map +1 -0
  239. package/dist/store/sync/netting.d.ts +120 -0
  240. package/dist/store/sync/netting.d.ts.map +1 -0
  241. package/dist/store/sync/netting.js +336 -0
  242. package/dist/store/sync/netting.js.map +1 -0
  243. package/dist/store/sync/replica.d.ts +27 -2
  244. package/dist/store/sync/replica.d.ts.map +1 -1
  245. package/dist/store/sync/replica.js +47 -3
  246. package/dist/store/sync/replica.js.map +1 -1
  247. package/dist/store/sync/schema.d.ts +12 -0
  248. package/dist/store/sync/schema.d.ts.map +1 -1
  249. package/dist/store/sync/schema.js +21 -0
  250. package/dist/store/sync/schema.js.map +1 -1
  251. package/dist/store/sync/seal-backlog.d.ts +21 -0
  252. package/dist/store/sync/seal-backlog.d.ts.map +1 -0
  253. package/dist/store/sync/seal-backlog.js +24 -0
  254. package/dist/store/sync/seal-backlog.js.map +1 -0
  255. package/dist/store/sync/sealer-values.d.ts +34 -0
  256. package/dist/store/sync/sealer-values.d.ts.map +1 -0
  257. package/dist/store/sync/sealer-values.js +53 -0
  258. package/dist/store/sync/sealer-values.js.map +1 -0
  259. package/dist/store/sync/sealer.d.ts +145 -0
  260. package/dist/store/sync/sealer.d.ts.map +1 -0
  261. package/dist/store/sync/sealer.js +906 -0
  262. package/dist/store/sync/sealer.js.map +1 -0
  263. package/dist/store/sync/structural.d.ts +63 -0
  264. package/dist/store/sync/structural.d.ts.map +1 -0
  265. package/dist/store/sync/structural.js +180 -0
  266. package/dist/store/sync/structural.js.map +1 -0
  267. package/dist/store/sync/timestamps.d.ts +92 -0
  268. package/dist/store/sync/timestamps.d.ts.map +1 -0
  269. package/dist/store/sync/timestamps.js +228 -0
  270. package/dist/store/sync/timestamps.js.map +1 -0
  271. package/dist/store/sync/tombstones.d.ts +75 -0
  272. package/dist/store/sync/tombstones.d.ts.map +1 -0
  273. package/dist/store/sync/tombstones.js +103 -0
  274. package/dist/store/sync/tombstones.js.map +1 -0
  275. package/dist/store/sync/trigger-classes.d.ts +221 -0
  276. package/dist/store/sync/trigger-classes.d.ts.map +1 -0
  277. package/dist/store/sync/trigger-classes.js +441 -0
  278. package/dist/store/sync/trigger-classes.js.map +1 -0
  279. package/dist/store/sync/trigger-suspend-at-path.d.ts +23 -0
  280. package/dist/store/sync/trigger-suspend-at-path.d.ts.map +1 -0
  281. package/dist/store/sync/trigger-suspend-at-path.js +44 -0
  282. package/dist/store/sync/trigger-suspend-at-path.js.map +1 -0
  283. package/dist/store/sync/writer-version.d.ts +43 -0
  284. package/dist/store/sync/writer-version.d.ts.map +1 -0
  285. package/dist/store/sync/writer-version.js +90 -0
  286. package/dist/store/sync/writer-version.js.map +1 -0
  287. package/dist/store/table-classification.d.ts.map +1 -1
  288. package/dist/store/table-classification.js +102 -0
  289. package/dist/store/table-classification.js.map +1 -1
  290. package/dist/store/trigger-suspend-schema.d.ts +44 -0
  291. package/dist/store/trigger-suspend-schema.d.ts.map +1 -0
  292. package/dist/store/trigger-suspend-schema.js +25 -0
  293. package/dist/store/trigger-suspend-schema.js.map +1 -0
  294. package/dist/store/vault-manifest.d.ts +365 -0
  295. package/dist/store/vault-manifest.d.ts.map +1 -0
  296. package/dist/store/vault-manifest.js +812 -0
  297. package/dist/store/vault-manifest.js.map +1 -0
  298. package/dist/store/writer-lease.d.ts +31 -0
  299. package/dist/store/writer-lease.d.ts.map +1 -1
  300. package/dist/store/writer-lease.js +65 -2
  301. package/dist/store/writer-lease.js.map +1 -1
  302. package/dist/system/health.d.ts.map +1 -1
  303. package/dist/system/health.js +21 -0
  304. package/dist/system/health.js.map +1 -1
  305. package/dist/system/project-health.d.ts.map +1 -1
  306. package/dist/system/project-health.js +3 -1
  307. package/dist/system/project-health.js.map +1 -1
  308. package/dist/tasks/affected-packages.d.ts +58 -0
  309. package/dist/tasks/affected-packages.d.ts.map +1 -1
  310. package/dist/tasks/affected-packages.js +75 -6
  311. package/dist/tasks/affected-packages.js.map +1 -1
  312. package/dist/tasks/affected-scope.d.ts +150 -23
  313. package/dist/tasks/affected-scope.d.ts.map +1 -1
  314. package/dist/tasks/affected-scope.js +320 -32
  315. package/dist/tasks/affected-scope.js.map +1 -1
  316. package/dist/tasks/change-set.d.ts +96 -0
  317. package/dist/tasks/change-set.d.ts.map +1 -1
  318. package/dist/tasks/change-set.js +169 -4
  319. package/dist/tasks/change-set.js.map +1 -1
  320. package/dist/tasks/complete-ci.d.ts +115 -0
  321. package/dist/tasks/complete-ci.d.ts.map +1 -0
  322. package/dist/tasks/complete-ci.js +171 -0
  323. package/dist/tasks/complete-ci.js.map +1 -0
  324. package/dist/tasks/complete.d.ts.map +1 -1
  325. package/dist/tasks/complete.js +50 -17
  326. package/dist/tasks/complete.js.map +1 -1
  327. package/dist/tasks/compute-task-view.d.ts.map +1 -1
  328. package/dist/tasks/compute-task-view.js +7 -0
  329. package/dist/tasks/compute-task-view.js.map +1 -1
  330. package/dist/tasks/done-plan.d.ts.map +1 -1
  331. package/dist/tasks/done-plan.js +51 -30
  332. package/dist/tasks/done-plan.js.map +1 -1
  333. package/dist/tasks/done-record.d.ts +6 -0
  334. package/dist/tasks/done-record.d.ts.map +1 -1
  335. package/dist/tasks/done-record.js +9 -3
  336. package/dist/tasks/done-record.js.map +1 -1
  337. package/dist/tasks/evidence.d.ts +3 -2
  338. package/dist/tasks/evidence.d.ts.map +1 -1
  339. package/dist/tasks/evidence.js +143 -12
  340. package/dist/tasks/evidence.js.map +1 -1
  341. package/dist/tasks/gate-notes.d.ts +22 -0
  342. package/dist/tasks/gate-notes.d.ts.map +1 -0
  343. package/dist/tasks/gate-notes.js +33 -0
  344. package/dist/tasks/gate-notes.js.map +1 -0
  345. package/dist/tasks/index.d.ts +2 -1
  346. package/dist/tasks/index.d.ts.map +1 -1
  347. package/dist/tasks/index.js +2 -1
  348. package/dist/tasks/index.js.map +1 -1
  349. package/dist/tasks/test-run-binding.d.ts +117 -0
  350. package/dist/tasks/test-run-binding.d.ts.map +1 -0
  351. package/dist/tasks/test-run-binding.js +365 -0
  352. package/dist/tasks/test-run-binding.js.map +1 -0
  353. package/dist/tasks/tool-cache-env.d.ts +123 -0
  354. package/dist/tasks/tool-cache-env.d.ts.map +1 -0
  355. package/dist/tasks/tool-cache-env.js +287 -0
  356. package/dist/tasks/tool-cache-env.js.map +1 -0
  357. package/dist/tasks/tool-cache-failed-first.d.ts +155 -0
  358. package/dist/tasks/tool-cache-failed-first.d.ts.map +1 -0
  359. package/dist/tasks/tool-cache-failed-first.js +285 -0
  360. package/dist/tasks/tool-cache-failed-first.js.map +1 -0
  361. package/dist/tasks/tool-cache.d.ts +375 -55
  362. package/dist/tasks/tool-cache.d.ts.map +1 -1
  363. package/dist/tasks/tool-cache.js +912 -303
  364. package/dist/tasks/tool-cache.js.map +1 -1
  365. package/dist/tasks/tool-resolver.d.ts +4 -3
  366. package/dist/tasks/tool-resolver.d.ts.map +1 -1
  367. package/dist/tasks/tool-resolver.js +15 -4
  368. package/dist/tasks/tool-resolver.js.map +1 -1
  369. package/dist/tasks/tool-semaphore.d.ts +67 -7
  370. package/dist/tasks/tool-semaphore.d.ts.map +1 -1
  371. package/dist/tasks/tool-semaphore.js +134 -56
  372. package/dist/tasks/tool-semaphore.js.map +1 -1
  373. package/dist/upgrade.d.ts.map +1 -1
  374. package/dist/upgrade.js +4 -0
  375. package/dist/upgrade.js.map +1 -1
  376. package/dist/validation/engine-ops.d.ts +6 -0
  377. package/dist/validation/engine-ops.d.ts.map +1 -1
  378. package/dist/validation/engine-ops.js +8 -0
  379. package/dist/validation/engine-ops.js.map +1 -1
  380. package/migrations/drizzle-cleo-project/20260930170000_t12819-trigger-suspend-clause/migration.sql +367 -0
  381. package/migrations/sync-journal/20260930120000_t12343-capture/migration.sql +47 -0
  382. package/migrations/sync-journal/20261001170000_t12984-sealer/migration.sql +101 -0
  383. package/package.json +13 -13
  384. package/templates/CLEO-INJECTION.md +5 -5
  385. package/templates/CLEO-REFERENCE.md +8 -4
@@ -0,0 +1,648 @@
1
+ /**
2
+ * `cleo run` admission: the one front door for heavy commands an agent runs
3
+ * itself (test runners, compilers, builds, installs).
4
+ *
5
+ * Every heavy command goes through the {@link ResourceGovernor} class budgets,
6
+ * so all `cleo run` jobs share one machine-wide budget per class, whichever
7
+ * agent, session or project asks. `cleo verify` still admits through the tool
8
+ * semaphore until #1775 (T12963) routes it through the governor too. This
9
+ * module holds the pure pieces; `run-governed.ts` runs the loop.
10
+ *
11
+ * - {@link resolveRunClass} / {@link isPausable}: the governor class and
12
+ * whether the job may be paused under pressure
13
+ * - the machine-wide job registry (`<cleoHome>/run/jobs/*.json`): who is
14
+ * running what, with a heartbeat, so the soft-stop envelope can name the
15
+ * holders and runners can coordinate pauses
16
+ * - orphan recovery ({@link reapOrphans}): a runner killed outright
17
+ * (SIGKILL, jetsam) leaves its detached child group behind; the next reap
18
+ * resumes and terminates it after checking it is the same process (start
19
+ * time). A failed `ps` is "unknown" and never acted on.
20
+ * - {@link decidePause}: under `backoff` only the oldest job runs; a job
21
+ * resumed by the starvation cap gets a guaranteed run window
22
+ * - {@link buildRunDeferral}: the `E_RESOURCE_DEFERRED` details and the ways
23
+ * an agent can keep making progress
24
+ *
25
+ * The registry and queue are per `CLEO_HOME` (the machine's CLEO data dir).
26
+ *
27
+ * @module resources/run-admission
28
+ * @task T12979
29
+ * @task T12980
30
+ * @epic T12978
31
+ */
32
+ import { execFileSync } from 'node:child_process';
33
+ import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync, } from 'node:fs';
34
+ import { hostname } from 'node:os';
35
+ import { join } from 'node:path';
36
+ import { getCleoHome } from '../paths.js';
37
+ // Class resolution lives in the dependency-free run-class module (the provider
38
+ // hook imports it on every Bash call); re-exported here for existing callers.
39
+ export { canonicalForClass, commandTarget, isPausable, isWatchCommand, looksHeavy, RUN_CLASS_ALIASES, resolveRunClass, } from './run-class.js';
40
+ // ---------------------------------------------------------------------------
41
+ // Redaction
42
+ // ---------------------------------------------------------------------------
43
+ const SECRET_NAME = '[A-Za-z0-9_-]*(?:token|secret|password|passwd|apikey|api-key|api_key|key)';
44
+ const ASSIGNMENT = new RegExp(`\\b(${SECRET_NAME})=\\S+`, 'gi');
45
+ const SECRET_FLAG = new RegExp(`^--?${SECRET_NAME}$`, 'i');
46
+ /**
47
+ * The command line as recorded: secret-looking `name=value` pairs, the value
48
+ * after a secret-looking flag (`--token X`), URL userinfo and bearer tokens
49
+ * masked; truncated to 160 characters.
50
+ */
51
+ export function redactCommand(argv) {
52
+ const out = [];
53
+ for (let i = 0; i < argv.length; i++) {
54
+ const token = argv[i];
55
+ out.push(token);
56
+ if (SECRET_FLAG.test(token) && i + 1 < argv.length) {
57
+ out.push('***');
58
+ i++;
59
+ }
60
+ }
61
+ const line = out
62
+ .join(' ')
63
+ .replace(ASSIGNMENT, '$1=***')
64
+ .replace(/(\w+:\/\/)[^/\s@]+@/g, '$1***@')
65
+ .replace(/\b(Bearer|Basic)\s+\S+/gi, '$1 ***');
66
+ return line.length > 160 ? `${line.slice(0, 157)}...` : line;
67
+ }
68
+ /**
69
+ * `ps` with a fixed locale and timezone. `lstart` is formatted per LC_TIME and
70
+ * TZ, so two processes with different environments (`cleo run -- env TZ=UTC …`)
71
+ * would print different strings for the same start time (#1777 round 4, MED-2).
72
+ */
73
+ const PS_ENV = { ...process.env, LC_ALL: 'C', TZ: 'UTC' };
74
+ /** A pid we may ever signal or probe: an integer above 1 (never 0, 1 or -1). */
75
+ export function isSignalablePid(pid) {
76
+ return typeof pid === 'number' && Number.isInteger(pid) && pid > 1;
77
+ }
78
+ /** One `ps -o lstart=` exec. Used only off the hot path (spawn, stale records). */
79
+ export const processStart = (pid) => {
80
+ if (!isSignalablePid(pid))
81
+ return null;
82
+ try {
83
+ const out = execFileSync('/bin/ps', ['-o', 'lstart=', '-p', String(pid)], {
84
+ encoding: 'utf-8',
85
+ timeout: 2000,
86
+ stdio: ['ignore', 'pipe', 'ignore'],
87
+ env: PS_ENV,
88
+ }).trim();
89
+ return out.length > 0 ? out : null;
90
+ }
91
+ catch {
92
+ return null;
93
+ }
94
+ };
95
+ function pidAlive(pid) {
96
+ if (!isSignalablePid(pid))
97
+ return false;
98
+ try {
99
+ process.kill(pid, 0);
100
+ return true;
101
+ }
102
+ catch (err) {
103
+ // EPERM: some process holds the pid (maybe not ours); ESRCH: gone.
104
+ return err.code === 'EPERM';
105
+ }
106
+ }
107
+ /** Signal one process (a nested job's non-detached child). Refuses pid ≤ 1. */
108
+ export function signalPid(pid, signal) {
109
+ if (!isSignalablePid(pid))
110
+ return false;
111
+ try {
112
+ process.kill(pid, signal);
113
+ return true;
114
+ }
115
+ catch {
116
+ return false;
117
+ }
118
+ }
119
+ /** Signal a whole process group. Never falls back to a bare pid. */
120
+ export function signalGroup(pid, signal) {
121
+ // kill(0) is our own group and kill(-1) every process we own: never.
122
+ if (!isSignalablePid(pid))
123
+ return false;
124
+ try {
125
+ process.kill(-pid, signal);
126
+ return true;
127
+ }
128
+ catch {
129
+ return false;
130
+ }
131
+ }
132
+ /**
133
+ * Whether a record's child leads its own process group (see
134
+ * {@link RunJob.leadsGroup}). Only a boolean is decisive: a missing or
135
+ * corrupt value (`"false"`, `1`) falls back to `parentJob`, so a truthy
136
+ * non-boolean never sends a group signal to a child that leads no group.
137
+ */
138
+ function leadsOwnGroup(job) {
139
+ if (typeof job.leadsGroup === 'boolean')
140
+ return job.leadsGroup;
141
+ return typeof job.parentJob !== 'string';
142
+ }
143
+ /** A record whose heartbeat is older than this is checked for a dead runner. */
144
+ export const JOB_STALE_MS = 60_000;
145
+ /** Registry directory: `<cleoHome>/run/jobs`. */
146
+ export function runJobsDir(cleoHome = getCleoHome()) {
147
+ return join(cleoHome, 'run', 'jobs');
148
+ }
149
+ /** Wait-queue directory for a class: `<cleoHome>/run/queue/<class>`. */
150
+ export function runQueueDir(cls, cleoHome = getCleoHome()) {
151
+ return join(cleoHome, 'run', 'queue', cls);
152
+ }
153
+ function writeAtomic(dir, name, value) {
154
+ try {
155
+ mkdirSync(dir, { recursive: true });
156
+ const tmp = join(dir, `.${name}.${process.pid}.tmp`);
157
+ writeFileSync(tmp, `${JSON.stringify(value)}\n`);
158
+ renameSync(tmp, join(dir, name));
159
+ }
160
+ catch {
161
+ // Best effort: a registry failure must never block work.
162
+ }
163
+ }
164
+ /** Overwrite a job record atomically. Never throws. */
165
+ export function writeRunJob(job, dir = runJobsDir()) {
166
+ writeAtomic(dir, `${job.id}.json`, job);
167
+ }
168
+ /** Remove a job record. Never throws. */
169
+ export function removeRunJob(id, dir = runJobsDir()) {
170
+ removeRecord(join(dir, `${id}.json`));
171
+ }
172
+ const DEFAULT_PROBES = {
173
+ alive: pidAlive,
174
+ start: processStart,
175
+ signal: signalGroup,
176
+ signalPid,
177
+ now: Date.now,
178
+ };
179
+ /**
180
+ * The runner of a record: `dead` when its pid is free, or (only once the
181
+ * heartbeat is stale, keeping `ps` off the hot path) when the pid now belongs
182
+ * to a different process. A failed `ps` is `unknown`, never `dead`: under the
183
+ * very overload this governor exists for, `ps` times out or cannot fork, and
184
+ * acting on that would signal live jobs (#1777 round 3, H-1).
185
+ */
186
+ export function runnerState(job, probes) {
187
+ if (!probes.alive(job.pid))
188
+ return 'dead';
189
+ if (!heartbeatStale(job.heartbeatAtMs, probes.now()))
190
+ return 'live';
191
+ const start = probes.start(job.pid);
192
+ if (start === null)
193
+ return 'unknown';
194
+ if (job.runnerStart !== null && start !== job.runnerStart)
195
+ return 'dead';
196
+ return 'live';
197
+ }
198
+ /** A heartbeat older than the window, or implausibly far in the future. */
199
+ function heartbeatStale(at, now) {
200
+ return now - at > JOB_STALE_MS || at - now > JOB_STALE_MS;
201
+ }
202
+ /**
203
+ * Resume and stop a dead runner's detached child group, which keeps running
204
+ * and may sit SIGSTOPped forever.
205
+ *
206
+ * - The child pid is held by a process: signal only when its start time
207
+ * matches the record (never a reused pid); when `ps` fails, `retry` later.
208
+ * - No process holds the pid: the leader is gone, but its workers may still
209
+ * be stopped in the group. Nothing else can lead a group with that id while
210
+ * the pid is free, so the group signal reaches only what is left of ours
211
+ * (or fails with ESRCH).
212
+ *
213
+ * @returns `done` when the record may be removed, `retry` to keep it.
214
+ */
215
+ function recoverOrphan(job, probes) {
216
+ if (!isSignalablePid(job.childPid) || job.childStart === null)
217
+ return 'done';
218
+ // A nested or foreground job's child leads no group: signal the process
219
+ // itself, and only while it is provably the same process (T13001).
220
+ const byPid = !leadsOwnGroup(job);
221
+ if (probes.alive(job.childPid)) {
222
+ const start = probes.start(job.childPid);
223
+ if (start === null)
224
+ return 'retry';
225
+ if (start !== job.childStart)
226
+ return 'done';
227
+ }
228
+ else if (byPid) {
229
+ return 'done';
230
+ }
231
+ const signal = byPid ? probes.signalPid : probes.signal;
232
+ signal(job.childPid, 'SIGCONT');
233
+ signal(job.childPid, 'SIGTERM');
234
+ return 'done';
235
+ }
236
+ function isJob(v) {
237
+ const j = v;
238
+ return (typeof j === 'object' &&
239
+ j !== null &&
240
+ typeof j.id === 'string' &&
241
+ isSignalablePid(j.pid) &&
242
+ (j.childPid === null || j.childPid === undefined || isSignalablePid(j.childPid)) &&
243
+ typeof j.startedAtMs === 'number' &&
244
+ typeof j.heartbeatAtMs === 'number');
245
+ }
246
+ /** Parsed records; `null` for an unreadable file. */
247
+ function readRecords(dir) {
248
+ let names;
249
+ try {
250
+ names = readdirSync(dir).filter((n) => n.endsWith('.json') && !n.startsWith('.'));
251
+ }
252
+ catch {
253
+ return [];
254
+ }
255
+ return names.map((name) => {
256
+ const path = join(dir, name);
257
+ try {
258
+ const v = JSON.parse(readFileSync(path, 'utf-8'));
259
+ return { path, job: isJob(v) ? v : null };
260
+ }
261
+ catch {
262
+ return { path, job: null };
263
+ }
264
+ });
265
+ }
266
+ /**
267
+ * Live jobs, oldest first. A pure read: it never signals or deletes (reaping
268
+ * is {@link reapOrphans}). Records whose runner is dead, unknown, or alive
269
+ * with a stale heartbeat (a suspended machine) are left out.
270
+ */
271
+ export function listRunJobs(dir = runJobsDir(), probes = {}) {
272
+ const p = { ...DEFAULT_PROBES, ...probes };
273
+ const jobs = [];
274
+ for (const { job } of readRecords(dir)) {
275
+ if (!job || heartbeatStale(job.heartbeatAtMs, p.now()))
276
+ continue;
277
+ if (runnerState(job, p) === 'live')
278
+ jobs.push(job);
279
+ }
280
+ return jobs.sort((a, b) => a.startedAtMs - b.startedAtMs || a.pid - b.pid);
281
+ }
282
+ /**
283
+ * Remove a registry or queue file. Best effort: a read-only CLEO home must
284
+ * never turn a reap or a queue read into a thrown error (#1777 R8-2).
285
+ */
286
+ function removeRecord(path) {
287
+ try {
288
+ rmSync(path, { force: true });
289
+ return true;
290
+ }
291
+ catch {
292
+ return false;
293
+ }
294
+ }
295
+ /**
296
+ * Reap the records of dead runners: resume and stop their orphaned child
297
+ * groups ({@link recoverOrphan}) and delete the record, unless the child's
298
+ * identity could not be read (kept for the next reap). Records whose runner
299
+ * is `unknown` are never touched. Unreadable files older than the stale
300
+ * window are removed.
301
+ *
302
+ * @returns how many records were removed.
303
+ */
304
+ export function reapOrphans(dir = runJobsDir(), probes = {}) {
305
+ const p = { ...DEFAULT_PROBES, ...probes };
306
+ let removed = 0;
307
+ for (const { path, job } of readRecords(dir)) {
308
+ if (!job) {
309
+ try {
310
+ if (p.now() - statSync(path).mtimeMs > JOB_STALE_MS && removeRecord(path))
311
+ removed++;
312
+ }
313
+ catch {
314
+ // Gone already.
315
+ }
316
+ continue;
317
+ }
318
+ if (runnerState(job, p) !== 'dead')
319
+ continue;
320
+ if (recoverOrphan(job, p) === 'done' && removeRecord(path))
321
+ removed++;
322
+ }
323
+ return removed;
324
+ }
325
+ /** The process group a pid belongs to, from one `ps` exec; null when unknown. */
326
+ export function processGroupOf(pid) {
327
+ try {
328
+ const out = execFileSync('/bin/ps', ['-o', 'pgid=', '-p', String(pid)], {
329
+ encoding: 'utf-8',
330
+ timeout: 2000,
331
+ stdio: ['ignore', 'pipe', 'ignore'],
332
+ env: PS_ENV,
333
+ }).trim();
334
+ const n = Number.parseInt(out, 10);
335
+ return Number.isInteger(n) && n > 0 ? n : null;
336
+ }
337
+ catch {
338
+ return null;
339
+ }
340
+ }
341
+ /** Ancestry walks stop after this many parents (a cycle or a runaway table). */
342
+ const MAX_ANCESTRY = 64;
343
+ /**
344
+ * The ancestors of a pid, nearest first, from ONE `ps` of the process table
345
+ * (pid 1 and below excluded); null when `ps` fails.
346
+ */
347
+ export function processAncestors(pid) {
348
+ let out;
349
+ try {
350
+ out = execFileSync('/bin/ps', ['-A', '-o', 'pid=,ppid='], {
351
+ encoding: 'utf-8',
352
+ timeout: 2000,
353
+ stdio: ['ignore', 'pipe', 'ignore'],
354
+ env: PS_ENV,
355
+ });
356
+ }
357
+ catch {
358
+ return null;
359
+ }
360
+ const parent = new Map();
361
+ for (const line of out.split('\n')) {
362
+ const [child, ppid] = line.trim().split(/\s+/).map(Number);
363
+ if (Number.isInteger(child) && Number.isInteger(ppid))
364
+ parent.set(child, ppid);
365
+ }
366
+ const chain = [];
367
+ let at = parent.get(pid);
368
+ while (at !== undefined && isSignalablePid(at) && chain.length < MAX_ANCESTRY) {
369
+ if (chain.includes(at))
370
+ break;
371
+ chain.push(at);
372
+ at = parent.get(at);
373
+ }
374
+ return chain;
375
+ }
376
+ /**
377
+ * The running `cleo run` job whose process tree `pid` belongs to, or null.
378
+ *
379
+ * A governed child is normally spawned detached, so it leads its own session
380
+ * and process group (pgid = its pid). A process whose group id equals a live
381
+ * job's `childPid`, with the leader's start time matching the record, runs
382
+ * inside that job. This cannot be forged from outside: a session leader's
383
+ * group can only be joined by processes in its own session, and the
384
+ * start-time check rules out a reused pid.
385
+ *
386
+ * When the group says nothing, ancestry decides: `pid` descends from the
387
+ * child of a live job that leads no group (a `--passthrough` run in a
388
+ * terminal's foreground group, OR a nested run). Ancestry can't be forged
389
+ * either (the kernel sets the parent; an orphan is reparented away from the
390
+ * job). It costs one `ps` of the process table, read only while at least one
391
+ * live job, foreground or nested, leads no group.
392
+ *
393
+ * Any failure to read `ps` returns null (normal admission).
394
+ */
395
+ export function parentRunJob(input) {
396
+ const p = { ...DEFAULT_PROBES, ...input.probes };
397
+ const pgid = (input.groupOf ?? processGroupOf)(input.pid);
398
+ if (pgid !== null && !isSignalablePid(pgid))
399
+ return null;
400
+ const jobs = listRunJobs(input.jobsDir ?? runJobsDir(), p).filter((j) => input.cls === undefined || j.class === input.cls);
401
+ /** The job whose child is `leader`, while that pid is provably its child. */
402
+ const childOf = (candidates, leader) => {
403
+ const job = candidates.find((j) => j.childPid === leader);
404
+ if (!job || job.childStart === null)
405
+ return null;
406
+ return p.start(leader) === job.childStart ? job : null;
407
+ };
408
+ // pgid === pid is fine: `cleo run -- cleo run -- …` makes the inner runner
409
+ // the outer job's child and its group leader, and it is nested.
410
+ const byGroup = pgid === null ? null : childOf(jobs, pgid);
411
+ if (byGroup)
412
+ return byGroup;
413
+ const groupless = jobs.filter((j) => !leadsOwnGroup(j));
414
+ if (groupless.length === 0)
415
+ return null;
416
+ for (const ancestor of (input.ancestorsOf ?? processAncestors)(input.pid) ?? []) {
417
+ const job = childOf(groupless, ancestor);
418
+ if (job)
419
+ return job;
420
+ }
421
+ return null;
422
+ }
423
+ /** Add or refresh a wait ticket. Never throws. */
424
+ export function writeQueueTicket(ticket, dir) {
425
+ writeAtomic(dir, `${ticket.id}.json`, ticket);
426
+ }
427
+ /** Remove a wait ticket. Never throws. */
428
+ export function removeQueueTicket(id, dir) {
429
+ removeRunJob(id, dir);
430
+ }
431
+ function isTicket(v) {
432
+ const t = v;
433
+ return (typeof t === 'object' &&
434
+ t !== null &&
435
+ typeof t.id === 'string' &&
436
+ isSignalablePid(t.pid) &&
437
+ typeof t.enqueuedAtMs === 'number' &&
438
+ typeof t.heartbeatAtMs === 'number');
439
+ }
440
+ /**
441
+ * Live tickets in arrival order (FIFO). Invalid tickets, tickets of a dead
442
+ * runner, and tickets whose heartbeat is stale or implausibly far in the
443
+ * future are dropped (#1777 round 3, L-2): an abandoned ticket never blocks
444
+ * a class for longer than the stale window.
445
+ */
446
+ export function listQueueTickets(dir, probes = {}) {
447
+ const p = { ...DEFAULT_PROBES, ...probes };
448
+ let names;
449
+ try {
450
+ names = readdirSync(dir).filter((n) => n.endsWith('.json') && !n.startsWith('.'));
451
+ }
452
+ catch {
453
+ return [];
454
+ }
455
+ const tickets = [];
456
+ for (const name of names) {
457
+ const path = join(dir, name);
458
+ let v;
459
+ try {
460
+ v = JSON.parse(readFileSync(path, 'utf-8'));
461
+ }
462
+ catch {
463
+ continue; // Torn write: its owner rewrites it within a poll.
464
+ }
465
+ if (!isTicket(v) || heartbeatStale(v.heartbeatAtMs, p.now()) || !p.alive(v.pid)) {
466
+ removeRecord(path);
467
+ continue;
468
+ }
469
+ tickets.push(v);
470
+ }
471
+ return tickets.sort((a, b) => a.enqueuedAtMs - b.enqueuedAtMs || a.pid - b.pid);
472
+ }
473
+ /**
474
+ * Live holders of `cleo verify` tool slots on this host, read from the tool
475
+ * semaphore's holder sidecars. Read-only: never touches a lock.
476
+ */
477
+ export function listVerifyHolders(cleoHome = getCleoHome(), alive = pidAlive) {
478
+ const locks = join(cleoHome, 'locks');
479
+ const out = [];
480
+ let dirs;
481
+ try {
482
+ dirs = readdirSync(locks).filter((d) => d.startsWith('tool-'));
483
+ }
484
+ catch {
485
+ return out;
486
+ }
487
+ const host = hostname();
488
+ for (const d of dirs) {
489
+ let files;
490
+ try {
491
+ files = readdirSync(join(locks, d)).filter((f) => f.endsWith('.holder.json'));
492
+ }
493
+ catch {
494
+ continue;
495
+ }
496
+ for (const f of files) {
497
+ try {
498
+ const slot = join(locks, d, f.slice(0, -'.holder.json'.length));
499
+ if (!existsSync(`${slot}.lock`))
500
+ continue;
501
+ const h = JSON.parse(readFileSync(join(locks, d, f), 'utf-8'));
502
+ if (h.host !== host || !alive(h.pid))
503
+ continue;
504
+ out.push({
505
+ tool: d.slice('tool-'.length),
506
+ pid: h.pid,
507
+ acquiredAtMs: Date.parse(h.acquiredAt),
508
+ });
509
+ }
510
+ catch {
511
+ // Unreadable sidecar: skip.
512
+ }
513
+ }
514
+ }
515
+ return out.sort((a, b) => a.acquiredAtMs - b.acquiredAtMs);
516
+ }
517
+ // ---------------------------------------------------------------------------
518
+ // Pause policy
519
+ // ---------------------------------------------------------------------------
520
+ /**
521
+ * A paused job resumes after this long even under pressure (no starvation).
522
+ *
523
+ * Kept below the slot-lock steal threshold: a pause freezes every process in
524
+ * the job's group, including any slot holder nested in it (a `cleo run`
525
+ * runner, or an in-process governor grant such as exodus-on-open or verify),
526
+ * whose lock then stops refreshing. A lock refreshes every
527
+ * `SLOT_LOCK_UPDATE_MS` (15 s) and is stolen once older than
528
+ * `SLOT_LOCK_STALE_MS` (10 min), so a holder frozen for less than 9 min 45 s
529
+ * keeps its slot (#1777 round 6, R6-1).
530
+ */
531
+ export const MAX_PAUSE_MS = 9 * 60_000;
532
+ /** After a cap resume, the job runs at least this long before it can pause again. */
533
+ export const CAP_RUN_WINDOW_MS = 5 * 60_000;
534
+ /**
535
+ * Should this job run or pause right now?
536
+ *
537
+ * - Below `backoff`, or a job that may not be paused: run.
538
+ * - A job with a live nested run that holds its own slot: run
539
+ * (`'nested-slot'`), so that run's slot lock never goes stale while frozen.
540
+ * - At `backoff`: the oldest live job keeps running so the machine always
541
+ * makes progress; every younger pausable job pauses. Pausing frees CPU at
542
+ * once and stops memory growth; nothing is killed and no work is lost.
543
+ * - A job paused for {@link MAX_PAUSE_MS} resumes (`'cap'`) and then runs for
544
+ * at least {@link CAP_RUN_WINDOW_MS} (`'run-window'`) before it can pause
545
+ * again, so a long backoff alternates jobs instead of starving them.
546
+ *
547
+ * @example
548
+ * ```ts
549
+ * decidePause({ state: 'backoff', self, jobs: [old, self], nowMs }).decision; // 'pause'
550
+ * decidePause({ state: 'hold', self, jobs: [old, self], nowMs }).decision; // 'run'
551
+ * ```
552
+ */
553
+ export function decidePause(input) {
554
+ if (!input.self.pausable)
555
+ return { decision: 'run', reason: 'not-pausable' };
556
+ // A nested run holding its own slot lives in this job's group: a SIGSTOP
557
+ // would freeze its runner, whose slot lock then goes stale and is taken
558
+ // while its child still runs (#1777 round 5, N1). Never pause over it.
559
+ if (input.jobs.some((j) => j.parentJob === input.self.id && j.holdsSlot === true)) {
560
+ return { decision: 'run', reason: 'nested-slot' };
561
+ }
562
+ if (input.state !== 'backoff')
563
+ return { decision: 'run', reason: 'below-backoff' };
564
+ const capAt = input.capResumedAtMs ?? null;
565
+ if (capAt !== null && input.nowMs - capAt < (input.runWindowMs ?? CAP_RUN_WINDOW_MS)) {
566
+ return { decision: 'run', reason: 'run-window' };
567
+ }
568
+ const paused = input.pausedAtMs ?? null;
569
+ if (paused !== null && input.nowMs - paused >= (input.maxPauseMs ?? MAX_PAUSE_MS)) {
570
+ return { decision: 'run', reason: 'cap' };
571
+ }
572
+ const oldest = input.jobs[0];
573
+ if (!oldest || oldest.id === input.self.id)
574
+ return { decision: 'run', reason: 'oldest' };
575
+ return { decision: 'pause', reason: 'younger' };
576
+ }
577
+ function shellQuote(token) {
578
+ return /^[\w@%+=:,./-]+$/.test(token) ? token : `'${token.replace(/'/g, `'\\''`)}'`;
579
+ }
580
+ /** Merge `cleo run` jobs and `cleo verify` holders into one oldest-first list. */
581
+ export function runningEntries(jobs, holders) {
582
+ const entries = [
583
+ ...jobs.map((j) => ({
584
+ source: 'run',
585
+ class: j.class,
586
+ command: j.command,
587
+ cwd: j.cwd,
588
+ startedAtMs: j.startedAtMs,
589
+ sessionId: j.sessionId,
590
+ pausedAtMs: j.pausedAtMs,
591
+ })),
592
+ ...holders.map((h) => ({
593
+ source: 'verify',
594
+ class: `tool:${h.tool}`,
595
+ command: `cleo verify (${h.tool})`,
596
+ cwd: null,
597
+ startedAtMs: h.acquiredAtMs,
598
+ sessionId: null,
599
+ pausedAtMs: null,
600
+ })),
601
+ ];
602
+ return entries.sort((a, b) => a.startedAtMs - b.startedAtMs);
603
+ }
604
+ /**
605
+ * Build the deferral details plus the ways forward. The alternatives are
606
+ * concrete commands, ordered by how little they cost the machine.
607
+ */
608
+ export function buildRunDeferral(input) {
609
+ const cmd = input.argv.map(shellQuote).join(' ');
610
+ const alternatives = [];
611
+ if (input.cls === 'test-run') {
612
+ alternatives.push({
613
+ action: 'Use CI as test evidence instead of a local run (zero local cost)',
614
+ command: 'cleo verify <taskId> --gate testsPassed --evidence "ci:<pr>"',
615
+ }, {
616
+ action: 'Run only the test file(s) you changed',
617
+ command: 'cleo run --class test -- npx vitest run <path/to/changed.test.ts>',
618
+ });
619
+ }
620
+ else {
621
+ alternatives.push({
622
+ action: 'Narrow the build to the package you changed',
623
+ command: 'cleo run -- pnpm --filter <package> run build',
624
+ });
625
+ }
626
+ alternatives.push({
627
+ action: 'Keep coding and retry later; nothing was started',
628
+ command: `cleo run -- ${cmd}`,
629
+ }, {
630
+ action: 'Wait in the FIFO queue for this class and start when admitted',
631
+ command: `cleo run --wait --timeout 1800 -- ${cmd}`,
632
+ });
633
+ return {
634
+ details: {
635
+ class: input.cls,
636
+ reason: input.reason,
637
+ retryAfterMs: input.retryAfterMs,
638
+ queuePosition: input.queuePosition ?? null,
639
+ pressure: input.pressure,
640
+ running: input.running,
641
+ },
642
+ alternatives,
643
+ fix: input.pressure.state === 'ok'
644
+ ? `The ${input.cls} class is at capacity; nothing was started. Continue other work, or re-run with --wait to queue.`
645
+ : `The machine is under pressure (${input.pressure.state}) and the ${input.cls} class is at capacity; nothing was started. Continue other work, or re-run with --wait to queue.`,
646
+ };
647
+ }
648
+ //# sourceMappingURL=run-admission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-admission.js","sourceRoot":"","sources":["../../src/resources/run-admission.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,UAAU,EACV,MAAM,EACN,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,+EAA+E;AAC/E,8EAA8E;AAC9E,OAAO,EAEL,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,WAAW,GAAG,2EAA2E,CAAC;AAChG,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,OAAO,WAAW,QAAQ,EAAE,IAAI,CAAC,CAAC;AAChE,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,OAAO,WAAW,GAAG,EAAE,GAAG,CAAC,CAAC;AAE3D;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,IAAuB;IACnD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAW,CAAC;QAChC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChB,IAAI,WAAW,CAAC,I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