@cleocode/core 2026.10.3 → 2026.10.5-rc.ci.672

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 (1373) hide show
  1. package/dist/bootstrap.d.ts.map +1 -1
  2. package/dist/bootstrap.js +7 -37
  3. package/dist/bootstrap.js.map +1 -1
  4. package/dist/build-provenance.json +2 -2
  5. package/dist/caamp/adapter.d.ts.map +1 -1
  6. package/dist/caamp/adapter.js +5 -2
  7. package/dist/caamp/adapter.js.map +1 -1
  8. package/dist/changesets/parse-frontmatter.d.ts +1 -1
  9. package/dist/changesets/parse-frontmatter.d.ts.map +1 -1
  10. package/dist/changesets/parse-frontmatter.js +2 -1
  11. package/dist/changesets/parse-frontmatter.js.map +1 -1
  12. package/dist/changesets/parser.d.ts +1 -1
  13. package/dist/changesets/parser.d.ts.map +1 -1
  14. package/dist/changesets/parser.js +2 -1
  15. package/dist/changesets/parser.js.map +1 -1
  16. package/dist/changesets/writer.d.ts +8 -1
  17. package/dist/changesets/writer.d.ts.map +1 -1
  18. package/dist/changesets/writer.js +56 -5
  19. package/dist/changesets/writer.js.map +1 -1
  20. package/dist/cloud/keys.d.ts +9 -0
  21. package/dist/cloud/keys.d.ts.map +1 -1
  22. package/dist/cloud/keys.js +11 -0
  23. package/dist/cloud/keys.js.map +1 -1
  24. package/dist/cloud/nexus-attach.d.ts +17 -0
  25. package/dist/cloud/nexus-attach.d.ts.map +1 -1
  26. package/dist/cloud/nexus-attach.js +30 -9
  27. package/dist/cloud/nexus-attach.js.map +1 -1
  28. package/dist/cloud/nexus-auth.d.ts +7 -1
  29. package/dist/cloud/nexus-auth.d.ts.map +1 -1
  30. package/dist/cloud/nexus-auth.js +7 -1
  31. package/dist/cloud/nexus-auth.js.map +1 -1
  32. package/dist/cloud/nexus-cloud-activity.d.ts.map +1 -1
  33. package/dist/cloud/nexus-cloud-activity.js +2 -1
  34. package/dist/cloud/nexus-cloud-activity.js.map +1 -1
  35. package/dist/cloud/nexus-cloud-conflicts.d.ts +48 -0
  36. package/dist/cloud/nexus-cloud-conflicts.d.ts.map +1 -0
  37. package/dist/cloud/nexus-cloud-conflicts.js +68 -0
  38. package/dist/cloud/nexus-cloud-conflicts.js.map +1 -0
  39. package/dist/cloud/nexus-cloud-status.d.ts +42 -6
  40. package/dist/cloud/nexus-cloud-status.d.ts.map +1 -1
  41. package/dist/cloud/nexus-cloud-status.js +233 -19
  42. package/dist/cloud/nexus-cloud-status.js.map +1 -1
  43. package/dist/cloud/nexus-cloud.d.ts +18 -1
  44. package/dist/cloud/nexus-cloud.d.ts.map +1 -1
  45. package/dist/cloud/nexus-cloud.js +56 -2
  46. package/dist/cloud/nexus-cloud.js.map +1 -1
  47. package/dist/cloud/nexus-credentials.d.ts +1 -1
  48. package/dist/cloud/nexus-credentials.d.ts.map +1 -1
  49. package/dist/cloud/nexus-credentials.js +1 -1
  50. package/dist/cloud/nexus-credentials.js.map +1 -1
  51. package/dist/cloud/nexus-enrol.d.ts +10 -1
  52. package/dist/cloud/nexus-enrol.d.ts.map +1 -1
  53. package/dist/cloud/nexus-enrol.js +47 -3
  54. package/dist/cloud/nexus-enrol.js.map +1 -1
  55. package/dist/cloud/nexus-first-run.d.ts +146 -0
  56. package/dist/cloud/nexus-first-run.d.ts.map +1 -0
  57. package/dist/cloud/nexus-first-run.js +358 -0
  58. package/dist/cloud/nexus-first-run.js.map +1 -0
  59. package/dist/cloud/nexus-link.d.ts +35 -4
  60. package/dist/cloud/nexus-link.d.ts.map +1 -1
  61. package/dist/cloud/nexus-link.js +172 -7
  62. package/dist/cloud/nexus-link.js.map +1 -1
  63. package/dist/cloud/nexus-presence-refresh.d.ts +65 -0
  64. package/dist/cloud/nexus-presence-refresh.d.ts.map +1 -0
  65. package/dist/cloud/nexus-presence-refresh.js +122 -0
  66. package/dist/cloud/nexus-presence-refresh.js.map +1 -0
  67. package/dist/cloud/nexus-project-history.d.ts +54 -0
  68. package/dist/cloud/nexus-project-history.d.ts.map +1 -0
  69. package/dist/cloud/nexus-project-history.js +108 -0
  70. package/dist/cloud/nexus-project-history.js.map +1 -0
  71. package/dist/cloud/nexus-project-names.d.ts +173 -0
  72. package/dist/cloud/nexus-project-names.d.ts.map +1 -0
  73. package/dist/cloud/nexus-project-names.js +314 -0
  74. package/dist/cloud/nexus-project-names.js.map +1 -0
  75. package/dist/cloud/nexus-vault-keys.d.ts +33 -2
  76. package/dist/cloud/nexus-vault-keys.d.ts.map +1 -1
  77. package/dist/cloud/nexus-vault-keys.js +144 -18
  78. package/dist/cloud/nexus-vault-keys.js.map +1 -1
  79. package/dist/cloud/nexus-vault.d.ts +7 -3
  80. package/dist/cloud/nexus-vault.d.ts.map +1 -1
  81. package/dist/cloud/nexus-vault.js +176 -29
  82. package/dist/cloud/nexus-vault.js.map +1 -1
  83. package/dist/cloud/presence.d.ts +1 -1
  84. package/dist/cloud/presence.d.ts.map +1 -1
  85. package/dist/cloud/presence.js +1 -1
  86. package/dist/cloud/presence.js.map +1 -1
  87. package/dist/cloud/projects.d.ts +7 -4
  88. package/dist/cloud/projects.d.ts.map +1 -1
  89. package/dist/cloud/projects.js +10 -1
  90. package/dist/cloud/projects.js.map +1 -1
  91. package/dist/cloud/signing.d.ts +14 -0
  92. package/dist/cloud/signing.d.ts.map +1 -1
  93. package/dist/cloud/signing.js +9 -0
  94. package/dist/cloud/signing.js.map +1 -1
  95. package/dist/conduit/cloud-endpoint.d.ts +96 -0
  96. package/dist/conduit/cloud-endpoint.d.ts.map +1 -0
  97. package/dist/conduit/cloud-endpoint.js +191 -0
  98. package/dist/conduit/cloud-endpoint.js.map +1 -0
  99. package/dist/conduit/conduit-client.d.ts.map +1 -1
  100. package/dist/conduit/conduit-client.js +2 -1
  101. package/dist/conduit/conduit-client.js.map +1 -1
  102. package/dist/conduit/factory.d.ts +4 -0
  103. package/dist/conduit/factory.d.ts.map +1 -1
  104. package/dist/conduit/factory.js +7 -1
  105. package/dist/conduit/factory.js.map +1 -1
  106. package/dist/conduit/http-transport.d.ts +12 -7
  107. package/dist/conduit/http-transport.d.ts.map +1 -1
  108. package/dist/conduit/http-transport.js +18 -11
  109. package/dist/conduit/http-transport.js.map +1 -1
  110. package/dist/conduit/index.d.ts +3 -1
  111. package/dist/conduit/index.d.ts.map +1 -1
  112. package/dist/conduit/index.js +3 -1
  113. package/dist/conduit/index.js.map +1 -1
  114. package/dist/conduit/sse-transport.d.ts +5 -1
  115. package/dist/conduit/sse-transport.d.ts.map +1 -1
  116. package/dist/conduit/sse-transport.js +10 -2
  117. package/dist/conduit/sse-transport.js.map +1 -1
  118. package/dist/config/registry.js +1 -1
  119. package/dist/config/registry.js.map +1 -1
  120. package/dist/core-paths.d.ts +13 -0
  121. package/dist/core-paths.d.ts.map +1 -0
  122. package/dist/core-paths.js +13 -0
  123. package/dist/core-paths.js.map +1 -0
  124. package/dist/decide/bench/source.js +1 -1
  125. package/dist/decide/bench/source.js.map +1 -1
  126. package/dist/decide/client.d.ts +1 -1
  127. package/dist/decide/client.d.ts.map +1 -1
  128. package/dist/decide/client.js +1 -1
  129. package/dist/decide/client.js.map +1 -1
  130. package/dist/decide/credentials.d.ts +1 -1
  131. package/dist/decide/credentials.d.ts.map +1 -1
  132. package/dist/decide/credentials.js +1 -1
  133. package/dist/decide/credentials.js.map +1 -1
  134. package/dist/decide/jev-wire.d.ts +1 -1
  135. package/dist/decide/jev-wire.d.ts.map +1 -1
  136. package/dist/decide/jev-wire.js +1 -1
  137. package/dist/decide/jev-wire.js.map +1 -1
  138. package/dist/decide/operations.d.ts +1 -1
  139. package/dist/decide/operations.d.ts.map +1 -1
  140. package/dist/decide/operations.js +1 -1
  141. package/dist/decide/operations.js.map +1 -1
  142. package/dist/decide/providers.d.ts +1 -1
  143. package/dist/decide/providers.d.ts.map +1 -1
  144. package/dist/decide/providers.js +1 -1
  145. package/dist/decide/providers.js.map +1 -1
  146. package/dist/decide/wizard.d.ts.map +1 -1
  147. package/dist/decide/wizard.js +1 -1
  148. package/dist/decide/wizard.js.map +1 -1
  149. package/dist/dispatch/config-domain-handler.d.ts +1 -1
  150. package/dist/dispatch/config-domain-handler.d.ts.map +1 -1
  151. package/dist/dispatch/config-domain-handler.js +1 -1
  152. package/dist/dispatch/config-domain-handler.js.map +1 -1
  153. package/dist/dispatch/contracts/derive-output-contract.d.ts +1 -1
  154. package/dist/dispatch/contracts/derive-output-contract.d.ts.map +1 -1
  155. package/dist/dispatch/contracts/derive-output-contract.js +2 -1
  156. package/dist/dispatch/contracts/derive-output-contract.js.map +1 -1
  157. package/dist/dispatch/contracts/ensures-schema.d.ts +1 -1
  158. package/dist/dispatch/contracts/ensures-schema.d.ts.map +1 -1
  159. package/dist/dispatch/contracts/ensures-schema.js +1 -1
  160. package/dist/dispatch/contracts/ensures-schema.js.map +1 -1
  161. package/dist/dispatch/contracts/input-contracts.d.ts +1 -1
  162. package/dist/dispatch/contracts/input-contracts.d.ts.map +1 -1
  163. package/dist/dispatch/contracts/input-contracts.js +3 -1
  164. package/dist/dispatch/contracts/input-contracts.js.map +1 -1
  165. package/dist/dispatch/contracts/output-contracts.d.ts +2 -1
  166. package/dist/dispatch/contracts/output-contracts.d.ts.map +1 -1
  167. package/dist/dispatch/contracts/output-contracts.js +1 -1
  168. package/dist/dispatch/contracts/output-contracts.js.map +1 -1
  169. package/dist/dispatch/describe-operation.d.ts +1 -1
  170. package/dist/dispatch/describe-operation.d.ts.map +1 -1
  171. package/dist/dispatch/describe-operation.js +1 -1
  172. package/dist/dispatch/describe-operation.js.map +1 -1
  173. package/dist/dispatch/mvi-projection.d.ts +1 -1
  174. package/dist/dispatch/mvi-projection.d.ts.map +1 -1
  175. package/dist/dispatch/mvi-projection.js +1 -1
  176. package/dist/dispatch/mvi-projection.js.map +1 -1
  177. package/dist/docs/display-alias.js +1 -1
  178. package/dist/docs/display-alias.js.map +1 -1
  179. package/dist/docs/docs-update.d.ts +1 -1
  180. package/dist/docs/docs-update.d.ts.map +1 -1
  181. package/dist/docs/docs-update.js +2 -1
  182. package/dist/docs/docs-update.js.map +1 -1
  183. package/dist/docs/export-document.js +14 -58410
  184. package/dist/docs/export-document.js.map +3 -3
  185. package/dist/docs/publish-pr.js +1 -1
  186. package/dist/docs/publish-pr.js.map +1 -1
  187. package/dist/docs/supersede.js +1 -1
  188. package/dist/docs/supersede.js.map +1 -1
  189. package/dist/docs/validate-body.d.ts +1 -1
  190. package/dist/docs/validate-body.d.ts.map +1 -1
  191. package/dist/docs/validate-body.js +1 -1
  192. package/dist/docs/validate-body.js.map +1 -1
  193. package/dist/docs/writer-registry.js +1 -1
  194. package/dist/docs/writer-registry.js.map +1 -1
  195. package/dist/doctor/acceptance-drift.js +1 -1
  196. package/dist/doctor/acceptance-drift.js.map +1 -1
  197. package/dist/doctor/db-substrate.d.ts +7 -10
  198. package/dist/doctor/db-substrate.d.ts.map +1 -1
  199. package/dist/doctor/db-substrate.js +11 -15
  200. package/dist/doctor/db-substrate.js.map +1 -1
  201. package/dist/doctor/invariant-audit.js +1 -1
  202. package/dist/doctor/invariant-audit.js.map +1 -1
  203. package/dist/doctor/malformed-task-ids.js +1 -1
  204. package/dist/doctor/malformed-task-ids.js.map +1 -1
  205. package/dist/doctor/migrations.d.ts +18 -0
  206. package/dist/doctor/migrations.d.ts.map +1 -1
  207. package/dist/doctor/migrations.js +54 -2
  208. package/dist/doctor/migrations.js.map +1 -1
  209. package/dist/doctor/row-identity-refill.d.ts +43 -0
  210. package/dist/doctor/row-identity-refill.d.ts.map +1 -0
  211. package/dist/doctor/row-identity-refill.js +186 -0
  212. package/dist/doctor/row-identity-refill.js.map +1 -0
  213. package/dist/doctor/superseded-store.d.ts.map +1 -1
  214. package/dist/doctor/superseded-store.js +51 -2
  215. package/dist/doctor/superseded-store.js.map +1 -1
  216. package/dist/doctor/sync-repair.d.ts +39 -0
  217. package/dist/doctor/sync-repair.d.ts.map +1 -0
  218. package/dist/doctor/sync-repair.js +71 -0
  219. package/dist/doctor/sync-repair.js.map +1 -0
  220. package/dist/doctor/sync-triggers.d.ts +63 -4
  221. package/dist/doctor/sync-triggers.d.ts.map +1 -1
  222. package/dist/doctor/sync-triggers.js +352 -9
  223. package/dist/doctor/sync-triggers.js.map +1 -1
  224. package/dist/doctor/twin-collapse.js +1 -1
  225. package/dist/doctor/twin-collapse.js.map +1 -1
  226. package/dist/engine/engine-ops.d.ts.map +1 -1
  227. package/dist/engine/engine-ops.js +7 -1
  228. package/dist/engine/engine-ops.js.map +1 -1
  229. package/dist/engine-result.d.ts +1 -1
  230. package/dist/engine-result.d.ts.map +1 -1
  231. package/dist/engine-result.js +1 -1
  232. package/dist/engine-result.js.map +1 -1
  233. package/dist/error-catalog.js +1 -1
  234. package/dist/error-catalog.js.map +1 -1
  235. package/dist/error-registry.d.ts +1 -1
  236. package/dist/error-registry.d.ts.map +1 -1
  237. package/dist/error-registry.js +1 -1
  238. package/dist/error-registry.js.map +1 -1
  239. package/dist/errors-to-engine.d.ts +20 -0
  240. package/dist/errors-to-engine.d.ts.map +1 -1
  241. package/dist/errors-to-engine.js +37 -0
  242. package/dist/errors-to-engine.js.map +1 -1
  243. package/dist/errors.d.ts +1 -1
  244. package/dist/errors.d.ts.map +1 -1
  245. package/dist/errors.js +1 -1
  246. package/dist/errors.js.map +1 -1
  247. package/dist/gc/janitor.d.ts +23 -4
  248. package/dist/gc/janitor.d.ts.map +1 -1
  249. package/dist/gc/janitor.js +71 -11
  250. package/dist/gc/janitor.js.map +1 -1
  251. package/dist/goal/continuation.d.ts +1 -1
  252. package/dist/goal/continuation.d.ts.map +1 -1
  253. package/dist/goal/continuation.js +1 -1
  254. package/dist/goal/continuation.js.map +1 -1
  255. package/dist/goal/judge.d.ts.map +1 -1
  256. package/dist/goal/judge.js +2 -1
  257. package/dist/goal/judge.js.map +1 -1
  258. package/dist/hooks/handlers/session-hooks.d.ts.map +1 -1
  259. package/dist/hooks/handlers/session-hooks.js +1 -1
  260. package/dist/hooks/handlers/session-hooks.js.map +1 -1
  261. package/dist/init/engine-ops.js +1 -1
  262. package/dist/init/engine-ops.js.map +1 -1
  263. package/dist/init.d.ts.map +1 -1
  264. package/dist/init.js +22 -37
  265. package/dist/init.js.map +1 -1
  266. package/dist/inject/index.js +1 -1
  267. package/dist/inject/index.js.map +1 -1
  268. package/dist/injection.d.ts.map +1 -1
  269. package/dist/injection.js +13 -0
  270. package/dist/injection.js.map +1 -1
  271. package/dist/internal.d.ts +4 -3
  272. package/dist/internal.d.ts.map +1 -1
  273. package/dist/internal.js +7 -4
  274. package/dist/internal.js.map +1 -1
  275. package/dist/issue/create.js +1 -1
  276. package/dist/issue/create.js.map +1 -1
  277. package/dist/json-schema-validator.js +1 -1
  278. package/dist/json-schema-validator.js.map +1 -1
  279. package/dist/lifecycle/index.d.ts +2 -23
  280. package/dist/lifecycle/index.d.ts.map +1 -1
  281. package/dist/lifecycle/index.js +5 -112
  282. package/dist/lifecycle/index.js.map +1 -1
  283. package/dist/lifecycle/kind-requirements.d.ts +1 -1
  284. package/dist/lifecycle/kind-requirements.d.ts.map +1 -1
  285. package/dist/lifecycle/kind-requirements.js +1 -1
  286. package/dist/lifecycle/kind-requirements.js.map +1 -1
  287. package/dist/lifecycle/pipeline.js +1 -1
  288. package/dist/lifecycle/pipeline.js.map +1 -1
  289. package/dist/lifecycle/resume.js +2 -2
  290. package/dist/lifecycle/resume.js.map +1 -1
  291. package/dist/lifecycle/state-machine.js +1 -1
  292. package/dist/lifecycle/state-machine.js.map +1 -1
  293. package/dist/lifecycle/status.d.ts +46 -0
  294. package/dist/lifecycle/status.d.ts.map +1 -0
  295. package/dist/lifecycle/status.js +147 -0
  296. package/dist/lifecycle/status.js.map +1 -0
  297. package/dist/lifecycle/verification/satisfies-validator.js +1 -1
  298. package/dist/lifecycle/verification/satisfies-validator.js.map +1 -1
  299. package/dist/llm/catalog-seeder.d.ts +1 -1
  300. package/dist/llm/catalog-seeder.d.ts.map +1 -1
  301. package/dist/llm/catalog-seeder.js +1 -1
  302. package/dist/llm/catalog-seeder.js.map +1 -1
  303. package/dist/llm/cli-ops.d.ts +1 -2
  304. package/dist/llm/cli-ops.d.ts.map +1 -1
  305. package/dist/llm/cli-ops.js +2 -1
  306. package/dist/llm/cli-ops.js.map +1 -1
  307. package/dist/llm/conversation.d.ts.map +1 -1
  308. package/dist/llm/conversation.js +15 -4
  309. package/dist/llm/conversation.js.map +1 -1
  310. package/dist/llm/credential-seeders/claude-code-seeder.js +1 -1
  311. package/dist/llm/credential-seeders/claude-code-seeder.js.map +1 -1
  312. package/dist/llm/credential-seeders/cleo-pkce-seeder.js +1 -1
  313. package/dist/llm/credential-seeders/cleo-pkce-seeder.js.map +1 -1
  314. package/dist/llm/credential-writeback.js +1 -1
  315. package/dist/llm/credential-writeback.js.map +1 -1
  316. package/dist/llm/entity-ops.d.ts +1 -1
  317. package/dist/llm/entity-ops.d.ts.map +1 -1
  318. package/dist/llm/entity-ops.js +2 -1
  319. package/dist/llm/entity-ops.js.map +1 -1
  320. package/dist/llm/llm-queue-admit.d.ts +1 -1
  321. package/dist/llm/llm-queue-admit.d.ts.map +1 -1
  322. package/dist/llm/llm-queue-admit.js +2 -1
  323. package/dist/llm/llm-queue-admit.js.map +1 -1
  324. package/dist/llm/onboarding/login-engine.js +1 -1
  325. package/dist/llm/onboarding/login-engine.js.map +1 -1
  326. package/dist/llm/pi/pi-errors.d.ts +1 -1
  327. package/dist/llm/pi/pi-errors.d.ts.map +1 -1
  328. package/dist/llm/pi/pi-errors.js +1 -1
  329. package/dist/llm/pi/pi-errors.js.map +1 -1
  330. package/dist/llm/plugin-facade.d.ts.map +1 -1
  331. package/dist/llm/plugin-facade.js +14 -93651
  332. package/dist/llm/plugin-facade.js.map +3 -3
  333. package/dist/llm/system-key.d.ts +1 -1
  334. package/dist/llm/system-key.d.ts.map +1 -1
  335. package/dist/llm/system-key.js +1 -1
  336. package/dist/llm/system-key.js.map +1 -1
  337. package/dist/llm/system-of-use-registry.d.ts +1 -1
  338. package/dist/llm/system-of-use-registry.d.ts.map +1 -1
  339. package/dist/llm/system-of-use-registry.js +1 -1
  340. package/dist/llm/system-of-use-registry.js.map +1 -1
  341. package/dist/llm/system-resolver.js +1 -1
  342. package/dist/llm/system-resolver.js.map +1 -1
  343. package/dist/llm/transports/bedrock.d.ts +1 -0
  344. package/dist/llm/transports/bedrock.d.ts.map +1 -1
  345. package/dist/llm/transports/bedrock.js +30 -12
  346. package/dist/llm/transports/bedrock.js.map +1 -1
  347. package/dist/memory/brain-host.d.ts +71 -0
  348. package/dist/memory/brain-host.d.ts.map +1 -0
  349. package/dist/memory/brain-host.js +84 -0
  350. package/dist/memory/brain-host.js.map +1 -0
  351. package/dist/memory/brain-writer-handlers.d.ts.map +1 -1
  352. package/dist/memory/brain-writer-handlers.js +24 -7
  353. package/dist/memory/brain-writer-handlers.js.map +1 -1
  354. package/dist/memory/brain-writer-thread.d.ts +66 -6
  355. package/dist/memory/brain-writer-thread.d.ts.map +1 -1
  356. package/dist/memory/brain-writer-thread.js +67 -10
  357. package/dist/memory/brain-writer-thread.js.map +1 -1
  358. package/dist/memory/brain-writer-worker.js +7 -0
  359. package/dist/memory/brain-writer-worker.js.map +1 -1
  360. package/dist/memory/decision-contradiction.d.ts.map +1 -1
  361. package/dist/memory/decision-contradiction.js +10 -5
  362. package/dist/memory/decision-contradiction.js.map +1 -1
  363. package/dist/memory/decisions.js +2 -1
  364. package/dist/memory/decisions.js.map +1 -1
  365. package/dist/memory/dialectic-evaluator.d.ts.map +1 -1
  366. package/dist/memory/dialectic-evaluator.js +4 -1
  367. package/dist/memory/dialectic-evaluator.js.map +1 -1
  368. package/dist/memory/embedding-backfill.d.ts +70 -0
  369. package/dist/memory/embedding-backfill.d.ts.map +1 -0
  370. package/dist/memory/embedding-backfill.js +110 -0
  371. package/dist/memory/embedding-backfill.js.map +1 -0
  372. package/dist/memory/index.js +1 -1
  373. package/dist/memory/index.js.map +1 -1
  374. package/dist/memory/manifest-identity.js +1 -1
  375. package/dist/memory/manifest-identity.js.map +1 -1
  376. package/dist/memory/retrieval/observe.d.ts +23 -0
  377. package/dist/memory/retrieval/observe.d.ts.map +1 -1
  378. package/dist/memory/retrieval/observe.js +82 -36
  379. package/dist/memory/retrieval/observe.js.map +1 -1
  380. package/dist/memory/transcript-extractor.d.ts.map +1 -1
  381. package/dist/memory/transcript-extractor.js +3 -2
  382. package/dist/memory/transcript-extractor.js.map +1 -1
  383. package/dist/metrics/model-provider-registry.d.ts.map +1 -1
  384. package/dist/metrics/model-provider-registry.js +6 -0
  385. package/dist/metrics/model-provider-registry.js.map +1 -1
  386. package/dist/metrics/token-service.d.ts +33 -0
  387. package/dist/metrics/token-service.d.ts.map +1 -1
  388. package/dist/metrics/token-service.js +35 -0
  389. package/dist/metrics/token-service.js.map +1 -1
  390. package/dist/migration/index.js +1 -1
  391. package/dist/migration/index.js.map +1 -1
  392. package/dist/migration/manual/T10165-backfill-adr-index.js +1 -1
  393. package/dist/migration/manual/T10165-backfill-adr-index.js.map +1 -1
  394. package/dist/nexus/api-contracts.d.ts.map +1 -1
  395. package/dist/nexus/api-contracts.js +27 -11
  396. package/dist/nexus/api-contracts.js.map +1 -1
  397. package/dist/nexus/api-extractors/http-extractor.d.ts +2 -2
  398. package/dist/nexus/api-extractors/http-extractor.d.ts.map +1 -1
  399. package/dist/nexus/api-extractors/http-extractor.js +3 -3
  400. package/dist/nexus/api-extractors/http-extractor.js.map +1 -1
  401. package/dist/nexus/assessment-projection.d.ts +1 -1
  402. package/dist/nexus/assessment-projection.d.ts.map +1 -1
  403. package/dist/nexus/assessment-projection.js +1 -1
  404. package/dist/nexus/assessment-projection.js.map +1 -1
  405. package/dist/nexus/clusters.js +1 -1
  406. package/dist/nexus/clusters.js.map +1 -1
  407. package/dist/nexus/deps.d.ts +1 -1
  408. package/dist/nexus/deps.d.ts.map +1 -1
  409. package/dist/nexus/deps.js +1 -1
  410. package/dist/nexus/deps.js.map +1 -1
  411. package/dist/nexus/diff.d.ts +1 -1
  412. package/dist/nexus/diff.d.ts.map +1 -1
  413. package/dist/nexus/diff.js +3 -2
  414. package/dist/nexus/diff.js.map +1 -1
  415. package/dist/nexus/fleet-status.d.ts +1 -1
  416. package/dist/nexus/fleet-status.d.ts.map +1 -1
  417. package/dist/nexus/fleet-status.js +1 -1
  418. package/dist/nexus/fleet-status.js.map +1 -1
  419. package/dist/nexus/flows.js +1 -1
  420. package/dist/nexus/flows.js.map +1 -1
  421. package/dist/nexus/identity.d.ts +8 -0
  422. package/dist/nexus/identity.d.ts.map +1 -1
  423. package/dist/nexus/identity.js +17 -1
  424. package/dist/nexus/identity.js.map +1 -1
  425. package/dist/nexus/index.d.ts +1 -1
  426. package/dist/nexus/index.d.ts.map +1 -1
  427. package/dist/nexus/index.js +2 -2
  428. package/dist/nexus/index.js.map +1 -1
  429. package/dist/nexus/nexus-bridge.d.ts.map +1 -1
  430. package/dist/nexus/nexus-bridge.js +5 -5
  431. package/dist/nexus/nexus-bridge.js.map +1 -1
  432. package/dist/nexus/permissions.d.ts +1 -1
  433. package/dist/nexus/permissions.d.ts.map +1 -1
  434. package/dist/nexus/permissions.js +1 -1
  435. package/dist/nexus/permissions.js.map +1 -1
  436. package/dist/nexus/query-dsl.js +1 -1
  437. package/dist/nexus/query-dsl.js.map +1 -1
  438. package/dist/nexus/query.d.ts +1 -2
  439. package/dist/nexus/query.d.ts.map +1 -1
  440. package/dist/nexus/query.js +1 -1
  441. package/dist/nexus/query.js.map +1 -1
  442. package/dist/nexus/registry-errors.js +1 -1
  443. package/dist/nexus/registry-errors.js.map +1 -1
  444. package/dist/nexus/registry.d.ts +23 -1
  445. package/dist/nexus/registry.d.ts.map +1 -1
  446. package/dist/nexus/registry.js +77 -2
  447. package/dist/nexus/registry.js.map +1 -1
  448. package/dist/nexus/workspace.js +1 -1
  449. package/dist/nexus/workspace.js.map +1 -1
  450. package/dist/orchestrate/pivot.d.ts.map +1 -1
  451. package/dist/orchestrate/pivot.js +2 -1
  452. package/dist/orchestrate/pivot.js.map +1 -1
  453. package/dist/orchestrate/query-ops.js +1 -1
  454. package/dist/orchestrate/query-ops.js.map +1 -1
  455. package/dist/orchestrate/spawn-ops.js +1 -1
  456. package/dist/orchestrate/spawn-ops.js.map +1 -1
  457. package/dist/orchestration/atomicity.d.ts +1 -1
  458. package/dist/orchestration/atomicity.d.ts.map +1 -1
  459. package/dist/orchestration/atomicity.js +1 -1
  460. package/dist/orchestration/atomicity.js.map +1 -1
  461. package/dist/orchestration/classify.js +1 -1
  462. package/dist/orchestration/classify.js.map +1 -1
  463. package/dist/orchestration/index.js +1 -1
  464. package/dist/orchestration/index.js.map +1 -1
  465. package/dist/orchestration/parallel.js +1 -1
  466. package/dist/orchestration/parallel.js.map +1 -1
  467. package/dist/orchestration/protocol-validators.d.ts +1 -1
  468. package/dist/orchestration/protocol-validators.d.ts.map +1 -1
  469. package/dist/orchestration/protocol-validators.js +1 -1
  470. package/dist/orchestration/protocol-validators.js.map +1 -1
  471. package/dist/orchestration/skill-ops.js +1 -1
  472. package/dist/orchestration/skill-ops.js.map +1 -1
  473. package/dist/orchestration/spawn-prompt.d.ts +9 -0
  474. package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
  475. package/dist/orchestration/spawn-prompt.js +13 -2
  476. package/dist/orchestration/spawn-prompt.js.map +1 -1
  477. package/dist/orchestration/spawn.js +1 -1
  478. package/dist/orchestration/spawn.js.map +1 -1
  479. package/dist/paths.d.ts +3 -1
  480. package/dist/paths.d.ts.map +1 -1
  481. package/dist/paths.js +4 -2
  482. package/dist/paths.js.map +1 -1
  483. package/dist/phases/deps.js +1 -1
  484. package/dist/phases/deps.js.map +1 -1
  485. package/dist/phases/index.js +1 -1
  486. package/dist/phases/index.js.map +1 -1
  487. package/dist/project-lifecycle.js +3 -3
  488. package/dist/project-lifecycle.js.map +1 -1
  489. package/dist/project-scope.js +1 -1
  490. package/dist/project-scope.js.map +1 -1
  491. package/dist/project-tombstone.js +1 -1
  492. package/dist/project-tombstone.js.map +1 -1
  493. package/dist/registrations.d.ts +30 -0
  494. package/dist/registrations.d.ts.map +1 -0
  495. package/dist/registrations.js +30 -0
  496. package/dist/registrations.js.map +1 -0
  497. package/dist/release/changesets-aggregator.js +1 -1
  498. package/dist/release/changesets-aggregator.js.map +1 -1
  499. package/dist/release/ci-evidence.d.ts +68 -2
  500. package/dist/release/ci-evidence.d.ts.map +1 -1
  501. package/dist/release/ci-evidence.js +203 -39
  502. package/dist/release/ci-evidence.js.map +1 -1
  503. package/dist/release/invariants/archive-reason-invariant.d.ts +1 -1
  504. package/dist/release/invariants/archive-reason-invariant.d.ts.map +1 -1
  505. package/dist/release/invariants/archive-reason-invariant.js +1 -1
  506. package/dist/release/invariants/archive-reason-invariant.js.map +1 -1
  507. package/dist/release/invariants/registry.d.ts +1 -1
  508. package/dist/release/invariants/registry.d.ts.map +1 -1
  509. package/dist/release/invariants/registry.js +1 -1
  510. package/dist/release/invariants/registry.js.map +1 -1
  511. package/dist/release/open.d.ts +4 -7
  512. package/dist/release/open.d.ts.map +1 -1
  513. package/dist/release/open.js +62 -24
  514. package/dist/release/open.js.map +1 -1
  515. package/dist/release/plan.d.ts +1 -2
  516. package/dist/release/plan.d.ts.map +1 -1
  517. package/dist/release/plan.js +4 -1
  518. package/dist/release/plan.js.map +1 -1
  519. package/dist/release/pr-evidence.d.ts +1 -1
  520. package/dist/release/pr-evidence.d.ts.map +1 -1
  521. package/dist/release/pr-evidence.js +2 -2
  522. package/dist/release/pr-evidence.js.map +1 -1
  523. package/dist/release/preflight-skip.d.ts +74 -10
  524. package/dist/release/preflight-skip.d.ts.map +1 -1
  525. package/dist/release/preflight-skip.js +254 -47
  526. package/dist/release/preflight-skip.js.map +1 -1
  527. package/dist/release/reconcile.d.ts +1 -1
  528. package/dist/release/reconcile.d.ts.map +1 -1
  529. package/dist/release/reconcile.js +19 -3
  530. package/dist/release/reconcile.js.map +1 -1
  531. package/dist/release/version-bump.d.ts +1 -1
  532. package/dist/release/version-bump.d.ts.map +1 -1
  533. package/dist/release/version-bump.js +1 -1
  534. package/dist/release/version-bump.js.map +1 -1
  535. package/dist/render/colors.js +1 -19
  536. package/dist/render/colors.js.map +1 -1
  537. package/dist/render/tasks/colors.js +1 -1
  538. package/dist/render/tasks/colors.js.map +1 -1
  539. package/dist/resources/admission-ledger.d.ts +587 -0
  540. package/dist/resources/admission-ledger.d.ts.map +1 -0
  541. package/dist/resources/admission-ledger.js +1401 -0
  542. package/dist/resources/admission-ledger.js.map +1 -0
  543. package/dist/resources/backend.d.ts +37 -1
  544. package/dist/resources/backend.d.ts.map +1 -1
  545. package/dist/resources/backend.js +1 -1
  546. package/dist/resources/darwin-backend.d.ts +152 -26
  547. package/dist/resources/darwin-backend.d.ts.map +1 -1
  548. package/dist/resources/darwin-backend.js +217 -34
  549. package/dist/resources/darwin-backend.js.map +1 -1
  550. package/dist/resources/governor.d.ts +36 -27
  551. package/dist/resources/governor.d.ts.map +1 -1
  552. package/dist/resources/governor.js +144 -49
  553. package/dist/resources/governor.js.map +1 -1
  554. package/dist/resources/heavy-command-hook-delivery.d.ts +144 -0
  555. package/dist/resources/heavy-command-hook-delivery.d.ts.map +1 -0
  556. package/dist/resources/heavy-command-hook-delivery.js +204 -0
  557. package/dist/resources/heavy-command-hook-delivery.js.map +1 -0
  558. package/dist/resources/heavy-command.d.ts +69 -0
  559. package/dist/resources/heavy-command.d.ts.map +1 -1
  560. package/dist/resources/heavy-command.js +479 -7
  561. package/dist/resources/heavy-command.js.map +1 -1
  562. package/dist/resources/pressure-gate.d.ts +148 -0
  563. package/dist/resources/pressure-gate.d.ts.map +1 -0
  564. package/dist/resources/pressure-gate.js +273 -0
  565. package/dist/resources/pressure-gate.js.map +1 -0
  566. package/dist/resources/run-admission.d.ts +33 -45
  567. package/dist/resources/run-admission.d.ts.map +1 -1
  568. package/dist/resources/run-admission.js +50 -118
  569. package/dist/resources/run-admission.js.map +1 -1
  570. package/dist/resources/run-class.d.ts +60 -4
  571. package/dist/resources/run-class.d.ts.map +1 -1
  572. package/dist/resources/run-class.js +474 -6
  573. package/dist/resources/run-class.js.map +1 -1
  574. package/dist/resources/run-governed.d.ts +43 -11
  575. package/dist/resources/run-governed.d.ts.map +1 -1
  576. package/dist/resources/run-governed.js +139 -99
  577. package/dist/resources/run-governed.js.map +1 -1
  578. package/dist/resources/slot-holder.d.ts +12 -4
  579. package/dist/resources/slot-holder.d.ts.map +1 -1
  580. package/dist/resources/slot-holder.js +19 -14
  581. package/dist/resources/slot-holder.js.map +1 -1
  582. package/dist/resources/spawn-wrapper.js +1 -1
  583. package/dist/resources/spawn-wrapper.js.map +1 -1
  584. package/dist/resources/supervisor-admit.d.ts +1 -1
  585. package/dist/resources/supervisor-admit.d.ts.map +1 -1
  586. package/dist/resources/supervisor-admit.js +2 -1
  587. package/dist/resources/supervisor-admit.js.map +1 -1
  588. package/dist/routing/build-command-groups.d.ts +1 -1
  589. package/dist/routing/build-command-groups.d.ts.map +1 -1
  590. package/dist/routing/build-command-groups.js +4 -1
  591. package/dist/routing/build-command-groups.js.map +1 -1
  592. package/dist/runtime/openapi/generate-openapi.d.ts +1 -1
  593. package/dist/runtime/openapi/generate-openapi.d.ts.map +1 -1
  594. package/dist/runtime/openapi/generate-openapi.js +1 -1
  595. package/dist/runtime/openapi/generate-openapi.js.map +1 -1
  596. package/dist/sagas/index.d.ts +3 -1
  597. package/dist/sagas/index.d.ts.map +1 -1
  598. package/dist/sagas/index.js +2 -5
  599. package/dist/sagas/index.js.map +1 -1
  600. package/dist/scaffold/ensure-skills.d.ts.map +1 -1
  601. package/dist/scaffold/ensure-skills.js +58 -2
  602. package/dist/scaffold/ensure-skills.js.map +1 -1
  603. package/dist/scaffold/project-identity.js +1 -1
  604. package/dist/scaffold/project-identity.js.map +1 -1
  605. package/dist/sdk/validator-attest.d.ts +1 -1
  606. package/dist/sdk/validator-attest.d.ts.map +1 -1
  607. package/dist/sdk/validator-attest.js +1 -1
  608. package/dist/sdk/validator-attest.js.map +1 -1
  609. package/dist/sdk/validator-reject.d.ts +1 -1
  610. package/dist/sdk/validator-reject.d.ts.map +1 -1
  611. package/dist/sdk/validator-reject.js +1 -1
  612. package/dist/sdk/validator-reject.js.map +1 -1
  613. package/dist/security/input-sanitization.js +2 -1
  614. package/dist/security/input-sanitization.js.map +1 -1
  615. package/dist/security/override-cap.js +1 -1
  616. package/dist/security/override-cap.js.map +1 -1
  617. package/dist/security/owner-override-auth.js +1 -1
  618. package/dist/security/owner-override-auth.js.map +1 -1
  619. package/dist/security/shared-evidence-tracker.js +1 -1
  620. package/dist/security/shared-evidence-tracker.js.map +1 -1
  621. package/dist/selfimprove/fix-gen.js +35 -93136
  622. package/dist/selfimprove/fix-gen.js.map +3 -3
  623. package/dist/sentient/daemon.d.ts.map +1 -1
  624. package/dist/sentient/daemon.js +3 -0
  625. package/dist/sentient/daemon.js.map +1 -1
  626. package/dist/sentient/tick.d.ts +7 -0
  627. package/dist/sentient/tick.d.ts.map +1 -1
  628. package/dist/sentient/tick.js +11 -0
  629. package/dist/sentient/tick.js.map +1 -1
  630. package/dist/sequence/index.js +1 -1
  631. package/dist/sequence/index.js.map +1 -1
  632. package/dist/session/engine-ops.d.ts +3 -45
  633. package/dist/session/engine-ops.d.ts.map +1 -1
  634. package/dist/session/engine-ops.js +63 -112
  635. package/dist/session/engine-ops.js.map +1 -1
  636. package/dist/session/status-op.d.ts +40 -0
  637. package/dist/session/status-op.d.ts.map +1 -0
  638. package/dist/session/status-op.js +71 -0
  639. package/dist/session/status-op.js.map +1 -0
  640. package/dist/session/task-current.d.ts +31 -0
  641. package/dist/session/task-current.d.ts.map +1 -0
  642. package/dist/session/task-current.js +59 -0
  643. package/dist/session/task-current.js.map +1 -0
  644. package/dist/sessions/assumptions.d.ts +1 -1
  645. package/dist/sessions/assumptions.d.ts.map +1 -1
  646. package/dist/sessions/assumptions.js +1 -1
  647. package/dist/sessions/assumptions.js.map +1 -1
  648. package/dist/sessions/briefing.d.ts.map +1 -1
  649. package/dist/sessions/briefing.js +11 -0
  650. package/dist/sessions/briefing.js.map +1 -1
  651. package/dist/sessions/context-inject.js +1 -1
  652. package/dist/sessions/context-inject.js.map +1 -1
  653. package/dist/sessions/decisions.d.ts +1 -1
  654. package/dist/sessions/decisions.d.ts.map +1 -1
  655. package/dist/sessions/decisions.js +1 -1
  656. package/dist/sessions/decisions.js.map +1 -1
  657. package/dist/sessions/focus-state-store.d.ts.map +1 -1
  658. package/dist/sessions/focus-state-store.js +2 -1
  659. package/dist/sessions/focus-state-store.js.map +1 -1
  660. package/dist/sessions/handoff.js +1 -1
  661. package/dist/sessions/handoff.js.map +1 -1
  662. package/dist/sessions/index.d.ts +1 -2
  663. package/dist/sessions/index.d.ts.map +1 -1
  664. package/dist/sessions/index.js +3 -2
  665. package/dist/sessions/index.js.map +1 -1
  666. package/dist/sessions/session-drift.js +1 -1
  667. package/dist/sessions/session-drift.js.map +1 -1
  668. package/dist/sessions/session-end-snapshot-entry.d.ts +4 -0
  669. package/dist/sessions/session-end-snapshot-entry.d.ts.map +1 -1
  670. package/dist/sessions/session-end-snapshot-entry.js +11 -0
  671. package/dist/sessions/session-end-snapshot-entry.js.map +1 -1
  672. package/dist/sessions/session-end-snapshot.d.ts.map +1 -1
  673. package/dist/sessions/session-end-snapshot.js +4 -0
  674. package/dist/sessions/session-end-snapshot.js.map +1 -1
  675. package/dist/sessions/session-enforcement.js +1 -1
  676. package/dist/sessions/session-enforcement.js.map +1 -1
  677. package/dist/sessions/session-show.d.ts +1 -2
  678. package/dist/sessions/session-show.d.ts.map +1 -1
  679. package/dist/sessions/session-show.js +1 -1
  680. package/dist/sessions/session-show.js.map +1 -1
  681. package/dist/sessions/session-stats.js +1 -1
  682. package/dist/sessions/session-stats.js.map +1 -1
  683. package/dist/sessions/session-suspend.d.ts +1 -2
  684. package/dist/sessions/session-suspend.d.ts.map +1 -1
  685. package/dist/sessions/session-suspend.js +1 -1
  686. package/dist/sessions/session-suspend.js.map +1 -1
  687. package/dist/sessions/session-switch.js +1 -1
  688. package/dist/sessions/session-switch.js.map +1 -1
  689. package/dist/sessions/snapshot.js +1 -1
  690. package/dist/sessions/snapshot.js.map +1 -1
  691. package/dist/sessions/terminal-identity.d.ts +1 -1
  692. package/dist/sessions/terminal-identity.d.ts.map +1 -1
  693. package/dist/sessions/terminal-identity.js +1 -1
  694. package/dist/sessions/terminal-identity.js.map +1 -1
  695. package/dist/setup/sections/integrations.d.ts.map +1 -1
  696. package/dist/setup/sections/integrations.js +9 -0
  697. package/dist/setup/sections/integrations.js.map +1 -1
  698. package/dist/setup/sections/models-roles.js +1 -1
  699. package/dist/setup/sections/models-roles.js.map +1 -1
  700. package/dist/setup/sections/verification.d.ts.map +1 -1
  701. package/dist/setup/sections/verification.js +8 -2
  702. package/dist/setup/sections/verification.js.map +1 -1
  703. package/dist/shutdown.d.ts +24 -0
  704. package/dist/shutdown.d.ts.map +1 -1
  705. package/dist/shutdown.js +30 -1
  706. package/dist/shutdown.js.map +1 -1
  707. package/dist/skills/agents/install.d.ts +46 -6
  708. package/dist/skills/agents/install.d.ts.map +1 -1
  709. package/dist/skills/agents/install.js +86 -17
  710. package/dist/skills/agents/install.js.map +1 -1
  711. package/dist/skills/injection/subagent.js +1 -1
  712. package/dist/skills/injection/subagent.js.map +1 -1
  713. package/dist/skills/manifests/research.d.ts.map +1 -1
  714. package/dist/skills/manifests/research.js +2 -1
  715. package/dist/skills/manifests/research.js.map +1 -1
  716. package/dist/skills/orchestrator/spawn.js +1 -1
  717. package/dist/skills/orchestrator/spawn.js.map +1 -1
  718. package/dist/skills/orchestrator/validator.js +1 -1
  719. package/dist/skills/orchestrator/validator.js.map +1 -1
  720. package/dist/snapshot/index.d.ts.map +1 -1
  721. package/dist/snapshot/index.js +13 -0
  722. package/dist/snapshot/index.js.map +1 -1
  723. package/dist/spawn/agent-identity.js +1 -1
  724. package/dist/spawn/agent-identity.js.map +1 -1
  725. package/dist/stats/index.d.ts.map +1 -1
  726. package/dist/stats/index.js +2 -1
  727. package/dist/stats/index.js.map +1 -1
  728. package/dist/store/agent-install.d.ts.map +1 -1
  729. package/dist/store/agent-install.js +2 -1
  730. package/dist/store/agent-install.js.map +1 -1
  731. package/dist/store/agent-registry-accessor.d.ts +1 -0
  732. package/dist/store/agent-registry-accessor.d.ts.map +1 -1
  733. package/dist/store/agent-registry-accessor.js +3 -1
  734. package/dist/store/agent-registry-accessor.js.map +1 -1
  735. package/dist/store/atomic.js +1 -1
  736. package/dist/store/atomic.js.map +1 -1
  737. package/dist/store/attachment-store.js +1 -1
  738. package/dist/store/attachment-store.js.map +1 -1
  739. package/dist/store/audit-log-schema.d.ts +645 -0
  740. package/dist/store/audit-log-schema.d.ts.map +1 -0
  741. package/dist/store/audit-log-schema.js +30 -0
  742. package/dist/store/audit-log-schema.js.map +1 -0
  743. package/dist/store/background-ops.d.ts +26 -0
  744. package/dist/store/background-ops.d.ts.map +1 -1
  745. package/dist/store/background-ops.js +46 -0
  746. package/dist/store/background-ops.js.map +1 -1
  747. package/dist/store/backup-recover.d.ts +36 -1
  748. package/dist/store/backup-recover.d.ts.map +1 -1
  749. package/dist/store/backup-recover.js +99 -1
  750. package/dist/store/backup-recover.js.map +1 -1
  751. package/dist/store/backup-verify.d.ts +1 -1
  752. package/dist/store/backup-verify.d.ts.map +1 -1
  753. package/dist/store/backup-verify.js +6 -1
  754. package/dist/store/backup-verify.js.map +1 -1
  755. package/dist/store/backup.js +1 -1
  756. package/dist/store/backup.js.map +1 -1
  757. package/dist/store/conduit-sqlite.d.ts.map +1 -1
  758. package/dist/store/conduit-sqlite.js +2 -26
  759. package/dist/store/conduit-sqlite.js.map +1 -1
  760. package/dist/store/converters.js +1 -1
  761. package/dist/store/converters.js.map +1 -1
  762. package/dist/store/db-helpers.js +1 -1
  763. package/dist/store/db-helpers.js.map +1 -1
  764. package/dist/store/dependency-cycles.js +1 -1
  765. package/dist/store/dependency-cycles.js.map +1 -1
  766. package/dist/store/display-id-alias.d.ts +2 -2
  767. package/dist/store/display-id-alias.d.ts.map +1 -1
  768. package/dist/store/display-id-alias.js +5 -28
  769. package/dist/store/display-id-alias.js.map +1 -1
  770. package/dist/store/drizzle-node-sqlite.d.ts +56 -0
  771. package/dist/store/drizzle-node-sqlite.d.ts.map +1 -0
  772. package/dist/store/drizzle-node-sqlite.js +87 -0
  773. package/dist/store/drizzle-node-sqlite.js.map +1 -0
  774. package/dist/store/dual-scope-db.d.ts +26 -33
  775. package/dist/store/dual-scope-db.d.ts.map +1 -1
  776. package/dist/store/dual-scope-db.js +416 -122
  777. package/dist/store/dual-scope-db.js.map +1 -1
  778. package/dist/store/exodus/abort-events.d.ts +134 -0
  779. package/dist/store/exodus/abort-events.d.ts.map +1 -1
  780. package/dist/store/exodus/abort-events.js +201 -0
  781. package/dist/store/exodus/abort-events.js.map +1 -1
  782. package/dist/store/exodus/migrate.d.ts +7 -0
  783. package/dist/store/exodus/migrate.d.ts.map +1 -1
  784. package/dist/store/exodus/migrate.js +156 -118
  785. package/dist/store/exodus/migrate.js.map +1 -1
  786. package/dist/store/exodus/on-open.d.ts +36 -0
  787. package/dist/store/exodus/on-open.d.ts.map +1 -1
  788. package/dist/store/exodus/on-open.js +102 -27
  789. package/dist/store/exodus/on-open.js.map +1 -1
  790. package/dist/store/exodus/prior-recoveries.d.ts +75 -0
  791. package/dist/store/exodus/prior-recoveries.d.ts.map +1 -0
  792. package/dist/store/exodus/prior-recoveries.js +122 -0
  793. package/dist/store/exodus/prior-recoveries.js.map +1 -0
  794. package/dist/store/exodus/reconcile.d.ts.map +1 -1
  795. package/dist/store/exodus/reconcile.js +188 -24
  796. package/dist/store/exodus/reconcile.js.map +1 -1
  797. package/dist/store/exodus/runtime-targets.d.ts +3 -3
  798. package/dist/store/exodus/runtime-targets.js +3 -3
  799. package/dist/store/exodus/task-id-collision-sql.d.ts +52 -0
  800. package/dist/store/exodus/task-id-collision-sql.d.ts.map +1 -0
  801. package/dist/store/exodus/task-id-collision-sql.js +97 -0
  802. package/dist/store/exodus/task-id-collision-sql.js.map +1 -0
  803. package/dist/store/exodus/task-id-remap.d.ts +113 -0
  804. package/dist/store/exodus/task-id-remap.d.ts.map +1 -0
  805. package/dist/store/exodus/task-id-remap.js +301 -0
  806. package/dist/store/exodus/task-id-remap.js.map +1 -0
  807. package/dist/store/exodus/verify-migration.js +1 -1
  808. package/dist/store/exodus/verify-migration.js.map +1 -1
  809. package/dist/store/exodus/write-guard.d.ts +136 -0
  810. package/dist/store/exodus/write-guard.d.ts.map +1 -0
  811. package/dist/store/exodus/write-guard.js +289 -0
  812. package/dist/store/exodus/write-guard.js.map +1 -0
  813. package/dist/store/identity-share.d.ts +31 -0
  814. package/dist/store/identity-share.d.ts.map +1 -0
  815. package/dist/store/identity-share.js +54 -0
  816. package/dist/store/identity-share.js.map +1 -0
  817. package/dist/store/import-remap.js +1 -1
  818. package/dist/store/import-remap.js.map +1 -1
  819. package/dist/store/import-sort.js +1 -1
  820. package/dist/store/import-sort.js.map +1 -1
  821. package/dist/store/json.js +1 -1
  822. package/dist/store/json.js.map +1 -1
  823. package/dist/store/legacy-tasks-lineage.js +3 -3
  824. package/dist/store/legacy-tasks-lineage.js.map +1 -1
  825. package/dist/store/lock.d.ts +17 -0
  826. package/dist/store/lock.d.ts.map +1 -1
  827. package/dist/store/lock.js +18 -1
  828. package/dist/store/lock.js.map +1 -1
  829. package/dist/store/memory-sqlite.d.ts.map +1 -1
  830. package/dist/store/memory-sqlite.js +2 -25
  831. package/dist/store/memory-sqlite.js.map +1 -1
  832. package/dist/store/migration-files.d.ts +30 -0
  833. package/dist/store/migration-files.d.ts.map +1 -0
  834. package/dist/store/migration-files.js +59 -0
  835. package/dist/store/migration-files.js.map +1 -0
  836. package/dist/store/migration-manager.d.ts.map +1 -1
  837. package/dist/store/migration-manager.js +14 -14
  838. package/dist/store/migration-manager.js.map +1 -1
  839. package/dist/store/migration-runner.d.ts.map +1 -1
  840. package/dist/store/migration-runner.js +2 -2
  841. package/dist/store/migration-runner.js.map +1 -1
  842. package/dist/store/migration-sqlite.d.ts +1 -1
  843. package/dist/store/migration-sqlite.d.ts.map +1 -1
  844. package/dist/store/migration-sqlite.js +290 -355
  845. package/dist/store/migration-sqlite.js.map +1 -1
  846. package/dist/store/open-cleo-db.d.ts.map +1 -1
  847. package/dist/store/open-cleo-db.js +4 -2
  848. package/dist/store/open-cleo-db.js.map +1 -1
  849. package/dist/store/pid-alive.d.ts +15 -0
  850. package/dist/store/pid-alive.d.ts.map +1 -0
  851. package/dist/store/pid-alive.js +24 -0
  852. package/dist/store/pid-alive.js.map +1 -0
  853. package/dist/store/portable-bundle-scan.d.ts +1 -1
  854. package/dist/store/portable-bundle-scan.d.ts.map +1 -1
  855. package/dist/store/portable-bundle-scan.js +1 -1
  856. package/dist/store/portable-bundle-scan.js.map +1 -1
  857. package/dist/store/portable-bundle.d.ts +10 -1
  858. package/dist/store/portable-bundle.d.ts.map +1 -1
  859. package/dist/store/portable-bundle.js +10 -1
  860. package/dist/store/portable-bundle.js.map +1 -1
  861. package/dist/store/recover-malformed-db.d.ts +1 -1
  862. package/dist/store/recover-malformed-db.d.ts.map +1 -1
  863. package/dist/store/recover-malformed-db.js +1 -1
  864. package/dist/store/recover-malformed-db.js.map +1 -1
  865. package/dist/store/repair-malformed-dbs.d.ts +1 -1
  866. package/dist/store/repair-malformed-dbs.d.ts.map +1 -1
  867. package/dist/store/repair-malformed-dbs.js +1 -1
  868. package/dist/store/repair-malformed-dbs.js.map +1 -1
  869. package/dist/store/restore-marker.d.ts +89 -0
  870. package/dist/store/restore-marker.d.ts.map +1 -0
  871. package/dist/store/restore-marker.js +197 -0
  872. package/dist/store/restore-marker.js.map +1 -0
  873. package/dist/store/restore-store.d.ts +85 -0
  874. package/dist/store/restore-store.d.ts.map +1 -0
  875. package/dist/store/restore-store.js +391 -0
  876. package/dist/store/restore-store.js.map +1 -0
  877. package/dist/store/row-identity.d.ts +123 -1
  878. package/dist/store/row-identity.d.ts.map +1 -1
  879. package/dist/store/row-identity.js +454 -80
  880. package/dist/store/row-identity.js.map +1 -1
  881. package/dist/store/schema/agent-registry-schema.d.ts +1 -1
  882. package/dist/store/schema/agent-registry-schema.d.ts.map +1 -1
  883. package/dist/store/schema/agent-registry-schema.js +5 -1
  884. package/dist/store/schema/agent-registry-schema.js.map +1 -1
  885. package/dist/store/schema/cleo-global/agent-registry.d.ts +1 -1
  886. package/dist/store/schema/cleo-global/agent-registry.d.ts.map +1 -1
  887. package/dist/store/schema/cleo-global/agent-registry.js +9 -5
  888. package/dist/store/schema/cleo-global/agent-registry.js.map +1 -1
  889. package/dist/store/schema/cleo-global/models-catalog.js +1 -1
  890. package/dist/store/schema/cleo-global/models-catalog.js.map +1 -1
  891. package/dist/store/schema/cleo-global/nexus.js +1 -1
  892. package/dist/store/schema/cleo-global/nexus.js.map +1 -1
  893. package/dist/store/schema/cleo-project/provenance-commits.d.ts +1 -1
  894. package/dist/store/schema/cleo-project/provenance-orphans.d.ts +1 -1
  895. package/dist/store/schema/cleo-project/provenance-orphans.d.ts.map +1 -1
  896. package/dist/store/schema/cleo-project/provenance-orphans.js +9 -2
  897. package/dist/store/schema/cleo-project/provenance-orphans.js.map +1 -1
  898. package/dist/store/schema/cleo-project/provenance-rest.d.ts +1 -1
  899. package/dist/store/schema/cleo-project/provenance-rest.js +1 -1
  900. package/dist/store/schema/cleo-project/provenance-rest.js.map +1 -1
  901. package/dist/store/schema/cleo-shared/brain.js +1 -1
  902. package/dist/store/schema/cleo-shared/brain.js.map +1 -1
  903. package/dist/store/schema/memory-schema.d.ts +1 -1
  904. package/dist/store/schema/memory-schema.d.ts.map +1 -1
  905. package/dist/store/schema/memory-schema.js +1 -1
  906. package/dist/store/schema/memory-schema.js.map +1 -1
  907. package/dist/store/schema/nexus-schema.js +1 -1
  908. package/dist/store/schema/nexus-schema.js.map +1 -1
  909. package/dist/store/service-host-matcher.d.ts +1 -1
  910. package/dist/store/service-host-matcher.d.ts.map +1 -1
  911. package/dist/store/service-host-matcher.js +1 -1
  912. package/dist/store/service-host-matcher.js.map +1 -1
  913. package/dist/store/service-oauth.js +1 -1
  914. package/dist/store/service-oauth.js.map +1 -1
  915. package/dist/store/session-store.d.ts.map +1 -1
  916. package/dist/store/session-store.js +7 -1
  917. package/dist/store/session-store.js.map +1 -1
  918. package/dist/store/sqlite-backup.d.ts +1 -1
  919. package/dist/store/sqlite-backup.d.ts.map +1 -1
  920. package/dist/store/sqlite-backup.js +1 -1
  921. package/dist/store/sqlite-backup.js.map +1 -1
  922. package/dist/store/sqlite-data-accessor.d.ts +52 -1
  923. package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
  924. package/dist/store/sqlite-data-accessor.js +95 -22
  925. package/dist/store/sqlite-data-accessor.js.map +1 -1
  926. package/dist/store/sqlite-native.d.ts.map +1 -1
  927. package/dist/store/sqlite-native.js +9 -9
  928. package/dist/store/sqlite-native.js.map +1 -1
  929. package/dist/store/sqlite-pragmas.d.ts +12 -5
  930. package/dist/store/sqlite-pragmas.d.ts.map +1 -1
  931. package/dist/store/sqlite-pragmas.js +13 -2
  932. package/dist/store/sqlite-pragmas.js.map +1 -1
  933. package/dist/store/sqlite.d.ts.map +1 -1
  934. package/dist/store/sqlite.js +7 -32
  935. package/dist/store/sqlite.js.map +1 -1
  936. package/dist/store/status-registry.d.ts +1 -1
  937. package/dist/store/status-registry.d.ts.map +1 -1
  938. package/dist/store/status-registry.js +1 -1
  939. package/dist/store/status-registry.js.map +1 -1
  940. package/dist/store/sync/apply/applier.d.ts +119 -0
  941. package/dist/store/sync/apply/applier.d.ts.map +1 -0
  942. package/dist/store/sync/apply/applier.js +1239 -0
  943. package/dist/store/sync/apply/applier.js.map +1 -0
  944. package/dist/store/sync/apply/fk.d.ts +47 -0
  945. package/dist/store/sync/apply/fk.d.ts.map +1 -0
  946. package/dist/store/sync/apply/fk.js +89 -0
  947. package/dist/store/sync/apply/fk.js.map +1 -0
  948. package/dist/store/sync/apply/footprints.d.ts +60 -0
  949. package/dist/store/sync/apply/footprints.d.ts.map +1 -0
  950. package/dist/store/sync/apply/footprints.js +235 -0
  951. package/dist/store/sync/apply/footprints.js.map +1 -0
  952. package/dist/store/sync/apply/frame.d.ts +80 -0
  953. package/dist/store/sync/apply/frame.d.ts.map +1 -0
  954. package/dist/store/sync/apply/frame.js +127 -0
  955. package/dist/store/sync/apply/frame.js.map +1 -0
  956. package/dist/store/sync/apply/index.d.ts +11 -0
  957. package/dist/store/sync/apply/index.d.ts.map +1 -0
  958. package/dist/store/sync/apply/index.js +11 -0
  959. package/dist/store/sync/apply/index.js.map +1 -0
  960. package/dist/store/sync/apply/parent-delete.d.ts +38 -0
  961. package/dist/store/sync/apply/parent-delete.d.ts.map +1 -0
  962. package/dist/store/sync/apply/parent-delete.js +41 -0
  963. package/dist/store/sync/apply/parent-delete.js.map +1 -0
  964. package/dist/store/sync/apply/post-apply.d.ts +67 -0
  965. package/dist/store/sync/apply/post-apply.d.ts.map +1 -0
  966. package/dist/store/sync/apply/post-apply.js +118 -0
  967. package/dist/store/sync/apply/post-apply.js.map +1 -0
  968. package/dist/store/sync/apply/refs.d.ts +60 -0
  969. package/dist/store/sync/apply/refs.d.ts.map +1 -0
  970. package/dist/store/sync/apply/refs.js +90 -0
  971. package/dist/store/sync/apply/refs.js.map +1 -0
  972. package/dist/store/sync/apply/write-api.d.ts +195 -0
  973. package/dist/store/sync/apply/write-api.d.ts.map +1 -0
  974. package/dist/store/sync/apply/write-api.js +416 -0
  975. package/dist/store/sync/apply/write-api.js.map +1 -0
  976. package/dist/store/sync/apply-intent.d.ts +117 -0
  977. package/dist/store/sync/apply-intent.d.ts.map +1 -0
  978. package/dist/store/sync/apply-intent.js +225 -0
  979. package/dist/store/sync/apply-intent.js.map +1 -0
  980. package/dist/store/sync/capture.d.ts +32 -2
  981. package/dist/store/sync/capture.d.ts.map +1 -1
  982. package/dist/store/sync/capture.js +47 -13
  983. package/dist/store/sync/capture.js.map +1 -1
  984. package/dist/store/sync/conflicts.d.ts +81 -0
  985. package/dist/store/sync/conflicts.d.ts.map +1 -0
  986. package/dist/store/sync/conflicts.js +98 -0
  987. package/dist/store/sync/conflicts.js.map +1 -0
  988. package/dist/store/sync/field-leave.d.ts +146 -0
  989. package/dist/store/sync/field-leave.d.ts.map +1 -0
  990. package/dist/store/sync/field-leave.js +241 -0
  991. package/dist/store/sync/field-leave.js.map +1 -0
  992. package/dist/store/sync/flags.d.ts +119 -0
  993. package/dist/store/sync/flags.d.ts.map +1 -1
  994. package/dist/store/sync/flags.js +360 -0
  995. package/dist/store/sync/flags.js.map +1 -1
  996. package/dist/store/sync/held.d.ts +197 -0
  997. package/dist/store/sync/held.d.ts.map +1 -0
  998. package/dist/store/sync/held.js +314 -0
  999. package/dist/store/sync/held.js.map +1 -0
  1000. package/dist/store/sync/identity-fill.d.ts.map +1 -1
  1001. package/dist/store/sync/identity-fill.js +10 -2
  1002. package/dist/store/sync/identity-fill.js.map +1 -1
  1003. package/dist/store/sync/inbox.d.ts +114 -0
  1004. package/dist/store/sync/inbox.d.ts.map +1 -0
  1005. package/dist/store/sync/inbox.js +222 -0
  1006. package/dist/store/sync/inbox.js.map +1 -0
  1007. package/dist/store/sync/inherit.d.ts +36 -0
  1008. package/dist/store/sync/inherit.d.ts.map +1 -0
  1009. package/dist/store/sync/inherit.js +38 -0
  1010. package/dist/store/sync/inherit.js.map +1 -0
  1011. package/dist/store/sync/merge/engine.d.ts +114 -0
  1012. package/dist/store/sync/merge/engine.d.ts.map +1 -0
  1013. package/dist/store/sync/merge/engine.js +698 -0
  1014. package/dist/store/sync/merge/engine.js.map +1 -0
  1015. package/dist/store/sync/merge/index.d.ts +11 -0
  1016. package/dist/store/sync/merge/index.d.ts.map +1 -0
  1017. package/dist/store/sync/merge/index.js +11 -0
  1018. package/dist/store/sync/merge/index.js.map +1 -0
  1019. package/dist/store/sync/merge/rules.d.ts +91 -0
  1020. package/dist/store/sync/merge/rules.d.ts.map +1 -0
  1021. package/dist/store/sync/merge/rules.js +151 -0
  1022. package/dist/store/sync/merge/rules.js.map +1 -0
  1023. package/dist/store/sync/merge/types.d.ts +206 -0
  1024. package/dist/store/sync/merge/types.d.ts.map +1 -0
  1025. package/dist/store/sync/merge/types.js +15 -0
  1026. package/dist/store/sync/merge/types.js.map +1 -0
  1027. package/dist/store/sync/migration-hooks.d.ts +47 -0
  1028. package/dist/store/sync/migration-hooks.d.ts.map +1 -0
  1029. package/dist/store/sync/migration-hooks.js +74 -0
  1030. package/dist/store/sync/migration-hooks.js.map +1 -0
  1031. package/dist/store/sync/netting.d.ts +5 -0
  1032. package/dist/store/sync/netting.d.ts.map +1 -1
  1033. package/dist/store/sync/netting.js +29 -2
  1034. package/dist/store/sync/netting.js.map +1 -1
  1035. package/dist/store/sync/remap.d.ts +72 -0
  1036. package/dist/store/sync/remap.d.ts.map +1 -0
  1037. package/dist/store/sync/remap.js +209 -0
  1038. package/dist/store/sync/remap.js.map +1 -0
  1039. package/dist/store/sync/repair.d.ts +180 -0
  1040. package/dist/store/sync/repair.d.ts.map +1 -0
  1041. package/dist/store/sync/repair.js +499 -0
  1042. package/dist/store/sync/repair.js.map +1 -0
  1043. package/dist/store/sync/replica-registry.d.ts +54 -0
  1044. package/dist/store/sync/replica-registry.d.ts.map +1 -1
  1045. package/dist/store/sync/replica-registry.js +72 -2
  1046. package/dist/store/sync/replica-registry.js.map +1 -1
  1047. package/dist/store/sync/replica.d.ts +71 -9
  1048. package/dist/store/sync/replica.d.ts.map +1 -1
  1049. package/dist/store/sync/replica.js +95 -11
  1050. package/dist/store/sync/replica.js.map +1 -1
  1051. package/dist/store/sync/row-meta.d.ts +148 -0
  1052. package/dist/store/sync/row-meta.d.ts.map +1 -0
  1053. package/dist/store/sync/row-meta.js +200 -0
  1054. package/dist/store/sync/row-meta.js.map +1 -0
  1055. package/dist/store/sync/schema.d.ts +13 -5
  1056. package/dist/store/sync/schema.d.ts.map +1 -1
  1057. package/dist/store/sync/schema.js +34 -7
  1058. package/dist/store/sync/schema.js.map +1 -1
  1059. package/dist/store/sync/sealer-values.d.ts.map +1 -1
  1060. package/dist/store/sync/sealer-values.js +1 -0
  1061. package/dist/store/sync/sealer-values.js.map +1 -1
  1062. package/dist/store/sync/sealer.d.ts +96 -0
  1063. package/dist/store/sync/sealer.d.ts.map +1 -1
  1064. package/dist/store/sync/sealer.js +532 -58
  1065. package/dist/store/sync/sealer.js.map +1 -1
  1066. package/dist/store/sync/sequencing.d.ts +175 -0
  1067. package/dist/store/sync/sequencing.d.ts.map +1 -0
  1068. package/dist/store/sync/sequencing.js +295 -0
  1069. package/dist/store/sync/sequencing.js.map +1 -0
  1070. package/dist/store/sync/structural.d.ts +30 -2
  1071. package/dist/store/sync/structural.d.ts.map +1 -1
  1072. package/dist/store/sync/structural.js +64 -2
  1073. package/dist/store/sync/structural.js.map +1 -1
  1074. package/dist/store/sync/timestamp-canon.d.ts +44 -0
  1075. package/dist/store/sync/timestamp-canon.d.ts.map +1 -0
  1076. package/dist/store/sync/timestamp-canon.js +102 -0
  1077. package/dist/store/sync/timestamp-canon.js.map +1 -0
  1078. package/dist/store/sync/timestamps.d.ts +1 -30
  1079. package/dist/store/sync/timestamps.d.ts.map +1 -1
  1080. package/dist/store/sync/timestamps.js +2 -89
  1081. package/dist/store/sync/timestamps.js.map +1 -1
  1082. package/dist/store/sync/trigger-classes.d.ts +8 -0
  1083. package/dist/store/sync/trigger-classes.d.ts.map +1 -1
  1084. package/dist/store/sync/trigger-classes.js +13 -0
  1085. package/dist/store/sync/trigger-classes.js.map +1 -1
  1086. package/dist/store/sync/write-actor.d.ts +58 -0
  1087. package/dist/store/sync/write-actor.d.ts.map +1 -0
  1088. package/dist/store/sync/write-actor.js +67 -0
  1089. package/dist/store/sync/write-actor.js.map +1 -0
  1090. package/dist/store/table-classification.d.ts +27 -0
  1091. package/dist/store/table-classification.d.ts.map +1 -1
  1092. package/dist/store/table-classification.js +116 -0
  1093. package/dist/store/table-classification.js.map +1 -1
  1094. package/dist/store/task-claim.d.ts +1 -1
  1095. package/dist/store/task-claim.d.ts.map +1 -1
  1096. package/dist/store/task-claim.js +1 -1
  1097. package/dist/store/task-claim.js.map +1 -1
  1098. package/dist/store/task-reference-columns.d.ts +27 -0
  1099. package/dist/store/task-reference-columns.d.ts.map +1 -0
  1100. package/dist/store/task-reference-columns.js +65 -0
  1101. package/dist/store/task-reference-columns.js.map +1 -0
  1102. package/dist/store/task-version.d.ts +1 -1
  1103. package/dist/store/task-version.d.ts.map +1 -1
  1104. package/dist/store/task-version.js +1 -1
  1105. package/dist/store/task-version.js.map +1 -1
  1106. package/dist/store/tasks-schema.d.ts +2 -1
  1107. package/dist/store/tasks-schema.d.ts.map +1 -1
  1108. package/dist/store/tasks-schema.js +5 -4
  1109. package/dist/store/tasks-schema.js.map +1 -1
  1110. package/dist/store/tasks-sqlite.d.ts +1 -1
  1111. package/dist/store/tasks-sqlite.d.ts.map +1 -1
  1112. package/dist/store/tasks-sqlite.js +3 -1
  1113. package/dist/store/tasks-sqlite.js.map +1 -1
  1114. package/dist/store/twin-collapse.d.ts +43 -14
  1115. package/dist/store/twin-collapse.d.ts.map +1 -1
  1116. package/dist/store/twin-collapse.js +373 -32
  1117. package/dist/store/twin-collapse.js.map +1 -1
  1118. package/dist/store/validation-schemas.d.ts +44 -674
  1119. package/dist/store/validation-schemas.d.ts.map +1 -1
  1120. package/dist/store/validation-schemas.js +2 -22
  1121. package/dist/store/validation-schemas.js.map +1 -1
  1122. package/dist/store/vault-manifest.d.ts +6 -2
  1123. package/dist/store/vault-manifest.d.ts.map +1 -1
  1124. package/dist/store/vault-manifest.js +10 -3
  1125. package/dist/store/vault-manifest.js.map +1 -1
  1126. package/dist/store/worktree-build-guard.js +1 -1
  1127. package/dist/store/worktree-build-guard.js.map +1 -1
  1128. package/dist/store/worktree-isolation-guard.js +1 -1
  1129. package/dist/store/worktree-isolation-guard.js.map +1 -1
  1130. package/dist/store/writer-lease.d.ts.map +1 -1
  1131. package/dist/store/writer-lease.js +1 -11
  1132. package/dist/store/writer-lease.js.map +1 -1
  1133. package/dist/store/zod-schema-factory.d.ts +16 -0
  1134. package/dist/store/zod-schema-factory.d.ts.map +1 -0
  1135. package/dist/store/zod-schema-factory.js +23 -0
  1136. package/dist/store/zod-schema-factory.js.map +1 -0
  1137. package/dist/system/backup.d.ts +106 -0
  1138. package/dist/system/backup.d.ts.map +1 -1
  1139. package/dist/system/backup.js +295 -19
  1140. package/dist/system/backup.js.map +1 -1
  1141. package/dist/system/cleanup.js +1 -1
  1142. package/dist/system/cleanup.js.map +1 -1
  1143. package/dist/system/health.d.ts +13 -0
  1144. package/dist/system/health.d.ts.map +1 -1
  1145. package/dist/system/health.js +96 -1
  1146. package/dist/system/health.js.map +1 -1
  1147. package/dist/system/labels.js +1 -1
  1148. package/dist/system/labels.js.map +1 -1
  1149. package/dist/system/migrate.js +1 -1
  1150. package/dist/system/migrate.js.map +1 -1
  1151. package/dist/system/safestop.d.ts.map +1 -1
  1152. package/dist/system/safestop.js +1 -1
  1153. package/dist/system/safestop.js.map +1 -1
  1154. package/dist/task-work/current.d.ts +34 -0
  1155. package/dist/task-work/current.d.ts.map +1 -0
  1156. package/dist/task-work/current.js +34 -0
  1157. package/dist/task-work/current.js.map +1 -0
  1158. package/dist/task-work/index.d.ts +2 -19
  1159. package/dist/task-work/index.d.ts.map +1 -1
  1160. package/dist/task-work/index.js +6 -20
  1161. package/dist/task-work/index.js.map +1 -1
  1162. package/dist/tasks/ac-identity.d.ts +28 -0
  1163. package/dist/tasks/ac-identity.d.ts.map +1 -0
  1164. package/dist/tasks/ac-identity.js +43 -0
  1165. package/dist/tasks/ac-identity.js.map +1 -0
  1166. package/dist/tasks/ac-immutability.d.ts +1 -1
  1167. package/dist/tasks/ac-immutability.d.ts.map +1 -1
  1168. package/dist/tasks/ac-immutability.js +1 -1
  1169. package/dist/tasks/ac-immutability.js.map +1 -1
  1170. package/dist/tasks/ac-table.d.ts +2 -14
  1171. package/dist/tasks/ac-table.d.ts.map +1 -1
  1172. package/dist/tasks/ac-table.js +6 -29
  1173. package/dist/tasks/ac-table.js.map +1 -1
  1174. package/dist/tasks/acceptance-input.js +1 -1
  1175. package/dist/tasks/acceptance-input.js.map +1 -1
  1176. package/dist/tasks/add.d.ts.map +1 -1
  1177. package/dist/tasks/add.js +3 -1
  1178. package/dist/tasks/add.js.map +1 -1
  1179. package/dist/tasks/affected-packages.d.ts +100 -19
  1180. package/dist/tasks/affected-packages.d.ts.map +1 -1
  1181. package/dist/tasks/affected-packages.js +169 -32
  1182. package/dist/tasks/affected-packages.js.map +1 -1
  1183. package/dist/tasks/affected-template.d.ts +93 -0
  1184. package/dist/tasks/affected-template.d.ts.map +1 -0
  1185. package/dist/tasks/affected-template.js +198 -0
  1186. package/dist/tasks/affected-template.js.map +1 -0
  1187. package/dist/tasks/archive.d.ts.map +1 -1
  1188. package/dist/tasks/archive.js +1 -1
  1189. package/dist/tasks/archive.js.map +1 -1
  1190. package/dist/tasks/axis-filters.d.ts.map +1 -1
  1191. package/dist/tasks/axis-filters.js +2 -1
  1192. package/dist/tasks/axis-filters.js.map +1 -1
  1193. package/dist/tasks/child-disposition.js +1 -1
  1194. package/dist/tasks/child-disposition.js.map +1 -1
  1195. package/dist/tasks/collection.js +1 -1
  1196. package/dist/tasks/collection.js.map +1 -1
  1197. package/dist/tasks/command-line.d.ts +4 -1
  1198. package/dist/tasks/command-line.d.ts.map +1 -1
  1199. package/dist/tasks/command-line.js +7 -2
  1200. package/dist/tasks/command-line.js.map +1 -1
  1201. package/dist/tasks/complete.d.ts.map +1 -1
  1202. package/dist/tasks/complete.js +2 -1
  1203. package/dist/tasks/complete.js.map +1 -1
  1204. package/dist/tasks/decompose.js +1 -1
  1205. package/dist/tasks/decompose.js.map +1 -1
  1206. package/dist/tasks/delete.js +1 -1
  1207. package/dist/tasks/delete.js.map +1 -1
  1208. package/dist/tasks/done-plan.d.ts +2 -1
  1209. package/dist/tasks/done-plan.d.ts.map +1 -1
  1210. package/dist/tasks/done-plan.js +21 -21
  1211. package/dist/tasks/done-plan.js.map +1 -1
  1212. package/dist/tasks/done-record.d.ts +1 -1
  1213. package/dist/tasks/done-record.d.ts.map +1 -1
  1214. package/dist/tasks/done-record.js +1 -1
  1215. package/dist/tasks/done-record.js.map +1 -1
  1216. package/dist/tasks/duplicate-detector.d.ts.map +1 -1
  1217. package/dist/tasks/duplicate-detector.js +11 -5
  1218. package/dist/tasks/duplicate-detector.js.map +1 -1
  1219. package/dist/tasks/enforcement.d.ts +2 -1
  1220. package/dist/tasks/enforcement.d.ts.map +1 -1
  1221. package/dist/tasks/enforcement.js +1 -1
  1222. package/dist/tasks/enforcement.js.map +1 -1
  1223. package/dist/tasks/engine-wrap-ops.js +1 -1
  1224. package/dist/tasks/engine-wrap-ops.js.map +1 -1
  1225. package/dist/tasks/engine-wrap.d.ts.map +1 -1
  1226. package/dist/tasks/engine-wrap.js +7 -3
  1227. package/dist/tasks/engine-wrap.js.map +1 -1
  1228. package/dist/tasks/epic-enforcement.js +1 -1
  1229. package/dist/tasks/epic-enforcement.js.map +1 -1
  1230. package/dist/tasks/evidence.d.ts.map +1 -1
  1231. package/dist/tasks/evidence.js +216 -20
  1232. package/dist/tasks/evidence.js.map +1 -1
  1233. package/dist/tasks/find.js +1 -1
  1234. package/dist/tasks/find.js.map +1 -1
  1235. package/dist/tasks/gate-result-cache.js +1 -1
  1236. package/dist/tasks/gate-result-cache.js.map +1 -1
  1237. package/dist/tasks/gate-runner.d.ts.map +1 -1
  1238. package/dist/tasks/gate-runner.js +1 -1
  1239. package/dist/tasks/gate-runner.js.map +1 -1
  1240. package/dist/tasks/heavy-tool-env.d.ts +454 -19
  1241. package/dist/tasks/heavy-tool-env.d.ts.map +1 -1
  1242. package/dist/tasks/heavy-tool-env.js +818 -42
  1243. package/dist/tasks/heavy-tool-env.js.map +1 -1
  1244. package/dist/tasks/index.d.ts +3 -3
  1245. package/dist/tasks/index.d.ts.map +1 -1
  1246. package/dist/tasks/index.js +3 -3
  1247. package/dist/tasks/index.js.map +1 -1
  1248. package/dist/tasks/labels.js +1 -1
  1249. package/dist/tasks/labels.js.map +1 -1
  1250. package/dist/tasks/nexus-impact-gate.js +1 -1
  1251. package/dist/tasks/nexus-impact-gate.js.map +1 -1
  1252. package/dist/tasks/pipeline-stage.js +1 -1
  1253. package/dist/tasks/pipeline-stage.js.map +1 -1
  1254. package/dist/tasks/population.js +1 -1
  1255. package/dist/tasks/population.js.map +1 -1
  1256. package/dist/tasks/ranking-audit.js +1 -1
  1257. package/dist/tasks/ranking-audit.js.map +1 -1
  1258. package/dist/tasks/reconcile-scope.js +1 -1
  1259. package/dist/tasks/reconcile-scope.js.map +1 -1
  1260. package/dist/tasks/relates.js +1 -1
  1261. package/dist/tasks/relates.js.map +1 -1
  1262. package/dist/tasks/req.d.ts.map +1 -1
  1263. package/dist/tasks/req.js +2 -1
  1264. package/dist/tasks/req.js.map +1 -1
  1265. package/dist/tasks/severity-attestation.d.ts +1 -1
  1266. package/dist/tasks/severity-attestation.d.ts.map +1 -1
  1267. package/dist/tasks/severity-attestation.js +1 -1
  1268. package/dist/tasks/severity-attestation.js.map +1 -1
  1269. package/dist/tasks/show.d.ts.map +1 -1
  1270. package/dist/tasks/show.js +47 -3
  1271. package/dist/tasks/show.js.map +1 -1
  1272. package/dist/tasks/task-import.js +1 -1
  1273. package/dist/tasks/task-import.js.map +1 -1
  1274. package/dist/tasks/task-reparent.d.ts.map +1 -1
  1275. package/dist/tasks/task-reparent.js +2 -1
  1276. package/dist/tasks/task-reparent.js.map +1 -1
  1277. package/dist/tasks/test-run-binding.d.ts.map +1 -1
  1278. package/dist/tasks/test-run-binding.js +9 -2
  1279. package/dist/tasks/test-run-binding.js.map +1 -1
  1280. package/dist/tasks/tool-cache-env.d.ts +20 -13
  1281. package/dist/tasks/tool-cache-env.d.ts.map +1 -1
  1282. package/dist/tasks/tool-cache-env.js +27 -48
  1283. package/dist/tasks/tool-cache-env.js.map +1 -1
  1284. package/dist/tasks/tool-cache.d.ts +30 -7
  1285. package/dist/tasks/tool-cache.d.ts.map +1 -1
  1286. package/dist/tasks/tool-cache.js +74 -20
  1287. package/dist/tasks/tool-cache.js.map +1 -1
  1288. package/dist/tasks/tool-resolver.d.ts +8 -0
  1289. package/dist/tasks/tool-resolver.d.ts.map +1 -1
  1290. package/dist/tasks/tool-resolver.js +15 -1
  1291. package/dist/tasks/tool-resolver.js.map +1 -1
  1292. package/dist/tasks/tool-runner-guard.d.ts +131 -0
  1293. package/dist/tasks/tool-runner-guard.d.ts.map +1 -0
  1294. package/dist/tasks/tool-runner-guard.js +141 -0
  1295. package/dist/tasks/tool-runner-guard.js.map +1 -0
  1296. package/dist/tasks/tool-semaphore.d.ts +106 -302
  1297. package/dist/tasks/tool-semaphore.d.ts.map +1 -1
  1298. package/dist/tasks/tool-semaphore.js +132 -558
  1299. package/dist/tasks/tool-semaphore.js.map +1 -1
  1300. package/dist/tasks/update.d.ts.map +1 -1
  1301. package/dist/tasks/update.js +2 -1
  1302. package/dist/tasks/update.js.map +1 -1
  1303. package/dist/upgrade.d.ts.map +1 -1
  1304. package/dist/upgrade.js +35 -31
  1305. package/dist/upgrade.js.map +1 -1
  1306. package/dist/validation/doctor/checks.d.ts +41 -0
  1307. package/dist/validation/doctor/checks.d.ts.map +1 -1
  1308. package/dist/validation/doctor/checks.js +251 -0
  1309. package/dist/validation/doctor/checks.js.map +1 -1
  1310. package/dist/validation/doctor/index.d.ts +1 -1
  1311. package/dist/validation/doctor/index.d.ts.map +1 -1
  1312. package/dist/validation/doctor/index.js +1 -1
  1313. package/dist/validation/doctor/index.js.map +1 -1
  1314. package/dist/validation/engine-ops.js +1 -1
  1315. package/dist/validation/engine-ops.js.map +1 -1
  1316. package/dist/validation/engine.d.ts +1 -1
  1317. package/dist/validation/engine.d.ts.map +1 -1
  1318. package/dist/validation/engine.js +2 -1
  1319. package/dist/validation/engine.js.map +1 -1
  1320. package/dist/validation/index.d.ts +1 -1
  1321. package/dist/validation/index.d.ts.map +1 -1
  1322. package/dist/validation/index.js +1 -1
  1323. package/dist/validation/index.js.map +1 -1
  1324. package/dist/validation/operation-gate-validators.js +1 -1
  1325. package/dist/validation/operation-gate-validators.js.map +1 -1
  1326. package/dist/validation/protocol-common.js +1 -1
  1327. package/dist/validation/protocol-common.js.map +1 -1
  1328. package/dist/validation/protocols/_shared.js +1 -1
  1329. package/dist/validation/protocols/_shared.js.map +1 -1
  1330. package/dist/validation/validate-ops.js +1 -1
  1331. package/dist/validation/validate-ops.js.map +1 -1
  1332. package/dist/validation/verification.js +1 -1
  1333. package/dist/validation/verification.js.map +1 -1
  1334. package/dist/workgraph/index.d.ts +1 -1
  1335. package/dist/workgraph/index.d.ts.map +1 -1
  1336. package/dist/workgraph/index.js +1 -1
  1337. package/dist/workgraph/index.js.map +1 -1
  1338. package/dist/workgraph/reparent-preflight.d.ts +1 -2
  1339. package/dist/workgraph/reparent-preflight.d.ts.map +1 -1
  1340. package/dist/workgraph/reparent-preflight.js +1 -1
  1341. package/dist/workgraph/reparent-preflight.js.map +1 -1
  1342. package/dist/workgraph/scaffold-validate.js +1 -1
  1343. package/dist/workgraph/scaffold-validate.js.map +1 -1
  1344. package/dist/worktree/force-unlock.d.ts +1 -1
  1345. package/dist/worktree/force-unlock.d.ts.map +1 -1
  1346. package/dist/worktree/force-unlock.js +1 -1
  1347. package/dist/worktree/force-unlock.js.map +1 -1
  1348. package/dist/worktree/isolation.d.ts +1 -1
  1349. package/dist/worktree/isolation.d.ts.map +1 -1
  1350. package/dist/worktree/isolation.js +1 -1
  1351. package/dist/worktree/isolation.js.map +1 -1
  1352. package/dist/worktree/list.d.ts +1 -1
  1353. package/dist/worktree/list.d.ts.map +1 -1
  1354. package/dist/worktree/list.js +1 -1
  1355. package/dist/worktree/list.js.map +1 -1
  1356. package/dist/worktree/prune.d.ts +1 -1
  1357. package/dist/worktree/prune.d.ts.map +1 -1
  1358. package/dist/worktree/prune.js +1 -1
  1359. package/dist/worktree/prune.js.map +1 -1
  1360. package/dist/worktree/worktree-adopt.d.ts +1 -2
  1361. package/dist/worktree/worktree-adopt.d.ts.map +1 -1
  1362. package/dist/worktree/worktree-adopt.js +1 -1
  1363. package/dist/worktree/worktree-adopt.js.map +1 -1
  1364. package/migrations/sync-journal/20261004120000_t12757-apply-intent/migration.sql +21 -0
  1365. package/migrations/sync-journal/20261005120000_t12344-inbox/migration.sql +67 -0
  1366. package/migrations/sync-journal/20261006120000_t13193-rebase-undo/migration.sql +51 -0
  1367. package/migrations/sync-journal/20261006130000_t13193-rebase-state/migration.sql +17 -0
  1368. package/migrations/sync-journal/20261006140000_t13193-held-rows/migration.sql +24 -0
  1369. package/package.json +13 -13
  1370. package/schemas/project-context.schema.json +19 -1
  1371. package/templates/CLEO-INJECTION.md +11 -11
  1372. package/templates/CLEO-REFERENCE.md +2 -2
  1373. package/templates/workflows/release-prepare.yml.tmpl +10 -10
@@ -28,18 +28,49 @@
28
28
  * |---|---|---|
29
29
  * | `NODE_OPTIONS=--max-old-space-size=N` | Heap ceiling for EVERY node process in the tree, inherited | node docs; appended, never clobbered |
30
30
  * | `VITEST_MAX_WORKERS=N` | `if (process.env.VITEST_MAX_WORKERS) resolved.maxWorkers = parseInt(...)` — overrides the resolved config, so it binds projects that set their own | read out of vitest 4.1.4 `dist/chunks/coverage.*.js` |
31
- * | `npm_config_workspace_concurrency=N` | Bounds `pnpm -r` fan-out across workspace packages | `npm_config_workspace_concurrency=1 pnpm config get workspace-concurrency` → `1` |
31
+ * | `npm_config_workspace_concurrency=N` / `pnpm_config_workspace_concurrency=N` | Bounds `pnpm -r` fan-out across workspace packages (pnpm 10 reads the first, pnpm 11+ the second) | `npm_config_workspace_concurrency=1 pnpm config get workspace-concurrency` → `1` on pnpm 10.30; `pnpm_config_…` → `1` on pnpm 12.6 (T13122) |
32
32
  *
33
33
  * Together these bound the product the semaphore could not see:
34
34
  * `packages in flight × workers per run × heap per worker`.
35
35
  *
36
- * Applied ONLY to `test` / `build`. Capping `lint` or `typecheck` would
37
- * serialise cheap single-process work for no benefit.
36
+ * The worker levers apply ONLY to `test` / `build`, the tools that fork.
37
+ * `typecheck` and `lint` are single processes, but not cheap ones: one
38
+ * TypeScript program on a large monorepo holds 2–5 GB (a live `tsc --noEmit`
39
+ * held 4.7 GB on 2026-10-03), so since T13123 they get the heap ceiling and the
40
+ * workspace-concurrency bound too ({@link isMemoryBoundTool}), and no worker
41
+ * variables, which nothing they run reads.
38
42
  *
39
- * A project that genuinely wants more can set any of these itself — an existing
40
- * value is always respected, because a deliberate setting beats our default.
43
+ * ## An inherited value can tighten the plan, never loosen it (T13122)
44
+ *
45
+ * The overlay is merged over the CALLER's environment: whatever the shell
46
+ * profile, the agent harness or a parent process exported. Until T13122 an
47
+ * inherited value always won, on the theory that "a deliberate setting beats our
48
+ * default". A shell profile is not a per-project decision: on 2026-10-03 a
49
+ * `~/.zprofile` export of `NODE_OPTIONS=--max-old-space-size=8192` reached a
50
+ * `cleo verify --evidence tool:test`, and the run got 6 workers × 8 GiB = all of
51
+ * a 48 GiB Mac, because the worker count was sized for a 4 GiB heap it was not
52
+ * getting.
53
+ *
54
+ * So the run has a heap budget — the default worker count times the default heap
55
+ * ({@link heavyRunBudgetMb}) — and the overlay is planned against it
56
+ * ({@link planHeavyToolEnv}):
57
+ *
58
+ * - an inherited `NODE_OPTIONS` heap that fits the budget is kept, and the
59
+ * worker count shrinks so `workers × heap` still fits; one above the budget
60
+ * is clamped to it;
61
+ * - an inherited worker count or workspace concurrency at or below the plan
62
+ * is kept; one above it is clamped;
63
+ * - only an explicit CLEO override asks for more: `CLEO_HEAVY_HEAP_MB`,
64
+ * `CLEO_HEAVY_WORKERS`, `CLEO_HEAVY_WORKSPACE_CONCURRENCY`.
65
+ *
66
+ * A project that wants more for its own suite still sets it in its own script
67
+ * (`"test": "NODE_OPTIONS=… vitest run"`) or config: that runs below the
68
+ * overlay and is untouched by it. The plan, and every value it clamped, is
69
+ * reported by `cleo verify` and `cleo run`.
41
70
  *
42
71
  * @task T12096
72
+ * @task T13122
73
+ * @task T13123
43
74
  */
44
75
  import { totalmem } from 'node:os';
45
76
  /**
@@ -56,6 +87,85 @@ export const GIB_PER_WORKER = 6;
56
87
  export const MAX_HEAVY_WORKERS = 6;
57
88
  /** Never grant fewer than this many — one worker must always be able to run. */
58
89
  export const MIN_HEAVY_WORKERS = 1;
90
+ const GIB_BYTES = 1024 ** 3;
91
+ /**
92
+ * RAM the admission ledger never hands out: the OS, resident apps, VMs and
93
+ * agent CLIs — `max(4 GiB, 25%)`.
94
+ *
95
+ * @param totalBytes - physical RAM in bytes.
96
+ * @task T13133
97
+ */
98
+ export function admissionReserveBytes(totalBytes) {
99
+ return Math.max(4 * GIB_BYTES, totalBytes * 0.25);
100
+ }
101
+ /**
102
+ * The machine-wide budget the admission ledger shares between heavy runs, in
103
+ * bytes (at least 1 GiB): total RAM minus {@link admissionReserveBytes}.
104
+ *
105
+ * @param totalBytes - physical RAM. @defaultValue os.totalmem()
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * admissionCapacityBytes(48 * 1024 ** 3); // 36 GiB
110
+ * ```
111
+ *
112
+ * @task T13133
113
+ */
114
+ export function admissionCapacityBytes(totalBytes = totalmem()) {
115
+ return Math.max(GIB_BYTES, totalBytes - admissionReserveBytes(totalBytes));
116
+ }
117
+ /**
118
+ * Share of the admission budget one heavy run plans its workers for (T13132).
119
+ * A whole-suite run sized to the entire budget left nothing for anyone else:
120
+ * on a 48 GiB Mac it planned 6 workers × 6 GiB = all 36 GiB, and 49 single-file
121
+ * runs queued behind it for 17 minutes. Planning for half keeps the other half
122
+ * open, at the cost of a slower whole-suite run.
123
+ */
124
+ export const PER_RUN_BUDGET_SHARE = 0.5;
125
+ /** Overrides the per-run share: a number in `(0, 1]` (e.g. `1` on a dedicated box). */
126
+ export const PER_RUN_SHARE_ENV = 'CLEO_PER_RUN_SHARE';
127
+ /**
128
+ * Variables a hosted CI runner sets, each with the value that marks it. A bare
129
+ * `CI` is not trusted: agent harnesses and devcontainers export it locally.
130
+ */
131
+ const CI_RUNNER_MARKERS = [
132
+ ['GITHUB_ACTIONS', 'true'],
133
+ ['GITLAB_CI', null],
134
+ ['BUILDKITE', 'true'],
135
+ ['CIRCLECI', 'true'],
136
+ ['TF_BUILD', 'True'],
137
+ ];
138
+ /**
139
+ * Share of the admission budget one heavy run plans for:
140
+ * `CLEO_PER_RUN_SHARE` when it is a number in `(0, 1]`; the whole budget on a
141
+ * hosted CI runner (GitHub Actions, GitLab CI, Buildkite, CircleCI, Azure
142
+ * Pipelines), which is single-tenant, so CI keeps its parallelism (2 workers on
143
+ * a 16 GiB GitHub runner, as before T13132); else {@link PER_RUN_BUDGET_SHARE}.
144
+ * Fixed per environment, so the worker count in the tool cache key is stable.
145
+ *
146
+ * @param env - the environment.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * perRunBudgetShare({}); // 0.5
151
+ * perRunBudgetShare({ GITHUB_ACTIONS: 'true' }); // 1
152
+ * perRunBudgetShare({ CI: '1' }); // 0.5 (a bare CI is not trusted)
153
+ * perRunBudgetShare({ CLEO_PER_RUN_SHARE: '1' }); // 1
154
+ * ```
155
+ */
156
+ export function perRunBudgetShare(env) {
157
+ const raw = env[PER_RUN_SHARE_ENV]?.trim();
158
+ if (raw !== undefined && raw !== '') {
159
+ const n = Number(raw);
160
+ if (Number.isFinite(n) && n > 0 && n <= 1)
161
+ return n;
162
+ }
163
+ const onRunner = CI_RUNNER_MARKERS.some(([name, value]) => {
164
+ const v = env[name];
165
+ return v !== undefined && v !== '' && (value === null || v === value);
166
+ });
167
+ return onRunner ? 1 : PER_RUN_BUDGET_SHARE;
168
+ }
59
169
  /**
60
170
  * Workspace packages allowed to run their test/build script concurrently.
61
171
  *
@@ -64,6 +174,87 @@ export const MIN_HEAVY_WORKERS = 1;
64
174
  * memory-bound box does not finish at all.
65
175
  */
66
176
  export const WORKSPACE_CONCURRENCY = 1;
177
+ /**
178
+ * The default heap never drops below this, in MiB, however small the machine —
179
+ * one worker must be able to run a real suite.
180
+ *
181
+ * @task T13122
182
+ */
183
+ export const MIN_HEAVY_HEAP_MB = 1024;
184
+ /**
185
+ * Fraction of total RAM the DEFAULT heap may reach. {@link HEAVY_TOOL_HEAP_MB}
186
+ * on an 8 GiB laptop is half the machine; on a 4 GiB box it would be all of it,
187
+ * which is no ceiling at all. Machines of 8 GiB and up are unaffected.
188
+ *
189
+ * @task T13122
190
+ */
191
+ export const HEAVY_HEAP_RAM_FRACTION = 0.5;
192
+ /**
193
+ * Explicit heap ceiling for heavy tools, in MiB. The only way to ask for a heap
194
+ * above the run's budget: unlike an inherited `NODE_OPTIONS`, it is never
195
+ * clamped.
196
+ *
197
+ * @task T13122
198
+ */
199
+ export const HEAVY_HEAP_ENV = 'CLEO_HEAVY_HEAP_MB';
200
+ /**
201
+ * Explicit worker count for heavy tools. Replaces the planned count for every
202
+ * runner variable, even when that puts the run over its budget.
203
+ *
204
+ * @task T13122
205
+ */
206
+ export const HEAVY_WORKERS_ENV = 'CLEO_HEAVY_WORKERS';
207
+ /**
208
+ * Explicit workspace concurrency for heavy tools (`pnpm -r` packages in flight).
209
+ *
210
+ * @task T13122
211
+ */
212
+ export const HEAVY_WORKSPACE_CONCURRENCY_ENV = 'CLEO_HEAVY_WORKSPACE_CONCURRENCY';
213
+ /**
214
+ * The two spellings of pnpm's `workspace-concurrency` in the environment. pnpm
215
+ * 10 reads only `npm_config_workspace_concurrency`; pnpm 11+ reads only
216
+ * `pnpm_config_workspace_concurrency` (measured: pnpm 10.30.0 and 12.6.0 each
217
+ * report `undefined` for the other spelling). Setting one bounded `pnpm -r`
218
+ * fan-out on one pnpm major and silently nothing on the other, so the overlay
219
+ * sets both — for every launcher, because an `npm test` script that runs
220
+ * `pnpm -r` still reads them. Both are read case-insensitively, and an
221
+ * uppercase spelling outranks the lowercase one, so an inherited
222
+ * `NPM_CONFIG_WORKSPACE_CONCURRENCY` is planned and overlaid as well
223
+ * ({@link workspaceConcurrencyNames}).
224
+ *
225
+ * @task T13122
226
+ */
227
+ export const WORKSPACE_CONCURRENCY_VARS = [
228
+ 'npm_config_workspace_concurrency',
229
+ 'pnpm_config_workspace_concurrency',
230
+ ];
231
+ /**
232
+ * Every environment name that sets pnpm's workspace concurrency in `env`: the
233
+ * two canonical spellings, plus any case or dash variant of them present (pnpm
234
+ * reads these case-insensitively, uppercase first, and `workspace-concurrency`
235
+ * with a dash as readily).
236
+ *
237
+ * @param env - The caller's environment.
238
+ * @returns The names to plan and overlay, canonical first.
239
+ * @task T13122
240
+ */
241
+ export function workspaceConcurrencyNames(env) {
242
+ const canonical = [...WORKSPACE_CONCURRENCY_VARS];
243
+ const wanted = new Set(canonical);
244
+ const variants = Object.keys(env).filter((name) => !wanted.has(name) && wanted.has(name.toLowerCase().replace(/-/g, '_')));
245
+ return [...canonical, ...variants.sort()];
246
+ }
247
+ /**
248
+ * V8 young-generation (semi-space) ceiling a plan allows, in MiB: Node 24's own
249
+ * default on a 64-bit host. `heap_size_limit` is old space plus three
250
+ * semi-spaces (measured on Node 24: `--max-old-space-size=4096` with
251
+ * `--max-semi-space-size=4096` reports 16384 MiB), so an inherited large
252
+ * semi-space would multiply the planned heap without touching the old-space
253
+ * flag; above this it is clamped.
254
+ *
255
+ * @task T13122
256
+ */
257
+ export const MAX_SEMI_SPACE_MB = 64;
67
258
  /**
68
259
  * Canonical tools treated as HEAVY — the ones that fork.
69
260
  *
@@ -97,6 +288,35 @@ const HEAVY_TOOLS = new Set(['test', 'build']);
97
288
  export function isHeavyTool(canonical) {
98
289
  return HEAVY_TOOLS.has(canonical);
99
290
  }
291
+ /**
292
+ * Canonical tools whose memory must be bounded: the heavy ones, plus the
293
+ * single-process tools that build a whole TypeScript program (T13123).
294
+ */
295
+ const MEMORY_BOUND_TOOLS = new Set(['test', 'build', 'typecheck', 'lint']);
296
+ /**
297
+ * Whether a canonical tool's memory is bounded: a heap ceiling and workspace
298
+ * concurrency in its spawn env, and a RAM-derived machine-wide slot count that
299
+ * shrinks under pressure.
300
+ *
301
+ * A superset of {@link isHeavyTool}. `typecheck` and `lint` were treated as
302
+ * cheap (`max(2, cpus/2)` slots, no ceiling) until T13123: nine concurrent
303
+ * `tsc` runs of 2–5 GB each on an 18-core box is most of 48 GB. `audit` and
304
+ * `security-scan` stay unbounded — they are network-bound and small.
305
+ *
306
+ * @param canonical - the tool in question.
307
+ * @returns `true` for `test`, `build`, `typecheck` and `lint`.
308
+ *
309
+ * @example
310
+ * ```ts
311
+ * isMemoryBoundTool('typecheck'); // true
312
+ * isMemoryBoundTool('audit'); // false
313
+ * ```
314
+ *
315
+ * @task T13123
316
+ */
317
+ export function isMemoryBoundTool(canonical) {
318
+ return MEMORY_BOUND_TOOLS.has(canonical);
319
+ }
100
320
  /**
101
321
  * Per-runner worker-count variables, keyed by the env var each runner reads.
102
322
  *
@@ -126,22 +346,369 @@ const WORKER_COUNT_VARS = [
126
346
  'PYTEST_XDIST_AUTO_NUM_WORKERS',
127
347
  ];
128
348
  /**
129
- * Worker count this machine can hold, given {@link GIB_PER_WORKER}.
349
+ * Default worker count one heavy run plans for, given {@link GIB_PER_WORKER}:
350
+ * {@link perRunBudgetShare} of the admission budget
351
+ * ({@link admissionCapacityBytes}) — half on a shared machine, so a
352
+ * whole-suite run never takes the budget other runs need (T13132), the whole
353
+ * budget on a single-tenant CI runner. Fixed per machine and environment, so
354
+ * the worker count — part of the tool cache key (T12989) — is stable.
355
+ *
356
+ * The planned count ({@link planHeavyToolEnv}) never exceeds this: a small
357
+ * inherited heap does not buy extra workers, because each worker also costs
358
+ * memory outside its heap.
130
359
  *
131
360
  * @param totalRamGib - total RAM in GiB; defaults to a live reading.
361
+ * @param env - the environment ({@link perRunBudgetShare}). @defaultValue process.env
132
362
  * @returns a value in `[MIN_HEAVY_WORKERS, MAX_HEAVY_WORKERS]`.
363
+ *
364
+ * @example
365
+ * ```ts
366
+ * heavyToolWorkers(48, {}); // 3 (half of the 36 GiB budget)
367
+ * heavyToolWorkers(16, {}); // 1
368
+ * heavyToolWorkers(16, { GITHUB_ACTIONS: 'true' }); // 2 (the whole 12 GiB budget)
369
+ * ```
133
370
  */
134
- export function heavyToolWorkers(totalRamGib = totalmem() / 1024 ** 3) {
135
- const byRam = Math.floor(totalRamGib / GIB_PER_WORKER);
371
+ export function heavyToolWorkers(totalRamGib = totalmem() / 1024 ** 3, env = process.env) {
372
+ const capacityGib = admissionCapacityBytes(Math.max(0, totalRamGib) * GIB_BYTES) / GIB_BYTES;
373
+ const byRam = Math.floor((capacityGib * perRunBudgetShare(env)) / GIB_PER_WORKER);
136
374
  return Math.min(MAX_HEAVY_WORKERS, Math.max(MIN_HEAVY_WORKERS, byRam));
137
375
  }
138
376
  /**
139
- * Append `--max-old-space-size` to an existing `NODE_OPTIONS`, or create it.
377
+ * Default heap ceiling per Node process, in MiB: {@link HEAVY_TOOL_HEAP_MB},
378
+ * lowered to {@link HEAVY_HEAP_RAM_FRACTION} of RAM on a machine under 8 GiB
379
+ * (never below {@link MIN_HEAVY_HEAP_MB}).
140
380
  *
141
- * Never clobbers: a project may legitimately set `--experimental-*` flags there,
142
- * and dropping them would break the very command we are trying to run. An
143
- * existing `--max-old-space-size` is left alone — an explicit choice outranks
144
- * our default.
381
+ * @param totalRamGib - total RAM in GiB; defaults to a live reading.
382
+ * @returns the default heap in MiB.
383
+ *
384
+ * @example
385
+ * ```ts
386
+ * defaultHeavyHeapMb(64); // → 4096
387
+ * defaultHeavyHeapMb(4); // → 2048
388
+ * ```
389
+ *
390
+ * @task T13122
391
+ */
392
+ export function defaultHeavyHeapMb(totalRamGib = totalmem() / 1024 ** 3) {
393
+ const byRam = Math.floor(totalRamGib * 1024 * HEAVY_HEAP_RAM_FRACTION);
394
+ return Math.min(HEAVY_TOOL_HEAP_MB, Math.max(MIN_HEAVY_HEAP_MB, byRam));
395
+ }
396
+ /**
397
+ * Default heap ceiling for a single-process tool (`typecheck`, `lint`), in MiB:
398
+ * {@link defaultHeavyHeapMb}, but never above a quarter of RAM — V8's own
399
+ * default old space on a machine under 16 GiB (measured 4288 MiB with no flags
400
+ * on a 64 GiB host, the capped default) — so the plan never RAISES a `tsc`'s
401
+ * ceiling on a small machine (review of #1810). Never below
402
+ * {@link MIN_HEAVY_HEAP_MB}.
403
+ *
404
+ * @param totalRamGib - total RAM in GiB; defaults to a live reading.
405
+ * @returns the default heap in MiB.
406
+ *
407
+ * @example
408
+ * ```ts
409
+ * defaultSingleProcessHeapMb(64); // → 4096
410
+ * defaultSingleProcessHeapMb(8); // → 2048
411
+ * ```
412
+ *
413
+ * @task T13123
414
+ */
415
+ export function defaultSingleProcessHeapMb(totalRamGib = totalmem() / 1024 ** 3) {
416
+ const quarter = Math.max(MIN_HEAVY_HEAP_MB, Math.floor((totalRamGib * 1024) / 4));
417
+ return Math.min(defaultHeavyHeapMb(totalRamGib), quarter);
418
+ }
419
+ /**
420
+ * Heap budget for one heavy run, in MiB: the default worker count times the
421
+ * default heap. `workspace concurrency × workers × heap` must fit in it.
422
+ *
423
+ * Since T13132 the worker count is half the admission budget's worth
424
+ * ({@link heavyToolWorkers}); an inherited heap is planned against the budget
425
+ * instead of multiplying it (T13122).
426
+ *
427
+ * @param totalRamGib - total RAM in GiB; defaults to a live reading.
428
+ * @param env - the environment ({@link perRunBudgetShare}). @defaultValue process.env
429
+ * @returns the budget in MiB.
430
+ *
431
+ * @example
432
+ * ```ts
433
+ * heavyRunBudgetMb(64, {}); // → 16384 (4 workers × 4096)
434
+ * heavyRunBudgetMb(16, {}); // → 4096 (1 worker × 4096)
435
+ * ```
436
+ *
437
+ * @task T13122
438
+ * @task T13132
439
+ */
440
+ export function heavyRunBudgetMb(totalRamGib = totalmem() / 1024 ** 3, env = process.env) {
441
+ return heavyToolWorkers(totalRamGib, env) * defaultHeavyHeapMb(totalRamGib);
442
+ }
443
+ /**
444
+ * `NODE_OPTIONS` flags that set a V8 heap limit. `max-old-space-size` and its
445
+ * percentage form decide the old-space ceiling; `max-semi-space-size` sizes the
446
+ * young generation, three of which count toward the limit, and is capped at
447
+ * {@link MAX_SEMI_SPACE_MB}.
448
+ *
449
+ * @task T12989
450
+ * @task T13122
451
+ */
452
+ export const HEAP_FLAG_NAMES = new Set([
453
+ 'max-old-space-size',
454
+ 'max-old-space-size-percentage',
455
+ 'max-semi-space-size',
456
+ ]);
457
+ /** The two flags that set the old-space ceiling, which a plan replaces. */
458
+ const OLD_SPACE_FLAGS = new Set([
459
+ 'max-old-space-size',
460
+ 'max-old-space-size-percentage',
461
+ ]);
462
+ /** The young-generation flag, capped at {@link MAX_SEMI_SPACE_MB}. */
463
+ const SEMI_SPACE_FLAG = new Set(['max-semi-space-size']);
464
+ function spannedWords(text) {
465
+ return [...text.matchAll(/\S+/g)].map((m) => ({
466
+ text: m[0],
467
+ start: m.index,
468
+ end: m.index + m[0].length,
469
+ }));
470
+ }
471
+ /**
472
+ * Remove the heap flags named in `names` from a `NODE_OPTIONS` value, cutting
473
+ * their spans (and the whitespace before each) out of the original string, so
474
+ * every other byte — quoted paths with runs of spaces included — is kept.
475
+ */
476
+ function cutHeapFlags(text, names) {
477
+ const words = spannedWords(text);
478
+ const tokens = words.map((w) => w.text);
479
+ let out = '';
480
+ let cursor = 0;
481
+ for (let i = 0; i < words.length; i++) {
482
+ const flag = heapTokenAt(tokens, i);
483
+ if (flag === null || !names.has(flag.name))
484
+ continue;
485
+ const first = words[i];
486
+ const last = words[i + flag.width - 1];
487
+ if (first === undefined || last === undefined)
488
+ continue;
489
+ // Drop the whitespace before the flag along with it.
490
+ let from = first.start;
491
+ while (from > cursor && /\s/.test(text[from - 1] ?? ''))
492
+ from--;
493
+ out += text.slice(cursor, from);
494
+ cursor = last.end;
495
+ i += flag.width - 1;
496
+ }
497
+ return (out + text.slice(cursor)).trim();
498
+ }
499
+ function heapTokenAt(tokens, i) {
500
+ const token = tokens[i] ?? '';
501
+ if (!token.startsWith('--'))
502
+ return null;
503
+ const eq = token.indexOf('=');
504
+ const name = (eq === -1 ? token.slice(2) : token.slice(2, eq)).replace(/_/g, '-');
505
+ if (!HEAP_FLAG_NAMES.has(name))
506
+ return null;
507
+ const next = tokens[i + 1];
508
+ if (eq === -1 && next !== undefined && /^\d+(\.\d+)?$/.test(next)) {
509
+ return { name, value: next, width: 2 };
510
+ }
511
+ return { name, value: eq === -1 ? '' : token.slice(eq + 1), width: 1 };
512
+ }
513
+ /**
514
+ * The V8 heap flags a `NODE_OPTIONS` value sets, by name, with the value in
515
+ * effect.
516
+ *
517
+ * V8 reads flags left to right and a later value replaces an earlier one, so
518
+ * the LAST occurrence of each flag is the effective one. Underscores in a flag
519
+ * name read as dashes, as they do to V8, and the space-separated spelling
520
+ * (`--max-old-space-size 4096`) is read too.
521
+ *
522
+ * @param nodeOptions - A `NODE_OPTIONS` value, if any.
523
+ * @returns flag name → effective value, in first-seen order.
524
+ *
525
+ * @task T12989
526
+ * @task T13122
527
+ */
528
+ export function parseHeapFlags(nodeOptions) {
529
+ const tokens = (nodeOptions ?? '').trim().split(/\s+/).filter(Boolean);
530
+ const values = new Map();
531
+ for (let i = 0; i < tokens.length; i++) {
532
+ const flag = heapTokenAt(tokens, i);
533
+ if (flag === null)
534
+ continue;
535
+ values.set(flag.name, flag.value);
536
+ i += flag.width - 1;
537
+ }
538
+ return values;
539
+ }
540
+ /**
541
+ * The old-space heap ceiling a `NODE_OPTIONS` value asks for, in MiB, or
542
+ * `null` when it sets none (or sets one Node could not use).
543
+ *
544
+ * `--max-old-space-size-percentage` wins over `--max-old-space-size` whatever
545
+ * their order (measured on Node 24.21: `=10` beside `=2048` gave a 6745 MiB
546
+ * limit on a 64 GiB machine either way round), and resolves against total RAM.
547
+ *
548
+ * @param nodeOptions - A `NODE_OPTIONS` value, if any.
549
+ * @param totalRamMb - Total RAM in MiB, for the percentage form.
550
+ * @returns the requested heap in MiB, or `null`.
551
+ *
552
+ * @example
553
+ * ```ts
554
+ * inheritedHeapMb('--max-old-space-size=8192', 65536); // → 8192
555
+ * inheritedHeapMb('--max-old-space-size-percentage=25', 65536); // → 16384
556
+ * inheritedHeapMb('--enable-source-maps', 65536); // → null
557
+ * ```
558
+ *
559
+ * @task T13122
560
+ */
561
+ export function inheritedHeapMb(nodeOptions, totalRamMb) {
562
+ const flags = parseHeapFlags(nodeOptions);
563
+ const pct = Number(flags.get('max-old-space-size-percentage') ?? Number.NaN);
564
+ if (Number.isFinite(pct) && pct > 0 && pct <= 100) {
565
+ return Math.floor((totalRamMb * pct) / 100);
566
+ }
567
+ const mb = Number(flags.get('max-old-space-size') ?? Number.NaN);
568
+ return Number.isFinite(mb) && mb >= 1 ? Math.floor(mb) : null;
569
+ }
570
+ /**
571
+ * Set the old-space heap ceiling in a `NODE_OPTIONS` value: every existing
572
+ * `--max-old-space-size` and `--max-old-space-size-percentage` is cut out and
573
+ * one `--max-old-space-size=<heapMb>` appended. Every other byte survives — a
574
+ * project may rely on `--experimental-*` or a quoted `--require` path there.
575
+ *
576
+ * Removing the percentage form is required, not tidiness: it outranks the size
577
+ * form whatever the order, so leaving it would silently undo the ceiling.
578
+ *
579
+ * @param existing - current `NODE_OPTIONS`, if any.
580
+ * @param heapMb - ceiling to apply.
581
+ * @returns the rewritten value.
582
+ *
583
+ * @example
584
+ * ```ts
585
+ * withHeapCeiling('--enable-source-maps --max-old-space-size=8192', 4096);
586
+ * // → '--enable-source-maps --max-old-space-size=4096'
587
+ * ```
588
+ *
589
+ * @task T13122
590
+ */
591
+ export function withHeapCeiling(existing, heapMb) {
592
+ const rest = cutHeapFlags(existing ?? '', OLD_SPACE_FLAGS);
593
+ const flag = `--max-old-space-size=${heapMb}`;
594
+ return rest.length > 0 ? `${rest} ${flag}` : flag;
595
+ }
596
+ /**
597
+ * Cap the semi-space (young generation) flag of a `NODE_OPTIONS` value at
598
+ * {@link MAX_SEMI_SPACE_MB}: a larger `--max-semi-space-size` is cut out and the
599
+ * cap appended. A value at or under the cap is left alone.
600
+ *
601
+ * @param existing - `NODE_OPTIONS`, if any.
602
+ * @returns The value to use, and the inherited semi-space it clamped (or `null`).
603
+ *
604
+ * @example
605
+ * ```ts
606
+ * withSemiSpaceCap('--max-semi-space-size=4096'); // → { value: '--max-semi-space-size=64', clampedFrom: 4096 }
607
+ * ```
608
+ *
609
+ * @task T13122
610
+ */
611
+ export function withSemiSpaceCap(existing) {
612
+ const raw = parseHeapFlags(existing).get('max-semi-space-size');
613
+ const semi = Number(raw ?? Number.NaN);
614
+ if (raw === undefined || (Number.isFinite(semi) && semi <= MAX_SEMI_SPACE_MB)) {
615
+ return { value: existing, clampedFrom: null };
616
+ }
617
+ const rest = cutHeapFlags(existing ?? '', SEMI_SPACE_FLAG);
618
+ const flag = `--max-semi-space-size=${MAX_SEMI_SPACE_MB}`;
619
+ return {
620
+ value: rest.length > 0 ? `${rest} ${flag}` : flag,
621
+ clampedFrom: Number.isFinite(semi) ? semi : null,
622
+ };
623
+ }
624
+ /**
625
+ * Bound an inherited `MAKEFLAGS` to `workers` jobs.
626
+ *
627
+ * Absent: `-j<workers>` (GNU make sizes a bare `-j` off nproc). Carrying a
628
+ * jobserver (`--jobserver-auth=` / `--jobserver-fds=`): kept, since inside a
629
+ * `make` recipe the parent's jobserver already bounds the jobs. Otherwise any
630
+ * `-j`, `-jN`, `--jobs[=N]`, a short cluster ending in j (`-sj18`) or make's
631
+ * dash-less first word (`j18`) above `workers` (a bare one is unlimited) is
632
+ * replaced by `-j<workers>`, keeping every other flag — a profile-wide
633
+ * `export MAKEFLAGS=-j18` no longer outruns the plan.
634
+ *
635
+ * @param raw - The inherited `MAKEFLAGS`.
636
+ * @param workers - The planned worker count.
637
+ * @returns The value to set, or `null` to keep the inherited one.
638
+ * @task T13122
639
+ */
640
+ export function boundMakeflags(raw, workers) {
641
+ if (raw === undefined || raw.trim() === '')
642
+ return `-j${workers}`;
643
+ const words = raw.trim().split(/\s+/);
644
+ if (words.some((w) => /^--jobserver-(auth|fds)=/.test(w)))
645
+ return null;
646
+ const kept = [];
647
+ let over = false;
648
+ for (let i = 0; i < words.length; i++) {
649
+ const word = words[i] ?? '';
650
+ const long = /^--jobs(?:=(\d*))?$/.exec(word);
651
+ // A short-flag cluster ending in j (`-j18`, `-sj18`, `-kj`), or make's own
652
+ // dash-less letter form as the first word (`j18`, `kj`). Only make's
653
+ // argument-less short flags may precede the j: in `-Ij18` the `j18` is
654
+ // -I's directory, and splitting it would hand -I the `-j` (review of #1824).
655
+ const short = long === null ? /^(-?)([BbdehikLnpqrRsStvw]*)j(\d*)$/.exec(word) : null;
656
+ const isShort = short !== null && (short[1] === '-' || i === 0);
657
+ if (long === null && !isShort) {
658
+ kept.push(word);
659
+ continue;
660
+ }
661
+ let count = long !== null ? (long[1] ?? '') : (short?.[3] ?? '');
662
+ const takesNext = long !== null ? long[1] === undefined : count === '';
663
+ const next = words[i + 1];
664
+ if (count === '' && takesNext && next !== undefined && /^\d+$/.test(next)) {
665
+ count = next;
666
+ i++;
667
+ }
668
+ // The cluster's other letters (`s`, `k`) are flags of their own: keep them.
669
+ if (isShort && short?.[2])
670
+ kept.push(`-${short[2]}`);
671
+ if (count === '' || Number(count) > workers)
672
+ over = true;
673
+ else
674
+ kept.push(`-j${count}`);
675
+ }
676
+ return over ? [...kept.filter((w) => !/^-j\d+$/.test(w)), `-j${workers}`].join(' ') : null;
677
+ }
678
+ /**
679
+ * Remove npm's `Unknown env config` warnings from captured output.
680
+ *
681
+ * npm warns once per run for every `npm_config_*` variable it does not know,
682
+ * including `npm_config_workspace_concurrency`, which the overlay sets for the
683
+ * `pnpm -r` an `npm test` script may run. The warning would otherwise sit in
684
+ * the stderr tail CLEO quotes when a tool fails and push the real error out of
685
+ * it; the variable itself stays, because dropping it for npm unbounded those
686
+ * child `pnpm -r` runs (review of #1808).
687
+ *
688
+ * @param text - Captured stderr.
689
+ * @returns The text without those warning lines.
690
+ * @task T13122
691
+ */
692
+ export function withoutNpmEnvConfigWarnings(text) {
693
+ if (!text.includes('Unknown env config'))
694
+ return text;
695
+ return text
696
+ .split('\n')
697
+ .filter(
698
+ // A coloured npm (FORCE_COLOR, color=always) prefixes ANSI codes.
699
+ (line) => !/^npm (warn|WARN) Unknown env config\b/.test(line.replace(ANSI_SGR, '')))
700
+ .join('\n');
701
+ }
702
+ /** ANSI select-graphic-rendition escapes (colours), stripped before matching npm's warning. */
703
+ const ANSI_SGR = /\u001b\[[0-9;]*m/g;
704
+ /**
705
+ * Append `--max-old-space-size` to an existing `NODE_OPTIONS`, or create it,
706
+ * leaving an existing `--max-old-space-size` alone.
707
+ *
708
+ * @deprecated Since T13122 the heavy-tool overlay plans the heap against the
709
+ * run's budget instead of letting any inherited value win; use
710
+ * {@link planHeavyToolEnv} (or {@link withHeapCeiling} to set a ceiling).
711
+ * Kept for SDK consumers.
145
712
  *
146
713
  * @param existing - current `NODE_OPTIONS`, if any.
147
714
  * @param heapMb - ceiling to apply.
@@ -154,50 +721,259 @@ export function mergeNodeOptions(existing, heapMb) {
154
721
  const flag = `--max-old-space-size=${heapMb}`;
155
722
  return current.length > 0 ? `${current} ${flag}` : flag;
156
723
  }
724
+ /** A strictly positive base-10 integer, or `null` (`'50%'`, `'0'`, `'-1'`, `'4x'` are all `null`). */
725
+ function positiveInt(raw) {
726
+ const text = (raw ?? '').trim();
727
+ if (!/^\d+$/.test(text))
728
+ return null;
729
+ const n = Number.parseInt(text, 10);
730
+ return n > 0 ? n : null;
731
+ }
732
+ /** An explicit `CLEO_HEAVY_*` override, or `null`; an unusable value is noted and ignored. */
733
+ function readOverride(env, name, ignored) {
734
+ const raw = env[name];
735
+ if (raw === undefined || raw.trim() === '')
736
+ return null;
737
+ const n = positiveInt(raw);
738
+ if (n === null)
739
+ ignored.push(`${name}=${JSON.stringify(raw)} (not a positive integer)`);
740
+ return n;
741
+ }
742
+ /** The heap flags of a `NODE_OPTIONS` value as one readable string, e.g. `--max-old-space-size=8192`. */
743
+ function heapFlagsText(nodeOptions) {
744
+ return [...parseHeapFlags(nodeOptions)]
745
+ .filter(([name]) => OLD_SPACE_FLAGS.has(name))
746
+ .map(([name, value]) => `--${name}=${value}`)
747
+ .join(' ');
748
+ }
749
+ function chooseHeap(env, override, maxHeapMb, totalRamMb, defaultHeapMb) {
750
+ const inherited = inheritedHeapMb(env.NODE_OPTIONS, totalRamMb);
751
+ if (override !== null)
752
+ return { heapMb: override, source: 'override', inherited };
753
+ // The default heap never shrinks to fit an explicit workspace concurrency: a
754
+ // run asked for that way is reported over budget instead (`overBudget`).
755
+ if (inherited === null)
756
+ return { heapMb: defaultHeapMb, source: 'default', inherited };
757
+ if (inherited <= maxHeapMb)
758
+ return { heapMb: inherited, source: 'inherited', inherited };
759
+ return { heapMb: maxHeapMb, source: 'clamped', inherited };
760
+ }
761
+ /** One worker-count variable: keep an inherited value within the plan, else overlay the plan. */
762
+ function planCount(name, raw, planned, forced, overlay, clamped, kept) {
763
+ const inherited = positiveInt(raw);
764
+ if (!forced && inherited !== null && inherited <= planned) {
765
+ kept.push(`${name}=${inherited}`);
766
+ return;
767
+ }
768
+ overlay[name] = String(planned);
769
+ if (!forced && raw !== undefined && raw !== '') {
770
+ clamped.push({ name, from: raw, to: String(planned) });
771
+ }
772
+ }
773
+ /** A tool that runs as one process: nothing to size. */
774
+ const SINGLE_PROCESS = {
775
+ workers: 1,
776
+ source: 'plan',
777
+ reason: 'one process, no worker pool',
778
+ };
157
779
  /**
158
- * Build the environment overlay for a heavy tool spawn.
780
+ * The worker count of a forking tool — `CLEO_HEAVY_WORKERS`, else as many as
781
+ * fit (`fit`, the budget over packages × heap), never above the default — written
782
+ * to every runner variable and to `MAKEFLAGS`.
783
+ */
784
+ function planWorkers(env, fit, defaultWorkers, ledger) {
785
+ const override = readOverride(env, HEAVY_WORKERS_ENV, ledger.ignored);
786
+ const workers = override ?? Math.max(MIN_HEAVY_WORKERS, Math.min(defaultWorkers, Math.floor(fit)));
787
+ for (const key of WORKER_COUNT_VARS) {
788
+ planCount(key, env[key], workers, override !== null, ledger.overlay, ledger.clamped, ledger.kept);
789
+ }
790
+ // GNU make sizes `-j` off nproc when told `-j` with no argument; an explicit
791
+ // job count bounds a Makefile-driven test/build target too.
792
+ const makeflags = boundMakeflags(env.MAKEFLAGS, workers);
793
+ if (makeflags !== null) {
794
+ ledger.overlay.MAKEFLAGS = makeflags;
795
+ if (env.MAKEFLAGS && env.MAKEFLAGS.trim() !== '' && override === null) {
796
+ ledger.clamped.push({ name: 'MAKEFLAGS', from: env.MAKEFLAGS, to: makeflags });
797
+ }
798
+ }
799
+ if (override !== null)
800
+ return { workers, source: 'override', reason: HEAVY_WORKERS_ENV };
801
+ return {
802
+ workers,
803
+ source: 'plan',
804
+ reason: workers < defaultWorkers
805
+ ? `fewer than the default ${defaultWorkers} so the run fits its budget`
806
+ : 'default for this RAM',
807
+ };
808
+ }
809
+ function heapReason(choice) {
810
+ switch (choice.source) {
811
+ case 'override':
812
+ return HEAVY_HEAP_ENV;
813
+ case 'inherited':
814
+ return 'inherited NODE_OPTIONS';
815
+ case 'clamped':
816
+ return `inherited NODE_OPTIONS asked for ${choice.inherited} MiB, more than the budget allows`;
817
+ default:
818
+ return 'CLEO default';
819
+ }
820
+ }
821
+ /**
822
+ * Plan a heavy or memory-bound tool spawn: the environment overlay, and the
823
+ * resource plan behind it (T13122, T13123).
824
+ *
825
+ * The heap is chosen first — `CLEO_HEAVY_HEAP_MB`, else the inherited
826
+ * `NODE_OPTIONS` heap when it fits the budget (clamped to it otherwise), else
827
+ * {@link defaultHeavyHeapMb}. The worker count then derives from the heap
828
+ * actually in effect, `⌊budget / (packages × heap)⌋`, never above
829
+ * {@link heavyToolWorkers}, so `packages × workers × heap` stays within
830
+ * {@link heavyRunBudgetMb}. Inherited worker counts and workspace concurrency
831
+ * are kept at or below the plan and clamped above it; `CLEO_HEAVY_WORKERS` and
832
+ * `CLEO_HEAVY_WORKSPACE_CONCURRENCY` override.
159
833
  *
160
- * Returns an empty object for non-heavy tools, so the caller can merge
161
- * unconditionally.
834
+ * A single-process memory-bound tool (`typecheck`, `lint`) gets the same heap
835
+ * ceiling and workspace concurrency, and no worker variables: its plan is one
836
+ * process (T13123).
162
837
  *
163
838
  * @param canonical - the canonical tool about to be spawned.
164
839
  * @param env - the environment the child would otherwise inherit.
165
840
  * @param totalRamGib - total RAM in GiB; injectable for deterministic tests.
166
- * @returns variables to overlay; existing deliberate values are preserved.
841
+ * @param maxWorkers - at most this many workers (a run that names its test
842
+ * files needs no more than one per file, T13132). @defaultValue no limit
843
+ * @returns the overlay and plan; an empty overlay and `null` plan for a tool
844
+ * that is not memory-bound (`audit`, `security-scan`).
167
845
  *
168
846
  * @example
169
847
  * ```ts
170
- * const overlay = heavyToolEnv('test', process.env, 62);
171
- * // { NODE_OPTIONS: '--max-old-space-size=4096',
172
- * // VITEST_MAX_WORKERS: '6',
173
- * // npm_config_workspace_concurrency: '1' }
174
- * heavyToolEnv('lint', process.env, 62); // → {}
848
+ * // A shell profile exported an 8 GiB heap on a 64 GiB machine:
849
+ * const { overlay, resources } = planHeavyToolEnv(
850
+ * 'test', { NODE_OPTIONS: '--max-old-space-size=8192' }, 64);
851
+ * overlay.VITEST_MAX_WORKERS; // → '2' (2 × 8192 = the 16384 MiB budget)
852
+ * resources?.heapSource; // → 'inherited'
175
853
  * ```
176
854
  *
177
855
  * @task T12096
856
+ * @task T13122
857
+ * @task T13123
858
+ * @task T13132
178
859
  */
179
- export function heavyToolEnv(canonical, env = process.env, totalRamGib = totalmem() / 1024 ** 3) {
180
- if (!isHeavyTool(canonical))
181
- return {};
182
- const overlay = {
183
- NODE_OPTIONS: mergeNodeOptions(env.NODE_OPTIONS, HEAVY_TOOL_HEAP_MB),
184
- };
185
- // Respect a deliberate setting; supply one otherwise. An existing value
186
- // always wins — a project that asked for more has outranked our default
187
- // since T12096, and that contract is unchanged.
188
- const workers = String(heavyToolWorkers(totalRamGib));
189
- for (const key of WORKER_COUNT_VARS) {
190
- if (!env[key])
191
- overlay[key] = workers;
860
+ export function planHeavyToolEnv(canonical, env = process.env, totalRamGib = totalmem() / 1024 ** 3, maxWorkers) {
861
+ if (!isMemoryBoundTool(canonical))
862
+ return { overlay: {}, resources: null };
863
+ const totalRamMb = Math.floor(totalRamGib * 1024);
864
+ const defaultWorkers = Math.min(heavyToolWorkers(totalRamGib, env), Math.max(MIN_HEAVY_WORKERS, Math.floor(maxWorkers ?? Number.POSITIVE_INFINITY)));
865
+ // A single process starts from Node's own default ceiling on its machine; a
866
+ // forking tool from the heavy default. Both share the heavy run's budget.
867
+ const defaultHeapMb = isHeavyTool(canonical)
868
+ ? defaultHeavyHeapMb(totalRamGib)
869
+ : defaultSingleProcessHeapMb(totalRamGib);
870
+ const budgetMb = defaultWorkers * defaultHeavyHeapMb(totalRamGib);
871
+ const overlay = {};
872
+ const clamped = [];
873
+ const kept = [];
874
+ const ignored = [];
875
+ // Packages in flight first: the heap ceiling an inherited value may keep is
876
+ // the budget shared between them.
877
+ const packagesOverride = readOverride(env, HEAVY_WORKSPACE_CONCURRENCY_ENV, ignored);
878
+ const packages = packagesOverride ?? WORKSPACE_CONCURRENCY;
879
+ const packageNames = workspaceConcurrencyNames(env);
880
+ for (const name of packageNames) {
881
+ planCount(name, env[name], packages, packagesOverride !== null, overlay, clamped, kept);
192
882
  }
193
- if (!env.npm_config_workspace_concurrency) {
194
- overlay.npm_config_workspace_concurrency = String(WORKSPACE_CONCURRENCY);
883
+ // What the child gets: the overlay's value, or the inherited one it kept —
884
+ // the largest across every spelling, since which one pnpm reads depends on
885
+ // its version and the case.
886
+ const packagesInFlight = Math.max(...packageNames.map((name) => positiveInt(overlay[name] ?? env[name]) ?? packages));
887
+ const heap = chooseHeap(env, readOverride(env, HEAVY_HEAP_ENV, ignored), Math.max(1, Math.floor(budgetMb / packagesInFlight)), totalRamMb, defaultHeapMb);
888
+ // Young generation first: three semi-spaces count toward the heap limit.
889
+ const semi = withSemiSpaceCap(env.NODE_OPTIONS);
890
+ if (semi.clampedFrom !== null) {
891
+ clamped.push({
892
+ name: 'NODE_OPTIONS',
893
+ from: `--max-semi-space-size=${semi.clampedFrom}`,
894
+ to: `--max-semi-space-size=${MAX_SEMI_SPACE_MB}`,
895
+ });
195
896
  }
196
- // GNU make sizes `-j` off nproc when told `-j` with no argument; an explicit
197
- // job count here bounds a Makefile-driven test/build target too.
198
- if (!env.MAKEFLAGS) {
199
- overlay.MAKEFLAGS = `-j${workers}`;
897
+ overlay.NODE_OPTIONS = withHeapCeiling(semi.value, heap.heapMb);
898
+ if (heap.source === 'clamped') {
899
+ clamped.push({
900
+ name: 'NODE_OPTIONS',
901
+ from: heapFlagsText(env.NODE_OPTIONS),
902
+ to: `--max-old-space-size=${heap.heapMb}`,
903
+ });
904
+ }
905
+ // A single-process tool (typecheck, lint) has no worker pool to size.
906
+ const pool = isHeavyTool(canonical)
907
+ ? planWorkers(env, budgetMb / (packagesInFlight * heap.heapMb), defaultWorkers, {
908
+ overlay,
909
+ clamped,
910
+ kept,
911
+ ignored,
912
+ })
913
+ : SINGLE_PROCESS;
914
+ const { workers } = pool;
915
+ const product = packagesInFlight * workers * heap.heapMb;
916
+ const overBudget = product > budgetMb;
917
+ const parts = [
918
+ `heap ${heap.heapMb} MiB (${heapReason(heap)}) × ${workers} worker(s) (${pool.reason}) × ` +
919
+ `${packagesInFlight} workspace package(s) at once = ${product} MiB of a ${budgetMb} MiB budget ` +
920
+ `(${Math.round(totalRamMb / 1024)} GiB RAM)`,
921
+ ];
922
+ if (clamped.length > 0) {
923
+ parts.push(`clamped ${clamped.map((c) => `${c.name} ${c.from} → ${c.to}`).join(', ')}; ` +
924
+ `set ${HEAVY_HEAP_ENV}, ${HEAVY_WORKERS_ENV} or ${HEAVY_WORKSPACE_CONCURRENCY_ENV} to ask for more`);
200
925
  }
201
- return overlay;
926
+ if (overBudget)
927
+ parts.push('OVER budget by an explicit CLEO_HEAVY_* override');
928
+ if (ignored.length > 0)
929
+ parts.push(`ignored ${ignored.join(', ')}`);
930
+ return {
931
+ overlay,
932
+ resources: {
933
+ heapMb: heap.heapMb,
934
+ heapSource: heap.source,
935
+ inheritedHeapMb: heap.inherited,
936
+ workers,
937
+ workersSource: pool.source,
938
+ workspaceConcurrency: packagesInFlight,
939
+ budgetMb,
940
+ totalRamMb,
941
+ clamped,
942
+ kept,
943
+ overBudget,
944
+ summary: parts.join('; '),
945
+ },
946
+ };
947
+ }
948
+ /**
949
+ * Build the environment overlay for a heavy or memory-bound tool spawn: the
950
+ * `overlay` of {@link planHeavyToolEnv}.
951
+ *
952
+ * Returns an empty object for a tool that is not memory-bound, so the caller
953
+ * can merge unconditionally.
954
+ *
955
+ * @param canonical - the canonical tool about to be spawned.
956
+ * @param env - the environment the child would otherwise inherit.
957
+ * @param totalRamGib - total RAM in GiB; injectable for deterministic tests.
958
+ * @returns variables to overlay; inherited values within the plan are kept.
959
+ *
960
+ * @example
961
+ * ```ts
962
+ * const overlay = heavyToolEnv('test', {}, 62);
963
+ * // { NODE_OPTIONS: '--max-old-space-size=4096',
964
+ * // VITEST_MAX_WORKERS: '6',
965
+ * // npm_config_workspace_concurrency: '1', … }
966
+ * heavyToolEnv('typecheck', {}, 62);
967
+ * // { NODE_OPTIONS: '--max-old-space-size=4096',
968
+ * // npm_config_workspace_concurrency: '1', pnpm_config_workspace_concurrency: '1' }
969
+ * heavyToolEnv('audit', process.env, 62); // → {}
970
+ * ```
971
+ *
972
+ * @task T12096
973
+ * @task T13122
974
+ * @task T13123
975
+ */
976
+ export function heavyToolEnv(canonical, env = process.env, totalRamGib = totalmem() / 1024 ** 3) {
977
+ return planHeavyToolEnv(canonical, env, totalRamGib).overlay;
202
978
  }
203
979
  //# sourceMappingURL=heavy-tool-env.js.map