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