@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
@@ -52,22 +52,26 @@
52
52
  import { existsSync, mkdirSync } from 'node:fs';
53
53
  import { createRequire } from 'node:module';
54
54
  import { dirname, join, resolve } from 'node:path';
55
- import { ExitCode } from '@cleocode/contracts';
55
+ import { ExitCode } from '@cleocode/contracts/exit-codes.js';
56
56
  import { isVaultRemotePath } from '@cleocode/paths';
57
57
  import { CleoError } from '../errors.js';
58
58
  import { getLogger } from '../logger.js';
59
59
  import { getCleoHome, resolveCleoDir } from '../paths.js';
60
60
  import { worktreeScope } from '../project-scope.js';
61
61
  import { observeOperation } from './background-ops.js';
62
- import { getRecordedExodusAbort } from './exodus/abort-events.js';
62
+ import { loadNodeSqliteDrizzle } from './drizzle-node-sqlite.js';
63
+ import { EXODUS_DEFERRED_FIX, ExodusAbortWriteUnsafeError, ExodusGuardFailedError, ExodusRunInProgressError, exodusRefusalMessage, exodusRunActiveElsewhere, getRecordedExodusAbort, } from './exodus/abort-events.js';
64
+ import { installExodusWriteGuard, peekExodusWriteGuard } from './exodus/write-guard.js';
63
65
  import { ForeignKeysNotRestoredError, migrateBracketed } from './migration-runner.js';
64
66
  import { assertStoreNotRelocated } from './relocated-store-guard.js';
65
67
  import { resolveConsolidatedJournalSiblings, resolveCorePackageMigrationsFolder, } from './resolve-migrations-folder.js';
66
- import { healRowIdentitySchema, missingRowIdentitySchema, ROW_IDENTITY } from './row-identity.js';
68
+ import { openUnlessRestoring } from './restore-marker.js';
69
+ import { healRowIdentitySchema, missingRowIdentitySchema, ROW_IDENTITY, registerRowUidFunction, rowIdentityFillPending, } from './row-identity.js';
67
70
  import { rowUidFillEnabled } from './row-identity-flag.js';
68
71
  import { applyPerfPragmas } from './sqlite-pragmas.js';
69
- import { captureBracketHooks, syncCaptureOpenPass } from './sync/capture.js';
72
+ import { syncCaptureOpenPass } from './sync/capture.js';
70
73
  import { prepareRowIdentityUnderCapture } from './sync/identity-fill.js';
74
+ import { syncMigrationHooks } from './sync/migration-hooks.js';
71
75
  import { ensureTriggerSuspendTable, verifyOwnedTriggers } from './sync/trigger-classes.js';
72
76
  import { assertWriterVersion } from './sync/writer-version.js';
73
77
  import { explainSchemaWriteDenial, installSchemaWriteGuard } from './worktree-build-guard.js';
@@ -95,48 +99,9 @@ export function getDualScopeNativeDb(handle) {
95
99
  return db.$client;
96
100
  throw new Error(`No native SQLite connection for ${handle.scope}::${handle.dbPath}`);
97
101
  }
98
- /**
99
- * Thrown by {@link assertWriteDurable} when a MUTATING caller is about to write
100
- * through a {@link DualScopeDbHandle} whose first-open exodus auto-migration
101
- * ABORTED (T11828 · DHQ-059).
102
- *
103
- * The consolidated `cleo.db` is internally consistent but EMPTY: the user's real
104
- * data is still in the legacy fleet (kept as the source of truth). Writing here
105
- * would land in a DB that does not reflect that data, so the write is NOT durable
106
- * against the source of truth. Read paths never raise this — they intentionally
107
- * skip {@link assertWriteDurable} and operate on the empty-but-consistent DB.
108
- *
109
- * Self-contained (mirrors `BackupRecoverError`) rather than a `CleoError` subclass
110
- * so the store layer does not need a new numeric `ExitCode` in `@cleocode/contracts`
111
- * for a condition that is surfaced structurally on the handle.
112
- *
113
- * @task T11828
114
- * @epic T11833
115
- * @saga T11242
116
- * @public
117
- */
118
- export class ExodusAbortWriteUnsafeError extends Error {
119
- /** Stable string error code for envelope `codeName` / log correlation. */
120
- codeName = 'E_EXODUS_ABORT_WRITE_UNSAFE';
121
- /** The structured abort detail carried by the handle. */
122
- detail;
123
- /** Remediation hint surfaced to the operator. */
124
- fix;
125
- /**
126
- * @param detail - The {@link ExodusAbortDetail} stamped on the handle.
127
- */
128
- constructor(detail) {
129
- super(`Refusing to write to consolidated ${detail.scope} cleo.db — exodus-on-open ABORTED ` +
130
- `(${detail.reason}). The DB is empty; legacy data is the source of truth. ` +
131
- `Run \`cleo doctor exodus-health\` then \`cleo exodus migrate\` (or restore via ` +
132
- `\`cleo doctor repair --role ${detail.scope === 'project' ? 'tasks' : 'nexus'}\`) before writing.`);
133
- this.name = 'ExodusAbortWriteUnsafeError';
134
- this.detail = detail;
135
- this.fix =
136
- 'Resolve the aborted migration (`cleo doctor exodus-health` → `cleo exodus migrate`) ' +
137
- 'so the consolidated cleo.db carries your data before mutating it.';
138
- }
139
- }
102
+ // The refusal error lives with the abort records (exodus/abort-events.ts), a
103
+ // light module the CORE error converters can import (T13167).
104
+ export { ExodusAbortWriteUnsafeError };
140
105
  /**
141
106
  * Assert that a {@link DualScopeDbHandle} is safe to WRITE through.
142
107
  *
@@ -171,23 +136,230 @@ export function assertWriteDurable(handle) {
171
136
  }
172
137
  }
173
138
  /**
174
- * Throw {@link ExodusAbortWriteUnsafeError} when ANY exodus-on-open abort is
175
- * recorded for this process (across either scope).
139
+ * Throw {@link ExodusAbortWriteUnsafeError} when the store behind `db` cannot be
140
+ * written durably: its exodus-on-open migration is deferred (an active guard on
141
+ * this connection) or aborted (a recorded abort for this store's path).
176
142
  *
177
143
  * Used by the consolidated-schema MUTATION primitives ({@link insertIdempotent} /
178
144
  * {@link upsertIdempotent}) which do not receive the originating
179
- * {@link DualScopeDbHandle} — they consult the process-local registry recorded by
180
- * {@link emitExodusAbort} instead. Read paths never call these primitives, so the
181
- * guard is write-only.
145
+ * {@link DualScopeDbHandle}. T13158: matched to the store being written, so a
146
+ * deferral or abort on one store never refuses another. When the store cannot
147
+ * be identified, any recorded abort refuses (the T11828 behaviour). Read paths
148
+ * never call these primitives, so the guard is write-only.
182
149
  *
183
- * @throws {ExodusAbortWriteUnsafeError} When a recorded abort exists.
150
+ * @param db - The drizzle handle about to be written.
151
+ * @throws {ExodusAbortWriteUnsafeError} When that store cannot be written durably.
184
152
  * @internal
185
153
  * @task T11828
154
+ * @task T13158
186
155
  */
187
- function assertNoRecordedExodusAbort() {
188
- const detail = getRecordedExodusAbort();
189
- if (detail) {
190
- throw new ExodusAbortWriteUnsafeError(detail);
156
+ // biome-ignore lint/suspicious/noExplicitAny: accepts both project and global schema handles
157
+ async function assertNoExodusRefusal(db) {
158
+ const native = '$client' in db && db.$client instanceof getDatabaseSyncCtor() ? db.$client : null;
159
+ const path = native?.location() ?? null;
160
+ if (native === null || path === null) {
161
+ const detail = getRecordedExodusAbort();
162
+ // @sync-invariant none:local-only this store's own legacy migration aborted or is pending; never replicated
163
+ if (detail)
164
+ throw new ExodusAbortWriteUnsafeError(detail);
165
+ return;
166
+ }
167
+ await assertExodusWriteSafe(native);
168
+ for (const scope of ['project', 'global']) {
169
+ const detail = getRecordedExodusAbort(scope);
170
+ if (detail && detail.kind !== 'deferred' && resolve(detail.dbPath) === resolve(path)) {
171
+ // @sync-invariant none:local-only this store's own legacy migration aborted; never replicated
172
+ throw new ExodusAbortWriteUnsafeError(detail);
173
+ }
174
+ }
175
+ }
176
+ // ── Deferred exodus-on-open (T13158) ─────────────────────────────────────────
177
+ /**
178
+ * Refuse a write through `nativeDb` while that store still owes its legacy
179
+ * migration: exodus-on-open was deferred or aborted while legacy rows wait
180
+ * (T13158, T13167).
181
+ *
182
+ * The production write chokepoints call this first (the task accessor's write
183
+ * transaction, session creation, {@link insertIdempotent},
184
+ * {@link upsertIdempotent}), so the caller gets the typed
185
+ * {@link ExodusAbortWriteUnsafeError} and its remedy rather than a wrapped
186
+ * SQLite trigger error. The guard is per connection, so one store's refusal
187
+ * never refuses another. Once the scope's anchor table has rows (the migration
188
+ * or a reconcile ran, in this process or another) the guard lifts and writes
189
+ * proceed. The temp triggers remain the backstop for every other write path.
190
+ *
191
+ * @param nativeDb - The connection about to be written.
192
+ * @throws {ExodusAbortWriteUnsafeError} When that store still owes its migration.
193
+ * @example
194
+ * ```ts
195
+ * await assertExodusWriteSafe(nativeDb);
196
+ * ```
197
+ * @task T13158
198
+ * @task T13167
199
+ */
200
+ export async function assertExodusWriteSafe(nativeDb) {
201
+ const { activeExodusWriteGuard } = await import('./exodus/write-guard.js');
202
+ const guard = activeExodusWriteGuard(nativeDb);
203
+ if (guard !== undefined) {
204
+ // @sync-invariant none:local-only this store's own legacy migration is pending or aborted; never replicated
205
+ throw new ExodusAbortWriteUnsafeError(guard.detail);
206
+ }
207
+ // T12785: another process is copying legacy rows into this store.
208
+ const path = nativeDb.location();
209
+ if (path !== null && exodusRunActiveElsewhere(path)) {
210
+ // @sync-invariant none:local-only another local process runs this store's legacy migration or reconcile; never replicated
211
+ throw new ExodusRunInProgressError(path);
212
+ }
213
+ }
214
+ /** Default bound on how long an open waits for the exodus `db-heavy` slot. */
215
+ const EXODUS_ADMISSION_WAIT_MS = 5_000;
216
+ /**
217
+ * How long an open waits for `db-heavy` before deferring its exodus migration:
218
+ * `CLEO_EXODUS_ADMISSION_WAIT_MS` (0–60000), else 5 s. Memory pressure defers at
219
+ * once regardless; the wait covers a slot another heavy op holds.
220
+ */
221
+ function exodusAdmissionWaitMs() {
222
+ const raw = process.env['CLEO_EXODUS_ADMISSION_WAIT_MS'];
223
+ if (raw === undefined || raw.trim() === '')
224
+ return EXODUS_ADMISSION_WAIT_MS;
225
+ const ms = Number(raw);
226
+ return Number.isInteger(ms) && ms >= 0 && ms <= 60_000 ? ms : EXODUS_ADMISSION_WAIT_MS;
227
+ }
228
+ /** The anchor table whose first row marks a scope's store as populated. */
229
+ function exodusAnchorTable(scope) {
230
+ return scope === 'project' ? 'tasks_tasks' : 'nexus_project_registry';
231
+ }
232
+ /**
233
+ * Guard a store that owes its legacy migration (T13158, T13167).
234
+ *
235
+ * When this scope's legacy sources hold rows, every INSERT into a table the
236
+ * migration fills is refused on this connection while the anchor table is
237
+ * empty (`E_EXODUS_DEFERRED_WRITE_UNSAFE` or `E_EXODUS_ABORT_WRITE_UNSAFE`,
238
+ * remedy included), and the refusal is recorded. Every handle on the
239
+ * connection reports it as `exodusAbort`. Called before a pending migration's
240
+ * handle is published (`deferred`), and on an `aborted` outcome.
241
+ *
242
+ * @param nativeDb - The handle's native connection.
243
+ * @param scope - The scope.
244
+ * @param dbPath - The consolidated store.
245
+ * @param cwd - Working directory used to resolve the project root.
246
+ * @param kind - `deferred` (not run yet) or `aborted`.
247
+ * @param reason - Why no migration has run, or why it aborted.
248
+ * @returns `true` when a guard was installed (legacy rows wait).
249
+ */
250
+ async function guardStrandedStore(nativeDb, scope, dbPath, cwd, kind, reason) {
251
+ const log = getLogger('dual-scope-db');
252
+ const { pendingExodusTargets } = await import('./exodus/write-guard.js');
253
+ let sources;
254
+ let tables;
255
+ let sentinels = {};
256
+ try {
257
+ ({ sources, tables, sentinels } = await pendingExodusTargets(scope, cwd));
258
+ }
259
+ catch (err) {
260
+ // The legacy files could not be read: assume they hold rows and protect the
261
+ // anchor table, whose first row would stop the migration for good.
262
+ log.warn({ err, scope, kind }, 'exodus-on-open: legacy sources could not be assessed');
263
+ sources = ['legacy stores (unreadable)'];
264
+ tables = [exodusAnchorTable(scope)];
265
+ }
266
+ if (sources.length === 0)
267
+ return false;
268
+ const detail = strandedDetail(scope, dbPath, kind, reason, sources);
269
+ let markerPath = null;
270
+ try {
271
+ const { exodusMarkerPath } = await import('./exodus/archive.js');
272
+ markerPath = exodusMarkerPath(scope, cwd, dbPath);
273
+ }
274
+ catch {
275
+ // No marker location: the guard lifts on the anchor alone.
276
+ }
277
+ installExodusWriteGuard(nativeDb, {
278
+ anchor: exodusAnchorTable(scope),
279
+ tables: [...new Set([...tables, exodusAnchorTable(scope)])],
280
+ sentinels,
281
+ sources,
282
+ markerPath,
283
+ detail,
284
+ }, exodusRefusalMessage(scope, detail.reason, kind));
285
+ const { emitExodusAbort } = await import('./exodus/abort-events.js');
286
+ emitExodusAbort(detail);
287
+ return true;
288
+ }
289
+ /**
290
+ * Last-resort guard for a store that owes a migration, used when
291
+ * {@link guardStrandedStore} throws: refuse INSERTs into the scope's anchor
292
+ * table, whose first row would stop the migration for good. A guard that is
293
+ * already installed is kept, since it covers more tables.
294
+ *
295
+ * @param nativeDb - The handle's native connection.
296
+ * @param scope - The scope.
297
+ * @param dbPath - The consolidated store.
298
+ * @param kind - `deferred` (not run yet) or `aborted`.
299
+ * @param reason - Why no migration has run, or why it aborted.
300
+ * @throws {ExodusGuardFailedError} When not even the anchor trigger can be
301
+ * installed: the open is refused rather than publishing a store any write
302
+ * (raw SQL included) could strand (T13171).
303
+ */
304
+ function guardAnchorOnly(nativeDb, scope, dbPath, kind, reason) {
305
+ if (peekExodusWriteGuard(nativeDb) !== undefined)
306
+ return;
307
+ const anchor = exodusAnchorTable(scope);
308
+ const sources = ['stores'];
309
+ const detail = strandedDetail(scope, dbPath, kind, reason, sources);
310
+ try {
311
+ installExodusWriteGuard(nativeDb, { anchor, tables: [anchor], sources, markerPath: null, detail }, exodusRefusalMessage(scope, detail.reason, kind));
312
+ }
313
+ catch (err) {
314
+ getLogger('dual-scope-db').error({ err, scope }, 'exodus-on-open: the store could not be guarded before its migration; refusing the open');
315
+ // @sync-invariant none:local-only this store's own legacy migration could not be guarded; never replicated
316
+ throw new ExodusGuardFailedError(scope, err);
317
+ }
318
+ }
319
+ /** The refusal detail for a store that owes the migration of `sources`. */
320
+ function strandedDetail(scope, dbPath, kind, reason, sources) {
321
+ return {
322
+ scope,
323
+ dbPath,
324
+ reason: `${reason}; legacy ${sources.join(', ')} still hold rows`,
325
+ at: Date.now(),
326
+ kind,
327
+ };
328
+ }
329
+ /**
330
+ * Record why a guarded store's migration was deferred this open (T13158):
331
+ * the refusal detail takes the governor's reason, the deferral is logged with
332
+ * it, and readers get a `W_EXODUS_DEFERRED` warning.
333
+ *
334
+ * @param nativeDb - The guarded connection.
335
+ * @param scope - The deferred scope.
336
+ * @param dbPath - The consolidated store.
337
+ * @param deferral - The governor's reason for deferring.
338
+ */
339
+ async function announceDeferredExodus(nativeDb, scope, dbPath, deferral) {
340
+ const log = getLogger('dual-scope-db');
341
+ const { activeExodusWriteGuard } = await import('./exodus/write-guard.js');
342
+ const guard = activeExodusWriteGuard(nativeDb);
343
+ if (guard === undefined)
344
+ return;
345
+ const detail = strandedDetail(scope, dbPath, 'deferred', deferral, guard.sources);
346
+ guard.detail = detail;
347
+ const { emitExodusAbort } = await import('./exodus/abort-events.js');
348
+ emitExodusAbort(detail);
349
+ log.warn({ scope, dbPath, reason: deferral, sources: guard.sources, guardedTables: guard.tables.length }, 'exodus-on-open deferred: the store is empty while legacy rows wait; writes to the ' +
350
+ 'tables the migration fills are refused until it runs (T13158)');
351
+ try {
352
+ const { pushWarning } = await import('../output.js');
353
+ pushWarning({
354
+ // @sync-invariant none:local-only a read warning about this store's pending legacy migration
355
+ code: 'W_EXODUS_DEFERRED',
356
+ message: `The ${scope} store has not been migrated from the legacy stores yet (${deferral}), so ` +
357
+ `results omit the data in ${guard.sources.join(', ')}. Writes are refused until it ` +
358
+ `runs. ${EXODUS_DEFERRED_FIX}`,
359
+ });
360
+ }
361
+ catch {
362
+ // A warning must never fail the open.
191
363
  }
192
364
  }
193
365
  const _cache = new Map();
@@ -249,19 +421,10 @@ export function resolveDualScopeDbPath(scope, cwd, capturedGlobalHome) {
249
421
  function migrationsSetName(scope) {
250
422
  return scope === 'project' ? 'drizzle-cleo-project' : 'drizzle-cleo-global';
251
423
  }
252
- // ── Lazy drizzle loading ─────────────────────────────────────────────────────
253
- // The drizzle-orm/node-sqlite driver statically imports `node:sqlite`, so we
254
- // load it lazily (matching the pattern in sqlite.ts, T11280) to avoid pulling
255
- // the native binding at module-load time and breaking lazy-init assertions.
424
+ // ── Lazy native loading ──────────────────────────────────────────────────────
425
+ // drizzle's node-sqlite driver loads lazily through ./drizzle-node-sqlite.ts
426
+ // (T11280, T13126). DatabaseSync is lazy too, to avoid an eager node:sqlite pull.
256
427
  const _require = createRequire(import.meta.url);
257
- let _drizzle = null;
258
- function getDrizzle() {
259
- if (_drizzle === null) {
260
- const mod = _require('drizzle-orm/node-sqlite');
261
- _drizzle = mod.drizzle;
262
- }
263
- return _drizzle;
264
- }
265
428
  let _DatabaseSyncCtor = null;
266
429
  function getDatabaseSyncCtor() {
267
430
  if (_DatabaseSyncCtor === null) {
@@ -396,7 +559,7 @@ db, migrationsFolder, log, execution) {
396
559
  }
397
560
  }
398
561
  execution?.assertActive();
399
- migrateBracketed(db, nativeDb, migrationsFolder, existenceTable(scope), `dual-scope-db[${scope}]`, resolveConsolidatedJournalSiblings(migrationsSetName(scope)), captureBracketHooks(nativeDb, scope));
562
+ migrateBracketed(db, nativeDb, migrationsFolder, existenceTable(scope), `dual-scope-db[${scope}]`, resolveConsolidatedJournalSiblings(migrationsSetName(scope)), syncMigrationHooks(nativeDb, scope));
400
563
  // NEW-6: the handle leaves the schema pass in its configured FK mode.
401
564
  assertHandleForeignKeys(nativeDb);
402
565
  execution?.assertActive();
@@ -431,13 +594,27 @@ db, migrationsFolder, log, execution) {
431
594
  }
432
595
  }
433
596
  /**
434
- * Whether this open has row-identity work: the fill (flag on), or identity
435
- * schema to heal (T12878). A scope with nothing declared has none.
597
+ * Whether the schema pass has row-identity work: identity schema to heal
598
+ * (T12878). A scope with nothing declared has none. The fill is decided after
599
+ * the schema pass by {@link rowIdentityFillPending} (T12341 C1).
436
600
  */
437
601
  function identityWorkOnOpen(nativeDb, scope) {
438
602
  if (ROW_IDENTITY[scope].length === 0)
439
603
  return false;
440
- return rowUidFillEnabled() || missingRowIdentitySchema(nativeDb).length > 0;
604
+ return missingRowIdentitySchema(nativeDb).length > 0;
605
+ }
606
+ /**
607
+ * The fill's pending work for this open, with the identity SQL functions
608
+ * registered. The chokepoint writers load only when there is work: a store the
609
+ * fill already completed opens without loading `sqlite-data-accessor` (T12341
610
+ * C1; it cost ~170 ms and ~15 MB on every open).
611
+ */
612
+ async function prepareFillWriters(nativeDb, scope) {
613
+ registerRowUidFunction(nativeDb, scope);
614
+ const pending = rowIdentityFillPending(nativeDb, scope);
615
+ if (pending.length > 0)
616
+ await import('./sqlite-data-accessor.js');
617
+ return pending;
441
618
  }
442
619
  /**
443
620
  * Open a DEDICATED, NON-cached consolidated dual-scope `cleo.db` connection
@@ -468,7 +645,8 @@ async function openDedicatedDualScopeDb(scope, dbPath, log, execution) {
468
645
  }
469
646
  execution?.assertActive();
470
647
  const DatabaseSyncCtor = getDatabaseSyncCtor();
471
- const nativeDb = new DatabaseSyncCtor(dbPath, { allowExtension: true });
648
+ // T13258: never open a store file a restore is replacing (before and after the open).
649
+ const nativeDb = openUnlessRestoring(dbPath, () => new DatabaseSyncCtor(dbPath, { allowExtension: true }));
472
650
  // Every operation after construction is wrapped so any exception —
473
651
  // pragmas, Drizzle wrapping, migration-folder resolution, lease, or
474
652
  // migration — closes the native handle before rethrow.
@@ -478,7 +656,7 @@ async function openDedicatedDualScopeDb(scope, dbPath, log, execution) {
478
656
  // T12687: a worktree build may not change a foreign store's schema — deny
479
657
  // every DDL on this handle before any schema code runs.
480
658
  installSchemaWriteGuard(nativeDb);
481
- const drizzle = getDrizzle();
659
+ const drizzle = loadNodeSqliteDrizzle();
482
660
  // biome-ignore lint/suspicious/noExplicitAny: dual-scope handle is untyped at construction; typed via DualScopeDbHandle<TScope>
483
661
  const db = drizzle({ client: nativeDb });
484
662
  const migrationsFolder = resolveCorePackageMigrationsFolder(migrationsSetName(scope));
@@ -496,9 +674,9 @@ async function openDedicatedDualScopeDb(scope, dbPath, log, execution) {
496
674
  // writers were loaded there when the fill is on.
497
675
  execution?.assertActive();
498
676
  if (rowUidFillEnabled() && ROW_IDENTITY[scope].length > 0) {
499
- await import('./sqlite-data-accessor.js');
677
+ const pending = await prepareFillWriters(nativeDb, scope);
500
678
  // Uncaptured under sync capture, with its tables marked suspect.
501
- prepareRowIdentityUnderCapture(nativeDb, scope, { triggers: false });
679
+ prepareRowIdentityUnderCapture(nativeDb, scope, { triggers: false, pending });
502
680
  }
503
681
  execution?.assertActive();
504
682
  log.debug({ scope, dbPath }, 'DEDICATED dual-scope cleo.db ready (T11782 FIX D)');
@@ -663,6 +841,9 @@ exodusCwd, options) {
663
841
  (async () => {
664
842
  let openingNative = null;
665
843
  let published = false;
844
+ // T13158: the exodus assessment, made BEFORE the handle is published (a
845
+ // holder object: the lease callback assigns it).
846
+ const exodusState = { preparation: null };
666
847
  try {
667
848
  execution?.assertActive();
668
849
  log.debug({ scope, dbPath: normalizedPath }, 'opening dual-scope cleo.db');
@@ -682,7 +863,8 @@ exodusCwd, options) {
682
863
  // single-keyed regardless of which domain opens the handle first.
683
864
  execution?.assertActive();
684
865
  const DatabaseSyncCtor = getDatabaseSyncCtor();
685
- const nativeDb = new DatabaseSyncCtor(normalizedPath, { allowExtension: true });
866
+ // T13258: never open a store file a restore is replacing (before and after the open).
867
+ const nativeDb = openUnlessRestoring(normalizedPath, () => new DatabaseSyncCtor(normalizedPath, { allowExtension: true }));
686
868
  openingNative = nativeDb;
687
869
  // Apply canonical pragma set (specs/sqlite-pragmas.json SSoT), bounding
688
870
  // per-connection memory for one-shot/CLI opens (full SSoT for daemon) — T11829.
@@ -691,7 +873,7 @@ exodusCwd, options) {
691
873
  // every DDL on this handle before any schema code runs.
692
874
  installSchemaWriteGuard(nativeDb);
693
875
  // Create the Drizzle ORM wrapper.
694
- const drizzle = getDrizzle();
876
+ const drizzle = loadNodeSqliteDrizzle();
695
877
  // biome-ignore lint/suspicious/noExplicitAny: dual-scope handle is untyped at construction; typed via DualScopeDbHandle<TScope>
696
878
  const db = drizzle({ client: nativeDb });
697
879
  // Resolve the migrations folder for this scope.
@@ -732,9 +914,9 @@ exodusCwd, options) {
732
914
  // once, and arm this connection's uid triggers. Never throws.
733
915
  execution?.assertActive();
734
916
  if (rowUidFillEnabled() && ROW_IDENTITY[scope].length > 0) {
735
- await import('./sqlite-data-accessor.js');
917
+ const pending = await prepareFillWriters(nativeDb, scope);
736
918
  // A derived rewrite: uncaptured, its tables marked suspect (S2).
737
- prepareRowIdentityUnderCapture(nativeDb, scope);
919
+ prepareRowIdentityUnderCapture(nativeDb, scope, { pending });
738
920
  }
739
921
  execution?.assertActive();
740
922
  log.debug({ scope, dbPath: normalizedPath }, 'dual-scope cleo.db ready');
@@ -748,6 +930,12 @@ exodusCwd, options) {
748
930
  get isOpen() {
749
931
  return nativeDb.isOpen;
750
932
  },
933
+ // T13158 / T13167: the marker is the connection's write guard, so
934
+ // every in-process holder sees a deferral or abort set (or lifted)
935
+ // after publication.
936
+ get exodusAbort() {
937
+ return peekExodusWriteGuard(nativeDb)?.detail;
938
+ },
751
939
  close() {
752
940
  // Identity-guarded deletion: only evict from the singleton cache
753
941
  // when the current entry still references THIS exact handle. A stale
@@ -765,6 +953,53 @@ exodusCwd, options) {
765
953
  }
766
954
  },
767
955
  };
956
+ // T13158: never publish an unguarded handle for a store that still
957
+ // owes a migration. Publication hands this connection to every
958
+ // concurrent in-process open, and an INSERT through it before the
959
+ // migration (or its guard) would make the store look populated and
960
+ // strand the legacy rows. So assess first, and when a migration is
961
+ // pending, guard the connection before anyone else can see it.
962
+ // Populated stores cost one COUNT(*) here.
963
+ if (exodusCwd !== undefined &&
964
+ normalizedPath === resolveDualScopeDbPath(scope, exodusCwd)) {
965
+ try {
966
+ execution?.assertActive();
967
+ const { prepareExodusOnOpen } = await import('./exodus/on-open.js');
968
+ execution?.assertActive();
969
+ exodusState.preparation = await prepareExodusOnOpen(scope, normalizedPath, nativeDb, exodusCwd);
970
+ }
971
+ catch (err) {
972
+ execution?.assertActive();
973
+ exodusState.preparation = null;
974
+ log.warn({ err, scope }, 'exodus-on-open assessment unavailable (non-fatal)');
975
+ }
976
+ // An abort decided at assessment (unreadable marker, plan mismatch,
977
+ // assessment failure) owes the same protection before publication
978
+ // as a pending migration (#1839 review HIGH): the post-lease abort
979
+ // branch would guard only after concurrent opens could write.
980
+ const preparation = exodusState.preparation;
981
+ const stranded = preparation?.kind === 'pending'
982
+ ? { kind: 'deferred', reason: 'its migration has not run yet' }
983
+ : preparation?.kind === 'decided' && preparation.result.outcome === 'aborted'
984
+ ? { kind: 'aborted', reason: preparation.result.reason }
985
+ : null;
986
+ if (stranded !== null) {
987
+ try {
988
+ execution?.assertActive();
989
+ await guardStrandedStore(nativeDb, scope, normalizedPath, exodusCwd, stranded.kind, stranded.reason);
990
+ }
991
+ catch (err) {
992
+ execution?.assertActive();
993
+ // A failed guard must cost neither the migration nor the
994
+ // protection (#1836 review LOW-a): the preparation stays
995
+ // pending, so the migration still runs after the lease, and the
996
+ // anchor table is guarded at the least. If even that fails, the
997
+ // open is refused (E_EXODUS_GUARD_FAILED, T13171).
998
+ log.warn({ err, scope }, 'exodus-on-open: the store could not be fully guarded before its migration');
999
+ guardAnchorOnly(nativeDb, scope, normalizedPath, stranded.kind, stranded.reason);
1000
+ }
1001
+ }
1002
+ }
768
1003
  execution?.assertActive();
769
1004
  // Update the cache entry to mark init complete.
770
1005
  const entry = _cache.get(key);
@@ -803,46 +1038,73 @@ exodusCwd, options) {
803
1038
  execution?.assertActive();
804
1039
  let finalHandle = handle;
805
1040
  if (exodusCwd !== undefined && normalizedPath === resolveDualScopeDbPath(scope, exodusCwd)) {
806
- // ── T12001 (Epic T11992) — db-heavy admission for the exodus auto-migrate ──
807
- // The on-open exodus (reconcile + parity verify + migrate) is a heavy DB op;
808
- // letting it co-schedule with builds/tests/agents is a historical OOM vector.
809
- // Admit it through the governor's `db-heavy` class (machine-wide serialized;
810
- // deferred under memory backoff). On a denial we SKIP the migration THIS open
811
- // (kill-switch precedent CLEO_DISABLE_EXODUS_ON_OPEN) — NEVER block or defer
812
- // the interactive command (interactive-cli is never gated) — and it re-runs
813
- // idempotently on a calmer open. Fail-open: ANY governor error proceeds
814
- // un-gated, byte-identical to pre-T12001 behaviour.
1041
+ // ── Exodus-on-open admission (T12001 · T13158) ──────────────────────────
1042
+ // Decide first, without a lock or the governor, whether this open needs
1043
+ // a migration at all: a populated store costs one COUNT(*), and only a
1044
+ // PENDING migration (empty store, this scope's legacy sources present)
1045
+ // asks for admission. The migration (reconcile + parity verify + copy)
1046
+ // is a heavy DB op, so it runs in the governor's machine-wide `db-heavy`
1047
+ // class, waiting a bounded time for the slot (T13158): `db-heavy` has one
1048
+ // slot machine-wide, so a sentient tick, a `cleo run --class db` job,
1049
+ // another project's exodus or a second `cleo` racing this first open
1050
+ // would otherwise defer it. Memory pressure still defers it at once
1051
+ // (CPU saturation never does: db-heavy is budgeted on memory alone, T13170).
1052
+ //
1053
+ // A migration still deferred after the wait does not run this open, and
1054
+ // the command gets the EMPTY store. While legacy rows wait, a write there
1055
+ // would strand them (a populated store never migrates), so the store
1056
+ // refuses INSERTs into every table the migration fills and readers are
1057
+ // warned (`guardStrandedStore`). The next open admits it again.
1058
+ // Fail-open: a governor error proceeds un-gated, as before T12001.
815
1059
  let releaseDbHeavy = null;
816
- let dbHeavyDeferred = false;
817
- try {
818
- execution?.assertActive();
819
- const { governor } = await import('../resources/governor.js');
820
- execution?.assertActive();
821
- const admit = await governor.tryAcquire('db-heavy');
822
- if (admit.deferred) {
823
- dbHeavyDeferred = true;
1060
+ let deferral = null;
1061
+ const preparation = exodusState.preparation;
1062
+ if (preparation?.kind === 'pending') {
1063
+ // The connection was guarded before publication (above). The guard
1064
+ // stays up through the admission wait AND the migration: the copy runs
1065
+ // on dedicated connections that never see its temp triggers, and the
1066
+ // triggers stop refusing on their own once the copy commits the anchor.
1067
+ try {
1068
+ execution?.assertActive();
1069
+ const { governor } = await import('../resources/governor.js');
1070
+ execution?.assertActive();
1071
+ const admit = await governor.acquire('db-heavy', {
1072
+ blocking: true,
1073
+ timeoutMs: exodusAdmissionWaitMs(),
1074
+ });
1075
+ if (admit.deferred) {
1076
+ deferral = admit.reason;
1077
+ }
1078
+ else {
1079
+ releaseDbHeavy = admit.release;
1080
+ }
824
1081
  }
825
- else {
826
- releaseDbHeavy = admit.release;
1082
+ catch {
1083
+ execution?.assertActive();
1084
+ // Governor unavailable — fail open (proceed un-gated).
1085
+ }
1086
+ if (deferral !== null) {
1087
+ await announceDeferredExodus(nativeDb, scope, normalizedPath, deferral);
827
1088
  }
828
1089
  }
829
- catch {
830
- execution?.assertActive();
831
- // Governor unavailable — fail open (proceed un-gated).
832
- }
833
- if (dbHeavyDeferred) {
834
- execution?.assertActive();
835
- log.debug({ scope, dbPath: normalizedPath }, 'exodus-on-open skipped this open — db-heavy deferred under memory pressure ' +
836
- '(re-runs idempotently on a calmer open)');
1090
+ if (preparation === null || deferral !== null) {
1091
+ // Assessment unavailable, or the migration deferred: the published
1092
+ // handle (guarded when legacy rows wait) is returned as opened.
837
1093
  }
838
1094
  else {
1095
+ const ready = preparation;
839
1096
  try {
840
1097
  execution?.assertActive();
841
- const { maybeRunExodusOnOpen } = await import('./exodus/on-open.js');
842
- execution?.assertActive();
843
- const result = await maybeRunExodusOnOpen(scope, normalizedPath, nativeDb, exodusCwd);
1098
+ const result = ready.kind === 'decided' ? ready.result : await ready.run();
844
1099
  execution?.assertActive();
845
1100
  if (result.outcome === 'migrated' || result.outcome === 'aborted') {
1101
+ if (result.outcome === 'migrated') {
1102
+ // The store now holds the legacy data: the pre-publication guard
1103
+ // (if this connection is still open and cached) comes down (T13158).
1104
+ // On `aborted` it stays: the store is still empty while legacy rows wait.
1105
+ const { liftExodusWriteGuard } = await import('./exodus/write-guard.js');
1106
+ liftExodusWriteGuard(nativeDb);
1107
+ }
846
1108
  // The migrate engine closed our handle — re-open fresh (un-armed) so the
847
1109
  // caller receives a valid, live handle bound to the now-(de)populated DB.
848
1110
  const reopened = scope === 'project'
@@ -855,17 +1117,43 @@ exodusCwd, options) {
855
1117
  // structured marker on the returned handle and (b) broadcasting a typed
856
1118
  // event. The non-zero error itself is raised on the write path via
857
1119
  // `assertWriteDurable(handle)` — NOT here, so read opens never throw.
858
- const abort = {
859
- scope,
860
- dbPath: normalizedPath,
861
- reason: result.reason,
862
- at: Date.now(),
863
- };
864
1120
  log.warn({ scope, reason: result.reason }, 'exodus-on-open aborted; consolidated cleo.db left empty, legacy kept as source — ' +
865
- 'mutating callers must check handle.exodusAbort / call assertWriteDurable (T11828)');
866
- const { emitExodusAbort } = await import('./exodus/abort-events.js');
867
- emitExodusAbort(abort);
868
- finalHandle = { ...reopened, exodusAbort: abort };
1121
+ 'writes to the tables the migration fills are refused (T11828, T13167)');
1122
+ // T13167: while legacy rows wait, guard the store the caller gets
1123
+ // exactly as a deferral is guarded: every INSERT into a table the
1124
+ // migration fills refuses, and the typed write checks and the
1125
+ // handle's `exodusAbort` marker report the abort.
1126
+ const guarded = await guardStrandedStore(getDualScopeNativeDb(reopened), scope, normalizedPath, exodusCwd, 'aborted', result.reason);
1127
+ if (guarded) {
1128
+ finalHandle = reopened;
1129
+ try {
1130
+ const { pushWarning } = await import('../output.js');
1131
+ pushWarning({
1132
+ // @sync-invariant none:local-only a read warning about this store's aborted legacy migration
1133
+ code: 'W_EXODUS_ABORTED',
1134
+ message: `The ${scope} store's migration from the legacy stores aborted ` +
1135
+ `(${result.reason}), so results omit the legacy data. Writes are refused ` +
1136
+ 'until it is resolved: run `cleo doctor exodus-health`, then ' +
1137
+ '`cleo exodus migrate`.',
1138
+ });
1139
+ }
1140
+ catch {
1141
+ // A warning must never fail the open.
1142
+ }
1143
+ }
1144
+ else {
1145
+ // No legacy rows at risk: record and mark the abort as before.
1146
+ const abort = {
1147
+ scope,
1148
+ dbPath: normalizedPath,
1149
+ reason: result.reason,
1150
+ at: Date.now(),
1151
+ kind: 'aborted',
1152
+ };
1153
+ const { emitExodusAbort } = await import('./exodus/abort-events.js');
1154
+ emitExodusAbort(abort);
1155
+ finalHandle = { ...reopened, exodusAbort: abort };
1156
+ }
869
1157
  }
870
1158
  else {
871
1159
  // A subsequent SUCCESSFUL migration resolves any prior abort recorded
@@ -875,6 +1163,12 @@ exodusCwd, options) {
875
1163
  finalHandle = reopened;
876
1164
  }
877
1165
  }
1166
+ else if (ready.kind === 'pending') {
1167
+ // Skipped after all (a concurrent process migrated it first): the
1168
+ // store owes nothing more, so the guard comes down (T13158).
1169
+ const { liftExodusWriteGuard } = await import('./exodus/write-guard.js');
1170
+ liftExodusWriteGuard(nativeDb);
1171
+ }
878
1172
  }
879
1173
  catch (err) {
880
1174
  execution?.assertActive();
@@ -1385,7 +1679,7 @@ export async function insertIdempotent(
1385
1679
  db, table, row,
1386
1680
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1387
1681
  _keyColumn) {
1388
- assertNoRecordedExodusAbort();
1682
+ await assertNoExodusRefusal(db);
1389
1683
  const identity = resolveDbIdentity(db);
1390
1684
  return withWriterLease(identity.scope, 'tasks', async () => {
1391
1685
  const result = await db.insert(table).values(row).onConflictDoNothing().returning();
@@ -1435,7 +1729,7 @@ db, table, row,
1435
1729
  _keyColumn,
1436
1730
  // biome-ignore lint/suspicious/noExplicitAny: column reference type varies by table
1437
1731
  conflictTarget, set) {
1438
- assertNoRecordedExodusAbort();
1732
+ await assertNoExodusRefusal(db);
1439
1733
  const identity = resolveDbIdentity(db);
1440
1734
  return withWriterLease(identity.scope, 'tasks', async () => {
1441
1735
  const updateSet = set ?? row;