@cleocode/core 2026.6.11 → 2026.6.13

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 (414) hide show
  1. package/dist/conduit/local-transport.d.ts +12 -0
  2. package/dist/conduit/local-transport.d.ts.map +1 -1
  3. package/dist/conduit/local-transport.js +53 -23
  4. package/dist/conduit/local-transport.js.map +1 -1
  5. package/dist/crypto/credentials.d.ts +37 -0
  6. package/dist/crypto/credentials.d.ts.map +1 -1
  7. package/dist/crypto/credentials.js +110 -0
  8. package/dist/crypto/credentials.js.map +1 -1
  9. package/dist/dispatch/contracts/derive-output-contract.d.ts +86 -0
  10. package/dist/dispatch/contracts/derive-output-contract.d.ts.map +1 -0
  11. package/dist/dispatch/contracts/derive-output-contract.js +347 -0
  12. package/dist/dispatch/contracts/derive-output-contract.js.map +1 -0
  13. package/dist/dispatch/contracts/ensures-schema.d.ts +77 -0
  14. package/dist/dispatch/contracts/ensures-schema.d.ts.map +1 -0
  15. package/dist/dispatch/contracts/ensures-schema.js +91 -0
  16. package/dist/dispatch/contracts/ensures-schema.js.map +1 -0
  17. package/dist/dispatch/contracts/output-contracts.d.ts +27 -5
  18. package/dist/dispatch/contracts/output-contracts.d.ts.map +1 -1
  19. package/dist/dispatch/contracts/output-contracts.js +29 -6
  20. package/dist/dispatch/contracts/output-contracts.js.map +1 -1
  21. package/dist/docs/export-document.js +2309 -1262
  22. package/dist/docs/export-document.js.map +3 -3
  23. package/dist/go/driver.d.ts +132 -7
  24. package/dist/go/driver.d.ts.map +1 -1
  25. package/dist/go/driver.js +135 -10
  26. package/dist/go/driver.js.map +1 -1
  27. package/dist/go/index.d.ts +1 -1
  28. package/dist/go/index.d.ts.map +1 -1
  29. package/dist/go/index.js +1 -1
  30. package/dist/go/index.js.map +1 -1
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +5 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/internal.d.ts +13 -10
  36. package/dist/internal.d.ts.map +1 -1
  37. package/dist/internal.js +11 -11
  38. package/dist/internal.js.map +1 -1
  39. package/dist/lifecycle/engine-ops.d.ts.map +1 -1
  40. package/dist/lifecycle/engine-ops.js +7 -4
  41. package/dist/lifecycle/engine-ops.js.map +1 -1
  42. package/dist/lifecycle/ivtr-loop.d.ts +108 -183
  43. package/dist/lifecycle/ivtr-loop.d.ts.map +1 -1
  44. package/dist/lifecycle/ivtr-loop.js +207 -522
  45. package/dist/lifecycle/ivtr-loop.js.map +1 -1
  46. package/dist/llm/auxiliary-fallback.js +1 -1
  47. package/dist/llm/auxiliary-fallback.js.map +1 -1
  48. package/dist/llm/cli-ops.d.ts +14 -1
  49. package/dist/llm/cli-ops.d.ts.map +1 -1
  50. package/dist/llm/cli-ops.js +41 -12
  51. package/dist/llm/cli-ops.js.map +1 -1
  52. package/dist/llm/concrete-session.d.ts.map +1 -1
  53. package/dist/llm/concrete-session.js +4 -0
  54. package/dist/llm/concrete-session.js.map +1 -1
  55. package/dist/llm/credentials.d.ts +35 -0
  56. package/dist/llm/credentials.d.ts.map +1 -1
  57. package/dist/llm/credentials.js +49 -0
  58. package/dist/llm/credentials.js.map +1 -1
  59. package/dist/llm/index.d.ts +4 -0
  60. package/dist/llm/index.d.ts.map +1 -1
  61. package/dist/llm/index.js +4 -0
  62. package/dist/llm/index.js.map +1 -1
  63. package/dist/llm/pi/gondolin-loader.d.ts +241 -0
  64. package/dist/llm/pi/gondolin-loader.d.ts.map +1 -0
  65. package/dist/llm/pi/gondolin-loader.js +195 -0
  66. package/dist/llm/pi/gondolin-loader.js.map +1 -0
  67. package/dist/llm/pi/index.d.ts +28 -0
  68. package/dist/llm/pi/index.d.ts.map +1 -0
  69. package/dist/llm/pi/index.js +27 -0
  70. package/dist/llm/pi/index.js.map +1 -0
  71. package/dist/llm/pi/pi-agent-adapter.d.ts +135 -0
  72. package/dist/llm/pi/pi-agent-adapter.d.ts.map +1 -0
  73. package/dist/llm/pi/pi-agent-adapter.js +329 -0
  74. package/dist/llm/pi/pi-agent-adapter.js.map +1 -0
  75. package/dist/llm/pi/pi-errors.d.ts +161 -0
  76. package/dist/llm/pi/pi-errors.d.ts.map +1 -0
  77. package/dist/llm/pi/pi-errors.js +296 -0
  78. package/dist/llm/pi/pi-errors.js.map +1 -0
  79. package/dist/llm/pi/pi-execution-env.d.ts +286 -0
  80. package/dist/llm/pi/pi-execution-env.d.ts.map +1 -0
  81. package/dist/llm/pi/pi-execution-env.js +406 -0
  82. package/dist/llm/pi/pi-execution-env.js.map +1 -0
  83. package/dist/llm/pi/pi-gondolin-env.d.ts +227 -0
  84. package/dist/llm/pi/pi-gondolin-env.d.ts.map +1 -0
  85. package/dist/llm/pi/pi-gondolin-env.js +541 -0
  86. package/dist/llm/pi/pi-gondolin-env.js.map +1 -0
  87. package/dist/llm/pi/pi-session-storage.d.ts +154 -0
  88. package/dist/llm/pi/pi-session-storage.d.ts.map +1 -0
  89. package/dist/llm/pi/pi-session-storage.js +314 -0
  90. package/dist/llm/pi/pi-session-storage.js.map +1 -0
  91. package/dist/llm/pi/pi-stream-fn.d.ts +124 -0
  92. package/dist/llm/pi/pi-stream-fn.d.ts.map +1 -0
  93. package/dist/llm/pi/pi-stream-fn.js +504 -0
  94. package/dist/llm/pi/pi-stream-fn.js.map +1 -0
  95. package/dist/llm/pi/pi-tool-bridge.d.ts +99 -0
  96. package/dist/llm/pi/pi-tool-bridge.d.ts.map +1 -0
  97. package/dist/llm/pi/pi-tool-bridge.js +117 -0
  98. package/dist/llm/pi/pi-tool-bridge.js.map +1 -0
  99. package/dist/llm/pi/pi-types.d.ts +56 -0
  100. package/dist/llm/pi/pi-types.d.ts.map +1 -0
  101. package/dist/llm/pi/pi-types.js +16 -0
  102. package/dist/llm/pi/pi-types.js.map +1 -0
  103. package/dist/llm/pi/resolve-execution-env.d.ts +194 -0
  104. package/dist/llm/pi/resolve-execution-env.d.ts.map +1 -0
  105. package/dist/llm/pi/resolve-execution-env.js +132 -0
  106. package/dist/llm/pi/resolve-execution-env.js.map +1 -0
  107. package/dist/llm/plugin-facade.js +2253 -1151
  108. package/dist/llm/plugin-facade.js.map +3 -3
  109. package/dist/llm/role-executor.d.ts.map +1 -1
  110. package/dist/llm/role-executor.js +8 -5
  111. package/dist/llm/role-executor.js.map +1 -1
  112. package/dist/llm/role-resolver.d.ts +46 -14
  113. package/dist/llm/role-resolver.d.ts.map +1 -1
  114. package/dist/llm/role-resolver.js +178 -20
  115. package/dist/llm/role-resolver.js.map +1 -1
  116. package/dist/llm/sealed-credential.d.ts +125 -0
  117. package/dist/llm/sealed-credential.d.ts.map +1 -0
  118. package/dist/llm/sealed-credential.js +133 -0
  119. package/dist/llm/sealed-credential.js.map +1 -0
  120. package/dist/llm/session-factory.d.ts.map +1 -1
  121. package/dist/llm/session-factory.js +6 -2
  122. package/dist/llm/session-factory.js.map +1 -1
  123. package/dist/llm/system-key.d.ts +67 -0
  124. package/dist/llm/system-key.d.ts.map +1 -0
  125. package/dist/llm/system-key.js +87 -0
  126. package/dist/llm/system-key.js.map +1 -0
  127. package/dist/llm/system-of-use-registry.d.ts +119 -0
  128. package/dist/llm/system-of-use-registry.d.ts.map +1 -0
  129. package/dist/llm/system-of-use-registry.js +200 -0
  130. package/dist/llm/system-of-use-registry.js.map +1 -0
  131. package/dist/llm/system-resolver.d.ts +32 -10
  132. package/dist/llm/system-resolver.d.ts.map +1 -1
  133. package/dist/llm/system-resolver.js +70 -18
  134. package/dist/llm/system-resolver.js.map +1 -1
  135. package/dist/memory/brain-writer-thread.d.ts.map +1 -1
  136. package/dist/memory/brain-writer-thread.js +116 -11
  137. package/dist/memory/brain-writer-thread.js.map +1 -1
  138. package/dist/memory/claude-mem-migration.d.ts.map +1 -1
  139. package/dist/memory/claude-mem-migration.js +21 -0
  140. package/dist/memory/claude-mem-migration.js.map +1 -1
  141. package/dist/memory/graph-memory-bridge.d.ts.map +1 -1
  142. package/dist/memory/graph-memory-bridge.js +32 -25
  143. package/dist/memory/graph-memory-bridge.js.map +1 -1
  144. package/dist/memory/llm-backend-resolver.js +23 -5
  145. package/dist/memory/llm-backend-resolver.js.map +1 -1
  146. package/dist/nexus/migrations/M-split-graph.d.ts.map +1 -1
  147. package/dist/nexus/migrations/M-split-graph.js +60 -53
  148. package/dist/nexus/migrations/M-split-graph.js.map +1 -1
  149. package/dist/orchestrate/pivot.d.ts.map +1 -1
  150. package/dist/orchestrate/pivot.js +20 -2
  151. package/dist/orchestrate/pivot.js.map +1 -1
  152. package/dist/release/engine-ops.js +2 -2
  153. package/dist/release/engine-ops.js.map +1 -1
  154. package/dist/release/plan.d.ts +4 -6
  155. package/dist/release/plan.d.ts.map +1 -1
  156. package/dist/release/plan.js +10 -23
  157. package/dist/release/plan.js.map +1 -1
  158. package/dist/release/reconcile.d.ts +0 -2
  159. package/dist/release/reconcile.d.ts.map +1 -1
  160. package/dist/release/reconcile.js +43 -50
  161. package/dist/release/reconcile.js.map +1 -1
  162. package/dist/release/release-manifest.d.ts.map +1 -1
  163. package/dist/release/release-manifest.js +4 -1
  164. package/dist/release/release-manifest.js.map +1 -1
  165. package/dist/release/verify-provenance.js +20 -20
  166. package/dist/release/verify-provenance.js.map +1 -1
  167. package/dist/routing/capability-matrix.d.ts.map +1 -1
  168. package/dist/routing/capability-matrix.js +0 -57
  169. package/dist/routing/capability-matrix.js.map +1 -1
  170. package/dist/selfimprove/budget.d.ts +206 -0
  171. package/dist/selfimprove/budget.d.ts.map +1 -0
  172. package/dist/selfimprove/budget.js +203 -0
  173. package/dist/selfimprove/budget.js.map +1 -0
  174. package/dist/selfimprove/dhq-adapter.d.ts +105 -0
  175. package/dist/selfimprove/dhq-adapter.d.ts.map +1 -0
  176. package/dist/selfimprove/dhq-adapter.js +95 -0
  177. package/dist/selfimprove/dhq-adapter.js.map +1 -0
  178. package/dist/selfimprove/draft-pr.d.ts +129 -0
  179. package/dist/selfimprove/draft-pr.d.ts.map +1 -0
  180. package/dist/selfimprove/draft-pr.js +158 -0
  181. package/dist/selfimprove/draft-pr.js.map +1 -0
  182. package/dist/selfimprove/envelope-diff.d.ts +162 -0
  183. package/dist/selfimprove/envelope-diff.d.ts.map +1 -0
  184. package/dist/selfimprove/envelope-diff.js +321 -0
  185. package/dist/selfimprove/envelope-diff.js.map +1 -0
  186. package/dist/selfimprove/replay.d.ts +121 -0
  187. package/dist/selfimprove/replay.d.ts.map +1 -0
  188. package/dist/selfimprove/replay.js +109 -0
  189. package/dist/selfimprove/replay.js.map +1 -0
  190. package/dist/selfimprove/run-loop.d.ts +148 -0
  191. package/dist/selfimprove/run-loop.d.ts.map +1 -0
  192. package/dist/selfimprove/run-loop.js +240 -0
  193. package/dist/selfimprove/run-loop.js.map +1 -0
  194. package/dist/selfimprove/scenario.d.ts +145 -0
  195. package/dist/selfimprove/scenario.d.ts.map +1 -0
  196. package/dist/selfimprove/scenario.js +243 -0
  197. package/dist/selfimprove/scenario.js.map +1 -0
  198. package/dist/sentient/daemon-entry.js +5 -0
  199. package/dist/sentient/daemon-entry.js.map +1 -1
  200. package/dist/sentient/daemon.d.ts.map +1 -1
  201. package/dist/sentient/daemon.js +19 -0
  202. package/dist/sentient/daemon.js.map +1 -1
  203. package/dist/sentient/hygiene-scan.d.ts.map +1 -1
  204. package/dist/sentient/hygiene-scan.js +14 -6
  205. package/dist/sentient/hygiene-scan.js.map +1 -1
  206. package/dist/sessions/briefing.d.ts.map +1 -1
  207. package/dist/sessions/briefing.js +13 -9
  208. package/dist/sessions/briefing.js.map +1 -1
  209. package/dist/sessions/connection-session-handle.d.ts +161 -0
  210. package/dist/sessions/connection-session-handle.d.ts.map +1 -0
  211. package/dist/sessions/connection-session-handle.js +168 -0
  212. package/dist/sessions/connection-session-handle.js.map +1 -0
  213. package/dist/sessions/handoff.d.ts.map +1 -1
  214. package/dist/sessions/handoff.js +9 -0
  215. package/dist/sessions/handoff.js.map +1 -1
  216. package/dist/sessions/index.d.ts +4 -1
  217. package/dist/sessions/index.d.ts.map +1 -1
  218. package/dist/sessions/index.js +31 -1
  219. package/dist/sessions/index.js.map +1 -1
  220. package/dist/sessions/session-id.d.ts +34 -0
  221. package/dist/sessions/session-id.d.ts.map +1 -1
  222. package/dist/sessions/session-id.js +37 -0
  223. package/dist/sessions/session-id.js.map +1 -1
  224. package/dist/sessions/session-manifest-mirror.d.ts +115 -0
  225. package/dist/sessions/session-manifest-mirror.d.ts.map +1 -0
  226. package/dist/sessions/session-manifest-mirror.js +250 -0
  227. package/dist/sessions/session-manifest-mirror.js.map +1 -0
  228. package/dist/sessions/session-switch.d.ts.map +1 -1
  229. package/dist/sessions/session-switch.js +5 -2
  230. package/dist/sessions/session-switch.js.map +1 -1
  231. package/dist/store/converters.d.ts.map +1 -1
  232. package/dist/store/converters.js +2 -0
  233. package/dist/store/converters.js.map +1 -1
  234. package/dist/store/db-helpers.d.ts.map +1 -1
  235. package/dist/store/db-helpers.js +2 -0
  236. package/dist/store/db-helpers.js.map +1 -1
  237. package/dist/store/dual-scope-db.d.ts.map +1 -1
  238. package/dist/store/dual-scope-db.js +87 -47
  239. package/dist/store/dual-scope-db.js.map +1 -1
  240. package/dist/store/pi-session-store.d.ts +151 -0
  241. package/dist/store/pi-session-store.d.ts.map +1 -0
  242. package/dist/store/pi-session-store.js +166 -0
  243. package/dist/store/pi-session-store.js.map +1 -0
  244. package/dist/store/safety-data-accessor.d.ts +1 -0
  245. package/dist/store/safety-data-accessor.d.ts.map +1 -1
  246. package/dist/store/safety-data-accessor.js +5 -0
  247. package/dist/store/safety-data-accessor.js.map +1 -1
  248. package/dist/store/schema/cleo-global/accounts.d.ts +357 -0
  249. package/dist/store/schema/cleo-global/accounts.d.ts.map +1 -0
  250. package/dist/store/schema/cleo-global/accounts.js +136 -0
  251. package/dist/store/schema/cleo-global/accounts.js.map +1 -0
  252. package/dist/store/schema/cleo-global/index.d.ts +2 -0
  253. package/dist/store/schema/cleo-global/index.d.ts.map +1 -1
  254. package/dist/store/schema/cleo-global/index.js +2 -0
  255. package/dist/store/schema/cleo-global/index.js.map +1 -1
  256. package/dist/store/schema/cleo-global/session-manifest.d.ts +217 -0
  257. package/dist/store/schema/cleo-global/session-manifest.d.ts.map +1 -0
  258. package/dist/store/schema/cleo-global/session-manifest.js +99 -0
  259. package/dist/store/schema/cleo-global/session-manifest.js.map +1 -0
  260. package/dist/store/schema/cleo-project/tasks-core.d.ts +16 -0
  261. package/dist/store/schema/cleo-project/tasks-core.d.ts.map +1 -1
  262. package/dist/store/schema/cleo-project/tasks-core.js +14 -0
  263. package/dist/store/schema/cleo-project/tasks-core.js.map +1 -1
  264. package/dist/store/schema/tasks.d.ts +16 -0
  265. package/dist/store/schema/tasks.d.ts.map +1 -1
  266. package/dist/store/schema/tasks.js +10 -0
  267. package/dist/store/schema/tasks.js.map +1 -1
  268. package/dist/store/selfimprove-dhq-schema.d.ts +284 -0
  269. package/dist/store/selfimprove-dhq-schema.d.ts.map +1 -0
  270. package/dist/store/selfimprove-dhq-schema.js +128 -0
  271. package/dist/store/selfimprove-dhq-schema.js.map +1 -0
  272. package/dist/store/selfimprove-dhq-store.d.ts +175 -0
  273. package/dist/store/selfimprove-dhq-store.d.ts.map +1 -0
  274. package/dist/store/selfimprove-dhq-store.js +182 -0
  275. package/dist/store/selfimprove-dhq-store.js.map +1 -0
  276. package/dist/store/session-store.d.ts +52 -13
  277. package/dist/store/session-store.d.ts.map +1 -1
  278. package/dist/store/session-store.js +71 -13
  279. package/dist/store/session-store.js.map +1 -1
  280. package/dist/store/sqlite-data-accessor.d.ts.map +1 -1
  281. package/dist/store/sqlite-data-accessor.js +7 -0
  282. package/dist/store/sqlite-data-accessor.js.map +1 -1
  283. package/dist/store/tasks-schema.d.ts +4 -0
  284. package/dist/store/tasks-schema.d.ts.map +1 -1
  285. package/dist/store/tasks-schema.js +14 -0
  286. package/dist/store/tasks-schema.js.map +1 -1
  287. package/dist/store/umbrella-data-accessor.d.ts +1 -0
  288. package/dist/store/umbrella-data-accessor.d.ts.map +1 -1
  289. package/dist/store/umbrella-data-accessor.js +5 -0
  290. package/dist/store/umbrella-data-accessor.js.map +1 -1
  291. package/dist/store/validation-schemas.d.ts +94 -62
  292. package/dist/store/validation-schemas.d.ts.map +1 -1
  293. package/dist/store/writer-lease-schema.d.ts +392 -0
  294. package/dist/store/writer-lease-schema.d.ts.map +1 -0
  295. package/dist/store/writer-lease-schema.js +142 -0
  296. package/dist/store/writer-lease-schema.js.map +1 -0
  297. package/dist/store/writer-lease.d.ts +368 -0
  298. package/dist/store/writer-lease.d.ts.map +1 -0
  299. package/dist/store/writer-lease.js +1002 -0
  300. package/dist/store/writer-lease.js.map +1 -0
  301. package/dist/task-tools/describe-schema.d.ts +4 -2
  302. package/dist/task-tools/describe-schema.d.ts.map +1 -1
  303. package/dist/task-tools/describe-schema.js +9 -3
  304. package/dist/task-tools/describe-schema.js.map +1 -1
  305. package/dist/tasks/backfill-child-projections.d.ts.map +1 -1
  306. package/dist/tasks/backfill-child-projections.js +14 -9
  307. package/dist/tasks/backfill-child-projections.js.map +1 -1
  308. package/dist/tasks/complete.d.ts.map +1 -1
  309. package/dist/tasks/complete.js +7 -10
  310. package/dist/tasks/complete.js.map +1 -1
  311. package/dist/tasks/duplicate-detector.d.ts.map +1 -1
  312. package/dist/tasks/duplicate-detector.js +14 -7
  313. package/dist/tasks/duplicate-detector.js.map +1 -1
  314. package/dist/telemetry/index.d.ts.map +1 -1
  315. package/dist/telemetry/index.js +10 -4
  316. package/dist/telemetry/index.js.map +1 -1
  317. package/dist/tools/agent-registry.d.ts +250 -0
  318. package/dist/tools/agent-registry.d.ts.map +1 -0
  319. package/dist/tools/agent-registry.js +292 -0
  320. package/dist/tools/agent-registry.js.map +1 -0
  321. package/dist/tools/agent-tool-families.d.ts +107 -0
  322. package/dist/tools/agent-tool-families.d.ts.map +1 -0
  323. package/dist/tools/agent-tool-families.js +527 -0
  324. package/dist/tools/agent-tool-families.js.map +1 -0
  325. package/dist/tools/browser-driver.d.ts +183 -0
  326. package/dist/tools/browser-driver.d.ts.map +1 -0
  327. package/dist/tools/browser-driver.js +242 -0
  328. package/dist/tools/browser-driver.js.map +1 -0
  329. package/dist/tools/builtin-agent-tools.d.ts +36 -0
  330. package/dist/tools/builtin-agent-tools.d.ts.map +1 -0
  331. package/dist/tools/builtin-agent-tools.js +150 -0
  332. package/dist/tools/builtin-agent-tools.js.map +1 -0
  333. package/dist/tools/dispatch.d.ts +370 -0
  334. package/dist/tools/dispatch.d.ts.map +1 -0
  335. package/dist/tools/dispatch.js +505 -0
  336. package/dist/tools/dispatch.js.map +1 -0
  337. package/dist/tools/env-scrub.d.ts +93 -0
  338. package/dist/tools/env-scrub.d.ts.map +1 -0
  339. package/dist/tools/env-scrub.js +176 -0
  340. package/dist/tools/env-scrub.js.map +1 -0
  341. package/dist/tools/fs.d.ts +30 -0
  342. package/dist/tools/fs.d.ts.map +1 -1
  343. package/dist/tools/fs.js +55 -2
  344. package/dist/tools/fs.js.map +1 -1
  345. package/dist/tools/guard.d.ts +15 -0
  346. package/dist/tools/guard.d.ts.map +1 -1
  347. package/dist/tools/guard.js +49 -12
  348. package/dist/tools/guard.js.map +1 -1
  349. package/dist/tools/index.d.ts +10 -0
  350. package/dist/tools/index.d.ts.map +1 -1
  351. package/dist/tools/index.js +37 -0
  352. package/dist/tools/index.js.map +1 -1
  353. package/dist/tools/pty.d.ts +45 -0
  354. package/dist/tools/pty.d.ts.map +1 -0
  355. package/dist/tools/pty.js +166 -0
  356. package/dist/tools/pty.js.map +1 -0
  357. package/dist/tools/schema-gen.d.ts +57 -0
  358. package/dist/tools/schema-gen.d.ts.map +1 -0
  359. package/dist/tools/schema-gen.js +52 -0
  360. package/dist/tools/schema-gen.js.map +1 -0
  361. package/dist/tools/shell.d.ts +12 -0
  362. package/dist/tools/shell.d.ts.map +1 -1
  363. package/dist/tools/shell.js +14 -1
  364. package/dist/tools/shell.js.map +1 -1
  365. package/dist/tools/web-agent-tools.d.ts +72 -0
  366. package/dist/tools/web-agent-tools.d.ts.map +1 -0
  367. package/dist/tools/web-agent-tools.js +393 -0
  368. package/dist/tools/web-agent-tools.js.map +1 -0
  369. package/dist/tools/web-search-backends.d.ts +156 -0
  370. package/dist/tools/web-search-backends.d.ts.map +1 -0
  371. package/dist/tools/web-search-backends.js +290 -0
  372. package/dist/tools/web-search-backends.js.map +1 -0
  373. package/dist/validation/ops.d.ts +1 -15
  374. package/dist/validation/ops.d.ts.map +1 -1
  375. package/dist/validation/ops.js +0 -20
  376. package/dist/validation/ops.js.map +1 -1
  377. package/migrations/drizzle-cleo-global/20260607000000_t11891-writer-leases/migration.sql +55 -0
  378. package/migrations/drizzle-cleo-global/20260607010000_t11639-session-manifest/migration.sql +43 -0
  379. package/migrations/drizzle-cleo-global/20260608000000_t11899-pi-session-tree/migration.sql +52 -0
  380. package/migrations/drizzle-cleo-global/20260608010000_t11709-accounts-credential-pool/migration.sql +72 -0
  381. package/migrations/drizzle-cleo-global/20260608020000_t11889-selfimprove-dhq/migration.sql +64 -0
  382. package/migrations/drizzle-cleo-project/20260606000000_t11884-restore-prefixed-task-triggers/migration.sql +272 -0
  383. package/migrations/drizzle-cleo-project/20260606000000_t11884-restore-prefixed-task-triggers/revert.sql +29 -0
  384. package/migrations/drizzle-cleo-project/20260606000100_t11883-tasks-releases-version-unique/migration.sql +21 -0
  385. package/migrations/drizzle-cleo-project/20260606000100_t11883-tasks-releases-version-unique/revert.sql +4 -0
  386. package/migrations/drizzle-cleo-project/20260607000000_t11891-writer-leases/migration.sql +55 -0
  387. package/migrations/drizzle-cleo-project/20260607010000_t11639-session-parent/migration.sql +22 -0
  388. package/migrations/drizzle-cleo-project/20260608000000_t11899-pi-session-tree/migration.sql +52 -0
  389. package/migrations/drizzle-cleo-project/20260608020000_t11889-selfimprove-dhq/migration.sql +64 -0
  390. package/package.json +15 -13
  391. package/dist/lifecycle/chain-composition.d.ts +0 -30
  392. package/dist/lifecycle/chain-composition.d.ts.map +0 -1
  393. package/dist/lifecycle/chain-composition.js +0 -152
  394. package/dist/lifecycle/chain-composition.js.map +0 -1
  395. package/dist/lifecycle/chain-store.d.ts +0 -70
  396. package/dist/lifecycle/chain-store.d.ts.map +0 -1
  397. package/dist/lifecycle/chain-store.js +0 -246
  398. package/dist/lifecycle/chain-store.js.map +0 -1
  399. package/dist/lifecycle/default-chain.d.ts +0 -39
  400. package/dist/lifecycle/default-chain.d.ts.map +0 -1
  401. package/dist/lifecycle/default-chain.js +0 -176
  402. package/dist/lifecycle/default-chain.js.map +0 -1
  403. package/dist/lifecycle/tessera-engine.d.ts +0 -48
  404. package/dist/lifecycle/tessera-engine.d.ts.map +0 -1
  405. package/dist/lifecycle/tessera-engine.js +0 -249
  406. package/dist/lifecycle/tessera-engine.js.map +0 -1
  407. package/dist/release/provenance-fk.d.ts +0 -74
  408. package/dist/release/provenance-fk.d.ts.map +0 -1
  409. package/dist/release/provenance-fk.js +0 -122
  410. package/dist/release/provenance-fk.js.map +0 -1
  411. package/dist/validation/chain-validation.d.ts +0 -43
  412. package/dist/validation/chain-validation.d.ts.map +0 -1
  413. package/dist/validation/chain-validation.js +0 -146
  414. package/dist/validation/chain-validation.js.map +0 -1
@@ -0,0 +1,72 @@
1
+ -- T11709 (EP-PROVIDER-VAULT · epic T10410 · saga SG-VAULT-CORE T10409) — the
2
+ -- pooled-LLM-credential `accounts` table in the consolidated GLOBAL cleo.db
3
+ -- (drizzle-cleo-global scope ONLY — this is a cross-project, machine-wide
4
+ -- credential pool with no project-tier analog, so it is NOT mirrored into
5
+ -- drizzle-cleo-project).
6
+ --
7
+ -- One row per LLM credential ("account") for one provider: the encrypted
8
+ -- secret/refresh material plus rotation / cooldown / health metadata the pool
9
+ -- runner consults to select the next live account and retire dead ones. Replaces
10
+ -- the legacy plaintext JSON blob with a queryable, `cleo health`-visible table.
11
+ --
12
+ -- `secret_enc` / `refresh_enc` are encryptGlobal() ciphertext (T11710), NEVER
13
+ -- plaintext. This is DISTINCT from `agent_registry_accounts` (the better-auth
14
+ -- OAuth-account table) — different physical name, different purpose.
15
+ --
16
+ -- ## Active-account pointer (raw partial unique index)
17
+ --
18
+ -- `is_active` is the per-provider "currently-selected" pointer: AT MOST ONE row
19
+ -- per `provider` may carry `is_active = 1`. drizzle-orm cannot model a partial
20
+ -- `WHERE` unique index, so it is emitted here as raw SQL (the established repo
21
+ -- pattern — cf. `_writer_leases.active`, T11627 · `project_agent_refs.enabled`).
22
+ -- The drizzle schema (accounts.ts) declares only the full-column table plus the
23
+ -- non-partial `(provider, label)` unique index that drizzle CAN emit.
24
+ --
25
+ -- ## Page-2 invariant
26
+ --
27
+ -- This migration runs AFTER the consolidation baseline (…_t11363-consolidation-
28
+ -- cleo-global) which already creates dozens of tables, so `accounts` is NEVER the
29
+ -- first CREATE on a fresh DB — rootpage 2 is already owned by
30
+ -- `__drizzle_migrations` / the baseline tables. No journal pre-create is required.
31
+ --
32
+ -- `IF NOT EXISTS` so a re-open over an already-migrated DB is a no-op. Each
33
+ -- statement is separated by a drizzle breakpoint marker line so node:sqlite
34
+ -- prepare() does not silently truncate the multi-statement file to statement one
35
+ -- (the marker token is intentionally not spelled out in this comment — drizzle's
36
+ -- readMigrationFiles splits the file on that literal substring).
37
+ --
38
+ -- @task T11709
39
+ -- @epic T10410
40
+ -- @saga T10409
41
+
42
+ CREATE TABLE IF NOT EXISTS `accounts` (
43
+ `id` integer PRIMARY KEY NOT NULL,
44
+ `provider` text NOT NULL,
45
+ `label` text NOT NULL,
46
+ `auth_type` text NOT NULL,
47
+ `secret_enc` text,
48
+ `refresh_enc` text,
49
+ `expires_at` text,
50
+ `priority` integer NOT NULL DEFAULT 0,
51
+ `source` text,
52
+ `status` text NOT NULL DEFAULT 'ok',
53
+ `last_error_code` text,
54
+ `cooldown_reset_at` text,
55
+ `request_count` integer NOT NULL DEFAULT 0,
56
+ `metadata` text NOT NULL DEFAULT '{}',
57
+ `is_active` integer NOT NULL DEFAULT 0,
58
+ `created_at` text NOT NULL DEFAULT (datetime('now')),
59
+ `updated_at` text NOT NULL DEFAULT (datetime('now')),
60
+ CHECK ("status" IN ('ok', 'exhausted', 'dead')),
61
+ CHECK ("is_active" IN (0, 1)),
62
+ CHECK ("expires_at" IS NULL OR "expires_at" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*'),
63
+ CHECK ("cooldown_reset_at" IS NULL OR "cooldown_reset_at" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*'),
64
+ CHECK ("created_at" IS NULL OR "created_at" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*'),
65
+ CHECK ("updated_at" IS NULL OR "updated_at" GLOB '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]*')
66
+ );
67
+ --> statement-breakpoint
68
+ CREATE UNIQUE INDEX IF NOT EXISTS `ux_accounts_provider_label` ON `accounts` (`provider`, `label`);
69
+ --> statement-breakpoint
70
+ CREATE UNIQUE INDEX IF NOT EXISTS `ux_accounts_active_provider` ON `accounts` (`provider`) WHERE `is_active` = 1;
71
+ --> statement-breakpoint
72
+ CREATE INDEX IF NOT EXISTS `idx_accounts_provider_status_priority` ON `accounts` (`provider`, `status`, `priority`);
@@ -0,0 +1,64 @@
1
+ -- T11889 (T11889-A · T11911) — the self-improvement-loop DHQ sink (`selfimprove_dhq`).
2
+ --
3
+ -- One row per Dogfood-Harness-Question raised by `cleo selfimprove run`: the loop
4
+ -- replays a canned scenario, diffs the LAFS envelopes against a golden, and on
5
+ -- regression UPSERTs exactly ONE row here via the leased Gate-3 accessor
6
+ -- (selfimprove-dhq-store.ts). On green it writes nothing.
7
+ --
8
+ -- Co-located inside EACH scope's consolidated cleo.db (this file is byte-identical
9
+ -- in drizzle-cleo-project and drizzle-cleo-global so the two lineages produce the
10
+ -- SAME migration hash — the consolidated single-file journal converges across both
11
+ -- under the CONSOLIDATED_JOURNAL_LINEAGES cross-lineage guard, T11829). Pure runtime
12
+ -- infrastructure (like `_writer_leases` from T11627 and `pi_session_*` from T11899)
13
+ -- — NOT part of the exodus target shape under `schema/cleo-project/`.
14
+ --
15
+ -- ## Idempotency invariant (partial UNIQUE index)
16
+ --
17
+ -- At most ONE row per `question_hash` may carry `status = 'open'`, so a repeated
18
+ -- regression UPSERTs the same open row instead of spamming duplicates. drizzle-orm
19
+ -- cannot model a partial WHERE unique index, so it is emitted here as raw SQL (the
20
+ -- established repo pattern — cf. `_writer_leases.active`, T11627 ·
21
+ -- `project_agent_refs.enabled`). The drizzle schema (selfimprove-dhq-schema.ts)
22
+ -- declares ONLY the full-column table plus the two non-partial indexes drizzle CAN
23
+ -- emit; the runtime bootstrap asserts this partial index exists
24
+ -- (assertSelfimproveDhqOpenIndexPresent).
25
+ --
26
+ -- ## Page-2 invariant
27
+ --
28
+ -- This migration runs AFTER the consolidation baseline (…_t11363-consolidation-
29
+ -- cleo-project) which already creates dozens of tables, so `selfimprove_dhq` is
30
+ -- NEVER the first CREATE on a fresh DB — rootpage 2 is already owned by
31
+ -- `__drizzle_migrations` / the baseline tables. No journal pre-create is required
32
+ -- (the lease cold-open path pre-creates `__drizzle_migrations` before any first
33
+ -- table, so the precondition holds even on a freshly cold-opened DB).
34
+ --
35
+ -- `IF NOT EXISTS` so a re-open over an already-migrated DB is a no-op. Each
36
+ -- statement is separated by a drizzle breakpoint marker line so node:sqlite
37
+ -- prepare() does not silently truncate the multi-statement file to statement one
38
+ -- (the marker token is intentionally not spelled out in this comment — drizzle's
39
+ -- readMigrationFiles splits the file on that literal substring).
40
+ --
41
+ -- @task T11889
42
+ -- @task T11911
43
+ -- @epic T11889
44
+
45
+ CREATE TABLE IF NOT EXISTS `selfimprove_dhq` (
46
+ `id` INTEGER PRIMARY KEY,
47
+ `dhq_id` TEXT NOT NULL,
48
+ `scenario` TEXT NOT NULL,
49
+ `question_hash` TEXT NOT NULL,
50
+ `title` TEXT NOT NULL,
51
+ `regression_json` TEXT NOT NULL,
52
+ `status` TEXT NOT NULL DEFAULT 'open',
53
+ `severity` TEXT,
54
+ `pr_url` TEXT,
55
+ `run_id` TEXT NOT NULL,
56
+ `created_at` INTEGER NOT NULL,
57
+ `updated_at` INTEGER NOT NULL
58
+ );
59
+ --> statement-breakpoint
60
+ CREATE INDEX IF NOT EXISTS `ix_selfimprove_dhq_status` ON `selfimprove_dhq` (`status`);
61
+ --> statement-breakpoint
62
+ CREATE INDEX IF NOT EXISTS `ix_selfimprove_dhq_scenario` ON `selfimprove_dhq` (`scenario`);
63
+ --> statement-breakpoint
64
+ CREATE UNIQUE INDEX IF NOT EXISTS `ux_selfimprove_dhq_open` ON `selfimprove_dhq` (`question_hash`) WHERE `status` = 'open';
@@ -0,0 +1,272 @@
1
+ -- T11884 — Restore task-domain invariant + handoff triggers on the PREFIXED tables.
2
+ --
3
+ -- ==========================================================================
4
+ -- Problem (latent bug exposed by the SG-DB-SUBSTRATE-V2 cutover)
5
+ -- ==========================================================================
6
+ -- The T11578 dual-scope cutover repointed the runtime drizzle symbols
7
+ -- (`tasks`, `task_relations`, `task_acceptance_criteria`, session handoff, …)
8
+ -- from the BARE un-prefixed tables onto the domain-prefixed tables
9
+ -- (`tasks_tasks`, `tasks_task_relations`, …). But the 12 SQLite invariant /
10
+ -- handoff triggers were authored ONLY on the bare tables (T877, T10572,
11
+ -- T10638, T1609) and were never recreated on the prefixed tables — exodus
12
+ -- copies rows with triggers absent on the target. Result: every task invariant
13
+ -- has been SILENTLY UNENFORCED on the live write path (`tasks_tasks` has zero
14
+ -- triggers), and the session-handoff `handoff_json` mirror is dead.
15
+ --
16
+ -- This migration recreates all 12 guards on the prefixed tables, with bodies
17
+ -- rewritten to reference `tasks_tasks` / `tasks_sessions`. New trigger NAMES
18
+ -- are used (prefixed) so they do NOT collide with the still-present legacy
19
+ -- triggers; when the legacy bare tables are dropped (E5 of the cutover) their
20
+ -- triggers drop with them and these remain the SSoT.
21
+ --
22
+ -- Invariants restored:
23
+ -- - tasks_tasks.parent_id cannot introduce a containment cycle
24
+ -- - tasks_tasks.parent_id obeys the saga->epic, epic->task|subtask,
25
+ -- task->subtask type matrix (sagas/tasks are roots)
26
+ -- - tasks_tasks status/pipeline_stage T877 invariant
27
+ -- - tasks_task_relations is non-containment-only
28
+ -- - tasks_task_acceptance_criteria child_task targets must be direct children
29
+ -- - tasks_session_handoff_entries is write-once + mirrors handoff_json into
30
+ -- tasks_sessions
31
+ --
32
+ -- Trigger messages keep the same stable error codes so CLI callers surface
33
+ -- identical remediation regardless of which physical table fired.
34
+ --
35
+ -- @task T11884
36
+ -- @epic T11883
37
+ -- @saga T11242
38
+
39
+ DROP TRIGGER IF EXISTS `tasks_tasks_parent_cycle_guard_insert`;
40
+ --> statement-breakpoint
41
+ DROP TRIGGER IF EXISTS `tasks_tasks_parent_cycle_guard_update`;
42
+ --> statement-breakpoint
43
+ DROP TRIGGER IF EXISTS `tasks_tasks_parent_type_matrix_insert`;
44
+ --> statement-breakpoint
45
+ DROP TRIGGER IF EXISTS `tasks_tasks_parent_type_matrix_update`;
46
+ --> statement-breakpoint
47
+ DROP TRIGGER IF EXISTS `trg_tasks_tasks_status_pipeline_insert`;
48
+ --> statement-breakpoint
49
+ DROP TRIGGER IF EXISTS `trg_tasks_tasks_status_pipeline_update`;
50
+ --> statement-breakpoint
51
+ DROP TRIGGER IF EXISTS `tasks_task_relations_non_containment_insert`;
52
+ --> statement-breakpoint
53
+ DROP TRIGGER IF EXISTS `tasks_task_relations_non_containment_update`;
54
+ --> statement-breakpoint
55
+ DROP TRIGGER IF EXISTS `tasks_task_acceptance_child_target_insert`;
56
+ --> statement-breakpoint
57
+ DROP TRIGGER IF EXISTS `tasks_task_acceptance_child_target_update`;
58
+ --> statement-breakpoint
59
+ DROP TRIGGER IF EXISTS `trg_tasks_session_handoff_mirror`;
60
+ --> statement-breakpoint
61
+ DROP TRIGGER IF EXISTS `trg_tasks_session_handoff_no_update`;
62
+ --> statement-breakpoint
63
+
64
+ -- ---------------------------------------------------------------------------
65
+ -- Parent-cycle guard (T10572) — tasks_tasks
66
+ -- ---------------------------------------------------------------------------
67
+ CREATE TRIGGER `tasks_tasks_parent_cycle_guard_insert`
68
+ BEFORE INSERT ON `tasks_tasks`
69
+ WHEN NEW.`parent_id` IS NOT NULL
70
+ BEGIN
71
+ SELECT RAISE(ABORT, 'E_TASK_PARENT_CYCLE: tasks.parent_id cannot create a containment cycle')
72
+ WHERE EXISTS (
73
+ WITH RECURSIVE ancestors(`id`, `parent_id`) AS (
74
+ SELECT parent.`id`, parent.`parent_id`
75
+ FROM `tasks_tasks` parent
76
+ WHERE parent.`id` = NEW.`parent_id`
77
+ UNION ALL
78
+ SELECT next_parent.`id`, next_parent.`parent_id`
79
+ FROM `tasks_tasks` next_parent
80
+ JOIN ancestors ON next_parent.`id` = ancestors.`parent_id`
81
+ WHERE ancestors.`parent_id` IS NOT NULL
82
+ )
83
+ SELECT 1 FROM ancestors WHERE ancestors.`id` = NEW.`id`
84
+ );
85
+ END;
86
+ --> statement-breakpoint
87
+
88
+ CREATE TRIGGER `tasks_tasks_parent_cycle_guard_update`
89
+ BEFORE UPDATE OF `parent_id` ON `tasks_tasks`
90
+ WHEN NEW.`parent_id` IS NOT NULL
91
+ BEGIN
92
+ SELECT RAISE(ABORT, 'E_TASK_PARENT_CYCLE: tasks.parent_id cannot create a containment cycle')
93
+ WHERE EXISTS (
94
+ WITH RECURSIVE ancestors(`id`, `parent_id`) AS (
95
+ SELECT parent.`id`, parent.`parent_id`
96
+ FROM `tasks_tasks` parent
97
+ WHERE parent.`id` = NEW.`parent_id`
98
+ UNION ALL
99
+ SELECT next_parent.`id`, next_parent.`parent_id`
100
+ FROM `tasks_tasks` next_parent
101
+ JOIN ancestors ON next_parent.`id` = ancestors.`parent_id`
102
+ WHERE ancestors.`parent_id` IS NOT NULL
103
+ )
104
+ SELECT 1 FROM ancestors WHERE ancestors.`id` = NEW.`id`
105
+ );
106
+ END;
107
+ --> statement-breakpoint
108
+
109
+ -- ---------------------------------------------------------------------------
110
+ -- Parent type-matrix guard (T10638) — tasks_tasks
111
+ -- ---------------------------------------------------------------------------
112
+ CREATE TRIGGER `tasks_tasks_parent_type_matrix_insert`
113
+ BEFORE INSERT ON `tasks_tasks`
114
+ WHEN NEW.`parent_id` IS NOT NULL
115
+ AND NEW.`type` IS NOT NULL
116
+ AND EXISTS (SELECT 1 FROM `tasks_tasks` parent WHERE parent.`id` = NEW.`parent_id` AND parent.`type` IS NOT NULL)
117
+ AND NOT EXISTS (
118
+ SELECT 1
119
+ FROM `tasks_tasks` parent
120
+ WHERE parent.`id` = NEW.`parent_id`
121
+ AND (
122
+ (NEW.`type` = 'epic' AND parent.`type` = 'saga')
123
+ OR (NEW.`type` = 'task' AND parent.`type` = 'epic')
124
+ OR (NEW.`type` = 'subtask' AND parent.`type` IN ('epic', 'task'))
125
+ )
126
+ )
127
+ BEGIN
128
+ SELECT RAISE(ABORT, 'E_TASK_PARENT_TYPE_MATRIX: tasks.parent_id must follow saga->epic, epic->task|subtask, and task->subtask; sagas/tasks must be roots');
129
+ END;
130
+ --> statement-breakpoint
131
+
132
+ CREATE TRIGGER `tasks_tasks_parent_type_matrix_update`
133
+ BEFORE UPDATE OF `parent_id`, `type` ON `tasks_tasks`
134
+ WHEN NEW.`parent_id` IS NOT NULL
135
+ AND NEW.`type` IS NOT NULL
136
+ AND EXISTS (SELECT 1 FROM `tasks_tasks` parent WHERE parent.`id` = NEW.`parent_id` AND parent.`type` IS NOT NULL)
137
+ AND NOT EXISTS (
138
+ SELECT 1
139
+ FROM `tasks_tasks` parent
140
+ WHERE parent.`id` = NEW.`parent_id`
141
+ AND (
142
+ (NEW.`type` = 'epic' AND parent.`type` = 'saga')
143
+ OR (NEW.`type` = 'task' AND parent.`type` = 'epic')
144
+ OR (NEW.`type` = 'subtask' AND parent.`type` IN ('epic', 'task'))
145
+ )
146
+ )
147
+ BEGIN
148
+ SELECT RAISE(ABORT, 'E_TASK_PARENT_TYPE_MATRIX: tasks.parent_id must follow saga->epic, epic->task|subtask, and task->subtask; sagas/tasks must be roots');
149
+ END;
150
+ --> statement-breakpoint
151
+
152
+ -- ---------------------------------------------------------------------------
153
+ -- Status / pipeline_stage invariant (T877) — tasks_tasks
154
+ -- ---------------------------------------------------------------------------
155
+ CREATE TRIGGER `trg_tasks_tasks_status_pipeline_insert`
156
+ BEFORE INSERT ON `tasks_tasks`
157
+ FOR EACH ROW
158
+ WHEN (NEW.`status` = 'done' AND (NEW.`pipeline_stage` IS NULL OR NEW.`pipeline_stage` NOT IN ('contribution','cancelled')))
159
+ OR (NEW.`status` = 'cancelled' AND (NEW.`pipeline_stage` IS NULL OR NEW.`pipeline_stage` != 'cancelled'))
160
+ BEGIN
161
+ SELECT RAISE(ABORT, 'T877_INVARIANT_VIOLATION: status/pipeline_stage mismatch. status=done requires pipeline_stage IN (contribution,cancelled); status=cancelled requires pipeline_stage=cancelled.');
162
+ END;
163
+ --> statement-breakpoint
164
+
165
+ CREATE TRIGGER `trg_tasks_tasks_status_pipeline_update`
166
+ BEFORE UPDATE OF `status`, `pipeline_stage` ON `tasks_tasks`
167
+ FOR EACH ROW
168
+ WHEN (NEW.`status` = 'done' AND (NEW.`pipeline_stage` IS NULL OR NEW.`pipeline_stage` NOT IN ('contribution','cancelled')))
169
+ OR (NEW.`status` = 'cancelled' AND (NEW.`pipeline_stage` IS NULL OR NEW.`pipeline_stage` != 'cancelled'))
170
+ BEGIN
171
+ SELECT RAISE(ABORT, 'T877_INVARIANT_VIOLATION: status/pipeline_stage mismatch. status=done requires pipeline_stage IN (contribution,cancelled); status=cancelled requires pipeline_stage=cancelled.');
172
+ END;
173
+ --> statement-breakpoint
174
+
175
+ -- ---------------------------------------------------------------------------
176
+ -- Non-containment guard (T10572) — tasks_task_relations
177
+ -- ---------------------------------------------------------------------------
178
+ CREATE TRIGGER `tasks_task_relations_non_containment_insert`
179
+ BEFORE INSERT ON `tasks_task_relations`
180
+ WHEN EXISTS (
181
+ SELECT 1
182
+ FROM `tasks_tasks` child
183
+ WHERE child.`id` = NEW.`task_id`
184
+ AND child.`parent_id` = NEW.`related_to`
185
+ ) OR EXISTS (
186
+ SELECT 1
187
+ FROM `tasks_tasks` child
188
+ WHERE child.`id` = NEW.`related_to`
189
+ AND child.`parent_id` = NEW.`task_id`
190
+ )
191
+ BEGIN
192
+ SELECT RAISE(ABORT, 'E_TASK_RELATION_CONTAINMENT: task_relations is non-containment-only; use tasks.parent_id for parent/child edges');
193
+ END;
194
+ --> statement-breakpoint
195
+
196
+ CREATE TRIGGER `tasks_task_relations_non_containment_update`
197
+ BEFORE UPDATE OF `task_id`, `related_to` ON `tasks_task_relations`
198
+ WHEN EXISTS (
199
+ SELECT 1
200
+ FROM `tasks_tasks` child
201
+ WHERE child.`id` = NEW.`task_id`
202
+ AND child.`parent_id` = NEW.`related_to`
203
+ ) OR EXISTS (
204
+ SELECT 1
205
+ FROM `tasks_tasks` child
206
+ WHERE child.`id` = NEW.`related_to`
207
+ AND child.`parent_id` = NEW.`task_id`
208
+ )
209
+ BEGIN
210
+ SELECT RAISE(ABORT, 'E_TASK_RELATION_CONTAINMENT: task_relations is non-containment-only; use tasks.parent_id for parent/child edges');
211
+ END;
212
+ --> statement-breakpoint
213
+
214
+ -- ---------------------------------------------------------------------------
215
+ -- Acceptance child_target containment guard (T10572) — tasks_task_acceptance_criteria
216
+ -- ---------------------------------------------------------------------------
217
+ CREATE TRIGGER `tasks_task_acceptance_child_target_insert`
218
+ BEFORE INSERT ON `tasks_task_acceptance_criteria`
219
+ WHEN NEW.`target_task_id` IS NOT NULL
220
+ AND (
221
+ NEW.`kind` <> 'child_task'
222
+ OR NOT EXISTS (
223
+ SELECT 1
224
+ FROM `tasks_tasks` child
225
+ WHERE child.`id` = NEW.`target_task_id`
226
+ AND child.`parent_id` = NEW.`task_id`
227
+ )
228
+ )
229
+ BEGIN
230
+ SELECT RAISE(ABORT, 'E_CHILD_TASK_TARGET_CONTAINMENT: child_task acceptance target_task_id must be a direct child of task_id; non-child_task criteria must not set target_task_id');
231
+ END;
232
+ --> statement-breakpoint
233
+
234
+ CREATE TRIGGER `tasks_task_acceptance_child_target_update`
235
+ BEFORE UPDATE OF `task_id`, `kind`, `target_task_id` ON `tasks_task_acceptance_criteria`
236
+ WHEN NEW.`target_task_id` IS NOT NULL
237
+ AND (
238
+ NEW.`kind` <> 'child_task'
239
+ OR NOT EXISTS (
240
+ SELECT 1
241
+ FROM `tasks_tasks` child
242
+ WHERE child.`id` = NEW.`target_task_id`
243
+ AND child.`parent_id` = NEW.`task_id`
244
+ )
245
+ )
246
+ BEGIN
247
+ SELECT RAISE(ABORT, 'E_CHILD_TASK_TARGET_CONTAINMENT: child_task acceptance target_task_id must be a direct child of task_id; non-child_task criteria must not set target_task_id');
248
+ END;
249
+ --> statement-breakpoint
250
+
251
+ -- ---------------------------------------------------------------------------
252
+ -- Session-handoff write-once + mirror (T1609) — tasks_session_handoff_entries
253
+ -- ---------------------------------------------------------------------------
254
+ CREATE TRIGGER `trg_tasks_session_handoff_mirror`
255
+ AFTER INSERT ON `tasks_session_handoff_entries`
256
+ FOR EACH ROW
257
+ BEGIN
258
+ UPDATE `tasks_sessions`
259
+ SET `handoff_json` = NEW.handoff_json
260
+ WHERE `id` = NEW.session_id;
261
+ END;
262
+ --> statement-breakpoint
263
+
264
+ CREATE TRIGGER `trg_tasks_session_handoff_no_update`
265
+ BEFORE UPDATE ON `tasks_session_handoff_entries`
266
+ FOR EACH ROW
267
+ BEGIN
268
+ SELECT RAISE(
269
+ ABORT,
270
+ 'T1609_HANDOFF_IMMUTABLE: session_handoff_entries rows are write-once. Use persistHandoff() exactly once per session.'
271
+ );
272
+ END;
@@ -0,0 +1,29 @@
1
+ -- Revert T11884 — drop the prefixed-table invariant + handoff triggers.
2
+ -- The legacy bare-table triggers are untouched (they remain the active guards
3
+ -- until the E5 cutover drops the bare tables).
4
+ --
5
+ -- @task T11884
6
+
7
+ DROP TRIGGER IF EXISTS `tasks_tasks_parent_cycle_guard_insert`;
8
+ --> statement-breakpoint
9
+ DROP TRIGGER IF EXISTS `tasks_tasks_parent_cycle_guard_update`;
10
+ --> statement-breakpoint
11
+ DROP TRIGGER IF EXISTS `tasks_tasks_parent_type_matrix_insert`;
12
+ --> statement-breakpoint
13
+ DROP TRIGGER IF EXISTS `tasks_tasks_parent_type_matrix_update`;
14
+ --> statement-breakpoint
15
+ DROP TRIGGER IF EXISTS `trg_tasks_tasks_status_pipeline_insert`;
16
+ --> statement-breakpoint
17
+ DROP TRIGGER IF EXISTS `trg_tasks_tasks_status_pipeline_update`;
18
+ --> statement-breakpoint
19
+ DROP TRIGGER IF EXISTS `tasks_task_relations_non_containment_insert`;
20
+ --> statement-breakpoint
21
+ DROP TRIGGER IF EXISTS `tasks_task_relations_non_containment_update`;
22
+ --> statement-breakpoint
23
+ DROP TRIGGER IF EXISTS `tasks_task_acceptance_child_target_insert`;
24
+ --> statement-breakpoint
25
+ DROP TRIGGER IF EXISTS `tasks_task_acceptance_child_target_update`;
26
+ --> statement-breakpoint
27
+ DROP TRIGGER IF EXISTS `trg_tasks_session_handoff_mirror`;
28
+ --> statement-breakpoint
29
+ DROP TRIGGER IF EXISTS `trg_tasks_session_handoff_no_update`;
@@ -0,0 +1,21 @@
1
+ -- T11883 (E2) — Repair the missing UNIQUE index on tasks_releases.version.
2
+ --
3
+ -- The drizzle schema declares `version: text('version').notNull().unique()`
4
+ -- (packages/core/src/store/schema/cleo-project/provenance-rest.ts:201), but the
5
+ -- T11363 consolidation migration that built `tasks_releases` emitted only a
6
+ -- NON-unique `idx_tasks_releases_version` — the UNIQUE was dropped during the
7
+ -- exodus build. `cleo release plan` upserts with
8
+ -- `onConflictDoUpdate({ target: releases.version })`, which REQUIRES a physical
9
+ -- unique index on `version`; once the provenance `releases` symbol is rebound to
10
+ -- `tasks_releases` (E3) the upsert would otherwise throw "ON CONFLICT clause
11
+ -- does not match any PRIMARY KEY or UNIQUE constraint". This is a pure
12
+ -- drift-repair (schema↔physical), so it ships as a custom migration rather than
13
+ -- a generated one (generate has no committed snapshot to diff an index against).
14
+ --
15
+ -- Safe: the live corpus has 0 duplicate versions (74 rows), and fresh/test DBs
16
+ -- are empty. IF NOT EXISTS keeps it idempotent under the reconciler's re-probe.
17
+ --
18
+ -- @task T11883
19
+ -- @saga T11242
20
+
21
+ CREATE UNIQUE INDEX IF NOT EXISTS `uq_tasks_releases_version` ON `tasks_releases` (`version`);
@@ -0,0 +1,4 @@
1
+ -- Revert T11883 (E2) — drop the repaired UNIQUE index on tasks_releases.version.
2
+ -- @task T11883
3
+
4
+ DROP INDEX IF EXISTS `uq_tasks_releases_version`;
@@ -0,0 +1,55 @@
1
+ -- T11627 (ST-2) — DbWriterLease arbitration tables (local-mode, daemon-disabled).
2
+ --
3
+ -- Co-located inside EACH scope's consolidated cleo.db (this file is byte-identical
4
+ -- in drizzle-cleo-project and drizzle-cleo-global so the two lineages produce the
5
+ -- SAME migration hash — the consolidated single-file journal converges across both
6
+ -- under the CONSOLIDATED_JOURNAL_LINEAGES cross-lineage guard, T11829).
7
+ --
8
+ -- The lease engine (packages/core/src/store/writer-lease.ts) arbitrates a single
9
+ -- in-process writer per (scope, lane) via BEGIN IMMEDIATE + epoch-CAS over the
10
+ -- `_writer_leases` row, healing the T5158 multi-writer corruption WITHOUT a running
11
+ -- supervisor daemon.
12
+ --
13
+ -- AC1 (at most one active writer per scope/lane) is enforced by the PARTIAL UNIQUE
14
+ -- index `ux_writer_leases_active … WHERE active = 1`. drizzle-orm cannot model a
15
+ -- partial WHERE index, so it is emitted here as raw SQL (the established repo
16
+ -- pattern — cf. project_agent_refs.enabled in conduit-schema). The drizzle schema
17
+ -- (writer-lease-schema.ts) declares ONLY the full-column tables; the runtime
18
+ -- bootstrap asserts this index exists (assertWriterLeaseActiveIndexPresent).
19
+ --
20
+ -- Each statement is separated by a drizzle breakpoint marker line so node:sqlite
21
+ -- prepare() does not silently truncate the multi-statement file to statement one.
22
+ -- (The marker token is intentionally NOT spelled out in this comment: drizzle's
23
+ -- readMigrationFiles splits the file on that literal substring, so writing it here
24
+ -- would split the comment mid-line and corrupt statement one.)
25
+ --
26
+ -- @task T11627
27
+ -- @epic T11625
28
+
29
+ CREATE TABLE IF NOT EXISTS `_writer_leases` (
30
+ `id` INTEGER PRIMARY KEY,
31
+ `scope` TEXT NOT NULL,
32
+ `lane` TEXT NOT NULL,
33
+ `holder_id` TEXT NOT NULL,
34
+ `holder_pid` INTEGER NOT NULL,
35
+ `epoch` INTEGER NOT NULL,
36
+ `acquired_at` INTEGER NOT NULL,
37
+ `heartbeat_at` INTEGER NOT NULL,
38
+ `ttl_ms` INTEGER NOT NULL,
39
+ `reentrancy_depth` INTEGER NOT NULL DEFAULT 1,
40
+ `active` INTEGER NOT NULL DEFAULT 1
41
+ );
42
+ --> statement-breakpoint
43
+ CREATE UNIQUE INDEX IF NOT EXISTS `ux_writer_leases_active` ON `_writer_leases` (`scope`, `lane`) WHERE `active` = 1;
44
+ --> statement-breakpoint
45
+ CREATE TABLE IF NOT EXISTS `_writer_queue` (
46
+ `ticket` INTEGER PRIMARY KEY AUTOINCREMENT,
47
+ `scope` TEXT NOT NULL,
48
+ `lane` TEXT NOT NULL,
49
+ `holder_id` TEXT NOT NULL,
50
+ `priority` INTEGER NOT NULL DEFAULT 100,
51
+ `enqueued_at` INTEGER NOT NULL,
52
+ `deadline_at` INTEGER NOT NULL
53
+ );
54
+ --> statement-breakpoint
55
+ CREATE INDEX IF NOT EXISTS `ix_writer_queue_order` ON `_writer_queue` (`scope`, `lane`, `priority` ASC, `ticket` ASC);
@@ -0,0 +1,22 @@
1
+ -- T11639 (EP-SESSION-MANIFEST · epic T11638) — add nullable `parent_session_id`
2
+ -- to `tasks_sessions` (consolidated PROJECT cleo.db, drizzle-cleo-project scope).
3
+ --
4
+ -- The fork-tree PARENT session edge: the orchestrator→worker spawn relationship,
5
+ -- sourced from CLEO_PARENT_SESSION_ID (stamped by the supervisor — T11629 / PR #996)
6
+ -- at session start. Distinct from `previous_session_id` (the linear resume chain).
7
+ -- Soft self-reference to `tasks_sessions.id`; nullable so a root session (no spawning
8
+ -- parent) and every existing row stay valid.
9
+ --
10
+ -- No CHECK constraint: `parent_session_id` is a plain free-text soft self-FK (not a
11
+ -- timestamp `_at`, boolean, or enum), so the T11363 consolidation-check injector
12
+ -- contributes nothing for it.
13
+ --
14
+ -- Each statement is separated by a drizzle breakpoint marker so node:sqlite prepare()
15
+ -- does not truncate the multi-statement file to statement one.
16
+ --
17
+ -- @task T11639
18
+ -- @epic T11638
19
+
20
+ ALTER TABLE `tasks_sessions` ADD COLUMN `parent_session_id` text;
21
+ --> statement-breakpoint
22
+ CREATE INDEX IF NOT EXISTS `idx_tasks_sessions_parent` ON `tasks_sessions` (`parent_session_id`);
@@ -0,0 +1,52 @@
1
+ -- T11761 (S3 · T11899) — Pi `SessionStorage` tree-persistence tables.
2
+ --
3
+ -- Backs `CleoSessionStorage` (packages/core/src/llm/pi/pi-session-storage.ts):
4
+ -- the durable cleo.db implementation of Pi's tree-structured `SessionStorage`
5
+ -- interface (@earendil-works/pi-agent-core). Every Pi session is a tree of
6
+ -- `SessionTreeEntry` nodes (id / parentId / timestamp / type / payload) plus one
7
+ -- leaf pointer per session; this file is the physical home for both.
8
+ --
9
+ -- Pure runtime infrastructure (like `_writer_leases` from T11627) — NOT part of
10
+ -- the exodus target shape under `schema/cleo-project/`. Co-located inside EACH
11
+ -- scope's consolidated cleo.db via the existing drizzle-cleo-project /
12
+ -- drizzle-cleo-global migration sets; this file is byte-identical across both
13
+ -- lineages so the two produce the SAME migration hash (the consolidated
14
+ -- single-file journal converges across both under CONSOLIDATED_JOURNAL_LINEAGES,
15
+ -- T11829). The Pi adapter resolves PROJECT scope; the global copy keeps the two
16
+ -- lineages' DDL convergent (the lease-table precedent).
17
+ --
18
+ -- ALL writes go through the writer lease (withWriterLease('project', 'bulk', …),
19
+ -- writer-lease.ts:1067) — the adapter NEVER opens a raw writer (Gate 3). These
20
+ -- tables are written by the store accessor (pi-session-store.ts) over the native
21
+ -- handle openDualScopeDb already holds, inside the leased section.
22
+ --
23
+ -- Each statement is separated by a drizzle breakpoint marker line so node:sqlite
24
+ -- prepare() does not silently truncate the multi-statement file to statement one
25
+ -- (the marker token is intentionally not spelled out in this comment — drizzle's
26
+ -- readMigrationFiles splits the file on that literal substring).
27
+ --
28
+ -- @task T11899
29
+ -- @task T11761
30
+ -- @epic T10403
31
+
32
+ CREATE TABLE IF NOT EXISTS `pi_session_entries` (
33
+ `session_id` TEXT NOT NULL,
34
+ `entry_id` TEXT NOT NULL,
35
+ `parent_id` TEXT,
36
+ `type` TEXT NOT NULL,
37
+ `payload_json` TEXT NOT NULL,
38
+ `seq` INTEGER NOT NULL,
39
+ `ts` TEXT NOT NULL,
40
+ PRIMARY KEY (`session_id`, `entry_id`)
41
+ );
42
+ --> statement-breakpoint
43
+ CREATE INDEX IF NOT EXISTS `ix_pi_session_entries_seq` ON `pi_session_entries` (`session_id`, `seq` ASC);
44
+ --> statement-breakpoint
45
+ CREATE INDEX IF NOT EXISTS `ix_pi_session_entries_parent` ON `pi_session_entries` (`session_id`, `parent_id`);
46
+ --> statement-breakpoint
47
+ CREATE TABLE IF NOT EXISTS `pi_session_leaf` (
48
+ `session_id` TEXT PRIMARY KEY,
49
+ `leaf_id` TEXT,
50
+ `created_at` TEXT NOT NULL,
51
+ `updated_at` TEXT NOT NULL
52
+ );
@@ -0,0 +1,64 @@
1
+ -- T11889 (T11889-A · T11911) — the self-improvement-loop DHQ sink (`selfimprove_dhq`).
2
+ --
3
+ -- One row per Dogfood-Harness-Question raised by `cleo selfimprove run`: the loop
4
+ -- replays a canned scenario, diffs the LAFS envelopes against a golden, and on
5
+ -- regression UPSERTs exactly ONE row here via the leased Gate-3 accessor
6
+ -- (selfimprove-dhq-store.ts). On green it writes nothing.
7
+ --
8
+ -- Co-located inside EACH scope's consolidated cleo.db (this file is byte-identical
9
+ -- in drizzle-cleo-project and drizzle-cleo-global so the two lineages produce the
10
+ -- SAME migration hash — the consolidated single-file journal converges across both
11
+ -- under the CONSOLIDATED_JOURNAL_LINEAGES cross-lineage guard, T11829). Pure runtime
12
+ -- infrastructure (like `_writer_leases` from T11627 and `pi_session_*` from T11899)
13
+ -- — NOT part of the exodus target shape under `schema/cleo-project/`.
14
+ --
15
+ -- ## Idempotency invariant (partial UNIQUE index)
16
+ --
17
+ -- At most ONE row per `question_hash` may carry `status = 'open'`, so a repeated
18
+ -- regression UPSERTs the same open row instead of spamming duplicates. drizzle-orm
19
+ -- cannot model a partial WHERE unique index, so it is emitted here as raw SQL (the
20
+ -- established repo pattern — cf. `_writer_leases.active`, T11627 ·
21
+ -- `project_agent_refs.enabled`). The drizzle schema (selfimprove-dhq-schema.ts)
22
+ -- declares ONLY the full-column table plus the two non-partial indexes drizzle CAN
23
+ -- emit; the runtime bootstrap asserts this partial index exists
24
+ -- (assertSelfimproveDhqOpenIndexPresent).
25
+ --
26
+ -- ## Page-2 invariant
27
+ --
28
+ -- This migration runs AFTER the consolidation baseline (…_t11363-consolidation-
29
+ -- cleo-project) which already creates dozens of tables, so `selfimprove_dhq` is
30
+ -- NEVER the first CREATE on a fresh DB — rootpage 2 is already owned by
31
+ -- `__drizzle_migrations` / the baseline tables. No journal pre-create is required
32
+ -- (the lease cold-open path pre-creates `__drizzle_migrations` before any first
33
+ -- table, so the precondition holds even on a freshly cold-opened DB).
34
+ --
35
+ -- `IF NOT EXISTS` so a re-open over an already-migrated DB is a no-op. Each
36
+ -- statement is separated by a drizzle breakpoint marker line so node:sqlite
37
+ -- prepare() does not silently truncate the multi-statement file to statement one
38
+ -- (the marker token is intentionally not spelled out in this comment — drizzle's
39
+ -- readMigrationFiles splits the file on that literal substring).
40
+ --
41
+ -- @task T11889
42
+ -- @task T11911
43
+ -- @epic T11889
44
+
45
+ CREATE TABLE IF NOT EXISTS `selfimprove_dhq` (
46
+ `id` INTEGER PRIMARY KEY,
47
+ `dhq_id` TEXT NOT NULL,
48
+ `scenario` TEXT NOT NULL,
49
+ `question_hash` TEXT NOT NULL,
50
+ `title` TEXT NOT NULL,
51
+ `regression_json` TEXT NOT NULL,
52
+ `status` TEXT NOT NULL DEFAULT 'open',
53
+ `severity` TEXT,
54
+ `pr_url` TEXT,
55
+ `run_id` TEXT NOT NULL,
56
+ `created_at` INTEGER NOT NULL,
57
+ `updated_at` INTEGER NOT NULL
58
+ );
59
+ --> statement-breakpoint
60
+ CREATE INDEX IF NOT EXISTS `ix_selfimprove_dhq_status` ON `selfimprove_dhq` (`status`);
61
+ --> statement-breakpoint
62
+ CREATE INDEX IF NOT EXISTS `ix_selfimprove_dhq_scenario` ON `selfimprove_dhq` (`scenario`);
63
+ --> statement-breakpoint
64
+ CREATE UNIQUE INDEX IF NOT EXISTS `ux_selfimprove_dhq_open` ON `selfimprove_dhq` (`question_hash`) WHERE `status` = 'open';