@remnic/core 9.69.44 → 9.69.46

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 (533) hide show
  1. package/dist/access-admin-ops-surface.d.ts +14 -14
  2. package/dist/access-admin-ops-surface.js +36 -36
  3. package/dist/access-audit.js +2 -2
  4. package/dist/access-authorization-probe.d.ts +14 -14
  5. package/dist/access-authorization-probe.js +37 -37
  6. package/dist/access-boundary.d.ts +14 -14
  7. package/dist/access-boundary.js +36 -36
  8. package/dist/access-cli.js +90 -87
  9. package/dist/access-cli.js.map +1 -1
  10. package/dist/access-coding-context-resolution.d.ts +1 -1
  11. package/dist/access-extraction-force-flush.d.ts +14 -14
  12. package/dist/access-extraction-force-flush.js +36 -36
  13. package/dist/access-health-types.d.ts +1 -1
  14. package/dist/access-http-briefing.d.ts +14 -14
  15. package/dist/access-http-briefing.js +37 -37
  16. package/dist/access-http-lcm-compaction.d.ts +14 -14
  17. package/dist/access-http-lifecycle-flush.d.ts +14 -14
  18. package/dist/access-http-offline-stream.d.ts +14 -14
  19. package/dist/access-http-query.d.ts +2 -2
  20. package/dist/access-http-query.js +38 -38
  21. package/dist/access-http.d.ts +15 -15
  22. package/dist/access-http.js +52 -52
  23. package/dist/access-identity-continuity-surface.d.ts +11 -11
  24. package/dist/access-identity-continuity-surface.js +36 -36
  25. package/dist/access-lcm-surface.d.ts +14 -14
  26. package/dist/access-lcm-surface.js +36 -36
  27. package/dist/access-mcp-shared-context-tools.d.ts +14 -14
  28. package/dist/access-mcp.d.ts +14 -14
  29. package/dist/access-mcp.js +44 -44
  30. package/dist/access-memory-search-fanout.d.ts +2 -2
  31. package/dist/{access-namespace-preflight-CE-RrXKu.d.ts → access-namespace-preflight-DDnsN22V.d.ts} +1 -1
  32. package/dist/access-namespace-preflight.d.ts +3 -3
  33. package/dist/access-namespace-preflight.js +36 -36
  34. package/dist/access-observe-transcript.d.ts +11 -11
  35. package/dist/access-observe-write-category.d.ts +3 -3
  36. package/dist/access-observe-write-category.js +4 -4
  37. package/dist/access-observe-write-surface.d.ts +14 -14
  38. package/dist/access-observe-write-surface.js +36 -36
  39. package/dist/access-offline-manifest.d.ts +11 -11
  40. package/dist/access-offline-manifest.js +3 -3
  41. package/dist/access-operations-batch.js +37 -37
  42. package/dist/access-operations.d.ts +14 -14
  43. package/dist/access-operations.js +43 -43
  44. package/dist/access-recall-concurrency.d.ts +14 -14
  45. package/dist/access-recall-concurrency.js +36 -36
  46. package/dist/access-recall-response.d.ts +14 -14
  47. package/dist/access-recall-response.js +36 -36
  48. package/dist/access-recall-surface.d.ts +14 -14
  49. package/dist/access-recall-surface.js +36 -36
  50. package/dist/access-schema.d.ts +114 -114
  51. package/dist/access-schema.js +3 -3
  52. package/dist/{access-service-Cww3xAAy.d.ts → access-service-DGynYlbE.d.ts} +73 -73
  53. package/dist/access-service-helpers.d.ts +14 -14
  54. package/dist/access-service.d.ts +14 -14
  55. package/dist/access-service.js +36 -36
  56. package/dist/access-surface-catalog.d.ts +14 -14
  57. package/dist/access-surface-catalog.js +38 -38
  58. package/dist/access-wearables-meetings-surface.d.ts +4 -4
  59. package/dist/action-confidence.d.ts +1 -1
  60. package/dist/active-memory-bridge.d.ts +1 -1
  61. package/dist/active-recall.d.ts +1 -1
  62. package/dist/activity/digest.d.ts +1 -1
  63. package/dist/ambient-provenance.d.ts +1 -1
  64. package/dist/artifact-search.d.ts +1 -1
  65. package/dist/{auto-sync-QZD4RD6H.js → auto-sync-DG5KEOF5.js} +5 -5
  66. package/dist/background-generation.d.ts +1 -1
  67. package/dist/behavior-learner.d.ts +1 -1
  68. package/dist/behavior-signals.d.ts +1 -1
  69. package/dist/bootstrap.d.ts +11 -11
  70. package/dist/briefing-window.d.ts +2 -2
  71. package/dist/briefing.d.ts +2 -2
  72. package/dist/briefing.js +12 -12
  73. package/dist/buffer-surprise-report.d.ts +1 -1
  74. package/dist/buffer-turn-helpers.d.ts +1 -1
  75. package/dist/buffer.d.ts +2 -2
  76. package/dist/buffer.js +3 -3
  77. package/dist/bulk-import/index.d.ts +3 -3
  78. package/dist/calibration.d.ts +1 -1
  79. package/dist/calibration.js +2 -2
  80. package/dist/capabilities.d.ts +1 -1
  81. package/dist/{catalog-Ya3DDn_T.d.ts → catalog-Dl2hYqpS.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 +13 -13
  85. package/dist/causal-trajectory-graph.d.ts +1 -1
  86. package/dist/{chunk-MOL7JK4F.js → chunk-3NYM6JA4.js} +2 -2
  87. package/dist/{chunk-WNMVUWI7.js → chunk-3UQIS2GC.js} +2 -2
  88. package/dist/{chunk-JDL5BYYF.js → chunk-47C6DF43.js} +3 -3
  89. package/dist/{chunk-ZBSP4BSN.js → chunk-4ECS33D4.js} +2 -2
  90. package/dist/{chunk-6EGIQEKC.js → chunk-4HTQ76O4.js} +2 -2
  91. package/dist/{chunk-7L54ARML.js → chunk-4XTSKGLX.js} +2 -2
  92. package/dist/{chunk-SUS64JER.js → chunk-5EHPB6RL.js} +2 -2
  93. package/dist/{chunk-J2MGTGKC.js → chunk-5ZXGH2ZL.js} +20 -3
  94. package/dist/chunk-5ZXGH2ZL.js.map +1 -0
  95. package/dist/{chunk-VDLNQVYW.js → chunk-62NYUFNH.js} +7 -7
  96. package/dist/{chunk-Y77UTH7F.js → chunk-66QOUYNS.js} +83 -64
  97. package/dist/chunk-66QOUYNS.js.map +1 -0
  98. package/dist/{chunk-SZV2L2IG.js → chunk-7BNB7KHB.js} +4 -4
  99. package/dist/chunk-AAQA6ZUP.js +41 -0
  100. package/dist/chunk-AAQA6ZUP.js.map +1 -0
  101. package/dist/{chunk-RJ7Z7YXK.js → chunk-AG6PANBG.js} +14 -20
  102. package/dist/chunk-AG6PANBG.js.map +1 -0
  103. package/dist/{chunk-IAGEEVQL.js → chunk-AN2O4KZY.js} +2 -2
  104. package/dist/{chunk-JUOJGZPV.js → chunk-AYP2FZFA.js} +2 -2
  105. package/dist/{chunk-XK76RJBN.js → chunk-AYZHHMTK.js} +2 -2
  106. package/dist/{chunk-LQVXSRAJ.js → chunk-B4EGAHHS.js} +2 -2
  107. package/dist/{chunk-HKQAI6XI.js → chunk-CFIHVWYZ.js} +2 -2
  108. package/dist/{chunk-DABSYX7V.js → chunk-CWMMKFO7.js} +3 -3
  109. package/dist/{chunk-WLHPCAVD.js → chunk-D5DTZBTV.js} +6 -6
  110. package/dist/{chunk-2HDLDBJW.js → chunk-DDBLZJRV.js} +2 -2
  111. package/dist/{chunk-F2FJTOV6.js → chunk-DO6R3LIE.js} +2 -2
  112. package/dist/{chunk-SHEHQBCG.js → chunk-DUJYRVUD.js} +638 -45
  113. package/dist/chunk-DUJYRVUD.js.map +1 -0
  114. package/dist/{chunk-LD22AAJI.js → chunk-EAZ3YZKN.js} +2 -2
  115. package/dist/{chunk-46FVFU7S.js → chunk-EC5SVM6H.js} +2 -2
  116. package/dist/{chunk-GKKLI23D.js → chunk-EEHQY7ER.js} +2 -2
  117. package/dist/{chunk-UHSOPTNB.js → chunk-EP6BA7VV.js} +50 -15
  118. package/dist/chunk-EP6BA7VV.js.map +1 -0
  119. package/dist/{chunk-BPXJINHW.js → chunk-EUP4AXIW.js} +2 -2
  120. package/dist/{chunk-2WMXZYMS.js → chunk-F5V7KRQS.js} +2 -2
  121. package/dist/{chunk-4AX5OYKC.js → chunk-FDDCZDBI.js} +2 -2
  122. package/dist/{chunk-XLPZN3A5.js → chunk-FMEP2RB5.js} +2 -2
  123. package/dist/{chunk-D7UUB33A.js → chunk-FSH6KRKO.js} +2 -2
  124. package/dist/{chunk-3254BYQV.js → chunk-GGY7WKMB.js} +1 -1
  125. package/dist/{chunk-ROXDOKLM.js → chunk-GYYLZOSO.js} +4 -4
  126. package/dist/{chunk-3K64PLY3.js → chunk-HXDXR2FH.js} +23 -23
  127. package/dist/{chunk-XOCGC3FJ.js → chunk-HYWPUYLO.js} +2 -2
  128. package/dist/{chunk-KQAFEZQX.js → chunk-IPLYGWQF.js} +5 -5
  129. package/dist/{chunk-M6FKXOYV.js → chunk-IXMWTNNY.js} +2 -2
  130. package/dist/{chunk-ZYSOT6HD.js → chunk-J3IWHCMF.js} +2 -2
  131. package/dist/{chunk-3YQ7VLP3.js → chunk-J5OXWG66.js} +2 -2
  132. package/dist/{chunk-H2N6SLTR.js → chunk-JIWZVOQM.js} +2 -2
  133. package/dist/{chunk-C3YEB7CR.js → chunk-JOP7W24J.js} +4 -4
  134. package/dist/{chunk-F6PTJLEM.js → chunk-K4KE5MYE.js} +1 -1
  135. package/dist/{chunk-IOTYIECA.js → chunk-KF57IQFX.js} +13 -13
  136. package/dist/{chunk-JL4TQYM5.js → chunk-L272A5QW.js} +33 -2
  137. package/dist/{chunk-JL4TQYM5.js.map → chunk-L272A5QW.js.map} +1 -1
  138. package/dist/chunk-M4DB6ZNN.js +87 -0
  139. package/dist/chunk-M4DB6ZNN.js.map +1 -0
  140. package/dist/{chunk-ZVQ5HF77.js → chunk-N46SNYMC.js} +2 -2
  141. package/dist/{chunk-YR5QT4SR.js → chunk-NAFPHFDM.js} +2 -2
  142. package/dist/{chunk-VHANUT45.js → chunk-ORQ7AZMU.js} +7 -7
  143. package/dist/{chunk-EOXCOZ6L.js → chunk-OV7GJ4KW.js} +2 -2
  144. package/dist/{chunk-VJXMFBVR.js → chunk-P7S7BVBJ.js} +2 -2
  145. package/dist/{chunk-GMU7MAHS.js → chunk-QUFJ3NJE.js} +260 -796
  146. package/dist/chunk-QUFJ3NJE.js.map +1 -0
  147. package/dist/{chunk-7F47R4H4.js → chunk-S3SND7SO.js} +2 -2
  148. package/dist/{chunk-5AJZ7EUW.js → chunk-S7KDHFF2.js} +2 -2
  149. package/dist/{chunk-4WMGRLTV.js → chunk-SRRZZHA5.js} +2 -2
  150. package/dist/{chunk-KDLOKVX7.js → chunk-SW42MMAH.js} +2 -2
  151. package/dist/{chunk-2YIUUXNK.js → chunk-T5NI5K46.js} +2 -2
  152. package/dist/{chunk-QCTXQ2HW.js → chunk-TE6B2UU6.js} +2 -2
  153. package/dist/{chunk-JDOBQPJY.js → chunk-TNQR7N52.js} +2 -2
  154. package/dist/{chunk-7K5Q6COX.js → chunk-TVVEYCNW.js} +4 -4
  155. package/dist/{chunk-T3F2HWIG.js → chunk-TZ44E732.js} +2 -2
  156. package/dist/{chunk-PF7LQ22G.js → chunk-U4ESGVZ2.js} +3 -3
  157. package/dist/{chunk-WJPR2XUN.js → chunk-UEJY6ZTQ.js} +2 -2
  158. package/dist/{chunk-K3IVJ5ML.js → chunk-UGGOQKO6.js} +26 -26
  159. package/dist/{chunk-OCX7OWOC.js → chunk-UOREPQ3C.js} +2 -2
  160. package/dist/{chunk-R3H2AXO2.js → chunk-VGRVJ6Z6.js} +2 -2
  161. package/dist/{chunk-IWHNT35B.js → chunk-WOBMSMUK.js} +3 -3
  162. package/dist/{chunk-DDGQDNQW.js → chunk-XLZZLUWL.js} +2 -2
  163. package/dist/{chunk-KORQWGUA.js → chunk-Y3XHIWVP.js} +2 -2
  164. package/dist/{chunk-BZDK5EOD.js → chunk-YFVIA5A6.js} +2 -2
  165. package/dist/{chunk-GR76OKET.js → chunk-YSBYNCCN.js} +2 -2
  166. package/dist/{chunk-OGAKUA7I.js → chunk-YUQPUK6H.js} +2 -2
  167. package/dist/{chunk-TRTLWUDD.js → chunk-ZTHGFTMW.js} +2 -2
  168. package/dist/{cli-Cl7bKIWJ.d.ts → cli-Cik3H7q1.d.ts} +5 -5
  169. package/dist/cli.d.ts +16 -16
  170. package/dist/cli.js +67 -67
  171. package/dist/coding/export-okf-codegraph.d.ts +1 -1
  172. package/dist/coding/export-okf-codegraph.js +11 -11
  173. package/dist/coding/pre-action-gate.d.ts +1 -1
  174. package/dist/compounding/engine.d.ts +2 -2
  175. package/dist/compounding/engine.js +12 -12
  176. package/dist/compounding/preference-consolidator.d.ts +1 -1
  177. package/dist/compression-optimizer.d.ts +1 -1
  178. package/dist/config.d.ts +1 -1
  179. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  180. package/dist/connectors/codex-materialize-runner.js +12 -12
  181. package/dist/connectors/codex-materialize.d.ts +1 -1
  182. package/dist/connectors/index.d.ts +1 -1
  183. package/dist/connectors/index.js +12 -12
  184. package/dist/consolidation-provenance-check.d.ts +2 -2
  185. package/dist/consolidation-undo.d.ts +2 -2
  186. package/dist/contradiction/index.d.ts +4 -4
  187. package/dist/converge-config.d.ts +1 -1
  188. package/dist/convergence-refresh.d.ts +2 -2
  189. package/dist/convergence-refresh.js +14 -14
  190. package/dist/conversation-index/backend.d.ts +1 -1
  191. package/dist/conversation-index/chunker.d.ts +1 -1
  192. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  193. package/dist/conversation-index/indexer.d.ts +1 -1
  194. package/dist/conversation-index/search.d.ts +1 -1
  195. package/dist/corpus-watermark.d.ts +1 -1
  196. package/dist/corpus-watermark.js +14 -14
  197. package/dist/cross-lingual-recall.d.ts +1 -1
  198. package/dist/day-summary.d.ts +1 -1
  199. package/dist/deep-recall-http-glue.d.ts +14 -14
  200. package/dist/deep-recall-http-glue.js +4 -4
  201. package/dist/deep-recall-mcp-tools.d.ts +14 -14
  202. package/dist/deep-recall-policy-llm.d.ts +2 -2
  203. package/dist/deep-recall-policy-llm.js +3 -3
  204. package/dist/deep-recall-seeds.d.ts +1 -1
  205. package/dist/delinearize.d.ts +1 -1
  206. package/dist/dependency-propagation-config.d.ts +1 -1
  207. package/dist/{dependency-propagation-delivery-CggS9BFT.d.ts → dependency-propagation-delivery-BXaUoVUf.d.ts} +1 -1
  208. package/dist/direct-answer-wiring.d.ts +1 -1
  209. package/dist/direct-answer.d.ts +1 -1
  210. package/dist/embedding-fallback.d.ts +1 -1
  211. package/dist/enrichment/index.d.ts +1 -1
  212. package/dist/entity-origin-fields.d.ts +1 -1
  213. package/dist/entity-retrieval.d.ts +2 -2
  214. package/dist/entity-retrieval.js +12 -12
  215. package/dist/entity-schema.d.ts +1 -1
  216. package/dist/episodic-context.d.ts +1 -1
  217. package/dist/eval-trajectory-contracts.d.ts +1 -1
  218. package/dist/eval-trajectory-store.d.ts +1 -1
  219. package/dist/eval-trajectory.d.ts +1 -1
  220. package/dist/explicit-capture.d.ts +11 -11
  221. package/dist/explicit-capture.js +2 -2
  222. package/dist/external-wiki-access.d.ts +14 -14
  223. package/dist/external-wiki-access.js +37 -37
  224. package/dist/external-wiki-collection-registration.d.ts +1 -1
  225. package/dist/external-wiki-collection.d.ts +1 -1
  226. package/dist/external-wiki-mcp-tools.d.ts +14 -14
  227. package/dist/extraction-error-classification.d.ts +1 -1
  228. package/dist/extraction-faithfulness.d.ts +2 -2
  229. package/dist/extraction-faithfulness.js +3 -3
  230. package/dist/extraction-judge-telemetry.d.ts +2 -2
  231. package/dist/extraction-judge-training.d.ts +2 -2
  232. package/dist/extraction-judge.d.ts +2 -2
  233. package/dist/extraction-judge.js +3 -3
  234. package/dist/extraction-liveness.d.ts +1 -1
  235. package/dist/extraction-normalization.d.ts +1 -1
  236. package/dist/extraction-prompt.d.ts +1 -1
  237. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  238. package/dist/extraction-source-grounding.d.ts +1 -1
  239. package/dist/extraction-span-config.d.ts +1 -1
  240. package/dist/extraction-span-materialize.d.ts +1 -1
  241. package/dist/extraction-span-wire.d.ts +23 -4
  242. package/dist/extraction-span-wire.js +7 -8
  243. package/dist/extraction-span-wire.js.map +1 -1
  244. package/dist/extraction.d.ts +2 -2
  245. package/dist/extraction.js +19 -17
  246. package/dist/fallback-llm-codex-subscription.d.ts +1 -1
  247. package/dist/fallback-llm-codex-subscription.js +1 -1
  248. package/dist/fallback-llm.d.ts +1 -1
  249. package/dist/fallback-llm.js +2 -2
  250. package/dist/{generic-recall-paths-CoXPSnCw.d.ts → generic-recall-paths-BkVVEoeO.d.ts} +1 -1
  251. package/dist/graph-append-error.d.ts +1 -1
  252. package/dist/graph-dashboard-diff.d.ts +1 -1
  253. package/dist/graph-dashboard-key.d.ts +1 -1
  254. package/dist/graph-dashboard-parser.d.ts +1 -1
  255. package/dist/graph-edge-reinforcement.d.ts +1 -1
  256. package/dist/graph-jsonl.d.ts +1 -1
  257. package/dist/graph-path-reconstruction.d.ts +1 -1
  258. package/dist/graph-path-scoring.d.ts +1 -1
  259. package/dist/graph-snapshot.d.ts +1 -1
  260. package/dist/graph.d.ts +1 -1
  261. package/dist/harmonic-retrieval.js +1 -1
  262. package/dist/importance.d.ts +1 -1
  263. package/dist/importers/index.d.ts +1 -1
  264. package/dist/importers/test-utils.d.ts +1 -1
  265. package/dist/in-flight-reads.d.ts +1 -1
  266. package/dist/{index-fdw_oK5a.d.ts → index-Zb6SUV4R.d.ts} +3 -3
  267. package/dist/index.d.ts +703 -703
  268. package/dist/index.js +90 -87
  269. package/dist/intent.d.ts +1 -1
  270. package/dist/lcm/engine.d.ts +1 -1
  271. package/dist/lcm/index.d.ts +1 -1
  272. package/dist/lcm/index.js +3 -3
  273. package/dist/lcm/tools.d.ts +1 -1
  274. package/dist/lifecycle.d.ts +1 -1
  275. package/dist/live-connectors-runner.d.ts +1 -1
  276. package/dist/{local-llm-3-jtw52a.d.ts → local-llm-DdrhmecM.d.ts} +1 -1
  277. package/dist/local-llm-helpers.d.ts +2 -2
  278. package/dist/local-llm.d.ts +2 -2
  279. package/dist/local-model-endpoint.d.ts +1 -1
  280. package/dist/location/index.d.ts +5 -5
  281. package/dist/location/index.js +14 -14
  282. package/dist/maintenance/memory-governance.d.ts +1 -1
  283. package/dist/maintenance/memory-governance.js +12 -12
  284. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
  285. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +12 -12
  286. package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
  287. package/dist/maintenance/rebuild-memory-projection.js +13 -13
  288. package/dist/{maintenance-DgeeH0a1.d.ts → maintenance-Du_VRvVg.d.ts} +3 -3
  289. package/dist/mcp-memory-inspector-app.d.ts +14 -14
  290. package/dist/memory-action-policy.d.ts +1 -1
  291. package/dist/memory-age.d.ts +100 -0
  292. package/dist/memory-age.js +22 -0
  293. package/dist/memory-age.js.map +1 -0
  294. package/dist/memory-cache.d.ts +1 -1
  295. package/dist/memory-controller.d.ts +1 -1
  296. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  297. package/dist/memory-projection-store.d.ts +1 -1
  298. package/dist/memory-provenance.d.ts +1 -1
  299. package/dist/memory-snapshot.d.ts +1 -1
  300. package/dist/memory-subject-cli.d.ts +14 -14
  301. package/dist/memory-subject.d.ts +14 -14
  302. package/dist/memory-worth-outcomes.d.ts +2 -2
  303. package/dist/models-json.d.ts +1 -1
  304. package/dist/namespaces/migrate.d.ts +3 -3
  305. package/dist/namespaces/migrate.js +13 -13
  306. package/dist/namespaces/principal.d.ts +1 -1
  307. package/dist/namespaces/search.d.ts +1 -1
  308. package/dist/namespaces/search.js +3 -3
  309. package/dist/namespaces/storage.d.ts +3 -3
  310. package/dist/namespaces/storage.js +12 -12
  311. package/dist/native-knowledge.d.ts +1 -1
  312. package/dist/offline-sync-impression-drain.d.ts +1 -1
  313. package/dist/operator-doctor-corpus.d.ts +1 -1
  314. package/dist/operator-doctor-corpus.js +15 -15
  315. package/dist/operator-doctor-replica.d.ts +1 -1
  316. package/dist/operator-toolkit.d.ts +3 -3
  317. package/dist/operator-toolkit.js +20 -20
  318. package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
  319. package/dist/orchestration/maintenance.d.ts +4 -4
  320. package/dist/orchestration/maintenance.js +20 -20
  321. package/dist/{orchestrator-VXWKdatm.d.ts → orchestrator-D9U3Zgjp.d.ts} +10 -10
  322. package/dist/orchestrator.d.ts +11 -11
  323. package/dist/orchestrator.js +90 -87
  324. package/dist/patterns-cli.d.ts +1 -1
  325. package/dist/{pipeline-CwXZBKR5.d.ts → pipeline-4lqKJZ_0.d.ts} +1 -1
  326. package/dist/policy-runtime.d.ts +1 -1
  327. package/dist/proactive-contention.d.ts +2 -2
  328. package/dist/provenance.d.ts +1 -1
  329. package/dist/{public-http-DdmM4scJ.d.ts → public-http-AabioFLh.d.ts} +1 -1
  330. package/dist/{qmd-DOLTPIQg.d.ts → qmd-DnoWaXKb.d.ts} +1 -1
  331. package/dist/qmd-preflight.d.ts +2 -2
  332. package/dist/qmd-recall-cache.d.ts +1 -1
  333. package/dist/qmd.d.ts +2 -2
  334. package/dist/recall-concurrency-config.d.ts +1 -1
  335. package/dist/recall-disclosure-escalation.d.ts +1 -1
  336. package/dist/recall-explain-renderer.d.ts +1 -1
  337. package/dist/recall-memory-map.d.ts +1 -1
  338. package/dist/recall-navigate-access.d.ts +1 -1
  339. package/dist/recall-navigate-disclosure.d.ts +1 -1
  340. package/dist/recall-navigate.d.ts +1 -1
  341. package/dist/recall-navigation-http-glue.d.ts +14 -14
  342. package/dist/recall-navigation-mcp-tools.d.ts +14 -14
  343. package/dist/recall-navigation-operations.js +37 -37
  344. package/dist/recall-navigation-renderer.d.ts +1 -1
  345. package/dist/recall-navigation.d.ts +1 -1
  346. package/dist/recall-navigation.js +36 -36
  347. package/dist/recall-planner-llm.d.ts +1 -1
  348. package/dist/recall-planner-llm.js +2 -2
  349. package/dist/recall-state-view-admission.d.ts +2 -2
  350. package/dist/recall-state-view-admission.js +3 -3
  351. package/dist/recall-state-view-anchors.d.ts +1 -1
  352. package/dist/recall-state.d.ts +1 -1
  353. package/dist/recall-tag-filter.d.ts +1 -1
  354. package/dist/recall-timings.d.ts +1 -1
  355. package/dist/recall-xray-cli.d.ts +1 -1
  356. package/dist/recall-xray-renderer.d.ts +1 -1
  357. package/dist/recall-xray.d.ts +1 -1
  358. package/dist/reconcile/cursor.d.ts +1 -1
  359. package/dist/reconcile/manifest.d.ts +1 -1
  360. package/dist/reconcile/manifest.js +2 -2
  361. package/dist/reconcile/plan.d.ts +1 -1
  362. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  363. package/dist/replay/normalizers/claude.d.ts +1 -1
  364. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  365. package/dist/replay/normalizers/shared.d.ts +1 -1
  366. package/dist/replay/runner.d.ts +1 -1
  367. package/dist/replay/types.d.ts +1 -1
  368. package/dist/replica-divergence.d.ts +1 -1
  369. package/dist/replica-peers-config.d.ts +1 -1
  370. package/dist/resolve-auth-token.d.ts +1 -1
  371. package/dist/retrieval-agents.d.ts +2 -2
  372. package/dist/retrieval-tiers.d.ts +1 -1
  373. package/dist/routing/engine.d.ts +1 -1
  374. package/dist/routing/store.d.ts +1 -1
  375. package/dist/salvage-envelope.d.ts +1 -1
  376. package/dist/schemas.d.ts +160 -160
  377. package/dist/{scope-profiles-C564-hrv.d.ts → scope-profiles-crazXegZ.d.ts} +1 -1
  378. package/dist/search/embed-helper.d.ts +1 -1
  379. package/dist/search/factory.d.ts +1 -1
  380. package/dist/search/factory.js +2 -2
  381. package/dist/search/index.d.ts +1 -1
  382. package/dist/search/index.js +4 -4
  383. package/dist/search/lancedb-backend.d.ts +1 -1
  384. package/dist/search/meilisearch-backend.d.ts +1 -1
  385. package/dist/search/noop-backend.d.ts +1 -1
  386. package/dist/search/orama-backend.d.ts +1 -1
  387. package/dist/search/port.d.ts +1 -1
  388. package/dist/search/remote-backend.d.ts +1 -1
  389. package/dist/{semantic-consolidation-g6x-ShY8.d.ts → semantic-consolidation-B09JI9WM.d.ts} +1 -1
  390. package/dist/semantic-consolidation.d.ts +2 -2
  391. package/dist/semantic-consolidation.js +13 -13
  392. package/dist/semantic-rule-promotion.js +12 -12
  393. package/dist/semantic-rule-verifier.d.ts +1 -1
  394. package/dist/semantic-rule-verifier.js +12 -12
  395. package/dist/{service-CaCOk0rd.d.ts → service-ByjbCuj7.d.ts} +2 -2
  396. package/dist/session-observer-bands.d.ts +1 -1
  397. package/dist/session-observer-state.d.ts +1 -1
  398. package/dist/shared-context/manager.d.ts +7 -7
  399. package/dist/signal.d.ts +1 -1
  400. package/dist/source-agent-qualifier.d.ts +1 -1
  401. package/dist/source-agent-qualifier.js +15 -15
  402. package/dist/source-attribution.d.ts +7 -4
  403. package/dist/source-attribution.js +1 -1
  404. package/dist/standup/build.js +12 -12
  405. package/dist/{storage-C9nsZX5Q.d.ts → storage-CbdF077z.d.ts} +17 -3
  406. package/dist/storage.d.ts +2 -2
  407. package/dist/storage.js +11 -11
  408. package/dist/subject-config.d.ts +1 -1
  409. package/dist/summarizer.d.ts +1 -1
  410. package/dist/summarizer.js +3 -3
  411. package/dist/summary-snapshot.d.ts +1 -1
  412. package/dist/support-passport/index.d.ts +17 -17
  413. package/dist/support-passport/index.js +39 -39
  414. package/dist/{tagging-BA4RFdH3.d.ts → tagging-CF7DNV7_.d.ts} +2 -2
  415. package/dist/temporal-supersession.d.ts +2 -2
  416. package/dist/temporal-timeline-recall.d.ts +1 -1
  417. package/dist/temporal-validity.d.ts +1 -1
  418. package/dist/threading.d.ts +1 -1
  419. package/dist/tier-migration.d.ts +2 -2
  420. package/dist/tier-routing.d.ts +1 -1
  421. package/dist/topics.d.ts +1 -1
  422. package/dist/transcript.d.ts +1 -1
  423. package/dist/transfer/autodetect.js +1 -1
  424. package/dist/transfer/backup.js +1 -1
  425. package/dist/transfer/capsule-export.js +2 -2
  426. package/dist/transfer/export-okf.d.ts +1 -1
  427. package/dist/transfer/export-okf.js +12 -12
  428. package/dist/transfer/types.d.ts +78 -78
  429. package/dist/trust-score-stage.d.ts +1 -1
  430. package/dist/trust-score.d.ts +1 -1
  431. package/dist/{types-Sps-lg5I.d.ts → types-nmhnJpxx.d.ts} +1 -1
  432. package/dist/types.d.ts +1 -1
  433. package/dist/utility-runtime.d.ts +1 -1
  434. package/dist/verified-recall.js +12 -12
  435. package/dist/who-knows-cli.d.ts +14 -14
  436. package/dist/who-knows-cli.js +13 -13
  437. package/dist/who-knows.d.ts +14 -14
  438. package/dist/who-knows.js +12 -12
  439. package/dist/write-envelope.d.ts +1 -1
  440. package/package.json +2 -2
  441. package/src/background-generation.test.ts +77 -0
  442. package/src/dedup/merge.test.ts +185 -8
  443. package/src/extraction-span-wire.test.ts +17 -1
  444. package/src/extraction-span-wire.ts +46 -3
  445. package/src/extraction.ts +2 -11
  446. package/src/memory-age.test.ts +106 -0
  447. package/src/memory-age.ts +196 -0
  448. package/src/orchestration/recall-search-pipeline.test.ts +207 -1
  449. package/src/orchestration/recall-search-pipeline.ts +13 -9
  450. package/src/orchestration/semantic-merge-commit-effects.ts +31 -9
  451. package/src/orchestration/semantic-merge-persist.ts +16 -5
  452. package/src/providers/codex-subscription.test.ts +109 -3
  453. package/src/providers/codex-subscription.ts +57 -17
  454. package/src/source-attribution.test.ts +27 -0
  455. package/src/source-attribution.ts +41 -5
  456. package/src/storage/cas-revision-host.ts +22 -0
  457. package/src/storage/cas-revision-store.test.ts +44 -1
  458. package/src/storage/cas-revision-store.ts +23 -0
  459. package/src/storage/tombstone-blocked-capture-sync.ts +26 -1
  460. package/src/storage-frontmatter-cas.test.ts +49 -1
  461. package/src/storage.ts +1 -1
  462. package/src/summarizer.ts +18 -0
  463. package/dist/chunk-GMU7MAHS.js.map +0 -1
  464. package/dist/chunk-J2MGTGKC.js.map +0 -1
  465. package/dist/chunk-RJ7Z7YXK.js.map +0 -1
  466. package/dist/chunk-SHEHQBCG.js.map +0 -1
  467. package/dist/chunk-UHSOPTNB.js.map +0 -1
  468. package/dist/chunk-Y77UTH7F.js.map +0 -1
  469. /package/dist/{auto-sync-QZD4RD6H.js.map → auto-sync-DG5KEOF5.js.map} +0 -0
  470. /package/dist/{chunk-MOL7JK4F.js.map → chunk-3NYM6JA4.js.map} +0 -0
  471. /package/dist/{chunk-WNMVUWI7.js.map → chunk-3UQIS2GC.js.map} +0 -0
  472. /package/dist/{chunk-JDL5BYYF.js.map → chunk-47C6DF43.js.map} +0 -0
  473. /package/dist/{chunk-ZBSP4BSN.js.map → chunk-4ECS33D4.js.map} +0 -0
  474. /package/dist/{chunk-6EGIQEKC.js.map → chunk-4HTQ76O4.js.map} +0 -0
  475. /package/dist/{chunk-7L54ARML.js.map → chunk-4XTSKGLX.js.map} +0 -0
  476. /package/dist/{chunk-SUS64JER.js.map → chunk-5EHPB6RL.js.map} +0 -0
  477. /package/dist/{chunk-VDLNQVYW.js.map → chunk-62NYUFNH.js.map} +0 -0
  478. /package/dist/{chunk-SZV2L2IG.js.map → chunk-7BNB7KHB.js.map} +0 -0
  479. /package/dist/{chunk-IAGEEVQL.js.map → chunk-AN2O4KZY.js.map} +0 -0
  480. /package/dist/{chunk-JUOJGZPV.js.map → chunk-AYP2FZFA.js.map} +0 -0
  481. /package/dist/{chunk-XK76RJBN.js.map → chunk-AYZHHMTK.js.map} +0 -0
  482. /package/dist/{chunk-LQVXSRAJ.js.map → chunk-B4EGAHHS.js.map} +0 -0
  483. /package/dist/{chunk-HKQAI6XI.js.map → chunk-CFIHVWYZ.js.map} +0 -0
  484. /package/dist/{chunk-DABSYX7V.js.map → chunk-CWMMKFO7.js.map} +0 -0
  485. /package/dist/{chunk-WLHPCAVD.js.map → chunk-D5DTZBTV.js.map} +0 -0
  486. /package/dist/{chunk-2HDLDBJW.js.map → chunk-DDBLZJRV.js.map} +0 -0
  487. /package/dist/{chunk-F2FJTOV6.js.map → chunk-DO6R3LIE.js.map} +0 -0
  488. /package/dist/{chunk-LD22AAJI.js.map → chunk-EAZ3YZKN.js.map} +0 -0
  489. /package/dist/{chunk-46FVFU7S.js.map → chunk-EC5SVM6H.js.map} +0 -0
  490. /package/dist/{chunk-GKKLI23D.js.map → chunk-EEHQY7ER.js.map} +0 -0
  491. /package/dist/{chunk-BPXJINHW.js.map → chunk-EUP4AXIW.js.map} +0 -0
  492. /package/dist/{chunk-2WMXZYMS.js.map → chunk-F5V7KRQS.js.map} +0 -0
  493. /package/dist/{chunk-4AX5OYKC.js.map → chunk-FDDCZDBI.js.map} +0 -0
  494. /package/dist/{chunk-XLPZN3A5.js.map → chunk-FMEP2RB5.js.map} +0 -0
  495. /package/dist/{chunk-D7UUB33A.js.map → chunk-FSH6KRKO.js.map} +0 -0
  496. /package/dist/{chunk-3254BYQV.js.map → chunk-GGY7WKMB.js.map} +0 -0
  497. /package/dist/{chunk-ROXDOKLM.js.map → chunk-GYYLZOSO.js.map} +0 -0
  498. /package/dist/{chunk-3K64PLY3.js.map → chunk-HXDXR2FH.js.map} +0 -0
  499. /package/dist/{chunk-XOCGC3FJ.js.map → chunk-HYWPUYLO.js.map} +0 -0
  500. /package/dist/{chunk-KQAFEZQX.js.map → chunk-IPLYGWQF.js.map} +0 -0
  501. /package/dist/{chunk-M6FKXOYV.js.map → chunk-IXMWTNNY.js.map} +0 -0
  502. /package/dist/{chunk-ZYSOT6HD.js.map → chunk-J3IWHCMF.js.map} +0 -0
  503. /package/dist/{chunk-3YQ7VLP3.js.map → chunk-J5OXWG66.js.map} +0 -0
  504. /package/dist/{chunk-H2N6SLTR.js.map → chunk-JIWZVOQM.js.map} +0 -0
  505. /package/dist/{chunk-C3YEB7CR.js.map → chunk-JOP7W24J.js.map} +0 -0
  506. /package/dist/{chunk-F6PTJLEM.js.map → chunk-K4KE5MYE.js.map} +0 -0
  507. /package/dist/{chunk-IOTYIECA.js.map → chunk-KF57IQFX.js.map} +0 -0
  508. /package/dist/{chunk-ZVQ5HF77.js.map → chunk-N46SNYMC.js.map} +0 -0
  509. /package/dist/{chunk-YR5QT4SR.js.map → chunk-NAFPHFDM.js.map} +0 -0
  510. /package/dist/{chunk-VHANUT45.js.map → chunk-ORQ7AZMU.js.map} +0 -0
  511. /package/dist/{chunk-EOXCOZ6L.js.map → chunk-OV7GJ4KW.js.map} +0 -0
  512. /package/dist/{chunk-VJXMFBVR.js.map → chunk-P7S7BVBJ.js.map} +0 -0
  513. /package/dist/{chunk-7F47R4H4.js.map → chunk-S3SND7SO.js.map} +0 -0
  514. /package/dist/{chunk-5AJZ7EUW.js.map → chunk-S7KDHFF2.js.map} +0 -0
  515. /package/dist/{chunk-4WMGRLTV.js.map → chunk-SRRZZHA5.js.map} +0 -0
  516. /package/dist/{chunk-KDLOKVX7.js.map → chunk-SW42MMAH.js.map} +0 -0
  517. /package/dist/{chunk-2YIUUXNK.js.map → chunk-T5NI5K46.js.map} +0 -0
  518. /package/dist/{chunk-QCTXQ2HW.js.map → chunk-TE6B2UU6.js.map} +0 -0
  519. /package/dist/{chunk-JDOBQPJY.js.map → chunk-TNQR7N52.js.map} +0 -0
  520. /package/dist/{chunk-7K5Q6COX.js.map → chunk-TVVEYCNW.js.map} +0 -0
  521. /package/dist/{chunk-T3F2HWIG.js.map → chunk-TZ44E732.js.map} +0 -0
  522. /package/dist/{chunk-PF7LQ22G.js.map → chunk-U4ESGVZ2.js.map} +0 -0
  523. /package/dist/{chunk-WJPR2XUN.js.map → chunk-UEJY6ZTQ.js.map} +0 -0
  524. /package/dist/{chunk-K3IVJ5ML.js.map → chunk-UGGOQKO6.js.map} +0 -0
  525. /package/dist/{chunk-OCX7OWOC.js.map → chunk-UOREPQ3C.js.map} +0 -0
  526. /package/dist/{chunk-R3H2AXO2.js.map → chunk-VGRVJ6Z6.js.map} +0 -0
  527. /package/dist/{chunk-IWHNT35B.js.map → chunk-WOBMSMUK.js.map} +0 -0
  528. /package/dist/{chunk-DDGQDNQW.js.map → chunk-XLZZLUWL.js.map} +0 -0
  529. /package/dist/{chunk-KORQWGUA.js.map → chunk-Y3XHIWVP.js.map} +0 -0
  530. /package/dist/{chunk-BZDK5EOD.js.map → chunk-YFVIA5A6.js.map} +0 -0
  531. /package/dist/{chunk-GR76OKET.js.map → chunk-YSBYNCCN.js.map} +0 -0
  532. /package/dist/{chunk-OGAKUA7I.js.map → chunk-YUQPUK6H.js.map} +0 -0
  533. /package/dist/{chunk-TRTLWUDD.js.map → chunk-ZTHGFTMW.js.map} +0 -0
@@ -1,3 +1,7 @@
1
+ import {
2
+ CAPSULE_SCHEMA_VERSION,
3
+ EXPORT_FORMAT
4
+ } from "./chunk-J4EB7DNW.js";
1
5
  import {
2
6
  CAPSULE_ID_PATTERN,
3
7
  CapsuleBlockSchema,
@@ -7,10 +11,6 @@ import {
7
11
  import {
8
12
  encryptCapsuleFile
9
13
  } from "./chunk-X7Y7WX73.js";
10
- import {
11
- CAPSULE_SCHEMA_VERSION,
12
- EXPORT_FORMAT
13
- } from "./chunk-J4EB7DNW.js";
14
14
  import {
15
15
  DEFAULT_TRANSFER_EXCLUDE_DIRS,
16
16
  computeTransferOutputRel
@@ -261,4 +261,4 @@ export {
261
261
  exportCapsule,
262
262
  isValidCapsuleSince
263
263
  };
264
- //# sourceMappingURL=chunk-KQAFEZQX.js.map
264
+ //# sourceMappingURL=chunk-IPLYGWQF.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  parseFrontmatter
3
- } from "./chunk-GMU7MAHS.js";
3
+ } from "./chunk-QUFJ3NJE.js";
4
4
  import {
5
5
  activityDigestPath,
6
6
  isValidActivityDate
@@ -199,4 +199,4 @@ export {
199
199
  buildStandup,
200
200
  standupHelp
201
201
  };
202
- //# sourceMappingURL=chunk-M6FKXOYV.js.map
202
+ //# sourceMappingURL=chunk-IXMWTNNY.js.map
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-AAD2ZS6P.js";
5
5
  import {
6
6
  gatewayTaskChainOptions
7
- } from "./chunk-TRTLWUDD.js";
7
+ } from "./chunk-ZTHGFTMW.js";
8
8
  import {
9
9
  extractJsonCandidates
10
10
  } from "./chunk-RGMVMVMF.js";
@@ -685,4 +685,4 @@ export {
685
685
  serializeFaithfulnessFields,
686
686
  parseFaithfulnessField
687
687
  };
688
- //# sourceMappingURL=chunk-ZYSOT6HD.js.map
688
+ //# sourceMappingURL=chunk-J3IWHCMF.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  StorageManager
3
- } from "./chunk-GMU7MAHS.js";
3
+ } from "./chunk-QUFJ3NJE.js";
4
4
  import {
5
5
  keyring_exports,
6
6
  secureStoreDir
@@ -412,4 +412,4 @@ export {
412
412
  resolveNamespaceStorageRoot,
413
413
  NamespaceStorageRouter
414
414
  };
415
- //# sourceMappingURL=chunk-3YQ7VLP3.js.map
415
+ //# sourceMappingURL=chunk-J5OXWG66.js.map
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-H3FZVNRN.js";
14
14
  import {
15
15
  ExtractionDeadlineError
16
- } from "./chunk-BPXJINHW.js";
16
+ } from "./chunk-EUP4AXIW.js";
17
17
  import {
18
18
  resolvePrincipal
19
19
  } from "./chunk-MRV7VSQK.js";
@@ -798,4 +798,4 @@ var SmartBuffer = class {
798
798
  export {
799
799
  SmartBuffer
800
800
  };
801
- //# sourceMappingURL=chunk-H2N6SLTR.js.map
801
+ //# sourceMappingURL=chunk-JIWZVOQM.js.map
@@ -1,3 +1,6 @@
1
+ import {
2
+ NoopSearchBackend
3
+ } from "./chunk-CYEPCZN5.js";
1
4
  import {
2
5
  OramaBackend
3
6
  } from "./chunk-G6NQ3L4T.js";
@@ -13,9 +16,6 @@ import {
13
16
  import {
14
17
  MeilisearchBackend
15
18
  } from "./chunk-KVO2BTA4.js";
16
- import {
17
- NoopSearchBackend
18
- } from "./chunk-CYEPCZN5.js";
19
19
  import {
20
20
  createConversationIndexBackend
21
21
  } from "./chunk-TFA6HPOA.js";
@@ -179,4 +179,4 @@ export {
179
179
  createConversationSearchBackend,
180
180
  createConversationIndexRuntime
181
181
  };
182
- //# sourceMappingURL=chunk-C3YEB7CR.js.map
182
+ //# sourceMappingURL=chunk-JOP7W24J.js.map
@@ -645,4 +645,4 @@ export {
645
645
  appendMemoryToGraphContext,
646
646
  resolvePersistedMemoryRelativePath
647
647
  };
648
- //# sourceMappingURL=chunk-F6PTJLEM.js.map
648
+ //# sourceMappingURL=chunk-K4KE5MYE.js.map
@@ -15,13 +15,13 @@ import {
15
15
  } from "./chunk-3HSRWJTC.js";
16
16
  import {
17
17
  respondDeepRecall
18
- } from "./chunk-WNMVUWI7.js";
18
+ } from "./chunk-3UQIS2GC.js";
19
19
  import {
20
20
  handleSupportPassportOwnerHttp
21
- } from "./chunk-WJPR2XUN.js";
21
+ } from "./chunk-UEJY6ZTQ.js";
22
22
  import {
23
23
  buildSupportPassportPublicRequestHandler
24
- } from "./chunk-EOXCOZ6L.js";
24
+ } from "./chunk-OV7GJ4KW.js";
25
25
  import {
26
26
  handleMcpGetSse
27
27
  } from "./chunk-SRT6SHVZ.js";
@@ -34,10 +34,10 @@ import {
34
34
  processChatMessage,
35
35
  sessionBelongsToPrincipal,
36
36
  subscribeChatTranscript
37
- } from "./chunk-ROXDOKLM.js";
37
+ } from "./chunk-GYYLZOSO.js";
38
38
  import {
39
39
  RelayMissionStoreError
40
- } from "./chunk-WLHPCAVD.js";
40
+ } from "./chunk-D5DTZBTV.js";
41
41
  import {
42
42
  executeResolution,
43
43
  isValidResolutionVerb
@@ -59,10 +59,10 @@ import {
59
59
  optionalNamespaceKindQueryParam,
60
60
  optionalQueryString,
61
61
  positiveIntQueryParam
62
- } from "./chunk-BZDK5EOD.js";
62
+ } from "./chunk-YFVIA5A6.js";
63
63
  import {
64
64
  respondBriefingHttp
65
- } from "./chunk-SUS64JER.js";
65
+ } from "./chunk-5EHPB6RL.js";
66
66
  import {
67
67
  maybeHandleLifecycleFlush
68
68
  } from "./chunk-TIDEL77O.js";
@@ -73,14 +73,14 @@ import {
73
73
  authorizationProbeNamespaces,
74
74
  authorizationProbeRequiresPrincipalNamespace,
75
75
  probeOperationAuthorization
76
- } from "./chunk-XK76RJBN.js";
76
+ } from "./chunk-AYZHHMTK.js";
77
77
  import {
78
78
  getOperation,
79
79
  resolveQueryNamespaceWritablePreflight
80
- } from "./chunk-3K64PLY3.js";
80
+ } from "./chunk-HXDXR2FH.js";
81
81
  import {
82
82
  handleWhoKnowsHttpQuery
83
- } from "./chunk-D7UUB33A.js";
83
+ } from "./chunk-FSH6KRKO.js";
84
84
  import {
85
85
  isTrustZoneName
86
86
  } from "./chunk-ROBHL3GL.js";
@@ -95,10 +95,10 @@ import {
95
95
  } from "./chunk-QLK3SL7Q.js";
96
96
  import {
97
97
  validateRequest
98
- } from "./chunk-JUOJGZPV.js";
98
+ } from "./chunk-AYP2FZFA.js";
99
99
  import {
100
100
  peerManifestRevision
101
- } from "./chunk-JDOBQPJY.js";
101
+ } from "./chunk-TNQR7N52.js";
102
102
  import {
103
103
  assertOperationAllowed,
104
104
  capabilityAllowsOp,
@@ -3595,4 +3595,4 @@ export {
3595
3595
  resolveDefaultAdminConsolePublicDir,
3596
3596
  EngramAccessHttpServer
3597
3597
  };
3598
- //# sourceMappingURL=chunk-IOTYIECA.js.map
3598
+ //# sourceMappingURL=chunk-KF57IQFX.js.map
@@ -155,9 +155,15 @@ function citationTemplatesToRecognize(primary, extra = []) {
155
155
  if (!citationTemplateIsDetectable(template)) return;
156
156
  if (!out.includes(template)) out.push(template);
157
157
  };
158
- add(DEFAULT_CITATION_FORMAT);
159
158
  add(primary);
160
159
  for (const template of extra) add(template);
160
+ add(DEFAULT_CITATION_FORMAT);
161
+ out.sort((a, b) => {
162
+ if (b.length !== a.length) return b.length - a.length;
163
+ if (a === primary && b !== primary) return -1;
164
+ if (b === primary && a !== primary) return 1;
165
+ return 0;
166
+ });
161
167
  return out;
162
168
  }
163
169
  function citationTemplatesForMerge(config) {
@@ -255,6 +261,12 @@ function stripCitationForTemplate(text, template) {
255
261
  if (typeof text !== "string" || text.length === 0) return text;
256
262
  const afterDefault = hasCitation(text) ? stripCitation(text) : text;
257
263
  if (!hasCitationForTemplate(afterDefault, template)) return afterDefault;
264
+ PLACEHOLDER_REGEX.lastIndex = 0;
265
+ if (!PLACEHOLDER_REGEX.test(template)) {
266
+ PLACEHOLDER_REGEX.lastIndex = 0;
267
+ return stripExactLiteralCitation(afterDefault, template);
268
+ }
269
+ PLACEHOLDER_REGEX.lastIndex = 0;
258
270
  const matcher = templateMatcher(template);
259
271
  if (!matcher) return afterDefault;
260
272
  const globalMatcher = new RegExp(
@@ -283,6 +295,25 @@ function stripCitationForTemplate(text, template) {
283
295
  }
284
296
  return result.trimEnd();
285
297
  }
298
+ function stripExactLiteralCitation(text, marker) {
299
+ if (marker.length === 0) return text;
300
+ let result = "";
301
+ let lastIndex = 0;
302
+ let idx = text.indexOf(marker);
303
+ if (idx === -1) return text;
304
+ while (idx !== -1) {
305
+ const before = text.slice(lastIndex, idx).replace(/[ \t]+$/, "");
306
+ result += before;
307
+ lastIndex = idx + marker.length;
308
+ idx = text.indexOf(marker, lastIndex);
309
+ }
310
+ const after = text.slice(lastIndex).replace(/^[ \t]+/, "");
311
+ if (after.length > 0) {
312
+ if (result.length > 0) result += " ";
313
+ result += after;
314
+ }
315
+ return result.trimEnd();
316
+ }
286
317
  function enclosingDelimiterRange(text, start, end) {
287
318
  if (start <= 0 || end >= text.length) return void 0;
288
319
  const opener = text[start - 1];
@@ -312,4 +343,4 @@ export {
312
343
  stripCitation,
313
344
  stripCitationForTemplate
314
345
  };
315
- //# sourceMappingURL=chunk-JL4TQYM5.js.map
346
+ //# sourceMappingURL=chunk-L272A5QW.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/source-attribution.ts"],"sourcesContent":["/**\n * Inline Source Attribution Protocol (issue #369)\n *\n * Extracted facts carry provenance inline inside the fact body, so the\n * citation survives hostile memory text, copy/paste, and LLM quoting. This\n * complements — never replaces — the YAML frontmatter provenance stored on\n * disk.\n *\n * Default format (matches issue #369 proposal):\n *\n * The foo service uses Redis for rate limiting. [Source: agent=planner, session=abc123, ts=2026-04-10T14:25:07Z]\n *\n * Key properties:\n * - Inline (part of the body, not metadata).\n * - Compact (typically <80 chars of overhead per fact).\n * - Machine-parseable by a single regex.\n * - Opt-in via `inlineSourceAttributionEnabled` config flag (default off\n * for backwards compatibility with existing downstream consumers).\n * - Legacy facts without a citation remain fully readable.\n *\n * The format template is configurable via `inlineSourceAttributionFormat`\n * with supported placeholders:\n *\n * {agent} — principal / agent identifier\n * {session} — full session key (colon-delimited)\n * {sessionId} — short stable session id (trailing component)\n * {ts} — extraction timestamp (ISO 8601)\n * {date} — extraction date (YYYY-MM-DD)\n *\n * Any privacy-sensitive identifiers should be normalized before being passed\n * to `formatCitation` — the helper treats them as opaque strings.\n */\n\n/** Default citation format template (matches issue #369). */\nexport const DEFAULT_CITATION_FORMAT =\n \"[Source: agent={agent}, session={sessionId}, ts={ts}]\";\n\n/** Sentinel value used when a provenance field is missing. */\nexport const CITATION_UNKNOWN = \"unknown\";\n\nexport interface CitationContext {\n /** Principal / agent identifier (e.g. resolved via resolvePrincipal). */\n agent?: string;\n /** Full session key (e.g. \"agent:planner:main\"). */\n session?: string;\n /**\n * Opaque short session id. Derived from the trailing component of the\n * session key when not provided explicitly. Use this for compact formats\n * that do not need the full colon-delimited session key.\n */\n sessionId?: string;\n /** Extraction timestamp as an ISO 8601 string. */\n ts?: string;\n}\n\nexport interface ParsedCitation {\n /** Agent identifier parsed from the citation (never crashes on malformed input). */\n agent?: string;\n /** Session identifier parsed from the citation. */\n session?: string;\n /** Extraction timestamp parsed from the citation. */\n ts?: string;\n /** The full matched citation substring. */\n raw: string;\n}\n\n/**\n * Regex that matches the default `[Source: agent=X, session=Y, ts=Z]` shape\n * as well as human-edited variants (extra whitespace, reordered fields,\n * subset of fields). Matches non-greedily so it can be anchored anywhere in\n * the text. Kept as a getter factory so callers do not share regex state.\n */\nfunction defaultCitationMatcher(): RegExp {\n // Bounded repetition {1,1024} instead of + so the match cannot backtrack\n // polynomially over hostile memory text (CodeQL js/polynomial-redos). A real\n // citation is far shorter than 1024 chars, so this is behavior-preserving for\n // any genuine [Source: …] block; only pathological/oversized input is excluded.\n return /\\[Source:([^\\]\\n]{1,1024})\\]/gi;\n}\n\n// Linear trailing-whitespace trim. Replaces text.replace(/\\s+$/u, \"\"), whose\n// anchored quantifier backtracks polynomially on long inputs (CodeQL\n// js/polynomial-redos). Matches the exact \\s (with u flag) semantics one char\n// at a time, so the trailing-content preservation logic in attachCitation is\n// unaffected.\nfunction trimTrailingWhitespace(text: string): string {\n let end = text.length;\n while (end > 0 && /\\s/u.test(text[end - 1]!)) end--;\n return text.slice(0, end);\n}\n\n/**\n * Derive a short session id from a full session key.\n * Falls back to the raw session string if no colon is present.\n */\nexport function deriveSessionId(session: string | undefined): string | undefined {\n if (!session) return undefined;\n const trimmed = session.trim();\n if (trimmed.length === 0) return undefined;\n const parts = trimmed.split(\":\").filter((p) => p.length > 0);\n if (parts.length === 0) return trimmed;\n return parts[parts.length - 1];\n}\n\n/**\n * Format an inline citation tag using the provided template.\n *\n * Missing context fields fall back to {@link CITATION_UNKNOWN} — the caller\n * should always get a non-empty, parseable tag.\n *\n * Uses a single-pass substitution so that values which themselves contain\n * placeholder syntax (e.g. an agent literally named `\"{ts}\"`) cannot be\n * re-interpreted by subsequent replacement steps. Each placeholder slot\n * receives exactly one lookup and the substituted value is treated as\n * terminal text, not template source.\n */\nexport function formatCitation(\n ctx: CitationContext,\n template: string = DEFAULT_CITATION_FORMAT,\n): string {\n const session = ctx.session ?? \"\";\n const sessionId = ctx.sessionId ?? deriveSessionId(session) ?? CITATION_UNKNOWN;\n const ts = ctx.ts ?? CITATION_UNKNOWN;\n const agent = ctx.agent && ctx.agent.trim().length > 0 ? ctx.agent : CITATION_UNKNOWN;\n const date = ts && ts !== CITATION_UNKNOWN ? ts.slice(0, 10) : CITATION_UNKNOWN;\n const sessionForTemplate = session.trim().length > 0 ? session : CITATION_UNKNOWN;\n\n // Map from recognised placeholder names to their resolved value. Unknown\n // placeholder names are left intact (returning the original `{name}`).\n const values: Record<string, string> = {\n agent,\n session: sessionForTemplate,\n sessionId,\n ts,\n date,\n };\n\n // Single-pass scan: replace every recognised `{name}` in one sweep so that\n // substituted values cannot themselves be treated as template source on a\n // subsequent pass. The replacer-function form also guarantees that `$` /\n // `$&` / `$1` sequences inside values are emitted literally.\n return template.replace(/\\{([a-zA-Z_][\\w]*)\\}/g, (match, name: string) => {\n return Object.prototype.hasOwnProperty.call(values, name)\n ? values[name]!\n : match;\n });\n}\n\n/**\n * Returns true if the text already carries at least one citation marker.\n * Safe to call on any string — never throws.\n */\nexport function hasCitation(text: string): boolean {\n if (typeof text !== \"string\" || text.length === 0) return false;\n return defaultCitationMatcher().test(text);\n}\n\n/**\n * Escape a string for use as a regex literal.\n */\nfunction escapeRegExp(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/**\n * Escape a single character for use INSIDE a character class `[...]`.\n * Special chars inside character classes: `]`, `\\`, `^`, `-`.\n */\nfunction escapeRegExpCharClass(ch: string): string {\n if (ch === \"]\") return \"\\\\]\";\n if (ch === \"\\\\\") return \"\\\\\\\\\";\n if (ch === \"^\") return \"\\\\^\";\n if (ch === \"-\") return \"\\\\-\";\n // Other regex meta chars are NOT special inside [...] but escaping them is safe.\n return escapeRegExp(ch);\n}\n\n/**\n * Build a per-placeholder token pattern that excludes newlines, whitespace,\n * and any punctuation characters used as inner separators in the template.\n *\n * This prevents a placeholder span from consuming separator bytes and\n * matching strings that cross separator boundaries in user-supplied content.\n *\n * @param nonWordSepChars - Set of non-word (non-alphanumeric, non-`_`) chars\n * extracted from the inner separator literals of the template.\n */\nfunction buildTokenPattern(nonWordSepChars: Set<string>): string {\n // Always exclude newlines and whitespace.\n const base = \"\\\\n\\\\s\";\n if (nonWordSepChars.size === 0) {\n // No inner separator punctuation — the placeholder spans the full space\n // between prefix and suffix. Fall back to a generous no-newline match.\n return `[^\\\\n]+?`;\n }\n const escaped = [...nonWordSepChars].map(escapeRegExpCharClass).join(\"\");\n return `[^${base}${escaped}]+?`;\n}\n\n/** Regex that matches a `{placeholder}` token inside a template string. */\nconst PLACEHOLDER_REGEX = /\\{[a-zA-Z_][\\w]*\\}/g;\n\n/**\n * Build a regex that matches a citation produced by the given template.\n *\n * The approach depends on the shape of the template:\n *\n * - **Normal case (non-empty literal prefix or suffix).** Anchor the match\n * on the outer literal frame and reconstruct the interior as\n * `interToken + sep + interToken + sep + ... + sep + lastToken`.\n * All **intermediate** per-placeholder tokens exclude the combined set of\n * non-word separator characters used between any two adjacent placeholders,\n * preventing a value from consuming a separator and crossing placeholder\n * boundaries. The **last** token is only required to avoid newlines because\n * it is terminated by the literal suffix anchor — this lets placeholder\n * values that legitimately contain a separator character be recognised (e.g.\n * an ISO-8601 timestamp `2026-04-10T14:25:07Z` in `[src:{agent}:{ts}]`\n * where `:` is the inter-placeholder separator). A template like\n * `[src:{agent}/{sessionId}@{date}]` emits\n * `\\[src:[^\\n\\s/@]+?\\/[^\\n\\s/@]+?@[^\\n]+?\\]` so that `[src:foo/bar]`\n * is NOT matched (wrong separator count), `[src:foo/bar/extra@2026]`\n * is NOT matched (intermediate token crosses a `/` boundary), and\n * `[src:planner/main@2026-04-10]` IS matched correctly.\n *\n * - **Placeholder-bounded with whitespace separator.** Both prefix and\n * suffix are empty and the separator literal(s) between placeholders\n * contain at least one whitespace character (e.g. `{source}: {content}`,\n * `{agent} {sessionId}`). A whitespace-containing separator produces\n * output that is visually indistinguishable from ordinary prose, so the\n * safe strategy is to require a **hard bracket/paren/angle delimiter** on\n * both sides of the reconstructed match. Prose almost never places\n * `[...]` / `(...)` / `<...>` around a phrase, so this yields clean\n * false-positive rejection.\n *\n * - **Placeholder-bounded with compact (non-whitespace) separator.** Both\n * prefix and suffix are empty and the separator literal(s) contain NO\n * whitespace (e.g. `{agent}:{sessionId}`, `{agent}/{sessionId}`).\n * `formatCitation` emits a compact token like `planner:main` with no\n * surrounding delimiters, so the bracket strategy cannot detect it.\n * Instead, the pattern requires that the entire token is bordered by\n * whitespace or a bracket/paren/angle on each side:\n *\n * `(?:(?<=[\\[\\(\\<])|(?<!\\S))[\\w.-]+<sep>[\\w.-]+(?:(?=[\\]\\)\\>])|(?!\\S))`\n *\n * This accepts `planner:main` when it appears standalone or inside a\n * bracket-wrapped token, and rejects `host:80` embedded inside a URL like\n * `http://host:80` because `host` is immediately preceded by `/`\n * (non-whitespace, non-bracket).\n *\n * - **All-placeholder case (no literals between placeholders either).** No\n * reliable regex can be built — a template like `{agent}{sessionId}`\n * contains no anchor characters. Returns `null`; {@link\n * hasCitationForTemplate} treats this as \"cannot detect\" and returns\n * false, falling back on explicit sentinel/format detection only for the\n * default `[Source: ...]` shape.\n *\n * Returns `null` when the template has no placeholders (fully-literal\n * citation, handled by the string-equality fast path in {@link\n * hasCitationForTemplate}) **or** when the template is entirely placeholder-\n * only with no literal content whatsoever.\n */\nfunction templateMatcher(template: string): RegExp | null {\n // Split around all {placeholder} tokens.\n const parts = template.split(PLACEHOLDER_REGEX);\n if (parts.length <= 1) return null;\n\n const prefix = parts[0] ?? \"\";\n const suffix = parts[parts.length - 1] ?? \"\";\n\n // Normal case: at least one literal frame on the outside.\n // Tighten the per-placeholder token so it cannot consume separator\n // characters and match strings that cross separator boundaries\n // (Finding 3 — Uru3).\n if (prefix.length > 0 || suffix.length > 0) {\n const escapedPrefix = escapeRegExp(prefix);\n const escapedSuffix = escapeRegExp(suffix);\n\n // Inner parts: literal separators that sit between adjacent placeholders.\n // For `[src:{agent}/{sessionId}@{date}]`, parts = [\"[src:\", \"/\", \"@\", \"]\"]\n // so innerParts = [\"/\", \"@\"].\n const innerParts = parts.slice(1, -1);\n\n // Collect only the non-word (punctuation/symbol) characters from each\n // inner separator so alphabetic separator text (unlikely but valid) does\n // not exclude letters from the per-placeholder token pattern.\n const nonWordSepChars = new Set<string>();\n for (const sep of innerParts) {\n for (const ch of sep) {\n if (!/\\w/.test(ch)) {\n nonWordSepChars.add(ch);\n }\n }\n }\n\n // All intermediate tokens (every placeholder except the last) use the\n // combined exclusion so they cannot cross placeholder boundaries.\n //\n // The LAST token is different: it is terminated by the literal suffix anchor\n // (e.g. `\\]`), so it does not need to exclude inner-separator characters.\n // Dropping that restriction lets placeholder values that legitimately contain\n // a separator character (e.g. an ISO-8601 timestamp `2026-04-10T14:25:07Z`\n // in template `[src:{agent}:{ts}]`) be recognised correctly instead of\n // producing false-negative misses that trigger duplicate citation injection.\n //\n // Only the LAST token is relaxed. Intermediate tokens keep the combined\n // exclusion so that cross-boundary false positives are still rejected\n // (e.g. `[src:foo/bar/extra@2026-04-11]` for `[src:{a}/{b}@{c}]`).\n const interToken = buildTokenPattern(nonWordSepChars);\n // Last token: terminated by suffix anchor — exclude only newlines.\n const lastToken = buildTokenPattern(new Set<string>());\n\n // Reconstruct the interior: interToken sep interToken sep ... sep lastToken\n // (or just lastToken when there are no inner separators at all).\n const middle =\n innerParts.length === 0\n ? lastToken\n : interToken +\n innerParts\n .slice(0, -1)\n .map((sep) => escapeRegExp(sep) + interToken)\n .join(\"\") +\n escapeRegExp(innerParts[innerParts.length - 1]!) +\n lastToken;\n\n const pattern = escapedPrefix + middle + escapedSuffix;\n return new RegExp(pattern, \"i\");\n }\n\n // Placeholder-bounded case: prefix and suffix are both empty.\n const middleLiterals = parts.slice(1, -1);\n const hasNonEmptyMiddle = middleLiterals.some((p) => p.length > 0);\n if (!hasNonEmptyMiddle) {\n // All-placeholder template with no literal content. Impossible to anchor\n // reliably without sentinel markers; signal the caller.\n return null;\n }\n\n // Identifier token: one or more word chars, dots, dashes, or colons.\n // Colons are included to allow timestamp values like \"10:30\" or session\n // keys like \"agent:planner:main\" inside compact placeholder-bounded\n // templates. URL-like fragments (`http://host:80`) are still rejected\n // because the lead anchor requires whitespace or a bracket immediately\n // before the first id-token group (`http` is preceded by `/`).\n const idToken = \"[\\\\w.:-]+\";\n const body =\n idToken +\n middleLiterals.map((lit) => escapeRegExp(lit) + idToken).join(\"\");\n\n const separatorText = middleLiterals.join(\"\");\n if (/\\s/.test(separatorText)) {\n // Separator contains whitespace: the emitted citation looks like ordinary\n // prose (e.g. `planner main`). Require a hard bracket/paren/angle\n // delimiter on both sides to prevent false matches on English text.\n const opener = \"[\\\\[\\\\(\\\\<]\";\n const closer = \"[\\\\]\\\\)\\\\>]\";\n return new RegExp(opener + body + closer, \"i\");\n }\n\n // Separator is compact (no whitespace): `formatCitation` emits a token like\n // `planner:main` without surrounding delimiters. The challenge is that the\n // same token shape also matches ordinary hyphenated or slashed prose words\n // (e.g. `long-term`, `docs/setup`), causing `hasCitationForTemplate` to\n // return true on uncited fact bodies and silently suppress citation injection\n // from `attachCitation`.\n //\n // Fix (Finding 1): tighten the trail anchor so a bare compact token is only\n // accepted when it sits at the very end of the string (possibly followed by\n // optional trailing whitespace or a newline). Since `attachCitation` always\n // appends the citation at the trimmed end of the fact body, a real citation\n // token will always appear at the tail. Prose like `\"long-term solution\"`\n // has `long-term` in the middle of the string (followed by ` solution`), so\n // the end-of-string anchor rejects it — no false positive, no silent drop.\n //\n // The lead anchor still accepts either a bracket opener or a whitespace\n // boundary (or start of string), so `\"Fact. planner:main\"` and standalone\n // `\"planner:main\"` are both detected after the first attachment pass.\n //\n // Bracket-wrapped form (e.g. `[planner:main]`) is also accepted via the\n // opener/closer pair — bracket still takes precedence over end-of-string.\n //\n // Example — why `http://host:80` does NOT match:\n // Trying to match `host:80`: the char before `h` is `/` (non-whitespace,\n // non-bracket), so `(?<=[\\[\\(\\<])` and `(?<!\\S)` both fail ⟹ no match.\n // Trying to match `http:...`: after `http:` the next chars are `//` which\n // are not `[\\w.-]+`, so the second id-token group fails ⟹ no match.\n const leadAnchor = \"(?:(?<=[\\\\[\\\\(\\\\<])|(?<!\\\\S))\";\n // Trail: either a bracket closer (for `[token]` shape) or end-of-string\n // optionally preceded by whitespace. The `(?!\\S)` is deliberately removed\n // so that a compact token in the MIDDLE of a sentence does not match.\n const trailAnchor = \"(?:(?=[\\\\]\\\\)\\\\>])|(?=\\\\s*$))\";\n return new RegExp(leadAnchor + body + trailAnchor, \"i\");\n}\n\n/**\n * Returns true if `text` already carries a citation produced by `template`\n * **or** by the default `[Source: ...]` format (for facts that were tagged\n * before a config change).\n *\n * Use this instead of {@link hasCitation} whenever the caller has access to\n * the configured `inlineSourceAttributionFormat`.\n *\n * All-placeholder templates such as `{agent}{sessionId}` have no literal\n * content to anchor on and therefore cannot be reliably detected without\n * dedicated sentinel markers. In that case the function returns `false` —\n * callers that need idempotent dedup for such templates should either adopt\n * a template with literal delimiters (recommended) or rely on the default\n * `[Source: ...]` marker detection which is always available via\n * {@link hasCitation}.\n */\nexport function hasCitationForTemplate(text: string, template: string): boolean {\n if (typeof text !== \"string\" || text.length === 0) return false;\n // Always accept the default format as a fallback so facts tagged before a\n // configuration change are not double-tagged on reprocessing.\n if (hasCitation(text)) return true;\n // If the configured template matches the default, we're done.\n //\n // Known limitation (Thread 2 — Codex P2): this fast path exits without\n // checking whether the content carries a citation from a DIFFERENT custom\n // template that was active before the config was changed back to the default.\n // Such a fact would be detected by `hasCitation` above only if the prior\n // custom template happened to match the default `[Source: ...]` pattern.\n // In practice, template changes mid-stream are rare, and the false-negative\n // (missing an old custom citation) produces a benign duplicate citation rather\n // than data loss. A full fix would require storing the citation template used\n // at write time in the frontmatter and checking that here.\n if (template === DEFAULT_CITATION_FORMAT) return false;\n\n // Fully-literal template (no placeholders): exact inclusion check.\n if (!PLACEHOLDER_REGEX.test(template)) {\n // Reset lastIndex because PLACEHOLDER_REGEX is declared with /g.\n PLACEHOLDER_REGEX.lastIndex = 0;\n return text.includes(template);\n }\n // Reset lastIndex after the .test() probe above.\n PLACEHOLDER_REGEX.lastIndex = 0;\n\n const matcher = templateMatcher(template);\n if (!matcher) {\n // All-placeholder template: cannot build a reliable matcher. See the\n // docstring — callers should not rely on dedup for this shape.\n return false;\n }\n return matcher.test(text);\n}\n\n/**\n * Return the LAST citation marker in `text` for the given template (or the\n * default `[Source: ...]` shape). `attachCitation` always appends at the\n * trimmed end, so the last occurrence is the most recently attached marker —\n * callers use this to lift a just-attached citation off a cited body and\n * re-attach it to a derived body (the merged-target commit path). Returns\n * null when the text carries no marker of this template (including\n * all-placeholder templates that cannot be matched reliably).\n */\nexport function lastCitationMarkerForTemplate(\n text: string,\n template: string = DEFAULT_CITATION_FORMAT,\n): string | null {\n if (typeof text !== \"string\" || text.length === 0) return null;\n let matcher: RegExp | null;\n if (template === DEFAULT_CITATION_FORMAT) {\n matcher = defaultCitationMatcher();\n } else if (!PLACEHOLDER_REGEX.test(template)) {\n // Fully-literal template: presence is exact inclusion (no placeholders\n // to widen the match).\n PLACEHOLDER_REGEX.lastIndex = 0;\n return text.includes(template) ? template : null;\n } else {\n PLACEHOLDER_REGEX.lastIndex = 0;\n matcher = templateMatcher(template);\n }\n if (!matcher) return null;\n const global = new RegExp(\n matcher.source,\n matcher.flags.includes(\"g\") ? matcher.flags : matcher.flags + \"g\",\n );\n let last: string | null = null;\n for (let match = global.exec(text); match !== null; match = global.exec(text)) {\n last = match[0];\n if (match[0].length === 0) global.lastIndex++;\n }\n return last;\n}\n\n/**\n * True when a template can be matched and stripped later. All-placeholder\n * templates such as `{agent}{sessionId}` have no literal anchors.\n */\nexport function citationTemplateIsDetectable(template: string): boolean {\n if (typeof template !== \"string\" || template.length === 0) return false;\n if (template === DEFAULT_CITATION_FORMAT) return true;\n PLACEHOLDER_REGEX.lastIndex = 0;\n if (!PLACEHOLDER_REGEX.test(template)) {\n PLACEHOLDER_REGEX.lastIndex = 0;\n return true;\n }\n PLACEHOLDER_REGEX.lastIndex = 0;\n return templateMatcher(template) !== null;\n}\n\n/**\n * Templates the merge path may lift, preserve, or strip: the default\n * format, the current format when it is detectable, then any prior\n * configured formats the caller still holds. Undetectable shapes are\n * dropped so we never hash or attach a marker we cannot re-match.\n */\nexport function citationTemplatesToRecognize(\n primary: string | undefined,\n extra: readonly string[] = [],\n): string[] {\n const out: string[] = [];\n const add = (template: string | undefined): void => {\n if (typeof template !== \"string\" || template.length === 0) return;\n if (!citationTemplateIsDetectable(template)) return;\n if (!out.includes(template)) out.push(template);\n };\n add(DEFAULT_CITATION_FORMAT);\n add(primary);\n for (const template of extra) add(template);\n return out;\n}\n\n/**\n * Prior formats the caller still holds, if any. Absent or malformed\n * history is ignored — fail safe, do not invent templates.\n */\nexport function citationTemplatesForMerge(config: {\n inlineSourceAttributionFormat?: string;\n inlineSourceAttributionFormatHistory?: unknown;\n}): string[] {\n const raw = config.inlineSourceAttributionFormatHistory;\n const extra = Array.isArray(raw)\n ? raw.filter((value): value is string => typeof value === \"string\" && value.length > 0)\n : [];\n return citationTemplatesToRecognize(config.inlineSourceAttributionFormat, extra);\n}\n\nexport function lastRecognizedCitationMarker(\n text: string,\n templates: readonly string[],\n): string | null {\n for (const template of templates) {\n const marker = lastCitationMarkerForTemplate(text, template);\n if (marker) return marker;\n }\n return null;\n}\n\nexport function stripRecognizedCitations(text: string, templates: readonly string[]): string {\n let out = text;\n for (const template of templates) {\n out = stripCitationForTemplate(out, template);\n }\n return out;\n}\n\n/**\n * Attach an inline citation to fact text.\n *\n * If the text already has a citation — either the default `[Source: ...]`\n * marker or one produced by the configured template — it is returned unchanged.\n * Existing provenance is respected and never overwritten. Otherwise the\n * citation is appended to the trimmed text with a single space separator,\n * which keeps the marker visually adjacent to the fact body.\n */\nexport function attachCitation(\n text: string,\n ctx: CitationContext,\n template: string = DEFAULT_CITATION_FORMAT,\n): string {\n if (typeof text !== \"string\") return text as unknown as string;\n if (hasCitationForTemplate(text, template)) return text;\n const trimmedEnd = trimTrailingWhitespace(text);\n if (trimmedEnd.length === 0) return text;\n const citation = formatCitation(ctx, template);\n // Preserve any trailing newline that callers rely on for markdown rendering.\n const trailing = text.slice(trimmedEnd.length);\n return `${trimmedEnd} ${citation}${trailing}`;\n}\n\n/**\n * Parse a single inline citation from a piece of text. Returns the first\n * citation encountered or `null` when none is present. Malformed citations\n * do not throw — fields that cannot be parsed simply remain `undefined`.\n */\nexport function parseCitation(text: string): ParsedCitation | null {\n if (typeof text !== \"string\" || text.length === 0) return null;\n const matcher = defaultCitationMatcher();\n const match = matcher.exec(text);\n if (!match) return null;\n\n const body = match[1] ?? \"\";\n const raw = match[0] ?? \"\";\n const parsed: ParsedCitation = { raw };\n\n const fields = body\n .split(\",\")\n .map((segment) => segment.trim())\n .filter((segment) => segment.length > 0);\n\n for (const field of fields) {\n const eqIdx = field.indexOf(\"=\");\n if (eqIdx <= 0) continue;\n const key = field.slice(0, eqIdx).trim().toLowerCase();\n const value = field.slice(eqIdx + 1).trim();\n if (value.length === 0) continue;\n switch (key) {\n case \"agent\":\n parsed.agent = value;\n break;\n case \"session\":\n case \"sessionid\":\n parsed.session = value;\n break;\n case \"ts\":\n case \"timestamp\":\n parsed.ts = value;\n break;\n default:\n // Unknown fields are ignored defensively so human edits never crash.\n break;\n }\n }\n\n return parsed;\n}\n\n/**\n * Parse every citation embedded in the text. Always returns an array; empty\n * when none are present.\n */\nexport function parseAllCitations(text: string): ParsedCitation[] {\n if (typeof text !== \"string\" || text.length === 0) return [];\n const matcher = defaultCitationMatcher();\n const results: ParsedCitation[] = [];\n let match: RegExpExecArray | null;\n while ((match = matcher.exec(text)) !== null) {\n const parsed = parseCitation(match[0]);\n if (parsed) results.push(parsed);\n }\n return results;\n}\n\n/**\n * Remove all inline citations from a piece of text.\n *\n * Callers that want the raw fact body (for dedup hashing, display, or\n * comparison) should use this helper instead of hand-rolled regexes so the\n * whole codebase agrees on the citation syntax.\n *\n * Finding 2 fix: when the input contains no citation marker, the input is\n * returned byte-for-byte unchanged. When a citation IS removed, whitespace\n * normalization is applied only at each join seam (the single space between\n * the preceding text and where the citation was), rather than across the\n * entire string. This preserves markdown hard-break spacing, aligned text,\n * and code-like snippets in fact bodies that happen to carry a citation.\n *\n * Implementation: each citation match is replaced by its \"seam fix\" — the\n * content before the match has its trailing whitespace trimmed and then a\n * single space is appended if any text remains, collapsing only the gap\n * left by the removed marker. Whitespace elsewhere in the body is untouched.\n */\nexport function stripCitation(text: string): string {\n if (typeof text !== \"string\" || text.length === 0) return text;\n // Early exit: no citation marker present — return the input unchanged so\n // that callers never lose formatting fidelity on uncited strings.\n if (!hasCitation(text)) return text;\n\n // Walk through all citations and slice them out one by one so that we can\n // normalise ONLY the whitespace at each seam rather than the entire string.\n const matcher = defaultCitationMatcher();\n let result = \"\";\n let lastIndex = 0;\n\n let match: RegExpExecArray | null;\n while ((match = matcher.exec(text)) !== null) {\n // Text before this citation. Trim trailing spaces/tabs at the seam only.\n const before = text.slice(lastIndex, match.index).replace(/[ \\t]+$/, \"\");\n result += before;\n lastIndex = match.index + match[0].length;\n }\n\n // Append any trailing text after the last citation. Trim leading\n // spaces/tabs and trailing whitespace at the join seam.\n const after = text.slice(lastIndex).replace(/^[ \\t]+/, \"\");\n if (after.length > 0) {\n if (result.length > 0) result += \" \";\n result += after;\n }\n\n return result.trimEnd();\n}\n\n/**\n * Strip an inline citation from text using a specific template regex.\n *\n * This is the template-aware counterpart to {@link stripCitation}. When the\n * caller holds the configured `inlineSourceAttributionFormat`, use this\n * function to strip citations produced by that template — including custom\n * templates that differ from the default `[Source: ...]` pattern.\n *\n * Behaviour:\n * - If the text has a **default-format** citation, strips it first\n * (always safe).\n * - Then, if the result has a **custom-template** citation detected by\n * `hasCitationForTemplate`, builds the template regex and removes every\n * occurrence. BOTH passes run when a body carries both forms — a target\n * written under the default format can carry the default marker plus a\n * custom marker appended after a config change; returning after the\n * default pass alone left the custom marker inside hash inputs (#2330).\n * - All-placeholder templates (no literal prefix/suffix/separator) cannot\n * produce a reliable matcher. `hasCitationForTemplate` already returns\n * `false` for such templates, so this function never attempts to strip an\n * undetectable citation. The text is returned unchanged when no citation\n * is detected.\n * - If no citation is detected for the given template, returns the text\n * unchanged.\n *\n * @returns The stripped text (or the original text when no citation is found).\n */\nexport function stripCitationForTemplate(\n text: string,\n template: string,\n): string {\n if (typeof text !== \"string\" || text.length === 0) return text;\n\n // First pass: the default-format marker, if any. A second pass below still\n // runs — a body can carry the default marker AND the custom template's\n // marker, and canonicalization must remove every recognized form.\n const afterDefault = hasCitation(text) ? stripCitation(text) : text;\n\n if (!hasCitationForTemplate(afterDefault, template)) return afterDefault;\n\n // Build the template matcher. hasCitationForTemplate already returned true,\n // which means templateMatcher produced a non-null result. The null branch\n // here is a defensive fallback only — the default pass already ran.\n const matcher = templateMatcher(template);\n if (!matcher) return afterDefault;\n\n // The matcher regex was built without the global flag; add it for exec loop.\n const globalMatcher = new RegExp(\n matcher.source,\n matcher.flags.includes(\"g\") ? matcher.flags : matcher.flags + \"g\",\n );\n let result = \"\";\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n\n while ((match = globalMatcher.exec(afterDefault)) !== null) {\n const matchEnd = match.index + match[0].length;\n const enclosure = enclosingDelimiterRange(afterDefault, match.index, matchEnd);\n const removalStart = enclosure?.start ?? match.index;\n const removalEnd = enclosure?.end ?? matchEnd;\n const before = afterDefault.slice(lastIndex, removalStart).replace(/[ \\t]+$/, \"\");\n result += before;\n lastIndex = removalEnd;\n // Guard against zero-width matches causing an infinite loop.\n if (match[0].length === 0) {\n globalMatcher.lastIndex++;\n }\n }\n\n const after = afterDefault.slice(lastIndex).replace(/^[ \\t]+/, \"\");\n if (after.length > 0) {\n if (result.length > 0) result += \" \";\n result += after;\n }\n\n return result.trimEnd();\n}\n\nfunction enclosingDelimiterRange(\n text: string,\n start: number,\n end: number,\n): { start: number; end: number } | undefined {\n if (start <= 0 || end >= text.length) return undefined;\n const opener = text[start - 1];\n const closer = text[end];\n if (\n (opener === \"[\" && closer === \"]\") ||\n (opener === \"(\" && closer === \")\") ||\n (opener === \"<\" && closer === \">\")\n ) {\n return { start: start - 1, end: end + 1 };\n }\n return undefined;\n}\n"],"mappings":";AAkCO,IAAM,0BACX;AAGK,IAAM,mBAAmB;AAkChC,SAAS,yBAAiC;AAKxC,SAAO;AACT;AAOA,SAAS,uBAAuB,MAAsB;AACpD,MAAI,MAAM,KAAK;AACf,SAAO,MAAM,KAAK,MAAM,KAAK,KAAK,MAAM,CAAC,CAAE,EAAG;AAC9C,SAAO,KAAK,MAAM,GAAG,GAAG;AAC1B;AAMO,SAAS,gBAAgB,SAAiD;AAC/E,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,UAAU,QAAQ,KAAK;AAC7B,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,QAAM,QAAQ,QAAQ,MAAM,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC;AAC3D,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,SAAO,MAAM,MAAM,SAAS,CAAC;AAC/B;AAcO,SAAS,eACd,KACA,WAAmB,yBACX;AACR,QAAM,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AAQ,cAAc,KAAK,YAAY,OAAO,MAAM;AAC1D,UAAM,WAAW,MAAM,QAAQ,MAAM,CAAC,EAAE;AACxC,UAAM,YAAY,wBAAwB,cAAc,MAAM,OAAO,QAAQ;AAC7E,UAAM,eAAe,WAAW,SAAS,MAAM;AAC/C,UAAM,aAAa,WAAW,OAAO;AACrC,UAAM,SAAS,aAAa,MAAM,WAAW,YAAY,EAAE,QAAQ,WAAW,EAAE;AAChF,cAAU;AACV,gBAAY;AAEZ,QAAI,MAAM,CAAC,EAAE,WAAW,GAAG;AACzB,oBAAc;AAAA,IAChB;AAAA,EACF;AAEA,QAAM,QAAQ,aAAa,MAAM,SAAS,EAAE,QAAQ,WAAW,EAAE;AACjE,MAAI,MAAM,SAAS,GAAG;AACpB,QAAI,OAAO,SAAS,EAAG,WAAU;AACjC,cAAU;AAAA,EACZ;AAEA,SAAO,OAAO,QAAQ;AACxB;AAEA,SAAS,wBACP,MACA,OACA,KAC4C;AAC5C,MAAI,SAAS,KAAK,OAAO,KAAK,OAAQ,QAAO;AAC7C,QAAM,SAAS,KAAK,QAAQ,CAAC;AAC7B,QAAM,SAAS,KAAK,GAAG;AACvB,MACG,WAAW,OAAO,WAAW,OAC7B,WAAW,OAAO,WAAW,OAC7B,WAAW,OAAO,WAAW,KAC9B;AACA,WAAO,EAAE,OAAO,QAAQ,GAAG,KAAK,MAAM,EAAE;AAAA,EAC1C;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/source-attribution.ts"],"sourcesContent":["/**\n * Inline Source Attribution Protocol (issue #369)\n *\n * Extracted facts carry provenance inline inside the fact body, so the\n * citation survives hostile memory text, copy/paste, and LLM quoting. This\n * complements — never replaces — the YAML frontmatter provenance stored on\n * disk.\n *\n * Default format (matches issue #369 proposal):\n *\n * The foo service uses Redis for rate limiting. [Source: agent=planner, session=abc123, ts=2026-04-10T14:25:07Z]\n *\n * Key properties:\n * - Inline (part of the body, not metadata).\n * - Compact (typically <80 chars of overhead per fact).\n * - Machine-parseable by a single regex.\n * - Opt-in via `inlineSourceAttributionEnabled` config flag (default off\n * for backwards compatibility with existing downstream consumers).\n * - Legacy facts without a citation remain fully readable.\n *\n * The format template is configurable via `inlineSourceAttributionFormat`\n * with supported placeholders:\n *\n * {agent} — principal / agent identifier\n * {session} — full session key (colon-delimited)\n * {sessionId} — short stable session id (trailing component)\n * {ts} — extraction timestamp (ISO 8601)\n * {date} — extraction date (YYYY-MM-DD)\n *\n * Any privacy-sensitive identifiers should be normalized before being passed\n * to `formatCitation` — the helper treats them as opaque strings.\n */\n\n/** Default citation format template (matches issue #369). */\nexport const DEFAULT_CITATION_FORMAT =\n \"[Source: agent={agent}, session={sessionId}, ts={ts}]\";\n\n/** Sentinel value used when a provenance field is missing. */\nexport const CITATION_UNKNOWN = \"unknown\";\n\nexport interface CitationContext {\n /** Principal / agent identifier (e.g. resolved via resolvePrincipal). */\n agent?: string;\n /** Full session key (e.g. \"agent:planner:main\"). */\n session?: string;\n /**\n * Opaque short session id. Derived from the trailing component of the\n * session key when not provided explicitly. Use this for compact formats\n * that do not need the full colon-delimited session key.\n */\n sessionId?: string;\n /** Extraction timestamp as an ISO 8601 string. */\n ts?: string;\n}\n\nexport interface ParsedCitation {\n /** Agent identifier parsed from the citation (never crashes on malformed input). */\n agent?: string;\n /** Session identifier parsed from the citation. */\n session?: string;\n /** Extraction timestamp parsed from the citation. */\n ts?: string;\n /** The full matched citation substring. */\n raw: string;\n}\n\n/**\n * Regex that matches the default `[Source: agent=X, session=Y, ts=Z]` shape\n * as well as human-edited variants (extra whitespace, reordered fields,\n * subset of fields). Matches non-greedily so it can be anchored anywhere in\n * the text. Kept as a getter factory so callers do not share regex state.\n */\nfunction defaultCitationMatcher(): RegExp {\n // Bounded repetition {1,1024} instead of + so the match cannot backtrack\n // polynomially over hostile memory text (CodeQL js/polynomial-redos). A real\n // citation is far shorter than 1024 chars, so this is behavior-preserving for\n // any genuine [Source: …] block; only pathological/oversized input is excluded.\n return /\\[Source:([^\\]\\n]{1,1024})\\]/gi;\n}\n\n// Linear trailing-whitespace trim. Replaces text.replace(/\\s+$/u, \"\"), whose\n// anchored quantifier backtracks polynomially on long inputs (CodeQL\n// js/polynomial-redos). Matches the exact \\s (with u flag) semantics one char\n// at a time, so the trailing-content preservation logic in attachCitation is\n// unaffected.\nfunction trimTrailingWhitespace(text: string): string {\n let end = text.length;\n while (end > 0 && /\\s/u.test(text[end - 1]!)) end--;\n return text.slice(0, end);\n}\n\n/**\n * Derive a short session id from a full session key.\n * Falls back to the raw session string if no colon is present.\n */\nexport function deriveSessionId(session: string | undefined): string | undefined {\n if (!session) return undefined;\n const trimmed = session.trim();\n if (trimmed.length === 0) return undefined;\n const parts = trimmed.split(\":\").filter((p) => p.length > 0);\n if (parts.length === 0) return trimmed;\n return parts[parts.length - 1];\n}\n\n/**\n * Format an inline citation tag using the provided template.\n *\n * Missing context fields fall back to {@link CITATION_UNKNOWN} — the caller\n * should always get a non-empty, parseable tag.\n *\n * Uses a single-pass substitution so that values which themselves contain\n * placeholder syntax (e.g. an agent literally named `\"{ts}\"`) cannot be\n * re-interpreted by subsequent replacement steps. Each placeholder slot\n * receives exactly one lookup and the substituted value is treated as\n * terminal text, not template source.\n */\nexport function formatCitation(\n ctx: CitationContext,\n template: string = DEFAULT_CITATION_FORMAT,\n): string {\n const session = ctx.session ?? \"\";\n const sessionId = ctx.sessionId ?? deriveSessionId(session) ?? CITATION_UNKNOWN;\n const ts = ctx.ts ?? CITATION_UNKNOWN;\n const agent = ctx.agent && ctx.agent.trim().length > 0 ? ctx.agent : CITATION_UNKNOWN;\n const date = ts && ts !== CITATION_UNKNOWN ? ts.slice(0, 10) : CITATION_UNKNOWN;\n const sessionForTemplate = session.trim().length > 0 ? session : CITATION_UNKNOWN;\n\n // Map from recognised placeholder names to their resolved value. Unknown\n // placeholder names are left intact (returning the original `{name}`).\n const values: Record<string, string> = {\n agent,\n session: sessionForTemplate,\n sessionId,\n ts,\n date,\n };\n\n // Single-pass scan: replace every recognised `{name}` in one sweep so that\n // substituted values cannot themselves be treated as template source on a\n // subsequent pass. The replacer-function form also guarantees that `$` /\n // `$&` / `$1` sequences inside values are emitted literally.\n return template.replace(/\\{([a-zA-Z_][\\w]*)\\}/g, (match, name: string) => {\n return Object.prototype.hasOwnProperty.call(values, name)\n ? values[name]!\n : match;\n });\n}\n\n/**\n * Returns true if the text already carries at least one citation marker.\n * Safe to call on any string — never throws.\n */\nexport function hasCitation(text: string): boolean {\n if (typeof text !== \"string\" || text.length === 0) return false;\n return defaultCitationMatcher().test(text);\n}\n\n/**\n * Escape a string for use as a regex literal.\n */\nfunction escapeRegExp(s: string): string {\n return s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/**\n * Escape a single character for use INSIDE a character class `[...]`.\n * Special chars inside character classes: `]`, `\\`, `^`, `-`.\n */\nfunction escapeRegExpCharClass(ch: string): string {\n if (ch === \"]\") return \"\\\\]\";\n if (ch === \"\\\\\") return \"\\\\\\\\\";\n if (ch === \"^\") return \"\\\\^\";\n if (ch === \"-\") return \"\\\\-\";\n // Other regex meta chars are NOT special inside [...] but escaping them is safe.\n return escapeRegExp(ch);\n}\n\n/**\n * Build a per-placeholder token pattern that excludes newlines, whitespace,\n * and any punctuation characters used as inner separators in the template.\n *\n * This prevents a placeholder span from consuming separator bytes and\n * matching strings that cross separator boundaries in user-supplied content.\n *\n * @param nonWordSepChars - Set of non-word (non-alphanumeric, non-`_`) chars\n * extracted from the inner separator literals of the template.\n */\nfunction buildTokenPattern(nonWordSepChars: Set<string>): string {\n // Always exclude newlines and whitespace.\n const base = \"\\\\n\\\\s\";\n if (nonWordSepChars.size === 0) {\n // No inner separator punctuation — the placeholder spans the full space\n // between prefix and suffix. Fall back to a generous no-newline match.\n return `[^\\\\n]+?`;\n }\n const escaped = [...nonWordSepChars].map(escapeRegExpCharClass).join(\"\");\n return `[^${base}${escaped}]+?`;\n}\n\n/** Regex that matches a `{placeholder}` token inside a template string. */\nconst PLACEHOLDER_REGEX = /\\{[a-zA-Z_][\\w]*\\}/g;\n\n/**\n * Build a regex that matches a citation produced by the given template.\n *\n * The approach depends on the shape of the template:\n *\n * - **Normal case (non-empty literal prefix or suffix).** Anchor the match\n * on the outer literal frame and reconstruct the interior as\n * `interToken + sep + interToken + sep + ... + sep + lastToken`.\n * All **intermediate** per-placeholder tokens exclude the combined set of\n * non-word separator characters used between any two adjacent placeholders,\n * preventing a value from consuming a separator and crossing placeholder\n * boundaries. The **last** token is only required to avoid newlines because\n * it is terminated by the literal suffix anchor — this lets placeholder\n * values that legitimately contain a separator character be recognised (e.g.\n * an ISO-8601 timestamp `2026-04-10T14:25:07Z` in `[src:{agent}:{ts}]`\n * where `:` is the inter-placeholder separator). A template like\n * `[src:{agent}/{sessionId}@{date}]` emits\n * `\\[src:[^\\n\\s/@]+?\\/[^\\n\\s/@]+?@[^\\n]+?\\]` so that `[src:foo/bar]`\n * is NOT matched (wrong separator count), `[src:foo/bar/extra@2026]`\n * is NOT matched (intermediate token crosses a `/` boundary), and\n * `[src:planner/main@2026-04-10]` IS matched correctly.\n *\n * - **Placeholder-bounded with whitespace separator.** Both prefix and\n * suffix are empty and the separator literal(s) between placeholders\n * contain at least one whitespace character (e.g. `{source}: {content}`,\n * `{agent} {sessionId}`). A whitespace-containing separator produces\n * output that is visually indistinguishable from ordinary prose, so the\n * safe strategy is to require a **hard bracket/paren/angle delimiter** on\n * both sides of the reconstructed match. Prose almost never places\n * `[...]` / `(...)` / `<...>` around a phrase, so this yields clean\n * false-positive rejection.\n *\n * - **Placeholder-bounded with compact (non-whitespace) separator.** Both\n * prefix and suffix are empty and the separator literal(s) contain NO\n * whitespace (e.g. `{agent}:{sessionId}`, `{agent}/{sessionId}`).\n * `formatCitation` emits a compact token like `planner:main` with no\n * surrounding delimiters, so the bracket strategy cannot detect it.\n * Instead, the pattern requires that the entire token is bordered by\n * whitespace or a bracket/paren/angle on each side:\n *\n * `(?:(?<=[\\[\\(\\<])|(?<!\\S))[\\w.-]+<sep>[\\w.-]+(?:(?=[\\]\\)\\>])|(?!\\S))`\n *\n * This accepts `planner:main` when it appears standalone or inside a\n * bracket-wrapped token, and rejects `host:80` embedded inside a URL like\n * `http://host:80` because `host` is immediately preceded by `/`\n * (non-whitespace, non-bracket).\n *\n * - **All-placeholder case (no literals between placeholders either).** No\n * reliable regex can be built — a template like `{agent}{sessionId}`\n * contains no anchor characters. Returns `null`; {@link\n * hasCitationForTemplate} treats this as \"cannot detect\" and returns\n * false, falling back on explicit sentinel/format detection only for the\n * default `[Source: ...]` shape.\n *\n * Returns `null` when the template has no placeholders (fully-literal\n * citation, handled by the string-equality fast path in {@link\n * hasCitationForTemplate}) **or** when the template is entirely placeholder-\n * only with no literal content whatsoever.\n */\nfunction templateMatcher(template: string): RegExp | null {\n // Split around all {placeholder} tokens.\n const parts = template.split(PLACEHOLDER_REGEX);\n if (parts.length <= 1) return null;\n\n const prefix = parts[0] ?? \"\";\n const suffix = parts[parts.length - 1] ?? \"\";\n\n // Normal case: at least one literal frame on the outside.\n // Tighten the per-placeholder token so it cannot consume separator\n // characters and match strings that cross separator boundaries\n // (Finding 3 — Uru3).\n if (prefix.length > 0 || suffix.length > 0) {\n const escapedPrefix = escapeRegExp(prefix);\n const escapedSuffix = escapeRegExp(suffix);\n\n // Inner parts: literal separators that sit between adjacent placeholders.\n // For `[src:{agent}/{sessionId}@{date}]`, parts = [\"[src:\", \"/\", \"@\", \"]\"]\n // so innerParts = [\"/\", \"@\"].\n const innerParts = parts.slice(1, -1);\n\n // Collect only the non-word (punctuation/symbol) characters from each\n // inner separator so alphabetic separator text (unlikely but valid) does\n // not exclude letters from the per-placeholder token pattern.\n const nonWordSepChars = new Set<string>();\n for (const sep of innerParts) {\n for (const ch of sep) {\n if (!/\\w/.test(ch)) {\n nonWordSepChars.add(ch);\n }\n }\n }\n\n // All intermediate tokens (every placeholder except the last) use the\n // combined exclusion so they cannot cross placeholder boundaries.\n //\n // The LAST token is different: it is terminated by the literal suffix anchor\n // (e.g. `\\]`), so it does not need to exclude inner-separator characters.\n // Dropping that restriction lets placeholder values that legitimately contain\n // a separator character (e.g. an ISO-8601 timestamp `2026-04-10T14:25:07Z`\n // in template `[src:{agent}:{ts}]`) be recognised correctly instead of\n // producing false-negative misses that trigger duplicate citation injection.\n //\n // Only the LAST token is relaxed. Intermediate tokens keep the combined\n // exclusion so that cross-boundary false positives are still rejected\n // (e.g. `[src:foo/bar/extra@2026-04-11]` for `[src:{a}/{b}@{c}]`).\n const interToken = buildTokenPattern(nonWordSepChars);\n // Last token: terminated by suffix anchor — exclude only newlines.\n const lastToken = buildTokenPattern(new Set<string>());\n\n // Reconstruct the interior: interToken sep interToken sep ... sep lastToken\n // (or just lastToken when there are no inner separators at all).\n const middle =\n innerParts.length === 0\n ? lastToken\n : interToken +\n innerParts\n .slice(0, -1)\n .map((sep) => escapeRegExp(sep) + interToken)\n .join(\"\") +\n escapeRegExp(innerParts[innerParts.length - 1]!) +\n lastToken;\n\n const pattern = escapedPrefix + middle + escapedSuffix;\n return new RegExp(pattern, \"i\");\n }\n\n // Placeholder-bounded case: prefix and suffix are both empty.\n const middleLiterals = parts.slice(1, -1);\n const hasNonEmptyMiddle = middleLiterals.some((p) => p.length > 0);\n if (!hasNonEmptyMiddle) {\n // All-placeholder template with no literal content. Impossible to anchor\n // reliably without sentinel markers; signal the caller.\n return null;\n }\n\n // Identifier token: one or more word chars, dots, dashes, or colons.\n // Colons are included to allow timestamp values like \"10:30\" or session\n // keys like \"agent:planner:main\" inside compact placeholder-bounded\n // templates. URL-like fragments (`http://host:80`) are still rejected\n // because the lead anchor requires whitespace or a bracket immediately\n // before the first id-token group (`http` is preceded by `/`).\n const idToken = \"[\\\\w.:-]+\";\n const body =\n idToken +\n middleLiterals.map((lit) => escapeRegExp(lit) + idToken).join(\"\");\n\n const separatorText = middleLiterals.join(\"\");\n if (/\\s/.test(separatorText)) {\n // Separator contains whitespace: the emitted citation looks like ordinary\n // prose (e.g. `planner main`). Require a hard bracket/paren/angle\n // delimiter on both sides to prevent false matches on English text.\n const opener = \"[\\\\[\\\\(\\\\<]\";\n const closer = \"[\\\\]\\\\)\\\\>]\";\n return new RegExp(opener + body + closer, \"i\");\n }\n\n // Separator is compact (no whitespace): `formatCitation` emits a token like\n // `planner:main` without surrounding delimiters. The challenge is that the\n // same token shape also matches ordinary hyphenated or slashed prose words\n // (e.g. `long-term`, `docs/setup`), causing `hasCitationForTemplate` to\n // return true on uncited fact bodies and silently suppress citation injection\n // from `attachCitation`.\n //\n // Fix (Finding 1): tighten the trail anchor so a bare compact token is only\n // accepted when it sits at the very end of the string (possibly followed by\n // optional trailing whitespace or a newline). Since `attachCitation` always\n // appends the citation at the trimmed end of the fact body, a real citation\n // token will always appear at the tail. Prose like `\"long-term solution\"`\n // has `long-term` in the middle of the string (followed by ` solution`), so\n // the end-of-string anchor rejects it — no false positive, no silent drop.\n //\n // The lead anchor still accepts either a bracket opener or a whitespace\n // boundary (or start of string), so `\"Fact. planner:main\"` and standalone\n // `\"planner:main\"` are both detected after the first attachment pass.\n //\n // Bracket-wrapped form (e.g. `[planner:main]`) is also accepted via the\n // opener/closer pair — bracket still takes precedence over end-of-string.\n //\n // Example — why `http://host:80` does NOT match:\n // Trying to match `host:80`: the char before `h` is `/` (non-whitespace,\n // non-bracket), so `(?<=[\\[\\(\\<])` and `(?<!\\S)` both fail ⟹ no match.\n // Trying to match `http:...`: after `http:` the next chars are `//` which\n // are not `[\\w.-]+`, so the second id-token group fails ⟹ no match.\n const leadAnchor = \"(?:(?<=[\\\\[\\\\(\\\\<])|(?<!\\\\S))\";\n // Trail: either a bracket closer (for `[token]` shape) or end-of-string\n // optionally preceded by whitespace. The `(?!\\S)` is deliberately removed\n // so that a compact token in the MIDDLE of a sentence does not match.\n const trailAnchor = \"(?:(?=[\\\\]\\\\)\\\\>])|(?=\\\\s*$))\";\n return new RegExp(leadAnchor + body + trailAnchor, \"i\");\n}\n\n/**\n * Returns true if `text` already carries a citation produced by `template`\n * **or** by the default `[Source: ...]` format (for facts that were tagged\n * before a config change).\n *\n * Use this instead of {@link hasCitation} whenever the caller has access to\n * the configured `inlineSourceAttributionFormat`.\n *\n * All-placeholder templates such as `{agent}{sessionId}` have no literal\n * content to anchor on and therefore cannot be reliably detected without\n * dedicated sentinel markers. In that case the function returns `false` —\n * callers that need idempotent dedup for such templates should either adopt\n * a template with literal delimiters (recommended) or rely on the default\n * `[Source: ...]` marker detection which is always available via\n * {@link hasCitation}.\n */\nexport function hasCitationForTemplate(text: string, template: string): boolean {\n if (typeof text !== \"string\" || text.length === 0) return false;\n // Always accept the default format as a fallback so facts tagged before a\n // configuration change are not double-tagged on reprocessing.\n if (hasCitation(text)) return true;\n // If the configured template matches the default, we're done.\n //\n // Known limitation (Thread 2 — Codex P2): this fast path exits without\n // checking whether the content carries a citation from a DIFFERENT custom\n // template that was active before the config was changed back to the default.\n // Such a fact would be detected by `hasCitation` above only if the prior\n // custom template happened to match the default `[Source: ...]` pattern.\n // In practice, template changes mid-stream are rare, and the false-negative\n // (missing an old custom citation) produces a benign duplicate citation rather\n // than data loss. A full fix would require storing the citation template used\n // at write time in the frontmatter and checking that here.\n if (template === DEFAULT_CITATION_FORMAT) return false;\n\n // Fully-literal template (no placeholders): exact inclusion check.\n if (!PLACEHOLDER_REGEX.test(template)) {\n // Reset lastIndex because PLACEHOLDER_REGEX is declared with /g.\n PLACEHOLDER_REGEX.lastIndex = 0;\n return text.includes(template);\n }\n // Reset lastIndex after the .test() probe above.\n PLACEHOLDER_REGEX.lastIndex = 0;\n\n const matcher = templateMatcher(template);\n if (!matcher) {\n // All-placeholder template: cannot build a reliable matcher. See the\n // docstring — callers should not rely on dedup for this shape.\n return false;\n }\n return matcher.test(text);\n}\n\n/**\n * Return the LAST citation marker in `text` for the given template (or the\n * default `[Source: ...]` shape). `attachCitation` always appends at the\n * trimmed end, so the last occurrence is the most recently attached marker —\n * callers use this to lift a just-attached citation off a cited body and\n * re-attach it to a derived body (the merged-target commit path). Returns\n * null when the text carries no marker of this template (including\n * all-placeholder templates that cannot be matched reliably).\n */\nexport function lastCitationMarkerForTemplate(\n text: string,\n template: string = DEFAULT_CITATION_FORMAT,\n): string | null {\n if (typeof text !== \"string\" || text.length === 0) return null;\n let matcher: RegExp | null;\n if (template === DEFAULT_CITATION_FORMAT) {\n matcher = defaultCitationMatcher();\n } else if (!PLACEHOLDER_REGEX.test(template)) {\n // Fully-literal template: presence is exact inclusion (no placeholders\n // to widen the match).\n PLACEHOLDER_REGEX.lastIndex = 0;\n return text.includes(template) ? template : null;\n } else {\n PLACEHOLDER_REGEX.lastIndex = 0;\n matcher = templateMatcher(template);\n }\n if (!matcher) return null;\n const global = new RegExp(\n matcher.source,\n matcher.flags.includes(\"g\") ? matcher.flags : matcher.flags + \"g\",\n );\n let last: string | null = null;\n for (let match = global.exec(text); match !== null; match = global.exec(text)) {\n last = match[0];\n if (match[0].length === 0) global.lastIndex++;\n }\n return last;\n}\n\n/**\n * True when a template can be matched and stripped later. All-placeholder\n * templates such as `{agent}{sessionId}` have no literal anchors.\n */\nexport function citationTemplateIsDetectable(template: string): boolean {\n if (typeof template !== \"string\" || template.length === 0) return false;\n if (template === DEFAULT_CITATION_FORMAT) return true;\n PLACEHOLDER_REGEX.lastIndex = 0;\n if (!PLACEHOLDER_REGEX.test(template)) {\n PLACEHOLDER_REGEX.lastIndex = 0;\n return true;\n }\n PLACEHOLDER_REGEX.lastIndex = 0;\n return templateMatcher(template) !== null;\n}\n\n/**\n * Templates the merge path may lift, preserve, or strip. Longest\n * templates first so an overlapping custom marker beats an inner default\n * match; the current template wins equal-length ties. Undetectable\n * shapes are dropped so we never hash or attach a marker we cannot re-match.\n */\nexport function citationTemplatesToRecognize(\n primary: string | undefined,\n extra: readonly string[] = [],\n): string[] {\n const out: string[] = [];\n const add = (template: string | undefined): void => {\n if (typeof template !== \"string\" || template.length === 0) return;\n if (!citationTemplateIsDetectable(template)) return;\n if (!out.includes(template)) out.push(template);\n };\n add(primary);\n for (const template of extra) add(template);\n add(DEFAULT_CITATION_FORMAT);\n out.sort((a, b) => {\n if (b.length !== a.length) return b.length - a.length;\n if (a === primary && b !== primary) return -1;\n if (b === primary && a !== primary) return 1;\n return 0;\n });\n return out;\n}\n\n/**\n * Prior formats the caller still holds, if any. Absent or malformed\n * history is ignored — fail safe, do not invent templates.\n */\nexport function citationTemplatesForMerge(config: {\n inlineSourceAttributionFormat?: string;\n inlineSourceAttributionFormatHistory?: unknown;\n}): string[] {\n const raw = config.inlineSourceAttributionFormatHistory;\n const extra = Array.isArray(raw)\n ? raw.filter((value): value is string => typeof value === \"string\" && value.length > 0)\n : [];\n return citationTemplatesToRecognize(config.inlineSourceAttributionFormat, extra);\n}\n\nexport function lastRecognizedCitationMarker(\n text: string,\n templates: readonly string[],\n): string | null {\n for (const template of templates) {\n const marker = lastCitationMarkerForTemplate(text, template);\n if (marker) return marker;\n }\n return null;\n}\n\nexport function stripRecognizedCitations(text: string, templates: readonly string[]): string {\n let out = text;\n for (const template of templates) {\n out = stripCitationForTemplate(out, template);\n }\n return out;\n}\n\n/**\n * Attach an inline citation to fact text.\n *\n * If the text already has a citation — either the default `[Source: ...]`\n * marker or one produced by the configured template — it is returned unchanged.\n * Existing provenance is respected and never overwritten. Otherwise the\n * citation is appended to the trimmed text with a single space separator,\n * which keeps the marker visually adjacent to the fact body.\n */\nexport function attachCitation(\n text: string,\n ctx: CitationContext,\n template: string = DEFAULT_CITATION_FORMAT,\n): string {\n if (typeof text !== \"string\") return text as unknown as string;\n if (hasCitationForTemplate(text, template)) return text;\n const trimmedEnd = trimTrailingWhitespace(text);\n if (trimmedEnd.length === 0) return text;\n const citation = formatCitation(ctx, template);\n // Preserve any trailing newline that callers rely on for markdown rendering.\n const trailing = text.slice(trimmedEnd.length);\n return `${trimmedEnd} ${citation}${trailing}`;\n}\n\n/**\n * Parse a single inline citation from a piece of text. Returns the first\n * citation encountered or `null` when none is present. Malformed citations\n * do not throw — fields that cannot be parsed simply remain `undefined`.\n */\nexport function parseCitation(text: string): ParsedCitation | null {\n if (typeof text !== \"string\" || text.length === 0) return null;\n const matcher = defaultCitationMatcher();\n const match = matcher.exec(text);\n if (!match) return null;\n\n const body = match[1] ?? \"\";\n const raw = match[0] ?? \"\";\n const parsed: ParsedCitation = { raw };\n\n const fields = body\n .split(\",\")\n .map((segment) => segment.trim())\n .filter((segment) => segment.length > 0);\n\n for (const field of fields) {\n const eqIdx = field.indexOf(\"=\");\n if (eqIdx <= 0) continue;\n const key = field.slice(0, eqIdx).trim().toLowerCase();\n const value = field.slice(eqIdx + 1).trim();\n if (value.length === 0) continue;\n switch (key) {\n case \"agent\":\n parsed.agent = value;\n break;\n case \"session\":\n case \"sessionid\":\n parsed.session = value;\n break;\n case \"ts\":\n case \"timestamp\":\n parsed.ts = value;\n break;\n default:\n // Unknown fields are ignored defensively so human edits never crash.\n break;\n }\n }\n\n return parsed;\n}\n\n/**\n * Parse every citation embedded in the text. Always returns an array; empty\n * when none are present.\n */\nexport function parseAllCitations(text: string): ParsedCitation[] {\n if (typeof text !== \"string\" || text.length === 0) return [];\n const matcher = defaultCitationMatcher();\n const results: ParsedCitation[] = [];\n let match: RegExpExecArray | null;\n while ((match = matcher.exec(text)) !== null) {\n const parsed = parseCitation(match[0]);\n if (parsed) results.push(parsed);\n }\n return results;\n}\n\n/**\n * Remove all inline citations from a piece of text.\n *\n * Callers that want the raw fact body (for dedup hashing, display, or\n * comparison) should use this helper instead of hand-rolled regexes so the\n * whole codebase agrees on the citation syntax.\n *\n * Finding 2 fix: when the input contains no citation marker, the input is\n * returned byte-for-byte unchanged. When a citation IS removed, whitespace\n * normalization is applied only at each join seam (the single space between\n * the preceding text and where the citation was), rather than across the\n * entire string. This preserves markdown hard-break spacing, aligned text,\n * and code-like snippets in fact bodies that happen to carry a citation.\n *\n * Implementation: each citation match is replaced by its \"seam fix\" — the\n * content before the match has its trailing whitespace trimmed and then a\n * single space is appended if any text remains, collapsing only the gap\n * left by the removed marker. Whitespace elsewhere in the body is untouched.\n */\nexport function stripCitation(text: string): string {\n if (typeof text !== \"string\" || text.length === 0) return text;\n // Early exit: no citation marker present — return the input unchanged so\n // that callers never lose formatting fidelity on uncited strings.\n if (!hasCitation(text)) return text;\n\n // Walk through all citations and slice them out one by one so that we can\n // normalise ONLY the whitespace at each seam rather than the entire string.\n const matcher = defaultCitationMatcher();\n let result = \"\";\n let lastIndex = 0;\n\n let match: RegExpExecArray | null;\n while ((match = matcher.exec(text)) !== null) {\n // Text before this citation. Trim trailing spaces/tabs at the seam only.\n const before = text.slice(lastIndex, match.index).replace(/[ \\t]+$/, \"\");\n result += before;\n lastIndex = match.index + match[0].length;\n }\n\n // Append any trailing text after the last citation. Trim leading\n // spaces/tabs and trailing whitespace at the join seam.\n const after = text.slice(lastIndex).replace(/^[ \\t]+/, \"\");\n if (after.length > 0) {\n if (result.length > 0) result += \" \";\n result += after;\n }\n\n return result.trimEnd();\n}\n\n/**\n * Strip an inline citation from text using a specific template regex.\n *\n * This is the template-aware counterpart to {@link stripCitation}. When the\n * caller holds the configured `inlineSourceAttributionFormat`, use this\n * function to strip citations produced by that template — including custom\n * templates that differ from the default `[Source: ...]` pattern.\n *\n * Behaviour:\n * - If the text has a **default-format** citation, strips it first\n * (always safe).\n * - Then, if the result has a **custom-template** citation detected by\n * `hasCitationForTemplate`, builds the template regex and removes every\n * occurrence. BOTH passes run when a body carries both forms — a target\n * written under the default format can carry the default marker plus a\n * custom marker appended after a config change; returning after the\n * default pass alone left the custom marker inside hash inputs (#2330).\n * - Fully-literal templates (no placeholders) are stripped by exact match\n * of the template text, the same inclusion check `hasCitationForTemplate`\n * uses.\n * - All-placeholder templates (no literal prefix/suffix/separator) cannot\n * produce a reliable matcher. `hasCitationForTemplate` already returns\n * `false` for such templates, so this function never attempts to strip an\n * undetectable citation. The text is returned unchanged when no citation\n * is detected.\n * - If no citation is detected for the given template, returns the text\n * unchanged.\n *\n * @returns The stripped text (or the original text when no citation is found).\n */\nexport function stripCitationForTemplate(\n text: string,\n template: string,\n): string {\n if (typeof text !== \"string\" || text.length === 0) return text;\n\n // First pass: the default-format marker, if any. A second pass below still\n // runs — a body can carry the default marker AND the custom template's\n // marker, and canonicalization must remove every recognized form.\n const afterDefault = hasCitation(text) ? stripCitation(text) : text;\n\n if (!hasCitationForTemplate(afterDefault, template)) return afterDefault;\n\n PLACEHOLDER_REGEX.lastIndex = 0;\n if (!PLACEHOLDER_REGEX.test(template)) {\n PLACEHOLDER_REGEX.lastIndex = 0;\n return stripExactLiteralCitation(afterDefault, template);\n }\n PLACEHOLDER_REGEX.lastIndex = 0;\n\n // Build the template matcher. hasCitationForTemplate already returned true,\n // which means templateMatcher produced a non-null result. The null branch\n // here is a defensive fallback only — the default pass already ran.\n const matcher = templateMatcher(template);\n if (!matcher) return afterDefault;\n\n // The matcher regex was built without the global flag; add it for exec loop.\n const globalMatcher = new RegExp(\n matcher.source,\n matcher.flags.includes(\"g\") ? matcher.flags : matcher.flags + \"g\",\n );\n let result = \"\";\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n\n while ((match = globalMatcher.exec(afterDefault)) !== null) {\n const matchEnd = match.index + match[0].length;\n const enclosure = enclosingDelimiterRange(afterDefault, match.index, matchEnd);\n const removalStart = enclosure?.start ?? match.index;\n const removalEnd = enclosure?.end ?? matchEnd;\n const before = afterDefault.slice(lastIndex, removalStart).replace(/[ \\t]+$/, \"\");\n result += before;\n lastIndex = removalEnd;\n // Guard against zero-width matches causing an infinite loop.\n if (match[0].length === 0) {\n globalMatcher.lastIndex++;\n }\n }\n\n const after = afterDefault.slice(lastIndex).replace(/^[ \\t]+/, \"\");\n if (after.length > 0) {\n if (result.length > 0) result += \" \";\n result += after;\n }\n\n return result.trimEnd();\n}\n\nfunction stripExactLiteralCitation(text: string, marker: string): string {\n if (marker.length === 0) return text;\n let result = \"\";\n let lastIndex = 0;\n let idx = text.indexOf(marker);\n if (idx === -1) return text;\n while (idx !== -1) {\n const before = text.slice(lastIndex, idx).replace(/[ \\t]+$/, \"\");\n result += before;\n lastIndex = idx + marker.length;\n idx = text.indexOf(marker, lastIndex);\n }\n const after = text.slice(lastIndex).replace(/^[ \\t]+/, \"\");\n if (after.length > 0) {\n if (result.length > 0) result += \" \";\n result += after;\n }\n return result.trimEnd();\n}\n\nfunction enclosingDelimiterRange(\n text: string,\n start: number,\n end: number,\n): { start: number; end: number } | undefined {\n if (start <= 0 || end >= text.length) return undefined;\n const opener = text[start - 1];\n const closer = text[end];\n if (\n (opener === \"[\" && closer === \"]\") ||\n (opener === \"(\" && closer === \")\") ||\n (opener === \"<\" && closer === \">\")\n ) {\n return { start: start - 1, end: end + 1 };\n }\n return undefined;\n}\n"],"mappings":";AAkCO,IAAM,0BACX;AAGK,IAAM,mBAAmB;AAkChC,SAAS,yBAAiC;AAKxC,SAAO;AACT;AAOA,SAAS,uBAAuB,MAAsB;AACpD,MAAI,MAAM,KAAK;AACf,SAAO,MAAM,KAAK,MAAM,KAAK,KAAK,MAAM,CAAC,CAAE,EAAG;AAC9C,SAAO,KAAK,MAAM,GAAG,GAAG;AAC1B;AAMO,SAAS,gBAAgB,SAAiD;AAC/E,MAAI,CAAC,QAAS,QAAO;AACrB,QAAM,UAAU,QAAQ,KAAK;AAC7B,MAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,QAAM,QAAQ,QAAQ,MAAM,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC;AAC3D,MAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,SAAO,MAAM,MAAM,SAAS,CAAC;AAC/B;AAcO,SAAS,eACd,KACA,WAAmB,yBACX;AACR,QAAM,UAAU,IAAI,WAAW;AAC/B,QAAM,YAAY,IAAI,aAAa,gBAAgB,OAAO,KAAK;AAC/D,QAAM,KAAK,IAAI,MAAM;AACrB,QAAM,QAAQ,IAAI,SAAS,IAAI,MAAM,KAAK,EAAE,SAAS,IAAI,IAAI,QAAQ;AACrE,QAAM,OAAO,MAAM,OAAO,mBAAmB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O,QAAQ;AACxB;AAEA,SAAS,wBACP,MACA,OACA,KAC4C;AAC5C,MAAI,SAAS,KAAK,OAAO,KAAK,OAAQ,QAAO;AAC7C,QAAM,SAAS,KAAK,QAAQ,CAAC;AAC7B,QAAM,SAAS,KAAK,GAAG;AACvB,MACG,WAAW,OAAO,WAAW,OAC7B,WAAW,OAAO,WAAW,OAC7B,WAAW,OAAO,WAAW,KAC9B;AACA,WAAO,EAAE,OAAO,QAAQ,GAAG,KAAK,MAAM,EAAE;AAAA,EAC1C;AACA,SAAO;AACT;","names":[]}
@@ -0,0 +1,87 @@
1
+ // src/memory-age.ts
2
+ import { stat } from "fs/promises";
3
+ var BULK_TOUCH_MIN_FILES = 2;
4
+ var BULK_TOUCH_STORE_FRACTION = 0.2;
5
+ var RECENCY_HALF_LIFE_DAYS = 7;
6
+ function finiteMs(value) {
7
+ if (typeof value !== "string") return null;
8
+ const ms = Date.parse(value);
9
+ return Number.isFinite(ms) ? ms : null;
10
+ }
11
+ function resolveMemoryAge(subject, mtimeMs, trust) {
12
+ const contentMs = finiteMs(subject.created) ?? finiteMs(subject.updated);
13
+ if (contentMs !== null) return { referenceMs: contentMs, source: "content" };
14
+ if (typeof mtimeMs === "number" && Number.isFinite(mtimeMs) && trust?.isTrusted(mtimeMs) !== false) {
15
+ return { referenceMs: mtimeMs, source: "mtime" };
16
+ }
17
+ return { referenceMs: null, source: "unknown" };
18
+ }
19
+ function utcDayKey(ms) {
20
+ return new Date(ms).toISOString().slice(0, 10);
21
+ }
22
+ function assessMtimeTrust(sampleMtimesMs) {
23
+ const counts = /* @__PURE__ */ new Map();
24
+ for (const ms of sampleMtimesMs) {
25
+ if (!Number.isFinite(ms)) continue;
26
+ const key = utcDayKey(ms);
27
+ counts.set(key, (counts.get(key) ?? 0) + 1);
28
+ }
29
+ const threshold = Math.max(
30
+ BULK_TOUCH_MIN_FILES,
31
+ sampleMtimesMs.length * BULK_TOUCH_STORE_FRACTION
32
+ );
33
+ const bulkTouchDays = /* @__PURE__ */ new Set();
34
+ for (const [day, count] of counts) {
35
+ if (count >= threshold) bulkTouchDays.add(day);
36
+ }
37
+ return {
38
+ bulkTouchDays,
39
+ isTrusted: (mtimeMs) => Number.isFinite(mtimeMs) && !bulkTouchDays.has(utcDayKey(mtimeMs))
40
+ };
41
+ }
42
+ async function collectMtimeFallbackContext(memories) {
43
+ const needsFallback = memories.some(
44
+ (m) => finiteMs(m.created) === null && finiteMs(m.updated) === null
45
+ );
46
+ if (!needsFallback) return null;
47
+ const stats = await Promise.all(
48
+ memories.map(async (m) => {
49
+ try {
50
+ return (await stat(m.path)).mtimeMs;
51
+ } catch {
52
+ return null;
53
+ }
54
+ })
55
+ );
56
+ const mtimeMsByPath = new Map(
57
+ memories.map((m, i) => [m.path, stats[i] ?? null])
58
+ );
59
+ const trust = assessMtimeTrust(
60
+ stats.filter((ms) => ms !== null && Number.isFinite(ms))
61
+ );
62
+ return { mtimeMsByPath, trust };
63
+ }
64
+ function applyRecencyBoost(score, memory, recencyWeight, nowMs, fallback) {
65
+ if (recencyWeight <= 0) return score;
66
+ const resolved = resolveMemoryAge(
67
+ memory.frontmatter,
68
+ fallback?.mtimeMsByPath.get(memory.path) ?? null,
69
+ fallback?.trust
70
+ );
71
+ if (resolved.referenceMs === null) return score;
72
+ const ageDays = Math.max(0, (nowMs - resolved.referenceMs) / 864e5);
73
+ const recencyScore = Math.pow(0.5, ageDays / RECENCY_HALF_LIFE_DAYS);
74
+ return score * (1 - recencyWeight) + recencyScore * recencyWeight;
75
+ }
76
+
77
+ export {
78
+ BULK_TOUCH_MIN_FILES,
79
+ BULK_TOUCH_STORE_FRACTION,
80
+ RECENCY_HALF_LIFE_DAYS,
81
+ resolveMemoryAge,
82
+ utcDayKey,
83
+ assessMtimeTrust,
84
+ collectMtimeFallbackContext,
85
+ applyRecencyBoost
86
+ };
87
+ //# sourceMappingURL=chunk-M4DB6ZNN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/memory-age.ts"],"sourcesContent":["/**\n * Shared memory-age resolution (issue #2976).\n *\n * \"Age is not mtime\" (distill-kura `weave.py` `age_days`): `cp -r`, a\n * restore, a checkout, or a bulk import resets file mtimes, so any freshness\n * mechanism keyed on mtime either switches itself off or boosts everything\n * equally. Remnic therefore resolves a memory's age from dates written\n * INSIDE the memory first:\n *\n * 1. frontmatter `created` — the recall ranking reference before #2976,\n * kept first so every dated memory scores exactly as it did;\n * 2. frontmatter `updated` — the content-revision date;\n * 3. file mtime — only when no content date exists AND the caller's trust\n * assessment accepts it (see `assessMtimeTrust`);\n * 4. otherwise UNKNOWN: no reference instant, and downstream scoring must\n * treat unknown age as never-fresh (no recency boost), never as\n * \"just written\".\n *\n * Bi-temporal `valid_at`/`observedAt` are deliberately NOT in the ladder:\n * they date when the fact was true, not when the memory was written, so a\n * fresh correction about an old event would be misaged by them.\n *\n * Bulk-touch heuristic (distill-kura measured 50/214 files sharing one\n * bulk-touch day, mtime understating true age by a median of 11 days, worst\n * case 425): a UTC calendar day shared by >= max(BULK_TOUCH_MIN_FILES,\n * BULK_TOUCH_STORE_FRACTION of the sampled files) is a bulk-touch day, and\n * mtimes falling on a bulk-touch day are untrusted — those ages are unknown,\n * not fresh. The sample is the scored result set of the calling pipeline\n * (bounded I/O), which observes a bulk-touched store as a same-day cluster.\n */\n\nimport { stat } from \"node:fs/promises\";\n\n/** Minimum files sharing one calendar day before that day is bulk-touched. */\nexport const BULK_TOUCH_MIN_FILES = 2;\n/** Fraction of the sampled files on one day that marks a bulk touch. */\nexport const BULK_TOUCH_STORE_FRACTION = 0.2;\n\n/** Recency half-life (days) used by `applyRecencyBoost`. */\nexport const RECENCY_HALF_LIFE_DAYS = 7;\n\n/** How the resolved age reference was obtained. */\nexport type MemoryAgeSource = \"content\" | \"mtime\" | \"unknown\";\n\nexport interface ResolvedMemoryAge {\n /** Reference instant for age computations, or null when age is unknown. */\n referenceMs: number | null;\n source: MemoryAgeSource;\n}\n\n/** Content dates written inside the memory (frontmatter). */\nexport interface MemoryAgeDates {\n created?: string | null;\n updated?: string | null;\n}\n\n/** Minimal memory shape the resolver needs; `path` keys the mtime fallback. */\nexport interface MemoryAgeSubject extends MemoryAgeDates {\n path: string;\n}\n\n/** MemoryFile slice `applyRecencyBoost` reads; dates live in frontmatter. */\nexport interface RecencyBoostSubject {\n path: string;\n frontmatter: MemoryAgeDates;\n}\n\n/** Result of assessing a sample of mtimes for bulk-touch clustering. */\nexport interface MtimeTrust {\n /** UTC day keys (\"YYYY-MM-DD\") whose mtime counts mark a bulk touch. */\n bulkTouchDays: ReadonlySet<string>;\n isTrusted(mtimeMs: number): boolean;\n}\n\n/** Per-recall mtime fallback context (null when no scored memory needs it). */\nexport interface MtimeFallbackContext {\n mtimeMsByPath: Map<string, number | null>;\n trust: MtimeTrust;\n}\n\nfunction finiteMs(value: string | null | undefined): number | null {\n if (typeof value !== \"string\") return null;\n const ms = Date.parse(value);\n return Number.isFinite(ms) ? ms : null;\n}\n\n/**\n * Resolve the reference instant for a memory's age. Content dates win over\n * mtime; an mtime is consulted only when no content date parses and the\n * trust assessment (when provided) accepts it; otherwise age is unknown.\n */\nexport function resolveMemoryAge(\n subject: MemoryAgeDates,\n mtimeMs?: number | null,\n trust?: MtimeTrust | null,\n): ResolvedMemoryAge {\n const contentMs = finiteMs(subject.created) ?? finiteMs(subject.updated);\n if (contentMs !== null) return { referenceMs: contentMs, source: \"content\" };\n if (\n typeof mtimeMs === \"number\" &&\n Number.isFinite(mtimeMs) &&\n trust?.isTrusted(mtimeMs) !== false\n ) {\n return { referenceMs: mtimeMs, source: \"mtime\" };\n }\n return { referenceMs: null, source: \"unknown\" };\n}\n\n/** UTC calendar-day key (\"YYYY-MM-DD\") for a millisecond instant. */\nexport function utcDayKey(ms: number): string {\n return new Date(ms).toISOString().slice(0, 10);\n}\n\n/**\n * Assess a sample of mtimes: days shared by >= max(BULK_TOUCH_MIN_FILES,\n * BULK_TOUCH_STORE_FRACTION of the sample) are bulk-touch days, and their\n * mtimes are untrusted for age. An empty or scattered sample trusts nothing\n * less than it did before — only clustering changes anything.\n */\nexport function assessMtimeTrust(sampleMtimesMs: readonly number[]): MtimeTrust {\n const counts = new Map<string, number>();\n for (const ms of sampleMtimesMs) {\n if (!Number.isFinite(ms)) continue;\n const key = utcDayKey(ms);\n counts.set(key, (counts.get(key) ?? 0) + 1);\n }\n const threshold = Math.max(\n BULK_TOUCH_MIN_FILES,\n sampleMtimesMs.length * BULK_TOUCH_STORE_FRACTION,\n );\n const bulkTouchDays = new Set<string>();\n for (const [day, count] of counts) {\n if (count >= threshold) bulkTouchDays.add(day);\n }\n return {\n bulkTouchDays,\n isTrusted: (mtimeMs: number) => Number.isFinite(mtimeMs) && !bulkTouchDays.has(utcDayKey(mtimeMs)),\n };\n}\n\n/**\n * Build the mtime fallback context for a recall boost pass. Returns null —\n * with zero stat calls — when every scored memory already has a content\n * date, so the common path pays nothing. Otherwise stats the scored files\n * (bounded by the result count) and assesses their mtimes for bulk-touch\n * clustering. Unreadable files map to null mtimes (unknown age, never fresh).\n */\nexport async function collectMtimeFallbackContext(\n memories: ReadonlyArray<MemoryAgeSubject>,\n): Promise<MtimeFallbackContext | null> {\n const needsFallback = memories.some(\n (m) => finiteMs(m.created) === null && finiteMs(m.updated) === null,\n );\n if (!needsFallback) return null;\n const stats = await Promise.all(\n memories.map(async (m) => {\n try {\n return (await stat(m.path)).mtimeMs;\n } catch {\n return null;\n }\n }),\n );\n const mtimeMsByPath = new Map<string, number | null>(\n memories.map((m, i) => [m.path, stats[i] ?? null]),\n );\n const trust = assessMtimeTrust(\n stats.filter((ms): ms is number => ms !== null && Number.isFinite(ms)),\n );\n return { mtimeMsByPath, trust };\n}\n\n/**\n * Apply the exponential recency blend to one score. Age resolves per\n * `resolveMemoryAge`; unknown age leaves the score untouched (never fresh).\n * A future reference instant clamps to age zero rather than boosting above\n * the recency ceiling (corrupt dates are not super-fresh).\n */\nexport function applyRecencyBoost(\n score: number,\n memory: RecencyBoostSubject,\n recencyWeight: number,\n nowMs: number,\n fallback?: MtimeFallbackContext | null,\n): number {\n if (recencyWeight <= 0) return score;\n const resolved = resolveMemoryAge(\n memory.frontmatter,\n fallback?.mtimeMsByPath.get(memory.path) ?? null,\n fallback?.trust,\n );\n if (resolved.referenceMs === null) return score;\n const ageDays = Math.max(0, (nowMs - resolved.referenceMs) / 86_400_000);\n const recencyScore = Math.pow(0.5, ageDays / RECENCY_HALF_LIFE_DAYS);\n return score * (1 - recencyWeight) + recencyScore * recencyWeight;\n}\n"],"mappings":";AA+BA,SAAS,YAAY;AAGd,IAAM,uBAAuB;AAE7B,IAAM,4BAA4B;AAGlC,IAAM,yBAAyB;AAyCtC,SAAS,SAAS,OAAiD;AACjE,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,KAAK,KAAK,MAAM,KAAK;AAC3B,SAAO,OAAO,SAAS,EAAE,IAAI,KAAK;AACpC;AAOO,SAAS,iBACd,SACA,SACA,OACmB;AACnB,QAAM,YAAY,SAAS,QAAQ,OAAO,KAAK,SAAS,QAAQ,OAAO;AACvE,MAAI,cAAc,KAAM,QAAO,EAAE,aAAa,WAAW,QAAQ,UAAU;AAC3E,MACE,OAAO,YAAY,YACnB,OAAO,SAAS,OAAO,KACvB,OAAO,UAAU,OAAO,MAAM,OAC9B;AACA,WAAO,EAAE,aAAa,SAAS,QAAQ,QAAQ;AAAA,EACjD;AACA,SAAO,EAAE,aAAa,MAAM,QAAQ,UAAU;AAChD;AAGO,SAAS,UAAU,IAAoB;AAC5C,SAAO,IAAI,KAAK,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,EAAE;AAC/C;AAQO,SAAS,iBAAiB,gBAA+C;AAC9E,QAAM,SAAS,oBAAI,IAAoB;AACvC,aAAW,MAAM,gBAAgB;AAC/B,QAAI,CAAC,OAAO,SAAS,EAAE,EAAG;AAC1B,UAAM,MAAM,UAAU,EAAE;AACxB,WAAO,IAAI,MAAM,OAAO,IAAI,GAAG,KAAK,KAAK,CAAC;A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AAI,IAAI,QAAQ,SAAS,eAAe,KAAU;AACvE,QAAM,eAAe,KAAK,IAAI,KAAK,UAAU,sBAAsB;AACnE,SAAO,SAAS,IAAI,iBAAiB,eAAe;AACtD;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SUPPORT_PASSPORT_DRAFT_MAX_CONTENT_CHARACTERS,
3
3
  SUPPORT_PASSPORT_DRAFT_MAX_MEMORIES
4
- } from "./chunk-3K64PLY3.js";
4
+ } from "./chunk-HXDXR2FH.js";
5
5
  import {
6
6
  SUPPORT_PASSPORT_SOURCE_MEMORY_ID_MAX_LENGTH
7
7
  } from "./chunk-PWPIERBM.js";
@@ -343,4 +343,4 @@ export {
343
343
  parseSupportPassportModelJob,
344
344
  SupportPassportModelBridge
345
345
  };
346
- //# sourceMappingURL=chunk-ZVQ5HF77.js.map
346
+ //# sourceMappingURL=chunk-N46SNYMC.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  gatewayTaskChainOptions
3
- } from "./chunk-TRTLWUDD.js";
3
+ } from "./chunk-ZTHGFTMW.js";
4
4
  import {
5
5
  isAbortError,
6
6
  throwIfAborted
@@ -70,4 +70,4 @@ export {
70
70
  DEEP_RECALL_POLICY_SYSTEM_PROMPT,
71
71
  callDeepRecallPolicyLlm
72
72
  };
73
- //# sourceMappingURL=chunk-YR5QT4SR.js.map
73
+ //# sourceMappingURL=chunk-NAFPHFDM.js.map