@remnic/core 9.4.2 → 9.6.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 (379) hide show
  1. package/dist/access-admin-ops-surface.d.ts +6 -6
  2. package/dist/access-admin-ops-surface.js +28 -28
  3. package/dist/access-boundary.d.ts +27 -8
  4. package/dist/access-boundary.js +33 -29
  5. package/dist/access-cli.js +83 -81
  6. package/dist/access-cli.js.map +1 -1
  7. package/dist/access-http.d.ts +52 -6
  8. package/dist/access-http.js +40 -38
  9. package/dist/access-identity-continuity-surface.d.ts +5 -5
  10. package/dist/access-identity-continuity-surface.js +28 -28
  11. package/dist/access-lcm-surface.d.ts +6 -6
  12. package/dist/access-lcm-surface.js +28 -28
  13. package/dist/access-mcp.d.ts +16 -6
  14. package/dist/access-mcp.js +37 -35
  15. package/dist/access-observe-write-surface.d.ts +6 -6
  16. package/dist/access-observe-write-surface.js +28 -28
  17. package/dist/access-operations-batch.js +33 -32
  18. package/dist/access-operations.d.ts +9 -9
  19. package/dist/access-operations.js +35 -34
  20. package/dist/access-recall-surface.d.ts +6 -6
  21. package/dist/access-recall-surface.js +28 -28
  22. package/dist/access-schema.d.ts +4 -4
  23. package/dist/access-schema.js +4 -4
  24. package/dist/{access-service-m-2VO_Ig.d.ts → access-service-CXJaql3A.d.ts} +4 -4
  25. package/dist/access-service.d.ts +6 -6
  26. package/dist/access-service.js +28 -28
  27. package/dist/access-surface-catalog.d.ts +6 -6
  28. package/dist/access-surface-catalog.js +1 -0
  29. package/dist/access-surface-catalog.js.map +1 -1
  30. package/dist/access-token-capabilities.d.ts +174 -0
  31. package/dist/access-token-capabilities.js +33 -0
  32. package/dist/action-confidence.d.ts +1 -1
  33. package/dist/active-memory-bridge.d.ts +1 -1
  34. package/dist/active-recall.d.ts +1 -1
  35. package/dist/active-recall.js +2 -2
  36. package/dist/adapters/index.js +4 -4
  37. package/dist/adapters/registry.js +2 -2
  38. package/dist/{auto-sync-HMHQHUAG.js → auto-sync-4A5YBWYO.js} +4 -4
  39. package/dist/behavior-learner.d.ts +1 -1
  40. package/dist/behavior-signals.d.ts +1 -1
  41. package/dist/bootstrap.d.ts +5 -5
  42. package/dist/briefing.d.ts +2 -2
  43. package/dist/briefing.js +9 -9
  44. package/dist/buffer-surprise-report.d.ts +1 -1
  45. package/dist/buffer.d.ts +2 -2
  46. package/dist/calibration.d.ts +1 -1
  47. package/dist/capabilities.d.ts +1 -1
  48. package/dist/{capsule-crypto-CZJSLEFG.js → capsule-crypto-RAARDY3M.js} +2 -2
  49. package/dist/capsule-crypto-RAARDY3M.js.map +1 -0
  50. package/dist/{catalog-BxWokdC2.d.ts → catalog-C9cu67Ig.d.ts} +1 -1
  51. package/dist/causal-behavior.d.ts +1 -1
  52. package/dist/causal-behavior.js +5 -5
  53. package/dist/causal-chain.js +3 -3
  54. package/dist/causal-consolidation.d.ts +1 -1
  55. package/dist/causal-consolidation.js +13 -13
  56. package/dist/causal-retrieval.js +3 -3
  57. package/dist/causal-trajectory-graph.d.ts +1 -1
  58. package/dist/causal-trajectory.js +1 -1
  59. package/dist/{chunk-6ZIETXZ2.js → chunk-23JFRB73.js} +2 -2
  60. package/dist/{chunk-IC6QX5TC.js → chunk-3XIY7MDQ.js} +6 -6
  61. package/dist/{chunk-FZGGZAAU.js → chunk-4GNEDXDI.js} +146 -2
  62. package/dist/chunk-4GNEDXDI.js.map +1 -0
  63. package/dist/{chunk-LOR6ZM5R.js → chunk-4LV23CHK.js} +2 -2
  64. package/dist/{chunk-E2SPGGUI.js → chunk-4OKLXWDZ.js} +13 -6
  65. package/dist/chunk-4OKLXWDZ.js.map +1 -0
  66. package/dist/{chunk-AER6MT24.js → chunk-6SXVCD7W.js} +2 -2
  67. package/dist/{chunk-OHDJ34CC.js → chunk-72WG5QKN.js} +2 -2
  68. package/dist/{chunk-CZAZX7JP.js → chunk-7MW3CVLD.js} +4 -4
  69. package/dist/{chunk-CXLNZXG5.js → chunk-7XGSIUP5.js} +1 -1
  70. package/dist/{chunk-CZAA5N5S.js → chunk-AYZJID4S.js} +2 -2
  71. package/dist/{chunk-M7XQSUBB.js → chunk-B3ABVQ36.js} +116 -9
  72. package/dist/chunk-B3ABVQ36.js.map +1 -0
  73. package/dist/{chunk-6BISDEN6.js → chunk-BEM4D2QG.js} +14 -14
  74. package/dist/{chunk-ZPOROUTX.js → chunk-CYWA2CXR.js} +5 -5
  75. package/dist/{chunk-M5QKGHCR.js → chunk-CYWCKFCL.js} +5 -5
  76. package/dist/chunk-D7FOKIY5.js +173 -0
  77. package/dist/chunk-D7FOKIY5.js.map +1 -0
  78. package/dist/{chunk-4BFRBP45.js → chunk-DEG5ULFJ.js} +2 -2
  79. package/dist/{chunk-JLR3JSTL.js → chunk-DS7MM2ES.js} +3 -3
  80. package/dist/{chunk-2BFLDH5F.js → chunk-EEIROWEG.js} +2 -2
  81. package/dist/{chunk-5QZDMSSN.js → chunk-FKCRGLRD.js} +237 -82
  82. package/dist/{chunk-5QZDMSSN.js.map → chunk-FKCRGLRD.js.map} +1 -1
  83. package/dist/{chunk-X4A62ET7.js → chunk-H2DXDQCQ.js} +17 -17
  84. package/dist/{chunk-27FLVMDC.js → chunk-HLN7RROI.js} +7 -7
  85. package/dist/chunk-IC2TCZJ2.js +54 -0
  86. package/dist/chunk-IC2TCZJ2.js.map +1 -0
  87. package/dist/{chunk-2U2A5HF4.js → chunk-J3XHPFEU.js} +6 -6
  88. package/dist/{chunk-AKUCU7CI.js → chunk-JI5AVXYO.js} +5 -5
  89. package/dist/{chunk-KCJ5H6XQ.js → chunk-JSNVWNGX.js} +2 -2
  90. package/dist/{chunk-7Z2DZNWN.js → chunk-KL4UAXUY.js} +43 -2
  91. package/dist/{chunk-7Z2DZNWN.js.map → chunk-KL4UAXUY.js.map} +1 -1
  92. package/dist/{chunk-FLVL4L3L.js → chunk-KTULX4YO.js} +4 -4
  93. package/dist/{chunk-ILFJ7AVS.js → chunk-LADFWYHY.js} +35 -21
  94. package/dist/chunk-LADFWYHY.js.map +1 -0
  95. package/dist/{chunk-437S3G37.js → chunk-LNQUAJNC.js} +1 -1
  96. package/dist/{chunk-EPGWWCZF.js → chunk-LR5DZ56F.js} +6 -6
  97. package/dist/{chunk-YDSWRD33.js → chunk-N3JDIRBW.js} +4 -4
  98. package/dist/{chunk-OUMTBFSQ.js → chunk-NKCPUHCI.js} +5 -5
  99. package/dist/{chunk-7QWMTOIF.js → chunk-P454KXD6.js} +112 -34
  100. package/dist/chunk-P454KXD6.js.map +1 -0
  101. package/dist/{chunk-DR6PEJU3.js → chunk-PCLIWBGD.js} +44 -59
  102. package/dist/chunk-PCLIWBGD.js.map +1 -0
  103. package/dist/{chunk-BGTAL46Y.js → chunk-PNLFN2PZ.js} +2 -2
  104. package/dist/{chunk-P6SYWE4G.js → chunk-PVUJ6WVV.js} +10 -10
  105. package/dist/{chunk-YPEMNNNY.js → chunk-RGK27ELN.js} +6 -6
  106. package/dist/{chunk-2QSZNTDO.js → chunk-RKNJBZ55.js} +4 -4
  107. package/dist/{chunk-66FLU5BT.js → chunk-SIRPLF54.js} +6 -6
  108. package/dist/{chunk-M7GGMGMZ.js → chunk-SVOHGUMI.js} +1202 -126
  109. package/dist/chunk-SVOHGUMI.js.map +1 -0
  110. package/dist/{chunk-HRCACVHL.js → chunk-TLUDFPZL.js} +2 -2
  111. package/dist/{chunk-2FOD2YY3.js → chunk-UFUKHGZD.js} +236 -103
  112. package/dist/chunk-UFUKHGZD.js.map +1 -0
  113. package/dist/{chunk-2MR3MFQB.js → chunk-UPSAT4PY.js} +2 -2
  114. package/dist/{chunk-4P4626RY.js → chunk-UTRJFDP2.js} +4 -4
  115. package/dist/{chunk-CGS7UKWM.js → chunk-VCW74PNH.js} +2 -2
  116. package/dist/{chunk-5GPPACXK.js → chunk-VSMRDBFT.js} +2 -1
  117. package/dist/{chunk-NG7YBCJO.js → chunk-XCL57M6Q.js} +4 -4
  118. package/dist/{chunk-CLX5VDNY.js → chunk-Y4RKAQZ7.js} +4 -4
  119. package/dist/{chunk-DGYCWCQ7.js → chunk-Y7UNNAZD.js} +2 -2
  120. package/dist/{chunk-EZ25VE3G.js → chunk-YNDLCWXS.js} +4 -4
  121. package/dist/{chunk-XN3TUUX2.js → chunk-YQB32INI.js} +2 -2
  122. package/dist/{cli-EiBBOt3r.d.ts → cli-CqdPA6z9.d.ts} +3 -3
  123. package/dist/cli.d.ts +7 -7
  124. package/dist/cli.js +61 -59
  125. package/dist/compounding/engine.d.ts +2 -2
  126. package/dist/compounding/engine.js +9 -9
  127. package/dist/compounding/preference-consolidator.d.ts +1 -1
  128. package/dist/compression-optimizer.d.ts +1 -1
  129. package/dist/config.d.ts +1 -1
  130. package/dist/config.js +2 -2
  131. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  132. package/dist/connectors/codex-materialize-runner.js +9 -9
  133. package/dist/connectors/codex-materialize.d.ts +1 -1
  134. package/dist/connectors/index.d.ts +1 -1
  135. package/dist/connectors/index.js +13 -11
  136. package/dist/consolidation-provenance-check.d.ts +2 -2
  137. package/dist/consolidation-undo.d.ts +2 -2
  138. package/dist/contradiction/index.d.ts +2 -2
  139. package/dist/contradiction/index.js +4 -4
  140. package/dist/conversation-index/backend.d.ts +1 -1
  141. package/dist/conversation-index/backend.js +2 -2
  142. package/dist/conversation-index/chunker.d.ts +1 -1
  143. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  144. package/dist/conversation-index/indexer.d.ts +1 -1
  145. package/dist/conversation-index/search.d.ts +1 -1
  146. package/dist/dashboard-runtime.js +2 -2
  147. package/dist/day-summary.d.ts +1 -1
  148. package/dist/delinearize.d.ts +1 -1
  149. package/dist/direct-answer-wiring.d.ts +1 -1
  150. package/dist/direct-answer.d.ts +1 -1
  151. package/dist/embedding-fallback.d.ts +1 -1
  152. package/dist/enrichment/index.d.ts +1 -1
  153. package/dist/entity-retrieval.d.ts +2 -2
  154. package/dist/entity-retrieval.js +9 -9
  155. package/dist/entity-schema.d.ts +1 -1
  156. package/dist/explicit-capture.d.ts +5 -5
  157. package/dist/extraction-faithfulness.d.ts +1 -1
  158. package/dist/extraction-judge-telemetry.d.ts +1 -1
  159. package/dist/extraction-judge-training.d.ts +1 -1
  160. package/dist/extraction-judge.d.ts +1 -1
  161. package/dist/extraction.d.ts +1 -1
  162. package/dist/fallback-llm.d.ts +1 -1
  163. package/dist/{first-start-migration-DY6YCRC2.js → first-start-migration-VBJQL6OI.js} +5 -5
  164. package/dist/graph-dashboard-diff.d.ts +1 -1
  165. package/dist/graph-dashboard-key.d.ts +1 -1
  166. package/dist/graph-dashboard-parser.d.ts +1 -1
  167. package/dist/graph-edge-reinforcement.d.ts +1 -1
  168. package/dist/graph-snapshot.d.ts +1 -1
  169. package/dist/graph.d.ts +1 -1
  170. package/dist/identity-continuity.d.ts +1 -1
  171. package/dist/importance.d.ts +1 -1
  172. package/dist/index.d.ts +271 -17
  173. package/dist/index.js +163 -99
  174. package/dist/intent.d.ts +1 -1
  175. package/dist/lcm/engine.d.ts +1 -1
  176. package/dist/lcm/engine.js +2 -2
  177. package/dist/lcm/index.d.ts +1 -1
  178. package/dist/lcm/index.js +2 -2
  179. package/dist/lcm/tools.d.ts +1 -1
  180. package/dist/lifecycle.d.ts +1 -1
  181. package/dist/live-connectors-runner.d.ts +1 -1
  182. package/dist/local-llm.d.ts +1 -1
  183. package/dist/local-model-endpoint.d.ts +1 -1
  184. package/dist/maintenance/memory-governance.d.ts +1 -1
  185. package/dist/maintenance/memory-governance.js +10 -10
  186. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +9 -9
  187. package/dist/maintenance/rebuild-memory-projection.js +11 -11
  188. package/dist/mcp-memory-inspector-app.d.ts +6 -6
  189. package/dist/mcp-read-only-tools.d.ts +16 -0
  190. package/dist/mcp-read-only-tools.js +8 -0
  191. package/dist/mcp-read-only-tools.js.map +1 -0
  192. package/dist/memory-action-policy.d.ts +1 -1
  193. package/dist/memory-cache.d.ts +1 -1
  194. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  195. package/dist/memory-projection-store.d.ts +1 -1
  196. package/dist/memory-provenance.d.ts +1 -1
  197. package/dist/memory-worth-outcomes.d.ts +2 -2
  198. package/dist/models-json.d.ts +1 -1
  199. package/dist/namespaces/migrate.d.ts +3 -3
  200. package/dist/namespaces/migrate.js +19 -19
  201. package/dist/namespaces/principal.d.ts +1 -1
  202. package/dist/namespaces/search.d.ts +1 -1
  203. package/dist/namespaces/search.js +10 -10
  204. package/dist/namespaces/storage.d.ts +3 -3
  205. package/dist/namespaces/storage.js +9 -9
  206. package/dist/native-knowledge.d.ts +1 -1
  207. package/dist/operator-toolkit.d.ts +2 -2
  208. package/dist/operator-toolkit.js +25 -25
  209. package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
  210. package/dist/orchestration/maintenance.d.ts +2 -2
  211. package/dist/orchestration/maintenance.js +11 -11
  212. package/dist/{orchestrator-B2Y28Z9t.d.ts → orchestrator-CWFrT8AF.d.ts} +91 -60
  213. package/dist/orchestrator.d.ts +5 -5
  214. package/dist/orchestrator.js +85 -83
  215. package/dist/patterns-cli.d.ts +1 -1
  216. package/dist/policy-runtime.d.ts +1 -1
  217. package/dist/provenance.d.ts +1 -1
  218. package/dist/{qmd-Db9mOkzB.d.ts → qmd--fnPMK60.d.ts} +1 -1
  219. package/dist/qmd-preflight.d.ts +2 -2
  220. package/dist/qmd-recall-cache.d.ts +1 -1
  221. package/dist/qmd.d.ts +2 -2
  222. package/dist/recall-disclosure-escalation.d.ts +1 -1
  223. package/dist/recall-explain-renderer.d.ts +1 -1
  224. package/dist/recall-planner-llm.d.ts +1 -1
  225. package/dist/recall-state.d.ts +1 -1
  226. package/dist/recall-tag-filter.d.ts +1 -1
  227. package/dist/recall-timings.d.ts +1 -1
  228. package/dist/recall-xray-cli.d.ts +1 -1
  229. package/dist/recall-xray-renderer.d.ts +1 -1
  230. package/dist/recall-xray.d.ts +1 -1
  231. package/dist/resolve-auth-token.d.ts +1 -1
  232. package/dist/resume-bundles.js +4 -4
  233. package/dist/retrieval-agents.d.ts +2 -2
  234. package/dist/retrieval-tiers.d.ts +1 -1
  235. package/dist/routing/engine.d.ts +1 -1
  236. package/dist/routing/store.d.ts +1 -1
  237. package/dist/schemas.d.ts +22 -22
  238. package/dist/search/document-scanner.js +2 -2
  239. package/dist/search/embed-helper.d.ts +1 -1
  240. package/dist/search/factory.d.ts +1 -1
  241. package/dist/search/factory.js +9 -9
  242. package/dist/search/index.d.ts +1 -1
  243. package/dist/search/index.js +13 -13
  244. package/dist/search/lancedb-backend.d.ts +1 -1
  245. package/dist/search/lancedb-backend.js +3 -3
  246. package/dist/search/meilisearch-backend.d.ts +1 -1
  247. package/dist/search/meilisearch-backend.js +3 -3
  248. package/dist/search/noop-backend.d.ts +1 -1
  249. package/dist/search/orama-backend.d.ts +1 -1
  250. package/dist/search/orama-backend.js +3 -3
  251. package/dist/search/port.d.ts +1 -1
  252. package/dist/search/remote-backend.d.ts +1 -1
  253. package/dist/{semantic-consolidation-BDVIbLRw.d.ts → semantic-consolidation-O5lMZ4LG.d.ts} +1 -1
  254. package/dist/semantic-consolidation.d.ts +2 -2
  255. package/dist/semantic-consolidation.js +11 -11
  256. package/dist/semantic-rule-promotion.js +9 -9
  257. package/dist/semantic-rule-verifier.d.ts +1 -1
  258. package/dist/semantic-rule-verifier.js +10 -10
  259. package/dist/session-observer-bands.d.ts +1 -1
  260. package/dist/session-observer-state.d.ts +1 -1
  261. package/dist/shared-context/manager.d.ts +1 -1
  262. package/dist/signal.d.ts +1 -1
  263. package/dist/storage-C1maCNbc.d.ts +1591 -0
  264. package/dist/storage.d.ts +5 -1239
  265. package/dist/storage.js +8 -8
  266. package/dist/summarizer.d.ts +1 -1
  267. package/dist/summary-snapshot.d.ts +1 -1
  268. package/dist/temporal-supersession.d.ts +2 -2
  269. package/dist/temporal-validity.d.ts +1 -1
  270. package/dist/threading.d.ts +1 -1
  271. package/dist/tier-migration.d.ts +2 -2
  272. package/dist/tier-routing.d.ts +1 -1
  273. package/dist/{tier-stats-TG6GUZ6N.js → tier-stats-5XF4UBRQ.js} +4 -4
  274. package/dist/tokens.d.ts +17 -2
  275. package/dist/tokens.js +3 -1
  276. package/dist/topics.d.ts +1 -1
  277. package/dist/transcript.d.ts +1 -1
  278. package/dist/transfer/backup.js +2 -2
  279. package/dist/transfer/capsule-export.js +3 -3
  280. package/dist/transfer/capsule-import.js +3 -3
  281. package/dist/transfer/types.d.ts +12 -12
  282. package/dist/trust-score-stage.d.ts +1 -1
  283. package/dist/trust-score.d.ts +1 -1
  284. package/dist/{types-ljkd82rn.d.ts → types-CGgcNWCG.d.ts} +31 -1
  285. package/dist/types.d.ts +1 -1
  286. package/dist/utility-runtime.d.ts +1 -1
  287. package/dist/verified-recall.js +10 -10
  288. package/package.json +2 -2
  289. package/src/access-boundary.test.ts +62 -0
  290. package/src/access-boundary.ts +165 -126
  291. package/src/access-http.test.ts +781 -0
  292. package/src/access-http.ts +334 -108
  293. package/src/access-mcp.test.ts +264 -0
  294. package/src/access-mcp.ts +45 -70
  295. package/src/access-operations-batch.ts +35 -12
  296. package/src/access-surface-catalog.test.ts +22 -14
  297. package/src/access-surface-catalog.ts +6 -3
  298. package/src/access-token-capabilities.test.ts +844 -0
  299. package/src/access-token-capabilities.ts +391 -0
  300. package/src/chat/chat-mcp.test.ts +232 -0
  301. package/src/chat/chat-session.ts +34 -0
  302. package/src/cli-wearables-fuse.test.ts +197 -0
  303. package/src/cli.ts +25 -0
  304. package/src/index.ts +14 -0
  305. package/src/mcp-read-only-tools.ts +61 -0
  306. package/src/storage.ts +16 -0
  307. package/src/tokens.ts +32 -3
  308. package/src/wearables/cli.test.ts +102 -0
  309. package/src/wearables/cli.ts +65 -0
  310. package/src/wearables/config.test.ts +32 -0
  311. package/src/wearables/config.ts +52 -0
  312. package/src/wearables/day-store.test.ts +246 -0
  313. package/src/wearables/day-store.ts +272 -3
  314. package/src/wearables/fusion/cluster.ts +230 -0
  315. package/src/wearables/fusion/fuse.ts +218 -0
  316. package/src/wearables/fusion/fusion.test.ts +2575 -0
  317. package/src/wearables/fusion/index.ts +50 -0
  318. package/src/wearables/fusion/reconcile.ts +831 -0
  319. package/src/wearables/fusion/reconstruct.ts +251 -0
  320. package/src/wearables/fusion/store.ts +480 -0
  321. package/src/wearables/fusion/types.ts +228 -0
  322. package/src/wearables/index.ts +41 -0
  323. package/src/wearables/service.test.ts +1030 -2
  324. package/src/wearables/service.ts +258 -16
  325. package/src/wearables/speakers.test.ts +128 -0
  326. package/src/wearables/speakers.ts +58 -4
  327. package/src/wearables/storage-io.test.ts +146 -0
  328. package/src/wearables/types.ts +31 -0
  329. package/dist/chunk-2FOD2YY3.js.map +0 -1
  330. package/dist/chunk-7QWMTOIF.js.map +0 -1
  331. package/dist/chunk-DR6PEJU3.js.map +0 -1
  332. package/dist/chunk-E2SPGGUI.js.map +0 -1
  333. package/dist/chunk-FZGGZAAU.js.map +0 -1
  334. package/dist/chunk-ILFJ7AVS.js.map +0 -1
  335. package/dist/chunk-M7GGMGMZ.js.map +0 -1
  336. package/dist/chunk-M7XQSUBB.js.map +0 -1
  337. /package/dist/{capsule-crypto-CZJSLEFG.js.map → access-token-capabilities.js.map} +0 -0
  338. /package/dist/{auto-sync-HMHQHUAG.js.map → auto-sync-4A5YBWYO.js.map} +0 -0
  339. /package/dist/{chunk-6ZIETXZ2.js.map → chunk-23JFRB73.js.map} +0 -0
  340. /package/dist/{chunk-IC6QX5TC.js.map → chunk-3XIY7MDQ.js.map} +0 -0
  341. /package/dist/{chunk-LOR6ZM5R.js.map → chunk-4LV23CHK.js.map} +0 -0
  342. /package/dist/{chunk-AER6MT24.js.map → chunk-6SXVCD7W.js.map} +0 -0
  343. /package/dist/{chunk-OHDJ34CC.js.map → chunk-72WG5QKN.js.map} +0 -0
  344. /package/dist/{chunk-CZAZX7JP.js.map → chunk-7MW3CVLD.js.map} +0 -0
  345. /package/dist/{chunk-CXLNZXG5.js.map → chunk-7XGSIUP5.js.map} +0 -0
  346. /package/dist/{chunk-CZAA5N5S.js.map → chunk-AYZJID4S.js.map} +0 -0
  347. /package/dist/{chunk-6BISDEN6.js.map → chunk-BEM4D2QG.js.map} +0 -0
  348. /package/dist/{chunk-ZPOROUTX.js.map → chunk-CYWA2CXR.js.map} +0 -0
  349. /package/dist/{chunk-M5QKGHCR.js.map → chunk-CYWCKFCL.js.map} +0 -0
  350. /package/dist/{chunk-4BFRBP45.js.map → chunk-DEG5ULFJ.js.map} +0 -0
  351. /package/dist/{chunk-JLR3JSTL.js.map → chunk-DS7MM2ES.js.map} +0 -0
  352. /package/dist/{chunk-2BFLDH5F.js.map → chunk-EEIROWEG.js.map} +0 -0
  353. /package/dist/{chunk-X4A62ET7.js.map → chunk-H2DXDQCQ.js.map} +0 -0
  354. /package/dist/{chunk-27FLVMDC.js.map → chunk-HLN7RROI.js.map} +0 -0
  355. /package/dist/{chunk-2U2A5HF4.js.map → chunk-J3XHPFEU.js.map} +0 -0
  356. /package/dist/{chunk-AKUCU7CI.js.map → chunk-JI5AVXYO.js.map} +0 -0
  357. /package/dist/{chunk-KCJ5H6XQ.js.map → chunk-JSNVWNGX.js.map} +0 -0
  358. /package/dist/{chunk-FLVL4L3L.js.map → chunk-KTULX4YO.js.map} +0 -0
  359. /package/dist/{chunk-437S3G37.js.map → chunk-LNQUAJNC.js.map} +0 -0
  360. /package/dist/{chunk-EPGWWCZF.js.map → chunk-LR5DZ56F.js.map} +0 -0
  361. /package/dist/{chunk-YDSWRD33.js.map → chunk-N3JDIRBW.js.map} +0 -0
  362. /package/dist/{chunk-OUMTBFSQ.js.map → chunk-NKCPUHCI.js.map} +0 -0
  363. /package/dist/{chunk-BGTAL46Y.js.map → chunk-PNLFN2PZ.js.map} +0 -0
  364. /package/dist/{chunk-P6SYWE4G.js.map → chunk-PVUJ6WVV.js.map} +0 -0
  365. /package/dist/{chunk-YPEMNNNY.js.map → chunk-RGK27ELN.js.map} +0 -0
  366. /package/dist/{chunk-2QSZNTDO.js.map → chunk-RKNJBZ55.js.map} +0 -0
  367. /package/dist/{chunk-66FLU5BT.js.map → chunk-SIRPLF54.js.map} +0 -0
  368. /package/dist/{chunk-HRCACVHL.js.map → chunk-TLUDFPZL.js.map} +0 -0
  369. /package/dist/{chunk-2MR3MFQB.js.map → chunk-UPSAT4PY.js.map} +0 -0
  370. /package/dist/{chunk-4P4626RY.js.map → chunk-UTRJFDP2.js.map} +0 -0
  371. /package/dist/{chunk-CGS7UKWM.js.map → chunk-VCW74PNH.js.map} +0 -0
  372. /package/dist/{chunk-5GPPACXK.js.map → chunk-VSMRDBFT.js.map} +0 -0
  373. /package/dist/{chunk-NG7YBCJO.js.map → chunk-XCL57M6Q.js.map} +0 -0
  374. /package/dist/{chunk-CLX5VDNY.js.map → chunk-Y4RKAQZ7.js.map} +0 -0
  375. /package/dist/{chunk-DGYCWCQ7.js.map → chunk-Y7UNNAZD.js.map} +0 -0
  376. /package/dist/{chunk-EZ25VE3G.js.map → chunk-YNDLCWXS.js.map} +0 -0
  377. /package/dist/{chunk-XN3TUUX2.js.map → chunk-YQB32INI.js.map} +0 -0
  378. /package/dist/{first-start-migration-DY6YCRC2.js.map → first-start-migration-VBJQL6OI.js.map} +0 -0
  379. /package/dist/{tier-stats-TG6GUZ6N.js.map → tier-stats-5XF4UBRQ.js.map} +0 -0
package/dist/storage.d.ts CHANGED
@@ -1,1245 +1,11 @@
1
- import { M as MemoryFile, P as PluginConfig, u as MemoryStatus, h as MemoryCategory, ae as ImportanceScore, aq as MemoryLink, q as MemoryFrontmatter, F as FaithfulnessFrontmatter, J as ProvenanceSource, a7 as EntityStructuredSection, ar as BufferState, as as MetaState, a2 as MemoryActionEvent, w as MemoryLifecycleEvent, X as BufferSurpriseEvent, B as BehaviorSignalEvent, a3 as CompressionGuidelineOptimizerState, aa as ContinuityIncidentOpenInput, a8 as ContinuityIncidentRecord, a9 as ContinuityIncidentCloseInput, ab as ContinuityImprovementLoop, ad as ContinuityLoopUpsertInput, ac as ContinuityLoopReviewInput, at as FileHygieneConfig, au as EntityRelationship, av as EntityActivityEntry, E as EntityFile, aw as AccessTrackingEntry, v as MemoryProjectionCurrentState, ax as MemorySummary, ap as TopicScore, ay as EntityTimelineEntry } from './types-ljkd82rn.js';
2
- import { VersioningConfig } from './page-versioning.js';
3
- import { ConsolidationOperator } from './consolidation-operator.js';
4
- import { ProjectedMemoryBrowseOptions, ProjectedMemoryBrowsePage, readProjectedGovernanceRecord } from './memory-projection-store.js';
1
+ import './types-CGgcNWCG.js';
2
+ import './page-versioning.js';
3
+ export { C as ContentHashIndex, w as MemoryLifecycleEventWriteOptions, M as MemoryWriteResult, R as ReextractJobRequest, S as StorageManager, x as buildEntitySchemaCacheKey, y as compareEntityTimestamps, z as compileEntityFacts, A as countEntityStructuredFacts, B as fingerprintEntityStructuredFacts, E as isEntitySynthesisStale, G as isValidBufferSurpriseEvent, r as normalizeAttributePairs, H as normalizeEntityName, I as normalizeFrontmatterForPath, J as normalizeStructuredSectionFacts, s as parseEntityFile, K as parseFrontmatter, L as parseFrontmatterStringValue, u as serializeEntityFile } from './storage-C1maCNbc.js';
4
+ import './consolidation-operator.js';
5
+ import './memory-projection-store.js';
5
6
  export { stripAttributesSuffix } from './structured-attributes.js';
6
7
  import './types-gb_SNtjR.js';
7
8
  import './message-parts/index.js';
8
9
  import './maintenance/memory-governance.js';
9
10
  import './runtime/better-sqlite.js';
10
11
  import 'better-sqlite3';
11
-
12
- /** Why a tombstone was emitted. */
13
- type TombstoneReason = "correction" | "supersession" | "retraction" | "contradiction_resolution";
14
- /** Who emitted the tombstone. */
15
- type TombstoneCreatedBy = "user_correction" | "contradiction_resolution" | "supersession" | "chat";
16
- /** Tier that matched on lookup. */
17
- type TombstoneMatchTier = "exact" | "normalized" | "keyed" | "semantic";
18
- /**
19
- * A single append-only tombstone log entry.
20
- *
21
- * `kind: "tombstone"` blocks; `kind: "revocation"` re-allows. The log is
22
- * never rewritten — the NEWEST matching entry wins at lookup (rule 25).
23
- */
24
- interface TombstoneEntry {
25
- /** Stable tombstone id (`tomb-<ts>-<rand>`). */
26
- id: string;
27
- kind: "tombstone" | "revocation";
28
- reason: TombstoneReason;
29
- /** The memory that was retired. */
30
- sourceMemoryId: string;
31
- /** sha256 of the retired memory's rawContent (rule 23). */
32
- contentHash: string;
33
- /** `ContentHashIndex.normalizeContent(rawContent)` — the pre-hash form. */
34
- normalizedText: string;
35
- entityRef?: string;
36
- /** Structured-attribute supersession key when one existed. */
37
- supersessionKey?: string;
38
- /** Namespace scope (rule 42). */
39
- namespace: string;
40
- createdAt: string;
41
- createdBy: TombstoneCreatedBy;
42
- /** For `kind: "revocation"`: the tombstone id being revoked. */
43
- revokes?: string;
44
- }
45
- /** A positive block decision returned by `TombstoneStore.lookup`. */
46
- interface TombstoneMatch {
47
- tombstoneId: string;
48
- matchedTier: TombstoneMatchTier;
49
- reason: TombstoneReason;
50
- }
51
- /** Inputs to a lookup. At least one discriminator must be present.
52
- *
53
- * Issue #1579 thread Ociag/Oci-W: `supersessionKeys` (plural) lets the write
54
- * chokepoint check EVERY derived key, not just the first. Emitters register
55
- * one tombstone per matched key (temporal-supersession, rebuild), so a block
56
- * can live on any later key; querying only `supersessionKeys[0]` missed it
57
- * and the retired fact resurrected as active. `supersessionKey` (singular)
58
- * remains for direct/unit callers; `lookup` checks the union of both. */
59
- interface TombstoneLookupQuery {
60
- contentHash?: string;
61
- normalizedText?: string;
62
- entityRef?: string;
63
- /** Single supersession key (direct/unit callers). */
64
- supersessionKey?: string;
65
- /** All derived supersession keys (write chokepoint). The keyed tier is
66
- * checked for each; the first active match wins. */
67
- supersessionKeys?: string[];
68
- namespace: string;
69
- }
70
- /** Configuration for a tombstone store instance. */
71
- interface TombstoneStoreOptions {
72
- enabled: boolean;
73
- semanticMatch: boolean;
74
- semanticThreshold: number;
75
- /** sha256 of raw content — wired to `ContentHashIndex.computeHash`. */
76
- hashContent: (raw: string) => string;
77
- /** Normalize raw content — wired to `ContentHashIndex.normalizeContent`. */
78
- normalizeText: (raw: string) => string;
79
- /**
80
- * Optional cosine similarity in [0, 1] for the semantic tier. When
81
- * undefined or when `semanticMatch` is false, the semantic tier is
82
- * skipped entirely.
83
- */
84
- semanticSimilarity?: (a: string, b: string) => number;
85
- /**
86
- * Cross-process write-lock timings for the tombstone JSONL mutation lock
87
- * (issue #1639). The secure-store append is a read-merge-write (read
88
- * encrypted → decrypt → concat → re-encrypt → atomic rename), so two
89
- * Remnic processes appending concurrently can each read the same contents
90
- * and the last writer drops the other's entry — breaking the
91
- * non-resurrection invariant. The lock serializes the mutation across
92
- * processes. When omitted, defaults that fit the short tombstone critical
93
- * section (mirroring the summary-snapshot lock): staleMs 30s, maxWaitMs 5s,
94
- * heartbeatMs floor(staleMs/3).
95
- */
96
- readonly lockStaleMs?: number;
97
- readonly lockMaxWaitMs?: number;
98
- readonly lockHeartbeatMs?: number;
99
- }
100
- /** Injected file I/O — the StorageManager wires its secure-store-aware
101
- * implementations so tombstones are encrypted at rest alongside other state.
102
- * `stat` is optional; when provided the store tracks the file mtime itself and
103
- * runs a cross-process staleness probe on each access (#1579). */
104
- interface TombstoneFileIo {
105
- read: (filePath: string) => Promise<string>;
106
- append: (filePath: string, content: string) => Promise<void>;
107
- write: (filePath: string, content: string) => Promise<void>;
108
- stat?: (filePath: string) => {
109
- mtimeMs: number;
110
- };
111
- }
112
- /** Aggregate stats for `remnic doctor`. */
113
- interface TombstoneStats {
114
- count: number;
115
- revoked: number;
116
- lastAppendAt: string | null;
117
- corruptedLines: number;
118
- /** Whether the in-memory index matches the on-disk file (rebuild check). */
119
- loaded: boolean;
120
- }
121
- /**
122
- * The instance-scoped tombstone store. One per StorageManager (rule 11),
123
- * namespace-scoped via `namespace` + the on-disk path (rule 42).
124
- *
125
- * The in-memory index is built lazily on first access and invalidated on
126
- * append + by the StorageManager's cache-invalidation chokepoint (rule 25).
127
- */
128
- declare class TombstoneStore {
129
- private readonly filePath;
130
- private readonly namespace;
131
- private readonly options;
132
- private readonly io;
133
- private entries;
134
- /** contentHash → tombstone id (newest) — exact tier. */
135
- private readonly byHash;
136
- /** normalizedText → tombstone id (newest) — normalized tier. */
137
- private readonly byNormalized;
138
- /** entityRef\0supersessionKey → tombstone id (newest) — keyed tier. */
139
- private readonly byKey;
140
- /** Tombstone ids that have a later revocation entry. */
141
- private readonly revokedIds;
142
- /** id → entry index (newest only, for revocation lookups). */
143
- private readonly byId;
144
- private loaded;
145
- private loadPromise;
146
- private corruptedLines;
147
- private lastAppendAt;
148
- /**
149
- * Last-seen mtime of the JSONL file (cross-process staleness probe, #1579).
150
- * Tracked inside the store so the StorageManager wiring stays thin. When the
151
- * file's mtime advances past this value between accesses, the in-memory index
152
- * is stale (a peer process appended) and is reloaded before the next lookup.
153
- */
154
- private fileMtimeMs;
155
- constructor(filePath: string, namespace: string, options: TombstoneStoreOptions, io: TombstoneFileIo);
156
- /**
157
- * Resolved cross-process write-lock timings (issue #1639). Defaults mirror
158
- * the summary-snapshot lock: a tombstone append critical section is
159
- * sub-second, so a stale lock older than 30s is a crashed holder; bounded
160
- * acquisition gives up after 5s and strict-fails rather than clobbering a
161
- * concurrent writer (which would reintroduce the lost-write race this lock
162
- * closes).
163
- */
164
- private readonly lockStaleMs;
165
- private readonly lockMaxWaitMs;
166
- private readonly lockHeartbeatMs;
167
- /**
168
- * Sibling advisory lockfile: `<tombstones>.jsonl` → `<tombstones>.lock`.
169
- * Shared by append, revoke, and rebuild so every JSONL mutation serializes
170
- * against the others across processes (issue #1639: "shared with rebuilds").
171
- */
172
- private get lockPath();
173
- /** Lazy load + build the in-memory index. Idempotent. */
174
- load(): Promise<void>;
175
- private loadInternal;
176
- private resetIndex;
177
- /**
178
- * Index an entry. Later entries (higher array index = newer createdAt)
179
- * OVERRIDE earlier ones at each tier key — the newest matching entry wins
180
- * (rule 25). Revocation entries mark their target as revoked.
181
- */
182
- private indexEntry;
183
- /** Invalidate the in-memory cache (rule 25). The next access reloads. */
184
- invalidate(): void;
185
- /**
186
- * Cross-process staleness probe (#1579). If the file's mtime advanced since
187
- * the last load/own-write, a peer process appended and our in-memory index is
188
- * stale — invalidate AND reload in place so the next lookup sees the new
189
- * entries. Best-effort: a stat error is swallowed (the loaded index is
190
- * retained rather than crashing the write path). No-op when no `stat` was
191
- * injected or when the mtime is unchanged. After our own append/revoke/rebuild
192
- * `markWritten` records the new mtime, so this probe does not fire for our
193
- * own writes (only for peer-process appends).
194
- */
195
- ensureFreshAgainstDisk(): Promise<void>;
196
- /**
197
- * Record the file mtime after THIS process writes (append / revoke / rebuild)
198
- * so `ensureFreshAgainstDisk` does not treat our own write as a peer append
199
- * and throw away the just-updated in-memory index (#1579 — avoids a needless
200
- * invalidate+reload in the hot write path).
201
- */
202
- private markWritten;
203
- private recordFileMtime;
204
- /**
205
- * Append a tombstone entry. Serialized via `serializeMutations` keyed by
206
- * file path so concurrent appends do not interleave, with rejection recovery
207
- * (rule 40 — a single failed append never poisons the chain). The in-memory
208
- * index is updated AFTER the durable append succeeds.
209
- *
210
- * Returns the new tombstone id.
211
- */
212
- appendTombstone(input: {
213
- reason: TombstoneReason;
214
- createdBy: TombstoneCreatedBy;
215
- sourceMemoryId: string;
216
- rawContent: string;
217
- entityRef?: string;
218
- supersessionKey?: string;
219
- createdAt?: string;
220
- /**
221
- * Pre-computed canonical contentHash from the retired memory's frontmatter.
222
- * When provided, used directly so the tombstone's exact tier matches the
223
- * hash writeMemory computes on re-extraction (issue #1579 review: cited
224
- * facts must not slip past the chokepoint because the emitter hashed the
225
- * citation-annotated body instead of the canonical source).
226
- */
227
- contentHash?: string;
228
- }): Promise<string>;
229
- /**
230
- * Append a revocation entry referencing `tombstoneId`. The log is
231
- * append-only; lookup treats a revoked tombstone as re-allowed (rule 25).
232
- */
233
- revoke(tombstoneId: string, createdBy: TombstoneCreatedBy): Promise<string>;
234
- private serializeAppend;
235
- /**
236
- * Acquire the cross-process tombstone write lock and run `task` under it
237
- * (issue #1639). Strict-fail on acquisition timeout: the secure-store append
238
- * is a read-merge-write, so a best-effort unlocked run would clobber a
239
- * concurrent writer — reintroducing the lost-write race this lock closes.
240
- * The thrown error surfaces to the caller (rule 34: never silently drop);
241
- * rebuild recovers the tombstone on the next maintenance cycle.
242
- *
243
- * In-process callers are already serialized by serializeMutations (one key
244
- * for append/revoke/rebuild), so this lock only contends across processes —
245
- * the single-process daemon (default deployment) acquires it immediately.
246
- */
247
- private withWriteLock;
248
- /**
249
- * Look up whether `query` is blocked by an active (non-revoked) tombstone.
250
- * Tiers are checked in order: exact (contentHash) → normalized → keyed →
251
- * semantic (off by default). Returns the first active match, or `null`.
252
- *
253
- * Namespace isolation (rule 42): only entries with `namespace === query.namespace`
254
- * match. The store is per-namespace, so this is belt-and-suspenders.
255
- */
256
- lookup(query: TombstoneLookupQuery): TombstoneMatch | null;
257
- /** Aggregate stats for the doctor / x-ray surfaces. */
258
- stats(): TombstoneStats;
259
- /** Read-only snapshot of all entries (for rebuild + tests). */
260
- snapshot(): readonly TombstoneEntry[];
261
- /**
262
- * Rebuild the in-memory index + JSONL from the supplied retired-memory
263
- * records + existing entries (preserving revocations). Byte-stable: entries
264
- * are sorted by (createdAt, id) before write (rule 38).
265
- *
266
- * Returns the count of tombstone entries written.
267
- */
268
- rebuild(retiredMemories: ReadonlyArray<RetiredMemoryRecord>): Promise<number>;
269
- }
270
- /** A retired memory projected into the shape `TombstoneStore.rebuild` consumes. */
271
- interface RetiredMemoryRecord {
272
- memoryId: string;
273
- rawContent: string;
274
- entityRef?: string;
275
- supersessionKey?: string;
276
- reason: TombstoneReason;
277
- createdBy: TombstoneCreatedBy;
278
- createdAt: string;
279
- /** Canonical contentHash from the retired memory's frontmatter (#1579). */
280
- contentHash?: string;
281
- }
282
-
283
- interface ReextractJobRequest {
284
- memoryId: string;
285
- model: string;
286
- requestedAt: string;
287
- source: "cli-migrate";
288
- }
289
- interface MemoryLifecycleEventWriteOptions {
290
- at?: Date;
291
- actor?: string;
292
- reasonCode?: string;
293
- ruleVersion?: string;
294
- relatedMemoryIds?: string[];
295
- correlationId?: string;
296
- }
297
- declare function parseFrontmatterStringValue(rawValue: string | undefined): string | undefined;
298
- declare function parseFrontmatter(raw: string): {
299
- frontmatter: MemoryFrontmatter;
300
- content: string;
301
- } | null;
302
- declare function normalizeFrontmatterForPath(frontmatter: MemoryFrontmatter, pathRel: string, content?: string): MemoryFrontmatter;
303
- /**
304
- * Normalize an entity name to a canonical form.
305
- * Strips non-alphanumeric chars, collapses hyphens, removes type prefix duplication.
306
- * e.g. "My Project" → "my-project"
307
- *
308
- * Checks caller-provided user aliases first, then built-in aliases. Alias
309
- * tables are instance state on StorageManager (issue #1534) — use
310
- * `storageManager.normalizeEntityName(raw, type)` when normalizing within a
311
- * store, or pass `storageManager.entityAliases` explicitly. Without an
312
- * aliases argument only the built-in structural aliases apply.
313
- */
314
- declare function normalizeEntityName(raw: string, type: string, aliases?: Readonly<Record<string, string>>): string;
315
- /**
316
- * Content-hash dedup index for facts.
317
- * Normalizes content (lowercase, strip punctuation, collapse whitespace),
318
- * computes SHA-256, and stores hashes in a line-delimited file.
319
- * Prevents writing semantically identical facts.
320
- */
321
- declare class ContentHashIndex {
322
- private hashes;
323
- private dirty;
324
- private readonly filePath;
325
- private readonly secureStoreKeyProvider;
326
- private readonly secureStoreWriteKeyProvider;
327
- private readonly memoryDir;
328
- constructor(stateDir: string, secureStoreKeyProvider?: () => Buffer | null, secureStoreWriteKeyProvider?: () => Buffer | null, memoryDir?: string);
329
- /** Load existing hashes from disk. Safe to call multiple times. */
330
- load(): Promise<void>;
331
- /** Check if content already exists in the index. */
332
- has(content: string): boolean;
333
- /** Add content hash to the index. */
334
- add(content: string): void;
335
- get size(): number;
336
- /** Clear all loaded hashes so the next save rewrites the index from scratch. */
337
- clear(): void;
338
- /** Persist index to disk if changed. */
339
- save(): Promise<void>;
340
- /** Remove a hash from the index (used when archiving/deleting). */
341
- remove(content: string): void;
342
- /**
343
- * Remove a pre-computed SHA-256 hash directly from the index without
344
- * re-hashing. Use this when the caller already holds the stored hash
345
- * (e.g. `memory.frontmatter.contentHash`) to avoid the double-hash bug
346
- * where `remove(hash)` would compute `hash(hash)` and never match the
347
- * entry.
348
- */
349
- removeByHash(hash: string): void;
350
- /**
351
- * Add a pre-computed SHA-256 hash directly to the index without re-hashing.
352
- * Use this when the caller already holds the stored hash
353
- * (e.g. `memory.frontmatter.contentHash`) so that the index records the raw
354
- * content hash rather than re-hashing the citation-annotated body.
355
- *
356
- * @internal Only called from `StorageManager.ensureFactHashIndexAuthoritative`.
357
- * Not part of the public API — prefer `add(content)` for external callers.
358
- */
359
- addByHash(hash: string): void;
360
- /** Normalize content (delegates to content-hash.ts for a single source of truth). */
361
- static normalizeContent(content: string): string;
362
- /** Compute SHA-256 hash (delegates to content-hash.ts for a single source of truth). */
363
- static computeHash(content: string): string;
364
- }
365
-
366
- declare function normalizeAttributePairs(pairs: Record<string, string>): string;
367
- declare function normalizeStructuredSectionFacts(facts: string[]): string[];
368
- declare function compileEntityFacts(timeline: EntityTimelineEntry[], structuredSections: EntityStructuredSection[]): string[];
369
- declare function compareEntityTimestamps(left?: string, right?: string): number;
370
- declare function countEntityStructuredFacts(entity: EntityFile): number;
371
- declare function fingerprintEntityStructuredFacts(entity: Pick<EntityFile, "structuredSections">): string | undefined;
372
- declare function isEntitySynthesisStale(entity: EntityFile): boolean;
373
- /**
374
- * Parse an entity markdown file into a structured EntityFile.
375
- * Backward compatible: old files without new sections get empty arrays.
376
- */
377
- declare function parseEntityFile(content: string, entitySchemas?: PluginConfig["entitySchemas"]): EntityFile;
378
- /**
379
- * Serialize an EntityFile back to markdown.
380
- * Writes the compiled-truth + timeline format while remaining parse-compatible
381
- * with the legacy in-memory `summary` and `facts` fields.
382
- */
383
- declare function serializeEntityFile(entity: EntityFile, entitySchemas?: PluginConfig["entitySchemas"]): string;
384
- declare function buildEntitySchemaCacheKey(entitySchemas?: PluginConfig["entitySchemas"]): string;
385
- /**
386
- * Full-schema type guard for a `BUFFER_SURPRISE` telemetry row
387
- * (issue #563 PR 3).
388
- *
389
- * The reader applies `limit` over the count of VALID rows, so
390
- * applying only a partial check (e.g. "has a finite surpriseScore")
391
- * and then deferring the rest of validation to
392
- * `reportBufferSurpriseDistribution` would silently count
393
- * schema-incomplete rows toward the limit, pushing genuinely-valid
394
- * earlier rows out of the report window. Validate everything the
395
- * downstream report requires at read time so the limit semantics and
396
- * the distribution semantics stay consistent.
397
- */
398
- declare function isValidBufferSurpriseEvent(value: unknown): value is BufferSurpriseEvent;
399
- /** Result of {@link StorageManager.writeMemory} (issue #1645). Carries the
400
- * persisted id PLUS the non-resurrection tombstone-block outcome (#1579) so
401
- * post-write callers can observe it — NEVER a silent no-op (rule 34). */
402
- interface MemoryWriteResult {
403
- /** The persisted memory id. */
404
- id: string;
405
- /** True when the #1579 tombstone chokepoint downgraded this write to
406
- * `pending_review` + `blockedBy`. Callers gate active post-write work on this. */
407
- tombstoneBlocked: boolean;
408
- /** The tombstone id that blocked the write, when `tombstoneBlocked`. */
409
- blockedBy?: string;
410
- }
411
- declare class StorageManager {
412
- private readonly baseDir;
413
- private readonly entitySchemas?;
414
- private knowledgeIndexCache;
415
- private artifactIndexCache;
416
- /** Read by storage/entity-store.ts (decomposition), hence not `private`. */
417
- static readonly KNOWLEDGE_INDEX_CACHE_TTL_MS = 600000;
418
- /** Read by storage/memory-read-store.ts (decomposition). */
419
- static readonly ARTIFACT_INDEX_CACHE_TTL_MS = 60000;
420
- private static readonly artifactWriteVersionByDir;
421
- private static readonly memoryStatusVersionByDir;
422
- private static readonly secureStoreEntityCacheKeyIds;
423
- private static nextSecureStoreEntityCacheKeyId;
424
- private static readonly coldWriteVersionByDir;
425
- private static readonly allMemoriesInFlight;
426
- /** Read by storage/memory-read-store.ts (decomposition). */
427
- static readonly COLD_SCAN_CACHE_TTL_MS = 30000;
428
- /** Read by storage/memory-read-store.ts (decomposition). */
429
- static readonly coldMemoriesCache: Map<string, {
430
- memories: MemoryFile[];
431
- loadedAt: number;
432
- coldVersion: number;
433
- }>;
434
- /** Read by storage/memory-read-store.ts (decomposition). */
435
- static readonly QUESTIONS_CACHE_TTL_MS = 60000;
436
- /** Read by storage/memory-read-store.ts (decomposition). */
437
- static readonly questionsCache: Map<string, {
438
- questions: Array<{
439
- id: string;
440
- question: string;
441
- context: string;
442
- priority: number;
443
- resolved: boolean;
444
- created: string;
445
- filePath: string;
446
- }>;
447
- loadedAt: number;
448
- }>;
449
- private factHashIndex;
450
- private factHashIndexLoadPromise;
451
- private factHashIndexAuthoritative;
452
- private factHashIndexAuthoritativePromise;
453
- private readonly secureAppendChains;
454
- private offlineSyncDigestCache;
455
- private offlineSyncDigestCacheLoadPromise;
456
- private offlineSyncDigestCacheWriteChain;
457
- private offlineSyncDigestCacheWriteTimer;
458
- /** Optional: set by the orchestrator after construction to enable template-aware citation stripping during legacy hash rebuild. */
459
- citationTemplate: string;
460
- /** Post-write catalog hook (#1522). Installed by the namespace router; fire-and-forget. */
461
- onCatalogWrite?: () => void;
462
- private notifyCatalogWrite;
463
- private tombstoneStore;
464
- private tombstoneStoreLoadPromise;
465
- private tombstonesConfig;
466
- /** Page-versioning configuration. Set by the orchestrator after construction. */
467
- private _versioningConfig;
468
- /** Set the page-versioning configuration. When `enabled` is false (default), all versioning calls are no-ops. */
469
- setVersioningConfig(config: VersioningConfig): void;
470
- /**
471
- * At-rest encryption key (issue #690 PR 3/4).
472
- *
473
- * When non-null, every memory file read is decrypted and every write
474
- * is encrypted using the secure-fs layer. When null, the storage
475
- * layer operates in plain-text mode (legacy/unencrypted store).
476
- *
477
- * Set by the orchestrator after init/unlock; cleared on lock.
478
- * The key buffer is NEVER logged or serialized.
479
- */
480
- private _secureStoreKey;
481
- /**
482
- * When true (and `_secureStoreKey` is non-null), new writes are
483
- * encrypted. Set to false to pause encryption of new writes while
484
- * still decrypting existing files.
485
- */
486
- private _secureStoreEncryptOnWrite;
487
- /**
488
- * When true, the secure-store is configured as required — writes
489
- * MUST be encrypted and a locked store MUST reject writes rather
490
- * than silently falling back to plaintext. Set by the orchestrator
491
- * from `resolveRecallAuxiliaryCapabilities(config).secureStore`.
492
- */
493
- private _secureStoreRequired;
494
- /**
495
- * Set or clear the at-rest encryption key.
496
- *
497
- * Pass a 32-byte Buffer to enable encryption; pass null to clear
498
- * (lock) the store. The caller is responsible for key lifecycle —
499
- * this method does not zero the buffer on replacement; the keyring
500
- * module (`keyring.ts`) owns zeroization.
501
- */
502
- setSecureStoreKey(key: Buffer | null, encryptOnWrite?: boolean): void;
503
- private getEntityCacheSecureStoreKey;
504
- /**
505
- * Mark the secure-store as required for this storage instance.
506
- * When required and locked, writes throw SecureStoreLockedError
507
- * rather than silently writing plaintext.
508
- */
509
- setSecureStoreRequired(required: boolean): void;
510
- /** Return true iff the secure-store key is currently set (store is unlocked). */
511
- isSecureStoreUnlocked(): boolean;
512
- /**
513
- * Resolve the effective write key.
514
- *
515
- * - If `_secureStoreEncryptOnWrite` is false: returns null (plain write).
516
- * - If `_secureStoreEncryptOnWrite` is true AND key is set: returns key.
517
- * - If `_secureStoreEncryptOnWrite` is true AND key is null AND
518
- * `_secureStoreRequired` is true: throws SecureStoreLockedError so the
519
- * write fails loudly rather than silently writing plaintext (P1 finding
520
- * from Cursor review of PR #767).
521
- * - If `_secureStoreEncryptOnWrite` is true AND key is null AND
522
- * `_secureStoreRequired` is false: returns null (unencrypted store).
523
- */
524
- private resolveWriteKey;
525
- /**
526
- * Snapshot the current content of a page before overwriting.
527
- * No-op when versioning is disabled or the file does not yet exist.
528
- */
529
- private snapshotBeforeWrite;
530
- /**
531
- * Consolidation provenance helper (issue #561 PR 2).
532
- *
533
- * Captures the current on-disk content of a source memory as a
534
- * page-version snapshot so the downstream consolidated write can record a
535
- * `derived_from` pointer that actually resolves. Returns the
536
- * `"<relative-path>:<versionId>"` entry expected by the `derived_from`
537
- * frontmatter field.
538
- *
539
- * Returns `null` when versioning is disabled (snapshots would not be
540
- * created), when the file does not exist (nothing to snapshot), or when
541
- * the snapshot write itself fails (best-effort — callers skip the entry
542
- * rather than block the consolidation).
543
- */
544
- snapshotForProvenance(filePath: string): Promise<string | null>;
545
- constructor(baseDir: string, entitySchemas?: PluginConfig["entitySchemas"]);
546
- /**
547
- * The LIVE class object of this instance (issue #1809 review of the
548
- * storage decomposition): extracted store modules must read/write the
549
- * shared static caches (questionsCache, coldMemoriesCache, ...) through
550
- * the SAME class binding the host methods use. Referencing the imported
551
- * `StorageManager` symbol from a split bundle chunk can yield a second
552
- * class copy with its own statics, split-braining the caches
553
- * (resolveQuestion clears copy A while readQuestions reads copy B).
554
- */
555
- get storageManagerClass(): typeof StorageManager;
556
- /** The root directory of this storage instance. */
557
- /** MemoryReadStore (storage.ts decomposition). Lazy; selfDeps live wiring. */
558
- private _memoryReadStore;
559
- private get memoryReadStore();
560
- /** EntityStore (storage.ts decomposition). Lazy; selfDeps live wiring. */
561
- private _entityStore;
562
- private get entityStore();
563
- /** IdentityContinuityStore (storage.ts decomposition). Lazy; selfDeps live wiring. */
564
- private _identityContinuityStore;
565
- private get identityContinuityStore();
566
- get dir(): string;
567
- private identityFilePath;
568
- private versionFilePath;
569
- private bumpSharedVersion;
570
- private readSharedVersion;
571
- private bumpMemoryStatusVersion;
572
- getMemoryStatusVersion(): number;
573
- private bumpArtifactWriteVersion;
574
- private getArtifactWriteVersion;
575
- private get wearablesDir();
576
- /**
577
- * Resolve the on-disk path for a source/day transcript. Throws on
578
- * malformed inputs — source ids and dates reach this from CLI/MCP/HTTP
579
- * surfaces and must never become path traversal.
580
- */
581
- wearableTranscriptPath(sourceId: string, date: string): string;
582
- writeWearableDayTranscript(sourceId: string, date: string, serialized: string): Promise<void>;
583
- /** Read a stored day transcript; null when the day has no file. */
584
- readWearableDayTranscript(sourceId: string, date: string): Promise<string | null>;
585
- listWearableTranscriptDays(sourceId?: string): Promise<Array<{
586
- source: string;
587
- date: string;
588
- }>>;
589
- /**
590
- * Locate a wearable-sourced memory by exact (trimmed) content,
591
- * ignoring the "[Attributes: ...]" suffix writeMemory appends for
592
- * structuredAttributes — callers pass the raw fact text. Used by the
593
- * smart trust pipeline to find an earlier borderline write when the
594
- * same fact re-extracts with stronger evidence.
595
- */
596
- findWearableMemoryByContent(content: string): Promise<{
597
- id: string;
598
- status: MemoryStatus | undefined;
599
- } | null>;
600
- /**
601
- * Promote a pending_review wearable memory to active in place,
602
- * merging updated trust evidence into structuredAttributes. Returns
603
- * false when the memory is missing or no longer pending_review (a
604
- * concurrent review decision wins), or when the row is tombstone-blocked
605
- * (`blockedBy` — issue #1579 threads OcuDx/Ocu1l): writeMemoryFrontmatter
606
- * bypasses the writeMemory chokepoint, so a blocked row must first be
607
- * cleared via revokeTombstone before promotion can proceed.
608
- */
609
- promoteWearableMemory(id: string, attributeUpdates: Record<string, string>, confidence?: number): Promise<boolean>;
610
- /**
611
- * Demote a pending_review wearable memory to rejected when a re-pass
612
- * produced an explicit judge-reject verdict, merging the evidence.
613
- * Returns false when the memory is missing or no longer
614
- * pending_review — active rows are NEVER auto-demoted (operator
615
- * approvals and accrued recall signals win; contradiction scans and
616
- * supersession own active-row retirement).
617
- */
618
- demoteWearableMemory(id: string, attributeUpdates: Record<string, string>): Promise<boolean>;
619
- private get factsDir();
620
- private get correctionsDir();
621
- private get proceduresDir();
622
- private get reasoningTracesDir();
623
- private get entitiesDir();
624
- private resolveEntityFilePath;
625
- private readStorageSecureFile;
626
- private writeStorageSecureFile;
627
- private writeStorageSecureFileChunks;
628
- private assertManagedStoragePath;
629
- readOfflineSyncFile(filePath: string): Promise<Buffer>;
630
- digestOfflineSyncFile(filePath: string): Promise<{
631
- sha256: string;
632
- bytes: number;
633
- }>;
634
- private loadOfflineSyncDigestCache;
635
- private readOfflineSyncDigestCache;
636
- private rememberOfflineSyncDigest;
637
- private scheduleOfflineSyncDigestCacheWrite;
638
- private queueOfflineSyncDigestCacheWrite;
639
- private offlineSyncFileIsEncrypted;
640
- writeOfflineSyncFile(filePath: string, content: Buffer): Promise<void>;
641
- writeOfflineSyncStagingFile(filePath: string, content: Buffer): Promise<void>;
642
- writeOfflineSyncFileChunks(filePath: string, chunks: AsyncIterable<Buffer>): Promise<void>;
643
- deleteOfflineSyncFile(filePath: string): Promise<void>;
644
- private invalidateAfterOfflineSyncMutation;
645
- createContentHashIndex(): ContentHashIndex;
646
- private appendStorageSecureFile;
647
- private appendStorageSecureFileUnlocked;
648
- private get stateDir();
649
- private get offlineSyncDigestCachePath();
650
- private get entitySynthesisQueuePath();
651
- private get factHashIndexReadyPath();
652
- /**
653
- * The on-disk tombstone log path. Lives under `<stateDir>/tombstones.jsonl`
654
- * so it is co-located with the fact-hash index and encrypted at rest when
655
- * the secure-store is enabled (the StorageManager's secure read/write
656
- * helpers are injected into the store).
657
- */
658
- private get tombstonesPath();
659
- /**
660
- * Configure the tombstone invariant for this storage instance. Installed
661
- * by the orchestrator after construction (same pattern as
662
- * `setVersioningConfig` / `citationTemplate`). When `enabled` is false
663
- * (default until the orchestrator wires config), the chokepoint check is a
664
- * no-op — pre-feature behavior for rollback safety (rule 30).
665
- */
666
- setTombstonesConfig(config: {
667
- enabled: boolean;
668
- semanticMatch: boolean;
669
- semanticThreshold: number;
670
- namespace: string;
671
- }): void;
672
- private buildTombstoneStore;
673
- /**
674
- * Lazily load the tombstone store. Mirrors the fact-hash-index lazy-load
675
- * pattern: a single in-flight load promise dedups concurrent first-access.
676
- * The cross-process staleness probe lives inside the store now (#1579): on
677
- * each cached access it stats its own file and invalidates if a peer process
678
- * appended, so the next lookup reloads from disk. If the probe just
679
- * invalidated the store, fall through to the reload branch — returning null
680
- * here was the original regression (the chokepoint threw and failed OPEN).
681
- */
682
- getTombstoneStore(): Promise<TombstoneStore>;
683
- /**
684
- * Whether tombstones are enabled on this storage. Callers that need to
685
- * distinguish "tombstones disabled" (null return is expected) from
686
- * "persistence failed" (appendTombstone swallows store errors and also
687
- * returns null) use this to fail closed when enabled (#1580 review OgIqp).
688
- */
689
- isTombstonesEnabled(): boolean;
690
- /**
691
- * Append a tombstone for a retired memory (issue #1579 emitters).
692
- * Best-effort: a tombstone append failure MUST NOT fail the supersession /
693
- * correction that triggered it (gotcha #13 / rule 34). The memory is
694
- * already retired on disk; the tombstone is the non-resurrection guard.
695
- */
696
- appendTombstone(input: {
697
- reason: TombstoneReason;
698
- createdBy: TombstoneCreatedBy;
699
- sourceMemoryId: string;
700
- rawContent: string;
701
- entityRef?: string;
702
- supersessionKey?: string;
703
- createdAt?: string;
704
- /** Canonical contentHash from the retired memory's frontmatter (#1579). */
705
- contentHash?: string;
706
- }): Promise<string | null>;
707
- /**
708
- * Revoke a tombstone (re-allow the content). Used by the review-queue
709
- * approval path when an operator approves a blocked memory.
710
- */
711
- revokeTombstone(tombstoneId: string, createdBy: TombstoneCreatedBy): Promise<string | null>;
712
- /** Aggregate tombstone stats for `remnic doctor`. */
713
- getTombstoneStats(): Promise<TombstoneStats | null>;
714
- /**
715
- * Rebuild the tombstone log from retired memories on disk. Exposed for
716
- * `remnic doctor --rebuild-tombstones` and tests.
717
- */
718
- rebuildTombstonesFromFiles(): Promise<number>;
719
- private getFactHashIndex;
720
- private ensureFactHashIndexAuthoritative;
721
- private get questionsDir();
722
- private get artifactsDir();
723
- private get identityDir();
724
- private get identityAnchorPath();
725
- private get identityIncidentsDir();
726
- private get identityAuditsWeeklyDir();
727
- private get identityAuditsMonthlyDir();
728
- private get identityImprovementLoopsPath();
729
- private get identityReflectionsPath();
730
- private get profilePath();
731
- private get memoryActionsPath();
732
- private get memoryLifecycleLedgerPath();
733
- private get compressionGuidelinesPath();
734
- private get compressionGuidelineDraftPath();
735
- private get compressionGuidelineStatePath();
736
- private get compressionGuidelineDraftStatePath();
737
- private get behaviorSignalsPath();
738
- /**
739
- * Buffer surprise telemetry ledger (issue #563 PR 3).
740
- *
741
- * Append-only JSONL of per-turn `BUFFER_SURPRISE` events emitted by
742
- * `SmartBuffer` when `bufferSurpriseTriggerEnabled` is on. Each row
743
- * captures the score, the threshold in force at the time, whether the
744
- * turn caused an extract_now upgrade, and the buffer size. Kept in
745
- * `state/` alongside the other append-only ledgers so cleanup and
746
- * governance sweeps can treat it uniformly.
747
- */
748
- private get bufferSurpriseLedgerPath();
749
- /**
750
- * Entity alias table loaded from THIS store's config/aliases.json.
751
- * Instance-scoped on purpose (issue #1534): multiple StorageManager
752
- * instances in one process (namespaces, hosted profiles, tenants) must
753
- * never share alias state — the previous module-level table let whichever
754
- * store loaded last rewrite every other store's canonical entity ids.
755
- */
756
- private userAliases;
757
- normalizeEntityName(raw: string, type: string): string;
758
- /**
759
- * Read-only view of this store's user alias table, for call sites that
760
- * normalize outside the manager (pass it to the free `normalizeEntityName`).
761
- */
762
- get entityAliases(): Readonly<Record<string, string>>;
763
- /**
764
- * Reload user-defined entity aliases from config/aliases.json in the memory
765
- * store. File format: { "variant": "canonical", ... }. The constructor
766
- * already loads aliases, so this is only needed to pick up file changes
767
- * (e.g. orchestrator.initialize() re-running on a live instance).
768
- * Non-object payloads and non-string or empty alias values are ignored.
769
- */
770
- loadAliases(): Promise<void>;
771
- private loadAliasesSync;
772
- ensureDirectories(): Promise<void>;
773
- /**
774
- * Resolve the on-disk write path for a memory of the given category, creating
775
- * the target directory. Category routing goes through the shared
776
- * `getCategoryDir()` chokepoint (utils/category-dir.ts → CATEGORY_DIR_MAP) so
777
- * decision/preference/moment/etc. outputs land in their dedicated dirs
778
- * (`decisions/`, `preferences/`, ...) instead of collapsing into `facts/`
779
- * (issue #1546; CLAUDE.md rule 39). `correction` keeps its historical flat
780
- * layout (no `<date>` subdir) as the corrections pipeline expects; every other
781
- * category — including `fact`/`entity`, which fall back to `facts/` — is dated
782
- * as `<dir>/<date>/`. Read/scan/reindex already iterate every category dir
783
- * (RECALL_FALLBACK_DIRS; QMD scans baseDir recursively), so writes stay found.
784
- */
785
- private resolveCategoryWritePath;
786
- writeMemory(category: MemoryCategory, content: string, options?: {
787
- actor?: string;
788
- confidence?: number;
789
- tags?: string[];
790
- entityRef?: string;
791
- source?: string;
792
- supersedes?: string;
793
- lineage?: string[];
794
- importance?: ImportanceScore;
795
- links?: MemoryLink[];
796
- intentGoal?: string;
797
- intentActionType?: string;
798
- intentEntityTypes?: string[];
799
- artifactType?: MemoryFrontmatter["artifactType"];
800
- sourceMemoryId?: string;
801
- sourceTurnId?: string;
802
- memoryKind?: MemoryFrontmatter["memoryKind"];
803
- expiresAt?: string;
804
- validAt?: string;
805
- observedAt?: string;
806
- eventTimeSource?: "extracted" | "assumed";
807
- invalidAt?: string;
808
- structuredAttributes?: Record<string, string>;
809
- /**
810
- * When provided, this string is used as the source for the fact-content
811
- * dedup hash index instead of the persisted body (`content`).
812
- *
813
- * Use this when the persisted body differs from the canonical fact text
814
- * — for example when `content` is a citation-annotated variant of a raw
815
- * fact. Passing the raw fact as `contentHashSource` ensures that
816
- * `hasFactContentHash(rawFact)` returns `true` after the write, so
817
- * subsequent extractions of the same logical fact are correctly deduped
818
- * even when their citation timestamp differs.
819
- */
820
- contentHashSource?: string;
821
- status?: MemoryStatus;
822
- /**
823
- * Consolidation provenance (issue #561 PR 2). When the caller is a
824
- * consolidation / supersession / dedup-merge path, these fields wire
825
- * the page-version snapshots the new memory was derived from and the
826
- * operator that produced it. Persisted onto frontmatter as
827
- * `derived_from` + `derived_via`; validated at serialize time.
828
- */
829
- derivedFrom?: string[];
830
- derivedVia?: ConsolidationOperator;
831
- /**
832
- * Faithfulness gate verdict (issue #1576). When provided, persisted to
833
- * frontmatter so downstream readers (TrustScore #1577, review queue)
834
- * can consume it. Absent = gate was off or fact predates #1576.
835
- */
836
- faithfulness?: FaithfulnessFrontmatter;
837
- /**
838
- * Claim-level provenance spans (issue #1575 PR 2). When provided,
839
- * persisted to frontmatter so downstream readers (memory_get, x-ray,
840
- * faithfulness gate #1576) can consume them. Absent = fact predates
841
- * #1575 or provenance was disabled.
842
- */
843
- sources?: ProvenanceSource[];
844
- provenance?: "verified" | "unverified" | "none";
845
- }): Promise<MemoryWriteResult>;
846
- hasFactContentHash(content: string): Promise<boolean>;
847
- private factContentHashForRemoval;
848
- private addActiveFactContentHash;
849
- /**
850
- * Re-register a fact's contentHash in the dedup index after a tombstone
851
- * block is lifted on approval (issue #1579 thread ObnTy). `writeMemory`
852
- * skips hash-index registration for tombstone-blocked facts (rule 44); when
853
- * the review queue later promotes such a fact back to `status: active`, the
854
- * hash must enter the index or the next extraction of the same content
855
- * creates a second active fact. Reads the memory by id so the caller (the
856
- * review CLI) does not need to re-parse the file. No-op for non-facts or
857
- * facts that are not active.
858
- */
859
- restoreFactHashAfterApproval(memoryId: string): Promise<void>;
860
- private syncFactHashIndexAfterRewrite;
861
- removeFactContentHashesForMemories(memories: MemoryFile[]): Promise<void>;
862
- isFactContentHashAuthoritative(): Promise<boolean>;
863
- writeArtifact(quote: string, options?: {
864
- actor?: string;
865
- tags?: string[];
866
- confidence?: number;
867
- artifactType?: MemoryFrontmatter["artifactType"];
868
- sourceMemoryId?: string;
869
- sourceTurnId?: string;
870
- intentGoal?: string;
871
- intentActionType?: string;
872
- intentEntityTypes?: string[];
873
- }): Promise<string>;
874
- private readAllArtifactsCached;
875
- searchArtifacts(query: string, maxResults: number): Promise<MemoryFile[]>;
876
- writeEntity(name: string, type: string, facts: string[], options?: {
877
- timestamp?: string;
878
- source?: string;
879
- sessionKey?: string;
880
- principal?: string;
881
- structuredSections?: EntityStructuredSection[];
882
- }): Promise<string>;
883
- readProfile(): Promise<string>;
884
- writeProfile(content: string): Promise<void>;
885
- /**
886
- * Normalize a string for fuzzy profile dedup: lowercase, strip punctuation, collapse whitespace.
887
- */
888
- private static normalizeForDedup;
889
- /**
890
- * Check if a new bullet is a fuzzy duplicate of any existing bullet.
891
- * Returns true if the new bullet should be skipped.
892
- */
893
- private static isFuzzyDuplicate;
894
- appendToProfile(updates: string[]): Promise<void>;
895
- /** Check if profile.md exceeds the max line cap and needs LLM consolidation */
896
- profileNeedsConsolidation(triggerLines?: number): Promise<boolean>;
897
- readAllMemories(): Promise<MemoryFile[]>;
898
- /** Invalidate the readAllMemories() cache after writes that add/remove memories. */
899
- /** Public cache invalidation for callers that need authoritative disk reads
900
- * (e.g. projection verify/rebuild). */
901
- invalidateAllMemoriesCacheForDir(): void;
902
- /** Invalidate only the cache layers affected by direct tier file deletes. */
903
- invalidateMemoryCachesForTiers(tiers: Iterable<"hot" | "cold" | "archive">): void;
904
- /** Clear ALL static caches. Use in tests that write files directly
905
- * (bypassing StorageManager.writeMemory) to avoid stale reads. */
906
- static clearAllStaticCaches(): void;
907
- /** Cancel any in-flight concurrent read so the next readAllMemories()
908
- * starts a fresh disk scan and sees the just-written data.
909
- *
910
- * Finding UvBq (PR #402 round-11): this method intentionally does NOT
911
- * invalidate the cold-scan cache. Ordinary hot-tier writes (writeMemory)
912
- * do not change cold-tier content, so evicting the cold cache on every hot
913
- * write was defeating the burst-dedup optimisation — the cold cache was
914
- * cleared before applyTemporalSupersession ran, causing a full cold-tree
915
- * disk scan on every write in a burst. Cold cache invalidation is handled
916
- * exclusively by invalidateColdMemoriesCache(), which is called only when
917
- * cold content actually changes (hot→cold demotions, writeMemoryFileAtomic
918
- * inside cold/, archiveMemory, etc.). */
919
- private invalidateAllMemoriesCache;
920
- /**
921
- * Invalidate the cold-scan cache for this storage root and bump the
922
- * on-disk cold-version sentinel so that other processes (gateway, CLI) see
923
- * the change immediately on their next readAllColdMemories() call.
924
- *
925
- * Must be called whenever a memory is written INTO the cold tier — hot→cold
926
- * demotion, atomic writes inside cold/, archiving a cold memory, etc.
927
- * NOT called on ordinary hot-tier writes (those don't change cold contents).
928
- *
929
- * Finding UvUy (PR #402 round-11): bumping the sentinel here makes the
930
- * per-process in-memory cache safe across process boundaries.
931
- */
932
- private invalidateColdMemoriesCache;
933
- /** Return the current cold-write version counter for this storage root.
934
- * Reads the on-disk sentinel (state/cold-write.log) so it reflects writes
935
- * made by other processes. */
936
- private readColdWriteVersion;
937
- /** Bump the on-disk cold-write version sentinel and update the in-process
938
- * fallback map. Called by invalidateColdMemoriesCache(). */
939
- private bumpColdWriteVersion;
940
- private normalizeMemoryReadBatchSize;
941
- private collectActiveMemoryPaths;
942
- private readParsedMemoriesFromPaths;
943
- private readWindowUpdatedMs;
944
- private filterWindowPathsByUpdatedAfter;
945
- private orderWindowPaths;
946
- private readWindowBoundedBatch;
947
- readMemoriesWindow(options?: {
948
- maxMemories?: number;
949
- batchSize?: number;
950
- updatedAfter?: Date;
951
- }): Promise<{
952
- memories: MemoryFile[];
953
- filePaths: string[];
954
- }>;
955
- private _readAllMemoriesFromDisk;
956
- readAllColdMemories(): Promise<MemoryFile[]>;
957
- /**
958
- * Read archived memory markdown files under archive/.
959
- * Used by long-term recall fallback when hot recall has no hits.
960
- */
961
- readArchivedMemories(): Promise<MemoryFile[]>;
962
- readMemoryByPath(filePath: string): Promise<MemoryFile | null>;
963
- private resolveTierRootDir;
964
- private resolveMemoryDateDir;
965
- private isArtifactMemory;
966
- buildTierMemoryPath(memory: MemoryFile, tier: "hot" | "cold"): string;
967
- private writeMemoryFileAtomic;
968
- moveMemoryToPath(memory: MemoryFile, targetPath: string): Promise<void>;
969
- migrateMemoryToTier(memory: MemoryFile, targetTier: "hot" | "cold"): Promise<{
970
- changed: boolean;
971
- targetPath: string;
972
- }>;
973
- private get archiveDir();
974
- /**
975
- * Archive a memory by moving it from facts/ to archive/YYYY-MM-DD/.
976
- * Updates frontmatter with archived status before moving.
977
- * Returns the new file path on success, null on failure.
978
- */
979
- archiveMemory(memory: MemoryFile, lifecycle?: MemoryLifecycleEventWriteOptions): Promise<string | null>;
980
- readEntities(): Promise<string[]>;
981
- readEntity(name: string): Promise<string>;
982
- listEntityNames(): Promise<string[]>;
983
- /**
984
- * Find an existing entity that fuzzy-matches the proposed name.
985
- * Returns the existing entity filename (without .md) or null if no match.
986
- *
987
- * Matching priority:
988
- * 1. Exact normalized match (handled by normalizeEntityName already)
989
- * 2. Dehyphenated match: "jane-doe" vs "janedoe"
990
- * 3. Substring containment: "handle-janedoe" contains "janedoe"
991
- * 4. Levenshtein ≤ 2 on dehyphenated names
992
- */
993
- findMatchingEntity(proposedName: string, type: string): Promise<string | null>;
994
- invalidateMemory(id: string): Promise<boolean>;
995
- updateMemory(id: string, newContent: string, options?: {
996
- supersedes?: string;
997
- lineage?: string[];
998
- actor?: string;
999
- }): Promise<boolean>;
1000
- /**
1001
- * Update frontmatter fields without changing memory content.
1002
- * Returns false when the memory is not found.
1003
- */
1004
- writeMemoryFrontmatter(memory: MemoryFile, patch: Partial<MemoryFrontmatter>, lifecycle?: MemoryLifecycleEventWriteOptions): Promise<boolean>;
1005
- /**
1006
- * Update frontmatter by memory ID.
1007
- * Prefer writeMemoryFrontmatter(memory, patch) in batch loops to avoid full-corpus rescans.
1008
- */
1009
- updateMemoryFrontmatter(id: string, patch: Partial<MemoryFrontmatter>): Promise<boolean>;
1010
- /** Remove memories past their TTL expiresAt date */
1011
- cleanExpiredTTL(): Promise<MemoryFile[]>;
1012
- loadBuffer(): Promise<BufferState>;
1013
- saveBuffer(state: BufferState): Promise<void>;
1014
- loadMeta(): Promise<MetaState>;
1015
- saveMeta(state: MetaState): Promise<void>;
1016
- appendMemoryActionEvents(events: MemoryActionEvent[]): Promise<number>;
1017
- appendMemoryLifecycleEvents(events: MemoryLifecycleEvent[]): Promise<number>;
1018
- appendBufferSurpriseEvents(events: BufferSurpriseEvent[]): Promise<number>;
1019
- readBufferSurpriseEvents(options?: {
1020
- limit?: number;
1021
- }): Promise<BufferSurpriseEvent[]>;
1022
- appendBehaviorSignals(events: BehaviorSignalEvent[]): Promise<number>;
1023
- appendReextractJobs(events: ReextractJobRequest[]): Promise<number>;
1024
- readReextractJobs(limit?: number): Promise<ReextractJobRequest[]>;
1025
- readBehaviorSignals(limit?: number): Promise<BehaviorSignalEvent[]>;
1026
- readMemoryActionEvents(limit?: number): Promise<MemoryActionEvent[]>;
1027
- readMemoryActionEventRows(limit?: number): Promise<Array<{
1028
- line: number;
1029
- event: MemoryActionEvent;
1030
- }>>;
1031
- readAllMemoryLifecycleEvents(): Promise<MemoryLifecycleEvent[]>;
1032
- readMemoryLifecycleEvents(limit?: number): Promise<MemoryLifecycleEvent[]>;
1033
- writeCompressionGuidelines(content: string): Promise<void>;
1034
- readCompressionGuidelines(): Promise<string | null>;
1035
- writeCompressionGuidelineDraft(content: string): Promise<void>;
1036
- readCompressionGuidelineDraft(): Promise<string | null>;
1037
- writeCompressionGuidelineOptimizerState(state: CompressionGuidelineOptimizerState): Promise<void>;
1038
- writeCompressionGuidelineDraftState(state: CompressionGuidelineOptimizerState): Promise<void>;
1039
- readCompressionGuidelineOptimizerState(): Promise<CompressionGuidelineOptimizerState | null>;
1040
- readCompressionGuidelineDraftState(): Promise<CompressionGuidelineOptimizerState | null>;
1041
- activateCompressionGuidelineDraft(options?: {
1042
- expectedContentHash?: string;
1043
- expectedGuidelineVersion?: number;
1044
- }): Promise<boolean>;
1045
- private readCompressionGuidelineStateFile;
1046
- writeIdentityAnchor(content: string): Promise<void>;
1047
- readIdentityAnchor(): Promise<string | null>;
1048
- appendContinuityIncident(input: ContinuityIncidentOpenInput): Promise<ContinuityIncidentRecord>;
1049
- readContinuityIncidents(limit?: number, state?: "open" | "closed" | "all"): Promise<ContinuityIncidentRecord[]>;
1050
- closeContinuityIncident(id: string, closure: ContinuityIncidentCloseInput): Promise<ContinuityIncidentRecord | null>;
1051
- writeIdentityAudit(period: "weekly" | "monthly", key: string, content: string): Promise<string>;
1052
- readIdentityAudit(period: "weekly" | "monthly", key: string): Promise<string | null>;
1053
- writeIdentityImprovementLoops(content: string): Promise<void>;
1054
- readIdentityImprovementLoops(): Promise<string | null>;
1055
- readIdentityImprovementLoopRegister(): Promise<ContinuityImprovementLoop[]>;
1056
- upsertIdentityImprovementLoop(input: ContinuityLoopUpsertInput): Promise<ContinuityImprovementLoop>;
1057
- reviewIdentityImprovementLoop(id: string, input: ContinuityLoopReviewInput): Promise<ContinuityImprovementLoop | null>;
1058
- private generateId;
1059
- writeQuestion(question: string, context: string, priority: number): Promise<string>;
1060
- readQuestions(opts?: {
1061
- unresolvedOnly?: boolean;
1062
- }): Promise<Array<{
1063
- id: string;
1064
- question: string;
1065
- context: string;
1066
- priority: number;
1067
- resolved: boolean;
1068
- created: string;
1069
- filePath: string;
1070
- }>>;
1071
- /** Invalidate the questions cache (call after writing a question). */
1072
- invalidateQuestionsCache(): void;
1073
- private parseQuestionFile;
1074
- private extractFrontmatterValue;
1075
- resolveQuestion(id: string): Promise<boolean>;
1076
- readIdentity(workspaceDir: string, namespace?: string): Promise<string>;
1077
- writeIdentity(workspaceDir: string, content: string, namespace?: string): Promise<void>;
1078
- /** Max size for IDENTITY.md before we stop appending reflections (15KB leaves room under 20KB gateway limit) */
1079
- private static readonly IDENTITY_MAX_BYTES;
1080
- /** Minimum interval between reflections (1 hour) */
1081
- private static readonly REFLECTION_COOLDOWN_MS;
1082
- appendToIdentity(workspaceDir: string, reflection: string, opts?: {
1083
- hygiene?: FileHygieneConfig;
1084
- namespace?: string;
1085
- }): Promise<void>;
1086
- readIdentityReflections(): Promise<string | null>;
1087
- writeIdentityReflections(content: string): Promise<void>;
1088
- appendIdentityReflection(reflection: string): Promise<void>;
1089
- /**
1090
- * Add a relationship to an entity file.
1091
- * Deduplicates by target+label.
1092
- */
1093
- addEntityRelationship(name: string, rel: EntityRelationship): Promise<void>;
1094
- /**
1095
- * Add an activity entry to an entity file.
1096
- * Prepends to the beginning, prunes oldest entries beyond maxEntries.
1097
- */
1098
- addEntityActivity(name: string, entry: EntityActivityEntry, maxEntries: number): Promise<void>;
1099
- /**
1100
- * Add an alias to an entity file. Deduplicates.
1101
- */
1102
- addEntityAlias(name: string, alias: string): Promise<void>;
1103
- updateEntitySynthesis(name: string, synthesis: string, options?: {
1104
- entityUpdatedAt?: string;
1105
- synthesisStructuredFactCount?: number;
1106
- synthesisStructuredFactDigest?: string;
1107
- synthesisTimelineCount?: number;
1108
- updatedAt?: string;
1109
- incrementVersion?: boolean;
1110
- }): Promise<void>;
1111
- /**
1112
- * Backward-compatible alias for legacy callers/tests.
1113
- */
1114
- updateEntitySummary(name: string, summary: string): Promise<void>;
1115
- readEntitySynthesisQueue(): Promise<string[]>;
1116
- refreshEntitySynthesisQueue(): Promise<string[]>;
1117
- removeEntitySynthesisQueueEntries(entityNames: string[]): Promise<void>;
1118
- migrateEntityFilesToCompiledTruthTimeline(): Promise<{
1119
- total: number;
1120
- migrated: number;
1121
- }>;
1122
- readAllEntityFiles(): Promise<EntityFile[]>;
1123
- /**
1124
- * Score an entity based on recency, frequency, activity, type priority,
1125
- * and relationship density.
1126
- *
1127
- * score = recency*0.40 + frequency*0.25 + activity*0.15 + typePriority*0.10 + relationshipDensity*0.10
1128
- */
1129
- static scoreEntity(entity: EntityFile, now: Date): number;
1130
- buildKnowledgeIndex(config: PluginConfig, overrides?: {
1131
- maxEntities?: number;
1132
- maxChars?: number;
1133
- }): Promise<{
1134
- result: string;
1135
- cached: boolean;
1136
- }>;
1137
- /** Invalidate the Knowledge Index cache (call after entity mutations). */
1138
- invalidateKnowledgeIndexCache(): void;
1139
- /** Max lines for profile.md before LLM consolidation triggers */
1140
- private static readonly PROFILE_MAX_LINES;
1141
- mergeFragmentedEntities(): Promise<number>;
1142
- cleanExpiredCommitments(decayDays: number): Promise<MemoryFile[]>;
1143
- /**
1144
- * Flush batched access tracking updates to disk.
1145
- * Called during consolidation or when buffer exceeds max size.
1146
- */
1147
- flushAccessTracking(entries: AccessTrackingEntry[]): Promise<number>;
1148
- /**
1149
- * Get a memory by its ID.
1150
- */
1151
- getMemoryById(id: string): Promise<MemoryFile | null>;
1152
- /**
1153
- * Check which of the given memory IDs actually exist on disk.
1154
- *
1155
- * Uses a lightweight directory scan (collectActiveMemoryPaths) that reads
1156
- * file names without parsing frontmatter — much cheaper than readAllMemories()
1157
- * for simple existence checks like citation usage tracking.
1158
- *
1159
- * Returns the subset of `ids` that correspond to real memory files.
1160
- */
1161
- filterExistingMemoryIds(ids: string[]): Promise<Set<string>>;
1162
- getProjectedMemoryState(id: string): Promise<MemoryProjectionCurrentState | null>;
1163
- browseProjectedMemories(options: ProjectedMemoryBrowseOptions): Promise<ProjectedMemoryBrowsePage | null>;
1164
- getProjectedGovernanceRecord(): Promise<ReturnType<typeof readProjectedGovernanceRecord>>;
1165
- private toProjectedCurrentState;
1166
- getMemoryTimeline(memoryId: string, limit?: number): Promise<MemoryLifecycleEvent[]>;
1167
- /**
1168
- * Write a memory chunk with parent reference.
1169
- * Chunk IDs follow format: {parentId}-chunk-{index}
1170
- */
1171
- writeChunk(parentId: string, chunkIndex: number, chunkTotal: number, category: MemoryCategory, content: string, options?: {
1172
- confidence?: number;
1173
- tags?: string[];
1174
- entityRef?: string;
1175
- source?: string;
1176
- importance?: ImportanceScore;
1177
- intentGoal?: string;
1178
- intentActionType?: string;
1179
- intentEntityTypes?: string[];
1180
- memoryKind?: MemoryFrontmatter["memoryKind"];
1181
- validAt?: string;
1182
- /** Lifecycle status (issue #1576): pending_review chunks stay out of active recall. */
1183
- status?: MemoryStatus;
1184
- /**
1185
- * Tombstone block provenance (issue #1645): when the parent fact was
1186
- * tombstone-blocked, propagate the tombstone id onto each chunk so an
1187
- * independently-surfaced chunk (memory_get/x-ray/doctor) reveals the block
1188
- * and the chunk stays pending_review, never an active resurrection.
1189
- */
1190
- blockedBy?: string;
1191
- /** Faithfulness gate verdict (issue #1576), propagated from the parent fact. */
1192
- faithfulness?: FaithfulnessFrontmatter;
1193
- /** Claim-level provenance spans (issue #1575 PR 2), propagated from the parent fact so a chunk surfaced independently (memory_get/x-ray) preserves them (chatgpt-codex-connector thread Ocvmo). */
1194
- sources?: ProvenanceSource[];
1195
- /** Coarse provenance tag (issue #1575 PR 2), propagated from the parent. */
1196
- provenance?: "verified" | "unverified" | "none";
1197
- invalidAt?: string;
1198
- observedAt?: string;
1199
- eventTimeSource?: "extracted" | "assumed";
1200
- }): Promise<string>;
1201
- /**
1202
- * Get all chunks for a given parent memory ID.
1203
- * Returns chunks sorted by chunkIndex.
1204
- */
1205
- getChunksForParent(parentId: string): Promise<MemoryFile[]>;
1206
- /**
1207
- * Mark a memory as superseded by another.
1208
- * Updates the old memory's status and adds the supersededBy link.
1209
- */
1210
- supersedeMemory(oldMemoryId: string, newMemoryId: string, reason: string): Promise<boolean>;
1211
- private get summariesDir();
1212
- /**
1213
- * Write a memory summary.
1214
- */
1215
- writeSummary(summary: MemorySummary): Promise<void>;
1216
- /**
1217
- * Get all summaries.
1218
- */
1219
- readSummaries(): Promise<MemorySummary[]>;
1220
- /**
1221
- * Archive memories (mark as archived, not delete).
1222
- */
1223
- archiveMemories(memoryIds: string[], summaryId: string): Promise<number>;
1224
- /**
1225
- * Save topic scores to meta.json.
1226
- */
1227
- saveTopics(topics: TopicScore[]): Promise<void>;
1228
- /**
1229
- * Load topic scores from meta.json.
1230
- */
1231
- loadTopics(): Promise<{
1232
- topics: TopicScore[];
1233
- updatedAt: string | null;
1234
- }>;
1235
- /**
1236
- * Add links to an existing memory.
1237
- */
1238
- addLinksToMemory(memoryId: string, links: MemoryLink[], lifecycle?: MemoryLifecycleEventWriteOptions): Promise<boolean>;
1239
- private summarizeLifecycleState;
1240
- private frontmatterPatchEventType;
1241
- private appendGeneratedMemoryLifecycleEvent;
1242
- private appendGeneratedMemoryLifecycleEventFailOpen;
1243
- }
1244
-
1245
- export { ContentHashIndex, type MemoryLifecycleEventWriteOptions, type MemoryWriteResult, type ReextractJobRequest, StorageManager, buildEntitySchemaCacheKey, compareEntityTimestamps, compileEntityFacts, countEntityStructuredFacts, fingerprintEntityStructuredFacts, isEntitySynthesisStale, isValidBufferSurpriseEvent, normalizeAttributePairs, normalizeEntityName, normalizeFrontmatterForPath, normalizeStructuredSectionFacts, parseEntityFile, parseFrontmatter, parseFrontmatterStringValue, serializeEntityFile };