@remnic/core 9.29.1 → 9.30.1

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 (358) hide show
  1. package/dist/access-admin-ops-surface.d.ts +11 -11
  2. package/dist/access-admin-ops-surface.js +19 -18
  3. package/dist/access-authorization-probe.d.ts +11 -11
  4. package/dist/access-authorization-probe.js +20 -19
  5. package/dist/access-boundary.d.ts +11 -11
  6. package/dist/access-boundary.js +19 -18
  7. package/dist/access-citation-namespace.js +2 -2
  8. package/dist/access-cli.js +45 -44
  9. package/dist/access-cli.js.map +1 -1
  10. package/dist/access-health-types.d.ts +1 -1
  11. package/dist/access-http-lcm-compaction.d.ts +11 -11
  12. package/dist/access-http.d.ts +11 -11
  13. package/dist/access-http.js +25 -24
  14. package/dist/access-identity-continuity-surface.d.ts +8 -8
  15. package/dist/access-identity-continuity-surface.js +19 -18
  16. package/dist/access-lcm-surface.d.ts +10 -10
  17. package/dist/access-lcm-surface.js +19 -18
  18. package/dist/access-mcp.d.ts +11 -11
  19. package/dist/access-mcp.js +23 -22
  20. package/dist/access-memory-search-fanout.d.ts +2 -2
  21. package/dist/{access-namespace-preflight-DCXBkDp0.d.ts → access-namespace-preflight-VfXssvoI.d.ts} +1 -1
  22. package/dist/access-namespace-preflight.d.ts +3 -3
  23. package/dist/access-namespace-preflight.js +19 -18
  24. package/dist/access-observe-write-surface.d.ts +10 -10
  25. package/dist/access-observe-write-surface.js +19 -18
  26. package/dist/access-operations-batch.js +20 -19
  27. package/dist/access-operations.d.ts +11 -11
  28. package/dist/access-operations.js +22 -21
  29. package/dist/access-recall-concurrency.d.ts +11 -11
  30. package/dist/access-recall-concurrency.js +19 -18
  31. package/dist/access-recall-response.d.ts +10 -10
  32. package/dist/access-recall-response.js +19 -18
  33. package/dist/access-recall-surface.d.ts +10 -10
  34. package/dist/access-recall-surface.js +19 -18
  35. package/dist/access-schema.js +3 -3
  36. package/dist/{access-service-DvPW_M5j.d.ts → access-service-B5RwVsTV.d.ts} +7 -7
  37. package/dist/access-service.d.ts +11 -11
  38. package/dist/access-service.js +19 -18
  39. package/dist/access-surface-catalog.d.ts +11 -11
  40. package/dist/access-wearables-meetings-surface.d.ts +4 -3
  41. package/dist/action-confidence.d.ts +1 -1
  42. package/dist/active-memory-bridge.d.ts +1 -1
  43. package/dist/active-recall.d.ts +1 -1
  44. package/dist/active-recall.js +3 -3
  45. package/dist/behavior-learner.d.ts +1 -1
  46. package/dist/behavior-signals.d.ts +1 -1
  47. package/dist/bootstrap.d.ts +8 -8
  48. package/dist/briefing.d.ts +3 -2
  49. package/dist/briefing.js +10 -9
  50. package/dist/buffer-surprise-report.d.ts +1 -1
  51. package/dist/buffer.d.ts +3 -2
  52. package/dist/bulk-import/index.d.ts +3 -3
  53. package/dist/calibration.d.ts +1 -1
  54. package/dist/capabilities.d.ts +1 -1
  55. package/dist/{catalog-BIVgftWu.d.ts → catalog-V7inUQdp.d.ts} +1 -1
  56. package/dist/causal-behavior.d.ts +1 -1
  57. package/dist/causal-consolidation.d.ts +1 -1
  58. package/dist/causal-consolidation.js +11 -10
  59. package/dist/causal-consolidation.js.map +1 -1
  60. package/dist/causal-trajectory-graph.d.ts +1 -1
  61. package/dist/{chunk-FZRQZW4H.js → chunk-2EUVEDF5.js} +2 -2
  62. package/dist/{chunk-PBUZNGMX.js → chunk-4WKA6I65.js} +20 -20
  63. package/dist/{chunk-PBUZNGMX.js.map → chunk-4WKA6I65.js.map} +1 -1
  64. package/dist/{chunk-AIK5W3IW.js → chunk-5TFP4CUL.js} +68 -2
  65. package/dist/chunk-5TFP4CUL.js.map +1 -0
  66. package/dist/{chunk-3JNDOAQ2.js → chunk-5W4ZLBEZ.js} +9 -9
  67. package/dist/{chunk-5ZCUDWD4.js → chunk-62U4J2GN.js} +2 -2
  68. package/dist/{chunk-IGPEJVBY.js → chunk-66772WBP.js} +2 -2
  69. package/dist/{chunk-EP5BVCRI.js → chunk-6BNE62PM.js} +2 -2
  70. package/dist/{chunk-AAP5T6QG.js → chunk-6DNMUYEE.js} +2 -2
  71. package/dist/{chunk-35DL7IOI.js → chunk-6FUPCJUL.js} +7 -7
  72. package/dist/{chunk-JP3YPDAW.js → chunk-6U7F52DE.js} +19 -19
  73. package/dist/{chunk-E4OCKU67.js → chunk-7XC2HX75.js} +2 -2
  74. package/dist/{chunk-OVRQLAYR.js → chunk-AZ5BTEKX.js} +2 -2
  75. package/dist/{chunk-2AXMQWCN.js → chunk-CZRYLSSW.js} +3 -3
  76. package/dist/chunk-FBUE6PD3.js +1769 -0
  77. package/dist/chunk-FBUE6PD3.js.map +1 -0
  78. package/dist/{chunk-PTSNLEXK.js → chunk-FDAMS4PK.js} +2 -2
  79. package/dist/{chunk-WL5EBRDH.js → chunk-FFAZ2XFU.js} +9 -8
  80. package/dist/chunk-FFAZ2XFU.js.map +1 -0
  81. package/dist/{chunk-2GXM5N5A.js → chunk-GIBMDSJ2.js} +2 -2
  82. package/dist/{chunk-E5OBR6CJ.js → chunk-H5CPS5JP.js} +3 -3
  83. package/dist/{chunk-2D7FEUCK.js → chunk-I5NLEENJ.js} +2 -2
  84. package/dist/{chunk-DRBXHRXE.js → chunk-IB26HVAJ.js} +2 -2
  85. package/dist/{chunk-QDKK63Y7.js → chunk-IC6CBHCA.js} +3 -3
  86. package/dist/{chunk-IAEAFLF2.js → chunk-JCBWCYEJ.js} +2 -2
  87. package/dist/{chunk-3PDOVUHC.js → chunk-KXB4VXHY.js} +2 -2
  88. package/dist/{chunk-WU7TTVOD.js → chunk-LBOD4U5B.js} +7 -7
  89. package/dist/{chunk-UBKEQOTD.js → chunk-LGHKJABJ.js} +3 -3
  90. package/dist/{chunk-VSURVXKY.js → chunk-M3C2V3PV.js} +10 -10
  91. package/dist/{chunk-OFHFH655.js → chunk-MJCGLM25.js} +8 -8
  92. package/dist/{chunk-OYJKSZIQ.js → chunk-NHWB6HG2.js} +2 -2
  93. package/dist/{chunk-TC3VNKGX.js → chunk-NM2WP3B7.js} +4 -4
  94. package/dist/{chunk-GAWOEQEQ.js → chunk-P5PXWTW7.js} +2 -2
  95. package/dist/chunk-PH3ZWL3W.js +786 -0
  96. package/dist/chunk-PH3ZWL3W.js.map +1 -0
  97. package/dist/{chunk-2QMKMVHH.js → chunk-QNWXCJ76.js} +2 -2
  98. package/dist/{chunk-JMQUBRV6.js → chunk-RGIWINDN.js} +340 -771
  99. package/dist/chunk-RGIWINDN.js.map +1 -0
  100. package/dist/{chunk-WRFBW2TT.js → chunk-SPJXKAVF.js} +3 -3
  101. package/dist/{chunk-HKJCMOT6.js → chunk-TH2LSRMG.js} +2 -2
  102. package/dist/{chunk-CW4AGY3G.js → chunk-VI2JQPNQ.js} +2 -2
  103. package/dist/{chunk-OP6F6L3S.js → chunk-W5EG6LE3.js} +2 -2
  104. package/dist/{chunk-DEBHXHJR.js → chunk-WIPEXG6R.js} +2 -2
  105. package/dist/{chunk-SH6YO3LT.js → chunk-WVO4G37W.js} +2 -2
  106. package/dist/{chunk-FUYEVEX7.js → chunk-YNQBRLC5.js} +24 -22
  107. package/dist/chunk-YNQBRLC5.js.map +1 -0
  108. package/dist/{chunk-7L45JFPW.js → chunk-YTQNQ4KB.js} +14 -14
  109. package/dist/{chunk-PKRIQL3V.js → chunk-YTSNAUXN.js} +2 -2
  110. package/dist/{chunk-5QDRGWT2.js → chunk-ZPSVBSOF.js} +4 -4
  111. package/dist/{cli-CxoSOiG0.d.ts → cli-C4GbETPC.d.ts} +5 -5
  112. package/dist/cli.d.ts +13 -13
  113. package/dist/cli.js +36 -35
  114. package/dist/compounding/engine.d.ts +3 -2
  115. package/dist/compounding/engine.js +10 -9
  116. package/dist/compounding/preference-consolidator.d.ts +1 -1
  117. package/dist/compression-optimizer.d.ts +1 -1
  118. package/dist/config.d.ts +1 -1
  119. package/dist/config.js +3 -3
  120. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  121. package/dist/connectors/codex-materialize-runner.js +10 -9
  122. package/dist/connectors/codex-materialize.d.ts +1 -1
  123. package/dist/connectors/index.d.ts +1 -1
  124. package/dist/connectors/index.js +10 -9
  125. package/dist/consolidation-provenance-check.d.ts +3 -2
  126. package/dist/consolidation-undo.d.ts +3 -2
  127. package/dist/contradiction/index.d.ts +3 -2
  128. package/dist/conversation-index/backend.d.ts +1 -1
  129. package/dist/conversation-index/chunker.d.ts +1 -1
  130. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  131. package/dist/conversation-index/indexer.d.ts +1 -1
  132. package/dist/conversation-index/search.d.ts +1 -1
  133. package/dist/corpus-watermark.d.ts +1 -1
  134. package/dist/corpus-watermark.js +12 -11
  135. package/dist/day-summary.d.ts +1 -1
  136. package/dist/delinearize.d.ts +1 -1
  137. package/dist/direct-answer-wiring.d.ts +1 -1
  138. package/dist/direct-answer.d.ts +1 -1
  139. package/dist/embedding-fallback.d.ts +1 -1
  140. package/dist/enrichment/index.d.ts +1 -1
  141. package/dist/entity-retrieval.d.ts +3 -2
  142. package/dist/entity-retrieval.js +10 -9
  143. package/dist/entity-schema.d.ts +1 -1
  144. package/dist/explicit-capture.d.ts +52 -10
  145. package/dist/explicit-capture.js +13 -1
  146. package/dist/extraction-error-classification.d.ts +1 -1
  147. package/dist/extraction-faithfulness.d.ts +1 -1
  148. package/dist/extraction-judge-telemetry.d.ts +1 -1
  149. package/dist/extraction-judge-training.d.ts +1 -1
  150. package/dist/extraction-judge.d.ts +1 -1
  151. package/dist/extraction-liveness.d.ts +1 -1
  152. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  153. package/dist/extraction-source-grounding.d.ts +1 -1
  154. package/dist/extraction.d.ts +1 -1
  155. package/dist/fallback-llm.d.ts +1 -1
  156. package/dist/{forget-HRPLVB3W.js → forget-4UY2EOKH.js} +3 -3
  157. package/dist/graph-dashboard-diff.d.ts +1 -1
  158. package/dist/graph-dashboard-key.d.ts +1 -1
  159. package/dist/graph-dashboard-parser.d.ts +1 -1
  160. package/dist/graph-edge-reinforcement.d.ts +1 -1
  161. package/dist/graph-snapshot.d.ts +1 -1
  162. package/dist/graph.d.ts +1 -1
  163. package/dist/importance.d.ts +1 -1
  164. package/dist/importers/index.d.ts +1 -1
  165. package/dist/in-flight-reads.d.ts +1 -1
  166. package/dist/index.d.ts +19 -19
  167. package/dist/index.js +47 -45
  168. package/dist/intent.d.ts +1 -1
  169. package/dist/lcm/engine.d.ts +1 -1
  170. package/dist/lcm/index.d.ts +1 -1
  171. package/dist/lcm/tools.d.ts +1 -1
  172. package/dist/lifecycle.d.ts +1 -1
  173. package/dist/live-connectors-runner.d.ts +1 -1
  174. package/dist/local-llm.d.ts +1 -1
  175. package/dist/local-model-endpoint.d.ts +1 -1
  176. package/dist/maintenance/memory-governance.d.ts +1 -1
  177. package/dist/maintenance/memory-governance.js +10 -9
  178. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
  179. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +10 -9
  180. package/dist/maintenance/rebuild-memory-projection.d.ts +3 -2
  181. package/dist/maintenance/rebuild-memory-projection.js +11 -10
  182. package/dist/{maintenance-Cb-PjxQd.d.ts → maintenance-CL30NWtc.d.ts} +3 -3
  183. package/dist/mcp-memory-inspector-app.d.ts +11 -11
  184. package/dist/memory-action-policy.d.ts +1 -1
  185. package/dist/memory-cache.d.ts +1 -1
  186. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  187. package/dist/memory-projection-store.d.ts +1 -1
  188. package/dist/memory-provenance.d.ts +1 -1
  189. package/dist/memory-worth-outcomes.d.ts +3 -2
  190. package/dist/models-json.d.ts +1 -1
  191. package/dist/namespaces/migrate.d.ts +4 -3
  192. package/dist/namespaces/migrate.js +11 -10
  193. package/dist/namespaces/principal.d.ts +1 -1
  194. package/dist/namespaces/search.d.ts +1 -1
  195. package/dist/namespaces/storage.d.ts +4 -3
  196. package/dist/namespaces/storage.js +10 -9
  197. package/dist/native-knowledge.d.ts +1 -1
  198. package/dist/offline-sync-impression-drain.d.ts +1 -1
  199. package/dist/offline-sync-impression-drain.js +5 -5
  200. package/dist/offline-sync.js +2 -2
  201. package/dist/operator-doctor-corpus.d.ts +1 -1
  202. package/dist/operator-doctor-corpus.js +13 -12
  203. package/dist/operator-doctor-replica.d.ts +1 -1
  204. package/dist/operator-toolkit.d.ts +4 -3
  205. package/dist/operator-toolkit.js +18 -17
  206. package/dist/orchestration/compression-guideline-coordinator.d.ts +3 -2
  207. package/dist/orchestration/maintenance.d.ts +5 -4
  208. package/dist/orchestration/maintenance.js +15 -14
  209. package/dist/{orchestrator-5GKqb_HL.d.ts → orchestrator-CKTCRwWV.d.ts} +7 -7
  210. package/dist/orchestrator.d.ts +8 -8
  211. package/dist/orchestrator.js +45 -44
  212. package/dist/patterns-cli.d.ts +1 -1
  213. package/dist/{pipeline-3Qi1TpRo.d.ts → pipeline-B7wj4rRZ.d.ts} +1 -1
  214. package/dist/policy-runtime.d.ts +1 -1
  215. package/dist/proactive-contention.d.ts +1 -1
  216. package/dist/provenance.d.ts +1 -1
  217. package/dist/{purge-YSGX5BOG.js → purge-533FZLS4.js} +16 -9
  218. package/dist/purge-533FZLS4.js.map +1 -0
  219. package/dist/qmd-preflight.d.ts +2 -2
  220. package/dist/{qmd-D9JqzzRX.d.ts → qmd-q9tg4dHp.d.ts} +1 -1
  221. package/dist/qmd-recall-cache.d.ts +1 -1
  222. package/dist/qmd.d.ts +2 -2
  223. package/dist/recall-concurrency-config.d.ts +1 -1
  224. package/dist/recall-disclosure-escalation.d.ts +1 -1
  225. package/dist/recall-explain-renderer.d.ts +1 -1
  226. package/dist/recall-memory-map.d.ts +1 -1
  227. package/dist/recall-planner-llm.d.ts +1 -1
  228. package/dist/recall-state.d.ts +1 -1
  229. package/dist/recall-state.js +2 -2
  230. package/dist/recall-tag-filter.d.ts +1 -1
  231. package/dist/recall-timings.d.ts +1 -1
  232. package/dist/recall-xray-cli.d.ts +1 -1
  233. package/dist/recall-xray-renderer.d.ts +1 -1
  234. package/dist/recall-xray.d.ts +1 -1
  235. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  236. package/dist/replay/normalizers/claude.d.ts +1 -1
  237. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  238. package/dist/replay/normalizers/shared.d.ts +1 -1
  239. package/dist/replay/runner.d.ts +1 -1
  240. package/dist/replay/types.d.ts +1 -1
  241. package/dist/replica-divergence.d.ts +1 -1
  242. package/dist/replica-peers-config.d.ts +1 -1
  243. package/dist/resolve-auth-token.d.ts +1 -1
  244. package/dist/resume-bundles.js +4 -4
  245. package/dist/retrieval-agents.d.ts +2 -2
  246. package/dist/retrieval-tiers.d.ts +1 -1
  247. package/dist/routing/engine.d.ts +1 -1
  248. package/dist/routing/store.d.ts +1 -1
  249. package/dist/salvage-envelope.d.ts +1 -1
  250. package/dist/{scope-profiles-C4g6_UdP.d.ts → scope-profiles-CWDyglPM.d.ts} +1 -1
  251. package/dist/search/embed-helper.d.ts +1 -1
  252. package/dist/search/factory.d.ts +1 -1
  253. package/dist/search/index.d.ts +1 -1
  254. package/dist/search/lancedb-backend.d.ts +1 -1
  255. package/dist/search/meilisearch-backend.d.ts +1 -1
  256. package/dist/search/noop-backend.d.ts +1 -1
  257. package/dist/search/orama-backend.d.ts +1 -1
  258. package/dist/search/port.d.ts +1 -1
  259. package/dist/search/remote-backend.d.ts +1 -1
  260. package/dist/secure-store/index.js +2 -2
  261. package/dist/{semantic-consolidation-BrxqnzTW.d.ts → semantic-consolidation-BUE3deLn.d.ts} +1 -1
  262. package/dist/semantic-consolidation.d.ts +2 -2
  263. package/dist/semantic-consolidation.js +11 -10
  264. package/dist/semantic-rule-promotion.js +10 -9
  265. package/dist/semantic-rule-verifier.d.ts +1 -1
  266. package/dist/semantic-rule-verifier.js +10 -9
  267. package/dist/{service-Bi1JgxdP.d.ts → service-CXgM0bQG.d.ts} +2 -2
  268. package/dist/session-observer-bands.d.ts +1 -1
  269. package/dist/session-observer-state.d.ts +1 -1
  270. package/dist/shared-context/manager.d.ts +1 -1
  271. package/dist/signal.d.ts +1 -1
  272. package/dist/{storage-CcH6yPk2.d.ts → storage-DysJq-XH.d.ts} +163 -27
  273. package/dist/storage.d.ts +3 -2
  274. package/dist/storage.js +12 -10
  275. package/dist/summarizer.d.ts +1 -1
  276. package/dist/summarizer.js +3 -3
  277. package/dist/summary-snapshot.d.ts +1 -1
  278. package/dist/summary-snapshot.js +2 -2
  279. package/dist/temporal-supersession.d.ts +3 -2
  280. package/dist/temporal-timeline-recall.d.ts +1 -1
  281. package/dist/temporal-validity.d.ts +1 -1
  282. package/dist/threading.d.ts +1 -1
  283. package/dist/tier-migration.d.ts +3 -2
  284. package/dist/tier-routing.d.ts +1 -1
  285. package/dist/topics.d.ts +1 -1
  286. package/dist/transcript.d.ts +1 -1
  287. package/dist/trust-score-stage.d.ts +1 -1
  288. package/dist/trust-score.d.ts +1 -1
  289. package/dist/{types-Dg0w9ADr.d.ts → types-aPPzhnjT.d.ts} +1 -1
  290. package/dist/types.d.ts +1 -1
  291. package/dist/utility-runtime.d.ts +1 -1
  292. package/dist/utils/serialize-mutations.d.ts +11 -7
  293. package/dist/utils/serialize-mutations.js +1 -1
  294. package/dist/verified-recall.js +10 -9
  295. package/dist/write-envelope.d.ts +1 -1
  296. package/package.json +2 -2
  297. package/src/access-observe-write-surface.ts +1 -1
  298. package/src/access-service-coding-write.test.ts +40 -0
  299. package/src/explicit-capture.test.ts +1110 -1
  300. package/src/explicit-capture.ts +534 -135
  301. package/src/maintenance/purge.test.ts +157 -1
  302. package/src/maintenance/purge.ts +15 -9
  303. package/src/orchestration/recall-internal-deps.ts +385 -0
  304. package/src/orchestration/recall-internal.ts +16 -375
  305. package/src/secure-store/secure-fs.ts +78 -1
  306. package/src/storage/content-hash-index.ts +43 -17
  307. package/src/storage/tombstone-blocked-capture-index.ts +562 -0
  308. package/src/storage/tombstone-blocked-capture-mutation.ts +284 -0
  309. package/src/storage/tombstone-blocked-capture-sync.ts +872 -0
  310. package/src/storage-fact-hash-index-defer.test.ts +2900 -57
  311. package/src/storage.ts +266 -265
  312. package/src/testing/subjects/tombstone-blocked-capture.test.ts +181 -0
  313. package/src/utils/serialize-mutations.test.ts +4 -1
  314. package/src/utils/serialize-mutations.ts +26 -27
  315. package/dist/chunk-55MDBZLC.js +0 -490
  316. package/dist/chunk-55MDBZLC.js.map +0 -1
  317. package/dist/chunk-AIK5W3IW.js.map +0 -1
  318. package/dist/chunk-FUYEVEX7.js.map +0 -1
  319. package/dist/chunk-JMQUBRV6.js.map +0 -1
  320. package/dist/chunk-WL5EBRDH.js.map +0 -1
  321. package/dist/purge-YSGX5BOG.js.map +0 -1
  322. /package/dist/{chunk-FZRQZW4H.js.map → chunk-2EUVEDF5.js.map} +0 -0
  323. /package/dist/{chunk-3JNDOAQ2.js.map → chunk-5W4ZLBEZ.js.map} +0 -0
  324. /package/dist/{chunk-5ZCUDWD4.js.map → chunk-62U4J2GN.js.map} +0 -0
  325. /package/dist/{chunk-IGPEJVBY.js.map → chunk-66772WBP.js.map} +0 -0
  326. /package/dist/{chunk-EP5BVCRI.js.map → chunk-6BNE62PM.js.map} +0 -0
  327. /package/dist/{chunk-AAP5T6QG.js.map → chunk-6DNMUYEE.js.map} +0 -0
  328. /package/dist/{chunk-35DL7IOI.js.map → chunk-6FUPCJUL.js.map} +0 -0
  329. /package/dist/{chunk-JP3YPDAW.js.map → chunk-6U7F52DE.js.map} +0 -0
  330. /package/dist/{chunk-E4OCKU67.js.map → chunk-7XC2HX75.js.map} +0 -0
  331. /package/dist/{chunk-OVRQLAYR.js.map → chunk-AZ5BTEKX.js.map} +0 -0
  332. /package/dist/{chunk-2AXMQWCN.js.map → chunk-CZRYLSSW.js.map} +0 -0
  333. /package/dist/{chunk-PTSNLEXK.js.map → chunk-FDAMS4PK.js.map} +0 -0
  334. /package/dist/{chunk-2GXM5N5A.js.map → chunk-GIBMDSJ2.js.map} +0 -0
  335. /package/dist/{chunk-E5OBR6CJ.js.map → chunk-H5CPS5JP.js.map} +0 -0
  336. /package/dist/{chunk-2D7FEUCK.js.map → chunk-I5NLEENJ.js.map} +0 -0
  337. /package/dist/{chunk-DRBXHRXE.js.map → chunk-IB26HVAJ.js.map} +0 -0
  338. /package/dist/{chunk-QDKK63Y7.js.map → chunk-IC6CBHCA.js.map} +0 -0
  339. /package/dist/{chunk-IAEAFLF2.js.map → chunk-JCBWCYEJ.js.map} +0 -0
  340. /package/dist/{chunk-3PDOVUHC.js.map → chunk-KXB4VXHY.js.map} +0 -0
  341. /package/dist/{chunk-WU7TTVOD.js.map → chunk-LBOD4U5B.js.map} +0 -0
  342. /package/dist/{chunk-UBKEQOTD.js.map → chunk-LGHKJABJ.js.map} +0 -0
  343. /package/dist/{chunk-VSURVXKY.js.map → chunk-M3C2V3PV.js.map} +0 -0
  344. /package/dist/{chunk-OFHFH655.js.map → chunk-MJCGLM25.js.map} +0 -0
  345. /package/dist/{chunk-OYJKSZIQ.js.map → chunk-NHWB6HG2.js.map} +0 -0
  346. /package/dist/{chunk-TC3VNKGX.js.map → chunk-NM2WP3B7.js.map} +0 -0
  347. /package/dist/{chunk-GAWOEQEQ.js.map → chunk-P5PXWTW7.js.map} +0 -0
  348. /package/dist/{chunk-2QMKMVHH.js.map → chunk-QNWXCJ76.js.map} +0 -0
  349. /package/dist/{chunk-WRFBW2TT.js.map → chunk-SPJXKAVF.js.map} +0 -0
  350. /package/dist/{chunk-HKJCMOT6.js.map → chunk-TH2LSRMG.js.map} +0 -0
  351. /package/dist/{chunk-CW4AGY3G.js.map → chunk-VI2JQPNQ.js.map} +0 -0
  352. /package/dist/{chunk-OP6F6L3S.js.map → chunk-W5EG6LE3.js.map} +0 -0
  353. /package/dist/{chunk-DEBHXHJR.js.map → chunk-WIPEXG6R.js.map} +0 -0
  354. /package/dist/{chunk-SH6YO3LT.js.map → chunk-WVO4G37W.js.map} +0 -0
  355. /package/dist/{chunk-7L45JFPW.js.map → chunk-YTQNQ4KB.js.map} +0 -0
  356. /package/dist/{chunk-PKRIQL3V.js.map → chunk-YTSNAUXN.js.map} +0 -0
  357. /package/dist/{chunk-5QDRGWT2.js.map → chunk-ZPSVBSOF.js.map} +0 -0
  358. /package/dist/{forget-HRPLVB3W.js.map → forget-4UY2EOKH.js.map} +0 -0
@@ -22,30 +22,23 @@
22
22
  import { createHash } from "node:crypto";
23
23
  import { readFile, stat, unlink } from "node:fs/promises";
24
24
  import path from "node:path";
25
- import { BoxBuilder, type BoxFrontmatter } from "../boxes.js";
25
+ import { type BoxFrontmatter } from "../boxes.js";
26
26
  import { type CapabilitySet, type GraphConstructionCapabilitySet, type MemoryLifecycleCapabilitySet, resolveCapabilities, resolveCompressionCapabilities, resolveConsolidationCapabilities, resolveConversationContextCapabilities, resolveCreationMemoryCapabilities, resolveGraphConstructionCapabilities, resolveIdentityContinuityCapabilities, resolveIndexingCapabilities, resolveMemoryLifecycleCapabilities, resolveNamespaceCapabilities, resolveObjectiveStateCapabilities, resolvePipelineProcessingCapabilities, resolvePresentationCapabilities, resolveQmdCapabilities, resolveRecallAuxiliaryCapabilities, resolveRecallEnhancementCapabilities, resolveSecurityCapabilities } from "../capabilities.js";
27
- import { type CausalTrajectorySearchResult, searchCausalTrajectories } from "../causal-trajectory.js";
28
- import { CompoundingEngine } from "../compounding/engine.js";
27
+ import { searchCausalTrajectories } from "../causal-trajectory.js";
29
28
  import { buildEntityRecallSection, entityRecentTranscriptLookbackHours, readRecentEntityTranscriptEntries } from "../entity-retrieval.js";
30
- import type { EvalShadowRecallRecord } from "../evals.js";
31
29
  import { buildEventOrderRecallSection, shouldRecallEventOrderEvidence } from "../event-order-recall.js";
32
30
  import { buildExplicitCueRecallSection } from "../explicit-cue-recall.js";
33
31
  import { buildFocusedListRecallSection, shouldRecallFocusedListEvidence } from "../focused-list-recall.js";
34
32
  import { type HarmonicRetrievalResult, searchHarmonicRetrieval } from "../harmonic-retrieval.js";
35
- import { StorageManager } from "../index.js";
36
33
  import { inferIntentFromText, planRecallMode } from "../intent.js";
37
- import { LcmEngine } from "../lcm/index.js";
38
34
  import { log } from "../logger.js";
39
35
  import { isActiveMemoryStatus } from "../memory-lifecycle-ledger-utils.js";
40
36
  import { buildRetrievedMemoryProvenance } from "../memory-provenance.js";
41
- import { NamespaceCatalog } from "../namespaces/catalog.js";
42
37
  import { canReadNamespace, resolvePrincipal } from "../namespaces/principal.js";
43
- import { NamespaceStorageRouter } from "../namespaces/storage.js";
44
38
  import { collectNativeKnowledgeChunks, formatNativeKnowledgeSection, searchNativeKnowledge } from "../native-knowledge.js";
45
- import { type ObjectiveStateSearchResult, objectiveStateStoreOverrideForNamespace, searchObjectiveStateSnapshots } from "../objective-state.js";
39
+ import { objectiveStateStoreOverrideForNamespace, searchObjectiveStateSnapshots } from "../objective-state.js";
46
40
  import { type GraphRecallRankedResult, type GraphRecallShadowComparison, mergeGraphExpandedResults } from "./graph-recall-coordinator.js";
47
41
  import { buildProcedureRecallSection } from "../procedural/procedure-recall.js";
48
- import { ProfilingCollector } from "../profiling.js";
49
42
  import { buildQmdRecallCacheKey, getCachedQmdRecall, setCachedQmdRecall } from "../qmd-recall-cache.js";
50
43
  import { MEMORY_ID_PATTERN } from "../recall-handles.js";
51
44
  import {
@@ -54,29 +47,30 @@ import {
54
47
  } from "../recall-context-composition.js";
55
48
  import { createRecallSectionMetricRecorder } from "../recall-qos.js";
56
49
  import { buildRecallQueryPolicy } from "../recall-query-policy.js";
57
- import { type GraphRecallExpandedEntry, type LastRecallBudgetSummary, type LastRecallSnapshot, LastRecallStore, RecallHandleHistoryStore } from "../recall-state.js";
58
- import { type RecallFilterTrace, type RecallXrayResult, type RecallXrayScoreDecomposition, type RecallXraySnapshot, buildXraySnapshot } from "../recall-xray.js";
50
+ import { type GraphRecallExpandedEntry, type LastRecallSnapshot } from "../recall-state.js";
51
+ import {
52
+ type RecallFilterTrace,
53
+ type RecallXrayResult,
54
+ type RecallXrayScoreDecomposition,
55
+ buildXraySnapshot,
56
+ } from "../recall-xray.js";
59
57
  import { foldQueueWaitTiming, recordRecallTiming } from "../recall-timings.js";
60
58
  import { findUnresolvedEntityRefs } from "../reconstruct.js";
61
- import { RerankCache, rerankLocalOrNoop, reorderByRankedKeys } from "../rerank.js";
59
+ import { rerankLocalOrNoop, reorderByRankedKeys } from "../rerank.js";
62
60
  import { buildResponseGuidanceRecallSection, shouldRecallResponseGuidance } from "../response-guidance-recall.js";
63
61
  import { type ParallelSearchResult, mergeWithAgentResults, runDirectAgent, runTemporalAgent, shouldRunAgent } from "../retrieval-agents.js";
64
62
  import { resolveScopePlan } from "../scopes/scope-plan.js";
65
- import type { SearchBackend, SearchDegradation, SearchQueryOptions } from "../search/port.js";
63
+ import type { SearchDegradation } from "../search/port.js";
66
64
  import { type VerifiedSemanticRuleResult, compareVerifiedSemanticRuleResults, searchVerifiedSemanticRules } from "../semantic-rule-verifier.js";
67
- import { SharedContextManager } from "../shared-context/manager.js";
68
65
  import { isDisagreementPrompt } from "../signal.js";
69
- import { HourlySummarizer } from "../summarizer.js";
70
66
  import { buildTargetedFactRecallSection, shouldRecallTargetedFactEvidence } from "../targeted-fact-recall.js";
71
67
  import { shouldFilterSupersededFromRecall } from "../temporal-supersession.js";
72
68
  import { queryTemporalTimelineAsync } from "../temporal-index.js";
73
69
  import { buildTemporalTimelineRecallSection, type TemporalTimelineRecallItem } from "../temporal-timeline-recall.js";
74
70
  import { isValidAsOf } from "../temporal-validity.js";
75
- import { TmtBuilder } from "../tmt.js";
76
- import { TranscriptManager } from "../transcript.js";
77
71
  import { type TrustStageResultItem, projectTrustForXray } from "../trust-score-stage.js";
78
- import { type TrustZoneSearchResult, searchTrustZoneRecords } from "../trust-zones.js";
79
- import type { CodingContext, EngramTraceEvent, IdentityInjectionMode, MemoryFile, MemoryIntent, PluginConfig, QmdSearchResult, RecallPlanMode, RecallSectionConfig } from "../types.js";
72
+ import { searchTrustZoneRecords } from "../trust-zones.js";
73
+ import type { IdentityInjectionMode, MemoryFile, QmdSearchResult, RecallPlanMode } from "../types.js";
80
74
  import { type VerifiedEpisodeResult, compareVerifiedEpisodeResults, searchVerifiedEpisodes } from "../verified-recall.js";
81
75
  import { type WorkProductLedgerSearchResult, searchWorkProductLedgerEntries } from "../work-product-ledger.js";
82
76
  import { abortError } from "../abort-error.js";
@@ -96,365 +90,12 @@ import {
96
90
  throwIfRecallAborted,
97
91
  type GraphRecallSnapshot,
98
92
  type IntentDebugSnapshot,
99
- type QmdRecallSnapshot,
100
93
  type QueryAwarePrefilter,
101
94
  type RecallInvocationOptions,
102
95
  } from "../orchestrator.js";
103
96
  import { isGenericRecallExcludedPath } from "./generic-recall-paths.js";
104
-
105
- import type {
106
- RecallSectionAppendOptions,
107
- RecallSectionBuckets,
108
- } from "./recall-section-coordinator.js";
109
-
110
- export interface RecallInternalDeps {
111
- readonly _recallWorkspaceOverrides: Map<string, string>;
112
- appendRecallSection(
113
- sectionBuckets: RecallSectionBuckets,
114
- sectionId: string,
115
- content: string,
116
- options?: RecallSectionAppendOptions,
117
- ): boolean;
118
- applyColdFallbackPipeline(options: {
119
- prompt: string;
120
- recallNamespaces: string[];
121
- recallResultLimit: number;
122
- recallMode: RecallPlanMode;
123
- /**
124
- * Recall-operation capability gates resolved once at recall entry (#1523).
125
- * OPTIONAL and additive: the recall pipeline threads a resolved set, but
126
- * callers that omit it (e.g. direct unit-test invocations) get an
127
- * equivalent config-derived set — behavior-preserving.
128
- */
129
- caps?: CapabilitySet;
130
- /** Graph-construction gates resolved at recall entry (#1566 Cluster A). */
131
- graphCaps?: GraphConstructionCapabilitySet;
132
- queryAwarePrefilter?: QueryAwarePrefilter;
133
- abortSignal?: AbortSignal;
134
- /** Backend degradation observer — cold-tier QMD must report like hot (#1536). */
135
- onDegradation?: (degradation: SearchDegradation) => void;
136
- /** Issue #680 — historical recall point in ms-since-epoch. */
137
- asOfMs?: number;
138
- /**
139
- * Optional out-parameter that receives the pre-MMR / pre-truncation
140
- * pool size captured inside the pipeline (issue #570 PR 1). The
141
- * X-ray capture block in `recallInternal` passes a small sink so
142
- * the cold-fallback branch's pre-truncation pool size can be
143
- * attributed back to the branch when `recallSource === "cold_fallback"`.
144
- * Unset by default so existing call sites are unaffected.
145
- */
146
- xrayPoolSizeSink?: { size: number };
147
- /**
148
- * Issue #1577 — out-parameter that receives the TrustScore stage's
149
- * per-path trust map (admitted + quarantined) when the cold path runs
150
- * trust scoring. Mirrors the xrayPoolSizeSink pattern so recallInternal
151
- can propagate trust data for epistemic rendering and X-ray visibility
152
- without changing the cold pipeline's return type.
153
- */
154
- trustByPathSink?: { trustByPath: Map<string, TrustStageResultItem> | null };
155
- deadlineAtMs?: number | null;
156
- /** Issue #681 — when true, bypass graphTraversalConfidenceFloor. */
157
- includeLowConfidence?: boolean;
158
- }): Promise<QmdSearchResult[]>;
159
- applyTrustScoreToBranch(
160
- results: QmdSearchResult[],
161
- namespaces: string[],
162
- caps: CapabilitySet,
163
- label: string,
164
- preloadedFrontmatter?: ReadonlyMap<string, MemoryFile>,
165
- abortSignal?: AbortSignal,
166
- ): Promise<{
167
- results: QmdSearchResult[];
168
- trustByPath: Map<string, TrustStageResultItem> | null;
169
- }>;
170
- assembleRecallSections(
171
- sectionBuckets: RecallSectionBuckets,
172
- budgetOverride?: number,
173
- ): {
174
- sections: string[];
175
- includedIds: string[];
176
- omittedIds: string[];
177
- truncated: boolean;
178
- finalChars: number;
179
- includedMemoryIds: string[];
180
- includedMemoryPaths: string[];
181
- includedMemoryNamespaces: Array<string | undefined>;
182
- omittedMemoryIds: string[];
183
- };
184
- boostSearchResults(
185
- results: QmdSearchResult[],
186
- _recallNamespaces: string[],
187
- prompt?: string,
188
- preloadedMemoryMap?: Map<string, MemoryFile>,
189
- options?: {
190
- allowLifecycleFiltered?: boolean;
191
- allowDedicatedSurface?: boolean;
192
- /**
193
- * Historical recall point in ms-since-epoch (issue #680). When
194
- * set, drops candidates that were not authoritative at this
195
- * instant per `temporal-validity.isValidAsOf`. Caller is
196
- * responsible for parsing/validating the user-supplied ISO
197
- * string at the input boundary (CLI / HTTP / MCP).
198
- */
199
- asOfMs?: number;
200
- },
201
- ): Promise<QmdSearchResult[]>;
202
- boxBuilderFor(storage: StorageManager): BoxBuilder;
203
- buildCompressionGuidelineRecallSection(): Promise<string | null>;
204
- buildConfiguredQmdSearchOptions(
205
- queryText: string,
206
- ): SearchQueryOptions | undefined;
207
- buildGraphRecallRankedResults(
208
- results: QmdSearchResult[],
209
- sourceLabelResolver: (path: string) => string[],
210
- limit?: number,
211
- ): GraphRecallRankedResult[];
212
- buildIdentityContinuitySection(options: {
213
- storage: StorageManager;
214
- recallMode: RecallPlanMode;
215
- prompt: string;
216
- }): Promise<{
217
- section: string;
218
- mode: IdentityInjectionMode;
219
- injectedChars: number;
220
- truncated: boolean;
221
- } | null>;
222
- buildLastRecallBudgetSummary(options: {
223
- requestedTopK?: number;
224
- recallResultLimit: number;
225
- qmdFetchLimit: number;
226
- qmdHybridFetchLimit: number;
227
- finalContextChars?: number;
228
- truncated?: boolean;
229
- includedSections?: string[];
230
- omittedSections?: string[];
231
- includedMemoryIds?: string[];
232
- includedMemoryPaths?: string[];
233
- includedMemoryNamespaces?: Array<string | undefined>;
234
- omittedMemoryIds?: string[];
235
- }): LastRecallBudgetSummary;
236
- buildQueryAwarePrefilter(
237
- prompt: string,
238
- recallNamespaces: string[],
239
- ): Promise<QueryAwarePrefilter>;
240
- collectLastRecallSources(
241
- sectionBuckets: RecallSectionBuckets,
242
- recallSource:
243
- | "none"
244
- | "hot_qmd"
245
- | "hot_embedding"
246
- | "cold_fallback"
247
- | "recent_scan",
248
- ): string[];
249
- readonly compounding?: CompoundingEngine;
250
- readonly config: PluginConfig;
251
- currentPolicyVersion(): string;
252
- diversifyAndLimitRecallResults(
253
- sectionId: string,
254
- results: QmdSearchResult[],
255
- limit: number,
256
- retrievalQuery?: string,
257
- caps?: CapabilitySet,
258
- ): QmdSearchResult[];
259
- effectiveCronRecallInstructionHeavyTokenCap(): number;
260
- emitTrace(event: EngramTraceEvent): void;
261
- expandResultsViaGraph(options: {
262
- memoryResults: QmdSearchResult[];
263
- recallNamespaces: string[];
264
- recallResultLimit: number;
265
- deadlineAtMs?: number | null;
266
- includeLowConfidence?: boolean;
267
- }): Promise<{
268
- merged: QmdSearchResult[];
269
- seedPaths: string[];
270
- expandedPaths: GraphRecallExpandedEntry[];
271
- seedResults: QmdSearchResult[];
272
- }>;
273
- extractMemoryIdsFromResults(results: QmdSearchResult[]): string[];
274
- readonly fastLlmForRerank: {
275
- chatCompletion: (
276
- messages: Array<{ role: string; content: string }>,
277
- options?: { maxTokens?: number; temperature?: number; timeoutMs?: number; operation?: string; priority?: "recall-critical" | "background" },
278
- ) => Promise<{ content: string } | null>;
279
- };
280
- fetchQmdMemoryResultsWithArtifactTopUp(
281
- prompt: string,
282
- qmdFetchLimit: number,
283
- qmdHybridFetchLimit: number,
284
- options: {
285
- namespacesEnabled: boolean;
286
- recallNamespaces: string[];
287
- resolveNamespace: (path: string) => string;
288
- collection?: string;
289
- queryAwarePrefilter?: QueryAwarePrefilter;
290
- searchOptions?: SearchQueryOptions;
291
- onDebugSnapshot?: (snapshot: QmdRecallSnapshot) => Promise<void>;
292
- /** Backend degradation observer, threaded into every QMD call (#1536). */
293
- onDegradation?: (degradation: SearchDegradation) => void;
294
- abortSignal?: AbortSignal;
295
- },
296
- ): Promise<QmdSearchResult[]>;
297
- filterSearchResultsForRecall(
298
- results: QmdSearchResult[],
299
- preloadedMemoryMap?: Map<string, MemoryFile>,
300
- options?: {
301
- allowLifecycleFiltered?: boolean;
302
- allowDedicatedSurface?: boolean;
303
- asOfMs?: number;
304
- deadlineAtMs?: number | null;
305
- abortSignal?: AbortSignal;
306
- dropUnresolved?: boolean;
307
- recallNamespaces?: readonly string[];
308
- },
309
- ): Promise<{ results: QmdSearchResult[]; memoryByPath: Map<string, MemoryFile> }>;
310
- formatCausalTrajectoryResults(
311
- results: CausalTrajectorySearchResult[],
312
- ): string;
313
- formatConversationRecallSection(
314
- results: Array<{ path: string; snippet: string; score: number }>,
315
- maxChars: number,
316
- ): string | null;
317
- formatHarmonicRetrievalResults(
318
- results: HarmonicRetrievalResult[],
319
- ): string;
320
- formatObjectiveStateResults(
321
- results: ObjectiveStateSearchResult[],
322
- ): string;
323
- formatQmdResults(
324
- title: string,
325
- results: QmdSearchResult[],
326
- sessionKey?: string,
327
- trustByPath?: Map<string, TrustStageResultItem> | null,
328
- ): string;
329
- formatTrustZoneResults(results: TrustZoneSearchResult[]): string;
330
- formatVerifiedEpisodeResults(
331
- results: VerifiedEpisodeResult[],
332
- ): string;
333
- formatVerifiedSemanticRuleResults(
334
- results: VerifiedSemanticRuleResult[],
335
- ): string;
336
- formatWorkProductResults(
337
- results: WorkProductLedgerSearchResult[],
338
- ): string;
339
- getCodingContextForSession(sessionKey: string | undefined): CodingContext | null;
340
- getPeerIdForSession(sessionKey: string | undefined): string | null;
341
- getRecallBudgetChars(override?: number): number;
342
- getRecallSectionEntry(
343
- sectionId: string,
344
- ): RecallSectionConfig | undefined;
345
- getRecallSectionMaxChars(
346
- sectionId: string,
347
- ): number | null | undefined;
348
- getRecallSectionNumber(
349
- sectionId: string,
350
- key: keyof RecallSectionConfig,
351
- ): number | undefined;
352
- getStorage(namespace?: string): Promise<StorageManager>;
353
- readonly handleHistory: RecallHandleHistoryStore;
354
- trackMemoryAccess(
355
- memoryIds: string[],
356
- memoryPaths?: string[],
357
- memoryNamespaces?: Array<string | undefined>,
358
- ): void;
359
- trackRecallBackgroundWrite(promise: Promise<void>, label: string): void;
360
- isRecallSectionEnabled(
361
- sectionId: string,
362
- defaultEnabled?: boolean,
363
- ): boolean;
364
- isSpecializedRecallSectionEnabled(
365
- sectionId: string,
366
- topLevelEnabled: boolean,
367
- ): boolean;
368
- lastQmdReprobeAtMs: number;
369
- readonly lastRecall: LastRecallStore;
370
- lastXraySnapshot: RecallXraySnapshot | null;
371
- readonly lcmEngine: LcmEngine | null;
372
- readonly namespaceCatalog: NamespaceCatalog;
373
- namespaceFromPath(p: string): string;
374
- readonly profiler: ProfilingCollector;
375
- publishRecallResults(options: {
376
- title: string;
377
- results: QmdSearchResult[];
378
- sectionBuckets: RecallSectionBuckets;
379
- retrievalQuery: string;
380
- sessionKey: string | undefined;
381
- identityInjection?: {
382
- mode: IdentityInjectionMode | "none";
383
- injectedChars: number;
384
- truncated: boolean;
385
- };
386
- /**
387
- * Issue #1577 — per-recall trust map. When present, quarantined items
388
- * are filtered from injection on EVERY recall path (hot QMD, embedding
389
- * fallback, cold archive, recent) so a faithfulness-contradicted memory
390
- * cannot sneak in via a branch that bypasses trust scoring (review:
391
- * fallback paths bypass trust). The map is also threaded to
392
- * formatQmdResults for the epistemic hedge.
393
- */
394
- trustByPath?: Map<string, TrustStageResultItem> | null;
395
- }): void;
396
- readonly qmd: SearchBackend;
397
- queueEvalShadowRecall(
398
- record: Omit<EvalShadowRecallRecord, "schemaVersion">,
399
- ): void;
400
- readAllMemoriesForNamespaces(
401
- namespaces: string[],
402
- ): Promise<MemoryFile[]>;
403
- recallArtifactsAcrossNamespaces(
404
- prompt: string,
405
- recallNamespaces: string[],
406
- targetCount: number,
407
- ): Promise<MemoryFile[]>;
408
- recallAssemblyClockMs(): number;
409
- recordLastGraphRecallSnapshot(options: {
410
- storage: StorageManager;
411
- prompt: string;
412
- recallMode: RecallPlanMode;
413
- recallNamespaces: string[];
414
- seedPaths: string[];
415
- expandedPaths: GraphRecallExpandedEntry[];
416
- status: "completed" | "skipped" | "aborted";
417
- reason?: string;
418
- shadowMode?: boolean;
419
- queryIntent: MemoryIntent;
420
- seedResults?: GraphRecallRankedResult[];
421
- finalResults?: GraphRecallRankedResult[];
422
- shadowComparison?: GraphRecallShadowComparison;
423
- }): Promise<void>;
424
- recordLastIntentSnapshot(options: {
425
- storage: StorageManager;
426
- snapshot: IntentDebugSnapshot;
427
- }): Promise<void>;
428
- recordLastIntentSnapshotForNamespace(options: {
429
- namespace: string;
430
- snapshot: IntentDebugSnapshot;
431
- }): Promise<void>;
432
- recordLastQmdRecallSnapshot(options: {
433
- storage: StorageManager;
434
- snapshot: QmdRecallSnapshot;
435
- }): Promise<void>;
436
- readonly rerankCache: RerankCache;
437
- searchConversationRecallResults(
438
- retrievalQuery: string,
439
- topK: number,
440
- ): Promise<Array<{ path: string; snippet: string; score: number }>>;
441
- searchEmbeddingFallback(
442
- query: string,
443
- limit: number,
444
- ): Promise<QmdSearchResult[]>;
445
- readonly sharedContext?: SharedContextManager;
446
- readonly storage: StorageManager;
447
- readonly storageRouter: NamespaceStorageRouter;
448
- readonly summarizer: HourlySummarizer;
449
- readonly tmtBuilder: TmtBuilder;
450
- readonly transcript: TranscriptManager;
451
- truncateArtifactForRecall(text: string, maxChars?: number): string;
452
- truncateRecallSectionToBudget(
453
- content: string,
454
- maxChars: number,
455
- ): string;
456
- }
457
-
97
+ import type { RecallSectionBuckets } from "./recall-section-coordinator.js";
98
+ import type { RecallInternalDeps } from "./recall-internal-deps.js";
458
99
  export class RecallInternalCoordinator {
459
100
  constructor(
460
101
  private readonly deps: RecallInternalDeps,
@@ -43,7 +43,7 @@
43
43
  * Naming: `secure-fs.ts` (not `vault-fs.ts`) — see `kdf.ts` naming note.
44
44
  */
45
45
 
46
- import { createCipheriv, randomBytes, randomUUID } from "node:crypto";
46
+ import { createCipheriv, createDecipheriv, randomBytes, randomUUID } from "node:crypto";
47
47
  import { lstat, mkdir, open as openFile, readFile, readdir, rename, unlink, writeFile } from "node:fs/promises";
48
48
  import path from "node:path";
49
49
 
@@ -416,6 +416,83 @@ export async function writeMaybeEncryptedFileFromChunks(
416
416
  }
417
417
  }
418
418
 
419
+ /**
420
+ * Stream a file through the secure-store reader without buffering the whole
421
+ * payload. Plaintext files are passed through unchanged; encrypted files are
422
+ * authenticated and decrypted incrementally.
423
+ */
424
+ export async function* readMaybeEncryptedFileFromChunks(
425
+ filePath: string,
426
+ key: Buffer | null,
427
+ memoryDir?: string,
428
+ chunkSize = 64 * 1024
429
+ ): AsyncIterable<Buffer> {
430
+ const handle = await openFile(filePath, "r");
431
+ const headerSize = MAGIC_HEADER_SIZE + ENVELOPE_HEADER_SIZE;
432
+ try {
433
+ const prefix = Buffer.alloc(headerSize);
434
+ const { bytesRead: prefixBytes } = await handle.read(prefix, 0, prefix.length, 0);
435
+ const prefixView = prefix.subarray(0, prefixBytes);
436
+ if (!isEncryptedFile(prefixView)) {
437
+ if (prefixBytes > 0) yield Buffer.from(prefixView);
438
+ let position = prefixBytes;
439
+ const buffer = Buffer.alloc(chunkSize);
440
+ for (;;) {
441
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, position);
442
+ if (bytesRead === 0) break;
443
+ position += bytesRead;
444
+ yield Buffer.from(buffer.subarray(0, bytesRead));
445
+ }
446
+ return;
447
+ }
448
+ if (prefixBytes < headerSize) {
449
+ throw new Error(`encrypted file header is truncated: ${filePath}`);
450
+ }
451
+ if (key === null) {
452
+ throw new SecureStoreLockedError(
453
+ `secure-store is locked — cannot read encrypted file at ${filePath}. ` +
454
+ "Run `remnic secure-store unlock` to decrypt."
455
+ );
456
+ }
457
+ const envelope = prefix.subarray(MAGIC_HEADER_SIZE);
458
+ const version = envelope.readUInt8(ENVELOPE_LAYOUT.version);
459
+ if (version !== ENVELOPE_VERSION) {
460
+ throw new Error(`secure-store: unsupported envelope version ${version}`);
461
+ }
462
+ const salt = envelope.subarray(
463
+ ENVELOPE_LAYOUT.salt,
464
+ ENVELOPE_LAYOUT.salt + ENVELOPE_SALT_LENGTH
465
+ );
466
+ const iv = envelope.subarray(ENVELOPE_LAYOUT.iv, ENVELOPE_LAYOUT.iv + IV_LENGTH);
467
+ const authTag = envelope.subarray(
468
+ ENVELOPE_LAYOUT.authTag,
469
+ ENVELOPE_LAYOUT.authTag + AUTH_TAG_LENGTH
470
+ );
471
+ const decipher = createDecipheriv("aes-256-gcm", key, iv, { authTagLength: AUTH_TAG_LENGTH });
472
+ decipher.setAAD(Buffer.concat([buildHeaderAad(salt), filePathAad(filePath, memoryDir)]));
473
+ decipher.setAuthTag(authTag);
474
+ let position = headerSize;
475
+ const buffer = Buffer.alloc(chunkSize);
476
+ try {
477
+ for (;;) {
478
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, position);
479
+ if (bytesRead === 0) break;
480
+ position += bytesRead;
481
+ const plain = decipher.update(buffer.subarray(0, bytesRead));
482
+ if (plain.length > 0) yield plain;
483
+ }
484
+ const final = decipher.final();
485
+ if (final.length > 0) yield final;
486
+ } catch (err) {
487
+ if (err instanceof SecureStoreDecryptError) throw err;
488
+ const message = err instanceof Error ? err.message : String(err);
489
+ throw new SecureStoreDecryptError(`secure-store decryption failed: ${message}`);
490
+ }
491
+ } finally {
492
+ await handle.close();
493
+ }
494
+ }
495
+
419
496
  // ---------------------------------------------------------------------------
420
497
  // Migration
421
498
  // ---------------------------------------------------------------------------
@@ -76,6 +76,14 @@ export class FactHashIndexNotAuthoritativeError extends Error {
76
76
  }
77
77
  }
78
78
 
79
+ type DiskFingerprint = {
80
+ mtimeMs: number;
81
+ size: number;
82
+ dev: number;
83
+ ino: number;
84
+ ctimeMs: number;
85
+ birthtimeMs: number;
86
+ };
79
87
  /**
80
88
  * Content-hash dedup index for facts.
81
89
  * Normalizes content (lowercase, strip punctuation, collapse whitespace),
@@ -120,15 +128,13 @@ export class ContentHashIndex {
120
128
  private reconcileRetryBarrier: Promise<void> | null = null;
121
129
  private reconcileRetryResolve: (() => void) | null = null;
122
130
  /**
123
- * On-disk fingerprint (mtime + byte size) of `fact-hashes.txt` captured at the
124
- * last point THIS instance's in-memory set matched disk — after `load()`,
125
- * `save()`, or a reconcile publish (PR #2016 review). A peer process that
126
- * advances the durable index changes this fingerprint;
127
- * {@link isDiskFingerprintCurrent} compares a single cheap `stat` against it so
128
- * a stale-but-"authoritative" snapshot is detected without an O(file-size)
129
- * re-read on the hot path.
131
+ * On-disk fingerprint captured at the last point THIS instance's in-memory
132
+ * set matched disk — after `load()`, `save()`, or a reconcile publish. A peer
133
+ * process that advances the durable index changes its file generation even
134
+ * when byte size and mtime collide, so the freshness check remains safe
135
+ * without an O(file-size) read on the hot path.
130
136
  */
131
- private lastSyncedFingerprint: { mtimeMs: number; size: number } | null = null;
137
+ private lastSyncedFingerprint: DiskFingerprint | null = null;
132
138
 
133
139
  constructor(
134
140
  stateDir: string,
@@ -166,10 +172,17 @@ export class ContentHashIndex {
166
172
  }
167
173
 
168
174
  /** Cheap `stat` of the durable index file; null when it does not exist yet. */
169
- private async statIndexFile(): Promise<{ mtimeMs: number; size: number } | null> {
175
+ private async statIndexFile(): Promise<DiskFingerprint | null> {
170
176
  try {
171
177
  const s = await stat(this.filePath);
172
- return { mtimeMs: s.mtimeMs, size: s.size };
178
+ return {
179
+ mtimeMs: s.mtimeMs,
180
+ size: s.size,
181
+ dev: s.dev,
182
+ ino: s.ino,
183
+ ctimeMs: s.ctimeMs,
184
+ birthtimeMs: s.birthtimeMs,
185
+ };
173
186
  } catch (err) {
174
187
  if (isErrnoCode(err, "ENOENT")) return null;
175
188
  throw err;
@@ -190,14 +203,15 @@ export class ContentHashIndex {
190
203
 
191
204
  /**
192
205
  * True when the durable index file is unchanged since this instance last
193
- * synced it (load / save / reconcile). False when a peer advanced it, when the
194
- * file appeared or vanished, or when freshness cannot be established (stat
195
- * error) — the caller then treats the in-memory snapshot as non-authoritative
196
- * and confirms a dedup miss against the durable corpus (PR #2016 review). One
197
- * `stat`, never an O(file-size) read, so the hot path stays cheap.
206
+ * synced it (load / save / reconcile). False when a peer advanced it, when
207
+ * the file appeared or vanished, or when freshness cannot be established
208
+ * (stat error) — the caller then treats the in-memory snapshot as
209
+ * non-authoritative and confirms a dedup miss against the durable corpus.
210
+ * The stat includes file identity and generation metadata so same-size,
211
+ * same-mtime atomic replacements are detected without reading the file body.
198
212
  */
199
213
  async isDiskFingerprintCurrent(): Promise<boolean> {
200
- let current: { mtimeMs: number; size: number } | null;
214
+ let current: DiskFingerprint | null;
201
215
  try {
202
216
  current = await this.statIndexFile();
203
217
  } catch {
@@ -207,7 +221,14 @@ export class ContentHashIndex {
207
221
  if (last === null || current === null) {
208
222
  return last === null && current === null;
209
223
  }
210
- return current.mtimeMs === last.mtimeMs && current.size === last.size;
224
+ return (
225
+ current.mtimeMs === last.mtimeMs &&
226
+ current.size === last.size &&
227
+ current.dev === last.dev &&
228
+ current.ino === last.ino &&
229
+ current.ctimeMs === last.ctimeMs &&
230
+ current.birthtimeMs === last.birthtimeMs
231
+ );
211
232
  }
212
233
 
213
234
  /** Check if content already exists in the index. */
@@ -475,6 +496,11 @@ export class ContentHashIndex {
475
496
  return this.reconcileRetryTimer !== null;
476
497
  }
477
498
 
499
+ /** True while this index has in-memory changes not yet published to disk. */
500
+ get hasPendingChanges(): boolean {
501
+ return this.dirty;
502
+ }
503
+
478
504
  /**
479
505
  * Resolve once any armed background reconcile-save retry chain has settled —
480
506
  * either it published the deferred additions, or it exhausted its bounded