nox-mem 3.1.1 → 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 (397) 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 +1 -22
  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/privacy/__tests__/filter.test.js +352 -0
  39. package/dist/providers/__tests__/conformance-extended.test.js +249 -0
  40. package/dist/providers/__tests__/conformance.test.js +98 -0
  41. package/dist/providers/__tests__/cost-cap.test.js +151 -0
  42. package/dist/providers/__tests__/e2e-real.test.js +79 -0
  43. package/dist/providers/__tests__/factory.test.js +80 -0
  44. package/dist/providers/__tests__/fallback.test.js +223 -0
  45. package/dist/providers/__tests__/gemini.test.js +191 -0
  46. package/dist/providers/__tests__/health.test.js +128 -0
  47. package/dist/providers/__tests__/telemetry.test.js +219 -0
  48. package/dist/reindex.js +2 -2
  49. package/package.json +3 -4
  50. package/dist/api/answer.d.ts +0 -116
  51. package/dist/api/answer.validate-patch.d.ts +0 -72
  52. package/dist/api/brief-diversity.d.ts +0 -64
  53. package/dist/api/brief.d.ts +0 -114
  54. package/dist/api/conflict.d.ts +0 -33
  55. package/dist/api/conflict.js +0 -143
  56. package/dist/api/cors.d.ts +0 -73
  57. package/dist/api/events-stream-limited.d.ts +0 -133
  58. package/dist/api/events-stream-limited.js +0 -217
  59. package/dist/api/events-stream.d.ts +0 -53
  60. package/dist/api/events-stream.js +0 -125
  61. package/dist/api/export.d.ts +0 -42
  62. package/dist/api/export.js +0 -85
  63. package/dist/api/health-confidence-adapter.d.ts +0 -29
  64. package/dist/api/health-confidence-adapter.js +0 -73
  65. package/dist/api/health-confidence.d.ts +0 -36
  66. package/dist/api/health-confidence.js +0 -141
  67. package/dist/api/hooks.d.ts +0 -50
  68. package/dist/api/hooks.js +0 -115
  69. package/dist/api/import.d.ts +0 -38
  70. package/dist/api/import.js +0 -87
  71. package/dist/api/ingest-event.d.ts +0 -65
  72. package/dist/api/mark.d.ts +0 -42
  73. package/dist/api/mark.js +0 -127
  74. package/dist/api/server-deps-a2.d.ts +0 -55
  75. package/dist/api/server-deps-a2.js +0 -138
  76. package/dist/api/server-deps-l2-l3.d.ts +0 -68
  77. package/dist/api/server-deps-l2-l3.js +0 -123
  78. package/dist/api/server-deps-p1.d.ts +0 -84
  79. package/dist/api/server-deps-p2.d.ts +0 -32
  80. package/dist/api/server-deps-p2.js +0 -84
  81. package/dist/api/server-deps-p5.d.ts +0 -66
  82. package/dist/api/server-deps-p5.js +0 -139
  83. package/dist/api/viewer-static.d.ts +0 -30
  84. package/dist/api/viewer-static.js +0 -102
  85. package/dist/api/wire-up.d.ts +0 -54
  86. package/dist/api-impact.d.ts +0 -30
  87. package/dist/api-server.d.ts +0 -2
  88. package/dist/backfill-fts-anchor.d.ts +0 -15
  89. package/dist/backfill-source-type.d.ts +0 -20
  90. package/dist/churn.d.ts +0 -31
  91. package/dist/cli/answer.d.ts +0 -66
  92. package/dist/cli/conflict.d.ts +0 -38
  93. package/dist/cli/conflict.js +0 -282
  94. package/dist/cli/export.d.ts +0 -51
  95. package/dist/cli/export.js +0 -280
  96. package/dist/cli/hooks.d.ts +0 -54
  97. package/dist/cli/hooks.js +0 -133
  98. package/dist/cli/import.d.ts +0 -52
  99. package/dist/cli/import.js +0 -274
  100. package/dist/cli/mark.d.ts +0 -33
  101. package/dist/cli/mark.js +0 -130
  102. package/dist/cli/ocr-batch.d.ts +0 -12
  103. package/dist/cli/ocr-batch.js +0 -411
  104. package/dist/cli/snapshot-main.d.ts +0 -30
  105. package/dist/cli/snapshot-main.js +0 -47
  106. package/dist/cli/viewer.d.ts +0 -35
  107. package/dist/cli/viewer.js +0 -71
  108. package/dist/cli-telemetry.d.ts +0 -36
  109. package/dist/cli-telemetry.js +0 -150
  110. package/dist/compact.d.ts +0 -7
  111. package/dist/consolidate.d.ts +0 -18
  112. package/dist/consolidation.d.ts +0 -32
  113. package/dist/cross-agent-v2.d.ts +0 -45
  114. package/dist/cross-search.d.ts +0 -11
  115. package/dist/crystallize.d.ts +0 -43
  116. package/dist/db.d.ts +0 -11
  117. package/dist/dedup.d.ts +0 -1
  118. package/dist/detect-changes.d.ts +0 -29
  119. package/dist/digest.d.ts +0 -1
  120. package/dist/doctor.d.ts +0 -1
  121. package/dist/embed.d.ts +0 -57
  122. package/dist/evals.d.ts +0 -176
  123. package/dist/evals.js +0 -351
  124. package/dist/generate-user-profile.d.ts +0 -18
  125. package/dist/graphify-ingest.d.ts +0 -18
  126. package/dist/impact.d.ts +0 -39
  127. package/dist/index.d.ts +0 -2
  128. package/dist/ingest-entity.d.ts +0 -44
  129. package/dist/ingest.d.ts +0 -13
  130. package/dist/kg-llm.d.ts +0 -39
  131. package/dist/knowledge-graph.d.ts +0 -72
  132. package/dist/lib/answer/config.d.ts +0 -41
  133. package/dist/lib/answer/index.d.ts +0 -47
  134. package/dist/lib/answer/prompt.d.ts +0 -37
  135. package/dist/lib/answer/provider.d.ts +0 -47
  136. package/dist/lib/answer/retrieval.d.ts +0 -36
  137. package/dist/lib/answer/telemetry.d.ts +0 -99
  138. package/dist/lib/answer/types.d.ts +0 -108
  139. package/dist/lib/api/error-leak-fix.d.ts +0 -54
  140. package/dist/lib/api/safe-error-message.d.ts +0 -70
  141. package/dist/lib/archive/common-passwords.d.ts +0 -37
  142. package/dist/lib/archive/common-passwords.js +0 -753
  143. package/dist/lib/archive/encryption.d.ts +0 -81
  144. package/dist/lib/archive/encryption.js +0 -236
  145. package/dist/lib/archive/enforce-strength.d.ts +0 -54
  146. package/dist/lib/archive/enforce-strength.js +0 -70
  147. package/dist/lib/archive/entropy.d.ts +0 -34
  148. package/dist/lib/archive/entropy.js +0 -180
  149. package/dist/lib/archive/export-locking.d.ts +0 -102
  150. package/dist/lib/archive/export-locking.js +0 -202
  151. package/dist/lib/archive/format.d.ts +0 -20
  152. package/dist/lib/archive/format.js +0 -174
  153. package/dist/lib/archive/index.d.ts +0 -23
  154. package/dist/lib/archive/index.js +0 -17
  155. package/dist/lib/archive/manifest.d.ts +0 -53
  156. package/dist/lib/archive/manifest.js +0 -183
  157. package/dist/lib/archive/migration.d.ts +0 -36
  158. package/dist/lib/archive/migration.js +0 -100
  159. package/dist/lib/archive/migrations/v18_to_v19.d.ts +0 -16
  160. package/dist/lib/archive/migrations/v18_to_v19.js +0 -18
  161. package/dist/lib/archive/orchestrator.d.ts +0 -166
  162. package/dist/lib/archive/orchestrator.js +0 -428
  163. package/dist/lib/archive/serializers/chunks.d.ts +0 -30
  164. package/dist/lib/archive/serializers/chunks.js +0 -113
  165. package/dist/lib/archive/serializers/embeddings.d.ts +0 -36
  166. package/dist/lib/archive/serializers/embeddings.js +0 -115
  167. package/dist/lib/archive/serializers/kg.d.ts +0 -28
  168. package/dist/lib/archive/serializers/kg.js +0 -184
  169. package/dist/lib/archive/serializers/ops_audit.d.ts +0 -21
  170. package/dist/lib/archive/serializers/ops_audit.js +0 -97
  171. package/dist/lib/archive/server-deps.d.ts +0 -131
  172. package/dist/lib/archive/server-deps.js +0 -232
  173. package/dist/lib/archive/strength.d.ts +0 -50
  174. package/dist/lib/archive/strength.js +0 -77
  175. package/dist/lib/archive/types.d.ts +0 -159
  176. package/dist/lib/archive/types.js +0 -45
  177. package/dist/lib/archive/unpack-streaming.d.ts +0 -70
  178. package/dist/lib/archive/unpack-streaming.js +0 -255
  179. package/dist/lib/auth/localhost-guard.d.ts +0 -106
  180. package/dist/lib/confidence/config.d.ts +0 -37
  181. package/dist/lib/confidence/config.js +0 -107
  182. package/dist/lib/confidence/db-shim-singleton.d.ts +0 -20
  183. package/dist/lib/confidence/db-shim-singleton.js +0 -41
  184. package/dist/lib/confidence/db-shim.d.ts +0 -47
  185. package/dist/lib/confidence/db-shim.js +0 -141
  186. package/dist/lib/confidence/mark.d.ts +0 -58
  187. package/dist/lib/confidence/mark.js +0 -168
  188. package/dist/lib/confidence/ranking.d.ts +0 -69
  189. package/dist/lib/confidence/ranking.js +0 -101
  190. package/dist/lib/confidence/search-filter.d.ts +0 -44
  191. package/dist/lib/confidence/search-filter.js +0 -103
  192. package/dist/lib/confidence/types.d.ts +0 -146
  193. package/dist/lib/confidence/types.js +0 -20
  194. package/dist/lib/confidence/write-hooks.d.ts +0 -50
  195. package/dist/lib/confidence/write-hooks.js +0 -159
  196. package/dist/lib/conflict/audit-fk-check.d.ts +0 -72
  197. package/dist/lib/conflict/audit-fk-check.js +0 -131
  198. package/dist/lib/conflict/audit-writer.d.ts +0 -39
  199. package/dist/lib/conflict/audit-writer.js +0 -133
  200. package/dist/lib/conflict/db-singleton.d.ts +0 -28
  201. package/dist/lib/conflict/db-singleton.js +0 -61
  202. package/dist/lib/conflict/db.d.ts +0 -27
  203. package/dist/lib/conflict/db.js +0 -20
  204. package/dist/lib/conflict/detector-direct.d.ts +0 -21
  205. package/dist/lib/conflict/detector-direct.js +0 -105
  206. package/dist/lib/conflict/evidence.d.ts +0 -24
  207. package/dist/lib/conflict/evidence.js +0 -76
  208. package/dist/lib/conflict/index.d.ts +0 -14
  209. package/dist/lib/conflict/index.js +0 -12
  210. package/dist/lib/conflict/scheduler.d.ts +0 -78
  211. package/dist/lib/conflict/scheduler.js +0 -111
  212. package/dist/lib/conflict/shadow.d.ts +0 -75
  213. package/dist/lib/conflict/shadow.js +0 -161
  214. package/dist/lib/conflict/types.d.ts +0 -133
  215. package/dist/lib/conflict/types.js +0 -19
  216. package/dist/lib/cost-cap.d.ts +0 -94
  217. package/dist/lib/deps/deps-registry.d.ts +0 -111
  218. package/dist/lib/error-sanitizer/middleware.d.ts +0 -43
  219. package/dist/lib/error-sanitizer/sanitize.d.ts +0 -78
  220. package/dist/lib/eval-batch.d.ts +0 -34
  221. package/dist/lib/eval-batch.js +0 -103
  222. package/dist/lib/eval-metrics.d.ts +0 -36
  223. package/dist/lib/eval-metrics.js +0 -95
  224. package/dist/lib/eval.d.ts +0 -106
  225. package/dist/lib/eval.js +0 -343
  226. package/dist/lib/events/bus.d.ts +0 -135
  227. package/dist/lib/fts-anchor.d.ts +0 -1
  228. package/dist/lib/hooks/classifier.d.ts +0 -47
  229. package/dist/lib/hooks/classifier.js +0 -129
  230. package/dist/lib/hooks/config.d.ts +0 -49
  231. package/dist/lib/hooks/config.js +0 -106
  232. package/dist/lib/hooks/decorators.d.ts +0 -35
  233. package/dist/lib/hooks/decorators.js +0 -59
  234. package/dist/lib/hooks/pipeline.d.ts +0 -76
  235. package/dist/lib/hooks/pipeline.js +0 -213
  236. package/dist/lib/hooks/privacy-filter-adapter.d.ts +0 -55
  237. package/dist/lib/hooks/privacy-filter-adapter.js +0 -84
  238. package/dist/lib/hooks/rate-limit-constant-time.d.ts +0 -57
  239. package/dist/lib/hooks/rate-limit-constant-time.js +0 -69
  240. package/dist/lib/hooks/rate-limit-dryrun-fix.d.ts +0 -71
  241. package/dist/lib/hooks/rate-limit-dryrun-fix.js +0 -110
  242. package/dist/lib/hooks/rate-limit.d.ts +0 -54
  243. package/dist/lib/hooks/rate-limit.js +0 -122
  244. package/dist/lib/hooks/server-deps.d.ts +0 -61
  245. package/dist/lib/hooks/server-deps.js +0 -92
  246. package/dist/lib/hooks/source-allowlist.d.ts +0 -26
  247. package/dist/lib/hooks/source-allowlist.js +0 -53
  248. package/dist/lib/hooks/types.d.ts +0 -129
  249. package/dist/lib/hooks/types.js +0 -24
  250. package/dist/lib/hooks/worker.d.ts +0 -56
  251. package/dist/lib/hooks/worker.js +0 -150
  252. package/dist/lib/ingest-router.d.ts +0 -25
  253. package/dist/lib/ocr-detector.d.ts +0 -61
  254. package/dist/lib/ocr-detector.js +0 -138
  255. package/dist/lib/ocr-engine-stub.d.ts +0 -48
  256. package/dist/lib/ocr-engine-stub.js +0 -190
  257. package/dist/lib/ocr-engines/google-doc-ai.d.ts +0 -36
  258. package/dist/lib/ocr-engines/google-doc-ai.js +0 -164
  259. package/dist/lib/ocr-jobs.d.ts +0 -67
  260. package/dist/lib/ocr-jobs.js +0 -129
  261. package/dist/lib/op-audit-extension/ran-at-guard.d.ts +0 -86
  262. package/dist/lib/op-audit.d.ts +0 -71
  263. package/dist/lib/privacy-br/detector.d.ts +0 -42
  264. package/dist/lib/privacy-br/detector.js +0 -130
  265. package/dist/lib/privacy-br/index.d.ts +0 -20
  266. package/dist/lib/privacy-br/index.js +0 -20
  267. package/dist/lib/privacy-br/integration.d.ts +0 -71
  268. package/dist/lib/privacy-br/integration.js +0 -74
  269. package/dist/lib/privacy-br/patterns.d.ts +0 -117
  270. package/dist/lib/privacy-br/patterns.js +0 -434
  271. package/dist/lib/privacy-br/redact.d.ts +0 -42
  272. package/dist/lib/privacy-br/redact.js +0 -103
  273. package/dist/lib/privacy-br/types.d.ts +0 -55
  274. package/dist/lib/privacy-br/types.js +0 -25
  275. package/dist/lib/regex-extract/extractor.d.ts +0 -30
  276. package/dist/lib/regex-extract/frontmatter.d.ts +0 -44
  277. package/dist/lib/regex-extract/index.d.ts +0 -14
  278. package/dist/lib/regex-extract/ingest-router-l4.d.ts +0 -76
  279. package/dist/lib/regex-extract/patterns.d.ts +0 -61
  280. package/dist/lib/regex-extract/production-wire.d.ts +0 -128
  281. package/dist/lib/regex-extract/reconcile.d.ts +0 -162
  282. package/dist/lib/regex-extract/strip-code.d.ts +0 -24
  283. package/dist/lib/regex-extract/types.d.ts +0 -48
  284. package/dist/lib/reranker.d.ts +0 -80
  285. package/dist/lib/shadow-tracker.d.ts +0 -191
  286. package/dist/lib/shadow-tracker.js +0 -384
  287. package/dist/lib/spo-injection.d.ts +0 -52
  288. package/dist/lib/telemetry-collector.d.ts +0 -158
  289. package/dist/lib/telemetry-collector.js +0 -249
  290. package/dist/lib/temporal-detector.d.ts +0 -27
  291. package/dist/lib/viewer/auth.d.ts +0 -37
  292. package/dist/lib/viewer/auth.js +0 -70
  293. package/dist/lib/viewer/backpressure.d.ts +0 -59
  294. package/dist/lib/viewer/backpressure.js +0 -100
  295. package/dist/lib/viewer/broadcast-singleton.d.ts +0 -34
  296. package/dist/lib/viewer/broadcast-singleton.js +0 -49
  297. package/dist/lib/viewer/broadcast.d.ts +0 -66
  298. package/dist/lib/viewer/broadcast.js +0 -96
  299. package/dist/lib/viewer/event-types.d.ts +0 -132
  300. package/dist/lib/viewer/event-types.js +0 -74
  301. package/dist/lib/viewer/instrumentation.d.ts +0 -106
  302. package/dist/lib/viewer/instrumentation.js +0 -224
  303. package/dist/lib/viewer/migration.d.ts +0 -23
  304. package/dist/lib/viewer/migration.js +0 -56
  305. package/dist/lib/viewer/redaction.d.ts +0 -44
  306. package/dist/lib/viewer/redaction.js +0 -139
  307. package/dist/lib/viewer/session.d.ts +0 -51
  308. package/dist/lib/viewer/session.js +0 -87
  309. package/dist/mcp/tools/answer.d.ts +0 -94
  310. package/dist/mcp/tools/archive.d.ts +0 -152
  311. package/dist/mcp/tools/archive.js +0 -170
  312. package/dist/mcp/tools/conflict.d.ts +0 -44
  313. package/dist/mcp/tools/conflict.js +0 -130
  314. package/dist/mcp/tools/hooks.d.ts +0 -29
  315. package/dist/mcp/tools/hooks.js +0 -78
  316. package/dist/mcp/tools/mark.d.ts +0 -38
  317. package/dist/mcp/tools/mark.js +0 -82
  318. package/dist/mcp/tools/viewer.d.ts +0 -58
  319. package/dist/mcp/tools/viewer.js +0 -64
  320. package/dist/mcp-server.d.ts +0 -2
  321. package/dist/metrics.d.ts +0 -3
  322. package/dist/noise-filter.d.ts +0 -18
  323. package/dist/notion-sync.d.ts +0 -7
  324. package/dist/notion-sync.js +0 -97
  325. package/dist/observability/adapters/a3-adapter.d.ts +0 -63
  326. package/dist/observability/adapters/a3-adapter.js +0 -83
  327. package/dist/observability/adapters/p1-adapter.d.ts +0 -49
  328. package/dist/observability/adapters/p1-adapter.js +0 -63
  329. package/dist/observability/adapters/p5-adapter.d.ts +0 -36
  330. package/dist/observability/adapters/p5-adapter.js +0 -71
  331. package/dist/observability/cardinality.d.ts +0 -61
  332. package/dist/observability/cardinality.js +0 -300
  333. package/dist/observability/collectors/db-stats.collector.d.ts +0 -9
  334. package/dist/observability/collectors/db-stats.collector.js +0 -88
  335. package/dist/observability/collectors/eventbus.collector.d.ts +0 -6
  336. package/dist/observability/collectors/eventbus.collector.js +0 -50
  337. package/dist/observability/collectors/process.collector.d.ts +0 -7
  338. package/dist/observability/collectors/process.collector.js +0 -93
  339. package/dist/observability/collectors/provider-telemetry.collector.d.ts +0 -11
  340. package/dist/observability/collectors/provider-telemetry.collector.js +0 -112
  341. package/dist/observability/collectors/search-telemetry.collector.d.ts +0 -12
  342. package/dist/observability/collectors/search-telemetry.collector.js +0 -76
  343. package/dist/observability/exporter.d.ts +0 -30
  344. package/dist/observability/exporter.js +0 -182
  345. package/dist/observability/index.d.ts +0 -22
  346. package/dist/observability/index.js +0 -21
  347. package/dist/observability/metrics.d.ts +0 -53
  348. package/dist/observability/metrics.js +0 -213
  349. package/dist/observability/privacy-guard.d.ts +0 -32
  350. package/dist/observability/privacy-guard.js +0 -116
  351. package/dist/observability/record.d.ts +0 -83
  352. package/dist/observability/record.js +0 -217
  353. package/dist/observability/registry.d.ts +0 -60
  354. package/dist/observability/registry.js +0 -93
  355. package/dist/observability/types.d.ts +0 -115
  356. package/dist/observability/types.js +0 -235
  357. package/dist/observability.d.ts +0 -131
  358. package/dist/plugins/nox-hooks/index.d.ts +0 -61
  359. package/dist/plugins/nox-hooks/index.js +0 -99
  360. package/dist/primer.d.ts +0 -1
  361. package/dist/privacy/filter.d.ts +0 -27
  362. package/dist/privacy/patterns.d.ts +0 -29
  363. package/dist/privacy/tag-parser.d.ts +0 -24
  364. package/dist/project-context-gen.d.ts +0 -10
  365. package/dist/providers/embedding/gemini.d.ts +0 -73
  366. package/dist/providers/embedding/openai.d.ts +0 -76
  367. package/dist/providers/embedding/types.d.ts +0 -39
  368. package/dist/providers/embedding/voyage.d.ts +0 -36
  369. package/dist/providers/index.d.ts +0 -116
  370. package/dist/providers/llm/anthropic.d.ts +0 -29
  371. package/dist/providers/llm/chain.d.ts +0 -99
  372. package/dist/providers/llm/gemini.d.ts +0 -48
  373. package/dist/providers/llm/openai.d.ts +0 -64
  374. package/dist/providers/llm/types.d.ts +0 -47
  375. package/dist/providers/telemetry.d.ts +0 -87
  376. package/dist/providers/types.d.ts +0 -42
  377. package/dist/query-entity-count.d.ts +0 -54
  378. package/dist/reflect.d.ts +0 -26
  379. package/dist/reindex-errors.d.ts +0 -7
  380. package/dist/reindex.d.ts +0 -16
  381. package/dist/retention.d.ts +0 -40
  382. package/dist/salience.d.ts +0 -85
  383. package/dist/scripts/migrate-v17-ops-audit.d.ts +0 -17
  384. package/dist/search-dedup.d.ts +0 -44
  385. package/dist/search-expansion.d.ts +0 -20
  386. package/dist/search.d.ts +0 -62
  387. package/dist/seh-detector.d.ts +0 -31
  388. package/dist/self-improve.d.ts +0 -1
  389. package/dist/session-distill.d.ts +0 -29
  390. package/dist/session-update.d.ts +0 -1
  391. package/dist/shared-memory.d.ts +0 -24
  392. package/dist/stats.d.ts +0 -1
  393. package/dist/temporal-retrieval.d.ts +0 -132
  394. package/dist/tier-manager.d.ts +0 -69
  395. package/dist/vectorize.d.ts +0 -16
  396. package/dist/version.d.ts +0 -1
  397. package/dist/watch.d.ts +0 -8
@@ -1,48 +0,0 @@
1
- /**
2
- * src/providers/llm/gemini.ts — Gemini LLM provider (T4).
3
- *
4
- * Real impl wrapping `generativelanguage.googleapis.com/v1beta`.
5
- * D41 default model: `gemini-2.5-flash-lite`.
6
- *
7
- * Models supported (opt-in via `NOX_LLM_MODEL`):
8
- * - `gemini-2.5-flash-lite` (default — cheapest, fastest, lowest quality)
9
- * - `gemini-2.5-flash` (KG extraction full, higher cost — CLAUDE.md regra #3)
10
- * - `gemini-2.5-pro` (opt-in, expensive — for synthesis/reflection)
11
- *
12
- * CLAUDE.md regra #3: NUNCA voltar pra `gemini-2.5-flash` (quota 3M/d estoura)
13
- * silently. Caller must explicitly select via env override. This impl honours
14
- * the constructor-time `model` arg verbatim — selection policy lives in
15
- * registry (T2).
16
- *
17
- * Wire shape mirrors the existing `src/lib/gemini-client.ts` so wrapping in
18
- * T13 is byte-equivalent at the request level.
19
- */
20
- import type { LLMProvider, CompleteOpts, CompleteResult } from "./types.js";
21
- import type { HealthStatus } from "../types.js";
22
- import { type FetchLike } from "../embedding/gemini.js";
23
- export declare const GEMINI_LLM_DEFAULT_MODEL = "gemini-2.5-flash-lite";
24
- /** Approximate context windows; used for the `contextWindow` readonly. */
25
- export declare const GEMINI_LLM_CONTEXT_WINDOWS: Record<string, number>;
26
- export interface GeminiLLMOpts {
27
- /** Override model. Default: gemini-2.5-flash-lite (D41). */
28
- model?: string;
29
- /** Override API key. Else read GEMINI_API_KEY. */
30
- apiKey?: string;
31
- /** Injected fetch for tests. */
32
- fetchFn?: FetchLike;
33
- /** Base URL override (lets tests point at fixture server). */
34
- baseUrl?: string;
35
- /** Override context window (else inferred from `model`). */
36
- contextWindow?: number;
37
- }
38
- export declare class GeminiLLMProvider implements LLMProvider {
39
- readonly name = "gemini";
40
- readonly model: string;
41
- readonly contextWindow: number;
42
- private readonly apiKey;
43
- private readonly fetchFn;
44
- private readonly baseUrl;
45
- constructor(opts?: GeminiLLMOpts);
46
- complete(opts: CompleteOpts): Promise<CompleteResult>;
47
- healthCheck(): Promise<HealthStatus>;
48
- }
@@ -1,64 +0,0 @@
1
- /**
2
- * src/providers/llm/openai.ts — OpenAI-compatible LLM provider (A3.1, real).
3
- *
4
- * Talks the OpenAI Chat Completions wire shape:
5
- * POST {baseUrl}/chat/completions
6
- * Authorization: Bearer <apiKey>
7
- * body: { model, messages: [...], temperature?, max_tokens? }
8
- * parse: choices[0].message.content
9
- *
10
- * Because the wire shape is the de-facto standard, this single class also drives
11
- * any OpenAI-compatible endpoint by overriding `baseUrl` + `model` + `apiKey`:
12
- *
13
- * | Backend | baseUrl | example model |
14
- * |-------------|------------------------------------------|--------------------------|
15
- * | OpenAI | https://api.openai.com/v1 (default) | gpt-4o-mini |
16
- * | DeepSeek | https://api.deepseek.com/v1 | deepseek-chat |
17
- * | OpenRouter | https://openrouter.ai/api/v1 | deepseek/deepseek-chat |
18
- * | Together | https://api.together.xyz/v1 | meta-llama/Llama-3.3-70B |
19
- * | local | http://127.0.0.1:11434/v1 (ollama etc.) | llama3.1 |
20
- *
21
- * Design parity with GeminiLLMProvider:
22
- * - `fetch` (Node 18+), no SDK dependency. `fetchFn` injectable for tests.
23
- * - Key resolved from constructor arg → OPENAI_API_KEY env. Stored privately,
24
- * never echoed in errors (redactSecrets()).
25
- * - Construction is NON-throwing when no key is present (factory-conformance:
26
- * selecting the provider must not fail boot when the user keeps Gemini default
27
- * but happens to set NOX_LLM_PROVIDER=openai without a key yet). The missing
28
- * key surfaces as MissingKeyError on the first real call (complete/healthCheck)
29
- * — never as a NotImplementedError; this is a live provider now.
30
- */
31
- import type { LLMProvider, CompleteOpts, CompleteResult } from "./types.js";
32
- import type { HealthStatus } from "../types.js";
33
- import { type FetchLike } from "../embedding/gemini.js";
34
- export declare const OPENAI_LLM_DEFAULT_MODEL = "gpt-4o-mini";
35
- export declare const OPENAI_LLM_CONTEXT_WINDOWS: Record<string, number>;
36
- /** Default endpoint. Override for DeepSeek/OpenRouter/Together/local. */
37
- export declare const OPENAI_LLM_DEFAULT_BASE_URL = "https://api.openai.com/v1";
38
- export interface OpenAILLMOpts {
39
- /** Override model. Default: gpt-4o-mini. */
40
- model?: string;
41
- /** Override API key. Else read OPENAI_API_KEY. */
42
- apiKey?: string;
43
- /** Injected fetch for tests; defaults to globalThis.fetch. */
44
- fetchFn?: FetchLike;
45
- /**
46
- * Base URL override (no trailing slash). Default https://api.openai.com/v1.
47
- * Point this at any OpenAI-compatible endpoint; `/chat/completions` and
48
- * `/models` are appended.
49
- */
50
- baseUrl?: string;
51
- /** Override context window (else inferred from `model`, fallback 128k). */
52
- contextWindow?: number;
53
- }
54
- export declare class OpenAILLMProvider implements LLMProvider {
55
- readonly name = "openai";
56
- readonly model: string;
57
- readonly contextWindow: number;
58
- private readonly apiKey;
59
- private readonly baseUrl;
60
- private readonly fetchFn;
61
- constructor(opts?: OpenAILLMOpts);
62
- complete(opts: CompleteOpts): Promise<CompleteResult>;
63
- healthCheck(): Promise<HealthStatus>;
64
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * src/providers/llm/types.ts — LLMProvider interface (T1).
3
- *
4
- * A3 spec §3 (locked from user task description):
5
- * readonly name, model, contextWindow
6
- * complete({system?, user, maxTokens?, temperature?}) -> {text, tokensIn, tokensOut, latencyMs}
7
- * healthCheck(): Promise<HealthStatus>
8
- *
9
- * Notes:
10
- * - `system` is optional — many calls (kg-extract, heartbeat) use only `user`.
11
- * - `maxTokens` / `temperature` are optional with provider-side defaults.
12
- * Defaults are intentionally NOT defined on the interface to let each provider
13
- * apply its own (e.g., Gemini flash-lite uses temperature=0.2 in heartbeat).
14
- * - Stubs may throw "not implemented" from `complete()`; `healthCheck()` MUST
15
- * still return a deterministic shape.
16
- */
17
- import type { HealthStatus } from "../types.js";
18
- export interface CompleteOpts {
19
- /** Optional system instruction; omitted if undefined. */
20
- system?: string;
21
- /** Required user prompt. */
22
- user: string;
23
- /** Output token budget; provider applies its own default if omitted. */
24
- maxTokens?: number;
25
- /** Sampling temperature; provider applies its own default if omitted. */
26
- temperature?: number;
27
- }
28
- export interface CompleteResult {
29
- /** Generated text from the model. */
30
- text: string;
31
- /** Input tokens billed by provider. */
32
- tokensIn: number;
33
- /** Output tokens billed by provider. */
34
- tokensOut: number;
35
- /** Wall-clock latency in milliseconds, end-to-end (provider call only). */
36
- latencyMs: number;
37
- }
38
- export interface LLMProvider {
39
- /** Provider id: 'gemini' | 'openai' | 'anthropic' | future ids. */
40
- readonly name: string;
41
- /** Model id (e.g., 'gemini-2.5-flash-lite', 'gpt-4o-mini'). */
42
- readonly model: string;
43
- /** Effective context window in tokens. */
44
- readonly contextWindow: number;
45
- complete(opts: CompleteOpts): Promise<CompleteResult>;
46
- healthCheck(): Promise<HealthStatus>;
47
- }
@@ -1,87 +0,0 @@
1
- export interface ProviderTelemetryRow {
2
- /** Unix ms timestamp. */
3
- ts: number;
4
- /** Provider id: 'gemini' | 'openai' | 'anthropic' | 'voyage'. */
5
- provider_id: string;
6
- /** Model id: e.g. 'gemini-2.5-flash-lite'. */
7
- model: string;
8
- /** 'embedding' | 'llm'. */
9
- kind: "embedding" | "llm";
10
- /** Input tokens billed (0 for embedding calls that don't report tokens). */
11
- tokens_in: number;
12
- /** Output tokens billed (0 for embedding calls). */
13
- tokens_out: number;
14
- /** Estimated cost in USD. */
15
- cost_usd: number;
16
- /** Wall-clock latency ms. */
17
- latency_ms: number;
18
- /** 1 = success, 0 = error. */
19
- ok: 0 | 1;
20
- /** Which caller produced this call: 'vectorize' | 'kg-extract' | 'reflect' | etc. */
21
- caller?: string;
22
- /** Session id for correlation (optional). */
23
- session_id?: string;
24
- /** Redacted error kind if ok=0. NEVER contains prompt text or keys. */
25
- error_kind?: string;
26
- }
27
- export type TelemetryWriteFn = (row: ProviderTelemetryRow) => Promise<void>;
28
- export interface TelemetryQueueOpts {
29
- writeFn?: TelemetryWriteFn;
30
- capacity?: number;
31
- /** Called on write error (default: console.error). Never throws. */
32
- onError?: (err: unknown) => void;
33
- }
34
- export declare class TelemetryQueue {
35
- private readonly queue;
36
- private readonly capacity;
37
- private readonly writeFn;
38
- private readonly onError;
39
- private flushing;
40
- constructor(opts?: TelemetryQueueOpts);
41
- /** Enqueue a row. Returns immediately. Drops oldest on overflow. */
42
- enqueue(row: ProviderTelemetryRow): void;
43
- private scheduleFlush;
44
- private flushSync;
45
- /** Drain all queued rows synchronously. Use for graceful shutdown + tests. */
46
- drain(): Promise<void>;
47
- /** Peek at current queue length (for monitoring). */
48
- get pending(): number;
49
- }
50
- export declare function setDefaultQueue(q: TelemetryQueue): void;
51
- export declare function getDefaultQueue(): TelemetryQueue;
52
- export interface RecordCallOpts {
53
- provider_id: string;
54
- model: string;
55
- kind: "embedding" | "llm";
56
- tokens_in?: number;
57
- tokens_out?: number;
58
- cost_usd?: number;
59
- latency_ms: number;
60
- ok: boolean;
61
- caller?: string;
62
- session_id?: string;
63
- /** Raw error message — will be redacted before logging. */
64
- errorRaw?: string;
65
- queue?: TelemetryQueue;
66
- }
67
- /** Record a provider call into the telemetry queue. Never throws. */
68
- export declare function recordProviderCall(opts: RecordCallOpts): void;
69
- export interface CostAggregate {
70
- /** USD spent in last 24h. */
71
- last24hUsd: number;
72
- /** Total calls in last 24h. */
73
- last24hCalls: number;
74
- /** Success rate 0-1 in last 24h. */
75
- last24hSuccessRate: number;
76
- /** Per-provider breakdown. */
77
- byProvider: Record<string, {
78
- usd: number;
79
- calls: number;
80
- }>;
81
- }
82
- /**
83
- * Compute aggregates from an array of rows.
84
- * In production, the API layer queries `provider_telemetry` directly via SQL.
85
- * This function is provided for in-memory tests.
86
- */
87
- export declare function aggregateCosts(rows: ProviderTelemetryRow[], nowMs?: number): CostAggregate;
@@ -1,42 +0,0 @@
1
- /**
2
- * src/providers/types.ts — Shared types + errors (T1).
3
- *
4
- * `HealthStatus` shape is consumed by both EmbeddingProvider.healthCheck()
5
- * and LLMProvider.healthCheck() — same contract on both sides keeps the
6
- * registry-level boot probe (T8) uniform.
7
- *
8
- * Errors are typed so the registry (T2) can surface clear messages and so
9
- * callers can distinguish "user config bug" from "transient backend issue"
10
- * without parsing error strings.
11
- */
12
- /** Health probe shape. `ok=false` MUST also fill `error`. */
13
- export interface HealthStatus {
14
- ok: boolean;
15
- /** Round-trip latency for the probe call. Optional when ok=false + no call made. */
16
- latencyMs?: number;
17
- /** Human-readable error message. REQUIRED when ok=false. Never contains API keys. */
18
- error?: string;
19
- }
20
- /** Thrown when an env API key is missing for the selected provider. */
21
- export declare class MissingKeyError extends Error {
22
- readonly providerName: string;
23
- readonly envVar: string;
24
- constructor(providerName: string, envVar: string);
25
- }
26
- /** Thrown when an unknown provider name is requested via env or factory arg. */
27
- export declare class UnknownProviderError extends Error {
28
- readonly requested: string;
29
- readonly known: readonly string[];
30
- constructor(requested: string, known: readonly string[]);
31
- }
32
- /** Thrown by stub providers when actual work is invoked (vs healthCheck). */
33
- export declare class NotImplementedError extends Error {
34
- readonly providerName: string;
35
- constructor(providerName: string, op: string);
36
- }
37
- /** Thrown when a provider's healthCheck fails at boot AND fail-fast is enabled. */
38
- export declare class ProviderHealthError extends Error {
39
- readonly providerName: string;
40
- readonly cause?: string;
41
- constructor(providerName: string, cause: string | undefined);
42
- }
@@ -1,54 +0,0 @@
1
- /**
2
- * query-entity-count.ts — G10d: Conditional Hard Mutex entity detection
3
- *
4
- * Counts named entities mentioned in a query by matching against the
5
- * `kg_entities` table (Option B — KG lookup, recommended in spec).
6
- *
7
- * Design constraints:
8
- * - Zero LLM calls — pure DB lookup, p95 <1ms on hot cache
9
- * - Cache TTL 5min — amortises cold-start overhead (~12KB index, ~5ms)
10
- * - Greedy longest-match — "Acme Corp" counts as 1, not 2
11
- * - Fallback: if DB unavailable or KG empty → returns 0 (mutex stays active,
12
- * same as current G10 hard mutex behaviour — no regression possible)
13
- * - PascalCase regex fallback when KG returns 0 rows
14
- *
15
- * Env flags used (evaluated at call time, NOT at module load):
16
- * (none — count is stateless data, flags live in search.ts)
17
- *
18
- * Cross-links:
19
- * - specs/2026-05-21-G10d-conditional-mutex-by-query-entities.md §3 Option B
20
- * - staged-1.7a/edits/search.ts — consumer of countQueryEntities()
21
- */
22
- import type Database from "better-sqlite3";
23
- export interface QueryEntityCountResult {
24
- count: number;
25
- matchedEntities: string[];
26
- method: "kg_lookup" | "fallback_regex";
27
- }
28
- /**
29
- * Returns the number of distinct KG entities mentioned in `query`.
30
- *
31
- * Algorithm:
32
- * 1. Check per-query cache (LRU, max 1000 entries).
33
- * 2. Load entity index from `kg_entities` (cached 5min).
34
- * 3. Greedy longest-match scan of lowercased query.
35
- * 4. If index is empty, fall back to PascalCase regex.
36
- * 5. Cache and return result.
37
- *
38
- * The `cacheable` option (default: true) allows callers to suppress caching
39
- * for eval harnesses that reuse query strings across different DB fixtures.
40
- *
41
- * @param query The raw search query string.
42
- * @param db The open better-sqlite3 database connection.
43
- * @param options.cacheable Whether to use per-query result cache (default true).
44
- */
45
- export declare function countQueryEntities(query: string, db: Database.Database, options?: {
46
- cacheable?: boolean;
47
- }): QueryEntityCountResult;
48
- /** Resets entity index AND query cache. Call in beforeEach for test isolation. */
49
- export declare function clearQueryEntityCache(): void;
50
- /**
51
- * @deprecated Use clearQueryEntityCache() — resets both caches.
52
- * Kept for backward compat with spec examples.
53
- */
54
- export declare function _resetEntityIndexCache(): void;
package/dist/reflect.d.ts DELETED
@@ -1,26 +0,0 @@
1
- export declare function ensureReflectCache(): void;
2
- export declare function getReflectCacheStats(): {
3
- entries: number;
4
- total_hits: number;
5
- top_queries: Array<{
6
- query: string;
7
- hits: number;
8
- last_hit_at: string | null;
9
- }>;
10
- };
11
- export declare function reflect(question: string, options?: {
12
- noCache?: boolean;
13
- }): Promise<{
14
- answer: string;
15
- evidence_count: number;
16
- cached: boolean;
17
- sources: string[];
18
- cache_kind?: 'exact' | 'semantic';
19
- }>;
20
- export declare function formatReflect(result: {
21
- answer: string;
22
- evidence_count: number;
23
- cached: boolean;
24
- sources: string[];
25
- cache_kind?: 'exact' | 'semantic';
26
- }): string;
@@ -1,7 +0,0 @@
1
- export declare const MIN_RETENTION_RATIO: number;
2
- export declare class ReindexWipeDetectedError extends Error {
3
- readonly preCount: number;
4
- readonly postCount: number;
5
- readonly ratio: number;
6
- constructor(preCount: number, postCount: number, ratio: number);
7
- }
package/dist/reindex.d.ts DELETED
@@ -1,16 +0,0 @@
1
- export { ReindexWipeDetectedError } from "./reindex-errors.js";
2
- interface ReindexResult {
3
- files: number;
4
- chunks: number;
5
- affected_rows?: number;
6
- notes?: string;
7
- dryRun?: boolean;
8
- preCount?: number;
9
- postCount?: number;
10
- upserted?: number;
11
- inserted?: number;
12
- orphaned?: number;
13
- }
14
- export declare function reindex(opts?: {
15
- dryRun?: boolean;
16
- }): Promise<ReindexResult>;
@@ -1,40 +0,0 @@
1
- export type RetentionDays = number | null;
2
- /**
3
- * RETENTION_BY_TYPE — mapping canônico chunk_type → retention_days.
4
- * Deve ficar em sync com o UPDATE no migrateToV8 (db.ts).
5
- *
6
- * Derivado do paper "Claude Memory Setup" + calibração com os 2106 chunks
7
- * reais do nox-mem (distribuição em 2026-04-23):
8
- * team=961, daily=630, other=278, decision=138, lesson=45,
9
- * feedback=17, project=15, pending=9, digest=7, person=6
10
- */
11
- export declare const RETENTION_BY_TYPE: Record<string, RetentionDays>;
12
- export declare const DEFAULT_RETENTION_DAYS = 90;
13
- /**
14
- * Resolve retention pro chunk baseado no tipo.
15
- * Retorna null (never-decay) ou número de dias.
16
- */
17
- export declare function getRetentionForType(chunkType: string): RetentionDays;
18
- /**
19
- * Detecta override de retention em HTML comment no markdown fonte.
20
- * Formatos aceitos:
21
- * <!-- retention: never -->
22
- * <!-- retention: 365 -->
23
- * <!-- retention: 30 days -->
24
- *
25
- * Retorna:
26
- * { found: true, value: null } — explicit never-decay
27
- * { found: true, value: <days> } — explicit days
28
- * { found: false } — no override (caller uses chunk_type default)
29
- */
30
- export declare function parseRetentionOverride(source: string): {
31
- found: true;
32
- value: RetentionDays;
33
- } | {
34
- found: false;
35
- };
36
- /**
37
- * Determina retention_days final pro chunk sendo ingested.
38
- * Precedência: override HTML comment > chunk_type default.
39
- */
40
- export declare function resolveRetention(chunkType: string, sourceContent?: string): RetentionDays;
@@ -1,85 +0,0 @@
1
- /**
2
- * staged-1.7a/edits/salience.ts
3
- *
4
- * Salience computation helper for nox-mem hybrid search.
5
- *
6
- * Implements the canonical formula documented in the paper (§3.2) and CLAUDE.md:
7
- *
8
- * salience = recency × pain × importance
9
- *
10
- * Where:
11
- * - recency ∈ [0,1] — half-life decay over `retention_days` window
12
- * - pain ∈ [0,1] — severity field on chunks (0.1 trivial → 1.0 outage)
13
- * - importance ∈ [0,1] — chunk_type / source_type / tier signal (manual mapping)
14
- *
15
- * Mode gating (per architectural constraint, paper §4 — "shadow discipline"):
16
- *
17
- * NOX_SALIENCE_MODE=shadow (DEFAULT) — compute but DO NOT apply to retrieval
18
- * NOX_SALIENCE_MODE=active — apply as additive delta in [-0.5, +0.5]
19
- * NOX_SALIENCE_MODE=off — short-circuit to 0 (ablation experiments)
20
- *
21
- * The 7-day shadow gate is enforced operationally by /api/health.salience telemetry
22
- * and `withOpAudit` activation logging — this module just honors whatever value
23
- * is set in the env at module-load (re-export getter for tests).
24
- *
25
- * Mirror module on the VPS lives at `src/lib/salience.ts` (per CLAUDE.md §"Schema v10").
26
- * This staged copy is the patch shipped via Wave A boost-stack-wiring.
27
- */
28
- export type SalienceMode = "shadow" | "active" | "off";
29
- export declare function getSalienceMode(): SalienceMode;
30
- export declare function resolveRetentionDays(retention_days: number | null | undefined, chunk_type: string | null | undefined): number;
31
- export declare function recencyComponent(source_date: string | null | undefined, last_accessed_at: string | null | undefined, retention_days: number, nowMs?: number): number;
32
- export declare function importanceComponent(chunk_type: string | null | undefined, explicitImportance?: number | null): number;
33
- export declare function painComponent(pain: number | null | undefined): number;
34
- export declare function inferPain(chunk_type: string | null | undefined, content: string | null | undefined): number;
35
- export declare function inferImportance(chunk_type: string | null | undefined): number;
36
- export interface SalienceInput {
37
- chunk_type?: string | null;
38
- source_type?: string | null;
39
- tier?: string | null;
40
- pain?: number | null;
41
- importance?: number | null;
42
- retention_days?: number | null;
43
- source_date?: string | null;
44
- created_at?: string | null;
45
- last_accessed_at?: string | null;
46
- /** Binary used/unused signal (introduced 2026-05-19 salience-additive refactor) */
47
- access_count?: number | null;
48
- }
49
- /**
50
- * Access-count component. Maps 0 → 0, log-saturating toward 1.0 at ~1000 accesses.
51
- */
52
- export declare function accessCountComponent(access_count: number | null | undefined): number;
53
- /**
54
- * Pure salience computation. Returns a number in [0, 1].
55
- * Does NOT consult NOX_SALIENCE_MODE — that gating lives in the caller (search.ts),
56
- * so this function stays pure and testable.
57
- *
58
- * v2 (2026-05-19): additive evidence-weighted formula.
59
- * See docs/audits/2026-05-19-salience-distribution-audit.md for rationale.
60
- * Previous multiplicative formula is preserved at `calculateSalienceLegacy`
61
- * for ablation comparison and shadow-discipline regression detection.
62
- */
63
- export declare function calculateSalience(chunk: SalienceInput, nowMs?: number): number;
64
- /**
65
- * Legacy multiplicative formula. Retained for ablation comparison only.
66
- * DO NOT USE in production scoring paths — proven to concentrate 99.7%
67
- * of chunks in a narrow dead-range (G4 ablation 2026-05-19).
68
- */
69
- export declare function calculateSalienceLegacy(chunk: SalienceInput, nowMs?: number): number;
70
- /**
71
- * Mirror of `src/lib/salience.ts:computeSalience` on the VPS — kept as an alias
72
- * so existing call-sites (e.g. /api/health.salience) keep working when the
73
- * staged patch lands on top of the VPS module graph.
74
- */
75
- export declare const computeSalience: typeof calculateSalience;
76
- /**
77
- * Classify salience score into a tier action (for /api/health.sectionDistribution).
78
- * Reconstructed from tier-manager.ts usage 2026-05-19 hotfix — pre-A `classifySalience`
79
- * was not preserved in PR #148 salience.ts rewrite; this restores backwards-compat.
80
- * promote: score >= 0.7 (candidate for tier promotion if not core)
81
- * retain: 0.4 <= score < 0.7
82
- * review: 0.15 <= score < 0.4
83
- * archive: score < 0.15
84
- */
85
- export declare function classifySalience(score: number): "promote" | "retain" | "review" | "archive";
@@ -1,17 +0,0 @@
1
- /**
2
- * Schema migration v.17 — ops_audit visibility columns.
3
- *
4
- * Wrapper standalone para aplicar migration v.17 com snapshot atômico pré-op
5
- * via withOpAudit, antes de restart da nox-mem-api (que aplicaria a mesma
6
- * migration via ensureSchema no boot, mas sem snapshot do main DB de 1.2GB).
7
- *
8
- * Pattern: withOpAudit('schema-v17-migration', ...) → VACUUM INTO atômico do
9
- * main DB → aplica ALTER TABLE → ops_audit row registrada com status='success'.
10
- *
11
- * Fase 2 / Gap C-migration (2026-05-15) — plans/2026-05-15-op-audit-gaps-review.md §10.6
12
- *
13
- * Uso na VPS:
14
- * cd /root/.openclaw/workspace/tools/nox-mem
15
- * NOX_DB_SOURCE=main node dist/scripts/migrate-v17-ops-audit.js
16
- */
17
- export {};
@@ -1,44 +0,0 @@
1
- /**
2
- * search-dedup.ts — 4-layer diversity filter for hybrid search results.
3
- *
4
- * Fase 1.6 — aplicado DEPOIS do RRF fusion, não interfere com scoring.
5
- * Inspiração: garrytan/gbrain search/dedup.ts.
6
- *
7
- * Layers (na ordem):
8
- * 1. Top 3 per source_file (evita 8 chunks do mesmo arquivo)
9
- * 2. Jaccard text-similarity >0.85 entre prefixos de 180 chars removido
10
- * (dedup textual sem custo de embedding; captura consolidations próximas)
11
- * 3. No single chunk_type pode ser >60% do resultado final
12
- * (força diversidade entre lesson / decision / code / conversation)
13
- * 4. Final cap per source_file:
14
- * - entity chunks (section IS NOT NULL): 3 (G12 R3 carve-out)
15
- * - non-entity chunks (section IS NULL): 2 (default)
16
- *
17
- * G12 R3 (2026-05-21): entity-format files emitem N+2 chunks (frontmatter +
18
- * compiled + timeline + N body). Cap=2 dropava o 3º chunk em queries
19
- * adversarial que precisavam de múltiplas seções da mesma entity (ex: gold
20
- * `<entity>::frontmatter` blocked porque ranks 1-2 já preenchidos por
21
- * `compiled` + outro). Carve-out só pra section!=NULL preserva comportamento
22
- * de markdown regular. Rollback rápido: NOX_DISABLE_G12_R3=1.
23
- *
24
- * Audit ref: audits/2026-05-21-G12-frontmatter-retrieval-audit.md §6 R3
25
- *
26
- * Não perde resultados únicos: se limit=5 e dedup cortar pra 3, 3 é o certo.
27
- * Melhor cobertura < ruído repetido.
28
- */
29
- import type { SearchResult } from "./search.js";
30
- /**
31
- * Layer 4 per-row cap selector. Entity chunks (section!=NULL) get
32
- * MAX_PER_FILE_FINAL_ENTITY=3; everything else stays at MAX_PER_FILE_FINAL=2.
33
- * Set NOX_DISABLE_G12_R3=1 to revert to flat cap=2.
34
- *
35
- * Exported for unit testing.
36
- */
37
- export declare function _layer4Cap(r: Pick<SearchResult, "section">): number;
38
- export declare function dedupe(results: SearchResult[], limit: number): SearchResult[];
39
- export declare const _internals: {
40
- MAX_PER_FILE_PRE: number;
41
- MAX_PER_FILE_FINAL: number;
42
- MAX_PER_FILE_FINAL_ENTITY: number;
43
- DISABLE_G12_R3: boolean;
44
- };
@@ -1,20 +0,0 @@
1
- /**
2
- * search-expansion.ts — Multi-perspective query rewriting via Gemini 2.5 Flash.
3
- *
4
- * Fase 1.6 — gera 2 variantes (técnica + paráfrase) além da query original.
5
- * Queries com <3 palavras, config off, ou Gemini unreachable retornam [query] intacta.
6
- *
7
- * Telemetria: retorna também o número de variantes efetivamente usadas para
8
- * gravar em search_telemetry.variants_count.
9
- */
10
- export interface ExpansionResult {
11
- variants: string[];
12
- skipped: boolean;
13
- reason?: "too_short" | "disabled" | "gemini_failed" | "no_api_key";
14
- }
15
- /**
16
- * Lê config `expansion_enabled` da tabela meta. Default = true (plano Fase 1.6).
17
- * Toggle sem redeploy: UPDATE meta SET value='false' WHERE key='expansion_enabled';
18
- */
19
- export declare function isExpansionEnabled(): boolean;
20
- export declare function expandQuery(query: string): Promise<ExpansionResult>;