hippo-memory 1.60.0 → 1.61.0

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 (585) hide show
  1. package/README.md +1 -1
  2. package/dist/ablation.js +9 -27
  3. package/dist/agent-memories/apply.js +4 -1
  4. package/dist/agent-memories/claude-code.js +1 -1
  5. package/dist/agent-memories/codex.js +1 -1
  6. package/dist/agent-memories/gemini.js +1 -1
  7. package/dist/agent-memories/legacy.js +1 -1
  8. package/dist/agent-memories/source.js +1 -1
  9. package/dist/agent-memories/sync.js +8 -3
  10. package/dist/ambient-store.d.ts +14 -0
  11. package/dist/ambient-store.js +90 -0
  12. package/dist/ambient.d.ts +23 -0
  13. package/dist/ambient.js +72 -50
  14. package/dist/api/assemble.d.ts +93 -0
  15. package/dist/api/assemble.js +152 -0
  16. package/dist/api/audit.d.ts +17 -0
  17. package/dist/api/audit.js +23 -0
  18. package/dist/api/auth.d.ts +79 -0
  19. package/dist/api/auth.js +178 -0
  20. package/dist/api/context-types.d.ts +105 -0
  21. package/dist/api/context-types.js +3 -0
  22. package/dist/api/context.d.ts +31 -0
  23. package/dist/api/context.js +705 -0
  24. package/dist/api/dormant.d.ts +30 -0
  25. package/dist/api/dormant.js +140 -0
  26. package/dist/api/drill-down.d.ts +84 -0
  27. package/dist/api/drill-down.js +123 -0
  28. package/dist/api/forget.d.ts +57 -0
  29. package/dist/api/forget.js +87 -0
  30. package/dist/api/goals.d.ts +18 -0
  31. package/dist/api/goals.js +33 -0
  32. package/dist/api/learn.d.ts +31 -0
  33. package/dist/api/learn.js +88 -0
  34. package/dist/api/outcome.d.ts +61 -0
  35. package/dist/api/outcome.js +66 -0
  36. package/dist/api/promote.d.ts +54 -0
  37. package/dist/api/promote.js +203 -0
  38. package/dist/api/quarantine.d.ts +24 -0
  39. package/dist/api/quarantine.js +121 -0
  40. package/dist/api/recall-types.d.ts +390 -0
  41. package/dist/api/recall-types.js +3 -0
  42. package/dist/api/recall.d.ts +36 -0
  43. package/dist/api/recall.js +634 -0
  44. package/dist/api/remember.d.ts +35 -0
  45. package/dist/api/remember.js +43 -0
  46. package/dist/api/sleep.d.ts +136 -0
  47. package/dist/api/sleep.js +271 -0
  48. package/dist/api/tokens.d.ts +26 -0
  49. package/dist/api/tokens.js +60 -0
  50. package/dist/api/types.d.ts +56 -0
  51. package/dist/api/types.js +38 -0
  52. package/dist/api.d.ts +20 -1262
  53. package/dist/api.js +25 -2727
  54. package/dist/audit.d.ts +3 -0
  55. package/dist/audit.js +6 -3
  56. package/dist/auth.d.ts +45 -4
  57. package/dist/auth.js +125 -48
  58. package/dist/autolearn.js +2 -2
  59. package/dist/capture/command.d.ts +33 -0
  60. package/dist/capture/command.js +264 -0
  61. package/dist/capture/compact.d.ts +44 -0
  62. package/dist/capture/compact.js +354 -0
  63. package/dist/capture/extract.d.ts +21 -0
  64. package/dist/capture/extract.js +464 -0
  65. package/dist/capture/transcript.d.ts +40 -0
  66. package/dist/capture/transcript.js +193 -0
  67. package/dist/capture-error.js +2 -1
  68. package/dist/churn-git.js +4 -2
  69. package/dist/cli/audit.d.ts +3 -0
  70. package/dist/cli/audit.js +159 -0
  71. package/dist/cli/auth.d.ts +2 -0
  72. package/dist/cli/auth.js +171 -0
  73. package/dist/cli/briefs.d.ts +4 -0
  74. package/dist/cli/briefs.js +435 -0
  75. package/dist/cli/card.d.ts +3 -0
  76. package/dist/cli/card.js +333 -0
  77. package/dist/cli/context.d.ts +15 -0
  78. package/dist/cli/context.js +366 -0
  79. package/dist/cli/continuity.d.ts +6 -0
  80. package/dist/cli/continuity.js +445 -0
  81. package/dist/cli/curate.d.ts +19 -0
  82. package/dist/cli/curate.js +555 -0
  83. package/dist/cli/dag.d.ts +5 -0
  84. package/dist/cli/dag.js +177 -0
  85. package/dist/cli/decisions.d.ts +4 -0
  86. package/dist/cli/decisions.js +528 -0
  87. package/dist/cli/eval.d.ts +5 -0
  88. package/dist/cli/eval.js +213 -0
  89. package/dist/cli/explain.d.ts +4 -0
  90. package/dist/cli/explain.js +150 -0
  91. package/dist/cli/goals.d.ts +2 -0
  92. package/dist/cli/goals.js +196 -0
  93. package/dist/cli/hook-blocks.d.ts +18 -0
  94. package/dist/cli/hook-blocks.js +233 -0
  95. package/dist/cli/init.d.ts +2 -0
  96. package/dist/cli/init.js +305 -0
  97. package/dist/cli/maintenance.d.ts +4 -0
  98. package/dist/cli/maintenance.js +179 -0
  99. package/dist/cli/playbooks.d.ts +4 -0
  100. package/dist/cli/playbooks.js +556 -0
  101. package/dist/cli/projects.js +1 -1
  102. package/dist/cli/recall.d.ts +7 -0
  103. package/dist/cli/recall.js +597 -0
  104. package/dist/cli/remember.d.ts +5 -0
  105. package/dist/cli/remember.js +442 -0
  106. package/dist/cli/serve.d.ts +5 -0
  107. package/dist/cli/serve.js +40 -0
  108. package/dist/cli/session-hooks.d.ts +29 -0
  109. package/dist/cli/session-hooks.js +637 -0
  110. package/dist/cli/setup.d.ts +4 -0
  111. package/dist/cli/setup.js +376 -0
  112. package/dist/cli/shared.d.ts +15 -19
  113. package/dist/cli/shared.js +50 -341
  114. package/dist/cli/slack.d.ts +2 -0
  115. package/dist/cli/slack.js +171 -0
  116. package/dist/cli/status.d.ts +18 -0
  117. package/dist/cli/status.js +400 -0
  118. package/dist/cli/transfer.d.ts +10 -0
  119. package/dist/cli/transfer.js +438 -0
  120. package/dist/cli/usage.d.ts +85 -0
  121. package/dist/cli/usage.js +741 -0
  122. package/dist/cli.d.ts +71 -120
  123. package/dist/cli.js +170 -8469
  124. package/dist/client.js +15 -8
  125. package/dist/compaction-record.js +6 -4
  126. package/dist/connectors/github/backfill.js +94 -87
  127. package/dist/connectors/github/cli-impl.js +4 -3
  128. package/dist/connectors/github/dlq.js +67 -54
  129. package/dist/connectors/github/ingest.js +34 -35
  130. package/dist/connectors/github/tenant-routing.js +3 -2
  131. package/dist/connectors/github/webhook.js +135 -216
  132. package/dist/connectors/slack/dlq.js +49 -61
  133. package/dist/connectors/slack/ingest.js +55 -48
  134. package/dist/connectors/slack/tenant-routing.js +4 -3
  135. package/dist/connectors/slack/webhook.js +72 -74
  136. package/dist/consolidate/conflicts.d.ts +10 -0
  137. package/dist/consolidate/conflicts.js +178 -0
  138. package/dist/consolidate/decay.d.ts +12 -0
  139. package/dist/consolidate/decay.js +145 -0
  140. package/dist/consolidate/llm-passes.d.ts +3 -0
  141. package/dist/consolidate/llm-passes.js +141 -0
  142. package/dist/consolidate/merge.d.ts +7 -0
  143. package/dist/consolidate/merge.js +251 -0
  144. package/dist/consolidate/physics-pass.d.ts +3 -0
  145. package/dist/consolidate/physics-pass.js +60 -0
  146. package/dist/consolidate/run.d.ts +69 -0
  147. package/dist/consolidate/run.js +76 -0
  148. package/dist/consolidate/sleep.d.ts +18 -0
  149. package/dist/consolidate/sleep.js +209 -0
  150. package/dist/consolidate/traces.d.ts +4 -0
  151. package/dist/consolidate/traces.js +178 -0
  152. package/dist/context-auto.js +7 -11
  153. package/dist/context-render.d.ts +1 -1
  154. package/dist/context-render.js +1 -1
  155. package/dist/customer-notes.d.ts +3 -0
  156. package/dist/customer-notes.js +6 -4
  157. package/dist/dag.js +6 -5
  158. package/dist/dashboard-actions.d.ts +20 -0
  159. package/dist/dashboard-actions.js +88 -0
  160. package/dist/dashboard-params.d.ts +45 -0
  161. package/dist/dashboard-params.js +127 -0
  162. package/dist/dashboard-queries.d.ts +15 -0
  163. package/dist/dashboard-queries.js +355 -0
  164. package/dist/dashboard-snapshot.d.ts +138 -0
  165. package/dist/dashboard-snapshot.js +308 -0
  166. package/dist/dashboard-types.d.ts +163 -0
  167. package/dist/dashboard-types.js +3 -0
  168. package/dist/dashboard.d.ts +6 -7
  169. package/dist/dashboard.js +228 -202
  170. package/dist/db/busy.d.ts +5 -0
  171. package/dist/db/busy.js +24 -0
  172. package/dist/db/continuity.d.ts +5 -0
  173. package/dist/db/continuity.js +145 -0
  174. package/dist/db/meta.d.ts +8 -0
  175. package/dist/db/meta.js +35 -0
  176. package/dist/db/migrate.d.ts +9 -0
  177. package/dist/db/migrate.js +138 -0
  178. package/dist/db/migrations/index.d.ts +5 -0
  179. package/dist/db/migrations/index.js +109 -0
  180. package/dist/db/migrations/types.d.ts +14 -0
  181. package/dist/db/migrations/types.js +2 -0
  182. package/dist/db/migrations/v01.d.ts +3 -0
  183. package/dist/db/migrations/v01.js +38 -0
  184. package/dist/db/migrations/v02.d.ts +3 -0
  185. package/dist/db/migrations/v02.js +21 -0
  186. package/dist/db/migrations/v03.d.ts +3 -0
  187. package/dist/db/migrations/v03.js +22 -0
  188. package/dist/db/migrations/v04.d.ts +3 -0
  189. package/dist/db/migrations/v04.js +28 -0
  190. package/dist/db/migrations/v05.d.ts +3 -0
  191. package/dist/db/migrations/v05.js +21 -0
  192. package/dist/db/migrations/v06.d.ts +3 -0
  193. package/dist/db/migrations/v06.js +25 -0
  194. package/dist/db/migrations/v07.d.ts +3 -0
  195. package/dist/db/migrations/v07.js +13 -0
  196. package/dist/db/migrations/v08.d.ts +3 -0
  197. package/dist/db/migrations/v08.js +8 -0
  198. package/dist/db/migrations/v09.d.ts +3 -0
  199. package/dist/db/migrations/v09.js +13 -0
  200. package/dist/db/migrations/v10.d.ts +3 -0
  201. package/dist/db/migrations/v10.js +17 -0
  202. package/dist/db/migrations/v11.d.ts +3 -0
  203. package/dist/db/migrations/v11.js +15 -0
  204. package/dist/db/migrations/v12.d.ts +3 -0
  205. package/dist/db/migrations/v12.js +11 -0
  206. package/dist/db/migrations/v13.d.ts +3 -0
  207. package/dist/db/migrations/v13.js +15 -0
  208. package/dist/db/migrations/v14.d.ts +3 -0
  209. package/dist/db/migrations/v14.js +66 -0
  210. package/dist/db/migrations/v15.d.ts +3 -0
  211. package/dist/db/migrations/v15.js +42 -0
  212. package/dist/db/migrations/v16.d.ts +3 -0
  213. package/dist/db/migrations/v16.js +61 -0
  214. package/dist/db/migrations/v17.d.ts +3 -0
  215. package/dist/db/migrations/v17.js +46 -0
  216. package/dist/db/migrations/v18.d.ts +3 -0
  217. package/dist/db/migrations/v18.js +60 -0
  218. package/dist/db/migrations/v19.d.ts +3 -0
  219. package/dist/db/migrations/v19.js +28 -0
  220. package/dist/db/migrations/v20.d.ts +3 -0
  221. package/dist/db/migrations/v20.js +42 -0
  222. package/dist/db/migrations/v21.d.ts +3 -0
  223. package/dist/db/migrations/v21.js +16 -0
  224. package/dist/db/migrations/v22.d.ts +3 -0
  225. package/dist/db/migrations/v22.js +82 -0
  226. package/dist/db/migrations/v23.d.ts +3 -0
  227. package/dist/db/migrations/v23.js +48 -0
  228. package/dist/db/migrations/v24.d.ts +3 -0
  229. package/dist/db/migrations/v24.js +72 -0
  230. package/dist/db/migrations/v25.d.ts +3 -0
  231. package/dist/db/migrations/v25.js +46 -0
  232. package/dist/db/migrations/v26.d.ts +3 -0
  233. package/dist/db/migrations/v26.js +23 -0
  234. package/dist/db/migrations/v27.d.ts +3 -0
  235. package/dist/db/migrations/v27.js +57 -0
  236. package/dist/db/migrations/v28.d.ts +3 -0
  237. package/dist/db/migrations/v28.js +38 -0
  238. package/dist/db/migrations/v29.d.ts +3 -0
  239. package/dist/db/migrations/v29.js +78 -0
  240. package/dist/db/migrations/v30.d.ts +3 -0
  241. package/dist/db/migrations/v30.js +92 -0
  242. package/dist/db/migrations/v31.d.ts +3 -0
  243. package/dist/db/migrations/v31.js +74 -0
  244. package/dist/db/migrations/v32.d.ts +3 -0
  245. package/dist/db/migrations/v32.js +102 -0
  246. package/dist/db/migrations/v33.d.ts +3 -0
  247. package/dist/db/migrations/v33.js +104 -0
  248. package/dist/db/migrations/v34.d.ts +3 -0
  249. package/dist/db/migrations/v34.js +93 -0
  250. package/dist/db/migrations/v35.d.ts +3 -0
  251. package/dist/db/migrations/v35.js +98 -0
  252. package/dist/db/migrations/v36.d.ts +3 -0
  253. package/dist/db/migrations/v36.js +98 -0
  254. package/dist/db/migrations/v37.d.ts +3 -0
  255. package/dist/db/migrations/v37.js +219 -0
  256. package/dist/db/migrations/v38.d.ts +3 -0
  257. package/dist/db/migrations/v38.js +277 -0
  258. package/dist/db/migrations/v39.d.ts +3 -0
  259. package/dist/db/migrations/v39.js +59 -0
  260. package/dist/db/migrations/v40.d.ts +3 -0
  261. package/dist/db/migrations/v40.js +74 -0
  262. package/dist/db/migrations/v41.d.ts +3 -0
  263. package/dist/db/migrations/v41.js +43 -0
  264. package/dist/db/migrations/v42.d.ts +3 -0
  265. package/dist/db/migrations/v42.js +41 -0
  266. package/dist/db/migrations/v43.d.ts +3 -0
  267. package/dist/db/migrations/v43.js +67 -0
  268. package/dist/db/migrations/v44.d.ts +3 -0
  269. package/dist/db/migrations/v44.js +28 -0
  270. package/dist/db/migrations/v45.d.ts +3 -0
  271. package/dist/db/migrations/v45.js +30 -0
  272. package/dist/db/migrations/v46.d.ts +3 -0
  273. package/dist/db/migrations/v46.js +25 -0
  274. package/dist/db/migrations/v47.d.ts +3 -0
  275. package/dist/db/migrations/v47.js +17 -0
  276. package/dist/db/migrations/v48.d.ts +3 -0
  277. package/dist/db/migrations/v48.js +10 -0
  278. package/dist/db/migrations/v49.d.ts +3 -0
  279. package/dist/db/migrations/v49.js +31 -0
  280. package/dist/db/migrations/v50.d.ts +3 -0
  281. package/dist/db/migrations/v50.js +67 -0
  282. package/dist/db/migrations/v51.d.ts +3 -0
  283. package/dist/db/migrations/v51.js +14 -0
  284. package/dist/db/migrations/v52.d.ts +3 -0
  285. package/dist/db/migrations/v52.js +7 -0
  286. package/dist/db/open.d.ts +23 -0
  287. package/dist/db/open.js +146 -0
  288. package/dist/db/sqlite.d.ts +21 -0
  289. package/dist/db/sqlite.js +8 -0
  290. package/dist/db/tables.d.ts +7 -0
  291. package/dist/db/tables.js +38 -0
  292. package/dist/db.d.ts +6 -46
  293. package/dist/db.js +5 -3049
  294. package/dist/decisions.d.ts +4 -1
  295. package/dist/decisions.js +9 -7
  296. package/dist/dedupe.js +3 -2
  297. package/dist/delivery-recorder.js +4 -1
  298. package/dist/doctor.js +3 -3
  299. package/dist/embedding-provider.d.ts +1 -1
  300. package/dist/embedding-provider.js +4 -3
  301. package/dist/embeddings.d.ts +9 -52
  302. package/dist/embeddings.js +43 -297
  303. package/dist/env.d.ts +75 -0
  304. package/dist/env.js +119 -0
  305. package/dist/eval-suite.js +1 -1
  306. package/dist/eval.js +2 -2
  307. package/dist/extract.js +1 -1
  308. package/dist/gated-write.js +3 -1
  309. package/dist/goals.d.ts +3 -1
  310. package/dist/goals.js +18 -0
  311. package/dist/graph/read.d.ts +73 -0
  312. package/dist/graph/read.js +325 -0
  313. package/dist/graph/rows.d.ts +45 -0
  314. package/dist/graph/rows.js +51 -0
  315. package/dist/graph/types.d.ts +83 -0
  316. package/dist/graph/types.js +11 -0
  317. package/dist/graph/write.d.ts +93 -0
  318. package/dist/{graph.js → graph/write.js} +6 -384
  319. package/dist/graph-extract.js +2 -1
  320. package/dist/graph-recall.d.ts +1 -1
  321. package/dist/graph-recall.js +2 -2
  322. package/dist/graph-stream.js +1 -1
  323. package/dist/graph-view.d.ts +1 -1
  324. package/dist/graph-view.js +1 -1
  325. package/dist/half-life-migration.d.ts +1 -1
  326. package/dist/half-life-migration.js +2 -1
  327. package/dist/hooks/codex-session.d.ts +8 -0
  328. package/dist/hooks/codex-session.js +76 -0
  329. package/dist/hooks/codex-wrapper.d.ts +55 -0
  330. package/dist/hooks/codex-wrapper.js +288 -0
  331. package/dist/hooks/json-hooks.d.ts +63 -0
  332. package/dist/hooks/json-hooks.js +356 -0
  333. package/dist/hooks/opencode.d.ts +50 -0
  334. package/dist/hooks/opencode.js +202 -0
  335. package/dist/hooks/shared.d.ts +54 -0
  336. package/dist/hooks/shared.js +77 -0
  337. package/dist/http-retry.d.ts +2 -0
  338. package/dist/http-retry.js +4 -3
  339. package/dist/http-util.d.ts +3 -0
  340. package/dist/http-util.js +10 -0
  341. package/dist/{importers.d.ts → importers/core.d.ts} +13 -17
  342. package/dist/importers/core.js +141 -0
  343. package/dist/importers/markdown-parse.d.ts +41 -0
  344. package/dist/importers/markdown-parse.js +132 -0
  345. package/dist/importers/markdown.d.ts +3 -0
  346. package/dist/importers/markdown.js +92 -0
  347. package/dist/importers/sources.d.ts +7 -0
  348. package/dist/importers/sources.js +229 -0
  349. package/dist/importers/vault.d.ts +11 -0
  350. package/dist/importers/vault.js +352 -0
  351. package/dist/incidents.d.ts +3 -0
  352. package/dist/incidents.js +7 -5
  353. package/dist/index.d.ts +25 -6
  354. package/dist/index.js +23 -6
  355. package/dist/invalidation.js +2 -1
  356. package/dist/judgment.js +2 -1
  357. package/dist/keyset.d.ts +13 -0
  358. package/dist/keyset.js +8 -0
  359. package/dist/local-embedding.d.ts +13 -0
  360. package/dist/local-embedding.js +165 -0
  361. package/dist/log.d.ts +7 -0
  362. package/dist/log.js +19 -1
  363. package/dist/mcp/admin-tools.d.ts +8 -0
  364. package/dist/mcp/admin-tools.js +116 -0
  365. package/dist/mcp/format.d.ts +27 -0
  366. package/dist/mcp/format.js +135 -0
  367. package/dist/mcp/memory-tools.d.ts +5 -0
  368. package/dist/mcp/memory-tools.js +83 -0
  369. package/dist/mcp/protocol.d.ts +83 -0
  370. package/dist/mcp/protocol.js +55 -0
  371. package/dist/mcp/recall-tools.d.ts +6 -0
  372. package/dist/mcp/recall-tools.js +320 -0
  373. package/dist/mcp/request.d.ts +10 -0
  374. package/dist/mcp/request.js +163 -0
  375. package/dist/mcp/server.d.ts +4 -75
  376. package/dist/mcp/server.js +7 -1190
  377. package/dist/mcp/session-state.d.ts +11 -0
  378. package/dist/mcp/session-state.js +28 -0
  379. package/dist/mcp/stdio.d.ts +8 -0
  380. package/dist/mcp/stdio.js +79 -0
  381. package/dist/mcp/tools.d.ts +11 -0
  382. package/dist/mcp/tools.js +247 -0
  383. package/dist/memory.d.ts +3 -0
  384. package/dist/memory.js +27 -1
  385. package/dist/multihop.d.ts +1 -1
  386. package/dist/multihop.js +2 -1
  387. package/dist/owner-validation.js +2 -1
  388. package/dist/physics-state.js +10 -7
  389. package/dist/policies.d.ts +3 -0
  390. package/dist/policies.js +8 -6
  391. package/dist/postinstall.js +3 -2
  392. package/dist/predictions/planning-fallacy.d.ts +100 -0
  393. package/dist/predictions/planning-fallacy.js +190 -0
  394. package/dist/{predictions.d.ts → predictions/store.d.ts} +7 -102
  395. package/dist/predictions/store.js +434 -0
  396. package/dist/processes.d.ts +3 -0
  397. package/dist/processes.js +7 -5
  398. package/dist/project-briefs.d.ts +3 -0
  399. package/dist/project-briefs.js +7 -5
  400. package/dist/project-identity.js +3 -2
  401. package/dist/project-merge.js +3 -1
  402. package/dist/quarantine.d.ts +2 -1
  403. package/dist/quarantine.js +8 -5
  404. package/dist/raw-archive.js +1 -1
  405. package/dist/recall-history.js +3 -2
  406. package/dist/recall-pipeline.d.ts +2 -2
  407. package/dist/recall-pipeline.js +16 -8
  408. package/dist/recall-scope.js +1 -1
  409. package/dist/recall-trace.d.ts +1 -1
  410. package/dist/refine-llm.js +2 -1
  411. package/dist/reject-flow.js +6 -1
  412. package/dist/rerankers/clef.js +6 -5
  413. package/dist/rerankers/jev.d.ts +1 -1
  414. package/dist/rerankers/jev.js +4 -4
  415. package/dist/rerankers/llm.d.ts +4 -2
  416. package/dist/rerankers/llm.js +58 -38
  417. package/dist/rerankers/types.d.ts +1 -1
  418. package/dist/salience.js +1 -1
  419. package/dist/scheduler.d.ts +1 -0
  420. package/dist/scheduler.js +26 -4
  421. package/dist/scope.js +4 -3
  422. package/dist/search/as-of.d.ts +10 -0
  423. package/dist/search/as-of.js +22 -0
  424. package/dist/search/bm25-search.d.ts +14 -0
  425. package/dist/search/bm25-search.js +43 -0
  426. package/dist/search/bm25.d.ts +15 -0
  427. package/dist/search/bm25.js +54 -0
  428. package/dist/search/boosts.d.ts +54 -0
  429. package/dist/search/boosts.js +94 -0
  430. package/dist/search/breakdown.d.ts +7 -0
  431. package/dist/search/breakdown.js +20 -0
  432. package/dist/search/explain.d.ts +25 -0
  433. package/dist/search/explain.js +31 -0
  434. package/dist/search/finalize.d.ts +8 -0
  435. package/dist/search/finalize.js +52 -0
  436. package/dist/search/fusion.d.ts +27 -0
  437. package/dist/search/fusion.js +42 -0
  438. package/dist/search/hybrid-score.d.ts +20 -0
  439. package/dist/search/hybrid-score.js +73 -0
  440. package/dist/search/hybrid.d.ts +46 -0
  441. package/dist/search/hybrid.js +64 -0
  442. package/dist/search/physics-search.d.ts +29 -0
  443. package/dist/search/physics-search.js +162 -0
  444. package/dist/search/rerank.d.ts +10 -0
  445. package/dist/search/rerank.js +72 -0
  446. package/dist/search/temporal.d.ts +15 -0
  447. package/dist/search/temporal.js +45 -0
  448. package/dist/search/types.d.ts +91 -0
  449. package/dist/search/types.js +2 -0
  450. package/dist/search/vector.d.ts +30 -0
  451. package/dist/search/vector.js +71 -0
  452. package/dist/secret-detect.d.ts +2 -0
  453. package/dist/secret-detect.js +2 -1
  454. package/dist/server/auth.d.ts +52 -0
  455. package/dist/server/auth.js +221 -0
  456. package/dist/server/client-ip.d.ts +25 -0
  457. package/dist/server/client-ip.js +92 -0
  458. package/dist/server/cursor.d.ts +23 -0
  459. package/dist/server/cursor.js +58 -0
  460. package/dist/server/lifecycle.d.ts +7 -0
  461. package/dist/server/lifecycle.js +29 -0
  462. package/dist/server/mcp-http.d.ts +5 -0
  463. package/dist/server/mcp-http.js +199 -0
  464. package/dist/server/request.d.ts +33 -0
  465. package/dist/server/request.js +103 -0
  466. package/dist/server/routes/admin.d.ts +9 -0
  467. package/dist/server/routes/admin.js +158 -0
  468. package/dist/server/routes/customer-notes.d.ts +7 -0
  469. package/dist/server/routes/customer-notes.js +112 -0
  470. package/dist/server/routes/decisions.d.ts +7 -0
  471. package/dist/server/routes/decisions.js +133 -0
  472. package/dist/server/routes/incidents.d.ts +7 -0
  473. package/dist/server/routes/incidents.js +126 -0
  474. package/dist/server/routes/memories.d.ts +10 -0
  475. package/dist/server/routes/memories.js +179 -0
  476. package/dist/server/routes/policies.d.ts +8 -0
  477. package/dist/server/routes/policies.js +151 -0
  478. package/dist/server/routes/predictions.d.ts +7 -0
  479. package/dist/server/routes/predictions.js +164 -0
  480. package/dist/server/routes/processes.d.ts +7 -0
  481. package/dist/server/routes/processes.js +161 -0
  482. package/dist/server/routes/project-briefs.d.ts +8 -0
  483. package/dist/server/routes/project-briefs.js +136 -0
  484. package/dist/server/routes/recall.d.ts +8 -0
  485. package/dist/server/routes/recall.js +340 -0
  486. package/dist/server/routes/skills.d.ts +8 -0
  487. package/dist/server/routes/skills.js +150 -0
  488. package/dist/server/types.d.ts +56 -0
  489. package/dist/server/types.js +2 -0
  490. package/dist/server/validation.d.ts +14 -0
  491. package/dist/server/validation.js +91 -0
  492. package/dist/server.d.ts +7 -61
  493. package/dist/server.js +69 -2362
  494. package/dist/session-digest.d.ts +1 -1
  495. package/dist/session-digest.js +9 -2
  496. package/dist/shared.d.ts +3 -1
  497. package/dist/shared.js +26 -22
  498. package/dist/skills.d.ts +3 -0
  499. package/dist/skills.js +7 -5
  500. package/dist/stdin.js +2 -2
  501. package/dist/store/audit-event.d.ts +19 -0
  502. package/dist/store/audit-event.js +33 -0
  503. package/dist/store/candidates.d.ts +42 -0
  504. package/dist/store/candidates.js +152 -0
  505. package/dist/store/conflicts.d.ts +44 -0
  506. package/dist/store/conflicts.js +444 -0
  507. package/dist/store/delete-and-batch.d.ts +63 -0
  508. package/dist/store/delete-and-batch.js +310 -0
  509. package/dist/store/entry-reads.d.ts +92 -0
  510. package/dist/store/entry-reads.js +255 -0
  511. package/dist/store/entry-row.d.ts +67 -0
  512. package/dist/store/entry-row.js +208 -0
  513. package/dist/store/entry-writes.d.ts +46 -0
  514. package/dist/store/entry-writes.js +148 -0
  515. package/dist/store/handoffs.d.ts +26 -0
  516. package/dist/store/handoffs.js +184 -0
  517. package/dist/store/index-and-stats.d.ts +52 -0
  518. package/dist/store/index-and-stats.js +214 -0
  519. package/dist/store/markdown.d.ts +10 -0
  520. package/dist/store/markdown.js +108 -0
  521. package/dist/store/mirrors.d.ts +49 -0
  522. package/dist/store/mirrors.js +312 -0
  523. package/dist/store/open.d.ts +15 -0
  524. package/dist/store/open.js +223 -0
  525. package/dist/store/rows.d.ts +178 -0
  526. package/dist/store/rows.js +158 -0
  527. package/dist/store/search-rows.d.ts +86 -0
  528. package/dist/store/search-rows.js +254 -0
  529. package/dist/store/sessions.d.ts +83 -0
  530. package/dist/store/sessions.js +272 -0
  531. package/dist/store/summaries.d.ts +94 -0
  532. package/dist/store/summaries.js +377 -0
  533. package/dist/store/tenant-lookup.d.ts +12 -0
  534. package/dist/store/tenant-lookup.js +16 -0
  535. package/dist/store-cards.js +2 -1
  536. package/dist/summary-dirty.d.ts +4 -0
  537. package/dist/summary-dirty.js +32 -0
  538. package/dist/support-bundle.js +4 -3
  539. package/dist/tenant.js +2 -2
  540. package/dist/tokenize.d.ts +2 -0
  541. package/dist/tokenize.js +16 -0
  542. package/dist/transcript-tail.d.ts +7 -0
  543. package/dist/transcript-tail.js +48 -0
  544. package/dist/vector-store.d.ts +27 -0
  545. package/dist/vector-store.js +210 -0
  546. package/dist/version.d.ts +2 -2
  547. package/dist/version.js +2 -2
  548. package/dist/working-memory.js +1 -1
  549. package/dist/yaml.js +36 -11
  550. package/dist-ui/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  551. package/dist-ui/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  552. package/dist-ui/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  553. package/dist-ui/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  554. package/dist-ui/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  555. package/dist-ui/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  556. package/dist-ui/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
  557. package/dist-ui/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
  558. package/dist-ui/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
  559. package/dist-ui/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
  560. package/dist-ui/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
  561. package/dist-ui/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
  562. package/dist-ui/assets/index-DPN7cP19.js +33 -0
  563. package/dist-ui/assets/index-dFloKRVr.css +1 -0
  564. package/dist-ui/index.html +3 -25
  565. package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
  566. package/extensions/openclaw-plugin/package.json +1 -1
  567. package/openclaw.plugin.json +1 -1
  568. package/package.json +1 -1
  569. package/dist/capture.d.ts +0 -155
  570. package/dist/capture.js +0 -1295
  571. package/dist/consolidate.d.ts +0 -58
  572. package/dist/consolidate.js +0 -1124
  573. package/dist/graph.d.ts +0 -245
  574. package/dist/hooks.d.ts +0 -208
  575. package/dist/hooks.js +0 -1076
  576. package/dist/importers.js +0 -900
  577. package/dist/predictions.js +0 -620
  578. package/dist/search.d.ts +0 -320
  579. package/dist/search.js +0 -970
  580. package/dist/store.d.ts +0 -776
  581. package/dist/store.js +0 -3473
  582. package/dist-ui/assets/d3-BiWEKnn4.js +0 -1
  583. package/dist-ui/assets/index-BhT8RvO6.js +0 -61
  584. package/dist-ui/assets/index-RoXXJ5dq.css +0 -1
  585. package/dist-ui/assets/three-BDgTxR1l.js +0 -4112
package/dist/store.d.ts DELETED
@@ -1,776 +0,0 @@
1
- /**
2
- * Storage layer for Hippo.
3
- *
4
- * SQLite is the source of truth.
5
- * Markdown + JSON files remain as human-readable compatibility mirrors.
6
- */
7
- import { MemoryEntry, Layer, type StrengthInputs } from './memory.js';
8
- import { openHippoDb, getHippoDbPath, type DatabaseSyncLike } from './db.js';
9
- import { SessionHandoff, HandoffEvidence, HandoffOutcome } from './handoff.js';
10
- import { type ResolveProjectIdentityOpts } from './project-identity.js';
11
- import { RejectedValueError } from './rejection.js';
12
- import { type DormantMove } from './dormant.js';
13
- /** A value that round-trips through JSON.stringify/JSON.parse unchanged. */
14
- type JsonValue = string | number | boolean | null | JsonValue[] | {
15
- [key: string]: JsonValue;
16
- };
17
- /**
18
- * Refusal audit for the AT1 rejection guard (plan §3). Written by the
19
- * transaction OWNER post-rollback — writeEntry's catch (no outer tx exists
20
- * there, so this lands in a fresh implicit transaction) and api.supersede's
21
- * catch (after its own ROLLBACK) — never inside a scope the caller's own
22
- * rollback could claw back. Best-effort `audit()` semantics: never throws.
23
- */
24
- export declare function auditRejectionRefusal(db: ReturnType<typeof openHippoDb>, err: RejectedValueError, actor: string): void;
25
- export interface IndexEntry {
26
- id: string;
27
- file: string;
28
- layer: Layer;
29
- strength: number;
30
- tags: string[];
31
- created: string;
32
- last_retrieved: string;
33
- pinned: boolean;
34
- }
35
- export interface HippoIndex {
36
- version: number;
37
- entries: Record<string, IndexEntry>;
38
- last_retrieval_ids: string[];
39
- /** LC1 (docs/plans/2026-08-02-lc1-recall-trace-persistence.md): id of the
40
- * most recent recall_traces row written by getContext/cmdRecall, mirrored
41
- * from the `last_trace_id` meta key exactly like last_retrieval_ids. null
42
- * when no trace has been written yet (fresh store, pre-v40 flow, or
43
- * api.recall-only usage — api.recall never sets this). */
44
- last_trace_id: string | null;
45
- }
46
- export interface TaskSnapshot {
47
- id: number;
48
- task: string;
49
- summary: string;
50
- next_step: string;
51
- status: string;
52
- source: string;
53
- session_id: string | null;
54
- scope: string | null;
55
- created_at: string;
56
- updated_at: string;
57
- }
58
- export interface MemoryConflict {
59
- id: number;
60
- memory_a_id: string;
61
- memory_b_id: string;
62
- reason: string;
63
- score: number;
64
- status: string;
65
- detected_at: string;
66
- updated_at: string;
67
- }
68
- export interface SessionEvent {
69
- id: number;
70
- session_id: string;
71
- task: string | null;
72
- event_type: string;
73
- content: string;
74
- source: string;
75
- scope: string | null;
76
- metadata: Record<string, JsonValue>;
77
- created_at: string;
78
- }
79
- export declare const MEMORY_SELECT_COLUMNS = "id, created, last_retrieved, retrieval_count, strength, half_life_days, layer, tags_json, emotional_valence, schema_fit, source, outcome_score, outcome_positive, outcome_negative, conflicts_with_json, pinned, confidence, content, parents_json, starred, trace_outcome, source_session_id, valid_from, superseded_by, extracted_from, dag_level, dag_parent_id, kind, scope, owner, artifact_ref, tenant_id, origin_project, descendant_count, earliest_at, latest_at, summary_dirty, last_rebuilt_at, rebuild_count, dag_level_3_built_at";
80
- /**
81
- * Default candidate-pool size for `loadSearchEntries` when called with
82
- * `limit === undefined`. Single source of truth; `api.recall` imports
83
- * this for `RecallResult.windowSize` reporting so the two cannot drift.
84
- */
85
- export declare const DEFAULT_SEARCH_CANDIDATE_LIMIT = 200;
86
- /** Nearest ancestor store like git; the strict join is the fallback so `hippo init` still creates `<cwd>/.hippo`. */
87
- export declare function getHippoRoot(cwd?: string, opts?: ResolveProjectIdentityOpts): string;
88
- export declare function isInitialized(hippoRoot: string): boolean;
89
- export declare function initStore(hippoRoot: string): void;
90
- /** One open connection with init done on it, for callers who used to pay for `initStore` + a second `openHippoDb`. */
91
- export declare function openStore(hippoRoot: string): DatabaseSyncLike;
92
- /** `meta` key holding the default half-life base a store's memories are on (src/half-life-migration.ts). */
93
- export declare const HALF_LIFE_BASE_META_KEY = "default_half_life_base";
94
- /** `meta` key set once no memory of a decision, incident or other object sits on the old flat 90 days. */
95
- export declare const TYPED_HALF_LIFE_META_KEY = "typed_half_life_on_default";
96
- /**
97
- * Serialize a MemoryEntry to markdown with YAML frontmatter.
98
- */
99
- export declare function serializeEntry(entry: MemoryEntry): string;
100
- /**
101
- * Deserialize a markdown file to a MemoryEntry.
102
- */
103
- export declare function deserializeEntry(raw: string): MemoryEntry | null;
104
- /**
105
- * v1.7.2 — recall-mode scope filter shape, exported so callers
106
- * (`loadRecallSearchEntries`) and tests can refer to it symbolically without
107
- * `Parameters<typeof loadSearchRows>[N]` indirection.
108
- *
109
- * Three modes:
110
- * - 'default-deny' — exclude scopes in `RECALL_DEFAULT_DENY_SCOPES` (T2).
111
- * - 'exact' — exact match on `m.scope = value` (api.recall's explicit-scope
112
- * request semantics).
113
- * - 'default-deny-or-exact' (v1.25.0) — the default-admitted set PLUS rows
114
- * whose scope equals `value`. This is the CLI `--scope` semantics: the
115
- * flag predates the envelope column as a TAG-boost ranking hint
116
- * (`scope:<v>` tags, HIPPO_SCOPE), so an explicit flag must UNLOCK the
117
- * named envelope scope in addition to the normal set rather than narrow
118
- * the result to it — narrowing would return zero rows for every
119
- * tag-scoped workflow (envelope scope NULL). Strictly safer than the
120
- * pre-v1.25.0 CLI behavior (no filter at all): other private scopes and
121
- * quarantine buckets stay denied.
122
- *
123
- * Background pipelines (`consolidate`, `embeddings`, `refine-llm`, ...) call
124
- * `loadSearchEntries` (no scopeFilter arg) and see all rows including
125
- * quarantine.
126
- */
127
- /** @internal v1.7.2 — internal SQL-builder shape; not on the public API
128
- * surface (not re-exported from `src/index.ts`). Subject to change. */
129
- export type RecallScopeFilter = {
130
- mode: 'default-deny';
131
- } | {
132
- mode: 'exact';
133
- value: string;
134
- } | {
135
- mode: 'default-deny-or-exact';
136
- value: string;
137
- };
138
- export declare function removeEntryMirrors(hippoRoot: string, id: string): void;
139
- /**
140
- * AT1 mirror-purge honesty fix (docs/plans/2026-08-15-at1-rejected-value-tombstone.md):
141
- * the candidate markdown mirror paths still on disk for `id`, computed the
142
- * same way `removeEntryMirrors` walks them (one per layer: buffer/episodic/
143
- * semantic), filtered to the ones that still `fs.existsSync`. Used to report
144
- * an EXPLICIT path when a best-effort purge fails and no reaper exists to
145
- * retry it — plain `removeEntryMirrors` returns void, giving no way to name
146
- * which file is stuck.
147
- */
148
- export declare function getExistingEntryMirrorPaths(hippoRoot: string, id: string): string[];
149
- /**
150
- * AT1 fix: best-effort markdown-mirror purge shared by `reject-flow.ts`'s
151
- * `rejectValue` and `resolveConflict`'s post-commit purge. Both used to log
152
- * "will retry via reaper on next open" for EVERY failure, but the reaper
153
- * (`cleanupArchivedMirrors`, raw-archive-mirror-cleanup.ts) only scans
154
- * `raw_archive` — that message was false for a non-raw id, which has no
155
- * reaper at all.
156
- *
157
- * Retries the unlink once synchronously (the common real-world failure is a
158
- * transient lock/AV-scanner false positive, not a permanent one). On a
159
- * second failure: raw ids still get the honest reaper message (true); non-raw
160
- * ids get the EXPLICIT leftover file path(s) and a manual-delete instruction,
161
- * since nothing will ever retry them automatically.
162
- *
163
- * Returns true if the mirror ended up purged (first or second attempt).
164
- */
165
- export declare function purgeMirrorBestEffort(hippoRoot: string, id: string, isRaw: boolean, logPrefix: string): boolean;
166
- /** Named field set for the legacy `stats.json` mirror — the only fields any
167
- * caller reads (see loadLegacyStatsFile's callers below). */
168
- interface LegacyStats {
169
- [key: string]: JsonValue;
170
- total_remembered: JsonValue;
171
- total_recalled: JsonValue;
172
- total_forgotten: JsonValue;
173
- consolidation_runs: JsonValue;
174
- }
175
- /** Derive the current `HippoIndex` from SQLite. Exported for `rebuildIndex`
176
- * (the only index.json writer) and the longmemeval benchmark. */
177
- export declare function buildIndexFromDb(db: ReturnType<typeof openHippoDb>): HippoIndex;
178
- /** Write the `index.json` mirror file for an already-derived index. Exported for
179
- * `rebuildIndex` (the only index.json writer) and the longmemeval benchmark. */
180
- export declare function writeIndexMirror(hippoRoot: string, index: HippoIndex): void;
181
- /** Load the derived index from SQLite. Read-only: index.json is only ever written by `rebuildIndex`. */
182
- export declare function loadIndex(hippoRoot: string): HippoIndex;
183
- /**
184
- * Persist mutable index metadata. Entry rows themselves are derived from SQLite.
185
- *
186
- * LC1 F1(c) structural fix: `last_retrieval_ids` and `last_trace_id` must
187
- * land atomically — callers (getContext, cmdRecall) fold a freshly-written
188
- * trace id into `index.last_trace_id` before calling this, relying on BOTH
189
- * meta keys committing together. Wrapped in BEGIN/COMMIT so a crash or a
190
- * mid-write failure can never advance one key without the other. index.json
191
- * is left untouched; only `rebuildIndex` writes it.
192
- */
193
- export declare function saveIndex(hippoRoot: string, index: HippoIndex): void;
194
- /**
195
- * Write a memory entry to SQLite and refresh compatibility mirrors.
196
- *
197
- * `opts.actor` defaults to 'cli' so unauthenticated direct-CLI callers still
198
- * get the right audit attribution. The HTTP server (A1) and api.* layer pass
199
- * the resolved actor (`api_key:<key_id>` / `localhost:cli`) so audit events
200
- * land with one row per write, no double-emit.
201
- *
202
- * `opts.afterWrite` is invoked inside the same SAVEPOINT as the memories
203
- * INSERT (mirrors archiveRawMemory's shape in raw-archive.ts). On callback
204
- * throw, the SAVEPOINT rolls back — the memory row never lands, and the
205
- * filesystem mirrors / audit emit never run. Used by E1.3+ connectors to
206
- * stamp idempotency rows atomically with the memory write.
207
- */
208
- /**
209
- * Stamp origin_project from the store's own location when the entry has
210
- * never been stamped (v39 memory scope isolation). The store dir is
211
- * `<project>/.hippo`, so its parent resolves to the owning project; the
212
- * home/global store resolves to '' (user-global). Callers that know a better
213
- * origin (shareMemory, syncGlobalToLocal) set entry.origin_project before
214
- * writing and this is a no-op. Returns a stamped copy; never mutates.
215
- *
216
- * NULL is deliberately PRESERVED, not re-stamped: null means "legacy row the
217
- * v39 migration found no evidence for" and is deny-by-default in ambient
218
- * context. A writeback (e.g. markRetrieved on a crossProject-included row)
219
- * must not launder it into an injectable origin - the migration is the only
220
- * evidence-based NULL converter (codex gating round 2 P1).
221
- */
222
- export declare function stampOriginProject(hippoRoot: string, entry: MemoryEntry): MemoryEntry;
223
- export declare function writeEntry(hippoRoot: string, entry: MemoryEntry, opts?: {
224
- actor?: string;
225
- afterWrite?: (db: DatabaseSyncLike, memoryId: string) => void;
226
- /** Runs AFTER the DB row commits (RELEASE SAVEPOINT in writeEntryDbOnly) but
227
- * BEFORE the markdown mirrors are written. Lets a caller perform a post-commit
228
- * side effect (e.g. mark the graph dirty) that must still happen even if a
229
- * mirror write then throws. Keep it best-effort — it runs on a committed,
230
- * idle connection, so opening another handle inside it is safe. */
231
- afterCommit?: () => void;
232
- }): void;
233
- /**
234
- * DB-only write path. Caller owns the open `db` handle. Runs SAVEPOINT +
235
- * upsert + afterWrite hook + audit row inside the SAVEPOINT scope. Caller
236
- * is responsible for opening `db`, optionally wrapping in a larger BEGIN/
237
- * COMMIT (e.g. supersede's BEGIN IMMEDIATE), closing `db`, AND calling
238
- * `writeEntryMirrors` after the larger tx commits — mirrors must run
239
- * post-commit so a rolled-back tx never leaves orphan markdown.
240
- *
241
- * Audit-order note: the audit row is emitted INSIDE the SAVEPOINT, so audit
242
- * commits atomically with the row INSERT. A subsequent mirror failure cannot
243
- * leave a recorded audit entry without its corresponding DB row. This is a
244
- * documented hardening over the prior writeEntry-as-monolith ordering.
245
- */
246
- export declare function writeEntryDbOnly(db: DatabaseSyncLike, entry: MemoryEntry, opts?: {
247
- actor?: string;
248
- afterWrite?: (db: DatabaseSyncLike, memoryId: string) => void;
249
- }): void;
250
- /** Markdown mirror path, invoked AFTER commit (a rolled-back tx must leave no orphan markdown). */
251
- export declare function writeEntryMirrors(hippoRoot: string, entry: MemoryEntry): void;
252
- /**
253
- * Read a memory entry by ID.
254
- *
255
- * When `tenantId` is provided, the read is scoped to that tenant (cross-tenant
256
- * lookups return null). When omitted, no tenant filter is applied — preserves
257
- * legacy single-tenant callers and the writeEntry/readEntry round-trip.
258
- */
259
- export declare function readEntry(hippoRoot: string, id: string, tenantId?: string): MemoryEntry | null;
260
- /**
261
- * Batched lookup. Caps at 500 ids per call to keep the IN(?,?,...) clause
262
- * within SQLite limits. Tenant filter is enforced when `tenantId` is passed.
263
- * Used by DAG-aware recall (docs/plans/2026-05-05-dag-recall.md Task 1.5)
264
- * to fetch parent summaries for a set of overflowed leaves.
265
- */
266
- export declare function loadEntriesByIds(hippoRoot: string, ids: readonly string[], tenantId?: string): MemoryEntry[];
267
- /** Strengthen what a read returned: update only the four retrieval columns on the live row, never a stale copy.
268
- * Best effort: a failure logs and never fails the read. Returns the ids found in this store. */
269
- export declare function strengthenRetrieved(hippoRoot: string, ids: readonly string[], tenantId?: string): Set<string>;
270
- /** strengthenRetrieved on the caller's handle, inside the caller's transaction. Throws; the caller decides. */
271
- export declare function strengthenRetrievedOn(db: DatabaseSyncLike, ids: readonly string[], tenantId?: string): Set<string>;
272
- /**
273
- * All `kind='raw'` rows for a given session, tenant-scoped, returned
274
- * oldest-first. Used by `api.assemble` to walk a session's chronological
275
- * context. Excludes superseded rows.
276
- *
277
- * Cap semantics (v1.6.2 codex fix): when `cap` is provided, the NEWEST
278
- * `cap` rows are loaded — `ORDER BY created DESC LIMIT cap` server-side,
279
- * reversed to oldest-first client-side. Pre-v1.6.2 ordered ASC + LIMIT,
280
- * which silently dropped the newest rows and broke fresh-tail in assemble.
281
- *
282
- * Returns `[]` for an empty sessionId. Final order: `created ASC, id ASC`.
283
- */
284
- export declare function loadSessionRawMemories(hippoRoot: string, sessionId: string, tenantId?: string, cap?: number): MemoryEntry[];
285
- /**
286
- * Pre-cap, scope-aware row count for a session. Lets `assemble` report
287
- * the full session size even when `rowCap` truncates the loaded window,
288
- * WITHOUT leaking rows the caller wouldn't have been allowed to load.
289
- *
290
- * v1.6.3 codex P1 / senior P0: an earlier draft of this helper ran an
291
- * unscoped COUNT, which let a no-scope caller infer the existence of
292
- * private rows by comparing `totalRaw` against `items.length`. This
293
- * version SQL-encodes the same default-deny rule `passesScopeFilterForRecall`
294
- * applies in TS:
295
- * - explicit scope passed: exact-match
296
- * - no scope: rows where scope IS NULL, or scope is NOT a `<source>:private:*`
297
- * pattern AND not the `unknown:legacy` quarantine bucket.
298
- *
299
- * `tenantId` is optional for back-compat. Pass `undefined` only when
300
- * intentionally counting cross-tenant; `assemble()` passes `ctx.tenantId`.
301
- */
302
- export declare function countSessionRawMemories(hippoRoot: string, sessionId: string, tenantId?: string, scope?: string): number;
303
- /**
304
- * Last N kind='raw' memories by `created` desc. Tenant scoped. When
305
- * `sessionId` is supplied, also constrains to a specific session — that
306
- * is the correct shape for "what did I just see in THIS session."
307
- *
308
- * v1.6.2 codex review fix: pre-v1.6.2 was tenant-wide only. With multiple
309
- * concurrent sessions in a tenant, fresh-tail recall surfaced unrelated
310
- * rows from other sessions and stamped them `isFreshTail=true`. Callers
311
- * that want session-scoped fresh-tail now pass `sessionId`. The
312
- * tenant-wide form (no sessionId) still exists for "anything new across
313
- * the whole tenant" — pass undefined to opt in.
314
- *
315
- * Bounded count cap at 200 — beyond that the caller should filter via
316
- * tags/scope rather than time-windowed recall.
317
- *
318
- * Deprecation note (v1.6.5) — the **tenant-wide call shape** (omitting
319
- * `sessionId`) is rarely the right shape for "what did I just see in this
320
- * conversation". `api.recall` enforces session scoping when
321
- * `HIPPO_REQUIRE_SESSION_SCOPED_FRESH_TAIL=1` is set, throwing
322
- * `RecallContractError` instead. Tenant-wide remains the back-compat default
323
- * but is discouraged for new callers. Passing `sessionId` is fully supported
324
- * and recommended; this function is NOT deprecated as a whole.
325
- */
326
- export declare function loadFreshRawMemories(hippoRoot: string, count: number, tenantId?: string, sessionId?: string): MemoryEntry[];
327
- /**
328
- * Direct DAG children of a parent summary. Tenant scoped. Returns only rows
329
- * whose `dag_parent_id` matches `parentId`; does NOT walk recursively.
330
- * Used by `drillDown` (Task 3).
331
- */
332
- export declare function loadChildrenOf(hippoRoot: string, parentId: string, tenantId?: string): MemoryEntry[];
333
- /** Tables whose rows keep a first-class object's backing memory in `memory_id` (ON DELETE SET NULL); tests/dormant-memories.test.ts pins it to the schema. */
334
- export declare const MEMORY_BACKED_TABLES: readonly ["predictions", "decisions", "incidents", "processes", "policies", "skills", "project_briefs", "customer_notes"];
335
- /** Ids of memories that back a first-class object, for passes that plan deletes before making them. A table missing from an older schema is skipped. */
336
- export declare function memoriesBackingObjects(hippoRoot: string): Set<string>;
337
- /**
338
- * AT1 (plan §4, round-2 fix, designed from source): db-scoped delete core.
339
- * `deleteEntry` used to open+close its OWN connection, which meant it could
340
- * never compose inside a caller's transaction (unlike writeEntry/
341
- * writeEntryDbOnly, which already split this way). Split identically: row-
342
- * meta SELECT, `DELETE FROM memories`, FTS delete, `forget` audit, DAG
343
- * dirty-mark. NO filesystem I/O — the caller's own transaction may still be
344
- * rolled back, and mirror writes must only happen post-commit.
345
- *
346
- * `opts.suppressForgetAudit` (default false, off): two AT1 callers set this
347
- * so a removed non-raw row does NOT ALSO emit a `forget` row, because each
348
- * already writes its own aggregate audit trail — `src/reject-flow.ts`'s
349
- * `rejectValue` (single `reject_value` row covering every same-digest row
350
- * removed) and `resolveConflict` (`conflict_resolve` row per resolution).
351
- * Default keeps `deleteEntry` byte-identical to its pre-split behavior.
352
- *
353
- * Returns `{tenantId, dagParentId}` for the removed row, or `null` if no row with `id`
354
- * existed or `automatic` refused it (pinned, raw, kept for good or backing an object at DELETE time, so a late pin wins).
355
- */
356
- export declare function deleteEntryCore(db: ReturnType<typeof openHippoDb>, id: string, opts?: {
357
- actor?: string;
358
- suppressForgetAudit?: boolean;
359
- reason?: string;
360
- automatic?: boolean;
361
- }): {
362
- tenantId: string;
363
- dagParentId: string | null;
364
- } | null;
365
- /**
366
- * Delete an entry from SQLite and mirrors.
367
- *
368
- * `opts.actor` defaults to 'cli'. The api.* layer threads `ctx.actor` so HTTP
369
- * callers land with `api_key:<key_id>` in the audit log without a duplicate
370
- * emit from the api wrapper.
371
- *
372
- * Thin wrapper over `deleteEntryCore` (open → core → mirrors → close);
373
- * behavior is byte-identical to the pre-split implementation for every
374
- * existing caller.
375
- */
376
- export declare function deleteEntry(hippoRoot: string, id: string, opts?: {
377
- actor?: string;
378
- reason?: string;
379
- automatic?: boolean;
380
- }): boolean;
381
- /** Consolidation's flush, one transaction. With `snapshot` (rows as the caller loaded them), a write keeps only
382
- * the fields the caller changed, takes the rest from the live row, and never resurrects a row that is gone.
383
- *
384
- * `dormant` (src/dormant.ts): each move's snapshot is inserted into `dormant_memories` and its `memories` row
385
- * leaves exactly like a delete (FTS row, DAG parent dirty-mark, mirrors), in the same transaction, so a memory
386
- * is never in both places or in neither. Deletes and moves both skip rows that are no longer auto-deletable
387
- * (pinned, raw, kept for good or backing an object since the caller decided). Returns the ids that left `memories`, deleted or moved. */
388
- export declare function batchWriteAndDelete(hippoRoot: string, toWrite: MemoryEntry[], toDeleteIds: string[], opts?: {
389
- snapshot?: ReadonlyMap<string, MemoryEntry>;
390
- dormant?: DormantMove[];
391
- }): string[];
392
- /**
393
- * Load all entries from SQLite.
394
- *
395
- * When `tenantId` is provided, results are scoped to that tenant. Omitting it
396
- * yields all rows (legacy behavior used by consolidate/autolearn etc.). Recall
397
- * paths that surface results to a user MUST pass a resolved tenant.
398
- */
399
- export declare function loadAllEntries(hippoRoot: string, tenantId?: string): MemoryEntry[];
400
- /** Every memory row on an open connection, so a caller can read inside its own transaction. */
401
- export declare function selectAllEntries(db: DatabaseSyncLike, tenantId?: string): MemoryEntry[];
402
- /** Live rows whose source starts with `prefix`, on the caller's handle; LIKE folds case, so the prefix is checked again exactly. */
403
- export declare function selectLiveEntriesBySourcePrefix(db: DatabaseSyncLike, tenantId: string, prefix: string): MemoryEntry[];
404
- /** Rewrites a live row's tags and its full-text row on the caller's transaction, with no audit row. */
405
- export declare function setEntryTagsInTx(db: DatabaseSyncLike, entry: MemoryEntry): void;
406
- /** Removes a row from `memories` and full-text search on the caller's transaction, as sleep's dormant move does, and marks its summary parent dirty. */
407
- export declare function deleteEntryRowInTx(db: DatabaseSyncLike, entry: MemoryEntry, actor: string): void;
408
- export declare function loadContentsWithTag(hippoRoot: string, tenantId: string, tag: string): string[];
409
- export interface AmbientRecallRequest {
410
- terms: string[];
411
- limit: number;
412
- }
413
- export interface AmbientLoadResult {
414
- entries: MemoryEntry[];
415
- recall?: MemoryEntry[];
416
- }
417
- /** Exported so the plan test runs the exact SQL; idx_memories_pinned (db.ts v51) serves it. */
418
- export declare const AMBIENT_PINNED_WHERE = "pinned = 1 AND superseded_by IS NULL AND tenant_id = ? ORDER BY created ASC, id ASC";
419
- /** Exported so the plan test runs the exact SQL; idx_memories_created_drift (db.ts v51) serves it. */
420
- export declare const AMBIENT_DRIFT_SQL = "SELECT 1 FROM memories WHERE superseded_by IS NULL AND tenant_id = ? AND (length(created) <> 24 OR created NOT LIKE '%Z') LIMIT 1";
421
- export declare function loadAmbientCandidates(hippoRoot: string, tenantId: string, recentNeeded: number, admit: (e: MemoryEntry) => boolean, recall?: AmbientRecallRequest): AmbientLoadResult;
422
- /** The rows a non-pinned context read may admit; each predicate is one getContext's admission applies again in JS. */
423
- export interface ContextCandidateFilter {
424
- /** Envelope scope asked for by name; absent applies recall's default deny. */
425
- exactScope?: string;
426
- /** Rows of this project and user-global rows pass; absent admits every origin. */
427
- project?: string;
428
- /** Most rows returned; past it, the rows decay has worn least win. */
429
- cap: number;
430
- now: Date;
431
- }
432
- /** Live tenant rows passing `filter`, at most `filter.cap`, in loadAllEntries' order; below the cap, every such row. */
433
- export declare function loadContextCandidates(hippoRoot: string, tenantId: string, filter: ContextCandidateFilter): MemoryEntry[];
434
- /** A row's strength inputs and tags, without its text or the JSON lists a full row parses. */
435
- export type StrengthRow = StrengthInputs & Pick<MemoryEntry, 'tags'>;
436
- /** Every tenant row as a StrengthRow, for whole-store health numbers; defaults match rowToEntry's. */
437
- export declare function loadStrengthRows(hippoRoot: string, tenantId: string): StrengthRow[];
438
- /** Text and source of tenant rows holding any of `words`; a row equal to a text apart from spacing holds its every word. */
439
- export declare function loadTextsHoldingWords(hippoRoot: string, tenantId: string, words: readonly string[]): Array<Pick<MemoryEntry, 'content' | 'source'>>;
440
- export interface SourceTally {
441
- source: string;
442
- count: number;
443
- latest: string;
444
- /** `created`, a unit separator, then `id` of the source's first row in loadAllEntries' order. */
445
- first: string;
446
- }
447
- /** Row count and newest `created` per source, for peer listings that need no row; all tenants when `tenantId` is absent. */
448
- export declare function tallySources(hippoRoot: string, tenantId?: string): SourceTally[];
449
- /**
450
- * Load likely search candidates directly from SQLite.
451
- * Uses FTS5 when available, falls back to LIKE matching, then full-store fallback.
452
- *
453
- * When `tenantId` is provided, every SELECT (FTS join, LIKE, fallback) filters
454
- * by tenant_id. Cross-tenant memories never surface. Omitted = no filter.
455
- */
456
- export declare function loadSearchEntries(hippoRoot: string, query: string, limit?: number, tenantId?: string): MemoryEntry[];
457
- /**
458
- * v1.7.1 — recall-mode loader. Pushes the recall-side scope predicate into
459
- * SQL so `unknown:legacy` cannot leak via any consumer that hasn't remembered
460
- * to re-filter (root-cause-over-patches: codex flagged this on v1.6.5 review).
461
- *
462
- * - `requestedScope` undefined / '': default-deny on `unknown:legacy`.
463
- * - `requestedScope` non-empty string: exact match on `m.scope = requestedScope`.
464
- *
465
- * Private-scope (`<source>:private:*`) exclusion: SQL applies a conservative
466
- * pre-window approximation (`NOT LIKE '%:private:%'`, v1.25.0 — codex P2:
467
- * post-window-only filtering let private rows starve admitted candidates out
468
- * of the LIMIT window); the exact anchored regex
469
- * (`passesScopeFilterForRecall`) remains the authoritative JS post-filter in
470
- * the recall consumers.
471
- *
472
- * Consumers: `api.recall` (v1.7.1+), `cmdRecall`/`cmdExplain` direct CLI paths
473
- * and `searchBothHybrid` recall mode (v1.25.0). Background pipelines
474
- * (`consolidate`, `embeddings`, `refine-llm`, ...) keep using
475
- * `loadSearchEntries` so they can see quarantined rows when needed.
476
- *
477
- * `tenantId` widened to optional in v1.25.0 for the searchBothHybrid recall
478
- * mode (its `tenantId` option is optional); `loadSearchRows` already treats
479
- * undefined as "no tenant filter" for legacy callers.
480
- */
481
- export declare function loadRecallSearchEntries(hippoRoot: string, query: string, limit?: number, tenantId?: string, requestedScope?: string, explicitScopeMode?: 'exact' | 'additive', includeSuperseded?: boolean): MemoryEntry[];
482
- export declare function loadRecallSearchEntriesFromDb(db: DatabaseSyncLike, query: string, limit?: number, tenantId?: string, requestedScope?: string, explicitScopeMode?: 'exact' | 'additive', includeSuperseded?: boolean): MemoryEntry[];
483
- /** Rarest-K prompt terms for this connection's FTS index, as a space-joined query string.
484
- * Without FTS, returns the first 32 terms, as before rarest-term selection. */
485
- export declare function pickRarestFtsQuery(db: DatabaseSyncLike, terms: readonly string[], maxTerms?: number): string;
486
- /**
487
- * Rebuild mirrors from SQLite, importing any legacy markdown files not already present.
488
- */
489
- export declare function rebuildIndex(hippoRoot: string): HippoIndex;
490
- export declare function updateStats(hippoRoot: string, delta: {
491
- remembered?: number;
492
- recalled?: number;
493
- forgotten?: number;
494
- }): void;
495
- export declare function loadStats(hippoRoot: string): LegacyStats;
496
- export declare function appendConsolidationRun(hippoRoot: string, run: {
497
- timestamp: string;
498
- decayed: number;
499
- merged: number;
500
- removed: number;
501
- }): void;
502
- /** Rows a tenant created since the last sleep (runs are host-wide), looking back at most 24 hours. */
503
- export declare function countCreatedSinceLastSleep(hippoRoot: string, tenantId: string, now?: Date): number;
504
- /**
505
- * Session decay context: provides the data needed for session-based and adaptive decay.
506
- */
507
- export interface SessionDecayContext {
508
- /** Total number of sleep (consolidation) cycles completed. */
509
- sleepCount: number;
510
- /** Average interval between recent sleep cycles, in days. 0 if < 2 cycles. */
511
- avgSessionIntervalDays: number;
512
- }
513
- /**
514
- * Load the session decay context from the store.
515
- * Uses consolidation_runs timestamps to compute session intervals.
516
- */
517
- export declare function loadSessionDecayContext(hippoRoot: string): SessionDecayContext;
518
- /**
519
- * Increment the sleep counter. Called after each consolidation run.
520
- */
521
- export declare function incrementSleepCount(hippoRoot: string): void;
522
- export declare function saveActiveTaskSnapshot(hippoRoot: string, tenantId: string, snapshot: {
523
- task: string;
524
- summary: string;
525
- next_step: string;
526
- source?: string;
527
- session_id?: string | null;
528
- scope?: string | null;
529
- }): TaskSnapshot;
530
- export declare function loadActiveTaskSnapshot(hippoRoot: string, tenantId: string): TaskSnapshot | null;
531
- /**
532
- * Default freshness bound for AMBIENT active-task-snapshot reads (DF1,
533
- * docs/plans/2026-08-23-df1-snapshot-lifecycle.md): 72h, chosen over 48h so
534
- * a Friday-evening orphan still offers continuity on Monday morning.
535
- * Exported so callers can override via `loadFreshActiveTaskSnapshot`'s
536
- * `opts.maxAgeMs`; deliberately no env knob (Simplicity First).
537
- */
538
- export declare const SNAPSHOT_AMBIENT_MAX_AGE_MS: number;
539
- /**
540
- * Bounded read for AMBIENT active-task-snapshot surfaces (UserPromptSubmit
541
- * hook context, MCP recall block) — the never-expires fix for DF1. A
542
- * snapshot written by `hippo pre-compact` has no death path tied to the
543
- * session that owns it, so an orphaned row would otherwise inject into
544
- * every prompt of every later session forever. Wraps `loadActiveTaskSnapshot`
545
- * (unchanged, still the source of truth for explicit continuity surfaces),
546
- * then applies, in order:
547
- *
548
- * 1. Owner match — ONLY when both `opts.sessionId` and the snapshot's
549
- * `session_id` are non-null, non-empty strings and strictly equal
550
- * (`===`). Owner reads are unbounded: the session that owns the snapshot
551
- * can always see its own working state, regardless of age.
552
- * 2. Age check — everything else, including absent-vs-absent ids. A
553
- * null/undefined/empty id on EITHER side never counts as an owner match;
554
- * it falls through here instead. (`runPreCompact` can legitimately save a
555
- * snapshot with `session_id = null`; a null-equals-null "match" would
556
- * reopen indefinite ambient injection for exactly those rows.) Returns
557
- * the snapshot only when `age(updated_at) <= maxAgeMs` (default
558
- * `SNAPSHOT_AMBIENT_MAX_AGE_MS`); otherwise null.
559
- *
560
- * No SQL change — age derives from the existing `updated_at` column.
561
- */
562
- export declare function loadFreshActiveTaskSnapshot(hippoRoot: string, tenantId: string, opts?: {
563
- maxAgeMs?: number;
564
- sessionId?: string | null;
565
- }): TaskSnapshot | null;
566
- export declare function clearActiveTaskSnapshot(hippoRoot: string, tenantId: string, clearedStatus?: string): boolean;
567
- /**
568
- * Close the `active` task snapshot(s) owned by `sessionId`, for the T3
569
- * session-end death path (DF1, docs/plans/2026-08-23-df1-snapshot-lifecycle.md).
570
- * Only one `active` row exists per tenant in practice (supersession happens
571
- * at save), but the WHERE clause scopes on `session_id` too — not just
572
- * `status='active' AND tenant_id=?` — so an ending session can never close a
573
- * different, newer session's active snapshot. Returns the number of rows
574
- * closed (0 when no active row is owned by `sessionId`).
575
- */
576
- export declare function closeTaskSnapshotsForSession(hippoRoot: string, tenantId: string, sessionId: string, status?: string): number;
577
- export declare function appendSessionEvent(hippoRoot: string, tenantId: string, event: {
578
- session_id: string;
579
- event_type: string;
580
- content: string;
581
- task?: string | null;
582
- source?: string;
583
- scope?: string | null;
584
- metadata?: Record<string, unknown>;
585
- }): SessionEvent;
586
- export declare function listSessionEvents(hippoRoot: string, tenantId: string, options?: {
587
- session_id?: string;
588
- task?: string;
589
- limit?: number;
590
- }): SessionEvent[];
591
- /**
592
- * Return session_ids with a `session_complete` event newer than `sinceMs`.
593
- * Used by the sleep auto-promotion pass to bound scanning to a fixed window.
594
- */
595
- export declare function findPromotableSessions(hippoRoot: string, tenantId: string, sinceMs: number): Array<{
596
- session_id: string;
597
- }>;
598
- /**
599
- * Idempotency guard — true if a trace-layer memory with this source_session_id
600
- * already exists.
601
- */
602
- export declare function traceExistsForSession(hippoRoot: string, tenantId: string, session_id: string): boolean;
603
- export declare function listMemoryConflicts(hippoRoot: string, status?: string, tenantId?: string): MemoryConflict[];
604
- export declare function replaceDetectedConflicts(hippoRoot: string, detected: Array<{
605
- memory_a_id: string;
606
- memory_b_id: string;
607
- reason: string;
608
- score: number;
609
- }>, detectedAt?: string): void;
610
- /**
611
- * AT1 (plan §5): additive-optional opts for resolveConflict.
612
- * `rejectLoserValue` implies removal of the loser regardless of
613
- * `forgetLoser` — you cannot tombstone a value and leave it live.
614
- */
615
- export interface ResolveConflictOpts {
616
- /** Tombstone the loser's normalized digest + kind-aware remove it. */
617
- rejectLoserValue?: boolean;
618
- /** Actor for the tombstone + the new conflict_resolve audit row. Defaults to 'cli'. */
619
- rejectedBy?: string;
620
- /** Reason recorded on the tombstone (and passed to archiveRawMemory if the
621
- * loser is kind='raw'). Defaults to a conflict-context string. */
622
- reason?: string;
623
- }
624
- /**
625
- * Resolve a conflict by keeping one memory and weakening the other.
626
- * Sets conflict status to 'resolved' and halves the loser's half-life.
627
- * If --forget is used, the loser is removed entirely (kind-aware: raw rows
628
- * are archived via archiveRawMemory, others deleted via deleteEntryCore —
629
- * AT1 fix for the pre-existing crash where a raw loser aborted the whole
630
- * resolve transaction against the append-only trigger). `opts.rejectLoserValue`
631
- * additionally tombstones the loser's normalized digest so it cannot be
632
- * re-asserted later.
633
- *
634
- * Every resolution path (weaken / forget / reject) emits a `conflict_resolve`
635
- * audit row (AT1 — previously resolveConflict wrote zero audit rows on any path).
636
- *
637
- * Returns the resolved conflict, or null if not found.
638
- */
639
- export declare function resolveConflict(hippoRoot: string, conflictId: number, keepId: string, forgetLoser?: boolean, tenantId?: string, opts?: ResolveConflictOpts): {
640
- conflict: MemoryConflict;
641
- loserId: string;
642
- } | null;
643
- /** Column list shared by every session_handoffs SELECT; store-cards.ts reuses it for the card handoff lookup. */
644
- export declare const HANDOFF_COLUMNS = "id, session_id, repo_root, task_id, summary, next_action, artifacts_json, scope, created_at, constraints_json, evidence_json, outcome, target_runtime, card_id";
645
- /**
646
- * Save a session handoff record. Returns the persisted handoff.
647
- */
648
- export declare function saveSessionHandoff(hippoRoot: string, tenantId: string, handoff: Omit<SessionHandoff, 'updatedAt'>): SessionHandoff;
649
- /** Load the most recent handoff, optionally filtered by session ID. */
650
- export declare function loadLatestHandoff(hippoRoot: string, tenantId: string, sessionId?: string, opts?: {
651
- unfinishedOnly?: boolean;
652
- maxAgeMs?: number;
653
- scopeFilter?: 'default-deny';
654
- excludeSessionId?: string;
655
- }): SessionHandoff | null;
656
- /**
657
- * Load a specific handoff by its row ID.
658
- */
659
- export declare function loadHandoffById(hippoRoot: string, tenantId: string, id: number): SessionHandoff | null;
660
- /** Stamp the outcome on a session's newest handoff, only if it has none yet. Returns rows changed. */
661
- export declare function stampHandoffOutcome(hippoRoot: string, tenantId: string, sessionId: string, outcome: HandoffOutcome): number;
662
- /** Auto-write a handoff at session-end (DF1 T3) from the session's active snapshot, else from `derived`, its transcript state.
663
- * @param evidence best-effort git state; outcome comes from the newest session_complete event.
664
- * @returns null when neither source is the session's, a newer handoff covers the snapshot, or the session's latest handoff was not read off its transcript. */
665
- export declare function writeSessionEndHandoff(hippoRoot: string, tenantId: string, sessionId: string, evidence: HandoffEvidence | null, derived?: Pick<TaskSnapshot, 'task' | 'summary' | 'next_step'> | null): SessionHandoff | null;
666
- /**
667
- * Load summaries flagged dirty for the given tenant. Sorted by latest_at
668
- * DESC (NULLS LAST) so E3's rebuild cap (HIPPO_DAG_REBUILD_CAP, default 20)
669
- * takes the most-recently-changed summaries first.
670
- *
671
- * Returns full MemoryEntry shape via MEMORY_SELECT_COLUMNS + rowToEntry
672
- * (v28 fields are part of the standard read path).
673
- */
674
- export declare function loadDirtySummaries(hippoRoot: string, tenantId: string): MemoryEntry[];
675
- /**
676
- * v0.30 / E2 — in-transaction variant of markSummaryDirty. Takes an open
677
- * db (caller is responsible for any SAVEPOINT/BEGIN). Used by E2's hook
678
- * sites: writeEntryDbOnly, api.supersede CAS, deleteEntry, archiveRawMemory,
679
- * batchWriteAndDelete. Each child mutation's dirty-mark is atomic with the
680
- * mutation itself (where the mutation IS in a SAVEPOINT/BEGIN — deleteEntry
681
- * is the exception, acceptably non-atomic by design).
682
- *
683
- * EXPORTED (required for cross-module use by api.ts + raw-archive.ts).
684
- * Risk of misuse (caller without open tx) is mitigated by the InTx
685
- * suffix + the DatabaseSyncLike typed param. Public surface for end users
686
- * stays at the markSummaryDirty (own-connection) variant.
687
- *
688
- * Same idempotency contract: 0->1 transition only, audit row only on
689
- * transition, no-op on non-summary / archived / unknown id / cross-tenant.
690
- */
691
- export declare function markSummaryDirtyInTx(db: DatabaseSyncLike, summaryId: string, tenantId: string, actor: string): void;
692
- /**
693
- * Mark a summary as dirty. Idempotent (re-marking dirty is a no-op + no
694
- * second audit row). Tenant-scoped to prevent cross-tenant writes via
695
- * parent-lookup. Called by E2 from invalidation.ts / writeEntry /
696
- * forgetMemory / archiveRawMemory whenever a child is invalidated,
697
- * superseded, forgotten, or archived.
698
- *
699
- * Quietly no-ops if the target row doesn't exist or isn't a level-2
700
- * summary (E5 will widen the dag_level guard to IN (2, 3) when level-3
701
- * build path lands). Emits a 'summary_marked_dirty' audit row on actual
702
- * state transitions (0 -> 1) via the audit() helper, which try/catches
703
- * for missing audit_log (the v27 self-heal scenario).
704
- */
705
- export declare function markSummaryDirty(hippoRoot: string, summaryId: string, tenantId: string, actor?: string): void;
706
- /**
707
- * v0.30 / E5 — host-wide loader for L2 topic summaries without an L3 parent.
708
- * Used by consolidate phase 1.9 (buildEntityProfiles) to cluster L2s into
709
- * L3 entity profiles. Mirrors loadAllDirtySummaries pattern (E3): SQL-level
710
- * filter is cheaper than reusing in-memory `survivors` (which doesn't
711
- * contain L2s freshly created by phase 1.7 buildDag).
712
- *
713
- * Returns entries with tenantId attached so per-cluster writes stay
714
- * tenant-scoped via summary.tenantId.
715
- */
716
- export declare function loadAllL2Summaries(hippoRoot: string): MemoryEntry[];
717
- /**
718
- * v0.30 / E3 — host-wide variant of loadDirtySummaries. Iterates all tenants
719
- * in one query so consolidate.ts (host-wide per L106-109) does not need a
720
- * per-tenant loop. Each returned MemoryEntry carries its own tenantId (via
721
- * rowToEntry), so per-summary children + rebuild UPDATE stay tenant-scoped.
722
- *
723
- * Sort: latest_at DESC NULLS LAST, id ASC — same as per-tenant variant so
724
- * HIPPO_DAG_REBUILD_CAP takes most-recently-changed summaries first.
725
- */
726
- export declare function loadAllDirtySummaries(hippoRoot: string): MemoryEntry[];
727
- /**
728
- * v0.30 / E3 — load live children of a DAG summary. Used by
729
- * rebuildDirtySummaries to regenerate content from the CURRENT child set
730
- * (not the children at create-time). Skips archived. Tenant-scoped
731
- * (defence in depth — dag_parent_id is unique-ish but tenant guard is
732
- * cheap). created column is TEXT NOT NULL since db.ts schema v1.
733
- */
734
- export declare function loadChildrenOfSummary(hippoRoot: string, summaryId: string, tenantId: string): MemoryEntry[];
735
- /**
736
- * v0.30 / E3 — patch applied by applyRebuildResult. Two-branch shape
737
- * (bumpRebuildCount false for zero-child case, true for normal rebuild).
738
- */
739
- export interface RebuildPatch {
740
- content: string;
741
- descendant_count: number;
742
- earliest_at: string | null;
743
- latest_at: string | null;
744
- bumpRebuildCount: boolean;
745
- zeroChildren: boolean;
746
- actor: string;
747
- }
748
- /**
749
- * v0.30 / E3 — apply a rebuild result to a dirty summary. Atomic: one
750
- * prepared UPDATE statement plus syncFtsRow inside one SAVEPOINT.
751
- * WHERE includes `AND summary_dirty = 1` so concurrent sleep's race-loser
752
- * becomes a no-op (no rebuild_count bump, no audit row).
753
- *
754
- * Returns `{ changed, refused }`. `changed` is true when this call's UPDATE
755
- * (content or metadata-only) affected a row; false on race-loss / unknown id
756
- * / archived / wrong dag_level. `refused` is true only when a tombstone hit
757
- * suppressed the content write AND the metadata UPDATE still landed — see
758
- * the return-semantics comment below for the full contract.
759
- */
760
- export declare function applyRebuildResult(hippoRoot: string, summary: MemoryEntry, patch: RebuildPatch): {
761
- changed: boolean;
762
- refused: boolean;
763
- };
764
- /**
765
- * v0.30 / E3 — clear summary_dirty on a freshly-built summary. Called by
766
- * buildDag immediately after the child-link loop finishes. Without this,
767
- * each member's writeEntry call fires markSummaryDirtyInTx on the just-
768
- * created parent (E2 hook at store.ts:1214), and the same sleep cycle's
769
- * E3 rebuild phase would re-rebuild every new summary (2x LLM cost).
770
- *
771
- * Idempotent: no-op + no audit if summary isn't dirty. Audit
772
- * source='buildDag-clean' distinguishes from E3-rebuild source.
773
- */
774
- export declare function clearSummaryDirtyAfterBuild(hippoRoot: string, summaryId: string, tenantId: string, actor?: string, source?: string): void;
775
- export { getHippoDbPath };
776
- //# sourceMappingURL=store.d.ts.map