@cleocode/core 2026.9.24 → 2026.9.26

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 (481) hide show
  1. package/dist/admin/import-tasks.d.ts.map +1 -1
  2. package/dist/admin/import-tasks.js +5 -2
  3. package/dist/admin/import-tasks.js.map +1 -1
  4. package/dist/admin/import.d.ts.map +1 -1
  5. package/dist/admin/import.js +7 -2
  6. package/dist/admin/import.js.map +1 -1
  7. package/dist/audit-prune.d.ts +32 -0
  8. package/dist/audit-prune.d.ts.map +1 -1
  9. package/dist/audit-prune.js +37 -3
  10. package/dist/audit-prune.js.map +1 -1
  11. package/dist/build-provenance.json +2 -2
  12. package/dist/cloud/crypto.d.ts +1 -2
  13. package/dist/cloud/crypto.d.ts.map +1 -1
  14. package/dist/cloud/crypto.js +1 -11
  15. package/dist/cloud/crypto.js.map +1 -1
  16. package/dist/cloud/index.d.ts +1 -0
  17. package/dist/cloud/index.d.ts.map +1 -1
  18. package/dist/cloud/index.js +1 -0
  19. package/dist/cloud/index.js.map +1 -1
  20. package/dist/cloud/nexus-auth.d.ts +26 -1
  21. package/dist/cloud/nexus-auth.d.ts.map +1 -1
  22. package/dist/cloud/nexus-auth.js +61 -32
  23. package/dist/cloud/nexus-auth.js.map +1 -1
  24. package/dist/cloud/nexus-credentials.js +2 -2
  25. package/dist/cloud/nexus-credentials.js.map +1 -1
  26. package/dist/cloud/nexus-device.d.ts +809 -0
  27. package/dist/cloud/nexus-device.d.ts.map +1 -0
  28. package/dist/cloud/nexus-device.js +1680 -0
  29. package/dist/cloud/nexus-device.js.map +1 -0
  30. package/dist/cloud/nexus-enrol.d.ts +210 -0
  31. package/dist/cloud/nexus-enrol.d.ts.map +1 -0
  32. package/dist/cloud/nexus-enrol.js +1023 -0
  33. package/dist/cloud/nexus-enrol.js.map +1 -0
  34. package/dist/cloud/nexus-link.d.ts +3 -0
  35. package/dist/cloud/nexus-link.d.ts.map +1 -1
  36. package/dist/cloud/nexus-link.js +38 -4
  37. package/dist/cloud/nexus-link.js.map +1 -1
  38. package/dist/cloud/signing.d.ts +20 -0
  39. package/dist/cloud/signing.d.ts.map +1 -1
  40. package/dist/cloud/signing.js +14 -0
  41. package/dist/cloud/signing.js.map +1 -1
  42. package/dist/cloud/uuidv7.d.ts +9 -0
  43. package/dist/cloud/uuidv7.d.ts.map +1 -0
  44. package/dist/cloud/uuidv7.js +19 -0
  45. package/dist/cloud/uuidv7.js.map +1 -0
  46. package/dist/crypto/credentials.d.ts +61 -0
  47. package/dist/crypto/credentials.d.ts.map +1 -1
  48. package/dist/crypto/credentials.js +154 -58
  49. package/dist/crypto/credentials.js.map +1 -1
  50. package/dist/decide/bench/index.d.ts +1 -1
  51. package/dist/decide/bench/index.d.ts.map +1 -1
  52. package/dist/decide/bench/index.js +1 -1
  53. package/dist/decide/bench/index.js.map +1 -1
  54. package/dist/decide/bench/operation.d.ts +1 -1
  55. package/dist/decide/bench/operation.d.ts.map +1 -1
  56. package/dist/decide/bench/operation.js +1 -1
  57. package/dist/decide/bench/operation.js.map +1 -1
  58. package/dist/decide/bench/profiles.d.ts +50 -22
  59. package/dist/decide/bench/profiles.d.ts.map +1 -1
  60. package/dist/decide/bench/profiles.js +103 -59
  61. package/dist/decide/bench/profiles.js.map +1 -1
  62. package/dist/decide/bench/report.d.ts.map +1 -1
  63. package/dist/decide/bench/report.js +6 -1
  64. package/dist/decide/bench/report.js.map +1 -1
  65. package/dist/decide/bench/runner.d.ts +6 -1
  66. package/dist/decide/bench/runner.d.ts.map +1 -1
  67. package/dist/decide/bench/runner.js +1 -0
  68. package/dist/decide/bench/runner.js.map +1 -1
  69. package/dist/decide/client.d.ts.map +1 -1
  70. package/dist/decide/client.js +11 -5
  71. package/dist/decide/client.js.map +1 -1
  72. package/dist/decide/jev-wire.d.ts +31 -1
  73. package/dist/decide/jev-wire.d.ts.map +1 -1
  74. package/dist/decide/jev-wire.js +61 -7
  75. package/dist/decide/jev-wire.js.map +1 -1
  76. package/dist/docs/export-document.js +12907 -10622
  77. package/dist/docs/export-document.js.map +3 -3
  78. package/dist/doctor/dependency-cycles.d.ts +41 -0
  79. package/dist/doctor/dependency-cycles.d.ts.map +1 -0
  80. package/dist/doctor/dependency-cycles.js +39 -0
  81. package/dist/doctor/dependency-cycles.js.map +1 -0
  82. package/dist/doctor/index.d.ts +2 -0
  83. package/dist/doctor/index.d.ts.map +1 -1
  84. package/dist/doctor/index.js +1 -0
  85. package/dist/doctor/index.js.map +1 -1
  86. package/dist/doctor/orphan-ac-bindings.d.ts +64 -0
  87. package/dist/doctor/orphan-ac-bindings.d.ts.map +1 -0
  88. package/dist/doctor/orphan-ac-bindings.js +59 -0
  89. package/dist/doctor/orphan-ac-bindings.js.map +1 -0
  90. package/dist/doctor/projects.d.ts.map +1 -1
  91. package/dist/doctor/projects.js +43 -29
  92. package/dist/doctor/projects.js.map +1 -1
  93. package/dist/doctor/row-identity.d.ts +42 -0
  94. package/dist/doctor/row-identity.d.ts.map +1 -0
  95. package/dist/doctor/row-identity.js +151 -0
  96. package/dist/doctor/row-identity.js.map +1 -0
  97. package/dist/doctor/twin-collapse.d.ts +58 -2
  98. package/dist/doctor/twin-collapse.d.ts.map +1 -1
  99. package/dist/doctor/twin-collapse.js +212 -14
  100. package/dist/doctor/twin-collapse.js.map +1 -1
  101. package/dist/error-catalog.d.ts.map +1 -1
  102. package/dist/error-catalog.js +4 -0
  103. package/dist/error-catalog.js.map +1 -1
  104. package/dist/error-registry.d.ts.map +1 -1
  105. package/dist/error-registry.js +8 -0
  106. package/dist/error-registry.js.map +1 -1
  107. package/dist/lifecycle/verification/satisfies-validator.d.ts.map +1 -1
  108. package/dist/lifecycle/verification/satisfies-validator.js +10 -0
  109. package/dist/lifecycle/verification/satisfies-validator.js.map +1 -1
  110. package/dist/llm/plugin-facade.js +17767 -15482
  111. package/dist/llm/plugin-facade.js.map +3 -3
  112. package/dist/memory/index.d.ts.map +1 -1
  113. package/dist/memory/index.js +19 -10
  114. package/dist/memory/index.js.map +1 -1
  115. package/dist/memory/manifest-identity.d.ts +171 -0
  116. package/dist/memory/manifest-identity.d.ts.map +1 -0
  117. package/dist/memory/manifest-identity.js +345 -0
  118. package/dist/memory/manifest-identity.js.map +1 -0
  119. package/dist/memory/mental-model-queue.d.ts +14 -4
  120. package/dist/memory/mental-model-queue.d.ts.map +1 -1
  121. package/dist/memory/mental-model-queue.js +64 -35
  122. package/dist/memory/mental-model-queue.js.map +1 -1
  123. package/dist/memory/pipeline-manifest-sqlite.d.ts +47 -5
  124. package/dist/memory/pipeline-manifest-sqlite.d.ts.map +1 -1
  125. package/dist/memory/pipeline-manifest-sqlite.js +130 -14
  126. package/dist/memory/pipeline-manifest-sqlite.js.map +1 -1
  127. package/dist/memory/retrieval/observe.d.ts.map +1 -1
  128. package/dist/memory/retrieval/observe.js +2 -0
  129. package/dist/memory/retrieval/observe.js.map +1 -1
  130. package/dist/memory/transcript-scanner.js +1 -1
  131. package/dist/nexus/deps.d.ts.map +1 -1
  132. package/dist/nexus/deps.js +7 -14
  133. package/dist/nexus/deps.js.map +1 -1
  134. package/dist/nexus/discover.d.ts.map +1 -1
  135. package/dist/nexus/discover.js +6 -9
  136. package/dist/nexus/discover.js.map +1 -1
  137. package/dist/nexus/git-state.d.ts.map +1 -1
  138. package/dist/nexus/git-state.js +10 -1
  139. package/dist/nexus/git-state.js.map +1 -1
  140. package/dist/nexus/projects-clean.d.ts.map +1 -1
  141. package/dist/nexus/projects-clean.js +22 -11
  142. package/dist/nexus/projects-clean.js.map +1 -1
  143. package/dist/nexus/projects-scan.d.ts.map +1 -1
  144. package/dist/nexus/projects-scan.js +8 -13
  145. package/dist/nexus/projects-scan.js.map +1 -1
  146. package/dist/nexus/query.d.ts.map +1 -1
  147. package/dist/nexus/query.js +4 -12
  148. package/dist/nexus/query.js.map +1 -1
  149. package/dist/nexus/registry-roots.d.ts +5 -2
  150. package/dist/nexus/registry-roots.d.ts.map +1 -1
  151. package/dist/nexus/registry-roots.js +8 -10
  152. package/dist/nexus/registry-roots.js.map +1 -1
  153. package/dist/nexus/registry.d.ts +18 -0
  154. package/dist/nexus/registry.d.ts.map +1 -1
  155. package/dist/nexus/registry.js +37 -16
  156. package/dist/nexus/registry.js.map +1 -1
  157. package/dist/nexus/workspace.d.ts.map +1 -1
  158. package/dist/nexus/workspace.js +54 -4
  159. package/dist/nexus/workspace.js.map +1 -1
  160. package/dist/orchestrate/lifecycle-ops.js +1 -1
  161. package/dist/orchestrate/lifecycle-ops.js.map +1 -1
  162. package/dist/orchestrate/pivot.d.ts.map +1 -1
  163. package/dist/orchestrate/pivot.js +4 -2
  164. package/dist/orchestrate/pivot.js.map +1 -1
  165. package/dist/orchestrate/query-ops.d.ts.map +1 -1
  166. package/dist/orchestrate/query-ops.js +3 -3
  167. package/dist/orchestrate/query-ops.js.map +1 -1
  168. package/dist/orchestrate/spawn-ops.js +1 -1
  169. package/dist/orchestrate/spawn-ops.js.map +1 -1
  170. package/dist/orchestrate/worktree-complete.d.ts.map +1 -1
  171. package/dist/orchestrate/worktree-complete.js +40 -2
  172. package/dist/orchestrate/worktree-complete.js.map +1 -1
  173. package/dist/orchestration/index.js +1 -1
  174. package/dist/orchestration/index.js.map +1 -1
  175. package/dist/orchestration/lead-rollup.d.ts.map +1 -1
  176. package/dist/orchestration/lead-rollup.js +3 -3
  177. package/dist/orchestration/lead-rollup.js.map +1 -1
  178. package/dist/orchestration/parallel.js +1 -1
  179. package/dist/orchestration/parallel.js.map +1 -1
  180. package/dist/orchestration/spawn-prompt.d.ts +26 -0
  181. package/dist/orchestration/spawn-prompt.d.ts.map +1 -1
  182. package/dist/orchestration/spawn-prompt.js +62 -91
  183. package/dist/orchestration/spawn-prompt.js.map +1 -1
  184. package/dist/orchestration/wave-topic.d.ts +4 -2
  185. package/dist/orchestration/wave-topic.d.ts.map +1 -1
  186. package/dist/orchestration/wave-topic.js +6 -4
  187. package/dist/orchestration/wave-topic.js.map +1 -1
  188. package/dist/orchestration/waves.d.ts +2 -1
  189. package/dist/orchestration/waves.d.ts.map +1 -1
  190. package/dist/orchestration/waves.js +4 -3
  191. package/dist/orchestration/waves.js.map +1 -1
  192. package/dist/phases/index.d.ts.map +1 -1
  193. package/dist/phases/index.js +4 -2
  194. package/dist/phases/index.js.map +1 -1
  195. package/dist/release/ci-evidence.d.ts +190 -0
  196. package/dist/release/ci-evidence.d.ts.map +1 -1
  197. package/dist/release/ci-evidence.js +436 -4
  198. package/dist/release/ci-evidence.js.map +1 -1
  199. package/dist/sdk/validator-ac-pull.d.ts.map +1 -1
  200. package/dist/sdk/validator-ac-pull.js +2 -1
  201. package/dist/sdk/validator-ac-pull.js.map +1 -1
  202. package/dist/selfimprove/fix-gen.js +12807 -10522
  203. package/dist/selfimprove/fix-gen.js.map +3 -3
  204. package/dist/sentient/cross-project-hygiene.d.ts +5 -0
  205. package/dist/sentient/cross-project-hygiene.d.ts.map +1 -1
  206. package/dist/sentient/cross-project-hygiene.js +7 -1
  207. package/dist/sentient/cross-project-hygiene.js.map +1 -1
  208. package/dist/sentient/propose-tick.d.ts.map +1 -1
  209. package/dist/sentient/propose-tick.js +2 -3
  210. package/dist/sentient/propose-tick.js.map +1 -1
  211. package/dist/sentient/stage-drift-tick.d.ts.map +1 -1
  212. package/dist/sentient/stage-drift-tick.js +2 -3
  213. package/dist/sentient/stage-drift-tick.js.map +1 -1
  214. package/dist/session/engine-ops.d.ts.map +1 -1
  215. package/dist/session/engine-ops.js +77 -49
  216. package/dist/session/engine-ops.js.map +1 -1
  217. package/dist/sessions/focus-state-store.d.ts +69 -23
  218. package/dist/sessions/focus-state-store.d.ts.map +1 -1
  219. package/dist/sessions/focus-state-store.js +113 -27
  220. package/dist/sessions/focus-state-store.js.map +1 -1
  221. package/dist/sessions/handoff.js +1 -1
  222. package/dist/sessions/handoff.js.map +1 -1
  223. package/dist/sessions/index.d.ts.map +1 -1
  224. package/dist/sessions/index.js +24 -13
  225. package/dist/sessions/index.js.map +1 -1
  226. package/dist/sessions/terminal-identity.d.ts +165 -17
  227. package/dist/sessions/terminal-identity.d.ts.map +1 -1
  228. package/dist/sessions/terminal-identity.js +341 -32
  229. package/dist/sessions/terminal-identity.js.map +1 -1
  230. package/dist/skills/manifests/research.js +2 -0
  231. package/dist/skills/manifests/research.js.map +1 -1
  232. package/dist/skills/orchestrator/startup.js +2 -2
  233. package/dist/skills/orchestrator/startup.js.map +1 -1
  234. package/dist/skills/orchestrator/validator.d.ts.map +1 -1
  235. package/dist/skills/orchestrator/validator.js +9 -2
  236. package/dist/skills/orchestrator/validator.js.map +1 -1
  237. package/dist/skills/validation.d.ts +4 -1
  238. package/dist/skills/validation.d.ts.map +1 -1
  239. package/dist/skills/validation.js +11 -3
  240. package/dist/skills/validation.js.map +1 -1
  241. package/dist/snapshot/index.d.ts +4 -0
  242. package/dist/snapshot/index.d.ts.map +1 -1
  243. package/dist/snapshot/index.js +50 -3
  244. package/dist/snapshot/index.js.map +1 -1
  245. package/dist/spawn/branch-lock.d.ts +111 -7
  246. package/dist/spawn/branch-lock.d.ts.map +1 -1
  247. package/dist/spawn/branch-lock.js +296 -8
  248. package/dist/spawn/branch-lock.js.map +1 -1
  249. package/dist/store/ac-binding-prune.d.ts +144 -0
  250. package/dist/store/ac-binding-prune.d.ts.map +1 -0
  251. package/dist/store/ac-binding-prune.js +293 -0
  252. package/dist/store/ac-binding-prune.js.map +1 -0
  253. package/dist/store/agent-registry-store.d.ts.map +1 -1
  254. package/dist/store/agent-registry-store.js +3 -2
  255. package/dist/store/agent-registry-store.js.map +1 -1
  256. package/dist/store/backup-sidecar.d.ts +85 -2
  257. package/dist/store/backup-sidecar.d.ts.map +1 -1
  258. package/dist/store/backup-sidecar.js +173 -1
  259. package/dist/store/backup-sidecar.js.map +1 -1
  260. package/dist/store/conduit-sqlite.d.ts.map +1 -1
  261. package/dist/store/conduit-sqlite.js +3 -2
  262. package/dist/store/conduit-sqlite.js.map +1 -1
  263. package/dist/store/credential-transfer.d.ts.map +1 -1
  264. package/dist/store/credential-transfer.js +3 -0
  265. package/dist/store/credential-transfer.js.map +1 -1
  266. package/dist/store/db-helpers.d.ts +32 -13
  267. package/dist/store/db-helpers.d.ts.map +1 -1
  268. package/dist/store/db-helpers.js +144 -40
  269. package/dist/store/db-helpers.js.map +1 -1
  270. package/dist/store/dependency-cycles.d.ts +164 -0
  271. package/dist/store/dependency-cycles.d.ts.map +1 -0
  272. package/dist/store/dependency-cycles.js +360 -0
  273. package/dist/store/dependency-cycles.js.map +1 -0
  274. package/dist/store/display-id-alias.d.ts +585 -0
  275. package/dist/store/display-id-alias.d.ts.map +1 -0
  276. package/dist/store/display-id-alias.js +1538 -0
  277. package/dist/store/display-id-alias.js.map +1 -0
  278. package/dist/store/dual-scope-db.d.ts.map +1 -1
  279. package/dist/store/dual-scope-db.js +48 -0
  280. package/dist/store/dual-scope-db.js.map +1 -1
  281. package/dist/store/exodus/migrate.d.ts.map +1 -1
  282. package/dist/store/exodus/migrate.js +8 -1
  283. package/dist/store/exodus/migrate.js.map +1 -1
  284. package/dist/store/exodus/reconcile.d.ts.map +1 -1
  285. package/dist/store/exodus/reconcile.js +7 -2
  286. package/dist/store/exodus/reconcile.js.map +1 -1
  287. package/dist/store/exodus/recovery.d.ts.map +1 -1
  288. package/dist/store/exodus/recovery.js +20 -1
  289. package/dist/store/exodus/recovery.js.map +1 -1
  290. package/dist/store/global-salt.d.ts +35 -0
  291. package/dist/store/global-salt.d.ts.map +1 -1
  292. package/dist/store/global-salt.js +136 -16
  293. package/dist/store/global-salt.js.map +1 -1
  294. package/dist/store/legacy-tasks-lineage.d.ts.map +1 -1
  295. package/dist/store/legacy-tasks-lineage.js +19 -2
  296. package/dist/store/legacy-tasks-lineage.js.map +1 -1
  297. package/dist/store/migration-sqlite.d.ts.map +1 -1
  298. package/dist/store/migration-sqlite.js +19 -11
  299. package/dist/store/migration-sqlite.js.map +1 -1
  300. package/dist/store/portable-bundle-scan.d.ts.map +1 -1
  301. package/dist/store/portable-bundle-scan.js +6 -0
  302. package/dist/store/portable-bundle-scan.js.map +1 -1
  303. package/dist/store/row-identity-flag.d.ts +26 -0
  304. package/dist/store/row-identity-flag.d.ts.map +1 -0
  305. package/dist/store/row-identity-flag.js +31 -0
  306. package/dist/store/row-identity-flag.js.map +1 -0
  307. package/dist/store/row-identity-registry.d.ts +61 -0
  308. package/dist/store/row-identity-registry.d.ts.map +1 -0
  309. package/dist/store/row-identity-registry.js +206 -0
  310. package/dist/store/row-identity-registry.js.map +1 -0
  311. package/dist/store/row-identity.d.ts +480 -0
  312. package/dist/store/row-identity.d.ts.map +1 -0
  313. package/dist/store/row-identity.js +1509 -0
  314. package/dist/store/row-identity.js.map +1 -0
  315. package/dist/store/safety-data-accessor.d.ts +5 -2
  316. package/dist/store/safety-data-accessor.d.ts.map +1 -1
  317. package/dist/store/safety-data-accessor.js +9 -2
  318. package/dist/store/safety-data-accessor.js.map +1 -1
  319. package/dist/store/schema/attachments.d.ts +1 -1
  320. package/dist/store/schema/audit.d.ts +4 -4
  321. package/dist/store/schema/background-jobs.d.ts +1 -1
  322. package/dist/store/schema/cleo-global/nexus.d.ts +1 -1
  323. package/dist/store/schema/cleo-global/skills.d.ts +2 -2
  324. package/dist/store/schema/cleo-project/audit.d.ts +4 -4
  325. package/dist/store/schema/cleo-project/docs.d.ts +1 -1
  326. package/dist/store/schema/cleo-project/lifecycle.d.ts +4 -4
  327. package/dist/store/schema/cleo-project/nexus-graph.d.ts +3 -3
  328. package/dist/store/schema/cleo-project/provenance-commits.d.ts +2 -2
  329. package/dist/store/schema/cleo-project/provenance-rest.d.ts +3 -3
  330. package/dist/store/schema/cleo-project/runtime.d.ts +3 -3
  331. package/dist/store/schema/cleo-project/tasks-core-batch2.d.ts +87 -1
  332. package/dist/store/schema/cleo-project/tasks-core-batch2.d.ts.map +1 -1
  333. package/dist/store/schema/cleo-project/tasks-core-batch2.js +35 -0
  334. package/dist/store/schema/cleo-project/tasks-core-batch2.js.map +1 -1
  335. package/dist/store/schema/cleo-project/tasks-core.d.ts +183 -7
  336. package/dist/store/schema/cleo-project/tasks-core.d.ts.map +1 -1
  337. package/dist/store/schema/cleo-project/tasks-core.js +52 -1
  338. package/dist/store/schema/cleo-project/tasks-core.js.map +1 -1
  339. package/dist/store/schema/cleo-shared/brain.d.ts +6 -6
  340. package/dist/store/schema/lifecycle.d.ts +4 -4
  341. package/dist/store/schema/manifest.d.ts +1 -1
  342. package/dist/store/schema/memory-schema.d.ts +5 -5
  343. package/dist/store/schema/nexus-schema.d.ts +3 -3
  344. package/dist/store/schema/provenance/releases.d.ts +1 -1
  345. package/dist/store/schema/skills-schema.d.ts +2 -2
  346. package/dist/store/schema/tasks.d.ts +6 -6
  347. package/dist/store/session-store.d.ts +63 -3
  348. package/dist/store/session-store.d.ts.map +1 -1
  349. package/dist/store/session-store.js +121 -8
  350. package/dist/store/session-store.js.map +1 -1
  351. package/dist/store/split-brain-import.d.ts +2 -14
  352. package/dist/store/split-brain-import.d.ts.map +1 -1
  353. package/dist/store/split-brain-import.js +40 -19
  354. package/dist/store/split-brain-import.js.map +1 -1
  355. package/dist/store/sqlite-data-accessor.d.ts +326 -2
  356. package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
  357. package/dist/store/sqlite-data-accessor.js +782 -49
  358. package/dist/store/sqlite-data-accessor.js.map +1 -1
  359. package/dist/store/sync/clock-store.d.ts +67 -0
  360. package/dist/store/sync/clock-store.d.ts.map +1 -0
  361. package/dist/store/sync/clock-store.js +117 -0
  362. package/dist/store/sync/clock-store.js.map +1 -0
  363. package/dist/store/sync/flags.d.ts +51 -0
  364. package/dist/store/sync/flags.d.ts.map +1 -0
  365. package/dist/store/sync/flags.js +81 -0
  366. package/dist/store/sync/flags.js.map +1 -0
  367. package/dist/store/sync/hlc.d.ts +115 -0
  368. package/dist/store/sync/hlc.d.ts.map +1 -0
  369. package/dist/store/sync/hlc.js +172 -0
  370. package/dist/store/sync/hlc.js.map +1 -0
  371. package/dist/store/sync/index.d.ts +20 -0
  372. package/dist/store/sync/index.d.ts.map +1 -0
  373. package/dist/store/sync/index.js +20 -0
  374. package/dist/store/sync/index.js.map +1 -0
  375. package/dist/store/sync/replica-registry.d.ts +85 -0
  376. package/dist/store/sync/replica-registry.d.ts.map +1 -0
  377. package/dist/store/sync/replica-registry.js +147 -0
  378. package/dist/store/sync/replica-registry.js.map +1 -0
  379. package/dist/store/sync/replica.d.ts +181 -0
  380. package/dist/store/sync/replica.d.ts.map +1 -0
  381. package/dist/store/sync/replica.js +305 -0
  382. package/dist/store/sync/replica.js.map +1 -0
  383. package/dist/store/sync/schema.d.ts +68 -0
  384. package/dist/store/sync/schema.d.ts.map +1 -0
  385. package/dist/store/sync/schema.js +130 -0
  386. package/dist/store/sync/schema.js.map +1 -0
  387. package/dist/store/sync/skew-hold.d.ts +71 -0
  388. package/dist/store/sync/skew-hold.d.ts.map +1 -0
  389. package/dist/store/sync/skew-hold.js +89 -0
  390. package/dist/store/sync/skew-hold.js.map +1 -0
  391. package/dist/store/table-classification.d.ts +10 -8
  392. package/dist/store/table-classification.d.ts.map +1 -1
  393. package/dist/store/table-classification.js +93 -25
  394. package/dist/store/table-classification.js.map +1 -1
  395. package/dist/store/tasks-sqlite.d.ts.map +1 -1
  396. package/dist/store/tasks-sqlite.js +23 -3
  397. package/dist/store/tasks-sqlite.js.map +1 -1
  398. package/dist/store/twin-collapse.d.ts +113 -2
  399. package/dist/store/twin-collapse.d.ts.map +1 -1
  400. package/dist/store/twin-collapse.js +247 -19
  401. package/dist/store/twin-collapse.js.map +1 -1
  402. package/dist/store/umbrella-data-accessor.d.ts +5 -2
  403. package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
  404. package/dist/store/umbrella-data-accessor.js +9 -2
  405. package/dist/store/umbrella-data-accessor.js.map +1 -1
  406. package/dist/store/validation-schemas.d.ts +241 -49
  407. package/dist/store/validation-schemas.d.ts.map +1 -1
  408. package/dist/system/health.d.ts +2 -0
  409. package/dist/system/health.d.ts.map +1 -1
  410. package/dist/system/health.js +57 -0
  411. package/dist/system/health.js.map +1 -1
  412. package/dist/system/project-health.d.ts +9 -2
  413. package/dist/system/project-health.d.ts.map +1 -1
  414. package/dist/system/project-health.js +8 -3
  415. package/dist/system/project-health.js.map +1 -1
  416. package/dist/task-work/index.d.ts.map +1 -1
  417. package/dist/task-work/index.js +9 -6
  418. package/dist/task-work/index.js.map +1 -1
  419. package/dist/tasks/ac-coverage-gate.d.ts.map +1 -1
  420. package/dist/tasks/ac-coverage-gate.js +3 -0
  421. package/dist/tasks/ac-coverage-gate.js.map +1 -1
  422. package/dist/tasks/ac-table.d.ts +35 -7
  423. package/dist/tasks/ac-table.d.ts.map +1 -1
  424. package/dist/tasks/ac-table.js +119 -14
  425. package/dist/tasks/ac-table.js.map +1 -1
  426. package/dist/tasks/add.d.ts.map +1 -1
  427. package/dist/tasks/add.js +48 -2
  428. package/dist/tasks/add.js.map +1 -1
  429. package/dist/tasks/analyze.d.ts.map +1 -1
  430. package/dist/tasks/analyze.js +3 -2
  431. package/dist/tasks/analyze.js.map +1 -1
  432. package/dist/tasks/backfill-child-projections.js +47 -6
  433. package/dist/tasks/backfill-child-projections.js.map +1 -1
  434. package/dist/tasks/complete.d.ts.map +1 -1
  435. package/dist/tasks/complete.js +6 -1
  436. package/dist/tasks/complete.js.map +1 -1
  437. package/dist/tasks/completion-evaluation.d.ts.map +1 -1
  438. package/dist/tasks/completion-evaluation.js +3 -0
  439. package/dist/tasks/completion-evaluation.js.map +1 -1
  440. package/dist/tasks/evidence.d.ts +19 -1
  441. package/dist/tasks/evidence.d.ts.map +1 -1
  442. package/dist/tasks/evidence.js +93 -21
  443. package/dist/tasks/evidence.js.map +1 -1
  444. package/dist/tasks/infer-add-params.js +1 -1
  445. package/dist/tasks/infer-add-params.js.map +1 -1
  446. package/dist/tasks/task-context.d.ts.map +1 -1
  447. package/dist/tasks/task-context.js +3 -1
  448. package/dist/tasks/task-context.js.map +1 -1
  449. package/dist/tasks/task-import.d.ts.map +1 -1
  450. package/dist/tasks/task-import.js +11 -3
  451. package/dist/tasks/task-import.js.map +1 -1
  452. package/dist/tasks/task-next.d.ts +5 -1
  453. package/dist/tasks/task-next.d.ts.map +1 -1
  454. package/dist/tasks/task-next.js +7 -2
  455. package/dist/tasks/task-next.js.map +1 -1
  456. package/dist/validation/compliance.d.ts +5 -1
  457. package/dist/validation/compliance.d.ts.map +1 -1
  458. package/dist/validation/compliance.js +24 -3
  459. package/dist/validation/compliance.js.map +1 -1
  460. package/dist/validation/engine-ops.d.ts.map +1 -1
  461. package/dist/validation/engine-ops.js +3 -2
  462. package/dist/validation/engine-ops.js.map +1 -1
  463. package/dist/validation/index.d.ts +1 -1
  464. package/dist/validation/index.d.ts.map +1 -1
  465. package/dist/validation/index.js +1 -1
  466. package/dist/validation/index.js.map +1 -1
  467. package/dist/validation/protocol-common.d.ts +47 -2
  468. package/dist/validation/protocol-common.d.ts.map +1 -1
  469. package/dist/validation/protocol-common.js +86 -21
  470. package/dist/validation/protocol-common.js.map +1 -1
  471. package/dist/workgraph/scaffold-apply.d.ts.map +1 -1
  472. package/dist/workgraph/scaffold-apply.js +14 -5
  473. package/dist/workgraph/scaffold-apply.js.map +1 -1
  474. package/migrations/README.md +12 -0
  475. package/migrations/drizzle-cleo-project/20260928120000_t12341-row-uids/migration.sql +169 -0
  476. package/migrations/drizzle-cleo-project/20260930160000_t12886-dependency-cycle-guard/migration.sql +76 -0
  477. package/migrations/drizzle-cleo-project/20260930160000_t12886-dependency-cycle-guard/revert.sql +7 -0
  478. package/migrations/sync-journal/20260929140000_t12342-sync-clock/migration.sql +42 -0
  479. package/package.json +13 -13
  480. package/templates/CLEO-INJECTION.md +2 -2
  481. package/templates/CLEO-REFERENCE.md +5 -1
@@ -0,0 +1,480 @@
1
+ /**
2
+ * Row uids (T12341): the merge key every syncing row carries.
3
+ *
4
+ * A table whose Gate A class syncs gets a `uid TEXT` column. The local primary
5
+ * key (`T####`, an AC id, a session id, a composite edge key) stays the local
6
+ * key, and local foreign keys keep pointing at it; the uid is what a merge
7
+ * compares, as (project, uid). Spec: `cleo docs fetch t12341-uid-scheme`.
8
+ *
9
+ * ## How a uid is made
10
+ *
11
+ * - **Minted, new row** (this build writes it): a random UUIDv7
12
+ * ({@link mintRowUid}), set by the Drizzle `$defaultFn` or by the writer.
13
+ * - **Minted, no uid yet** (an existing row, or one an older build or a raw-SQL
14
+ * writer inserted): a DETERMINISTIC v7-layout uid. Its timestamp is the
15
+ * row's birth; its other 74 bits are SHA-256 over (scope, table, key, birth,
16
+ * the uids of its owning rows, and, for append-only tables, a frozen content
17
+ * list) ({@link mintedRowUid}). A `randomOnly` table (portable-secret) gets a
18
+ * random uid instead.
19
+ * - **Natural** (edges, labels): a UUIDv8 over the key with every reference
20
+ * replaced by the referenced row's uid ({@link naturalRowUid}); a pure
21
+ * function of the row. Symmetric relation types hash their endpoints in
22
+ * sorted order; the reversed twin of a symmetric edge stored both ways takes
23
+ * the `natural-mirror` recipe. A reference whose row does not exist hashes
24
+ * `dangling:<raw key>` and is reported.
25
+ *
26
+ * Deterministic identity can coincide for different rows (the same `T100`
27
+ * with the same `created_at` in two stores). Every minted row therefore also
28
+ * carries a birth fingerprint ({@link birthFingerprint}, `birth_fp`), hashed
29
+ * once from creation facts no edit changes. Same uid and same `birth_fp` is
30
+ * the same row; same uid and a different `birth_fp` is a COLLISION
31
+ * ({@link classifyUidMatch}), which the merge never merges.
32
+ *
33
+ * ## When uids are filled
34
+ *
35
+ * {@link prepareRowIdentity} runs on every open of a `cleo.db`, inside the
36
+ * cold-open lease right after the migrations:
37
+ *
38
+ * 1. re-asserts the identity columns and indexes (idempotent; heals a
39
+ * migration the journal probe stamped without running its index DDL);
40
+ * 2. registers the deterministic SQL functions on the connection, re-links
41
+ * acceptance criteria an older build recreated without their uid (the AC
42
+ * uid graveyard, spec §6.5), then fills every NULL uid (minted tables,
43
+ * owners first; then natural tables), the stored reference facts (`ac_uid`,
44
+ * `ac_text_hash`) and the birth fingerprints, in one savepoint;
45
+ * 3. installs one TEMP `AFTER INSERT` trigger per declared table on this
46
+ * connection, so a row inserted here without them gets the same values the
47
+ * open pass would give it, in the same statement. A trigger never fails the
48
+ * insert: a value that would clash is left NULL and reported at the next
49
+ * open.
50
+ *
51
+ * A row an older build inserts keeps NULL values until the next open by this
52
+ * build: there is no persistent trigger that computes them (see the
53
+ * migration's header). Row uids are OPT-IN: nothing here runs unless
54
+ * `CLEO_ROW_UID_FILL=1` ({@link rowUidFillEnabled}).
55
+ *
56
+ * A failure never fails the open: it is logged, and the rows keep NULL values
57
+ * until a later open succeeds. A uid's timestamp is ordering sugar only: HLC
58
+ * (T12342) never reads time from a uid.
59
+ *
60
+ * @module
61
+ * @task T12341
62
+ * @epic T12323
63
+ */
64
+ import type { DatabaseSync } from 'node:sqlite';
65
+ import type { TableScope } from '@cleocode/contracts';
66
+ import { BIRTH_FP_COLUMN, ROW_IDENTITY, rowIdentityColumns, rowIdentitySpec, UID_COLUMN } from './row-identity-registry.js';
67
+ export { BIRTH_FP_COLUMN, ROW_IDENTITY, rowIdentityColumns, rowIdentitySpec, UID_COLUMN };
68
+ /** Domain separator hashed into every deterministic uid. Changing it re-keys every row. */
69
+ export declare const ROW_UID_DOMAIN = "cleo/row-uid/v1";
70
+ /** Domain separator hashed into every birth fingerprint. */
71
+ export declare const ROW_BIRTH_DOMAIN = "cleo/row-birth/v1";
72
+ /** Per-connection SQL function computing a deterministic uid. */
73
+ export declare const ROW_UID_SQL_FUNCTION = "cleo_row_uid";
74
+ /** Per-connection SQL function computing a birth fingerprint. */
75
+ export declare const ROW_BIRTH_FP_SQL_FUNCTION = "cleo_row_birth_fp";
76
+ /** Per-connection SQL function returning a fresh random UUIDv7 (`randomOnly` tables). */
77
+ export declare const ROW_RANDOM_UID_SQL_FUNCTION = "cleo_row_random_uid";
78
+ /** Per-connection SQL function hashing AC text like `acTextHash`. */
79
+ export declare const AC_TEXT_HASH_SQL_FUNCTION = "cleo_ac_text_hash";
80
+ /** Physical name of the AC uid graveyard (spec §6.5). */
81
+ export declare const AC_UID_GRAVEYARD = "tasks_ac_uid_graveyard";
82
+ /**
83
+ * The literal-table writes the open pass makes, supplied by the tasks
84
+ * chokepoint (`store/sqlite-data-accessor.ts`, which registers them when it
85
+ * loads) so they stay enumerable by gate 28.
86
+ */
87
+ export interface RowIdentityWriters {
88
+ relinkAcUidNative(db: DatabaseSync, acId: string, uid: string, birthFp: string | null): number;
89
+ clearAcUidGraveyardNative(db: DatabaseSync): void;
90
+ writeRowIdentityMetaNative(db: DatabaseSync, key: string, value: string): void;
91
+ fillIdentityColumnNative(db: DatabaseSync, table: string, column: string, valueSql: string, rowid?: number): number;
92
+ clearBirthFpNative(db: DatabaseSync, table: string, rowid: number): void;
93
+ }
94
+ /**
95
+ * Register the chokepoint's row-identity writers (called once by
96
+ * `store/sqlite-data-accessor.ts` at load).
97
+ *
98
+ * @param writers - The writers.
99
+ */
100
+ export declare function registerRowIdentityWriters(writers: RowIdentityWriters): void;
101
+ /** A SQL value as node:sqlite passes it to a function. */
102
+ export type UidInput = string | number | bigint | Uint8Array | null;
103
+ /**
104
+ * Unambiguous encoding of uid inputs: per value a type tag (0 null, 1 text,
105
+ * 2 integer, 3 real, 4 blob), a big-endian u32 byte length, and the bytes. An
106
+ * integer-valued number is tag 2 (SQLite `3` and `3.0` encode alike); any other
107
+ * number is tag 3 with its ECMAScript shortest round-trip text. Frozen for
108
+ * recipe v1.
109
+ *
110
+ * @param values - Inputs in hash order.
111
+ * @returns The encoded bytes.
112
+ */
113
+ export declare function encodeUidInputs(values: readonly UidInput[]): Buffer;
114
+ /**
115
+ * Epoch milliseconds of a stored timestamp, or `null` when absent or not a
116
+ * strict ISO-8601 / SQLite timestamp. A value WITHOUT a zone is UTC:
117
+ * `datetime('now')` writes `YYYY-MM-DD HH:MM:SS` meaning UTC, and a zoneless
118
+ * `YYYY-MM-DDTHH:MM:SS` is read the same way, never as the device's local
119
+ * time (`Date.parse` would, and a uid would then depend on the device's
120
+ * timezone). Anything else (`Date.parse` extensions such as `Sep 24 2026`,
121
+ * out-of-range fields) is `null`, i.e. an unparseable birth. Comparing that
122
+ * text against ISO text is wrong within a day (`' '` sorts before `'T'`), so
123
+ * every comparison and every uid birth goes through this function (T12329).
124
+ *
125
+ * @param value - Stored timestamp.
126
+ * @returns Epoch milliseconds, or `null`.
127
+ */
128
+ export declare function parseStoreTimestamp(value: UidInput | undefined): number | null;
129
+ /**
130
+ * A new uid for a row this build creates: a random UUIDv7.
131
+ *
132
+ * @param birthMs - The row's own birth, for a row imported with one (an
133
+ * importer must never stamp import time into an old row's uid).
134
+ * @returns Canonical lowercase UUID string.
135
+ */
136
+ export declare function mintRowUid(birthMs?: number): string;
137
+ /**
138
+ * The deterministic uid of a minted row that has none: a v7 layout whose
139
+ * timestamp is the row's birth and whose other 74 bits come from SHA-256 over
140
+ * the row's identity. An unknown birth gives timestamp 0; the row's birth
141
+ * fingerprint flags it (`birth:unknown`), and {@link rowIdentityFindings}
142
+ * lists it.
143
+ *
144
+ * @param scope - Store scope.
145
+ * @param table - Physical table name.
146
+ * @param key - Local key values.
147
+ * @param birth - Stored birth value (any format, or null).
148
+ * @param ownerUids - Uids of the owning rows.
149
+ * @param content - Frozen content values of an append-only row.
150
+ * @returns Canonical lowercase UUID string.
151
+ */
152
+ export declare function mintedRowUid(scope: TableScope, table: string, key: readonly UidInput[], birth: UidInput, ownerUids?: readonly UidInput[], content?: readonly UidInput[]): string;
153
+ /**
154
+ * The new uid of a minted child row when its owner is re-keyed (spec §6.4):
155
+ * derived from STORED identity only (the child's old uid and the owner's new
156
+ * uid), never from a local key or content, so every replica that computes it
157
+ * gets the same value whatever display ids it holds. The child's timestamp
158
+ * bits are kept; the other 74 bits come from SHA-256.
159
+ *
160
+ * @param scope - Store scope.
161
+ * @param table - Physical table of the child.
162
+ * @param oldChildUid - The child's uid before the re-key.
163
+ * @param newOwnerUid - The owner's new uid.
164
+ * @returns Canonical lowercase UUID string.
165
+ */
166
+ export declare function rekeyedChildUid(scope: TableScope, table: string, oldChildUid: string, newOwnerUid: string): string;
167
+ /** Recipe of a natural uid: the edge itself, or the reversed twin of a symmetric edge. */
168
+ export type NaturalRecipe = 'natural' | 'natural-mirror';
169
+ /**
170
+ * The uid of a natural row: a UUIDv8 over (scope, table, key), with every
171
+ * reference in the key already replaced by the referenced row's uid.
172
+ *
173
+ * @param scope - Store scope.
174
+ * @param table - Physical table name.
175
+ * @param parts - Key values, references as uids.
176
+ * @param recipe - `natural-mirror` for the reversed twin of a symmetric edge.
177
+ * @returns Canonical lowercase UUID string.
178
+ */
179
+ export declare function naturalRowUid(scope: TableScope, table: string, parts: readonly UidInput[], recipe?: NaturalRecipe): string;
180
+ /**
181
+ * Canonical form of a text input to a birth fingerprint: Unicode NFC, line
182
+ * endings as LF, surrounding whitespace trimmed. Two stores that hold the same
183
+ * text in different normal forms fingerprint it identically.
184
+ *
185
+ * @param text - Stored text.
186
+ * @returns The canonical text.
187
+ */
188
+ export declare function canonicalText(text: string): string;
189
+ /**
190
+ * A minted row's birth fingerprint: 128 bits of SHA-256 over the canonical
191
+ * birth (epoch ms when it parses, so a format-only difference fingerprints
192
+ * alike; a flagged token otherwise) and the table's frozen birth facts, each
193
+ * canonicalised ({@link canonicalText}). Computed ONCE, when the row first
194
+ * gets its identity, from the row as it is then; never recomputed. It is
195
+ * write-once and syncs with the row: a receiver stores the value it receives.
196
+ *
197
+ * @param table - Physical table name.
198
+ * @param birth - Stored birth value.
199
+ * @param facts - Birth fact values, in declared order.
200
+ * @returns 32 lowercase hex characters.
201
+ */
202
+ export declare function birthFingerprint(table: string, birth: UidInput, facts: readonly UidInput[]): string;
203
+ /** How two rows that carry the same uid relate. */
204
+ export type UidMatch = 'same-row' | 'collision' | 'unknown';
205
+ /**
206
+ * Classify two rows of one table that carry the same uid (merge contract,
207
+ * spec §6.4): equal birth fingerprints are one row; different ones are a
208
+ * COLLISION that must never be merged; a missing fingerprint must be filled
209
+ * before the row is emitted.
210
+ *
211
+ * @param a - Birth fingerprint of one row.
212
+ * @param b - Birth fingerprint of the other.
213
+ * @returns The relation.
214
+ */
215
+ export declare function classifyUidMatch(a: string | null, b: string | null): UidMatch;
216
+ /**
217
+ * Register the identity SQL functions on a connection: the deterministic uid
218
+ * and birth fingerprint, the AC text hash, and a random v7 for `randomOnly`
219
+ * tables.
220
+ *
221
+ * @param db - Connection on a `cleo.db`.
222
+ * @param scope - The store's scope.
223
+ */
224
+ export declare function registerRowUidFunction(db: DatabaseSync, scope: TableScope): void;
225
+ /**
226
+ * Re-assert the identity columns and indexes of every declared table present
227
+ * in the store. Idempotent; the migration normally created them already.
228
+ *
229
+ * @param db - Connection on a `cleo.db`.
230
+ * @param scope - The store's scope.
231
+ * @returns Statements that had to be run (empty on a healthy store).
232
+ */
233
+ export declare function ensureRowIdentitySchema(db: DatabaseSync, scope: TableScope): string[];
234
+ /** Findings the open pass reports (and `cleo doctor` can list). */
235
+ export interface RowIdentityFindings {
236
+ /** Minted rows whose birth is missing or unparseable (uid timestamp 0), per table. */
237
+ readonly unknownBirth: Readonly<Record<string, number>>;
238
+ /** Natural rows with a key reference to a row that does not exist, per table. */
239
+ readonly danglingRefs: Readonly<Record<string, number>>;
240
+ /** Reversed twins of symmetric edges stored both ways (duplicates to drop), per table. */
241
+ readonly mirrorEdges: Readonly<Record<string, number>>;
242
+ }
243
+ /** What one fill pass did. */
244
+ export interface RowUidFillReport {
245
+ /** Uids written per table. */
246
+ readonly filled: Readonly<Record<string, number>>;
247
+ /** Stored reference facts written, per `table.column`. */
248
+ readonly refsFilled: Readonly<Record<string, number>>;
249
+ /** Birth fingerprints written per table. */
250
+ readonly fingerprinted: Readonly<Record<string, number>>;
251
+ /** Acceptance criteria re-linked to their uid from the graveyard. */
252
+ readonly relinked: number;
253
+ /** Rows left without a uid or fingerprint, per table (a uniqueness clash). */
254
+ readonly unfilled: Readonly<Record<string, number>>;
255
+ /** Rows the recipes flag. */
256
+ readonly findings: RowIdentityFindings;
257
+ /** Schema statements the pass had to re-run. */
258
+ readonly healed: readonly string[];
259
+ /**
260
+ * Pre-release identity values: `none` (the recipe marker is current, or
261
+ * there were no values), `cleared` (values without the current recipe
262
+ * marker were cleared and refilled), or `refused` (they were kept because
263
+ * uids have already synced; spec §12.1).
264
+ */
265
+ readonly refill: 'none' | 'cleared' | 'refused';
266
+ }
267
+ /**
268
+ * Fill the NULL uids of one declared table (the open pass's recipe). Requires
269
+ * {@link registerRowUidFunction} on the connection. Used after a uid re-key,
270
+ * which clears the uids of the natural rows keyed by the re-keyed row.
271
+ *
272
+ * @param db - Connection on a `cleo.db`.
273
+ * @param scope - The store's scope.
274
+ * @param table - Declared table.
275
+ * @returns Uids written.
276
+ */
277
+ export declare function fillTableUids(db: DatabaseSync, scope: TableScope, table: string, writers?: RowIdentityWriters): number;
278
+ /**
279
+ * Rows the recipes flag: minted rows with an unknown birth (uid timestamp 0),
280
+ * natural rows with a dangling key reference, and reversed twins of symmetric
281
+ * edges stored both ways.
282
+ *
283
+ * @param db - Connection on a `cleo.db`.
284
+ * @param scope - The store's scope.
285
+ * @returns Counts per table (tables without findings are absent).
286
+ */
287
+ export declare function rowIdentityFindings(db: DatabaseSync, scope: TableScope): RowIdentityFindings;
288
+ /**
289
+ * Fill every NULL uid, stored reference fact and birth fingerprint of the
290
+ * declared tables, in one savepoint, after re-linking graveyard AC uids.
291
+ * Requires {@link registerRowUidFunction} on the connection. Idempotent: a
292
+ * filled store writes nothing.
293
+ *
294
+ * @param db - Connection on a `cleo.db`.
295
+ * @param scope - The store's scope.
296
+ * @returns What was written and what could not be.
297
+ */
298
+ export declare function fillRowUids(db: DatabaseSync, scope: TableScope, writers?: RowIdentityWriters): Omit<RowUidFillReport, 'healed' | 'findings' | 'refill'>;
299
+ /**
300
+ * Install the per-connection TEMP triggers that fill a uid, the stored
301
+ * reference facts and the birth fingerprint on insert, in that order. Each
302
+ * step is guarded so the trigger never fails the insert: a uid that would
303
+ * clash is left NULL (a symmetric edge first tries its mirror recipe).
304
+ * Requires {@link registerRowUidFunction}.
305
+ *
306
+ * @param db - Connection on a `cleo.db`.
307
+ * @param scope - The store's scope.
308
+ */
309
+ export declare function installRowUidTriggers(db: DatabaseSync, scope: TableScope): void;
310
+ /**
311
+ * Bring a freshly opened `cleo.db` connection's row identity up to date:
312
+ * schema, graveyard re-link, fill, per-connection triggers. Never throws: a
313
+ * failure is logged and the store opens with the values it has.
314
+ *
315
+ * @param db - Connection on a `cleo.db`, after its migrations ran.
316
+ * @param scope - The store's scope.
317
+ * @param options - `triggers: false` skips the per-connection triggers (a
318
+ * dedicated migration connection: exodus refuses copies whose triggers call
319
+ * an opaque function, so its rows are filled at the next open instead).
320
+ * @returns The fill report, or `null` when skipped or failed.
321
+ */
322
+ /**
323
+ * Version of every identity recipe this build derives (uid, natural uid,
324
+ * birth fingerprint, encoding). Written to {@link ROW_IDENTITY_META_TABLE} under
325
+ * {@link ROW_IDENTITY_RECIPE_KEY} by the first fill; bumped by any change to a
326
+ * recipe, a frozen content or birth-fact list, or the encoding.
327
+ */
328
+ export declare const ROW_IDENTITY_RECIPE = "cleo/row-identity/v2";
329
+ /**
330
+ * The recipe 9.25 shipped (v1). v2 changed only the birth facts of AC history
331
+ * and evidence bindings (@refFp:ac_uid and ac_text_hash → none / ac_id,
332
+ * T12802); a store filled
333
+ * with v1 has those two tables' fingerprints re-derived (see
334
+ * {@link v1ReleaseBirthFp}).
335
+ */
336
+ export declare const ROW_IDENTITY_RECIPE_V1 = "cleo/row-identity/v1";
337
+ /**
338
+ * The v1 fingerprint of an AC-history or binding row, to recognise a value
339
+ * the 9.25 recipe derived: v1 hashed the criterion's fingerprint
340
+ * (`@refFp:ac_uid`), or `ref:none` / `ref:missing`. Other tables: `null`
341
+ * (their v1 and v2 recipes are the same).
342
+ *
343
+ * @param db - Connection on the project `cleo.db`.
344
+ * @param table - Declared minted table.
345
+ * @param row - The stored row.
346
+ * @returns The v1 value, or `null`.
347
+ * @task T12802
348
+ */
349
+ export declare function v1ReleaseBirthFp(db: DatabaseSync, table: string, row: Readonly<Record<string, UidInput>>): string | null;
350
+ /**
351
+ * Local-only key/value table of the row-identity layer. Not
352
+ * `tasks_schema_meta`: the twin collapse drops twin-only keys of that table on
353
+ * its first run (T12535), which would lose the marker.
354
+ */
355
+ export declare const ROW_IDENTITY_META_TABLE = "tasks_row_identity_meta";
356
+ /** Key holding the recipe version the store's identity values were derived with. */
357
+ export declare const ROW_IDENTITY_RECIPE_KEY = "row_identity_recipe";
358
+ /**
359
+ * Key the sync layer (T12342/T12343) writes BEFORE the
360
+ * first uid leaves the device. Once present, identity values are shared and
361
+ * are never cleared locally.
362
+ */
363
+ export declare const ROW_IDENTITY_SYNCED_KEY = "row_identity_synced";
364
+ /**
365
+ * Re-create the tables, trigger and columns the uid migration adds when they
366
+ * are missing: a store the journal probe stamped as migrated after only its
367
+ * ADD COLUMNs had run (Scenario 3, Case A) otherwise never gets them.
368
+ * Idempotent.
369
+ *
370
+ * @param db - Connection on the project `cleo.db`.
371
+ * @returns Statements that had to be run.
372
+ */
373
+ export declare function ensureIdentityTables(db: DatabaseSync): string[];
374
+ /**
375
+ * The birth fingerprint the pre-release v4/v5 build derived (the recipe that
376
+ * reached live cleocode on 2026-09-28): raw birth text, raw facts, the task
377
+ * title from the earliest `task_created` audit event, and an AC's OWNER UID
378
+ * instead of its owner's fingerprint. Used only to recognise those values.
379
+ *
380
+ * @param db - Connection on the project `cleo.db`.
381
+ * @param table - Minted table.
382
+ * @param row - The stored row.
383
+ * @returns The pre-release fingerprint, or `null` when the table had none.
384
+ */
385
+ export declare function preReleaseBirthFp(db: DatabaseSync, table: string, row: Readonly<Record<string, UidInput>>): string | null;
386
+ /**
387
+ * Record that the store's identity values follow {@link ROW_IDENTITY_RECIPE}.
388
+ * The fill writes it; {@link markRowIdentityShared} writes it too on the
389
+ * first receive (a device that pulls before it ever fills).
390
+ *
391
+ * @param db - Connection on the project `cleo.db`.
392
+ */
393
+ export declare function writeRecipeMarker(db: DatabaseSync, writers?: RowIdentityWriters): void;
394
+ /**
395
+ * Whether the store's identity values are shared with other devices
396
+ * ({@link ROW_IDENTITY_SYNCED_KEY} present): from then on no local write may
397
+ * clear or re-point a uid.
398
+ *
399
+ * @param db - Connection on the project `cleo.db`.
400
+ * @returns True once identity has been sent or received.
401
+ * @task T12806
402
+ */
403
+ export declare function rowIdentityShared(db: DatabaseSync): boolean;
404
+ /**
405
+ * Record that identity values are now SHARED with other devices: the recipe
406
+ * marker, and {@link ROW_IDENTITY_SYNCED_KEY} (first write wins, with the
407
+ * direction). Called on the first receive (a pull-first clone that never
408
+ * filled) as well as before the first send; once present, the open pass
409
+ * never clears an identity value (spec §12.1).
410
+ *
411
+ * @param db - Connection on the project `cleo.db`.
412
+ * @param direction - `receive` (the merge applied a row or op) or `send`.
413
+ * @param writers - The chokepoint writers.
414
+ * @task T12746
415
+ */
416
+ export declare function markRowIdentityShared(db: DatabaseSync, direction: 'send' | 'receive', writers?: RowIdentityWriters): void;
417
+ /**
418
+ * Re-create the row-identity SCHEMA a store should have, on every open,
419
+ * whatever the fill flag (T12878). DDL only: the identity tables, the
420
+ * graveyard trigger, the columns an early table lacks, the uid columns and
421
+ * their indexes. No row value is read or written. A store whose uid migration
422
+ * was journaled without running its statements (journal Scenario 3 Case A:
423
+ * live cleocode under 9.25, spec §12.2) gets the full schema here; the fill,
424
+ * refill and TEMP triggers stay opt-in ({@link prepareRowIdentity}).
425
+ *
426
+ * Never throws: a failure is logged and the open continues.
427
+ *
428
+ * @param db - Connection on a `cleo.db`, inside the cold-open lease.
429
+ * @param scope - The store's scope.
430
+ * @returns The DDL statements it ran (empty when the schema was complete).
431
+ * @task T12878
432
+ */
433
+ export declare function healRowIdentitySchema(db: DatabaseSync, scope: TableScope, writers?: RowIdentityWriters | undefined): string[];
434
+ /**
435
+ * Meta key of the heal receipt: when the open last re-created missing
436
+ * identity schema, and what (T12878). Local-only bookkeeping of the heal
437
+ * itself, in `tasks_row_identity_meta`; no row value of any other table is
438
+ * written. `cleo doctor` (the `row_identity` check) shows it.
439
+ */
440
+ export declare const ROW_IDENTITY_HEAL_KEY = "row_identity_schema_healed";
441
+ /** The receipt {@link healRowIdentitySchema} leaves when it re-created schema. */
442
+ export interface RowIdentityHealReceipt {
443
+ readonly at: string;
444
+ readonly scope?: TableScope;
445
+ readonly statements: number;
446
+ /** Objects re-created or columns added (table, index, trigger or `table.column`). */
447
+ readonly objects: readonly string[];
448
+ }
449
+ /**
450
+ * The last heal receipt of a store, read-only (`undefined` when the schema
451
+ * never needed healing).
452
+ *
453
+ * @param db - Connection on a project `cleo.db` (read-only is fine).
454
+ * @returns The receipt.
455
+ * @task T12878
456
+ */
457
+ export declare function readRowIdentityHealReceipt(db: DatabaseSync): RowIdentityHealReceipt | undefined;
458
+ /**
459
+ * Every heal receipt a store kept, oldest first (read-only).
460
+ *
461
+ * @param db - Connection on a project `cleo.db` (read-only is fine).
462
+ * @returns The receipts (empty when the schema never needed healing).
463
+ * @task T12878
464
+ */
465
+ export declare function readRowIdentityHealHistory(db: DatabaseSync): RowIdentityHealReceipt[];
466
+ /**
467
+ * Identity schema a project store lacks, read-only: missing identity tables,
468
+ * the graveyard trigger, and the alias / graveyard columns an early table
469
+ * lacks (T12878; the open heals them).
470
+ *
471
+ * @param db - Connection on a project `cleo.db` (read-only is fine).
472
+ * @returns What is missing (empty when complete).
473
+ * @task T12878
474
+ */
475
+ export declare function missingRowIdentitySchema(db: DatabaseSync): string[];
476
+ export declare function prepareRowIdentity(db: DatabaseSync, scope: TableScope, options?: {
477
+ readonly triggers?: boolean;
478
+ readonly writers?: RowIdentityWriters;
479
+ }): RowUidFillReport | null;
480
+ //# sourceMappingURL=row-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"row-identity.d.ts","sourceRoot":"","sources":["../../src/store/row-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAG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