nox-mem 3.1.1 → 3.2.1

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 (398) hide show
  1. package/README.md +24 -16
  2. package/dist/__tests__/brief-diversity.test.js +266 -0
  3. package/dist/__tests__/brief.test.js +287 -0
  4. package/dist/__tests__/churn.test.js +66 -0
  5. package/dist/__tests__/edge-typing.test.js +99 -0
  6. package/dist/__tests__/ingest-event.test.js +151 -0
  7. package/dist/__tests__/op-audit-e2e.test.js +130 -0
  8. package/dist/__tests__/pragma-alignment.test.js +123 -0
  9. package/dist/__tests__/reranker.test.js +326 -0
  10. package/dist/__tests__/retention.test.js +99 -0
  11. package/dist/__tests__/search-track-access.test.js +49 -0
  12. package/dist/__tests__/spo-injection.test.js +172 -0
  13. package/dist/__tests__/temporal-detector.test.js +103 -0
  14. package/dist/api/wire-up.js +12 -381
  15. package/dist/api-server.js +6 -102
  16. package/dist/crystallize.js +3 -5
  17. package/dist/db.js +61 -2
  18. package/dist/embed.js +23 -2
  19. package/dist/index.js +1 -22
  20. package/dist/knowledge-graph.js +20 -0
  21. package/dist/lib/answer/__tests__/e2e-gemini.test.js +229 -0
  22. package/dist/lib/answer/__tests__/integration-sqlite.test.js +388 -0
  23. package/dist/lib/answer/__tests__/integration.test.js +347 -0
  24. package/dist/lib/answer/__tests__/prompt.test.js +117 -0
  25. package/dist/lib/answer/__tests__/t5-t10.test.js +501 -0
  26. package/dist/lib/answer/provider.js +29 -4
  27. package/dist/lib/api/__tests__/safe-error-message.test.js +155 -0
  28. package/dist/lib/auth/__tests__/localhost-guard.test.js +144 -0
  29. package/dist/lib/error-sanitizer/__tests__/sanitize.test.js +354 -0
  30. package/dist/lib/events/__tests__/bus.test.js +208 -0
  31. package/dist/lib/ingest-router.js +0 -43
  32. package/dist/lib/op-audit-extension/__tests__/ran-at-guard.test.js +109 -0
  33. package/dist/lib/regex-extract/__tests__/extractor.test.js +197 -0
  34. package/dist/lib/regex-extract/__tests__/frontmatter.test.js +75 -0
  35. package/dist/lib/regex-extract/__tests__/ingest-router-l4.test.js +139 -0
  36. package/dist/lib/regex-extract/__tests__/production-wire.test.js +177 -0
  37. package/dist/lib/regex-extract/__tests__/reconcile.test.js +170 -0
  38. package/dist/lib/regex-extract/__tests__/strip-code.test.js +36 -0
  39. package/dist/privacy/__tests__/filter.test.js +352 -0
  40. package/dist/providers/__tests__/conformance-extended.test.js +249 -0
  41. package/dist/providers/__tests__/conformance.test.js +98 -0
  42. package/dist/providers/__tests__/cost-cap.test.js +151 -0
  43. package/dist/providers/__tests__/e2e-real.test.js +79 -0
  44. package/dist/providers/__tests__/factory.test.js +80 -0
  45. package/dist/providers/__tests__/fallback.test.js +223 -0
  46. package/dist/providers/__tests__/gemini.test.js +191 -0
  47. package/dist/providers/__tests__/health.test.js +128 -0
  48. package/dist/providers/__tests__/telemetry.test.js +219 -0
  49. package/dist/reindex.js +2 -2
  50. package/package.json +3 -4
  51. package/dist/api/answer.d.ts +0 -116
  52. package/dist/api/answer.validate-patch.d.ts +0 -72
  53. package/dist/api/brief-diversity.d.ts +0 -64
  54. package/dist/api/brief.d.ts +0 -114
  55. package/dist/api/conflict.d.ts +0 -33
  56. package/dist/api/conflict.js +0 -143
  57. package/dist/api/cors.d.ts +0 -73
  58. package/dist/api/events-stream-limited.d.ts +0 -133
  59. package/dist/api/events-stream-limited.js +0 -217
  60. package/dist/api/events-stream.d.ts +0 -53
  61. package/dist/api/events-stream.js +0 -125
  62. package/dist/api/export.d.ts +0 -42
  63. package/dist/api/export.js +0 -85
  64. package/dist/api/health-confidence-adapter.d.ts +0 -29
  65. package/dist/api/health-confidence-adapter.js +0 -73
  66. package/dist/api/health-confidence.d.ts +0 -36
  67. package/dist/api/health-confidence.js +0 -141
  68. package/dist/api/hooks.d.ts +0 -50
  69. package/dist/api/hooks.js +0 -115
  70. package/dist/api/import.d.ts +0 -38
  71. package/dist/api/import.js +0 -87
  72. package/dist/api/ingest-event.d.ts +0 -65
  73. package/dist/api/mark.d.ts +0 -42
  74. package/dist/api/mark.js +0 -127
  75. package/dist/api/server-deps-a2.d.ts +0 -55
  76. package/dist/api/server-deps-a2.js +0 -138
  77. package/dist/api/server-deps-l2-l3.d.ts +0 -68
  78. package/dist/api/server-deps-l2-l3.js +0 -123
  79. package/dist/api/server-deps-p1.d.ts +0 -84
  80. package/dist/api/server-deps-p2.d.ts +0 -32
  81. package/dist/api/server-deps-p2.js +0 -84
  82. package/dist/api/server-deps-p5.d.ts +0 -66
  83. package/dist/api/server-deps-p5.js +0 -139
  84. package/dist/api/viewer-static.d.ts +0 -30
  85. package/dist/api/viewer-static.js +0 -102
  86. package/dist/api/wire-up.d.ts +0 -54
  87. package/dist/api-impact.d.ts +0 -30
  88. package/dist/api-server.d.ts +0 -2
  89. package/dist/backfill-fts-anchor.d.ts +0 -15
  90. package/dist/backfill-source-type.d.ts +0 -20
  91. package/dist/churn.d.ts +0 -31
  92. package/dist/cli/answer.d.ts +0 -66
  93. package/dist/cli/conflict.d.ts +0 -38
  94. package/dist/cli/conflict.js +0 -282
  95. package/dist/cli/export.d.ts +0 -51
  96. package/dist/cli/export.js +0 -280
  97. package/dist/cli/hooks.d.ts +0 -54
  98. package/dist/cli/hooks.js +0 -133
  99. package/dist/cli/import.d.ts +0 -52
  100. package/dist/cli/import.js +0 -274
  101. package/dist/cli/mark.d.ts +0 -33
  102. package/dist/cli/mark.js +0 -130
  103. package/dist/cli/ocr-batch.d.ts +0 -12
  104. package/dist/cli/ocr-batch.js +0 -411
  105. package/dist/cli/snapshot-main.d.ts +0 -30
  106. package/dist/cli/snapshot-main.js +0 -47
  107. package/dist/cli/viewer.d.ts +0 -35
  108. package/dist/cli/viewer.js +0 -71
  109. package/dist/cli-telemetry.d.ts +0 -36
  110. package/dist/cli-telemetry.js +0 -150
  111. package/dist/compact.d.ts +0 -7
  112. package/dist/consolidate.d.ts +0 -18
  113. package/dist/consolidation.d.ts +0 -32
  114. package/dist/cross-agent-v2.d.ts +0 -45
  115. package/dist/cross-search.d.ts +0 -11
  116. package/dist/crystallize.d.ts +0 -43
  117. package/dist/db.d.ts +0 -11
  118. package/dist/dedup.d.ts +0 -1
  119. package/dist/detect-changes.d.ts +0 -29
  120. package/dist/digest.d.ts +0 -1
  121. package/dist/doctor.d.ts +0 -1
  122. package/dist/embed.d.ts +0 -57
  123. package/dist/evals.d.ts +0 -176
  124. package/dist/evals.js +0 -351
  125. package/dist/generate-user-profile.d.ts +0 -18
  126. package/dist/graphify-ingest.d.ts +0 -18
  127. package/dist/impact.d.ts +0 -39
  128. package/dist/index.d.ts +0 -2
  129. package/dist/ingest-entity.d.ts +0 -44
  130. package/dist/ingest.d.ts +0 -13
  131. package/dist/kg-llm.d.ts +0 -39
  132. package/dist/knowledge-graph.d.ts +0 -72
  133. package/dist/lib/answer/config.d.ts +0 -41
  134. package/dist/lib/answer/index.d.ts +0 -47
  135. package/dist/lib/answer/prompt.d.ts +0 -37
  136. package/dist/lib/answer/provider.d.ts +0 -47
  137. package/dist/lib/answer/retrieval.d.ts +0 -36
  138. package/dist/lib/answer/telemetry.d.ts +0 -99
  139. package/dist/lib/answer/types.d.ts +0 -108
  140. package/dist/lib/api/error-leak-fix.d.ts +0 -54
  141. package/dist/lib/api/safe-error-message.d.ts +0 -70
  142. package/dist/lib/archive/common-passwords.d.ts +0 -37
  143. package/dist/lib/archive/common-passwords.js +0 -753
  144. package/dist/lib/archive/encryption.d.ts +0 -81
  145. package/dist/lib/archive/encryption.js +0 -236
  146. package/dist/lib/archive/enforce-strength.d.ts +0 -54
  147. package/dist/lib/archive/enforce-strength.js +0 -70
  148. package/dist/lib/archive/entropy.d.ts +0 -34
  149. package/dist/lib/archive/entropy.js +0 -180
  150. package/dist/lib/archive/export-locking.d.ts +0 -102
  151. package/dist/lib/archive/export-locking.js +0 -202
  152. package/dist/lib/archive/format.d.ts +0 -20
  153. package/dist/lib/archive/format.js +0 -174
  154. package/dist/lib/archive/index.d.ts +0 -23
  155. package/dist/lib/archive/index.js +0 -17
  156. package/dist/lib/archive/manifest.d.ts +0 -53
  157. package/dist/lib/archive/manifest.js +0 -183
  158. package/dist/lib/archive/migration.d.ts +0 -36
  159. package/dist/lib/archive/migration.js +0 -100
  160. package/dist/lib/archive/migrations/v18_to_v19.d.ts +0 -16
  161. package/dist/lib/archive/migrations/v18_to_v19.js +0 -18
  162. package/dist/lib/archive/orchestrator.d.ts +0 -166
  163. package/dist/lib/archive/orchestrator.js +0 -428
  164. package/dist/lib/archive/serializers/chunks.d.ts +0 -30
  165. package/dist/lib/archive/serializers/chunks.js +0 -113
  166. package/dist/lib/archive/serializers/embeddings.d.ts +0 -36
  167. package/dist/lib/archive/serializers/embeddings.js +0 -115
  168. package/dist/lib/archive/serializers/kg.d.ts +0 -28
  169. package/dist/lib/archive/serializers/kg.js +0 -184
  170. package/dist/lib/archive/serializers/ops_audit.d.ts +0 -21
  171. package/dist/lib/archive/serializers/ops_audit.js +0 -97
  172. package/dist/lib/archive/server-deps.d.ts +0 -131
  173. package/dist/lib/archive/server-deps.js +0 -232
  174. package/dist/lib/archive/strength.d.ts +0 -50
  175. package/dist/lib/archive/strength.js +0 -77
  176. package/dist/lib/archive/types.d.ts +0 -159
  177. package/dist/lib/archive/types.js +0 -45
  178. package/dist/lib/archive/unpack-streaming.d.ts +0 -70
  179. package/dist/lib/archive/unpack-streaming.js +0 -255
  180. package/dist/lib/auth/localhost-guard.d.ts +0 -106
  181. package/dist/lib/confidence/config.d.ts +0 -37
  182. package/dist/lib/confidence/config.js +0 -107
  183. package/dist/lib/confidence/db-shim-singleton.d.ts +0 -20
  184. package/dist/lib/confidence/db-shim-singleton.js +0 -41
  185. package/dist/lib/confidence/db-shim.d.ts +0 -47
  186. package/dist/lib/confidence/db-shim.js +0 -141
  187. package/dist/lib/confidence/mark.d.ts +0 -58
  188. package/dist/lib/confidence/mark.js +0 -168
  189. package/dist/lib/confidence/ranking.d.ts +0 -69
  190. package/dist/lib/confidence/ranking.js +0 -101
  191. package/dist/lib/confidence/search-filter.d.ts +0 -44
  192. package/dist/lib/confidence/search-filter.js +0 -103
  193. package/dist/lib/confidence/types.d.ts +0 -146
  194. package/dist/lib/confidence/types.js +0 -20
  195. package/dist/lib/confidence/write-hooks.d.ts +0 -50
  196. package/dist/lib/confidence/write-hooks.js +0 -159
  197. package/dist/lib/conflict/audit-fk-check.d.ts +0 -72
  198. package/dist/lib/conflict/audit-fk-check.js +0 -131
  199. package/dist/lib/conflict/audit-writer.d.ts +0 -39
  200. package/dist/lib/conflict/audit-writer.js +0 -133
  201. package/dist/lib/conflict/db-singleton.d.ts +0 -28
  202. package/dist/lib/conflict/db-singleton.js +0 -61
  203. package/dist/lib/conflict/db.d.ts +0 -27
  204. package/dist/lib/conflict/db.js +0 -20
  205. package/dist/lib/conflict/detector-direct.d.ts +0 -21
  206. package/dist/lib/conflict/detector-direct.js +0 -105
  207. package/dist/lib/conflict/evidence.d.ts +0 -24
  208. package/dist/lib/conflict/evidence.js +0 -76
  209. package/dist/lib/conflict/index.d.ts +0 -14
  210. package/dist/lib/conflict/index.js +0 -12
  211. package/dist/lib/conflict/scheduler.d.ts +0 -78
  212. package/dist/lib/conflict/scheduler.js +0 -111
  213. package/dist/lib/conflict/shadow.d.ts +0 -75
  214. package/dist/lib/conflict/shadow.js +0 -161
  215. package/dist/lib/conflict/types.d.ts +0 -133
  216. package/dist/lib/conflict/types.js +0 -19
  217. package/dist/lib/cost-cap.d.ts +0 -94
  218. package/dist/lib/deps/deps-registry.d.ts +0 -111
  219. package/dist/lib/error-sanitizer/middleware.d.ts +0 -43
  220. package/dist/lib/error-sanitizer/sanitize.d.ts +0 -78
  221. package/dist/lib/eval-batch.d.ts +0 -34
  222. package/dist/lib/eval-batch.js +0 -103
  223. package/dist/lib/eval-metrics.d.ts +0 -36
  224. package/dist/lib/eval-metrics.js +0 -95
  225. package/dist/lib/eval.d.ts +0 -106
  226. package/dist/lib/eval.js +0 -343
  227. package/dist/lib/events/bus.d.ts +0 -135
  228. package/dist/lib/fts-anchor.d.ts +0 -1
  229. package/dist/lib/hooks/classifier.d.ts +0 -47
  230. package/dist/lib/hooks/classifier.js +0 -129
  231. package/dist/lib/hooks/config.d.ts +0 -49
  232. package/dist/lib/hooks/config.js +0 -106
  233. package/dist/lib/hooks/decorators.d.ts +0 -35
  234. package/dist/lib/hooks/decorators.js +0 -59
  235. package/dist/lib/hooks/pipeline.d.ts +0 -76
  236. package/dist/lib/hooks/pipeline.js +0 -213
  237. package/dist/lib/hooks/privacy-filter-adapter.d.ts +0 -55
  238. package/dist/lib/hooks/privacy-filter-adapter.js +0 -84
  239. package/dist/lib/hooks/rate-limit-constant-time.d.ts +0 -57
  240. package/dist/lib/hooks/rate-limit-constant-time.js +0 -69
  241. package/dist/lib/hooks/rate-limit-dryrun-fix.d.ts +0 -71
  242. package/dist/lib/hooks/rate-limit-dryrun-fix.js +0 -110
  243. package/dist/lib/hooks/rate-limit.d.ts +0 -54
  244. package/dist/lib/hooks/rate-limit.js +0 -122
  245. package/dist/lib/hooks/server-deps.d.ts +0 -61
  246. package/dist/lib/hooks/server-deps.js +0 -92
  247. package/dist/lib/hooks/source-allowlist.d.ts +0 -26
  248. package/dist/lib/hooks/source-allowlist.js +0 -53
  249. package/dist/lib/hooks/types.d.ts +0 -129
  250. package/dist/lib/hooks/types.js +0 -24
  251. package/dist/lib/hooks/worker.d.ts +0 -56
  252. package/dist/lib/hooks/worker.js +0 -150
  253. package/dist/lib/ingest-router.d.ts +0 -25
  254. package/dist/lib/ocr-detector.d.ts +0 -61
  255. package/dist/lib/ocr-detector.js +0 -138
  256. package/dist/lib/ocr-engine-stub.d.ts +0 -48
  257. package/dist/lib/ocr-engine-stub.js +0 -190
  258. package/dist/lib/ocr-engines/google-doc-ai.d.ts +0 -36
  259. package/dist/lib/ocr-engines/google-doc-ai.js +0 -164
  260. package/dist/lib/ocr-jobs.d.ts +0 -67
  261. package/dist/lib/ocr-jobs.js +0 -129
  262. package/dist/lib/op-audit-extension/ran-at-guard.d.ts +0 -86
  263. package/dist/lib/op-audit.d.ts +0 -71
  264. package/dist/lib/privacy-br/detector.d.ts +0 -42
  265. package/dist/lib/privacy-br/detector.js +0 -130
  266. package/dist/lib/privacy-br/index.d.ts +0 -20
  267. package/dist/lib/privacy-br/index.js +0 -20
  268. package/dist/lib/privacy-br/integration.d.ts +0 -71
  269. package/dist/lib/privacy-br/integration.js +0 -74
  270. package/dist/lib/privacy-br/patterns.d.ts +0 -117
  271. package/dist/lib/privacy-br/patterns.js +0 -434
  272. package/dist/lib/privacy-br/redact.d.ts +0 -42
  273. package/dist/lib/privacy-br/redact.js +0 -103
  274. package/dist/lib/privacy-br/types.d.ts +0 -55
  275. package/dist/lib/privacy-br/types.js +0 -25
  276. package/dist/lib/regex-extract/extractor.d.ts +0 -30
  277. package/dist/lib/regex-extract/frontmatter.d.ts +0 -44
  278. package/dist/lib/regex-extract/index.d.ts +0 -14
  279. package/dist/lib/regex-extract/ingest-router-l4.d.ts +0 -76
  280. package/dist/lib/regex-extract/patterns.d.ts +0 -61
  281. package/dist/lib/regex-extract/production-wire.d.ts +0 -128
  282. package/dist/lib/regex-extract/reconcile.d.ts +0 -162
  283. package/dist/lib/regex-extract/strip-code.d.ts +0 -24
  284. package/dist/lib/regex-extract/types.d.ts +0 -48
  285. package/dist/lib/reranker.d.ts +0 -80
  286. package/dist/lib/shadow-tracker.d.ts +0 -191
  287. package/dist/lib/shadow-tracker.js +0 -384
  288. package/dist/lib/spo-injection.d.ts +0 -52
  289. package/dist/lib/telemetry-collector.d.ts +0 -158
  290. package/dist/lib/telemetry-collector.js +0 -249
  291. package/dist/lib/temporal-detector.d.ts +0 -27
  292. package/dist/lib/viewer/auth.d.ts +0 -37
  293. package/dist/lib/viewer/auth.js +0 -70
  294. package/dist/lib/viewer/backpressure.d.ts +0 -59
  295. package/dist/lib/viewer/backpressure.js +0 -100
  296. package/dist/lib/viewer/broadcast-singleton.d.ts +0 -34
  297. package/dist/lib/viewer/broadcast-singleton.js +0 -49
  298. package/dist/lib/viewer/broadcast.d.ts +0 -66
  299. package/dist/lib/viewer/broadcast.js +0 -96
  300. package/dist/lib/viewer/event-types.d.ts +0 -132
  301. package/dist/lib/viewer/event-types.js +0 -74
  302. package/dist/lib/viewer/instrumentation.d.ts +0 -106
  303. package/dist/lib/viewer/instrumentation.js +0 -224
  304. package/dist/lib/viewer/migration.d.ts +0 -23
  305. package/dist/lib/viewer/migration.js +0 -56
  306. package/dist/lib/viewer/redaction.d.ts +0 -44
  307. package/dist/lib/viewer/redaction.js +0 -139
  308. package/dist/lib/viewer/session.d.ts +0 -51
  309. package/dist/lib/viewer/session.js +0 -87
  310. package/dist/mcp/tools/answer.d.ts +0 -94
  311. package/dist/mcp/tools/archive.d.ts +0 -152
  312. package/dist/mcp/tools/archive.js +0 -170
  313. package/dist/mcp/tools/conflict.d.ts +0 -44
  314. package/dist/mcp/tools/conflict.js +0 -130
  315. package/dist/mcp/tools/hooks.d.ts +0 -29
  316. package/dist/mcp/tools/hooks.js +0 -78
  317. package/dist/mcp/tools/mark.d.ts +0 -38
  318. package/dist/mcp/tools/mark.js +0 -82
  319. package/dist/mcp/tools/viewer.d.ts +0 -58
  320. package/dist/mcp/tools/viewer.js +0 -64
  321. package/dist/mcp-server.d.ts +0 -2
  322. package/dist/metrics.d.ts +0 -3
  323. package/dist/noise-filter.d.ts +0 -18
  324. package/dist/notion-sync.d.ts +0 -7
  325. package/dist/notion-sync.js +0 -97
  326. package/dist/observability/adapters/a3-adapter.d.ts +0 -63
  327. package/dist/observability/adapters/a3-adapter.js +0 -83
  328. package/dist/observability/adapters/p1-adapter.d.ts +0 -49
  329. package/dist/observability/adapters/p1-adapter.js +0 -63
  330. package/dist/observability/adapters/p5-adapter.d.ts +0 -36
  331. package/dist/observability/adapters/p5-adapter.js +0 -71
  332. package/dist/observability/cardinality.d.ts +0 -61
  333. package/dist/observability/cardinality.js +0 -300
  334. package/dist/observability/collectors/db-stats.collector.d.ts +0 -9
  335. package/dist/observability/collectors/db-stats.collector.js +0 -88
  336. package/dist/observability/collectors/eventbus.collector.d.ts +0 -6
  337. package/dist/observability/collectors/eventbus.collector.js +0 -50
  338. package/dist/observability/collectors/process.collector.d.ts +0 -7
  339. package/dist/observability/collectors/process.collector.js +0 -93
  340. package/dist/observability/collectors/provider-telemetry.collector.d.ts +0 -11
  341. package/dist/observability/collectors/provider-telemetry.collector.js +0 -112
  342. package/dist/observability/collectors/search-telemetry.collector.d.ts +0 -12
  343. package/dist/observability/collectors/search-telemetry.collector.js +0 -76
  344. package/dist/observability/exporter.d.ts +0 -30
  345. package/dist/observability/exporter.js +0 -182
  346. package/dist/observability/index.d.ts +0 -22
  347. package/dist/observability/index.js +0 -21
  348. package/dist/observability/metrics.d.ts +0 -53
  349. package/dist/observability/metrics.js +0 -213
  350. package/dist/observability/privacy-guard.d.ts +0 -32
  351. package/dist/observability/privacy-guard.js +0 -116
  352. package/dist/observability/record.d.ts +0 -83
  353. package/dist/observability/record.js +0 -217
  354. package/dist/observability/registry.d.ts +0 -60
  355. package/dist/observability/registry.js +0 -93
  356. package/dist/observability/types.d.ts +0 -115
  357. package/dist/observability/types.js +0 -235
  358. package/dist/observability.d.ts +0 -131
  359. package/dist/plugins/nox-hooks/index.d.ts +0 -61
  360. package/dist/plugins/nox-hooks/index.js +0 -99
  361. package/dist/primer.d.ts +0 -1
  362. package/dist/privacy/filter.d.ts +0 -27
  363. package/dist/privacy/patterns.d.ts +0 -29
  364. package/dist/privacy/tag-parser.d.ts +0 -24
  365. package/dist/project-context-gen.d.ts +0 -10
  366. package/dist/providers/embedding/gemini.d.ts +0 -73
  367. package/dist/providers/embedding/openai.d.ts +0 -76
  368. package/dist/providers/embedding/types.d.ts +0 -39
  369. package/dist/providers/embedding/voyage.d.ts +0 -36
  370. package/dist/providers/index.d.ts +0 -116
  371. package/dist/providers/llm/anthropic.d.ts +0 -29
  372. package/dist/providers/llm/chain.d.ts +0 -99
  373. package/dist/providers/llm/gemini.d.ts +0 -48
  374. package/dist/providers/llm/openai.d.ts +0 -64
  375. package/dist/providers/llm/types.d.ts +0 -47
  376. package/dist/providers/telemetry.d.ts +0 -87
  377. package/dist/providers/types.d.ts +0 -42
  378. package/dist/query-entity-count.d.ts +0 -54
  379. package/dist/reflect.d.ts +0 -26
  380. package/dist/reindex-errors.d.ts +0 -7
  381. package/dist/reindex.d.ts +0 -16
  382. package/dist/retention.d.ts +0 -40
  383. package/dist/salience.d.ts +0 -85
  384. package/dist/scripts/migrate-v17-ops-audit.d.ts +0 -17
  385. package/dist/search-dedup.d.ts +0 -44
  386. package/dist/search-expansion.d.ts +0 -20
  387. package/dist/search.d.ts +0 -62
  388. package/dist/seh-detector.d.ts +0 -31
  389. package/dist/self-improve.d.ts +0 -1
  390. package/dist/session-distill.d.ts +0 -29
  391. package/dist/session-update.d.ts +0 -1
  392. package/dist/shared-memory.d.ts +0 -24
  393. package/dist/stats.d.ts +0 -1
  394. package/dist/temporal-retrieval.d.ts +0 -132
  395. package/dist/tier-manager.d.ts +0 -69
  396. package/dist/vectorize.d.ts +0 -16
  397. package/dist/version.d.ts +0 -1
  398. package/dist/watch.d.ts +0 -8
@@ -1,100 +0,0 @@
1
- /**
2
- * T9 — Backpressure ring buffer
3
- *
4
- * Bounded queue per SSE client. Producer pushes events; consumer drains.
5
- * If consumer is slow and buffer hits capacity, OLDEST event is dropped
6
- * (not the new one) so the recent stream stays current. Producer NEVER
7
- * blocks — drop counter is incremented and exposed via `stats()`.
8
- *
9
- * Design:
10
- * - O(1) push + drain via circular buffer (Array-backed deque)
11
- * - No locks (single-threaded JS); concurrency safe wrt the event loop
12
- * - Stats are read-only snapshots
13
- */
14
- export class BackpressureQueue {
15
- capacity;
16
- buf;
17
- head = 0;
18
- tail = 0;
19
- size_ = 0;
20
- dropped_ = 0;
21
- enqueued_ = 0;
22
- constructor(capacity) {
23
- this.capacity = capacity;
24
- if (capacity <= 0 || !Number.isFinite(capacity)) {
25
- throw new Error(`BackpressureQueue capacity must be > 0, got ${capacity}`);
26
- }
27
- this.buf = new Array(capacity);
28
- }
29
- /**
30
- * Push an item. Returns:
31
- * - "ok" if buffered
32
- * - "dropped_oldest" if buffer was full and oldest was evicted to make room
33
- */
34
- push(item) {
35
- this.enqueued_ += 1;
36
- if (this.size_ === this.capacity) {
37
- // Drop oldest by advancing head.
38
- this.buf[this.head] = undefined;
39
- this.head = (this.head + 1) % this.capacity;
40
- this.size_ -= 1;
41
- this.dropped_ += 1;
42
- // continue to insert new at tail
43
- }
44
- this.buf[this.tail] = item;
45
- this.tail = (this.tail + 1) % this.capacity;
46
- this.size_ += 1;
47
- return this.dropped_ > 0 && this.size_ === this.capacity ? "dropped_oldest" : "ok";
48
- }
49
- /** Pop oldest item. Undefined if empty. */
50
- shift() {
51
- if (this.size_ === 0)
52
- return undefined;
53
- const out = this.buf[this.head];
54
- this.buf[this.head] = undefined;
55
- this.head = (this.head + 1) % this.capacity;
56
- this.size_ -= 1;
57
- return out;
58
- }
59
- /** Drain up to `max` items into an array. */
60
- drain(max = Infinity) {
61
- const out = [];
62
- let n = 0;
63
- while (this.size_ > 0 && n < max) {
64
- const item = this.shift();
65
- if (item !== undefined)
66
- out.push(item);
67
- n += 1;
68
- }
69
- return out;
70
- }
71
- get length() {
72
- return this.size_;
73
- }
74
- stats() {
75
- return {
76
- size: this.size_,
77
- dropped: this.dropped_,
78
- enqueued: this.enqueued_,
79
- capacity: this.capacity,
80
- };
81
- }
82
- /** Reset to empty. Counters preserved unless `hard=true`. */
83
- clear(hard = false) {
84
- this.head = 0;
85
- this.tail = 0;
86
- this.size_ = 0;
87
- this.buf = new Array(this.capacity);
88
- if (hard) {
89
- this.dropped_ = 0;
90
- this.enqueued_ = 0;
91
- }
92
- }
93
- }
94
- export function isSinkSaturated(sink) {
95
- const len = sink.writableLength;
96
- const hwm = sink.writableHighWaterMark;
97
- if (typeof len !== "number" || typeof hwm !== "number")
98
- return false;
99
- return len >= hwm;
100
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * src/lib/viewer/broadcast-singleton.ts — Wave O T3 (part 1).
3
- *
4
- * Wire-up.ts (#92, line 312) calls `brMod.getBroadcaster()` SYNCHRONOUSLY.
5
- * The lazy `await import("../lib/viewer/broadcast.js")` at the route entry
6
- * resolves the module; after that, `getBroadcaster()` must return the
7
- * instance immediately.
8
- *
9
- * Implementation:
10
- * - Top-level await resolves the staged-P5 `Broadcaster` ctor at module
11
- * load. Once `import("../lib/viewer/broadcast.js")` finishes in wire-up,
12
- * this file (re-exported from `broadcast.js`) is already initialized.
13
- * - `getBroadcaster()` is sync — returns the cached instance.
14
- * - When the ctor isn't loadable (staged-P5 not deployed), the wire-up's
15
- * `if (!brMod || typeof brMod.getBroadcaster !== "function")` branch
16
- * handles 503 directly because we throw at module load → outer
17
- * `tryImport` swallows → null module → 503 path.
18
- *
19
- * After rsync, `broadcast.ts` (staged-P5) gets ONE appended line:
20
- *
21
- * export { getBroadcaster, resetBroadcasterForTests } from "./broadcast-singleton.js";
22
- *
23
- * This keeps the wire-up's lazy-import semantics intact.
24
- */
25
- /**
26
- * Sync accessor — returns the singleton Broadcaster. Creates on first call.
27
- * Wire-up.ts calls this without await; do not change the signature.
28
- */
29
- export declare function getBroadcaster(opts?: {
30
- ringCapacity?: number;
31
- clientCapacity?: number;
32
- }): any;
33
- /** Drop the singleton — test-only. */
34
- export declare function resetBroadcasterForTests(): void;
@@ -1,49 +0,0 @@
1
- /**
2
- * src/lib/viewer/broadcast-singleton.ts — Wave O T3 (part 1).
3
- *
4
- * Wire-up.ts (#92, line 312) calls `brMod.getBroadcaster()` SYNCHRONOUSLY.
5
- * The lazy `await import("../lib/viewer/broadcast.js")` at the route entry
6
- * resolves the module; after that, `getBroadcaster()` must return the
7
- * instance immediately.
8
- *
9
- * Implementation:
10
- * - Top-level await resolves the staged-P5 `Broadcaster` ctor at module
11
- * load. Once `import("../lib/viewer/broadcast.js")` finishes in wire-up,
12
- * this file (re-exported from `broadcast.js`) is already initialized.
13
- * - `getBroadcaster()` is sync — returns the cached instance.
14
- * - When the ctor isn't loadable (staged-P5 not deployed), the wire-up's
15
- * `if (!brMod || typeof brMod.getBroadcaster !== "function")` branch
16
- * handles 503 directly because we throw at module load → outer
17
- * `tryImport` swallows → null module → 503 path.
18
- *
19
- * After rsync, `broadcast.ts` (staged-P5) gets ONE appended line:
20
- *
21
- * export { getBroadcaster, resetBroadcasterForTests } from "./broadcast-singleton.js";
22
- *
23
- * This keeps the wire-up's lazy-import semantics intact.
24
- */
25
- // Top-level await — ESM allows this. Throws if the file is missing, which
26
- // propagates up to wire-up's `tryImport` (caught, mapped to 503).
27
- // String indirection — `./broadcast.js` is co-located only after staged-P5
28
- // is rsynced. TypeScript can't resolve at compile time; that's intentional.
29
- const BROADCAST_SPEC = "./broadcast.js";
30
- const _mod = await import(BROADCAST_SPEC);
31
- const _Broadcaster = _mod.Broadcaster ?? _mod.default?.Broadcaster;
32
- if (typeof _Broadcaster !== "function") {
33
- throw new Error("broadcast-singleton: Broadcaster class missing from ./broadcast.js");
34
- }
35
- let _instance = null;
36
- /**
37
- * Sync accessor — returns the singleton Broadcaster. Creates on first call.
38
- * Wire-up.ts calls this without await; do not change the signature.
39
- */
40
- export function getBroadcaster(opts) {
41
- if (_instance)
42
- return _instance;
43
- _instance = new _Broadcaster(opts);
44
- return _instance;
45
- }
46
- /** Drop the singleton — test-only. */
47
- export function resetBroadcasterForTests() {
48
- _instance = null;
49
- }
@@ -1,66 +0,0 @@
1
- /**
2
- * T10 — Multi-client broadcast
3
- *
4
- * Single source (instrumentation) → fan-out to N SSE clients.
5
- * Each client gets its own BackpressureQueue so a slow one cannot
6
- * stall fast ones (no head-of-line blocking).
7
- *
8
- * In addition to per-client queues, a SHARED ring buffer keeps the last
9
- * N events so reconnecting clients can resume via Last-Event-ID.
10
- */
11
- import { BackpressureQueue } from "./backpressure.js";
12
- import { type ViewerEvent } from "./event-types.js";
13
- export interface BroadcastEnvelope {
14
- /** Monotonic numeric id used in SSE `id:` line. */
15
- id: number;
16
- ev: ViewerEvent;
17
- }
18
- export interface ClientHandle {
19
- /** Globally unique id. */
20
- id: string;
21
- /** Per-client queue. */
22
- queue: BackpressureQueue<BroadcastEnvelope>;
23
- /** Last id sent to this client (for Last-Event-ID resume). */
24
- lastSentId: number;
25
- /** Notify hook — called when push happens (so consumer wakes up). */
26
- notify: () => void;
27
- }
28
- export interface BroadcasterOptions {
29
- /** Ring buffer (replay) capacity. Default 1000. */
30
- ringCapacity?: number;
31
- /** Per-client queue capacity. Default 100. */
32
- clientCapacity?: number;
33
- }
34
- export declare class Broadcaster {
35
- private readonly ring;
36
- private readonly clients;
37
- private nextId;
38
- readonly ringCapacity: number;
39
- readonly clientCapacity: number;
40
- constructor(opts?: BroadcasterOptions);
41
- /**
42
- * Publish an event. Updates ring buffer and pushes to all connected clients.
43
- * Each client backpressure is independent; producer never blocks.
44
- */
45
- publish(ev: ViewerEvent): BroadcastEnvelope;
46
- /**
47
- * Register a new SSE client. Returns the client handle for read access.
48
- * If `lastEventId` provided and within ring, the queue is pre-seeded with
49
- * the gap so client can resume.
50
- */
51
- addClient(id: string, notify: () => void, lastEventId?: number): ClientHandle;
52
- removeClient(id: string): void;
53
- /** Read current ring buffer snapshot (shallow copy). */
54
- ringSnapshot(): readonly BroadcastEnvelope[];
55
- /** Number of active clients. */
56
- clientCount(): number;
57
- /** Per-client stats. */
58
- clientStats(): Array<{
59
- id: string;
60
- queueSize: number;
61
- dropped: number;
62
- lastSentId: number;
63
- }>;
64
- /** Force-drop oldest envelopes globally (e.g. memory pressure). */
65
- trimRingTo(size: number): number;
66
- }
@@ -1,96 +0,0 @@
1
- /**
2
- * T10 — Multi-client broadcast
3
- *
4
- * Single source (instrumentation) → fan-out to N SSE clients.
5
- * Each client gets its own BackpressureQueue so a slow one cannot
6
- * stall fast ones (no head-of-line blocking).
7
- *
8
- * In addition to per-client queues, a SHARED ring buffer keeps the last
9
- * N events so reconnecting clients can resume via Last-Event-ID.
10
- */
11
- import { BackpressureQueue } from "./backpressure.js";
12
- export class Broadcaster {
13
- ring = [];
14
- clients = new Map();
15
- nextId = 1;
16
- ringCapacity;
17
- clientCapacity;
18
- constructor(opts = {}) {
19
- this.ringCapacity = opts.ringCapacity ?? 1000;
20
- this.clientCapacity = opts.clientCapacity ?? 100;
21
- }
22
- /**
23
- * Publish an event. Updates ring buffer and pushes to all connected clients.
24
- * Each client backpressure is independent; producer never blocks.
25
- */
26
- publish(ev) {
27
- const envelope = { id: this.nextId, ev };
28
- this.nextId += 1;
29
- this.ring.push(envelope);
30
- if (this.ring.length > this.ringCapacity) {
31
- this.ring.shift();
32
- }
33
- for (const client of this.clients.values()) {
34
- client.queue.push(envelope);
35
- try {
36
- client.notify();
37
- }
38
- catch {
39
- // Notification failure must never stop broadcast.
40
- }
41
- }
42
- return envelope;
43
- }
44
- /**
45
- * Register a new SSE client. Returns the client handle for read access.
46
- * If `lastEventId` provided and within ring, the queue is pre-seeded with
47
- * the gap so client can resume.
48
- */
49
- addClient(id, notify, lastEventId) {
50
- const queue = new BackpressureQueue(this.clientCapacity);
51
- const client = {
52
- id,
53
- queue,
54
- lastSentId: lastEventId ?? 0,
55
- notify,
56
- };
57
- this.clients.set(id, client);
58
- if (lastEventId !== undefined) {
59
- for (const env of this.ring) {
60
- if (env.id > lastEventId) {
61
- queue.push(env);
62
- }
63
- }
64
- }
65
- return client;
66
- }
67
- removeClient(id) {
68
- this.clients.delete(id);
69
- }
70
- /** Read current ring buffer snapshot (shallow copy). */
71
- ringSnapshot() {
72
- return this.ring.slice();
73
- }
74
- /** Number of active clients. */
75
- clientCount() {
76
- return this.clients.size;
77
- }
78
- /** Per-client stats. */
79
- clientStats() {
80
- return Array.from(this.clients.values()).map((c) => ({
81
- id: c.id,
82
- queueSize: c.queue.length,
83
- dropped: c.queue.stats().dropped,
84
- lastSentId: c.lastSentId,
85
- }));
86
- }
87
- /** Force-drop oldest envelopes globally (e.g. memory pressure). */
88
- trimRingTo(size) {
89
- let dropped = 0;
90
- while (this.ring.length > size) {
91
- this.ring.shift();
92
- dropped += 1;
93
- }
94
- return dropped;
95
- }
96
- }
@@ -1,132 +0,0 @@
1
- /**
2
- * T1 — Viewer Event Taxonomy
3
- *
4
- * Discriminated union of all events the viewer surfaces.
5
- * Each event has a stable shape: ts, type, source, summary, details.
6
- *
7
- * This is the **post-redaction** shape: payloads here are SAFE to send
8
- * over the wire. Raw chunk content, raw query text, embeddings, and
9
- * other sensitive fields are stripped upstream by `redaction.ts`.
10
- *
11
- * Schema v1 frozen — additive-only post-launch (new kinds OK, no rename/remove).
12
- */
13
- export type ViewerEventKind = "ingest" | "search" | "kg" | "crystallize" | "op_audit";
14
- export type ViewerEventSource = "ingest-router" | "ingest-watcher" | "search-hybrid" | "kg-extract" | "crystallize" | "op-audit" | "provider" | "health" | "unknown";
15
- export interface ViewerEventBase {
16
- /** ISO 8601 UTC timestamp, monotonic per type. */
17
- ts: string;
18
- /** Discriminator — high-level category. */
19
- type: ViewerEventKind;
20
- /** Where this event originated (module/subsystem). */
21
- source: ViewerEventSource;
22
- /** Short human-readable summary, 1 line, no secrets. */
23
- summary: string;
24
- }
25
- export interface IngestEventDetails {
26
- /** Chunk id from `chunks` table. */
27
- chunk_id: number;
28
- /** Type of chunk (entity/event/code/file/note/...). */
29
- chunk_kind: string;
30
- /** Character length of redacted content. */
31
- length: number;
32
- /** Count of redactions applied (privacy filter). */
33
- redaction_count: number;
34
- /** Section within entity file format (compiled/frontmatter/timeline/null). */
35
- section: string | null;
36
- /** Retention horizon (days) or null = never decay. */
37
- retention_days: number | null;
38
- /** Pain severity 0.1-1.0. */
39
- pain: number;
40
- /** Source file basename only — never full path. */
41
- source_basename?: string;
42
- }
43
- export interface IngestEvent extends ViewerEventBase {
44
- type: "ingest";
45
- details: IngestEventDetails;
46
- }
47
- export interface SearchEventDetails {
48
- /** sha256(query).slice(0,16) — for correlation without disclosure. */
49
- query_hash: string;
50
- /**
51
- * Raw query text. Present only if `NOX_VIEWER_SHOW_QUERY=1`.
52
- * Default "<redacted>".
53
- */
54
- query: string;
55
- /** Total wall latency in ms. */
56
- latency_ms: number;
57
- /** Requested top-k. */
58
- top_k: number;
59
- /** Number of results returned (post-fusion). */
60
- result_count: number;
61
- /** Search mode taken. */
62
- mode: "hybrid" | "fts" | "vector";
63
- /** Score breakdown by contribution channel (sum ≈ 1.0). */
64
- hybrid_breakdown: {
65
- bm25: number;
66
- vec: number;
67
- kg: number;
68
- };
69
- }
70
- export interface SearchEvent extends ViewerEventBase {
71
- type: "search";
72
- details: SearchEventDetails;
73
- }
74
- export interface KgEntityCreatedDetails {
75
- kg_kind: "entity_created";
76
- entity_id: number;
77
- entity_type: string;
78
- /** sha1(name).slice(0,8) — name never raw on wire. */
79
- name_hash: string;
80
- confidence: number;
81
- }
82
- export interface KgRelationCreatedDetails {
83
- kg_kind: "relation_created";
84
- relation_id: number;
85
- source_entity_id: number;
86
- target_entity_id: number;
87
- relation_type: string;
88
- confidence: number;
89
- }
90
- export type KgEventDetails = KgEntityCreatedDetails | KgRelationCreatedDetails;
91
- export interface KgEvent extends ViewerEventBase {
92
- type: "kg";
93
- details: KgEventDetails;
94
- }
95
- export interface CrystallizeEventDetails {
96
- /** Source chunks counted in the crystallized output. */
97
- source_chunk_count: number;
98
- /** Entity id receiving the crystallized output. */
99
- target_entity_id: number;
100
- /** Number of redactions applied in the compiled section. */
101
- redaction_count: number;
102
- /** Status (started/success/failed). */
103
- status: "started" | "success" | "failed";
104
- /** Wall duration in ms (success only). */
105
- duration_ms?: number;
106
- }
107
- export interface CrystallizeEvent extends ViewerEventBase {
108
- type: "crystallize";
109
- details: CrystallizeEventDetails;
110
- }
111
- export type OpAuditOp = "reindex" | "consolidate" | "compact" | "crystallize" | "kg-prune" | "viewer.connect" | "viewer.disconnect" | string;
112
- export interface OpAuditEventDetails {
113
- op_id: number | string;
114
- op: OpAuditOp;
115
- status: "started" | "success" | "failed" | "crashed";
116
- dry_run: boolean;
117
- duration_ms?: number;
118
- rows_affected?: number;
119
- }
120
- export interface OpAuditEvent extends ViewerEventBase {
121
- type: "op_audit";
122
- details: OpAuditEventDetails;
123
- }
124
- export type ViewerEvent = IngestEvent | SearchEvent | KgEvent | CrystallizeEvent | OpAuditEvent;
125
- export declare function isIngestEvent(ev: ViewerEvent): ev is IngestEvent;
126
- export declare function isSearchEvent(ev: ViewerEvent): ev is SearchEvent;
127
- export declare function isKgEvent(ev: ViewerEvent): ev is KgEvent;
128
- export declare function isCrystallizeEvent(ev: ViewerEvent): ev is CrystallizeEvent;
129
- export declare function isOpAuditEvent(ev: ViewerEvent): ev is OpAuditEvent;
130
- export declare function isValidViewerEvent(x: unknown): x is ViewerEvent;
131
- export declare function nowIso(): string;
132
- export declare function eventKindLabel(ev: ViewerEvent): string;
@@ -1,74 +0,0 @@
1
- /**
2
- * T1 — Viewer Event Taxonomy
3
- *
4
- * Discriminated union of all events the viewer surfaces.
5
- * Each event has a stable shape: ts, type, source, summary, details.
6
- *
7
- * This is the **post-redaction** shape: payloads here are SAFE to send
8
- * over the wire. Raw chunk content, raw query text, embeddings, and
9
- * other sensitive fields are stripped upstream by `redaction.ts`.
10
- *
11
- * Schema v1 frozen — additive-only post-launch (new kinds OK, no rename/remove).
12
- */
13
- // ─── Type guards (exhaustive, runtime-safe) ──────────────────────────────────
14
- export function isIngestEvent(ev) {
15
- return ev.type === "ingest";
16
- }
17
- export function isSearchEvent(ev) {
18
- return ev.type === "search";
19
- }
20
- export function isKgEvent(ev) {
21
- return ev.type === "kg";
22
- }
23
- export function isCrystallizeEvent(ev) {
24
- return ev.type === "crystallize";
25
- }
26
- export function isOpAuditEvent(ev) {
27
- return ev.type === "op_audit";
28
- }
29
- // ─── Validators (cheap, no schema lib) ───────────────────────────────────────
30
- const VALID_TYPES = new Set([
31
- "ingest",
32
- "search",
33
- "kg",
34
- "crystallize",
35
- "op_audit",
36
- ]);
37
- const VALID_SOURCES = new Set([
38
- "ingest-router",
39
- "ingest-watcher",
40
- "search-hybrid",
41
- "kg-extract",
42
- "crystallize",
43
- "op-audit",
44
- "provider",
45
- "health",
46
- "unknown",
47
- ]);
48
- export function isValidViewerEvent(x) {
49
- if (!x || typeof x !== "object")
50
- return false;
51
- const ev = x;
52
- if (typeof ev.ts !== "string" || !ev.ts)
53
- return false;
54
- if (typeof ev.type !== "string" || !VALID_TYPES.has(ev.type))
55
- return false;
56
- if (typeof ev.source !== "string" || !VALID_SOURCES.has(ev.source)) {
57
- return false;
58
- }
59
- if (typeof ev.summary !== "string")
60
- return false;
61
- if (!ev.details || typeof ev.details !== "object")
62
- return false;
63
- return true;
64
- }
65
- // ─── Helpers ─────────────────────────────────────────────────────────────────
66
- export function nowIso() {
67
- return new Date().toISOString();
68
- }
69
- export function eventKindLabel(ev) {
70
- if (isKgEvent(ev)) {
71
- return `${ev.type}.${ev.details.kg_kind}`;
72
- }
73
- return ev.type;
74
- }
@@ -1,106 +0,0 @@
1
- /**
2
- * T2 — Event source instrumentation
3
- *
4
- * Adapter layer: subscribes to the P5a internal bus (`bus` singleton from
5
- * `lib/events/bus.ts`) and converts each raw payload into a redacted
6
- * `ViewerEvent` ready for the SSE feed.
7
- *
8
- * Design:
9
- * - Single subscriber per kind — fan-out happens downstream (broadcast.ts).
10
- * - Pure conversion: no I/O, no DB calls, no async — keep emit→adapter <1ms.
11
- * - Output goes through `redactEvent()` so default-deny is enforced once.
12
- *
13
- * The bus dependency is injected as `BusLike` for tests so we can swap a
14
- * mock EventEmitter without touching globals.
15
- */
16
- import { EventEmitter } from "node:events";
17
- import { type ViewerEvent, type IngestEvent, type SearchEvent, type KgEvent, type CrystallizeEvent, type OpAuditEvent } from "./event-types.js";
18
- export interface BusLike {
19
- on(event: string, listener: (...args: unknown[]) => void): this;
20
- off(event: string, listener: (...args: unknown[]) => void): this;
21
- }
22
- interface BusChunkCreated {
23
- chunk_id: number;
24
- source_file?: string;
25
- type?: string;
26
- section?: string;
27
- token_count?: number;
28
- length?: number;
29
- redaction_count?: number;
30
- retention_days?: number | null;
31
- pain?: number;
32
- ts: number;
33
- }
34
- interface BusChunkDeleted {
35
- chunk_id: number;
36
- ts: number;
37
- }
38
- interface BusKgEntityCreated {
39
- entity_id: number;
40
- name: string;
41
- entity_type: string;
42
- confidence?: number;
43
- ts: number;
44
- }
45
- interface BusKgRelationCreated {
46
- relation_id: number;
47
- source_entity_id: number;
48
- target_entity_id: number;
49
- relation_type: string;
50
- confidence?: number;
51
- ts: number;
52
- }
53
- interface BusSearchExecuted {
54
- query?: string;
55
- query_hash?: string;
56
- latency_ms: number;
57
- top_k: number;
58
- result_count: number;
59
- mode?: "hybrid" | "fts" | "vector";
60
- bm25_score?: number;
61
- vec_score?: number;
62
- kg_score?: number;
63
- ts: number;
64
- }
65
- interface BusOpAuditStarted {
66
- op_id: number;
67
- op_type: string;
68
- dry_run?: boolean;
69
- ts: number;
70
- }
71
- interface BusOpAuditCompleted {
72
- op_id: number;
73
- op_type: string;
74
- status: "success" | "failed" | "crashed";
75
- duration_ms: number;
76
- rows_affected?: number;
77
- ts: number;
78
- }
79
- export declare function mapChunkCreated(p: BusChunkCreated): IngestEvent;
80
- export declare function mapChunkDeleted(p: BusChunkDeleted): IngestEvent;
81
- export declare function mapKgEntityCreated(p: BusKgEntityCreated): KgEvent;
82
- export declare function mapKgRelationCreated(p: BusKgRelationCreated): KgEvent;
83
- export declare function mapSearchExecuted(p: BusSearchExecuted): SearchEvent;
84
- export declare function mapOpAuditStarted(p: BusOpAuditStarted): OpAuditEvent;
85
- export declare function mapOpAuditCompleted(p: BusOpAuditCompleted): OpAuditEvent;
86
- export declare function buildCrystallizeEvent(status: "started" | "success" | "failed", target_entity_id: number, source_chunk_count: number, duration_ms?: number, redaction_count?: number): CrystallizeEvent;
87
- export interface InstrumentationOptions {
88
- /** Callback invoked with each ready-to-ship ViewerEvent (post-redaction). */
89
- onEvent: (ev: ViewerEvent) => void;
90
- /** Optional override for environment flag (defaults to env). */
91
- showQuery?: boolean;
92
- }
93
- export interface InstrumentationHandle {
94
- /** Unsubscribe all listeners and detach from bus. */
95
- detach: () => void;
96
- /** Count of events emitted since attach. */
97
- emitted: () => number;
98
- }
99
- /**
100
- * Attach to the P5a bus. Every relevant bus event is mapped and forwarded
101
- * through `redactEvent()` to the consumer.
102
- */
103
- export declare function attachInstrumentation(bus: BusLike, opts: InstrumentationOptions): InstrumentationHandle;
104
- /** Convenience: create a fresh isolated EventEmitter for tests. */
105
- export declare function makeTestBus(): EventEmitter;
106
- export {};