@remnic/core 9.65.1 → 9.65.2

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 (536) hide show
  1. package/dist/access-admin-ops-surface.d.ts +11 -11
  2. package/dist/access-admin-ops-surface.js +35 -34
  3. package/dist/access-authorization-probe.d.ts +12 -13
  4. package/dist/access-authorization-probe.js +36 -35
  5. package/dist/access-boundary.d.ts +12 -156
  6. package/dist/access-boundary.js +35 -34
  7. package/dist/access-cli.js +107 -104
  8. package/dist/access-cli.js.map +1 -1
  9. package/dist/access-coding-context-resolution.d.ts +1 -1
  10. package/dist/access-extraction-force-flush.d.ts +11 -11
  11. package/dist/access-extraction-force-flush.js +35 -34
  12. package/dist/access-health-types.d.ts +1 -1
  13. package/dist/access-http-lcm-compaction.d.ts +11 -11
  14. package/dist/access-http-lifecycle-flush.d.ts +12 -13
  15. package/dist/access-http-offline-stream.d.ts +11 -11
  16. package/dist/access-http-query.d.ts +2 -2
  17. package/dist/access-http-query.js +37 -36
  18. package/dist/access-http.d.ts +12 -12
  19. package/dist/access-http.js +54 -53
  20. package/dist/access-identity-continuity-surface.d.ts +9 -9
  21. package/dist/access-identity-continuity-surface.js +35 -34
  22. package/dist/access-lcm-surface.d.ts +11 -11
  23. package/dist/access-lcm-surface.js +35 -34
  24. package/dist/access-mcp-admin-tools.js +1 -1
  25. package/dist/access-mcp-output-schemas.js +1 -1
  26. package/dist/access-mcp.d.ts +11 -11
  27. package/dist/access-mcp.js +47 -44
  28. package/dist/access-memory-search-fanout.d.ts +2 -2
  29. package/dist/{access-namespace-preflight-BKUnKsBv.d.ts → access-namespace-preflight-Dhvcl-T0.d.ts} +1 -1
  30. package/dist/access-namespace-preflight.d.ts +3 -3
  31. package/dist/access-namespace-preflight.js +35 -34
  32. package/dist/access-observe-write-surface.d.ts +11 -11
  33. package/dist/access-observe-write-surface.js +35 -34
  34. package/dist/access-offline-manifest.d.ts +9 -9
  35. package/dist/access-offline-manifest.js +5 -5
  36. package/dist/access-operations-batch.js +38 -37
  37. package/dist/access-operations.d.ts +18 -19
  38. package/dist/access-operations.js +41 -40
  39. package/dist/access-recall-concurrency.d.ts +11 -11
  40. package/dist/access-recall-concurrency.js +35 -34
  41. package/dist/access-recall-response.d.ts +11 -11
  42. package/dist/access-recall-response.js +35 -34
  43. package/dist/access-recall-surface.d.ts +11 -11
  44. package/dist/access-recall-surface.js +35 -34
  45. package/dist/access-schema.d.ts +118 -118
  46. package/dist/access-schema.js +3 -3
  47. package/dist/{access-service-B1Lbb-nQ.d.ts → access-service-Bke1alZO.d.ts} +478 -74
  48. package/dist/access-service-helpers.d.ts +11 -11
  49. package/dist/access-service.d.ts +11 -11
  50. package/dist/access-service.js +35 -34
  51. package/dist/access-surface-catalog.d.ts +12 -13
  52. package/dist/access-surface-catalog.js +39 -36
  53. package/dist/access-surface-catalog.js.map +1 -1
  54. package/dist/access-wearables-meetings-surface.d.ts +3 -3
  55. package/dist/action-confidence.d.ts +1 -1
  56. package/dist/active-memory-bridge.d.ts +1 -1
  57. package/dist/active-recall.d.ts +1 -1
  58. package/dist/active-recall.js +6 -1
  59. package/dist/active-recall.js.map +1 -1
  60. package/dist/adapters/index.js +4 -4
  61. package/dist/adapters/registry.js +2 -2
  62. package/dist/ambient-provenance.d.ts +1 -1
  63. package/dist/artifact-search.d.ts +1 -1
  64. package/dist/{auto-sync-5L7EUZ27.js → auto-sync-H64ZCNIR.js} +13 -5
  65. package/dist/{auto-sync-5L7EUZ27.js.map → auto-sync-H64ZCNIR.js.map} +1 -1
  66. package/dist/behavior-learner.d.ts +1 -1
  67. package/dist/behavior-signals.d.ts +1 -1
  68. package/dist/bootstrap.d.ts +9 -9
  69. package/dist/briefing-window.d.ts +2 -2
  70. package/dist/briefing.d.ts +2 -2
  71. package/dist/briefing.js +16 -15
  72. package/dist/buffer-surprise-report.d.ts +1 -1
  73. package/dist/buffer-turn-helpers.d.ts +1 -1
  74. package/dist/buffer.d.ts +2 -2
  75. package/dist/buffer.js +4 -4
  76. package/dist/bulk-import/index.d.ts +3 -3
  77. package/dist/calibration.d.ts +1 -1
  78. package/dist/calibration.js +1 -1
  79. package/dist/capabilities.d.ts +1 -1
  80. package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-YO5QJ6L3.js} +2 -2
  81. package/dist/{catalog-DjVhJoRM.d.ts → catalog-DV6qnbr7.d.ts} +1 -1
  82. package/dist/causal-behavior.d.ts +1 -1
  83. package/dist/causal-consolidation.d.ts +1 -1
  84. package/dist/causal-consolidation.js +17 -16
  85. package/dist/causal-consolidation.js.map +1 -1
  86. package/dist/causal-trajectory-graph.d.ts +1 -1
  87. package/dist/{chunk-LYIZXQYY.js → chunk-2E36UXVW.js} +2 -2
  88. package/dist/{chunk-7QFBLYFP.js → chunk-2XDWWPTN.js} +3 -3
  89. package/dist/{chunk-CFRBTATE.js → chunk-2YI72KM3.js} +3 -3
  90. package/dist/{chunk-3YTTAGPB.js → chunk-3DVBKTSO.js} +2 -2
  91. package/dist/{chunk-VPGRXEAB.js → chunk-3I7ASZN3.js} +2 -2
  92. package/dist/{chunk-EIR5VLIH.js → chunk-4K7IW3F7.js} +2 -2
  93. package/dist/chunk-4K7IW3F7.js.map +1 -0
  94. package/dist/{chunk-WTOE7CW4.js → chunk-4KYOLI6M.js} +13 -13
  95. package/dist/chunk-573TEZCD.js +88 -0
  96. package/dist/chunk-573TEZCD.js.map +1 -0
  97. package/dist/{chunk-ESCQ6LY7.js → chunk-5NM4OH4P.js} +3 -3
  98. package/dist/{chunk-Y23B2QXP.js → chunk-5YQ63T4B.js} +2 -2
  99. package/dist/{chunk-PMVPCZJZ.js → chunk-6433HV72.js} +2 -2
  100. package/dist/{chunk-4NZHHGVL.js → chunk-7BDZTALN.js} +4 -1
  101. package/dist/chunk-7BDZTALN.js.map +1 -0
  102. package/dist/{chunk-NS5ETDYD.js → chunk-7BEPVIH3.js} +3 -3
  103. package/dist/{chunk-JG22O53B.js → chunk-7CBKAQIG.js} +2 -1
  104. package/dist/chunk-7CBKAQIG.js.map +1 -0
  105. package/dist/{chunk-W6TSGWYS.js → chunk-7YQ4IYS2.js} +2 -2
  106. package/dist/chunk-AAXJNINV.js +55 -0
  107. package/dist/chunk-AAXJNINV.js.map +1 -0
  108. package/dist/{chunk-YQ3CBLL4.js → chunk-BWLRUMOG.js} +78 -8
  109. package/dist/chunk-BWLRUMOG.js.map +1 -0
  110. package/dist/{chunk-2NLLXCJG.js → chunk-BXLOS5AJ.js} +2 -2
  111. package/dist/{chunk-CEH2AFXG.js → chunk-C24UZSFW.js} +6 -6
  112. package/dist/{chunk-ZPN7W3OP.js → chunk-CDUUDBWJ.js} +3 -3
  113. package/dist/{chunk-5UYSCYR7.js → chunk-CT56C22C.js} +4 -4
  114. package/dist/{chunk-HJQZQUPC.js → chunk-DJZWNKFO.js} +5 -5
  115. package/dist/{chunk-X7Y7WX73.js → chunk-DQEMWVMT.js} +1 -1
  116. package/dist/{chunk-CCTVAVTT.js → chunk-DZUJ46DO.js} +2 -2
  117. package/dist/{chunk-N6TRHP72.js → chunk-EILZG5VC.js} +2 -2
  118. package/dist/{chunk-GXWDWOWP.js → chunk-GDFVPUJ5.js} +2 -2
  119. package/dist/{chunk-7PWWGYGO.js → chunk-GNCCUR6K.js} +2 -2
  120. package/dist/{chunk-KPBLJCCV.js → chunk-IID2CMUU.js} +2 -2
  121. package/dist/{chunk-DEFI2QBT.js → chunk-J275IYMG.js} +25 -22
  122. package/dist/chunk-J275IYMG.js.map +1 -0
  123. package/dist/{chunk-UYCIS6V5.js → chunk-JCWY73FK.js} +2 -2
  124. package/dist/{chunk-SYJ6EKKE.js → chunk-JYYBA7TF.js} +2 -2
  125. package/dist/{chunk-T42L3S6A.js → chunk-LBWQ65SX.js} +4 -4
  126. package/dist/{chunk-MSTNSVXI.js → chunk-LDBFXD4F.js} +2 -1
  127. package/dist/chunk-LDBFXD4F.js.map +1 -0
  128. package/dist/{chunk-LWVO2QZV.js → chunk-LGO6A7GJ.js} +50 -50
  129. package/dist/{chunk-CEQF6L5K.js → chunk-LUNJ3WFO.js} +9 -7
  130. package/dist/chunk-LUNJ3WFO.js.map +1 -0
  131. package/dist/{chunk-2572MRP2.js → chunk-LZH5FR2W.js} +2 -2
  132. package/dist/{chunk-256FBCVX.js → chunk-M4AHBM72.js} +7 -7
  133. package/dist/{chunk-YEQEGSJA.js → chunk-MN4KB2A4.js} +3 -3
  134. package/dist/{chunk-AGKIG3YA.js → chunk-NKKD4ZAU.js} +2 -2
  135. package/dist/{chunk-3TMYV3LP.js → chunk-NTWN6HB2.js} +5 -5
  136. package/dist/{chunk-63FHSH7E.js → chunk-OCZIYAE5.js} +4 -4
  137. package/dist/{chunk-I2HTKOOP.js → chunk-ODZG724P.js} +2 -2
  138. package/dist/{chunk-HQSBYI5X.js → chunk-OTHZWLUD.js} +2 -2
  139. package/dist/{chunk-4W6INNXO.js → chunk-PE255F4T.js} +2 -2
  140. package/dist/{chunk-6L27N6YI.js → chunk-QOS5LBZN.js} +2 -2
  141. package/dist/{chunk-G72IPMR7.js → chunk-R4OCGPSH.js} +2 -2
  142. package/dist/{chunk-MIBKEW7A.js → chunk-R7JAM2XF.js} +3 -3
  143. package/dist/{chunk-LCU5R6TQ.js → chunk-RAIUTAZZ.js} +22 -3
  144. package/dist/chunk-RAIUTAZZ.js.map +1 -0
  145. package/dist/chunk-RIAM7DND.js +167 -0
  146. package/dist/chunk-RIAM7DND.js.map +1 -0
  147. package/dist/{chunk-JBPKEARU.js → chunk-RKNJBZ55.js} +4 -4
  148. package/dist/{chunk-HUNSEO5U.js → chunk-S2DPMJXH.js} +2 -2
  149. package/dist/{chunk-3PXVYJMC.js → chunk-SB7D4BT7.js} +536 -114
  150. package/dist/chunk-SB7D4BT7.js.map +1 -0
  151. package/dist/{chunk-JFJ3MHGV.js → chunk-SBDCZ2AX.js} +1 -1
  152. package/dist/chunk-SBDCZ2AX.js.map +1 -0
  153. package/dist/{chunk-HQSPXTQO.js → chunk-SIHSCCUQ.js} +1 -1
  154. package/dist/{chunk-R3AAOKR2.js → chunk-SPUJNJJC.js} +2 -2
  155. package/dist/{chunk-IAY7YBXS.js → chunk-SQI57UCJ.js} +2 -2
  156. package/dist/{chunk-CTQRPANJ.js → chunk-SVSRPG6M.js} +2 -2
  157. package/dist/{chunk-56BSXSHC.js → chunk-TBOJ76ER.js} +14 -1
  158. package/dist/{chunk-56BSXSHC.js.map → chunk-TBOJ76ER.js.map} +1 -1
  159. package/dist/{chunk-Z54TXZ2F.js → chunk-TF77C7SV.js} +14 -7
  160. package/dist/chunk-TF77C7SV.js.map +1 -0
  161. package/dist/{chunk-S2VBSTTA.js → chunk-THG4GYIE.js} +2 -2
  162. package/dist/{chunk-IXRC7EQG.js → chunk-TR7DGXGI.js} +2 -2
  163. package/dist/{chunk-GEULB2VI.js → chunk-TZNQUNKL.js} +7 -1
  164. package/dist/chunk-TZNQUNKL.js.map +1 -0
  165. package/dist/{chunk-BC4QD3FM.js → chunk-UIN2BWDD.js} +2 -2
  166. package/dist/{chunk-JTSVMJHV.js → chunk-UXO5IMBK.js} +3 -3
  167. package/dist/{chunk-DBXZZIDU.js → chunk-V3MXUL3D.js} +138 -73
  168. package/dist/chunk-V3MXUL3D.js.map +1 -0
  169. package/dist/{chunk-KQAFEZQX.js → chunk-VDX2J7OX.js} +2 -2
  170. package/dist/{chunk-MUJ4QFUQ.js → chunk-W4BMEGQA.js} +4 -4
  171. package/dist/{chunk-5HK3CJAR.js → chunk-W675UJCZ.js} +2 -2
  172. package/dist/{chunk-MDVBCPOS.js → chunk-XCTXS7VY.js} +2 -2
  173. package/dist/{chunk-53ENM6F6.js → chunk-XRYZRW54.js} +2 -2
  174. package/dist/{chunk-VJ6ECBIP.js → chunk-Y7DK7HHJ.js} +2 -2
  175. package/dist/{chunk-3MADV4YC.js → chunk-YB42WZCY.js} +2 -2
  176. package/dist/{chunk-X5SDZMO7.js → chunk-YHCBJULX.js} +2 -2
  177. package/dist/{chunk-3RHFGGI5.js → chunk-YLDXWCZP.js} +20 -5
  178. package/dist/chunk-YLDXWCZP.js.map +1 -0
  179. package/dist/{chunk-6JJT5AKI.js → chunk-Z7PBQPJ4.js} +2 -2
  180. package/dist/{chunk-ALCJRQ72.js → chunk-ZO6AXLEH.js} +2 -2
  181. package/dist/{chunk-VZVP2W4O.js → chunk-ZQHI2BZB.js} +2 -2
  182. package/dist/{chunk-CUS6S7PN.js → chunk-ZWXJBFZU.js} +9 -9
  183. package/dist/chunk-ZWXJBFZU.js.map +1 -0
  184. package/dist/{cli-Pulnz-qm.d.ts → cli-cShQ13XG.d.ts} +5 -5
  185. package/dist/cli.d.ts +13 -13
  186. package/dist/cli.js +77 -75
  187. package/dist/coding/pre-action-gate.d.ts +1 -1
  188. package/dist/compounding/engine.d.ts +2 -2
  189. package/dist/compounding/engine.js +17 -16
  190. package/dist/compounding/preference-consolidator.d.ts +1 -1
  191. package/dist/compression-optimizer.d.ts +1 -1
  192. package/dist/config.d.ts +1 -1
  193. package/dist/config.js +6 -1
  194. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  195. package/dist/connectors/codex-materialize-runner.js +16 -15
  196. package/dist/connectors/codex-materialize.d.ts +1 -1
  197. package/dist/connectors/index.d.ts +1 -1
  198. package/dist/connectors/index.js +16 -15
  199. package/dist/consolidation-provenance-check.d.ts +2 -2
  200. package/dist/consolidation-undo.d.ts +2 -2
  201. package/dist/contradiction/index.d.ts +2 -2
  202. package/dist/contradiction/index.js +10 -2
  203. package/dist/converge-config.d.ts +1 -1
  204. package/dist/convergence-refresh.d.ts +2 -2
  205. package/dist/convergence-refresh.js +18 -17
  206. package/dist/conversation-index/backend.d.ts +1 -1
  207. package/dist/conversation-index/chunker.d.ts +1 -1
  208. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  209. package/dist/conversation-index/indexer.d.ts +1 -1
  210. package/dist/conversation-index/search.d.ts +1 -1
  211. package/dist/corpus-watermark.d.ts +1 -1
  212. package/dist/corpus-watermark.js +18 -17
  213. package/dist/cross-lingual-recall.d.ts +1 -1
  214. package/dist/day-summary.d.ts +1 -1
  215. package/dist/delinearize.d.ts +1 -1
  216. package/dist/dependency-propagation-config.d.ts +1 -1
  217. package/dist/{dependency-propagation-delivery-Co17gxYb.d.ts → dependency-propagation-delivery-CsGg-VwS.d.ts} +1 -1
  218. package/dist/direct-answer-wiring.d.ts +1 -1
  219. package/dist/direct-answer.d.ts +1 -1
  220. package/dist/embedding-fallback.d.ts +1 -1
  221. package/dist/enrichment/index.d.ts +1 -1
  222. package/dist/entity-origin-fields.d.ts +1 -1
  223. package/dist/entity-retrieval.d.ts +2 -2
  224. package/dist/entity-retrieval.js +16 -15
  225. package/dist/entity-schema.d.ts +1 -1
  226. package/dist/episodic-context.d.ts +1 -1
  227. package/dist/explicit-capture.d.ts +9 -9
  228. package/dist/explicit-capture.js +7 -6
  229. package/dist/external-wiki-access.d.ts +12 -13
  230. package/dist/external-wiki-access.js +36 -35
  231. package/dist/external-wiki-collection-registration.d.ts +1 -1
  232. package/dist/external-wiki-collection.d.ts +1 -1
  233. package/dist/external-wiki-mcp-tools.d.ts +11 -11
  234. package/dist/extraction-error-classification.d.ts +1 -1
  235. package/dist/extraction-faithfulness.d.ts +1 -1
  236. package/dist/extraction-judge-telemetry.d.ts +1 -1
  237. package/dist/extraction-judge-training.d.ts +1 -1
  238. package/dist/extraction-judge.d.ts +1 -1
  239. package/dist/extraction-judge.js +2 -2
  240. package/dist/extraction-liveness.d.ts +1 -1
  241. package/dist/extraction-normalization.d.ts +1 -1
  242. package/dist/extraction-normalization.js +2 -2
  243. package/dist/extraction-prompt.d.ts +2 -2
  244. package/dist/extraction-prompt.js +1 -1
  245. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  246. package/dist/extraction-source-grounding.d.ts +1 -1
  247. package/dist/extraction.d.ts +1 -1
  248. package/dist/extraction.js +22 -21
  249. package/dist/fallback-llm.d.ts +1 -1
  250. package/dist/graph-dashboard-diff.d.ts +1 -1
  251. package/dist/graph-dashboard-key.d.ts +1 -1
  252. package/dist/graph-dashboard-parser.d.ts +1 -1
  253. package/dist/graph-edge-reinforcement.d.ts +1 -1
  254. package/dist/graph-path-reconstruction.d.ts +1 -1
  255. package/dist/graph-path-scoring.d.ts +1 -1
  256. package/dist/graph-snapshot.d.ts +1 -1
  257. package/dist/graph.d.ts +1 -1
  258. package/dist/harmonic-retrieval.js +1 -1
  259. package/dist/importance.d.ts +1 -1
  260. package/dist/importers/index.d.ts +1 -1
  261. package/dist/in-flight-reads.d.ts +1 -1
  262. package/dist/index.d.ts +716 -699
  263. package/dist/index.js +173 -125
  264. package/dist/intent.d.ts +1 -1
  265. package/dist/lcm/engine.d.ts +1 -1
  266. package/dist/lcm/engine.js +3 -3
  267. package/dist/lcm/index.d.ts +1 -1
  268. package/dist/lcm/index.js +6 -6
  269. package/dist/lcm/tools.d.ts +1 -1
  270. package/dist/lifecycle.d.ts +1 -1
  271. package/dist/live-connectors-runner.d.ts +1 -1
  272. package/dist/local-llm.d.ts +1 -1
  273. package/dist/local-model-endpoint.d.ts +1 -1
  274. package/dist/maintenance/memory-governance.d.ts +1 -1
  275. package/dist/maintenance/memory-governance.js +16 -15
  276. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
  277. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +16 -15
  278. package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
  279. package/dist/maintenance/rebuild-memory-projection.js +17 -16
  280. package/dist/{maintenance-DiSLtVN7.d.ts → maintenance-jhMpeGne.d.ts} +3 -3
  281. package/dist/mcp-memory-inspector-app.d.ts +11 -11
  282. package/dist/mcp-read-only-tools.js +1 -1
  283. package/dist/memory-action-policy.d.ts +1 -1
  284. package/dist/memory-cache.d.ts +1 -1
  285. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  286. package/dist/memory-projection-store.d.ts +1 -1
  287. package/dist/memory-provenance.d.ts +1 -1
  288. package/dist/memory-snapshot.d.ts +1 -1
  289. package/dist/memory-subject-cli.d.ts +177 -0
  290. package/dist/memory-subject-cli.js +16 -0
  291. package/dist/memory-subject.d.ts +128 -0
  292. package/dist/memory-subject.js +44 -0
  293. package/dist/memory-subject.js.map +1 -0
  294. package/dist/memory-worth-outcomes.d.ts +5 -4
  295. package/dist/memory-worth-outcomes.js +1 -1
  296. package/dist/models-json.d.ts +1 -1
  297. package/dist/namespaces/migrate.d.ts +3 -3
  298. package/dist/namespaces/migrate.js +17 -16
  299. package/dist/namespaces/principal.d.ts +1 -1
  300. package/dist/namespaces/search.d.ts +1 -1
  301. package/dist/namespaces/search.js +6 -6
  302. package/dist/namespaces/storage.d.ts +3 -3
  303. package/dist/namespaces/storage.js +16 -15
  304. package/dist/native-knowledge.d.ts +1 -1
  305. package/dist/offline-sync-impression-drain.d.ts +1 -1
  306. package/dist/operator-doctor-corpus.d.ts +1 -1
  307. package/dist/operator-doctor-corpus.js +19 -18
  308. package/dist/operator-doctor-replica.d.ts +1 -1
  309. package/dist/operator-toolkit.d.ts +3 -3
  310. package/dist/operator-toolkit.js +26 -24
  311. package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
  312. package/dist/orchestration/maintenance.d.ts +4 -4
  313. package/dist/orchestration/maintenance.js +22 -21
  314. package/dist/{orchestrator-DzCaxNS4.d.ts → orchestrator-DyGUC7re.d.ts} +8 -8
  315. package/dist/orchestrator.d.ts +9 -9
  316. package/dist/orchestrator.js +108 -105
  317. package/dist/patterns-cli.d.ts +1 -1
  318. package/dist/{pipeline-HJ8DKbFl.d.ts → pipeline-C25Oxtp1.d.ts} +1 -1
  319. package/dist/policy-runtime.d.ts +1 -1
  320. package/dist/proactive-contention.d.ts +1 -1
  321. package/dist/provenance.d.ts +1 -1
  322. package/dist/{public-http-DwXauTX3.d.ts → public-http-CMe7NQzj.d.ts} +1 -1
  323. package/dist/{qmd-BzxluoLt.d.ts → qmd-DkDVCbgF.d.ts} +1 -1
  324. package/dist/qmd-preflight.d.ts +2 -2
  325. package/dist/qmd-recall-cache.d.ts +1 -1
  326. package/dist/qmd.d.ts +2 -2
  327. package/dist/qmd.js +4 -4
  328. package/dist/recall-concurrency-config.d.ts +1 -1
  329. package/dist/recall-disclosure-escalation.d.ts +1 -1
  330. package/dist/recall-explain-renderer.d.ts +1 -1
  331. package/dist/recall-explain-renderer.js +3 -3
  332. package/dist/recall-memory-map.d.ts +1 -1
  333. package/dist/recall-planner-llm.d.ts +1 -1
  334. package/dist/recall-state.d.ts +1 -1
  335. package/dist/recall-tag-filter.d.ts +1 -1
  336. package/dist/recall-timings.d.ts +1 -1
  337. package/dist/recall-xray-cli.d.ts +1 -1
  338. package/dist/recall-xray-cli.js +4 -4
  339. package/dist/recall-xray-renderer.d.ts +1 -1
  340. package/dist/recall-xray-renderer.js +3 -3
  341. package/dist/recall-xray.d.ts +1 -1
  342. package/dist/recall-xray.js +2 -2
  343. package/dist/reconcile/cursor.d.ts +1 -1
  344. package/dist/reconcile/manifest.d.ts +1 -1
  345. package/dist/reconcile/manifest.js +3 -3
  346. package/dist/reconcile/plan.d.ts +1 -1
  347. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  348. package/dist/replay/normalizers/claude.d.ts +1 -1
  349. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  350. package/dist/replay/normalizers/shared.d.ts +1 -1
  351. package/dist/replay/runner.d.ts +1 -1
  352. package/dist/replay/types.d.ts +1 -1
  353. package/dist/replica-divergence.d.ts +1 -1
  354. package/dist/replica-peers-config.d.ts +1 -1
  355. package/dist/{resolution-DKMBPXHI.js → resolution-MFY72STR.js} +11 -3
  356. package/dist/resolution-MFY72STR.js.map +1 -0
  357. package/dist/resolve-auth-token.d.ts +1 -1
  358. package/dist/resume-bundles.js +7 -2
  359. package/dist/retrieval-agents.d.ts +2 -2
  360. package/dist/retrieval-tiers.d.ts +1 -1
  361. package/dist/routing/engine.d.ts +1 -1
  362. package/dist/routing/store.d.ts +1 -1
  363. package/dist/salvage-envelope.d.ts +1 -1
  364. package/dist/salvage-envelope.js +10 -2
  365. package/dist/schemas.d.ts +104 -90
  366. package/dist/schemas.js +1 -1
  367. package/dist/{scope-profiles-CEMZz0t5.d.ts → scope-profiles-B9xMoFO-.d.ts} +1 -1
  368. package/dist/search/embed-helper.d.ts +1 -1
  369. package/dist/search/factory.d.ts +1 -1
  370. package/dist/search/factory.js +5 -5
  371. package/dist/search/index.d.ts +1 -1
  372. package/dist/search/index.js +9 -9
  373. package/dist/search/lancedb-backend.d.ts +1 -1
  374. package/dist/search/meilisearch-backend.d.ts +1 -1
  375. package/dist/search/noop-backend.d.ts +1 -1
  376. package/dist/search/orama-backend.d.ts +1 -1
  377. package/dist/search/port.d.ts +1 -1
  378. package/dist/search/remote-backend.d.ts +1 -1
  379. package/dist/{semantic-consolidation-D9dYj6vu.d.ts → semantic-consolidation-C4uykW84.d.ts} +1 -1
  380. package/dist/semantic-consolidation.d.ts +2 -2
  381. package/dist/semantic-consolidation.js +17 -16
  382. package/dist/semantic-rule-promotion.js +16 -15
  383. package/dist/semantic-rule-verifier.d.ts +1 -1
  384. package/dist/semantic-rule-verifier.js +16 -15
  385. package/dist/{service-_qgST_0y.d.ts → service-DCZDZNcV.d.ts} +2 -2
  386. package/dist/session-observer-bands.d.ts +1 -1
  387. package/dist/session-observer-state.d.ts +1 -1
  388. package/dist/shared-context/manager.d.ts +11 -11
  389. package/dist/signal.d.ts +1 -1
  390. package/dist/source-agent-qualifier.d.ts +1 -1
  391. package/dist/source-agent-qualifier.js +18 -17
  392. package/dist/{storage-B9lbNTYE.d.ts → storage-CcKmEjL8.d.ts} +3 -2
  393. package/dist/storage.d.ts +2 -2
  394. package/dist/storage.js +18 -17
  395. package/dist/subject-config.d.ts +38 -0
  396. package/dist/subject-config.js +20 -0
  397. package/dist/subject-config.js.map +1 -0
  398. package/dist/summarizer.d.ts +1 -1
  399. package/dist/summary-snapshot.d.ts +1 -1
  400. package/dist/support-passport/index.d.ts +14 -14
  401. package/dist/support-passport/index.js +38 -37
  402. package/dist/temporal-supersession.d.ts +2 -2
  403. package/dist/temporal-timeline-recall.d.ts +1 -1
  404. package/dist/temporal-validity.d.ts +1 -1
  405. package/dist/threading.d.ts +1 -1
  406. package/dist/tier-migration.d.ts +2 -2
  407. package/dist/tier-routing.d.ts +1 -1
  408. package/dist/topics.d.ts +1 -1
  409. package/dist/transcript.d.ts +1 -1
  410. package/dist/transfer/backup.js +2 -2
  411. package/dist/transfer/capsule-export.js +2 -2
  412. package/dist/transfer/capsule-import.js +2 -2
  413. package/dist/transfer/types.d.ts +66 -66
  414. package/dist/trust-score-stage.d.ts +1 -1
  415. package/dist/trust-score.d.ts +1 -1
  416. package/dist/{types-BrEzuxPA.d.ts → types-Pi0lfaEt.d.ts} +38 -29
  417. package/dist/types.d.ts +1 -1
  418. package/dist/types.js +1 -1
  419. package/dist/utility-runtime.d.ts +1 -1
  420. package/dist/verified-recall.js +16 -15
  421. package/dist/who-knows-cli.d.ts +11 -11
  422. package/dist/who-knows-cli.js +17 -16
  423. package/dist/who-knows.d.ts +11 -11
  424. package/dist/who-knows.js +16 -15
  425. package/dist/write-envelope.d.ts +5 -2
  426. package/dist/write-envelope.js +10 -1
  427. package/package.json +2 -2
  428. package/scripts/build-with-heap.mjs +1 -1
  429. package/src/access-boundary.ts +2 -0
  430. package/src/access-mcp-admin-tools.ts +14 -0
  431. package/src/access-mcp-output-schemas.ts +6 -0
  432. package/src/access-mcp.ts +6 -6
  433. package/src/access-operations-batch.ts +8 -0
  434. package/src/access-service.ts +85 -0
  435. package/src/access-surface-catalog.ts +2 -0
  436. package/src/config.ts +10 -17
  437. package/src/extraction-prompt.ts +1 -0
  438. package/src/extraction.ts +4 -1
  439. package/src/index.ts +5 -6
  440. package/src/mcp-read-only-tools.ts +1 -0
  441. package/src/memory-subject-cli.ts +135 -0
  442. package/src/memory-subject.test.ts +48 -0
  443. package/src/memory-subject.ts +314 -0
  444. package/src/memory-worth-outcomes.test.ts +6 -2
  445. package/src/memory-worth-outcomes.ts +11 -7
  446. package/src/operator-toolkit.ts +1 -1
  447. package/src/orchestration/extraction-persist.ts +48 -48
  448. package/src/orchestration/recall-internal.ts +6 -5
  449. package/src/procedural/library-maintenance.test.ts +582 -0
  450. package/src/procedural/library-maintenance.ts +546 -0
  451. package/src/procedural/maintenance-config.ts +78 -0
  452. package/src/procedural/procedure-recall.ts +29 -1
  453. package/src/procedural/procedure-stats.ts +20 -0
  454. package/src/schemas.ts +7 -0
  455. package/src/spaces/index.ts +38 -2
  456. package/src/storage.ts +6 -2
  457. package/src/subject-config.ts +80 -0
  458. package/src/types.ts +26 -29
  459. package/src/write-envelope.test.ts +14 -0
  460. package/src/write-envelope.ts +24 -3
  461. package/dist/chunk-3PXVYJMC.js.map +0 -1
  462. package/dist/chunk-3RHFGGI5.js.map +0 -1
  463. package/dist/chunk-4NZHHGVL.js.map +0 -1
  464. package/dist/chunk-CEQF6L5K.js.map +0 -1
  465. package/dist/chunk-CUS6S7PN.js.map +0 -1
  466. package/dist/chunk-DBXZZIDU.js.map +0 -1
  467. package/dist/chunk-DEFI2QBT.js.map +0 -1
  468. package/dist/chunk-EIR5VLIH.js.map +0 -1
  469. package/dist/chunk-GEULB2VI.js.map +0 -1
  470. package/dist/chunk-JFJ3MHGV.js.map +0 -1
  471. package/dist/chunk-JG22O53B.js.map +0 -1
  472. package/dist/chunk-LCU5R6TQ.js.map +0 -1
  473. package/dist/chunk-MSTNSVXI.js.map +0 -1
  474. package/dist/chunk-YQ3CBLL4.js.map +0 -1
  475. package/dist/chunk-Z54TXZ2F.js.map +0 -1
  476. /package/dist/{capsule-crypto-7FJQINUR.js.map → capsule-crypto-YO5QJ6L3.js.map} +0 -0
  477. /package/dist/{chunk-LYIZXQYY.js.map → chunk-2E36UXVW.js.map} +0 -0
  478. /package/dist/{chunk-7QFBLYFP.js.map → chunk-2XDWWPTN.js.map} +0 -0
  479. /package/dist/{chunk-CFRBTATE.js.map → chunk-2YI72KM3.js.map} +0 -0
  480. /package/dist/{chunk-3YTTAGPB.js.map → chunk-3DVBKTSO.js.map} +0 -0
  481. /package/dist/{chunk-VPGRXEAB.js.map → chunk-3I7ASZN3.js.map} +0 -0
  482. /package/dist/{chunk-WTOE7CW4.js.map → chunk-4KYOLI6M.js.map} +0 -0
  483. /package/dist/{chunk-ESCQ6LY7.js.map → chunk-5NM4OH4P.js.map} +0 -0
  484. /package/dist/{chunk-Y23B2QXP.js.map → chunk-5YQ63T4B.js.map} +0 -0
  485. /package/dist/{chunk-PMVPCZJZ.js.map → chunk-6433HV72.js.map} +0 -0
  486. /package/dist/{chunk-NS5ETDYD.js.map → chunk-7BEPVIH3.js.map} +0 -0
  487. /package/dist/{chunk-W6TSGWYS.js.map → chunk-7YQ4IYS2.js.map} +0 -0
  488. /package/dist/{chunk-2NLLXCJG.js.map → chunk-BXLOS5AJ.js.map} +0 -0
  489. /package/dist/{chunk-CEH2AFXG.js.map → chunk-C24UZSFW.js.map} +0 -0
  490. /package/dist/{chunk-ZPN7W3OP.js.map → chunk-CDUUDBWJ.js.map} +0 -0
  491. /package/dist/{chunk-5UYSCYR7.js.map → chunk-CT56C22C.js.map} +0 -0
  492. /package/dist/{chunk-HJQZQUPC.js.map → chunk-DJZWNKFO.js.map} +0 -0
  493. /package/dist/{chunk-X7Y7WX73.js.map → chunk-DQEMWVMT.js.map} +0 -0
  494. /package/dist/{chunk-CCTVAVTT.js.map → chunk-DZUJ46DO.js.map} +0 -0
  495. /package/dist/{chunk-N6TRHP72.js.map → chunk-EILZG5VC.js.map} +0 -0
  496. /package/dist/{chunk-GXWDWOWP.js.map → chunk-GDFVPUJ5.js.map} +0 -0
  497. /package/dist/{chunk-7PWWGYGO.js.map → chunk-GNCCUR6K.js.map} +0 -0
  498. /package/dist/{chunk-KPBLJCCV.js.map → chunk-IID2CMUU.js.map} +0 -0
  499. /package/dist/{chunk-UYCIS6V5.js.map → chunk-JCWY73FK.js.map} +0 -0
  500. /package/dist/{chunk-SYJ6EKKE.js.map → chunk-JYYBA7TF.js.map} +0 -0
  501. /package/dist/{chunk-T42L3S6A.js.map → chunk-LBWQ65SX.js.map} +0 -0
  502. /package/dist/{chunk-LWVO2QZV.js.map → chunk-LGO6A7GJ.js.map} +0 -0
  503. /package/dist/{chunk-2572MRP2.js.map → chunk-LZH5FR2W.js.map} +0 -0
  504. /package/dist/{chunk-256FBCVX.js.map → chunk-M4AHBM72.js.map} +0 -0
  505. /package/dist/{chunk-YEQEGSJA.js.map → chunk-MN4KB2A4.js.map} +0 -0
  506. /package/dist/{chunk-AGKIG3YA.js.map → chunk-NKKD4ZAU.js.map} +0 -0
  507. /package/dist/{chunk-3TMYV3LP.js.map → chunk-NTWN6HB2.js.map} +0 -0
  508. /package/dist/{chunk-63FHSH7E.js.map → chunk-OCZIYAE5.js.map} +0 -0
  509. /package/dist/{chunk-I2HTKOOP.js.map → chunk-ODZG724P.js.map} +0 -0
  510. /package/dist/{chunk-HQSBYI5X.js.map → chunk-OTHZWLUD.js.map} +0 -0
  511. /package/dist/{chunk-4W6INNXO.js.map → chunk-PE255F4T.js.map} +0 -0
  512. /package/dist/{chunk-6L27N6YI.js.map → chunk-QOS5LBZN.js.map} +0 -0
  513. /package/dist/{chunk-G72IPMR7.js.map → chunk-R4OCGPSH.js.map} +0 -0
  514. /package/dist/{chunk-MIBKEW7A.js.map → chunk-R7JAM2XF.js.map} +0 -0
  515. /package/dist/{chunk-JBPKEARU.js.map → chunk-RKNJBZ55.js.map} +0 -0
  516. /package/dist/{chunk-HUNSEO5U.js.map → chunk-S2DPMJXH.js.map} +0 -0
  517. /package/dist/{chunk-HQSPXTQO.js.map → chunk-SIHSCCUQ.js.map} +0 -0
  518. /package/dist/{chunk-R3AAOKR2.js.map → chunk-SPUJNJJC.js.map} +0 -0
  519. /package/dist/{chunk-IAY7YBXS.js.map → chunk-SQI57UCJ.js.map} +0 -0
  520. /package/dist/{chunk-CTQRPANJ.js.map → chunk-SVSRPG6M.js.map} +0 -0
  521. /package/dist/{chunk-S2VBSTTA.js.map → chunk-THG4GYIE.js.map} +0 -0
  522. /package/dist/{chunk-IXRC7EQG.js.map → chunk-TR7DGXGI.js.map} +0 -0
  523. /package/dist/{chunk-BC4QD3FM.js.map → chunk-UIN2BWDD.js.map} +0 -0
  524. /package/dist/{chunk-JTSVMJHV.js.map → chunk-UXO5IMBK.js.map} +0 -0
  525. /package/dist/{chunk-KQAFEZQX.js.map → chunk-VDX2J7OX.js.map} +0 -0
  526. /package/dist/{chunk-MUJ4QFUQ.js.map → chunk-W4BMEGQA.js.map} +0 -0
  527. /package/dist/{chunk-5HK3CJAR.js.map → chunk-W675UJCZ.js.map} +0 -0
  528. /package/dist/{chunk-MDVBCPOS.js.map → chunk-XCTXS7VY.js.map} +0 -0
  529. /package/dist/{chunk-53ENM6F6.js.map → chunk-XRYZRW54.js.map} +0 -0
  530. /package/dist/{chunk-VJ6ECBIP.js.map → chunk-Y7DK7HHJ.js.map} +0 -0
  531. /package/dist/{chunk-3MADV4YC.js.map → chunk-YB42WZCY.js.map} +0 -0
  532. /package/dist/{chunk-X5SDZMO7.js.map → chunk-YHCBJULX.js.map} +0 -0
  533. /package/dist/{chunk-6JJT5AKI.js.map → chunk-Z7PBQPJ4.js.map} +0 -0
  534. /package/dist/{chunk-ALCJRQ72.js.map → chunk-ZO6AXLEH.js.map} +0 -0
  535. /package/dist/{chunk-VZVP2W4O.js.map → chunk-ZQHI2BZB.js.map} +0 -0
  536. /package/dist/{resolution-DKMBPXHI.js.map → memory-subject-cli.js.map} +0 -0
@@ -8,20 +8,20 @@ import {
8
8
  } from "./chunk-GDB4J2H3.js";
9
9
  import {
10
10
  importCapsule
11
- } from "./chunk-PMVPCZJZ.js";
11
+ } from "./chunk-6433HV72.js";
12
12
  import {
13
13
  buildCodingGraphInstallHint,
14
14
  tryLoadCodingGraphModule
15
15
  } from "./chunk-VQ7B2Q6M.js";
16
- import {
17
- WriteQuarantineStore
18
- } from "./chunk-PJSK6OJM.js";
19
16
  import {
20
17
  WHO_KNOWS_DEFAULT_LIMIT,
21
18
  computeWhoKnows,
22
19
  loadWhoKnowsEntities,
23
20
  validateWhoKnowsInput
24
- } from "./chunk-R3AAOKR2.js";
21
+ } from "./chunk-SPUJNJJC.js";
22
+ import {
23
+ WriteQuarantineStore
24
+ } from "./chunk-PJSK6OJM.js";
25
25
  import {
26
26
  trustResultFor
27
27
  } from "./chunk-GNVZQ5JN.js";
@@ -45,25 +45,25 @@ import {
45
45
  } from "./chunk-H7XKCNR6.js";
46
46
  import {
47
47
  toRecallExplainJson
48
- } from "./chunk-W6TSGWYS.js";
48
+ } from "./chunk-7YQ4IYS2.js";
49
49
  import {
50
50
  estimateRecallTokens
51
- } from "./chunk-VPGRXEAB.js";
51
+ } from "./chunk-3I7ASZN3.js";
52
52
  import {
53
53
  readAggregateExtractionWatermark
54
- } from "./chunk-4W6INNXO.js";
54
+ } from "./chunk-PE255F4T.js";
55
+ import {
56
+ ReplicaDivergenceMonitor
57
+ } from "./chunk-CVILPI77.js";
55
58
  import {
56
59
  recordObjectiveStateSnapshotsFromObservedMessages
57
60
  } from "./chunk-2HIJHXB3.js";
58
61
  import {
59
62
  objectiveStateStoreOverrideForNamespace
60
63
  } from "./chunk-HTP6XRUI.js";
61
- import {
62
- ReplicaDivergenceMonitor
63
- } from "./chunk-CVILPI77.js";
64
64
  import {
65
65
  recordMemoryOutcome
66
- } from "./chunk-EIR5VLIH.js";
66
+ } from "./chunk-4K7IW3F7.js";
67
67
  import {
68
68
  coerceIncludedMemories
69
69
  } from "./chunk-2YA5N2BY.js";
@@ -90,13 +90,14 @@ import {
90
90
  } from "./chunk-IVKIODHO.js";
91
91
  import {
92
92
  buildProcedurePersistBody,
93
- normalizeProcedureSteps
93
+ normalizeProcedureSteps,
94
+ parseProcedureStepsFromBody
94
95
  } from "./chunk-QDW3E4RD.js";
95
96
  import {
96
97
  persistExplicitCapture,
97
98
  queueExplicitCaptureForReview,
98
99
  validateExplicitCaptureInput
99
- } from "./chunk-NS5ETDYD.js";
100
+ } from "./chunk-7BEPVIH3.js";
100
101
  import {
101
102
  boundRecallContextComposition,
102
103
  composeRecallContext,
@@ -116,18 +117,18 @@ import {
116
117
  listMemoryGovernanceRuns,
117
118
  readMemoryGovernanceRunArtifact,
118
119
  runMemoryGovernance
119
- } from "./chunk-SYJ6EKKE.js";
120
+ } from "./chunk-JYYBA7TF.js";
120
121
  import {
121
122
  CorpusWatermarkCache,
122
123
  computeServiceCorpusCensus
123
- } from "./chunk-53ENM6F6.js";
124
+ } from "./chunk-XRYZRW54.js";
124
125
  import {
125
126
  ExtractionDeadlineError,
126
127
  isActivityDigestPath,
127
128
  isArtifactMemoryPath,
128
129
  isLocationDayPath,
129
130
  isMeetingRecordPath
130
- } from "./chunk-S2VBSTTA.js";
131
+ } from "./chunk-THG4GYIE.js";
131
132
  import {
132
133
  defaultCapsulesDir
133
134
  } from "./chunk-ZY2MNJR6.js";
@@ -141,21 +142,21 @@ import {
141
142
  enqueuePassiveCorrectionNotification,
142
143
  parseBriefingFocus,
143
144
  parseBriefingWindow
144
- } from "./chunk-3TMYV3LP.js";
145
+ } from "./chunk-NTWN6HB2.js";
145
146
  import {
146
147
  parseEntityFile,
147
148
  parseFrontmatter,
148
149
  qmdCollectionPathParts,
149
150
  qmdResultPathCandidates,
150
151
  selfDeps
151
- } from "./chunk-DEFI2QBT.js";
152
+ } from "./chunk-J275IYMG.js";
152
153
  import {
153
154
  namespaceCollectionName
154
- } from "./chunk-X5SDZMO7.js";
155
+ } from "./chunk-YHCBJULX.js";
155
156
  import {
156
157
  DEFAULT_RECALL_DISCLOSURE,
157
158
  isRecallDisclosure
158
- } from "./chunk-JFJ3MHGV.js";
159
+ } from "./chunk-SBDCZ2AX.js";
159
160
  import {
160
161
  normalizeProjectionPreview,
161
162
  normalizeProjectionTags
@@ -166,7 +167,7 @@ import {
166
167
  buildObserveRequestFingerprint,
167
168
  composeMemoryEnvelope,
168
169
  isMemoryCategory
169
- } from "./chunk-LCU5R6TQ.js";
170
+ } from "./chunk-RAIUTAZZ.js";
170
171
  import {
171
172
  applyTagFilter,
172
173
  normalizeTags,
@@ -175,6 +176,9 @@ import {
175
176
  import {
176
177
  createVersion
177
178
  } from "./chunk-UFKPQBXH.js";
179
+ import {
180
+ bumpMemoryCorpusVersionForDir
181
+ } from "./chunk-XCB6QDL6.js";
178
182
  import {
179
183
  supersessionKeysForFact
180
184
  } from "./chunk-5WITETWU.js";
@@ -194,9 +198,12 @@ import {
194
198
  import {
195
199
  isExternalWikiCollectionName
196
200
  } from "./chunk-JV3C2MNQ.js";
201
+ import {
202
+ computePromotionCandidates
203
+ } from "./chunk-RIAM7DND.js";
197
204
  import {
198
205
  exportCapsule
199
- } from "./chunk-KQAFEZQX.js";
206
+ } from "./chunk-VDX2J7OX.js";
200
207
  import {
201
208
  evaluateActionConfidence
202
209
  } from "./chunk-Z2YFLXHU.js";
@@ -225,7 +232,7 @@ import {
225
232
  } from "./chunk-LNEWDF2A.js";
226
233
  import {
227
234
  createOfflineSyncManifestStream
228
- } from "./chunk-I2HTKOOP.js";
235
+ } from "./chunk-ODZG724P.js";
229
236
  import {
230
237
  offlineSyncStorageForSnapshot
231
238
  } from "./chunk-HZNYJN77.js";
@@ -243,6 +250,7 @@ import {
243
250
  } from "./chunk-KCT36JAW.js";
244
251
  import {
245
252
  inferMemoryStatus,
253
+ isActiveMemoryStatus,
246
254
  toMemoryPathRel
247
255
  } from "./chunk-7RJUVTVF.js";
248
256
  import {
@@ -251,13 +259,6 @@ import {
251
259
  import {
252
260
  displayErrorDetail
253
261
  } from "./chunk-RL6NEVXT.js";
254
- import {
255
- computeContentHash
256
- } from "./chunk-5FVVY2EB.js";
257
- import {
258
- serializeMutations,
259
- withHeldFileLock
260
- } from "./chunk-FFAZ2XFU.js";
261
262
  import {
262
263
  SUPPORT_PASSPORT_ATTRIBUTE_KEYS,
263
264
  SUPPORT_PASSPORT_CARD_TAG,
@@ -284,6 +285,13 @@ import {
284
285
  import {
285
286
  stripAttributesSuffix
286
287
  } from "./chunk-JDSVLVCG.js";
288
+ import {
289
+ computeContentHash
290
+ } from "./chunk-5FVVY2EB.js";
291
+ import {
292
+ serializeMutations,
293
+ withHeldFileLock
294
+ } from "./chunk-FFAZ2XFU.js";
287
295
  import {
288
296
  sanitizeMemoryContent
289
297
  } from "./chunk-5GKPFL3S.js";
@@ -374,6 +382,10 @@ import {
374
382
  raceAbort,
375
383
  throwIfAborted
376
384
  } from "./chunk-BTTPKDIL.js";
385
+ import {
386
+ readJsonFile,
387
+ writeJsonFileAtomic
388
+ } from "./chunk-P77QX3ID.js";
377
389
  import {
378
390
  AccessAuditAdapter
379
391
  } from "./chunk-TVVEYCNW.js";
@@ -5367,6 +5379,7 @@ var OPERATION_NAMES = [
5367
5379
  "recall_tier_explain",
5368
5380
  "recall_xray",
5369
5381
  "who_knows",
5382
+ "promotion_candidates",
5370
5383
  "namespace_writable",
5371
5384
  "wearables_status",
5372
5385
  "wearables_sync",
@@ -5387,6 +5400,7 @@ var OPERATION_NAMES = [
5387
5400
  "procedure_mining_run",
5388
5401
  "pattern_reinforcement_run",
5389
5402
  "procedural_stats",
5403
+ "procedure_library_maintenance",
5390
5404
  "memory_timeline",
5391
5405
  "suggestion_submit",
5392
5406
  "entity_get",
@@ -5558,10 +5572,10 @@ function formatZodIssues(error) {
5558
5572
  const parts = [];
5559
5573
  for (const issue of error.issues) {
5560
5574
  const hasNumeric = issue.path.some((p) => typeof p === "number");
5561
- const path16 = hasNumeric ? issue.path.filter((p) => typeof p === "string").join(".") || "(root)" : issue.path.length > 0 ? issue.path.join(".") : "(root)";
5575
+ const path17 = hasNumeric ? issue.path.filter((p) => typeof p === "string").join(".") || "(root)" : issue.path.length > 0 ? issue.path.join(".") : "(root)";
5562
5576
  const options = enumOptionsFromIssue(issue);
5563
5577
  const suffix = options ? `. Valid: ${options.join(", ")}` : "";
5564
- parts.push(`${path16}: ${issue.message}${suffix}`);
5578
+ parts.push(`${path17}: ${issue.message}${suffix}`);
5565
5579
  }
5566
5580
  return parts.length > 0 ? `request validation failed: ${parts.join("; ")}` : "request validation failed";
5567
5581
  }
@@ -6114,6 +6128,343 @@ async function promoteMemory(options) {
6114
6128
  };
6115
6129
  }
6116
6130
 
6131
+ // src/procedural/library-maintenance.ts
6132
+ import path10 from "path";
6133
+ var MAINTENANCE_ACTOR = "procedure-library-maintenance";
6134
+ var MAINTENANCE_RULE_VERSION = "procedure-library-maintenance:1";
6135
+ function maintenanceMarkerPath(memoryDir) {
6136
+ return path10.join(memoryDir, "state", "procedure-maintenance.json");
6137
+ }
6138
+ async function readProcedureMaintenanceMarker(memoryDir) {
6139
+ try {
6140
+ const raw = await readJsonFile(maintenanceMarkerPath(memoryDir));
6141
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) return null;
6142
+ const m = raw;
6143
+ if (typeof m.lastRunAt !== "string") return null;
6144
+ return {
6145
+ schemaVersion: 1,
6146
+ lastRunAt: m.lastRunAt,
6147
+ lastApplyAt: typeof m.lastApplyAt === "string" ? m.lastApplyAt : null,
6148
+ appliedCount: typeof m.appliedCount === "number" ? m.appliedCount : 0
6149
+ };
6150
+ } catch {
6151
+ return null;
6152
+ }
6153
+ }
6154
+ function evidenceFor(m) {
6155
+ return {
6156
+ memoryId: m.frontmatter.id,
6157
+ mwSuccess: m.frontmatter.mw_success ?? 0,
6158
+ mwFail: m.frontmatter.mw_fail ?? 0,
6159
+ lastAccessed: m.frontmatter.lastAccessed ?? null,
6160
+ updated: m.frontmatter.updated ?? null
6161
+ };
6162
+ }
6163
+ function tsMs(value) {
6164
+ if (typeof value !== "string") return null;
6165
+ const ms = Date.parse(value);
6166
+ return Number.isFinite(ms) ? ms : null;
6167
+ }
6168
+ function procedureTitle(content) {
6169
+ const text = content.replace(/\r\n/g, "\n").trim();
6170
+ const idx = text.search(/^##\s+Step\s+\d+\s*$/im);
6171
+ return (idx === -1 ? text : text.slice(0, idx)).trim();
6172
+ }
6173
+ function normalizePhrase(s) {
6174
+ return s.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
6175
+ }
6176
+ function stepSignature(steps) {
6177
+ if (steps === null) return "<unparsed>";
6178
+ return steps.map(
6179
+ (s) => `${s.order}|${normalizePhrase(s.intent)}|${s.toolCall?.kind ?? ""}|${s.toolCall?.signature ?? ""}`
6180
+ ).join(";;");
6181
+ }
6182
+ function isUserEditedProcedure(content) {
6183
+ const steps = parseProcedureStepsFromBody(content);
6184
+ if (steps === null) return true;
6185
+ const rebuilt = buildProcedurePersistBody(procedureTitle(content), steps);
6186
+ return rebuilt.trim() !== content.replace(/\r\n/g, "\n").trim();
6187
+ }
6188
+ function compareCanonical(a, b) {
6189
+ const aMs = tsMs(a.frontmatter.updated) ?? tsMs(a.frontmatter.created) ?? 0;
6190
+ const bMs = tsMs(b.frontmatter.updated) ?? tsMs(b.frontmatter.created) ?? 0;
6191
+ if (aMs !== bMs) return aMs > bMs ? -1 : 1;
6192
+ const aId = a.frontmatter.id ?? "";
6193
+ const bId = b.frontmatter.id ?? "";
6194
+ if (aId !== bId) return aId < bId ? -1 : 1;
6195
+ return 0;
6196
+ }
6197
+ function recentTrajectoryToolText(trajectories) {
6198
+ return trajectories.map((r) => r.actionSummary).join("\n").toLowerCase();
6199
+ }
6200
+ async function runProcedureLibraryMaintenance(options) {
6201
+ const now = options.now ?? /* @__PURE__ */ new Date();
6202
+ const nowIso = now.toISOString();
6203
+ const mode = options.apply === true ? "apply" : "shadow";
6204
+ const cfg = options.config.procedural;
6205
+ if (cfg?.enabled !== true || cfg.maintenance?.enabled !== true) {
6206
+ return {
6207
+ schemaVersion: 1,
6208
+ generatedAt: nowIso,
6209
+ mode,
6210
+ scannedProcedures: 0,
6211
+ proposed: [],
6212
+ applied: [],
6213
+ appliedCount: 0,
6214
+ skippedReason: cfg?.enabled !== true ? "procedural_disabled" : "maintenance_disabled"
6215
+ };
6216
+ }
6217
+ const maintenance = cfg.maintenance;
6218
+ const all = await options.storage.readAllMemories();
6219
+ const byId = /* @__PURE__ */ new Map();
6220
+ for (const m of all) {
6221
+ if (m.frontmatter.category !== "procedure") continue;
6222
+ if (!isActiveMemoryStatus(m.frontmatter.status)) continue;
6223
+ if (typeof m.frontmatter.id === "string" && m.frontmatter.id.length > 0) {
6224
+ byId.set(m.frontmatter.id, m);
6225
+ }
6226
+ }
6227
+ const activeProcedures = [...byId.values()];
6228
+ const report = {
6229
+ schemaVersion: 1,
6230
+ generatedAt: nowIso,
6231
+ mode,
6232
+ scannedProcedures: activeProcedures.length,
6233
+ proposed: [],
6234
+ applied: [],
6235
+ appliedCount: 0
6236
+ };
6237
+ if (activeProcedures.length === 0 && mode === "shadow") return report;
6238
+ const mergeConsumed = /* @__PURE__ */ new Set();
6239
+ if (maintenance.mergeEnabled) {
6240
+ const clusters = /* @__PURE__ */ new Map();
6241
+ for (const m of activeProcedures) {
6242
+ const steps = parseProcedureStepsFromBody(m.content);
6243
+ const key = `${normalizePhrase(procedureTitle(m.content))}
6244
+ @@
6245
+ ${stepSignature(steps)}`;
6246
+ const bucket = clusters.get(key);
6247
+ if (bucket) bucket.push(m);
6248
+ else clusters.set(key, [m]);
6249
+ }
6250
+ for (const cluster of clusters.values()) {
6251
+ if (cluster.length < 2) continue;
6252
+ const sortedCluster = [...cluster].sort(compareCanonical);
6253
+ const userEdited = sortedCluster.filter((m) => isUserEditedProcedure(m.content));
6254
+ if (userEdited.length > 0) {
6255
+ report.proposed.push({
6256
+ action: "flag_user_edited",
6257
+ reasonCode: "user_edited_protected",
6258
+ memoryIds: sortedCluster.map((m) => m.frontmatter.id),
6259
+ reason: "duplicate-signature cluster contains user-edited bodies; merge skipped for manual review",
6260
+ evidence: sortedCluster.map(evidenceFor)
6261
+ });
6262
+ continue;
6263
+ }
6264
+ const canonical = sortedCluster[0];
6265
+ const duplicates = sortedCluster.slice(1);
6266
+ for (const m of sortedCluster) mergeConsumed.add(m.frontmatter.id);
6267
+ report.proposed.push({
6268
+ action: "merge",
6269
+ reasonCode: "merge_duplicate_signature",
6270
+ memoryIds: [canonical.frontmatter.id, ...duplicates.map((m) => m.frontmatter.id)],
6271
+ canonicalId: canonical.frontmatter.id,
6272
+ reason: `near-identical trigger phrase + step signature across ${sortedCluster.length} active procedures`,
6273
+ evidence: sortedCluster.map(evidenceFor)
6274
+ });
6275
+ }
6276
+ }
6277
+ const trajectoryDir = typeof options.config.causalTrajectoryStoreDir === "string" && options.config.causalTrajectoryStoreDir.trim().length > 0 ? options.config.causalTrajectoryStoreDir.trim() : void 0;
6278
+ const { trajectories } = await readCausalTrajectoryRecords({
6279
+ memoryDir: options.memoryDir,
6280
+ causalTrajectoryStoreDir: trajectoryDir
6281
+ });
6282
+ const recentTrajectories = filterTrajectoriesByLookbackDays(
6283
+ trajectories,
6284
+ cfg.lookbackDays,
6285
+ now.getTime()
6286
+ );
6287
+ const repairFlags = [];
6288
+ const staleToolsByProcedure = /* @__PURE__ */ new Map();
6289
+ if (recentTrajectories.length > 0) {
6290
+ const toolText = recentTrajectoryToolText(recentTrajectories);
6291
+ for (const m of activeProcedures) {
6292
+ if (mergeConsumed.has(m.frontmatter.id)) continue;
6293
+ const steps = parseProcedureStepsFromBody(m.content);
6294
+ if (steps === null) continue;
6295
+ const tools = [
6296
+ ...new Set(
6297
+ steps.map((s) => s.toolCall?.kind).filter((t) => typeof t === "string" && t.length > 0)
6298
+ )
6299
+ ];
6300
+ if (tools.length === 0) continue;
6301
+ const stale = tools.filter((t) => !toolText.includes(t.toLowerCase()));
6302
+ if (stale.length === 0) continue;
6303
+ staleToolsByProcedure.set(m.frontmatter.id, stale);
6304
+ repairFlags.push({
6305
+ action: "flag_repair",
6306
+ reasonCode: "needs_repair_stale_tools",
6307
+ memoryIds: [m.frontmatter.id],
6308
+ reason: `tools absent from last ${cfg.lookbackDays}d of trajectories: ${stale.join(", ")}`,
6309
+ evidence: [evidenceFor(m)]
6310
+ });
6311
+ }
6312
+ }
6313
+ const retireActions = [];
6314
+ const retireIds = /* @__PURE__ */ new Set();
6315
+ const idleMs = maintenance.retireIdleDays * 24 * 60 * 60 * 1e3;
6316
+ for (const m of activeProcedures) {
6317
+ if (mergeConsumed.has(m.frontmatter.id)) continue;
6318
+ const mwSuccess = m.frontmatter.mw_success ?? 0;
6319
+ const mwFail = m.frontmatter.mw_fail ?? 0;
6320
+ const failureDominant = mwFail >= maintenance.retireMinOutcomes && mwFail > mwSuccess * maintenance.retireFailRatio;
6321
+ const lastSignalMs = tsMs(m.frontmatter.lastAccessed) ?? tsMs(m.frontmatter.updated);
6322
+ const idle = maintenance.retireIdleDays > 0 && mwSuccess + mwFail === 0 && lastSignalMs !== null && lastSignalMs < now.getTime() - idleMs;
6323
+ const reasonCode = failureDominant ? "retire_failure_dominant" : idle ? "retire_idle" : null;
6324
+ if (reasonCode === null) continue;
6325
+ if (isUserEditedProcedure(m.content)) {
6326
+ report.proposed.push({
6327
+ action: "flag_user_edited",
6328
+ reasonCode: "user_edited_protected",
6329
+ memoryIds: [m.frontmatter.id],
6330
+ reason: `user-edited body exempt from automatic retirement (${reasonCode} waived)`,
6331
+ evidence: [evidenceFor(m)]
6332
+ });
6333
+ continue;
6334
+ }
6335
+ retireIds.add(m.frontmatter.id);
6336
+ retireActions.push({
6337
+ action: "retire",
6338
+ reasonCode,
6339
+ memoryIds: [m.frontmatter.id],
6340
+ reason: reasonCode === "retire_failure_dominant" ? `mw_fail ${mwFail} >= ${maintenance.retireMinOutcomes} and > mw_success ${mwSuccess} * ${maintenance.retireFailRatio}` : `no access signal for ${maintenance.retireIdleDays}d and zero recorded outcomes`,
6341
+ evidence: [evidenceFor(m)]
6342
+ });
6343
+ }
6344
+ for (const flag of repairFlags) {
6345
+ if (retireIds.has(flag.memoryIds[0])) continue;
6346
+ report.proposed.push(flag);
6347
+ }
6348
+ report.proposed.push(...retireActions);
6349
+ if (mode === "shadow") return report;
6350
+ const applied = report.proposed;
6351
+ let writes = 0;
6352
+ for (const action of applied) {
6353
+ try {
6354
+ if (action.action === "merge") {
6355
+ const canonicalId = action.canonicalId;
6356
+ const canonical = canonicalId !== void 0 ? byId.get(canonicalId) : void 0;
6357
+ if (!canonical || canonicalId === void 0) continue;
6358
+ const memberIds = [...action.memoryIds].sort();
6359
+ const previousCount = canonical.frontmatter.reinforcement_count ?? 0;
6360
+ const newCount = Math.max(previousCount, memberIds.length);
6361
+ if (newCount !== canonical.frontmatter.reinforcement_count || canonical.frontmatter.derived_via !== "pattern-reinforcement") {
6362
+ await options.storage.writeMemoryFrontmatter(
6363
+ canonical,
6364
+ {
6365
+ reinforcement_count: newCount,
6366
+ last_reinforced_at: nowIso,
6367
+ derived_via: "pattern-reinforcement",
6368
+ derived_from: memberIds,
6369
+ updated: nowIso
6370
+ },
6371
+ {
6372
+ actor: MAINTENANCE_ACTOR,
6373
+ reasonCode: action.reasonCode,
6374
+ ruleVersion: MAINTENANCE_RULE_VERSION,
6375
+ relatedMemoryIds: memberIds
6376
+ }
6377
+ );
6378
+ writes += 1;
6379
+ }
6380
+ for (const memberId of action.memoryIds) {
6381
+ if (memberId === canonicalId) continue;
6382
+ const member = byId.get(memberId);
6383
+ if (!member) continue;
6384
+ await options.storage.writeMemoryFrontmatter(
6385
+ member,
6386
+ {
6387
+ status: "superseded",
6388
+ supersededBy: canonicalId,
6389
+ supersededAt: nowIso,
6390
+ updated: nowIso
6391
+ },
6392
+ {
6393
+ actor: MAINTENANCE_ACTOR,
6394
+ reasonCode: action.reasonCode,
6395
+ ruleVersion: MAINTENANCE_RULE_VERSION,
6396
+ relatedMemoryIds: [canonicalId]
6397
+ }
6398
+ );
6399
+ writes += 1;
6400
+ }
6401
+ } else if (action.action === "retire") {
6402
+ const memory = byId.get(action.memoryIds[0]);
6403
+ if (!memory) continue;
6404
+ const archivedPath = await options.storage.archiveMemory(memory, {
6405
+ at: now,
6406
+ actor: `${MAINTENANCE_ACTOR}.apply`,
6407
+ reasonCode: action.reasonCode,
6408
+ ruleVersion: MAINTENANCE_RULE_VERSION,
6409
+ relatedMemoryIds: []
6410
+ });
6411
+ if (archivedPath !== null) writes += 1;
6412
+ } else if (action.action === "flag_repair") {
6413
+ const memory = byId.get(action.memoryIds[0]);
6414
+ if (!memory) continue;
6415
+ const existing = memory.frontmatter.structuredAttributes ?? {};
6416
+ const prior = existing.needsRepair;
6417
+ let priorReason = null;
6418
+ if (typeof prior === "string") {
6419
+ try {
6420
+ const parsed = JSON.parse(prior);
6421
+ if (typeof parsed.reason === "string") priorReason = parsed.reason;
6422
+ } catch {
6423
+ priorReason = prior;
6424
+ }
6425
+ }
6426
+ if (priorReason === action.reason) continue;
6427
+ const stamp = JSON.stringify({ reason: action.reason, detectedAt: nowIso });
6428
+ await options.storage.writeMemoryFrontmatter(
6429
+ memory,
6430
+ {
6431
+ structuredAttributes: { ...existing, needsRepair: stamp },
6432
+ updated: nowIso
6433
+ },
6434
+ {
6435
+ actor: MAINTENANCE_ACTOR,
6436
+ reasonCode: action.reasonCode,
6437
+ ruleVersion: MAINTENANCE_RULE_VERSION
6438
+ }
6439
+ );
6440
+ writes += 1;
6441
+ }
6442
+ report.applied.push(action);
6443
+ } catch (err) {
6444
+ log.warn(
6445
+ `procedure-library-maintenance: action ${action.reasonCode} on ${action.memoryIds.join(",")} failed: ${err instanceof Error ? err.message : String(err)}`
6446
+ );
6447
+ }
6448
+ }
6449
+ report.appliedCount = report.applied.length;
6450
+ if (writes > 0) {
6451
+ bumpMemoryCorpusVersionForDir(options.memoryDir);
6452
+ }
6453
+ try {
6454
+ await writeJsonFileAtomic(maintenanceMarkerPath(options.memoryDir), {
6455
+ schemaVersion: 1,
6456
+ lastRunAt: nowIso,
6457
+ lastApplyAt: nowIso,
6458
+ appliedCount: report.appliedCount
6459
+ });
6460
+ } catch (err) {
6461
+ log.warn(
6462
+ `procedure-library-maintenance: failed to persist run marker: ${err instanceof Error ? err.message : String(err)}`
6463
+ );
6464
+ }
6465
+ return report;
6466
+ }
6467
+
6117
6468
  // src/procedural/procedure-stats.ts
6118
6469
  function snapshotConfig(config) {
6119
6470
  const p = config.procedural;
@@ -6127,7 +6478,7 @@ function snapshotConfig(config) {
6127
6478
  recallMaxProcedures: typeof p?.recallMaxProcedures === "number" ? p.recallMaxProcedures : 0
6128
6479
  };
6129
6480
  }
6130
- function tsMs(value) {
6481
+ function tsMs2(value) {
6131
6482
  if (typeof value !== "string") return null;
6132
6483
  const ms = Date.parse(value);
6133
6484
  return Number.isFinite(ms) ? ms : null;
@@ -6149,6 +6500,7 @@ async function computeProcedureStats(options) {
6149
6500
  let lastWriteMs = null;
6150
6501
  let writesLast7Days = 0;
6151
6502
  let minerSourced = 0;
6503
+ let needsRepairFlags = 0;
6152
6504
  const known = [
6153
6505
  "active",
6154
6506
  "pending_review",
@@ -6172,8 +6524,8 @@ async function computeProcedureStats(options) {
6172
6524
  } else {
6173
6525
  counts.other += 1;
6174
6526
  }
6175
- const createdMs = tsMs(m.frontmatter.created);
6176
- const updatedMs = tsMs(m.frontmatter.updated);
6527
+ const createdMs = tsMs2(m.frontmatter.created);
6528
+ const updatedMs = tsMs2(m.frontmatter.updated);
6177
6529
  const latestMs = createdMs !== null && updatedMs !== null ? Math.max(createdMs, updatedMs) : updatedMs ?? createdMs;
6178
6530
  if (latestMs !== null) {
6179
6531
  if (lastWriteMs === null || latestMs > lastWriteMs) {
@@ -6186,7 +6538,11 @@ async function computeProcedureStats(options) {
6186
6538
  if (m.frontmatter.source === "procedure-miner") {
6187
6539
  minerSourced += 1;
6188
6540
  }
6541
+ if (m.frontmatter.structuredAttributes?.needsRepair !== void 0 && isActiveMemoryStatus(m.frontmatter.status)) {
6542
+ needsRepairFlags += 1;
6543
+ }
6189
6544
  }
6545
+ const maintenanceMarker = await readProcedureMaintenanceMarker(storage.dir);
6190
6546
  return {
6191
6547
  schemaVersion: 1,
6192
6548
  generatedAt: new Date(nowMs).toISOString(),
@@ -6196,7 +6552,9 @@ async function computeProcedureStats(options) {
6196
6552
  writesLast7Days,
6197
6553
  minerSourced
6198
6554
  },
6199
- config: snapshotConfig(config)
6555
+ config: snapshotConfig(config),
6556
+ lastMaintenanceAt: maintenanceMarker?.lastRunAt ?? null,
6557
+ needsRepairFlags
6200
6558
  };
6201
6559
  }
6202
6560
  function formatProcedureStatsText(report) {
@@ -6231,6 +6589,10 @@ function formatProcedureStatsText(report) {
6231
6589
  lines.push(` lastWriteAt: ${recent.lastWriteAt ?? "(none)"}`);
6232
6590
  lines.push(` writesLast7Days: ${recent.writesLast7Days}`);
6233
6591
  lines.push(` minerSourced: ${recent.minerSourced}`);
6592
+ lines.push("");
6593
+ lines.push(` maintenance:`);
6594
+ lines.push(` lastMaintenanceAt: ${report.lastMaintenanceAt ?? "(never)"}`);
6595
+ lines.push(` needsRepairFlags: ${report.needsRepairFlags}`);
6234
6596
  return lines.join("\n") + "\n";
6235
6597
  }
6236
6598
 
@@ -8691,7 +9053,7 @@ import { createHash as createHash5 } from "crypto";
8691
9053
  import * as nodePath2 from "path";
8692
9054
 
8693
9055
  // src/orchestration/recall-result-formatter.ts
8694
- import path10 from "path";
9056
+ import path11 from "path";
8695
9057
  function renderConnectorLabel(connector) {
8696
9058
  if (!isValidConnectorId(connector)) return null;
8697
9059
  return connector.length <= CONNECTOR_LABEL_MAX_LENGTH ? connector : `${connector.slice(0, CONNECTOR_LABEL_MAX_LENGTH - 1)}\u2026`;
@@ -8713,15 +9075,15 @@ function resolveEffectiveIdentityInjectionMode(options) {
8713
9075
  return { mode: options.configuredMode, shouldInject: true };
8714
9076
  }
8715
9077
  function displayResultPath(resultPath, memoryDir, namespace) {
8716
- if (!path10.isAbsolute(resultPath)) return resultPath;
8717
- const root = path10.resolve(memoryDir);
8718
- const nsRoot = path10.join(root, "namespaces");
8719
- if (namespace && (resultPath === nsRoot || resultPath.startsWith(nsRoot + path10.sep))) {
8720
- const afterNs = path10.relative(nsRoot, resultPath).split(path10.sep).slice(1).join("/");
9078
+ if (!path11.isAbsolute(resultPath)) return resultPath;
9079
+ const root = path11.resolve(memoryDir);
9080
+ const nsRoot = path11.join(root, "namespaces");
9081
+ if (namespace && (resultPath === nsRoot || resultPath.startsWith(nsRoot + path11.sep))) {
9082
+ const afterNs = path11.relative(nsRoot, resultPath).split(path11.sep).slice(1).join("/");
8721
9083
  if (afterNs) return `${namespace}/${afterNs}`;
8722
9084
  }
8723
- const rel = path10.relative(root, resultPath);
8724
- return rel && !rel.startsWith("..") && !path10.isAbsolute(rel) ? rel.split(path10.sep).join("/") : resultPath;
9085
+ const rel = path11.relative(root, resultPath);
9086
+ return rel && !rel.startsWith("..") && !path11.isAbsolute(rel) ? rel.split(path11.sep).join("/") : resultPath;
8725
9087
  }
8726
9088
  function displaySafeRecallSnapshot(snapshot, memoryDir) {
8727
9089
  const includedMemories = coerceIncludedMemories(snapshot).map((memory) => ({
@@ -10180,14 +10542,14 @@ async function completeSupportPassportReplacementPrior(input) {
10180
10542
  }
10181
10543
 
10182
10544
  // src/support-passport/generated-batch.ts
10183
- import path12 from "path";
10545
+ import path13 from "path";
10184
10546
  import { z as z2 } from "zod";
10185
10547
 
10186
10548
  // src/support-passport/private-file.ts
10187
10549
  import { randomUUID } from "crypto";
10188
10550
  import { constants as fsConstants } from "fs";
10189
10551
  import { lstat as lstat3, mkdir as mkdir3, open, rename as rename2, rm as rm2, stat as stat2 } from "fs/promises";
10190
- import path11 from "path";
10552
+ import path12 from "path";
10191
10553
  var UNSUPPORTED_DIRECTORY_SYNC_ERRORS = /* @__PURE__ */ new Set(["EINVAL", "ENOSYS", "ENOTSUP", "EOPNOTSUPP"]);
10192
10554
  var NON_WRITABLE_ANCESTOR_SYNC_ERRORS = /* @__PURE__ */ new Set(["EROFS", "EPERM", "EACCES"]);
10193
10555
  function assertStableDirectory(before, opened, after, errorMessage) {
@@ -10213,8 +10575,8 @@ function openFlags(...flags) {
10213
10575
  return combined;
10214
10576
  }
10215
10577
  function assertContainedPath(trustedRoot, directory, errorMessage) {
10216
- const relative2 = path11.relative(path11.resolve(trustedRoot), path11.resolve(directory));
10217
- if (relative2 === ".." || relative2.startsWith(`..${path11.sep}`) || path11.isAbsolute(relative2)) {
10578
+ const relative2 = path12.relative(path12.resolve(trustedRoot), path12.resolve(directory));
10579
+ if (relative2 === ".." || relative2.startsWith(`..${path12.sep}`) || path12.isAbsolute(relative2)) {
10218
10580
  throw new Error(errorMessage);
10219
10581
  }
10220
10582
  }
@@ -10247,7 +10609,7 @@ async function syncDirectoryHandle(handle) {
10247
10609
  }
10248
10610
  async function resolvePrivateDirectoryPath(directory, handle, opened, errorMessage, platform = process.platform) {
10249
10611
  const descriptorRoot = requirePrivateFileDescriptorRoot(platform, errorMessage);
10250
- const pinnedPath = path11.join(descriptorRoot, String(handle.fd));
10612
+ const pinnedPath = path12.join(descriptorRoot, String(handle.fd));
10251
10613
  const metadata = await stat2(pinnedPath);
10252
10614
  if (!metadata.isDirectory() || metadata.dev !== opened.dev || metadata.ino !== opened.ino) {
10253
10615
  throw new Error(errorMessage);
@@ -10263,12 +10625,12 @@ function requirePrivateFileDescriptorRoot(platform, errorMessage) {
10263
10625
  throw new Error(errorMessage);
10264
10626
  }
10265
10627
  async function openStableDirectoryFromRoot(trustedRoot, directory, errorMessage, platform = process.platform) {
10266
- const root = path11.resolve(trustedRoot);
10267
- const target = path11.resolve(directory);
10628
+ const root = path12.resolve(trustedRoot);
10629
+ const target = path12.resolve(directory);
10268
10630
  assertContainedPath(root, target, errorMessage);
10269
10631
  requirePrivateFileDescriptorRoot(platform, errorMessage);
10270
- const relative2 = path11.relative(root, target);
10271
- const components = relative2 === "" ? [] : relative2.split(path11.sep);
10632
+ const relative2 = path12.relative(root, target);
10633
+ const components = relative2 === "" ? [] : relative2.split(path12.sep);
10272
10634
  const handles = [];
10273
10635
  let currentPath = root;
10274
10636
  try {
@@ -10276,10 +10638,10 @@ async function openStableDirectoryFromRoot(trustedRoot, directory, errorMessage,
10276
10638
  handles.push(current.handle);
10277
10639
  for (const component of components) {
10278
10640
  const pinnedParent = await resolvePrivateDirectoryPath(currentPath, current.handle, current.opened, errorMessage);
10279
- const child = await openDirectoryNoFollow(path11.join(pinnedParent, component), errorMessage);
10641
+ const child = await openDirectoryNoFollow(path12.join(pinnedParent, component), errorMessage);
10280
10642
  handles.push(child.handle);
10281
10643
  assertStableDirectory(current.before, current.opened, await lstat3(currentPath), errorMessage);
10282
- currentPath = path11.join(currentPath, component);
10644
+ currentPath = path12.join(currentPath, component);
10283
10645
  current = child;
10284
10646
  }
10285
10647
  assertStableDirectory(current.before, current.opened, await lstat3(target), errorMessage);
@@ -10300,12 +10662,12 @@ async function openStableDirectoryFromRoot(trustedRoot, directory, errorMessage,
10300
10662
  }
10301
10663
  }
10302
10664
  async function ensurePrivateDirectoryNoFollow(trustedRoot, directory, errorMessage, syncVerifiedParent = syncDirectoryHandle, hardenExistingChildren = true, platform = process.platform) {
10303
- const root = path11.resolve(trustedRoot);
10304
- const target = path11.resolve(directory);
10665
+ const root = path12.resolve(trustedRoot);
10666
+ const target = path12.resolve(directory);
10305
10667
  assertContainedPath(root, target, errorMessage);
10306
- const relative2 = path11.relative(root, target);
10668
+ const relative2 = path12.relative(root, target);
10307
10669
  requirePrivateFileDescriptorRoot(platform, errorMessage);
10308
- const components = relative2 === "" ? [] : relative2.split(path11.sep);
10670
+ const components = relative2 === "" ? [] : relative2.split(path12.sep);
10309
10671
  const handles = [];
10310
10672
  let currentPath = root;
10311
10673
  try {
@@ -10313,7 +10675,7 @@ async function ensurePrivateDirectoryNoFollow(trustedRoot, directory, errorMessa
10313
10675
  handles.push(current.handle);
10314
10676
  for (const component of components) {
10315
10677
  const pinnedParent = await resolvePrivateDirectoryPath(currentPath, current.handle, current.opened, errorMessage);
10316
- const childPath = path11.join(pinnedParent, component);
10678
+ const childPath = path12.join(pinnedParent, component);
10317
10679
  let created = false;
10318
10680
  try {
10319
10681
  await mkdir3(childPath, { mode: 448 });
@@ -10328,7 +10690,7 @@ async function ensurePrivateDirectoryNoFollow(trustedRoot, directory, errorMessa
10328
10690
  await child.handle.chmod(448);
10329
10691
  }
10330
10692
  assertStableDirectory(current.before, current.opened, await lstat3(currentPath), errorMessage);
10331
- currentPath = path11.join(currentPath, component);
10693
+ currentPath = path12.join(currentPath, component);
10332
10694
  current = child;
10333
10695
  }
10334
10696
  assertStableDirectory(current.before, current.opened, await lstat3(target), errorMessage);
@@ -10337,8 +10699,8 @@ async function ensurePrivateDirectoryNoFollow(trustedRoot, directory, errorMessa
10337
10699
  }
10338
10700
  }
10339
10701
  async function ensurePrivateDirectoryTreeNoFollow(directory, errorMessage, syncVerifiedParent = syncDirectoryHandle, platform = process.platform) {
10340
- const target = path11.resolve(directory);
10341
- const filesystemRoot = path11.parse(target).root;
10702
+ const target = path12.resolve(directory);
10703
+ const filesystemRoot = path12.parse(target).root;
10342
10704
  const rootMetadata = await stat2(filesystemRoot);
10343
10705
  await ensurePrivateDirectoryNoFollow(
10344
10706
  filesystemRoot,
@@ -10373,15 +10735,15 @@ async function withPrivateDirectoryNoFollow(trustedRoot, directory, errorMessage
10373
10735
  }
10374
10736
  }
10375
10737
  async function readPrivateFileNoFollow(directory, filePath, errorMessage, trustedRoot = directory, platform = process.platform) {
10376
- if (path11.dirname(filePath) !== path11.resolve(directory)) throw new Error(errorMessage);
10377
- const targetName = path11.basename(filePath);
10738
+ if (path12.dirname(filePath) !== path12.resolve(directory)) throw new Error(errorMessage);
10739
+ const targetName = path12.basename(filePath);
10378
10740
  let directoryHandles = [];
10379
10741
  let fileHandle;
10380
10742
  try {
10381
10743
  const stableDirectory = await openStableDirectoryFromRoot(trustedRoot, directory, errorMessage, platform);
10382
10744
  directoryHandles = stableDirectory.handles;
10383
10745
  const pinnedDirectory = stableDirectory.pinnedDirectory;
10384
- const targetPath = path11.join(pinnedDirectory, targetName);
10746
+ const targetPath = path12.join(pinnedDirectory, targetName);
10385
10747
  const before = await lstat3(targetPath);
10386
10748
  if (before.isSymbolicLink() || !before.isFile()) throw new Error(errorMessage);
10387
10749
  try {
@@ -10400,10 +10762,10 @@ async function readPrivateFileNoFollow(directory, filePath, errorMessage, truste
10400
10762
  }
10401
10763
  }
10402
10764
  async function appendPrivateFileAtPinnedDirectory(pinnedDirectory, targetName, content, errorMessage, directoryHandle, openFile) {
10403
- if (targetName.length === 0 || targetName === "." || targetName === ".." || path11.basename(targetName) !== targetName) {
10765
+ if (targetName.length === 0 || targetName === "." || targetName === ".." || path12.basename(targetName) !== targetName) {
10404
10766
  throw new Error(errorMessage);
10405
10767
  }
10406
- const targetPath = path11.join(pinnedDirectory, targetName);
10768
+ const targetPath = path12.join(pinnedDirectory, targetName);
10407
10769
  let fileHandle;
10408
10770
  try {
10409
10771
  try {
@@ -10439,8 +10801,8 @@ async function appendPrivateFileAtPinnedDirectory(pinnedDirectory, targetName, c
10439
10801
  }
10440
10802
  async function appendPrivateFileInPinnedDirectory(pinnedDirectory, fileName, content, errorMessage, platform = process.platform) {
10441
10803
  const descriptorRoot = requirePrivateFileDescriptorRoot(platform, errorMessage);
10442
- const resolvedDirectory = path11.resolve(pinnedDirectory);
10443
- const descriptor = path11.relative(descriptorRoot, resolvedDirectory);
10804
+ const resolvedDirectory = path12.resolve(pinnedDirectory);
10805
+ const descriptor = path12.relative(descriptorRoot, resolvedDirectory);
10444
10806
  if (!/^\d+$/.test(descriptor)) throw new Error(errorMessage);
10445
10807
  const before = await stat2(resolvedDirectory);
10446
10808
  if (!before.isDirectory()) throw new Error(errorMessage);
@@ -10456,8 +10818,8 @@ async function appendPrivateFileInPinnedDirectory(pinnedDirectory, fileName, con
10456
10818
  }
10457
10819
  }
10458
10820
  async function writePrivateFileAtomicallyNoFollow(directory, filePath, content, errorMessage, trustedRoot = directory, platform = process.platform, syncVerifiedDirectory = syncDirectoryHandle) {
10459
- if (path11.dirname(filePath) !== path11.resolve(directory)) throw new Error(errorMessage);
10460
- const targetName = path11.basename(filePath);
10821
+ if (path12.dirname(filePath) !== path12.resolve(directory)) throw new Error(errorMessage);
10822
+ const targetName = path12.basename(filePath);
10461
10823
  const tempName = `.${targetName}.${randomUUID()}.tmp`;
10462
10824
  let tempPath;
10463
10825
  let directoryHandles = [];
@@ -10466,8 +10828,8 @@ async function writePrivateFileAtomicallyNoFollow(directory, filePath, content,
10466
10828
  const stableDirectory = await openStableDirectoryFromRoot(trustedRoot, directory, errorMessage, platform);
10467
10829
  directoryHandles = stableDirectory.handles;
10468
10830
  const pinnedDirectory = stableDirectory.pinnedDirectory;
10469
- tempPath = path11.join(pinnedDirectory, tempName);
10470
- const targetPath = path11.join(pinnedDirectory, targetName);
10831
+ tempPath = path12.join(pinnedDirectory, tempName);
10832
+ const targetPath = path12.join(pinnedDirectory, targetName);
10471
10833
  try {
10472
10834
  fileHandle = await open(
10473
10835
  tempPath,
@@ -10504,7 +10866,7 @@ async function writePrivateFileAtomicallyNoFollow(directory, filePath, content,
10504
10866
  }
10505
10867
  async function removePrivateFilesNoFollow(directory, fileNames, errorMessage, trustedRoot = directory, platform = process.platform) {
10506
10868
  if (fileNames.some(
10507
- (fileName) => fileName.length === 0 || fileName === "." || fileName === ".." || path11.basename(fileName) !== fileName
10869
+ (fileName) => fileName.length === 0 || fileName === "." || fileName === ".." || path12.basename(fileName) !== fileName
10508
10870
  )) {
10509
10871
  throw new Error(errorMessage);
10510
10872
  }
@@ -10514,7 +10876,7 @@ async function removePrivateFilesNoFollow(directory, fileNames, errorMessage, tr
10514
10876
  directoryHandles = stableDirectory.handles;
10515
10877
  const pinnedDirectory = stableDirectory.pinnedDirectory;
10516
10878
  for (const fileName of fileNames) {
10517
- await rm2(path11.join(pinnedDirectory, fileName), { force: true });
10879
+ await rm2(path12.join(pinnedDirectory, fileName), { force: true });
10518
10880
  }
10519
10881
  assertStableDirectory(stableDirectory.before, stableDirectory.opened, await lstat3(directory), errorMessage);
10520
10882
  if (stableDirectory.handle) await syncDirectoryHandle(stableDirectory.handle);
@@ -10535,13 +10897,13 @@ var GeneratedBatchMarkerSchema = z2.object({
10535
10897
  }).strict();
10536
10898
  var BATCH_ERROR = "The generated draft batch state is not safe.";
10537
10899
  function batchDirectory(storage) {
10538
- return path12.join(storage.dir, "state", "support-passport", "generated-batches");
10900
+ return path13.join(storage.dir, "state", "support-passport", "generated-batches");
10539
10901
  }
10540
10902
  function batchFileName(batchId) {
10541
10903
  return `${BatchIdSchema.parse(batchId)}.json`;
10542
10904
  }
10543
10905
  function batchPath(storage, batchId) {
10544
- return path12.join(batchDirectory(storage), batchFileName(batchId));
10906
+ return path13.join(batchDirectory(storage), batchFileName(batchId));
10545
10907
  }
10546
10908
  function markerFor(context, batchId, size, complete) {
10547
10909
  return GeneratedBatchMarkerSchema.parse({
@@ -10966,7 +11328,7 @@ var SupportPassportAnswerModelInputSchema = z4.object({
10966
11328
 
10967
11329
  // src/support-passport/owner-lock.ts
10968
11330
  import { createHash as createHash6 } from "crypto";
10969
- import path13 from "path";
11331
+ import path14 from "path";
10970
11332
  var CARD_MUTATION_LOCK_STALE_MS = 6e4;
10971
11333
  var CARD_MUTATION_LOCK_MAX_WAIT_MS = 3e4;
10972
11334
  function computeSupportPassportOwnerLockKey(namespace, principal) {
@@ -10977,7 +11339,7 @@ function supportPassportOwnerLockPath(storage, scope) {
10977
11339
  if (!/^[a-f0-9]{64}$/.test(ownerLockKey)) {
10978
11340
  throw new SupportPassportError("card_data_invalid", "The support passport owner scope is invalid.", 500);
10979
11341
  }
10980
- return path13.join(storage.dir, "state", `support-passport-cards-${ownerLockKey}.lock`);
11342
+ return path14.join(storage.dir, "state", `support-passport-cards-${ownerLockKey}.lock`);
10981
11343
  }
10982
11344
  async function withSupportPassportOwnerLock(storage, scope, task) {
10983
11345
  const lockPath = supportPassportOwnerLockPath(storage, scope);
@@ -11875,7 +12237,7 @@ var SupportPassportCardService = class {
11875
12237
  // src/support-passport/grant-store.ts
11876
12238
  import { createHash as createHash7, randomBytes, randomUUID as randomUUID3, timingSafeEqual } from "crypto";
11877
12239
  import { lstat as lstat4, open as open2, readdir as readdir4 } from "fs/promises";
11878
- import path14 from "path";
12240
+ import path15 from "path";
11879
12241
  var GRANT_LOCK_STALE_MS = 3e4;
11880
12242
  var GRANT_LOCK_WAIT_MS = 5e3;
11881
12243
  var GRANT_LOCK_HEARTBEAT_MS = 1e4;
@@ -11967,9 +12329,9 @@ var SupportPassportGrantStore = class {
11967
12329
  runWithHeldFileLock;
11968
12330
  syncDirectory;
11969
12331
  constructor(options) {
11970
- this.memoryDir = path14.resolve(expandTildePath(options.memoryDir));
11971
- this.grantsDir = path14.join(this.memoryDir, "state", "support-passport", "grants");
11972
- this.ownerIndexesDir = path14.join(this.grantsDir, "owners");
12332
+ this.memoryDir = path15.resolve(expandTildePath(options.memoryDir));
12333
+ this.grantsDir = path15.join(this.memoryDir, "state", "support-passport", "grants");
12334
+ this.ownerIndexesDir = path15.join(this.grantsDir, "owners");
11973
12335
  this.now = options.now ?? (() => /* @__PURE__ */ new Date());
11974
12336
  this.makeSecret = options.makeSecret ?? (() => randomBytes(32));
11975
12337
  this.makeGrantId = options.makeGrantId ?? randomUUID3;
@@ -12182,11 +12544,11 @@ var SupportPassportGrantStore = class {
12182
12544
  }
12183
12545
  filePath(grantId) {
12184
12546
  const normalizedGrantId = normalizeGrantId(grantId);
12185
- return path14.join(this.grantsDir, `${normalizedGrantId}.json`);
12547
+ return path15.join(this.grantsDir, `${normalizedGrantId}.json`);
12186
12548
  }
12187
12549
  ownerIndexPath(ownerHash) {
12188
12550
  if (!SAFE_OWNER_INDEX_HASH.test(ownerHash)) throw new Error("support passport owner index hash is invalid");
12189
- return path14.join(this.ownerIndexesDir, `${ownerHash}.json`);
12551
+ return path15.join(this.ownerIndexesDir, `${ownerHash}.json`);
12190
12552
  }
12191
12553
  ownerHash(namespace, principalHash) {
12192
12554
  return sha256("support-passport-owner-index:v1", `${namespace}\0${principalHash}`);
@@ -12242,12 +12604,12 @@ var SupportPassportGrantStore = class {
12242
12604
  this.grantsDir,
12243
12605
  grantIds.map((grantId) => `${grantId}.json`),
12244
12606
  "support passport grant files must be regular files in a stable directory",
12245
- path14.parse(this.memoryDir).root
12607
+ path15.parse(this.memoryDir).root
12246
12608
  );
12247
12609
  }
12248
12610
  ownerMembershipDirectory(ownerHash) {
12249
12611
  if (!SAFE_OWNER_INDEX_HASH.test(ownerHash)) throw new Error("support passport owner index hash is invalid");
12250
- return path14.join(this.ownerIndexesDir, ownerHash);
12612
+ return path15.join(this.ownerIndexesDir, ownerHash);
12251
12613
  }
12252
12614
  async ensureOwnerMembershipDirectory(ownerHash) {
12253
12615
  const directory = this.ownerMembershipDirectory(ownerHash);
@@ -12262,11 +12624,11 @@ var SupportPassportGrantStore = class {
12262
12624
  const directory = await this.ensureOwnerMembershipDirectory(ownerHash);
12263
12625
  await writePrivateFileAtomicallyNoFollow(
12264
12626
  directory,
12265
- path14.join(directory, `${state.grantId}.json`),
12627
+ path15.join(directory, `${state.grantId}.json`),
12266
12628
  `${JSON.stringify({ schemaVersion: 1, grantId: state.grantId })}
12267
12629
  `,
12268
12630
  "support passport owner membership must be regular files in a stable directory",
12269
- path14.parse(this.memoryDir).root
12631
+ path15.parse(this.memoryDir).root
12270
12632
  );
12271
12633
  }
12272
12634
  async removeOwnerMembership(state) {
@@ -12276,7 +12638,7 @@ var SupportPassportGrantStore = class {
12276
12638
  directory,
12277
12639
  [`${state.grantId}.json`],
12278
12640
  "support passport owner membership must be regular files in a stable directory",
12279
- path14.parse(this.memoryDir).root
12641
+ path15.parse(this.memoryDir).root
12280
12642
  );
12281
12643
  }
12282
12644
  async removeStoredGrant(state) {
@@ -12377,7 +12739,7 @@ var SupportPassportGrantStore = class {
12377
12739
  const ownerHash = this.ownerHash(namespace, principalHash);
12378
12740
  const directory = await this.ensureOwnerMembershipDirectory(ownerHash);
12379
12741
  const grantIds = await withPrivateDirectoryNoFollow(
12380
- path14.parse(this.memoryDir).root,
12742
+ path15.parse(this.memoryDir).root,
12381
12743
  directory,
12382
12744
  "support passport owner membership must be regular files in a stable directory",
12383
12745
  async (pinnedDirectory) => {
@@ -12408,7 +12770,7 @@ var SupportPassportGrantStore = class {
12408
12770
  this.ownerIndexesDir,
12409
12771
  filePath,
12410
12772
  "support passport owner indexes must be regular files in a stable directory",
12411
- path14.parse(this.memoryDir).root
12773
+ path15.parse(this.memoryDir).root
12412
12774
  );
12413
12775
  } catch (error) {
12414
12776
  if (error.code === "ENOENT") return [];
@@ -12448,7 +12810,7 @@ var SupportPassportGrantStore = class {
12448
12810
  `${JSON.stringify({ schemaVersion: 1, ownerHash, grantIds }, null, 2)}
12449
12811
  `,
12450
12812
  "support passport owner indexes must be regular files in a stable directory",
12451
- path14.parse(this.memoryDir).root
12813
+ path15.parse(this.memoryDir).root
12452
12814
  );
12453
12815
  }
12454
12816
  async readState(grantId) {
@@ -12458,7 +12820,7 @@ var SupportPassportGrantStore = class {
12458
12820
  this.grantsDir,
12459
12821
  filePath,
12460
12822
  "support passport grant files must be regular files in a stable directory",
12461
- path14.parse(this.memoryDir).root
12823
+ path15.parse(this.memoryDir).root
12462
12824
  );
12463
12825
  try {
12464
12826
  const state = SupportPassportGrantStateSchema.parse(JSON.parse(content));
@@ -12492,7 +12854,7 @@ var SupportPassportGrantStore = class {
12492
12854
  `${JSON.stringify(state, null, 2)}
12493
12855
  `,
12494
12856
  "support passport grant files must be regular files in a stable directory",
12495
- path14.parse(this.memoryDir).root
12857
+ path15.parse(this.memoryDir).root
12496
12858
  );
12497
12859
  }
12498
12860
  async ensureSafeDirectories() {
@@ -12526,8 +12888,8 @@ var SupportPassportGrantStore = class {
12526
12888
  void 0
12527
12889
  );
12528
12890
  this.memoryDir = configuredMemoryDir;
12529
- this.grantsDir = path14.join(configuredMemoryDir, "state", "support-passport", "grants");
12530
- this.ownerIndexesDir = path14.join(this.grantsDir, "owners");
12891
+ this.grantsDir = path15.join(configuredMemoryDir, "state", "support-passport", "grants");
12892
+ this.ownerIndexesDir = path15.join(this.grantsDir, "owners");
12531
12893
  })();
12532
12894
  }
12533
12895
  const currentAttempt = this.memoryRootReady;
@@ -12541,12 +12903,12 @@ var SupportPassportGrantStore = class {
12541
12903
  async withMutationLock(task) {
12542
12904
  await this.ensureSafeDirectories();
12543
12905
  return await withPrivateDirectoryNoFollow(
12544
- path14.parse(this.memoryDir).root,
12906
+ path15.parse(this.memoryDir).root,
12545
12907
  this.grantsDir,
12546
12908
  "support passport grant lock directory must remain inside the memory directory",
12547
12909
  async (pinnedDirectory) => await this.withExclusiveLock(
12548
12910
  `support-passport-grants:${this.grantsDir}`,
12549
- path14.join(pinnedDirectory, ".grants.lock"),
12911
+ path15.join(pinnedDirectory, ".grants.lock"),
12550
12912
  task
12551
12913
  )
12552
12914
  );
@@ -12555,12 +12917,12 @@ var SupportPassportGrantStore = class {
12555
12917
  const normalizedGrantId = normalizeGrantId(grantId);
12556
12918
  await this.ensureSafeDirectories();
12557
12919
  return await withPrivateDirectoryNoFollow(
12558
- path14.parse(this.memoryDir).root,
12920
+ path15.parse(this.memoryDir).root,
12559
12921
  this.grantsDir,
12560
12922
  "support passport grant lock directory must remain inside the memory directory",
12561
12923
  async (pinnedDirectory) => await this.withExclusiveLock(
12562
12924
  `support-passport-grant:${this.grantsDir}:${normalizedGrantId}`,
12563
- path14.join(pinnedDirectory, `.${normalizedGrantId}.lock`),
12925
+ path15.join(pinnedDirectory, `.${normalizedGrantId}.lock`),
12564
12926
  task
12565
12927
  )
12566
12928
  );
@@ -12568,12 +12930,12 @@ var SupportPassportGrantStore = class {
12568
12930
  async withOwnerIndexLock(ownerHash, task) {
12569
12931
  await this.ensureSafeDirectories();
12570
12932
  return await withPrivateDirectoryNoFollow(
12571
- path14.parse(this.memoryDir).root,
12933
+ path15.parse(this.memoryDir).root,
12572
12934
  this.ownerIndexesDir,
12573
12935
  "support passport owner lock directory must remain inside the memory directory",
12574
12936
  async (pinnedDirectory) => await this.withExclusiveLock(
12575
12937
  `support-passport-owner:${this.ownerIndexesDir}:${ownerHash}`,
12576
- path14.join(pinnedDirectory, `.${ownerHash}.lock`),
12938
+ path15.join(pinnedDirectory, `.${ownerHash}.lock`),
12577
12939
  task
12578
12940
  )
12579
12941
  );
@@ -13411,7 +13773,7 @@ var SupportPassportModelAdapter = class {
13411
13773
 
13412
13774
  // src/support-passport/model-audit.ts
13413
13775
  import { createHash as createHash8 } from "crypto";
13414
- import path15 from "path";
13776
+ import path16 from "path";
13415
13777
  import { z as z5 } from "zod";
13416
13778
  var HashSchema = z5.string().regex(/^[a-f0-9]{64}$/);
13417
13779
  var SupportPassportModelAuditRecordSchema = z5.object({
@@ -13456,15 +13818,15 @@ var SupportPassportModelAuditStore = class {
13456
13818
  memoryRootReady;
13457
13819
  runWithHeldFileLock;
13458
13820
  constructor(options) {
13459
- this.memoryDir = path15.resolve(expandTildePath(options.memoryDir));
13460
- this.auditDir = path15.join(this.memoryDir, "state", "support-passport", "audit");
13821
+ this.memoryDir = path16.resolve(expandTildePath(options.memoryDir));
13822
+ this.auditDir = path16.join(this.memoryDir, "state", "support-passport", "audit");
13461
13823
  this.runWithHeldFileLock = options.withHeldFileLock ?? withHeldFileLock;
13462
13824
  }
13463
13825
  async record(input) {
13464
13826
  const record = SupportPassportModelAuditRecordSchema.parse(input);
13465
13827
  await this.ensureSafeDirectories();
13466
13828
  const day = record.occurredAt.slice(0, 10);
13467
- const filePath = path15.join(this.auditDir, `${day}.jsonl`);
13829
+ const filePath = path16.join(this.auditDir, `${day}.jsonl`);
13468
13830
  await serializeMutations(
13469
13831
  `support-passport-audit:${filePath}`,
13470
13832
  () => withPrivateDirectoryNoFollow(
@@ -13472,7 +13834,7 @@ var SupportPassportModelAuditStore = class {
13472
13834
  this.auditDir,
13473
13835
  "support passport audit directory must remain inside the memory directory",
13474
13836
  async (pinnedDirectory) => await this.runWithHeldFileLock(
13475
- path15.join(pinnedDirectory, `.${day}.lock`),
13837
+ path16.join(pinnedDirectory, `.${day}.lock`),
13476
13838
  {
13477
13839
  staleMs: 3e4,
13478
13840
  maxWaitMs: 5e3,
@@ -13509,7 +13871,7 @@ var SupportPassportModelAuditStore = class {
13509
13871
  "support passport memory directory must be a stable directory"
13510
13872
  );
13511
13873
  this.memoryDir = configuredMemoryDir;
13512
- this.auditDir = path15.join(configuredMemoryDir, "state", "support-passport", "audit");
13874
+ this.auditDir = path16.join(configuredMemoryDir, "state", "support-passport", "audit");
13513
13875
  })();
13514
13876
  }
13515
13877
  const currentAttempt = this.memoryRootReady;
@@ -15223,6 +15585,36 @@ var EngramAccessService = class extends SupportPassportAccessServiceBase {
15223
15585
  ]);
15224
15586
  return computeWhoKnows({ topic, limit, memories, entities });
15225
15587
  }
15588
+ /**
15589
+ * Read-only promotion-candidate surfacing (issue #2372): agent-subject,
15590
+ * active, reuse-signaled memories in the caller's namespace with no
15591
+ * equivalent in the target layer. No auto-promotion — callers use the
15592
+ * existing promotion commands.
15593
+ */
15594
+ async promotionCandidates(request) {
15595
+ const limit = request.limit ?? 20;
15596
+ if (!Number.isInteger(limit) || limit < 1 || limit > 100) {
15597
+ throw new EngramAccessInputError(
15598
+ `promotion_candidates: limit expects an integer in [1, 100] (got ${String(request.limit)})`
15599
+ );
15600
+ }
15601
+ const resolvedNamespace = this.resolveReadableNamespace(request.namespace, request.authenticatedPrincipal);
15602
+ const resolvedTarget = this.resolveReadableNamespace(
15603
+ request.targetNamespace ?? this.orchestrator.config.sharedNamespace,
15604
+ request.authenticatedPrincipal
15605
+ );
15606
+ const minAccessCount = this.orchestrator.config.promotionCandidates.minAccessCount;
15607
+ const [memories, targetMemories] = await Promise.all([
15608
+ (await this.orchestrator.getStorage(resolvedNamespace)).readAllMemories(),
15609
+ (await this.orchestrator.getStorage(resolvedTarget)).readAllMemories()
15610
+ ]);
15611
+ return {
15612
+ namespace: resolvedNamespace,
15613
+ targetNamespace: resolvedTarget,
15614
+ minAccessCount,
15615
+ candidates: computePromotionCandidates({ memories, targetMemories, minAccessCount, limit })
15616
+ };
15617
+ }
15226
15618
  async memoryStore(request, hooks) {
15227
15619
  return this.accessObserveWriteSurface.memoryStore(request, hooks);
15228
15620
  }
@@ -15863,6 +16255,35 @@ var EngramAccessService = class extends SupportPassportAccessServiceBase {
15863
16255
  });
15864
16256
  return { namespace: resolvedNamespace, ...report };
15865
16257
  }
16258
+ /**
16259
+ * Procedure library health maintenance (issue #2370). Shadow-first: the
16260
+ * gate is checked BEFORE any storage read, so `maintenance.enabled=false`
16261
+ * returns `{ enabled: false }` having touched nothing but config. Apply
16262
+ * mode additionally requires `apply: true`; `dryRun: true` forces shadow.
16263
+ *
16264
+ * The authenticated principal (never a client-supplied actor) drives the
16265
+ * namespace via the same writable resolver `procedureMiningRun` uses, so
16266
+ * cross-tenant writes are impossible.
16267
+ */
16268
+ async procedureLibraryMaintenance(request, principal) {
16269
+ const procedural = this.orchestrator.config.procedural;
16270
+ if (procedural?.enabled !== true || procedural.maintenance?.enabled !== true) {
16271
+ return { enabled: false };
16272
+ }
16273
+ const resolvedNamespace = this.writableNamespaceFor(
16274
+ request.namespace,
16275
+ void 0,
16276
+ request.authenticatedPrincipal ?? principal
16277
+ );
16278
+ const storage = await this.orchestrator.getStorage(resolvedNamespace);
16279
+ const report = await runProcedureLibraryMaintenance({
16280
+ memoryDir: storage.dir,
16281
+ storage,
16282
+ config: this.orchestrator.config,
16283
+ apply: request.apply === true && request.dryRun !== true
16284
+ });
16285
+ return { enabled: true, namespace: resolvedNamespace, report };
16286
+ }
15866
16287
  async memorySummarizeHourly() {
15867
16288
  await this.orchestrator.summarizer.runHourly();
15868
16289
  return {
@@ -16987,7 +17408,7 @@ var EngramAccessService = class extends SupportPassportAccessServiceBase {
16987
17408
  const resolvedNamespace = this.resolveReadableNamespace(options.namespace, options.principal);
16988
17409
  const storage = await offlineSyncStorageForSnapshot(this.orchestrator, resolvedNamespace);
16989
17410
  const storageHash = createHash10("sha256").update(storage.dir).digest("hex").slice(0, 16);
16990
- const deletions = [...await storage.readDeletionRevisions()].map(([path16, mtimeMs]) => ({ path: path16, mtimeMs }));
17411
+ const deletions = [...await storage.readDeletionRevisions()].map(([path17, mtimeMs]) => ({ path: path17, mtimeMs }));
16991
17412
  const snapshotBuilder = options.includeContent === false && options.baseFiles && options.baseFiles.length > 0 ? buildOfflineSyncSnapshotFromBase : buildOfflineSyncSnapshot;
16992
17413
  const snapshot = await snapshotBuilder({
16993
17414
  root: storage.dir,
@@ -17013,7 +17434,7 @@ var EngramAccessService = class extends SupportPassportAccessServiceBase {
17013
17434
  const storageHash = createHash10("sha256").update(storage.dir).digest("hex").slice(0, 16);
17014
17435
  const deletions = await filterOfflineSyncDeletionRevisions({
17015
17436
  root: storage.dir,
17016
- deletions: [...await storage.readDeletionRevisions()].map(([path16, mtimeMs]) => ({ path: path16, mtimeMs })),
17437
+ deletions: [...await storage.readDeletionRevisions()].map(([path17, mtimeMs]) => ({ path: path17, mtimeMs })),
17017
17438
  includeTranscripts: options.includeTranscripts !== false,
17018
17439
  userExcludeRegexps: this.offlineSyncUserExcludes
17019
17440
  });
@@ -17647,6 +18068,7 @@ export {
17647
18068
  resolveNamespaceWritablePreflight,
17648
18069
  resolveAuthorizedNamespaceWritablePreflight,
17649
18070
  resolveQueryNamespaceWritablePreflight,
18071
+ runProcedureLibraryMaintenance,
17650
18072
  computeProcedureStats,
17651
18073
  formatProcedureStatsText,
17652
18074
  AccessIdentityContinuitySurface,
@@ -17705,4 +18127,4 @@ export {
17705
18127
  EngramAccessService,
17706
18128
  AccessAdminOpsSurface
17707
18129
  };
17708
- //# sourceMappingURL=chunk-3PXVYJMC.js.map
18130
+ //# sourceMappingURL=chunk-SB7D4BT7.js.map