hippo-memory 1.71.0 → 1.72.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 (555) hide show
  1. package/README.md +1 -1
  2. package/dist/agent-memories/apply.d.ts +0 -11
  3. package/dist/agent-memories/apply.js +6 -21
  4. package/dist/agent-memories/claude-code.js +1 -1
  5. package/dist/agent-memories/codex.js +1 -1
  6. package/dist/agent-memories/copilot.d.ts +1 -3
  7. package/dist/agent-memories/copilot.js +1 -17
  8. package/dist/agent-memories/project-folds.d.ts +10 -0
  9. package/dist/agent-memories/project-folds.js +34 -0
  10. package/dist/agent-memories/sync.js +8 -6
  11. package/dist/api/assemble.js +1 -1
  12. package/dist/api/audit.d.ts +29 -1
  13. package/dist/api/audit.js +44 -5
  14. package/dist/api/auth.d.ts +7 -4
  15. package/dist/api/auth.js +12 -8
  16. package/dist/api/auto-sleep.d.ts +5 -2
  17. package/dist/api/auto-sleep.js +7 -3
  18. package/dist/api/availability.js +2 -3
  19. package/dist/api/cards.d.ts +42 -0
  20. package/dist/api/cards.js +52 -0
  21. package/dist/api/conflicts.d.ts +28 -0
  22. package/dist/api/conflicts.js +61 -0
  23. package/dist/api/context-render.js +4 -3
  24. package/dist/api/context-select.js +9 -11
  25. package/dist/api/context.js +17 -8
  26. package/dist/api/continuity.d.ts +47 -0
  27. package/dist/api/continuity.js +66 -0
  28. package/dist/api/dormant.js +4 -2
  29. package/dist/api/drill-down.js +1 -1
  30. package/dist/api/embeddings.d.ts +17 -0
  31. package/dist/api/embeddings.js +28 -0
  32. package/dist/api/error-reply.d.ts +8 -0
  33. package/dist/api/error-reply.js +21 -0
  34. package/dist/api/forget.d.ts +6 -2
  35. package/dist/api/forget.js +18 -7
  36. package/dist/api/goals.d.ts +1 -1
  37. package/dist/api/goals.js +5 -9
  38. package/dist/api/index.d.ts +4 -2
  39. package/dist/api/index.js +4 -2
  40. package/dist/api/instruction-detect.js +5 -1
  41. package/dist/api/learn.d.ts +4 -0
  42. package/dist/api/learn.js +53 -27
  43. package/dist/api/ledger-db.d.ts +2 -6
  44. package/dist/api/ledger-db.js +4 -36
  45. package/dist/api/memories.d.ts +19 -1
  46. package/dist/api/memories.js +39 -0
  47. package/dist/api/objects.d.ts +1 -1
  48. package/dist/api/outcome.js +1 -1
  49. package/dist/api/pilot-arm.d.ts +1 -11
  50. package/dist/api/pilot-arm.js +5 -45
  51. package/dist/api/predictions.d.ts +3 -1
  52. package/dist/api/predictions.js +6 -0
  53. package/dist/api/projects.d.ts +21 -0
  54. package/dist/api/projects.js +24 -0
  55. package/dist/api/promote.js +1 -1
  56. package/dist/api/prompt-hook.d.ts +15 -2
  57. package/dist/api/prompt-hook.js +44 -4
  58. package/dist/api/recall-cli.d.ts +3 -0
  59. package/dist/api/recall-cli.js +13 -4
  60. package/dist/api/recall-core.js +3 -3
  61. package/dist/api/recall-pipeline.js +6 -7
  62. package/dist/api/recall-request.js +1 -1
  63. package/dist/api/recall.d.ts +0 -3
  64. package/dist/api/recall.js +19 -44
  65. package/dist/api/remember-local.js +1 -1
  66. package/dist/api/remember.d.ts +2 -1
  67. package/dist/api/remember.js +3 -2
  68. package/dist/api/session-end.d.ts +22 -0
  69. package/dist/api/session-end.js +101 -0
  70. package/dist/api/sleep-run.d.ts +1 -1
  71. package/dist/api/sleep-run.js +13 -9
  72. package/dist/api/status.d.ts +24 -0
  73. package/dist/api/status.js +40 -0
  74. package/dist/api/store-init.d.ts +4 -0
  75. package/dist/api/store-init.js +9 -0
  76. package/dist/api/tokens.js +1 -1
  77. package/dist/api/types.d.ts +2 -0
  78. package/dist/api/types.js +6 -1
  79. package/dist/capture/caller-session.d.ts +0 -3
  80. package/dist/capture/caller-session.js +1 -12
  81. package/dist/capture/capture-error.d.ts +2 -2
  82. package/dist/capture/capture-error.js +23 -18
  83. package/dist/capture/codex-patch.js +3 -1
  84. package/dist/capture/command.js +36 -95
  85. package/dist/capture/compact.js +10 -5
  86. package/dist/capture/compaction-items-caller.js +11 -20
  87. package/dist/capture/compaction-record.d.ts +7 -93
  88. package/dist/capture/compaction-record.js +29 -426
  89. package/dist/capture/compaction-spool.d.ts +4 -2
  90. package/dist/capture/compaction-spool.js +20 -6
  91. package/dist/capture/copilot-transcript.d.ts +2 -1
  92. package/dist/capture/copilot-transcript.js +2 -1
  93. package/dist/capture/extract.d.ts +5 -2
  94. package/dist/capture/extract.js +4 -3
  95. package/dist/capture/failure-caller.d.ts +1 -1
  96. package/dist/capture/failure-caller.js +21 -16
  97. package/dist/capture/failure-reading.d.ts +2 -1
  98. package/dist/capture/failure-reading.js +7 -9
  99. package/dist/capture/pre-compact-caller.js +5 -4
  100. package/dist/capture/session-digest.js +4 -3
  101. package/dist/capture/session-end-caller.js +2 -1
  102. package/dist/capture/session-worker.js +3 -4
  103. package/dist/capture/transcript.d.ts +2 -1
  104. package/dist/capture/transcript.js +6 -3
  105. package/dist/capture/working-state.d.ts +4 -2
  106. package/dist/capture/working-state.js +4 -2
  107. package/dist/cli/audit-prune.d.ts +0 -25
  108. package/dist/cli/audit-prune.js +1 -27
  109. package/dist/cli/audit.js +13 -13
  110. package/dist/cli/auth.d.ts +1 -1
  111. package/dist/cli/auth.js +12 -13
  112. package/dist/cli/briefs.d.ts +1 -4
  113. package/dist/cli/briefs.js +37 -292
  114. package/dist/cli/card.js +41 -33
  115. package/dist/cli/client.d.ts +5 -0
  116. package/dist/cli/client.js +24 -8
  117. package/dist/cli/compact-resume-payload.js +1 -1
  118. package/dist/cli/context.d.ts +1 -1
  119. package/dist/cli/context.js +12 -12
  120. package/dist/cli/continuity.d.ts +1 -1
  121. package/dist/cli/continuity.js +36 -39
  122. package/dist/cli/curate.d.ts +1 -1
  123. package/dist/cli/curate.js +23 -27
  124. package/dist/cli/dag.d.ts +1 -1
  125. package/dist/cli/dag.js +23 -8
  126. package/dist/cli/decisions.d.ts +0 -2
  127. package/dist/cli/decisions.js +4 -281
  128. package/dist/cli/eval.d.ts +1 -1
  129. package/dist/cli/eval.js +12 -13
  130. package/dist/cli/explain.d.ts +1 -1
  131. package/dist/cli/explain.js +21 -25
  132. package/dist/cli/flag-values.js +16 -6
  133. package/dist/cli/flags.d.ts +0 -289
  134. package/dist/cli/flags.js +3 -138
  135. package/dist/cli/graph.d.ts +3 -0
  136. package/dist/cli/graph.js +83 -0
  137. package/dist/cli/hook-runtime.d.ts +3 -5
  138. package/dist/cli/hook-runtime.js +7 -34
  139. package/dist/cli/incidents.d.ts +3 -0
  140. package/dist/cli/incidents.js +112 -0
  141. package/dist/cli/init.d.ts +1 -1
  142. package/dist/cli/init.js +28 -19
  143. package/dist/cli/install-steps.d.ts +2 -1
  144. package/dist/cli/install-steps.js +11 -3
  145. package/dist/cli/last-sleep.js +1 -1
  146. package/dist/cli/lenient-id.d.ts +2 -0
  147. package/dist/cli/lenient-id.js +13 -0
  148. package/dist/cli/maintenance.d.ts +3 -3
  149. package/dist/cli/maintenance.js +29 -30
  150. package/dist/cli/notes.d.ts +2 -0
  151. package/dist/cli/notes.js +41 -0
  152. package/dist/cli/open-browser.d.ts +14 -0
  153. package/dist/cli/open-browser.js +26 -0
  154. package/dist/cli/playbooks.d.ts +3 -4
  155. package/dist/cli/playbooks.js +126 -290
  156. package/dist/cli/predictions.d.ts +3 -0
  157. package/dist/cli/predictions.js +175 -0
  158. package/dist/cli/print.js +2 -1
  159. package/dist/cli/projects.js +30 -22
  160. package/dist/cli/quality-repair-once.d.ts +1 -1
  161. package/dist/cli/quality-repair-once.js +6 -5
  162. package/dist/cli/recall.js +13 -7
  163. package/dist/cli/refine-llm.js +17 -17
  164. package/dist/cli/remember.js +12 -12
  165. package/dist/cli/scheduler.js +2 -1
  166. package/dist/cli/serve.js +3 -3
  167. package/dist/cli/session-hooks.d.ts +1 -1
  168. package/dist/cli/session-hooks.js +45 -115
  169. package/dist/cli/setup.d.ts +1 -1
  170. package/dist/cli/setup.js +17 -10
  171. package/dist/cli/shared.d.ts +2 -6
  172. package/dist/cli/shared.js +9 -29
  173. package/dist/cli/sleep-render.js +6 -3
  174. package/dist/cli/sleep.js +6 -37
  175. package/dist/cli/status.d.ts +3 -3
  176. package/dist/cli/status.js +32 -35
  177. package/dist/cli/transfer.d.ts +1 -1
  178. package/dist/cli/transfer.js +33 -31
  179. package/dist/cli/usage.d.ts +0 -79
  180. package/dist/cli/usage.js +1 -695
  181. package/dist/cli/verb-row.d.ts +32 -0
  182. package/dist/cli/verb-row.js +6 -0
  183. package/dist/cli/verbs/health.d.ts +27 -0
  184. package/dist/cli/verbs/health.js +232 -0
  185. package/dist/cli/verbs/memory.d.ts +16 -0
  186. package/dist/cli/verbs/memory.js +244 -0
  187. package/dist/cli/verbs/objects.d.ts +20 -0
  188. package/dist/cli/verbs/objects.js +254 -0
  189. package/dist/cli/verbs/sessions.d.ts +31 -0
  190. package/dist/cli/verbs/sessions.js +312 -0
  191. package/dist/cli/verbs.d.ts +81 -0
  192. package/dist/cli/verbs.js +7 -0
  193. package/dist/cli/versioned-verbs.d.ts +51 -0
  194. package/dist/cli/versioned-verbs.js +79 -0
  195. package/dist/cli.d.ts +1 -272
  196. package/dist/cli.js +23 -313
  197. package/dist/connectors/dlq.d.ts +39 -3
  198. package/dist/connectors/dlq.js +37 -3
  199. package/dist/connectors/github/backfill.js +12 -3
  200. package/dist/connectors/github/dlq.js +31 -73
  201. package/dist/connectors/github/ingest.d.ts +2 -6
  202. package/dist/connectors/github/ingest.js +3 -28
  203. package/dist/connectors/github/webhook.d.ts +2 -1
  204. package/dist/connectors/github/webhook.js +33 -2
  205. package/dist/connectors/ingest.d.ts +10 -0
  206. package/dist/connectors/ingest.js +28 -0
  207. package/dist/connectors/slack/dlq.js +49 -71
  208. package/dist/connectors/slack/ingest.d.ts +2 -6
  209. package/dist/connectors/slack/ingest.js +2 -27
  210. package/dist/connectors/slack/webhook.d.ts +2 -1
  211. package/dist/connectors/slack/webhook.js +2 -1
  212. package/dist/consolidate/conflicts.js +1 -1
  213. package/dist/consolidate/dag.js +15 -9
  214. package/dist/consolidate/dedupe.d.ts +7 -0
  215. package/dist/consolidate/dedupe.js +5 -3
  216. package/dist/consolidate/llm-passes.js +45 -19
  217. package/dist/consolidate/memory-value.js +2 -1
  218. package/dist/consolidate/merge.js +2 -2
  219. package/dist/consolidate/physics-pass.d.ts +6 -1
  220. package/dist/consolidate/physics-pass.js +26 -6
  221. package/dist/consolidate/replay.js +11 -4
  222. package/dist/consolidate/sleep.js +8 -5
  223. package/dist/consolidate/traces.js +3 -3
  224. package/dist/core/ablation.d.ts +10 -0
  225. package/dist/core/ablation.js +12 -0
  226. package/dist/{sharing/scope.d.ts → core/active-scope.d.ts} +1 -1
  227. package/dist/{sharing/scope.js → core/active-scope.js} +1 -1
  228. package/dist/core/ambient.d.ts +4 -0
  229. package/dist/core/ambient.js +39 -18
  230. package/dist/core/api-errors.d.ts +16 -0
  231. package/dist/core/api-errors.js +20 -0
  232. package/dist/core/card.js +3 -1
  233. package/dist/core/compaction-timing.d.ts +7 -0
  234. package/dist/core/compaction-timing.js +9 -0
  235. package/dist/core/config.d.ts +1 -1
  236. package/dist/core/config.js +7 -2
  237. package/dist/core/cosine.d.ts +3 -0
  238. package/dist/core/cosine.js +19 -0
  239. package/dist/{store → core}/markdown.d.ts +1 -1
  240. package/dist/{store → core}/markdown.js +2 -2
  241. package/dist/core/memory-audit.d.ts +17 -0
  242. package/dist/core/memory-audit.js +54 -0
  243. package/dist/core/memory.d.ts +10 -4
  244. package/dist/core/memory.js +25 -18
  245. package/dist/{consolidate → core}/merged-row.d.ts +1 -1
  246. package/dist/{consolidate → core}/merged-row.js +1 -1
  247. package/dist/core/physics.js +6 -16
  248. package/dist/core/prediction.d.ts +3 -0
  249. package/dist/core/prediction.js +6 -0
  250. package/dist/core/project-identity.d.ts +3 -0
  251. package/dist/core/project-identity.js +10 -1
  252. package/dist/{store → core}/recall-scope.d.ts +1 -10
  253. package/dist/{store → core}/recall-scope.js +2 -19
  254. package/dist/db/busy.d.ts +2 -7
  255. package/dist/db/busy.js +21 -26
  256. package/dist/db/connect.d.ts +0 -1
  257. package/dist/db/connect.js +5 -6
  258. package/dist/db/index.d.ts +3 -3
  259. package/dist/db/index.js +3 -3
  260. package/dist/db/migrations/index.d.ts +1 -1
  261. package/dist/db/migrations/index.js +3 -1
  262. package/dist/db/migrations/v55.d.ts +3 -0
  263. package/dist/db/migrations/v55.js +17 -0
  264. package/dist/db/open.d.ts +0 -2
  265. package/dist/db/open.js +6 -10
  266. package/dist/db/physics-state.js +3 -3
  267. package/dist/db/tables.d.ts +2 -0
  268. package/dist/db/tables.js +6 -2
  269. package/dist/db/vector-store.js +17 -4
  270. package/dist/db/wal-checkpointer.js +2 -1
  271. package/dist/doctor.js +11 -8
  272. package/dist/embeddings/local.d.ts +62 -0
  273. package/dist/embeddings/local.js +146 -0
  274. package/dist/{store/embeddings → embeddings}/provider.d.ts +5 -2
  275. package/dist/{store/embeddings → embeddings}/provider.js +18 -15
  276. package/dist/embeddings/transformers.d.ts +26 -0
  277. package/dist/embeddings/transformers.js +89 -0
  278. package/dist/entry/session-text.d.ts +1 -1
  279. package/dist/entry/session-text.js +1 -1
  280. package/dist/eval/eval-suite.js +17 -11
  281. package/dist/eval/eval.js +1 -1
  282. package/dist/eval/judgment.js +11 -4
  283. package/dist/graph/extract.js +3 -3
  284. package/dist/graph/recall.js +1 -1
  285. package/dist/graph/view.js +13 -5
  286. package/dist/graph/write.d.ts +1 -1
  287. package/dist/graph/write.js +9 -9
  288. package/dist/hooks/codex-session.js +3 -2
  289. package/dist/hooks/codex-wrapper.js +2 -1
  290. package/dist/hooks/json-hooks.js +4 -2
  291. package/dist/hooks/opencode.js +8 -5
  292. package/dist/hooks/shared.d.ts +0 -6
  293. package/dist/hooks/shared.js +4 -15
  294. package/dist/importers/core.js +1 -1
  295. package/dist/importers/sources.js +5 -4
  296. package/dist/importers/vault.js +7 -5
  297. package/dist/index.d.ts +3 -2
  298. package/dist/index.js +3 -2
  299. package/dist/learn/autolearn.d.ts +10 -2
  300. package/dist/learn/autolearn.js +32 -12
  301. package/dist/learn/churn-git.js +13 -4
  302. package/dist/learn/extract.d.ts +3 -2
  303. package/dist/learn/extract.js +6 -4
  304. package/dist/learn/forward-claim-detector.js +4 -2
  305. package/dist/learn/invalidation.js +10 -6
  306. package/dist/mcp/admin-tools.d.ts +2 -2
  307. package/dist/mcp/admin-tools.js +27 -48
  308. package/dist/mcp/format.js +3 -2
  309. package/dist/mcp/framing.d.ts +1 -0
  310. package/dist/mcp/framing.js +1 -1
  311. package/dist/mcp/memory-tools.js +3 -1
  312. package/dist/mcp/protocol.d.ts +11 -7
  313. package/dist/mcp/protocol.js +25 -12
  314. package/dist/mcp/recall-tools.js +12 -9
  315. package/dist/mcp/request.js +2 -1
  316. package/dist/mcp/stdio.js +24 -8
  317. package/dist/mcp/tool-args.js +2 -1
  318. package/dist/mcp/tools.js +44 -21
  319. package/dist/objects/customer-notes.d.ts +2 -2
  320. package/dist/objects/decisions.d.ts +2 -2
  321. package/dist/objects/descriptor.d.ts +1 -1
  322. package/dist/objects/incidents.d.ts +2 -2
  323. package/dist/objects/lifecycle.d.ts +1 -1
  324. package/dist/objects/lifecycle.js +2 -1
  325. package/dist/objects/policies.d.ts +2 -2
  326. package/dist/objects/policies.js +2 -1
  327. package/dist/objects/processes.d.ts +2 -2
  328. package/dist/objects/project-briefs.d.ts +2 -2
  329. package/dist/objects/project-briefs.js +2 -3
  330. package/dist/objects/skills.d.ts +2 -2
  331. package/dist/postinstall.js +1 -1
  332. package/dist/rerankers/clef.js +3 -6
  333. package/dist/rerankers/cross-encoder.d.ts +31 -2
  334. package/dist/rerankers/cross-encoder.js +63 -97
  335. package/dist/rerankers/index.js +5 -4
  336. package/dist/rerankers/jev.js +2 -4
  337. package/dist/rerankers/outage-warning.d.ts +3 -1
  338. package/dist/rerankers/outage-warning.js +5 -3
  339. package/dist/search/bm25-search.js +1 -1
  340. package/dist/search/boosts.js +1 -1
  341. package/dist/search/embed-memories.d.ts +9 -0
  342. package/dist/search/embed-memories.js +377 -0
  343. package/dist/search/goal-boost.d.ts +1 -1
  344. package/dist/search/goal-boost.js +6 -3
  345. package/dist/search/hybrid.d.ts +9 -2
  346. package/dist/search/hybrid.js +9 -4
  347. package/dist/search/physics-search.d.ts +6 -3
  348. package/dist/search/physics-search.js +22 -15
  349. package/dist/search/rerank.js +1 -1
  350. package/dist/search/vector.d.ts +8 -6
  351. package/dist/search/vector.js +10 -13
  352. package/dist/server/auth.d.ts +2 -0
  353. package/dist/server/auth.js +17 -7
  354. package/dist/server/boot.js +7 -66
  355. package/dist/server/client-ip.d.ts +0 -2
  356. package/dist/server/client-ip.js +3 -2
  357. package/dist/server/deadline.d.ts +0 -2
  358. package/dist/server/deadline.js +1 -7
  359. package/dist/server/defaults.d.ts +1 -0
  360. package/dist/server/defaults.js +1 -0
  361. package/dist/server/mcp-http.js +16 -11
  362. package/dist/server/request.js +7 -2
  363. package/dist/server/route-checks.d.ts +7 -0
  364. package/dist/server/route-checks.js +42 -0
  365. package/dist/server/route-table.d.ts +9 -8
  366. package/dist/server/route-table.js +127 -132
  367. package/dist/server/routes/admin.d.ts +8 -8
  368. package/dist/server/routes/admin.js +13 -21
  369. package/dist/server/routes/customer-notes.d.ts +6 -6
  370. package/dist/server/routes/customer-notes.js +1 -2
  371. package/dist/server/routes/decisions.d.ts +6 -6
  372. package/dist/server/routes/decisions.js +2 -4
  373. package/dist/server/routes/incidents.d.ts +6 -6
  374. package/dist/server/routes/incidents.js +2 -5
  375. package/dist/server/routes/memories.d.ts +9 -9
  376. package/dist/server/routes/memories.js +15 -38
  377. package/dist/server/routes/object-routes.d.ts +6 -6
  378. package/dist/server/routes/object-routes.js +4 -7
  379. package/dist/server/routes/policies.d.ts +7 -7
  380. package/dist/server/routes/policies.js +2 -4
  381. package/dist/server/routes/predictions.d.ts +6 -6
  382. package/dist/server/routes/predictions.js +9 -13
  383. package/dist/server/routes/processes.d.ts +6 -6
  384. package/dist/server/routes/processes.js +1 -2
  385. package/dist/server/routes/project-briefs.d.ts +7 -7
  386. package/dist/server/routes/project-briefs.js +2 -4
  387. package/dist/server/routes/recall.d.ts +5 -5
  388. package/dist/server/routes/recall.js +6 -10
  389. package/dist/server/routes/skills.d.ts +7 -7
  390. package/dist/server/routes/skills.js +2 -4
  391. package/dist/server/server-detect.d.ts +7 -1
  392. package/dist/server/server-detect.js +36 -11
  393. package/dist/server/sleep-child.js +26 -7
  394. package/dist/server/sleep-offload.d.ts +11 -5
  395. package/dist/server/sleep-offload.js +17 -11
  396. package/dist/server/types.d.ts +22 -10
  397. package/dist/server/validation.d.ts +1 -2
  398. package/dist/server/validation.js +6 -11
  399. package/dist/server.d.ts +5 -4
  400. package/dist/server.js +5 -4
  401. package/dist/sharing/global-store.js +2 -2
  402. package/dist/sharing/global-sync.js +38 -45
  403. package/dist/sharing/project-merge.d.ts +7 -14
  404. package/dist/sharing/project-merge.js +57 -121
  405. package/dist/sharing/search-both.js +1 -1
  406. package/dist/sharing/share.d.ts +2 -0
  407. package/dist/sharing/share.js +37 -34
  408. package/dist/store/ambient.js +5 -6
  409. package/dist/store/audit-event.d.ts +1 -1
  410. package/dist/store/audit.d.ts +0 -16
  411. package/dist/store/audit.js +4 -55
  412. package/dist/store/auth.d.ts +4 -2
  413. package/dist/store/auth.js +7 -3
  414. package/dist/store/candidates.d.ts +3 -2
  415. package/dist/store/candidates.js +42 -23
  416. package/dist/store/capture-write.d.ts +17 -0
  417. package/dist/store/capture-write.js +35 -0
  418. package/dist/store/cards.js +1 -1
  419. package/dist/store/compaction-caller.d.ts +18 -0
  420. package/dist/store/compaction-caller.js +29 -0
  421. package/dist/store/compactions-record.d.ts +115 -0
  422. package/dist/store/compactions-record.js +417 -0
  423. package/dist/store/compactions.js +6 -4
  424. package/dist/store/conflicts.js +7 -4
  425. package/dist/store/connectors/dlq.d.ts +10 -0
  426. package/dist/store/connectors/dlq.js +32 -0
  427. package/dist/store/connectors/github.d.ts +7 -9
  428. package/dist/store/connectors/github.js +30 -53
  429. package/dist/store/connectors/slack.d.ts +2 -11
  430. package/dist/store/connectors/slack.js +18 -47
  431. package/dist/store/dashboard-reads.js +7 -6
  432. package/dist/store/delete-and-batch.d.ts +6 -0
  433. package/dist/store/delete-and-batch.js +36 -3
  434. package/dist/store/delivery-recorder.d.ts +10 -3
  435. package/dist/store/delivery-recorder.js +12 -5
  436. package/dist/store/descendant-page.js +6 -3
  437. package/dist/store/dormant.d.ts +1 -1
  438. package/dist/store/dormant.js +3 -1
  439. package/dist/store/embeddings/index.d.ts +2 -12
  440. package/dist/store/embeddings/index.js +5 -374
  441. package/dist/store/entry-reads.d.ts +13 -4
  442. package/dist/store/entry-reads.js +47 -11
  443. package/dist/store/entry-writes.d.ts +5 -5
  444. package/dist/store/entry-writes.js +32 -12
  445. package/dist/store/failure-log-at.d.ts +8 -0
  446. package/dist/store/failure-log-at.js +16 -0
  447. package/dist/store/failure-log.d.ts +2 -2
  448. package/dist/store/failure-log.js +5 -3
  449. package/dist/{trust → store}/gated-write.d.ts +3 -1
  450. package/dist/{trust → store}/gated-write.js +7 -5
  451. package/dist/store/goals.js +20 -18
  452. package/dist/store/graph-reads.js +4 -2
  453. package/dist/store/graph-writes.d.ts +6 -6
  454. package/dist/store/graph-writes.js +48 -71
  455. package/dist/store/handoffs.d.ts +1 -1
  456. package/dist/store/handoffs.js +6 -6
  457. package/dist/store/index-and-stats.js +2 -2
  458. package/dist/store/key-writes.js +1 -1
  459. package/dist/store/ledger-turn.d.ts +9 -0
  460. package/dist/store/ledger-turn.js +38 -0
  461. package/dist/store/mirrors.js +10 -6
  462. package/dist/store/open.d.ts +0 -4
  463. package/dist/store/open.js +40 -53
  464. package/dist/store/pilot-arm.d.ts +12 -0
  465. package/dist/store/pilot-arm.js +42 -0
  466. package/dist/store/port.d.ts +9 -3
  467. package/dist/store/port.js +8 -0
  468. package/dist/store/predictions.d.ts +1 -2
  469. package/dist/store/predictions.js +3 -6
  470. package/dist/store/project-tags.d.ts +62 -0
  471. package/dist/store/project-tags.js +67 -0
  472. package/dist/store/quarantine.js +2 -1
  473. package/dist/store/recall-trace.d.ts +2 -0
  474. package/dist/store/recall-trace.js +18 -2
  475. package/dist/store/rejected-values.js +2 -1
  476. package/dist/store/rejection-probe.d.ts +4 -0
  477. package/dist/store/rejection-probe.js +19 -0
  478. package/dist/store/rejection.d.ts +0 -17
  479. package/dist/store/rejection.js +1 -21
  480. package/dist/store/rule-sql.d.ts +9 -0
  481. package/dist/store/rule-sql.js +21 -2
  482. package/dist/store/search-rows.js +9 -4
  483. package/dist/store/sessions.js +4 -2
  484. package/dist/store/set-aside.d.ts +14 -0
  485. package/dist/store/set-aside.js +23 -0
  486. package/dist/store/sqlite/busy.d.ts +3 -0
  487. package/dist/store/sqlite/busy.js +8 -0
  488. package/dist/store/sqlite/connector-events-group.js +4 -7
  489. package/dist/store/sqlite/connector-writes-group.js +3 -3
  490. package/dist/store/sqlite/entry-writes-group.js +2 -2
  491. package/dist/store/sqlite/error-codec.js +4 -3
  492. package/dist/store/sqlite/executor.js +10 -4
  493. package/dist/store/sqlite/graph-reads-group.js +1 -1
  494. package/dist/store/sqlite/held-connection.d.ts +9 -0
  495. package/dist/store/sqlite/held-connection.js +41 -0
  496. package/dist/store/sqlite/object-rows.d.ts +1 -1
  497. package/dist/store/sqlite/objects-group.d.ts +1 -1
  498. package/dist/store/sqlite/objects-group.js +1 -1
  499. package/dist/store/sqlite/store.js +14 -12
  500. package/dist/store/summaries.d.ts +3 -3
  501. package/dist/store/summaries.js +5 -4
  502. package/dist/store/token-ledger.d.ts +0 -7
  503. package/dist/store/token-ledger.js +0 -35
  504. package/dist/store/vector-index.js +3 -2
  505. package/dist/support-bundle.js +2 -3
  506. package/dist/trust/reject-flow.js +2 -2
  507. package/dist/util/agent-homes.d.ts +15 -0
  508. package/dist/util/agent-homes.js +34 -0
  509. package/dist/util/anthropic-messages.d.ts +3 -0
  510. package/dist/util/anthropic-messages.js +22 -5
  511. package/dist/util/chunked.d.ts +3 -0
  512. package/dist/util/chunked.js +10 -0
  513. package/dist/util/ellipsize.d.ts +3 -0
  514. package/dist/util/ellipsize.js +5 -0
  515. package/dist/util/env.d.ts +2 -1
  516. package/dist/util/env.js +2 -1
  517. package/dist/util/format.d.ts +3 -0
  518. package/dist/util/format.js +6 -0
  519. package/dist/util/hook-payload.d.ts +8 -0
  520. package/dist/util/hook-payload.js +37 -0
  521. package/dist/util/http-retry.d.ts +6 -0
  522. package/dist/util/http-retry.js +43 -5
  523. package/dist/util/http-util.d.ts +0 -8
  524. package/dist/util/http-util.js +10 -21
  525. package/dist/util/limits.d.ts +7 -0
  526. package/dist/util/limits.js +14 -0
  527. package/dist/util/log.d.ts +4 -0
  528. package/dist/util/log.js +9 -0
  529. package/dist/util/request-scope.d.ts +3 -1
  530. package/dist/util/request-scope.js +11 -6
  531. package/dist/util/secret-detect.js +6 -1
  532. package/dist/util/sqlite-blocked.d.ts +2 -0
  533. package/dist/util/sqlite-blocked.js +5 -0
  534. package/dist/util/stream-tee.d.ts +3 -0
  535. package/dist/util/stream-tee.js +35 -0
  536. package/dist/util/time.d.ts +4 -0
  537. package/dist/util/time.js +4 -0
  538. package/dist/util/version.d.ts +1 -1
  539. package/dist/util/version.js +1 -1
  540. package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
  541. package/extensions/openclaw-plugin/package.json +1 -1
  542. package/openclaw.plugin.json +1 -1
  543. package/package.json +2 -2
  544. package/dist/store/embeddings/local.d.ts +0 -15
  545. package/dist/store/embeddings/local.js +0 -175
  546. /package/dist/{cli → api}/correction-latency.d.ts +0 -0
  547. /package/dist/{cli → api}/correction-latency.js +0 -0
  548. /package/dist/{cli → api}/provenance-coverage.d.ts +0 -0
  549. /package/dist/{cli → api}/provenance-coverage.js +0 -0
  550. /package/dist/{store → core}/object-types.d.ts +0 -0
  551. /package/dist/{store → core}/object-types.js +0 -0
  552. /package/dist/{capture → util}/compaction-items.d.ts +0 -0
  553. /package/dist/{capture → util}/compaction-items.js +0 -0
  554. /package/dist/{store → util}/yaml.d.ts +0 -0
  555. /package/dist/{store → util}/yaml.js +0 -0
@@ -1,6 +1,7 @@
1
1
  /** Learned memory-value scorer, a rescue-only veto in the sleep decay pass (it can only shrink the condemned set); mirrors benchmarks/memory-value/*.mjs.
2
2
  * rescueSet rescues a condemned entry iff it ranks in the top 30% (RESCUE_BUDGET) of its tenant's non-pinned set; memory-value-wiring.test.ts guards parity. */
3
3
  import { DEFAULT_TENANT_ID } from '../util/env.js';
4
+ import { strengthAblation } from '../core/ablation.js';
4
5
  import { calculateStrength } from '../core/memory.js';
5
6
  import { compareEntryIdentity } from '../core/compare.js';
6
7
  import { MEMORY_VALUE_WEIGHTS, SOURCE_ARTIFACT_SHA256 } from './memory-value-weights.js';
@@ -31,7 +32,7 @@ export function computeMvFeatures(entry, now) {
31
32
  return {
32
33
  age_days: ageDays,
33
34
  half_life_days: entry.half_life_days,
34
- strength: calculateStrength(entry, now), // clock-basis, never decayOpts — see doc comment above
35
+ strength: calculateStrength(entry, now, { ablation: strengthAblation() }), // clock-basis, never the production decay basis — see doc comment above
35
36
  retrieval_count: entry.retrieval_count,
36
37
  outcome_positive: pos,
37
38
  outcome_negative: neg,
@@ -3,10 +3,10 @@ import { tokenize } from '../util/tokenize.js';
3
3
  import { jaccardMinShared, overlapPartners } from './overlap-index.js';
4
4
  import { compareEntryIdentity } from '../core/compare.js';
5
5
  import { duplicateKey, mergedText } from '../util/same-text.js';
6
- import { successorAfterRetirement } from './merged-row.js';
6
+ import { successorAfterRetirement } from '../core/merged-row.js';
7
7
  import { rejectionDigest } from '../store/rejection.js';
8
8
  import { reportAuditWriteFailure } from '../store/audit.js';
9
- import { derivationScope, derivationPartitionKey } from '../store/recall-scope.js';
9
+ import { derivationScope, derivationPartitionKey } from '../core/recall-scope.js';
10
10
  import { jaccardSets } from './conflicts.js';
11
11
  import { keptAsWritten } from './run.js';
12
12
  import { isReusable } from '../core/memory-quality.js';
@@ -1,3 +1,8 @@
1
+ import { type PhysicsParticle } from '../core/physics.js';
2
+ import type { MemoryEntry } from '../core/memory.js';
1
3
  import type { SleepRun } from './run.js';
2
- export declare function physicsPass(run: SleepRun): void;
4
+ export declare function physicsPass(run: SleepRun, maxParticles?: number): void;
5
+ /** Every stored particle in load order up to the cap; past it, the most recently recalled survivors (memory id breaks ties),
6
+ * then particles with no survivor. */
7
+ export declare function particlesToSimulate(stored: PhysicsParticle[], entries: ReadonlyMap<string, MemoryEntry>, max?: number): PhysicsParticle[];
3
8
  //# sourceMappingURL=physics-pass.d.ts.map
@@ -3,8 +3,10 @@ import { loadStoredParticles, saveStoredParticles } from '../store/vector-index.
3
3
  import { simulate } from '../core/physics.js';
4
4
  import { errorMessage } from '../util/log.js';
5
5
  const STATS_DECIMALS = 4;
6
+ // Every substep is all-pairs, so one sleep moves at most this many particles; the rest keep their stored state until they are recalled.
7
+ const SLEEP_PHYSICS_MAX_PARTICLES = 1000;
6
8
  // 2. Physics simulation pass
7
- export function physicsPass(run) {
9
+ export function physicsPass(run, maxParticles = SLEEP_PHYSICS_MAX_PARTICLES) {
8
10
  if (run.dryRun)
9
11
  return;
10
12
  const { config, result } = run;
@@ -12,27 +14,45 @@ export function physicsPass(run) {
12
14
  const physicsEnabled = config.physics.enabled === true
13
15
  || (config.physics.enabled === 'auto');
14
16
  if (physicsEnabled)
15
- simulateStoredParticles(run);
17
+ simulateStoredParticles(run, maxParticles);
16
18
  }
17
19
  catch (error) {
18
20
  result.details.push(` ⚠️ physics simulation skipped: ${errorMessage(error)}`);
19
21
  }
20
22
  }
21
- function simulateStoredParticles(run) {
23
+ function simulateStoredParticles(run, maxParticles) {
22
24
  const { result, survivors } = run;
23
- const particles = loadStoredParticles(run.hippoRoot);
24
- if (particles.length === 0)
25
+ const stored = loadStoredParticles(run.hippoRoot);
26
+ if (stored.length === 0)
25
27
  return;
26
28
  // Build entry lookup for property refresh
27
29
  const entryMap = new Map(survivors.map(e => [e.id, e]));
30
+ const particles = particlesToSimulate(stored, entryMap, maxParticles);
28
31
  refreshParticleProperties(particles, entryMap, run.now);
29
32
  const stats = simulate(particles, survivorForces(run));
30
33
  saveStoredParticles(run.hippoRoot, particles);
31
34
  result.physicsSimulated = stats.particleCount;
32
- result.details.push(` ⚛️ physics: ${stats.particleCount} particles, ` +
35
+ const capped = particles.length < stored.length ? ` (the ${particles.length} most recently recalled of ${stored.length})` : '';
36
+ result.details.push(` ⚛️ physics: ${stats.particleCount} particles${capped}, ` +
33
37
  `avg vel ${stats.avgVelocityMagnitude.toFixed(STATS_DECIMALS)}, ` +
34
38
  `energy ${stats.energy.total.toFixed(STATS_DECIMALS)}`);
35
39
  }
40
+ /** Every stored particle in load order up to the cap; past it, the most recently recalled survivors (memory id breaks ties),
41
+ * then particles with no survivor. */
42
+ export function particlesToSimulate(stored, entries, max = SLEEP_PHYSICS_MAX_PARTICLES) {
43
+ if (stored.length <= max)
44
+ return stored;
45
+ const recalled = (p) => entries.get(p.memoryId)?.last_retrieved ?? '';
46
+ const ranked = [...stored].sort((a, b) => {
47
+ const [ra, rb] = [recalled(a), recalled(b)];
48
+ if (ra !== rb)
49
+ return ra < rb ? 1 : -1;
50
+ return a.memoryId < b.memoryId ? -1 : a.memoryId > b.memoryId ? 1 : 0;
51
+ });
52
+ const kept = new Set(ranked.slice(0, max));
53
+ // Load order, not rank order: the force sums run in this order, so a capped run matches an uncapped one over the same set.
54
+ return stored.filter((p) => kept.has(p));
55
+ }
36
56
  function survivorForces(run) {
37
57
  // Build conflict pairs from survivors
38
58
  const conflictPairs = new Map();
@@ -1,5 +1,6 @@
1
1
  /** Replay: during `hippo sleep`, sample N survivors weighted by reward, valence, under-rehearsal and age, then apply the `markRetrieved` strengthening.
2
2
  * A lightweight deterministic analog of hippocampal replay, so important memories stay strong without being queried; distinct from decay, physics and merge. */
3
+ import { HOUR_MS } from '../util/time.js';
3
4
  import { isOutcomeSlowAblated } from '../core/ablation.js';
4
5
  import { resolveConfidence } from '../core/memory.js';
5
6
  const VALENCE_WEIGHT = {
@@ -8,6 +9,12 @@ const VALENCE_WEIGHT = {
8
9
  negative: 1.5,
9
10
  critical: 2.0,
10
11
  };
12
+ // Floor keeps every weight positive for sampleForReplay; the rest scale reward and idle boosts.
13
+ const REWARD_FLOOR = 0.1;
14
+ const REWARD_POSITIVE_GAIN = 0.5;
15
+ const REWARD_NET_GAIN = 0.25;
16
+ const IDLE_BOOST_GAIN = 0.1;
17
+ const STRENGTH_FLOOR = 0.1;
11
18
  /** Priority score for ranking survivors for replay (higher = more likely sampled); pure in the entry and current time. */
12
19
  export function replayPriority(entry, now, outcomeAblated) {
13
20
  const pos = entry.outcome_positive ?? 0;
@@ -16,18 +23,18 @@ export function replayPriority(entry, now, outcomeAblated) {
16
23
  // The clamp is required because sampleForReplay needs all weights positive.
17
24
  const rewardSignal = outcomeAblated
18
25
  ? 1.0 // EVAL-ONLY ablation (see ablation.ts): outcome-off also silences replay's reward bias
19
- : Math.max(0.1, 1 + pos * 0.5 + (pos - neg) * 0.25);
26
+ : Math.max(REWARD_FLOOR, 1 + pos * REWARD_POSITIVE_GAIN + (pos - neg) * REWARD_NET_GAIN);
20
27
  const valence = VALENCE_WEIGHT[entry.emotional_valence] ?? 1.0;
21
28
  // Under-rehearsed memories benefit most from replay.
22
29
  const underRehearsed = 1 / (1 + (entry.retrieval_count ?? 0));
23
30
  // Idle-time boost: memories that haven't been touched recently need rehearsal more.
24
31
  const lastRetrieved = new Date(entry.last_retrieved);
25
32
  const deltaMs = now.getTime() - lastRetrieved.getTime();
26
- const ageHours = Number.isFinite(deltaMs) ? Math.max(0, deltaMs / 3_600_000) : 0;
27
- const idleBoost = 1 + Math.log1p(ageHours) * 0.1;
33
+ const ageHours = Number.isFinite(deltaMs) ? Math.max(0, deltaMs / HOUR_MS) : 0;
34
+ const idleBoost = 1 + Math.log1p(ageHours) * IDLE_BOOST_GAIN;
28
35
  // Weight by current strength so dead-and-decaying memories don't waste replay slots.
29
36
  const rawStrength = Number.isFinite(entry.strength) ? entry.strength : 0;
30
- const strengthFloor = Math.max(0.1, rawStrength);
37
+ const strengthFloor = Math.max(STRENGTH_FLOOR, rawStrength);
31
38
  return rewardSignal * valence * underRehearsed * idleBoost * strengthFloor;
32
39
  }
33
40
  /** Deterministic 32-bit RNG (Mulberry32): same seed, same sequence, so replay is reproducible without a random-number dependency. */
@@ -1,5 +1,5 @@
1
1
  /** Consolidation engine ("Sleep"): decay pass (drop entries below the strength threshold), merge pass (semantic summaries of overlapping episodics), stats. */
2
- import { evalNow } from '../core/ablation.js';
2
+ import { evalNow, strengthAblation } from '../core/ablation.js';
3
3
  import { canAutoDelete } from '../core/memory.js';
4
4
  import { loadAllEntriesWithBase } from '../store/entry-reads.js';
5
5
  import { commitInChunks, memoriesBackingObjects } from '../store/delete-and-batch.js';
@@ -11,7 +11,7 @@ import { loadConfig } from '../core/config.js';
11
11
  import { recordAuditEventsRowByRow, reportAuditWriteFailure } from '../store/audit.js';
12
12
  import { lazyTombstoneChecks } from '../store/tombstone-checks.js';
13
13
  import { migrateDefaultHalfLife, LEGACY_TYPED_HALF_LIFE } from './half-life-migration.js';
14
- import { errorMessage, log } from '../util/log.js';
14
+ import { errorFields, errorMessage, log } from '../util/log.js';
15
15
  import { WRITE_BUDGET } from '../util/write-budget.js';
16
16
  import { decayPass } from './decay.js';
17
17
  import { familyUnits, groupFlush } from './flush-units.js';
@@ -68,6 +68,7 @@ function sessionDecayOptions(hippoRoot, config) {
68
68
  decayBasis: config.decayBasis,
69
69
  avgSessionIntervalDays: sessionCtx.avgSessionIntervalDays,
70
70
  sleepCount: sessionCtx.sleepCount,
71
+ ablation: strengthAblation(),
71
72
  };
72
73
  }
73
74
  /** Every pass between decay and the flush; the tombstone-check handle closes whichever of them throws. */
@@ -96,7 +97,8 @@ function migrateHalfLives(hippoRoot, dryRun, result) {
96
97
  result.details.push(` ⏳ ${dryRun ? 'would move' : 'moved'} ${halfLife.rescaled} memories from the ${halfLife.from}-day to the ${halfLife.to}-day half-life`);
97
98
  }
98
99
  if (halfLife.typed > 0) {
99
- result.details.push(` ⏳ ${dryRun ? 'would move' : 'moved'} ${halfLife.typed} memories of decisions, incidents and other objects from the ${LEGACY_TYPED_HALF_LIFE}-day to the ${halfLife.to}-day half-life`);
100
+ result.details.push(` ⏳ ${dryRun ? 'would move' : 'moved'} ${halfLife.typed} memories of decisions, incidents and other objects ` +
101
+ `from the ${LEGACY_TYPED_HALF_LIFE}-day to the ${halfLife.to}-day half-life`);
100
102
  }
101
103
  return halfLife;
102
104
  }
@@ -126,7 +128,8 @@ async function expireDormant(run, budget) {
126
128
  const cutoff = new Date(run.now.getTime() - config.dormant.retentionDays * DAY_MS).toISOString();
127
129
  result.dormantExpired = await expireDormantBefore(run.hippoRoot, cutoff, { dryRun, budget, busyWaitMs: SLEEP_DB_WAIT_MS });
128
130
  if (result.dormantExpired > 0) {
129
- result.details.push(` ⌛ ${dryRun ? 'would expire' : 'expired'} ${result.dormantExpired} dormant memor${result.dormantExpired === 1 ? 'y' : 'ies'} older than ${config.dormant.retentionDays} days`);
131
+ result.details.push(` ⌛ ${dryRun ? 'would expire' : 'expired'} ${result.dormantExpired} dormant memor${result.dormantExpired === 1 ? 'y' : 'ies'} ` +
132
+ `older than ${config.dormant.retentionDays} days`);
130
133
  }
131
134
  }
132
135
  // 4. Log run
@@ -175,7 +178,7 @@ function auditRescues(run, { rescuedEntries, rankById }) {
175
178
  }
176
179
  catch (err) {
177
180
  // An audit store that will not open must never crash the mutation it records.
178
- log.debug(`mv_rescue audit unavailable: ${errorMessage(err)}`);
181
+ log.warn(`mv_rescue audit unavailable: ${errorMessage(err)}`, { errorClass: errorFields(err).errorClass });
179
182
  result.details.push(` ⚠️ memory-value: mv_rescue audit unavailable this cycle ` +
180
183
  `(${rescuedEntries.length} rescue${rescuedEntries.length === 1 ? '' : 's'} not audited)`);
181
184
  }
@@ -1,4 +1,4 @@
1
- import { isRecallBoostAblated } from '../core/ablation.js';
1
+ import { isRecallBoostAblated, strengthAblation } from '../core/ablation.js';
2
2
  import { Layer, createMemory, markRetrieved } from '../core/memory.js';
3
3
  import { findPromotableSessions, traceExistsForSession, listSessionEvents } from '../store/sessions.js';
4
4
  import { rejectionDigest } from '../store/rejection.js';
@@ -6,7 +6,7 @@ import { sampleForReplay } from './replay.js';
6
6
  import { renderTraceContent } from './trace.js';
7
7
  import { resolveTenantId } from '../store/tenant.js';
8
8
  import { reportAuditWriteFailure } from '../store/audit.js';
9
- import { commonDerivationScope } from '../store/recall-scope.js';
9
+ import { commonDerivationScope } from '../core/recall-scope.js';
10
10
  import { log } from '../util/log.js';
11
11
  import { REPLAY_COUNT_DEFAULT } from './run.js';
12
12
  import { isJsonString } from '../util/json.js';
@@ -136,7 +136,7 @@ export function replayPass(run) {
136
136
  const picked = sampleForReplay(survivors, replayCount, now, seed);
137
137
  if (picked.length === 0)
138
138
  return;
139
- const rehearsed = markRetrieved(picked, now);
139
+ const rehearsed = markRetrieved(picked, now, { ablation: strengthAblation() });
140
140
  const rehearsedById = new Map(rehearsed.map((e) => [e.id, e]));
141
141
  // Update survivors in place so downstream passes see rehearsed state.
142
142
  for (let i = 0; i < survivors.length; i++) {
@@ -1,6 +1,16 @@
1
1
  /** EVAL-ONLY ablation switches (HIPPO_ABLATE_*, HIPPO_EVAL_RECENCY_DAYS, HIPPO_FAKE_NOW): each cuts ONE mechanism (outcome also replayPriority bias).
2
2
  * Not a production surface. Env is read once per process; tests that mutate these vars MUST call _resetAblationCacheForTests() in beforeEach AND afterEach. See
3
3
  * docs/ARCHITECTURE.md#srccoreablationts. */
4
+ /** The three switches strength scoring honours, resolved by the entry layer and handed to core in DecayOptions. */
5
+ export interface StrengthAblation {
6
+ readonly decay: boolean;
7
+ readonly recallBoost: boolean;
8
+ readonly outcomeSlow: boolean;
9
+ }
10
+ /** Production scoring: nothing ablated. Core falls back to this, so it never reads the environment. */
11
+ export declare const NO_STRENGTH_ABLATION: StrengthAblation;
12
+ /** The frozen strength switches for this process; entry-layer callers pass them as `DecayOptions.ablation`. */
13
+ export declare function strengthAblation(): StrengthAblation;
4
14
  export declare function isDecayAblated(): boolean;
5
15
  export declare function isRecallBoostAblated(): boolean;
6
16
  export declare function isOutcomeSlowAblated(): boolean;
@@ -2,7 +2,10 @@
2
2
  * Not a production surface. Env is read once per process; tests that mutate these vars MUST call _resetAblationCacheForTests() in beforeEach AND afterEach. See
3
3
  * docs/ARCHITECTURE.md#srccoreablationts. */
4
4
  import { envAblateDecay, envAblateOutcome, envAblateOutcomeFast, envAblateOutcomeSlow, envAblateRecallBoost, envAblateRecency, envEvalRecencyDays, envFakeNowMs, } from '../util/env.js';
5
+ /** Production scoring: nothing ablated. Core falls back to this, so it never reads the environment. */
6
+ export const NO_STRENGTH_ABLATION = Object.freeze({ decay: false, recallBoost: false, outcomeSlow: false });
5
7
  let _cache;
8
+ let _strengthCache;
6
9
  function readFlags() {
7
10
  if (_cache !== undefined)
8
11
  return _cache;
@@ -18,6 +21,14 @@ function readFlags() {
18
21
  };
19
22
  return _cache;
20
23
  }
24
+ /** The frozen strength switches for this process; entry-layer callers pass them as `DecayOptions.ablation`. */
25
+ export function strengthAblation() {
26
+ if (_strengthCache === undefined) {
27
+ const f = readFlags();
28
+ _strengthCache = Object.freeze({ decay: f.decay, recallBoost: f.recallBoost, outcomeSlow: f.outcomeSlow });
29
+ }
30
+ return _strengthCache;
31
+ }
21
32
  export function isDecayAblated() {
22
33
  return readFlags().decay;
23
34
  }
@@ -45,5 +56,6 @@ export function evalNow() {
45
56
  /** Test-only. See module JSDoc: call in BOTH beforeEach AND afterEach. */
46
57
  export function _resetAblationCacheForTests() {
47
58
  _cache = undefined;
59
+ _strengthCache = undefined;
48
60
  }
49
61
  //# sourceMappingURL=ablation.js.map
@@ -4,4 +4,4 @@ export declare function detectScope(): string | null;
4
4
  /** Compute scope match between a memory's scope tags and the active scope.
5
5
  * Returns: 1 if matching scope, -1 if mismatching scope, 0 if neutral (no scope on either side). */
6
6
  export declare function scopeMatch(memoryTags: string[], activeScope: string | null): -1 | 0 | 1;
7
- //# sourceMappingURL=scope.d.ts.map
7
+ //# sourceMappingURL=active-scope.d.ts.map
@@ -26,4 +26,4 @@ export function scopeMatch(memoryTags, activeScope) {
26
26
  return 1; // match
27
27
  return -1; // mismatch
28
28
  }
29
- //# sourceMappingURL=scope.js.map
29
+ //# sourceMappingURL=active-scope.js.map
@@ -13,6 +13,10 @@ export interface AmbientState {
13
13
  dagDepth: number;
14
14
  totalMemories: number;
15
15
  }
16
+ /** A memory is fresh when created within this window. */
17
+ export declare const AMBIENT_FRESH_WINDOW_MS: number;
18
+ /** A memory counts as high schema fit strictly above this. */
19
+ export declare const HIGH_SCHEMA_FIT_ABOVE = 0.7;
16
20
  /** Row counts and sums an AmbientState is derived from; two stores' tallies add with addAmbientTallies. */
17
21
  export interface AmbientTallies {
18
22
  total: number;
@@ -1,9 +1,29 @@
1
1
  /** Ambient state vector: a compact O(N) summary of the corpus telling the agent "where it is" in knowledge-space without retrieving specific memories. */
2
- import { evalNow } from './ablation.js';
2
+ import { evalNow, strengthAblation } from './ablation.js';
3
3
  import { Layer } from './memory.js';
4
4
  import { calculateStrength } from './memory.js';
5
5
  import { DAY_MS } from '../util/time.js';
6
6
  const STATE_DECIMALS = 3;
7
+ // Cut points renderAmbientSummary uses to turn the state vector into words.
8
+ const SUMMARY_THRESHOLD = {
9
+ freshHigh: 0.5,
10
+ freshLow: 0.1,
11
+ skewHigh: 0.3,
12
+ skewLow: -0.3,
13
+ consolidatedHigh: 0.4,
14
+ consolidatedLow: 0.1,
15
+ extractionHigh: 0.5,
16
+ conflictShown: 0.1,
17
+ dagDepthShown: 2,
18
+ strengthLow: 0.3,
19
+ strengthHigh: 0.7,
20
+ entropyHigh: 0.8,
21
+ entropyLow: 0.3,
22
+ };
23
+ /** A memory is fresh when created within this window. */
24
+ export const AMBIENT_FRESH_WINDOW_MS = 7 * DAY_MS;
25
+ /** A memory counts as high schema fit strictly above this. */
26
+ export const HIGH_SCHEMA_FIT_ABOVE = 0.7;
7
27
  /** The tallies of two disjoint row sets taken together. */
8
28
  export function addAmbientTallies(a, b) {
9
29
  const tagCounts = new Map(a.tagCounts);
@@ -31,7 +51,7 @@ export function isErrorTagged(tags) {
31
51
  /** Tallies over loaded entries; superseded rows count toward the total only, as they always have here. */
32
52
  export function tallyAmbientEntries(entries, now) {
33
53
  const currentTime = now ?? evalNow(); // honors HIPPO_FAKE_NOW (eval-only)
34
- const sevenDaysAgo = currentTime.getTime() - 7 * DAY_MS;
54
+ const freshAfter = currentTime.getTime() - AMBIENT_FRESH_WINDOW_MS;
35
55
  const t = {
36
56
  total: entries.length, strengthSum: 0, fresh: 0, negative: 0, highSchemaFit: 0, errors: 0,
37
57
  semantic: 0, episodic: 0, conflicts: 0, extracted: 0, maxDagLevel: 0, tagCounts: new Map(),
@@ -41,14 +61,14 @@ export function tallyAmbientEntries(entries, now) {
41
61
  continue;
42
62
  for (const tag of entry.tags)
43
63
  t.tagCounts.set(tag, (t.tagCounts.get(tag) ?? 0) + 1);
44
- t.strengthSum += calculateStrength(entry, currentTime);
45
- if (new Date(entry.created).getTime() > sevenDaysAgo)
64
+ t.strengthSum += calculateStrength(entry, currentTime, { ablation: strengthAblation() });
65
+ if (new Date(entry.created).getTime() > freshAfter)
46
66
  t.fresh++;
47
67
  if (entry.emotional_valence === 'negative' || entry.emotional_valence === 'critical')
48
68
  t.negative++;
49
69
  if (isErrorTagged(entry.tags))
50
70
  t.errors++;
51
- if (entry.schema_fit > 0.7)
71
+ if (entry.schema_fit > HIGH_SCHEMA_FIT_ABOVE)
52
72
  t.highSchemaFit++;
53
73
  if (entry.layer === Layer.Semantic)
54
74
  t.semantic++;
@@ -116,33 +136,34 @@ function shannonEntropy(counts, total) {
116
136
  export function renderAmbientSummary(state) {
117
137
  if (state.totalMemories === 0)
118
138
  return 'Memory state: empty store, no memories yet.';
139
+ const T = SUMMARY_THRESHOLD;
119
140
  const parts = [];
120
141
  parts.push(`${state.totalMemories} memories`);
121
- if (state.recencyFreshness > 0.5)
142
+ if (state.recencyFreshness > T.freshHigh)
122
143
  parts.push('mostly fresh (<7d)');
123
- else if (state.recencyFreshness < 0.1)
144
+ else if (state.recencyFreshness < T.freshLow)
124
145
  parts.push('mostly aged');
125
- if (state.emotionalSkew > 0.3)
146
+ if (state.emotionalSkew > T.skewHigh)
126
147
  parts.push('error-focused');
127
- else if (state.emotionalSkew < -0.3)
148
+ else if (state.emotionalSkew < T.skewLow)
128
149
  parts.push('steady operation');
129
- if (state.consolidationRatio > 0.4)
150
+ if (state.consolidationRatio > T.consolidatedHigh)
130
151
  parts.push('well-consolidated');
131
- else if (state.consolidationRatio < 0.1)
152
+ else if (state.consolidationRatio < T.consolidatedLow)
132
153
  parts.push('mostly episodic');
133
- if (state.extractionCoverage > 0.5)
154
+ if (state.extractionCoverage > T.extractionHigh)
134
155
  parts.push('high extraction coverage');
135
- if (state.conflictIntensity > 0.1)
156
+ if (state.conflictIntensity > T.conflictShown)
136
157
  parts.push(`${(state.conflictIntensity * 100).toFixed(0)}% conflict rate`);
137
- if (state.dagDepth >= 2)
158
+ if (state.dagDepth >= T.dagDepthShown)
138
159
  parts.push(`DAG depth ${state.dagDepth}`);
139
- if (state.avgStrength < 0.3)
160
+ if (state.avgStrength < T.strengthLow)
140
161
  parts.push('low avg strength (aging corpus)');
141
- else if (state.avgStrength > 0.7)
162
+ else if (state.avgStrength > T.strengthHigh)
142
163
  parts.push('high avg strength');
143
- if (state.tagEntropy > 0.8)
164
+ if (state.tagEntropy > T.entropyHigh)
144
165
  parts.push('diverse topics');
145
- else if (state.tagEntropy < 0.3)
166
+ else if (state.tagEntropy < T.entropyLow)
146
167
  parts.push('narrow focus');
147
168
  return `Memory state: ${parts.join(', ')}.`;
148
169
  }
@@ -24,4 +24,20 @@ export declare class ConflictError extends ApiError {
24
24
  readonly status = 409;
25
25
  constructor(message: string);
26
26
  }
27
+ /** Thrown by the write-path guard (checkRejectionGuard, via upsertEntryRow) when a write would introduce a tombstoned value; carries what the
28
+ * transaction-owner catch blocks (writeEntry, api.supersede) need to write the post-rollback `reject_refusal` audit row via `auditRejectionRefusal`. */
29
+ export declare class RejectedValueError extends BadRequestError {
30
+ readonly digest: string;
31
+ readonly tenantId: string;
32
+ readonly entryId: string;
33
+ readonly reason: string | null;
34
+ readonly rejectedAt: string;
35
+ constructor(opts: {
36
+ digest: string;
37
+ tenantId: string;
38
+ entryId: string;
39
+ reason: string | null;
40
+ rejectedAt: string;
41
+ });
42
+ }
27
43
  //# sourceMappingURL=api-errors.d.ts.map
@@ -1,4 +1,5 @@
1
1
  /** Errors whose HTTP status is part of the API contract; the server maps by class, so message text can change freely. */
2
+ import { DIGEST_DISPLAY_CHARS } from '../util/token-text.js';
2
3
  /** Base class: an error the caller caused, carrying the status the HTTP layer answers with. */
3
4
  export class ApiError extends Error {
4
5
  }
@@ -34,4 +35,23 @@ export class ConflictError extends ApiError {
34
35
  this.name = 'ConflictError';
35
36
  }
36
37
  }
38
+ /** Thrown by the write-path guard (checkRejectionGuard, via upsertEntryRow) when a write would introduce a tombstoned value; carries what the
39
+ * transaction-owner catch blocks (writeEntry, api.supersede) need to write the post-rollback `reject_refusal` audit row via `auditRejectionRefusal`. */
40
+ export class RejectedValueError extends BadRequestError {
41
+ digest;
42
+ tenantId;
43
+ entryId;
44
+ reason;
45
+ rejectedAt;
46
+ constructor(opts) {
47
+ super(`Memory value refused: matches a rejected value (digest ${opts.digest.slice(0, DIGEST_DISPLAY_CHARS)}..., ` +
48
+ `reason: ${opts.reason ?? 'none given'}). Run "hippo unreject" to allow it again.`);
49
+ this.name = 'RejectedValueError';
50
+ this.digest = opts.digest;
51
+ this.tenantId = opts.tenantId;
52
+ this.entryId = opts.entryId;
53
+ this.reason = opts.reason;
54
+ this.rejectedAt = opts.rejectedAt;
55
+ }
56
+ }
37
57
  //# sourceMappingURL=api-errors.js.map
package/dist/core/card.js CHANGED
@@ -1,3 +1,5 @@
1
+ // Work-queue card types: a claimable unit of work, N candidates claim one row, first wins.
2
+ import { HOUR_MS } from '../util/time.js';
1
3
  const CARD_STATUSES = ['backlog', 'ready', 'running', 'blocked', 'review', 'done', 'shelved'];
2
4
  /** Narrows a raw string, such as a CLI flag value, to a CardStatus. */
3
5
  export function isCardStatus(v) {
@@ -15,7 +17,7 @@ export const CARD_TRANSITIONS = {
15
17
  };
16
18
  // SHORTCUT: one fixed lease for every claim; add a per-claim lease when the W3 dispatcher heartbeats on a timer.
17
19
  /** How long a claim or a heartbeat keeps a running card's lease before reclaimExpiredCards may return it to ready. */
18
- export const CARD_LEASE_MS = 4 * 60 * 60 * 1000;
20
+ export const CARD_LEASE_MS = 4 * HOUR_MS;
19
21
  /** Throws on any move CARD_TRANSITIONS does not allow, before a status write touches the row. */
20
22
  export function assertCardTransition(from, to) {
21
23
  for (const status of from) {
@@ -0,0 +1,7 @@
1
+ /** PostCompact has 10 s in all (PreCompact 30 s), so a locked store must be given up on early. */
2
+ export declare const COMPACTION_DB_WAIT_MS = 2000;
3
+ /** Long enough that a live hook has finished with its own record. */
4
+ export declare const REPLAY_AFTER_MS: number;
5
+ /** Claude Code deletes transcripts after 30 days, so an older gap can never be filled. */
6
+ export declare const TRANSCRIPT_FILL_WINDOW_MS: number;
7
+ //# sourceMappingURL=compaction-timing.d.ts.map
@@ -0,0 +1,9 @@
1
+ // Waits and windows shared by the compaction record's SQL (src/store) and the hooks and CLI that schedule it.
2
+ import { DAY_MS, MINUTE_MS } from '../util/time.js';
3
+ /** PostCompact has 10 s in all (PreCompact 30 s), so a locked store must be given up on early. */
4
+ export const COMPACTION_DB_WAIT_MS = 2000;
5
+ /** Long enough that a live hook has finished with its own record. */
6
+ export const REPLAY_AFTER_MS = 10 * MINUTE_MS;
7
+ /** Claude Code deletes transcripts after 30 days, so an older gap can never be filled. */
8
+ export const TRANSCRIPT_FILL_WINDOW_MS = 30 * DAY_MS;
9
+ //# sourceMappingURL=compaction-timing.js.map
@@ -20,7 +20,7 @@ export interface HippoConfig {
20
20
  model: string;
21
21
  hybridWeight: number;
22
22
  /** Embedding backend: 'local' (default) = zero-dependency transformers.js; 'openai' | 'voyage' | 'cohere' = opt-in API embedder needing the provider's
23
- * API key in env (OPENAI_API_KEY / VOYAGE_API_KEY / COHERE_API_KEY). See src/store/embeddings/provider.ts. */
23
+ * API key in env (OPENAI_API_KEY / VOYAGE_API_KEY / COHERE_API_KEY). See src/embeddings/provider.ts. */
24
24
  provider?: 'local' | 'openai' | 'voyage' | 'cohere';
25
25
  /** Optional API base-URL override (self-host / proxy). HTTPS only (localhost
26
26
  * may use http). Ignored by the local provider. */
@@ -6,7 +6,7 @@ import * as path from 'path';
6
6
  import { DEFAULT_PHYSICS_CONFIG, mergePhysicsConfig } from './physics-config.js';
7
7
  import { DEFAULT_HALF_LIFE_DAYS } from './memory.js';
8
8
  import { DEFAULT_LOCAL_BUMP, DEFAULT_RECALL_BUDGET } from './search-types.js';
9
- import { errorMessage, log } from '../util/log.js';
9
+ import { errorCode, errorMessage, log } from '../util/log.js';
10
10
  import { isJsonObject } from '../util/json.js';
11
11
  export const DEFAULT_CONFIG = {
12
12
  defaultHalfLifeDays: DEFAULT_HALF_LIFE_DAYS,
@@ -243,7 +243,12 @@ function fileStamp(file) {
243
243
  return stat === undefined ? null : `${stat.mtimeMs}:${stat.size}`;
244
244
  }
245
245
  catch (err) {
246
- log.debug(`config: ${file} could not be reached, read as missing: ${errorMessage(err)}`);
246
+ const code = errorCode(err);
247
+ const message = `config: ${file} could not be reached, read as missing: ${errorMessage(err)}`;
248
+ if (code === 'EACCES' || code === 'EPERM')
249
+ log.warnThenDebug(`config-unreachable:${file}:${code}`, message, { path: file, code });
250
+ else
251
+ log.debug(message);
247
252
  return null;
248
253
  }
249
254
  }
@@ -0,0 +1,3 @@
1
+ /** Cosine over any indexable vectors (a Float32 view scores as its number[] copy); 0 for empty, mismatched or zero-norm input. */
2
+ export declare function cosineOf(a: ArrayLike<number>, b: ArrayLike<number>): number;
3
+ //# sourceMappingURL=cosine.d.ts.map
@@ -0,0 +1,19 @@
1
+ /** Cosine over any indexable vectors (a Float32 view scores as its number[] copy); 0 for empty, mismatched or zero-norm input. */
2
+ export function cosineOf(a, b) {
3
+ if (a.length === 0 || b.length === 0 || a.length !== b.length)
4
+ return 0;
5
+ let dot = 0;
6
+ let normA = 0;
7
+ let normB = 0;
8
+ for (let i = 0; i < a.length; i++) {
9
+ dot += a[i] * b[i];
10
+ normA += a[i] * a[i];
11
+ normB += b[i] * b[i];
12
+ }
13
+ const denom = Math.sqrt(normA) * Math.sqrt(normB);
14
+ if (denom < 1e-10)
15
+ return 0;
16
+ // Clamp to [-1, 1] to handle floating point drift
17
+ return Math.min(1, Math.max(-1, dot / denom));
18
+ }
19
+ //# sourceMappingURL=cosine.js.map
@@ -1,4 +1,4 @@
1
- import { type MemoryEntry } from '../core/memory.js';
1
+ import { type MemoryEntry } from './memory.js';
2
2
  /** Serialize a MemoryEntry to markdown with YAML frontmatter. */
3
3
  export declare function serializeEntry(entry: MemoryEntry): string;
4
4
  /** Deserialize a markdown file to a MemoryEntry. */
@@ -1,6 +1,6 @@
1
1
  import { DEFAULT_TENANT_ID } from '../util/env.js';
2
- import { FALLBACK_HALF_LIFE_DAYS, DEFAULT_SCHEMA_FIT } from '../core/memory.js';
3
- import { dumpFrontmatter, parseFrontmatter } from './yaml.js';
2
+ import { FALLBACK_HALF_LIFE_DAYS, DEFAULT_SCHEMA_FIT } from './memory.js';
3
+ import { dumpFrontmatter, parseFrontmatter } from '../util/yaml.js';
4
4
  /** The fields every mirror file carries; serializeEntry adds the optional ones. */
5
5
  function entryFrontmatter(entry) {
6
6
  return {
@@ -0,0 +1,17 @@
1
+ import { type MemoryEntry } from './memory.js';
2
+ export type AuditSeverity = 'warning' | 'error';
3
+ export interface AuditIssue {
4
+ memoryId: string;
5
+ content: string;
6
+ severity: AuditSeverity;
7
+ reason: string;
8
+ }
9
+ export interface AuditResult {
10
+ total: number;
11
+ issues: AuditIssue[];
12
+ clean: number;
13
+ }
14
+ export declare function auditMemory(entry: MemoryEntry, backsObject?: boolean): AuditIssue | null;
15
+ /** `backing`: ids of memories that back an object (store.memoriesBackingObjects). */
16
+ export declare function auditMemories(entries: MemoryEntry[], backing: ReadonlySet<string>): AuditResult;
17
+ //# sourceMappingURL=memory-audit.d.ts.map