@cleocode/core 2026.9.22 → 2026.9.24

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 (821) hide show
  1. package/dist/admin/import-tasks.d.ts.map +1 -1
  2. package/dist/admin/import-tasks.js +35 -6
  3. package/dist/admin/import-tasks.js.map +1 -1
  4. package/dist/admin/import.d.ts.map +1 -1
  5. package/dist/admin/import.js +25 -6
  6. package/dist/admin/import.js.map +1 -1
  7. package/dist/build-provenance.json +6 -0
  8. package/dist/cloud/http.d.ts +8 -0
  9. package/dist/cloud/http.d.ts.map +1 -1
  10. package/dist/cloud/http.js +8 -1
  11. package/dist/cloud/http.js.map +1 -1
  12. package/dist/cloud/index.d.ts +6 -1
  13. package/dist/cloud/index.d.ts.map +1 -1
  14. package/dist/cloud/index.js +6 -1
  15. package/dist/cloud/index.js.map +1 -1
  16. package/dist/cloud/nexus-auth.d.ts +169 -0
  17. package/dist/cloud/nexus-auth.d.ts.map +1 -0
  18. package/dist/cloud/nexus-auth.js +372 -0
  19. package/dist/cloud/nexus-auth.js.map +1 -0
  20. package/dist/cloud/nexus-credentials.d.ts +188 -0
  21. package/dist/cloud/nexus-credentials.d.ts.map +1 -0
  22. package/dist/cloud/nexus-credentials.js +323 -0
  23. package/dist/cloud/nexus-credentials.js.map +1 -0
  24. package/dist/cloud/nexus-link.d.ts +85 -0
  25. package/dist/cloud/nexus-link.d.ts.map +1 -0
  26. package/dist/cloud/nexus-link.js +226 -0
  27. package/dist/cloud/nexus-link.js.map +1 -0
  28. package/dist/cloud/presence.d.ts +88 -0
  29. package/dist/cloud/presence.d.ts.map +1 -0
  30. package/dist/cloud/presence.js +137 -0
  31. package/dist/cloud/presence.js.map +1 -0
  32. package/dist/cloud/projects.d.ts +3 -1
  33. package/dist/cloud/projects.d.ts.map +1 -1
  34. package/dist/cloud/projects.js +4 -2
  35. package/dist/cloud/projects.js.map +1 -1
  36. package/dist/crypto/credentials.d.ts +14 -4
  37. package/dist/crypto/credentials.d.ts.map +1 -1
  38. package/dist/crypto/credentials.js +15 -1
  39. package/dist/crypto/credentials.js.map +1 -1
  40. package/dist/decide/audit.d.ts +7 -1
  41. package/dist/decide/audit.d.ts.map +1 -1
  42. package/dist/decide/audit.js.map +1 -1
  43. package/dist/decide/bench/dataset.d.ts +125 -0
  44. package/dist/decide/bench/dataset.d.ts.map +1 -0
  45. package/dist/decide/bench/dataset.js +457 -0
  46. package/dist/decide/bench/dataset.js.map +1 -0
  47. package/dist/decide/bench/index.d.ts +23 -0
  48. package/dist/decide/bench/index.d.ts.map +1 -0
  49. package/dist/decide/bench/index.js +23 -0
  50. package/dist/decide/bench/index.js.map +1 -0
  51. package/dist/decide/bench/metrics.d.ts +55 -0
  52. package/dist/decide/bench/metrics.d.ts.map +1 -0
  53. package/dist/decide/bench/metrics.js +100 -0
  54. package/dist/decide/bench/metrics.js.map +1 -0
  55. package/dist/decide/bench/operation.d.ts +119 -0
  56. package/dist/decide/bench/operation.d.ts.map +1 -0
  57. package/dist/decide/bench/operation.js +171 -0
  58. package/dist/decide/bench/operation.js.map +1 -0
  59. package/dist/decide/bench/profiles.d.ts +74 -0
  60. package/dist/decide/bench/profiles.d.ts.map +1 -0
  61. package/dist/decide/bench/profiles.js +131 -0
  62. package/dist/decide/bench/profiles.js.map +1 -0
  63. package/dist/decide/bench/questions.d.ts +40 -0
  64. package/dist/decide/bench/questions.d.ts.map +1 -0
  65. package/dist/decide/bench/questions.js +107 -0
  66. package/dist/decide/bench/questions.js.map +1 -0
  67. package/dist/decide/bench/report.d.ts +21 -0
  68. package/dist/decide/bench/report.d.ts.map +1 -0
  69. package/dist/decide/bench/report.js +120 -0
  70. package/dist/decide/bench/report.js.map +1 -0
  71. package/dist/decide/bench/runner.d.ts +203 -0
  72. package/dist/decide/bench/runner.d.ts.map +1 -0
  73. package/dist/decide/bench/runner.js +335 -0
  74. package/dist/decide/bench/runner.js.map +1 -0
  75. package/dist/decide/bench/source.d.ts +21 -0
  76. package/dist/decide/bench/source.d.ts.map +1 -0
  77. package/dist/decide/bench/source.js +67 -0
  78. package/dist/decide/bench/source.js.map +1 -0
  79. package/dist/decide/bench/spot-check.d.ts +117 -0
  80. package/dist/decide/bench/spot-check.d.ts.map +1 -0
  81. package/dist/decide/bench/spot-check.js +221 -0
  82. package/dist/decide/bench/spot-check.js.map +1 -0
  83. package/dist/decide/bench/stats.d.ts +57 -0
  84. package/dist/decide/bench/stats.d.ts.map +1 -0
  85. package/dist/decide/bench/stats.js +82 -0
  86. package/dist/decide/bench/stats.js.map +1 -0
  87. package/dist/decide/bench/types.d.ts +216 -0
  88. package/dist/decide/bench/types.d.ts.map +1 -0
  89. package/dist/decide/bench/types.js +104 -0
  90. package/dist/decide/bench/types.js.map +1 -0
  91. package/dist/decide/client.d.ts +80 -4
  92. package/dist/decide/client.d.ts.map +1 -1
  93. package/dist/decide/client.js +428 -39
  94. package/dist/decide/client.js.map +1 -1
  95. package/dist/decide/credentials.d.ts +200 -16
  96. package/dist/decide/credentials.d.ts.map +1 -1
  97. package/dist/decide/credentials.js +547 -45
  98. package/dist/decide/credentials.js.map +1 -1
  99. package/dist/decide/index.d.ts +10 -4
  100. package/dist/decide/index.d.ts.map +1 -1
  101. package/dist/decide/index.js +10 -4
  102. package/dist/decide/index.js.map +1 -1
  103. package/dist/decide/jev-wire.d.ts +105 -7
  104. package/dist/decide/jev-wire.d.ts.map +1 -1
  105. package/dist/decide/jev-wire.js +426 -54
  106. package/dist/decide/jev-wire.js.map +1 -1
  107. package/dist/decide/operations.d.ts +149 -21
  108. package/dist/decide/operations.d.ts.map +1 -1
  109. package/dist/decide/operations.js +241 -31
  110. package/dist/decide/operations.js.map +1 -1
  111. package/dist/decide/provider-state.d.ts +162 -0
  112. package/dist/decide/provider-state.d.ts.map +1 -0
  113. package/dist/decide/provider-state.js +267 -0
  114. package/dist/decide/provider-state.js.map +1 -0
  115. package/dist/decide/provider.d.ts +31 -5
  116. package/dist/decide/provider.d.ts.map +1 -1
  117. package/dist/decide/provider.js.map +1 -1
  118. package/dist/decide/providers.d.ts +71 -0
  119. package/dist/decide/providers.d.ts.map +1 -0
  120. package/dist/decide/providers.js +85 -0
  121. package/dist/decide/providers.js.map +1 -0
  122. package/dist/decide/site.d.ts +2 -2
  123. package/dist/decide/site.d.ts.map +1 -1
  124. package/dist/decide/site.js +2 -0
  125. package/dist/decide/site.js.map +1 -1
  126. package/dist/decide/sites/list.d.ts +46 -0
  127. package/dist/decide/sites/list.d.ts.map +1 -0
  128. package/dist/decide/sites/list.js +206 -0
  129. package/dist/decide/sites/list.js.map +1 -0
  130. package/dist/decide/sites/registry.d.ts +152 -0
  131. package/dist/decide/sites/registry.d.ts.map +1 -0
  132. package/dist/decide/sites/registry.js +398 -0
  133. package/dist/decide/sites/registry.js.map +1 -0
  134. package/dist/decide/spend.d.ts +196 -0
  135. package/dist/decide/spend.d.ts.map +1 -0
  136. package/dist/decide/spend.js +387 -0
  137. package/dist/decide/spend.js.map +1 -0
  138. package/dist/decide/wizard.d.ts +61 -0
  139. package/dist/decide/wizard.d.ts.map +1 -0
  140. package/dist/decide/wizard.js +197 -0
  141. package/dist/decide/wizard.js.map +1 -0
  142. package/dist/dispatch/mvi-projection.d.ts +15 -2
  143. package/dist/dispatch/mvi-projection.d.ts.map +1 -1
  144. package/dist/dispatch/mvi-projection.js +73 -12
  145. package/dist/dispatch/mvi-projection.js.map +1 -1
  146. package/dist/docs/adr-allocator.d.ts +2 -2
  147. package/dist/docs/adr-allocator.d.ts.map +1 -1
  148. package/dist/docs/adr-allocator.js +17 -4
  149. package/dist/docs/adr-allocator.js.map +1 -1
  150. package/dist/docs/blob-consolidation.js +1 -1
  151. package/dist/docs/blob-consolidation.js.map +1 -1
  152. package/dist/docs/display-alias.d.ts +1 -1
  153. package/dist/docs/display-alias.d.ts.map +1 -1
  154. package/dist/docs/display-alias.js +7 -4
  155. package/dist/docs/display-alias.js.map +1 -1
  156. package/dist/docs/docs-audit.d.ts.map +1 -1
  157. package/dist/docs/docs-audit.js +1 -2
  158. package/dist/docs/docs-audit.js.map +1 -1
  159. package/dist/docs/docs-inconsistency-detector.js +1 -1
  160. package/dist/docs/docs-inconsistency-detector.js.map +1 -1
  161. package/dist/docs/docs-update.d.ts.map +1 -1
  162. package/dist/docs/docs-update.js +6 -1
  163. package/dist/docs/docs-update.js.map +1 -1
  164. package/dist/docs/export-document.js +3462 -1227
  165. package/dist/docs/export-document.js.map +3 -3
  166. package/dist/docs/numbering.js +1 -1
  167. package/dist/docs/numbering.js.map +1 -1
  168. package/dist/docs/supersede.d.ts.map +1 -1
  169. package/dist/docs/supersede.js +6 -3
  170. package/dist/docs/supersede.js.map +1 -1
  171. package/dist/docs/version-ssot.js +1 -1
  172. package/dist/docs/version-ssot.js.map +1 -1
  173. package/dist/doctor/db-substrate.d.ts.map +1 -1
  174. package/dist/doctor/db-substrate.js +39 -24
  175. package/dist/doctor/db-substrate.js.map +1 -1
  176. package/dist/doctor/knowledge-summary.d.ts +10 -3
  177. package/dist/doctor/knowledge-summary.d.ts.map +1 -1
  178. package/dist/doctor/knowledge-summary.js +10 -3
  179. package/dist/doctor/knowledge-summary.js.map +1 -1
  180. package/dist/doctor/project-identity.d.ts +128 -37
  181. package/dist/doctor/project-identity.d.ts.map +1 -1
  182. package/dist/doctor/project-identity.js +476 -63
  183. package/dist/doctor/project-identity.js.map +1 -1
  184. package/dist/doctor/twin-collapse.d.ts +52 -2
  185. package/dist/doctor/twin-collapse.d.ts.map +1 -1
  186. package/dist/doctor/twin-collapse.js +108 -4
  187. package/dist/doctor/twin-collapse.js.map +1 -1
  188. package/dist/error-catalog.js +2 -2
  189. package/dist/error-catalog.js.map +1 -1
  190. package/dist/error-registry.js +1 -1
  191. package/dist/error-registry.js.map +1 -1
  192. package/dist/gateway-client/generated/types.gen.d.ts +22 -2
  193. package/dist/gateway-client/generated/types.gen.d.ts.map +1 -1
  194. package/dist/index.d.ts +3 -3
  195. package/dist/index.d.ts.map +1 -1
  196. package/dist/index.js +2 -2
  197. package/dist/index.js.map +1 -1
  198. package/dist/init/scaffold-workflows.d.ts.map +1 -1
  199. package/dist/init/scaffold-workflows.js +6 -3
  200. package/dist/init/scaffold-workflows.js.map +1 -1
  201. package/dist/init/upgrade-workflows.d.ts.map +1 -1
  202. package/dist/init/upgrade-workflows.js +6 -3
  203. package/dist/init/upgrade-workflows.js.map +1 -1
  204. package/dist/init.d.ts.map +1 -1
  205. package/dist/init.js +20 -11
  206. package/dist/init.js.map +1 -1
  207. package/dist/inject/index.d.ts.map +1 -1
  208. package/dist/inject/index.js +2 -3
  209. package/dist/inject/index.js.map +1 -1
  210. package/dist/internal.d.ts +6 -5
  211. package/dist/internal.d.ts.map +1 -1
  212. package/dist/internal.js +7 -5
  213. package/dist/internal.js.map +1 -1
  214. package/dist/llm/credential-remove-entry.d.ts +59 -0
  215. package/dist/llm/credential-remove-entry.d.ts.map +1 -0
  216. package/dist/llm/credential-remove-entry.js +101 -0
  217. package/dist/llm/credential-remove-entry.js.map +1 -0
  218. package/dist/llm/oauth/device-code.d.ts +26 -6
  219. package/dist/llm/oauth/device-code.d.ts.map +1 -1
  220. package/dist/llm/oauth/device-code.js +44 -12
  221. package/dist/llm/oauth/device-code.js.map +1 -1
  222. package/dist/llm/plugin-facade.js +3556 -1321
  223. package/dist/llm/plugin-facade.js.map +3 -3
  224. package/dist/memory/attention.d.ts.map +1 -1
  225. package/dist/memory/attention.js +5 -3
  226. package/dist/memory/attention.js.map +1 -1
  227. package/dist/memory/decision-contradiction.d.ts +3 -3
  228. package/dist/memory/decision-contradiction.d.ts.map +1 -1
  229. package/dist/memory/decision-contradiction.js +4 -3
  230. package/dist/memory/decision-contradiction.js.map +1 -1
  231. package/dist/memory/decisions.d.ts +48 -3
  232. package/dist/memory/decisions.d.ts.map +1 -1
  233. package/dist/memory/decisions.js +98 -14
  234. package/dist/memory/decisions.js.map +1 -1
  235. package/dist/memory/graph-memory-bridge.d.ts.map +1 -1
  236. package/dist/memory/graph-memory-bridge.js +2 -0
  237. package/dist/memory/graph-memory-bridge.js.map +1 -1
  238. package/dist/memory/learnings.d.ts +6 -6
  239. package/dist/memory/observation-type-decision.d.ts +2 -2
  240. package/dist/memory/observation-type-decision.d.ts.map +1 -1
  241. package/dist/memory/observation-type-decision.js +3 -2
  242. package/dist/memory/observation-type-decision.js.map +1 -1
  243. package/dist/memory/patterns.d.ts +4 -4
  244. package/dist/memory/pipeline-manifest-sqlite.d.ts +111 -0
  245. package/dist/memory/pipeline-manifest-sqlite.d.ts.map +1 -1
  246. package/dist/memory/pipeline-manifest-sqlite.js +230 -2
  247. package/dist/memory/pipeline-manifest-sqlite.js.map +1 -1
  248. package/dist/migration/manual/T10165-backfill-adr-index.d.ts.map +1 -1
  249. package/dist/migration/manual/T10165-backfill-adr-index.js +5 -1
  250. package/dist/migration/manual/T10165-backfill-adr-index.js.map +1 -1
  251. package/dist/nexus/fleet-status.d.ts +83 -0
  252. package/dist/nexus/fleet-status.d.ts.map +1 -0
  253. package/dist/nexus/fleet-status.js +414 -0
  254. package/dist/nexus/fleet-status.js.map +1 -0
  255. package/dist/nexus/git-state.d.ts +15 -0
  256. package/dist/nexus/git-state.d.ts.map +1 -1
  257. package/dist/nexus/git-state.js +67 -2
  258. package/dist/nexus/git-state.js.map +1 -1
  259. package/dist/nexus/identity.d.ts.map +1 -1
  260. package/dist/nexus/identity.js +4 -0
  261. package/dist/nexus/identity.js.map +1 -1
  262. package/dist/nexus/index.d.ts +4 -1
  263. package/dist/nexus/index.d.ts.map +1 -1
  264. package/dist/nexus/index.js +7 -1
  265. package/dist/nexus/index.js.map +1 -1
  266. package/dist/nexus/migrate-json-to-sqlite.d.ts +3 -2
  267. package/dist/nexus/migrate-json-to-sqlite.d.ts.map +1 -1
  268. package/dist/nexus/migrate-json-to-sqlite.js +9 -17
  269. package/dist/nexus/migrate-json-to-sqlite.js.map +1 -1
  270. package/dist/nexus/migrations/M-split-graph.d.ts.map +1 -1
  271. package/dist/nexus/migrations/M-split-graph.js +4 -0
  272. package/dist/nexus/migrations/M-split-graph.js.map +1 -1
  273. package/dist/nexus/ops.d.ts +1 -0
  274. package/dist/nexus/ops.d.ts.map +1 -1
  275. package/dist/nexus/project-activity.d.ts +104 -0
  276. package/dist/nexus/project-activity.d.ts.map +1 -0
  277. package/dist/nexus/project-activity.js +150 -0
  278. package/dist/nexus/project-activity.js.map +1 -0
  279. package/dist/nexus/query.d.ts +2 -2
  280. package/dist/nexus/query.d.ts.map +1 -1
  281. package/dist/nexus/query.js +4 -19
  282. package/dist/nexus/query.js.map +1 -1
  283. package/dist/nexus/registry-errors.d.ts +61 -0
  284. package/dist/nexus/registry-errors.d.ts.map +1 -0
  285. package/dist/nexus/registry-errors.js +85 -0
  286. package/dist/nexus/registry-errors.js.map +1 -0
  287. package/dist/nexus/registry.d.ts +30 -5
  288. package/dist/nexus/registry.d.ts.map +1 -1
  289. package/dist/nexus/registry.js +115 -70
  290. package/dist/nexus/registry.js.map +1 -1
  291. package/dist/nexus/store.d.ts.map +1 -1
  292. package/dist/nexus/store.js +2 -0
  293. package/dist/nexus/store.js.map +1 -1
  294. package/dist/orchestrate/pivot.d.ts +4 -0
  295. package/dist/orchestrate/pivot.d.ts.map +1 -1
  296. package/dist/orchestrate/pivot.js +82 -14
  297. package/dist/orchestrate/pivot.js.map +1 -1
  298. package/dist/orchestrate/plan.d.ts.map +1 -1
  299. package/dist/orchestrate/plan.js +3 -0
  300. package/dist/orchestrate/plan.js.map +1 -1
  301. package/dist/orchestrate/query-ops.d.ts.map +1 -1
  302. package/dist/orchestrate/query-ops.js +29 -27
  303. package/dist/orchestrate/query-ops.js.map +1 -1
  304. package/dist/orchestrate/spawn-ops.d.ts.map +1 -1
  305. package/dist/orchestrate/spawn-ops.js +29 -3
  306. package/dist/orchestrate/spawn-ops.js.map +1 -1
  307. package/dist/orchestration/bootstrap.d.ts.map +1 -1
  308. package/dist/orchestration/bootstrap.js +20 -14
  309. package/dist/orchestration/bootstrap.js.map +1 -1
  310. package/dist/orchestration/index.d.ts +15 -1
  311. package/dist/orchestration/index.d.ts.map +1 -1
  312. package/dist/orchestration/index.js +25 -6
  313. package/dist/orchestration/index.js.map +1 -1
  314. package/dist/orchestration/lead-rollup.d.ts +7 -1
  315. package/dist/orchestration/lead-rollup.d.ts.map +1 -1
  316. package/dist/orchestration/lead-rollup.js +20 -5
  317. package/dist/orchestration/lead-rollup.js.map +1 -1
  318. package/dist/orchestration/owner-decision-readiness.d.ts +2 -2
  319. package/dist/orchestration/owner-decision-readiness.d.ts.map +1 -1
  320. package/dist/orchestration/owner-decision-readiness.js +3 -2
  321. package/dist/orchestration/owner-decision-readiness.js.map +1 -1
  322. package/dist/orchestration/spawn-prompt.js +1 -1
  323. package/dist/orchestration/spawn-prompt.js.map +1 -1
  324. package/dist/orchestration/validate-spawn.d.ts.map +1 -1
  325. package/dist/orchestration/validate-spawn.js +2 -0
  326. package/dist/orchestration/validate-spawn.js.map +1 -1
  327. package/dist/orchestration/waves.d.ts +21 -10
  328. package/dist/orchestration/waves.d.ts.map +1 -1
  329. package/dist/orchestration/waves.js +38 -35
  330. package/dist/orchestration/waves.js.map +1 -1
  331. package/dist/paths.d.ts +9 -2
  332. package/dist/paths.d.ts.map +1 -1
  333. package/dist/paths.js +30 -13
  334. package/dist/paths.js.map +1 -1
  335. package/dist/phases/index.d.ts +1 -1
  336. package/dist/phases/index.d.ts.map +1 -1
  337. package/dist/phases/index.js +3 -4
  338. package/dist/phases/index.js.map +1 -1
  339. package/dist/project-info.d.ts +40 -3
  340. package/dist/project-info.d.ts.map +1 -1
  341. package/dist/project-info.js +74 -6
  342. package/dist/project-info.js.map +1 -1
  343. package/dist/project-lifecycle.d.ts +28 -7
  344. package/dist/project-lifecycle.d.ts.map +1 -1
  345. package/dist/project-lifecycle.js +114 -47
  346. package/dist/project-lifecycle.js.map +1 -1
  347. package/dist/project-scope.d.ts +86 -3
  348. package/dist/project-scope.d.ts.map +1 -1
  349. package/dist/project-scope.js +192 -17
  350. package/dist/project-scope.js.map +1 -1
  351. package/dist/release/github-pr.d.ts.map +1 -1
  352. package/dist/release/github-pr.js +2 -1
  353. package/dist/release/github-pr.js.map +1 -1
  354. package/dist/release/open.d.ts +12 -2
  355. package/dist/release/open.d.ts.map +1 -1
  356. package/dist/release/open.js +32 -3
  357. package/dist/release/open.js.map +1 -1
  358. package/dist/release/preflight-skip.d.ts +73 -0
  359. package/dist/release/preflight-skip.d.ts.map +1 -0
  360. package/dist/release/preflight-skip.js +254 -0
  361. package/dist/release/preflight-skip.js.map +1 -0
  362. package/dist/render/decide/index.d.ts +51 -0
  363. package/dist/render/decide/index.d.ts.map +1 -0
  364. package/dist/render/decide/index.js +289 -0
  365. package/dist/render/decide/index.js.map +1 -0
  366. package/dist/render/index.d.ts +1 -0
  367. package/dist/render/index.d.ts.map +1 -1
  368. package/dist/render/index.js +1 -0
  369. package/dist/render/index.js.map +1 -1
  370. package/dist/render/nexus/graph/index.d.ts +5 -0
  371. package/dist/render/nexus/graph/index.d.ts.map +1 -1
  372. package/dist/render/nexus/graph/index.js +53 -0
  373. package/dist/render/nexus/graph/index.js.map +1 -1
  374. package/dist/routing/capability-matrix.d.ts.map +1 -1
  375. package/dist/routing/capability-matrix.js +7 -0
  376. package/dist/routing/capability-matrix.js.map +1 -1
  377. package/dist/scaffold/ensure-config.d.ts +14 -6
  378. package/dist/scaffold/ensure-config.d.ts.map +1 -1
  379. package/dist/scaffold/ensure-config.js +39 -17
  380. package/dist/scaffold/ensure-config.js.map +1 -1
  381. package/dist/scaffold/project-identity.d.ts +115 -23
  382. package/dist/scaffold/project-identity.d.ts.map +1 -1
  383. package/dist/scaffold/project-identity.js +196 -44
  384. package/dist/scaffold/project-identity.js.map +1 -1
  385. package/dist/selfimprove/fix-gen.js +3569 -1334
  386. package/dist/selfimprove/fix-gen.js.map +3 -3
  387. package/dist/sentient/cross-project-hygiene.d.ts +12 -6
  388. package/dist/sentient/cross-project-hygiene.d.ts.map +1 -1
  389. package/dist/sentient/cross-project-hygiene.js +15 -10
  390. package/dist/sentient/cross-project-hygiene.js.map +1 -1
  391. package/dist/session/engine-ops.d.ts +13 -4
  392. package/dist/session/engine-ops.d.ts.map +1 -1
  393. package/dist/session/engine-ops.js +38 -45
  394. package/dist/session/engine-ops.js.map +1 -1
  395. package/dist/sessions/briefing.d.ts +7 -3
  396. package/dist/sessions/briefing.d.ts.map +1 -1
  397. package/dist/sessions/briefing.js +32 -71
  398. package/dist/sessions/briefing.js.map +1 -1
  399. package/dist/sessions/drift-watchdog.d.ts.map +1 -1
  400. package/dist/sessions/drift-watchdog.js +11 -19
  401. package/dist/sessions/drift-watchdog.js.map +1 -1
  402. package/dist/sessions/focus-state-store.d.ts +109 -27
  403. package/dist/sessions/focus-state-store.d.ts.map +1 -1
  404. package/dist/sessions/focus-state-store.js +171 -39
  405. package/dist/sessions/focus-state-store.js.map +1 -1
  406. package/dist/sessions/handoff.d.ts.map +1 -1
  407. package/dist/sessions/handoff.js +9 -18
  408. package/dist/sessions/handoff.js.map +1 -1
  409. package/dist/sessions/index.d.ts +4 -2
  410. package/dist/sessions/index.d.ts.map +1 -1
  411. package/dist/sessions/index.js +35 -6
  412. package/dist/sessions/index.js.map +1 -1
  413. package/dist/sessions/session-drift.d.ts.map +1 -1
  414. package/dist/sessions/session-drift.js +4 -2
  415. package/dist/sessions/session-drift.js.map +1 -1
  416. package/dist/sessions/session-view.d.ts +8 -1
  417. package/dist/sessions/session-view.d.ts.map +1 -1
  418. package/dist/sessions/session-view.js +9 -2
  419. package/dist/sessions/session-view.js.map +1 -1
  420. package/dist/setup/config-json-merge.d.ts +28 -0
  421. package/dist/setup/config-json-merge.d.ts.map +1 -1
  422. package/dist/setup/config-json-merge.js +52 -0
  423. package/dist/setup/config-json-merge.js.map +1 -1
  424. package/dist/setup/index.d.ts +15 -10
  425. package/dist/setup/index.d.ts.map +1 -1
  426. package/dist/setup/index.js +19 -10
  427. package/dist/setup/index.js.map +1 -1
  428. package/dist/setup/sections/llm.js +1 -1
  429. package/dist/setup/sections/llm.js.map +1 -1
  430. package/dist/setup/sections/nexus-account.d.ts +32 -0
  431. package/dist/setup/sections/nexus-account.d.ts.map +1 -0
  432. package/dist/setup/sections/nexus-account.js +64 -0
  433. package/dist/setup/sections/nexus-account.js.map +1 -0
  434. package/dist/setup/sections/system-one.d.ts +28 -0
  435. package/dist/setup/sections/system-one.d.ts.map +1 -0
  436. package/dist/setup/sections/system-one.js +53 -0
  437. package/dist/setup/sections/system-one.js.map +1 -0
  438. package/dist/setup/wizard.d.ts +15 -1
  439. package/dist/setup/wizard.d.ts.map +1 -1
  440. package/dist/setup/wizard.js +15 -0
  441. package/dist/setup/wizard.js.map +1 -1
  442. package/dist/skills/orchestrator/startup.d.ts.map +1 -1
  443. package/dist/skills/orchestrator/startup.js +18 -31
  444. package/dist/skills/orchestrator/startup.js.map +1 -1
  445. package/dist/skills/prune-bundled.d.ts +40 -1
  446. package/dist/skills/prune-bundled.d.ts.map +1 -1
  447. package/dist/skills/prune-bundled.js +117 -1
  448. package/dist/skills/prune-bundled.js.map +1 -1
  449. package/dist/snapshot/index.d.ts.map +1 -1
  450. package/dist/snapshot/index.js +60 -53
  451. package/dist/snapshot/index.js.map +1 -1
  452. package/dist/spawn/agent-identity.d.ts +33 -1
  453. package/dist/spawn/agent-identity.d.ts.map +1 -1
  454. package/dist/spawn/agent-identity.js +53 -1
  455. package/dist/spawn/agent-identity.js.map +1 -1
  456. package/dist/spawn/index.d.ts +1 -1
  457. package/dist/spawn/index.d.ts.map +1 -1
  458. package/dist/spawn/index.js +1 -1
  459. package/dist/spawn/index.js.map +1 -1
  460. package/dist/stats/index.d.ts.map +1 -1
  461. package/dist/stats/index.js +3 -4
  462. package/dist/stats/index.js.map +1 -1
  463. package/dist/status/index.d.ts +12 -3
  464. package/dist/status/index.d.ts.map +1 -1
  465. package/dist/status/index.js +47 -5
  466. package/dist/status/index.js.map +1 -1
  467. package/dist/store/agent-registry-accessor.d.ts.map +1 -1
  468. package/dist/store/agent-registry-accessor.js +2 -0
  469. package/dist/store/agent-registry-accessor.js.map +1 -1
  470. package/dist/store/attachment-repair.d.ts.map +1 -1
  471. package/dist/store/attachment-repair.js +42 -3
  472. package/dist/store/attachment-repair.js.map +1 -1
  473. package/dist/store/attachment-store.d.ts.map +1 -1
  474. package/dist/store/attachment-store.js +30 -46
  475. package/dist/store/attachment-store.js.map +1 -1
  476. package/dist/store/backup-pack.js +1 -1
  477. package/dist/store/backup-pack.js.map +1 -1
  478. package/dist/store/backup-recover-brain.d.ts +4 -0
  479. package/dist/store/backup-recover-brain.d.ts.map +1 -1
  480. package/dist/store/backup-recover-brain.js +2 -0
  481. package/dist/store/backup-recover-brain.js.map +1 -1
  482. package/dist/store/backup-recover.d.ts +9 -0
  483. package/dist/store/backup-recover.d.ts.map +1 -1
  484. package/dist/store/backup-recover.js +28 -1
  485. package/dist/store/backup-recover.js.map +1 -1
  486. package/dist/store/backup-sidecar.d.ts +30 -0
  487. package/dist/store/backup-sidecar.d.ts.map +1 -1
  488. package/dist/store/backup-sidecar.js +90 -2
  489. package/dist/store/backup-sidecar.js.map +1 -1
  490. package/dist/store/backup.d.ts +15 -1
  491. package/dist/store/backup.d.ts.map +1 -1
  492. package/dist/store/backup.js +18 -2
  493. package/dist/store/backup.js.map +1 -1
  494. package/dist/store/blob-keep.d.ts +135 -0
  495. package/dist/store/blob-keep.d.ts.map +1 -0
  496. package/dist/store/blob-keep.js +283 -0
  497. package/dist/store/blob-keep.js.map +1 -0
  498. package/dist/store/conduit-sqlite.d.ts.map +1 -1
  499. package/dist/store/conduit-sqlite.js +3 -0
  500. package/dist/store/conduit-sqlite.js.map +1 -1
  501. package/dist/store/converters.d.ts.map +1 -1
  502. package/dist/store/converters.js +11 -0
  503. package/dist/store/converters.js.map +1 -1
  504. package/dist/store/credential-transfer.d.ts +37 -5
  505. package/dist/store/credential-transfer.d.ts.map +1 -1
  506. package/dist/store/credential-transfer.js +75 -18
  507. package/dist/store/credential-transfer.js.map +1 -1
  508. package/dist/store/cross-db-cleanup.d.ts.map +1 -1
  509. package/dist/store/cross-db-cleanup.js +2 -0
  510. package/dist/store/cross-db-cleanup.js.map +1 -1
  511. package/dist/store/data-accessor.d.ts +1 -1
  512. package/dist/store/data-accessor.d.ts.map +1 -1
  513. package/dist/store/data-accessor.js.map +1 -1
  514. package/dist/store/db-helpers.d.ts +18 -0
  515. package/dist/store/db-helpers.d.ts.map +1 -1
  516. package/dist/store/db-helpers.js +46 -0
  517. package/dist/store/db-helpers.js.map +1 -1
  518. package/dist/store/dual-scope-db.d.ts.map +1 -1
  519. package/dist/store/dual-scope-db.js +13 -2
  520. package/dist/store/dual-scope-db.js.map +1 -1
  521. package/dist/store/exodus/on-open.d.ts.map +1 -1
  522. package/dist/store/exodus/on-open.js +35 -0
  523. package/dist/store/exodus/on-open.js.map +1 -1
  524. package/dist/store/exodus/runtime-targets.d.ts +3 -3
  525. package/dist/store/exodus/runtime-targets.js +3 -3
  526. package/dist/store/import-remap.d.ts +12 -1
  527. package/dist/store/import-remap.d.ts.map +1 -1
  528. package/dist/store/import-remap.js +14 -0
  529. package/dist/store/import-remap.js.map +1 -1
  530. package/dist/store/legacy-tasks-lineage.d.ts +3 -1
  531. package/dist/store/legacy-tasks-lineage.d.ts.map +1 -1
  532. package/dist/store/legacy-tasks-lineage.js +3 -1
  533. package/dist/store/legacy-tasks-lineage.js.map +1 -1
  534. package/dist/store/memory-accessor.js +1 -1
  535. package/dist/store/memory-accessor.js.map +1 -1
  536. package/dist/store/migrate-signaldock-to-conduit.d.ts.map +1 -1
  537. package/dist/store/migrate-signaldock-to-conduit.js +3 -0
  538. package/dist/store/migrate-signaldock-to-conduit.js.map +1 -1
  539. package/dist/store/migration-manager.d.ts +61 -0
  540. package/dist/store/migration-manager.d.ts.map +1 -1
  541. package/dist/store/migration-manager.js +138 -6
  542. package/dist/store/migration-manager.js.map +1 -1
  543. package/dist/store/migration-sqlite.d.ts.map +1 -1
  544. package/dist/store/migration-sqlite.js +2 -0
  545. package/dist/store/migration-sqlite.js.map +1 -1
  546. package/dist/store/nexus-sqlite.d.ts.map +1 -1
  547. package/dist/store/nexus-sqlite.js +3 -0
  548. package/dist/store/nexus-sqlite.js.map +1 -1
  549. package/dist/store/nexus-validation-schemas.d.ts +64 -0
  550. package/dist/store/nexus-validation-schemas.d.ts.map +1 -1
  551. package/dist/store/open-cleo-db.d.ts.map +1 -1
  552. package/dist/store/open-cleo-db.js +3 -0
  553. package/dist/store/open-cleo-db.js.map +1 -1
  554. package/dist/store/portable-bundle-import.d.ts +8 -0
  555. package/dist/store/portable-bundle-import.d.ts.map +1 -1
  556. package/dist/store/portable-bundle-import.js +12 -0
  557. package/dist/store/portable-bundle-import.js.map +1 -1
  558. package/dist/store/portable-bundle-relocate.d.ts.map +1 -1
  559. package/dist/store/portable-bundle-relocate.js +2 -0
  560. package/dist/store/portable-bundle-relocate.js.map +1 -1
  561. package/dist/store/portable-bundle-scan.d.ts.map +1 -1
  562. package/dist/store/portable-bundle-scan.js +2 -1
  563. package/dist/store/portable-bundle-scan.js.map +1 -1
  564. package/dist/store/portable-bundle.d.ts.map +1 -1
  565. package/dist/store/portable-bundle.js +15 -14
  566. package/dist/store/portable-bundle.js.map +1 -1
  567. package/dist/store/ports/domain-binding.d.ts.map +1 -1
  568. package/dist/store/ports/domain-binding.js +5 -0
  569. package/dist/store/ports/domain-binding.js.map +1 -1
  570. package/dist/store/pre-repair-snapshot.d.ts +4 -1
  571. package/dist/store/pre-repair-snapshot.d.ts.map +1 -1
  572. package/dist/store/pre-repair-snapshot.js +5 -1
  573. package/dist/store/pre-repair-snapshot.js.map +1 -1
  574. package/dist/store/regenerators.d.ts +4 -2
  575. package/dist/store/regenerators.d.ts.map +1 -1
  576. package/dist/store/regenerators.js +7 -3
  577. package/dist/store/regenerators.js.map +1 -1
  578. package/dist/store/repair-malformed-dbs.d.ts +4 -0
  579. package/dist/store/repair-malformed-dbs.d.ts.map +1 -1
  580. package/dist/store/repair-malformed-dbs.js +3 -0
  581. package/dist/store/repair-malformed-dbs.js.map +1 -1
  582. package/dist/store/safety-data-accessor.d.ts +8 -3
  583. package/dist/store/safety-data-accessor.d.ts.map +1 -1
  584. package/dist/store/safety-data-accessor.js +11 -4
  585. package/dist/store/safety-data-accessor.js.map +1 -1
  586. package/dist/store/schema/cleo-global/nexus.d.ts +48 -0
  587. package/dist/store/schema/cleo-global/nexus.d.ts.map +1 -1
  588. package/dist/store/schema/cleo-global/nexus.js +17 -0
  589. package/dist/store/schema/cleo-global/nexus.js.map +1 -1
  590. package/dist/store/schema/cleo-project/docs.d.ts +16 -0
  591. package/dist/store/schema/cleo-project/docs.d.ts.map +1 -1
  592. package/dist/store/schema/cleo-project/docs.js +10 -0
  593. package/dist/store/schema/cleo-project/docs.js.map +1 -1
  594. package/dist/store/schema/cleo-project/tasks-core.d.ts +80 -0
  595. package/dist/store/schema/cleo-project/tasks-core.d.ts.map +1 -1
  596. package/dist/store/schema/cleo-project/tasks-core.js +25 -1
  597. package/dist/store/schema/cleo-project/tasks-core.js.map +1 -1
  598. package/dist/store/schema/cleo-shared/brain.d.ts +1 -1
  599. package/dist/store/schema/memory-schema.d.ts +1 -1
  600. package/dist/store/schema/nexus-schema.d.ts +48 -0
  601. package/dist/store/schema/nexus-schema.d.ts.map +1 -1
  602. package/dist/store/schema/nexus-schema.js +28 -7
  603. package/dist/store/schema/nexus-schema.js.map +1 -1
  604. package/dist/store/session-store.d.ts +65 -0
  605. package/dist/store/session-store.d.ts.map +1 -1
  606. package/dist/store/session-store.js +108 -7
  607. package/dist/store/session-store.js.map +1 -1
  608. package/dist/store/split-brain-import.d.ts.map +1 -1
  609. package/dist/store/split-brain-import.js +2 -0
  610. package/dist/store/split-brain-import.js.map +1 -1
  611. package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
  612. package/dist/store/sqlite-data-accessor.js +252 -47
  613. package/dist/store/sqlite-data-accessor.js.map +1 -1
  614. package/dist/store/sqlite-native.d.ts.map +1 -1
  615. package/dist/store/sqlite-native.js +1 -0
  616. package/dist/store/sqlite-native.js.map +1 -1
  617. package/dist/store/sqlite.d.ts +15 -3
  618. package/dist/store/sqlite.d.ts.map +1 -1
  619. package/dist/store/sqlite.js +57 -20
  620. package/dist/store/sqlite.js.map +1 -1
  621. package/dist/store/store-write-guard.d.ts +9 -3
  622. package/dist/store/store-write-guard.d.ts.map +1 -1
  623. package/dist/store/store-write-guard.js +25 -4
  624. package/dist/store/store-write-guard.js.map +1 -1
  625. package/dist/store/table-classification.d.ts +1 -1
  626. package/dist/store/table-classification.d.ts.map +1 -1
  627. package/dist/store/table-classification.js +34 -8
  628. package/dist/store/table-classification.js.map +1 -1
  629. package/dist/store/task-claim.d.ts +144 -0
  630. package/dist/store/task-claim.d.ts.map +1 -0
  631. package/dist/store/task-claim.js +195 -0
  632. package/dist/store/task-claim.js.map +1 -0
  633. package/dist/store/task-version.d.ts +43 -5
  634. package/dist/store/task-version.d.ts.map +1 -1
  635. package/dist/store/task-version.js +113 -17
  636. package/dist/store/task-version.js.map +1 -1
  637. package/dist/store/tasks-schema.d.ts +2 -0
  638. package/dist/store/tasks-schema.d.ts.map +1 -1
  639. package/dist/store/tasks-schema.js +1 -0
  640. package/dist/store/tasks-schema.js.map +1 -1
  641. package/dist/store/tasks-sqlite.js +1 -1
  642. package/dist/store/tasks-sqlite.js.map +1 -1
  643. package/dist/store/twin-collapse.d.ts +339 -22
  644. package/dist/store/twin-collapse.d.ts.map +1 -1
  645. package/dist/store/twin-collapse.js +1323 -48
  646. package/dist/store/twin-collapse.js.map +1 -1
  647. package/dist/store/umbrella-data-accessor.d.ts +8 -3
  648. package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
  649. package/dist/store/umbrella-data-accessor.js +10 -4
  650. package/dist/store/umbrella-data-accessor.js.map +1 -1
  651. package/dist/store/validation-schemas.d.ts +161 -1
  652. package/dist/store/validation-schemas.d.ts.map +1 -1
  653. package/dist/store/with-retry.d.ts +36 -0
  654. package/dist/store/with-retry.d.ts.map +1 -1
  655. package/dist/store/with-retry.js +51 -0
  656. package/dist/store/with-retry.js.map +1 -1
  657. package/dist/store/worktree-build-guard.d.ts +200 -0
  658. package/dist/store/worktree-build-guard.d.ts.map +1 -0
  659. package/dist/store/worktree-build-guard.js +497 -0
  660. package/dist/store/worktree-build-guard.js.map +1 -0
  661. package/dist/store/worktree-isolation-guard.d.ts +138 -0
  662. package/dist/store/worktree-isolation-guard.d.ts.map +1 -1
  663. package/dist/store/worktree-isolation-guard.js +189 -2
  664. package/dist/store/worktree-isolation-guard.js.map +1 -1
  665. package/dist/store/writer-lease.d.ts.map +1 -1
  666. package/dist/store/writer-lease.js +2 -0
  667. package/dist/store/writer-lease.js.map +1 -1
  668. package/dist/system/backup.d.ts +13 -2
  669. package/dist/system/backup.d.ts.map +1 -1
  670. package/dist/system/backup.js +11 -3
  671. package/dist/system/backup.js.map +1 -1
  672. package/dist/system/health.d.ts.map +1 -1
  673. package/dist/system/health.js +3 -1
  674. package/dist/system/health.js.map +1 -1
  675. package/dist/system/inject-generate.d.ts.map +1 -1
  676. package/dist/system/inject-generate.js +23 -10
  677. package/dist/system/inject-generate.js.map +1 -1
  678. package/dist/system/project-health.d.ts +8 -0
  679. package/dist/system/project-health.d.ts.map +1 -1
  680. package/dist/system/project-health.js +13 -5
  681. package/dist/system/project-health.js.map +1 -1
  682. package/dist/task-tools/index.d.ts +4 -2
  683. package/dist/task-tools/index.d.ts.map +1 -1
  684. package/dist/task-tools/index.js +3 -2
  685. package/dist/task-tools/index.js.map +1 -1
  686. package/dist/task-tools/score-task-priority.d.ts +131 -18
  687. package/dist/task-tools/score-task-priority.d.ts.map +1 -1
  688. package/dist/task-tools/score-task-priority.js +243 -80
  689. package/dist/task-tools/score-task-priority.js.map +1 -1
  690. package/dist/task-work/claims.d.ts +215 -0
  691. package/dist/task-work/claims.d.ts.map +1 -0
  692. package/dist/task-work/claims.js +272 -0
  693. package/dist/task-work/claims.js.map +1 -0
  694. package/dist/task-work/index.d.ts +47 -3
  695. package/dist/task-work/index.d.ts.map +1 -1
  696. package/dist/task-work/index.js +74 -41
  697. package/dist/task-work/index.js.map +1 -1
  698. package/dist/tasks/add.d.ts.map +1 -1
  699. package/dist/tasks/add.js +3 -2
  700. package/dist/tasks/add.js.map +1 -1
  701. package/dist/tasks/affected-packages.d.ts +5 -1
  702. package/dist/tasks/affected-packages.d.ts.map +1 -1
  703. package/dist/tasks/affected-packages.js +21 -3
  704. package/dist/tasks/affected-packages.js.map +1 -1
  705. package/dist/tasks/analyze.d.ts +29 -1
  706. package/dist/tasks/analyze.d.ts.map +1 -1
  707. package/dist/tasks/analyze.js +47 -37
  708. package/dist/tasks/analyze.js.map +1 -1
  709. package/dist/tasks/backfill-child-projections.d.ts.map +1 -1
  710. package/dist/tasks/backfill-child-projections.js +4 -1
  711. package/dist/tasks/backfill-child-projections.js.map +1 -1
  712. package/dist/tasks/change-set.d.ts +5 -0
  713. package/dist/tasks/change-set.d.ts.map +1 -1
  714. package/dist/tasks/change-set.js +75 -6
  715. package/dist/tasks/change-set.js.map +1 -1
  716. package/dist/tasks/command-line.d.ts +54 -0
  717. package/dist/tasks/command-line.d.ts.map +1 -0
  718. package/dist/tasks/command-line.js +151 -0
  719. package/dist/tasks/command-line.js.map +1 -0
  720. package/dist/tasks/complete.d.ts +16 -0
  721. package/dist/tasks/complete.d.ts.map +1 -1
  722. package/dist/tasks/complete.js +27 -7
  723. package/dist/tasks/complete.js.map +1 -1
  724. package/dist/tasks/component-pr.d.ts +162 -1
  725. package/dist/tasks/component-pr.d.ts.map +1 -1
  726. package/dist/tasks/component-pr.js +639 -53
  727. package/dist/tasks/component-pr.js.map +1 -1
  728. package/dist/tasks/delete.d.ts.map +1 -1
  729. package/dist/tasks/delete.js +20 -0
  730. package/dist/tasks/delete.js.map +1 -1
  731. package/dist/tasks/done-record.d.ts +14 -1
  732. package/dist/tasks/done-record.d.ts.map +1 -1
  733. package/dist/tasks/done-record.js +37 -0
  734. package/dist/tasks/done-record.js.map +1 -1
  735. package/dist/tasks/duplicate-detector.d.ts +23 -4
  736. package/dist/tasks/duplicate-detector.d.ts.map +1 -1
  737. package/dist/tasks/duplicate-detector.js +14 -5
  738. package/dist/tasks/duplicate-detector.js.map +1 -1
  739. package/dist/tasks/engine-wrap-ops.d.ts +48 -10
  740. package/dist/tasks/engine-wrap-ops.d.ts.map +1 -1
  741. package/dist/tasks/engine-wrap-ops.js +78 -10
  742. package/dist/tasks/engine-wrap-ops.js.map +1 -1
  743. package/dist/tasks/engine-wrap.d.ts +1 -1
  744. package/dist/tasks/engine-wrap.d.ts.map +1 -1
  745. package/dist/tasks/engine-wrap.js +1 -1
  746. package/dist/tasks/engine-wrap.js.map +1 -1
  747. package/dist/tasks/evidence.d.ts +2 -0
  748. package/dist/tasks/evidence.d.ts.map +1 -1
  749. package/dist/tasks/evidence.js +30 -4
  750. package/dist/tasks/evidence.js.map +1 -1
  751. package/dist/tasks/gate-runner.d.ts.map +1 -1
  752. package/dist/tasks/gate-runner.js +48 -12
  753. package/dist/tasks/gate-runner.js.map +1 -1
  754. package/dist/tasks/graph-ops.d.ts +9 -2
  755. package/dist/tasks/graph-ops.d.ts.map +1 -1
  756. package/dist/tasks/graph-ops.js +24 -32
  757. package/dist/tasks/graph-ops.js.map +1 -1
  758. package/dist/tasks/index.d.ts +1 -1
  759. package/dist/tasks/index.d.ts.map +1 -1
  760. package/dist/tasks/index.js +1 -1
  761. package/dist/tasks/index.js.map +1 -1
  762. package/dist/tasks/ops.d.ts +1 -0
  763. package/dist/tasks/ops.d.ts.map +1 -1
  764. package/dist/tasks/plan.d.ts.map +1 -1
  765. package/dist/tasks/plan.js +16 -60
  766. package/dist/tasks/plan.js.map +1 -1
  767. package/dist/tasks/ranking-audit.d.ts +122 -0
  768. package/dist/tasks/ranking-audit.d.ts.map +1 -0
  769. package/dist/tasks/ranking-audit.js +193 -0
  770. package/dist/tasks/ranking-audit.js.map +1 -0
  771. package/dist/tasks/task-analyze.d.ts.map +1 -1
  772. package/dist/tasks/task-analyze.js +19 -32
  773. package/dist/tasks/task-analyze.js.map +1 -1
  774. package/dist/tasks/task-context.d.ts.map +1 -1
  775. package/dist/tasks/task-context.js +13 -0
  776. package/dist/tasks/task-context.js.map +1 -1
  777. package/dist/tasks/task-import.d.ts.map +1 -1
  778. package/dist/tasks/task-import.js +21 -12
  779. package/dist/tasks/task-import.js.map +1 -1
  780. package/dist/tasks/task-next.d.ts +67 -2
  781. package/dist/tasks/task-next.d.ts.map +1 -1
  782. package/dist/tasks/task-next.js +99 -102
  783. package/dist/tasks/task-next.js.map +1 -1
  784. package/dist/tasks/task-ops.d.ts +1 -1
  785. package/dist/tasks/task-ops.d.ts.map +1 -1
  786. package/dist/tasks/task-ops.js +1 -1
  787. package/dist/tasks/task-ops.js.map +1 -1
  788. package/dist/tasks/tool-resolver.d.ts +7 -1
  789. package/dist/tasks/tool-resolver.d.ts.map +1 -1
  790. package/dist/tasks/tool-resolver.js +24 -10
  791. package/dist/tasks/tool-resolver.js.map +1 -1
  792. package/dist/tasks/update.d.ts +8 -2
  793. package/dist/tasks/update.d.ts.map +1 -1
  794. package/dist/tasks/update.js +35 -6
  795. package/dist/tasks/update.js.map +1 -1
  796. package/dist/telemetry/sqlite.d.ts.map +1 -1
  797. package/dist/telemetry/sqlite.js +2 -0
  798. package/dist/telemetry/sqlite.js.map +1 -1
  799. package/dist/upgrade.d.ts +1 -1
  800. package/dist/upgrade.d.ts.map +1 -1
  801. package/dist/upgrade.js +48 -9
  802. package/dist/upgrade.js.map +1 -1
  803. package/dist/validation/doctor/checks.d.ts +20 -6
  804. package/dist/validation/doctor/checks.d.ts.map +1 -1
  805. package/dist/validation/doctor/checks.js +53 -10
  806. package/dist/validation/doctor/checks.js.map +1 -1
  807. package/dist/validation/validate-ops.d.ts.map +1 -1
  808. package/dist/validation/validate-ops.js +2 -3
  809. package/dist/validation/validate-ops.js.map +1 -1
  810. package/migrations/drizzle-cleo-global/20260929010000_t12512-registry-probed-opened/migration.sql +35 -0
  811. package/migrations/drizzle-cleo-global/20260929020000_t12721-git-state-head-committed-at/migration.sql +25 -0
  812. package/migrations/drizzle-cleo-project/20260929000000_t12535-docs-attachments-union-shape/migration.sql +21 -0
  813. package/migrations/drizzle-cleo-project/20260929120000_t12502-task-claim-leases/migration.sql +77 -0
  814. package/migrations/drizzle-cleo-project/20260929130000_t12736-claim-lease-iso-repair/migration.sql +37 -0
  815. package/package.json +24 -14
  816. package/schemas/config.schema.json +13 -0
  817. package/schemas/project-info.schema.json +10 -4
  818. package/templates/CLEO-INJECTION.md +1 -1
  819. package/templates/CLEO-REFERENCE.md +7 -3
  820. package/templates/cleo-gitignore +11 -0
  821. package/templates/workflows/release-prepare.yml.tmpl +156 -10
@@ -0,0 +1,497 @@
1
+ /**
2
+ * Worktree-build schema-write guard (T12687).
3
+ *
4
+ * A CLI built inside a linked git worktree carries that branch's UNRELEASED
5
+ * migrations and schema code. Path resolution maps a worktree to its parent
6
+ * project's store (T12460), so running that build — `cleo check arch`, an
7
+ * unsandboxed CLI test, a reviewer trying a PR build — changed the schema of
8
+ * the LIVE main-checkout store. Incident 2026-09-29: cleo-nexus's slice-2
9
+ * build wrote `__drizzle_migrations` row 114 into the live cleocode store; the
10
+ * released CLI then deleted the unknown row as an orphan and the next slice-2
11
+ * open re-ran `ADD COLUMN` and failed.
12
+ *
13
+ * ## One decision per store, enforced on the handle
14
+ *
15
+ * {@link schemaWriteRefusal} decides, once per store path, whether this build
16
+ * may change that store's schema. When it may not,
17
+ * {@link installSchemaWriteGuard} installs a SQLite authorizer on the handle
18
+ * that DENIES every schema change — `ALTER`, `DROP`, and any `CREATE` of an
19
+ * object that does not already exist (a `CREATE … IF NOT EXISTS` of an
20
+ * existing object is a no-op and stays allowed). That covers every DDL site
21
+ * at once — drizzle migrations, `ensureColumns`, raw `ALTER`s, table
22
+ * rebuilds, twin collapse, exodus — including sites added later. Migration
23
+ * sites additionally fail fast with {@link WorktreeBuildSchemaError} when the
24
+ * build has pending migrations: the store would not match what this build
25
+ * reads, so it refuses rather than failing later with `no such column`.
26
+ *
27
+ * ## Who is a dev build
28
+ *
29
+ * The build stamp `dist/build-provenance.json` (written at build time) names
30
+ * the linked worktree the build was made in, or null for a main checkout / CI
31
+ * clone — how released packages are built. The stamp travels with the build,
32
+ * so an `npm pack`ed worktree build installed globally, or a `dist` copied
33
+ * outside any checkout, is still recognised. Without a stamp (running from
34
+ * source), the running file's own location decides, and a path under
35
+ * `node_modules` counts as installed.
36
+ *
37
+ * Allowed without an opt-in: stores inside the build's own worktree, and the
38
+ * test harness's fixtures (under `VITEST`, a store below `os.tmpdir()` — the
39
+ * fork sandbox; or a store below a {@link TEST_SANDBOX_MARKER} for CLI
40
+ * children a test spawns). `VITEST` alone is NOT an exemption: a test that
41
+ * reaches a real checkout's store is refused (T12737). Outside the harness a
42
+ * temp directory alone is not one either — a project cloned under `/tmp` is a
43
+ * real store. Everything else needs `CLEO_ALLOW_WORKTREE_BUILD_MIGRATIONS=1`.
44
+ *
45
+ * @task T12687
46
+ */
47
+ import { existsSync, readFileSync, realpathSync } from 'node:fs';
48
+ import { createRequire } from 'node:module';
49
+ import { tmpdir } from 'node:os';
50
+ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
51
+ import { fileURLToPath } from 'node:url';
52
+ import { ExitCode } from '@cleocode/contracts';
53
+ import { CleoError } from '../errors.js';
54
+ import { isGitLinkedCheckout } from '../project-scope.js';
55
+ /** Opt-in that lets a worktree build change the schema of a store outside its worktree. */
56
+ export const ALLOW_WORKTREE_BUILD_MIGRATIONS_ENV = 'CLEO_ALLOW_WORKTREE_BUILD_MIGRATIONS';
57
+ /**
58
+ * File the test harness (`vitest.setup.ts`) writes at the root of each fork's
59
+ * sandbox. A store below it is a fixture — including one opened by a CLI child
60
+ * process the test spawned: such a child carries `VITEST` only when the test
61
+ * passes its own environment through, and many build an explicit `env`.
62
+ * A marker inside a git checkout is ignored: the sandbox is never in one, so a
63
+ * marker there was committed or planted in a real project.
64
+ */
65
+ export const TEST_SANDBOX_MARKER = '.cleo-test-sandbox';
66
+ /** Error code of {@link WorktreeBuildSchemaError}. */
67
+ export const E_WORKTREE_BUILD_SCHEMA = 'E_WORKTREE_BUILD_SCHEMA';
68
+ let overrides = null;
69
+ const decisions = new Map();
70
+ /**
71
+ * Replace the guard's view of the running build (tests only: a test process
72
+ * runs from source inside the harness, so it cannot be a dev build itself).
73
+ *
74
+ * @param next - Partial options, or null to restore the defaults.
75
+ * @internal
76
+ */
77
+ export function setWorktreeBuildGuardForTests(next) {
78
+ overrides = next;
79
+ decisions.clear();
80
+ }
81
+ function realOrResolved(path) {
82
+ try {
83
+ return realpathSync(path);
84
+ }
85
+ catch {
86
+ return resolve(path);
87
+ }
88
+ }
89
+ function isWithin(root, path) {
90
+ const local = relative(root, path);
91
+ return local === '' || (!isAbsolute(local) && local !== '..' && !local.startsWith(`..${sep}`));
92
+ }
93
+ /** Whether `dir` or an ancestor is a git checkout (has `.git`). */
94
+ function insideGitCheckout(dir) {
95
+ let current = dir;
96
+ for (;;) {
97
+ if (existsSync(join(current, '.git')))
98
+ return true;
99
+ const parent = dirname(current);
100
+ if (parent === current)
101
+ return false;
102
+ current = parent;
103
+ }
104
+ }
105
+ /**
106
+ * Whether a {@link TEST_SANDBOX_MARKER} sits in `path` or an ancestor, outside
107
+ * any git checkout (a marker inside a checkout is refused).
108
+ */
109
+ function insideTestSandbox(path) {
110
+ let dir = dirname(path);
111
+ for (;;) {
112
+ if (existsSync(join(dir, TEST_SANDBOX_MARKER)))
113
+ return !insideGitCheckout(dir);
114
+ const parent = dirname(dir);
115
+ if (parent === dir)
116
+ return false;
117
+ dir = parent;
118
+ }
119
+ }
120
+ /**
121
+ * Root of the linked git worktree containing `path`, or null when the nearest
122
+ * enclosing checkout is a main checkout (or there is none).
123
+ *
124
+ * @param path - Any path.
125
+ * @returns The linked worktree root, or null.
126
+ */
127
+ export function linkedWorktreeRootOf(path) {
128
+ let dir = realOrResolved(path);
129
+ for (;;) {
130
+ if (isGitLinkedCheckout(dir))
131
+ return dir;
132
+ if (existsSync(join(dir, '.git')))
133
+ return null; // a main checkout
134
+ const parent = dirname(dir);
135
+ if (parent === dir)
136
+ return null;
137
+ dir = parent;
138
+ }
139
+ }
140
+ /**
141
+ * The build stamp beside the running build: the nearest `build-provenance.json`
142
+ * walking up from `codePath`, stopping at the package root.
143
+ *
144
+ * @param codePath - A file of the running build.
145
+ * @returns The stamp, or null when there is none (running from source).
146
+ */
147
+ export function readBuildProvenance(codePath) {
148
+ let dir = dirname(codePath);
149
+ for (;;) {
150
+ const stamp = join(dir, 'build-provenance.json');
151
+ if (existsSync(stamp)) {
152
+ try {
153
+ const parsed = JSON.parse(readFileSync(stamp, 'utf8'));
154
+ if (typeof parsed === 'object' && parsed !== null && 'linkedWorktree' in parsed) {
155
+ const value = parsed.linkedWorktree;
156
+ // Only an explicit null or a path is trusted; anything else falls back.
157
+ if (value === null || typeof value === 'string')
158
+ return { linkedWorktree: value };
159
+ }
160
+ }
161
+ catch {
162
+ // An unreadable stamp decides nothing; fall back to the path.
163
+ }
164
+ return null;
165
+ }
166
+ if (existsSync(join(dir, 'package.json')))
167
+ return null;
168
+ const parent = dirname(dir);
169
+ if (parent === dir)
170
+ return null;
171
+ dir = parent;
172
+ }
173
+ }
174
+ /**
175
+ * The linked worktree this build came from, or null for a released build.
176
+ *
177
+ * @param options - Injection points; defaults describe this process.
178
+ * @returns The worktree root, or null.
179
+ */
180
+ export function devBuildWorktree(options = {}) {
181
+ const codePath = options.codePath ?? overrides?.codePath ?? fileURLToPath(import.meta.url);
182
+ const provenance = options.provenance !== undefined
183
+ ? options.provenance
184
+ : overrides?.provenance !== undefined
185
+ ? overrides.provenance
186
+ : readBuildProvenance(codePath);
187
+ if (provenance)
188
+ return provenance.linkedWorktree;
189
+ if (codePath.split(/[\\/]/).includes('node_modules'))
190
+ return null;
191
+ return linkedWorktreeRootOf(codePath);
192
+ }
193
+ /**
194
+ * Why this build must not change the schema of `dbPath`, or null when it may.
195
+ *
196
+ * @param dbPath - Store path.
197
+ * @param options - Injection points; defaults describe this process.
198
+ * @returns The refusal naming the build's worktree, the store and the opt-in.
199
+ * @task T12687
200
+ */
201
+ export function schemaWriteRefusal(dbPath, options = {}) {
202
+ const env = options.env ?? overrides?.env ?? process.env;
203
+ const buildWorktree = devBuildWorktree(options);
204
+ if (buildWorktree === null)
205
+ return null;
206
+ const store = realOrResolved(dbPath);
207
+ if (isWithin(realOrResolved(buildWorktree), store))
208
+ return null;
209
+ // The test harness owns its FIXTURE stores — those under a temp root — and
210
+ // nothing else: an unconditional VITEST exemption let a test run from a
211
+ // worktree migrate the live main-checkout store (T12737).
212
+ if (env['VITEST']) {
213
+ const fixtureRoots = options.fixtureRoots ?? overrides?.fixtureRoots ?? [tmpdir()];
214
+ if (fixtureRoots.some((root) => isWithin(realOrResolved(root), store)))
215
+ return null;
216
+ }
217
+ const honourTestSandbox = options.honourTestSandbox ?? overrides?.honourTestSandbox ?? true;
218
+ if (honourTestSandbox && insideTestSandbox(store))
219
+ return null;
220
+ if (env[ALLOW_WORKTREE_BUILD_MIGRATIONS_ENV] === '1')
221
+ return null;
222
+ return (`Refusing to change the schema of ${store}: this CLI was built inside the git worktree ` +
223
+ `${buildWorktree}, and its schema may be unreleased. Run the released \`cleo\` against this ` +
224
+ `store, or opt in with ${ALLOW_WORKTREE_BUILD_MIGRATIONS_ENV}=1 (T12687).`);
225
+ }
226
+ /** Backwards-compatible alias of {@link schemaWriteRefusal}. */
227
+ export const worktreeBuildMigrationRefusal = schemaWriteRefusal;
228
+ /**
229
+ * The per-store decision, memoised for the process (one decision per store).
230
+ *
231
+ * @param dbPath - Store path.
232
+ * @returns The refusal, or null when schema writes are allowed.
233
+ */
234
+ function decisionFor(dbPath) {
235
+ const key = realOrResolved(dbPath);
236
+ if (!decisions.has(key))
237
+ decisions.set(key, schemaWriteRefusal(key));
238
+ return decisions.get(key) ?? null;
239
+ }
240
+ /**
241
+ * Whether this build may change the schema of the store behind `nativeDb`.
242
+ *
243
+ * @param nativeDb - Store handle (`location()` is its path; in-memory is always allowed).
244
+ * @returns `true` when schema writes are allowed.
245
+ */
246
+ export function schemaWritesAllowed(nativeDb) {
247
+ const dbPath = nativeDb.location();
248
+ return !dbPath || decisionFor(dbPath) === null;
249
+ }
250
+ /** Refusal raised when a dev build would change a foreign store's schema (T12687). */
251
+ export class WorktreeBuildSchemaError extends CleoError {
252
+ constructor(message) {
253
+ super(ExitCode.CONFIG_ERROR, `${E_WORKTREE_BUILD_SCHEMA}: ${message}`, {
254
+ fix: 'Use the released `cleo` for this store, run the build against a store inside its own ' +
255
+ `worktree, or set ${ALLOW_WORKTREE_BUILD_MIGRATIONS_ENV}=1 to accept the schema change.`,
256
+ });
257
+ }
258
+ }
259
+ /** Whether `error` is (or wraps) a {@link WorktreeBuildSchemaError}. */
260
+ export function isWorktreeBuildSchemaError(error) {
261
+ return error instanceof Error && error.message.includes(E_WORKTREE_BUILD_SCHEMA);
262
+ }
263
+ /**
264
+ * SQLite action codes, loaded on first use: `node:sqlite` must not load at
265
+ * module-init time (sqlite.ts imports this module; T1331 lazy-init contract).
266
+ */
267
+ let authorizerCodes;
268
+ function codes() {
269
+ if (authorizerCodes)
270
+ return authorizerCodes;
271
+ const sqlite = createRequire(import.meta.url)('node:sqlite')
272
+ .constants;
273
+ authorizerCodes = {
274
+ sqlite,
275
+ creates: new Map([
276
+ [sqlite.SQLITE_CREATE_TABLE, 'table'],
277
+ [sqlite.SQLITE_CREATE_VTABLE, 'table'],
278
+ [sqlite.SQLITE_CREATE_INDEX, 'index'],
279
+ [sqlite.SQLITE_CREATE_TRIGGER, 'trigger'],
280
+ [sqlite.SQLITE_CREATE_VIEW, 'view'],
281
+ ]),
282
+ changes: new Set([
283
+ sqlite.SQLITE_ALTER_TABLE,
284
+ sqlite.SQLITE_DROP_TABLE,
285
+ sqlite.SQLITE_DROP_INDEX,
286
+ sqlite.SQLITE_DROP_TRIGGER,
287
+ sqlite.SQLITE_DROP_VIEW,
288
+ sqlite.SQLITE_DROP_VTABLE,
289
+ ]),
290
+ };
291
+ return authorizerCodes;
292
+ }
293
+ const guards = new WeakMap();
294
+ /** Refusal for an ATTACH whose store this build cannot identify from its name. */
295
+ const UNKNOWN_ATTACH_REFUSAL = 'a store was ATTACHed by a bound, computed or URI filename, so this build cannot tell whose ' +
296
+ 'store it is; schema changes on unmapped schemas are refused until the guard is refreshed';
297
+ /**
298
+ * The refusal for an ATTACH, judged from the name SQLite's callback reports.
299
+ *
300
+ * Only a plain path is judged directly. The callback reports the filename only
301
+ * when it is a string literal (null otherwise), and a `file:` URI or a name
302
+ * with a `?` query is not a path: resolved against cwd it lands inside the
303
+ * worktree and would pass. Those fail closed until a refresh maps the real
304
+ * path from `PRAGMA database_list`. `''` and `:memory:` open private stores.
305
+ *
306
+ * @param name - The ATTACH callback's filename argument.
307
+ * @returns The refusal, or `null` when the attach is allowed.
308
+ */
309
+ function attachRefusal(name) {
310
+ if (name === '' || name === ':memory:')
311
+ return null;
312
+ if (typeof name !== 'string' || /^file:/i.test(name) || name.includes('?')) {
313
+ return UNKNOWN_ATTACH_REFUSAL;
314
+ }
315
+ return decisionFor(name);
316
+ }
317
+ function readSchemas(nativeDb) {
318
+ const schemas = new Map();
319
+ const list = nativeDb.prepare('PRAGMA database_list').all();
320
+ for (const { name, file } of list) {
321
+ if (name === 'temp')
322
+ continue;
323
+ const rows = nativeDb
324
+ .prepare(`SELECT type, name FROM "${name.replaceAll('"', '""')}".sqlite_master`)
325
+ .all();
326
+ schemas.set(name.toLowerCase(), {
327
+ refusal: file ? decisionFor(file) : null, // '' = in-memory
328
+ objects: new Set(rows.map((r) => `${r.type}:${r.name}`)),
329
+ });
330
+ }
331
+ return schemas;
332
+ }
333
+ let processBuildWorktree;
334
+ /**
335
+ * Whether this process is a dev build (the guard's precondition). The test
336
+ * harness is not exempt here: {@link schemaWriteRefusal} exempts its fixture
337
+ * stores per store, so a test run from a worktree that reaches a real store is
338
+ * still guarded (T12737).
339
+ */
340
+ function guardActive() {
341
+ if (overrides)
342
+ return devBuildWorktree() !== null;
343
+ if (processBuildWorktree === undefined)
344
+ processBuildWorktree = devBuildWorktree();
345
+ return processBuildWorktree !== null;
346
+ }
347
+ /**
348
+ * Install the schema-write guard on a freshly opened writable handle. Call it
349
+ * right after opening, before any schema code runs.
350
+ *
351
+ * Only a dev build (outside the test harness) installs anything; released
352
+ * builds pay nothing. The authorizer then applies, PER SCHEMA, the decision
353
+ * for that schema's file: on a refused schema it denies `ALTER`, `DROP` and
354
+ * any `CREATE` of an object that does not already exist. That covers the main
355
+ * schema and any store ATTACHed later — an exempt handle (in-memory or inside
356
+ * the build's own worktree) that attaches a foreign store is guarded on the
357
+ * attached schema too.
358
+ *
359
+ * @param nativeDb - Freshly opened writable handle.
360
+ * @returns `true` when the main schema itself is refused.
361
+ * @task T12687
362
+ */
363
+ export function installSchemaWriteGuard(nativeDb) {
364
+ if (!guardActive())
365
+ return false;
366
+ const location = nativeDb.location();
367
+ const mainRefusal = location ? decisionFor(location) : null; // in-memory is always allowed
368
+ if (typeof nativeDb.setAuthorizer !== 'function') {
369
+ // No authorizer in this Node: refuse a refused store outright rather than
370
+ // leave schema code unguarded.
371
+ if (mainRefusal)
372
+ throw new WorktreeBuildSchemaError(mainRefusal);
373
+ return false;
374
+ }
375
+ const state = {
376
+ schemas: readSchemas(nativeDb),
377
+ unmappedAttachRefusal: null,
378
+ stale: false,
379
+ lastDenied: null,
380
+ };
381
+ guards.set(nativeDb, state);
382
+ const { sqlite, creates, changes } = codes();
383
+ nativeDb.setAuthorizer((action, arg1, arg2, dbName) => {
384
+ if (action === sqlite.SQLITE_ATTACH) {
385
+ const refusal = attachRefusal(arg1);
386
+ if (refusal && !state.unmappedAttachRefusal)
387
+ state.unmappedAttachRefusal = refusal;
388
+ return sqlite.SQLITE_OK;
389
+ }
390
+ if (action === sqlite.SQLITE_DETACH) {
391
+ state.stale = true;
392
+ return sqlite.SQLITE_OK;
393
+ }
394
+ const createType = creates.get(action);
395
+ if (createType === undefined && !changes.has(action))
396
+ return sqlite.SQLITE_OK;
397
+ // SQLITE_ALTER_TABLE passes (schema, table) in arg1/arg2 and no dbName;
398
+ // every other action passes the schema as dbName.
399
+ // Schema names are case-insensitive in SQLite; the map is keyed lower-case.
400
+ const schema = ((action === sqlite.SQLITE_ALTER_TABLE ? arg1 : dbName) ?? 'main').toLowerCase();
401
+ if (schema === 'temp')
402
+ return sqlite.SQLITE_OK;
403
+ // After a DETACH every schema is unmapped until refresh. Its old refusal
404
+ // still applies, because the DETACH may have failed after authorization.
405
+ const mapped = state.schemas.get(schema);
406
+ const policy = state.stale ? undefined : mapped;
407
+ const refusal = policy
408
+ ? policy.refusal
409
+ : (mapped?.refusal ?? null) || state.unmappedAttachRefusal;
410
+ if (refusal === null)
411
+ return sqlite.SQLITE_OK;
412
+ // CREATE … IF NOT EXISTS of an existing object is a no-op.
413
+ if (createType !== undefined && policy?.objects.has(`${createType}:${arg1}`)) {
414
+ return sqlite.SQLITE_OK;
415
+ }
416
+ state.lastDenied = {
417
+ what: createType !== undefined
418
+ ? `CREATE ${createType} ${schema}.${arg1}`
419
+ : `schema change on ${schema}.${(action === sqlite.SQLITE_ALTER_TABLE ? arg2 : arg1) ?? ''}`,
420
+ refusal,
421
+ };
422
+ return sqlite.SQLITE_DENY;
423
+ });
424
+ return mainRefusal !== null;
425
+ }
426
+ /**
427
+ * Re-read the schema map after an `ATTACH`, so the attached schema gets its own
428
+ * decision and no-op `CREATE … IF NOT EXISTS` statements on it stay allowed.
429
+ *
430
+ * @param nativeDb - A handle passed to {@link installSchemaWriteGuard}.
431
+ */
432
+ export function refreshSchemaWriteGuard(nativeDb) {
433
+ const state = guards.get(nativeDb);
434
+ if (!state)
435
+ return;
436
+ state.schemas = readSchemas(nativeDb);
437
+ state.unmappedAttachRefusal = null;
438
+ state.stale = false;
439
+ }
440
+ /**
441
+ * Turn SQLite's bare `not authorized` from a guarded handle into the refusal
442
+ * that says why and what to do. Other errors are returned unchanged.
443
+ *
444
+ * @param nativeDb - The handle the error came from.
445
+ * @param error - The caught error.
446
+ * @returns The error to rethrow.
447
+ */
448
+ export function explainSchemaWriteDenial(nativeDb, error) {
449
+ if (!(error instanceof Error) || !/not authorized/i.test(error.message))
450
+ return error;
451
+ const denied = guards.get(nativeDb)?.lastDenied;
452
+ if (!denied)
453
+ return error;
454
+ return new WorktreeBuildSchemaError(`${denied.refusal} Denied: ${denied.what}.`);
455
+ }
456
+ /**
457
+ * Migrations of one lineage that `nativeDb`'s journal does not yet record.
458
+ *
459
+ * @param nativeDb - Store handle.
460
+ * @param migrations - The lineage's local migrations.
461
+ * @returns Names (or hashes) of the pending migrations; all of them when the
462
+ * journal table does not exist yet.
463
+ */
464
+ export function pendingMigrations(nativeDb, migrations) {
465
+ const hasJournal = nativeDb
466
+ .prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = '__drizzle_migrations'")
467
+ .get();
468
+ const applied = hasJournal
469
+ ? new Set(nativeDb.prepare('SELECT hash FROM main."__drizzle_migrations"').all().map((row) => row.hash))
470
+ : new Set();
471
+ return migrations.filter((m) => !applied.has(m.hash)).map((m) => m.name ?? m.hash);
472
+ }
473
+ /**
474
+ * The guard at a migration site: when this build may not change the store's
475
+ * schema and the lineage has pending migrations, FAIL FAST — the store does
476
+ * not match what this build reads, so continuing would only fail later with
477
+ * `no such column`.
478
+ *
479
+ * @param nativeDb - Store handle.
480
+ * @param migrations - The lineage's local migrations.
481
+ * @throws {WorktreeBuildSchemaError} naming the build worktree, the store,
482
+ * the pending migrations and the opt-in.
483
+ * @task T12687
484
+ */
485
+ export function assertNoPendingMigrationsForWorktreeBuild(nativeDb, migrations) {
486
+ const dbPath = nativeDb.location();
487
+ if (!dbPath)
488
+ return;
489
+ const refusal = decisionFor(dbPath);
490
+ if (refusal === null)
491
+ return;
492
+ const pending = pendingMigrations(nativeDb, migrations);
493
+ if (pending.length === 0)
494
+ return;
495
+ throw new WorktreeBuildSchemaError(`${refusal} Pending migrations: ${pending.join(', ')}.`);
496
+ }
497
+ //# sourceMappingURL=worktree-build-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-build-guard.js","sourceRoot":"","sources":["../../src/store/worktree-build-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,2FAA2F;AAC3F,MAAM,CAAC,MAAM,mCAAmC,GAAG,sCAAsC,CAAC;AAE1F;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAExD,sDAAsD;AACtD,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AA+BjE,IAAI,SAAS,GAA8C,IAAI,CAAC;AAChE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,UAAU,6BAA6B,CAC3C,IAA+C;IAE/C,SAAS,GAAG,IAAI,CAAC;IACjB,SAAS,CAAC,KAAK,EAAE,CAAC;AACpB,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,IAAI,CAAC;QACH,OAAO,YAAY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AwB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9F,CAAC"}
@@ -15,6 +15,7 @@
15
15
  * @saga T9800
16
16
  * @decision D009
17
17
  */
18
+ import { CleoError } from '../errors.js';
18
19
  /**
19
20
  * Refuse to open a project-scope store file that lives inside a git worktree.
20
21
  *
@@ -61,4 +62,141 @@ export declare function assertStorePathIsNotWorktreeResident(role: string, dbPat
61
62
  * ```
62
63
  */
63
64
  export declare function assertDbPathIsNotWorktreeResident(role: string, cwd?: string): void;
65
+ /** Error code: a whole-store rewrite would land inside a linked worktree (T12708). */
66
+ export declare const E_WT_STORE_REWRITE_REFUSED = "E_WT_STORE_REWRITE_REFUSED";
67
+ /** Error code: a whole-store rewrite of the owning project's store needs confirmation (T12708). */
68
+ export declare const E_WT_STORE_REWRITE_CONFIRM_REQUIRED = "E_WT_STORE_REWRITE_CONFIRM_REQUIRED";
69
+ /** CLI flag that confirms a whole-store rewrite of the owning project's live store. */
70
+ export declare const CONFIRM_OWNER_STORE_FLAG = "--confirm-owner-store";
71
+ /**
72
+ * Audit file, under the owning project's `.cleo/audit/`, recording every
73
+ * confirmed owner-store rewrite run from one of its worktrees (T12708).
74
+ */
75
+ export declare const OWNER_STORE_REWRITE_AUDIT_FILE = "owner-store-rewrite.jsonl";
76
+ /** Inputs of {@link ownerStoreRewriteRefusal} and {@link assertOwnerStoreRewriteConfirmed}. */
77
+ export interface OwnerStoreRewriteOptions {
78
+ /**
79
+ * Directory the operation was invoked from. Explicit commands receive it
80
+ * from the CLI layer; open-time rewrites pass {@link invocationDirectory}.
81
+ */
82
+ cwd: string;
83
+ /** The operator confirmed overwriting the owning project's live store. */
84
+ confirmOwnerStore?: boolean | undefined;
85
+ /**
86
+ * The rewrite runs implicitly when a store opens (auto-recovery, exodus
87
+ * first-open migration, lineage rebuild, upgrade storage migration). It
88
+ * targets the owning project's store exactly as it would from the project
89
+ * root, so it needs no confirmation there: only a worktree-resident target
90
+ * is refused, and a run from a worktree is audited. Unreleased worktree
91
+ * builds are stopped separately by the T12687 schema-write guard.
92
+ */
93
+ openTime?: boolean | undefined;
94
+ }
95
+ /** One row of {@link OWNER_STORE_REWRITE_AUDIT_FILE}. */
96
+ export interface OwnerStoreRewriteAuditRow {
97
+ /** ISO-8601 time of the rewrite. */
98
+ timestamp: string;
99
+ /** Operation label, e.g. `restore` or `backup recover tasks`. */
100
+ operation: string;
101
+ /** `confirmed` by {@link CONFIRM_OWNER_STORE_FLAG}, or an `open-time` rewrite. */
102
+ trigger: 'confirmed' | 'open-time';
103
+ /** Linked worktree the operation was run from. */
104
+ worktree: string;
105
+ /** Store file or `.cleo/` directory that was overwritten. */
106
+ store: string;
107
+ /** Invocation directory. */
108
+ cwd: string;
109
+ /** Process id of the writer. */
110
+ pid: number;
111
+ }
112
+ /**
113
+ * The directory an open-time store rewrite was invoked from.
114
+ *
115
+ * Open-time rewrites receive the caller's optional `cwd`, the same value the
116
+ * store path was resolved from; when it is absent the store was resolved from
117
+ * the process directory, so that is the invocation directory.
118
+ *
119
+ * @param cwd - The caller's optional working directory.
120
+ * @returns The absolute invocation directory.
121
+ * @example
122
+ * ```ts
123
+ * invocationDirectory(undefined); // the process directory
124
+ * ```
125
+ * @task T12708
126
+ */
127
+ export declare function invocationDirectory(cwd: string | undefined): string;
128
+ /**
129
+ * Decide whether a whole-store rewrite (restore, recovery, import, rebuild,
130
+ * migration) of a project store may run (T12680, T12708). Every whole-store
131
+ * rewrite shares this decision and its messages.
132
+ *
133
+ * - A target inside a linked worktree is refused: CLEO never reads a
134
+ * worktree-resident store (T12460), so the rewrite would be lost.
135
+ * - The owning project's store, reached from one of its worktrees by an
136
+ * explicit command, needs {@link CONFIRM_OWNER_STORE_FLAG}: path resolution
137
+ * sent the operation to that LIVE store, so the operator must say they mean
138
+ * it. An open-time rewrite ({@link OwnerStoreRewriteOptions.openTime}) is
139
+ * allowed there.
140
+ * - Anything else (not a `<root>/.cleo` store, not run from a worktree, or a
141
+ * store the worktree does not own) is allowed.
142
+ *
143
+ * @param operation - Label naming the rewrite in the message and audit row.
144
+ * @param target - Store file (`<root>/.cleo/cleo.db`) or `.cleo/` directory.
145
+ * @param opts - Invocation directory and confirmation.
146
+ * @returns The refusal, or null when the rewrite may proceed. Never writes.
147
+ * @example
148
+ * ```ts
149
+ * ownerStoreRewriteRefusal('restore', '/home/u/p/.cleo', { cwd: '/wt/T1' }); // CleoError
150
+ * ```
151
+ * @task T12708
152
+ */
153
+ export declare function ownerStoreRewriteRefusal(operation: string, target: string, opts: OwnerStoreRewriteOptions): CleoError | null;
154
+ /**
155
+ * Enforce {@link ownerStoreRewriteRefusal} and audit a confirmed overwrite.
156
+ *
157
+ * When the rewrite targets the owning project's store from one of its
158
+ * worktrees (confirmed, or an open-time rewrite), a row naming the worktree,
159
+ * store, operation and trigger is appended to `<owner>/.cleo/audit/`
160
+ * {@link OWNER_STORE_REWRITE_AUDIT_FILE} before anything is written. A failed
161
+ * audit write refuses the rewrite (the error propagates).
162
+ *
163
+ * @param operation - Label naming the rewrite in the message and audit row.
164
+ * @param target - Store file (`<root>/.cleo/cleo.db`) or `.cleo/` directory.
165
+ * @param opts - Invocation directory and confirmation.
166
+ * @throws `CleoError` {@link E_WT_STORE_REWRITE_REFUSED} or
167
+ * {@link E_WT_STORE_REWRITE_CONFIRM_REQUIRED}.
168
+ * @example
169
+ * ```ts
170
+ * assertOwnerStoreRewriteConfirmed('backup recover tasks', '/home/u/p/.cleo/cleo.db', {
171
+ * cwd: '/wt/T1',
172
+ * confirmOwnerStore: true,
173
+ * }); // appends an audit row, returns
174
+ * ```
175
+ * @task T12708
176
+ */
177
+ export declare function assertOwnerStoreRewriteConfirmed(operation: string, target: string, opts: OwnerStoreRewriteOptions): void;
178
+ /**
179
+ * Guard a manual restore (`cleo restore backup`, `admin.backup` restore) that
180
+ * is run from inside a linked git worktree (T12680): the shared whole-store
181
+ * rewrite guard ({@link assertOwnerStoreRewriteConfirmed}) with the project's
182
+ * `.cleo/` as the target.
183
+ *
184
+ * @param storeRoot - Project root whose `.cleo/` the restore writes.
185
+ * @param opts - `cwd` the restore was invoked from (required: core never
186
+ * falls back to `process.cwd()`; the CLI layer supplies it), and
187
+ * `confirmOwnerStore` to allow overwriting the owner's live store.
188
+ * @throws `CleoError` {@link E_WT_STORE_REWRITE_REFUSED} when the store lies
189
+ * inside a worktree, or {@link E_WT_STORE_REWRITE_CONFIRM_REQUIRED} when
190
+ * confirmation is missing.
191
+ * @example
192
+ * ```ts
193
+ * assertRestoreTargetConfirmed('/home/u/project', { cwd: '/data/cleo/worktrees/abc/T1' }); // throws
194
+ * ```
195
+ * @task T12680
196
+ * @task T12708
197
+ */
198
+ export declare function assertRestoreTargetConfirmed(storeRoot: string, opts: {
199
+ cwd: string;
200
+ confirmOwnerStore?: boolean | undefined;
201
+ }): void;
64
202
  //# sourceMappingURL=worktree-isolation-guard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"worktree-isolation-guard.d.ts","sourceRoot":"","sources":["../../src/store/worktree-isolation-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAWH;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oCAAoC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAoBvF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iCAAiC,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAUlF"}
1
+ {"version":3,"file":"worktree-isolation-guard.d.ts","sourceRoot":"","sources":["../../src/store/worktree-isolation-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAWzC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oCAAoC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAA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