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,150 +0,0 @@
1
- // F15 SEH (2026-05-03): self-evolving hooks via CLI telemetry.
2
- // Cada subcomando registra stats; insights derivados detectam regressions e features dormentes.
3
- import { getDb } from "./db.js";
4
- export function ensureCliTelemetry() {
5
- const db = getDb();
6
- db.exec(`
7
- CREATE TABLE IF NOT EXISTS cli_telemetry (
8
- id INTEGER PRIMARY KEY AUTOINCREMENT,
9
- command TEXT NOT NULL,
10
- args_summary TEXT,
11
- status TEXT NOT NULL CHECK(status IN ('success','failed','timeout')),
12
- duration_ms INTEGER NOT NULL,
13
- ts TEXT DEFAULT (datetime('now'))
14
- );
15
- CREATE INDEX IF NOT EXISTS idx_cli_telemetry_cmd ON cli_telemetry(command, ts);
16
- CREATE INDEX IF NOT EXISTS idx_cli_telemetry_ts ON cli_telemetry(ts);
17
- -- CODE-FIX HIGH: covering index for p95 single-pass per command
18
- CREATE INDEX IF NOT EXISTS idx_cli_telemetry_cmd_dur ON cli_telemetry(command, duration_ms);
19
- `);
20
- }
21
- // SEC-FIX HIGH #5: redaction defensiva — bloqueia secrets em args_summary
22
- const SECRET_PATTERN = /(api[_-]?key|token|password|passwd|secret|bearer|auth)[=\s:]+\S+/gi;
23
- function redactSecrets(s) {
24
- if (!s)
25
- return null;
26
- return s.replace(SECRET_PATTERN, "$1=***").substring(0, 200); // cap length
27
- }
28
- export function recordCliRun(opts) {
29
- if (process.env.NOX_CLI_TELEMETRY === "0")
30
- return; // opt-out
31
- try {
32
- const db = getDb();
33
- ensureCliTelemetry();
34
- // SEC-FIX HIGH #5: SEMPRE redact mesmo que caller passe raw (defesa em camadas)
35
- const safeArgs = redactSecrets(opts.argsSummary);
36
- db.prepare("INSERT INTO cli_telemetry (command, args_summary, status, duration_ms) VALUES (?, ?, ?, ?)").run(opts.command, safeArgs, opts.status, Math.round(opts.durationMs));
37
- }
38
- catch {
39
- // fail-open: telemetry never blocks user work
40
- }
41
- }
42
- export function computeCliInsights(opts = {}) {
43
- const start = Date.now();
44
- const db = getDb();
45
- ensureCliTelemetry();
46
- const windowDays = opts.windowDays ?? 7;
47
- const total7dRow = db.prepare(`SELECT COUNT(*) AS c FROM cli_telemetry WHERE ts > datetime('now', '-' || ? || ' days')`).get(windowDays);
48
- const totalAllRow = db.prepare("SELECT COUNT(*) AS c FROM cli_telemetry").get();
49
- const uniqueRow = db.prepare("SELECT COUNT(DISTINCT command) AS c FROM cli_telemetry").get();
50
- // Per-command stats — CODE-FIX HIGH: single-pass com all rows + agrupamento in-memory
51
- // (era N+1 query: 1 GROUP BY + 1 OFFSET por comando). Agora 1 query covering index.
52
- // CODE-FIX MEDIUM: julianday em vez de naive Date+Z (timezone-safe)
53
- const allRuns = db.prepare(`SELECT command, status, duration_ms, ts,
54
- ROUND((julianday('now') - julianday(ts)), 0) AS days_ago
55
- FROM cli_telemetry ORDER BY command, duration_ms ASC`).all();
56
- const groupMap = new Map();
57
- for (const r of allRuns) {
58
- if (!groupMap.has(r.command))
59
- groupMap.set(r.command, []);
60
- groupMap.get(r.command).push(r);
61
- }
62
- const byCommand = Array.from(groupMap.entries()).map(([cmd, runs]) => {
63
- const total = runs.length;
64
- const success = runs.filter((r) => r.status === 'success').length;
65
- const failed = total - success;
66
- const avg = Math.round((runs.reduce((s, r) => s + r.duration_ms, 0) / total) * 10) / 10;
67
- // p95 via in-memory sorted access (runs already sorted asc por SQL ORDER BY)
68
- const p95Idx = Math.max(0, Math.floor(total * 0.95) - 1);
69
- const p95 = runs[p95Idx]?.duration_ms ?? avg;
70
- const lastRun = runs.reduce((latest, r) => r.ts > latest ? r.ts : latest, "");
71
- const daysSince = Math.min(...runs.map((r) => r.days_ago));
72
- return {
73
- command: cmd,
74
- total_runs: total,
75
- success_rate: total === 0 ? 0 : Math.round((success / total) * 1000) / 10,
76
- failed_runs: failed,
77
- avg_duration_ms: avg,
78
- p95_duration_ms: p95,
79
- last_run_at: lastRun,
80
- days_since_last_run: daysSince,
81
- };
82
- }).sort((a, b) => b.total_runs - a.total_runs);
83
- const slowCommands = [...byCommand]
84
- .filter((c) => c.p95_duration_ms > 5000) // > 5s
85
- .sort((a, b) => b.p95_duration_ms - a.p95_duration_ms)
86
- .slice(0, 5);
87
- const errorProne = [...byCommand]
88
- .filter((c) => c.total_runs >= 3 && c.success_rate < 90)
89
- .sort((a, b) => a.success_rate - b.success_rate)
90
- .slice(0, 5);
91
- const dormantCommands = [...byCommand]
92
- .filter((c) => c.days_since_last_run >= 14)
93
- .sort((a, b) => b.days_since_last_run - a.days_since_last_run)
94
- .slice(0, 5);
95
- const recentErrors = db.prepare(`SELECT command, ts, duration_ms FROM cli_telemetry
96
- WHERE status != 'success' AND ts > datetime('now', '-' || ? || ' days')
97
- ORDER BY ts DESC LIMIT 10`).all(windowDays);
98
- return {
99
- total_runs_7d: total7dRow.c,
100
- total_runs_alltime: totalAllRow.c,
101
- unique_commands: uniqueRow.c,
102
- by_command: byCommand,
103
- slow_commands: slowCommands,
104
- error_prone_commands: errorProne,
105
- dormant_commands: dormantCommands,
106
- recent_errors: recentErrors,
107
- duration_ms: Date.now() - start,
108
- };
109
- }
110
- export function formatCliInsights(insights, mode = 'text') {
111
- if (mode === 'json')
112
- return JSON.stringify(insights, null, 2);
113
- const lines = [];
114
- lines.push(`## CLI Telemetry Insights (F15 SEH)`);
115
- lines.push(`Total runs 7d: ${insights.total_runs_7d} | All-time: ${insights.total_runs_alltime} | Unique commands: ${insights.unique_commands} | Computed in ${insights.duration_ms}ms`);
116
- if (insights.total_runs_alltime === 0) {
117
- lines.push(`\n(no telemetry data yet — run a few subcomandos pra populate)`);
118
- return lines.join("\n");
119
- }
120
- lines.push(`\n### 📊 Top 10 most-used commands`);
121
- for (const c of insights.by_command.slice(0, 10)) {
122
- const sr = c.success_rate.toFixed(1);
123
- lines.push(` ${c.command.padEnd(20)} runs=${String(c.total_runs).padStart(5)} sr=${sr}% avg=${c.avg_duration_ms}ms p95=${c.p95_duration_ms}ms last=${c.days_since_last_run}d`);
124
- }
125
- if (insights.slow_commands.length > 0) {
126
- lines.push(`\n### 🐢 Slow commands (p95 > 5s)`);
127
- for (const c of insights.slow_commands) {
128
- lines.push(` ${c.command} — p95=${c.p95_duration_ms}ms (avg=${c.avg_duration_ms}ms, runs=${c.total_runs})`);
129
- }
130
- }
131
- if (insights.error_prone_commands.length > 0) {
132
- lines.push(`\n### ⚠️ Error-prone commands (success_rate < 90%, runs ≥ 3)`);
133
- for (const c of insights.error_prone_commands) {
134
- lines.push(` ${c.command} — sr=${c.success_rate}% (${c.failed_runs}/${c.total_runs} failed)`);
135
- }
136
- }
137
- if (insights.dormant_commands.length > 0) {
138
- lines.push(`\n### 💤 Dormant commands (last run > 14d)`);
139
- for (const c of insights.dormant_commands) {
140
- lines.push(` ${c.command} — last=${c.days_since_last_run}d ago (total runs=${c.total_runs})`);
141
- }
142
- }
143
- if (insights.recent_errors.length > 0) {
144
- lines.push(`\n### 🔴 Recent errors (last ${insights.recent_errors.length})`);
145
- for (const e of insights.recent_errors) {
146
- lines.push(` ${e.ts} ${e.command} (${e.duration_ms}ms)`);
147
- }
148
- }
149
- return lines.join("\n");
150
- }
package/dist/compact.d.ts DELETED
@@ -1,7 +0,0 @@
1
- interface CompactResult {
2
- compacted: number;
3
- deleted: number;
4
- summaries: number;
5
- }
6
- export declare function compact(ageDays?: number, dryRun?: boolean): Promise<CompactResult>;
7
- export {};
@@ -1,18 +0,0 @@
1
- export interface NotionItem {
2
- title: string;
3
- date: string;
4
- category: string;
5
- content: string;
6
- source: string;
7
- }
8
- export declare function consolidate(options?: {
9
- retryFailed?: boolean;
10
- dryRun?: boolean;
11
- }): Promise<{
12
- processed: number;
13
- extracted: number;
14
- skipped: number;
15
- remaining: number;
16
- notionItems: NotionItem[];
17
- dryRun?: boolean;
18
- }>;
@@ -1,32 +0,0 @@
1
- export interface MergeCandidate {
2
- primary: {
3
- id: number;
4
- name: string;
5
- type: string;
6
- mentions: number;
7
- };
8
- duplicate: {
9
- id: number;
10
- name: string;
11
- type: string;
12
- mentions: number;
13
- };
14
- similarity: number;
15
- reason: 'exact_lower' | 'substring' | 'levenshtein' | 'normalized';
16
- shared_evidence_chunks: number;
17
- fp_risk: 'low' | 'medium' | 'high';
18
- fp_reasons: string[];
19
- }
20
- export interface ConsolidationResult {
21
- scanned_entities: number;
22
- candidate_pairs: number;
23
- by_type: Record<string, number>;
24
- by_fp_risk: Record<string, number>;
25
- candidates: MergeCandidate[];
26
- duration_ms: number;
27
- }
28
- export declare function findMergeCandidates(opts?: {
29
- minSim?: number;
30
- maxPerType?: number;
31
- }): ConsolidationResult;
32
- export declare function formatConsolidation(r: ConsolidationResult, mode?: 'json' | 'text', limit?: number): string;
@@ -1,45 +0,0 @@
1
- export interface AgentProfile {
2
- agent: string;
3
- totalChunks: number;
4
- topTypes: Array<{
5
- type: string;
6
- count: number;
7
- }>;
8
- topTopics: string[];
9
- lastActivity: string | null;
10
- uniqueStrength: string;
11
- }
12
- export declare function profileAgent(agentName: string): AgentProfile | null;
13
- export declare function profileAllAgents(): AgentProfile[];
14
- export interface SharedInsight {
15
- agent: string;
16
- type: string;
17
- text: string;
18
- date: string | null;
19
- relevance: number;
20
- }
21
- export declare function pullInsightsFrom(sourceAgent: string, types?: string[], limit?: number): SharedInsight[];
22
- export declare function pullAllInsights(excludeAgent?: string, types?: string[], limitPerAgent?: number): SharedInsight[];
23
- export interface CrossEntity {
24
- name: string;
25
- type: string;
26
- agents: string[];
27
- totalMentions: number;
28
- }
29
- export declare function mergeCrossKnowledgeGraphs(): {
30
- entities: CrossEntity[];
31
- totalRelations: number;
32
- };
33
- export declare function findPath(startName: string, endName: string, maxDepth?: number): Array<{
34
- entity: string;
35
- relation: string;
36
- }> | null;
37
- export declare function formatProfiles(profiles: AgentProfile[]): string;
38
- export declare function formatPath(path: Array<{
39
- entity: string;
40
- relation: string;
41
- }> | null): string;
42
- export declare function formatCrossKG(result: {
43
- entities: CrossEntity[];
44
- totalRelations: number;
45
- }): string;
@@ -1,11 +0,0 @@
1
- export interface CrossSearchResult {
2
- agent: string;
3
- score: number;
4
- source_file: string;
5
- chunk_type: string;
6
- chunk_text: string;
7
- source_date: string | null;
8
- }
9
- export declare function crossSearch(query: string, limit?: number): CrossSearchResult[];
10
- export declare function formatCrossResults(results: CrossSearchResult[]): string;
11
- export declare function getCrossStats(): string;
@@ -1,43 +0,0 @@
1
- interface ProcedureInput {
2
- title: string;
3
- steps: string[];
4
- agent?: string;
5
- tags?: string[];
6
- preconditions?: string[];
7
- }
8
- export interface ValidationEntry {
9
- timestamp: string;
10
- outcome: "success" | "failure" | "partial";
11
- agent: string;
12
- notes?: string;
13
- }
14
- export interface ValidationOptions {
15
- outcome?: "success" | "failure" | "partial";
16
- agent?: string;
17
- notes?: string;
18
- }
19
- /**
20
- * Save a procedure as a type=procedure chunk and (best-effort) embed it
21
- * immediately so it is hybrid-searchable without waiting for the weekly
22
- * vectorize cron. Embedding failure never aborts the save — FTS still works.
23
- */
24
- export declare function crystallize(input: ProcedureInput): Promise<number>;
25
- /**
26
- * Record a validation attempt for a procedure. Each call appends a structured
27
- * entry to metadata.validations[] so we can track WHO validated, WHEN, and
28
- * whether the run succeeded/failed/partial. Outcome defaults to "success"
29
- * to preserve the old boolean-flip behavior for callers that pass no args.
30
- */
31
- export declare function validateProcedure(chunkId: number, options?: ValidationOptions): void;
32
- export declare function listProcedures(): Array<{
33
- id: number;
34
- title: string;
35
- validated: boolean;
36
- steps: number;
37
- agent: string;
38
- validations: number;
39
- successRate: number | null;
40
- lastValidated: string | null;
41
- }>;
42
- export declare function formatProcedureList(procs: ReturnType<typeof listProcedures>): string;
43
- export {};
package/dist/db.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import Database from "better-sqlite3";
2
- export declare const DB_PATH: string;
3
- export declare const BACKUP_DIR: string;
4
- export declare function checkLargeDbIngestGuard(db: Database.Database, operation: string): void;
5
- export declare function getDb(): Database.Database;
6
- export declare function closeDb(): void;
7
- /**
8
- * Backup SQLite using the online backup API (safe even during writes).
9
- * Retains up to `keepDays` daily backups.
10
- */
11
- export declare function backupDb(keepDays?: number): string;
package/dist/dedup.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function isDuplicate(text: string, sourceFile: string, chunkType: string): Promise<boolean>;
@@ -1,29 +0,0 @@
1
- export interface ChangedFile {
2
- path: string;
3
- status: string;
4
- is_entity_file: boolean;
5
- entity_type?: string;
6
- entity_slug?: string;
7
- }
8
- export interface AffectedEntity {
9
- name: string;
10
- type: string;
11
- mention_count: number;
12
- source_files: string[];
13
- via: 'entity_file' | 'chunk_reference';
14
- }
15
- export interface DetectChangesResult {
16
- since: string;
17
- head: string;
18
- repo: string;
19
- files_changed: number;
20
- files: ChangedFile[];
21
- affected_entities: AffectedEntity[];
22
- scanned_chunks: number;
23
- duration_ms: number;
24
- }
25
- export declare function detectChanges(opts: {
26
- since: string;
27
- repo: string;
28
- }): DetectChangesResult;
29
- export declare function formatDetectChanges(r: DetectChangesResult, mode?: 'json' | 'text'): string;
package/dist/digest.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function digest(): Promise<void>;
package/dist/doctor.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function doctor(): Promise<void>;
package/dist/embed.d.ts DELETED
@@ -1,57 +0,0 @@
1
- /**
2
- * embed.ts - Semantic embedding via Gemini API (gemini-embedding-001, 768-dim)
3
- * Uses the same API key already configured in the OpenClaw gateway.
4
- * Zero local model weight, zero sqlite-vec binding issues.
5
- *
6
- * Provider routing (added 2026-06-15):
7
- * When NOX_EMBEDDING_PROVIDER / NOX_EMBED_PROVIDER is set to anything other
8
- * than "gemini" (the default), embedding calls are delegated to the abstract
9
- * EmbeddingProvider from src/providers/. The native Gemini path (taskType-aware
10
- * RETRIEVAL_DOCUMENT / RETRIEVAL_QUERY) is preserved 100% when using gemini.
11
- */
12
- import Database from "better-sqlite3";
13
- declare const EMBEDDING_DIM = 3072;
14
- /**
15
- * Returns the effective embedding dimension for the current provider.
16
- * Priority: provider.dimensions > NOX_EMBEDDING_DIM / NOX_EMBED_DIM env > EMBEDDING_DIM (3072).
17
- * Used by ensureVecTable so the vec0 column matches whatever provider is active.
18
- */
19
- export declare function activeEmbeddingDim(): number;
20
- export declare function embedText(text: string): Promise<Float32Array>;
21
- /**
22
- * True batch embedding via Gemini batchEmbedContents API.
23
- * Sends up to `batchSize` texts per HTTP call (default 50) — on gemini-embedding-001
24
- * at 3072d we've measured ~13x throughput vs the per-text loop.
25
- * Pauses `pauseMs` between batches to stay under 100 RPM on the free tier.
26
- */
27
- export declare function embedBatchAPI(texts: string[], options?: {
28
- batchSize?: number;
29
- pauseMs?: number;
30
- onProgress?: (done: number, total: number) => void;
31
- }): Promise<Float32Array[]>;
32
- /**
33
- * Legacy serial embedBatch kept for callers that still use it; now delegates
34
- * to the batch API with batchSize=1 preserved only to keep error-per-item
35
- * semantics where they exist. Prefer embedBatchAPI for new code.
36
- */
37
- export declare function embedBatch(texts: string[]): Promise<Float32Array[]>;
38
- /**
39
- * sqlite-vec v0.1.x compatibility note:
40
- * - Does NOT support named INTEGER PRIMARY KEY columns
41
- * - DOES support rowid-based inserts
42
- * - We use a companion table (vec_chunk_map) to map rowid → chunk_id
43
- * - Schema: vec_chunks has only `embedding` column, rowid = auto
44
- * vec_chunk_map(vec_rowid, chunk_id) tracks the mapping
45
- */
46
- export declare function ensureVecTable(db: Database.Database): void;
47
- export declare function upsertEmbedding(db: Database.Database, chunkId: number, embedding: Float32Array): void;
48
- export declare function semanticSearch(db: Database.Database, queryEmbedding: Float32Array, limit?: number): Array<{
49
- chunk_id: number;
50
- distance: number;
51
- source_file: string;
52
- chunk_type: string;
53
- chunk_text: string;
54
- source_date: string | null;
55
- }>;
56
- export declare function countEmbedded(db: Database.Database): number;
57
- export { EMBEDDING_DIM };
package/dist/evals.d.ts DELETED
@@ -1,176 +0,0 @@
1
- /**
2
- * evals.ts — F10 Phase B endpoint (Eval Dashboard)
3
- *
4
- * Adds one read-only endpoint under `/api/observability/*`:
5
- *
6
- * GET /api/observability/evals?db_source=<filter>&limit=<n>
7
- * Returns the historical ablation/gate runs aggregated from `audits/data-G*`
8
- * directories on disk. Each row carries enough metric breadth to drive the
9
- * dashboard (nDCG@10, MRR, recall@10), the DB it ran against (for the post-G6
10
- * fiasco filter — see [[g6-ablation-results-2026-05-20]]), and a list of gate
11
- * annotations that match its run date.
12
- *
13
- * Source data layer
14
- * -----------------
15
- * The audits directory is heterogeneous:
16
- *
17
- * audits/data-g10b/*.json → {summary, per_category} per run (a8 mutex active/disabled)
18
- * audits/data-g10c/*.json → derived aggregate: {aggregate.active, aggregate.disabled,
19
- * per_style_active, per_style_disabled}
20
- * audits/data-g10d/*.json → {summary, per_category} per t-threshold (a8d_t1/t2/baseline/control)
21
- * audits/data-g10e/*.json → derived per-query diff array (NOT a run aggregate — skipped)
22
- *
23
- * Each "summary" block has:
24
- * { label, toggles, n_queries, fixture_dir, endpoint, ndcg_at_10, mrr,
25
- * recall_at_10, precision_at_5, mean_latency_ms, p95_latency_ms,
26
- * n_valid_queries, wallclock_s }
27
- *
28
- * Adapter strategy:
29
- * - Walk `audits/data-<X>/` directories.
30
- * - For each .json file, sniff the shape:
31
- * (a) `{ summary, per_category, ... }` → emit one row from summary
32
- * (b) `{ aggregate: { active, disabled }, ... }` → emit two rows (one per agg key)
33
- * (c) anything else (e.g. per-query derived array) → skip with a warn to stderr
34
- * - `ran_at` = file mtime (UTC ISO), since aggregate JSONs don't carry a wall-clock.
35
- * - `db_source` = parsed from `summary.fixture_dir` (last path component → e.g.
36
- * "g9-g5db-2026-05-20" → "g5.db"; the convention is documented in
37
- * [[g6-ablation-results-2026-05-20]] and [[g10-mutex-validated-2026-05-20]]).
38
- * - `config_id` = `summary.label` (already unique per run).
39
- * - `run_id` = `<G-bucket>::<label>` for stability across reads.
40
- *
41
- * Annotations:
42
- * - Loaded from `public/observability/gate-annotations.json` once per process.
43
- * - A row gets every annotation whose date falls on the same UTC calendar day.
44
- *
45
- * Caching:
46
- * - 5-minute in-memory TTL (spec allows). Single-process server, no infra.
47
- * - Test harness exposes `_resetEvalsCache()` to clear state between cases.
48
- *
49
- * Spec: specs/2026-05-01-F10-observability-dashboard.md §"P1 EVAL DASHBOARD"
50
- * Status: Phase B implementation-ready
51
- */
52
- export interface EvalRow {
53
- run_id: string;
54
- config_id: string;
55
- db_source: string;
56
- ndcg_at_10: number | null;
57
- mrr: number | null;
58
- recall_at_10: number | null;
59
- precision_at_5: number | null;
60
- mean_latency_ms: number | null;
61
- p95_latency_ms: number | null;
62
- n_queries: number | null;
63
- ran_at: string;
64
- ran_at_ms: number;
65
- source_path: string;
66
- annotations: string[];
67
- }
68
- export interface GateAnnotation {
69
- date: string;
70
- label: string;
71
- description?: string;
72
- }
73
- interface SummaryShape {
74
- label?: unknown;
75
- toggles?: unknown;
76
- n_queries?: unknown;
77
- fixture_dir?: unknown;
78
- endpoint?: unknown;
79
- ndcg_at_10?: unknown;
80
- mrr?: unknown;
81
- recall_at_10?: unknown;
82
- precision_at_5?: unknown;
83
- mean_latency_ms?: unknown;
84
- p95_latency_ms?: unknown;
85
- n_valid_queries?: unknown;
86
- wallclock_s?: unknown;
87
- }
88
- /**
89
- * Maps the fixture_dir leaf to the canonical DB filename, the way the team
90
- * tracks DBs in audits. The convention (per [[g6-ablation-results-2026-05-20]]
91
- * and follow-ups) is that a fixture directory contains a substring naming the
92
- * DB the eval was actually run against.
93
- *
94
- * Examples seen on disk:
95
- * /path/to/workspace/eval-data/g9-g5db-2026-05-20 → "g5.db"
96
- * /…/eval-data/entity-eval-v2 → "entity-eval-v2.db"
97
- * /…/eval-data/entity-eval → "entity-eval.db"
98
- * /…/eval-data/g9 → "g9.db"
99
- *
100
- * Returns "unknown.db" if no match. Tests must cover the unknown fallback.
101
- */
102
- export declare function inferDbSource(fixtureDir: string | null): string;
103
- /**
104
- * Bucket key derived from the data-Gxx directory name. Used for stable run_ids
105
- * and as a fallback config grouping in the UI.
106
- */
107
- export declare function gateBucketFromDir(dir: string): string;
108
- declare function toNumOrNull(v: unknown): number | null;
109
- declare function toStringOrNull(v: unknown): string | null;
110
- /**
111
- * Returns the YYYY-MM-DD UTC calendar string for an ms timestamp. ISO substring
112
- * is intentional — keeps the implementation portable across Node versions and
113
- * avoids a Date locale dependency.
114
- */
115
- export declare function isoDay(ms: number): string;
116
- /**
117
- * Picks every annotation whose `date` matches the run's UTC calendar day.
118
- * Returns label strings (not the full object) — the UI only needs the labels
119
- * to overlay vertical lines + tooltips, and richer data lives in the gate file.
120
- */
121
- export declare function matchAnnotations(ranAtMs: number, annotations: GateAnnotation[]): string[];
122
- /**
123
- * Parses one audit JSON file into a list of normalized EvalRow.
124
- *
125
- * Returns `[]` (with stderr warning) when the file is unreadable, malformed,
126
- * or carries a shape we explicitly do not aggregate (e.g. per-query diff arrays).
127
- * Never throws — endpoint hardening per spec.
128
- */
129
- export declare function parseAuditFile(filePath: string, fileMtimeMs: number, bucket: string, annotations: GateAnnotation[]): EvalRow[];
130
- declare function rowFromSummary(s: SummaryShape, filePath: string, bucket: string, ranAt: string, ranAtMs: number, annotations: string[], configSuffix: string | null): EvalRow | null;
131
- /**
132
- * Returns the sorted absolute paths of `audits/data-*` JSON files under the
133
- * given root. Best-effort: directories that disappear mid-walk are skipped.
134
- */
135
- export declare function collectAuditFiles(auditsRoot: string): Array<{
136
- file: string;
137
- bucket: string;
138
- mtimeMs: number;
139
- }>;
140
- /**
141
- * Best-effort load of the gate-annotations.json file. Returns `[]` on missing
142
- * file, parse error, or wrong shape — callers tolerate empty annotation list.
143
- */
144
- export declare function loadAnnotations(filePath: string): GateAnnotation[];
145
- /** Exposed for tests. */
146
- export declare function _resetEvalsCache(): void;
147
- export interface EvalsQuery {
148
- /** Filter by db_source (e.g. "g5.db"). "all" or undefined = no filter. */
149
- dbSource?: string;
150
- /** Limit (default 500, max 2000). */
151
- limit?: number;
152
- /** Force refresh (skip TTL). */
153
- force?: boolean;
154
- }
155
- export interface EvalsHandlerOptions {
156
- auditsRoot?: string;
157
- annotationsPath?: string;
158
- ttlMs?: number;
159
- now?: () => number;
160
- }
161
- /**
162
- * Build the row list from disk (no cache). Useful for tests.
163
- */
164
- export declare function buildEvalRows(opts?: EvalsHandlerOptions): EvalRow[];
165
- /**
166
- * Endpoint handler. Returns an array of EvalRow already sorted by ran_at ASC,
167
- * filtered by db_source if requested, and capped to `limit`.
168
- */
169
- export declare function handleObsEvals(query?: EvalsQuery, opts?: EvalsHandlerOptions): EvalRow[];
170
- export declare const _internals: {
171
- DEFAULT_TTL_MS: number;
172
- toNumOrNull: typeof toNumOrNull;
173
- toStringOrNull: typeof toStringOrNull;
174
- rowFromSummary: typeof rowFromSummary;
175
- };
176
- export {};