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,73 +0,0 @@
1
- /**
2
- * src/api/health-confidence-adapter.ts — Wave O T4 (L3 health piece).
3
- *
4
- * Wire-up.ts (#92, line 446) does:
5
- *
6
- * const mod = await tryImport("./health-confidence.js");
7
- * if (!mod?.handleHealthConfidence) writeJson(res, ..., 503);
8
- * const out = await mod.handleHealthConfidence();
9
- *
10
- * staged-L3 ships `computeConfidenceHealth(db, rankingMode?)` — not the
11
- * arg-free `handleHealthConfidence()` the wire-up needs. This adapter wraps
12
- * the upstream function with deps-registry's DB singleton.
13
- *
14
- * Apply step appends to staged-L3's `health-confidence.ts`:
15
- *
16
- * export { handleHealthConfidence } from "./health-confidence-adapter.js";
17
- *
18
- * The adapter returns `{status, body}` per the wire-up contract.
19
- */
20
- import { getDb } from "../lib/deps/deps-registry.js";
21
- /**
22
- * Wire-up-shaped handler. No args — pulls DB from registry; returns 503 when
23
- * the L3 health module or the DB is unavailable.
24
- */
25
- export async function handleHealthConfidence() {
26
- const db = await getDb();
27
- if (!db) {
28
- return {
29
- status: 503,
30
- body: { error: "not_implemented", reason: "DB unavailable" },
31
- };
32
- }
33
- // String indirection — `./health-confidence.js` is co-located only after
34
- // staged-L3 is rsynced; here in the staged-wire-up-adapters tree the file
35
- // isn't present, so we let the dynamic import fail and return 503.
36
- const HC_SPEC = "./health-confidence.js";
37
- let mod;
38
- try {
39
- mod = await import(HC_SPEC);
40
- }
41
- catch {
42
- return {
43
- status: 503,
44
- body: {
45
- error: "not_implemented",
46
- reason: "L3 health-confidence module not deployed",
47
- },
48
- };
49
- }
50
- const compute = mod.computeConfidenceHealth ?? mod.default?.computeConfidenceHealth;
51
- if (typeof compute !== "function") {
52
- return {
53
- status: 503,
54
- body: {
55
- error: "not_implemented",
56
- reason: "computeConfidenceHealth export missing",
57
- },
58
- };
59
- }
60
- try {
61
- const slice = compute(db);
62
- return { status: 200, body: { confidence: slice } };
63
- }
64
- catch (err) {
65
- return {
66
- status: 500,
67
- body: {
68
- error: "internal_error",
69
- message: err.message ?? "compute failed",
70
- },
71
- };
72
- }
73
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * src/api/health-confidence.ts — confidence telemetry slice for /api/health.
3
- *
4
- * Surface added per spec §7-8:
5
- * /api/health.confidence = {
6
- * ranking_mode,
7
- * provenance: { observed, declared, inferred, derived, "user-marked", null },
8
- * confidence_distribution: { mean, p25, p50, p75, p95, stddev },
9
- * superseded_count
10
- * }
11
- *
12
- * Implementation:
13
- * - One SQL query for provenance histogram (GROUP BY provenance_kind)
14
- * - One SQL query for confidence percentiles (single-pass via NTILE)
15
- * - One SQL query for superseded_count
16
- *
17
- * For sqlite-compat, percentiles are computed via `quantile` simulated by
18
- * pulling sorted values + index math. Modest cost (<10ms even on 100k chunks).
19
- *
20
- * Falls back gracefully if columns don't exist (pre-v19 DB) — returns
21
- * "schema_version_lt_19" marker in result.
22
- */
23
- import type { Db } from "../lib/confidence/db-shim.js";
24
- import type { ConfidenceHealthSlice, RankingMode } from "../lib/confidence/types.js";
25
- declare function percentile(sorted: number[], q: number): number;
26
- declare function meanStddev(vals: number[]): {
27
- mean: number;
28
- stddev: number;
29
- };
30
- /**
31
- * Returns the confidence slice for /api/health.
32
- * `rankingMode` defaults to current cfg.ranking_mode.
33
- */
34
- export declare function computeConfidenceHealth(db: Db, rankingMode?: RankingMode): ConfidenceHealthSlice;
35
- export { percentile, meanStddev };
36
- export { handleHealthConfidence } from "./health-confidence-adapter.js";
@@ -1,141 +0,0 @@
1
- /**
2
- * src/api/health-confidence.ts — confidence telemetry slice for /api/health.
3
- *
4
- * Surface added per spec §7-8:
5
- * /api/health.confidence = {
6
- * ranking_mode,
7
- * provenance: { observed, declared, inferred, derived, "user-marked", null },
8
- * confidence_distribution: { mean, p25, p50, p75, p95, stddev },
9
- * superseded_count
10
- * }
11
- *
12
- * Implementation:
13
- * - One SQL query for provenance histogram (GROUP BY provenance_kind)
14
- * - One SQL query for confidence percentiles (single-pass via NTILE)
15
- * - One SQL query for superseded_count
16
- *
17
- * For sqlite-compat, percentiles are computed via `quantile` simulated by
18
- * pulling sorted values + index math. Modest cost (<10ms even on 100k chunks).
19
- *
20
- * Falls back gracefully if columns don't exist (pre-v19 DB) — returns
21
- * "schema_version_lt_19" marker in result.
22
- */
23
- import { resolveConfig } from "../lib/confidence/config.js";
24
- const KNOWN_KINDS = [
25
- "observed",
26
- "declared",
27
- "inferred",
28
- "derived",
29
- "user-marked",
30
- "null",
31
- ];
32
- function emptyProvenance() {
33
- return {
34
- observed: 0,
35
- declared: 0,
36
- inferred: 0,
37
- derived: 0,
38
- "user-marked": 0,
39
- null: 0,
40
- };
41
- }
42
- function emptyDistribution() {
43
- return { mean: 0, p25: 0, p50: 0, p75: 0, p95: 0, stddev: 0 };
44
- }
45
- function percentile(sorted, q) {
46
- if (sorted.length === 0)
47
- return 0;
48
- if (sorted.length === 1)
49
- return sorted[0];
50
- const pos = q * (sorted.length - 1);
51
- const lo = Math.floor(pos);
52
- const hi = Math.ceil(pos);
53
- if (lo === hi)
54
- return sorted[lo];
55
- const frac = pos - lo;
56
- return sorted[lo] * (1 - frac) + sorted[hi] * frac;
57
- }
58
- function meanStddev(vals) {
59
- if (vals.length === 0)
60
- return { mean: 0, stddev: 0 };
61
- const mean = vals.reduce((a, b) => a + b, 0) / vals.length;
62
- const variance = vals.reduce((a, b) => a + (b - mean) ** 2, 0) / vals.length;
63
- return { mean, stddev: Math.sqrt(variance) };
64
- }
65
- /**
66
- * Returns the confidence slice for /api/health.
67
- * `rankingMode` defaults to current cfg.ranking_mode.
68
- */
69
- export function computeConfidenceHealth(db, rankingMode) {
70
- const mode = rankingMode ?? resolveConfig().ranking_mode;
71
- let provenanceRows = [];
72
- try {
73
- provenanceRows = db
74
- .prepare("SELECT provenance_kind, COUNT(*) AS count FROM chunks GROUP BY provenance_kind")
75
- .all();
76
- }
77
- catch {
78
- // Pre-v19 schema → empty histogram
79
- return {
80
- provenance: emptyProvenance(),
81
- confidence_distribution: emptyDistribution(),
82
- superseded_count: 0,
83
- ranking_mode: mode,
84
- };
85
- }
86
- const provenance = emptyProvenance();
87
- for (const row of provenanceRows) {
88
- const key = (row.provenance_kind ?? "null");
89
- if (KNOWN_KINDS.includes(key)) {
90
- provenance[key] = row.count;
91
- }
92
- else {
93
- provenance.null += row.count;
94
- }
95
- }
96
- let confidenceVals = [];
97
- try {
98
- const rows = db
99
- .prepare("SELECT confidence FROM chunks WHERE confidence IS NOT NULL ORDER BY confidence ASC")
100
- .all();
101
- confidenceVals = rows
102
- .map((r) => r.confidence)
103
- .filter((v) => typeof v === "number" && Number.isFinite(v));
104
- }
105
- catch {
106
- confidenceVals = [];
107
- }
108
- const { mean, stddev } = meanStddev(confidenceVals);
109
- const distribution = {
110
- mean,
111
- stddev,
112
- p25: percentile(confidenceVals, 0.25),
113
- p50: percentile(confidenceVals, 0.5),
114
- p75: percentile(confidenceVals, 0.75),
115
- p95: percentile(confidenceVals, 0.95),
116
- };
117
- let superseded_count = 0;
118
- try {
119
- const row = db
120
- .prepare("SELECT COUNT(*) AS count FROM chunks WHERE superseded_by IS NOT NULL")
121
- .get();
122
- superseded_count = row?.count ?? 0;
123
- }
124
- catch {
125
- superseded_count = 0;
126
- }
127
- return {
128
- provenance,
129
- confidence_distribution: distribution,
130
- superseded_count,
131
- ranking_mode: mode,
132
- };
133
- }
134
- export { percentile, meanStddev };
135
- // ─── Wire-up adapter re-export ──────────────────────────────────────────────
136
- // handleHealthConfidence() is the arg-free wire-up contract; the real impl
137
- // lives in health-confidence-adapter.ts which wraps computeConfidenceHealth()
138
- // with DB injection via deps-registry. Without this re-export, wire-up.ts
139
- // tryImport("./health-confidence.js") finds the module but not the symbol →
140
- // 503 "L3 health not deployed". Same pattern as L2 db.ts re-export (PR #115).
141
- export { handleHealthConfidence } from "./health-confidence-adapter.js";
@@ -1,50 +0,0 @@
1
- /**
2
- * src/api/hooks.ts — T12: HTTP endpoints for hooks inspection + dryrun.
3
- *
4
- * Routes (mounted under /api/hooks):
5
- *
6
- * GET /api/hooks/status → 200 { config, queueDepth, rateLimitTokens }
7
- * GET /api/hooks/recent → 200 { rows: [...metadata only...] }
8
- * POST /api/hooks/dryrun → 200 { result, trace } — accepts { text } body
9
- *
10
- * Output sanitization:
11
- * - status returns config + counters; never raw events
12
- * - recent returns only metadata fields (event_uuid, ts, redaction_count,
13
- * kind, session_id, project_slug); NEVER payload content
14
- * - dryrun returns per-layer trace (layer + reason) and the redacted
15
- * output preview (truncated to 200 chars)
16
- */
17
- import { type TelemetrySink } from "../lib/hooks/pipeline.js";
18
- import { type HookConfig } from "../lib/hooks/config.js";
19
- export interface HttpRequest {
20
- method: string;
21
- path: string;
22
- query?: Record<string, string>;
23
- body?: unknown;
24
- }
25
- export interface HttpResponse {
26
- status: number;
27
- body: Record<string, unknown>;
28
- }
29
- export interface HooksApiDeps {
30
- readRecent: (limit: number) => Promise<Array<{
31
- event_uuid: string;
32
- session_id: string;
33
- project_slug: string;
34
- kind: string;
35
- timestamp: string;
36
- redaction_count: number;
37
- }>>;
38
- config?: HookConfig;
39
- telemetry?: TelemetrySink;
40
- /** Inject queue inspector (e.g., from plugin handle). Default returns 0. */
41
- inspectQueue?: () => {
42
- queueDepth: number;
43
- rateLimitTokens?: number;
44
- };
45
- }
46
- /**
47
- * Route a single HTTP request. Returns an HttpResponse.
48
- * No Express/Fastify dep — host wires this into whichever framework.
49
- */
50
- export declare function handleHooksRequest(req: HttpRequest, deps: HooksApiDeps): Promise<HttpResponse>;
package/dist/api/hooks.js DELETED
@@ -1,115 +0,0 @@
1
- /**
2
- * src/api/hooks.ts — T12: HTTP endpoints for hooks inspection + dryrun.
3
- *
4
- * Routes (mounted under /api/hooks):
5
- *
6
- * GET /api/hooks/status → 200 { config, queueDepth, rateLimitTokens }
7
- * GET /api/hooks/recent → 200 { rows: [...metadata only...] }
8
- * POST /api/hooks/dryrun → 200 { result, trace } — accepts { text } body
9
- *
10
- * Output sanitization:
11
- * - status returns config + counters; never raw events
12
- * - recent returns only metadata fields (event_uuid, ts, redaction_count,
13
- * kind, session_id, project_slug); NEVER payload content
14
- * - dryrun returns per-layer trace (layer + reason) and the redacted
15
- * output preview (truncated to 200 chars)
16
- */
17
- import { randomUUID } from "node:crypto";
18
- import { createPipeline } from "../lib/hooks/pipeline.js";
19
- import { loadConfig } from "../lib/hooks/config.js";
20
- /**
21
- * Route a single HTTP request. Returns an HttpResponse.
22
- * No Express/Fastify dep — host wires this into whichever framework.
23
- */
24
- export async function handleHooksRequest(req, deps) {
25
- const { method, path } = req;
26
- if (method === "GET" && path === "/api/hooks/status") {
27
- const config = deps.config ?? loadConfig();
28
- const inspect = deps.inspectQueue ? deps.inspectQueue() : { queueDepth: 0 };
29
- return {
30
- status: 200,
31
- body: {
32
- config: {
33
- enabled: config.enabled,
34
- allowed_sources: Array.from(config.allowedSources),
35
- rate_limit_per_min: config.rateLimitPerMin,
36
- dedup_threshold: config.dedupThreshold,
37
- llm_classify: config.llmClassify,
38
- dry_run: config.dryRun,
39
- queue_size: config.queueSize,
40
- min_length: config.minLength,
41
- pii_policy: config.piiPolicy,
42
- },
43
- queueDepth: inspect.queueDepth,
44
- rateLimitTokens: inspect.rateLimitTokens ?? null,
45
- },
46
- };
47
- }
48
- if (method === "GET" && path === "/api/hooks/recent") {
49
- const limit = Math.max(1, Math.min(100, Number.parseInt(req.query?.["limit"] ?? "20", 10) || 20));
50
- try {
51
- const rows = await deps.readRecent(limit);
52
- // Sanitize: drop payload_json entirely
53
- const sanitized = rows.map((r) => ({
54
- event_uuid: r.event_uuid,
55
- session_id: r.session_id,
56
- project_slug: r.project_slug,
57
- kind: r.kind,
58
- timestamp: r.timestamp,
59
- redaction_count: r.redaction_count,
60
- }));
61
- return { status: 200, body: { rows: sanitized } };
62
- }
63
- catch (e) {
64
- return { status: 500, body: { error: e.message } };
65
- }
66
- }
67
- if (method === "POST" && path === "/api/hooks/dryrun") {
68
- const body = (req.body ?? {});
69
- if (typeof body.text !== "string" || body.text.length === 0) {
70
- return { status: 400, body: { error: "missing required field: text (non-empty string)" } };
71
- }
72
- const role = typeof body.role === "string" ? body.role : "user";
73
- const source = typeof body.source === "string" ? body.source : "api";
74
- const base = deps.config ?? loadConfig();
75
- const forced = {
76
- ...base,
77
- enabled: true,
78
- dryRun: true,
79
- allowedSources: new Set([...base.allowedSources, "api", "cli"]),
80
- };
81
- const trace = [];
82
- const pipeline = createPipeline({
83
- config: forced,
84
- telemetry: (row) => {
85
- trace.push(row);
86
- },
87
- });
88
- const event = {
89
- event_id: `dr_${randomUUID()}`,
90
- source: source,
91
- role: role,
92
- content: body.text,
93
- session_id: "api-dryrun",
94
- project_slug: "api",
95
- ts: new Date().toISOString(),
96
- };
97
- const result = await pipeline.run(event);
98
- return {
99
- status: 200,
100
- body: {
101
- result,
102
- trace: trace.map((t) => {
103
- const p = JSON.parse(t.payload_json);
104
- return {
105
- layer: p.layer,
106
- reason: p.reason,
107
- redaction_count: t.redaction_count,
108
- kind: t.kind,
109
- };
110
- }),
111
- },
112
- };
113
- }
114
- return { status: 404, body: { error: `no route for ${method} ${path}` } };
115
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * T13 — HTTP `POST /api/import` handler (framework-agnostic).
3
- *
4
- * Accepts JSON body `{ archive_b64: string, passphrase?: string, mode?: 'merge'|'replace',
5
- * dry_run?: bool, verify_only?: bool }`. Caller is responsible for adapting to
6
- * multipart/form-data on the host server side (we keep the contract pure JSON
7
- * here to avoid pulling a multipart parser dependency into staged-A2).
8
- *
9
- * Returns summary JSON: counts, conflicts, duration.
10
- */
11
- import { ProgressEvent } from "../lib/archive/orchestrator.js";
12
- import { ChunkRow, KgEntityRow, KgRelationRow, OpsAuditRow } from "../lib/archive/types.js";
13
- export interface HttpImportBody {
14
- /** Base64-encoded gzipped tar archive. */
15
- archive_b64?: string;
16
- passphrase?: string;
17
- mode?: "merge" | "replace";
18
- dry_run?: boolean;
19
- verify_only?: boolean;
20
- }
21
- export interface HttpResponse {
22
- status: number;
23
- headers: Record<string, string>;
24
- body: Buffer | string;
25
- }
26
- export interface HttpImportDeps {
27
- loadExisting: () => Promise<{
28
- chunks: ChunkRow[];
29
- kg_entities: KgEntityRow[];
30
- kg_relations: KgRelationRow[];
31
- ops_audit: OpsAuditRow[];
32
- }>;
33
- currentSchemaVersion: () => Promise<number>;
34
- persist?: (resolved: import("../lib/archive/orchestrator.js").ImportResult["resolved"]) => Promise<void>;
35
- signal?: AbortSignal;
36
- onProgress?: (ev: ProgressEvent) => void;
37
- }
38
- export declare function handleImport(body: HttpImportBody, deps: HttpImportDeps): Promise<HttpResponse>;
@@ -1,87 +0,0 @@
1
- /**
2
- * T13 — HTTP `POST /api/import` handler (framework-agnostic).
3
- *
4
- * Accepts JSON body `{ archive_b64: string, passphrase?: string, mode?: 'merge'|'replace',
5
- * dry_run?: bool, verify_only?: bool }`. Caller is responsible for adapting to
6
- * multipart/form-data on the host server side (we keep the contract pure JSON
7
- * here to avoid pulling a multipart parser dependency into staged-A2).
8
- *
9
- * Returns summary JSON: counts, conflicts, duration.
10
- */
11
- import { runImport, } from "../lib/archive/orchestrator.js";
12
- import { BadPassphraseError, TamperedArchiveError } from "../lib/archive/types.js";
13
- export async function handleImport(body, deps) {
14
- if (!body.archive_b64) {
15
- return jsonResponse(400, { error: "archive_b64 required" });
16
- }
17
- let archive;
18
- try {
19
- archive = Buffer.from(body.archive_b64, "base64");
20
- if (archive.length === 0) {
21
- return jsonResponse(400, { error: "archive_b64 decoded to empty buffer" });
22
- }
23
- }
24
- catch (err) {
25
- return jsonResponse(400, { error: `bad base64: ${err.message}` });
26
- }
27
- const existing = await deps.loadExisting();
28
- const currentSchemaVersion = await deps.currentSchemaVersion();
29
- const req = {
30
- archive,
31
- passphrase: body.passphrase,
32
- mode: body.mode ?? "merge",
33
- dry_run: body.dry_run === true,
34
- verify_only: body.verify_only === true,
35
- current_schema_version: currentSchemaVersion,
36
- existing,
37
- signal: deps.signal,
38
- onProgress: deps.onProgress,
39
- };
40
- let result;
41
- try {
42
- result = await runImport(req);
43
- }
44
- catch (err) {
45
- if (err instanceof BadPassphraseError) {
46
- return jsonResponse(401, { error: "bad passphrase" });
47
- }
48
- if (err instanceof TamperedArchiveError) {
49
- return jsonResponse(409, { error: "archive tampered" });
50
- }
51
- const msg = err.message;
52
- if (/encrypted/.test(msg) && !body.passphrase) {
53
- return jsonResponse(401, { error: "passphrase required" });
54
- }
55
- if (/cancel/i.test(msg)) {
56
- return jsonResponse(499, { error: "cancelled" });
57
- }
58
- return jsonResponse(500, { error: msg });
59
- }
60
- if (!body.dry_run && !body.verify_only && deps.persist) {
61
- try {
62
- await deps.persist(result.resolved);
63
- }
64
- catch (err) {
65
- return jsonResponse(500, {
66
- error: `persist failed: ${err.message}`,
67
- });
68
- }
69
- }
70
- return jsonResponse(200, {
71
- mode: body.mode ?? "merge",
72
- dry_run: body.dry_run === true,
73
- verify_only: body.verify_only === true,
74
- encrypted: result.manifest.encryption.enabled,
75
- schema_version_archive: result.manifest.schema_version,
76
- schema_version_target: currentSchemaVersion,
77
- stats: result.stats,
78
- duration_ms: result.duration_ms,
79
- });
80
- }
81
- function jsonResponse(status, payload) {
82
- return {
83
- status,
84
- headers: { "Content-Type": "application/json" },
85
- body: JSON.stringify(payload),
86
- };
87
- }
@@ -1,65 +0,0 @@
1
- /**
2
- * F4b — POST /api/ingest-event (Session Priming Loop, Fluxo D)
3
- *
4
- * Write-side do loop: a sessão deposita um digest tipado ao encerrar.
5
- * "Toda sessão nasce contextualizada E MORRE CONTRIBUINDO."
6
- *
7
- * Specs (memoria-nox):
8
- * - PRD: specs/2026-06-04-session-priming-loop.md (§7 Fluxo D, §4.4)
9
- * - Base: specs/2026-05-17-P2-hooks-autocapture.md (§4 endpoint; este módulo
10
- * implementa o SUBSET kind=session_end. Desvio documentado de P2 §6: o
11
- * digest vai DIRETO pra `chunks` como type=daily — a tabela `agent_events`
12
- * separada do P2 é pro autocapture full de ~170 eventos/sessão, que não é
13
- * o caso aqui: 1 digest/sessão.)
14
- *
15
- * Invariantes:
16
- * - Append-only em `chunks` (INSERT, nunca UPDATE/DELETE) — guardas de
17
- * op-audit (regra #6) não aplicam; FTS entra via trigger chunks_ai;
18
- * embedding fica pro vectorize (nightly cron / canary self-heal).
19
- * - Decaível por padrão (PRD §4.4): chunk_type=daily, retention_days=90.
20
- * O crystallize nightly promove o que sobreviver à curadoria.
21
- * - Dedup por (kind, session_id) — mesma sessão NUNCA ingere 2× (re-POST
22
- * idempotente retorna deduped:true).
23
- * - Auth: o token gate global do api-server (F2) já exige Bearer em
24
- * requests proxiadas (x-forwarded-for); localhost direto passa.
25
- * - Privacy (espírito do P2 §5 sem a dependência A1 full): redaction
26
- * server-side de padrões de credencial conhecidos + redaction_count
27
- * no response.
28
- */
29
- interface PreparedStatement {
30
- all(...args: unknown[]): unknown[];
31
- get(...args: unknown[]): unknown;
32
- run(...args: unknown[]): unknown;
33
- }
34
- export interface IngestDb {
35
- prepare(sql: string): PreparedStatement;
36
- exec(sql: string): void;
37
- }
38
- export interface IngestEventRequest {
39
- kind: string;
40
- session_id: string;
41
- scope?: string;
42
- host?: string;
43
- content: string;
44
- /** Discriminador de ocorrência pra kinds que disparam N× por sessão
45
- * (pre_compact compacta várias vezes em sessão longa). Idempotência
46
- * vira (kind, session_id, seq); ausente = (kind, session_id). */
47
- seq?: string;
48
- }
49
- export type IngestEventResponse = {
50
- status: number;
51
- body: unknown;
52
- };
53
- export declare function redactSecrets(text: string): {
54
- clean: string;
55
- count: number;
56
- };
57
- export declare function parseIngestEvent(body: unknown): {
58
- ok: true;
59
- req: Required<Omit<IngestEventRequest, "scope" | "host" | "seq">> & Pick<IngestEventRequest, "scope" | "host" | "seq">;
60
- } | {
61
- ok: false;
62
- error: string;
63
- };
64
- export declare function handleIngestEvent(db: IngestDb, body: unknown): IngestEventResponse;
65
- export {};
@@ -1,42 +0,0 @@
1
- /**
2
- * src/api/mark.ts — HTTP routes for L3 mark workflow.
3
- *
4
- * Routes:
5
- * POST /api/chunk/:id/mark body { kind: "canonical"|"refuted"|"stale", notes?: string }
6
- * POST /api/chunk/:id/supersede body { by_chunk_id: number, notes?: string, reason?: string }
7
- *
8
- * Returns 200 + JSON on success, 400 on bad request, 404 on missing chunk,
9
- * 500 on unexpected.
10
- *
11
- * Framework-agnostic: exposes request/response handlers that take a minimal
12
- * Request shape. Production caller (Express/Fastify/native http) wires them
13
- * via `handleMarkRequest()` and `handleSupersedeRequest()`.
14
- */
15
- import type { Db } from "../lib/confidence/db-shim.js";
16
- import type { MarkResult } from "../lib/confidence/types.js";
17
- export interface ApiResponse<T = unknown> {
18
- status: number;
19
- body: T | {
20
- ok: false;
21
- error: string;
22
- code: string;
23
- };
24
- }
25
- interface MarkBody {
26
- kind?: string;
27
- notes?: string;
28
- }
29
- interface SupersedeBody {
30
- by_chunk_id?: number;
31
- notes?: string;
32
- reason?: string;
33
- }
34
- /**
35
- * handleMarkRequest(db, idStr, body) → ApiResponse<MarkResult>
36
- */
37
- export declare function handleMarkRequest(db: Db, idStr: string, body: MarkBody | null | undefined): ApiResponse<MarkResult>;
38
- /**
39
- * handleSupersedeRequest(db, idStr, body) → ApiResponse<MarkResult>
40
- */
41
- export declare function handleSupersedeRequest(db: Db, idStr: string, body: SupersedeBody | null | undefined): ApiResponse<MarkResult>;
42
- export {};