@remnic/core 9.32.0 → 9.34.0

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 (383) hide show
  1. package/dist/access-admin-ops-surface.d.ts +10 -10
  2. package/dist/access-admin-ops-surface.js +29 -28
  3. package/dist/access-authorization-probe.d.ts +10 -10
  4. package/dist/access-authorization-probe.js +30 -29
  5. package/dist/access-boundary.d.ts +10 -10
  6. package/dist/access-boundary.js +29 -28
  7. package/dist/access-cli.js +71 -68
  8. package/dist/access-cli.js.map +1 -1
  9. package/dist/access-extraction-force-flush.d.ts +10 -10
  10. package/dist/access-extraction-force-flush.js +29 -28
  11. package/dist/access-health-types.d.ts +1 -1
  12. package/dist/access-http-lcm-compaction.d.ts +10 -10
  13. package/dist/access-http-lifecycle-flush.d.ts +10 -10
  14. package/dist/access-http.d.ts +10 -10
  15. package/dist/access-http.js +41 -40
  16. package/dist/access-identity-continuity-surface.d.ts +8 -8
  17. package/dist/access-identity-continuity-surface.js +29 -28
  18. package/dist/access-lcm-surface.d.ts +10 -10
  19. package/dist/access-lcm-surface.js +29 -28
  20. package/dist/access-mcp.d.ts +10 -10
  21. package/dist/access-mcp.js +35 -34
  22. package/dist/access-memory-search-fanout.d.ts +2 -2
  23. package/dist/{access-namespace-preflight-COhbXBqS.d.ts → access-namespace-preflight-CWyL4Zai.d.ts} +1 -1
  24. package/dist/access-namespace-preflight.d.ts +3 -3
  25. package/dist/access-namespace-preflight.js +29 -28
  26. package/dist/access-observe-write-surface.d.ts +10 -10
  27. package/dist/access-observe-write-surface.js +29 -28
  28. package/dist/access-operations-batch.js +32 -31
  29. package/dist/access-operations.d.ts +10 -10
  30. package/dist/access-operations.js +34 -33
  31. package/dist/access-recall-concurrency.d.ts +10 -10
  32. package/dist/access-recall-concurrency.js +29 -28
  33. package/dist/access-recall-response.d.ts +10 -10
  34. package/dist/access-recall-response.js +29 -28
  35. package/dist/access-recall-surface.d.ts +10 -10
  36. package/dist/access-recall-surface.js +29 -28
  37. package/dist/access-schema.js +3 -3
  38. package/dist/{access-service-BmBTtEKO.d.ts → access-service-D9zIBlpp.d.ts} +7 -7
  39. package/dist/access-service-helpers.d.ts +10 -10
  40. package/dist/access-service.d.ts +10 -10
  41. package/dist/access-service.js +29 -28
  42. package/dist/access-surface-catalog.d.ts +10 -10
  43. package/dist/access-wearables-meetings-surface.d.ts +3 -3
  44. package/dist/action-confidence.d.ts +1 -1
  45. package/dist/active-memory-bridge.d.ts +1 -1
  46. package/dist/active-recall.d.ts +1 -1
  47. package/dist/adapters/index.js +7 -7
  48. package/dist/adapters/registry.js +3 -3
  49. package/dist/auto-sync-UPTUVE4X.js +1 -1
  50. package/dist/behavior-learner.d.ts +1 -1
  51. package/dist/behavior-signals.d.ts +1 -1
  52. package/dist/bootstrap.d.ts +8 -8
  53. package/dist/briefing.d.ts +2 -2
  54. package/dist/briefing.js +7 -7
  55. package/dist/buffer-surprise-report.d.ts +1 -1
  56. package/dist/buffer-turn-helpers.d.ts +1 -1
  57. package/dist/buffer.d.ts +2 -2
  58. package/dist/buffer.js +2 -2
  59. package/dist/bulk-import/index.d.ts +3 -3
  60. package/dist/calibration.d.ts +1 -1
  61. package/dist/capabilities.d.ts +1 -1
  62. package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-GWVG7LGC.js} +2 -2
  63. package/dist/{catalog-Dm-DvNBY.d.ts → catalog-Du4bpZWM.d.ts} +1 -1
  64. package/dist/causal-behavior.d.ts +1 -1
  65. package/dist/causal-consolidation.d.ts +1 -1
  66. package/dist/causal-consolidation.js +8 -8
  67. package/dist/causal-trajectory-graph.d.ts +1 -1
  68. package/dist/{chunk-FHBITMRY.js → chunk-4TGZCYHH.js} +15 -15
  69. package/dist/{chunk-KQAFEZQX.js → chunk-5W7CTZ2E.js} +4 -4
  70. package/dist/{chunk-ODGOP7P2.js → chunk-6HXQ2YO5.js} +2 -2
  71. package/dist/{chunk-65ZPVYTA.js → chunk-7CCVK67W.js} +5 -5
  72. package/dist/{chunk-2QIMTVEJ.js → chunk-7TWUCYER.js} +3 -1
  73. package/dist/chunk-7TWUCYER.js.map +1 -0
  74. package/dist/{chunk-UORKJ34C.js → chunk-7ZHGPX56.js} +2 -2
  75. package/dist/{chunk-G2YQ57YO.js → chunk-AEPYA55F.js} +2 -2
  76. package/dist/chunk-B6XHIBIB.js +111 -0
  77. package/dist/chunk-B6XHIBIB.js.map +1 -0
  78. package/dist/{chunk-AJL6NNX6.js → chunk-BIXWNHIL.js} +2 -2
  79. package/dist/{chunk-TGTTESJS.js → chunk-CMQZNEIF.js} +2 -2
  80. package/dist/chunk-CMQZNEIF.js.map +1 -0
  81. package/dist/{chunk-J3ZGPYXB.js → chunk-DG2R7M7K.js} +34 -36
  82. package/dist/chunk-DG2R7M7K.js.map +1 -0
  83. package/dist/{chunk-QDTZ2HF7.js → chunk-DMT2RGAZ.js} +3 -3
  84. package/dist/{chunk-QIHIHZYC.js → chunk-DP7ZV2II.js} +42 -89
  85. package/dist/chunk-DP7ZV2II.js.map +1 -0
  86. package/dist/{chunk-5WZVQRHV.js → chunk-EO7X2LDK.js} +2 -2
  87. package/dist/{chunk-TL4TO3EA.js → chunk-F3BNEYX2.js} +2 -2
  88. package/dist/{chunk-AQEJE3WO.js → chunk-FL3AM5KE.js} +3 -3
  89. package/dist/{chunk-3F2LKUMU.js → chunk-FYO2GAZJ.js} +2 -2
  90. package/dist/{chunk-2Q4JJ3FZ.js → chunk-HULSU7PS.js} +2 -2
  91. package/dist/{chunk-VVDPPDDF.js → chunk-HXDWZFNP.js} +1 -1
  92. package/dist/chunk-HXDWZFNP.js.map +1 -0
  93. package/dist/{chunk-3EQ2XB3W.js → chunk-IZXTZ7BF.js} +5 -5
  94. package/dist/{chunk-THCPRMRF.js → chunk-J6SLNQRO.js} +2 -2
  95. package/dist/{chunk-IGWFKW4B.js → chunk-KEWUNL7P.js} +2 -2
  96. package/dist/{chunk-27HHNYSQ.js → chunk-KJT3PZAR.js} +3 -3
  97. package/dist/chunk-KWMXR7XS.js +138 -0
  98. package/dist/chunk-KWMXR7XS.js.map +1 -0
  99. package/dist/{chunk-OPBTPRGY.js → chunk-KWU6MAD4.js} +2 -2
  100. package/dist/{chunk-227UFSEQ.js → chunk-LEPOP46W.js} +4 -4
  101. package/dist/{chunk-HFQQWAMS.js → chunk-LRYAQGDR.js} +38 -38
  102. package/dist/{chunk-VMZ56EE3.js → chunk-MYXWPG5O.js} +2 -2
  103. package/dist/{chunk-YX5LN6JR.js → chunk-OPRP6Q4Z.js} +3 -3
  104. package/dist/{chunk-2NLLXCJG.js → chunk-OWHERGF2.js} +2 -2
  105. package/dist/{chunk-2NTGBZLZ.js → chunk-OXBPHIKH.js} +8 -8
  106. package/dist/{chunk-QMWFQBIL.js → chunk-QEPNZBBC.js} +3 -3
  107. package/dist/{chunk-CE5355TT.js → chunk-QHYB4MJV.js} +2 -2
  108. package/dist/{chunk-AU7Q3LSC.js → chunk-RKNJBZ55.js} +7 -7
  109. package/dist/{chunk-FMFLGS5Z.js → chunk-RLOVRJZN.js} +8 -8
  110. package/dist/{chunk-CJDNT45S.js → chunk-RQBF54FC.js} +6 -6
  111. package/dist/{chunk-LUQ443JP.js → chunk-RSFWAI4D.js} +68 -48
  112. package/dist/chunk-RSFWAI4D.js.map +1 -0
  113. package/dist/{chunk-YPC7W6GA.js → chunk-RYMPLSIT.js} +3 -2
  114. package/dist/{chunk-YPC7W6GA.js.map → chunk-RYMPLSIT.js.map} +1 -1
  115. package/dist/{chunk-E6BMSH7U.js → chunk-SUZI6BHQ.js} +2 -2
  116. package/dist/chunk-T2TTP3KU.js +28 -0
  117. package/dist/chunk-T2TTP3KU.js.map +1 -0
  118. package/dist/{chunk-35IVNNRK.js → chunk-TCIWHK3N.js} +2 -2
  119. package/dist/{chunk-X7Y7WX73.js → chunk-UVYI6VIX.js} +1 -1
  120. package/dist/{chunk-6P7MTSU5.js → chunk-WFYWGDM6.js} +2 -2
  121. package/dist/{chunk-HKPJPOW7.js → chunk-XABS455Y.js} +2 -2
  122. package/dist/{chunk-U7QYBSQJ.js → chunk-XWDZQIYU.js} +2 -2
  123. package/dist/{chunk-Z7XKUWYS.js → chunk-Y2ZD2RVG.js} +2 -2
  124. package/dist/{chunk-AQWVJURR.js → chunk-Y6OWJ3V5.js} +2 -2
  125. package/dist/{chunk-J7WZUL2K.js → chunk-Y6XRTQMV.js} +8 -8
  126. package/dist/{chunk-MAXVH44E.js → chunk-Z54EM5YZ.js} +7 -7
  127. package/dist/{cli-DRJLv1Xt.d.ts → cli-mFX-QQvx.d.ts} +5 -5
  128. package/dist/cli.d.ts +12 -12
  129. package/dist/cli.js +57 -56
  130. package/dist/compounding/engine.d.ts +2 -2
  131. package/dist/compounding/engine.js +7 -7
  132. package/dist/compounding/preference-consolidator.d.ts +1 -1
  133. package/dist/compression-optimizer.d.ts +1 -1
  134. package/dist/config.d.ts +1 -1
  135. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  136. package/dist/connectors/codex-materialize-runner.js +7 -7
  137. package/dist/connectors/codex-materialize.d.ts +1 -1
  138. package/dist/connectors/index.d.ts +4 -2
  139. package/dist/connectors/index.js +12 -8
  140. package/dist/consolidation-provenance-check.d.ts +2 -2
  141. package/dist/consolidation-undo.d.ts +2 -2
  142. package/dist/contradiction/index.d.ts +2 -2
  143. package/dist/contradiction/index.js +4 -4
  144. package/dist/conversation-index/backend.d.ts +1 -1
  145. package/dist/conversation-index/backend.js +2 -2
  146. package/dist/conversation-index/chunker.d.ts +1 -1
  147. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  148. package/dist/conversation-index/indexer.d.ts +1 -1
  149. package/dist/conversation-index/search.d.ts +1 -1
  150. package/dist/corpus-watermark.d.ts +1 -1
  151. package/dist/corpus-watermark.js +15 -15
  152. package/dist/day-summary.d.ts +1 -1
  153. package/dist/delinearize.d.ts +1 -1
  154. package/dist/direct-answer-wiring.d.ts +1 -1
  155. package/dist/direct-answer.d.ts +1 -1
  156. package/dist/embedding-fallback.d.ts +1 -1
  157. package/dist/enrichment/index.d.ts +1 -1
  158. package/dist/entity-retrieval.d.ts +2 -2
  159. package/dist/entity-retrieval.js +7 -7
  160. package/dist/entity-schema.d.ts +1 -1
  161. package/dist/explicit-capture.d.ts +8 -8
  162. package/dist/explicit-capture.js +3 -3
  163. package/dist/extraction-error-classification.d.ts +1 -1
  164. package/dist/extraction-faithfulness.d.ts +1 -1
  165. package/dist/extraction-judge-telemetry.d.ts +1 -1
  166. package/dist/extraction-judge-training.d.ts +1 -1
  167. package/dist/extraction-judge.d.ts +1 -1
  168. package/dist/extraction-liveness.d.ts +1 -1
  169. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  170. package/dist/extraction-source-grounding.d.ts +1 -1
  171. package/dist/extraction.d.ts +1 -2
  172. package/dist/extraction.js +63 -2
  173. package/dist/fallback-llm.d.ts +1 -1
  174. package/dist/graph-dashboard-diff.d.ts +1 -1
  175. package/dist/graph-dashboard-key.d.ts +1 -1
  176. package/dist/graph-dashboard-parser.d.ts +1 -1
  177. package/dist/graph-edge-reinforcement.d.ts +1 -1
  178. package/dist/graph-snapshot.d.ts +1 -1
  179. package/dist/graph.d.ts +1 -1
  180. package/dist/importance.d.ts +1 -1
  181. package/dist/importers/index.d.ts +1 -1
  182. package/dist/in-flight-reads.d.ts +1 -1
  183. package/dist/index.d.ts +19 -19
  184. package/dist/index.js +115 -112
  185. package/dist/intent.d.ts +1 -1
  186. package/dist/lcm/engine.d.ts +1 -1
  187. package/dist/lcm/engine.js +3 -3
  188. package/dist/lcm/index.d.ts +1 -1
  189. package/dist/lcm/index.js +6 -6
  190. package/dist/lcm/tools.d.ts +1 -1
  191. package/dist/lifecycle.d.ts +1 -1
  192. package/dist/live-connectors-runner.d.ts +1 -1
  193. package/dist/local-llm.d.ts +1 -1
  194. package/dist/local-model-endpoint.d.ts +1 -1
  195. package/dist/maintenance/memory-governance.d.ts +1 -1
  196. package/dist/maintenance/memory-governance.js +7 -7
  197. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
  198. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +7 -7
  199. package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
  200. package/dist/maintenance/rebuild-memory-projection.js +8 -8
  201. package/dist/{maintenance-C6Pffz30.d.ts → maintenance-70Wq118b.d.ts} +3 -3
  202. package/dist/mcp-memory-inspector-app.d.ts +10 -10
  203. package/dist/memory-action-policy.d.ts +1 -1
  204. package/dist/memory-cache.d.ts +1 -1
  205. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  206. package/dist/memory-projection-store.d.ts +1 -1
  207. package/dist/memory-provenance.d.ts +1 -1
  208. package/dist/memory-worth-outcomes.d.ts +2 -2
  209. package/dist/models-json.d.ts +1 -1
  210. package/dist/namespaces/migrate.d.ts +3 -3
  211. package/dist/namespaces/migrate.js +14 -14
  212. package/dist/namespaces/principal.d.ts +1 -1
  213. package/dist/namespaces/search.d.ts +1 -1
  214. package/dist/namespaces/search.js +6 -6
  215. package/dist/namespaces/storage.d.ts +3 -3
  216. package/dist/namespaces/storage.js +7 -7
  217. package/dist/native-knowledge.d.ts +1 -1
  218. package/dist/offline-sync-impression-drain.d.ts +1 -1
  219. package/dist/operator-doctor-corpus.d.ts +1 -1
  220. package/dist/operator-doctor-corpus.js +16 -16
  221. package/dist/operator-doctor-replica.d.ts +1 -1
  222. package/dist/operator-toolkit.d.ts +3 -3
  223. package/dist/operator-toolkit.js +19 -19
  224. package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
  225. package/dist/orchestration/maintenance.d.ts +4 -4
  226. package/dist/orchestration/maintenance.js +12 -12
  227. package/dist/{orchestrator-eQlmasno.d.ts → orchestrator-BH8LT-NX.d.ts} +7 -7
  228. package/dist/orchestrator.d.ts +8 -8
  229. package/dist/orchestrator.js +72 -69
  230. package/dist/patterns-cli.d.ts +1 -1
  231. package/dist/{pipeline-CZGmAMQ2.d.ts → pipeline-DSLWFeHz.d.ts} +1 -1
  232. package/dist/policy-runtime.d.ts +1 -1
  233. package/dist/proactive-contention.d.ts +1 -1
  234. package/dist/provenance.d.ts +1 -1
  235. package/dist/{qmd-DBj4MF8T.d.ts → qmd-BSDGyr0H.d.ts} +1 -1
  236. package/dist/qmd-preflight.d.ts +2 -2
  237. package/dist/qmd-recall-cache.d.ts +1 -1
  238. package/dist/qmd.d.ts +2 -2
  239. package/dist/recall-concurrency-config.d.ts +1 -1
  240. package/dist/recall-disclosure-escalation.d.ts +1 -1
  241. package/dist/recall-explain-renderer.d.ts +1 -1
  242. package/dist/recall-explain-renderer.js +3 -3
  243. package/dist/recall-memory-map.d.ts +1 -1
  244. package/dist/recall-planner-llm.d.ts +1 -1
  245. package/dist/recall-state.d.ts +1 -1
  246. package/dist/recall-tag-filter.d.ts +1 -1
  247. package/dist/recall-timings.d.ts +1 -1
  248. package/dist/recall-xray-cli.d.ts +1 -1
  249. package/dist/recall-xray-cli.js +4 -4
  250. package/dist/recall-xray-renderer.d.ts +1 -1
  251. package/dist/recall-xray-renderer.js +3 -3
  252. package/dist/recall-xray.d.ts +1 -1
  253. package/dist/recall-xray.js +2 -2
  254. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  255. package/dist/replay/normalizers/claude.d.ts +1 -1
  256. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  257. package/dist/replay/normalizers/shared.d.ts +1 -1
  258. package/dist/replay/runner.d.ts +1 -1
  259. package/dist/replay/types.d.ts +1 -1
  260. package/dist/replica-divergence.d.ts +1 -1
  261. package/dist/replica-peers-config.d.ts +1 -1
  262. package/dist/resolve-auth-token.d.ts +1 -1
  263. package/dist/retrieval-agents.d.ts +2 -2
  264. package/dist/retrieval-tiers.d.ts +1 -1
  265. package/dist/routing/engine.d.ts +1 -1
  266. package/dist/routing/store.d.ts +1 -1
  267. package/dist/salvage-envelope.d.ts +1 -1
  268. package/dist/schemas.js +1 -1
  269. package/dist/{scope-profiles-S85lrsUn.d.ts → scope-profiles-C4zY-a2K.d.ts} +1 -1
  270. package/dist/search/embed-helper.d.ts +1 -1
  271. package/dist/search/factory.d.ts +1 -1
  272. package/dist/search/factory.js +5 -5
  273. package/dist/search/index.d.ts +1 -1
  274. package/dist/search/index.js +9 -9
  275. package/dist/search/lancedb-backend.d.ts +1 -1
  276. package/dist/search/meilisearch-backend.d.ts +1 -1
  277. package/dist/search/noop-backend.d.ts +1 -1
  278. package/dist/search/orama-backend.d.ts +1 -1
  279. package/dist/search/port.d.ts +1 -1
  280. package/dist/search/remote-backend.d.ts +1 -1
  281. package/dist/{semantic-consolidation-DVzDcV6x.d.ts → semantic-consolidation-ChKRYpRO.d.ts} +1 -1
  282. package/dist/semantic-consolidation.d.ts +2 -2
  283. package/dist/semantic-consolidation.js +8 -8
  284. package/dist/semantic-rule-promotion.js +7 -7
  285. package/dist/semantic-rule-verifier.d.ts +1 -1
  286. package/dist/semantic-rule-verifier.js +7 -7
  287. package/dist/{service-C2M-wD4W.d.ts → service-CrxXHz5T.d.ts} +2 -2
  288. package/dist/session-observer-bands.d.ts +1 -1
  289. package/dist/session-observer-state.d.ts +1 -1
  290. package/dist/shared-context/manager.d.ts +1 -1
  291. package/dist/signal.d.ts +1 -1
  292. package/dist/source-agent-qualifier.d.ts +24 -0
  293. package/dist/source-agent-qualifier.js +98 -0
  294. package/dist/source-agent-qualifier.js.map +1 -0
  295. package/dist/{storage-dyBC3Q84.d.ts → storage-CyWa1Jm6.d.ts} +1 -1
  296. package/dist/storage.d.ts +2 -2
  297. package/dist/storage.js +6 -6
  298. package/dist/summarizer.d.ts +1 -1
  299. package/dist/summary-snapshot.d.ts +1 -1
  300. package/dist/temporal-supersession.d.ts +2 -2
  301. package/dist/temporal-timeline-recall.d.ts +1 -1
  302. package/dist/temporal-validity.d.ts +1 -1
  303. package/dist/threading.d.ts +1 -1
  304. package/dist/tier-migration.d.ts +2 -2
  305. package/dist/tier-routing.d.ts +1 -1
  306. package/dist/tool-scoped-memory.d.ts +47 -0
  307. package/dist/tool-scoped-memory.js +12 -0
  308. package/dist/tool-scoped-memory.js.map +1 -0
  309. package/dist/topics.d.ts +1 -1
  310. package/dist/transcript.d.ts +1 -1
  311. package/dist/transfer/backup.js +2 -2
  312. package/dist/transfer/capsule-export.js +2 -2
  313. package/dist/transfer/capsule-import.js +2 -2
  314. package/dist/trust-score-stage.d.ts +1 -1
  315. package/dist/trust-score.d.ts +1 -1
  316. package/dist/{types-D63ZI--P.d.ts → types-5398p7Zm.d.ts} +7 -8
  317. package/dist/types.d.ts +1 -1
  318. package/dist/types.js +1 -1
  319. package/dist/utility-runtime.d.ts +1 -1
  320. package/dist/verified-recall.js +7 -7
  321. package/dist/write-envelope.d.ts +1 -1
  322. package/package.json +2 -2
  323. package/src/connector-provenance-lifecycle.test.ts +86 -3
  324. package/src/connectors/index.ts +2 -2
  325. package/src/connectors/label.ts +18 -0
  326. package/src/extraction-redaction-rules.test.ts +53 -0
  327. package/src/extraction-scope-source-agent.test.ts +513 -0
  328. package/src/extraction.ts +45 -98
  329. package/src/index.ts +1 -1
  330. package/src/orchestration/extraction-persist.ts +31 -32
  331. package/src/orchestration/extraction-run.ts +1 -1
  332. package/src/orchestration/recall-result-formatter.ts +2 -1
  333. package/src/schemas.ts +1 -1
  334. package/src/source-agent-qualifier.ts +156 -0
  335. package/src/tool-scoped-memory.test.ts +199 -0
  336. package/src/tool-scoped-memory.ts +190 -0
  337. package/src/types.ts +7 -8
  338. package/dist/chunk-2QIMTVEJ.js.map +0 -1
  339. package/dist/chunk-J3ZGPYXB.js.map +0 -1
  340. package/dist/chunk-LUQ443JP.js.map +0 -1
  341. package/dist/chunk-QIHIHZYC.js.map +0 -1
  342. package/dist/chunk-TGTTESJS.js.map +0 -1
  343. package/dist/chunk-VVDPPDDF.js.map +0 -1
  344. /package/dist/{capsule-crypto-7FJQINUR.js.map → capsule-crypto-GWVG7LGC.js.map} +0 -0
  345. /package/dist/{chunk-FHBITMRY.js.map → chunk-4TGZCYHH.js.map} +0 -0
  346. /package/dist/{chunk-KQAFEZQX.js.map → chunk-5W7CTZ2E.js.map} +0 -0
  347. /package/dist/{chunk-ODGOP7P2.js.map → chunk-6HXQ2YO5.js.map} +0 -0
  348. /package/dist/{chunk-65ZPVYTA.js.map → chunk-7CCVK67W.js.map} +0 -0
  349. /package/dist/{chunk-UORKJ34C.js.map → chunk-7ZHGPX56.js.map} +0 -0
  350. /package/dist/{chunk-G2YQ57YO.js.map → chunk-AEPYA55F.js.map} +0 -0
  351. /package/dist/{chunk-AJL6NNX6.js.map → chunk-BIXWNHIL.js.map} +0 -0
  352. /package/dist/{chunk-QDTZ2HF7.js.map → chunk-DMT2RGAZ.js.map} +0 -0
  353. /package/dist/{chunk-5WZVQRHV.js.map → chunk-EO7X2LDK.js.map} +0 -0
  354. /package/dist/{chunk-TL4TO3EA.js.map → chunk-F3BNEYX2.js.map} +0 -0
  355. /package/dist/{chunk-AQEJE3WO.js.map → chunk-FL3AM5KE.js.map} +0 -0
  356. /package/dist/{chunk-3F2LKUMU.js.map → chunk-FYO2GAZJ.js.map} +0 -0
  357. /package/dist/{chunk-2Q4JJ3FZ.js.map → chunk-HULSU7PS.js.map} +0 -0
  358. /package/dist/{chunk-3EQ2XB3W.js.map → chunk-IZXTZ7BF.js.map} +0 -0
  359. /package/dist/{chunk-THCPRMRF.js.map → chunk-J6SLNQRO.js.map} +0 -0
  360. /package/dist/{chunk-IGWFKW4B.js.map → chunk-KEWUNL7P.js.map} +0 -0
  361. /package/dist/{chunk-27HHNYSQ.js.map → chunk-KJT3PZAR.js.map} +0 -0
  362. /package/dist/{chunk-OPBTPRGY.js.map → chunk-KWU6MAD4.js.map} +0 -0
  363. /package/dist/{chunk-227UFSEQ.js.map → chunk-LEPOP46W.js.map} +0 -0
  364. /package/dist/{chunk-HFQQWAMS.js.map → chunk-LRYAQGDR.js.map} +0 -0
  365. /package/dist/{chunk-VMZ56EE3.js.map → chunk-MYXWPG5O.js.map} +0 -0
  366. /package/dist/{chunk-YX5LN6JR.js.map → chunk-OPRP6Q4Z.js.map} +0 -0
  367. /package/dist/{chunk-2NLLXCJG.js.map → chunk-OWHERGF2.js.map} +0 -0
  368. /package/dist/{chunk-2NTGBZLZ.js.map → chunk-OXBPHIKH.js.map} +0 -0
  369. /package/dist/{chunk-QMWFQBIL.js.map → chunk-QEPNZBBC.js.map} +0 -0
  370. /package/dist/{chunk-CE5355TT.js.map → chunk-QHYB4MJV.js.map} +0 -0
  371. /package/dist/{chunk-AU7Q3LSC.js.map → chunk-RKNJBZ55.js.map} +0 -0
  372. /package/dist/{chunk-FMFLGS5Z.js.map → chunk-RLOVRJZN.js.map} +0 -0
  373. /package/dist/{chunk-CJDNT45S.js.map → chunk-RQBF54FC.js.map} +0 -0
  374. /package/dist/{chunk-E6BMSH7U.js.map → chunk-SUZI6BHQ.js.map} +0 -0
  375. /package/dist/{chunk-35IVNNRK.js.map → chunk-TCIWHK3N.js.map} +0 -0
  376. /package/dist/{chunk-X7Y7WX73.js.map → chunk-UVYI6VIX.js.map} +0 -0
  377. /package/dist/{chunk-6P7MTSU5.js.map → chunk-WFYWGDM6.js.map} +0 -0
  378. /package/dist/{chunk-HKPJPOW7.js.map → chunk-XABS455Y.js.map} +0 -0
  379. /package/dist/{chunk-U7QYBSQJ.js.map → chunk-XWDZQIYU.js.map} +0 -0
  380. /package/dist/{chunk-Z7XKUWYS.js.map → chunk-Y2ZD2RVG.js.map} +0 -0
  381. /package/dist/{chunk-AQWVJURR.js.map → chunk-Y6OWJ3V5.js.map} +0 -0
  382. /package/dist/{chunk-J7WZUL2K.js.map → chunk-Y6XRTQMV.js.map} +0 -0
  383. /package/dist/{chunk-MAXVH44E.js.map → chunk-Z54EM5YZ.js.map} +0 -0
@@ -0,0 +1,199 @@
1
+ import test from "node:test";
2
+ import assert from "node:assert/strict";
3
+
4
+ import {
5
+ referencesAgentSpecificTool,
6
+ shouldPromoteGlobalFactToShared,
7
+ withholdToolScopedFromSharedNamespace,
8
+ } from "./tool-scoped-memory.js";
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // referencesAgentSpecificTool — table-driven, both polarities.
12
+ //
13
+ // Tuning bias (issue #2183): a FALSE POSITIVE is cheap (the fact stays in the
14
+ // narrower namespace — the documented safe default); a FALSE NEGATIVE is the
15
+ // cross-integration tool-collision bug. Detection leans permissive but must not
16
+ // fire on ordinary prose. Keywords and generic names are word-anchored so
17
+ // "tooling"/"commander" and the "search" inside "research" do not match.
18
+ // ---------------------------------------------------------------------------
19
+
20
+ const REF_CASES: Array<{ content: string; expected: boolean; note: string }> = [
21
+ // ---- MUST match --------------------------------------------------------
22
+ { content: "Prefer the search tool and provide a path when locating code.", expected: true, note: "generic name adjacent to 'tool'" },
23
+ { content: "Use the `read` tool before editing a file.", expected: true, note: "backticked token adjacent to 'tool'" },
24
+ { content: "The exec tool requires an absolute cwd.", expected: true, note: "generic name 'exec' adjacent to 'tool'" },
25
+ { content: "Use `search` when locating code.", expected: true, note: "imperative invocation + backticked identifier" },
26
+ { content: "Run `rg` before editing.", expected: true, note: "imperative invocation + backticked identifier" },
27
+ { content: "Use /search with a path.", expected: true, note: "slash-command syntax" },
28
+ // ---- MUST NOT match ----------------------------------------------------
29
+ { content: "User prefers dark mode in all editors", expected: false, note: "portable preference; no tool/command context" },
30
+ { content: "PostgreSQL 15 requires the uuid-ossp extension for gen_random_uuid()", expected: false, note: "portable framework knowledge" },
31
+ { content: "Magento 2.4.8 has a race condition in checkout", expected: false, note: "'condition' is not a keyword; 'checkout' is not generic" },
32
+ { content: "The user reads documentation before starting a task", expected: false, note: "the bare verb 'reads' is not a tool reference" },
33
+ { content: "Search tooling improves developer productivity", expected: false, note: "'tool' must not match the prefix of 'tooling'" },
34
+ { content: "Research tool improves accuracy", expected: false, note: "'search' must not match inside 'research'" },
35
+ ];
36
+
37
+ for (const { content, expected, note } of REF_CASES) {
38
+ test(`referencesAgentSpecificTool: ${expected ? "detects" : "ignores"} "${content.slice(0, 44)}…" (${note})`, () => {
39
+ assert.equal(referencesAgentSpecificTool(content), expected, note);
40
+ });
41
+ }
42
+
43
+ const EXTRA_POSITIVE: string[] = [
44
+ "The `checkout` command switches branches.",
45
+ "The browser tool navigates to the URL first.",
46
+ "Always run the memory tool after a context switch.",
47
+ "the tool named search returns repo hits",
48
+ "Pi exposes a search tool; OpenClaw exposes a same-named web tool.",
49
+ "Invoke `memory_store` to persist the reflection.",
50
+ "Use search when locating implementation",
51
+ "Run rg before editing",
52
+ "Call memory_store to persist the result",
53
+ "Run grep before editing",
54
+ "Use curl to fetch the URL",
55
+ "The memory_store tool persists results",
56
+ "Use the grep command to search files",
57
+ "Call memory_store() to persist the result",
58
+ "Use search() when locating code",
59
+ "Run rg() to find symbols",
60
+ "Use --force when reinstalling",
61
+ "The --format cli flag selects JSON",
62
+ "Run rg --files before editing",
63
+ "Use grep -n TODO when reviewing",
64
+ "Run `rg --files` before editing",
65
+ "The Bash tool executes commands",
66
+ "Use the Edit tool before saving",
67
+ "The WebFetch tool retrieves pages",
68
+ "Run git status before committing",
69
+ "Use npm install to add dependencies",
70
+ "The Bash Tool executes commands",
71
+ "Run git checkout -b feature before editing",
72
+ "Run `git status` before committing",
73
+ "Use `npm install` to add dependencies",
74
+ "Run `git checkout -b feature` before editing",
75
+ "Use edit before saving",
76
+ "Use bashExecution before editing",
77
+ "The bashExecution tool executes commands",
78
+ "Call bashExecution() to persist data",
79
+ "Use /remnic flush before reset",
80
+ "The /remnic command controls memory",
81
+ "Use `/remnic flush` before reset",
82
+ "Use `search --path src` when locating code",
83
+ ];
84
+ for (const content of EXTRA_POSITIVE) {
85
+ test(`referencesAgentSpecificTool detects: "${content.slice(0, 44)}…"`, () => {
86
+ assert.equal(referencesAgentSpecificTool(content), true);
87
+ });
88
+ }
89
+
90
+ const EXTRA_NEGATIVE: string[] = [
91
+ "Git is a useful tool for version control.",
92
+ "The command line is faster than the GUI for this workflow.",
93
+ "She has a good command of the deployment process.",
94
+ "Communication is the main tool of a leader.",
95
+ "PostgreSQL read replicas lag under heavy load.",
96
+ "Memory usage spikes during compaction.",
97
+ "The browser caches static assets aggressively.",
98
+ "Reading long files is slow.",
99
+ "He writes detailed notes after every meeting.",
100
+ "Leadership requires command of the subject matter.",
101
+ "Writers use memory and emotion to craft stories.",
102
+ "I use search engines daily for research.",
103
+ "Use memory wisely and rest often.",
104
+ "Visit https://example.com/search for docs.",
105
+ "The service reads configuration from /etc/remnic/config.json",
106
+ "Logs live under /var/log/remnic",
107
+ "Restore the backup from /tmp/dump.sql",
108
+ "Use /etc/remnic/config.json for configuration",
109
+ "The service should use /health for readiness checks",
110
+ "Use PostgreSQL for durable storage",
111
+ "Use TypeScript in new packages",
112
+ "Run migrations after deployment",
113
+ "Use Redis for caching",
114
+ "Use 'least privilege' when designing authorization",
115
+ 'Run "database migrations" after deployment',
116
+ "Use SQL for analytics",
117
+ "Use API for integration",
118
+ "Use Go for backend services",
119
+ "Use `/etc/remnic/config.json` for configuration",
120
+ "Run `/var/log/remnic` cleanup",
121
+ "Call me before you leave",
122
+ "Use it to simplify the workflow",
123
+ "Run in before deploying",
124
+ "Use 2024-2025 data for the baseline",
125
+ "The tool — a recent addition — is optional",
126
+ "Use `TypeScript` for new packages",
127
+ "Use `config.json` for configuration",
128
+ "Use `/health` for readiness checks",
129
+ "Writers use edit passes",
130
+ "Use macOS for development",
131
+ "Use iOS for mobile apps",
132
+ "Use eBay for purchases",
133
+ "Automation tool reduces repetitive work",
134
+ "Encryption tool selection should follow the threat model",
135
+ "Monitoring tool availability affects reliability",
136
+ "Use user_id in API responses",
137
+ "Use database_name for the connection",
138
+ "Use feature_flag when rolling out changes",
139
+ "Use least-privilege when designing authorization",
140
+ "Use TypeScript-first for new packages",
141
+ ];
142
+ for (const content of EXTRA_NEGATIVE) {
143
+ test(`referencesAgentSpecificTool ignores prose: "${content.slice(0, 44)}…"`, () => {
144
+ assert.equal(referencesAgentSpecificTool(content), false);
145
+ });
146
+ }
147
+
148
+ test("referencesAgentSpecificTool: empty/non-string input is false (no throw)", () => {
149
+ assert.equal(referencesAgentSpecificTool(""), false);
150
+ assert.equal(referencesAgentSpecificTool(" "), false);
151
+ });
152
+
153
+ // ---------------------------------------------------------------------------
154
+ // shouldPromoteGlobalFactToShared — composed scope-routing predicate.
155
+ // ---------------------------------------------------------------------------
156
+
157
+ const PROMOTION_CASES: Array<{ name: string; args: { scope: string | null | undefined; content: string; sourceConnector?: string; procedureSteps?: ReadonlyArray<{ intent?: string; toolCall?: { kind?: string; signature?: string } }> }; expected: boolean }> = [
158
+ { name: "global portable fact, no connector -> promote", args: { scope: "global", content: "User prefers dark mode in all editors" }, expected: true },
159
+ { name: "global tool-scoped fact WITH connector -> withhold (#2183)", args: { scope: "global", content: "Prefer the search tool when locating code.", sourceConnector: "pi" }, expected: false },
160
+ { name: "global tool-scoped fact, no knob -> withheld when connector known", args: { scope: "global", content: "The exec tool requires an absolute cwd.", sourceConnector: "openclaw" }, expected: false },
161
+ { name: "global tool-scoped fact WITHOUT connector -> promote (unattributed)", args: { scope: "global", content: "Prefer the search tool when locating code." }, expected: true },
162
+ { name: "project-scoped fact -> never promote via this path", args: { scope: "project", content: "Prefer the search tool when locating code.", sourceConnector: "pi" }, expected: false },
163
+ { name: "empty connector string is treated as unknown -> promote", args: { scope: "global", content: "Prefer the search tool when locating code.", sourceConnector: "" }, expected: true },
164
+ { name: "global portable-title procedure with tool-bearing steps + connector -> withhold (#2183 P2, scope-routing)", args: { scope: "global", content: "Workflow for locating implementation", sourceConnector: "pi", procedureSteps: [{ intent: "find the symbol", toolCall: { kind: "search", signature: "search('foo')" } }, { intent: "open the file", toolCall: { kind: "read", signature: "read('bar')" } }] }, expected: false },
165
+ ];
166
+ for (const { name, args, expected } of PROMOTION_CASES) {
167
+ test(`shouldPromoteGlobalFactToShared: ${name}`, () => {
168
+ assert.equal(shouldPromoteGlobalFactToShared(args), expected);
169
+ });
170
+ }
171
+
172
+ // ---------------------------------------------------------------------------
173
+ // withholdToolScopedFromSharedNamespace — the SINGLE primitive every shared-
174
+ // namespace promotion path consults. Includes structured procedure tool
175
+ // identity (issue #2183 P2): a portable title + tool-bearing steps withholds.
176
+ // ---------------------------------------------------------------------------
177
+
178
+ const WITHHOLD_CASES: Array<{
179
+ name: string;
180
+ args: { content: string; sourceConnector?: string; procedureSteps?: ReadonlyArray<{ intent?: string; toolCall?: { kind?: string; signature?: string } }> };
181
+ expected: boolean;
182
+ }> = [
183
+ { name: "tool-scoped + connector -> withhold", args: { content: "Prefer the search tool when locating code.", sourceConnector: "pi" }, expected: true },
184
+ { name: "tool-scoped + empty connector -> do not withhold", args: { content: "Prefer the search tool when locating code.", sourceConnector: "" }, expected: false },
185
+ { name: "tool-scoped + whitespace-only connector -> do not withhold", args: { content: "Prefer the search tool when locating code.", sourceConnector: " " }, expected: false },
186
+ { name: "tool-scoped + no connector -> do not withhold", args: { content: "Prefer the search tool when locating code." }, expected: false },
187
+ { name: "portable + connector -> do not withhold", args: { content: "User prefers dark mode in all editors", sourceConnector: "pi" }, expected: false },
188
+ { name: "portable title + connector + tool-bearing steps -> withhold (#2183 P2)", args: { content: "When locating implementation", sourceConnector: "pi", procedureSteps: [{ intent: "find", toolCall: { kind: "search", signature: "search('foo')" } }] }, expected: true },
189
+ { name: "portable title + connector + steps without toolCall -> do not withhold", args: { content: "When locating implementation", sourceConnector: "pi", procedureSteps: [{ intent: "read the docs" }] }, expected: false },
190
+ { name: "portable title + connector + steps with empty kind -> do not withhold", args: { content: "When locating implementation", sourceConnector: "pi", procedureSteps: [{ intent: "x", toolCall: { kind: " ", signature: "y" } }] }, expected: false },
191
+ { name: "tool-bearing steps but NO connector -> do not withhold (unattributed)", args: { content: "When locating implementation", procedureSteps: [{ intent: "find", toolCall: { kind: "search", signature: "search('foo')" } }] }, expected: false },
192
+ { name: "portable title + intent-only tool step + connector -> withhold (#2183 intent text)", args: { content: "Workflow for locating implementation", sourceConnector: "pi", procedureSteps: [{ intent: "Run grep before editing" }] }, expected: true },
193
+ { name: "portable title + all-portable steps + connector -> do not withhold", args: { content: "Workflow for code review", sourceConnector: "pi", procedureSteps: [{ intent: "Read the changes carefully" }, { intent: "Approve the work" }] }, expected: false },
194
+ ];
195
+ for (const { name, args, expected } of WITHHOLD_CASES) {
196
+ test(`withholdToolScopedFromSharedNamespace: ${name}`, () => {
197
+ assert.equal(withholdToolScopedFromSharedNamespace(args), expected);
198
+ });
199
+ }
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Tool-scoped memory guard (issue #2183).
3
+ *
4
+ * A tool-related fact extracted from a specific agent integration carries an
5
+ * UNQUALIFIED tool name — "use the search tool" — with no agent identity
6
+ * attached (the conversation handed to the extraction LLM is rendered as
7
+ * `[role] content` only). Promoting such a fact to the shared namespace lets a
8
+ * DIFFERENT integration that exposes a same-named but incompatible tool (Pi
9
+ * `search` = repo code search vs OpenClaw `search` = web search) consume it.
10
+ *
11
+ * `referencesAgentSpecificTool` flags fact text that references a specific
12
+ * tool/command invocation rather than portable knowledge. The promotion guard
13
+ * in `orchestration/extraction-persist.ts` uses it — when the producing
14
+ * integration is known (`sourceConnector`) — to keep such a fact in that
15
+ * integration's own namespace.
16
+ *
17
+ * Tuning bias: a FALSE POSITIVE is cheap — the fact stays in the narrower
18
+ * namespace, the documented safe default. A FALSE NEGATIVE is the actual
19
+ * cross-integration collision bug, so detection leans permissive — but it must
20
+ * not fire on ordinary prose.
21
+ */
22
+
23
+ const BT = "`";
24
+
25
+ // Generic tool names + host-tool names emitted by the agent adapters.
26
+ // Evidence: "edit" — Pi messages.test.ts:43 ({ type: "toolCall", name: "edit" }).
27
+ // "bash" — Pi messages.test.ts:70 (bashExecution tool rendering). "glob",
28
+ // "webfetch", "task" — standard Claude Code tools (Pi wraps Claude Code).
29
+ const GENERIC_TOOL_NAMES = [
30
+ "read", "write", "search", "fetch", "browser", "exec", "shell", "memory",
31
+ "edit", "bash", "glob", "webfetch", "task",
32
+ "remnic",
33
+ ];
34
+ const KNOWN_CLI_NAMES = [
35
+ "grep", "curl", "git", "npm", "pnpm", "sed", "awk", "jq", "cat", "ssh",
36
+ "docker", "kubectl", "make", "rg", "ls", "cd",
37
+ ];
38
+ const GENERIC_NAMES_ALT = GENERIC_TOOL_NAMES.join("|");
39
+ const KNOWN_NAMES_ALT = [...GENERIC_TOOL_NAMES, ...KNOWN_CLI_NAMES].join("|");
40
+ const CLI_NAMES_ALT = KNOWN_CLI_NAMES.join("|");
41
+
42
+ const FS_ROOTS = "(?:etc|var|usr|tmp|home|opt|srv|proc|dev)";
43
+ const FLAG = "(?:--|-)[A-Za-z][A-Za-z0-9]*(?:-[A-Za-z0-9]+)*\\b";
44
+ const FLAG_NAKED = "(?:--|-)[A-Za-z][A-Za-z0-9]*(?:-[A-Za-z0-9]+)*";
45
+ const OPCODE = "[A-Za-z0-9_./-]{1,20}";
46
+
47
+ const NO_SLASH_TOKEN = "[A-Za-z0-9_.-]{1,60}";
48
+ const SLASH_CMD_TOKEN = "/(?:" + GENERIC_NAMES_ALT + ")\\b";
49
+ const QUOTED_CONTENT = "(?:" + NO_SLASH_TOKEN + "|" + SLASH_CMD_TOKEN + ")";
50
+ const QUOTED_PERMISSIVE =
51
+ "(?:" + BT + QUOTED_CONTENT + BT + "|\"" + QUOTED_CONTENT + "\"|'" + QUOTED_CONTENT + "')";
52
+
53
+ const SNAKE = "(?:[a-z][a-z0-9]*(?:_[a-z0-9]+)+)\\b";
54
+ const SNAKE_NON_DATA = "(?:[a-z][a-z0-9]*(?:_[a-z0-9]+)*(?:_(?!id\\b|name\\b|flag\\b|count\\b|at\\b|url\\b|key\\b|type\\b)[a-z0-9]+))\\b";
55
+ const SNAKE_KEBAB = "(?:[a-z][a-z0-9]*(?:[_-][a-z0-9]+)+)\\b";
56
+
57
+ const KNOWN_NAMES_CI = "\\b(?:" + KNOWN_NAMES_ALT + ")\\b";
58
+ const CLI_NAMES_CI = "\\b(?:" + CLI_NAMES_ALT + ")\\b";
59
+ const KEYWORD = "\\b(?:mcp[ _]tool|slash[ _]command|cli[ _]flag|subcommand|tool|command)\\b";
60
+
61
+ const IDENT = "(?:" + QUOTED_PERMISSIVE + "|" + KNOWN_NAMES_CI + "|" + SNAKE_KEBAB + "|" + FLAG + ")";
62
+
63
+ const IMM = "[\\s'\"" + BT + "]{1,4}";
64
+ const CONN = "\\s+(?:named|called|aka)\\s+";
65
+ const VERB = "\\b(?:use|run|call|invoke)\\b";
66
+ const SLASH_GENERIC = "/(?:" + GENERIC_NAMES_ALT + ")\\b";
67
+ const CLAUSE_BOUNDARY = "(?:$|[.,;(:]|(?:when|before|after|to|with|for|on|in|if|unless|whenever)\\b)";
68
+ const ARGS = "(?:\\s+" + FLAG + "(?:\\s+" + OPCODE + "){0,4})?";
69
+ const CLI_ARG_TOKEN = "(?:[a-z][a-z0-9-]{0,15}|" + FLAG_NAKED + "|" + OPCODE + ")";
70
+ const CLI_ARG_RUN = "(?:\\s+" + CLI_ARG_TOKEN + "){1,4}";
71
+
72
+ // Shared: a CLI tool or slash command optionally followed by a bounded
73
+ // argument run. Used by BOTH the quoted and unquoted invocation arms so
74
+ // quoting cannot diverge from unquoted again (#2183 round 20).
75
+ const CMD_WITH_ARGS = "(?:(?:" + CLI_NAMES_CI + "|" + SLASH_GENERIC + ")" + CLI_ARG_RUN + ")";
76
+ const QSTRICT_CONTENT =
77
+ "(?:" + KNOWN_NAMES_ALT + "|[a-z][a-z0-9]*(?:[_-][a-z0-9]+)+" + "|" + FLAG_NAKED + "|" + SLASH_CMD_TOKEN +
78
+ "|" + CMD_WITH_ARGS + "|(?:" + KNOWN_NAMES_ALT + ")" + CLI_ARG_RUN + ")";
79
+ const QUOTED_STRICT =
80
+ "(?:" + BT + QSTRICT_CONTENT + BT + "|\"" + QSTRICT_CONTENT + "\"|'" + QSTRICT_CONTENT + "')";
81
+
82
+ const INVOCATION_FLAG_ARGS =
83
+ VERB + "\\s+(?:" + QUOTED_STRICT + "|" + KNOWN_NAMES_CI + "|" + SNAKE_NON_DATA + "|" + SLASH_GENERIC + "|" + FLAG + ")" + ARGS + "(?=\\s*" + CLAUSE_BOUNDARY + ")";
84
+ const INVOCATION_CLI_ARGS =
85
+ VERB + "\\s+" + CMD_WITH_ARGS + "(?=\\s*" + CLAUSE_BOUNDARY + ")";
86
+ const INVOCATION = "(?:" + INVOCATION_FLAG_ARGS + "|" + INVOCATION_CLI_ARGS + ")";
87
+
88
+ const TOOL_REFERENCE_CI = new RegExp(
89
+ "(?:" +
90
+ IDENT + IMM + KEYWORD + "|" + KEYWORD + IMM + IDENT + "|" +
91
+ KEYWORD + CONN + IDENT + "|" + IDENT + CONN + KEYWORD + "|" +
92
+ INVOCATION +
93
+ ")",
94
+ "i",
95
+ );
96
+
97
+ function hasCapitalisedToolName(content: string): boolean {
98
+ // Structural discriminator: a capitalised identifier beside a tool/command
99
+ // keyword qualifies ONLY when preceded by an article or invocation verb (not
100
+ // sentence-initial), or connected via named/called/aka. This replaces the
101
+ // blocklist approach — a structural rule beats a growing STOP_WORDS set.
102
+ for (const re of [
103
+ /(?:the|a|an|this|that|these|those|use|run|call|invoke)\s+([A-Za-z][A-Za-z0-9]+)\b[\s'`<>]{0,4}\b(?:tool|command|subcommand)\b/gi,
104
+ /\b(?:tool|command|subcommand)\b\s+(?:named|called|aka)\s+([A-Za-z][A-Za-z0-9]+)\b/gi,
105
+ ]) {
106
+ re.lastIndex = 0;
107
+ let match;
108
+ while ((match = re.exec(content)) !== null) {
109
+ const w = match[1];
110
+ if (w && w[0] >= "A" && w[0] <= "Z") return true;
111
+ }
112
+ }
113
+ return false;
114
+ }
115
+
116
+ function hasCamelCaseToolName(content: string): boolean {
117
+ // Case-sensitive: camelCase (lowercase start, interior uppercase) is a common
118
+ // host-tool naming convention (bashExecution, memoryStore, webFetch). Ordinary
119
+ // English words are never camelCase, and PascalCase (PostgreSQL, TypeScript)
120
+ // starts uppercase so is handled by hasCapitalisedToolName instead.
121
+ const camelRe = /\b([a-z]{3,}[a-z0-9]*[A-Z][a-z][A-Za-z0-9]*)\b/g;
122
+ let m;
123
+ while ((m = camelRe.exec(content)) !== null) {
124
+ const token = m[1];
125
+ const start = m.index!;
126
+ const end = start + token.length;
127
+ const before = content.slice(Math.max(0, start - 20), start);
128
+ const after = content.slice(end);
129
+ // Invocation: preceded by a verb, followed by a clause boundary or call syntax.
130
+ if (/(?:^|\s)(?:use|run|call|invoke)\s*$/i.test(before) &&
131
+ /^(?:\s*(?:$|[.,;(:]|(?:when|before|after|to|with|for|on|in|if|unless|whenever)\b))/i.test(after)) {
132
+ return true;
133
+ }
134
+ // Keyword-adjacent: camelCase beside a tool/command keyword.
135
+ if (/^(?:\s*(?:tool|command|subcommand)\b)/i.test(after) ||
136
+ /(?:tool|command|subcommand)\s*$/i.test(before)) {
137
+ return true;
138
+ }
139
+ }
140
+ return false;
141
+ }
142
+
143
+ export function referencesAgentSpecificTool(content: string): boolean {
144
+ if (typeof content !== "string" || content.length === 0) return false;
145
+ return TOOL_REFERENCE_CI.test(content) || hasCapitalisedToolName(content) || hasCamelCaseToolName(content);
146
+ }
147
+
148
+ export interface ToolScopeWithholdInputs {
149
+ content: string;
150
+ sourceConnector?: string;
151
+ procedureSteps?: ReadonlyArray<{ intent?: string; expectedOutcome?: string; toolCall?: { kind?: string } }>;
152
+ }
153
+
154
+ export function withholdToolScopedFromSharedNamespace({
155
+ content,
156
+ sourceConnector,
157
+ procedureSteps,
158
+ }: ToolScopeWithholdInputs): boolean {
159
+ if (typeof sourceConnector !== "string" || sourceConnector.trim().length === 0) return false;
160
+ if (referencesAgentSpecificTool(content)) return true;
161
+ if (
162
+ procedureSteps?.some((s) => {
163
+ const kind = s.toolCall?.kind;
164
+ if (typeof kind === "string" && kind.trim().length > 0) return true;
165
+ const stepText = [s.intent, s.expectedOutcome]
166
+ .filter((t): t is string => typeof t === "string" && t.length > 0)
167
+ .join(" ");
168
+ return stepText.length > 0 && referencesAgentSpecificTool(stepText);
169
+ })
170
+ ) {
171
+ return true;
172
+ }
173
+ return false;
174
+ }
175
+
176
+ export interface GlobalFactPromotionInputs {
177
+ scope: string | null | undefined;
178
+ content: string;
179
+ sourceConnector?: string;
180
+ procedureSteps?: ReadonlyArray<{ toolCall?: { kind?: string } }>;
181
+ }
182
+
183
+ export function shouldPromoteGlobalFactToShared(inputs: GlobalFactPromotionInputs): boolean {
184
+ if (inputs.scope !== "global") return false;
185
+ return !withholdToolScopedFromSharedNamespace({
186
+ content: inputs.content,
187
+ sourceConnector: inputs.sourceConnector,
188
+ procedureSteps: inputs.procedureSteps,
189
+ });
190
+ }
package/src/types.ts CHANGED
@@ -23,15 +23,12 @@ export type ExtractionPassSource = "base" | "proactive";
23
23
  /**
24
24
  * Scope classification for extracted facts (issue #XXX).
25
25
  *
26
- * - `"project"` — knowledge specific to one codebase: file paths, environment
27
- * configs, deployment details, project-specific workarounds, team/stakeholder
28
- * info tied to one project.
29
- * - `"global"` knowledge that applies across projects: core framework bugs,
30
- * library behavior, API patterns, user preferences, tool configurations,
31
- * general coding patterns, infrastructure knowledge.
26
+ * - `"project"` — one codebase (paths, env configs, deployment, stakeholders);
27
+ * also tool/command or CLI-flag instructions tied to one agent.
28
+ * - `"global"` across projects: framework bugs, library/API behavior,
29
+ * user preferences, coding patterns, infrastructure.
32
30
  *
33
- * Default is `"project"` when a coding context is active, `"global"` when no
34
- * coding context is present.
31
+ * Default is `"project"` with a coding context active, else `"global"`.
35
32
  */
36
33
  export type MemoryScope = "project" | "global";
37
34
  export type SlotMismatchMode = "error" | "warn" | "silent";
@@ -3333,6 +3330,8 @@ export interface ExtractionResult {
3333
3330
  extractionFailure?: string;
3334
3331
  /** Coarse class used by the retry/backoff + circuit-breaker layer (extraction hot loop). */
3335
3332
  extractionFailureClass?: ExtractionFailureClass;
3333
+ /** Trusted source connector resolved over boundedTurns; persisted verbatim by the orchestrator so it is not recomputed (#2183). */
3334
+ sourceConnector?: string;
3336
3335
  }
3337
3336
 
3338
3337
  export interface EntityMention {