@remnic/core 9.3.734 → 9.3.735

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 (258) hide show
  1. package/dist/access-boundary.d.ts +8 -6
  2. package/dist/access-boundary.js +9 -9
  3. package/dist/access-cli.js +24 -24
  4. package/dist/access-http.d.ts +8 -6
  5. package/dist/access-http.js +14 -14
  6. package/dist/access-mcp.d.ts +8 -6
  7. package/dist/access-mcp.js +13 -13
  8. package/dist/access-operations-batch.js +11 -11
  9. package/dist/access-operations.d.ts +8 -6
  10. package/dist/access-operations.js +12 -12
  11. package/dist/access-schema.d.ts +4 -4
  12. package/dist/{access-service-rjFfmfKB.d.ts → access-service-CVx7mmvK.d.ts} +3 -3
  13. package/dist/access-service.d.ts +8 -6
  14. package/dist/access-service.js +8 -8
  15. package/dist/access-surface-catalog.d.ts +8 -6
  16. package/dist/action-confidence.d.ts +1 -1
  17. package/dist/active-memory-bridge.d.ts +1 -1
  18. package/dist/active-memory-bridge.js +3 -3
  19. package/dist/active-recall.d.ts +1 -1
  20. package/dist/behavior-learner.d.ts +1 -1
  21. package/dist/behavior-signals.d.ts +1 -1
  22. package/dist/bootstrap.d.ts +7 -5
  23. package/dist/briefing.d.ts +1 -1
  24. package/dist/buffer-surprise-report.d.ts +1 -1
  25. package/dist/buffer.d.ts +1 -1
  26. package/dist/calibration.d.ts +1 -1
  27. package/dist/capabilities.d.ts +101 -2
  28. package/dist/capabilities.js +13 -3
  29. package/dist/{catalog-DHYXzM4-.d.ts → catalog-BVhDEUhT.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-trajectory-graph.d.ts +1 -1
  33. package/dist/{chunk-IWMGBNXY.js → chunk-2T2N7ISV.js} +3 -3
  34. package/dist/{chunk-K7PAILHO.js → chunk-5BOQNB2K.js} +3 -3
  35. package/dist/{chunk-Q5LGXWNG.js → chunk-AAIHDIMD.js} +6 -6
  36. package/dist/{chunk-WHQ2JB35.js → chunk-AB2E5DCN.js} +2 -2
  37. package/dist/{chunk-FAGERSH2.js → chunk-AE7NTZ75.js} +3 -3
  38. package/dist/{chunk-V5OVSGB6.js → chunk-AESC5OQJ.js} +2 -2
  39. package/dist/{chunk-7FPJFCXL.js → chunk-BXPG5AVX.js} +4 -4
  40. package/dist/{chunk-UH3NYOHN.js → chunk-CHJIWG2H.js} +2 -2
  41. package/dist/{chunk-IDIXGGDN.js → chunk-E4LYJ7PY.js} +6 -6
  42. package/dist/{chunk-WTTVFSCO.js → chunk-FF36YNKY.js} +3 -3
  43. package/dist/{chunk-Z7J3OAPR.js → chunk-FLCYY5JX.js} +456 -398
  44. package/dist/chunk-FLCYY5JX.js.map +1 -0
  45. package/dist/{chunk-TJSQHO4Q.js → chunk-FLPKEMSO.js} +2 -2
  46. package/dist/{chunk-UF3N7IRP.js → chunk-G54IDCD3.js} +45 -41
  47. package/dist/chunk-G54IDCD3.js.map +1 -0
  48. package/dist/{chunk-UK6U5C3N.js → chunk-GB2FZOWB.js} +3 -3
  49. package/dist/{chunk-5OYHJIJN.js → chunk-GYICIICQ.js} +3 -3
  50. package/dist/{chunk-PEF2XOIV.js → chunk-HFXZIF3V.js} +3 -3
  51. package/dist/{chunk-PKO5NJ65.js → chunk-HLPYL6LC.js} +27 -24
  52. package/dist/chunk-HLPYL6LC.js.map +1 -0
  53. package/dist/{chunk-ET5HXSQL.js → chunk-IPI45Q4S.js} +2 -2
  54. package/dist/{chunk-2L5RTVMO.js → chunk-IX4L7E5G.js} +2 -2
  55. package/dist/{chunk-SYX73XD7.js → chunk-IXGXALRV.js} +10 -7
  56. package/dist/chunk-IXGXALRV.js.map +1 -0
  57. package/dist/{chunk-SHJGBAIW.js → chunk-JWDE7OVJ.js} +44 -2
  58. package/dist/{chunk-SHJGBAIW.js.map → chunk-JWDE7OVJ.js.map} +1 -1
  59. package/dist/{chunk-IZLTOS5L.js → chunk-K3Y2SJTN.js} +4 -4
  60. package/dist/{chunk-CILX2XW7.js → chunk-NDKW67ER.js} +2 -2
  61. package/dist/{chunk-54RCE5Z3.js → chunk-NNJKEAP2.js} +2 -2
  62. package/dist/{chunk-LV32K4OP.js → chunk-OYHYBHHI.js} +2 -2
  63. package/dist/{chunk-5DIKZKOD.js → chunk-P6VLG7KE.js} +2 -2
  64. package/dist/{chunk-T7CGPTFU.js → chunk-QNTLWH3T.js} +3 -3
  65. package/dist/{chunk-6U7TES2M.js → chunk-UO6MPN77.js} +13 -12
  66. package/dist/chunk-UO6MPN77.js.map +1 -0
  67. package/dist/{chunk-NDYQIN6C.js → chunk-VOEVVIP3.js} +3 -3
  68. package/dist/{chunk-3QETM5NG.js → chunk-ZBZ4XULO.js} +3 -3
  69. package/dist/{cli-XVpmSoQs.d.ts → cli-Cx5Mxwk7.d.ts} +3 -3
  70. package/dist/cli.d.ts +9 -7
  71. package/dist/cli.js +20 -20
  72. package/dist/compounding/engine.d.ts +1 -1
  73. package/dist/compounding/engine.js +2 -2
  74. package/dist/compounding/preference-consolidator.d.ts +1 -1
  75. package/dist/compression-optimizer.d.ts +1 -1
  76. package/dist/config.d.ts +1 -1
  77. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  78. package/dist/connectors/codex-materialize.d.ts +1 -1
  79. package/dist/connectors/index.d.ts +1 -1
  80. package/dist/consolidation-provenance-check.d.ts +1 -1
  81. package/dist/consolidation-undo.d.ts +1 -1
  82. package/dist/contradiction/index.d.ts +1 -1
  83. package/dist/contradiction/index.js +2 -2
  84. package/dist/{contradiction-scan-OUHMCUBT.js → contradiction-scan-2B4AE4TI.js} +3 -3
  85. package/dist/conversation-index/backend.d.ts +1 -1
  86. package/dist/conversation-index/chunker.d.ts +1 -1
  87. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  88. package/dist/conversation-index/indexer.d.ts +1 -1
  89. package/dist/conversation-index/search.d.ts +1 -1
  90. package/dist/day-summary.d.ts +1 -1
  91. package/dist/delinearize.d.ts +1 -1
  92. package/dist/direct-answer-wiring.d.ts +1 -1
  93. package/dist/direct-answer.d.ts +1 -1
  94. package/dist/embedding-fallback.d.ts +1 -1
  95. package/dist/embedding-fallback.js +2 -2
  96. package/dist/enrichment/index.d.ts +1 -1
  97. package/dist/entity-retrieval.d.ts +1 -1
  98. package/dist/entity-retrieval.js +2 -2
  99. package/dist/entity-schema.d.ts +1 -1
  100. package/dist/explicit-capture.d.ts +7 -5
  101. package/dist/explicit-capture.js +2 -2
  102. package/dist/extraction-faithfulness.d.ts +1 -1
  103. package/dist/extraction-judge-telemetry.d.ts +1 -1
  104. package/dist/extraction-judge-training.d.ts +1 -1
  105. package/dist/extraction-judge.d.ts +1 -1
  106. package/dist/extraction.d.ts +1 -1
  107. package/dist/extraction.js +3 -3
  108. package/dist/fallback-llm.d.ts +1 -1
  109. package/dist/{first-start-migration-W4U6XDKI.js → first-start-migration-2RQYDIZ7.js} +6 -5
  110. package/dist/first-start-migration-2RQYDIZ7.js.map +1 -0
  111. package/dist/graph-dashboard-diff.d.ts +1 -1
  112. package/dist/graph-dashboard-key.d.ts +1 -1
  113. package/dist/graph-dashboard-parser.d.ts +1 -1
  114. package/dist/graph-edge-reinforcement.d.ts +1 -1
  115. package/dist/graph-snapshot.d.ts +1 -1
  116. package/dist/graph.d.ts +1 -1
  117. package/dist/identity-continuity.d.ts +1 -1
  118. package/dist/importance.d.ts +1 -1
  119. package/dist/index.d.ts +9 -9
  120. package/dist/index.js +30 -30
  121. package/dist/intent.d.ts +1 -1
  122. package/dist/lcm/engine.d.ts +1 -1
  123. package/dist/lcm/index.d.ts +1 -1
  124. package/dist/lcm/tools.d.ts +1 -1
  125. package/dist/lifecycle.d.ts +1 -1
  126. package/dist/live-connectors-runner.d.ts +1 -1
  127. package/dist/local-llm.d.ts +1 -1
  128. package/dist/local-llm.js +2 -2
  129. package/dist/local-model-endpoint.d.ts +1 -1
  130. package/dist/maintenance/memory-governance.d.ts +1 -1
  131. package/dist/mcp-memory-inspector-app.d.ts +8 -6
  132. package/dist/memory-action-policy.d.ts +1 -1
  133. package/dist/memory-cache.d.ts +1 -1
  134. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  135. package/dist/memory-projection-store.d.ts +1 -1
  136. package/dist/memory-provenance.d.ts +1 -1
  137. package/dist/memory-worth-outcomes.d.ts +1 -1
  138. package/dist/models-json.d.ts +1 -1
  139. package/dist/namespaces/migrate.d.ts +2 -2
  140. package/dist/namespaces/migrate.js +6 -6
  141. package/dist/namespaces/principal.d.ts +1 -1
  142. package/dist/namespaces/principal.js +2 -2
  143. package/dist/namespaces/search.d.ts +1 -1
  144. package/dist/namespaces/search.js +4 -4
  145. package/dist/namespaces/storage.d.ts +2 -2
  146. package/dist/namespaces/storage.js +2 -2
  147. package/dist/native-knowledge.d.ts +1 -1
  148. package/dist/operator-toolkit.d.ts +1 -1
  149. package/dist/operator-toolkit.js +11 -11
  150. package/dist/orchestration/compression-guideline-coordinator.d.ts +1 -1
  151. package/dist/orchestration/compression-guideline-coordinator.js +2 -1
  152. package/dist/orchestration/maintenance.d.ts +2 -2
  153. package/dist/orchestration/maintenance.js +6 -6
  154. package/dist/{orchestrator-BXi-gadS.d.ts → orchestrator-oF0cceBX.d.ts} +80 -16
  155. package/dist/orchestrator.d.ts +7 -5
  156. package/dist/orchestrator.js +19 -19
  157. package/dist/patterns-cli.d.ts +1 -1
  158. package/dist/policy-runtime.d.ts +1 -1
  159. package/dist/provenance.d.ts +1 -1
  160. package/dist/qmd-recall-cache.d.ts +1 -1
  161. package/dist/qmd.d.ts +1 -1
  162. package/dist/recall-disclosure-escalation.d.ts +1 -1
  163. package/dist/recall-explain-renderer.d.ts +1 -1
  164. package/dist/recall-planner-llm.d.ts +1 -1
  165. package/dist/recall-state.d.ts +1 -1
  166. package/dist/recall-tag-filter.d.ts +1 -1
  167. package/dist/recall-xray-cli.d.ts +1 -1
  168. package/dist/recall-xray-renderer.d.ts +1 -1
  169. package/dist/recall-xray.d.ts +1 -1
  170. package/dist/resolve-auth-token.d.ts +1 -1
  171. package/dist/retrieval-agents.d.ts +1 -1
  172. package/dist/retrieval-tiers.d.ts +1 -1
  173. package/dist/routing/engine.d.ts +1 -1
  174. package/dist/routing/store.d.ts +1 -1
  175. package/dist/schemas.d.ts +24 -24
  176. package/dist/search/embed-helper.d.ts +1 -1
  177. package/dist/search/embed-helper.js +2 -2
  178. package/dist/search/factory.d.ts +1 -1
  179. package/dist/search/factory.js +3 -3
  180. package/dist/search/index.d.ts +1 -1
  181. package/dist/search/index.js +3 -3
  182. package/dist/search/lancedb-backend.d.ts +1 -1
  183. package/dist/search/meilisearch-backend.d.ts +1 -1
  184. package/dist/search/noop-backend.d.ts +1 -1
  185. package/dist/search/orama-backend.d.ts +1 -1
  186. package/dist/search/port.d.ts +1 -1
  187. package/dist/search/remote-backend.d.ts +1 -1
  188. package/dist/{semantic-consolidation-DeL5grLx.d.ts → semantic-consolidation-DKGbufYO.d.ts} +1 -1
  189. package/dist/semantic-consolidation.d.ts +2 -2
  190. package/dist/semantic-rule-verifier.d.ts +1 -1
  191. package/dist/session-observer-bands.d.ts +1 -1
  192. package/dist/session-observer-state.d.ts +1 -1
  193. package/dist/shared-context/manager.d.ts +3 -3
  194. package/dist/signal.d.ts +1 -1
  195. package/dist/storage.d.ts +1 -1
  196. package/dist/summarizer.d.ts +1 -1
  197. package/dist/summarizer.js +3 -3
  198. package/dist/summary-snapshot.d.ts +1 -1
  199. package/dist/temporal-supersession.d.ts +1 -1
  200. package/dist/temporal-validity.d.ts +1 -1
  201. package/dist/threading.d.ts +1 -1
  202. package/dist/tier-migration.d.ts +1 -1
  203. package/dist/tier-routing.d.ts +1 -1
  204. package/dist/{tier-stats-LSM35HZY.js → tier-stats-KPDIISG7.js} +6 -5
  205. package/dist/tier-stats-KPDIISG7.js.map +1 -0
  206. package/dist/topics.d.ts +1 -1
  207. package/dist/transcript.d.ts +1 -1
  208. package/dist/transfer/types.d.ts +42 -42
  209. package/dist/trust-score-stage.d.ts +1 -1
  210. package/dist/trust-score.d.ts +1 -1
  211. package/dist/{types-CpFz51Pv.d.ts → types-C7UCxpuO.d.ts} +1 -1
  212. package/dist/types.d.ts +1 -1
  213. package/dist/utility-runtime.d.ts +1 -1
  214. package/package.json +2 -2
  215. package/src/access-service.ts +20 -20
  216. package/src/capabilities.test.ts +197 -0
  217. package/src/capabilities.ts +206 -0
  218. package/src/cli/creation-ledger-commands.ts +2 -2
  219. package/src/cli/research-status-commands.ts +13 -13
  220. package/src/cli.ts +17 -17
  221. package/src/maintenance/first-start-migration.ts +3 -3
  222. package/src/maintenance/tier-stats.ts +3 -3
  223. package/src/operator-toolkit.ts +8 -8
  224. package/src/orchestration/compression-guideline-coordinator.ts +7 -6
  225. package/src/orchestration/lifecycle-policy-coordinator.ts +504 -0
  226. package/src/orchestrator.ts +28 -383
  227. package/dist/chunk-6U7TES2M.js.map +0 -1
  228. package/dist/chunk-PKO5NJ65.js.map +0 -1
  229. package/dist/chunk-SYX73XD7.js.map +0 -1
  230. package/dist/chunk-UF3N7IRP.js.map +0 -1
  231. package/dist/chunk-Z7J3OAPR.js.map +0 -1
  232. package/dist/first-start-migration-W4U6XDKI.js.map +0 -1
  233. package/dist/tier-stats-LSM35HZY.js.map +0 -1
  234. /package/dist/{chunk-IWMGBNXY.js.map → chunk-2T2N7ISV.js.map} +0 -0
  235. /package/dist/{chunk-K7PAILHO.js.map → chunk-5BOQNB2K.js.map} +0 -0
  236. /package/dist/{chunk-Q5LGXWNG.js.map → chunk-AAIHDIMD.js.map} +0 -0
  237. /package/dist/{chunk-WHQ2JB35.js.map → chunk-AB2E5DCN.js.map} +0 -0
  238. /package/dist/{chunk-FAGERSH2.js.map → chunk-AE7NTZ75.js.map} +0 -0
  239. /package/dist/{chunk-V5OVSGB6.js.map → chunk-AESC5OQJ.js.map} +0 -0
  240. /package/dist/{chunk-7FPJFCXL.js.map → chunk-BXPG5AVX.js.map} +0 -0
  241. /package/dist/{chunk-UH3NYOHN.js.map → chunk-CHJIWG2H.js.map} +0 -0
  242. /package/dist/{chunk-IDIXGGDN.js.map → chunk-E4LYJ7PY.js.map} +0 -0
  243. /package/dist/{chunk-WTTVFSCO.js.map → chunk-FF36YNKY.js.map} +0 -0
  244. /package/dist/{chunk-TJSQHO4Q.js.map → chunk-FLPKEMSO.js.map} +0 -0
  245. /package/dist/{chunk-UK6U5C3N.js.map → chunk-GB2FZOWB.js.map} +0 -0
  246. /package/dist/{chunk-5OYHJIJN.js.map → chunk-GYICIICQ.js.map} +0 -0
  247. /package/dist/{chunk-PEF2XOIV.js.map → chunk-HFXZIF3V.js.map} +0 -0
  248. /package/dist/{chunk-ET5HXSQL.js.map → chunk-IPI45Q4S.js.map} +0 -0
  249. /package/dist/{chunk-2L5RTVMO.js.map → chunk-IX4L7E5G.js.map} +0 -0
  250. /package/dist/{chunk-IZLTOS5L.js.map → chunk-K3Y2SJTN.js.map} +0 -0
  251. /package/dist/{chunk-CILX2XW7.js.map → chunk-NDKW67ER.js.map} +0 -0
  252. /package/dist/{chunk-54RCE5Z3.js.map → chunk-NNJKEAP2.js.map} +0 -0
  253. /package/dist/{chunk-LV32K4OP.js.map → chunk-OYHYBHHI.js.map} +0 -0
  254. /package/dist/{chunk-5DIKZKOD.js.map → chunk-P6VLG7KE.js.map} +0 -0
  255. /package/dist/{chunk-T7CGPTFU.js.map → chunk-QNTLWH3T.js.map} +0 -0
  256. /package/dist/{chunk-NDYQIN6C.js.map → chunk-VOEVVIP3.js.map} +0 -0
  257. /package/dist/{chunk-3QETM5NG.js.map → chunk-ZBZ4XULO.js.map} +0 -0
  258. /package/dist/{contradiction-scan-OUHMCUBT.js.map → contradiction-scan-2B4AE4TI.js.map} +0 -0
@@ -7,10 +7,10 @@ import {
7
7
  } from "./chunk-OZECYVGI.js";
8
8
  import {
9
9
  CompressionGuidelineCoordinator
10
- } from "./chunk-SYX73XD7.js";
10
+ } from "./chunk-IXGXALRV.js";
11
11
  import {
12
12
  MaintenanceScheduler
13
- } from "./chunk-5OYHJIJN.js";
13
+ } from "./chunk-GYICIICQ.js";
14
14
  import {
15
15
  runPeerProfileReasoner
16
16
  } from "./chunk-I74SUMNI.js";
@@ -29,7 +29,7 @@ import {
29
29
  import {
30
30
  CompoundingEngine,
31
31
  defaultTierMigrationCycleBudget
32
- } from "./chunk-ET5HXSQL.js";
32
+ } from "./chunk-IPI45Q4S.js";
33
33
  import {
34
34
  SharedContextManager
35
35
  } from "./chunk-UFS7OXGL.js";
@@ -63,7 +63,7 @@ import {
63
63
  } from "./chunk-UHGBNIOS.js";
64
64
  import {
65
65
  HourlySummarizer
66
- } from "./chunk-PEF2XOIV.js";
66
+ } from "./chunk-HFXZIF3V.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-WTTVFSCO.js";
163
+ } from "./chunk-FF36YNKY.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-2L5RTVMO.js";
172
+ } from "./chunk-IX4L7E5G.js";
173
173
  import {
174
174
  buildFocusedListRecallSection,
175
175
  shouldRecallFocusedListEvidence
@@ -193,12 +193,12 @@ import {
193
193
  } from "./chunk-Q6IP2ARR.js";
194
194
  import {
195
195
  EmbeddingFallback
196
- } from "./chunk-UH3NYOHN.js";
196
+ } from "./chunk-CHJIWG2H.js";
197
197
  import {
198
198
  buildEntityRecallSection,
199
199
  entityRecentTranscriptLookbackHours,
200
200
  readRecentEntityTranscriptEntries
201
- } from "./chunk-V5OVSGB6.js";
201
+ } from "./chunk-AESC5OQJ.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-FAGERSH2.js";
231
+ } from "./chunk-AE7NTZ75.js";
232
232
  import {
233
233
  NamespaceCatalog,
234
234
  planNamespaceMaintenance
235
- } from "./chunk-7FPJFCXL.js";
235
+ } from "./chunk-BXPG5AVX.js";
236
236
  import {
237
237
  NamespaceStorageRouter
238
- } from "./chunk-54RCE5Z3.js";
238
+ } from "./chunk-NNJKEAP2.js";
239
239
  import {
240
240
  searchHarmonicRetrieval
241
241
  } from "./chunk-AV5ZEH4M.js";
@@ -333,14 +333,14 @@ import {
333
333
  resolveNamespaceFromStorageDir,
334
334
  resolveScopePlan,
335
335
  resolveScopeProfilePlan
336
- } from "./chunk-UK6U5C3N.js";
336
+ } from "./chunk-GB2FZOWB.js";
337
337
  import {
338
338
  NamespaceSearchRouter
339
- } from "./chunk-3QETM5NG.js";
339
+ } from "./chunk-ZBZ4XULO.js";
340
340
  import {
341
341
  createConversationIndexRuntime,
342
342
  createSearchBackend
343
- } from "./chunk-K7PAILHO.js";
343
+ } from "./chunk-5BOQNB2K.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-CILX2XW7.js";
366
+ } from "./chunk-NDKW67ER.js";
367
367
  import {
368
368
  searchCausalTrajectories
369
369
  } from "./chunk-SQNED75R.js";
@@ -465,18 +465,23 @@ import {
465
465
  defaultNamespaceForPrincipal,
466
466
  recallNamespacesForPrincipal,
467
467
  resolvePrincipal
468
- } from "./chunk-LV32K4OP.js";
468
+ } from "./chunk-OYHYBHHI.js";
469
469
  import {
470
470
  resolveCapabilities,
471
+ resolveCompressionCapabilities,
471
472
  resolveCreationMemoryCapabilities,
473
+ resolveEvalCapabilities,
472
474
  resolveGraphConstructionCapabilities,
473
475
  resolveIdentityContinuityCapabilities,
474
476
  resolveIndexingCapabilities,
475
477
  resolveLocalLlmCapabilities,
476
478
  resolveMemoryLifecycleCapabilities,
477
479
  resolveNamespaceCapabilities,
478
- resolveQmdCapabilities
479
- } from "./chunk-SHJGBAIW.js";
480
+ resolveObjectiveStateCapabilities,
481
+ resolveQmdCapabilities,
482
+ resolveSecurityCapabilities,
483
+ resolveUtilityLearningCapabilities
484
+ } from "./chunk-JWDE7OVJ.js";
480
485
  import {
481
486
  isSafeRouteNamespace,
482
487
  selectRouteRule
@@ -501,19 +506,19 @@ import {
501
506
  } from "./chunk-PVGDJXVK.js";
502
507
 
503
508
  // src/orchestrator.ts
504
- import path3 from "path";
509
+ import path4 from "path";
505
510
  import os2 from "os";
506
511
  import { createHash, randomBytes } from "crypto";
507
512
  import { existsSync, readFileSync } from "fs";
508
513
  import {
509
514
  lstat,
510
- mkdir as mkdir2,
515
+ mkdir as mkdir3,
511
516
  readdir,
512
517
  readFile as readFile2,
513
518
  realpath,
514
519
  stat,
515
520
  unlink,
516
- writeFile as writeFile2
521
+ writeFile as writeFile3
517
522
  } from "fs/promises";
518
523
 
519
524
  // src/procedural/procedure-recall.ts
@@ -1130,6 +1135,307 @@ var SemanticConsolidationCoordinator = class {
1130
1135
  }
1131
1136
  };
1132
1137
 
1138
+ // src/orchestration/lifecycle-policy-coordinator.ts
1139
+ import path2 from "path";
1140
+ import { mkdir, writeFile } from "fs/promises";
1141
+ var LifecyclePolicyCoordinator = class {
1142
+ constructor(deps) {
1143
+ this.deps = deps;
1144
+ }
1145
+ deps;
1146
+ get config() {
1147
+ return this.deps.config;
1148
+ }
1149
+ // -------------------------------------------------------------------------
1150
+ // Action-outcome priors (feeds lifecycle transition decisions)
1151
+ // -------------------------------------------------------------------------
1152
+ actionOutcomePriorDelta(event) {
1153
+ if (event.outcome === "failed") return -0.3;
1154
+ if (event.policyDecision === "deny") return -0.22;
1155
+ if (event.policyDecision === "defer") return -0.14;
1156
+ if (event.outcome === "skipped") return -0.1;
1157
+ if (event.outcome !== "applied") return 0;
1158
+ switch (event.action) {
1159
+ case "store_episode":
1160
+ case "store_note":
1161
+ case "update_note":
1162
+ return 0.08;
1163
+ case "create_artifact":
1164
+ case "summarize_node":
1165
+ case "link_graph":
1166
+ return 0.04;
1167
+ case "discard":
1168
+ return -0.03;
1169
+ default:
1170
+ return 0;
1171
+ }
1172
+ }
1173
+ async buildLifecycleActionPriors(storage = this.deps.getStorage()) {
1174
+ const events = await storage.readMemoryActionEvents(1200);
1175
+ if (events.length === 0) return /* @__PURE__ */ new Map();
1176
+ const nowMs = Date.now();
1177
+ const windowMs = 14 * 24 * 60 * 60 * 1e3;
1178
+ const byMemory = /* @__PURE__ */ new Map();
1179
+ for (const event of events) {
1180
+ if (typeof event.memoryId !== "string" || event.memoryId.trim().length === 0)
1181
+ continue;
1182
+ const ts = Date.parse(event.timestamp);
1183
+ if (!Number.isFinite(ts)) continue;
1184
+ const ageMs = nowMs - ts;
1185
+ if (ageMs < 0 || ageMs > windowMs) continue;
1186
+ const delta = this.actionOutcomePriorDelta(event);
1187
+ if (delta === 0) continue;
1188
+ const recencyWeight = Math.max(0.2, 1 - ageMs / windowMs);
1189
+ const list = byMemory.get(event.memoryId) ?? [];
1190
+ if (list.length >= 8) list.shift();
1191
+ list.push({
1192
+ weightedDelta: delta * recencyWeight,
1193
+ weight: recencyWeight
1194
+ });
1195
+ byMemory.set(event.memoryId, list);
1196
+ }
1197
+ const out = /* @__PURE__ */ new Map();
1198
+ for (const [memoryId, deltas] of byMemory.entries()) {
1199
+ if (deltas.length === 0) continue;
1200
+ const weightedSum = deltas.reduce(
1201
+ (sum, item) => sum + item.weightedDelta,
1202
+ 0
1203
+ );
1204
+ const weightTotal = deltas.reduce((sum, item) => sum + item.weight, 0);
1205
+ if (weightTotal <= 0) continue;
1206
+ const score = weightedSum / weightTotal;
1207
+ out.set(memoryId, Math.max(-0.25, Math.min(0.15, score)));
1208
+ }
1209
+ return out;
1210
+ }
1211
+ // -------------------------------------------------------------------------
1212
+ // Lifecycle policy pass (heat/decay scoring + transition)
1213
+ // -------------------------------------------------------------------------
1214
+ async runLifecyclePolicyPass(allMemories, storage = this.deps.getStorage()) {
1215
+ const now = /* @__PURE__ */ new Date();
1216
+ const nowIso = now.toISOString();
1217
+ const countsByState = {
1218
+ candidate: 0,
1219
+ validated: 0,
1220
+ active: 0,
1221
+ stale: 0,
1222
+ archived: 0
1223
+ };
1224
+ const transitionCounts = {};
1225
+ let updatedCount = 0;
1226
+ let disputedCount = 0;
1227
+ let evaluatedCount = 0;
1228
+ const lifecycleCaps = resolveMemoryLifecycleCapabilities(this.config);
1229
+ const thresholds = this.deps.getEffectiveLifecycleThresholds();
1230
+ const policy = {
1231
+ promoteHeatThreshold: thresholds.promoteHeatThreshold,
1232
+ staleDecayThreshold: thresholds.staleDecayThreshold,
1233
+ archiveDecayThreshold: thresholds.archiveDecayThreshold,
1234
+ protectedCategories: this.config.lifecycleProtectedCategories
1235
+ };
1236
+ const actionPriors = await this.buildLifecycleActionPriors(storage);
1237
+ for (const memory of allMemories) {
1238
+ if (memory.frontmatter.status === "superseded" || memory.frontmatter.status === "forgotten") {
1239
+ continue;
1240
+ }
1241
+ evaluatedCount += 1;
1242
+ const currentState = resolveLifecycleState(memory.frontmatter);
1243
+ const actionPriorScore = actionPriors.get(memory.frontmatter.id);
1244
+ const signals = typeof actionPriorScore === "number" && Number.isFinite(actionPriorScore) ? { actionPriorScore } : void 0;
1245
+ const decision = decideLifecycleTransition(memory, policy, now, signals);
1246
+ const nextState = memory.frontmatter.status === "archived" ? "archived" : decision.nextState;
1247
+ countsByState[nextState] += 1;
1248
+ if (memory.frontmatter.verificationState === "disputed") {
1249
+ disputedCount += 1;
1250
+ }
1251
+ if (nextState !== currentState) {
1252
+ const key = `${currentState}->${nextState}`;
1253
+ transitionCounts[key] = (transitionCounts[key] ?? 0) + 1;
1254
+ }
1255
+ const prevHeat = memory.frontmatter.heatScore;
1256
+ const prevDecay = memory.frontmatter.decayScore;
1257
+ const scoreDelta = Math.abs((prevHeat ?? -1) - decision.heatScore) + Math.abs((prevDecay ?? -1) - decision.decayScore);
1258
+ const shouldPersist = memory.frontmatter.lifecycleState !== nextState || memory.frontmatter.heatScore === void 0 || memory.frontmatter.decayScore === void 0 || memory.frontmatter.lastValidatedAt === void 0 || scoreDelta >= 0.01;
1259
+ if (!shouldPersist) continue;
1260
+ const wrote = await storage.writeMemoryFrontmatter(memory, {
1261
+ lifecycleState: nextState,
1262
+ heatScore: decision.heatScore,
1263
+ decayScore: decision.decayScore,
1264
+ lastValidatedAt: nowIso
1265
+ });
1266
+ if (wrote) updatedCount += 1;
1267
+ }
1268
+ if (!lifecycleCaps.lifecycleMetrics) return updatedCount;
1269
+ const total = evaluatedCount;
1270
+ const metrics = {
1271
+ generatedAt: nowIso,
1272
+ memoriesEvaluated: total,
1273
+ memoriesUpdated: updatedCount,
1274
+ countsByLifecycleState: countsByState,
1275
+ transitionCounts,
1276
+ staleRatio: total > 0 ? countsByState.stale / total : 0,
1277
+ disputedRatio: total > 0 ? disputedCount / total : 0,
1278
+ policy: {
1279
+ promoteHeatThreshold: thresholds.promoteHeatThreshold,
1280
+ staleDecayThreshold: thresholds.staleDecayThreshold,
1281
+ archiveDecayThreshold: thresholds.archiveDecayThreshold,
1282
+ protectedCategories: this.config.lifecycleProtectedCategories
1283
+ }
1284
+ };
1285
+ const metricsPath = path2.join(
1286
+ storage.dir,
1287
+ "state",
1288
+ "lifecycle-metrics.json"
1289
+ );
1290
+ await mkdir(path2.dirname(metricsPath), { recursive: true });
1291
+ await writeFile(metricsPath, JSON.stringify(metrics, null, 2), "utf-8");
1292
+ return updatedCount;
1293
+ }
1294
+ // -------------------------------------------------------------------------
1295
+ // Fact archival
1296
+ // -------------------------------------------------------------------------
1297
+ /**
1298
+ * Archive old, low-importance, rarely-accessed facts (v6.0).
1299
+ * Moves eligible facts from facts/ to archive/YYYY-MM-DD/.
1300
+ * Returns the number of archived facts.
1301
+ */
1302
+ async runFactArchival(allMemories) {
1303
+ const storage = this.deps.getStorage();
1304
+ const now = Date.now();
1305
+ const ageCutoffMs = this.config.factArchivalAgeDays * 24 * 60 * 60 * 1e3;
1306
+ const protectedCategories = new Set(
1307
+ this.config.factArchivalProtectedCategories
1308
+ );
1309
+ let archivedCount = 0;
1310
+ for (const memory of allMemories) {
1311
+ const fm = memory.frontmatter;
1312
+ if (fm.status && fm.status !== "active") continue;
1313
+ if (protectedCategories.has(fm.category)) continue;
1314
+ if (fm.category === "correction") continue;
1315
+ const createdMs = new Date(fm.created).getTime();
1316
+ if (now - createdMs < ageCutoffMs) continue;
1317
+ const importanceScore = fm.importance?.score ?? 0.5;
1318
+ if (importanceScore >= this.config.factArchivalMaxImportance) continue;
1319
+ const accessCount = fm.accessCount ?? 0;
1320
+ if (accessCount > this.config.factArchivalMaxAccessCount) continue;
1321
+ const result = await storage.archiveMemory(memory);
1322
+ if (result) {
1323
+ await this.deps.removeContentHashForMemory(
1324
+ storage,
1325
+ memory,
1326
+ "fact-archival"
1327
+ );
1328
+ await this.deps.embeddingFallback.removeFromIndex(memory.frontmatter.id);
1329
+ if (resolveIndexingCapabilities(this.config).queryAwareIndexing && memory.path && memory.frontmatter?.created) {
1330
+ deindexMemory(
1331
+ this.config.memoryDir,
1332
+ memory.path,
1333
+ memory.frontmatter.created,
1334
+ memory.frontmatter.tags ?? []
1335
+ );
1336
+ }
1337
+ archivedCount++;
1338
+ }
1339
+ }
1340
+ if (archivedCount > 0) {
1341
+ await this.deps.saveContentHashIndexes().catch(
1342
+ (err) => log.warn(`content-hash index save failed during archival: ${err}`)
1343
+ );
1344
+ }
1345
+ return archivedCount;
1346
+ }
1347
+ // -------------------------------------------------------------------------
1348
+ // Summarization (Phase 4A)
1349
+ // -------------------------------------------------------------------------
1350
+ /**
1351
+ * Run memory summarization if memory count exceeds threshold (Phase 4A).
1352
+ */
1353
+ async runSummarization(allMemories) {
1354
+ const storage = this.deps.getStorage();
1355
+ const activeMemories = allMemories.filter(
1356
+ (m) => isActiveMemoryStatus(m.frontmatter.status)
1357
+ );
1358
+ if (activeMemories.length < this.config.summarizationTriggerCount) {
1359
+ return;
1360
+ }
1361
+ log.info(
1362
+ `memory count (${activeMemories.length}) exceeds threshold (${this.config.summarizationTriggerCount}) \u2014 running summarization`
1363
+ );
1364
+ const sorted = activeMemories.sort(
1365
+ (a, b) => new Date(a.frontmatter.created).getTime() - new Date(b.frontmatter.created).getTime()
1366
+ );
1367
+ const recentToKeep = Math.max(0, this.config.summarizationRecentToKeep);
1368
+ const toSummarize = recentToKeep > 0 ? sorted.slice(0, -recentToKeep) : sorted;
1369
+ const candidates = toSummarize.filter((m) => {
1370
+ if (m.frontmatter.entityRef) return false;
1371
+ const protectedTags = this.config.summarizationProtectedTags;
1372
+ if (m.frontmatter.tags.some((t) => protectedTags.includes(t)))
1373
+ return false;
1374
+ const importance = m.frontmatter.importance?.score ?? 0.5;
1375
+ if (importance >= this.config.summarizationImportanceThreshold)
1376
+ return false;
1377
+ return true;
1378
+ });
1379
+ if (candidates.length < 50) {
1380
+ log.debug(
1381
+ `only ${candidates.length} candidates for summarization \u2014 skipping`
1382
+ );
1383
+ return;
1384
+ }
1385
+ const batchSize = 50;
1386
+ for (let i = 0; i < candidates.length; i += batchSize) {
1387
+ const batch = candidates.slice(i, i + batchSize);
1388
+ const batchData = batch.map((m) => ({
1389
+ id: m.frontmatter.id,
1390
+ content: m.content,
1391
+ category: m.frontmatter.category,
1392
+ created: m.frontmatter.created
1393
+ }));
1394
+ const result = await this.deps.extraction.summarizeMemories(batchData);
1395
+ if (!result) continue;
1396
+ const summary = {
1397
+ id: `summary-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
1398
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
1399
+ timeRangeStart: batch[0].frontmatter.created,
1400
+ timeRangeEnd: batch[batch.length - 1].frontmatter.created,
1401
+ summaryText: result.summaryText,
1402
+ keyFacts: result.keyFacts,
1403
+ keyEntities: result.keyEntities,
1404
+ sourceEpisodeIds: batch.map((m) => m.frontmatter.id)
1405
+ };
1406
+ await storage.writeSummary(summary);
1407
+ const archived = await storage.archiveMemories(
1408
+ batch.map((m) => m.frontmatter.id),
1409
+ summary.id
1410
+ );
1411
+ log.info(
1412
+ `created summary ${summary.id} from ${batch.length} memories, archived ${archived}`
1413
+ );
1414
+ }
1415
+ }
1416
+ // -------------------------------------------------------------------------
1417
+ // Topic extraction (Phase 4B)
1418
+ // -------------------------------------------------------------------------
1419
+ /**
1420
+ * Run topic extraction on all memories (Phase 4B).
1421
+ */
1422
+ async runTopicExtraction(allMemories) {
1423
+ const storage = this.deps.getStorage();
1424
+ const activeMemories = allMemories.filter(
1425
+ (m) => isActiveMemoryStatus(m.frontmatter.status)
1426
+ );
1427
+ if (activeMemories.length === 0) return;
1428
+ const topics = extractTopics(
1429
+ activeMemories,
1430
+ this.config.topicExtractionTopN
1431
+ );
1432
+ await storage.saveTopics(topics);
1433
+ log.debug(
1434
+ `extracted ${topics.length} topics from ${activeMemories.length} memories`
1435
+ );
1436
+ }
1437
+ };
1438
+
1133
1439
  // src/maintenance/pattern-reinforcement.ts
1134
1440
  function patternReinforcementKey(content) {
1135
1441
  return content.trim().toLowerCase().replace(/\s+/g, " ").slice(0, 200);
@@ -1462,8 +1768,8 @@ function generateResolverDocument(taxonomy) {
1462
1768
  }
1463
1769
 
1464
1770
  // src/taxonomy/taxonomy-loader.ts
1465
- import { readFile, mkdir, writeFile } from "fs/promises";
1466
- import path2 from "path";
1771
+ import { readFile, mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
1772
+ import path3 from "path";
1467
1773
  var TAXONOMY_DIR = ".taxonomy";
1468
1774
  var TAXONOMY_FILE = "taxonomy.json";
1469
1775
  var MAX_SLUG_LENGTH = 32;
@@ -1561,7 +1867,7 @@ function validateTaxonomy(taxonomy) {
1561
1867
  }
1562
1868
  }
1563
1869
  async function loadTaxonomy(memoryDir) {
1564
- const taxonomyPath = path2.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
1870
+ const taxonomyPath = path3.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
1565
1871
  let raw;
1566
1872
  try {
1567
1873
  raw = await readFile(taxonomyPath, "utf-8");
@@ -1611,16 +1917,16 @@ async function loadTaxonomy(memoryDir) {
1611
1917
  }
1612
1918
  async function saveTaxonomy(memoryDir, taxonomy) {
1613
1919
  validateTaxonomy(taxonomy);
1614
- const dir = path2.join(memoryDir, TAXONOMY_DIR);
1615
- await mkdir(dir, { recursive: true });
1616
- const filePath = path2.join(dir, TAXONOMY_FILE);
1617
- await writeFile(filePath, JSON.stringify(taxonomy, null, 2) + "\n", "utf-8");
1920
+ const dir = path3.join(memoryDir, TAXONOMY_DIR);
1921
+ await mkdir2(dir, { recursive: true });
1922
+ const filePath = path3.join(dir, TAXONOMY_FILE);
1923
+ await writeFile2(filePath, JSON.stringify(taxonomy, null, 2) + "\n", "utf-8");
1618
1924
  }
1619
1925
  function getTaxonomyDir(memoryDir) {
1620
- return path2.join(memoryDir, TAXONOMY_DIR);
1926
+ return path3.join(memoryDir, TAXONOMY_DIR);
1621
1927
  }
1622
1928
  function getTaxonomyFilePath(memoryDir) {
1623
- return path2.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
1929
+ return path3.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
1624
1930
  }
1625
1931
 
1626
1932
  // src/wearables/registry.ts
@@ -2586,7 +2892,7 @@ async function raceRecallAbort(promise, signal, message = "recall aborted") {
2586
2892
  }
2587
2893
  }
2588
2894
  function qmdCollectionPathParts(resultPath) {
2589
- if (!resultPath || path3.isAbsolute(resultPath)) return null;
2895
+ if (!resultPath || path4.isAbsolute(resultPath)) return null;
2590
2896
  const normalized = resultPath.replace(/\\/g, "/").replace(/^\/+/, "");
2591
2897
  const slashIndex = normalized.indexOf("/");
2592
2898
  if (slashIndex <= 0 || slashIndex >= normalized.length - 1) return null;
@@ -2599,9 +2905,9 @@ function qmdCollectionPathParts(resultPath) {
2599
2905
  }
2600
2906
  function qmdResultPathCandidates(storageDir, resultPath) {
2601
2907
  const candidates = /* @__PURE__ */ new Set();
2602
- const storageRoot = path3.resolve(storageDir);
2908
+ const storageRoot = path4.resolve(storageDir);
2603
2909
  const addCandidate = (candidate) => {
2604
- const resolved = path3.resolve(candidate);
2910
+ const resolved = path4.resolve(candidate);
2605
2911
  if (isPathInsideStorageRoot(storageRoot, resolved)) {
2606
2912
  candidates.add(resolved);
2607
2913
  }
@@ -2609,12 +2915,12 @@ function qmdResultPathCandidates(storageDir, resultPath) {
2609
2915
  const addRelativeCandidates = (relativePath) => {
2610
2916
  const normalized = relativePath.replace(/\\/g, "/").replace(/^\/+/, "");
2611
2917
  if (!normalized) return;
2612
- addCandidate(path3.join(storageRoot, normalized));
2918
+ addCandidate(path4.join(storageRoot, normalized));
2613
2919
  if (/^\d{4}-\d{2}-\d{2}\//.test(normalized)) {
2614
- addCandidate(path3.join(storageRoot, "facts", normalized));
2920
+ addCandidate(path4.join(storageRoot, "facts", normalized));
2615
2921
  }
2616
2922
  };
2617
- if (path3.isAbsolute(resultPath)) {
2923
+ if (path4.isAbsolute(resultPath)) {
2618
2924
  addCandidate(resultPath);
2619
2925
  } else {
2620
2926
  addRelativeCandidates(resultPath);
@@ -2731,7 +3037,7 @@ async function qmdStartupCollectionCheckWithTimeout(promise, controller, label)
2731
3037
  return await Promise.race([checkedPromise, timeoutPromise]);
2732
3038
  }
2733
3039
  function defaultWorkspaceDir() {
2734
- return path3.join(os2.homedir(), ".openclaw", "workspace");
3040
+ return path4.join(os2.homedir(), ".openclaw", "workspace");
2735
3041
  }
2736
3042
  function sanitizeSessionKeyForFilename(sessionKey) {
2737
3043
  const readable = sessionKey.replace(/[^a-zA-Z0-9._-]/g, "_");
@@ -3024,11 +3330,11 @@ function mergeGraphExpandedResults(primary, expanded) {
3024
3330
  return Array.from(mergedByPath.values());
3025
3331
  }
3026
3332
  function graphPathRelativeToStorage(storageDir, candidatePath) {
3027
- const absolutePath = path3.isAbsolute(candidatePath) ? candidatePath : path3.resolve(storageDir, candidatePath);
3028
- const rel = path3.relative(storageDir, absolutePath);
3333
+ const absolutePath = path4.isAbsolute(candidatePath) ? candidatePath : path4.resolve(storageDir, candidatePath);
3334
+ const rel = path4.relative(storageDir, absolutePath);
3029
3335
  if (!rel || rel === ".") return null;
3030
3336
  if (rel.startsWith("..")) return null;
3031
- return rel.split(path3.sep).join("/");
3337
+ return rel.split(path4.sep).join("/");
3032
3338
  }
3033
3339
  function normalizeGraphActivationScore(score) {
3034
3340
  const bounded = Number.isFinite(score) && score > 0 ? score : 0;
@@ -3173,7 +3479,7 @@ function buildMemoryPathById(allMemsForGraph, storageDir) {
3173
3479
  for (const mem of allMemsForGraph ?? []) {
3174
3480
  const id = mem.frontmatter.id;
3175
3481
  if (!id) continue;
3176
- pathById.set(id, path3.relative(storageDir, mem.path));
3482
+ pathById.set(id, path4.relative(storageDir, mem.path));
3177
3483
  }
3178
3484
  return pathById;
3179
3485
  }
@@ -3181,7 +3487,7 @@ function appendMemoryToGraphContext(options) {
3181
3487
  if (!Array.isArray(options.allMemsForGraph)) return;
3182
3488
  const nowIso = (/* @__PURE__ */ new Date()).toISOString();
3183
3489
  options.allMemsForGraph.push({
3184
- path: path3.join(options.storageDir, options.memoryRelPath),
3490
+ path: path4.join(options.storageDir, options.memoryRelPath),
3185
3491
  content: options.content,
3186
3492
  frontmatter: {
3187
3493
  id: options.memoryId,
@@ -3201,16 +3507,16 @@ function resolvePersistedMemoryRelativePath(options) {
3201
3507
  const persisted = options.pathById.get(options.memoryId);
3202
3508
  if (persisted) return persisted;
3203
3509
  if (options.category === "correction") {
3204
- return path3.join("corrections", `${options.memoryId}.md`);
3510
+ return path4.join("corrections", `${options.memoryId}.md`);
3205
3511
  }
3206
3512
  const subtree = categoryDirName(options.category);
3207
3513
  const idParts = options.memoryId.split("-");
3208
3514
  const maybeTimestamp = Number(idParts[1]);
3209
3515
  if (Number.isFinite(maybeTimestamp) && maybeTimestamp > 0) {
3210
3516
  const day = new Date(maybeTimestamp).toISOString().slice(0, 10);
3211
- return path3.join(subtree, day, `${options.memoryId}.md`);
3517
+ return path4.join(subtree, day, `${options.memoryId}.md`);
3212
3518
  }
3213
- return path3.join(subtree, `${options.memoryId}.md`);
3519
+ return path4.join(subtree, `${options.memoryId}.md`);
3214
3520
  }
3215
3521
  var Orchestrator = class _Orchestrator {
3216
3522
  storage;
@@ -3290,6 +3596,7 @@ var Orchestrator = class _Orchestrator {
3290
3596
  tierMigrationCoordinator;
3291
3597
  compressionGuidelineCoordinator;
3292
3598
  semanticConsolidationCoordinator;
3599
+ lifecyclePolicyCoordinator;
3293
3600
  /**
3294
3601
  * In-memory X-ray snapshot from the most recent `recall()` call that
3295
3602
  * was invoked with `xrayCapture: true` (issue #570 PR 1). Scope is
@@ -3671,7 +3978,7 @@ var Orchestrator = class _Orchestrator {
3671
3978
  const defaultNs = normalizeNamespaceIdentity(this.config.defaultNamespace);
3672
3979
  if (ns !== defaultNs && !isSafeRouteNamespace(ns)) return;
3673
3980
  if (!this.storageDirMatchesNamespaceHint(ns, storageDir)) return;
3674
- const resolvedStorageDir = path3.resolve(storageDir);
3981
+ const resolvedStorageDir = path4.resolve(storageDir);
3675
3982
  let hints = this.namespaceStorageDirHints.get(resolvedStorageDir);
3676
3983
  if (!hints) {
3677
3984
  hints = /* @__PURE__ */ new Set();
@@ -3682,21 +3989,21 @@ var Orchestrator = class _Orchestrator {
3682
3989
  storageDirMatchesNamespaceHint(namespace, storageDir) {
3683
3990
  const ns = normalizeNamespaceIdentity(namespace);
3684
3991
  if (!ns) return false;
3685
- const resolvedStorageDir = path3.resolve(storageDir);
3686
- const resolvedMemoryDir = path3.resolve(this.config.memoryDir);
3992
+ const resolvedStorageDir = path4.resolve(storageDir);
3993
+ const resolvedMemoryDir = path4.resolve(this.config.memoryDir);
3687
3994
  const defaultNs = normalizeNamespaceIdentity(this.config.defaultNamespace);
3688
3995
  if (resolvedStorageDir === resolvedMemoryDir) return ns === defaultNs;
3689
- const resolvedNamespacesDir = path3.join(resolvedMemoryDir, "namespaces");
3996
+ const resolvedNamespacesDir = path4.join(resolvedMemoryDir, "namespaces");
3690
3997
  if (!isPathInsideStorageRoot(resolvedNamespacesDir, resolvedStorageDir)) return false;
3691
- const rawRoot = path3.resolve(resolvedNamespacesDir, ns);
3692
- const tokenRoot = path3.resolve(resolvedNamespacesDir, namespaceIdentityToken(ns));
3998
+ const rawRoot = path4.resolve(resolvedNamespacesDir, ns);
3999
+ const tokenRoot = path4.resolve(resolvedNamespacesDir, namespaceIdentityToken(ns));
3693
4000
  return resolvedStorageDir === rawRoot || resolvedStorageDir === tokenRoot;
3694
4001
  }
3695
4002
  namespaceStorageDirHintOwnershipRank(record, resolvedStorageDir, configured) {
3696
- if (resolvedStorageDir === path3.resolve(this.config.memoryDir)) {
4003
+ if (resolvedStorageDir === path4.resolve(this.config.memoryDir)) {
3697
4004
  return record.namespace === normalizeNamespaceIdentity(this.config.defaultNamespace) ? 0 : 3;
3698
4005
  }
3699
- const leaf = path3.basename(resolvedStorageDir);
4006
+ const leaf = path4.basename(resolvedStorageDir);
3700
4007
  const tokenOwnsRoot = namespaceIdentityToken(record.namespace) === leaf;
3701
4008
  if (tokenOwnsRoot && configured.has(record.namespace)) return 0;
3702
4009
  if (record.namespace === leaf) return 1;
@@ -3724,7 +4031,7 @@ var Orchestrator = class _Orchestrator {
3724
4031
  loadNamespaceStorageDirHintsFromCatalog() {
3725
4032
  if (this.namespaceStorageDirHintsLoaded || !this.namespaceCatalog.enabled) return;
3726
4033
  this.namespaceStorageDirHintsLoaded = true;
3727
- const catalogPath = path3.join(this.config.memoryDir, "state", "namespaces.jsonl");
4034
+ const catalogPath = path4.join(this.config.memoryDir, "state", "namespaces.jsonl");
3728
4035
  if (!existsSync(catalogPath)) return;
3729
4036
  let body;
3730
4037
  try {
@@ -3761,7 +4068,7 @@ var Orchestrator = class _Orchestrator {
3761
4068
  if (!this.storageDirMatchesNamespaceHint(record.namespace, record.storageDir)) {
3762
4069
  continue;
3763
4070
  }
3764
- const resolvedStorageDir = path3.resolve(record.storageDir);
4071
+ const resolvedStorageDir = path4.resolve(record.storageDir);
3765
4072
  const current = preferredByStorageDir.get(resolvedStorageDir);
3766
4073
  preferredByStorageDir.set(
3767
4074
  resolvedStorageDir,
@@ -4025,7 +4332,7 @@ var Orchestrator = class _Orchestrator {
4025
4332
  this.config = config;
4026
4333
  this.profiler = new ProfilingCollector({
4027
4334
  enabled: config.profilingEnabled,
4028
- storageDir: config.profilingStorageDir || path3.join(config.memoryDir, "profiling"),
4335
+ storageDir: config.profilingStorageDir || path4.join(config.memoryDir, "profiling"),
4029
4336
  maxTraces: config.profilingMaxTraces
4030
4337
  });
4031
4338
  this.namespaceCatalog = new NamespaceCatalog(config);
@@ -4094,7 +4401,7 @@ var Orchestrator = class _Orchestrator {
4094
4401
  this.compounding = config.compoundingEnabled ? new CompoundingEngine(config, this.storage) : void 0;
4095
4402
  this.buffer = new SmartBuffer(config, this.storage);
4096
4403
  this.transcript = new TranscriptManager(config);
4097
- this.conversationIndexDir = path3.join(
4404
+ this.conversationIndexDir = path4.join(
4098
4405
  config.memoryDir,
4099
4406
  "conversation-index",
4100
4407
  "chunks"
@@ -4174,8 +4481,17 @@ var Orchestrator = class _Orchestrator {
4174
4481
  config.gatewayConfig,
4175
4482
  this.modelRegistry
4176
4483
  );
4484
+ this.lifecyclePolicyCoordinator = new LifecyclePolicyCoordinator({
4485
+ config,
4486
+ getStorage: () => this.storage,
4487
+ extraction: this.extraction,
4488
+ embeddingFallback: this.embeddingFallback,
4489
+ getEffectiveLifecycleThresholds: () => this.effectiveLifecycleThresholds(),
4490
+ removeContentHashForMemory: (targetStorage, memory, context) => this.removeContentHashForMemory(targetStorage, memory, context),
4491
+ saveContentHashIndexes: () => this.saveContentHashIndexes()
4492
+ });
4177
4493
  this.threading = new ThreadingManager(
4178
- path3.join(config.memoryDir, "threads"),
4494
+ path4.join(config.memoryDir, "threads"),
4179
4495
  config.threadingGapMinutes
4180
4496
  );
4181
4497
  const lifecycleCaps = resolveMemoryLifecycleCapabilities(config);
@@ -4466,8 +4782,8 @@ var Orchestrator = class _Orchestrator {
4466
4782
  this.runtimePolicyValues = await this.policyRuntime.loadRuntimeValues();
4467
4783
  this.utilityRuntimeValues = await loadUtilityRuntimeValues({
4468
4784
  memoryDir: this.config.memoryDir,
4469
- memoryUtilityLearningEnabled: this.config.memoryUtilityLearningEnabled,
4470
- promotionByOutcomeEnabled: this.config.promotionByOutcomeEnabled
4785
+ memoryUtilityLearningEnabled: resolveUtilityLearningCapabilities(this.config).memoryUtilityLearning,
4786
+ promotionByOutcomeEnabled: resolveUtilityLearningCapabilities(this.config).promotionByOutcome
4471
4787
  });
4472
4788
  if (this.config.factDeduplicationEnabled) {
4473
4789
  this.contentHashIndex = this.storage.createContentHashIndex();
@@ -4498,7 +4814,7 @@ var Orchestrator = class _Orchestrator {
4498
4814
  const files = await readdir(wsDir).catch(() => []);
4499
4815
  for (const f of files) {
4500
4816
  if (!f.startsWith(".compaction-reset-signal-")) continue;
4501
- const fp = path3.join(wsDir, f);
4817
+ const fp = path4.join(wsDir, f);
4502
4818
  const s = await stat(fp).catch(() => null);
4503
4819
  if (s && Date.now() - s.mtimeMs >= COMPACTION_SIGNAL_MAX_AGE_MS) {
4504
4820
  await unlink(fp).catch(() => {
@@ -4693,7 +5009,7 @@ var Orchestrator = class _Orchestrator {
4693
5009
  if (signal.aborted) return;
4694
5010
  if (lifecycleCaps.lifecyclePolicy && resolveQmdCapabilities(this.config).qmdTierMigration) {
4695
5011
  try {
4696
- const { runFirstStartMigration } = await import("./first-start-migration-W4U6XDKI.js");
5012
+ const { runFirstStartMigration } = await import("./first-start-migration-2RQYDIZ7.js");
4697
5013
  const result = await runFirstStartMigration({
4698
5014
  storage: this.storage,
4699
5015
  config: this.config,
@@ -5007,15 +5323,15 @@ ${doc.content}` : doc.content,
5007
5323
  this.lastFileHygieneRunAtMs = now;
5008
5324
  if (hygiene.rotateEnabled) {
5009
5325
  for (const rel of hygiene.rotatePaths) {
5010
- const abs = path3.isAbsolute(rel) ? rel : path3.join(this.config.workspaceDir, rel);
5326
+ const abs = path4.isAbsolute(rel) ? rel : path4.join(this.config.workspaceDir, rel);
5011
5327
  try {
5012
5328
  const raw = await readFile2(abs, "utf-8");
5013
5329
  if (raw.length > hygiene.rotateMaxBytes) {
5014
- const archiveDir = path3.join(
5330
+ const archiveDir = path4.join(
5015
5331
  this.config.workspaceDir,
5016
5332
  hygiene.archiveDir
5017
5333
  );
5018
- const base = path3.basename(abs);
5334
+ const base = path4.basename(abs);
5019
5335
  const prefix = base.toUpperCase().replace(/\.MD$/i, "").replace(/[^A-Z0-9]+/g, "-") || "FILE";
5020
5336
  const { newContent } = await rotateMarkdownFileToArchive({
5021
5337
  filePath: abs,
@@ -5023,7 +5339,7 @@ ${doc.content}` : doc.content,
5023
5339
  archivePrefix: prefix,
5024
5340
  keepTailChars: hygiene.rotateKeepTailChars
5025
5341
  });
5026
- await writeFile2(abs, newContent, "utf-8");
5342
+ await writeFile3(abs, newContent, "utf-8");
5027
5343
  }
5028
5344
  } catch {
5029
5345
  }
@@ -5040,8 +5356,8 @@ ${doc.content}` : doc.content,
5040
5356
  log.warn(w.message);
5041
5357
  }
5042
5358
  if (hygiene.warningsLogEnabled && warnings.length > 0) {
5043
- const fp = path3.join(this.config.memoryDir, hygiene.warningsLogPath);
5044
- await mkdir2(path3.dirname(fp), { recursive: true });
5359
+ const fp = path4.join(this.config.memoryDir, hygiene.warningsLogPath);
5360
+ await mkdir3(path4.dirname(fp), { recursive: true });
5045
5361
  const stamp = (/* @__PURE__ */ new Date()).toISOString();
5046
5362
  const block = `
5047
5363
 
@@ -5054,7 +5370,7 @@ ${doc.content}` : doc.content,
5054
5370
  } catch {
5055
5371
  existing = "# Engram File Hygiene Warnings\n";
5056
5372
  }
5057
- await writeFile2(fp, existing + block, "utf-8");
5373
+ await writeFile3(fp, existing + block, "utf-8");
5058
5374
  }
5059
5375
  }
5060
5376
  }
@@ -5287,7 +5603,7 @@ ${evidenceText}`
5287
5603
  for (const categoryDir of RECALL_FALLBACK_DIRS) {
5288
5604
  if (memoryRootReal === null) break;
5289
5605
  for (const date of datesToScan) {
5290
- const dateDir = path3.join(storage.dir, categoryDir, date);
5606
+ const dateDir = path4.join(storage.dir, categoryDir, date);
5291
5607
  try {
5292
5608
  const dirStat = await lstat(dateDir);
5293
5609
  if (dirStat.isSymbolicLink() || !dirStat.isDirectory()) continue;
@@ -5296,7 +5612,7 @@ ${evidenceText}`
5296
5612
  for (const entry of entries) {
5297
5613
  if (entry.isSymbolicLink()) continue;
5298
5614
  if (!entry.name.endsWith(".md")) continue;
5299
- const fullPath = path3.join(dateDir, entry.name);
5615
+ const fullPath = path4.join(dateDir, entry.name);
5300
5616
  try {
5301
5617
  assertPathInsideRoot(memoryRootReal, await realpath(fullPath), fullPath);
5302
5618
  const raw = await readFile2(fullPath, "utf-8");
@@ -5318,7 +5634,7 @@ ${evidenceText}`
5318
5634
  facts.push({
5319
5635
  path: fullPath,
5320
5636
  frontmatter: {
5321
- id: fm.id || path3.basename(entry.name, ".md"),
5637
+ id: fm.id || path4.basename(entry.name, ".md"),
5322
5638
  category: fm.category || "fact",
5323
5639
  created,
5324
5640
  updated: fm.updated || created,
@@ -5341,13 +5657,13 @@ ${evidenceText}`
5341
5657
  return a.frontmatter.created < b.frontmatter.created ? -1 : 1;
5342
5658
  });
5343
5659
  const hourlySummaries = [];
5344
- const hourlyBaseDir = path3.join(storage.dir, "summaries", "hourly");
5660
+ const hourlyBaseDir = path4.join(storage.dir, "summaries", "hourly");
5345
5661
  try {
5346
5662
  const sessionKeys = await readdir(hourlyBaseDir, { withFileTypes: true });
5347
5663
  for (const sk of sessionKeys) {
5348
5664
  if (!sk.isDirectory()) continue;
5349
5665
  for (const date of datesToScan) {
5350
- const summaryFile = path3.join(hourlyBaseDir, sk.name, `${date}.md`);
5666
+ const summaryFile = path4.join(hourlyBaseDir, sk.name, `${date}.md`);
5351
5667
  try {
5352
5668
  const raw = await readFile2(summaryFile, "utf-8");
5353
5669
  const filtered = filterHourlySummaryMarkdownForLocalDay(
@@ -5395,7 +5711,7 @@ ${evidenceText}`
5395
5711
  action: event.action,
5396
5712
  eligibility,
5397
5713
  options: {
5398
- actionsEnabled: this.config.contextCompressionActionsEnabled,
5714
+ actionsEnabled: resolveCompressionCapabilities(this.config).contextCompressionActions,
5399
5715
  maxCompressionTokensPerHour: this.config.maxCompressionTokensPerHour
5400
5716
  }
5401
5717
  });
@@ -5451,7 +5767,7 @@ ${evidenceText}`
5451
5767
  }
5452
5768
  async getLastGraphRecallSnapshot(namespace) {
5453
5769
  const storage = await this.getStorage(namespace);
5454
- const snapshotPath = path3.join(
5770
+ const snapshotPath = path4.join(
5455
5771
  storage.dir,
5456
5772
  "state",
5457
5773
  "last_graph_recall.json"
@@ -5490,7 +5806,7 @@ ${evidenceText}`
5490
5806
  }
5491
5807
  async getLastIntentSnapshot(namespace) {
5492
5808
  const storage = await this.getStorage(namespace);
5493
- const snapshotPath = path3.join(storage.dir, "state", "last_intent.json");
5809
+ const snapshotPath = path4.join(storage.dir, "state", "last_intent.json");
5494
5810
  try {
5495
5811
  const raw = await readFile2(snapshotPath, "utf-8");
5496
5812
  const parsed = JSON.parse(raw);
@@ -5523,7 +5839,7 @@ ${evidenceText}`
5523
5839
  }
5524
5840
  async getLastQmdRecallSnapshot(namespace) {
5525
5841
  const storage = await this.getStorage(namespace);
5526
- const snapshotPath = path3.join(
5842
+ const snapshotPath = path4.join(
5527
5843
  storage.dir,
5528
5844
  "state",
5529
5845
  "last_qmd_recall.json"
@@ -5676,7 +5992,7 @@ ${r.snippet.trim()}
5676
5992
  const entries = await readdir(dir, { withFileTypes: true });
5677
5993
  let total = 0;
5678
5994
  for (const entry of entries) {
5679
- const fullPath = path3.join(dir, entry.name);
5995
+ const fullPath = path4.join(dir, entry.name);
5680
5996
  if (entry.isDirectory()) {
5681
5997
  total += await this.countConversationChunkDocs(fullPath);
5682
5998
  continue;
@@ -6582,7 +6898,7 @@ ${r.snippet.trim()}
6582
6898
  resolvedPath = resolvedCold.result.path;
6583
6899
  resolvedResult = resolvedCold.result;
6584
6900
  }
6585
- if (!path3.isAbsolute(resolvedPath)) {
6901
+ if (!path4.isAbsolute(resolvedPath)) {
6586
6902
  resolvedAmbiguousSeeds.set(result.path, null);
6587
6903
  return null;
6588
6904
  }
@@ -6607,7 +6923,7 @@ ${r.snippet.trim()}
6607
6923
  }
6608
6924
  continue;
6609
6925
  }
6610
- if (path3.isAbsolute(result.path)) {
6926
+ if (path4.isAbsolute(result.path)) {
6611
6927
  const resolved = await resolveAmbiguousSeedOwner(result, null);
6612
6928
  if (resolved) {
6613
6929
  addResultForNamespace(resolved.namespace, resolved.result);
@@ -6650,7 +6966,7 @@ ${r.snippet.trim()}
6650
6966
  0
6651
6967
  );
6652
6968
  seedPaths.push(
6653
- ...seedRelativePaths.map((rel) => path3.join(storage.dir, rel))
6969
+ ...seedRelativePaths.map((rel) => path4.join(storage.dir, rel))
6654
6970
  );
6655
6971
  const seedSet = new Set(seedRelativePaths);
6656
6972
  const expanded = await this.graphIndexFor(storage).spreadingActivation(
@@ -6666,7 +6982,7 @@ ${r.snippet.trim()}
6666
6982
  for (const candidate of expanded.slice(0, perNamespaceExpandedCap)) {
6667
6983
  if (deadlineExpired()) break;
6668
6984
  if (seedSet.has(candidate.path)) continue;
6669
- const memoryPath = path3.resolve(storage.dir, candidate.path);
6985
+ const memoryPath = path4.resolve(storage.dir, candidate.path);
6670
6986
  const memory = await storage.readMemoryByPath(memoryPath);
6671
6987
  if (deadlineExpired()) break;
6672
6988
  if (!memory) continue;
@@ -6691,7 +7007,7 @@ ${r.snippet.trim()}
6691
7007
  path: memory.path,
6692
7008
  score,
6693
7009
  namespace,
6694
- seed: path3.resolve(storage.dir, candidate.seed),
7010
+ seed: path4.resolve(storage.dir, candidate.seed),
6695
7011
  hopDepth: candidate.hopDepth,
6696
7012
  decayedWeight: candidate.decayedWeight,
6697
7013
  graphType: candidate.graphType,
@@ -6712,12 +7028,12 @@ ${r.snippet.trim()}
6712
7028
  }
6713
7029
  async recordLastGraphRecallSnapshot(options) {
6714
7030
  try {
6715
- const snapshotPath = path3.join(
7031
+ const snapshotPath = path4.join(
6716
7032
  options.storage.dir,
6717
7033
  "state",
6718
7034
  "last_graph_recall.json"
6719
7035
  );
6720
- await mkdir2(path3.dirname(snapshotPath), { recursive: true });
7036
+ await mkdir3(path4.dirname(snapshotPath), { recursive: true });
6721
7037
  const now = (/* @__PURE__ */ new Date()).toISOString();
6722
7038
  const totalSeedCount = options.seedPaths.length;
6723
7039
  const totalExpandedCount = options.expandedPaths.length;
@@ -6744,20 +7060,20 @@ ${r.snippet.trim()}
6744
7060
  finalResults: (options.finalResults ?? []).slice(0, 64),
6745
7061
  shadowComparison: options.shadowComparison
6746
7062
  };
6747
- await writeFile2(snapshotPath, JSON.stringify(payload, null, 2), "utf-8");
7063
+ await writeFile3(snapshotPath, JSON.stringify(payload, null, 2), "utf-8");
6748
7064
  } catch (err) {
6749
7065
  log.debug(`last graph recall write failed: ${err}`);
6750
7066
  }
6751
7067
  }
6752
7068
  async recordLastIntentSnapshot(options) {
6753
7069
  try {
6754
- const snapshotPath = path3.join(
7070
+ const snapshotPath = path4.join(
6755
7071
  options.storage.dir,
6756
7072
  "state",
6757
7073
  "last_intent.json"
6758
7074
  );
6759
- await mkdir2(path3.dirname(snapshotPath), { recursive: true });
6760
- await writeFile2(
7075
+ await mkdir3(path4.dirname(snapshotPath), { recursive: true });
7076
+ await writeFile3(
6761
7077
  snapshotPath,
6762
7078
  JSON.stringify(options.snapshot, null, 2),
6763
7079
  "utf-8"
@@ -6768,13 +7084,13 @@ ${r.snippet.trim()}
6768
7084
  }
6769
7085
  async recordLastQmdRecallSnapshot(options) {
6770
7086
  try {
6771
- const snapshotPath = path3.join(
7087
+ const snapshotPath = path4.join(
6772
7088
  options.storage.dir,
6773
7089
  "state",
6774
7090
  "last_qmd_recall.json"
6775
7091
  );
6776
- await mkdir2(path3.dirname(snapshotPath), { recursive: true });
6777
- await writeFile2(
7092
+ await mkdir3(path4.dirname(snapshotPath), { recursive: true });
7093
+ await writeFile3(
6778
7094
  snapshotPath,
6779
7095
  JSON.stringify(options.snapshot, null, 2),
6780
7096
  "utf-8"
@@ -6788,9 +7104,9 @@ ${r.snippet.trim()}
6788
7104
  const stateDir = await this.resolveStateDirForNamespace(
6789
7105
  options.namespace
6790
7106
  );
6791
- const snapshotPath = path3.join(stateDir, "last_intent.json");
6792
- await mkdir2(path3.dirname(snapshotPath), { recursive: true });
6793
- await writeFile2(
7107
+ const snapshotPath = path4.join(stateDir, "last_intent.json");
7108
+ await mkdir3(path4.dirname(snapshotPath), { recursive: true });
7109
+ await writeFile3(
6794
7110
  snapshotPath,
6795
7111
  JSON.stringify(options.snapshot, null, 2),
6796
7112
  "utf-8"
@@ -6801,12 +7117,12 @@ ${r.snippet.trim()}
6801
7117
  }
6802
7118
  async resolveStateDirForNamespace(namespace) {
6803
7119
  if (!resolveNamespaceCapabilities(this.config).namespaces) {
6804
- return path3.join(this.config.memoryDir, "state");
7120
+ return path4.join(this.config.memoryDir, "state");
6805
7121
  }
6806
7122
  if (namespace !== this.config.defaultNamespace) {
6807
- return path3.join(this.config.memoryDir, "namespaces", namespace, "state");
7123
+ return path4.join(this.config.memoryDir, "namespaces", namespace, "state");
6808
7124
  }
6809
- const candidate = path3.join(
7125
+ const candidate = path4.join(
6810
7126
  this.config.memoryDir,
6811
7127
  "namespaces",
6812
7128
  this.config.defaultNamespace
@@ -6814,11 +7130,11 @@ ${r.snippet.trim()}
6814
7130
  try {
6815
7131
  const candidateStat = await stat(candidate);
6816
7132
  if (candidateStat.isDirectory()) {
6817
- return path3.join(candidate, "state");
7133
+ return path4.join(candidate, "state");
6818
7134
  }
6819
7135
  } catch {
6820
7136
  }
6821
- return path3.join(this.config.memoryDir, "state");
7137
+ return path4.join(this.config.memoryDir, "state");
6822
7138
  }
6823
7139
  buildGraphRecallRankedResults(results, sourceLabelResolver, limit = 64) {
6824
7140
  return results.slice(0, limit).map((result) => ({
@@ -7220,7 +7536,7 @@ ${r.snippet.trim()}
7220
7536
  const graphExpandedResultPaths = /* @__PURE__ */ new Set();
7221
7537
  const graphSourceLabelsForPath = (resultPath) => {
7222
7538
  const labels = [];
7223
- const normalizedPath = resultPath.split(path3.sep).join("/");
7539
+ const normalizedPath = resultPath.split(path4.sep).join("/");
7224
7540
  const isEntityPath = normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/");
7225
7541
  if (graphBaselinePaths.has(resultPath)) labels.push("baseline");
7226
7542
  if (graphExpandedResultPaths.has(resultPath))
@@ -7370,7 +7686,7 @@ ${r.snippet.trim()}
7370
7686
  profileStorageNamespaces.map((namespace) => this.storageRouter.storageFor(namespace))
7371
7687
  );
7372
7688
  const emptyProfileStorage = new Proxy(
7373
- { dir: path3.join(this.config.memoryDir, ".empty-scope-profile") },
7689
+ { dir: path4.join(this.config.memoryDir, ".empty-scope-profile") },
7374
7690
  {
7375
7691
  get(target, prop) {
7376
7692
  if (prop in target) return target[prop];
@@ -7852,9 +8168,9 @@ ${rows.join("\n")}
7852
8168
  })();
7853
8169
  const objectiveStatePromise = (async () => {
7854
8170
  const t0 = Date.now();
7855
- if (!this.config.objectiveStateMemoryEnabled || !this.config.objectiveStateRecallEnabled || !this.isRecallSectionEnabled(
8171
+ if (!resolveObjectiveStateCapabilities(this.config).objectiveStateMemory || !resolveObjectiveStateCapabilities(this.config).objectiveStateRecall || !this.isRecallSectionEnabled(
7856
8172
  "objective-state",
7857
- this.config.objectiveStateRecallEnabled === true
8173
+ resolveObjectiveStateCapabilities(this.config).objectiveStateRecall === true
7858
8174
  )) {
7859
8175
  recordRecallSectionMetric({
7860
8176
  section: "objectiveState",
@@ -8073,9 +8389,9 @@ ${rows.join("\n")}
8073
8389
  })();
8074
8390
  const trustZonePromise = (async () => {
8075
8391
  const t0 = Date.now();
8076
- if (!this.config.trustZonesEnabled || !this.config.trustZoneRecallEnabled || !this.isRecallSectionEnabled(
8392
+ if (!resolveSecurityCapabilities(this.config).trustZones || !resolveSecurityCapabilities(this.config).trustZoneRecall || !this.isRecallSectionEnabled(
8077
8393
  "trust-zones",
8078
- this.config.trustZoneRecallEnabled === true
8394
+ resolveSecurityCapabilities(this.config).trustZoneRecall === true
8079
8395
  )) {
8080
8396
  recordRecallSectionMetric({
8081
8397
  section: "trustZones",
@@ -8846,11 +9162,11 @@ ${formatted}`;
8846
9162
  if (!this.config.compactionResetEnabled) return null;
8847
9163
  const workspaceDir = compactionWorkspaceDir || this.config.workspaceDir || defaultWorkspaceDir();
8848
9164
  const safeSessionKey = sanitizeSessionKeyForFilename(effectiveSessionKey);
8849
- const signalPath = path3.join(
9165
+ const signalPath = path4.join(
8850
9166
  workspaceDir,
8851
9167
  `.compaction-reset-signal-${safeSessionKey}`
8852
9168
  );
8853
- const bootPath = path3.join(workspaceDir, "BOOT.md");
9169
+ const bootPath = path4.join(workspaceDir, "BOOT.md");
8854
9170
  try {
8855
9171
  const signalStat = await stat(signalPath).catch(() => null);
8856
9172
  if (!signalStat) return null;
@@ -10535,7 +10851,7 @@ ${tmtNode.summary}`
10535
10851
  });
10536
10852
  if (this.isRecallSectionEnabled(
10537
10853
  "compression-guidelines",
10538
- this.config.compressionGuidelineLearningEnabled === true
10854
+ resolveCompressionCapabilities(this.config).compressionGuidelineLearning === true
10539
10855
  )) {
10540
10856
  const compressionGuidelineSection = await this.buildCompressionGuidelineRecallSection();
10541
10857
  if (compressionGuidelineSection) {
@@ -13452,7 +13768,7 @@ ${normalized}`).digest("hex");
13452
13768
  const allMems = allMemsForGraph ?? [];
13453
13769
  for (const m of allMems) {
13454
13770
  if (m.frontmatter.entityRef === entityRef) {
13455
- const rel = path3.relative(storage.dir, m.path);
13771
+ const rel = path4.relative(storage.dir, m.path);
13456
13772
  if (rel !== memoryRelPath) entitySiblings.push(rel);
13457
13773
  }
13458
13774
  }
@@ -13776,7 +14092,7 @@ ${normalized}`).digest("hex");
13776
14092
  }
13777
14093
  if (this.config.semanticConsolidationEnabled) {
13778
14094
  try {
13779
- const stateFilePath = path3.join(
14095
+ const stateFilePath = path4.join(
13780
14096
  this.config.memoryDir,
13781
14097
  "state",
13782
14098
  "semantic-consolidation-last-run.json"
@@ -13824,9 +14140,9 @@ ${normalized}`).digest("hex");
13824
14140
  );
13825
14141
  }
13826
14142
  if (semResult.errors === 0 || semResult.memoriesArchived > 0) {
13827
- const stateDir = path3.join(this.config.memoryDir, "state");
13828
- await mkdir2(stateDir, { recursive: true });
13829
- await writeFile2(
14143
+ const stateDir = path4.join(this.config.memoryDir, "state");
14144
+ await mkdir3(stateDir, { recursive: true });
14145
+ await writeFile3(
13830
14146
  stateFilePath,
13831
14147
  JSON.stringify({ lastRunAt: (/* @__PURE__ */ new Date()).toISOString() }),
13832
14148
  "utf-8"
@@ -13951,65 +14267,6 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
13951
14267
  async buildCompressionGuidelineRecallSection() {
13952
14268
  return this.compressionGuidelineCoordinator.buildCompressionGuidelineRecallSection();
13953
14269
  }
13954
- actionOutcomePriorDelta(event) {
13955
- if (event.outcome === "failed") return -0.3;
13956
- if (event.policyDecision === "deny") return -0.22;
13957
- if (event.policyDecision === "defer") return -0.14;
13958
- if (event.outcome === "skipped") return -0.1;
13959
- if (event.outcome !== "applied") return 0;
13960
- switch (event.action) {
13961
- case "store_episode":
13962
- case "store_note":
13963
- case "update_note":
13964
- return 0.08;
13965
- case "create_artifact":
13966
- case "summarize_node":
13967
- case "link_graph":
13968
- return 0.04;
13969
- case "discard":
13970
- return -0.03;
13971
- default:
13972
- return 0;
13973
- }
13974
- }
13975
- async buildLifecycleActionPriors(storage = this.storage) {
13976
- const events = await storage.readMemoryActionEvents(1200);
13977
- if (events.length === 0) return /* @__PURE__ */ new Map();
13978
- const nowMs = Date.now();
13979
- const windowMs = 14 * 24 * 60 * 60 * 1e3;
13980
- const byMemory = /* @__PURE__ */ new Map();
13981
- for (const event of events) {
13982
- if (typeof event.memoryId !== "string" || event.memoryId.trim().length === 0)
13983
- continue;
13984
- const ts = Date.parse(event.timestamp);
13985
- if (!Number.isFinite(ts)) continue;
13986
- const ageMs = nowMs - ts;
13987
- if (ageMs < 0 || ageMs > windowMs) continue;
13988
- const delta = this.actionOutcomePriorDelta(event);
13989
- if (delta === 0) continue;
13990
- const recencyWeight = Math.max(0.2, 1 - ageMs / windowMs);
13991
- const list = byMemory.get(event.memoryId) ?? [];
13992
- if (list.length >= 8) list.shift();
13993
- list.push({
13994
- weightedDelta: delta * recencyWeight,
13995
- weight: recencyWeight
13996
- });
13997
- byMemory.set(event.memoryId, list);
13998
- }
13999
- const out = /* @__PURE__ */ new Map();
14000
- for (const [memoryId, deltas] of byMemory.entries()) {
14001
- if (deltas.length === 0) continue;
14002
- const weightedSum = deltas.reduce(
14003
- (sum, item) => sum + item.weightedDelta,
14004
- 0
14005
- );
14006
- const weightTotal = deltas.reduce((sum, item) => sum + item.weight, 0);
14007
- if (weightTotal <= 0) continue;
14008
- const score = weightedSum / weightTotal;
14009
- out.set(memoryId, Math.max(-0.25, Math.min(0.15, score)));
14010
- }
14011
- return out;
14012
- }
14013
14270
  async recordScheduledDreamsPhaseRun(phase, itemsProcessed, notes, timing = {}) {
14014
14271
  try {
14015
14272
  const { recordDreamsPhaseRun } = await import("./dreams-ledger-6UODQOX6.js");
@@ -14033,215 +14290,16 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
14033
14290
  return { memoriesAssessed: lifecycleCorpus.length };
14034
14291
  }
14035
14292
  async runLifecyclePolicyPass(allMemories, storage = this.storage) {
14036
- const now = /* @__PURE__ */ new Date();
14037
- const nowIso = now.toISOString();
14038
- const countsByState = {
14039
- candidate: 0,
14040
- validated: 0,
14041
- active: 0,
14042
- stale: 0,
14043
- archived: 0
14044
- };
14045
- const transitionCounts = {};
14046
- let updatedCount = 0;
14047
- let disputedCount = 0;
14048
- let evaluatedCount = 0;
14049
- const lifecycleCaps = resolveMemoryLifecycleCapabilities(this.config);
14050
- const thresholds = this.effectiveLifecycleThresholds();
14051
- const policy = {
14052
- promoteHeatThreshold: thresholds.promoteHeatThreshold,
14053
- staleDecayThreshold: thresholds.staleDecayThreshold,
14054
- archiveDecayThreshold: thresholds.archiveDecayThreshold,
14055
- protectedCategories: this.config.lifecycleProtectedCategories
14056
- };
14057
- const actionPriors = await this.buildLifecycleActionPriors(storage);
14058
- for (const memory of allMemories) {
14059
- if (memory.frontmatter.status === "superseded" || memory.frontmatter.status === "forgotten") {
14060
- continue;
14061
- }
14062
- evaluatedCount += 1;
14063
- const currentState = resolveLifecycleState(memory.frontmatter);
14064
- const actionPriorScore = actionPriors.get(memory.frontmatter.id);
14065
- const signals = typeof actionPriorScore === "number" && Number.isFinite(actionPriorScore) ? { actionPriorScore } : void 0;
14066
- const decision = decideLifecycleTransition(memory, policy, now, signals);
14067
- const nextState = memory.frontmatter.status === "archived" ? "archived" : decision.nextState;
14068
- countsByState[nextState] += 1;
14069
- if (memory.frontmatter.verificationState === "disputed") {
14070
- disputedCount += 1;
14071
- }
14072
- if (nextState !== currentState) {
14073
- const key = `${currentState}->${nextState}`;
14074
- transitionCounts[key] = (transitionCounts[key] ?? 0) + 1;
14075
- }
14076
- const prevHeat = memory.frontmatter.heatScore;
14077
- const prevDecay = memory.frontmatter.decayScore;
14078
- const scoreDelta = Math.abs((prevHeat ?? -1) - decision.heatScore) + Math.abs((prevDecay ?? -1) - decision.decayScore);
14079
- const shouldPersist = memory.frontmatter.lifecycleState !== nextState || memory.frontmatter.heatScore === void 0 || memory.frontmatter.decayScore === void 0 || memory.frontmatter.lastValidatedAt === void 0 || scoreDelta >= 0.01;
14080
- if (!shouldPersist) continue;
14081
- const wrote = await storage.writeMemoryFrontmatter(memory, {
14082
- lifecycleState: nextState,
14083
- heatScore: decision.heatScore,
14084
- decayScore: decision.decayScore,
14085
- lastValidatedAt: nowIso
14086
- });
14087
- if (wrote) updatedCount += 1;
14088
- }
14089
- if (!lifecycleCaps.lifecycleMetrics) return updatedCount;
14090
- const total = evaluatedCount;
14091
- const metrics = {
14092
- generatedAt: nowIso,
14093
- memoriesEvaluated: total,
14094
- memoriesUpdated: updatedCount,
14095
- countsByLifecycleState: countsByState,
14096
- transitionCounts,
14097
- staleRatio: total > 0 ? countsByState.stale / total : 0,
14098
- disputedRatio: total > 0 ? disputedCount / total : 0,
14099
- policy: {
14100
- promoteHeatThreshold: thresholds.promoteHeatThreshold,
14101
- staleDecayThreshold: thresholds.staleDecayThreshold,
14102
- archiveDecayThreshold: thresholds.archiveDecayThreshold,
14103
- protectedCategories: this.config.lifecycleProtectedCategories
14104
- }
14105
- };
14106
- const metricsPath = path3.join(
14107
- storage.dir,
14108
- "state",
14109
- "lifecycle-metrics.json"
14110
- );
14111
- await mkdir2(path3.dirname(metricsPath), { recursive: true });
14112
- await writeFile2(metricsPath, JSON.stringify(metrics, null, 2), "utf-8");
14113
- return updatedCount;
14293
+ return this.lifecyclePolicyCoordinator.runLifecyclePolicyPass(allMemories, storage);
14114
14294
  }
14115
- /**
14116
- * Archive old, low-importance, rarely-accessed facts (v6.0).
14117
- * Moves eligible facts from facts/ to archive/YYYY-MM-DD/.
14118
- * Returns the number of archived facts.
14119
- */
14120
14295
  async runFactArchival(allMemories) {
14121
- const now = Date.now();
14122
- const ageCutoffMs = this.config.factArchivalAgeDays * 24 * 60 * 60 * 1e3;
14123
- const protectedCategories = new Set(
14124
- this.config.factArchivalProtectedCategories
14125
- );
14126
- let archivedCount = 0;
14127
- for (const memory of allMemories) {
14128
- const fm = memory.frontmatter;
14129
- if (fm.status && fm.status !== "active") continue;
14130
- if (protectedCategories.has(fm.category)) continue;
14131
- if (fm.category === "correction") continue;
14132
- const createdMs = new Date(fm.created).getTime();
14133
- if (now - createdMs < ageCutoffMs) continue;
14134
- const importanceScore = fm.importance?.score ?? 0.5;
14135
- if (importanceScore >= this.config.factArchivalMaxImportance) continue;
14136
- const accessCount = fm.accessCount ?? 0;
14137
- if (accessCount > this.config.factArchivalMaxAccessCount) continue;
14138
- const result = await this.storage.archiveMemory(memory);
14139
- if (result) {
14140
- await this.removeContentHashForMemory(
14141
- this.storage,
14142
- memory,
14143
- "fact-archival"
14144
- );
14145
- await this.embeddingFallback.removeFromIndex(memory.frontmatter.id);
14146
- if (resolveIndexingCapabilities(this.config).queryAwareIndexing && memory.path && memory.frontmatter?.created) {
14147
- deindexMemory(
14148
- this.config.memoryDir,
14149
- memory.path,
14150
- memory.frontmatter.created,
14151
- memory.frontmatter.tags ?? []
14152
- );
14153
- }
14154
- archivedCount++;
14155
- }
14156
- }
14157
- if (archivedCount > 0) {
14158
- await this.saveContentHashIndexes().catch(
14159
- (err) => log.warn(`content-hash index save failed during archival: ${err}`)
14160
- );
14161
- }
14162
- return archivedCount;
14296
+ return this.lifecyclePolicyCoordinator.runFactArchival(allMemories);
14163
14297
  }
14164
- /**
14165
- * Run memory summarization if memory count exceeds threshold (Phase 4A).
14166
- */
14167
14298
  async runSummarization(allMemories) {
14168
- const activeMemories = allMemories.filter(
14169
- (m) => isActiveMemoryStatus(m.frontmatter.status)
14170
- );
14171
- if (activeMemories.length < this.config.summarizationTriggerCount) {
14172
- return;
14173
- }
14174
- log.info(
14175
- `memory count (${activeMemories.length}) exceeds threshold (${this.config.summarizationTriggerCount}) \u2014 running summarization`
14176
- );
14177
- const sorted = activeMemories.sort(
14178
- (a, b) => new Date(a.frontmatter.created).getTime() - new Date(b.frontmatter.created).getTime()
14179
- );
14180
- const recentToKeep = Math.max(0, this.config.summarizationRecentToKeep);
14181
- const toSummarize = recentToKeep > 0 ? sorted.slice(0, -recentToKeep) : sorted;
14182
- const candidates = toSummarize.filter((m) => {
14183
- if (m.frontmatter.entityRef) return false;
14184
- const protectedTags = this.config.summarizationProtectedTags;
14185
- if (m.frontmatter.tags.some((t) => protectedTags.includes(t)))
14186
- return false;
14187
- const importance = m.frontmatter.importance?.score ?? 0.5;
14188
- if (importance >= this.config.summarizationImportanceThreshold)
14189
- return false;
14190
- return true;
14191
- });
14192
- if (candidates.length < 50) {
14193
- log.debug(
14194
- `only ${candidates.length} candidates for summarization \u2014 skipping`
14195
- );
14196
- return;
14197
- }
14198
- const batchSize = 50;
14199
- for (let i = 0; i < candidates.length; i += batchSize) {
14200
- const batch = candidates.slice(i, i + batchSize);
14201
- const batchData = batch.map((m) => ({
14202
- id: m.frontmatter.id,
14203
- content: m.content,
14204
- category: m.frontmatter.category,
14205
- created: m.frontmatter.created
14206
- }));
14207
- const result = await this.extraction.summarizeMemories(batchData);
14208
- if (!result) continue;
14209
- const summary = {
14210
- id: `summary-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
14211
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
14212
- timeRangeStart: batch[0].frontmatter.created,
14213
- timeRangeEnd: batch[batch.length - 1].frontmatter.created,
14214
- summaryText: result.summaryText,
14215
- keyFacts: result.keyFacts,
14216
- keyEntities: result.keyEntities,
14217
- sourceEpisodeIds: batch.map((m) => m.frontmatter.id)
14218
- };
14219
- await this.storage.writeSummary(summary);
14220
- const archived = await this.storage.archiveMemories(
14221
- batch.map((m) => m.frontmatter.id),
14222
- summary.id
14223
- );
14224
- log.info(
14225
- `created summary ${summary.id} from ${batch.length} memories, archived ${archived}`
14226
- );
14227
- }
14299
+ return this.lifecyclePolicyCoordinator.runSummarization(allMemories);
14228
14300
  }
14229
- /**
14230
- * Run topic extraction on all memories (Phase 4B).
14231
- */
14232
14301
  async runTopicExtraction(allMemories) {
14233
- const activeMemories = allMemories.filter(
14234
- (m) => isActiveMemoryStatus(m.frontmatter.status)
14235
- );
14236
- if (activeMemories.length === 0) return;
14237
- const topics = extractTopics(
14238
- activeMemories,
14239
- this.config.topicExtractionTopN
14240
- );
14241
- await this.storage.saveTopics(topics);
14242
- log.debug(
14243
- `extracted ${topics.length} topics from ${activeMemories.length} memories`
14244
- );
14302
+ return this.lifecyclePolicyCoordinator.runTopicExtraction(allMemories);
14245
14303
  }
14246
14304
  /** Threshold (bytes) at which IDENTITY.md reflections get auto-consolidated */
14247
14305
  static IDENTITY_CONSOLIDATE_THRESHOLD = 8e3;
@@ -14589,7 +14647,7 @@ ${lines.join("\n\n")}`;
14589
14647
  }
14590
14648
  }
14591
14649
  queueEvalShadowRecall(record) {
14592
- if (!this.config.evalHarnessEnabled || !this.config.evalShadowModeEnabled)
14650
+ if (!resolveEvalCapabilities(this.config).evalHarness || !resolveEvalCapabilities(this.config).evalShadowMode)
14593
14651
  return;
14594
14652
  this.evalShadowWriteChain = this.evalShadowWriteChain.catch(() => void 0).then(async () => {
14595
14653
  try {
@@ -14651,7 +14709,7 @@ ${lines.join("\n\n")}`;
14651
14709
  const seenStorageDirs = /* @__PURE__ */ new Set();
14652
14710
  const addStorage = (storage) => {
14653
14711
  const storageDir = storageDirFor(storage);
14654
- const storageKey = storageDir ? path3.resolve(storageDir) : `storage-without-dir-${storages.length}`;
14712
+ const storageKey = storageDir ? path4.resolve(storageDir) : `storage-without-dir-${storages.length}`;
14655
14713
  if (seenStorageDirs.has(storageKey)) return;
14656
14714
  seenStorageDirs.add(storageKey);
14657
14715
  storages.push(storage);
@@ -14681,7 +14739,7 @@ ${lines.join("\n\n")}`;
14681
14739
  continue;
14682
14740
  }
14683
14741
  try {
14684
- const coldRoot = path3.join(storageDir, "cold");
14742
+ const coldRoot = path4.join(storageDir, "cold");
14685
14743
  for (const candidate of qmdResultPathCandidates(
14686
14744
  coldRoot,
14687
14745
  parts.relativePath
@@ -14722,7 +14780,7 @@ ${lines.join("\n\n")}`;
14722
14780
  return null;
14723
14781
  }
14724
14782
  }
14725
- if (path3.isAbsolute(resultPath)) {
14783
+ if (path4.isAbsolute(resultPath)) {
14726
14784
  if (!fallbackStorageDir) {
14727
14785
  return await fallbackStorage.readMemoryByPath(resultPath);
14728
14786
  }
@@ -14761,7 +14819,7 @@ ${lines.join("\n\n")}`;
14761
14819
  );
14762
14820
  if (!memory) return null;
14763
14821
  let ownerNamespace = null;
14764
- if (path3.isAbsolute(memory.path)) {
14822
+ if (path4.isAbsolute(memory.path)) {
14765
14823
  const ownerStorage = await this.storageForAbsoluteQmdResultPath(
14766
14824
  memory.path,
14767
14825
  fallbackStorage,
@@ -14785,16 +14843,16 @@ ${lines.join("\n\n")}`;
14785
14843
  };
14786
14844
  }
14787
14845
  async storageForAbsoluteQmdResultPath(resultPath, fallbackStorage, recallNamespaces = []) {
14788
- const resolvedPath = path3.resolve(resultPath);
14789
- const memoryRoot = path3.resolve(this.config.memoryDir);
14790
- const namespacesRoot = path3.join(memoryRoot, "namespaces");
14846
+ const resolvedPath = path4.resolve(resultPath);
14847
+ const memoryRoot = path4.resolve(this.config.memoryDir);
14848
+ const namespacesRoot = path4.join(memoryRoot, "namespaces");
14791
14849
  const fallbackStorageDir = typeof fallbackStorage.dir === "string" && fallbackStorage.dir ? fallbackStorage.dir : null;
14792
14850
  const matches = [];
14793
14851
  const seenDirs = /* @__PURE__ */ new Set();
14794
14852
  const maybeAddStorage = (storage, namespace) => {
14795
14853
  const storageDir = typeof storage.dir === "string" && storage.dir ? storage.dir : null;
14796
14854
  if (!storageDir) return;
14797
- const candidateRoot = path3.resolve(storageDir);
14855
+ const candidateRoot = path4.resolve(storageDir);
14798
14856
  if (seenDirs.has(candidateRoot)) return;
14799
14857
  if (!isPathInsideStorageRoot(candidateRoot, resolvedPath)) return;
14800
14858
  if (candidateRoot === memoryRoot && isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
@@ -14812,7 +14870,7 @@ ${lines.join("\n\n")}`;
14812
14870
  candidateNamespaces.add(ns);
14813
14871
  }
14814
14872
  if (isPathInsideStorageRoot(namespacesRoot, resolvedPath)) {
14815
- const relativeToNamespaces = path3.relative(namespacesRoot, resolvedPath);
14873
+ const relativeToNamespaces = path4.relative(namespacesRoot, resolvedPath);
14816
14874
  const [namespaceSegment] = relativeToNamespaces.split(/[\\/]/);
14817
14875
  if (namespaceSegment) {
14818
14876
  candidateNamespaces.add(
@@ -14857,7 +14915,7 @@ ${lines.join("\n\n")}`;
14857
14915
  nsMap = buildMemoryWorthCounterMap(memories);
14858
14916
  this.memoryWorthCounterCache.set(ns, { at: nowMs, counters: nsMap });
14859
14917
  }
14860
- for (const [path4, c] of nsMap) counters.set(path4, c);
14918
+ for (const [path5, c] of nsMap) counters.set(path5, c);
14861
14919
  } catch (err) {
14862
14920
  log.debug("memory-worth: failed to read namespace, skipping", {
14863
14921
  namespace: ns,
@@ -14940,7 +14998,7 @@ ${lines.join("\n\n")}`;
14940
14998
  namespaces,
14941
14999
  {
14942
15000
  readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
14943
- readMemoryFrontmatter: async (path4) => {
15001
+ readMemoryFrontmatter: async (path5) => {
14944
15002
  if (!fallbackReader) {
14945
15003
  for (const ns of namespaces) {
14946
15004
  try {
@@ -14951,7 +15009,7 @@ ${lines.join("\n\n")}`;
14951
15009
  }
14952
15010
  }
14953
15011
  if (!fallbackReader) return null;
14954
- const memory = await this.readQmdResultMemory(path4, fallbackReader, namespaces);
15012
+ const memory = await this.readQmdResultMemory(path5, fallbackReader, namespaces);
14955
15013
  return memory ? memory.frontmatter : null;
14956
15014
  }
14957
15015
  },
@@ -15121,12 +15179,12 @@ ${lines.join("\n\n")}`;
15121
15179
  */
15122
15180
  semanticDedupScopeFor(targetStorage) {
15123
15181
  if (!resolveNamespaceCapabilities(this.config).namespaces) return {};
15124
- const memoryDir = path3.resolve(this.config.memoryDir);
15125
- const storageDir = path3.resolve(targetStorage.dir);
15182
+ const memoryDir = path4.resolve(this.config.memoryDir);
15183
+ const storageDir = path4.resolve(targetStorage.dir);
15126
15184
  if (storageDir === memoryDir) {
15127
15185
  return { pathExcludePrefixes: ["namespaces/"] };
15128
15186
  }
15129
- let rel = path3.relative(memoryDir, storageDir);
15187
+ let rel = path4.relative(memoryDir, storageDir);
15130
15188
  if (!rel || rel.startsWith("..")) {
15131
15189
  log.debug(
15132
15190
  `semantic dedup: target storage dir ${storageDir} is outside memoryDir ${memoryDir}; scoping lookup to absolute path prefix`
@@ -15145,7 +15203,7 @@ ${lines.join("\n\n")}`;
15145
15203
  if (hits.length === 0) return [];
15146
15204
  const results = [];
15147
15205
  for (const hit of hits) {
15148
- const fullPath = path3.isAbsolute(hit.path) ? hit.path : path3.join(this.config.memoryDir, hit.path);
15206
+ const fullPath = path4.isAbsolute(hit.path) ? hit.path : path4.join(this.config.memoryDir, hit.path);
15149
15207
  const memory = await this.storage.readMemoryByPath(fullPath);
15150
15208
  if (!memory) continue;
15151
15209
  results.push({
@@ -15342,7 +15400,7 @@ ${lines.join("\n\n")}`;
15342
15400
  const storage = await this.storageRouter.storageFor(namespace);
15343
15401
  const storageDir = typeof storage.dir === "string" && storage.dir ? storage.dir : null;
15344
15402
  if (!storageDir) continue;
15345
- const recallRoot = path3.resolve(storageDir);
15403
+ const recallRoot = path4.resolve(storageDir);
15346
15404
  if (seenRecallRoots.has(recallRoot)) continue;
15347
15405
  seenRecallRoots.add(recallRoot);
15348
15406
  recallRoots.push(recallRoot);
@@ -15366,8 +15424,8 @@ ${lines.join("\n\n")}`;
15366
15424
  if (resolvedCold) scopedResults.push(resolvedCold.result);
15367
15425
  continue;
15368
15426
  }
15369
- if (path3.isAbsolute(result.path)) {
15370
- const resolvedPath = path3.resolve(result.path);
15427
+ if (path4.isAbsolute(result.path)) {
15428
+ const resolvedPath = path4.resolve(result.path);
15371
15429
  if (recallRoots.some(
15372
15430
  (recallRoot) => isPathInsideStorageRoot(recallRoot, resolvedPath)
15373
15431
  )) {
@@ -16302,4 +16360,4 @@ export {
16302
16360
  resolvePersistedMemoryRelativePath,
16303
16361
  Orchestrator
16304
16362
  };
16305
- //# sourceMappingURL=chunk-Z7J3OAPR.js.map
16363
+ //# sourceMappingURL=chunk-FLCYY5JX.js.map