@jungjaehoon/mama-core 2.4.1 → 4.1.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 (378) hide show
  1. package/README.md +76 -239
  2. package/db/migrations/030-case-first-memory-substrate.sql +13 -98
  3. package/db/migrations/034-add-connector-event-scope-columns.sql +9 -13
  4. package/db/migrations/039-add-connector-event-operator-ingest-seq.sql +9 -95
  5. package/db/migrations/062-refresh-connector-event-sequences.sql +9 -113
  6. package/db/migrations/063-refresh-legacy-connector-event-updates.sql +9 -32
  7. package/db/migrations/067-add-connector-event-source-entity-id.sql +9 -13
  8. package/db/migrations/069-create-registry-nodes.sql +52 -0
  9. package/db/migrations/070-record-identity.sql +35 -0
  10. package/db/migrations/071-service-operation-origins.sql +187 -0
  11. package/db/migrations/072-observation-versions.sql +29 -0
  12. package/db/migrations/073-registry-corrections.sql +45 -0
  13. package/db/migrations/074-work-graph-ref-kinds.sql +39 -0
  14. package/db/migrations/075-agent-judgments.sql +58 -0
  15. package/db/migrations/076-scoped-checkpoint-bindings.sql +15 -0
  16. package/db/migrations/077-legacy-record-kind.sql +6 -0
  17. package/db/migrations/078-source-ingest-commands.sql +18 -0
  18. package/db/migrations/079-twin-edge-relations.sql +43 -0
  19. package/db/migrations/080-restore-duration-days.sql +7 -0
  20. package/db/migrations/081-mailbox.sql +61 -0
  21. package/db/migrations/082-commitments-row-id.sql +12 -0
  22. package/db/migrations/083-observation-is-the-evidence.sql +49 -0
  23. package/db/migrations/084-scope-kind-is-not-the-cores-to-list.sql +34 -0
  24. package/db/migrations/085-a-migration-has-a-source.sql +37 -0
  25. package/db/migrations/086-the-mailbox-is-generic.sql +110 -0
  26. package/db/migrations/087-mailbox-payload.sql +5 -0
  27. package/db/migrations/088-native-input-journal.sql +14 -0
  28. package/db/migrations/089-native-turn-receipt-lookup.sql +3 -0
  29. package/db/migrations/090-model-run-native-inputs.sql +29 -0
  30. package/db/migrations/091-native-turn-results.sql +11 -0
  31. package/db/migrations/092-restore-decision-fts.sql +34 -0
  32. package/db/migrations/093-native-turn-primary-kind.sql +14 -0
  33. package/db/migrations/094-commitment-run-provenance.sql +9 -0
  34. package/db/migrations/095-model-run-native-input-identity.sql +39 -0
  35. package/db/migrations/096-drop-connector-event-index-fts.sql +9 -0
  36. package/db/migrations/097-native-input-json-validity.sql +37 -0
  37. package/db/migrations/098-workflow-memory-kind.sql +105 -0
  38. package/db/migrations/099-commitment-revision-graph.sql +2 -0
  39. package/dist/action-contracts.d.ts +212 -0
  40. package/dist/action-contracts.js +10 -0
  41. package/dist/api/catalog.d.ts +118 -0
  42. package/dist/api/catalog.js +1756 -0
  43. package/dist/api/dispatch.d.ts +76 -0
  44. package/dist/api/dispatch.js +372 -0
  45. package/dist/canonicalize.d.ts +2 -2
  46. package/dist/canonicalize.js +3 -3
  47. package/dist/client/client.d.ts +33 -0
  48. package/dist/client/client.js +123 -0
  49. package/dist/client/ipc.d.ts +81 -0
  50. package/dist/client/ipc.js +314 -0
  51. package/dist/db-adapter/base-adapter.d.ts +6 -66
  52. package/dist/db-adapter/base-adapter.js +6 -6
  53. package/dist/db-adapter/index.d.ts +5 -5
  54. package/dist/db-adapter/index.js +2 -5
  55. package/dist/db-adapter/node-sqlite-adapter.d.ts +85 -15
  56. package/dist/db-adapter/node-sqlite-adapter.js +1985 -570
  57. package/dist/db-manager.d.ts +53 -97
  58. package/dist/db-manager.js +121 -603
  59. package/dist/embedding/embedder.d.ts +132 -0
  60. package/dist/embedding/embedder.js +299 -0
  61. package/dist/identity/principal-repository.d.ts +2 -2
  62. package/dist/index.d.ts +43 -58
  63. package/dist/index.js +97 -145
  64. package/dist/{context-compile/channel-grant.d.ts → knowledge/access.d.ts} +12 -17
  65. package/dist/knowledge/access.js +663 -0
  66. package/dist/knowledge/case-errors.d.ts +31 -0
  67. package/dist/knowledge/case-errors.js +40 -0
  68. package/dist/{cases/search-rollup.d.ts → knowledge/case-search-rollup.d.ts} +5 -4
  69. package/dist/{cases/search-rollup.js → knowledge/case-search-rollup.js} +6 -8
  70. package/dist/{cases/store.d.ts → knowledge/case-store.d.ts} +3 -6
  71. package/dist/{cases/store.js → knowledge/case-store.js} +7 -42
  72. package/dist/{cases/timeline-range.d.ts → knowledge/case-timeline-range.d.ts} +3 -3
  73. package/dist/{cases/timeline-range.js → knowledge/case-timeline-range.js} +47 -25
  74. package/dist/{cases/types.d.ts → knowledge/case-types.d.ts} +8 -2
  75. package/dist/{cases/types.js → knowledge/case-types.js} +1 -1
  76. package/dist/knowledge/commitment-revision-migration.d.ts +4 -0
  77. package/dist/knowledge/commitment-revision-migration.js +50 -0
  78. package/dist/knowledge/commitments.d.ts +192 -0
  79. package/dist/knowledge/commitments.js +386 -0
  80. package/dist/knowledge/decision-edges.d.ts +70 -0
  81. package/dist/knowledge/decision-edges.js +123 -0
  82. package/dist/{agent-graph/types.d.ts → knowledge/graph-query.d.ts} +80 -70
  83. package/dist/knowledge/graph-query.js +1585 -0
  84. package/dist/knowledge/identity.d.ts +16 -0
  85. package/dist/knowledge/identity.js +22 -0
  86. package/dist/knowledge/index.d.ts +47 -0
  87. package/dist/knowledge/index.js +90 -0
  88. package/dist/knowledge/judgment-edge.d.ts +6 -0
  89. package/dist/knowledge/judgment-edge.js +22 -0
  90. package/dist/knowledge/judgments.d.ts +118 -0
  91. package/dist/knowledge/judgments.js +802 -0
  92. package/dist/knowledge/observations.d.ts +160 -0
  93. package/dist/knowledge/observations.js +449 -0
  94. package/dist/knowledge/question-type.d.ts +34 -0
  95. package/dist/knowledge/question-type.js +70 -0
  96. package/dist/{search → knowledge}/ranker-features.js +1 -1
  97. package/dist/{search → knowledge}/search-quality.d.ts +0 -1
  98. package/dist/knowledge/search.d.ts +38 -0
  99. package/dist/knowledge/search.js +91 -0
  100. package/dist/knowledge/source-ingest.d.ts +65 -0
  101. package/dist/knowledge/source-ingest.js +174 -0
  102. package/dist/{edges/types.d.ts → knowledge/twin-edge-types.d.ts} +31 -4
  103. package/dist/{edges/types.js → knowledge/twin-edge-types.js} +13 -2
  104. package/dist/knowledge/work-dates.d.ts +49 -0
  105. package/dist/knowledge/work-dates.js +120 -0
  106. package/dist/mama-api.d.ts +114 -778
  107. package/dist/mama-api.js +313 -2461
  108. package/dist/memory/api.d.ts +264 -24
  109. package/dist/memory/api.js +1633 -843
  110. package/dist/memory/bootstrap-builder.d.ts +2 -1
  111. package/dist/memory/bootstrap-builder.js +5 -5
  112. package/dist/memory/channel-summary-state-store.d.ts +3 -2
  113. package/dist/memory/channel-summary-state-store.js +53 -51
  114. package/dist/memory/channel-summary-store.d.ts +5 -3
  115. package/dist/memory/channel-summary-store.js +3 -8
  116. package/dist/memory/dashboard-read.d.ts +46 -0
  117. package/dist/memory/dashboard-read.js +94 -0
  118. package/dist/memory/event-store.d.ts +3 -3
  119. package/dist/memory/event-store.js +3 -10
  120. package/dist/memory/finding-store.d.ts +3 -2
  121. package/dist/memory/finding-store.js +2 -7
  122. package/dist/memory/graph-read.d.ts +52 -0
  123. package/dist/memory/graph-read.js +130 -0
  124. package/dist/memory/judgment-types.d.ts +394 -0
  125. package/dist/memory/judgment-types.js +16 -0
  126. package/dist/memory/provenance-audit.d.ts +5 -2
  127. package/dist/memory/provenance-audit.js +8 -14
  128. package/dist/memory/provenance-live.d.ts +141 -0
  129. package/dist/memory/provenance-live.js +409 -0
  130. package/dist/memory/provenance-query.d.ts +5 -4
  131. package/dist/memory/provenance-query.js +21 -29
  132. package/dist/memory/provenance-resolver.d.ts +191 -0
  133. package/dist/memory/provenance-resolver.js +155 -0
  134. package/dist/memory/provenance.d.ts +1 -11
  135. package/dist/memory/provenance.js +2 -33
  136. package/dist/memory/recall-sanitize.d.ts +55 -0
  137. package/dist/memory/recall-sanitize.js +144 -0
  138. package/dist/memory/secret-filter.d.ts +32 -0
  139. package/dist/memory/secret-filter.js +126 -0
  140. package/dist/memory/truth-store.d.ts +2 -1
  141. package/dist/memory/truth-store.js +1 -4
  142. package/dist/memory/types.d.ts +74 -24
  143. package/dist/memory/types.js +75 -5
  144. package/dist/memory/write-adapters.d.ts +98 -0
  145. package/dist/memory/write-adapters.js +242 -0
  146. package/dist/operations/owner-action-effects.d.ts +53 -0
  147. package/dist/operations/owner-action-effects.js +96 -0
  148. package/dist/provenance/source-ref.d.ts +1 -1
  149. package/dist/provenance/source-ref.js +0 -2
  150. package/dist/registry/corrections.d.ts +31 -0
  151. package/dist/registry/corrections.js +332 -0
  152. package/dist/registry/record-identity.d.ts +49 -0
  153. package/dist/registry/record-identity.js +133 -0
  154. package/dist/registry/store.d.ts +101 -0
  155. package/dist/registry/store.js +395 -0
  156. package/dist/registry/types.d.ts +28 -0
  157. package/dist/registry/types.js +5 -0
  158. package/dist/relevance-scorer.js +2 -2
  159. package/dist/runtime/agent-event-bus.d.ts +50 -0
  160. package/dist/runtime/agent-event-bus.js +101 -0
  161. package/dist/runtime/drivers/claude-cli-wrapper.d.ts +152 -0
  162. package/dist/runtime/drivers/claude-cli-wrapper.js +375 -0
  163. package/dist/runtime/drivers/claude-effort.d.ts +4 -0
  164. package/dist/runtime/drivers/claude-effort.js +16 -0
  165. package/dist/runtime/drivers/cli-arg-redaction.d.ts +2 -0
  166. package/dist/runtime/drivers/cli-arg-redaction.js +18 -0
  167. package/dist/runtime/drivers/cli-secret-redaction.d.ts +17 -0
  168. package/dist/runtime/drivers/cli-secret-redaction.js +126 -0
  169. package/dist/runtime/drivers/codex-app-server-process.d.ts +277 -0
  170. package/dist/runtime/drivers/codex-app-server-process.js +2342 -0
  171. package/dist/runtime/drivers/codex-auxiliary-tools.d.ts +17 -0
  172. package/dist/runtime/drivers/codex-auxiliary-tools.js +267 -0
  173. package/dist/runtime/drivers/codex-home.d.ts +20 -0
  174. package/dist/runtime/drivers/codex-home.js +674 -0
  175. package/dist/runtime/drivers/codex-thread-registry.d.ts +63 -0
  176. package/dist/runtime/drivers/codex-thread-registry.js +433 -0
  177. package/dist/runtime/drivers/persistent-cli-adapter.d.ts +160 -0
  178. package/dist/runtime/drivers/persistent-cli-adapter.js +396 -0
  179. package/dist/runtime/drivers/persistent-cli-process.d.ts +425 -0
  180. package/dist/runtime/drivers/persistent-cli-process.js +1529 -0
  181. package/dist/runtime/drivers/types.d.ts +456 -0
  182. package/dist/runtime/drivers/types.js +110 -0
  183. package/dist/runtime/mailbox.d.ts +223 -0
  184. package/dist/runtime/mailbox.js +582 -0
  185. package/dist/runtime/model-run-store.d.ts +28 -0
  186. package/dist/{model-runs/store.js → runtime/model-run-store.js} +81 -41
  187. package/dist/{model-runs/types.d.ts → runtime/model-run-types.d.ts} +33 -4
  188. package/dist/{model-runs/types.js → runtime/model-run-types.js} +1 -1
  189. package/dist/runtime/native-effect-observer.d.ts +22 -0
  190. package/dist/runtime/native-effect-observer.js +103 -0
  191. package/dist/runtime/native-input-journal.d.ts +46 -0
  192. package/dist/runtime/native-input-journal.js +308 -0
  193. package/dist/runtime/native-prompt.d.ts +118 -0
  194. package/dist/runtime/native-prompt.js +496 -0
  195. package/dist/runtime/native-session.d.ts +10 -0
  196. package/dist/{agent-graph/index.js → runtime/native-session.js} +9 -6
  197. package/dist/runtime/native-tool-trace-observer.d.ts +5 -0
  198. package/dist/runtime/native-tool-trace-observer.js +65 -0
  199. package/dist/runtime/native-turn.d.ts +272 -0
  200. package/dist/runtime/native-turn.js +1041 -0
  201. package/dist/runtime/operations.d.ts +236 -0
  202. package/dist/runtime/operations.js +565 -0
  203. package/dist/runtime/post-tool-handler.d.ts +74 -0
  204. package/dist/runtime/post-tool-handler.js +137 -0
  205. package/dist/runtime/prompt-layers.d.ts +126 -0
  206. package/dist/runtime/prompt-layers.js +239 -0
  207. package/dist/runtime/runtime-process.d.ts +102 -0
  208. package/dist/runtime/runtime-process.js +206 -0
  209. package/dist/runtime/runtime.d.ts +278 -0
  210. package/dist/runtime/runtime.js +563 -0
  211. package/dist/runtime/session-pool.d.ts +176 -0
  212. package/dist/runtime/session-pool.js +369 -0
  213. package/dist/runtime/stimulus-payload.d.ts +5 -0
  214. package/dist/runtime/stimulus-payload.js +50 -0
  215. package/dist/runtime/subagent-bridge.d.ts +24 -0
  216. package/dist/{agent-graph/types.js → runtime/subagent-bridge.js} +1 -1
  217. package/dist/runtime/text-completion.d.ts +22 -0
  218. package/dist/{agent-situation/types.js → runtime/text-completion.js} +1 -1
  219. package/dist/runtime/token-estimator.d.ts +25 -0
  220. package/dist/runtime/token-estimator.js +75 -0
  221. package/dist/runtime/tool-trace-store.d.ts +22 -0
  222. package/dist/{model-runs → runtime}/tool-trace-store.js +46 -27
  223. package/dist/runtime/trace-summary.d.ts +5 -0
  224. package/dist/runtime/trace-summary.js +74 -0
  225. package/dist/runtime/turn-text.d.ts +23 -0
  226. package/dist/runtime/turn-text.js +41 -0
  227. package/dist/storage/database.d.ts +67 -0
  228. package/dist/storage/database.js +158 -0
  229. package/package.json +20 -34
  230. package/dist/agent-graph/alias-write.d.ts +0 -3
  231. package/dist/agent-graph/alias-write.js +0 -234
  232. package/dist/agent-graph/entity-resolve.d.ts +0 -3
  233. package/dist/agent-graph/entity-resolve.js +0 -271
  234. package/dist/agent-graph/errors.d.ts +0 -4
  235. package/dist/agent-graph/errors.js +0 -11
  236. package/dist/agent-graph/graph-query.d.ts +0 -5
  237. package/dist/agent-graph/graph-query.js +0 -360
  238. package/dist/agent-graph/index.d.ts +0 -6
  239. package/dist/agent-situation/builder.d.ts +0 -8
  240. package/dist/agent-situation/builder.js +0 -239
  241. package/dist/agent-situation/cache-key.d.ts +0 -4
  242. package/dist/agent-situation/cache-key.js +0 -64
  243. package/dist/agent-situation/index.d.ts +0 -7
  244. package/dist/agent-situation/index.js +0 -28
  245. package/dist/agent-situation/packet-store.d.ts +0 -27
  246. package/dist/agent-situation/packet-store.js +0 -228
  247. package/dist/agent-situation/ranking-policy.d.ts +0 -18
  248. package/dist/agent-situation/ranking-policy.js +0 -75
  249. package/dist/agent-situation/source-readers.d.ts +0 -52
  250. package/dist/agent-situation/source-readers.js +0 -300
  251. package/dist/agent-situation/types.d.ts +0 -195
  252. package/dist/cases/wiki-page-index.d.ts +0 -37
  253. package/dist/cases/wiki-page-index.js +0 -201
  254. package/dist/config-loader.d.ts +0 -68
  255. package/dist/config-loader.js +0 -239
  256. package/dist/connectors/event-index.d.ts +0 -24
  257. package/dist/connectors/event-index.js +0 -245
  258. package/dist/connectors/raw-query.d.ts +0 -40
  259. package/dist/connectors/raw-query.js +0 -412
  260. package/dist/connectors/types.d.ts +0 -117
  261. package/dist/connectors/types.js +0 -3
  262. package/dist/context-compile/boundary-defaults.d.ts +0 -12
  263. package/dist/context-compile/boundary-defaults.js +0 -105
  264. package/dist/context-compile/channel-grant.js +0 -66
  265. package/dist/context-compile/compiler-policy.d.ts +0 -39
  266. package/dist/context-compile/compiler-policy.js +0 -147
  267. package/dist/context-compile/compiler.d.ts +0 -18
  268. package/dist/context-compile/compiler.js +0 -404
  269. package/dist/context-compile/index.d.ts +0 -10
  270. package/dist/context-compile/index.js +0 -26
  271. package/dist/context-compile/packet-store.d.ts +0 -8
  272. package/dist/context-compile/packet-store.js +0 -239
  273. package/dist/context-compile/ref.d.ts +0 -7
  274. package/dist/context-compile/ref.js +0 -102
  275. package/dist/context-compile/source-readers.d.ts +0 -70
  276. package/dist/context-compile/source-readers.js +0 -840
  277. package/dist/context-compile/types.d.ts +0 -155
  278. package/dist/context-compile/types.js +0 -11
  279. package/dist/context-compile/visibility.d.ts +0 -21
  280. package/dist/context-compile/visibility.js +0 -224
  281. package/dist/decision-tracker.d.ts +0 -206
  282. package/dist/decision-tracker.js +0 -481
  283. package/dist/edges/ref-validation.d.ts +0 -7
  284. package/dist/edges/ref-validation.js +0 -321
  285. package/dist/edges/store.d.ts +0 -8
  286. package/dist/edges/store.js +0 -129
  287. package/dist/embedding-client.d.ts +0 -28
  288. package/dist/embedding-client.js +0 -53
  289. package/dist/embedding-server/index.d.ts +0 -67
  290. package/dist/embedding-server/index.js +0 -405
  291. package/dist/embedding-server/mobile/auth.d.ts +0 -44
  292. package/dist/embedding-server/mobile/auth.js +0 -150
  293. package/dist/embedding-server/mobile/daemon.d.ts +0 -129
  294. package/dist/embedding-server/mobile/daemon.js +0 -313
  295. package/dist/embedding-server/mobile/output-parser.d.ts +0 -115
  296. package/dist/embedding-server/mobile/output-parser.js +0 -241
  297. package/dist/embedding-server/mobile/session-api.d.ts +0 -57
  298. package/dist/embedding-server/mobile/session-api.js +0 -261
  299. package/dist/embedding-server/mobile/session-manager.d.ts +0 -138
  300. package/dist/embedding-server/mobile/session-manager.js +0 -378
  301. package/dist/embedding-server/mobile/websocket-handler.d.ts +0 -137
  302. package/dist/embedding-server/mobile/websocket-handler.js +0 -486
  303. package/dist/embeddings.d.ts +0 -68
  304. package/dist/embeddings.js +0 -244
  305. package/dist/entities/audit-metrics.d.ts +0 -68
  306. package/dist/entities/audit-metrics.js +0 -124
  307. package/dist/entities/candidate-generator.d.ts +0 -8
  308. package/dist/entities/candidate-generator.js +0 -24
  309. package/dist/entities/entity-linked-decision-counts.d.ts +0 -2
  310. package/dist/entities/entity-linked-decision-counts.js +0 -29
  311. package/dist/entities/entity-list.d.ts +0 -22
  312. package/dist/entities/entity-list.js +0 -3
  313. package/dist/entities/entity-orphan-list.d.ts +0 -17
  314. package/dist/entities/entity-orphan-list.js +0 -3
  315. package/dist/entities/entity-search.d.ts +0 -20
  316. package/dist/entities/entity-search.js +0 -3
  317. package/dist/entities/errors.d.ts +0 -55
  318. package/dist/entities/errors.js +0 -100
  319. package/dist/entities/lineage-store.d.ts +0 -28
  320. package/dist/entities/lineage-store.js +0 -204
  321. package/dist/entities/normalization.d.ts +0 -14
  322. package/dist/entities/normalization.js +0 -63
  323. package/dist/entities/policy-store.d.ts +0 -8
  324. package/dist/entities/policy-store.js +0 -75
  325. package/dist/entities/policy-types.d.ts +0 -72
  326. package/dist/entities/policy-types.js +0 -59
  327. package/dist/entities/projection.d.ts +0 -8
  328. package/dist/entities/projection.js +0 -82
  329. package/dist/entities/provenance-query.d.ts +0 -32
  330. package/dist/entities/provenance-query.js +0 -3
  331. package/dist/entities/read-identity.d.ts +0 -31
  332. package/dist/entities/read-identity.js +0 -264
  333. package/dist/entities/recall-bridge.d.ts +0 -5
  334. package/dist/entities/recall-bridge.js +0 -171
  335. package/dist/entities/resolution-engine.d.ts +0 -8
  336. package/dist/entities/resolution-engine.js +0 -3
  337. package/dist/entities/rollback-preview.d.ts +0 -35
  338. package/dist/entities/rollback-preview.js +0 -3
  339. package/dist/entities/source-locator.d.ts +0 -3
  340. package/dist/entities/source-locator.js +0 -32
  341. package/dist/entities/store.d.ts +0 -69
  342. package/dist/entities/store.js +0 -544
  343. package/dist/entities/types.d.ts +0 -166
  344. package/dist/entities/types.js +0 -30
  345. package/dist/memory/extraction-prompt.d.ts +0 -4
  346. package/dist/memory/extraction-prompt.js +0 -89
  347. package/dist/memory/scope-backfill.d.ts +0 -14
  348. package/dist/memory/scope-backfill.js +0 -3
  349. package/dist/memory/scope-store.d.ts +0 -4
  350. package/dist/memory/scope-store.js +0 -9
  351. package/dist/memory-store.d.ts +0 -87
  352. package/dist/memory-store.js +0 -78
  353. package/dist/model-runs/store.d.ts +0 -13
  354. package/dist/model-runs/tool-trace-store.d.ts +0 -8
  355. package/dist/notification-manager.d.ts +0 -7
  356. package/dist/notification-manager.js +0 -12
  357. package/dist/outcome-tracker.d.ts +0 -151
  358. package/dist/outcome-tracker.js +0 -271
  359. package/dist/query-intent.d.ts +0 -23
  360. package/dist/query-intent.js +0 -114
  361. package/dist/runtime/trusted-provenance.d.ts +0 -3
  362. package/dist/runtime/trusted-provenance.js +0 -6
  363. package/dist/search/question-type.d.ts +0 -5
  364. package/dist/search/question-type.js +0 -41
  365. package/dist/test-utils.d.ts +0 -80
  366. package/dist/test-utils.js +0 -218
  367. package/dist/tier-validator.d.ts +0 -43
  368. package/dist/tier-validator.js +0 -159
  369. package/dist/time-formatter.d.ts +0 -25
  370. package/dist/time-formatter.js +0 -93
  371. /package/dist/{search → knowledge}/feedback-store.d.ts +0 -0
  372. /package/dist/{search → knowledge}/feedback-store.js +0 -0
  373. /package/dist/{search → knowledge}/ranker-features.d.ts +0 -0
  374. /package/dist/{search → knowledge}/ranker-rescore.d.ts +0 -0
  375. /package/dist/{search → knowledge}/ranker-rescore.js +0 -0
  376. /package/dist/{search → knowledge}/ranker-trainer.d.ts +0 -0
  377. /package/dist/{search → knowledge}/ranker-trainer.js +0 -0
  378. /package/dist/{search → knowledge}/search-quality.js +0 -0
@@ -0,0 +1,394 @@
1
+ import type { MemoryEventRecord, MemoryScopeRef } from './types.js';
2
+ import type { TwinRef } from '../knowledge/twin-edge-types.js';
3
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
4
+ [key: string]: JsonValue;
5
+ };
6
+ export type WorkReference = TwinRef | {
7
+ kind: 'registry' | 'observation';
8
+ id: string;
9
+ };
10
+ export type WorkRef = WorkReference;
11
+ export interface RecordLink {
12
+ relation: 'supersedes' | 'refines' | 'contradicts' | 'mentions' | 'derived_from' | 'builds_on' | 'debates' | 'synthesizes' | 'blocks' | 'next_action_for' | 'case_member' | 'amends';
13
+ target: WorkReference;
14
+ attrs?: {
15
+ role?: string;
16
+ slot?: string;
17
+ [key: string]: JsonValue | undefined;
18
+ };
19
+ }
20
+ /**
21
+ * What a revision sets on a piece of work.
22
+ *
23
+ * The core reads exactly three of these: the date fields, because a commitment's due
24
+ * time is something it reasons about. Everything else round-trips as JSON through
25
+ * `set_json` and is never destructured here -- it is one product's board vocabulary
26
+ * (status, priority, assignee, resolution) and the product's own action schema is
27
+ * where it is spelled out and checked.
28
+ */
29
+ export interface OwnerWorkPatch {
30
+ dueAt?: string | null;
31
+ deadline?: string | null;
32
+ /**
33
+ * The offset (minutes from UTC, -840..840) a bare `deadline`'s day starts in.
34
+ * Pairs with the date fields: an exact `dueAt` derives it, a bare deadline
35
+ * may state it alone. Absent means the owner's zone answers.
36
+ */
37
+ deadlineOffsetMinutes?: number | null;
38
+ [field: string]: JsonValue | undefined;
39
+ }
40
+ /**
41
+ * The named lifecycle judgments an owner row accepts. A reclassification is a
42
+ * revision whose status and resolutionKind are the SAME statement: completed
43
+ * work and an item that was never a task must not close identically.
44
+ */
45
+ export declare const WORK_RECLASSIFY_DISPOSITIONS: readonly ["completed_evidence", "completed_no_issue", "non_task_record", "non_task_memory", "reopen"];
46
+ export type WorkReclassifyDisposition = (typeof WORK_RECLASSIFY_DISPOSITIONS)[number];
47
+ export type WorkAssignment = {
48
+ set?: OwnerWorkPatch;
49
+ clear?: Array<keyof OwnerWorkPatch>;
50
+ } & ({
51
+ operation: 'create';
52
+ /**
53
+ * Import vocabulary: the identity this work already had in a predecessor
54
+ * store. A migration that brings existing owner rows into the commitment
55
+ * log names their task id and revision so the log keeps the row's number
56
+ * and CAS history instead of minting a new identity. Absent for work
57
+ * first stated through this command log.
58
+ */
59
+ imported?: {
60
+ rowId: number;
61
+ revision?: number;
62
+ createdAt?: number;
63
+ };
64
+ } | {
65
+ operation: 'revise';
66
+ commitmentId: string;
67
+ expectedRevision?: number;
68
+ } | {
69
+ operation: 'withdraw';
70
+ commitmentId: string;
71
+ expectedRevision: number;
72
+ });
73
+ /**
74
+ * Legacy decisions-row fields that public save adapters keep projecting. These
75
+ * columns remain the read model for existing recall/provenance surfaces until
76
+ * the readers migrate to the command log.
77
+ */
78
+ export interface JudgmentRecordFields {
79
+ kind?: string | null;
80
+ status?: string | null;
81
+ summary?: string | null;
82
+ isStatic?: number | null;
83
+ userInvolvement?: string | null;
84
+ sessionId?: string | null;
85
+ needsValidation?: number | null;
86
+ trustContext?: string | null;
87
+ refinedFrom?: string[] | null;
88
+ /**
89
+ * Legacy `decisions.supersedes` column for records whose predecessor was
90
+ * declared through the supersedeTargets projection rather than the
91
+ * scope-checked `replaces` command field.
92
+ */
93
+ supersedes?: string | null;
94
+ }
95
+ /**
96
+ * Append-only correction to an existing memory row's projection columns. The
97
+ * judgment record stays the authority; the named columns on the target row are
98
+ * the maintained projection that current readers consume.
99
+ */
100
+ export interface JudgmentAmendment {
101
+ target: {
102
+ kind: 'memory';
103
+ id: string;
104
+ };
105
+ outcome?: string | null;
106
+ failureReason?: string | null;
107
+ limitation?: string | null;
108
+ status?: string | null;
109
+ confidence?: number | null;
110
+ durationDays?: number | null;
111
+ supersedes?: string | null;
112
+ supersededBy?: string | null;
113
+ }
114
+ /** Provenance carried onto the record's memory_events row. */
115
+ export interface JudgmentEventMeta {
116
+ eventType?: MemoryEventRecord['event_type'];
117
+ actor?: MemoryEventRecord['actor'];
118
+ sourceTurnId?: string;
119
+ reason?: string;
120
+ evidenceRefs?: string[];
121
+ }
122
+ /**
123
+ * Compatibility projections the command applies inside the same transaction so
124
+ * pre-command readers keep working. None of these create authority beyond the
125
+ * command itself; they mirror what the legacy writers used to persist inline.
126
+ */
127
+ export interface JudgmentProjections {
128
+ /** Legacy decision_edges rows kept in sync for recall readers. `fromId`
129
+ * defaults to the appended record; amendment commands may name another row. */
130
+ decisionEdges?: Array<{
131
+ fromId?: string;
132
+ targetId: string;
133
+ relationship: string;
134
+ reason?: string | null;
135
+ weight?: number;
136
+ createdBy?: string;
137
+ approvedByUser?: number | null;
138
+ }>;
139
+ /**
140
+ * Rows the command marks as superseded by the appended record. This mirrors
141
+ * the legacy save surface where an unsigned caller's explicit `supersedes`
142
+ * relationship moved the named target out of current truth; the command
143
+ * boundary keeps `replaces` for scope-admitted supersession instead.
144
+ */
145
+ supersedeTargets?: string[];
146
+ /** Registry record identity binding (item + actors). */
147
+ recordIdentity?: {
148
+ itemId?: string | null;
149
+ actors?: Array<{
150
+ personId: string;
151
+ role: string;
152
+ }>;
153
+ };
154
+ }
155
+ export interface JudgmentCommand {
156
+ commandId: string;
157
+ topic: string;
158
+ summary: string;
159
+ reasoning?: string;
160
+ recordKind: 'judgment' | 'commitment';
161
+ payload?: Record<string, JsonValue>;
162
+ appliesFrom?: number;
163
+ appliesUntil?: number;
164
+ links?: RecordLink[];
165
+ replaces?: Array<{
166
+ id: string;
167
+ reason: string;
168
+ }>;
169
+ work?: WorkAssignment;
170
+ scopes?: MemoryScopeRef[];
171
+ /** Confidence supplied by the caller; no synthesis happens here. */
172
+ confidence?: number;
173
+ /** ISO 8601 YYYY-MM-DD for when the recorded event actually occurred. */
174
+ eventDate?: string | null;
175
+ /** Milliseconds epoch for when the recorded event actually occurred. */
176
+ eventDatetime?: number | null;
177
+ outcome?: string | null;
178
+ failureReason?: string | null;
179
+ limitation?: string | null;
180
+ evidence?: string | string[] | null;
181
+ alternatives?: string | string[] | null;
182
+ risks?: string | null;
183
+ /** Source references carried from normalized write provenance. */
184
+ sourceRefs?: string[];
185
+ /** Compact provenance record persisted on the decision row. */
186
+ provenance?: Record<string, JsonValue>;
187
+ /**
188
+ * Authored record agent. Absent means the access principal writes the record;
189
+ * an explicit null keeps the column empty for honest unsigned writes.
190
+ */
191
+ agentId?: string | null;
192
+ modelRunId?: string | null;
193
+ envelopeHash?: string | null;
194
+ gatewayCallId?: string | null;
195
+ /** Domain capture time for the record (decisions.created_at). */
196
+ recordedAt?: number;
197
+ /** Legacy decisions-row projection fields. */
198
+ record?: JudgmentRecordFields;
199
+ /** Append-only amendments applied to existing memory rows in-transaction. */
200
+ amends?: JudgmentAmendment[];
201
+ /** Memory event metadata for the record's save event. */
202
+ event?: JudgmentEventMeta;
203
+ /** Legacy compatibility projections written in the same transaction. */
204
+ projections?: JudgmentProjections;
205
+ }
206
+ export interface JudgmentReceipt {
207
+ status: 'committed';
208
+ recordId: string;
209
+ commandId: string;
210
+ edgeIds: string[];
211
+ watermark: number;
212
+ work?: {
213
+ commitmentId: string;
214
+ revision: number;
215
+ };
216
+ diagnostics: Array<{
217
+ stage: string;
218
+ code: string;
219
+ message: string;
220
+ }>;
221
+ }
222
+ export type IdentityCorrectionAssignment = {
223
+ edgeId: string;
224
+ endpoint: 'from' | 'to';
225
+ } & ({
226
+ targetNodeId: string | null;
227
+ targetClientKey?: never;
228
+ } | {
229
+ targetClientKey: string;
230
+ targetNodeId?: never;
231
+ });
232
+ export type IdentityCorrection = {
233
+ commandId: string;
234
+ expectedRevision: number;
235
+ reason: string;
236
+ scopes?: MemoryScopeRef[];
237
+ evidence?: ReadonlyArray<{
238
+ kind: 'observation';
239
+ id: string;
240
+ }>;
241
+ } & ({
242
+ operation: 'add_alias';
243
+ nodeId: string;
244
+ alias: string;
245
+ } | {
246
+ operation: 'merge';
247
+ survivorId: string;
248
+ memberIds: readonly string[];
249
+ } | {
250
+ operation: 'split';
251
+ parentId: string;
252
+ children: ReadonlyArray<{
253
+ clientKey?: string;
254
+ name: string;
255
+ aliases?: readonly string[];
256
+ }>;
257
+ assignments: readonly IdentityCorrectionAssignment[];
258
+ } | {
259
+ operation: 'assign_refs';
260
+ parentId: string;
261
+ assignments: readonly IdentityCorrectionAssignment[];
262
+ });
263
+ export interface IdentityCorrectionReceipt {
264
+ commandId: string;
265
+ identityRevision: number;
266
+ children: Array<{
267
+ clientKey: string;
268
+ ref: {
269
+ kind: 'registry';
270
+ id: string;
271
+ };
272
+ }>;
273
+ changedSlots: Array<{
274
+ edgeId: string;
275
+ endpoint: 'from' | 'to';
276
+ }>;
277
+ unresolved: Array<{
278
+ edgeId: string;
279
+ endpoint: 'from' | 'to';
280
+ }>;
281
+ }
282
+ export interface WorkGraphQuery {
283
+ seeds?: WorkReference[];
284
+ search?: {
285
+ text: string;
286
+ kinds?: WorkReference['kind'][];
287
+ };
288
+ view: 'overview' | 'browse' | 'neighbors' | 'timeline' | 'paths' | 'detail';
289
+ section?: 'summary' | 'reasoning' | 'payload';
290
+ textOffset?: number;
291
+ textLimit?: number;
292
+ from?: WorkReference;
293
+ to?: WorkReference;
294
+ maxDepth?: number;
295
+ direction?: 'in' | 'out' | 'both';
296
+ relations?: string[];
297
+ history?: 'current' | 'all';
298
+ eventRange?: {
299
+ start?: number;
300
+ end?: number;
301
+ };
302
+ recordedRange?: {
303
+ start?: number;
304
+ end?: number;
305
+ };
306
+ asOf?: number;
307
+ limit?: number;
308
+ cursor?: string;
309
+ }
310
+ export type WorkGraphNodeData = {
311
+ kind: 'memory';
312
+ recordKind: 'legacy' | 'judgment' | 'commitment';
313
+ /** Stored classification, independent of the graph reference kind. */
314
+ memoryKind?: string | null;
315
+ topic: string;
316
+ summary: string;
317
+ recordedAt: number;
318
+ appliesFrom: number | null;
319
+ appliesUntil: number | null;
320
+ stateAtSnapshot: 'current' | 'replaced' | 'withdrawn' | 'not_yet_effective' | 'expired';
321
+ replaces: string[];
322
+ payload: Record<string, JsonValue>;
323
+ /** The commitment this record is a revision of, when it is one. */
324
+ work: {
325
+ commitmentId: string;
326
+ rowId: number;
327
+ revision: number;
328
+ latestJudgmentRef: WorkReference;
329
+ } | null;
330
+ /**
331
+ * Whether `summary` holds the whole selected section text. When it does not,
332
+ * `nextRead` is the same query with the offset advanced past what was returned.
333
+ */
334
+ content: {
335
+ complete: boolean;
336
+ nextRead: WorkGraphQuery | null;
337
+ };
338
+ } | {
339
+ kind: 'registry';
340
+ nodeKind: 'item' | 'person' | 'client';
341
+ name: string;
342
+ parentId: string | null;
343
+ visibleAliases: string[];
344
+ identityRevision: number;
345
+ visibleChildren: Array<{
346
+ kind: 'registry';
347
+ id: string;
348
+ name: string;
349
+ }>;
350
+ unresolvedSlots: Array<{
351
+ edgeId: string;
352
+ endpoint: 'from' | 'to';
353
+ }>;
354
+ } | {
355
+ kind: 'observation';
356
+ connector: string;
357
+ sourceId: string;
358
+ sourceAt: number | null;
359
+ observedAt: number;
360
+ contentHash: string;
361
+ } | {
362
+ kind: 'case' | 'entity' | 'report' | 'edge' | 'raw';
363
+ data: Record<string, JsonValue>;
364
+ };
365
+ export interface WorkGraphPage {
366
+ nodes: Array<{
367
+ ref: WorkReference;
368
+ resolvedRef: WorkReference;
369
+ label: string;
370
+ data: WorkGraphNodeData;
371
+ }>;
372
+ edges: Array<{
373
+ id: string;
374
+ relation: string;
375
+ from: WorkReference;
376
+ to: WorkReference;
377
+ resolvedFrom: WorkReference;
378
+ resolvedTo: WorkReference;
379
+ attrs: JsonValue;
380
+ }>;
381
+ coverage: {
382
+ returned: number;
383
+ total: number | null;
384
+ complete: boolean;
385
+ reasons: string[];
386
+ };
387
+ snapshot: {
388
+ judgmentWatermark: number;
389
+ identityRevision: number;
390
+ asOf: number;
391
+ };
392
+ nextCursor: string | null;
393
+ }
394
+ //# sourceMappingURL=judgment-types.d.ts.map
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WORK_RECLASSIFY_DISPOSITIONS = void 0;
4
+ /**
5
+ * The named lifecycle judgments an owner row accepts. A reclassification is a
6
+ * revision whose status and resolutionKind are the SAME statement: completed
7
+ * work and an item that was never a task must not close identically.
8
+ */
9
+ exports.WORK_RECLASSIFY_DISPOSITIONS = [
10
+ 'completed_evidence',
11
+ 'completed_no_issue',
12
+ 'non_task_record',
13
+ 'non_task_memory',
14
+ 'reopen',
15
+ ];
16
+ //# sourceMappingURL=judgment-types.js.map
@@ -1,3 +1,5 @@
1
+ import type { DatabaseAdapter } from '../db-manager.js';
2
+ type ProvenanceAuditAdapter = Pick<DatabaseAdapter, 'prepare'>;
1
3
  import type { MemoryEventRecord, MemoryScopeRef } from './types.js';
2
4
  export interface MemoryProvenanceAuditRecord {
3
5
  memory_id: string;
@@ -17,6 +19,7 @@ export interface MemoryProvenanceAuditListOptions {
17
19
  gateway_call_id?: string;
18
20
  limit?: number;
19
21
  }
20
- export declare function getMemoryProvenanceAudit(memoryId: string): Promise<MemoryProvenanceAuditRecord | null>;
21
- export declare function listMemoryProvenanceAudit(options: MemoryProvenanceAuditListOptions): Promise<MemoryProvenanceAuditRecord[]>;
22
+ export declare function getMemoryProvenanceAudit(adapter: ProvenanceAuditAdapter, memoryId: string): Promise<MemoryProvenanceAuditRecord | null>;
23
+ export declare function listMemoryProvenanceAudit(adapter: ProvenanceAuditAdapter, options: MemoryProvenanceAuditListOptions): Promise<MemoryProvenanceAuditRecord[]>;
24
+ export {};
22
25
  //# sourceMappingURL=provenance-audit.d.ts.map
@@ -2,11 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMemoryProvenanceAudit = getMemoryProvenanceAudit;
4
4
  exports.listMemoryProvenanceAudit = listMemoryProvenanceAudit;
5
- const db_manager_js_1 = require("../db-manager.js");
6
5
  const event_store_js_1 = require("./event-store.js");
7
- async function getMemoryProvenanceAudit(memoryId) {
8
- await (0, db_manager_js_1.initDB)();
9
- const adapter = (0, db_manager_js_1.getAdapter)();
6
+ async function getMemoryProvenanceAudit(adapter, memoryId) {
10
7
  const row = adapter
11
8
  .prepare(`
12
9
  SELECT id, topic, decision, summary, envelope_hash, model_run_id, gateway_call_id,
@@ -15,11 +12,9 @@ async function getMemoryProvenanceAudit(memoryId) {
15
12
  WHERE id = ?
16
13
  `)
17
14
  .get(memoryId);
18
- return row ? toAuditRecord(row) : null;
15
+ return row ? toAuditRecord(adapter, row) : null;
19
16
  }
20
- async function listMemoryProvenanceAudit(options) {
21
- await (0, db_manager_js_1.initDB)();
22
- const adapter = (0, db_manager_js_1.getAdapter)();
17
+ async function listMemoryProvenanceAudit(adapter, options) {
23
18
  const filter = buildAuditFilter(options);
24
19
  const rows = adapter
25
20
  .prepare(`
@@ -33,7 +28,7 @@ async function listMemoryProvenanceAudit(options) {
33
28
  .all(...filter.params, normalizeLimit(options.limit));
34
29
  const records = [];
35
30
  for (const row of rows) {
36
- records.push(await toAuditRecord(row));
31
+ records.push(await toAuditRecord(adapter, row));
37
32
  }
38
33
  return records;
39
34
  }
@@ -52,9 +47,9 @@ function buildAuditFilter(options) {
52
47
  }
53
48
  return { sql: filters[0], params };
54
49
  }
55
- async function toAuditRecord(row) {
56
- const events = await (0, event_store_js_1.listMemoryEventsForMemory)(row.id);
57
- const scopeRefs = listScopeRefs(row.id);
50
+ async function toAuditRecord(adapter, row) {
51
+ const events = await (0, event_store_js_1.listMemoryEventsForMemory)(adapter, row.id);
52
+ const scopeRefs = listScopeRefs(adapter, row.id);
58
53
  const provenance = parseObject(row.provenance_json);
59
54
  const legacyCaveats = [];
60
55
  if (provenance.source_type === 'legacy') {
@@ -76,8 +71,7 @@ async function toAuditRecord(row) {
76
71
  legacy_caveats: legacyCaveats,
77
72
  };
78
73
  }
79
- function listScopeRefs(memoryId) {
80
- const adapter = (0, db_manager_js_1.getAdapter)();
74
+ function listScopeRefs(adapter, memoryId) {
81
75
  const rows = adapter
82
76
  .prepare(`
83
77
  SELECT ms.kind, ms.external_id
@@ -0,0 +1,141 @@
1
+ /**
2
+ * The live wiring for provenance resolution: real memory records, real events, real scope.
3
+ *
4
+ * The resolver itself is pure. This is where it meets the database, and the one rule that
5
+ * governs the whole file is that CITATION MUST NOT OUT-READ READING. If this path were
6
+ * more permissive than the path that reads raw events normally, then citing a claim would
7
+ * become a way to see events the read path denies - the handle would launder access.
8
+ * So this path does not have its own rule any more. When the caller holds a channel grant
9
+ * it calls the SAME function the reader compiles into SQL (mama-core channel-grant.ts).
10
+ * Mirroring by hand is what this file used to do, and the mirror held right up until the
11
+ * reader changed - at which point citation started refusing excerpts for the very events
12
+ * the reader was citing, and the differential test kept passing because its fixtures never
13
+ * set a grant.
14
+ *
15
+ * The pre-grant rule below is retained for callers that hold no channel or connector-wide
16
+ * grant. Connector-wide authority is stated by the principal, not by the tool payload,
17
+ * and mirrors the owner's stored-source read path. This matters for unscoped rows:
18
+ * denying them outright would make provenance useless for most of the corpus.
19
+ */
20
+ import type { DatabaseAdapter } from '../db-manager.js';
21
+ import type { MemoryScopeRef } from './types.js';
22
+ import { type ChannelGrant } from '../knowledge/access.js';
23
+ import { type IndexedEvent, type ParsedSourceRef, type ProvenanceResolution } from './provenance-resolver.js';
24
+ /** The columns the predicate needs. Shared so a test reads exactly what production does. */
25
+ /**
26
+ * The evidence columns, read from observations under the names the resolver uses.
27
+ *
28
+ * This selected them from the connector event index, which is how "what does this
29
+ * memory rest on" came to require the connector package. An observation is what a
30
+ * judgment rests on, and it is the core's own table.
31
+ */
32
+ export declare const OBSERVATION_COLUMNS = "observation_id AS event_index_id, source AS source_connector,\n source_id, channel, body AS content, observed_at, source_at,\n memory_scope_kind, memory_scope_id, project_id, tenant_id";
33
+ export interface EventRow {
34
+ event_index_id: unknown;
35
+ source_connector: unknown;
36
+ source_id: unknown;
37
+ channel: unknown;
38
+ content: unknown;
39
+ observed_at: unknown;
40
+ source_at: unknown;
41
+ memory_scope_kind: unknown;
42
+ memory_scope_id: unknown;
43
+ project_id: unknown;
44
+ tenant_id: unknown;
45
+ }
46
+ export interface LiveProvenanceOptions {
47
+ /** Scopes active NOW. Not the scopes the memory was written under. */
48
+ scopes: MemoryScopeRef[];
49
+ /** Raw connectors this caller may read. Empty means NO raw events, never all. */
50
+ connectors: readonly string[];
51
+ /** Connector-wide read authority stated by the principal, never by tool input. */
52
+ wideConnectors?: readonly string[];
53
+ /** Exact caller for durable scheduled/native input support visibility. */
54
+ principalId?: string;
55
+ /**
56
+ * The channels of each connector this caller may read, when the caller holds a grant.
57
+ * Present means the grant decides, exactly as it does in the reader. Absent means the
58
+ * pre-grant rule applies, so a caller that has not been given one is unaffected.
59
+ */
60
+ channels?: ChannelGrant;
61
+ /** Project and tenant window, mirroring the reader's filters on the same columns. */
62
+ projectIds?: readonly string[];
63
+ tenantId?: string | null;
64
+ /**
65
+ * Visibility clamp on observation time, in epoch ms. Only the MAX is threaded from the
66
+ * call site, deliberately: the reader's lower bound comes solely from `range.start_ms`,
67
+ * which is caller-chosen narrowing, while the upper bound folds in `as_of`, which is an
68
+ * authority clamp. A future reader should not "fix" the asymmetry. The reader bounds raw candidates
69
+ * by `COALESCE(event_datetime, source_timestamp_ms)`; without a counterpart here, an
70
+ * `as_of` boundary would hold for reading and not for citation. Nothing assigns
71
+ * `envelope.scope.as_of` today, so these are null in practice - implemented now
72
+ * because a filter with no counterpart is exactly the shape the tenant leak had.
73
+ */
74
+ minObservedMs?: number | null;
75
+ maxObservedMs?: number | null;
76
+ /** Inclusive source/event-time ceiling for replay visibility. */
77
+ maxSourceMs?: number | null;
78
+ excerptChars?: number;
79
+ /** Redaction to apply to excerpts, so this surface scrubs what recall scrubs. */
80
+ redact?: (text: string) => string;
81
+ }
82
+ /**
83
+ * Parse a stored source ref into what it actually is.
84
+ *
85
+ * The shapes here were measured, not guessed. Of the source refs on this machine 13,403
86
+ * are `memory:`, 1,748 are `envelope:`, 9 are `message:` and none are `raw:`. An earlier
87
+ * version of this parser understood only `raw:` and reported every real memory as
88
+ * `unsupported_ref` - a tool that was wired, callable, and answered nothing.
89
+ */
90
+ export declare function parseSourceRef(ref: string): ParsedSourceRef;
91
+ /**
92
+ * Whether an event may be shown under the authority active now.
93
+ *
94
+ * When a channel grant is supplied this DELEGATES to the shared rule rather than copying
95
+ * it. The previous version copied the reader clause for clause and said so in a comment,
96
+ * which held until the reader changed - then the copy silently became a different rule
97
+ * that refused excerpts for the very events the reader was citing. The differential test
98
+ * meant to catch that kept passing, because its fixtures never set a grant.
99
+ *
100
+ * "A shared predicate would be better than a faithful copy" is what the old comment here
101
+ * said. It was right.
102
+ *
103
+ * Without a grant the pre-grant rule still applies, so callers that have not been given
104
+ * one behave exactly as before.
105
+ */
106
+ export declare function isEventVisibleNow(event: IndexedEvent, options: {
107
+ scopes: readonly MemoryScopeRef[];
108
+ connectors: readonly string[];
109
+ wideConnectors?: readonly string[];
110
+ channels?: ChannelGrant;
111
+ projectIds?: readonly string[];
112
+ tenantId?: string | null;
113
+ minObservedMs?: number | null;
114
+ maxObservedMs?: number | null;
115
+ maxSourceMs?: number | null;
116
+ }): boolean;
117
+ /**
118
+ * Row to the struct the predicate judges.
119
+ *
120
+ * Exported because it is the layer BELOW the predicate, and a differential that
121
+ * hand-builds its own struct proves the predicate mirrors the reader while leaving this
122
+ * mapping unjudged - which is where a scope-column coercion bug already lived once.
123
+ */
124
+ export declare function toIndexedEvent(row: EventRow): IndexedEvent;
125
+ /**
126
+ * Whether a message ref may be named.
127
+ *
128
+ * `sourceMessageRef` is built as `source:channelId:turnId` (message-router.ts), and a
129
+ * channel scope id as `source:channelId` (scope-context.ts) - so a ref belongs to a
130
+ * caller's channel exactly when an active channel scope is its prefix. Compared as a
131
+ * prefix rather than parsed, because a turn id can itself contain a colon
132
+ * (`generated:<uuid>`) and splitting on the last one would silently mis-attribute it.
133
+ *
134
+ * This matters beyond tidiness: every memory carrying such a ref is also bound to
135
+ * global:system, which every caller holds, so an unchecked ref handed a private channel
136
+ * identifier to any agent that could read the memory at all.
137
+ */
138
+ export declare function isMessageRefVisible(ref: string, scopes: readonly MemoryScopeRef[]): boolean;
139
+ /** Resolve one memory's support against the live index and the scopes active now. */
140
+ export declare function resolveMemoryProvenanceLive(adapter: DatabaseAdapter, memoryId: string, options: LiveProvenanceOptions): Promise<ProvenanceResolution>;
141
+ //# sourceMappingURL=provenance-live.d.ts.map