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,30 +0,0 @@
1
- /**
2
- * T3 + T5 — Entity ref + code-path extractors.
3
- *
4
- * Pure functions: no IO, no DB, no async. Caller composes with stripCodeBlocks
5
- * (default) and frontmatter parsing in the router (T6).
6
- *
7
- * Adapted from gbrain/src/core/link-extraction.ts (MIT) — adjusted to nox-mem
8
- * domain (DIR_PATTERN whitelist, FK-id resolution deferred to router).
9
- *
10
- * Spec: specs/2026-05-18-L4-regex-first-extraction.md §6.2-§6.4.
11
- */
12
- import { CodeRef, EntityRef } from "./types.js";
13
- /**
14
- * Pure regex-based entity-ref extractor.
15
- *
16
- * Pipeline:
17
- * 1. stripCodeBlocks (suppress matches inside ```code```)
18
- * 2. Markdown links `[Name](type/slug)`
19
- * 3. Obsidian wikilinks `[[type/slug|Display]]`
20
- * 4. Bare refs `type/slug` (boundary-anchored)
21
- * 5. Dedupe by canonical key
22
- */
23
- export declare function extractEntityRefsRegex(content: string): EntityRef[];
24
- /**
25
- * T5 — extract code-path references (`src/foo.ts:42`, `specs/X.md`).
26
- *
27
- * Stripped of code fences first (gbrain pattern — avoid recursive matches
28
- * inside example fences).
29
- */
30
- export declare function extractCodeRefs(content: string): CodeRef[];
@@ -1,44 +0,0 @@
1
- /**
2
- * T4 — extractFrontmatterRelations.
3
- *
4
- * Parses a small, well-known subset of YAML frontmatter (scalars + flow/block
5
- * arrays of scalars) — enough to support the 6 rules in spec §5 without an
6
- * external dep. If consumers need full YAML they can preprocess and pass the
7
- * already-parsed object via {@link extractFrontmatterRelationsFromObject}.
8
- *
9
- * Spec: specs/2026-05-18-L4-regex-first-extraction.md §5.
10
- */
11
- import { FrontmatterRelation } from "./types.js";
12
- /** Pull the `---`-delimited block from the head of a markdown doc. */
13
- export declare function extractFrontmatterBlock(content: string): string | null;
14
- interface ParsedField {
15
- key: string;
16
- /** Single scalar value (no array). */
17
- scalar?: string;
18
- /** Array values (collected from flow `[a, b]` or block `- a\n- b`). */
19
- array?: string[];
20
- }
21
- /**
22
- * Minimal YAML scalar/array parser for top-level fields. NOT a full YAML
23
- * implementation — handles:
24
- * - `key: value`
25
- * - `key: "quoted value"`
26
- * - `key: [a, b, c]` (flow array)
27
- * - block array:
28
- * key:
29
- * - a
30
- * - b
31
- */
32
- export declare function parseFrontmatterFields(block: string): ParsedField[];
33
- /**
34
- * Parse frontmatter block + emit typed relations per spec §5 table.
35
- *
36
- * Returns [] when the doc has no frontmatter.
37
- */
38
- export declare function extractFrontmatterRelations(content: string): FrontmatterRelation[];
39
- /**
40
- * Variant for callers that already parsed YAML (e.g. via gray-matter elsewhere
41
- * in the pipeline). Object values may be string | string[].
42
- */
43
- export declare function extractFrontmatterRelationsFromObject(data: Record<string, unknown>): FrontmatterRelation[];
44
- export {};
@@ -1,14 +0,0 @@
1
- /**
2
- * L4 regex-extract — public surface (T1-T6).
3
- *
4
- * gbrain-inspired (MIT, Garry Tan) regex-first KG extraction with Gemini
5
- * fallback. See specs/2026-05-18-L4-regex-first-extraction.md.
6
- */
7
- export * from "./types.js";
8
- export { stripCodeBlocks, type StripResult } from "./strip-code.js";
9
- export { DIR_PATTERN, OPTIONAL_TOP, SLUG_CHARS, buildMarkdownLinkRe, buildWikilinkRe, buildBareRefRe, buildCodeRefRe, } from "./patterns.js";
10
- export { extractEntityRefsRegex, extractCodeRefs } from "./extractor.js";
11
- export { extractFrontmatterBlock, parseFrontmatterFields, extractFrontmatterRelations, extractFrontmatterRelationsFromObject, } from "./frontmatter.js";
12
- export { decideExtraction, mergeRelations, type ChunkContext, type ExtractionTelemetry, type IngestDecision, type MergedRelation, } from "./ingest-router-l4.js";
13
- export { reconcileEntityLinks, extractTargetSlugsFromContent, detectSlugChange, rewriteChunksForRename, detectCircularRename, STALE_CONFIDENCE, STALE_REASON, type ReconcilerRelation, type ReconcileAction, type ReconcileResult, type ReconcileOptions, type ChunkRewriteResult, } from "./reconcile.js";
14
- export { runProductionFastPath, filterHighConfidence, mergeWithLlmRelations, relationDedupKey, isRegexEnabled, isSkipGeminiEnabled, scoreEntityRef, scoreFrontmatterRelation, CONFIDENCE_THRESHOLD, CONFIDENCE_FRONTMATTER, CONFIDENCE_EXPLICIT_LINK, CONFIDENCE_BARE_REF, type ScoredRelation, type ProductionWireResult, } from "./production-wire.js";
@@ -1,76 +0,0 @@
1
- /**
2
- * T6 — Ingest router integration: regex-first KG extraction with Gemini fallback.
3
- *
4
- * Pure orchestration layer — no DB writes, no Gemini API calls. Returns a
5
- * structured decision payload that the actual ingest router (production
6
- * `src/lib/ingest-router.ts`) consumes to:
7
- * 1) write `kg_relations` rows tagged `extraction_method`
8
- * 2) decide whether to invoke `geminiKgExtract`
9
- * 3) merge + dedup results
10
- * 4) emit telemetry per spec §7
11
- *
12
- * Keeping this layer pure means it's covered by unit tests without DB or
13
- * network fixtures — the integration test layer (T7+ deferred) wires the
14
- * production ingestor.
15
- *
16
- * Spec: specs/2026-05-18-L4-regex-first-extraction.md §3 + §7.
17
- */
18
- import { RegexExtractionResult } from "./types.js";
19
- /** Chunk metadata that the production ingest router already maintains. */
20
- export interface ChunkContext {
21
- /** Chunk section per schema v10 (NULL for legacy/unsectioned chunks). */
22
- section: "compiled" | "frontmatter" | "timeline" | "prose" | null;
23
- /** Chunk type taxonomy (used to force Gemini for conversation logs). */
24
- type: "entity" | "spec" | "audit" | "conversation" | "daily_log" | "freeform" | "code" | "other";
25
- /** Raw chunk content (markdown). */
26
- content: string;
27
- /** Approximate chunk size in characters — used to short-circuit tiny chunks. */
28
- size?: number;
29
- }
30
- /** Per-chunk telemetry record emitted per spec §7. */
31
- export interface ExtractionTelemetry {
32
- section: ChunkContext["section"];
33
- extraction_method: "regex_only" | "gemini_only" | "regex_primary_gemini_secondary" | "gemini_only_after_regex_zero";
34
- regex_relations_count: number;
35
- /** Set by production caller once Gemini returns; unset here. */
36
- gemini_relations_count: number | null;
37
- gemini_call_skipped: boolean;
38
- latency_ms: {
39
- regex: number;
40
- gemini: number | null;
41
- total: number | null;
42
- };
43
- }
44
- /** Decision returned by the router pre-Gemini. */
45
- export interface IngestDecision {
46
- /** All regex-extracted artifacts (entity refs + frontmatter rels + code refs). */
47
- regex: RegexExtractionResult;
48
- /** Total count of regex relations (refs + frontmatter; code refs counted separately). */
49
- regexRelationsCount: number;
50
- /** Whether the caller should SKIP the Gemini KG call. */
51
- skipGemini: boolean;
52
- /** Telemetry placeholder — Gemini fields filled by caller post-call. */
53
- telemetry: ExtractionTelemetry;
54
- }
55
- /**
56
- * Run regex extraction + decide whether Gemini should be skipped.
57
- *
58
- * Skip-gate (spec §7):
59
- * section ∈ {compiled, frontmatter, timeline}
60
- * AND regex_relations_count ≥ 1
61
- * AND chunk.type ∉ {conversation, daily_log, freeform}
62
- */
63
- export declare function decideExtraction(chunk: ChunkContext): IngestDecision;
64
- /**
65
- * Merge regex + Gemini relations into a single dedup'd set ready for insert.
66
- * Production caller passes Gemini relations after the API call when skipGemini
67
- * was false. Dedup key = `<source>|<target>|<type>` (case-insensitive).
68
- */
69
- export interface MergedRelation {
70
- /** Source entity key (chunk-owning entity), resolved by caller. */
71
- source: string;
72
- target: string;
73
- relationType: string;
74
- extraction_method: "regex" | "gemini";
75
- }
76
- export declare function mergeRelations(regex: MergedRelation[], gemini: MergedRelation[]): MergedRelation[];
@@ -1,61 +0,0 @@
1
- /**
2
- * T2 — DIR_PATTERN + entity-ref regexes.
3
- *
4
- * Adapted from gbrain/src/core/link-extraction.ts (MIT). Adjusted for nox-mem
5
- * entity-type whitelist (specs/2026-05-18-L4-regex-first-extraction.md §4).
6
- *
7
- * IMPORTANT: All consumer regexes carry the global flag (`g`). Always reset
8
- * `.lastIndex = 0` before reuse or instantiate a fresh RegExp; callers in
9
- * extractor.ts do so by constructing per call via {@link buildEntityRefRe}.
10
- */
11
- /** `(?:feedback|person|...)` literal alternation snippet — non-capturing. */
12
- export declare const DIR_PATTERN: string;
13
- /** Top-level dir prefix `entities/` is optional in wikilinks. */
14
- export declare const OPTIONAL_TOP = "(?:entities\\/)?";
15
- /** Slug character class: letters, digits, underscore, dash. NO dots (drops `.md`). */
16
- export declare const SLUG_CHARS = "[a-z0-9_\\-]+";
17
- /**
18
- * Markdown-link form: `[Name](path/to/entityType/slug)`, optional `.md`, optional
19
- * tooltip `"..."`. Path may have `../` prefix.
20
- *
21
- * Groups:
22
- * 1 — display text
23
- * 2 — entity type
24
- * 3 — slug (no .md, no anchor)
25
- */
26
- export declare function buildMarkdownLinkRe(): RegExp;
27
- /**
28
- * Obsidian wikilink form: `[[entityType/slug]]`, optional `entities/` prefix,
29
- * optional `#anchor`, optional `|display`. Accept ASCII-aware slugs only —
30
- * Unicode boundary issues handled in extractor via stripping non-slug chars.
31
- *
32
- * Groups:
33
- * 1 — entity type
34
- * 2 — slug
35
- * 3 — display (after `|`, optional)
36
- */
37
- export declare function buildWikilinkRe(): RegExp;
38
- /**
39
- * Bare slug form: standalone `entityType/slug` token, only when surrounded by
40
- * whitespace/start/punctuation boundary. Uses lookbehind/lookahead WITHOUT
41
- * `\b` (MEMORY.md `JS regex \b falha em Unicode`).
42
- *
43
- * Tightly anchored to avoid URL false-positives — disallow `/` directly before
44
- * the token (so `example.com/feedback/foo` does NOT match).
45
- *
46
- * Groups:
47
- * 1 — entity type
48
- * 2 — slug
49
- */
50
- export declare function buildBareRefRe(): RegExp;
51
- /**
52
- * Code-path references (`src/lib/op-audit.ts:42`, `specs/foo.md`). Domain dirs
53
- * are whitelisted to suppress matches against unrelated path-like text.
54
- *
55
- * Groups:
56
- * 1 — top-level dir
57
- * 2 — path under root (extension included)
58
- * 3 — extension
59
- * 4 — line number (optional)
60
- */
61
- export declare function buildCodeRefRe(): RegExp;
@@ -1,128 +0,0 @@
1
- /**
2
- * T9 — Production wire-up: regex extractor as FAST-PATH before LLM extraction.
3
- *
4
- * Hooks the regex extractor into the existing `ingestFile()` pipeline as a
5
- * fast-path check BEFORE calling Gemini for KG extraction.
6
- *
7
- * Decision rule (spec §7 + T9):
8
- * If regex extraction confidence ≥ CONFIDENCE_THRESHOLD (0.8):
9
- * - Typed link from frontmatter (is_agent_of, supersedes, etc.) → confidence=0.95
10
- * - Explicit [[wikilink]] or [md-link](slug) → confidence=0.90
11
- * - Bare ref `entityType/slug` → confidence=0.75 (below threshold → falls through)
12
- * → SKIP Gemini for this chunk
13
- * Else:
14
- * → Fall through to LLM (existing path)
15
- *
16
- * Telemetry: `extraction_method` logged per kg_relations row.
17
- *
18
- * This module is a pure adapter — it wraps `decideExtraction` with the
19
- * confidence-gate logic and returns a wire-compatible result. The production
20
- * `ingestFile()` router imports this and acts on the decision.
21
- *
22
- * Spec: specs/2026-05-18-L4-regex-first-extraction.md §3, §7, T9.
23
- */
24
- import { type ChunkContext, type IngestDecision } from "./ingest-router-l4.js";
25
- import { type EntityRef, type FrontmatterRelation } from "./types.js";
26
- /**
27
- * Minimum confidence required to skip LLM extraction.
28
- * Below this, fall through to Gemini (existing path).
29
- */
30
- export declare const CONFIDENCE_THRESHOLD = 0.8;
31
- /** Confidence for frontmatter typed-link relations (highest precision). */
32
- export declare const CONFIDENCE_FRONTMATTER = 0.95;
33
- /** Confidence for explicit [[wikilink]] or [md-link](slug) matches. */
34
- export declare const CONFIDENCE_EXPLICIT_LINK = 0.9;
35
- /** Confidence for bare `entityType/slug` references. */
36
- export declare const CONFIDENCE_BARE_REF = 0.75;
37
- /**
38
- * Confidence-scored relation ready for kg_relations insert.
39
- * All fields are production-wire compatible (no DB types imported here).
40
- */
41
- export interface ScoredRelation {
42
- /** Source entity slug (chunk-owning entity). */
43
- sourceSlug: string;
44
- /** Target entity slug. */
45
- targetSlug: string;
46
- /** Relation type. */
47
- relationType: string;
48
- /** Confidence score [0.0, 1.0]. */
49
- confidence: number;
50
- /** Extraction method for telemetry. */
51
- extraction_method: "regex" | "llm";
52
- /** Raw reason tag for kg_relations.relation_reason. */
53
- relation_reason: "regex_extracted" | "gemini_extracted";
54
- }
55
- /** Wire-compatible result from the fast-path check. */
56
- export interface ProductionWireResult {
57
- /** Relations from regex with confidence scores. */
58
- regexRelations: ScoredRelation[];
59
- /** Maximum confidence seen in any relation (gate decision basis). */
60
- maxConfidence: number;
61
- /** Whether to skip the LLM call (max confidence ≥ threshold). */
62
- skipLlm: boolean;
63
- /** Extraction decision from decideExtraction (for telemetry). */
64
- decision: IngestDecision;
65
- /** Telemetry fields for logging to kg_relations. */
66
- telemetry: {
67
- extraction_method: "regex_only" | "gemini_only" | "regex_primary_gemini_secondary" | "gemini_only_after_regex_zero";
68
- regex_relations_count: number;
69
- gemini_call_skipped: boolean;
70
- latency_ms_regex: number;
71
- };
72
- }
73
- /**
74
- * Compute confidence for a single entity ref based on its source pattern.
75
- * Spec §7: frontmatter > explicit link > bare ref.
76
- */
77
- export declare function scoreEntityRef(ref: EntityRef): number;
78
- /**
79
- * Compute confidence for a frontmatter-derived typed relation.
80
- * Frontmatter fields are explicitly authored → highest precision.
81
- */
82
- export declare function scoreFrontmatterRelation(_rel: FrontmatterRelation): number;
83
- /**
84
- * Run the regex fast-path check for a chunk.
85
- *
86
- * 1. Calls `decideExtraction` to get regex hits and LLM skip decision.
87
- * 2. Scores each relation by confidence.
88
- * 3. If max confidence ≥ CONFIDENCE_THRESHOLD → skipLlm=true.
89
- * 4. Returns scored relations ready for kg_relations insert.
90
- *
91
- * @param chunk Chunk metadata + content.
92
- * @param sourceSlug The entity slug this chunk belongs to (for FK resolution).
93
- */
94
- export declare function runProductionFastPath(chunk: ChunkContext, sourceSlug: string): ProductionWireResult;
95
- /**
96
- * Filter a list of scored relations to only those above the confidence gate.
97
- * Used when merging regex + LLM output — only high-confidence regex relations
98
- * suppress their LLM counterparts.
99
- */
100
- export declare function filterHighConfidence(relations: ScoredRelation[], threshold?: number): ScoredRelation[];
101
- /**
102
- * Build a dedup key for a relation — used to merge regex + LLM output.
103
- * Key = `<sourceSlug>|<targetSlug>|<relationType>` (case-insensitive).
104
- */
105
- export declare function relationDedupKey(r: {
106
- sourceSlug: string;
107
- targetSlug: string;
108
- relationType: string;
109
- }): string;
110
- /**
111
- * Merge regex scored relations with LLM relations. Deduplicates by key,
112
- * preferring high-confidence regex entries over LLM for the same triple.
113
- */
114
- export declare function mergeWithLlmRelations(regexRelations: ScoredRelation[], llmRelations: Array<{
115
- sourceSlug: string;
116
- targetSlug: string;
117
- relationType: string;
118
- }>): ScoredRelation[];
119
- /**
120
- * Returns true when the L4 regex feature is enabled via env flag.
121
- * Feature is opt-in via `NOX_L4_REGEX_ENABLED=1`.
122
- */
123
- export declare function isRegexEnabled(): boolean;
124
- /**
125
- * Returns true when the skip-Gemini gate is enabled.
126
- * Requires both `NOX_L4_REGEX_ENABLED=1` AND `NOX_L4_SKIP_GEMINI=1`.
127
- */
128
- export declare function isSkipGeminiEnabled(): boolean;
@@ -1,162 +0,0 @@
1
- /**
2
- * T7 — Stale-link reconciliation on entity file update.
3
- *
4
- * When an entity file is renamed or edited, links pointing to the old slug may
5
- * become stale. This module handles two modes:
6
- *
7
- * - stale-mark (default): sets `confidence` to STALE_CONFIDENCE + adds a
8
- * `superseded_by` pointer to the new slug in each affected relation.
9
- * - auto-rename (env `NOX_L4_AUTO_RENAME=1`): rewrites old slug → new slug
10
- * across all affected kg_relations records.
11
- *
12
- * CRITICAL: auto-rename is DESTRUCTIVE — must require explicit env opt-in.
13
- * Default is stale-mark (append-only philosophy per CLAUDE.md regra 6).
14
- *
15
- * Spec: specs/2026-05-18-L4-regex-first-extraction.md §8.
16
- */
17
- /** Confidence assigned to stale relations (low — known stale). */
18
- export declare const STALE_CONFIDENCE = 0.3;
19
- /**
20
- * Reason string written to superseded_reason when stale-marking a relation.
21
- * Matches the reason used in the stale-link reconciliation flow (spec §8).
22
- */
23
- export declare const STALE_REASON = "stale_link_reconciliation";
24
- /** A single KG relation as seen by the reconciler (minimal projection). */
25
- export interface ReconcilerRelation {
26
- /** Composite key identifying this relation: `<sourceSlug>|<targetSlug>|<relationType>`. */
27
- key: string;
28
- /** Source entity slug (e.g. `feedback/no_secrets`). */
29
- sourceSlug: string;
30
- /** Target entity slug (e.g. `decision/d41`). */
31
- targetSlug: string;
32
- /** Relation type label. */
33
- relationType: string;
34
- /** Extraction method tag (only regex-extracted rels are managed by this reconciler). */
35
- extraction_method: "regex" | "gemini" | string;
36
- /** Current confidence score (0.0-1.0). */
37
- confidence: number;
38
- /** Whether already superseded. */
39
- superseded?: boolean;
40
- }
41
- /** Discriminated reconciliation action. */
42
- export type ReconcileAction = {
43
- type: "mark_stale";
44
- relation: ReconcilerRelation;
45
- /** New confidence value written (STALE_CONFIDENCE). */
46
- newConfidence: number;
47
- /** Reason written to superseded_reason. */
48
- supersededReason: string;
49
- } | {
50
- type: "auto_rename";
51
- relation: ReconcilerRelation;
52
- /** Old target slug being replaced. */
53
- oldTargetSlug: string;
54
- /** New target slug replacing the old one. */
55
- newTargetSlug: string;
56
- } | {
57
- type: "add";
58
- /** New target slug extracted from updated content. */
59
- targetSlug: string;
60
- relationType: string;
61
- } | {
62
- type: "noop";
63
- targetSlug: string;
64
- };
65
- /** Full reconciliation result. */
66
- export interface ReconcileResult {
67
- actions: ReconcileAction[];
68
- /** Relations newly found (adds). */
69
- added: string[];
70
- /** Relations removed from active content (marked stale or auto-renamed). */
71
- removed: string[];
72
- /** Relations unchanged. */
73
- unchanged: string[];
74
- /** Operating mode used. */
75
- mode: "stale_mark" | "auto_rename";
76
- }
77
- /**
78
- * Derive the full set of target slugs found in `content` via regex extraction
79
- * (entity refs + frontmatter relations combined). Code refs are excluded from
80
- * reconciliation — they're not direct KG entity slugs.
81
- */
82
- export declare function extractTargetSlugsFromContent(content: string): Set<string>;
83
- export interface ReconcileOptions {
84
- /**
85
- * If true, auto-rename is enabled (env `NOX_L4_AUTO_RENAME=1`).
86
- * Default: false (stale-mark mode).
87
- *
88
- * CRITICAL: auto-rename rewrites relations in-place. Never default to true.
89
- */
90
- autoRename?: boolean;
91
- /**
92
- * When autoRename=true and the old slug has been replaced by a known new
93
- * slug, pass it here so the auto-rename action can record the mapping.
94
- * If not provided, stale-mark is used even in auto-rename mode.
95
- */
96
- newSlug?: string;
97
- }
98
- /**
99
- * Reconcile kg_relations for a given entity when its content changes.
100
- *
101
- * Algorithm (spec §8):
102
- * 1. Extract new target slugs from `newContent` via regex.
103
- * 2. Diff `existingRelations` vs new slug set:
104
- * - Added: in new set, not in existing → emit `add` action.
105
- * - Removed: in existing (regex_extracted only), not in new set → emit
106
- * `mark_stale` or `auto_rename` action.
107
- * - Unchanged: present in both → emit `noop`.
108
- * 3. Gemini relations (extraction_method='gemini') are NEVER touched —
109
- * deferred to next Gemini run.
110
- * 4. Already-superseded relations are skipped.
111
- *
112
- * @param sourceSlug The entity being reconciled (e.g. `feedback/no_secrets`).
113
- * @param newContent New markdown content of the entity file.
114
- * @param existingRelations Current `kg_relations` rows for this entity.
115
- * @param opts Reconcile options.
116
- */
117
- export declare function reconcileEntityLinks(sourceSlug: string, newContent: string, existingRelations: ReconcilerRelation[], opts?: ReconcileOptions): ReconcileResult;
118
- /**
119
- * Detect whether an entity slug has changed between two content snapshots by
120
- * comparing the `slug` frontmatter field (or the first heading). Returns the
121
- * detected new slug if different, null if no change detected.
122
- *
123
- * This is a lightweight heuristic — the definitive source is the filesystem
124
- * rename event from the watcher. Use this as a sanity check.
125
- */
126
- export declare function detectSlugChange(oldContent: string, newContent: string): {
127
- changed: boolean;
128
- oldSlug: string | null;
129
- newSlug: string | null;
130
- };
131
- /**
132
- * Apply auto-rename across a set of chunk texts that reference `oldSlug`.
133
- * Rewrites `oldSlug` → `newSlug` in:
134
- * - Markdown links `[label](oldSlug)`
135
- * - Wikilinks `[[oldSlug]]`
136
- * - Bare refs ` oldSlug ` (boundary-sensitive)
137
- *
138
- * Returns an array of results: `{ chunkId, original, rewritten, changed }`.
139
- *
140
- * CRITICAL: Only call when `NOX_L4_AUTO_RENAME=1`. The caller is responsible
141
- * for writing the rewritten texts back to the DB.
142
- */
143
- export interface ChunkRewriteResult {
144
- chunkId: string;
145
- original: string;
146
- rewritten: string;
147
- changed: boolean;
148
- }
149
- export declare function rewriteChunksForRename(chunks: Array<{
150
- chunkId: string;
151
- content: string;
152
- }>, oldSlug: string, newSlug: string): ChunkRewriteResult[];
153
- /**
154
- * Validate a sequence of renames for circular dependencies.
155
- * Returns an error string if a cycle is detected, null otherwise.
156
- *
157
- * A cycle exists when following rename chain A→B→C→A.
158
- */
159
- export declare function detectCircularRename(renames: Array<{
160
- from: string;
161
- to: string;
162
- }>): string | null;
@@ -1,24 +0,0 @@
1
- /**
2
- * T1 — stripCodeBlocks helper.
3
- *
4
- * Adapted from gbrain/src/core/link-extraction.ts (MIT, Garry Tan, https://github.com/garry-tan/gbrain).
5
- * Spec: specs/2026-05-18-L4-regex-first-extraction.md §6.1.
6
- *
7
- * Replaces fenced ``` blocks (with optional language tag) AND inline `code`
8
- * with whitespace of equivalent length. Preserving length keeps any downstream
9
- * offset/line maths stable across the strip — callers can run regexes over the
10
- * stripped buffer and report locations against the original text.
11
- */
12
- /** Stable result of stripping. */
13
- export interface StripResult {
14
- stripped: string;
15
- hadFences: boolean;
16
- }
17
- /**
18
- * Strip fenced + inline + indented-4 code spans from markdown, returning a
19
- * length-preserved string safe for further regex matching.
20
- *
21
- * Order matters: fences first (so triple-backtick inline doesn't get clipped),
22
- * then inline backticks.
23
- */
24
- export declare function stripCodeBlocks(text: string): StripResult;
@@ -1,48 +0,0 @@
1
- /**
2
- * L4 regex-extract — shared types.
3
- *
4
- * Cross-ref: specs/2026-05-18-L4-regex-first-extraction.md §4-§7.
5
- */
6
- /** Whitelist of recognized entity types (DIR_PATTERN sources). */
7
- export declare const NOX_ENTITY_TYPES: readonly ["feedback", "person", "lesson", "decision", "project", "team", "daily", "pending", "graph_node", "agent", "incident", "spec", "audit", "skill", "persona", "reference", "entities"];
8
- export type NoxEntityType = (typeof NOX_ENTITY_TYPES)[number];
9
- /** A single extracted entity reference (markdown link / wikilink / bare). */
10
- export interface EntityRef {
11
- /** Entity type bucket. */
12
- entityType: NoxEntityType;
13
- /** Slug (no extension, no fragment). */
14
- slug: string;
15
- /** Canonical key `<entityType>/<slug>` — dedup key. */
16
- key: string;
17
- /** Visible display text (markdown alt-text / wikilink pipe). */
18
- display?: string;
19
- /** Source pattern that matched. */
20
- source: "markdown_link" | "wikilink" | "bare_ref";
21
- }
22
- /** Frontmatter-derived typed relation (§5 table). */
23
- export interface FrontmatterRelation {
24
- relationType: "is_agent_of" | "references" | "supersedes" | "caused_by" | "resolves" | "decided_by";
25
- /** Target entity key `<entityType>/<slug>`; may be unqualified — caller resolves stub. */
26
- target: string;
27
- /** Raw field value from YAML for audit. */
28
- raw: string;
29
- }
30
- /** Code-path reference (e.g. `src/lib/op-audit.ts:42`). */
31
- export interface CodeRef {
32
- /** Top-level dir (src, specs, audits, etc.). */
33
- root: string;
34
- /** Full path under root (e.g. `lib/op-audit.ts`). */
35
- path: string;
36
- /** Optional 1-based line number. */
37
- line?: number;
38
- /** Virtual entity key `codepath/<normalized_path>` for KG storage. */
39
- key: string;
40
- }
41
- /** Aggregated regex extraction result. */
42
- export interface RegexExtractionResult {
43
- entityRefs: EntityRef[];
44
- frontmatterRelations: FrontmatterRelation[];
45
- codeRefs: CodeRef[];
46
- /** True when stripCodeBlocks removed at least one fence/inline span. */
47
- hadCodeFences: boolean;
48
- }
@@ -1,80 +0,0 @@
1
- export type RerankerMode = "off" | "shadow" | "active";
2
- export interface RerankCandidate {
3
- id?: number;
4
- chunk_text: string;
5
- [k: string]: any;
6
- }
7
- export interface RerankSummary {
8
- mode: RerankerMode;
9
- topKIn: number;
10
- topKOut: number;
11
- latencyMs: number;
12
- positionChanges: number;
13
- liftScore: number;
14
- failed: boolean;
15
- failureReason?: string;
16
- }
17
- export declare const DEFAULT_TOP_K_IN = 50;
18
- export declare const DEFAULT_TOP_K_OUT = 10;
19
- export declare const DEFAULT_MODEL = "Xenova/bge-reranker-base";
20
- export declare const DEFAULT_TIMEOUT_MS = 2000;
21
- export declare function getMode(): RerankerMode;
22
- export declare function getTopKIn(): number;
23
- export declare function getTopKOut(): number;
24
- export declare function getModelName(): string;
25
- export declare function getTimeoutMs(): number;
26
- export type RerankerFn = (pairs: Array<{
27
- text: string;
28
- text_pair: string;
29
- }>) => Promise<Array<{
30
- score: number;
31
- }>>;
32
- /**
33
- * Test hook: injetar uma fn mock pra evitar download do modelo.
34
- * Em produção, NÃO chamar — `rerank()` carrega lazy via @xenova/transformers.
35
- *
36
- * Quando fn=null + reset=true (default), limpa singleton + cached error.
37
- * Use reset=false só pra cenários onde você quer preservar erro cacheado.
38
- */
39
- export declare function __setRerankerFnForTesting(fn: RerankerFn | null, reset?: boolean): void;
40
- /**
41
- * Pre-warm o singleton do modelo. Chamado pelo nox-mem-api boot quando
42
- * NOX_RERANKER_MODE != off, pra evitar cold-start de ~12-90s no primeiro
43
- * search request (D01 spec §risks §1). Idempotente: subsequent calls são no-op.
44
- */
45
- export declare function preloadModel(): Promise<void>;
46
- /**
47
- * Conta chunks que mudaram posição entre os top-K original e o pós-rerank.
48
- * Trabalha por id (campo opcional). Chunks sem id são ignorados (não rastreáveis).
49
- */
50
- export declare function computePositionChanges(origTopK: RerankCandidate[], newTopK: RerankCandidate[]): number;
51
- /**
52
- * Lift score: mean displacement normalizado em [0, 1].
53
- *
54
- * Combina dois sinais:
55
- * 1) displacement intra-intersection: |orig_pos − new_pos| pra ids em ambos
56
- * 2) turnover (set churn): id que entrou OU saiu conta como displacement = K
57
- *
58
- * Total = sum(deltas) / (count * K), onde K = max(|orig|, |new|).
59
- *
60
- * Edge cases:
61
- * - sets disjoint → todos turnover, score = 1
62
- * - identical → 0
63
- * - swap top-2 (K=5) → 2 ids movem 1 cada → 2/(5*4) = 0.1
64
- */
65
- export declare function computeLiftScore(origTopK: RerankCandidate[], newTopK: RerankCandidate[]): number;
66
- /**
67
- * Rerank candidates via cross-encoder. Comportamento per mode:
68
- *
69
- * - off: no-op, retorna candidates.slice(0, topK), summary mode='off'
70
- * - shadow: roda reranker, calcula lift, retorna candidates ORIGINAIS top-K
71
- * (não muta ranking — caller recebe ordem pre-rerank)
72
- * - active: roda reranker, retorna pós-rerank top-K (muta ranking)
73
- *
74
- * Fail-open: qualquer erro (model load, timeout, ONNX crash) → retorna
75
- * candidates.slice(0, topK) original com summary.failed=true. Não joga.
76
- */
77
- export declare function rerank(query: string, candidates: RerankCandidate[], topKOut?: number): Promise<{
78
- results: RerankCandidate[];
79
- summary: RerankSummary;
80
- }>;