@remnic/core 9.3.742 → 9.3.743

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 (261) hide show
  1. package/dist/access-boundary.d.ts +5 -5
  2. package/dist/access-boundary.js +10 -10
  3. package/dist/access-cli.js +29 -29
  4. package/dist/access-http.d.ts +5 -5
  5. package/dist/access-http.js +15 -15
  6. package/dist/access-mcp.d.ts +5 -5
  7. package/dist/access-mcp.js +14 -14
  8. package/dist/access-operations-batch.js +12 -12
  9. package/dist/access-operations.d.ts +5 -5
  10. package/dist/access-operations.js +13 -13
  11. package/dist/{access-service-K8n12dXu.d.ts → access-service-BeW5GOg1.d.ts} +3 -3
  12. package/dist/access-service.d.ts +5 -5
  13. package/dist/access-service.js +9 -9
  14. package/dist/access-surface-catalog.d.ts +5 -5
  15. package/dist/action-confidence.d.ts +1 -1
  16. package/dist/active-memory-bridge.d.ts +1 -1
  17. package/dist/active-memory-bridge.js +3 -3
  18. package/dist/active-recall.d.ts +1 -1
  19. package/dist/behavior-learner.d.ts +1 -1
  20. package/dist/behavior-signals.d.ts +1 -1
  21. package/dist/bootstrap.d.ts +4 -4
  22. package/dist/briefing.d.ts +1 -1
  23. package/dist/buffer-surprise-report.d.ts +1 -1
  24. package/dist/buffer.d.ts +1 -1
  25. package/dist/buffer.js +2 -2
  26. package/dist/calibration.d.ts +1 -1
  27. package/dist/capabilities.d.ts +10 -5
  28. package/dist/capabilities.js +1 -1
  29. package/dist/{catalog-_Bap6vfD.d.ts → catalog-CX0CjOaf.d.ts} +1 -1
  30. package/dist/causal-behavior.d.ts +1 -1
  31. package/dist/causal-consolidation.d.ts +1 -1
  32. package/dist/causal-consolidation.js +2 -2
  33. package/dist/causal-trajectory-graph.d.ts +1 -1
  34. package/dist/{chunk-X5PMDVY4.js → chunk-3EA5LIFJ.js} +4 -4
  35. package/dist/{chunk-YNHRWFAP.js → chunk-4DLFJJOQ.js} +2 -2
  36. package/dist/{chunk-WIMKOTNY.js → chunk-5QANTTY2.js} +2 -2
  37. package/dist/{chunk-AM7YKD7V.js → chunk-5UNSGRCR.js} +5 -5
  38. package/dist/{chunk-Y6PNYJVO.js → chunk-A2KKLCOS.js} +2 -2
  39. package/dist/{chunk-O4IWVWSW.js → chunk-AVBT5WEW.js} +3 -3
  40. package/dist/{chunk-QUNH5UZH.js → chunk-BYLC4DKI.js} +2 -2
  41. package/dist/{chunk-UOVDO6TC.js → chunk-CHELXDTO.js} +3 -3
  42. package/dist/{chunk-TQQN64J2.js → chunk-DBSMLRTO.js} +2 -2
  43. package/dist/{chunk-EZZUNKMJ.js → chunk-DYK27X7V.js} +3 -3
  44. package/dist/{chunk-K2N6WIZM.js → chunk-E7RGJQWP.js} +2 -2
  45. package/dist/{chunk-M4WI23X3.js → chunk-EEKDRAWX.js} +2 -2
  46. package/dist/{chunk-GFJ5ABKS.js → chunk-G5FP7VSQ.js} +11 -11
  47. package/dist/{chunk-BE6NEQLF.js → chunk-HAZVVOYT.js} +3 -3
  48. package/dist/{chunk-OT5K26NG.js → chunk-HM6UJPPO.js} +2 -2
  49. package/dist/{chunk-PI4JHLDD.js → chunk-IP5SANO2.js} +2 -2
  50. package/dist/{chunk-WHEF76BQ.js → chunk-JRZV3767.js} +2 -2
  51. package/dist/{chunk-OS5RKJOH.js → chunk-JZ7P26GF.js} +2 -2
  52. package/dist/{chunk-Y62QPRKV.js → chunk-K5LLP4CY.js} +2 -2
  53. package/dist/{chunk-C3Z5YJSM.js → chunk-LOPZ2DWR.js} +2 -2
  54. package/dist/{chunk-BJPL5WAL.js → chunk-MXDG6SRH.js} +3 -3
  55. package/dist/{chunk-UYYSOMS2.js → chunk-NBP3YHHS.js} +4 -4
  56. package/dist/{chunk-USHVHI6J.js → chunk-NNL4LJAD.js} +3 -3
  57. package/dist/{chunk-GPX5E36D.js → chunk-OSMBC3JU.js} +2 -2
  58. package/dist/{chunk-OUSOMUFV.js → chunk-PE6XR4GG.js} +2 -2
  59. package/dist/{chunk-CMPXLMC3.js → chunk-PI23H7FV.js} +3 -3
  60. package/dist/{chunk-WGDE2TJP.js → chunk-QOGXUNWL.js} +4 -4
  61. package/dist/{chunk-ELL5VYXC.js → chunk-RNWWAS5V.js} +3 -3
  62. package/dist/{chunk-JMMSVRF4.js → chunk-TQPSOTC7.js} +7 -7
  63. package/dist/{chunk-AX4TRSRE.js → chunk-U5WVRMCA.js} +2 -2
  64. package/dist/{chunk-7ADHJ6SU.js → chunk-VE54E6RP.js} +4 -4
  65. package/dist/{chunk-7HUGLMSW.js → chunk-VO4VARZL.js} +465 -321
  66. package/dist/chunk-VO4VARZL.js.map +1 -0
  67. package/dist/{chunk-G7Q4D2G3.js → chunk-VSF7AAGE.js} +1 -3
  68. package/dist/chunk-VSF7AAGE.js.map +1 -0
  69. package/dist/{chunk-OVYBENIJ.js → chunk-W3M34XT4.js} +3 -3
  70. package/dist/{chunk-NHJYUIII.js → chunk-WPLRJ4XM.js} +7 -7
  71. package/dist/{chunk-UEIF7RWQ.js → chunk-XEADGIAA.js} +6 -6
  72. package/dist/{cli-BEOLy1xo.d.ts → cli-BYad9YYY.d.ts} +3 -3
  73. package/dist/cli.d.ts +6 -6
  74. package/dist/cli.js +21 -21
  75. package/dist/compounding/engine.d.ts +1 -1
  76. package/dist/compounding/engine.js +3 -3
  77. package/dist/compounding/preference-consolidator.d.ts +1 -1
  78. package/dist/compression-optimizer.d.ts +1 -1
  79. package/dist/config.d.ts +1 -1
  80. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  81. package/dist/connectors/codex-materialize.d.ts +1 -1
  82. package/dist/connectors/index.d.ts +1 -1
  83. package/dist/connectors/index.js +2 -2
  84. package/dist/consolidation-provenance-check.d.ts +1 -1
  85. package/dist/consolidation-undo.d.ts +1 -1
  86. package/dist/contradiction/index.d.ts +1 -1
  87. package/dist/contradiction/index.js +2 -2
  88. package/dist/{contradiction-scan-UERKJESC.js → contradiction-scan-3FJYWS3G.js} +3 -3
  89. package/dist/conversation-index/backend.d.ts +1 -1
  90. package/dist/conversation-index/chunker.d.ts +1 -1
  91. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  92. package/dist/conversation-index/indexer.d.ts +1 -1
  93. package/dist/conversation-index/search.d.ts +1 -1
  94. package/dist/day-summary.d.ts +1 -1
  95. package/dist/day-summary.js +2 -2
  96. package/dist/delinearize.d.ts +1 -1
  97. package/dist/direct-answer-wiring.d.ts +1 -1
  98. package/dist/direct-answer.d.ts +1 -1
  99. package/dist/embedding-fallback.d.ts +1 -1
  100. package/dist/embedding-fallback.js +2 -2
  101. package/dist/enrichment/index.d.ts +1 -1
  102. package/dist/entity-retrieval.d.ts +1 -1
  103. package/dist/entity-retrieval.js +2 -2
  104. package/dist/entity-schema.d.ts +1 -1
  105. package/dist/explicit-capture.d.ts +4 -4
  106. package/dist/explicit-capture.js +2 -2
  107. package/dist/extraction-faithfulness.d.ts +1 -1
  108. package/dist/extraction-judge-telemetry.d.ts +1 -1
  109. package/dist/extraction-judge-training.d.ts +1 -1
  110. package/dist/extraction-judge.d.ts +1 -1
  111. package/dist/extraction.d.ts +1 -1
  112. package/dist/extraction.js +4 -4
  113. package/dist/fallback-llm.d.ts +1 -1
  114. package/dist/{first-start-migration-GQ3UQNIL.js → first-start-migration-4I3VDSYS.js} +2 -2
  115. package/dist/graph-dashboard-diff.d.ts +1 -1
  116. package/dist/graph-dashboard-key.d.ts +1 -1
  117. package/dist/graph-dashboard-parser.d.ts +1 -1
  118. package/dist/graph-edge-reinforcement.d.ts +1 -1
  119. package/dist/graph-snapshot.d.ts +1 -1
  120. package/dist/graph.d.ts +1 -1
  121. package/dist/identity-continuity.d.ts +1 -1
  122. package/dist/importance.d.ts +1 -1
  123. package/dist/index.d.ts +9 -9
  124. package/dist/index.js +36 -36
  125. package/dist/intent.d.ts +1 -1
  126. package/dist/lcm/engine.d.ts +1 -1
  127. package/dist/lcm/index.d.ts +1 -1
  128. package/dist/lcm/tools.d.ts +1 -1
  129. package/dist/lifecycle.d.ts +1 -1
  130. package/dist/live-connectors-runner.d.ts +1 -1
  131. package/dist/local-llm.d.ts +1 -1
  132. package/dist/local-llm.js +2 -2
  133. package/dist/local-model-endpoint.d.ts +1 -1
  134. package/dist/maintenance/memory-governance.d.ts +1 -1
  135. package/dist/mcp-memory-inspector-app.d.ts +5 -5
  136. package/dist/memory-action-policy.d.ts +1 -1
  137. package/dist/memory-cache.d.ts +1 -1
  138. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  139. package/dist/memory-projection-store.d.ts +1 -1
  140. package/dist/memory-provenance.d.ts +1 -1
  141. package/dist/memory-worth-outcomes.d.ts +1 -1
  142. package/dist/models-json.d.ts +1 -1
  143. package/dist/namespaces/migrate.d.ts +2 -2
  144. package/dist/namespaces/migrate.js +6 -6
  145. package/dist/namespaces/principal.d.ts +1 -1
  146. package/dist/namespaces/principal.js +2 -2
  147. package/dist/namespaces/search.d.ts +1 -1
  148. package/dist/namespaces/search.js +4 -4
  149. package/dist/namespaces/storage.d.ts +2 -2
  150. package/dist/namespaces/storage.js +2 -2
  151. package/dist/native-knowledge.d.ts +1 -1
  152. package/dist/operator-toolkit.d.ts +1 -1
  153. package/dist/operator-toolkit.js +11 -11
  154. package/dist/orchestration/compression-guideline-coordinator.d.ts +1 -1
  155. package/dist/orchestration/compression-guideline-coordinator.js +2 -2
  156. package/dist/orchestration/maintenance.d.ts +2 -2
  157. package/dist/orchestration/maintenance.js +6 -6
  158. package/dist/{orchestrator-Dr-1v5EL.d.ts → orchestrator-CupigmWu.d.ts} +163 -7
  159. package/dist/orchestrator.d.ts +4 -4
  160. package/dist/orchestrator.js +24 -24
  161. package/dist/patterns-cli.d.ts +1 -1
  162. package/dist/policy-runtime.d.ts +1 -1
  163. package/dist/provenance.d.ts +1 -1
  164. package/dist/qmd-recall-cache.d.ts +1 -1
  165. package/dist/qmd.d.ts +1 -1
  166. package/dist/recall-disclosure-escalation.d.ts +1 -1
  167. package/dist/recall-explain-renderer.d.ts +1 -1
  168. package/dist/recall-planner-llm.d.ts +1 -1
  169. package/dist/recall-state.d.ts +1 -1
  170. package/dist/recall-tag-filter.d.ts +1 -1
  171. package/dist/recall-xray-cli.d.ts +1 -1
  172. package/dist/recall-xray-renderer.d.ts +1 -1
  173. package/dist/recall-xray.d.ts +1 -1
  174. package/dist/resolve-auth-token.d.ts +1 -1
  175. package/dist/retrieval-agents.d.ts +1 -1
  176. package/dist/retrieval-tiers.d.ts +1 -1
  177. package/dist/routing/engine.d.ts +1 -1
  178. package/dist/routing/store.d.ts +1 -1
  179. package/dist/search/embed-helper.d.ts +1 -1
  180. package/dist/search/embed-helper.js +2 -2
  181. package/dist/search/factory.d.ts +1 -1
  182. package/dist/search/factory.js +3 -3
  183. package/dist/search/index.d.ts +1 -1
  184. package/dist/search/index.js +3 -3
  185. package/dist/search/lancedb-backend.d.ts +1 -1
  186. package/dist/search/meilisearch-backend.d.ts +1 -1
  187. package/dist/search/noop-backend.d.ts +1 -1
  188. package/dist/search/orama-backend.d.ts +1 -1
  189. package/dist/search/port.d.ts +1 -1
  190. package/dist/search/remote-backend.d.ts +1 -1
  191. package/dist/{semantic-consolidation-DsIEiCka.d.ts → semantic-consolidation-ByzGwC9c.d.ts} +1 -1
  192. package/dist/semantic-consolidation.d.ts +2 -2
  193. package/dist/semantic-consolidation.js +2 -2
  194. package/dist/semantic-rule-verifier.d.ts +1 -1
  195. package/dist/session-observer-bands.d.ts +1 -1
  196. package/dist/session-observer-state.d.ts +1 -1
  197. package/dist/shared-context/manager.d.ts +1 -1
  198. package/dist/shared-context/manager.js +2 -2
  199. package/dist/signal.d.ts +1 -1
  200. package/dist/storage.d.ts +1 -1
  201. package/dist/summarizer.d.ts +1 -1
  202. package/dist/summarizer.js +3 -3
  203. package/dist/summary-snapshot.d.ts +1 -1
  204. package/dist/temporal-supersession.d.ts +1 -1
  205. package/dist/temporal-validity.d.ts +1 -1
  206. package/dist/threading.d.ts +1 -1
  207. package/dist/tier-migration.d.ts +1 -1
  208. package/dist/tier-routing.d.ts +1 -1
  209. package/dist/{tier-stats-CSKL7BDG.js → tier-stats-5XF4UBRQ.js} +2 -2
  210. package/dist/topics.d.ts +1 -1
  211. package/dist/transcript.d.ts +1 -1
  212. package/dist/trust-score-stage.d.ts +1 -1
  213. package/dist/trust-score.d.ts +1 -1
  214. package/dist/{types-CglNn2V-.d.ts → types-5Jik3r4G.d.ts} +1 -1
  215. package/dist/types.d.ts +1 -1
  216. package/dist/utility-runtime.d.ts +1 -1
  217. package/package.json +2 -2
  218. package/src/capabilities.test.ts +0 -2
  219. package/src/capabilities.ts +7 -6
  220. package/src/orchestration/contradiction-linking-coordinator.ts +336 -0
  221. package/src/orchestration/recall-section-coordinator.ts +349 -0
  222. package/src/orchestrator.ts +67 -400
  223. package/dist/chunk-7HUGLMSW.js.map +0 -1
  224. package/dist/chunk-G7Q4D2G3.js.map +0 -1
  225. /package/dist/{chunk-X5PMDVY4.js.map → chunk-3EA5LIFJ.js.map} +0 -0
  226. /package/dist/{chunk-YNHRWFAP.js.map → chunk-4DLFJJOQ.js.map} +0 -0
  227. /package/dist/{chunk-WIMKOTNY.js.map → chunk-5QANTTY2.js.map} +0 -0
  228. /package/dist/{chunk-AM7YKD7V.js.map → chunk-5UNSGRCR.js.map} +0 -0
  229. /package/dist/{chunk-Y6PNYJVO.js.map → chunk-A2KKLCOS.js.map} +0 -0
  230. /package/dist/{chunk-O4IWVWSW.js.map → chunk-AVBT5WEW.js.map} +0 -0
  231. /package/dist/{chunk-QUNH5UZH.js.map → chunk-BYLC4DKI.js.map} +0 -0
  232. /package/dist/{chunk-UOVDO6TC.js.map → chunk-CHELXDTO.js.map} +0 -0
  233. /package/dist/{chunk-TQQN64J2.js.map → chunk-DBSMLRTO.js.map} +0 -0
  234. /package/dist/{chunk-EZZUNKMJ.js.map → chunk-DYK27X7V.js.map} +0 -0
  235. /package/dist/{chunk-K2N6WIZM.js.map → chunk-E7RGJQWP.js.map} +0 -0
  236. /package/dist/{chunk-M4WI23X3.js.map → chunk-EEKDRAWX.js.map} +0 -0
  237. /package/dist/{chunk-GFJ5ABKS.js.map → chunk-G5FP7VSQ.js.map} +0 -0
  238. /package/dist/{chunk-BE6NEQLF.js.map → chunk-HAZVVOYT.js.map} +0 -0
  239. /package/dist/{chunk-OT5K26NG.js.map → chunk-HM6UJPPO.js.map} +0 -0
  240. /package/dist/{chunk-PI4JHLDD.js.map → chunk-IP5SANO2.js.map} +0 -0
  241. /package/dist/{chunk-WHEF76BQ.js.map → chunk-JRZV3767.js.map} +0 -0
  242. /package/dist/{chunk-OS5RKJOH.js.map → chunk-JZ7P26GF.js.map} +0 -0
  243. /package/dist/{chunk-Y62QPRKV.js.map → chunk-K5LLP4CY.js.map} +0 -0
  244. /package/dist/{chunk-C3Z5YJSM.js.map → chunk-LOPZ2DWR.js.map} +0 -0
  245. /package/dist/{chunk-BJPL5WAL.js.map → chunk-MXDG6SRH.js.map} +0 -0
  246. /package/dist/{chunk-UYYSOMS2.js.map → chunk-NBP3YHHS.js.map} +0 -0
  247. /package/dist/{chunk-USHVHI6J.js.map → chunk-NNL4LJAD.js.map} +0 -0
  248. /package/dist/{chunk-GPX5E36D.js.map → chunk-OSMBC3JU.js.map} +0 -0
  249. /package/dist/{chunk-OUSOMUFV.js.map → chunk-PE6XR4GG.js.map} +0 -0
  250. /package/dist/{chunk-CMPXLMC3.js.map → chunk-PI23H7FV.js.map} +0 -0
  251. /package/dist/{chunk-WGDE2TJP.js.map → chunk-QOGXUNWL.js.map} +0 -0
  252. /package/dist/{chunk-ELL5VYXC.js.map → chunk-RNWWAS5V.js.map} +0 -0
  253. /package/dist/{chunk-JMMSVRF4.js.map → chunk-TQPSOTC7.js.map} +0 -0
  254. /package/dist/{chunk-AX4TRSRE.js.map → chunk-U5WVRMCA.js.map} +0 -0
  255. /package/dist/{chunk-7ADHJ6SU.js.map → chunk-VE54E6RP.js.map} +0 -0
  256. /package/dist/{chunk-OVYBENIJ.js.map → chunk-W3M34XT4.js.map} +0 -0
  257. /package/dist/{chunk-NHJYUIII.js.map → chunk-WPLRJ4XM.js.map} +0 -0
  258. /package/dist/{chunk-UEIF7RWQ.js.map → chunk-XEADGIAA.js.map} +0 -0
  259. /package/dist/{contradiction-scan-UERKJESC.js.map → contradiction-scan-3FJYWS3G.js.map} +0 -0
  260. /package/dist/{first-start-migration-GQ3UQNIL.js.map → first-start-migration-4I3VDSYS.js.map} +0 -0
  261. /package/dist/{tier-stats-CSKL7BDG.js.map → tier-stats-5XF4UBRQ.js.map} +0 -0
@@ -7,10 +7,10 @@ import {
7
7
  } from "./chunk-C7LDPZJJ.js";
8
8
  import {
9
9
  CompressionGuidelineCoordinator
10
- } from "./chunk-WIMKOTNY.js";
10
+ } from "./chunk-5QANTTY2.js";
11
11
  import {
12
12
  MaintenanceScheduler
13
- } from "./chunk-BJPL5WAL.js";
13
+ } from "./chunk-MXDG6SRH.js";
14
14
  import {
15
15
  runPeerProfileReasoner
16
16
  } from "./chunk-I74SUMNI.js";
@@ -29,10 +29,10 @@ import {
29
29
  import {
30
30
  CompoundingEngine,
31
31
  defaultTierMigrationCycleBudget
32
- } from "./chunk-UOVDO6TC.js";
32
+ } from "./chunk-CHELXDTO.js";
33
33
  import {
34
34
  SharedContextManager
35
- } from "./chunk-WHEF76BQ.js";
35
+ } from "./chunk-JRZV3767.js";
36
36
  import {
37
37
  applyTrustScoreStage,
38
38
  buildTrustSignalsForRerank,
@@ -63,7 +63,7 @@ import {
63
63
  } from "./chunk-UHGBNIOS.js";
64
64
  import {
65
65
  HourlySummarizer
66
- } from "./chunk-USHVHI6J.js";
66
+ } from "./chunk-NNL4LJAD.js";
67
67
  import {
68
68
  buildTargetedFactRecallSection,
69
69
  shouldRecallTargetedFactEvidence
@@ -160,7 +160,7 @@ import {
160
160
  } from "./chunk-LTHVM4XN.js";
161
161
  import {
162
162
  ExtractionEngine
163
- } from "./chunk-WGDE2TJP.js";
163
+ } from "./chunk-QOGXUNWL.js";
164
164
  import {
165
165
  parseMemoryActionEligibilityContext
166
166
  } from "./chunk-5GSUBCZM.js";
@@ -169,7 +169,7 @@ import {
169
169
  } from "./chunk-PWFWCGOO.js";
170
170
  import {
171
171
  LocalLlmClient
172
- } from "./chunk-TQQN64J2.js";
172
+ } from "./chunk-DBSMLRTO.js";
173
173
  import {
174
174
  buildFocusedListRecallSection,
175
175
  shouldRecallFocusedListEvidence
@@ -187,18 +187,18 @@ import {
187
187
  } from "./chunk-4463LUIE.js";
188
188
  import {
189
189
  formatDaySummaryMemories
190
- } from "./chunk-C3Z5YJSM.js";
190
+ } from "./chunk-LOPZ2DWR.js";
191
191
  import {
192
192
  tryDirectAnswer
193
193
  } from "./chunk-Q6IP2ARR.js";
194
194
  import {
195
195
  EmbeddingFallback
196
- } from "./chunk-GPX5E36D.js";
196
+ } from "./chunk-OSMBC3JU.js";
197
197
  import {
198
198
  buildEntityRecallSection,
199
199
  entityRecentTranscriptLookbackHours,
200
200
  readRecentEntityTranscriptEntries
201
- } from "./chunk-K2N6WIZM.js";
201
+ } from "./chunk-E7RGJQWP.js";
202
202
  import {
203
203
  RoutingRulesStore
204
204
  } from "./chunk-WIWPSQYU.js";
@@ -228,14 +228,14 @@ import {
228
228
  import {
229
229
  runNamespaceMaintenanceFanout,
230
230
  summarizeNamespaceMaintenanceHealth
231
- } from "./chunk-O4IWVWSW.js";
231
+ } from "./chunk-AVBT5WEW.js";
232
232
  import {
233
233
  NamespaceCatalog,
234
234
  planNamespaceMaintenance
235
- } from "./chunk-X5PMDVY4.js";
235
+ } from "./chunk-3EA5LIFJ.js";
236
236
  import {
237
237
  NamespaceStorageRouter
238
- } from "./chunk-AX4TRSRE.js";
238
+ } from "./chunk-U5WVRMCA.js";
239
239
  import {
240
240
  searchHarmonicRetrieval
241
241
  } from "./chunk-AV5ZEH4M.js";
@@ -270,7 +270,7 @@ import {
270
270
  materializeAfterSemanticConsolidation,
271
271
  parseConsolidationResponse,
272
272
  parseOperatorAwareConsolidationResponse
273
- } from "./chunk-PI4JHLDD.js";
273
+ } from "./chunk-IP5SANO2.js";
274
274
  import {
275
275
  buildRecallQueryPolicy
276
276
  } from "./chunk-LBJBNWS2.js";
@@ -292,7 +292,7 @@ import {
292
292
  } from "./chunk-UQ7RN5HK.js";
293
293
  import {
294
294
  SmartBuffer
295
- } from "./chunk-OS5RKJOH.js";
295
+ } from "./chunk-JZ7P26GF.js";
296
296
  import {
297
297
  isDisagreementPrompt
298
298
  } from "./chunk-H3FZVNRN.js";
@@ -311,7 +311,7 @@ import {
311
311
  clusterByKey,
312
312
  createCorrectionService,
313
313
  detectPassiveCorrections
314
- } from "./chunk-Y6PNYJVO.js";
314
+ } from "./chunk-A2KKLCOS.js";
315
315
  import {
316
316
  listTrustZoneRecords,
317
317
  searchTrustZoneRecords
@@ -333,14 +333,14 @@ import {
333
333
  resolveNamespaceFromStorageDir,
334
334
  resolveScopePlan,
335
335
  resolveScopeProfilePlan
336
- } from "./chunk-OVYBENIJ.js";
336
+ } from "./chunk-W3M34XT4.js";
337
337
  import {
338
338
  NamespaceSearchRouter
339
- } from "./chunk-BE6NEQLF.js";
339
+ } from "./chunk-HAZVVOYT.js";
340
340
  import {
341
341
  createConversationIndexRuntime,
342
342
  createSearchBackend
343
- } from "./chunk-ELL5VYXC.js";
343
+ } from "./chunk-RNWWAS5V.js";
344
344
  import {
345
345
  NoopSearchBackend
346
346
  } from "./chunk-CYEPCZN5.js";
@@ -363,7 +363,7 @@ import {
363
363
  } from "./chunk-QDW3E4RD.js";
364
364
  import {
365
365
  shouldSkipImplicitExtraction
366
- } from "./chunk-Y62QPRKV.js";
366
+ } from "./chunk-K5LLP4CY.js";
367
367
  import {
368
368
  searchCausalTrajectories
369
369
  } from "./chunk-SQNED75R.js";
@@ -465,7 +465,7 @@ import {
465
465
  defaultNamespaceForPrincipal,
466
466
  recallNamespacesForPrincipal,
467
467
  resolvePrincipal
468
- } from "./chunk-OUSOMUFV.js";
468
+ } from "./chunk-PE6XR4GG.js";
469
469
  import {
470
470
  isSafeRouteNamespace,
471
471
  selectRouteRule
@@ -491,7 +491,7 @@ import {
491
491
  resolveRecallEnhancementCapabilities,
492
492
  resolveSecurityCapabilities,
493
493
  resolveUtilityLearningCapabilities
494
- } from "./chunk-G7Q4D2G3.js";
494
+ } from "./chunk-VSF7AAGE.js";
495
495
  import {
496
496
  sanitizeMemoryContent
497
497
  } from "./chunk-5GKPFL3S.js";
@@ -2391,6 +2391,210 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
2391
2391
  }
2392
2392
  };
2393
2393
 
2394
+ // src/orchestration/recall-section-coordinator.ts
2395
+ var RecallSectionCoordinator = class {
2396
+ getConfig;
2397
+ resolveSectionEnabled;
2398
+ constructor(options) {
2399
+ this.getConfig = options.getConfig;
2400
+ this.resolveSectionEnabled = options.resolveSectionEnabled ?? ((id, def) => this.isRecallSectionEnabled(id, def));
2401
+ }
2402
+ getRecallSectionEntry(sectionId) {
2403
+ const pipeline = Array.isArray(this.getConfig().recallPipeline) ? this.getConfig().recallPipeline : [];
2404
+ return pipeline.find((entry) => entry.id === sectionId);
2405
+ }
2406
+ isRecallSectionEnabled(sectionId, defaultEnabled = true) {
2407
+ const entry = this.getRecallSectionEntry(sectionId);
2408
+ if (!entry) return defaultEnabled;
2409
+ return entry.enabled !== false;
2410
+ }
2411
+ isSpecializedRecallSectionEnabled(sectionId, topLevelEnabled) {
2412
+ const entry = this.getRecallSectionEntry(sectionId);
2413
+ if (!entry) return topLevelEnabled;
2414
+ return entry.enabled === true || topLevelEnabled && entry.enabled !== false;
2415
+ }
2416
+ getRecallSectionMaxChars(sectionId) {
2417
+ const entry = this.getRecallSectionEntry(sectionId);
2418
+ if (!entry) return void 0;
2419
+ if (entry.maxChars === null) return null;
2420
+ if (typeof entry.maxChars !== "number") return void 0;
2421
+ return Math.max(0, Math.floor(entry.maxChars));
2422
+ }
2423
+ getRecallSectionNumber(sectionId, key) {
2424
+ const entry = this.getRecallSectionEntry(sectionId);
2425
+ if (!entry) return void 0;
2426
+ const value = entry[key];
2427
+ if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
2428
+ return Math.max(0, Math.floor(value));
2429
+ }
2430
+ appendRecallSection(sectionBuckets, sectionId, content) {
2431
+ if (!this.resolveSectionEnabled(sectionId, true)) return false;
2432
+ const trimmed = content.trim();
2433
+ if (trimmed.length === 0) return false;
2434
+ const maxChars = this.getRecallSectionMaxChars(sectionId);
2435
+ let finalContent = trimmed;
2436
+ if (maxChars === 0) return false;
2437
+ if (typeof maxChars === "number" && finalContent.length > maxChars) {
2438
+ finalContent = `${finalContent.slice(0, maxChars)}
2439
+
2440
+ ...(trimmed)
2441
+ `;
2442
+ }
2443
+ const existing = sectionBuckets.get(sectionId) ?? [];
2444
+ existing.push(finalContent);
2445
+ sectionBuckets.set(sectionId, existing);
2446
+ return true;
2447
+ }
2448
+ truncateRecallSectionToBudget(content, maxChars) {
2449
+ if (maxChars <= 0) return "";
2450
+ if (content.length <= maxChars) return content;
2451
+ const suffix = "\n\n...(memory context trimmed)";
2452
+ if (maxChars <= suffix.length) {
2453
+ return content.slice(0, maxChars);
2454
+ }
2455
+ return `${content.slice(0, maxChars - suffix.length)}${suffix}`;
2456
+ }
2457
+ protectedRecallSectionIds(sectionBuckets) {
2458
+ const protectedIds = /* @__PURE__ */ new Set();
2459
+ if ((sectionBuckets.get("memories")?.length ?? 0) > 0) {
2460
+ protectedIds.add("memories");
2461
+ }
2462
+ return protectedIds;
2463
+ }
2464
+ protectedRecallReservationChars(content) {
2465
+ const headingBoundary = content.indexOf("\n\n");
2466
+ const headingChars = headingBoundary >= 0 ? headingBoundary + 2 : Math.min(content.length, 24);
2467
+ return Math.min(content.length, Math.max(headingChars, 24));
2468
+ }
2469
+ estimateReservedRecallBudget(entries, startIndex, protectedIds, alreadyIncludedCount) {
2470
+ const separatorLength = "\n\n---\n\n".length;
2471
+ let reserved = 0;
2472
+ let simulatedIncluded = alreadyIncludedCount;
2473
+ for (let i = startIndex; i < entries.length; i += 1) {
2474
+ const entry = entries[i];
2475
+ if (!entry || !protectedIds.has(entry.id)) continue;
2476
+ if (simulatedIncluded > 0) {
2477
+ reserved += separatorLength;
2478
+ }
2479
+ reserved += this.protectedRecallReservationChars(entry.content);
2480
+ simulatedIncluded += 1;
2481
+ }
2482
+ return reserved;
2483
+ }
2484
+ getRecallBudgetChars(override) {
2485
+ if (typeof override === "number" && Number.isFinite(override) && override >= 0) {
2486
+ return Math.floor(override);
2487
+ }
2488
+ const configuredBudget = this.getConfig().recallBudgetChars;
2489
+ if (typeof configuredBudget === "number" && Number.isFinite(configuredBudget) && configuredBudget >= 0) {
2490
+ return Math.floor(configuredBudget);
2491
+ }
2492
+ const tokenBudget = this.getConfig().maxMemoryTokens;
2493
+ if (typeof tokenBudget === "number" && Number.isFinite(tokenBudget) && tokenBudget >= 0) {
2494
+ return Math.floor(tokenBudget * 4);
2495
+ }
2496
+ return 0;
2497
+ }
2498
+ assembleRecallSections(sectionBuckets, budgetOverride) {
2499
+ const orderedEntries = [];
2500
+ const pipeline = Array.isArray(this.getConfig().recallPipeline) ? this.getConfig().recallPipeline : [];
2501
+ const orderedIds = pipeline.filter((entry) => entry.enabled !== false).map((entry) => entry.id);
2502
+ const seen = /* @__PURE__ */ new Set();
2503
+ for (const id of orderedIds) {
2504
+ const chunks = sectionBuckets.get(id);
2505
+ if (!chunks || chunks.length === 0) continue;
2506
+ orderedEntries.push({ id, content: chunks.join("\n\n") });
2507
+ seen.add(id);
2508
+ }
2509
+ for (const [id, chunks] of sectionBuckets.entries()) {
2510
+ if (seen.has(id)) continue;
2511
+ if (chunks.length === 0) continue;
2512
+ orderedEntries.push({ id, content: chunks.join("\n\n") });
2513
+ }
2514
+ const budget = this.getRecallBudgetChars(budgetOverride);
2515
+ if (budget === 0) {
2516
+ return {
2517
+ sections: [],
2518
+ includedIds: [],
2519
+ omittedIds: orderedEntries.map((entry) => entry.id),
2520
+ truncated: orderedEntries.length > 0,
2521
+ finalChars: 0
2522
+ };
2523
+ }
2524
+ const separator = "\n\n---\n\n";
2525
+ const protectedIds = this.protectedRecallSectionIds(sectionBuckets);
2526
+ const sections = [];
2527
+ const includedIds = [];
2528
+ const omittedIds = [];
2529
+ let usedChars = 0;
2530
+ let truncated = false;
2531
+ for (let index = 0; index < orderedEntries.length; index += 1) {
2532
+ const entry = orderedEntries[index];
2533
+ const separatorChars = sections.length > 0 ? separator.length : 0;
2534
+ const reserve = protectedIds.has(entry.id) ? 0 : this.estimateReservedRecallBudget(
2535
+ orderedEntries,
2536
+ index + 1,
2537
+ protectedIds,
2538
+ sections.length + 1
2539
+ );
2540
+ const availableForEntry = budget - usedChars - separatorChars - reserve;
2541
+ if (availableForEntry <= 0) {
2542
+ omittedIds.push(entry.id);
2543
+ truncated = true;
2544
+ continue;
2545
+ }
2546
+ const finalContent = this.truncateRecallSectionToBudget(
2547
+ entry.content,
2548
+ availableForEntry
2549
+ );
2550
+ if (!finalContent) {
2551
+ omittedIds.push(entry.id);
2552
+ truncated = true;
2553
+ continue;
2554
+ }
2555
+ if (finalContent.length < entry.content.length) {
2556
+ truncated = true;
2557
+ }
2558
+ sections.push(finalContent);
2559
+ includedIds.push(entry.id);
2560
+ usedChars += separatorChars + finalContent.length;
2561
+ }
2562
+ return {
2563
+ sections,
2564
+ includedIds,
2565
+ omittedIds,
2566
+ truncated,
2567
+ finalChars: usedChars
2568
+ };
2569
+ }
2570
+ buildLastRecallBudgetSummary(options) {
2571
+ return {
2572
+ requestedTopK: options.requestedTopK,
2573
+ appliedTopK: options.recallResultLimit,
2574
+ recallBudgetChars: this.getRecallBudgetChars(),
2575
+ maxMemoryTokens: this.getConfig().maxMemoryTokens,
2576
+ qmdFetchLimit: options.qmdFetchLimit,
2577
+ qmdHybridFetchLimit: options.qmdHybridFetchLimit,
2578
+ finalContextChars: options.finalContextChars,
2579
+ truncated: options.truncated,
2580
+ includedSections: [...options.includedSections ?? []],
2581
+ omittedSections: [...options.omittedSections ?? []]
2582
+ };
2583
+ }
2584
+ collectLastRecallSources(sectionBuckets, recallSource) {
2585
+ const used = /* @__PURE__ */ new Set();
2586
+ if (recallSource !== "none") {
2587
+ used.add(recallSource);
2588
+ }
2589
+ for (const [sectionId, chunks] of sectionBuckets.entries()) {
2590
+ if (chunks.length > 0) {
2591
+ used.add(sectionId);
2592
+ }
2593
+ }
2594
+ return [...used];
2595
+ }
2596
+ };
2597
+
2394
2598
  // src/orchestration/qmd-result-resolver.ts
2395
2599
  import path4 from "path";
2396
2600
  function qmdCollectionPathParts(resultPath) {
@@ -2642,6 +2846,176 @@ var QmdResultResolver = class {
2642
2846
  }
2643
2847
  };
2644
2848
 
2849
+ // src/orchestration/contradiction-linking-coordinator.ts
2850
+ var ContradictionLinkingCoordinator = class {
2851
+ getConfig;
2852
+ isSearchAvailable;
2853
+ searchAcrossNamespaces;
2854
+ extractMemoryIdsFromResults;
2855
+ namespaceFromPath;
2856
+ storageForNamespace;
2857
+ getExtraction;
2858
+ constructor(options) {
2859
+ this.getConfig = options.getConfig;
2860
+ this.isSearchAvailable = options.isSearchAvailable;
2861
+ this.searchAcrossNamespaces = options.searchAcrossNamespaces;
2862
+ this.extractMemoryIdsFromResults = options.extractMemoryIdsFromResults;
2863
+ this.namespaceFromPath = options.namespaceFromPath;
2864
+ this.storageForNamespace = options.storageForNamespace;
2865
+ this.getExtraction = options.getExtraction;
2866
+ }
2867
+ /**
2868
+ * Check if a new memory contradicts an existing one.
2869
+ * Uses QMD to find similar memories, then LLM to verify contradiction.
2870
+ */
2871
+ async checkForContradiction(content, category, namespaceScope) {
2872
+ if (!this.isSearchAvailable()) return null;
2873
+ const config = this.getConfig();
2874
+ const results = await this.searchAcrossNamespaces({
2875
+ query: content,
2876
+ namespaces: [namespaceScope],
2877
+ maxResults: 5,
2878
+ mode: "search"
2879
+ });
2880
+ for (const result of results) {
2881
+ if (result.score < config.contradictionSimilarityThreshold) {
2882
+ continue;
2883
+ }
2884
+ const memoryId = this.extractMemoryIdsFromResults([result])[0];
2885
+ if (!memoryId) continue;
2886
+ const resultNamespace = this.namespaceFromPath(result.path);
2887
+ if (resultNamespace !== namespaceScope) continue;
2888
+ const resultStorage = await this.storageForNamespace(resultNamespace);
2889
+ const existingMemory = await resultStorage.getMemoryById(memoryId);
2890
+ if (!existingMemory) continue;
2891
+ if (existingMemory.frontmatter.status === "superseded" || existingMemory.frontmatter.status === "forgotten") {
2892
+ continue;
2893
+ }
2894
+ const extraction = this.getExtraction();
2895
+ const verification = await extraction.verifyContradiction(
2896
+ { content, category },
2897
+ {
2898
+ id: existingMemory.frontmatter.id,
2899
+ content: existingMemory.content,
2900
+ category: existingMemory.frontmatter.category,
2901
+ created: existingMemory.frontmatter.created
2902
+ }
2903
+ );
2904
+ if (!verification) continue;
2905
+ if (verification.isContradiction && verification.confidence >= config.contradictionMinConfidence) {
2906
+ if (verification.whichIsNewer === "first") {
2907
+ log.info(
2908
+ `detected contradiction (confidence: ${verification.confidence}): ${existingMemory.frontmatter.id} vs new memory \u2014 existing is newer, incoming fact is stale`
2909
+ );
2910
+ continue;
2911
+ }
2912
+ log.info(
2913
+ `detected contradiction (confidence: ${verification.confidence}): ${existingMemory.frontmatter.id} vs new memory${config.contradictionAutoResolve ? " (auto-resolved)" : " (queued for manual review)"}`
2914
+ );
2915
+ return {
2916
+ supersededId: existingMemory.frontmatter.id,
2917
+ confidence: verification.confidence,
2918
+ reason: verification.reasoning,
2919
+ supersededPath: existingMemory.path,
2920
+ supersededCreated: existingMemory.frontmatter.created,
2921
+ supersededTags: existingMemory.frontmatter.tags ?? []
2922
+ };
2923
+ }
2924
+ }
2925
+ return null;
2926
+ }
2927
+ /**
2928
+ * #1645: Complete the deferred contradiction auto-resolve after writeMemory
2929
+ * returns and the new write's tombstone status is known. Retires the old
2930
+ * memory + deindexes it ONLY when the new write is genuinely active (not
2931
+ * tombstone-blocked / pending_review). A blocked write must not retire the
2932
+ * only active copy — deferring here closes the "contradictionAutoResolve
2933
+ * supersedes before tombstone status is known" defect class.
2934
+ */
2935
+ async applyDeferredContradictionResolve(contradiction, storage, newMemoryId, postWriteGuard) {
2936
+ const config = this.getConfig();
2937
+ if (postWriteGuard && contradiction && config.contradictionAutoResolve) {
2938
+ try {
2939
+ const blockedRow = await storage.getMemoryById(newMemoryId);
2940
+ if (blockedRow?.frontmatter?.supersedes) {
2941
+ await storage.writeMemoryFrontmatter(blockedRow, { supersedes: void 0 });
2942
+ }
2943
+ } catch (err) {
2944
+ log.warn(
2945
+ `contradiction auto-resolve supersedes clear failed for blocked ${newMemoryId}: ${err}`
2946
+ );
2947
+ }
2948
+ }
2949
+ if (!contradiction || !config.contradictionAutoResolve || postWriteGuard) {
2950
+ return;
2951
+ }
2952
+ try {
2953
+ await storage.supersedeMemory(
2954
+ contradiction.supersededId,
2955
+ newMemoryId,
2956
+ contradiction.reason
2957
+ );
2958
+ if (resolveIndexingCapabilities(config).queryAwareIndexing && contradiction.supersededPath) {
2959
+ deindexMemory(
2960
+ config.memoryDir,
2961
+ contradiction.supersededPath,
2962
+ contradiction.supersededCreated,
2963
+ contradiction.supersededTags
2964
+ );
2965
+ }
2966
+ } catch (err) {
2967
+ log.warn(
2968
+ `contradiction auto-resolve supersede failed for ${contradiction.supersededId}: ${err}`
2969
+ );
2970
+ }
2971
+ }
2972
+ // ---------------------------------------------------------------------------
2973
+ // Memory Linking (Phase 3A)
2974
+ // ---------------------------------------------------------------------------
2975
+ /**
2976
+ * Suggest links for a new memory based on similar existing memories.
2977
+ */
2978
+ async suggestLinksForMemory(content, category, namespaceScope) {
2979
+ if (!this.isSearchAvailable()) return [];
2980
+ const results = await this.searchAcrossNamespaces({
2981
+ query: content,
2982
+ namespaces: [namespaceScope],
2983
+ maxResults: 5,
2984
+ mode: "search"
2985
+ });
2986
+ if (results.length === 0) return [];
2987
+ const candidates = [];
2988
+ for (const result of results) {
2989
+ const memoryId = this.extractMemoryIdsFromResults([result])[0];
2990
+ if (!memoryId) continue;
2991
+ const resultNamespace = this.namespaceFromPath(result.path);
2992
+ if (resultNamespace !== namespaceScope) continue;
2993
+ const resultStorage = await this.storageForNamespace(resultNamespace);
2994
+ const memory = await resultStorage.getMemoryById(memoryId);
2995
+ if (memory && memory.frontmatter.status !== "superseded" && memory.frontmatter.status !== "forgotten") {
2996
+ candidates.push({
2997
+ id: memory.frontmatter.id,
2998
+ content: memory.content,
2999
+ category: memory.frontmatter.category
3000
+ });
3001
+ }
3002
+ }
3003
+ if (candidates.length === 0) return [];
3004
+ const extraction = this.getExtraction();
3005
+ const suggestions = await extraction.suggestLinks(
3006
+ { content, category },
3007
+ candidates
3008
+ );
3009
+ if (!suggestions || suggestions.links.length === 0) return [];
3010
+ return suggestions.links.map((link) => ({
3011
+ targetId: link.targetId,
3012
+ linkType: link.linkType,
3013
+ strength: link.strength,
3014
+ reason: link.reason || void 0
3015
+ }));
3016
+ }
3017
+ };
3018
+
2645
3019
  // src/maintenance/pattern-reinforcement.ts
2646
3020
  function patternReinforcementKey(content) {
2647
3021
  return content.trim().toLowerCase().replace(/\s+/g, " ").slice(0, 200);
@@ -4767,7 +5141,9 @@ var Orchestrator = class _Orchestrator {
4767
5141
  */
4768
5142
  conversationIndexCoordinator;
4769
5143
  recallRerankCoordinator;
5144
+ recallSectionCoordinator;
4770
5145
  qmdResultResolver;
5146
+ contradictionLinkingCoordinator;
4771
5147
  heartbeatObserverChains = /* @__PURE__ */ new Map();
4772
5148
  recentExtractionFingerprints = /* @__PURE__ */ new Map();
4773
5149
  consolidationObservers = /* @__PURE__ */ new Set();
@@ -5500,6 +5876,19 @@ var Orchestrator = class _Orchestrator {
5500
5876
  getStorage: (namespace) => this.getStorage(namespace),
5501
5877
  readQmdResultMemory: (resultPath, fallbackStorage, recallNamespaces) => this.readQmdResultMemory(resultPath, fallbackStorage, recallNamespaces)
5502
5878
  });
5879
+ this.recallSectionCoordinator = new RecallSectionCoordinator({
5880
+ getConfig: () => this.config,
5881
+ resolveSectionEnabled: (id, def) => this.isRecallSectionEnabled(id, def)
5882
+ });
5883
+ this.contradictionLinkingCoordinator = new ContradictionLinkingCoordinator({
5884
+ getConfig: () => this.config,
5885
+ isSearchAvailable: () => this.isSearchAvailableForNamespaceRouting(),
5886
+ searchAcrossNamespaces: (options) => this.searchAcrossNamespaces(options),
5887
+ extractMemoryIdsFromResults: (results) => this.extractMemoryIdsFromResults(results),
5888
+ namespaceFromPath: (p) => this.namespaceFromPath(p),
5889
+ storageForNamespace: (namespace) => this.storageRouter.storageFor(namespace),
5890
+ getExtraction: () => this.extraction
5891
+ });
5503
5892
  this.modelRegistry = new ModelRegistry(config.memoryDir);
5504
5893
  this.relevance = new RelevanceStore(config.memoryDir);
5505
5894
  this.negatives = new NegativeExampleStore(config.memoryDir);
@@ -6115,7 +6504,7 @@ var Orchestrator = class _Orchestrator {
6115
6504
  if (signal.aborted) return;
6116
6505
  if (lifecycleCaps.lifecyclePolicy && resolveQmdCapabilities(this.config).qmdTierMigration) {
6117
6506
  try {
6118
- const { runFirstStartMigration } = await import("./first-start-migration-GQ3UQNIL.js");
6507
+ const { runFirstStartMigration } = await import("./first-start-migration-4I3VDSYS.js");
6119
6508
  const result = await runFirstStartMigration({
6120
6509
  storage: this.storage,
6121
6510
  config: this.config,
@@ -7968,173 +8357,51 @@ ${doc.content}` : doc.content,
7968
8357
  sourceLabels: sourceLabelResolver(result.path)
7969
8358
  }));
7970
8359
  }
8360
+ // Issue #1526 (seam 13): recall section budgeting/assembly moved to
8361
+ // RecallSectionCoordinator. Thin delegation keeps the orchestrator's
8362
+ // recallInternal call sites stable.
7971
8363
  getRecallSectionEntry(sectionId) {
7972
- const pipeline = Array.isArray(this.config.recallPipeline) ? this.config.recallPipeline : [];
7973
- return pipeline.find((entry) => entry.id === sectionId);
8364
+ return this.recallSectionCoordinator.getRecallSectionEntry(sectionId);
7974
8365
  }
7975
8366
  isRecallSectionEnabled(sectionId, defaultEnabled = true) {
7976
- const entry = this.getRecallSectionEntry(sectionId);
7977
- if (!entry) return defaultEnabled;
7978
- return entry.enabled !== false;
8367
+ return this.recallSectionCoordinator.isRecallSectionEnabled(
8368
+ sectionId,
8369
+ defaultEnabled
8370
+ );
7979
8371
  }
7980
8372
  isSpecializedRecallSectionEnabled(sectionId, topLevelEnabled) {
7981
- const entry = this.getRecallSectionEntry(sectionId);
7982
- if (!entry) return topLevelEnabled;
7983
- return entry.enabled === true || topLevelEnabled && entry.enabled !== false;
7984
- }
7985
- getRecallSectionMaxChars(sectionId) {
7986
- const entry = this.getRecallSectionEntry(sectionId);
7987
- if (!entry) return void 0;
7988
- if (entry.maxChars === null) return null;
7989
- if (typeof entry.maxChars !== "number") return void 0;
7990
- return Math.max(0, Math.floor(entry.maxChars));
7991
- }
7992
- getRecallSectionNumber(sectionId, key) {
7993
- const entry = this.getRecallSectionEntry(sectionId);
7994
- if (!entry) return void 0;
7995
- const value = entry[key];
7996
- if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
7997
- return Math.max(0, Math.floor(value));
7998
- }
7999
- appendRecallSection(sectionBuckets, sectionId, content) {
8000
- if (!this.isRecallSectionEnabled(sectionId)) return false;
8001
- const trimmed = content.trim();
8002
- if (trimmed.length === 0) return false;
8003
- const maxChars = this.getRecallSectionMaxChars(sectionId);
8004
- let finalContent = trimmed;
8005
- if (maxChars === 0) return false;
8006
- if (typeof maxChars === "number" && finalContent.length > maxChars) {
8007
- finalContent = `${finalContent.slice(0, maxChars)}
8008
-
8009
- ...(trimmed)
8010
- `;
8011
- }
8012
- const existing = sectionBuckets.get(sectionId) ?? [];
8013
- existing.push(finalContent);
8014
- sectionBuckets.set(sectionId, existing);
8015
- return true;
8373
+ return this.recallSectionCoordinator.isSpecializedRecallSectionEnabled(
8374
+ sectionId,
8375
+ topLevelEnabled
8376
+ );
8016
8377
  }
8017
- truncateRecallSectionToBudget(content, maxChars) {
8018
- if (maxChars <= 0) return "";
8019
- if (content.length <= maxChars) return content;
8020
- const suffix = "\n\n...(memory context trimmed)";
8021
- if (maxChars <= suffix.length) {
8022
- return content.slice(0, maxChars);
8023
- }
8024
- return `${content.slice(0, maxChars - suffix.length)}${suffix}`;
8378
+ getRecallSectionMaxChars(sectionId) {
8379
+ return this.recallSectionCoordinator.getRecallSectionMaxChars(sectionId);
8025
8380
  }
8026
- protectedRecallSectionIds(sectionBuckets) {
8027
- const protectedIds = /* @__PURE__ */ new Set();
8028
- if ((sectionBuckets.get("memories")?.length ?? 0) > 0) {
8029
- protectedIds.add("memories");
8030
- }
8031
- return protectedIds;
8381
+ getRecallSectionNumber(sectionId, key) {
8382
+ return this.recallSectionCoordinator.getRecallSectionNumber(sectionId, key);
8032
8383
  }
8033
- protectedRecallReservationChars(content) {
8034
- const headingBoundary = content.indexOf("\n\n");
8035
- const headingChars = headingBoundary >= 0 ? headingBoundary + 2 : Math.min(content.length, 24);
8036
- return Math.min(content.length, Math.max(headingChars, 24));
8384
+ appendRecallSection(sectionBuckets, sectionId, content) {
8385
+ return this.recallSectionCoordinator.appendRecallSection(
8386
+ sectionBuckets,
8387
+ sectionId,
8388
+ content
8389
+ );
8037
8390
  }
8038
- estimateReservedRecallBudget(entries, startIndex, protectedIds, alreadyIncludedCount) {
8039
- const separatorLength = "\n\n---\n\n".length;
8040
- let reserved = 0;
8041
- let simulatedIncluded = alreadyIncludedCount;
8042
- for (let i = startIndex; i < entries.length; i += 1) {
8043
- const entry = entries[i];
8044
- if (!entry || !protectedIds.has(entry.id)) continue;
8045
- if (simulatedIncluded > 0) {
8046
- reserved += separatorLength;
8047
- }
8048
- reserved += this.protectedRecallReservationChars(entry.content);
8049
- simulatedIncluded += 1;
8050
- }
8051
- return reserved;
8391
+ truncateRecallSectionToBudget(content, maxChars) {
8392
+ return this.recallSectionCoordinator.truncateRecallSectionToBudget(
8393
+ content,
8394
+ maxChars
8395
+ );
8052
8396
  }
8053
8397
  getRecallBudgetChars(override) {
8054
- if (typeof override === "number" && Number.isFinite(override) && override >= 0) {
8055
- return Math.floor(override);
8056
- }
8057
- const configuredBudget = this.config.recallBudgetChars;
8058
- if (typeof configuredBudget === "number" && Number.isFinite(configuredBudget) && configuredBudget >= 0) {
8059
- return Math.floor(configuredBudget);
8060
- }
8061
- const tokenBudget = this.config.maxMemoryTokens;
8062
- if (typeof tokenBudget === "number" && Number.isFinite(tokenBudget) && tokenBudget >= 0) {
8063
- return Math.floor(tokenBudget * 4);
8064
- }
8065
- return 0;
8398
+ return this.recallSectionCoordinator.getRecallBudgetChars(override);
8066
8399
  }
8067
8400
  assembleRecallSections(sectionBuckets, budgetOverride) {
8068
- const orderedEntries = [];
8069
- const pipeline = Array.isArray(this.config.recallPipeline) ? this.config.recallPipeline : [];
8070
- const orderedIds = pipeline.filter((entry) => entry.enabled !== false).map((entry) => entry.id);
8071
- const seen = /* @__PURE__ */ new Set();
8072
- for (const id of orderedIds) {
8073
- const chunks = sectionBuckets.get(id);
8074
- if (!chunks || chunks.length === 0) continue;
8075
- orderedEntries.push({ id, content: chunks.join("\n\n") });
8076
- seen.add(id);
8077
- }
8078
- for (const [id, chunks] of sectionBuckets.entries()) {
8079
- if (seen.has(id)) continue;
8080
- if (chunks.length === 0) continue;
8081
- orderedEntries.push({ id, content: chunks.join("\n\n") });
8082
- }
8083
- const budget = this.getRecallBudgetChars(budgetOverride);
8084
- if (budget === 0) {
8085
- return {
8086
- sections: [],
8087
- includedIds: [],
8088
- omittedIds: orderedEntries.map((entry) => entry.id),
8089
- truncated: orderedEntries.length > 0,
8090
- finalChars: 0
8091
- };
8092
- }
8093
- const separator = "\n\n---\n\n";
8094
- const protectedIds = this.protectedRecallSectionIds(sectionBuckets);
8095
- const sections = [];
8096
- const includedIds = [];
8097
- const omittedIds = [];
8098
- let usedChars = 0;
8099
- let truncated = false;
8100
- for (let index = 0; index < orderedEntries.length; index += 1) {
8101
- const entry = orderedEntries[index];
8102
- const separatorChars = sections.length > 0 ? separator.length : 0;
8103
- const reserve = protectedIds.has(entry.id) ? 0 : this.estimateReservedRecallBudget(
8104
- orderedEntries,
8105
- index + 1,
8106
- protectedIds,
8107
- sections.length + 1
8108
- );
8109
- const availableForEntry = budget - usedChars - separatorChars - reserve;
8110
- if (availableForEntry <= 0) {
8111
- omittedIds.push(entry.id);
8112
- truncated = true;
8113
- continue;
8114
- }
8115
- const finalContent = this.truncateRecallSectionToBudget(
8116
- entry.content,
8117
- availableForEntry
8118
- );
8119
- if (!finalContent) {
8120
- omittedIds.push(entry.id);
8121
- truncated = true;
8122
- continue;
8123
- }
8124
- if (finalContent.length < entry.content.length) {
8125
- truncated = true;
8126
- }
8127
- sections.push(finalContent);
8128
- includedIds.push(entry.id);
8129
- usedChars += separatorChars + finalContent.length;
8130
- }
8131
- return {
8132
- sections,
8133
- includedIds,
8134
- omittedIds,
8135
- truncated,
8136
- finalChars: usedChars
8137
- };
8401
+ return this.recallSectionCoordinator.assembleRecallSections(
8402
+ sectionBuckets,
8403
+ budgetOverride
8404
+ );
8138
8405
  }
8139
8406
  /**
8140
8407
  * Clock source for the shared post-retrieval assembly/enrichment budget. The
@@ -15304,30 +15571,13 @@ ${reflectionsContent.trim()}
15304
15571
  return this.recallRerankCoordinator.applyMmrToQmdResults(sectionId, results, caps);
15305
15572
  }
15306
15573
  buildLastRecallBudgetSummary(options) {
15307
- return {
15308
- requestedTopK: options.requestedTopK,
15309
- appliedTopK: options.recallResultLimit,
15310
- recallBudgetChars: this.getRecallBudgetChars(),
15311
- maxMemoryTokens: this.config.maxMemoryTokens,
15312
- qmdFetchLimit: options.qmdFetchLimit,
15313
- qmdHybridFetchLimit: options.qmdHybridFetchLimit,
15314
- finalContextChars: options.finalContextChars,
15315
- truncated: options.truncated,
15316
- includedSections: [...options.includedSections ?? []],
15317
- omittedSections: [...options.omittedSections ?? []]
15318
- };
15574
+ return this.recallSectionCoordinator.buildLastRecallBudgetSummary(options);
15319
15575
  }
15320
15576
  collectLastRecallSources(sectionBuckets, recallSource) {
15321
- const used = /* @__PURE__ */ new Set();
15322
- if (recallSource !== "none") {
15323
- used.add(recallSource);
15324
- }
15325
- for (const [sectionId, chunks] of sectionBuckets.entries()) {
15326
- if (chunks.length > 0) {
15327
- used.add(sectionId);
15328
- }
15329
- }
15330
- return [...used];
15577
+ return this.recallSectionCoordinator.collectLastRecallSources(
15578
+ sectionBuckets,
15579
+ recallSource
15580
+ );
15331
15581
  }
15332
15582
  /**
15333
15583
  * Issue #373 — nearest-neighbor lookup for the write-time semantic dedup
@@ -16289,58 +16539,11 @@ ${reflectionsContent.trim()}
16289
16539
  * Uses QMD to find similar memories, then LLM to verify contradiction.
16290
16540
  */
16291
16541
  async checkForContradiction(content, category, namespaceScope) {
16292
- if (!this.isSearchAvailableForNamespaceRouting()) return null;
16293
- const results = await this.searchAcrossNamespaces({
16294
- query: content,
16295
- namespaces: [namespaceScope],
16296
- maxResults: 5,
16297
- mode: "search"
16298
- });
16299
- for (const result of results) {
16300
- if (result.score < this.config.contradictionSimilarityThreshold) {
16301
- continue;
16302
- }
16303
- const memoryId = this.extractMemoryIdsFromResults([result])[0];
16304
- if (!memoryId) continue;
16305
- const resultNamespace = this.namespaceFromPath(result.path);
16306
- if (resultNamespace !== namespaceScope) continue;
16307
- const resultStorage = await this.storageRouter.storageFor(resultNamespace);
16308
- const existingMemory = await resultStorage.getMemoryById(memoryId);
16309
- if (!existingMemory) continue;
16310
- if (existingMemory.frontmatter.status === "superseded" || existingMemory.frontmatter.status === "forgotten") {
16311
- continue;
16312
- }
16313
- const verification = await this.extraction.verifyContradiction(
16314
- { content, category },
16315
- {
16316
- id: existingMemory.frontmatter.id,
16317
- content: existingMemory.content,
16318
- category: existingMemory.frontmatter.category,
16319
- created: existingMemory.frontmatter.created
16320
- }
16321
- );
16322
- if (!verification) continue;
16323
- if (verification.isContradiction && verification.confidence >= this.config.contradictionMinConfidence) {
16324
- if (verification.whichIsNewer === "first") {
16325
- log.info(
16326
- `detected contradiction (confidence: ${verification.confidence}): ${existingMemory.frontmatter.id} vs new memory \u2014 existing is newer, incoming fact is stale`
16327
- );
16328
- continue;
16329
- }
16330
- log.info(
16331
- `detected contradiction (confidence: ${verification.confidence}): ${existingMemory.frontmatter.id} vs new memory${this.config.contradictionAutoResolve ? " (auto-resolved)" : " (queued for manual review)"}`
16332
- );
16333
- return {
16334
- supersededId: existingMemory.frontmatter.id,
16335
- confidence: verification.confidence,
16336
- reason: verification.reasoning,
16337
- supersededPath: existingMemory.path,
16338
- supersededCreated: existingMemory.frontmatter.created,
16339
- supersededTags: existingMemory.frontmatter.tags ?? []
16340
- };
16341
- }
16342
- }
16343
- return null;
16542
+ return this.contradictionLinkingCoordinator.checkForContradiction(
16543
+ content,
16544
+ category,
16545
+ namespaceScope
16546
+ );
16344
16547
  }
16345
16548
  /**
16346
16549
  * #1645: Complete the deferred contradiction auto-resolve after writeMemory
@@ -16351,40 +16554,12 @@ ${reflectionsContent.trim()}
16351
16554
  * supersedes before tombstone status is known" defect class.
16352
16555
  */
16353
16556
  async applyDeferredContradictionResolve(contradiction, storage, newMemoryId, postWriteGuard) {
16354
- if (postWriteGuard && contradiction && this.config.contradictionAutoResolve) {
16355
- try {
16356
- const blockedRow = await storage.getMemoryById(newMemoryId);
16357
- if (blockedRow?.frontmatter?.supersedes) {
16358
- await storage.writeMemoryFrontmatter(blockedRow, { supersedes: void 0 });
16359
- }
16360
- } catch (err) {
16361
- log.warn(
16362
- `contradiction auto-resolve supersedes clear failed for blocked ${newMemoryId}: ${err}`
16363
- );
16364
- }
16365
- }
16366
- if (!contradiction || !this.config.contradictionAutoResolve || postWriteGuard) {
16367
- return;
16368
- }
16369
- try {
16370
- await storage.supersedeMemory(
16371
- contradiction.supersededId,
16372
- newMemoryId,
16373
- contradiction.reason
16374
- );
16375
- if (resolveIndexingCapabilities(this.config).queryAwareIndexing && contradiction.supersededPath) {
16376
- deindexMemory(
16377
- this.config.memoryDir,
16378
- contradiction.supersededPath,
16379
- contradiction.supersededCreated,
16380
- contradiction.supersededTags
16381
- );
16382
- }
16383
- } catch (err) {
16384
- log.warn(
16385
- `contradiction auto-resolve supersede failed for ${contradiction.supersededId}: ${err}`
16386
- );
16387
- }
16557
+ return this.contradictionLinkingCoordinator.applyDeferredContradictionResolve(
16558
+ contradiction,
16559
+ storage,
16560
+ newMemoryId,
16561
+ postWriteGuard
16562
+ );
16388
16563
  }
16389
16564
  // ---------------------------------------------------------------------------
16390
16565
  // Memory Linking (Phase 3A)
@@ -16393,42 +16568,11 @@ ${reflectionsContent.trim()}
16393
16568
  * Suggest links for a new memory based on similar existing memories.
16394
16569
  */
16395
16570
  async suggestLinksForMemory(content, category, namespaceScope) {
16396
- if (!this.isSearchAvailableForNamespaceRouting()) return [];
16397
- const results = await this.searchAcrossNamespaces({
16398
- query: content,
16399
- namespaces: [namespaceScope],
16400
- maxResults: 5,
16401
- mode: "search"
16402
- });
16403
- if (results.length === 0) return [];
16404
- const candidates = [];
16405
- for (const result of results) {
16406
- const memoryId = this.extractMemoryIdsFromResults([result])[0];
16407
- if (!memoryId) continue;
16408
- const resultNamespace = this.namespaceFromPath(result.path);
16409
- if (resultNamespace !== namespaceScope) continue;
16410
- const resultStorage = await this.storageRouter.storageFor(resultNamespace);
16411
- const memory = await resultStorage.getMemoryById(memoryId);
16412
- if (memory && memory.frontmatter.status !== "superseded" && memory.frontmatter.status !== "forgotten") {
16413
- candidates.push({
16414
- id: memory.frontmatter.id,
16415
- content: memory.content,
16416
- category: memory.frontmatter.category
16417
- });
16418
- }
16419
- }
16420
- if (candidates.length === 0) return [];
16421
- const suggestions = await this.extraction.suggestLinks(
16422
- { content, category },
16423
- candidates
16571
+ return this.contradictionLinkingCoordinator.suggestLinksForMemory(
16572
+ content,
16573
+ category,
16574
+ namespaceScope
16424
16575
  );
16425
- if (!suggestions || suggestions.links.length === 0) return [];
16426
- return suggestions.links.map((link) => ({
16427
- targetId: link.targetId,
16428
- linkType: link.linkType,
16429
- strength: link.strength,
16430
- reason: link.reason || void 0
16431
- }));
16432
16576
  }
16433
16577
  async graphSeedPathRelativeToStorage(storage, result, recallNamespaces = []) {
16434
16578
  const parts = qmdCollectionPathParts(result.path);
@@ -16557,4 +16701,4 @@ export {
16557
16701
  resolvePersistedMemoryRelativePath,
16558
16702
  Orchestrator
16559
16703
  };
16560
- //# sourceMappingURL=chunk-7HUGLMSW.js.map
16704
+ //# sourceMappingURL=chunk-VO4VARZL.js.map