@remnic/core 9.65.2 → 9.65.4

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 (492) hide show
  1. package/dist/access-admin-ops-surface.d.ts +44 -44
  2. package/dist/access-admin-ops-surface.js +21 -19
  3. package/dist/access-authorization-probe.d.ts +38 -38
  4. package/dist/access-authorization-probe.js +22 -20
  5. package/dist/access-boundary.d.ts +40 -40
  6. package/dist/access-boundary.js +21 -19
  7. package/dist/access-cli.js +62 -60
  8. package/dist/access-cli.js.map +1 -1
  9. package/dist/access-coding-context-resolution.d.ts +3 -1
  10. package/dist/access-extraction-force-flush.d.ts +25 -25
  11. package/dist/access-extraction-force-flush.js +21 -19
  12. package/dist/access-health-types.d.ts +3 -1
  13. package/dist/access-http-lcm-compaction.d.ts +39 -39
  14. package/dist/access-http-lifecycle-flush.d.ts +39 -39
  15. package/dist/access-http-offline-stream.d.ts +25 -25
  16. package/dist/access-http-query.d.ts +4 -2
  17. package/dist/access-http-query.js +23 -21
  18. package/dist/access-http.d.ts +51 -44
  19. package/dist/access-http.js +37 -35
  20. package/dist/access-identity-continuity-surface.d.ts +12 -12
  21. package/dist/access-identity-continuity-surface.js +21 -19
  22. package/dist/access-lcm-surface.d.ts +27 -27
  23. package/dist/access-lcm-surface.js +21 -19
  24. package/dist/access-mcp-admin-tools.d.ts +9 -1
  25. package/dist/access-mcp-admin-tools.js +3 -1
  26. package/dist/access-mcp-output-schemas.js +1 -1
  27. package/dist/access-mcp.d.ts +39 -39
  28. package/dist/access-mcp.js +31 -29
  29. package/dist/access-memory-search-fanout.d.ts +4 -2
  30. package/dist/{access-namespace-preflight-Dhvcl-T0.d.ts → access-namespace-preflight-D_6mo8ms.d.ts} +1 -1
  31. package/dist/access-namespace-preflight.d.ts +5 -3
  32. package/dist/access-namespace-preflight.js +21 -19
  33. package/dist/access-observe-write-surface.d.ts +39 -39
  34. package/dist/access-observe-write-surface.js +21 -19
  35. package/dist/access-offline-manifest.d.ts +12 -12
  36. package/dist/access-offline-manifest.js +3 -3
  37. package/dist/access-operations-batch.js +25 -23
  38. package/dist/access-operations.d.ts +40 -40
  39. package/dist/access-operations.js +28 -26
  40. package/dist/access-recall-concurrency.d.ts +40 -40
  41. package/dist/access-recall-concurrency.js +21 -19
  42. package/dist/access-recall-response.d.ts +24 -24
  43. package/dist/access-recall-response.js +21 -19
  44. package/dist/access-recall-surface.d.ts +24 -24
  45. package/dist/access-recall-surface.js +21 -19
  46. package/dist/access-schema.d.ts +45 -45
  47. package/dist/{access-service-Bke1alZO.d.ts → access-service-DqPa3hy4.d.ts} +219 -75
  48. package/dist/access-service-helpers.d.ts +40 -40
  49. package/dist/access-service.d.ts +47 -47
  50. package/dist/access-service.js +21 -19
  51. package/dist/access-surface-catalog.d.ts +40 -40
  52. package/dist/access-surface-catalog.js +27 -21
  53. package/dist/access-surface-catalog.js.map +1 -1
  54. package/dist/access-wearables-meetings-surface.d.ts +5 -3
  55. package/dist/action-confidence.d.ts +3 -1
  56. package/dist/active-memory-bridge.d.ts +3 -1
  57. package/dist/active-recall.d.ts +3 -1
  58. package/dist/active-recall.js +10 -1
  59. package/dist/active-recall.js.map +1 -1
  60. package/dist/ambient-provenance.d.ts +3 -1
  61. package/dist/artifact-search.d.ts +3 -1
  62. package/dist/{auto-sync-H64ZCNIR.js → auto-sync-XVMLL2RH.js} +5 -5
  63. package/dist/behavior-learner.d.ts +3 -1
  64. package/dist/behavior-signals.d.ts +3 -1
  65. package/dist/bootstrap.d.ts +12 -12
  66. package/dist/briefing-window.d.ts +4 -2
  67. package/dist/briefing.d.ts +4 -2
  68. package/dist/briefing.js +4 -4
  69. package/dist/buffer-surprise-report.d.ts +3 -1
  70. package/dist/buffer-turn-helpers.d.ts +3 -1
  71. package/dist/buffer.d.ts +4 -2
  72. package/dist/bulk-import/index.d.ts +5 -3
  73. package/dist/calibration.d.ts +3 -1
  74. package/dist/capabilities.d.ts +3 -1
  75. package/dist/{catalog-DV6qnbr7.d.ts → catalog-DO_7zfkv.d.ts} +1 -1
  76. package/dist/causal-behavior.d.ts +1 -1
  77. package/dist/causal-consolidation.d.ts +3 -1
  78. package/dist/causal-consolidation.js +12 -9
  79. package/dist/causal-consolidation.js.map +1 -1
  80. package/dist/causal-trajectory-graph.d.ts +1 -1
  81. package/dist/chunk-236PXYG7.js +232 -0
  82. package/dist/chunk-236PXYG7.js.map +1 -0
  83. package/dist/{chunk-YB42WZCY.js → chunk-2IXQSGCU.js} +2 -2
  84. package/dist/{chunk-PE255F4T.js → chunk-2MVTAIL3.js} +2 -2
  85. package/dist/{chunk-LGO6A7GJ.js → chunk-3JZBPTLD.js} +338 -80
  86. package/dist/chunk-3JZBPTLD.js.map +1 -0
  87. package/dist/{chunk-GDFVPUJ5.js → chunk-3NH3VP3U.js} +2 -2
  88. package/dist/{chunk-TBOJ76ER.js → chunk-AB3A7EFH.js} +18 -2
  89. package/dist/{chunk-TBOJ76ER.js.map → chunk-AB3A7EFH.js.map} +1 -1
  90. package/dist/{chunk-GNCCUR6K.js → chunk-AXGFOFNY.js} +2 -2
  91. package/dist/{chunk-SB7D4BT7.js → chunk-AZLLH6YA.js} +1554 -114
  92. package/dist/chunk-AZLLH6YA.js.map +1 -0
  93. package/dist/{chunk-5YQ63T4B.js → chunk-BK5G2MHO.js} +2 -2
  94. package/dist/{chunk-LZH5FR2W.js → chunk-CQBIN77D.js} +2 -2
  95. package/dist/{chunk-35NN3ZFA.js → chunk-CTVWELNK.js} +21 -3
  96. package/dist/chunk-CTVWELNK.js.map +1 -0
  97. package/dist/{chunk-NKKD4ZAU.js → chunk-DORFF5N5.js} +2 -2
  98. package/dist/{chunk-BWLRUMOG.js → chunk-DPNXADEI.js} +441 -2
  99. package/dist/chunk-DPNXADEI.js.map +1 -0
  100. package/dist/{chunk-SQI57UCJ.js → chunk-DUEDOYZD.js} +2 -2
  101. package/dist/{chunk-5NM4OH4P.js → chunk-DUZARALI.js} +3 -3
  102. package/dist/{chunk-2E36UXVW.js → chunk-ECLJ4LA2.js} +2 -2
  103. package/dist/{chunk-TZNQUNKL.js → chunk-FC7TIRFS.js} +15 -1
  104. package/dist/chunk-FC7TIRFS.js.map +1 -0
  105. package/dist/{chunk-IID2CMUU.js → chunk-GHD2LLG4.js} +2 -2
  106. package/dist/{chunk-ZQHI2BZB.js → chunk-HF5BUTI6.js} +2 -2
  107. package/dist/{chunk-3DVBKTSO.js → chunk-HSZMX3ZJ.js} +4 -4
  108. package/dist/{chunk-S2DPMJXH.js → chunk-I23ZHYSL.js} +2 -2
  109. package/dist/{chunk-ODZG724P.js → chunk-I2HTKOOP.js} +2 -2
  110. package/dist/chunk-I32NKXE2.js +879 -0
  111. package/dist/chunk-I32NKXE2.js.map +1 -0
  112. package/dist/{chunk-NTWN6HB2.js → chunk-IURMJBGP.js} +2 -2
  113. package/dist/{chunk-OCZIYAE5.js → chunk-IWKGOCL6.js} +3 -3
  114. package/dist/{chunk-UXO5IMBK.js → chunk-J3ATBB7M.js} +2 -2
  115. package/dist/{chunk-Y7DK7HHJ.js → chunk-JPAKBNTM.js} +2 -2
  116. package/dist/{chunk-SPUJNJJC.js → chunk-KFIOPZ25.js} +2 -2
  117. package/dist/{chunk-JYYBA7TF.js → chunk-KOO37E4Y.js} +2 -2
  118. package/dist/{chunk-OTHZWLUD.js → chunk-KPB2QHJZ.js} +2 -2
  119. package/dist/{chunk-SBDCZ2AX.js → chunk-LBFFNDFM.js} +1 -1
  120. package/dist/chunk-LBFFNDFM.js.map +1 -0
  121. package/dist/{chunk-CT56C22C.js → chunk-LYBIHM4N.js} +4 -4
  122. package/dist/{chunk-3I7ASZN3.js → chunk-MFOSZUIT.js} +2 -2
  123. package/dist/{chunk-DZUJ46DO.js → chunk-NLEH4RTB.js} +2 -2
  124. package/dist/{chunk-ZO6AXLEH.js → chunk-OCCHUEZB.js} +2 -2
  125. package/dist/{chunk-EILZG5VC.js → chunk-OU34IQXV.js} +2 -2
  126. package/dist/{chunk-2XDWWPTN.js → chunk-OZDFB22S.js} +2 -2
  127. package/dist/{chunk-UIN2BWDD.js → chunk-PTZQYCJ4.js} +2 -2
  128. package/dist/{chunk-7BY7V4YX.js → chunk-Q4WONDMJ.js} +4 -3
  129. package/dist/{chunk-7BY7V4YX.js.map → chunk-Q4WONDMJ.js.map} +1 -1
  130. package/dist/{chunk-Z7PBQPJ4.js → chunk-QJW4MZSW.js} +2 -2
  131. package/dist/{chunk-R7JAM2XF.js → chunk-R2MZCYA6.js} +3 -3
  132. package/dist/{chunk-TF77C7SV.js → chunk-SR5LNI6Q.js} +7 -5
  133. package/dist/chunk-SR5LNI6Q.js.map +1 -0
  134. package/dist/{chunk-LBWQ65SX.js → chunk-T42L3S6A.js} +4 -4
  135. package/dist/{chunk-J275IYMG.js → chunk-THVI4Y7X.js} +34 -7
  136. package/dist/chunk-THVI4Y7X.js.map +1 -0
  137. package/dist/{chunk-QOS5LBZN.js → chunk-TJFI3K2O.js} +15 -3
  138. package/dist/chunk-TJFI3K2O.js.map +1 -0
  139. package/dist/{chunk-2YI72KM3.js → chunk-UCKG36HO.js} +2 -2
  140. package/dist/{chunk-SIHSCCUQ.js → chunk-UFR6HX7A.js} +1 -1
  141. package/dist/{chunk-CDUUDBWJ.js → chunk-VFYRYFLL.js} +2 -2
  142. package/dist/{chunk-XRYZRW54.js → chunk-WDXD6ITO.js} +2 -2
  143. package/dist/{chunk-4KYOLI6M.js → chunk-XGM3VQWG.js} +120 -14
  144. package/dist/chunk-XGM3VQWG.js.map +1 -0
  145. package/dist/{chunk-MN4KB2A4.js → chunk-YDKF4MSJ.js} +3 -3
  146. package/dist/{chunk-YLDXWCZP.js → chunk-YHGCT462.js} +14 -9
  147. package/dist/chunk-YHGCT462.js.map +1 -0
  148. package/dist/{chunk-7YQ4IYS2.js → chunk-YOXVZJFM.js} +2 -2
  149. package/dist/{chunk-ZWXJBFZU.js → chunk-YZJM6CLF.js} +8 -8
  150. package/dist/chunk-ZCUTSMR2.js +61 -0
  151. package/dist/chunk-ZCUTSMR2.js.map +1 -0
  152. package/dist/{chunk-LUNJ3WFO.js → chunk-ZK4BFABK.js} +4 -4
  153. package/dist/{chunk-V3MXUL3D.js → chunk-ZPOHEB5Z.js} +329 -653
  154. package/dist/chunk-ZPOHEB5Z.js.map +1 -0
  155. package/dist/{chunk-RDFF2NAU.js → chunk-ZXBTTMGZ.js} +184 -88
  156. package/dist/chunk-ZXBTTMGZ.js.map +1 -0
  157. package/dist/{cli-cShQ13XG.d.ts → cli-DO3i14pM.d.ts} +5 -5
  158. package/dist/cli.d.ts +25 -25
  159. package/dist/cli.js +51 -48
  160. package/dist/coding/pre-action-gate.d.ts +2 -60
  161. package/dist/compounding/engine.d.ts +4 -2
  162. package/dist/compounding/engine.js +4 -4
  163. package/dist/compounding/preference-consolidator.d.ts +3 -1
  164. package/dist/compression-optimizer.d.ts +3 -1
  165. package/dist/config.d.ts +3 -1
  166. package/dist/config.js +10 -1
  167. package/dist/connectors/codex-materialize-runner.d.ts +3 -1
  168. package/dist/connectors/codex-materialize-runner.js +8 -5
  169. package/dist/connectors/codex-materialize.d.ts +16 -1
  170. package/dist/connectors/codex-materialize.js +10 -1
  171. package/dist/connectors/index.d.ts +3 -1
  172. package/dist/connectors/index.js +8 -5
  173. package/dist/consolidation-provenance-check.d.ts +4 -2
  174. package/dist/consolidation-undo.d.ts +4 -2
  175. package/dist/contradiction/index.d.ts +10 -270
  176. package/dist/contradiction/index.js +12 -7
  177. package/dist/{contradiction-review-QKJH5DKD.js → contradiction-review-WRVLRWHS.js} +6 -2
  178. package/dist/{contradiction-scan-VOTQRRSX.js → contradiction-scan-AKUWPX5N.js} +5 -3
  179. package/dist/converge-config.d.ts +3 -1
  180. package/dist/convergence-refresh.d.ts +4 -2
  181. package/dist/convergence-refresh.js +6 -6
  182. package/dist/conversation-index/backend.d.ts +3 -1
  183. package/dist/conversation-index/chunker.d.ts +3 -1
  184. package/dist/conversation-index/faiss-adapter.d.ts +3 -1
  185. package/dist/conversation-index/indexer.d.ts +3 -1
  186. package/dist/conversation-index/search.d.ts +3 -1
  187. package/dist/corpus-watermark.d.ts +3 -1
  188. package/dist/corpus-watermark.js +6 -6
  189. package/dist/cross-lingual-recall.d.ts +3 -1
  190. package/dist/day-summary.d.ts +3 -1
  191. package/dist/delinearize.d.ts +3 -1
  192. package/dist/dependency-propagation-config.d.ts +3 -1
  193. package/dist/{dependency-propagation-delivery-CsGg-VwS.d.ts → dependency-propagation-delivery-D23_x-s5.d.ts} +1 -1
  194. package/dist/direct-answer-wiring.d.ts +3 -1
  195. package/dist/direct-answer.d.ts +3 -1
  196. package/dist/embedding-fallback.d.ts +3 -1
  197. package/dist/enrichment/index.d.ts +3 -1
  198. package/dist/entity-origin-fields.d.ts +3 -1
  199. package/dist/entity-retrieval.d.ts +4 -2
  200. package/dist/entity-retrieval.js +4 -4
  201. package/dist/entity-schema.d.ts +3 -1
  202. package/dist/episodic-context.d.ts +3 -1
  203. package/dist/explicit-capture.d.ts +12 -12
  204. package/dist/explicit-capture.js +1 -1
  205. package/dist/external-wiki-access.d.ts +40 -40
  206. package/dist/external-wiki-access.js +22 -20
  207. package/dist/external-wiki-collection-registration.d.ts +3 -1
  208. package/dist/external-wiki-collection.d.ts +3 -1
  209. package/dist/external-wiki-mcp-tools.d.ts +40 -40
  210. package/dist/extraction-error-classification.d.ts +3 -1
  211. package/dist/extraction-faithfulness.d.ts +3 -1
  212. package/dist/extraction-judge-telemetry.d.ts +3 -1
  213. package/dist/extraction-judge-training.d.ts +3 -1
  214. package/dist/extraction-judge.d.ts +3 -1
  215. package/dist/extraction-judge.js +2 -2
  216. package/dist/extraction-liveness.d.ts +3 -1
  217. package/dist/extraction-normalization.d.ts +3 -1
  218. package/dist/extraction-prompt.d.ts +3 -1
  219. package/dist/extraction-source-grounding-rules.d.ts +3 -1
  220. package/dist/extraction-source-grounding.d.ts +3 -1
  221. package/dist/extraction.d.ts +3 -1
  222. package/dist/extraction.js +9 -7
  223. package/dist/fallback-llm.d.ts +3 -1
  224. package/dist/graph-dashboard-diff.d.ts +3 -1
  225. package/dist/graph-dashboard-key.d.ts +3 -1
  226. package/dist/graph-dashboard-parser.d.ts +3 -1
  227. package/dist/graph-edge-reinforcement.d.ts +3 -1
  228. package/dist/graph-path-reconstruction.d.ts +3 -1
  229. package/dist/graph-path-scoring.d.ts +3 -1
  230. package/dist/graph-snapshot.d.ts +3 -1
  231. package/dist/graph.d.ts +3 -1
  232. package/dist/harmonic-retrieval.js +1 -1
  233. package/dist/importance.d.ts +3 -1
  234. package/dist/importers/index.d.ts +3 -1
  235. package/dist/in-flight-reads.d.ts +3 -1
  236. package/dist/index--QhGIXF2.d.ts +284 -0
  237. package/dist/index.d.ts +314 -45
  238. package/dist/index.js +163 -88
  239. package/dist/intent.d.ts +3 -1
  240. package/dist/lcm/engine.d.ts +3 -1
  241. package/dist/lcm/index.d.ts +3 -1
  242. package/dist/lcm/tools.d.ts +3 -1
  243. package/dist/lifecycle.d.ts +3 -1
  244. package/dist/live-connectors-runner.d.ts +3 -1
  245. package/dist/local-llm.d.ts +3 -1
  246. package/dist/local-model-endpoint.d.ts +3 -1
  247. package/dist/maintenance/memory-governance.d.ts +3 -1
  248. package/dist/maintenance/memory-governance.js +4 -4
  249. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +4 -2
  250. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +4 -4
  251. package/dist/maintenance/rebuild-memory-projection.d.ts +4 -2
  252. package/dist/maintenance/rebuild-memory-projection.js +5 -5
  253. package/dist/{maintenance-jhMpeGne.d.ts → maintenance-PFvY1Pw_.d.ts} +3 -3
  254. package/dist/mcp-memory-inspector-app.d.ts +37 -37
  255. package/dist/memory-action-policy.d.ts +3 -1
  256. package/dist/memory-cache.d.ts +3 -1
  257. package/dist/memory-lifecycle-ledger-utils.d.ts +3 -1
  258. package/dist/memory-projection-store.d.ts +3 -1
  259. package/dist/memory-provenance.d.ts +3 -1
  260. package/dist/memory-snapshot.d.ts +3 -1
  261. package/dist/memory-subject-cli.d.ts +40 -40
  262. package/dist/memory-subject.d.ts +42 -42
  263. package/dist/memory-worth-outcomes.d.ts +4 -2
  264. package/dist/models-json.d.ts +3 -1
  265. package/dist/namespaces/migrate.d.ts +5 -3
  266. package/dist/namespaces/migrate.js +5 -5
  267. package/dist/namespaces/principal.d.ts +3 -1
  268. package/dist/namespaces/search.d.ts +3 -1
  269. package/dist/namespaces/storage.d.ts +5 -3
  270. package/dist/namespaces/storage.js +4 -4
  271. package/dist/native-knowledge.d.ts +3 -1
  272. package/dist/offline-sync-impression-drain.d.ts +3 -1
  273. package/dist/operator-doctor-corpus.d.ts +3 -1
  274. package/dist/operator-doctor-corpus.js +7 -7
  275. package/dist/operator-doctor-replica.d.ts +3 -1
  276. package/dist/operator-toolkit.d.ts +5 -3
  277. package/dist/operator-toolkit.js +19 -13
  278. package/dist/orchestration/compression-guideline-coordinator.d.ts +4 -2
  279. package/dist/orchestration/maintenance.d.ts +6 -4
  280. package/dist/orchestration/maintenance.js +10 -10
  281. package/dist/{orchestrator-DyGUC7re.d.ts → orchestrator-4wzJrPVm.d.ts} +23 -9
  282. package/dist/orchestrator.d.ts +12 -12
  283. package/dist/orchestrator.js +62 -60
  284. package/dist/patterns-cli.d.ts +3 -1
  285. package/dist/{pipeline-C25Oxtp1.d.ts → pipeline-CgXgdIrF.d.ts} +1 -1
  286. package/dist/policy-runtime.d.ts +3 -1
  287. package/dist/proactive-contention.d.ts +3 -1
  288. package/dist/provenance.d.ts +3 -1
  289. package/dist/{public-http-CMe7NQzj.d.ts → public-http-DhIXYBYI.d.ts} +1 -1
  290. package/dist/{qmd-DkDVCbgF.d.ts → qmd-BppGGxsi.d.ts} +1 -1
  291. package/dist/qmd-preflight.d.ts +4 -2
  292. package/dist/qmd-recall-cache.d.ts +3 -1
  293. package/dist/qmd.d.ts +4 -2
  294. package/dist/recall-concurrency-config.d.ts +3 -1
  295. package/dist/recall-disclosure-escalation.d.ts +3 -1
  296. package/dist/recall-explain-renderer.d.ts +3 -1
  297. package/dist/recall-explain-renderer.js +3 -3
  298. package/dist/recall-memory-map.d.ts +3 -1
  299. package/dist/recall-planner-llm.d.ts +3 -1
  300. package/dist/recall-state.d.ts +3 -1
  301. package/dist/recall-tag-filter.d.ts +3 -1
  302. package/dist/recall-timings.d.ts +3 -1
  303. package/dist/recall-xray-cli.d.ts +3 -1
  304. package/dist/recall-xray-cli.js +4 -4
  305. package/dist/recall-xray-renderer.d.ts +3 -1
  306. package/dist/recall-xray-renderer.js +3 -3
  307. package/dist/recall-xray.d.ts +3 -1
  308. package/dist/recall-xray.js +2 -2
  309. package/dist/reconcile/cursor.d.ts +3 -1
  310. package/dist/reconcile/manifest.d.ts +3 -1
  311. package/dist/reconcile/manifest.js +2 -2
  312. package/dist/reconcile/plan.d.ts +3 -1
  313. package/dist/replay/normalizers/chatgpt.d.ts +3 -1
  314. package/dist/replay/normalizers/claude.d.ts +3 -1
  315. package/dist/replay/normalizers/openclaw.d.ts +3 -1
  316. package/dist/replay/normalizers/shared.d.ts +3 -1
  317. package/dist/replay/runner.d.ts +3 -1
  318. package/dist/replay/types.d.ts +3 -1
  319. package/dist/replica-divergence.d.ts +3 -1
  320. package/dist/replica-peers-config.d.ts +3 -1
  321. package/dist/{resolution-MFY72STR.js → resolution-4552BNRV.js} +14 -4
  322. package/dist/resolve-auth-token.d.ts +3 -1
  323. package/dist/resume-bundles.js +8 -2
  324. package/dist/retrieval-agents.d.ts +4 -2
  325. package/dist/retrieval-tiers.d.ts +3 -1
  326. package/dist/routing/engine.d.ts +3 -1
  327. package/dist/routing/store.d.ts +3 -1
  328. package/dist/salvage-envelope.d.ts +3 -1
  329. package/dist/salvage-envelope.js +1 -1
  330. package/dist/schemas.d.ts +44 -44
  331. package/dist/{scope-profiles-B9xMoFO-.d.ts → scope-profiles-ChZUtxDU.d.ts} +1 -1
  332. package/dist/search/embed-helper.d.ts +3 -1
  333. package/dist/search/factory.d.ts +3 -1
  334. package/dist/search/index.d.ts +3 -1
  335. package/dist/search/lancedb-backend.d.ts +3 -1
  336. package/dist/search/meilisearch-backend.d.ts +3 -1
  337. package/dist/search/noop-backend.d.ts +3 -1
  338. package/dist/search/orama-backend.d.ts +3 -1
  339. package/dist/search/port.d.ts +3 -1
  340. package/dist/search/remote-backend.d.ts +3 -1
  341. package/dist/{semantic-TddhF0y7.d.ts → semantic-BalR6EXU.d.ts} +1 -1
  342. package/dist/{semantic-consolidation-C4uykW84.d.ts → semantic-consolidation-mSPwQSmF.d.ts} +1 -1
  343. package/dist/semantic-consolidation.d.ts +4 -2
  344. package/dist/semantic-consolidation.js +9 -6
  345. package/dist/semantic-rule-promotion.js +4 -4
  346. package/dist/semantic-rule-verifier.d.ts +3 -1
  347. package/dist/semantic-rule-verifier.js +4 -4
  348. package/dist/{service-DCZDZNcV.d.ts → service-BICWLwSP.d.ts} +2 -2
  349. package/dist/session-observer-bands.d.ts +3 -1
  350. package/dist/session-observer-state.d.ts +3 -1
  351. package/dist/shared-context/manager.d.ts +3 -1
  352. package/dist/signal.d.ts +3 -1
  353. package/dist/skills-registry.js +4 -56
  354. package/dist/skills-registry.js.map +1 -1
  355. package/dist/source-agent-qualifier.d.ts +3 -1
  356. package/dist/source-agent-qualifier.js +8 -5
  357. package/dist/{storage-CcKmEjL8.d.ts → storage-B7urx1K3.d.ts} +1 -1
  358. package/dist/storage.d.ts +4 -2
  359. package/dist/storage.js +6 -6
  360. package/dist/subject-config.d.ts +3 -1
  361. package/dist/summarizer.d.ts +3 -1
  362. package/dist/summary-snapshot.d.ts +3 -1
  363. package/dist/support-passport/index.d.ts +43 -43
  364. package/dist/support-passport/index.js +24 -22
  365. package/dist/temporal-supersession.d.ts +4 -2
  366. package/dist/temporal-timeline-recall.d.ts +3 -1
  367. package/dist/temporal-validity.d.ts +3 -1
  368. package/dist/threading.d.ts +3 -1
  369. package/dist/tier-migration.d.ts +4 -2
  370. package/dist/tier-routing.d.ts +3 -1
  371. package/dist/topics.d.ts +3 -1
  372. package/dist/transcript.d.ts +3 -1
  373. package/dist/transfer/types.d.ts +20 -20
  374. package/dist/trust-score-stage.d.ts +3 -1
  375. package/dist/trust-score.d.ts +3 -1
  376. package/dist/{types-Pi0lfaEt.d.ts → types-ETU5N6nB.d.ts} +433 -7
  377. package/dist/types.d.ts +3 -1
  378. package/dist/types.js +1 -1
  379. package/dist/utility-runtime.d.ts +3 -1
  380. package/dist/verified-recall.js +4 -4
  381. package/dist/who-knows-cli.d.ts +40 -40
  382. package/dist/who-knows-cli.js +5 -5
  383. package/dist/who-knows.d.ts +42 -42
  384. package/dist/who-knows.js +4 -4
  385. package/dist/write-envelope.d.ts +3 -1
  386. package/dist/write-envelope.js +1 -1
  387. package/package.json +2 -2
  388. package/src/access-boundary.ts +4 -0
  389. package/src/access-http.ts +6 -5
  390. package/src/access-mcp-admin-tools.ts +24 -0
  391. package/src/access-mcp-output-schemas.ts +14 -0
  392. package/src/access-mcp.ts +2 -2
  393. package/src/access-operations-batch.ts +5 -0
  394. package/src/access-service.ts +27 -0
  395. package/src/access-surface-catalog.test.ts +24 -0
  396. package/src/access-surface-catalog.ts +4 -0
  397. package/src/cli/skills-commands.ts +150 -0
  398. package/src/cli.ts +4 -2
  399. package/src/coding/action-gate.test.ts +341 -0
  400. package/src/coding/action-gate.ts +556 -0
  401. package/src/config.ts +9 -2
  402. package/src/connectors/codex-materialize-runner.ts +16 -0
  403. package/src/connectors/codex-materialize-skills.test.ts +141 -0
  404. package/src/connectors/codex-materialize.ts +58 -40
  405. package/src/connectors/materialize-paths.ts +50 -0
  406. package/src/connectors/materialize-skills.ts +127 -0
  407. package/src/contradiction/contradiction-review.ts +50 -4
  408. package/src/contradiction/contradiction-scan.ts +14 -3
  409. package/src/contradiction/resolution.ts +50 -2
  410. package/src/index.ts +9 -13
  411. package/src/orchestration/recall-rerank-coordinator.ts +123 -4
  412. package/src/orchestration/recall-result-formatter.ts +6 -2
  413. package/src/orchestration/recall-search-pipeline.ts +14 -1
  414. package/src/preferences/drift-config.ts +118 -0
  415. package/src/preferences/drift-recall.ts +133 -0
  416. package/src/preferences/drift-types.ts +87 -0
  417. package/src/preferences/index.ts +12 -0
  418. package/src/preferences/preference-drift.test.ts +690 -0
  419. package/src/preferences/preference-drift.ts +724 -0
  420. package/src/procedural/skill-io.test.ts +190 -0
  421. package/src/procedural/skill-io.ts +220 -0
  422. package/src/procedural/skill-projection.test.ts +214 -0
  423. package/src/procedural/skill-projection.ts +356 -0
  424. package/src/review/review-deck-access.test.ts +325 -0
  425. package/src/review/review-deck-http-base.ts +133 -0
  426. package/src/review/review-deck-mutation.test.ts +417 -0
  427. package/src/review/review-deck-mutation.ts +677 -0
  428. package/src/review/review-deck-snapshot.ts +196 -0
  429. package/src/review/review-deck-surface.ts +117 -0
  430. package/src/review/review-deck.test.ts +347 -0
  431. package/src/review/review-deck.ts +311 -0
  432. package/src/storage.ts +4 -6
  433. package/src/types.ts +9 -6
  434. package/dist/chunk-35NN3ZFA.js.map +0 -1
  435. package/dist/chunk-4KYOLI6M.js.map +0 -1
  436. package/dist/chunk-BWLRUMOG.js.map +0 -1
  437. package/dist/chunk-J275IYMG.js.map +0 -1
  438. package/dist/chunk-LGO6A7GJ.js.map +0 -1
  439. package/dist/chunk-QOS5LBZN.js.map +0 -1
  440. package/dist/chunk-RDFF2NAU.js.map +0 -1
  441. package/dist/chunk-SB7D4BT7.js.map +0 -1
  442. package/dist/chunk-SBDCZ2AX.js.map +0 -1
  443. package/dist/chunk-TF77C7SV.js.map +0 -1
  444. package/dist/chunk-TZNQUNKL.js.map +0 -1
  445. package/dist/chunk-V3MXUL3D.js.map +0 -1
  446. package/dist/chunk-XCTXS7VY.js +0 -402
  447. package/dist/chunk-XCTXS7VY.js.map +0 -1
  448. package/dist/chunk-YLDXWCZP.js.map +0 -1
  449. /package/dist/{auto-sync-H64ZCNIR.js.map → auto-sync-XVMLL2RH.js.map} +0 -0
  450. /package/dist/{chunk-YB42WZCY.js.map → chunk-2IXQSGCU.js.map} +0 -0
  451. /package/dist/{chunk-PE255F4T.js.map → chunk-2MVTAIL3.js.map} +0 -0
  452. /package/dist/{chunk-GDFVPUJ5.js.map → chunk-3NH3VP3U.js.map} +0 -0
  453. /package/dist/{chunk-GNCCUR6K.js.map → chunk-AXGFOFNY.js.map} +0 -0
  454. /package/dist/{chunk-5YQ63T4B.js.map → chunk-BK5G2MHO.js.map} +0 -0
  455. /package/dist/{chunk-LZH5FR2W.js.map → chunk-CQBIN77D.js.map} +0 -0
  456. /package/dist/{chunk-NKKD4ZAU.js.map → chunk-DORFF5N5.js.map} +0 -0
  457. /package/dist/{chunk-SQI57UCJ.js.map → chunk-DUEDOYZD.js.map} +0 -0
  458. /package/dist/{chunk-5NM4OH4P.js.map → chunk-DUZARALI.js.map} +0 -0
  459. /package/dist/{chunk-2E36UXVW.js.map → chunk-ECLJ4LA2.js.map} +0 -0
  460. /package/dist/{chunk-IID2CMUU.js.map → chunk-GHD2LLG4.js.map} +0 -0
  461. /package/dist/{chunk-ZQHI2BZB.js.map → chunk-HF5BUTI6.js.map} +0 -0
  462. /package/dist/{chunk-3DVBKTSO.js.map → chunk-HSZMX3ZJ.js.map} +0 -0
  463. /package/dist/{chunk-S2DPMJXH.js.map → chunk-I23ZHYSL.js.map} +0 -0
  464. /package/dist/{chunk-ODZG724P.js.map → chunk-I2HTKOOP.js.map} +0 -0
  465. /package/dist/{chunk-NTWN6HB2.js.map → chunk-IURMJBGP.js.map} +0 -0
  466. /package/dist/{chunk-OCZIYAE5.js.map → chunk-IWKGOCL6.js.map} +0 -0
  467. /package/dist/{chunk-UXO5IMBK.js.map → chunk-J3ATBB7M.js.map} +0 -0
  468. /package/dist/{chunk-Y7DK7HHJ.js.map → chunk-JPAKBNTM.js.map} +0 -0
  469. /package/dist/{chunk-SPUJNJJC.js.map → chunk-KFIOPZ25.js.map} +0 -0
  470. /package/dist/{chunk-JYYBA7TF.js.map → chunk-KOO37E4Y.js.map} +0 -0
  471. /package/dist/{chunk-OTHZWLUD.js.map → chunk-KPB2QHJZ.js.map} +0 -0
  472. /package/dist/{chunk-CT56C22C.js.map → chunk-LYBIHM4N.js.map} +0 -0
  473. /package/dist/{chunk-3I7ASZN3.js.map → chunk-MFOSZUIT.js.map} +0 -0
  474. /package/dist/{chunk-DZUJ46DO.js.map → chunk-NLEH4RTB.js.map} +0 -0
  475. /package/dist/{chunk-ZO6AXLEH.js.map → chunk-OCCHUEZB.js.map} +0 -0
  476. /package/dist/{chunk-EILZG5VC.js.map → chunk-OU34IQXV.js.map} +0 -0
  477. /package/dist/{chunk-2XDWWPTN.js.map → chunk-OZDFB22S.js.map} +0 -0
  478. /package/dist/{chunk-UIN2BWDD.js.map → chunk-PTZQYCJ4.js.map} +0 -0
  479. /package/dist/{chunk-Z7PBQPJ4.js.map → chunk-QJW4MZSW.js.map} +0 -0
  480. /package/dist/{chunk-R7JAM2XF.js.map → chunk-R2MZCYA6.js.map} +0 -0
  481. /package/dist/{chunk-LBWQ65SX.js.map → chunk-T42L3S6A.js.map} +0 -0
  482. /package/dist/{chunk-2YI72KM3.js.map → chunk-UCKG36HO.js.map} +0 -0
  483. /package/dist/{chunk-SIHSCCUQ.js.map → chunk-UFR6HX7A.js.map} +0 -0
  484. /package/dist/{chunk-CDUUDBWJ.js.map → chunk-VFYRYFLL.js.map} +0 -0
  485. /package/dist/{chunk-XRYZRW54.js.map → chunk-WDXD6ITO.js.map} +0 -0
  486. /package/dist/{chunk-MN4KB2A4.js.map → chunk-YDKF4MSJ.js.map} +0 -0
  487. /package/dist/{chunk-7YQ4IYS2.js.map → chunk-YOXVZJFM.js.map} +0 -0
  488. /package/dist/{chunk-ZWXJBFZU.js.map → chunk-YZJM6CLF.js.map} +0 -0
  489. /package/dist/{chunk-LUNJ3WFO.js.map → chunk-ZK4BFABK.js.map} +0 -0
  490. /package/dist/{contradiction-review-QKJH5DKD.js.map → contradiction-review-WRVLRWHS.js.map} +0 -0
  491. /package/dist/{contradiction-scan-VOTQRRSX.js.map → contradiction-scan-AKUWPX5N.js.map} +0 -0
  492. /package/dist/{resolution-MFY72STR.js.map → resolution-4552BNRV.js.map} +0 -0
@@ -6,14 +6,14 @@ import {
6
6
  loadSyncState,
7
7
  syncWearableSource,
8
8
  wearableSourceLabel
9
- } from "./chunk-CDUUDBWJ.js";
9
+ } from "./chunk-VFYRYFLL.js";
10
10
  import {
11
11
  CompressionGuidelineCoordinator
12
12
  } from "./chunk-UXREWVW4.js";
13
13
  import {
14
14
  ActivityStore,
15
15
  MaintenanceScheduler
16
- } from "./chunk-CT56C22C.js";
16
+ } from "./chunk-LYBIHM4N.js";
17
17
  import {
18
18
  runPeerProfileReasoner
19
19
  } from "./chunk-I74SUMNI.js";
@@ -32,7 +32,7 @@ import {
32
32
  import {
33
33
  CompoundingEngine,
34
34
  defaultTierMigrationCycleBudget
35
- } from "./chunk-2YI72KM3.js";
35
+ } from "./chunk-UCKG36HO.js";
36
36
  import {
37
37
  SharedContextManager
38
38
  } from "./chunk-VI637ILW.js";
@@ -160,7 +160,7 @@ import {
160
160
  } from "./chunk-OH7QLI6W.js";
161
161
  import {
162
162
  ExtractionEngine
163
- } from "./chunk-LUNJ3WFO.js";
163
+ } from "./chunk-ZK4BFABK.js";
164
164
  import {
165
165
  parseMemoryActionEligibilityContext
166
166
  } from "./chunk-7BDZTALN.js";
@@ -176,7 +176,7 @@ import {
176
176
  getVerdictKind,
177
177
  judgeFactDurability,
178
178
  validateProcedureExtraction
179
- } from "./chunk-3DVBKTSO.js";
179
+ } from "./chunk-HSZMX3ZJ.js";
180
180
  import {
181
181
  buildExplicitCueRecallSection
182
182
  } from "./chunk-TVIVY7KU.js";
@@ -184,7 +184,7 @@ import {
184
184
  buildEntityRecallSection,
185
185
  entityRecentTranscriptLookbackHours,
186
186
  readRecentEntityTranscriptEntries
187
- } from "./chunk-DZUJ46DO.js";
187
+ } from "./chunk-NLEH4RTB.js";
188
188
  import {
189
189
  planEpisodeWindowsWithFallback
190
190
  } from "./chunk-T3GIETKV.js";
@@ -209,14 +209,14 @@ import {
209
209
  } from "./chunk-VY47VI2T.js";
210
210
  import {
211
211
  refreshConvergedNamespaces
212
- } from "./chunk-Y7DK7HHJ.js";
212
+ } from "./chunk-JPAKBNTM.js";
213
213
  import {
214
214
  builtInConnectorPackageSpecifier,
215
215
  ensureBuiltInWearableConnectors,
216
216
  getWearableConnector,
217
217
  listWearableConnectors,
218
218
  screenCandidateFact
219
- } from "./chunk-LGO6A7GJ.js";
219
+ } from "./chunk-3JZBPTLD.js";
220
220
  import {
221
221
  RoutingRulesStore
222
222
  } from "./chunk-TBUEE7XF.js";
@@ -226,14 +226,14 @@ import {
226
226
  import {
227
227
  compareVerifiedEpisodeResults,
228
228
  searchVerifiedEpisodes
229
- } from "./chunk-2E36UXVW.js";
229
+ } from "./chunk-ECLJ4LA2.js";
230
230
  import {
231
231
  ThreadingManager
232
232
  } from "./chunk-OJP3N7UK.js";
233
233
  import {
234
234
  compareVerifiedSemanticRuleResults,
235
235
  searchVerifiedSemanticRules
236
- } from "./chunk-ZO6AXLEH.js";
236
+ } from "./chunk-OCCHUEZB.js";
237
237
  import {
238
238
  searchWorkProductLedgerEntries
239
239
  } from "./chunk-NRLELHAY.js";
@@ -246,13 +246,13 @@ import {
246
246
  import {
247
247
  runNamespaceMaintenanceFanout,
248
248
  summarizeNamespaceMaintenanceHealth
249
- } from "./chunk-ZWXJBFZU.js";
249
+ } from "./chunk-YZJM6CLF.js";
250
250
  import {
251
251
  planNamespaceMaintenance
252
- } from "./chunk-MN4KB2A4.js";
252
+ } from "./chunk-YDKF4MSJ.js";
253
253
  import {
254
254
  searchHarmonicRetrieval
255
- } from "./chunk-SIHSCCUQ.js";
255
+ } from "./chunk-UFR6HX7A.js";
256
256
  import {
257
257
  isAboveImportanceThreshold,
258
258
  scoreImportance
@@ -287,7 +287,7 @@ import {
287
287
  materializeAfterSemanticConsolidation,
288
288
  parseConsolidationResponse,
289
289
  parseOperatorAwareConsolidationResponse
290
- } from "./chunk-ZQHI2BZB.js";
290
+ } from "./chunk-HF5BUTI6.js";
291
291
  import {
292
292
  BootstrapEngine
293
293
  } from "./chunk-MYVPLJOO.js";
@@ -305,7 +305,7 @@ import {
305
305
  } from "./chunk-6TBIWIAG.js";
306
306
  import {
307
307
  detectMeetings
308
- } from "./chunk-BWLRUMOG.js";
308
+ } from "./chunk-DPNXADEI.js";
309
309
  import {
310
310
  compileCorrectionRule,
311
311
  correctionsFilePath,
@@ -330,14 +330,14 @@ import {
330
330
  } from "./chunk-KD3QD3A5.js";
331
331
  import {
332
332
  MeetingsInputError
333
- } from "./chunk-4KYOLI6M.js";
333
+ } from "./chunk-XGM3VQWG.js";
334
334
  import {
335
335
  WearablesInputError,
336
336
  describeErrorForOperator
337
337
  } from "./chunk-V7IZKJI3.js";
338
338
  import {
339
339
  NamespaceCatalog
340
- } from "./chunk-SQI57UCJ.js";
340
+ } from "./chunk-DUEDOYZD.js";
341
341
  import {
342
342
  recordDreamsPhaseRun
343
343
  } from "./chunk-EQWEIIKQ.js";
@@ -354,7 +354,7 @@ import {
354
354
  filterRecallCandidates,
355
355
  isGenericRecallExcludedPath,
356
356
  isTopLevelArchivePath
357
- } from "./chunk-SB7D4BT7.js";
357
+ } from "./chunk-AZLLH6YA.js";
358
358
  import {
359
359
  importCapsule
360
360
  } from "./chunk-6433HV72.js";
@@ -380,7 +380,7 @@ import {
380
380
  } from "./chunk-ZVZHG7AI.js";
381
381
  import {
382
382
  buildXraySnapshot
383
- } from "./chunk-3I7ASZN3.js";
383
+ } from "./chunk-MFOSZUIT.js";
384
384
  import {
385
385
  objectiveStateStoreOverrideForNamespace,
386
386
  searchObjectiveStateSnapshots
@@ -395,9 +395,6 @@ import {
395
395
  import {
396
396
  LocalLlmClient
397
397
  } from "./chunk-IVKIODHO.js";
398
- import {
399
- buildProcedurePersistBody
400
- } from "./chunk-QDW3E4RD.js";
401
398
  import {
402
399
  shouldSkipImplicitExtraction
403
400
  } from "./chunk-7BEPVIH3.js";
@@ -411,7 +408,7 @@ import {
411
408
  } from "./chunk-7ZNJN5WZ.js";
412
409
  import {
413
410
  NamespaceStorageRouter
414
- } from "./chunk-LZH5FR2W.js";
411
+ } from "./chunk-CQBIN77D.js";
415
412
  import {
416
413
  GraphIndex
417
414
  } from "./chunk-BIJAWZYW.js";
@@ -462,12 +459,9 @@ import {
462
459
  isTaskInitiationIntent,
463
460
  planRecallMode
464
461
  } from "./chunk-CSAKJVXW.js";
465
- import {
466
- searchCausalTrajectories
467
- } from "./chunk-PP7R754B.js";
468
462
  import {
469
463
  buildChainFollowupGenerator
470
- } from "./chunk-NTWN6HB2.js";
464
+ } from "./chunk-IURMJBGP.js";
471
465
  import {
472
466
  QmdResultResolver,
473
467
  StorageManager,
@@ -486,7 +480,7 @@ import {
486
480
  reconstructFusionInputs,
487
481
  selfDeps,
488
482
  serializeFusionDay
489
- } from "./chunk-J275IYMG.js";
483
+ } from "./chunk-THVI4Y7X.js";
490
484
  import {
491
485
  bodyIsEscaped,
492
486
  decodeTranscriptBody,
@@ -522,7 +516,7 @@ import {
522
516
  } from "./chunk-S2V7RUCL.js";
523
517
  import {
524
518
  confidenceTier
525
- } from "./chunk-SBDCZ2AX.js";
519
+ } from "./chunk-LBFFNDFM.js";
526
520
  import {
527
521
  lintWorkspaceFiles,
528
522
  rotateMarkdownFileToArchive
@@ -590,6 +584,12 @@ import {
590
584
  import {
591
585
  assertExternalWikiRootOutsideMemoryDirCanonical
592
586
  } from "./chunk-JV3C2MNQ.js";
587
+ import {
588
+ buildProcedurePersistBody
589
+ } from "./chunk-QDW3E4RD.js";
590
+ import {
591
+ searchCausalTrajectories
592
+ } from "./chunk-PP7R754B.js";
593
593
  import {
594
594
  evaluateSubjectGuard,
595
595
  isSharedPromotionTarget,
@@ -650,13 +650,13 @@ import {
650
650
  excludeSupportPassportPrivateMemories,
651
651
  isSupportPassportPrivateMemory
652
652
  } from "./chunk-XDL5CYZN.js";
653
+ import {
654
+ ContentHashIndex
655
+ } from "./chunk-JOEJG4SD.js";
653
656
  import {
654
657
  normalizeAttributePairs,
655
658
  stripAttributesSuffix
656
659
  } from "./chunk-JDSVLVCG.js";
657
- import {
658
- ContentHashIndex
659
- } from "./chunk-JOEJG4SD.js";
660
660
  import {
661
661
  sanitizeMemoryContent
662
662
  } from "./chunk-5GKPFL3S.js";
@@ -2061,6 +2061,49 @@ ${body}
2061
2061
  }
2062
2062
  };
2063
2063
 
2064
+ // src/preferences/drift-recall.ts
2065
+ var DAY_MS = 24 * 60 * 60 * 1e3;
2066
+ function isPreferenceDriftStageActive(config) {
2067
+ if (!config) return false;
2068
+ const damping = config.recallDamping && config.stalePenalty < 1;
2069
+ return damping || config.annotateAfterDays > 0;
2070
+ }
2071
+ function driftAgeNote(frontmatter, config, now) {
2072
+ if (config.annotateAfterDays <= 0) return void 0;
2073
+ if (!frontmatter || frontmatter.category !== "preference") return void 0;
2074
+ const anchor = frontmatter.lastCorroborated ?? frontmatter.created;
2075
+ if (typeof anchor !== "string") return void 0;
2076
+ const anchorMs = Date.parse(anchor);
2077
+ if (!Number.isFinite(anchorMs)) return void 0;
2078
+ const ageDays = Math.floor((now.getTime() - anchorMs) / DAY_MS);
2079
+ if (ageDays < config.annotateAfterDays) return void 0;
2080
+ const stated = new Date(anchorMs).toISOString().slice(0, 7);
2081
+ return frontmatter.lastCorroborated ? `(corroborated ${stated}; not since)` : `(stated ${stated}; not corroborated since)`;
2082
+ }
2083
+ function applyPreferenceDriftRanking(inputs, options) {
2084
+ const { config, now } = options;
2085
+ const damping = config.recallDamping && config.stalePenalty < 1;
2086
+ const scored = inputs.map((input, index) => {
2087
+ const fm = input.frontmatter;
2088
+ const isStalePreference = fm?.category === "preference" && fm.driftState === "stale";
2089
+ const multiplier = damping && isStalePreference ? config.stalePenalty : 1;
2090
+ return {
2091
+ key: input.key,
2092
+ index,
2093
+ multiplier,
2094
+ damped: input.rank * multiplier,
2095
+ note: driftAgeNote(fm, config, now)
2096
+ };
2097
+ });
2098
+ scored.sort((a, b) => {
2099
+ if (a.damped !== b.damped) return a.damped > b.damped ? -1 : 1;
2100
+ if (a.index !== b.index) return a.index < b.index ? -1 : 1;
2101
+ if (a.key !== b.key) return a.key < b.key ? -1 : 1;
2102
+ return 0;
2103
+ });
2104
+ return scored.map((s) => s.note ? { key: s.key, multiplier: s.multiplier, note: s.note } : { key: s.key, multiplier: s.multiplier });
2105
+ }
2106
+
2064
2107
  // src/orchestration/recall-rerank-coordinator.ts
2065
2108
  function reconcileRecallResultPartition(partition, appliedResults) {
2066
2109
  return partition ? { appliedResults, headroomResults: partition.headroomResults } : null;
@@ -2260,7 +2303,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
2260
2303
  namespaces,
2261
2304
  {
2262
2305
  readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
2263
- readMemoryFrontmatter: async (path35, preferredNamespace) => {
2306
+ readMemoryFrontmatter: async (path34, preferredNamespace) => {
2264
2307
  if (!fallbackReader) {
2265
2308
  for (const ns of namespaces) {
2266
2309
  try {
@@ -2272,7 +2315,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
2272
2315
  }
2273
2316
  if (!fallbackReader) return null;
2274
2317
  const memory = await this.readQmdResultMemory(
2275
- path35,
2318
+ path34,
2276
2319
  fallbackReader,
2277
2320
  namespaces,
2278
2321
  preferredNamespace
@@ -2337,9 +2380,13 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
2337
2380
  * errors so a storage hiccup never breaks a fallback path.
2338
2381
  */
2339
2382
  async applyTrustScoreToBranch(results, namespaces, caps, label, preloadedFrontmatter, abortSignal) {
2383
+ let staged = results;
2384
+ let trustByPath = null;
2340
2385
  if (caps.recallTrustScore && results.length > 0) {
2341
2386
  try {
2342
- return await this.applyTrustScoreRerank(results, namespaces, preloadedFrontmatter, abortSignal);
2387
+ const outcome = await this.applyTrustScoreRerank(results, namespaces, preloadedFrontmatter, abortSignal);
2388
+ staged = outcome.results;
2389
+ trustByPath = outcome.trustByPath;
2343
2390
  } catch (err) {
2344
2391
  log.debug(`trust-score stage (${label}) failed open`, {
2345
2392
  error: err.message
@@ -2347,20 +2394,106 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
2347
2394
  }
2348
2395
  } else if (caps.recallMemoryWorthFilter && results.length > 0) {
2349
2396
  try {
2350
- const filtered = await this.applyMemoryWorthRerank(
2397
+ staged = await this.applyMemoryWorthRerank(
2351
2398
  results,
2352
2399
  namespaces,
2353
2400
  preloadedFrontmatter,
2354
2401
  abortSignal
2355
2402
  );
2356
- return { results: filtered, trustByPath: null };
2357
2403
  } catch (err) {
2358
2404
  log.debug(`memory-worth filter (${label}) failed open`, {
2359
2405
  error: err.message
2360
2406
  });
2361
2407
  }
2362
2408
  }
2363
- return { results, trustByPath: null };
2409
+ const damped = await this.applyPreferenceDriftStage(
2410
+ staged,
2411
+ namespaces,
2412
+ preloadedFrontmatter,
2413
+ abortSignal
2414
+ );
2415
+ return { results: damped, trustByPath };
2416
+ }
2417
+ /**
2418
+ * Issue #2371 — stale-preference damping + injection annotation.
2419
+ *
2420
+ * Runs immediately after the trust/Memory-Worth stage on EVERY recall branch
2421
+ * (hot QMD, embedding fallback, recent scan, cold fallback), so the feature
2422
+ * gate applies uniformly and fallback parity holds (§27, AGENTS.md retrieval
2423
+ * guardrails). Fully inert on the default config: when neither damping nor
2424
+ * annotation is active the input array is returned untouched and NO
2425
+ * frontmatter is read, so recall ordering and injected text stay
2426
+ * byte-identical to pre-#2371.
2427
+ *
2428
+ * Fail-open: any lookup error leaves the branch's results unchanged.
2429
+ */
2430
+ async applyPreferenceDriftStage(results, namespaces, preloadedFrontmatter, abortSignal) {
2431
+ const config = this.getConfig();
2432
+ if (!isPreferenceDriftStageActive(config.driftDetection)) return results;
2433
+ if (results.length === 0) return results;
2434
+ try {
2435
+ const frontmatterByKey = /* @__PURE__ */ new Map();
2436
+ const missing = [];
2437
+ for (const r of results) {
2438
+ const key = memoryMapKey(r);
2439
+ const preloaded = preloadedFrontmatter?.get(key) ?? preloadedFrontmatter?.get(r.path);
2440
+ if (preloaded) {
2441
+ frontmatterByKey.set(key, preloaded.frontmatter);
2442
+ } else {
2443
+ missing.push(r);
2444
+ }
2445
+ }
2446
+ if (missing.length > 0) {
2447
+ let reader = null;
2448
+ for (const ns of namespaces) {
2449
+ try {
2450
+ reader = await this.getStorage(ns);
2451
+ break;
2452
+ } catch {
2453
+ }
2454
+ }
2455
+ if (reader) {
2456
+ const readerNn = reader;
2457
+ const BATCH = 16;
2458
+ for (let off = 0; off < missing.length; off += BATCH) {
2459
+ if (abortSignal?.aborted) break;
2460
+ await Promise.all(
2461
+ missing.slice(off, off + BATCH).map(async (r) => {
2462
+ try {
2463
+ const memory = await this.readQmdResultMemory(r.path, readerNn, namespaces, r.namespace);
2464
+ if (memory) frontmatterByKey.set(memoryMapKey(r), memory.frontmatter);
2465
+ } catch (err) {
2466
+ log.debug("preference-drift: direct path lookup failed", {
2467
+ path: r.path,
2468
+ error: err.message
2469
+ });
2470
+ }
2471
+ })
2472
+ );
2473
+ }
2474
+ }
2475
+ }
2476
+ const ranked = results.map((r, i) => ({
2477
+ key: memoryMapKey(r),
2478
+ rank: results.length - i,
2479
+ frontmatter: frontmatterByKey.get(memoryMapKey(r))
2480
+ }));
2481
+ const ordered = applyPreferenceDriftRanking(ranked, {
2482
+ config: config.driftDetection,
2483
+ now: /* @__PURE__ */ new Date()
2484
+ });
2485
+ const byKey = new Map(results.map((r) => [memoryMapKey(r), r]));
2486
+ const reordered = [];
2487
+ for (const item of ordered) {
2488
+ const original = byKey.get(item.key);
2489
+ if (!original) continue;
2490
+ reordered.push(item.note ? { ...original, driftNote: item.note } : original);
2491
+ }
2492
+ return reordered;
2493
+ } catch (err) {
2494
+ log.debug("preference-drift stage failed open", { error: err.message });
2495
+ return results;
2496
+ }
2364
2497
  }
2365
2498
  diversifyRecallResultsWithHeadroom(sectionId, results, limit, retrievalQuery, caps = resolveCapabilities(this.getConfig())) {
2366
2499
  const safeLimit = typeof limit === "number" && Number.isFinite(limit) ? Math.max(0, Math.floor(limit)) : 0;
@@ -13491,6 +13624,13 @@ var RecallSearchPipelineCoordinator = class {
13491
13624
  });
13492
13625
  }
13493
13626
  }
13627
+ if (results.length > 0) {
13628
+ results = await this.deps.recallRerankCoordinator.applyPreferenceDriftStage(
13629
+ results,
13630
+ options.recallNamespaces,
13631
+ boostInput.memoryByPath
13632
+ );
13633
+ }
13494
13634
  if (options.xrayPoolSizeSink) {
13495
13635
  options.xrayPoolSizeSink.size = Math.max(
13496
13636
  options.xrayPoolSizeSink.size,
@@ -15512,7 +15652,7 @@ var OrchestratorInitCoordinator = class {
15512
15652
  if (signal.aborted) return;
15513
15653
  if (!this.deps.wearablesAutoSyncHandle && this.deps.config.wearables.enabled && this.deps.config.wearables.autoSyncEnabled && Object.values(this.deps.config.wearables.sources).some((source) => source.enabled)) {
15514
15654
  try {
15515
- const { startWearablesAutoSync } = await import("./auto-sync-H64ZCNIR.js");
15655
+ const { startWearablesAutoSync } = await import("./auto-sync-XVMLL2RH.js");
15516
15656
  if (signal.aborted) return;
15517
15657
  this.deps.wearablesAutoSyncHandle = startWearablesAutoSync(
15518
15658
  {
@@ -22158,9 +22298,9 @@ function readStructuralSymbol(entry) {
22158
22298
  const rec = entry;
22159
22299
  const symbol = typeof rec.symbol === "string" ? rec.symbol.trim() : "";
22160
22300
  if (!symbol) return null;
22161
- const path35 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
22301
+ const path34 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
22162
22302
  const kind = typeof rec.kind === "string" && rec.kind.length > 0 ? rec.kind : void 0;
22163
- const item = path35 !== void 0 && kind !== void 0 ? { symbol, path: path35, kind } : path35 !== void 0 ? { symbol, path: path35 } : kind !== void 0 ? { symbol, kind } : { symbol };
22303
+ const item = path34 !== void 0 && kind !== void 0 ? { symbol, path: path34, kind } : path34 !== void 0 ? { symbol, path: path34 } : kind !== void 0 ? { symbol, kind } : { symbol };
22164
22304
  return item;
22165
22305
  }
22166
22306
  function classifySpawnError(err) {
@@ -24431,474 +24571,9 @@ function walkMdFiles(dir, memoryRootReal, categoryRootReal, callback) {
24431
24571
  }
24432
24572
  }
24433
24573
 
24434
- // src/review/index.ts
24574
+ // src/sync/index.ts
24435
24575
  import fs5 from "fs";
24436
24576
  import path29 from "path";
24437
- var historicalIdCache3 = new HistoricalEntityCanonicalIdCache();
24438
- function writeReviewFileCanonicalized(memoryDir, filePath, content) {
24439
- const stateDir = path29.join(memoryDir, "state");
24440
- const idsAtWrite = historicalIdCache3.get(stateDir);
24441
- let originalBytes = null;
24442
- try {
24443
- originalBytes = fs5.readFileSync(filePath, "utf8");
24444
- } catch {
24445
- originalBytes = null;
24446
- }
24447
- const written = canonicalizeEntityRefFrontmatter(content, idsAtWrite);
24448
- fs5.writeFileSync(filePath, written, "utf8");
24449
- try {
24450
- repairContentAfterJournalMoveSync({
24451
- stateDir,
24452
- cache: historicalIdCache3,
24453
- idsAtWrite,
24454
- rawContent: content,
24455
- lastWritten: written,
24456
- rewrite: (next) => fs5.writeFileSync(filePath, next, "utf8")
24457
- });
24458
- } catch (err) {
24459
- try {
24460
- if (originalBytes === null) {
24461
- fs5.unlinkSync(filePath);
24462
- } else {
24463
- fs5.writeFileSync(filePath, originalBytes, "utf8");
24464
- }
24465
- } catch {
24466
- }
24467
- throw err;
24468
- }
24469
- }
24470
- var DEFAULT_CONFIDENCE_THRESHOLD = 0.7;
24471
- function realMemoryRoot(memoryDir) {
24472
- try {
24473
- const stat5 = fs5.lstatSync(memoryDir);
24474
- if (!stat5.isDirectory() || stat5.isSymbolicLink()) return null;
24475
- return fs5.realpathSync(memoryDir);
24476
- } catch {
24477
- return null;
24478
- }
24479
- }
24480
- function isPathInside2(rootReal, candidateReal) {
24481
- const relative = path29.relative(rootReal, candidateReal);
24482
- return relative === "" || !!relative && !relative.startsWith("..") && !path29.isAbsolute(relative);
24483
- }
24484
- function isSafeDirectory(rootReal, dir) {
24485
- try {
24486
- const stat5 = fs5.lstatSync(dir);
24487
- if (!stat5.isDirectory() || stat5.isSymbolicLink()) return false;
24488
- return isPathInside2(rootReal, fs5.realpathSync(dir));
24489
- } catch {
24490
- return false;
24491
- }
24492
- }
24493
- function ensureSafeDirectory(rootReal, dir) {
24494
- if (fs5.existsSync(dir)) {
24495
- if (!isSafeDirectory(rootReal, dir)) {
24496
- throw new Error(`Refusing to write through unsafe review path: ${dir}`);
24497
- }
24498
- return;
24499
- }
24500
- fs5.mkdirSync(dir, { recursive: true });
24501
- if (!isSafeDirectory(rootReal, dir)) {
24502
- throw new Error(`Refusing to write through unsafe review path: ${dir}`);
24503
- }
24504
- }
24505
- function listReviewItems(options) {
24506
- const startTime = Date.now();
24507
- const {
24508
- memoryDir,
24509
- reason: filterReason,
24510
- limit = 50,
24511
- confidenceThreshold = DEFAULT_CONFIDENCE_THRESHOLD
24512
- } = options;
24513
- const maxItems = Math.max(0, limit);
24514
- const rootReal = realMemoryRoot(memoryDir);
24515
- if (!rootReal || maxItems === 0) {
24516
- return { items: [], total: 0, durationMs: Date.now() - startTime };
24517
- }
24518
- const items = [];
24519
- const isLimitReached = () => items.length >= maxItems;
24520
- const addItem = (item) => {
24521
- if (isLimitReached()) return;
24522
- if (filterReason && item.reviewReason !== filterReason) return;
24523
- items.push(item);
24524
- };
24525
- const suggestionsDir = path29.join(memoryDir, "suggestions");
24526
- if (!isLimitReached() && fs5.existsSync(suggestionsDir) && isSafeDirectory(rootReal, suggestionsDir)) {
24527
- walkMd(rootReal, suggestionsDir, (filePath, content) => {
24528
- if (isLimitReached()) return true;
24529
- const fm = parseFrontmatter4(content);
24530
- const body = extractBody4(content);
24531
- if (!fm?.id) return false;
24532
- addItem({
24533
- id: fm.id,
24534
- content: body,
24535
- category: fm.category ?? "suggestion",
24536
- confidence: parseConfidence(fm.confidence, 0.5),
24537
- confidenceTier: fm.confidenceTier ?? "low",
24538
- source: fm.source ?? "unknown",
24539
- filePath,
24540
- created: fm.created ?? (/* @__PURE__ */ new Date()).toISOString(),
24541
- reviewReason: "suggestion"
24542
- });
24543
- return isLimitReached();
24544
- });
24545
- }
24546
- const reviewDir = path29.join(memoryDir, "review");
24547
- if (!isLimitReached() && fs5.existsSync(reviewDir) && isSafeDirectory(rootReal, reviewDir)) {
24548
- walkMd(rootReal, reviewDir, (filePath, content) => {
24549
- if (isLimitReached()) return true;
24550
- const fm = parseFrontmatter4(content);
24551
- const body = extractBody4(content);
24552
- if (!fm?.id) return false;
24553
- addItem({
24554
- id: fm.id,
24555
- content: body,
24556
- category: fm.category ?? "review",
24557
- confidence: parseConfidence(fm.confidence, 0.5),
24558
- confidenceTier: fm.confidenceTier ?? "low",
24559
- source: fm.source ?? "unknown",
24560
- filePath,
24561
- created: fm.created ?? (/* @__PURE__ */ new Date()).toISOString(),
24562
- reviewReason: fm.reviewReason ?? "low_confidence",
24563
- context: fm.context
24564
- });
24565
- return isLimitReached();
24566
- });
24567
- }
24568
- const categories = ALL_CATEGORY_DIRS;
24569
- for (const category of categories) {
24570
- if (isLimitReached()) break;
24571
- const dir = path29.join(memoryDir, category);
24572
- if (!fs5.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
24573
- walkMd(rootReal, dir, (filePath, content) => {
24574
- if (isLimitReached()) return true;
24575
- const fm = parseFrontmatter4(content);
24576
- const body = extractBody4(content);
24577
- if (!fm?.id) return false;
24578
- const confidence = parseConfidence(fm.confidence, 1);
24579
- if (confidence >= confidenceThreshold && !(typeof fm.blockedBy === "string" && fm.blockedBy.length > 0)) return false;
24580
- if (parseBoolean(fm.reviewDismissed)) return false;
24581
- if (items.some((i) => i.id === fm.id)) return false;
24582
- addItem({
24583
- id: fm.id,
24584
- content: body,
24585
- category: fm.category ?? category.slice(0, -1),
24586
- confidence,
24587
- confidenceTier: fm.confidenceTier ?? "low",
24588
- source: fm.source ?? "unknown",
24589
- filePath,
24590
- created: fm.created ?? (/* @__PURE__ */ new Date()).toISOString(),
24591
- reviewReason: typeof fm.blockedBy === "string" && fm.blockedBy.length > 0 ? "tombstone_blocked" : "low_confidence"
24592
- });
24593
- return isLimitReached();
24594
- });
24595
- }
24596
- return {
24597
- items,
24598
- total: items.length,
24599
- durationMs: Date.now() - startTime
24600
- };
24601
- }
24602
- function performReview(memoryDir, itemId, action, options = {}) {
24603
- const result = action === "approve" ? approveItem(memoryDir, itemId, options) : action === "dismiss" ? dismissItem(memoryDir, itemId, options) : flagItem(memoryDir, itemId, options);
24604
- if (result.updatedPath !== void 0) bumpMemoryCorpusVersionForDir(memoryDir);
24605
- return result;
24606
- }
24607
- function approveItem(memoryDir, itemId, options) {
24608
- const rootReal = realMemoryRoot(memoryDir);
24609
- if (!rootReal) return { itemId, action: "approve", message: "Item not found" };
24610
- const found = findReviewFileById(memoryDir, itemId, options);
24611
- if (!found) {
24612
- return { itemId, action: "approve", message: "Item not found" };
24613
- }
24614
- const content = fs5.readFileSync(found.filePath, "utf8");
24615
- const fm = parseFrontmatter4(content);
24616
- if (!fm) return { itemId, action: "approve", message: "Could not parse frontmatter" };
24617
- const blockedBy = typeof fm.blockedBy === "string" ? fm.blockedBy : null;
24618
- const fireBlockedRevocation = () => {
24619
- if (!blockedBy || !options.onApproveBlockedMemory) return;
24620
- try {
24621
- const maybe = options.onApproveBlockedMemory(blockedBy, itemId);
24622
- if (maybe && typeof maybe.then === "function") {
24623
- void maybe.catch(() => void 0);
24624
- }
24625
- } catch {
24626
- }
24627
- };
24628
- const updatedContent = updateFrontmatterFields(content, {
24629
- confidence: "0.9",
24630
- confidenceTier: "high",
24631
- reviewDismissed: null,
24632
- // Clear the tombstone-block markers so the promoted memory is active.
24633
- // Clear the tombstone-block markers AND restore active status so the
24634
- // promoted memory is fully active in recall + provenance (issue #1579
24635
- // review: leaving status: pending_review kept it invisible to recall).
24636
- ...blockedBy ? { blockedBy: null, tombstoneBlockTier: null, status: "active" } : {}
24637
- });
24638
- if (found.location === "category") {
24639
- writeReviewFileCanonicalized(memoryDir, found.filePath, updatedContent);
24640
- fireBlockedRevocation();
24641
- return {
24642
- itemId,
24643
- action: "approve",
24644
- updatedPath: found.filePath,
24645
- message: "Approved low-confidence memory in place with confidence 0.9",
24646
- ...blockedBy ? { clearedTombstoneId: blockedBy } : {}
24647
- };
24648
- }
24649
- const category = fm.category ?? "fact";
24650
- const targetDir = getCategoryDir(memoryDir, category);
24651
- const dateDir = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
24652
- ensureSafeDirectory(rootReal, targetDir);
24653
- const outputPath = path29.join(targetDir, dateDir, path29.basename(found.filePath));
24654
- ensureSafeDirectory(rootReal, path29.dirname(outputPath));
24655
- const reviewStateDir = path29.join(memoryDir, "state");
24656
- const idsAtWrite = historicalIdCache3.get(reviewStateDir);
24657
- const promotedWritten = canonicalizeEntityRefFrontmatter(updatedContent, idsAtWrite);
24658
- const promotedPath = writeFileWithoutClobber(outputPath, promotedWritten, itemId);
24659
- try {
24660
- repairContentAfterJournalMoveSync({
24661
- stateDir: reviewStateDir,
24662
- cache: historicalIdCache3,
24663
- idsAtWrite,
24664
- rawContent: updatedContent,
24665
- lastWritten: promotedWritten,
24666
- rewrite: (next) => fs5.writeFileSync(promotedPath, next, "utf8")
24667
- });
24668
- } catch (err) {
24669
- try {
24670
- fs5.unlinkSync(promotedPath);
24671
- } catch {
24672
- }
24673
- throw err;
24674
- }
24675
- fs5.unlinkSync(found.filePath);
24676
- fireBlockedRevocation();
24677
- return {
24678
- itemId,
24679
- action: "approve",
24680
- updatedPath: promotedPath,
24681
- message: `Promoted to ${category} with confidence 0.9`,
24682
- ...blockedBy ? { clearedTombstoneId: blockedBy } : {}
24683
- };
24684
- }
24685
- function dismissItem(memoryDir, itemId, options) {
24686
- const found = findReviewFileById(memoryDir, itemId, options);
24687
- if (!found) {
24688
- return { itemId, action: "dismiss", message: "Item not found" };
24689
- }
24690
- if (found.location === "queue") {
24691
- fs5.unlinkSync(found.filePath);
24692
- return { itemId, action: "dismiss", message: "Dismissed and removed" };
24693
- }
24694
- const content = fs5.readFileSync(found.filePath, "utf8");
24695
- writeReviewFileCanonicalized(
24696
- memoryDir,
24697
- found.filePath,
24698
- updateFrontmatterFields(content, {
24699
- reviewDismissed: "true",
24700
- reviewDismissedAt: (/* @__PURE__ */ new Date()).toISOString()
24701
- })
24702
- );
24703
- return {
24704
- itemId,
24705
- action: "dismiss",
24706
- updatedPath: found.filePath,
24707
- message: "Dismissed low-confidence memory in place"
24708
- };
24709
- }
24710
- function flagItem(memoryDir, itemId, options) {
24711
- const found = findReviewFileById(memoryDir, itemId, options);
24712
- if (!found) {
24713
- return { itemId, action: "flag", message: "Item not found" };
24714
- }
24715
- const content = fs5.readFileSync(found.filePath, "utf8");
24716
- const fixed = updateFrontmatterFields(content, {
24717
- flagged: "true",
24718
- flaggedAt: (/* @__PURE__ */ new Date()).toISOString()
24719
- });
24720
- writeReviewFileCanonicalized(memoryDir, found.filePath, fixed);
24721
- return {
24722
- itemId,
24723
- action: "flag",
24724
- updatedPath: found.filePath,
24725
- message: "Flagged for further review"
24726
- };
24727
- }
24728
- function findReviewFileById(memoryDir, id, options = {}) {
24729
- const rootReal = realMemoryRoot(memoryDir);
24730
- if (!rootReal) return null;
24731
- for (const loc of ["suggestions", "review"]) {
24732
- const dir = path29.join(memoryDir, loc);
24733
- if (!fs5.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
24734
- const found = findFileById(rootReal, dir, id);
24735
- if (found) return { filePath: found, location: "queue" };
24736
- }
24737
- for (const category of ALL_CATEGORY_DIRS) {
24738
- const dir = path29.join(memoryDir, category);
24739
- if (!fs5.existsSync(dir) || !isSafeDirectory(rootReal, dir)) continue;
24740
- const found = findFileById(rootReal, dir, id, (fm) => isLowConfidenceReviewCandidate(fm, options));
24741
- if (found) return { filePath: found, location: "category" };
24742
- }
24743
- return null;
24744
- }
24745
- function findFileById(rootReal, dir, id, include) {
24746
- const files = walkMdPaths(rootReal, dir);
24747
- for (const filePath of files) {
24748
- const content = readFileSafe3(filePath);
24749
- if (!content) continue;
24750
- const fm = parseFrontmatter4(content);
24751
- if (fm?.id === id && (!include || include(fm))) return filePath;
24752
- }
24753
- return null;
24754
- }
24755
- function isLowConfidenceReviewCandidate(fm, options) {
24756
- const threshold = options.confidenceThreshold ?? DEFAULT_CONFIDENCE_THRESHOLD;
24757
- if (typeof fm.blockedBy === "string" && fm.blockedBy.length > 0) {
24758
- return !parseBoolean(fm.reviewDismissed);
24759
- }
24760
- return parseConfidence(fm.confidence, 1) < threshold && !parseBoolean(fm.reviewDismissed);
24761
- }
24762
- function parseBoolean(value) {
24763
- if (typeof value === "boolean") return value;
24764
- if (typeof value !== "string") return false;
24765
- const normalized = value.trim().toLowerCase();
24766
- return normalized === "true" || normalized === "1" || normalized === "yes";
24767
- }
24768
- function parseConfidence(value, fallback) {
24769
- if (typeof value === "number") return Number.isFinite(value) ? value : fallback;
24770
- if (typeof value === "string") {
24771
- const n = parseFloat(value);
24772
- return Number.isFinite(n) ? n : fallback;
24773
- }
24774
- return fallback;
24775
- }
24776
- function updateFrontmatterFields(content, fields) {
24777
- const match = content.match(/^(---\n)([\s\S]*?)(\n---(?:\n|$))/);
24778
- if (!match) return content;
24779
- const seen = /* @__PURE__ */ new Set();
24780
- const lines = match[2].split("\n");
24781
- const nextLines = [];
24782
- for (const line of lines) {
24783
- const colonIdx = line.indexOf(":");
24784
- if (colonIdx === -1) {
24785
- nextLines.push(line);
24786
- continue;
24787
- }
24788
- const key = line.slice(0, colonIdx).trim();
24789
- if (!Object.prototype.hasOwnProperty.call(fields, key)) {
24790
- nextLines.push(line);
24791
- continue;
24792
- }
24793
- seen.add(key);
24794
- const value = fields[key];
24795
- if (value !== null) {
24796
- nextLines.push(`${key}: ${value}`);
24797
- }
24798
- }
24799
- for (const [key, value] of Object.entries(fields)) {
24800
- if (value !== null && !seen.has(key)) {
24801
- nextLines.push(`${key}: ${value}`);
24802
- }
24803
- }
24804
- return `${match[1]}${nextLines.join("\n")}${match[3]}${content.slice(match[0].length)}`;
24805
- }
24806
- function readFileSafe3(filePath) {
24807
- try {
24808
- return fs5.readFileSync(filePath, "utf8");
24809
- } catch {
24810
- return null;
24811
- }
24812
- }
24813
- function writeFileWithoutClobber(basePath, content, discriminator) {
24814
- const parsed = path29.parse(basePath);
24815
- const safeDiscriminator = sanitizeFilePart(discriminator);
24816
- for (let attempt = 0; attempt < 1e3; attempt++) {
24817
- const candidate = attempt === 0 ? basePath : path29.join(
24818
- parsed.dir,
24819
- `${parsed.name}-${safeDiscriminator}${attempt === 1 ? "" : `-${attempt}`}${parsed.ext || ".md"}`
24820
- );
24821
- try {
24822
- fs5.writeFileSync(candidate, content, { encoding: "utf8", flag: "wx" });
24823
- return candidate;
24824
- } catch (error) {
24825
- if (error.code === "EEXIST") continue;
24826
- throw error;
24827
- }
24828
- }
24829
- throw new Error(`Could not find a free review promotion path for ${basePath}`);
24830
- }
24831
- function sanitizeFilePart(value) {
24832
- const chars = [];
24833
- let previousWasDash = false;
24834
- for (const char of value) {
24835
- const next = isSafeFilePartChar(char) ? char : "-";
24836
- if (next === "-" && previousWasDash) continue;
24837
- chars.push(next);
24838
- previousWasDash = next === "-";
24839
- if (chars.length >= 64) break;
24840
- }
24841
- let start = 0;
24842
- let end = chars.length;
24843
- while (start < end && chars[start] === "-") start++;
24844
- while (end > start && chars[end - 1] === "-") end--;
24845
- const sanitized = chars.slice(start, end).join("");
24846
- return sanitized || "review-item";
24847
- }
24848
- function isSafeFilePartChar(value) {
24849
- if (value.length !== 1) return false;
24850
- const code = value.charCodeAt(0);
24851
- return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || value === "." || value === "_" || value === "-";
24852
- }
24853
- function parseFrontmatter4(content) {
24854
- const match = content.match(/^---\n([\s\S]*?)\n---/);
24855
- if (!match) return null;
24856
- const fm = {};
24857
- for (const line of match[1].split("\n")) {
24858
- const colonIdx = line.indexOf(":");
24859
- if (colonIdx === -1) continue;
24860
- const key = line.slice(0, colonIdx).trim();
24861
- const value = line.slice(colonIdx + 1).trim();
24862
- fm[key] = value;
24863
- }
24864
- return fm;
24865
- }
24866
- function extractBody4(content) {
24867
- const match = content.match(/^---\n[\s\S]*?\n---\n([\s\S]*)/);
24868
- return match ? match[1].trim() : content.trim();
24869
- }
24870
- function walkMd(rootReal, dir, callback) {
24871
- if (!isSafeDirectory(rootReal, dir)) return false;
24872
- for (const entry of fs5.readdirSync(dir, { withFileTypes: true })) {
24873
- const fullPath = path29.join(dir, entry.name);
24874
- if (entry.isSymbolicLink()) continue;
24875
- if (entry.isDirectory()) {
24876
- if (walkMd(rootReal, fullPath, callback)) return true;
24877
- } else if (entry.isFile() && entry.name.endsWith(".md")) {
24878
- const content = readFileSafe3(fullPath);
24879
- if (content && callback(fullPath, content) === true) return true;
24880
- }
24881
- }
24882
- return false;
24883
- }
24884
- function walkMdPaths(rootReal, dir) {
24885
- const results = [];
24886
- if (!isSafeDirectory(rootReal, dir)) return results;
24887
- for (const entry of fs5.readdirSync(dir, { withFileTypes: true })) {
24888
- const fullPath = path29.join(dir, entry.name);
24889
- if (entry.isSymbolicLink()) continue;
24890
- if (entry.isDirectory()) {
24891
- results.push(...walkMdPaths(rootReal, fullPath));
24892
- } else if (entry.isFile() && entry.name.endsWith(".md")) {
24893
- results.push(fullPath);
24894
- }
24895
- }
24896
- return results;
24897
- }
24898
-
24899
- // src/sync/index.ts
24900
- import fs6 from "fs";
24901
- import path30 from "path";
24902
24577
  import crypto6 from "crypto";
24903
24578
  var DEFAULT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".txt", ".mdx", ".rst"]);
24904
24579
  var DEFAULT_EXCLUDE2 = /* @__PURE__ */ new Set([
@@ -24920,7 +24595,7 @@ function syncChanges(options) {
24920
24595
  } = options;
24921
24596
  const extSet = new Set(extensions);
24922
24597
  const excludeSet = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE2, ...excludeDirs]);
24923
- const stateFilePath = options.stateFile ?? path30.join(memoryDir, ".sync-state.json");
24598
+ const stateFilePath = options.stateFile ?? path29.join(memoryDir, ".sync-state.json");
24924
24599
  const prevState = loadState(stateFilePath);
24925
24600
  const currentFiles = scanFiles(sourceDir, extSet, excludeSet);
24926
24601
  const changes = computeDiff(currentFiles, prevState.fileHashes, sourceDir);
@@ -24936,8 +24611,8 @@ function syncChanges(options) {
24936
24611
  for (const [relPath, hash] of Object.entries(currentFiles)) {
24937
24612
  newState.fileHashes[relPath] = hash;
24938
24613
  }
24939
- fs6.mkdirSync(path30.dirname(stateFilePath), { recursive: true });
24940
- fs6.writeFileSync(stateFilePath, JSON.stringify(newState, null, 2));
24614
+ fs5.mkdirSync(path29.dirname(stateFilePath), { recursive: true });
24615
+ fs5.writeFileSync(stateFilePath, JSON.stringify(newState, null, 2));
24941
24616
  }
24942
24617
  return {
24943
24618
  scanned: Object.keys(currentFiles).length,
@@ -24991,7 +24666,7 @@ function scanFiles(root, extensions, exclude) {
24991
24666
  function walk(dir, isRoot = false) {
24992
24667
  let entries;
24993
24668
  try {
24994
- entries = fs6.readdirSync(dir, { withFileTypes: true });
24669
+ entries = fs5.readdirSync(dir, { withFileTypes: true });
24995
24670
  } catch (err) {
24996
24671
  if (isRoot) {
24997
24672
  throw new Error(
@@ -25002,15 +24677,15 @@ function scanFiles(root, extensions, exclude) {
25002
24677
  }
25003
24678
  for (const entry of entries) {
25004
24679
  if (exclude.has(entry.name)) continue;
25005
- const fullPath = path30.join(dir, entry.name);
24680
+ const fullPath = path29.join(dir, entry.name);
25006
24681
  if (entry.isDirectory()) {
25007
24682
  walk(fullPath);
25008
24683
  } else if (entry.isFile()) {
25009
- const ext = path30.extname(entry.name).toLowerCase();
24684
+ const ext = path29.extname(entry.name).toLowerCase();
25010
24685
  if (!extensions.has(ext)) continue;
25011
- const relPath = path30.relative(root, fullPath);
24686
+ const relPath = path29.relative(root, fullPath);
25012
24687
  try {
25013
- const content = fs6.readFileSync(fullPath, "utf8");
24688
+ const content = fs5.readFileSync(fullPath, "utf8");
25014
24689
  result[relPath] = hashContent3(content);
25015
24690
  } catch {
25016
24691
  }
@@ -25023,11 +24698,11 @@ function scanFiles(root, extensions, exclude) {
25023
24698
  function computeDiff(current, previous, sourceDir) {
25024
24699
  const changes = [];
25025
24700
  for (const [relPath, hash] of Object.entries(current)) {
25026
- const fullPath = path30.join(sourceDir, relPath);
24701
+ const fullPath = path29.join(sourceDir, relPath);
25027
24702
  if (!(relPath in previous)) {
25028
24703
  let size = 0;
25029
24704
  try {
25030
- size = fs6.statSync(fullPath).size;
24705
+ size = fs5.statSync(fullPath).size;
25031
24706
  } catch {
25032
24707
  }
25033
24708
  changes.push({
@@ -25040,7 +24715,7 @@ function computeDiff(current, previous, sourceDir) {
25040
24715
  } else if (previous[relPath] !== hash) {
25041
24716
  let size = 0;
25042
24717
  try {
25043
- size = fs6.statSync(fullPath).size;
24718
+ size = fs5.statSync(fullPath).size;
25044
24719
  } catch {
25045
24720
  }
25046
24721
  changes.push({
@@ -25056,7 +24731,7 @@ function computeDiff(current, previous, sourceDir) {
25056
24731
  for (const relPath of Object.keys(previous)) {
25057
24732
  if (!(relPath in current)) {
25058
24733
  changes.push({
25059
- filePath: path30.join(sourceDir, relPath),
24734
+ filePath: path29.join(sourceDir, relPath),
25060
24735
  relativePath: relPath,
25061
24736
  type: "deleted",
25062
24737
  currentHash: "",
@@ -25068,7 +24743,7 @@ function computeDiff(current, previous, sourceDir) {
25068
24743
  }
25069
24744
  function loadState(stateFilePath) {
25070
24745
  try {
25071
- const raw = fs6.readFileSync(stateFilePath, "utf8");
24746
+ const raw = fs5.readFileSync(stateFilePath, "utf8");
25072
24747
  return JSON.parse(raw);
25073
24748
  } catch {
25074
24749
  return {
@@ -25085,25 +24760,25 @@ function hashContent3(content) {
25085
24760
  // src/spaces/index.ts
25086
24761
  import { spawnSync } from "child_process";
25087
24762
  import crypto7 from "crypto";
25088
- import fs7 from "fs";
25089
- import path31 from "path";
25090
- var historicalIdCache4 = new HistoricalEntityCanonicalIdCache();
24763
+ import fs6 from "fs";
24764
+ import path30 from "path";
24765
+ var historicalIdCache3 = new HistoricalEntityCanonicalIdCache();
25091
24766
  var MANIFEST_VERSION = 1;
25092
24767
  var MANIFEST_LOCK_STALE_MS = 3e4;
25093
24768
  var MANIFEST_LOCK_TIMEOUT_MS = MANIFEST_LOCK_STALE_MS + 1e4;
25094
24769
  var MANIFEST_LOCK_SLEEP_MS = 20;
25095
24770
  function normalizeSpaceMemoryDir(memoryDir) {
25096
- return path31.resolve(memoryDir);
24771
+ return path30.resolve(memoryDir);
25097
24772
  }
25098
24773
  function getSpacesDir(baseDir) {
25099
24774
  const homeDir = baseDir ?? resolveHomeDir();
25100
- return path31.join(homeDir, ".config", "engram", "spaces");
24775
+ return path30.join(homeDir, ".config", "engram", "spaces");
25101
24776
  }
25102
24777
  function getManifestPath(baseDir) {
25103
- return path31.join(getSpacesDir(baseDir), "manifest.json");
24778
+ return path30.join(getSpacesDir(baseDir), "manifest.json");
25104
24779
  }
25105
24780
  function loadManifest(baseDir, memoryDirOverride) {
25106
- if (fs7.existsSync(getManifestPath(baseDir))) {
24781
+ if (fs6.existsSync(getManifestPath(baseDir))) {
25107
24782
  try {
25108
24783
  return readManifestUnlocked(baseDir, memoryDirOverride, { bootstrapIfMissing: false });
25109
24784
  } catch (error) {
@@ -25129,7 +24804,7 @@ function updateManifest(baseDir, updater, memoryDirOverride) {
25129
24804
  }
25130
24805
  function readManifestUnlocked(baseDir, memoryDirOverride, options = {}) {
25131
24806
  const manifestPath2 = getManifestPath(baseDir);
25132
- if (!fs7.existsSync(manifestPath2)) {
24807
+ if (!fs6.existsSync(manifestPath2)) {
25133
24808
  if (options.bootstrapIfMissing === false) {
25134
24809
  const error = new Error(`Spaces manifest not found: ${manifestPath2}`);
25135
24810
  error.code = "ENOENT";
@@ -25142,21 +24817,21 @@ function readManifestUnlocked(baseDir, memoryDirOverride, options = {}) {
25142
24817
  version: MANIFEST_VERSION
25143
24818
  };
25144
24819
  }
25145
- const raw = JSON.parse(fs7.readFileSync(manifestPath2, "utf8"));
24820
+ const raw = JSON.parse(fs6.readFileSync(manifestPath2, "utf8"));
25146
24821
  return raw;
25147
24822
  }
25148
24823
  function saveManifestUnlocked(manifest, baseDir) {
25149
24824
  const manifestPath2 = getManifestPath(baseDir);
25150
- const manifestDir2 = path31.dirname(manifestPath2);
25151
- fs7.mkdirSync(manifestDir2, { recursive: true });
25152
- const tempPath = path31.join(manifestDir2, `.manifest.${process.pid}.${Date.now()}.${crypto7.randomUUID()}.tmp`);
24825
+ const manifestDir2 = path30.dirname(manifestPath2);
24826
+ fs6.mkdirSync(manifestDir2, { recursive: true });
24827
+ const tempPath = path30.join(manifestDir2, `.manifest.${process.pid}.${Date.now()}.${crypto7.randomUUID()}.tmp`);
25153
24828
  try {
25154
- fs7.writeFileSync(tempPath, `${JSON.stringify(manifest, null, 2)}
24829
+ fs6.writeFileSync(tempPath, `${JSON.stringify(manifest, null, 2)}
25155
24830
  `, { flag: "wx" });
25156
- fs7.renameSync(tempPath, manifestPath2);
24831
+ fs6.renameSync(tempPath, manifestPath2);
25157
24832
  } catch (error) {
25158
24833
  try {
25159
- fs7.rmSync(tempPath, { force: true });
24834
+ fs6.rmSync(tempPath, { force: true });
25160
24835
  } catch {
25161
24836
  }
25162
24837
  throw error;
@@ -25164,7 +24839,7 @@ function saveManifestUnlocked(manifest, baseDir) {
25164
24839
  }
25165
24840
  function withManifestLock(baseDir, operation) {
25166
24841
  const lockDir = `${getManifestPath(baseDir)}.lock`;
25167
- fs7.mkdirSync(path31.dirname(lockDir), { recursive: true });
24842
+ fs6.mkdirSync(path30.dirname(lockDir), { recursive: true });
25168
24843
  const lockOwner = acquireManifestLock(lockDir);
25169
24844
  try {
25170
24845
  return operation();
@@ -25177,10 +24852,10 @@ function acquireManifestLock(lockDir) {
25177
24852
  const owner = createManifestLockOwner();
25178
24853
  const reclaimDir = getManifestLockReclaimDir(lockDir);
25179
24854
  while (true) {
25180
- if (fs7.existsSync(reclaimDir)) {
24855
+ if (fs6.existsSync(reclaimDir)) {
25181
24856
  removeStaleManifestReclaimLock(reclaimDir);
25182
24857
  }
25183
- if (fs7.existsSync(reclaimDir)) {
24858
+ if (fs6.existsSync(reclaimDir)) {
25184
24859
  if (Date.now() >= deadline) {
25185
24860
  throw new Error(`Timed out waiting for spaces manifest reclaim lock: ${reclaimDir}`);
25186
24861
  }
@@ -25188,15 +24863,15 @@ function acquireManifestLock(lockDir) {
25188
24863
  continue;
25189
24864
  }
25190
24865
  try {
25191
- fs7.mkdirSync(lockDir, { recursive: false });
24866
+ fs6.mkdirSync(lockDir, { recursive: false });
25192
24867
  try {
25193
- fs7.writeFileSync(path31.join(lockDir, "owner"), `${owner}
24868
+ fs6.writeFileSync(path30.join(lockDir, "owner"), `${owner}
25194
24869
  `, { flag: "wx" });
25195
24870
  } catch (error) {
25196
- fs7.rmSync(lockDir, { recursive: true, force: true });
24871
+ fs6.rmSync(lockDir, { recursive: true, force: true });
25197
24872
  throw error;
25198
24873
  }
25199
- if (fs7.existsSync(reclaimDir)) {
24874
+ if (fs6.existsSync(reclaimDir)) {
25200
24875
  releaseManifestLock(lockDir, owner);
25201
24876
  if (Date.now() >= deadline) {
25202
24877
  throw new Error(`Timed out waiting for spaces manifest reclaim lock: ${reclaimDir}`);
@@ -25220,9 +24895,9 @@ function acquireManifestLock(lockDir) {
25220
24895
  }
25221
24896
  function releaseManifestLock(lockDir, owner) {
25222
24897
  try {
25223
- const ownerPath = path31.join(lockDir, "owner");
25224
- if (fs7.readFileSync(ownerPath, "utf8").trim() === owner) {
25225
- fs7.rmSync(lockDir, { recursive: true, force: true });
24898
+ const ownerPath = path30.join(lockDir, "owner");
24899
+ if (fs6.readFileSync(ownerPath, "utf8").trim() === owner) {
24900
+ fs6.rmSync(lockDir, { recursive: true, force: true });
25226
24901
  }
25227
24902
  } catch (error) {
25228
24903
  if (error.code !== "ENOENT") {
@@ -25234,12 +24909,12 @@ function removeStaleManifestLock(lockDir) {
25234
24909
  const reclaimDir = getManifestLockReclaimDir(lockDir);
25235
24910
  const reclaimOwner = createManifestLockOwner();
25236
24911
  try {
25237
- fs7.mkdirSync(reclaimDir, { recursive: false });
24912
+ fs6.mkdirSync(reclaimDir, { recursive: false });
25238
24913
  try {
25239
- fs7.writeFileSync(path31.join(reclaimDir, "owner"), `${reclaimOwner}
24914
+ fs6.writeFileSync(path30.join(reclaimDir, "owner"), `${reclaimOwner}
25240
24915
  `, { flag: "wx" });
25241
24916
  } catch (error) {
25242
- fs7.rmSync(reclaimDir, { recursive: true, force: true });
24917
+ fs6.rmSync(reclaimDir, { recursive: true, force: true });
25243
24918
  throw error;
25244
24919
  }
25245
24920
  } catch (error) {
@@ -25259,16 +24934,16 @@ function removeStaleManifestLock(lockDir) {
25259
24934
  }
25260
24935
  const tombstoneDir = `${lockDir}.stale.${process.pid}.${crypto7.randomUUID()}`;
25261
24936
  try {
25262
- fs7.renameSync(lockDir, tombstoneDir);
24937
+ fs6.renameSync(lockDir, tombstoneDir);
25263
24938
  } catch (error) {
25264
24939
  if (error.code !== "ENOENT") {
25265
24940
  throw error;
25266
24941
  }
25267
24942
  return;
25268
24943
  }
25269
- fs7.rmSync(tombstoneDir, { recursive: true, force: true });
24944
+ fs6.rmSync(tombstoneDir, { recursive: true, force: true });
25270
24945
  } finally {
25271
- fs7.rmSync(reclaimDir, { recursive: true, force: true });
24946
+ fs6.rmSync(reclaimDir, { recursive: true, force: true });
25272
24947
  }
25273
24948
  }
25274
24949
  function getManifestLockReclaimDir(lockDir) {
@@ -25291,19 +24966,19 @@ function removeStaleManifestReclaimLock(reclaimDir) {
25291
24966
  }
25292
24967
  const tombstoneDir = `${reclaimDir}.stale.${process.pid}.${crypto7.randomUUID()}`;
25293
24968
  try {
25294
- fs7.renameSync(reclaimDir, tombstoneDir);
24969
+ fs6.renameSync(reclaimDir, tombstoneDir);
25295
24970
  } catch (error) {
25296
24971
  if (error.code !== "ENOENT") {
25297
24972
  throw error;
25298
24973
  }
25299
24974
  return;
25300
24975
  }
25301
- fs7.rmSync(tombstoneDir, { recursive: true, force: true });
24976
+ fs6.rmSync(tombstoneDir, { recursive: true, force: true });
25302
24977
  }
25303
24978
  function readManifestLockSnapshot(lockDir) {
25304
24979
  let stat5;
25305
24980
  try {
25306
- stat5 = fs7.statSync(lockDir);
24981
+ stat5 = fs6.statSync(lockDir);
25307
24982
  } catch (error) {
25308
24983
  if (error.code === "ENOENT") {
25309
24984
  return void 0;
@@ -25311,7 +24986,7 @@ function readManifestLockSnapshot(lockDir) {
25311
24986
  throw error;
25312
24987
  }
25313
24988
  try {
25314
- const owner = fs7.readFileSync(path31.join(lockDir, "owner"), "utf8").trim();
24989
+ const owner = fs6.readFileSync(path30.join(lockDir, "owner"), "utf8").trim();
25315
24990
  return { mtimeMs: stat5.mtimeMs, owner };
25316
24991
  } catch (error) {
25317
24992
  if (error.code === "ENOENT") {
@@ -25383,9 +25058,9 @@ function sleepSync(ms) {
25383
25058
  }
25384
25059
  function createPersonalSpace(baseDir, memoryDirOverride) {
25385
25060
  const homeDir = baseDir ?? resolveHomeDir();
25386
- const standalonePath = path31.join(homeDir, ".engram", "memory");
25387
- const openclawPath = path31.join(homeDir, ".openclaw", "workspace", "memory", "local");
25388
- const memoryDir = memoryDirOverride ?? readEnvVar("REMNIC_MEMORY_DIR") ?? readEnvVar("ENGRAM_MEMORY_DIR") ?? (fs7.existsSync(standalonePath) ? standalonePath : fs7.existsSync(openclawPath) ? openclawPath : standalonePath);
25061
+ const standalonePath = path30.join(homeDir, ".engram", "memory");
25062
+ const openclawPath = path30.join(homeDir, ".openclaw", "workspace", "memory", "local");
25063
+ const memoryDir = memoryDirOverride ?? readEnvVar("REMNIC_MEMORY_DIR") ?? readEnvVar("ENGRAM_MEMORY_DIR") ?? (fs6.existsSync(standalonePath) ? standalonePath : fs6.existsSync(openclawPath) ? openclawPath : standalonePath);
25389
25064
  const normalizedMemoryDir = normalizeSpaceMemoryDir(memoryDir);
25390
25065
  const now = (/* @__PURE__ */ new Date()).toISOString();
25391
25066
  return {
@@ -25413,7 +25088,7 @@ function createSpace(options) {
25413
25088
  const id = options.name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-");
25414
25089
  const now = (/* @__PURE__ */ new Date()).toISOString();
25415
25090
  const memoryDir = normalizeSpaceMemoryDir(
25416
- options.memoryDir ?? path31.join(getSpacesDir(options.baseDir), id, "memory")
25091
+ options.memoryDir ?? path30.join(getSpacesDir(options.baseDir), id, "memory")
25417
25092
  );
25418
25093
  const space = updateManifest(options.baseDir, (manifest) => {
25419
25094
  if (manifest.spaces.some((s) => s.id === id)) {
@@ -25433,7 +25108,7 @@ function createSpace(options) {
25433
25108
  owner: readEnvVar("USER"),
25434
25109
  parentSpaceId: options.parentSpaceId
25435
25110
  };
25436
- fs7.mkdirSync(memoryDir, { recursive: true });
25111
+ fs6.mkdirSync(memoryDir, { recursive: true });
25437
25112
  manifest.spaces.push(created);
25438
25113
  manifest.updatedAt = now;
25439
25114
  return created;
@@ -25591,9 +25266,9 @@ async function promoteSpace(sourceSpaceId, targetSpaceId, options) {
25591
25266
  const subjectWarnings = [];
25592
25267
  const warnedMemoryIds = [];
25593
25268
  if (target.kind === "team") {
25594
- const sourceFiles = fs7.existsSync(source.memoryDir) ? walkMd2(fs7.realpathSync(source.memoryDir)) : [];
25269
+ const sourceFiles = fs6.existsSync(source.memoryDir) ? walkMd(fs6.realpathSync(source.memoryDir)) : [];
25595
25270
  for (const file of sourceFiles) {
25596
- const fm = parseSimpleFrontmatter(fs7.readFileSync(file, "utf8"));
25271
+ const fm = parseSimpleFrontmatter(fs6.readFileSync(file, "utf8"));
25597
25272
  if (!fm?.id) continue;
25598
25273
  if (options?.memoryIds?.length && !options.memoryIds.includes(fm.id)) continue;
25599
25274
  const decision = evaluateSubjectGuard({
@@ -25659,39 +25334,39 @@ async function mergeSpaces(sourceSpaceId, targetSpaceId, options) {
25659
25334
  };
25660
25335
  }
25661
25336
  function getAuditLog(baseDir) {
25662
- const auditPath = path31.join(getSpacesDir(baseDir), "audit.jsonl");
25663
- if (!fs7.existsSync(auditPath)) return [];
25664
- const lines = fs7.readFileSync(auditPath, "utf8").trim().split("\n");
25337
+ const auditPath = path30.join(getSpacesDir(baseDir), "audit.jsonl");
25338
+ if (!fs6.existsSync(auditPath)) return [];
25339
+ const lines = fs6.readFileSync(auditPath, "utf8").trim().split("\n");
25665
25340
  return lines.filter((l) => l.trim()).map((l) => JSON.parse(l));
25666
25341
  }
25667
25342
  function appendAudit(entry, baseDir) {
25668
- const auditPath = path31.join(getSpacesDir(baseDir), "audit.jsonl");
25669
- fs7.mkdirSync(path31.dirname(auditPath), { recursive: true });
25343
+ const auditPath = path30.join(getSpacesDir(baseDir), "audit.jsonl");
25344
+ fs6.mkdirSync(path30.dirname(auditPath), { recursive: true });
25670
25345
  const full = {
25671
25346
  id: crypto7.randomUUID(),
25672
25347
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
25673
25348
  ...entry
25674
25349
  };
25675
- fs7.appendFileSync(auditPath, `${JSON.stringify(full)}
25350
+ fs6.appendFileSync(auditPath, `${JSON.stringify(full)}
25676
25351
  `);
25677
25352
  }
25678
25353
  async function copyMemories(sourceDir, targetDir, options) {
25679
- if (!fs7.existsSync(sourceDir)) {
25354
+ if (!fs6.existsSync(sourceDir)) {
25680
25355
  return { merged: 0, conflicts: [], skipped: 0 };
25681
25356
  }
25682
- const sourceRoot = fs7.realpathSync(sourceDir);
25683
- fs7.mkdirSync(targetDir, { recursive: true });
25684
- const targetRoot = fs7.realpathSync(targetDir);
25685
- const sourceFiles = walkMd2(sourceRoot);
25357
+ const sourceRoot = fs6.realpathSync(sourceDir);
25358
+ fs6.mkdirSync(targetDir, { recursive: true });
25359
+ const targetRoot = fs6.realpathSync(targetDir);
25360
+ const sourceFiles = walkMd(sourceRoot);
25686
25361
  const sourceEntityIds = new Set(
25687
25362
  sourceFiles.filter((p) => {
25688
25363
  const rp = safeRealpath(p);
25689
25364
  if (!rp || !isPathInsideRoot(rp, sourceRoot)) return false;
25690
- const rel = path31.relative(sourceRoot, rp);
25691
- const mapped = path31.resolve(targetRoot, rel);
25365
+ const rel = path30.relative(sourceRoot, rp);
25366
+ const mapped = path30.resolve(targetRoot, rel);
25692
25367
  if (!isPathInsideRoot(mapped, targetRoot)) return false;
25693
25368
  return classifyEntityRefWritePath(targetRoot, mapped) === "entity";
25694
- }).map((p) => path31.basename(p, ".md"))
25369
+ }).map((p) => path30.basename(p, ".md"))
25695
25370
  );
25696
25371
  const firstEntityId = sourceEntityIds.values().next().value;
25697
25372
  if (firstEntityId === void 0) {
@@ -25699,7 +25374,7 @@ async function copyMemories(sourceDir, targetDir, options) {
25699
25374
  }
25700
25375
  return withRawEntityPageMutation(
25701
25376
  targetRoot,
25702
- path31.join(targetRoot, "entities", `${firstEntityId}.md`),
25377
+ path30.join(targetRoot, "entities", `${firstEntityId}.md`),
25703
25378
  async () => copyPreparedMemories(
25704
25379
  sourceFiles,
25705
25380
  sourceRoot,
@@ -25725,15 +25400,15 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
25725
25400
  skipped++;
25726
25401
  continue;
25727
25402
  }
25728
- const content = fs7.readFileSync(sourcePath, "utf8");
25729
- const relativePath = path31.relative(sourceRoot, sourceRealPath);
25730
- const targetPath = path31.resolve(targetRoot, relativePath);
25403
+ const content = fs6.readFileSync(sourcePath, "utf8");
25404
+ const relativePath = path30.relative(sourceRoot, sourceRealPath);
25405
+ const targetPath = path30.resolve(targetRoot, relativePath);
25731
25406
  if (!isPathInsideRoot(targetPath, targetRoot)) {
25732
25407
  skipped++;
25733
25408
  continue;
25734
25409
  }
25735
25410
  const targetKind = classifyEntityRefWritePath(targetRoot, targetPath);
25736
- const idsAtCompare = historicalIdCache4.get(path31.join(targetRoot, "state"));
25411
+ const idsAtCompare = historicalIdCache3.get(path30.join(targetRoot, "state"));
25737
25412
  const sourceRef = targetKind === "memory" ? readEntityRefFromFrontmatter(content) : null;
25738
25413
  const refHasSourceClaimant = sourceRef !== null && sourceEntityIds.has(sourceRef);
25739
25414
  const canonicalContent = targetKind === "memory" && !refHasSourceClaimant ? canonicalizeEntityRefFrontmatter(content, idsAtCompare) : content;
@@ -25745,7 +25420,7 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
25745
25420
  continue;
25746
25421
  }
25747
25422
  }
25748
- if (fs7.existsSync(targetPath)) {
25423
+ if (fs6.existsSync(targetPath)) {
25749
25424
  const targetStat = safeLstat(targetPath);
25750
25425
  if (!targetStat?.isFile() || targetStat.isSymbolicLink()) {
25751
25426
  skipped++;
@@ -25757,10 +25432,10 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
25757
25432
  continue;
25758
25433
  }
25759
25434
  }
25760
- if (fs7.existsSync(targetPath) && !options?.force) {
25761
- const targetContent = fs7.readFileSync(targetPath, "utf8");
25435
+ if (fs6.existsSync(targetPath) && !options?.force) {
25436
+ const targetContent = fs6.readFileSync(targetPath, "utf8");
25762
25437
  const targetHash = hashContent4(targetContent);
25763
- if (hashContent4(canonicalContent) === targetHash && historicalIdCache4.get(path31.join(targetRoot, "state")) === idsAtCompare) {
25438
+ if (hashContent4(canonicalContent) === targetHash && historicalIdCache3.get(path30.join(targetRoot, "state")) === idsAtCompare) {
25764
25439
  skipped++;
25765
25440
  continue;
25766
25441
  }
@@ -25776,48 +25451,48 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
25776
25451
  continue;
25777
25452
  }
25778
25453
  }
25779
- fs7.mkdirSync(path31.dirname(targetPath), { recursive: true });
25780
- const targetParentRealPath = safeRealpath(path31.dirname(targetPath));
25454
+ fs6.mkdirSync(path30.dirname(targetPath), { recursive: true });
25455
+ const targetParentRealPath = safeRealpath(path30.dirname(targetPath));
25781
25456
  if (!targetParentRealPath || !isPathInsideRoot(targetParentRealPath, targetRoot)) {
25782
25457
  skipped++;
25783
25458
  continue;
25784
25459
  }
25785
- const stateDir = path31.join(targetRoot, "state");
25460
+ const stateDir = path30.join(targetRoot, "state");
25786
25461
  if (targetKind === "memory" && !refHasSourceClaimant) {
25787
- const idsAtWrite = historicalIdCache4.get(stateDir);
25462
+ const idsAtWrite = historicalIdCache3.get(stateDir);
25788
25463
  const written = canonicalizeEntityRefFrontmatter(content, idsAtWrite);
25789
25464
  let priorTarget = null;
25790
25465
  try {
25791
- priorTarget = fs7.readFileSync(targetPath, "utf8");
25466
+ priorTarget = fs6.readFileSync(targetPath, "utf8");
25792
25467
  } catch {
25793
25468
  priorTarget = null;
25794
25469
  }
25795
- fs7.writeFileSync(targetPath, written);
25470
+ fs6.writeFileSync(targetPath, written);
25796
25471
  try {
25797
25472
  repairContentAfterJournalMoveSync({
25798
25473
  stateDir,
25799
- cache: historicalIdCache4,
25474
+ cache: historicalIdCache3,
25800
25475
  idsAtWrite,
25801
25476
  rawContent: content,
25802
25477
  lastWritten: written,
25803
- rewrite: (next) => fs7.writeFileSync(targetPath, next)
25478
+ rewrite: (next) => fs6.writeFileSync(targetPath, next)
25804
25479
  });
25805
25480
  } catch (err) {
25806
25481
  try {
25807
25482
  if (priorTarget === null) {
25808
- fs7.unlinkSync(targetPath);
25483
+ fs6.unlinkSync(targetPath);
25809
25484
  } else {
25810
- fs7.writeFileSync(targetPath, priorTarget);
25485
+ fs6.writeFileSync(targetPath, priorTarget);
25811
25486
  }
25812
25487
  } catch {
25813
25488
  }
25814
25489
  throw err;
25815
25490
  }
25816
25491
  } else if (targetKind === "memory") {
25817
- fs7.writeFileSync(targetPath, content);
25492
+ fs6.writeFileSync(targetPath, content);
25818
25493
  reconcileNeeded = true;
25819
25494
  } else {
25820
- fs7.writeFileSync(targetPath, content);
25495
+ fs6.writeFileSync(targetPath, content);
25821
25496
  if (targetKind === "entity") {
25822
25497
  reconcileNeeded = true;
25823
25498
  }
@@ -25826,18 +25501,18 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
25826
25501
  bumpMemoryCorpusVersionForDir(targetRoot);
25827
25502
  }
25828
25503
  if (reconcileNeeded) {
25829
- requestEntityCanonicalIdReconcileSync(path31.join(targetRoot, "state"));
25504
+ requestEntityCanonicalIdReconcileSync(path30.join(targetRoot, "state"));
25830
25505
  }
25831
25506
  return { merged, conflicts, skipped };
25832
25507
  }
25833
25508
  function hashContent4(content) {
25834
25509
  return crypto7.createHash("sha256").update(content).digest("hex").slice(0, 16);
25835
25510
  }
25836
- function walkMd2(dir) {
25511
+ function walkMd(dir) {
25837
25512
  const results = [];
25838
25513
  function walk(d) {
25839
- for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
25840
- const fullPath = path31.join(d, entry.name);
25514
+ for (const entry of fs6.readdirSync(d, { withFileTypes: true })) {
25515
+ const fullPath = path30.join(d, entry.name);
25841
25516
  if (entry.isSymbolicLink()) {
25842
25517
  continue;
25843
25518
  }
@@ -25853,21 +25528,21 @@ function walkMd2(dir) {
25853
25528
  }
25854
25529
  function safeLstat(filePath) {
25855
25530
  try {
25856
- return fs7.lstatSync(filePath);
25531
+ return fs6.lstatSync(filePath);
25857
25532
  } catch {
25858
25533
  return null;
25859
25534
  }
25860
25535
  }
25861
25536
  function safeRealpath(filePath) {
25862
25537
  try {
25863
- return fs7.realpathSync(filePath);
25538
+ return fs6.realpathSync(filePath);
25864
25539
  } catch {
25865
25540
  return null;
25866
25541
  }
25867
25542
  }
25868
25543
  function isPathInsideRoot(candidatePath, rootPath) {
25869
- const relative = path31.relative(rootPath, candidatePath);
25870
- return relative === "" || !relative.startsWith("..") && !path31.isAbsolute(relative);
25544
+ const relative = path30.relative(rootPath, candidatePath);
25545
+ return relative === "" || !relative.startsWith("..") && !path30.isAbsolute(relative);
25871
25546
  }
25872
25547
  function parseSimpleFrontmatter(content) {
25873
25548
  const match = content.match(/^---\n([\s\S]*?)\n---/);
@@ -25986,9 +25661,9 @@ var REMNIC_RECALL_DECISION_RULES = `## When to Use Recall vs Direct Read
25986
25661
  `;
25987
25662
 
25988
25663
  // src/memory-extension/codex-publisher.ts
25989
- import fs8 from "fs";
25664
+ import fs7 from "fs";
25990
25665
  import os from "os";
25991
- import path32 from "path";
25666
+ import path31 from "path";
25992
25667
  var REMNIC_EXTENSION_DIR_NAME = "remnic";
25993
25668
  function resolveEnvHome(env) {
25994
25669
  if (env === void 0) return resolveHomeDir();
@@ -25997,12 +25672,12 @@ function resolveEnvHome(env) {
25997
25672
  function expandTildeWithHome(input, homeDir) {
25998
25673
  if (input === "~") return homeDir;
25999
25674
  if (input.startsWith("~/") || input.startsWith("~\\")) {
26000
- return path32.join(homeDir, input.slice(2));
25675
+ return path31.join(homeDir, input.slice(2));
26001
25676
  }
26002
25677
  return input;
26003
25678
  }
26004
25679
  function normalizeHostRoot(input, homeDir) {
26005
- return path32.resolve(expandTildeWithHome(input.trim(), homeDir));
25680
+ return path31.resolve(expandTildeWithHome(input.trim(), homeDir));
26006
25681
  }
26007
25682
  var CodexMemoryExtensionPublisher = class {
26008
25683
  hostId = "codex";
@@ -26016,13 +25691,13 @@ var CodexMemoryExtensionPublisher = class {
26016
25691
  async resolveExtensionRoot(env) {
26017
25692
  const homeDir = resolveEnvHome(env);
26018
25693
  const codexHomeInput = env === void 0 ? readEnvVar("CODEX_HOME")?.trim() : env.CODEX_HOME?.trim();
26019
- const codexHome = codexHomeInput ? normalizeHostRoot(codexHomeInput, homeDir) : path32.resolve(homeDir, ".codex");
26020
- return path32.join(codexHome, "memories_extensions", REMNIC_EXTENSION_DIR_NAME);
25694
+ const codexHome = codexHomeInput ? normalizeHostRoot(codexHomeInput, homeDir) : path31.resolve(homeDir, ".codex");
25695
+ return path31.join(codexHome, "memories_extensions", REMNIC_EXTENSION_DIR_NAME);
26021
25696
  }
26022
25697
  async isHostAvailable() {
26023
25698
  try {
26024
- const home = readEnvVar("CODEX_HOME")?.trim() || path32.join(resolveHomeDir(), ".codex");
26025
- return fs8.existsSync(home);
25699
+ const home = readEnvVar("CODEX_HOME")?.trim() || path31.join(resolveHomeDir(), ".codex");
25700
+ return fs7.existsSync(home);
26026
25701
  } catch {
26027
25702
  return false;
26028
25703
  }
@@ -26072,22 +25747,22 @@ When running inside the Codex phase-2 consolidation sandbox:
26072
25747
  }
26073
25748
  async publish(ctx) {
26074
25749
  const extensionRoot = await this.resolveExtensionRoot();
26075
- const instructionsPath = path32.join(extensionRoot, "instructions.md");
25750
+ const instructionsPath = path31.join(extensionRoot, "instructions.md");
26076
25751
  const filesWritten = [];
26077
25752
  const skipped = [];
26078
25753
  ctx.log.info(`Publishing Codex memory extension to ${extensionRoot}`);
26079
- fs8.mkdirSync(extensionRoot, { recursive: true });
25754
+ fs7.mkdirSync(extensionRoot, { recursive: true });
26080
25755
  const content = await this.renderInstructions(ctx);
26081
25756
  const tmpPath = `${instructionsPath}.tmp-${process.pid}-${Date.now()}`;
26082
25757
  try {
26083
- fs8.writeFileSync(tmpPath, content, "utf-8");
26084
- fs8.renameSync(tmpPath, instructionsPath);
25758
+ fs7.writeFileSync(tmpPath, content, "utf-8");
25759
+ fs7.renameSync(tmpPath, instructionsPath);
26085
25760
  filesWritten.push(instructionsPath);
26086
25761
  ctx.log.info(`Wrote ${instructionsPath}`);
26087
25762
  } catch (err) {
26088
25763
  try {
26089
- if (fs8.existsSync(tmpPath)) {
26090
- fs8.unlinkSync(tmpPath);
25764
+ if (fs7.existsSync(tmpPath)) {
25765
+ fs7.unlinkSync(tmpPath);
26091
25766
  }
26092
25767
  } catch {
26093
25768
  }
@@ -26102,8 +25777,8 @@ When running inside the Codex phase-2 consolidation sandbox:
26102
25777
  }
26103
25778
  async unpublish() {
26104
25779
  const extensionRoot = await this.resolveExtensionRoot();
26105
- if (fs8.existsSync(extensionRoot)) {
26106
- fs8.rmSync(extensionRoot, { recursive: true, force: true });
25780
+ if (fs7.existsSync(extensionRoot)) {
25781
+ fs7.rmSync(extensionRoot, { recursive: true, force: true });
26107
25782
  }
26108
25783
  }
26109
25784
  };
@@ -26448,7 +26123,7 @@ async function generateActivityMemories(date, digestBody, config, deps) {
26448
26123
  // src/session-summaries/index.ts
26449
26124
  import { createHash as createHash9 } from "crypto";
26450
26125
  import { lstat as lstat3, mkdir as mkdir7, readFile as readFile7, readdir as readdir4, rename, rm, stat as stat4, writeFile as writeFile7 } from "fs/promises";
26451
- import path33 from "path";
26126
+ import path32 from "path";
26452
26127
 
26453
26128
  // src/session-summaries/adapters.ts
26454
26129
  var VALID_ROLES = /* @__PURE__ */ new Set(["user", "assistant", "tool", "system", "other"]);
@@ -26953,7 +26628,7 @@ function shortHash(value, length = 16) {
26953
26628
  async function listTranscriptFiles(root, maxFiles) {
26954
26629
  const out = [];
26955
26630
  let truncated = false;
26956
- const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path33.sep}` : entryName;
26631
+ const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path32.sep}` : entryName;
26957
26632
  async function visit(dir) {
26958
26633
  if (truncated) return;
26959
26634
  const entries = (await readdir4(dir, { withFileTypes: true })).sort(
@@ -26963,13 +26638,13 @@ async function listTranscriptFiles(root, maxFiles) {
26963
26638
  if (truncated) return;
26964
26639
  if (entry.name.startsWith(".")) continue;
26965
26640
  if (entry.isSymbolicLink()) continue;
26966
- const fullPath = path33.join(dir, entry.name);
26641
+ const fullPath = path32.join(dir, entry.name);
26967
26642
  if (entry.isDirectory()) {
26968
26643
  await visit(fullPath);
26969
26644
  continue;
26970
26645
  }
26971
26646
  if (!entry.isFile()) continue;
26972
- const ext = path33.extname(entry.name).toLowerCase();
26647
+ const ext = path32.extname(entry.name).toLowerCase();
26973
26648
  if (!SUPPORTED_EXTENSIONS.has(ext)) continue;
26974
26649
  out.push(fullPath);
26975
26650
  if (out.length > maxFiles) {
@@ -26996,7 +26671,7 @@ function normalizeInputDir(inputDir) {
26996
26671
  if (typeof inputDir !== "string" || inputDir.trim().length === 0) {
26997
26672
  throw new Error("inputDir must be a non-empty string");
26998
26673
  }
26999
- return path33.resolve(expandTildePath(inputDir.trim()));
26674
+ return path32.resolve(expandTildePath(inputDir.trim()));
27000
26675
  }
27001
26676
  function initRoleCounts() {
27002
26677
  return {
@@ -27153,11 +26828,11 @@ async function collectLocalSessionSummaries(options) {
27153
26828
  continue;
27154
26829
  }
27155
26830
  seenFileHashes.add(fileHash);
27156
- const fileExtension = path33.extname(filePath).toLowerCase();
26831
+ const fileExtension = path32.extname(filePath).toLowerCase();
27157
26832
  const parsed = await adapter.parseFile(
27158
26833
  {
27159
26834
  content,
27160
- fileName: path33.basename(filePath),
26835
+ fileName: path32.basename(filePath),
27161
26836
  fileExtension,
27162
26837
  fileRef: fileHash
27163
26838
  },
@@ -27213,7 +26888,7 @@ async function collectLocalSessionSummaries(options) {
27213
26888
  }
27214
26889
  async function readRedactionConfig(pathLike) {
27215
26890
  if (!pathLike) return void 0;
27216
- const raw = await readFile7(path33.resolve(expandTildePath(pathLike)), "utf-8");
26891
+ const raw = await readFile7(path32.resolve(expandTildePath(pathLike)), "utf-8");
27217
26892
  const parsed = JSON.parse(raw);
27218
26893
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
27219
26894
  throw new Error("redaction config must be a JSON object");
@@ -27226,15 +26901,15 @@ function toJsonl(drafts) {
27226
26901
  }
27227
26902
  function defaultDraftOutputPath(memoryDir, generatedAt) {
27228
26903
  const stamp = generatedAt.replace(/[:.]/g, "-");
27229
- return path33.join(
27230
- path33.resolve(expandTildePath(memoryDir)),
26904
+ return path32.join(
26905
+ path32.resolve(expandTildePath(memoryDir)),
27231
26906
  "state",
27232
26907
  "session-summary-drafts",
27233
26908
  `session-summaries-${stamp}.jsonl`
27234
26909
  );
27235
26910
  }
27236
26911
  async function writeDrafts(filePath, drafts) {
27237
- await mkdir7(path33.dirname(filePath), { recursive: true });
26912
+ await mkdir7(path32.dirname(filePath), { recursive: true });
27238
26913
  const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
27239
26914
  try {
27240
26915
  await writeFile7(tempPath, toJsonl(drafts), "utf-8");
@@ -27252,7 +26927,7 @@ async function runLocalSessionSummaryCliCommand(options) {
27252
26927
  });
27253
26928
  const wroteFiles = [];
27254
26929
  if (options.output) {
27255
- const outputPath = path33.resolve(expandTildePath(options.output));
26930
+ const outputPath = path32.resolve(expandTildePath(options.output));
27256
26931
  await writeDrafts(outputPath, report.drafts);
27257
26932
  wroteFiles.push(outputPath);
27258
26933
  }
@@ -27287,19 +26962,19 @@ async function runLocalSessionSummaryCliCommand(options) {
27287
26962
 
27288
26963
  // src/transfer/capsule-fork.ts
27289
26964
  import { lstat as lstat4, mkdir as mkdir8, readFile as readFile8, realpath as realpath3, writeFile as writeFile8 } from "fs/promises";
27290
- import path34 from "path";
26965
+ import path33 from "path";
27291
26966
  async function forkCapsule(opts) {
27292
26967
  validateForkId(opts.forkId);
27293
- const rootAbs = path34.resolve(opts.targetRoot);
26968
+ const rootAbs = path33.resolve(opts.targetRoot);
27294
26969
  await assertIsDirectoryNotSymlink(rootAbs, "forkCapsule", "targetRoot");
27295
- const forkDirAbs = path34.join(rootAbs, "forks", opts.forkId);
26970
+ const forkDirAbs = path33.join(rootAbs, "forks", opts.forkId);
27296
26971
  const forkEntryExists = await pathEntryExists(forkDirAbs);
27297
26972
  if (forkEntryExists) {
27298
26973
  throw new Error(
27299
26974
  `forkCapsule: fork path already exists \u2014 forkId "${opts.forkId}" is already in use at: ${forkDirAbs}`
27300
26975
  );
27301
26976
  }
27302
- const archiveAbs = path34.resolve(opts.sourceArchive);
26977
+ const archiveAbs = path33.resolve(opts.sourceArchive);
27303
26978
  const importResult = await importCapsule({
27304
26979
  archivePath: archiveAbs,
27305
26980
  root: rootAbs,
@@ -27321,10 +26996,10 @@ async function forkCapsule(opts) {
27321
26996
  importedRecords: importResult.imported.length,
27322
26997
  skippedRecords: importResult.skipped.length
27323
26998
  };
27324
- const lineagePath = path34.join(forkDirAbs, "lineage.json");
26999
+ const lineagePath = path33.join(forkDirAbs, "lineage.json");
27325
27000
  const rootReal = await realpath3(rootAbs);
27326
27001
  await assertRealpathInsideRoot(rootReal, lineagePath, `forks/${opts.forkId}/lineage.json`, "forkCapsule");
27327
- await mkdir8(path34.dirname(lineagePath), { recursive: true });
27002
+ await mkdir8(path33.dirname(lineagePath), { recursive: true });
27328
27003
  await writeFile8(lineagePath, JSON.stringify(lineage, null, 2) + "\n", "utf-8");
27329
27004
  return {
27330
27005
  archivePath: archiveAbs,
@@ -27338,11 +27013,11 @@ async function readForkLineage(targetRoot, forkId) {
27338
27013
  if (typeof forkId !== "string" || forkId.length === 0 || forkId.length > 64 || !CAPSULE_ID_PATTERN.test(forkId)) {
27339
27014
  return null;
27340
27015
  }
27341
- const rootAbs = path34.resolve(targetRoot);
27016
+ const rootAbs = path33.resolve(targetRoot);
27342
27017
  const rootReal = await realpath3(rootAbs).catch(() => rootAbs);
27343
- const lineagePath = path34.join(rootReal, "forks", forkId, "lineage.json");
27344
- const rel = path34.relative(rootReal, lineagePath);
27345
- if (rel.startsWith("..") || path34.isAbsolute(rel)) {
27018
+ const lineagePath = path33.join(rootReal, "forks", forkId, "lineage.json");
27019
+ const rel = path33.relative(rootReal, lineagePath);
27020
+ if (rel.startsWith("..") || path33.isAbsolute(rel)) {
27346
27021
  return null;
27347
27022
  }
27348
27023
  if (!await isLineagePathContained(rootReal, lineagePath)) {
@@ -27383,23 +27058,26 @@ async function pathEntryExists(absPath) {
27383
27058
  async function isLineagePathContained(rootReal, lineagePath) {
27384
27059
  let existing = lineagePath;
27385
27060
  const suffix = [];
27386
- while (existing !== path34.dirname(existing)) {
27061
+ while (existing !== path33.dirname(existing)) {
27387
27062
  const st = await lstat4(existing).catch(() => null);
27388
27063
  if (st !== null) break;
27389
- suffix.unshift(path34.basename(existing));
27390
- existing = path34.dirname(existing);
27064
+ suffix.unshift(path33.basename(existing));
27065
+ existing = path33.dirname(existing);
27391
27066
  }
27392
27067
  const existingReal = await realpath3(existing).catch(() => existing);
27393
- const targetReal = suffix.length > 0 ? path34.join(existingReal, ...suffix) : existingReal;
27394
- const rel = path34.relative(rootReal, targetReal);
27068
+ const targetReal = suffix.length > 0 ? path33.join(existingReal, ...suffix) : existingReal;
27069
+ const rel = path33.relative(rootReal, targetReal);
27395
27070
  if (rel === "") return true;
27396
27071
  if (rel === "..") return false;
27397
- if (rel.startsWith(`..${path34.sep}`)) return false;
27398
- if (path34.isAbsolute(rel)) return false;
27072
+ if (rel.startsWith(`..${path33.sep}`)) return false;
27073
+ if (path33.isAbsolute(rel)) return false;
27399
27074
  return true;
27400
27075
  }
27401
27076
 
27402
27077
  export {
27078
+ isPreferenceDriftStageActive,
27079
+ driftAgeNote,
27080
+ applyPreferenceDriftRanking,
27403
27081
  buildProcedureRecallSection,
27404
27082
  RELAY_DEMO_MISSION_ID,
27405
27083
  RELAY_DEMO_NAMESPACE,
@@ -27438,8 +27116,6 @@ export {
27438
27116
  findDuplicates,
27439
27117
  findContradictions,
27440
27118
  decideSemanticDedup,
27441
- listReviewItems,
27442
- performReview,
27443
27119
  syncChanges,
27444
27120
  watchForChanges,
27445
27121
  getSpacesDir,
@@ -27514,4 +27190,4 @@ export {
27514
27190
  blendGraphExpandedRecallScore,
27515
27191
  Orchestrator
27516
27192
  };
27517
- //# sourceMappingURL=chunk-V3MXUL3D.js.map
27193
+ //# sourceMappingURL=chunk-ZPOHEB5Z.js.map