nox-mem 3.1.0 → 3.2.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 (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/db.js +61 -2
  17. package/dist/embed.js +23 -2
  18. package/dist/index.js +3 -23
  19. package/dist/knowledge-graph.js +20 -0
  20. package/dist/lib/answer/__tests__/e2e-gemini.test.js +229 -0
  21. package/dist/lib/answer/__tests__/integration-sqlite.test.js +388 -0
  22. package/dist/lib/answer/__tests__/integration.test.js +347 -0
  23. package/dist/lib/answer/__tests__/prompt.test.js +117 -0
  24. package/dist/lib/answer/__tests__/t5-t10.test.js +501 -0
  25. package/dist/lib/answer/provider.js +29 -4
  26. package/dist/lib/api/__tests__/safe-error-message.test.js +155 -0
  27. package/dist/lib/auth/__tests__/localhost-guard.test.js +144 -0
  28. package/dist/lib/error-sanitizer/__tests__/sanitize.test.js +354 -0
  29. package/dist/lib/events/__tests__/bus.test.js +208 -0
  30. package/dist/lib/ingest-router.js +0 -43
  31. package/dist/lib/op-audit-extension/__tests__/ran-at-guard.test.js +109 -0
  32. package/dist/lib/regex-extract/__tests__/extractor.test.js +197 -0
  33. package/dist/lib/regex-extract/__tests__/frontmatter.test.js +75 -0
  34. package/dist/lib/regex-extract/__tests__/ingest-router-l4.test.js +139 -0
  35. package/dist/lib/regex-extract/__tests__/production-wire.test.js +177 -0
  36. package/dist/lib/regex-extract/__tests__/reconcile.test.js +170 -0
  37. package/dist/lib/regex-extract/__tests__/strip-code.test.js +36 -0
  38. package/dist/mcp-server.js +2 -1
  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/dist/version.js +22 -0
  51. package/package.json +3 -4
  52. package/dist/api/answer.d.ts +0 -116
  53. package/dist/api/answer.validate-patch.d.ts +0 -72
  54. package/dist/api/brief-diversity.d.ts +0 -64
  55. package/dist/api/brief.d.ts +0 -114
  56. package/dist/api/conflict.d.ts +0 -33
  57. package/dist/api/conflict.js +0 -143
  58. package/dist/api/cors.d.ts +0 -73
  59. package/dist/api/events-stream-limited.d.ts +0 -133
  60. package/dist/api/events-stream-limited.js +0 -217
  61. package/dist/api/events-stream.d.ts +0 -53
  62. package/dist/api/events-stream.js +0 -125
  63. package/dist/api/export.d.ts +0 -42
  64. package/dist/api/export.js +0 -85
  65. package/dist/api/health-confidence-adapter.d.ts +0 -29
  66. package/dist/api/health-confidence-adapter.js +0 -73
  67. package/dist/api/health-confidence.d.ts +0 -36
  68. package/dist/api/health-confidence.js +0 -141
  69. package/dist/api/hooks.d.ts +0 -50
  70. package/dist/api/hooks.js +0 -115
  71. package/dist/api/import.d.ts +0 -38
  72. package/dist/api/import.js +0 -87
  73. package/dist/api/ingest-event.d.ts +0 -65
  74. package/dist/api/mark.d.ts +0 -42
  75. package/dist/api/mark.js +0 -127
  76. package/dist/api/server-deps-a2.d.ts +0 -55
  77. package/dist/api/server-deps-a2.js +0 -138
  78. package/dist/api/server-deps-l2-l3.d.ts +0 -68
  79. package/dist/api/server-deps-l2-l3.js +0 -123
  80. package/dist/api/server-deps-p1.d.ts +0 -84
  81. package/dist/api/server-deps-p2.d.ts +0 -32
  82. package/dist/api/server-deps-p2.js +0 -84
  83. package/dist/api/server-deps-p5.d.ts +0 -66
  84. package/dist/api/server-deps-p5.js +0 -139
  85. package/dist/api/viewer-static.d.ts +0 -30
  86. package/dist/api/viewer-static.js +0 -102
  87. package/dist/api/wire-up.d.ts +0 -54
  88. package/dist/api-impact.d.ts +0 -30
  89. package/dist/api-server.d.ts +0 -2
  90. package/dist/backfill-fts-anchor.d.ts +0 -15
  91. package/dist/backfill-source-type.d.ts +0 -20
  92. package/dist/churn.d.ts +0 -31
  93. package/dist/cli/answer.d.ts +0 -66
  94. package/dist/cli/conflict.d.ts +0 -38
  95. package/dist/cli/conflict.js +0 -282
  96. package/dist/cli/export.d.ts +0 -51
  97. package/dist/cli/export.js +0 -280
  98. package/dist/cli/hooks.d.ts +0 -54
  99. package/dist/cli/hooks.js +0 -133
  100. package/dist/cli/import.d.ts +0 -52
  101. package/dist/cli/import.js +0 -274
  102. package/dist/cli/mark.d.ts +0 -33
  103. package/dist/cli/mark.js +0 -130
  104. package/dist/cli/ocr-batch.d.ts +0 -12
  105. package/dist/cli/ocr-batch.js +0 -411
  106. package/dist/cli/snapshot-main.d.ts +0 -30
  107. package/dist/cli/snapshot-main.js +0 -47
  108. package/dist/cli/viewer.d.ts +0 -35
  109. package/dist/cli/viewer.js +0 -71
  110. package/dist/cli-telemetry.d.ts +0 -36
  111. package/dist/cli-telemetry.js +0 -150
  112. package/dist/compact.d.ts +0 -7
  113. package/dist/consolidate.d.ts +0 -18
  114. package/dist/consolidation.d.ts +0 -32
  115. package/dist/cross-agent-v2.d.ts +0 -45
  116. package/dist/cross-search.d.ts +0 -11
  117. package/dist/crystallize.d.ts +0 -43
  118. package/dist/db.d.ts +0 -11
  119. package/dist/dedup.d.ts +0 -1
  120. package/dist/detect-changes.d.ts +0 -29
  121. package/dist/digest.d.ts +0 -1
  122. package/dist/doctor.d.ts +0 -1
  123. package/dist/embed.d.ts +0 -57
  124. package/dist/evals.d.ts +0 -176
  125. package/dist/evals.js +0 -351
  126. package/dist/generate-user-profile.d.ts +0 -18
  127. package/dist/graphify-ingest.d.ts +0 -18
  128. package/dist/impact.d.ts +0 -39
  129. package/dist/index.d.ts +0 -2
  130. package/dist/ingest-entity.d.ts +0 -44
  131. package/dist/ingest.d.ts +0 -13
  132. package/dist/kg-llm.d.ts +0 -39
  133. package/dist/knowledge-graph.d.ts +0 -72
  134. package/dist/lib/answer/config.d.ts +0 -41
  135. package/dist/lib/answer/index.d.ts +0 -47
  136. package/dist/lib/answer/prompt.d.ts +0 -37
  137. package/dist/lib/answer/provider.d.ts +0 -47
  138. package/dist/lib/answer/retrieval.d.ts +0 -36
  139. package/dist/lib/answer/telemetry.d.ts +0 -99
  140. package/dist/lib/answer/types.d.ts +0 -108
  141. package/dist/lib/api/error-leak-fix.d.ts +0 -54
  142. package/dist/lib/api/safe-error-message.d.ts +0 -70
  143. package/dist/lib/archive/common-passwords.d.ts +0 -37
  144. package/dist/lib/archive/common-passwords.js +0 -753
  145. package/dist/lib/archive/encryption.d.ts +0 -81
  146. package/dist/lib/archive/encryption.js +0 -236
  147. package/dist/lib/archive/enforce-strength.d.ts +0 -54
  148. package/dist/lib/archive/enforce-strength.js +0 -70
  149. package/dist/lib/archive/entropy.d.ts +0 -34
  150. package/dist/lib/archive/entropy.js +0 -180
  151. package/dist/lib/archive/export-locking.d.ts +0 -102
  152. package/dist/lib/archive/export-locking.js +0 -202
  153. package/dist/lib/archive/format.d.ts +0 -20
  154. package/dist/lib/archive/format.js +0 -174
  155. package/dist/lib/archive/index.d.ts +0 -23
  156. package/dist/lib/archive/index.js +0 -17
  157. package/dist/lib/archive/manifest.d.ts +0 -53
  158. package/dist/lib/archive/manifest.js +0 -183
  159. package/dist/lib/archive/migration.d.ts +0 -36
  160. package/dist/lib/archive/migration.js +0 -100
  161. package/dist/lib/archive/migrations/v18_to_v19.d.ts +0 -16
  162. package/dist/lib/archive/migrations/v18_to_v19.js +0 -18
  163. package/dist/lib/archive/orchestrator.d.ts +0 -166
  164. package/dist/lib/archive/orchestrator.js +0 -428
  165. package/dist/lib/archive/serializers/chunks.d.ts +0 -30
  166. package/dist/lib/archive/serializers/chunks.js +0 -113
  167. package/dist/lib/archive/serializers/embeddings.d.ts +0 -36
  168. package/dist/lib/archive/serializers/embeddings.js +0 -115
  169. package/dist/lib/archive/serializers/kg.d.ts +0 -28
  170. package/dist/lib/archive/serializers/kg.js +0 -184
  171. package/dist/lib/archive/serializers/ops_audit.d.ts +0 -21
  172. package/dist/lib/archive/serializers/ops_audit.js +0 -97
  173. package/dist/lib/archive/server-deps.d.ts +0 -131
  174. package/dist/lib/archive/server-deps.js +0 -232
  175. package/dist/lib/archive/strength.d.ts +0 -50
  176. package/dist/lib/archive/strength.js +0 -77
  177. package/dist/lib/archive/types.d.ts +0 -159
  178. package/dist/lib/archive/types.js +0 -45
  179. package/dist/lib/archive/unpack-streaming.d.ts +0 -70
  180. package/dist/lib/archive/unpack-streaming.js +0 -255
  181. package/dist/lib/auth/localhost-guard.d.ts +0 -106
  182. package/dist/lib/confidence/config.d.ts +0 -37
  183. package/dist/lib/confidence/config.js +0 -107
  184. package/dist/lib/confidence/db-shim-singleton.d.ts +0 -20
  185. package/dist/lib/confidence/db-shim-singleton.js +0 -41
  186. package/dist/lib/confidence/db-shim.d.ts +0 -47
  187. package/dist/lib/confidence/db-shim.js +0 -141
  188. package/dist/lib/confidence/mark.d.ts +0 -58
  189. package/dist/lib/confidence/mark.js +0 -168
  190. package/dist/lib/confidence/ranking.d.ts +0 -69
  191. package/dist/lib/confidence/ranking.js +0 -101
  192. package/dist/lib/confidence/search-filter.d.ts +0 -44
  193. package/dist/lib/confidence/search-filter.js +0 -103
  194. package/dist/lib/confidence/types.d.ts +0 -146
  195. package/dist/lib/confidence/types.js +0 -20
  196. package/dist/lib/confidence/write-hooks.d.ts +0 -50
  197. package/dist/lib/confidence/write-hooks.js +0 -159
  198. package/dist/lib/conflict/audit-fk-check.d.ts +0 -72
  199. package/dist/lib/conflict/audit-fk-check.js +0 -131
  200. package/dist/lib/conflict/audit-writer.d.ts +0 -39
  201. package/dist/lib/conflict/audit-writer.js +0 -133
  202. package/dist/lib/conflict/db-singleton.d.ts +0 -28
  203. package/dist/lib/conflict/db-singleton.js +0 -61
  204. package/dist/lib/conflict/db.d.ts +0 -27
  205. package/dist/lib/conflict/db.js +0 -20
  206. package/dist/lib/conflict/detector-direct.d.ts +0 -21
  207. package/dist/lib/conflict/detector-direct.js +0 -105
  208. package/dist/lib/conflict/evidence.d.ts +0 -24
  209. package/dist/lib/conflict/evidence.js +0 -76
  210. package/dist/lib/conflict/index.d.ts +0 -14
  211. package/dist/lib/conflict/index.js +0 -12
  212. package/dist/lib/conflict/scheduler.d.ts +0 -78
  213. package/dist/lib/conflict/scheduler.js +0 -111
  214. package/dist/lib/conflict/shadow.d.ts +0 -75
  215. package/dist/lib/conflict/shadow.js +0 -161
  216. package/dist/lib/conflict/types.d.ts +0 -133
  217. package/dist/lib/conflict/types.js +0 -19
  218. package/dist/lib/cost-cap.d.ts +0 -94
  219. package/dist/lib/deps/deps-registry.d.ts +0 -111
  220. package/dist/lib/error-sanitizer/middleware.d.ts +0 -43
  221. package/dist/lib/error-sanitizer/sanitize.d.ts +0 -78
  222. package/dist/lib/eval-batch.d.ts +0 -34
  223. package/dist/lib/eval-batch.js +0 -103
  224. package/dist/lib/eval-metrics.d.ts +0 -36
  225. package/dist/lib/eval-metrics.js +0 -95
  226. package/dist/lib/eval.d.ts +0 -106
  227. package/dist/lib/eval.js +0 -343
  228. package/dist/lib/events/bus.d.ts +0 -135
  229. package/dist/lib/fts-anchor.d.ts +0 -1
  230. package/dist/lib/hooks/classifier.d.ts +0 -47
  231. package/dist/lib/hooks/classifier.js +0 -129
  232. package/dist/lib/hooks/config.d.ts +0 -49
  233. package/dist/lib/hooks/config.js +0 -106
  234. package/dist/lib/hooks/decorators.d.ts +0 -35
  235. package/dist/lib/hooks/decorators.js +0 -59
  236. package/dist/lib/hooks/pipeline.d.ts +0 -76
  237. package/dist/lib/hooks/pipeline.js +0 -213
  238. package/dist/lib/hooks/privacy-filter-adapter.d.ts +0 -55
  239. package/dist/lib/hooks/privacy-filter-adapter.js +0 -84
  240. package/dist/lib/hooks/rate-limit-constant-time.d.ts +0 -57
  241. package/dist/lib/hooks/rate-limit-constant-time.js +0 -69
  242. package/dist/lib/hooks/rate-limit-dryrun-fix.d.ts +0 -71
  243. package/dist/lib/hooks/rate-limit-dryrun-fix.js +0 -110
  244. package/dist/lib/hooks/rate-limit.d.ts +0 -54
  245. package/dist/lib/hooks/rate-limit.js +0 -122
  246. package/dist/lib/hooks/server-deps.d.ts +0 -61
  247. package/dist/lib/hooks/server-deps.js +0 -92
  248. package/dist/lib/hooks/source-allowlist.d.ts +0 -26
  249. package/dist/lib/hooks/source-allowlist.js +0 -53
  250. package/dist/lib/hooks/types.d.ts +0 -129
  251. package/dist/lib/hooks/types.js +0 -24
  252. package/dist/lib/hooks/worker.d.ts +0 -56
  253. package/dist/lib/hooks/worker.js +0 -150
  254. package/dist/lib/ingest-router.d.ts +0 -25
  255. package/dist/lib/ocr-detector.d.ts +0 -61
  256. package/dist/lib/ocr-detector.js +0 -138
  257. package/dist/lib/ocr-engine-stub.d.ts +0 -48
  258. package/dist/lib/ocr-engine-stub.js +0 -190
  259. package/dist/lib/ocr-engines/google-doc-ai.d.ts +0 -36
  260. package/dist/lib/ocr-engines/google-doc-ai.js +0 -164
  261. package/dist/lib/ocr-jobs.d.ts +0 -67
  262. package/dist/lib/ocr-jobs.js +0 -129
  263. package/dist/lib/op-audit-extension/ran-at-guard.d.ts +0 -86
  264. package/dist/lib/op-audit.d.ts +0 -71
  265. package/dist/lib/privacy-br/detector.d.ts +0 -42
  266. package/dist/lib/privacy-br/detector.js +0 -130
  267. package/dist/lib/privacy-br/index.d.ts +0 -20
  268. package/dist/lib/privacy-br/index.js +0 -20
  269. package/dist/lib/privacy-br/integration.d.ts +0 -71
  270. package/dist/lib/privacy-br/integration.js +0 -74
  271. package/dist/lib/privacy-br/patterns.d.ts +0 -117
  272. package/dist/lib/privacy-br/patterns.js +0 -434
  273. package/dist/lib/privacy-br/redact.d.ts +0 -42
  274. package/dist/lib/privacy-br/redact.js +0 -103
  275. package/dist/lib/privacy-br/types.d.ts +0 -55
  276. package/dist/lib/privacy-br/types.js +0 -25
  277. package/dist/lib/regex-extract/extractor.d.ts +0 -30
  278. package/dist/lib/regex-extract/frontmatter.d.ts +0 -44
  279. package/dist/lib/regex-extract/index.d.ts +0 -14
  280. package/dist/lib/regex-extract/ingest-router-l4.d.ts +0 -76
  281. package/dist/lib/regex-extract/patterns.d.ts +0 -61
  282. package/dist/lib/regex-extract/production-wire.d.ts +0 -128
  283. package/dist/lib/regex-extract/reconcile.d.ts +0 -162
  284. package/dist/lib/regex-extract/strip-code.d.ts +0 -24
  285. package/dist/lib/regex-extract/types.d.ts +0 -48
  286. package/dist/lib/reranker.d.ts +0 -80
  287. package/dist/lib/shadow-tracker.d.ts +0 -191
  288. package/dist/lib/shadow-tracker.js +0 -384
  289. package/dist/lib/spo-injection.d.ts +0 -52
  290. package/dist/lib/telemetry-collector.d.ts +0 -158
  291. package/dist/lib/telemetry-collector.js +0 -249
  292. package/dist/lib/temporal-detector.d.ts +0 -27
  293. package/dist/lib/viewer/auth.d.ts +0 -37
  294. package/dist/lib/viewer/auth.js +0 -70
  295. package/dist/lib/viewer/backpressure.d.ts +0 -59
  296. package/dist/lib/viewer/backpressure.js +0 -100
  297. package/dist/lib/viewer/broadcast-singleton.d.ts +0 -34
  298. package/dist/lib/viewer/broadcast-singleton.js +0 -49
  299. package/dist/lib/viewer/broadcast.d.ts +0 -66
  300. package/dist/lib/viewer/broadcast.js +0 -96
  301. package/dist/lib/viewer/event-types.d.ts +0 -132
  302. package/dist/lib/viewer/event-types.js +0 -74
  303. package/dist/lib/viewer/instrumentation.d.ts +0 -106
  304. package/dist/lib/viewer/instrumentation.js +0 -224
  305. package/dist/lib/viewer/migration.d.ts +0 -23
  306. package/dist/lib/viewer/migration.js +0 -56
  307. package/dist/lib/viewer/redaction.d.ts +0 -44
  308. package/dist/lib/viewer/redaction.js +0 -139
  309. package/dist/lib/viewer/session.d.ts +0 -51
  310. package/dist/lib/viewer/session.js +0 -87
  311. package/dist/mcp/tools/answer.d.ts +0 -94
  312. package/dist/mcp/tools/archive.d.ts +0 -152
  313. package/dist/mcp/tools/archive.js +0 -170
  314. package/dist/mcp/tools/conflict.d.ts +0 -44
  315. package/dist/mcp/tools/conflict.js +0 -130
  316. package/dist/mcp/tools/hooks.d.ts +0 -29
  317. package/dist/mcp/tools/hooks.js +0 -78
  318. package/dist/mcp/tools/mark.d.ts +0 -38
  319. package/dist/mcp/tools/mark.js +0 -82
  320. package/dist/mcp/tools/viewer.d.ts +0 -58
  321. package/dist/mcp/tools/viewer.js +0 -64
  322. package/dist/mcp-server.d.ts +0 -2
  323. package/dist/metrics.d.ts +0 -3
  324. package/dist/noise-filter.d.ts +0 -18
  325. package/dist/notion-sync.d.ts +0 -7
  326. package/dist/notion-sync.js +0 -97
  327. package/dist/observability/adapters/a3-adapter.d.ts +0 -63
  328. package/dist/observability/adapters/a3-adapter.js +0 -83
  329. package/dist/observability/adapters/p1-adapter.d.ts +0 -49
  330. package/dist/observability/adapters/p1-adapter.js +0 -63
  331. package/dist/observability/adapters/p5-adapter.d.ts +0 -36
  332. package/dist/observability/adapters/p5-adapter.js +0 -71
  333. package/dist/observability/cardinality.d.ts +0 -61
  334. package/dist/observability/cardinality.js +0 -300
  335. package/dist/observability/collectors/db-stats.collector.d.ts +0 -9
  336. package/dist/observability/collectors/db-stats.collector.js +0 -88
  337. package/dist/observability/collectors/eventbus.collector.d.ts +0 -6
  338. package/dist/observability/collectors/eventbus.collector.js +0 -50
  339. package/dist/observability/collectors/process.collector.d.ts +0 -7
  340. package/dist/observability/collectors/process.collector.js +0 -93
  341. package/dist/observability/collectors/provider-telemetry.collector.d.ts +0 -11
  342. package/dist/observability/collectors/provider-telemetry.collector.js +0 -112
  343. package/dist/observability/collectors/search-telemetry.collector.d.ts +0 -12
  344. package/dist/observability/collectors/search-telemetry.collector.js +0 -76
  345. package/dist/observability/exporter.d.ts +0 -30
  346. package/dist/observability/exporter.js +0 -182
  347. package/dist/observability/index.d.ts +0 -22
  348. package/dist/observability/index.js +0 -21
  349. package/dist/observability/metrics.d.ts +0 -53
  350. package/dist/observability/metrics.js +0 -213
  351. package/dist/observability/privacy-guard.d.ts +0 -32
  352. package/dist/observability/privacy-guard.js +0 -116
  353. package/dist/observability/record.d.ts +0 -83
  354. package/dist/observability/record.js +0 -217
  355. package/dist/observability/registry.d.ts +0 -60
  356. package/dist/observability/registry.js +0 -93
  357. package/dist/observability/types.d.ts +0 -115
  358. package/dist/observability/types.js +0 -235
  359. package/dist/observability.d.ts +0 -131
  360. package/dist/plugins/nox-hooks/index.d.ts +0 -61
  361. package/dist/plugins/nox-hooks/index.js +0 -99
  362. package/dist/primer.d.ts +0 -1
  363. package/dist/privacy/filter.d.ts +0 -27
  364. package/dist/privacy/patterns.d.ts +0 -29
  365. package/dist/privacy/tag-parser.d.ts +0 -24
  366. package/dist/project-context-gen.d.ts +0 -10
  367. package/dist/providers/embedding/gemini.d.ts +0 -73
  368. package/dist/providers/embedding/openai.d.ts +0 -76
  369. package/dist/providers/embedding/types.d.ts +0 -39
  370. package/dist/providers/embedding/voyage.d.ts +0 -36
  371. package/dist/providers/index.d.ts +0 -116
  372. package/dist/providers/llm/anthropic.d.ts +0 -29
  373. package/dist/providers/llm/chain.d.ts +0 -99
  374. package/dist/providers/llm/gemini.d.ts +0 -48
  375. package/dist/providers/llm/openai.d.ts +0 -64
  376. package/dist/providers/llm/types.d.ts +0 -47
  377. package/dist/providers/telemetry.d.ts +0 -87
  378. package/dist/providers/types.d.ts +0 -42
  379. package/dist/query-entity-count.d.ts +0 -54
  380. package/dist/reflect.d.ts +0 -26
  381. package/dist/reindex-errors.d.ts +0 -7
  382. package/dist/reindex.d.ts +0 -16
  383. package/dist/retention.d.ts +0 -40
  384. package/dist/salience.d.ts +0 -85
  385. package/dist/scripts/migrate-v17-ops-audit.d.ts +0 -17
  386. package/dist/search-dedup.d.ts +0 -44
  387. package/dist/search-expansion.d.ts +0 -20
  388. package/dist/search.d.ts +0 -62
  389. package/dist/seh-detector.d.ts +0 -31
  390. package/dist/self-improve.d.ts +0 -1
  391. package/dist/session-distill.d.ts +0 -29
  392. package/dist/session-update.d.ts +0 -1
  393. package/dist/shared-memory.d.ts +0 -24
  394. package/dist/stats.d.ts +0 -1
  395. package/dist/temporal-retrieval.d.ts +0 -132
  396. package/dist/tier-manager.d.ts +0 -69
  397. package/dist/vectorize.d.ts +0 -16
  398. package/dist/watch.d.ts +0 -8
@@ -1,7 +0,0 @@
1
- export interface ProcessCollectorOpts {
2
- /** Sampling interval ms. Default 10_000. */
3
- intervalMs?: number;
4
- }
5
- export declare function startProcessCollector(opts?: ProcessCollectorOpts): void;
6
- export declare function stopProcessCollector(): void;
7
- export declare function collectOnce(): void;
@@ -1,93 +0,0 @@
1
- /**
2
- * src/observability/collectors/process.collector.ts — Node runtime metrics.
3
- *
4
- * Periodically samples Node.js process stats into the corresponding gauges
5
- * and counters. Intended to be wired by the API server bootstrap:
6
- *
7
- * import { startProcessCollector } from "./observability/collectors/process.collector.js";
8
- * startProcessCollector();
9
- *
10
- * Sampling cadence is conservative (10s) to minimise CPU overhead.
11
- */
12
- import { performance, monitorEventLoopDelay } from "node:perf_hooks";
13
- import { processCpuUserSecondsTotal, processCpuSystemSecondsTotal, processResidentMemoryBytes, processOpenFds, nodejsEventloopLagSeconds, } from "../metrics.js";
14
- let intervalHandle;
15
- let lastCpu;
16
- let elMonitor;
17
- export function startProcessCollector(opts = {}) {
18
- if (intervalHandle)
19
- return; // idempotent
20
- const interval = opts.intervalMs ?? 10_000;
21
- elMonitor = monitorEventLoopDelay({ resolution: 50 });
22
- elMonitor.enable();
23
- lastCpu = process.cpuUsage();
24
- intervalHandle = setInterval(() => {
25
- try {
26
- collectOnce();
27
- }
28
- catch {
29
- // Never throw from a metrics sampler.
30
- }
31
- }, interval);
32
- // Allow process to exit cleanly.
33
- intervalHandle.unref?.();
34
- // Take one immediate sample for fresh /metrics.
35
- collectOnce();
36
- }
37
- export function stopProcessCollector() {
38
- if (intervalHandle) {
39
- clearInterval(intervalHandle);
40
- intervalHandle = undefined;
41
- }
42
- if (elMonitor) {
43
- elMonitor.disable();
44
- elMonitor = undefined;
45
- }
46
- lastCpu = undefined;
47
- }
48
- export function collectOnce() {
49
- // CPU — delta since last sample. Counter is monotonic, so we accumulate.
50
- const cur = process.cpuUsage();
51
- if (lastCpu) {
52
- const userDeltaMicros = cur.user - lastCpu.user;
53
- const sysDeltaMicros = cur.system - lastCpu.system;
54
- if (userDeltaMicros > 0) {
55
- processCpuUserSecondsTotal.inc({}, userDeltaMicros / 1e6);
56
- }
57
- if (sysDeltaMicros > 0) {
58
- processCpuSystemSecondsTotal.inc({}, sysDeltaMicros / 1e6);
59
- }
60
- }
61
- lastCpu = cur;
62
- // Memory
63
- const mem = process.memoryUsage();
64
- processResidentMemoryBytes.set(mem.rss);
65
- // Open FDs (POSIX-only best effort).
66
- const fdCount = bestEffortFdCount();
67
- if (fdCount >= 0)
68
- processOpenFds.set(fdCount);
69
- // Event loop lag — use mean since last sample then reset.
70
- if (elMonitor) {
71
- const meanNs = elMonitor.mean;
72
- elMonitor.reset();
73
- if (Number.isFinite(meanNs)) {
74
- nodejsEventloopLagSeconds.set(meanNs / 1e9);
75
- }
76
- }
77
- // Touch performance.now() so V8 doesn't dead-code-elim.
78
- void performance.now();
79
- }
80
- function bestEffortFdCount() {
81
- try {
82
- // /proc/self/fd is Linux-specific.
83
- if (process.platform !== "linux")
84
- return -1;
85
- // eslint-disable-next-line @typescript-eslint/no-require-imports
86
- const fs = require("node:fs");
87
- const list = fs.readdirSync("/proc/self/fd");
88
- return list.length;
89
- }
90
- catch {
91
- return -1;
92
- }
93
- }
@@ -1,11 +0,0 @@
1
- export type DbQueryFn = (sql: string, params?: ReadonlyArray<string | number>) => Array<Record<string, unknown>>;
2
- export interface ProviderTelemetryCollectorOpts {
3
- query: DbQueryFn;
4
- intervalMs?: number;
5
- startId?: number;
6
- }
7
- export declare function startProviderTelemetryCollector(opts: ProviderTelemetryCollectorOpts): void;
8
- export declare function stopProviderTelemetryCollector(): void;
9
- export declare function drain(query: DbQueryFn): number;
10
- export declare function getCursor(): number;
11
- export declare function resetCursor(): void;
@@ -1,112 +0,0 @@
1
- /**
2
- * src/observability/collectors/provider-telemetry.collector.ts
3
- *
4
- * Reads `provider_telemetry` (schema v11, A3) and translates rows into
5
- * `nox_provider_*` metric increments.
6
- *
7
- * Columns (per A3 telemetry spec):
8
- * ts, provider_id, model, kind ('embedding'|'llm'),
9
- * tokens_in, tokens_out, cost_usd, latency_ms, ok (0|1),
10
- * caller, session_id, error_kind
11
- *
12
- * Privacy: `error_kind` is already redacted at write time (see
13
- * src/providers/telemetry.ts). We do NOT export caller or session_id.
14
- */
15
- import { providerCallsTotal, providerDurationSeconds, providerCostUsdTotal, providerTokensTotal, auditRowsTotal, } from "../metrics.js";
16
- import { guardLabels } from "../privacy-guard.js";
17
- let intervalHandle;
18
- let cursor = 0;
19
- export function startProviderTelemetryCollector(opts) {
20
- if (intervalHandle)
21
- return;
22
- cursor = opts.startId ?? 0;
23
- const interval = opts.intervalMs ?? 5_000;
24
- const runOnce = () => {
25
- try {
26
- drain(opts.query);
27
- }
28
- catch {
29
- // never crash
30
- }
31
- };
32
- runOnce();
33
- intervalHandle = setInterval(runOnce, interval);
34
- intervalHandle.unref?.();
35
- }
36
- export function stopProviderTelemetryCollector() {
37
- if (intervalHandle) {
38
- clearInterval(intervalHandle);
39
- intervalHandle = undefined;
40
- }
41
- }
42
- export function drain(query) {
43
- const rows = query(`SELECT id, provider_id, model, kind, tokens_in, tokens_out,
44
- cost_usd, latency_ms, ok
45
- FROM provider_telemetry
46
- WHERE id > ?
47
- ORDER BY id ASC
48
- LIMIT 1000`, [cursor]);
49
- for (const r of rows) {
50
- const id = Number(r.id);
51
- const provider = String(r.provider_id ?? "other");
52
- const model = String(r.model ?? "unknown");
53
- const kind = String(r.kind ?? "llm");
54
- const tokensIn = Number(r.tokens_in ?? 0);
55
- const tokensOut = Number(r.tokens_out ?? 0);
56
- const cost = Number(r.cost_usd ?? 0);
57
- const latMs = Number(r.latency_ms ?? 0);
58
- const ok = Number(r.ok ?? 0) === 1;
59
- const outcome = ok ? "success" : "error";
60
- const callL = guardLabels("nox_provider_calls_total", {
61
- provider,
62
- model,
63
- outcome,
64
- }).labels;
65
- if (callL)
66
- providerCallsTotal.inc(callL);
67
- const durL = guardLabels("nox_provider_duration_seconds", {
68
- provider,
69
- kind,
70
- }).labels;
71
- if (durL)
72
- providerDurationSeconds.observe(durL, latMs / 1000);
73
- if (cost > 0) {
74
- const costL = guardLabels("nox_provider_cost_usd_total", {
75
- provider,
76
- model,
77
- }).labels;
78
- if (costL)
79
- providerCostUsdTotal.inc(costL, cost);
80
- }
81
- if (tokensIn > 0) {
82
- const lbl = guardLabels("nox_provider_tokens_total", {
83
- provider,
84
- direction: "input",
85
- }).labels;
86
- if (lbl)
87
- providerTokensTotal.inc(lbl, tokensIn);
88
- }
89
- if (tokensOut > 0) {
90
- const lbl = guardLabels("nox_provider_tokens_total", {
91
- provider,
92
- direction: "output",
93
- }).labels;
94
- if (lbl)
95
- providerTokensTotal.inc(lbl, tokensOut);
96
- }
97
- const auditL = guardLabels("nox_audit_rows_total", {
98
- table: "provider_telemetry",
99
- }).labels;
100
- if (auditL)
101
- auditRowsTotal.inc(auditL);
102
- if (id > cursor)
103
- cursor = id;
104
- }
105
- return rows.length;
106
- }
107
- export function getCursor() {
108
- return cursor;
109
- }
110
- export function resetCursor() {
111
- cursor = 0;
112
- }
@@ -1,12 +0,0 @@
1
- export type DbQueryFn = (sql: string, params?: ReadonlyArray<string | number>) => Array<Record<string, unknown>>;
2
- export interface SearchTelemetryCollectorOpts {
3
- query: DbQueryFn;
4
- intervalMs?: number;
5
- /** Initial cursor (id watermark). Default 0. */
6
- startId?: number;
7
- }
8
- export declare function startSearchTelemetryCollector(opts: SearchTelemetryCollectorOpts): void;
9
- export declare function stopSearchTelemetryCollector(): void;
10
- export declare function drain(query: DbQueryFn): number;
11
- export declare function getCursor(): number;
12
- export declare function resetCursor(): void;
@@ -1,76 +0,0 @@
1
- /**
2
- * src/observability/collectors/search-telemetry.collector.ts
3
- *
4
- * Polls `search_telemetry` (post-A0 column set) and translates rows into
5
- * `nox_search_*` metric increments. Rows are read in batches keyed by an
6
- * incrementing cursor so we don't double-count.
7
- *
8
- * Schema dependency:
9
- * search_telemetry(id INTEGER PK, ts INTEGER, method TEXT, duration_ms INTEGER,
10
- * results_count INTEGER, outcome TEXT, …)
11
- *
12
- * IMPORTANT: This collector does NOT read query_text — it only consumes the
13
- * categorical fields. Privacy invariant.
14
- */
15
- import { searchRequestsTotal, searchDurationSeconds, searchResultsReturned, } from "../metrics.js";
16
- import { guardLabels } from "../privacy-guard.js";
17
- let intervalHandle;
18
- let cursor = 0;
19
- export function startSearchTelemetryCollector(opts) {
20
- if (intervalHandle)
21
- return;
22
- cursor = opts.startId ?? 0;
23
- const interval = opts.intervalMs ?? 5_000;
24
- const runOnce = () => {
25
- try {
26
- drain(opts.query);
27
- }
28
- catch {
29
- // never crash
30
- }
31
- };
32
- runOnce();
33
- intervalHandle = setInterval(runOnce, interval);
34
- intervalHandle.unref?.();
35
- }
36
- export function stopSearchTelemetryCollector() {
37
- if (intervalHandle) {
38
- clearInterval(intervalHandle);
39
- intervalHandle = undefined;
40
- }
41
- }
42
- export function drain(query) {
43
- const rows = query(`SELECT id, method, duration_ms, results_count, outcome
44
- FROM search_telemetry
45
- WHERE id > ?
46
- ORDER BY id ASC
47
- LIMIT 1000`, [cursor]);
48
- for (const r of rows) {
49
- const id = Number(r.id);
50
- const method = String(r.method ?? "other");
51
- const durMs = Number(r.duration_ms ?? 0);
52
- const count = Number(r.results_count ?? 0);
53
- const outcome = String(r.outcome ?? "success");
54
- const reqL = guardLabels("nox_search_requests_total", {
55
- method,
56
- outcome,
57
- }).labels;
58
- if (reqL)
59
- searchRequestsTotal.inc(reqL);
60
- const durL = guardLabels("nox_search_duration_seconds", { method }).labels;
61
- if (durL)
62
- searchDurationSeconds.observe(durL, durMs / 1000);
63
- const resL = guardLabels("nox_search_results_returned", { method }).labels;
64
- if (resL)
65
- searchResultsReturned.observe(resL, count);
66
- if (id > cursor)
67
- cursor = id;
68
- }
69
- return rows.length;
70
- }
71
- export function getCursor() {
72
- return cursor;
73
- }
74
- export function resetCursor() {
75
- cursor = 0;
76
- }
@@ -1,30 +0,0 @@
1
- import { type MetricsRegistry, type RegistrySnapshot } from "./registry.js";
2
- export declare const OPENMETRICS_CONTENT_TYPE = "application/openmetrics-text; version=1.0.0; charset=utf-8";
3
- export declare const PROMETHEUS_CONTENT_TYPE = "text/plain; version=0.0.4; charset=utf-8";
4
- /**
5
- * Render a full snapshot to text. Stable line order:
6
- * - Sorted by metric name.
7
- * - For each metric: `# HELP`, `# TYPE`, optional `# UNIT`, samples.
8
- * - Samples within a metric: sorted by stringified labels.
9
- */
10
- export declare function render(snapshot: RegistrySnapshot): string;
11
- export interface MetricsRequest {
12
- /** Lower-cased URL search params for filtering, e.g. ?names=a,b */
13
- searchParams?: URLSearchParams | Record<string, string>;
14
- /** Standard HTTP headers as a Record (lower-case keys). */
15
- headers?: Record<string, string | string[] | undefined>;
16
- }
17
- export interface MetricsResponse {
18
- status: number;
19
- headers: Record<string, string>;
20
- /** Body — string or Buffer (when gzipped). */
21
- body: string | Buffer;
22
- }
23
- export interface ExporterOpts {
24
- registry?: MetricsRegistry;
25
- /** If set, require `Authorization: Bearer <token>`. */
26
- token?: string;
27
- /** Content type — defaults to OpenMetrics. */
28
- contentType?: string;
29
- }
30
- export declare function handle(req: MetricsRequest, opts?: ExporterOpts): MetricsResponse;
@@ -1,182 +0,0 @@
1
- /**
2
- * src/observability/exporter.ts — `/metrics` exporter (T5).
3
- *
4
- * Serializes the registry snapshot to OpenMetrics text format (Prometheus
5
- * 0.0.4+ compatible).
6
- *
7
- * RESPONSIBILITIES:
8
- * 1. Render Counter / Gauge / Histogram in canonical order.
9
- * 2. Filter by `?names=metric1,metric2` (CSV).
10
- * 3. Optional Bearer-token auth (`NOX_METRICS_TOKEN` env).
11
- * 4. Gzip the body when Accept-Encoding lists gzip.
12
- *
13
- * NEVER expose:
14
- * - Stack traces
15
- * - Caller identity
16
- * - Anything beyond the registered metrics
17
- *
18
- * The exporter is designed to be transport-agnostic. The `handle()` function
19
- * accepts a Request-like input and returns a Response-like output, so it can
20
- * plug into the existing nox-mem HTTP API (port 18802) or any Node http
21
- * server.
22
- */
23
- import { gzipSync } from "node:zlib";
24
- import { getDefaultRegistry } from "./registry.js";
25
- import { escapeLabelValue, } from "./types.js";
26
- // ─── Content-type & version ─────────────────────────────────────────────────
27
- export const OPENMETRICS_CONTENT_TYPE = "application/openmetrics-text; version=1.0.0; charset=utf-8";
28
- export const PROMETHEUS_CONTENT_TYPE = "text/plain; version=0.0.4; charset=utf-8";
29
- // ─── Rendering ───────────────────────────────────────────────────────────────
30
- /**
31
- * Render a full snapshot to text. Stable line order:
32
- * - Sorted by metric name.
33
- * - For each metric: `# HELP`, `# TYPE`, optional `# UNIT`, samples.
34
- * - Samples within a metric: sorted by stringified labels.
35
- */
36
- export function render(snapshot) {
37
- const lines = [];
38
- // Render counters
39
- for (const c of snapshot.counters) {
40
- renderCounter(c, lines);
41
- }
42
- // Render gauges
43
- for (const g of snapshot.gauges) {
44
- renderGauge(g, lines);
45
- }
46
- // Render histograms
47
- for (const h of snapshot.histograms) {
48
- renderHistogram(h, lines);
49
- }
50
- // OpenMetrics EOF terminator (optional in Prometheus mode; safe in both).
51
- lines.push("# EOF");
52
- return lines.join("\n") + "\n";
53
- }
54
- function renderHeader(meta, lines) {
55
- lines.push(`# HELP ${meta.name} ${escapeHelp(meta.help)}`);
56
- lines.push(`# TYPE ${meta.name} ${meta.kind}`);
57
- if (meta.unit)
58
- lines.push(`# UNIT ${meta.name} ${meta.unit}`);
59
- }
60
- function escapeHelp(s) {
61
- return s.replace(/\\/g, "\\\\").replace(/\n/g, "\\n");
62
- }
63
- function labelsToString(labels) {
64
- const keys = Object.keys(labels).sort();
65
- if (keys.length === 0)
66
- return "";
67
- const parts = [];
68
- for (const k of keys) {
69
- const v = labels[k];
70
- if (typeof v !== "string")
71
- continue;
72
- parts.push(`${k}="${escapeLabelValue(v)}"`);
73
- }
74
- if (parts.length === 0)
75
- return "";
76
- return `{${parts.join(",")}}`;
77
- }
78
- function renderCounter(c, lines) {
79
- renderHeader(c.meta, lines);
80
- const samples = sortSamples(c.collect().map((s) => ({ labels: s.labels, value: s.value })));
81
- for (const s of samples) {
82
- lines.push(`${c.meta.name}${labelsToString(s.labels)} ${formatValue(s.value)}`);
83
- }
84
- }
85
- function renderGauge(g, lines) {
86
- renderHeader(g.meta, lines);
87
- const samples = sortSamples(g.collect().map((s) => ({ labels: s.labels, value: s.value })));
88
- for (const s of samples) {
89
- lines.push(`${g.meta.name}${labelsToString(s.labels)} ${formatValue(s.value)}`);
90
- }
91
- }
92
- function renderHistogram(h, lines) {
93
- renderHeader(h.meta, lines);
94
- for (const s of h.collect()) {
95
- const base = { ...s.labels };
96
- for (let i = 0; i < s.buckets.length; i++) {
97
- const lbl = { ...base, le: formatLe(s.buckets[i]) };
98
- lines.push(`${h.meta.name}_bucket${labelsToString(lbl)} ${formatValue(s.bucketCounts[i])}`);
99
- }
100
- // +Inf bucket
101
- const inf = { ...base, le: "+Inf" };
102
- lines.push(`${h.meta.name}_bucket${labelsToString(inf)} ${formatValue(s.count)}`);
103
- lines.push(`${h.meta.name}_sum${labelsToString(base)} ${formatValue(s.sum)}`);
104
- lines.push(`${h.meta.name}_count${labelsToString(base)} ${formatValue(s.count)}`);
105
- }
106
- }
107
- function sortSamples(samples) {
108
- return [...samples].sort((a, b) => labelsToString(a.labels).localeCompare(labelsToString(b.labels)));
109
- }
110
- function formatValue(v) {
111
- if (Number.isInteger(v))
112
- return String(v);
113
- return v.toString();
114
- }
115
- function formatLe(v) {
116
- // Use plain number; Prometheus accepts both "1" and "1.0".
117
- return v.toString();
118
- }
119
- export function handle(req, opts = {}) {
120
- const token = opts.token ?? process.env.NOX_METRICS_TOKEN;
121
- if (token) {
122
- const auth = headerString(req.headers, "authorization");
123
- if (!auth || !auth.startsWith("Bearer ") || auth.slice(7) !== token) {
124
- return {
125
- status: 401,
126
- headers: {
127
- "content-type": "text/plain; charset=utf-8",
128
- "www-authenticate": 'Bearer realm="nox-metrics"',
129
- },
130
- body: "unauthorized\n",
131
- };
132
- }
133
- }
134
- const reg = opts.registry ?? getDefaultRegistry();
135
- const snap = reg.collect();
136
- const names = parseNames(req.searchParams);
137
- const filtered = names.size === 0 ? snap : filterSnapshot(snap, names);
138
- const text = render(filtered);
139
- const acceptEnc = headerString(req.headers, "accept-encoding") ?? "";
140
- const wantsGzip = /\bgzip\b/i.test(acceptEnc);
141
- const headers = {
142
- "content-type": opts.contentType ?? OPENMETRICS_CONTENT_TYPE,
143
- "cache-control": "no-store",
144
- "x-metrics-snapshot-at": String(snap.takenAt),
145
- };
146
- if (wantsGzip) {
147
- const body = gzipSync(Buffer.from(text, "utf8"));
148
- headers["content-encoding"] = "gzip";
149
- headers["content-length"] = String(body.length);
150
- return { status: 200, headers, body };
151
- }
152
- return { status: 200, headers, body: text };
153
- }
154
- function headerString(headers, name) {
155
- if (!headers)
156
- return undefined;
157
- const v = headers[name] ?? headers[name.toLowerCase()];
158
- if (Array.isArray(v))
159
- return v[0];
160
- return v;
161
- }
162
- function parseNames(params) {
163
- if (!params)
164
- return new Set();
165
- const raw = params instanceof URLSearchParams
166
- ? params.get("names")
167
- : params["names"];
168
- if (!raw)
169
- return new Set();
170
- return new Set(raw
171
- .split(",")
172
- .map((s) => s.trim())
173
- .filter((s) => s.length > 0));
174
- }
175
- function filterSnapshot(snap, names) {
176
- return Object.freeze({
177
- takenAt: snap.takenAt,
178
- counters: snap.counters.filter((c) => names.has(c.meta.name)),
179
- gauges: snap.gauges.filter((g) => names.has(g.meta.name)),
180
- histograms: snap.histograms.filter((h) => names.has(h.meta.name)),
181
- });
182
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * src/observability/index.ts — Public barrel for the observability package.
3
- *
4
- * Importers should prefer this entry over deep paths. The recording API
5
- * (`recordSearch`, `recordAnswer`, …) is the only thing 99% of callers need.
6
- */
7
- export * from "./types.js";
8
- export { MetricsRegistry, getDefaultRegistry, resetDefaultRegistry, } from "./registry.js";
9
- export type { RegistrySnapshot, AnyMetric } from "./registry.js";
10
- export { ALL_METRIC_NAMES, type MetricName, chunksTotal, embeddingsTotal, kgEntitiesTotal, kgRelationsTotal, searchRequestsTotal, searchDurationSeconds, searchResultsReturned, answerRequestsTotal, answerDurationSeconds, answerTokensTotal, providerCallsTotal, providerDurationSeconds, providerCostUsdTotal, providerTokensTotal, hooksEventsTotal, hooksPipelineDurationSeconds, viewerConnections, viewerEventsTotal, viewerDroppedTotal, dbSizeBytes, chunksActive, chunksStale, auditRowsTotal, processCpuUserSecondsTotal, processCpuSystemSecondsTotal, processResidentMemoryBytes, processOpenFds, nodejsEventloopLagSeconds, } from "./metrics.js";
11
- export { CardinalityGuard, getDefaultGuard, resetDefaultGuard, applyDefaultPolicies, } from "./cardinality.js";
12
- export { sanitizeString, sanitizeLabels, sanitizeLabelValue, guardLabels, } from "./privacy-guard.js";
13
- export { recordSearch, recordAnswer, recordProviderCall, recordChunkIngest, recordEmbedding, recordKgEntity, recordKgRelation, recordHookEvent, recordViewerConnect, recordViewerDisconnect, recordViewerEvent, recordViewerDropped, recordAuditWrite, startTimer, type SearchMethod, type SearchOutcome, type AnswerOutcome, type AnswerTiming, type ProviderKind, type ProviderOutcome, type ProvenanceKind, } from "./record.js";
14
- export { handle, render, OPENMETRICS_CONTENT_TYPE, PROMETHEUS_CONTENT_TYPE, type MetricsRequest, type MetricsResponse, type ExporterOpts, } from "./exporter.js";
15
- export { startProcessCollector, stopProcessCollector, collectOnce as collectProcessOnce, } from "./collectors/process.collector.js";
16
- export { startDbStatsCollector, stopDbStatsCollector, collectDbStats, } from "./collectors/db-stats.collector.js";
17
- export { startSearchTelemetryCollector, stopSearchTelemetryCollector, drain as drainSearchTelemetry, } from "./collectors/search-telemetry.collector.js";
18
- export { startProviderTelemetryCollector, stopProviderTelemetryCollector, drain as drainProviderTelemetry, } from "./collectors/provider-telemetry.collector.js";
19
- export { attachEventBusCollector, detachEventBusCollector, type EventBusLike, } from "./collectors/eventbus.collector.js";
20
- export { withAnswerMetrics, type AnswerHandler, type AnswerResult, } from "./adapters/p1-adapter.js";
21
- export { instrumentProviderCall, classifyProviderError, type ProviderCallMeta, type ProviderCallResult, type ProviderInner, } from "./adapters/a3-adapter.js";
22
- export { wrapBroadcast, trackConnection, reportBackpressureDrop, type BroadcastEvent, type BroadcastFn, type SocketLike, } from "./adapters/p5-adapter.js";
@@ -1,21 +0,0 @@
1
- /**
2
- * src/observability/index.ts — Public barrel for the observability package.
3
- *
4
- * Importers should prefer this entry over deep paths. The recording API
5
- * (`recordSearch`, `recordAnswer`, …) is the only thing 99% of callers need.
6
- */
7
- export * from "./types.js";
8
- export { MetricsRegistry, getDefaultRegistry, resetDefaultRegistry, } from "./registry.js";
9
- export { ALL_METRIC_NAMES, chunksTotal, embeddingsTotal, kgEntitiesTotal, kgRelationsTotal, searchRequestsTotal, searchDurationSeconds, searchResultsReturned, answerRequestsTotal, answerDurationSeconds, answerTokensTotal, providerCallsTotal, providerDurationSeconds, providerCostUsdTotal, providerTokensTotal, hooksEventsTotal, hooksPipelineDurationSeconds, viewerConnections, viewerEventsTotal, viewerDroppedTotal, dbSizeBytes, chunksActive, chunksStale, auditRowsTotal, processCpuUserSecondsTotal, processCpuSystemSecondsTotal, processResidentMemoryBytes, processOpenFds, nodejsEventloopLagSeconds, } from "./metrics.js";
10
- export { CardinalityGuard, getDefaultGuard, resetDefaultGuard, applyDefaultPolicies, } from "./cardinality.js";
11
- export { sanitizeString, sanitizeLabels, sanitizeLabelValue, guardLabels, } from "./privacy-guard.js";
12
- export { recordSearch, recordAnswer, recordProviderCall, recordChunkIngest, recordEmbedding, recordKgEntity, recordKgRelation, recordHookEvent, recordViewerConnect, recordViewerDisconnect, recordViewerEvent, recordViewerDropped, recordAuditWrite, startTimer, } from "./record.js";
13
- export { handle, render, OPENMETRICS_CONTENT_TYPE, PROMETHEUS_CONTENT_TYPE, } from "./exporter.js";
14
- export { startProcessCollector, stopProcessCollector, collectOnce as collectProcessOnce, } from "./collectors/process.collector.js";
15
- export { startDbStatsCollector, stopDbStatsCollector, collectDbStats, } from "./collectors/db-stats.collector.js";
16
- export { startSearchTelemetryCollector, stopSearchTelemetryCollector, drain as drainSearchTelemetry, } from "./collectors/search-telemetry.collector.js";
17
- export { startProviderTelemetryCollector, stopProviderTelemetryCollector, drain as drainProviderTelemetry, } from "./collectors/provider-telemetry.collector.js";
18
- export { attachEventBusCollector, detachEventBusCollector, } from "./collectors/eventbus.collector.js";
19
- export { withAnswerMetrics, } from "./adapters/p1-adapter.js";
20
- export { instrumentProviderCall, classifyProviderError, } from "./adapters/a3-adapter.js";
21
- export { wrapBroadcast, trackConnection, reportBackpressureDrop, } from "./adapters/p5-adapter.js";
@@ -1,53 +0,0 @@
1
- /**
2
- * src/observability/metrics.ts — Standard metric catalog (T3).
3
- *
4
- * Single source of truth for every metric exported by nox-mem. Each metric is
5
- * defined as a singleton attached to the default registry on first import.
6
- *
7
- * Naming convention (Prometheus + OpenMetrics best practices):
8
- * - snake_case
9
- * - prefix `nox_` for nox-mem metrics, `process_` / `nodejs_` for runtime
10
- * - `_total` suffix for Counter
11
- * - `_seconds` / `_bytes` for unit-bearing observations
12
- *
13
- * Cardinality budget per metric is conservative — see ./cardinality.ts.
14
- *
15
- * NOTE: Importing this module is a side-effect: it registers metrics into the
16
- * default registry. Tests using a fresh `new MetricsRegistry()` must either
17
- * import this and use the same singletons, or define their own metrics.
18
- */
19
- import { Counter, Gauge, Histogram } from "./types.js";
20
- export declare const chunksTotal: Counter;
21
- export declare const embeddingsTotal: Counter;
22
- export declare const kgEntitiesTotal: Counter;
23
- export declare const kgRelationsTotal: Counter;
24
- export declare const searchRequestsTotal: Counter;
25
- export declare const searchDurationSeconds: Histogram;
26
- export declare const searchResultsReturned: Histogram;
27
- export declare const answerRequestsTotal: Counter;
28
- export declare const answerDurationSeconds: Histogram;
29
- export declare const answerTokensTotal: Counter;
30
- export declare const providerCallsTotal: Counter;
31
- export declare const providerDurationSeconds: Histogram;
32
- export declare const providerCostUsdTotal: Counter;
33
- export declare const providerTokensTotal: Counter;
34
- export declare const hooksEventsTotal: Counter;
35
- export declare const hooksPipelineDurationSeconds: Histogram;
36
- export declare const viewerConnections: Gauge;
37
- export declare const viewerEventsTotal: Counter;
38
- export declare const viewerDroppedTotal: Counter;
39
- export declare const dbSizeBytes: Gauge;
40
- export declare const chunksActive: Gauge;
41
- export declare const chunksStale: Gauge;
42
- export declare const auditRowsTotal: Counter;
43
- export declare const processCpuUserSecondsTotal: Counter;
44
- export declare const processCpuSystemSecondsTotal: Counter;
45
- export declare const processResidentMemoryBytes: Gauge;
46
- export declare const processOpenFds: Gauge;
47
- export declare const nodejsEventloopLagSeconds: Gauge;
48
- /**
49
- * Names of every metric registered by this module.
50
- * Order: same as registration order above.
51
- */
52
- export declare const ALL_METRIC_NAMES: readonly ["nox_chunks_total", "nox_embeddings_total", "nox_kg_entities_total", "nox_kg_relations_total", "nox_search_requests_total", "nox_search_duration_seconds", "nox_search_results_returned", "nox_answer_requests_total", "nox_answer_duration_seconds", "nox_answer_tokens_total", "nox_provider_calls_total", "nox_provider_duration_seconds", "nox_provider_cost_usd_total", "nox_provider_tokens_total", "nox_hooks_events_total", "nox_hooks_pipeline_duration_seconds", "nox_viewer_connections", "nox_viewer_events_total", "nox_viewer_dropped_total", "nox_db_size_bytes", "nox_chunks_active", "nox_chunks_stale", "nox_audit_rows_total", "process_cpu_user_seconds_total", "process_cpu_system_seconds_total", "process_resident_memory_bytes", "process_open_fds", "nodejs_eventloop_lag_seconds"];
53
- export type MetricName = (typeof ALL_METRIC_NAMES)[number];