@dikolab/kbdb 0.4.3 → 0.6.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 (224) hide show
  1. package/CLA.md +68 -0
  2. package/LICENSE +676 -12
  3. package/LICENSING.md +58 -0
  4. package/README.md +50 -27
  5. package/README.md.bak +320 -0
  6. package/dist/README.md +320 -0
  7. package/dist/{chunk-BJXEVALU.mjs → chunk-QLJ33C74.mjs} +44 -44
  8. package/dist/chunk-QLJ33C74.mjs.map +7 -0
  9. package/dist/cli.cjs +550 -232
  10. package/dist/cli.cjs.map +4 -4
  11. package/dist/cli.d.ts +0 -8
  12. package/dist/cli.mjs +483 -154
  13. package/dist/cli.mjs.map +4 -4
  14. package/dist/kbdb-worker.cjs +36 -5
  15. package/dist/kbdb-worker.cjs.map +3 -3
  16. package/dist/mod.cjs +89 -30
  17. package/dist/mod.cjs.map +4 -4
  18. package/dist/mod.mjs +88 -30
  19. package/dist/mod.mjs.map +4 -4
  20. package/dist/src/cli.d.ts +0 -8
  21. package/dist/src/shared/cli/constants/defaults.constant.d.ts +1 -1
  22. package/dist/src/shared/cli/constants/recfile-command-field-map.constant.d.ts +8 -0
  23. package/dist/src/shared/cli/constants/recfile-field-maps.constant.d.ts +21 -0
  24. package/dist/src/shared/cli/functions/compute-directory-level.function.d.ts +14 -0
  25. package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +2 -28
  26. package/dist/src/shared/cli/functions/format-command-output.function.d.ts +14 -0
  27. package/dist/src/shared/cli/functions/format-db-not-found.function.d.ts +20 -0
  28. package/dist/src/shared/cli/functions/format-output.function.d.ts +1 -0
  29. package/dist/src/shared/cli/functions/format-recfile-output.function.d.ts +11 -0
  30. package/dist/src/shared/cli/functions/render-recfile-value.function.d.ts +11 -0
  31. package/dist/src/shared/cli/functions/resolve-db-dir.function.d.ts +24 -0
  32. package/dist/src/shared/cli/functions/resolve-recfile-key.function.d.ts +9 -0
  33. package/dist/src/shared/cli/functions/run-db-path.function.d.ts +10 -0
  34. package/dist/src/shared/cli/functions/run-export.function.d.ts +8 -4
  35. package/dist/src/shared/cli/functions/run-import.function.d.ts +4 -0
  36. package/dist/src/shared/cli/functions/run-learn.function.d.ts +12 -0
  37. package/dist/src/shared/cli/index.d.ts +4 -1
  38. package/dist/src/shared/cli/typings/cli-options.interface.d.ts +9 -2
  39. package/dist/src/shared/cli/typings/db-resolution.interface.d.ts +9 -0
  40. package/dist/src/shared/cli/typings/recfile-field-map.type.d.ts +10 -0
  41. package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
  42. package/dist/src/shared/wasm-codec/functions/decode-option-u8.function.d.ts +9 -0
  43. package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +4 -0
  44. package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +2 -45
  45. package/dist/src/shared/wasm-codec/functions/encode-update-section-params.function.d.ts +10 -1
  46. package/dist/src/shared/wasm-codec/index.d.ts +1 -1
  47. package/dist/src/shared/wasm-codec/typings/add-section-input.model.d.ts +6 -0
  48. package/dist/src/shared/wasm-codec/typings/section-record-trailing.model.d.ts +5 -0
  49. package/dist/src/shared/wasm-codec/typings/section-record.model.d.ts +5 -0
  50. package/dist/src/shared/worker-client/functions/build-deno-permissions.function.d.ts +11 -0
  51. package/dist/src/shared/worker-client/functions/read-crash-reason.function.d.ts +9 -0
  52. package/dist/src/shared/worker-client/functions/resolve-spawn-script.function.d.ts +6 -0
  53. package/dist/src/shared/worker-client/functions/spawn-daemon.function.d.ts +1 -1
  54. package/dist/src/shared/worker-client/typings/section.model.d.ts +5 -0
  55. package/dist/src/shared/worker-client/typings/worker-client-options.interface.d.ts +0 -6
  56. package/dist/src/shared/worker-daemon/functions/count-files.function.d.ts +12 -0
  57. package/dist/src/shared/worker-daemon/functions/handle-import.function.d.ts +2 -0
  58. package/dist/src/shared/worker-daemon/functions/handle-read-ops.function.d.ts +8 -0
  59. package/dist/src/shared/worker-daemon/functions/validate-daemon-path.function.d.ts +15 -0
  60. package/dist/src/worker.d.ts +0 -7
  61. package/dist/wasm/default-embedding/kbdb_default_embedding_bg.wasm +0 -0
  62. package/dist/wasm/default-embedding/package.json +1 -1
  63. package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
  64. package/dist/wasm/fs-database/package.json +1 -1
  65. package/dist/wasm/fs-migration/kbdb_fs_migration_bg.wasm +0 -0
  66. package/dist/wasm/fs-migration/package.json +1 -1
  67. package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
  68. package/dist/wasm/kb-worker/package.json +1 -1
  69. package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
  70. package/dist/wasm/query-parser/package.json +1 -1
  71. package/dist/worker.d.ts +0 -7
  72. package/dist/worker.mjs +37 -6
  73. package/dist/worker.mjs.map +3 -3
  74. package/package.json +13 -12
  75. package/dist/chunk-BJXEVALU.mjs.map +0 -7
  76. package/dist/src/shared/cli/functions/resolve-raw-db-path.function.d.ts +0 -10
  77. package/docs/details/README.md +0 -30
  78. package/docs/details/agent-tooling.md +0 -132
  79. package/docs/details/cli.md +0 -777
  80. package/docs/details/knowledge-base.md +0 -180
  81. package/docs/details/library-api.md +0 -495
  82. package/docs/details/mcp-server.md +0 -482
  83. package/docs/details/search-and-ranking.md +0 -575
  84. package/docs/details/storage.md +0 -531
  85. package/docs/goals/agents.md +0 -751
  86. package/docs/goals/architecture.svg +0 -198
  87. package/docs/goals/auto-capture.md +0 -378
  88. package/docs/goals/benchmarking.md +0 -296
  89. package/docs/goals/cli.md +0 -2654
  90. package/docs/goals/concurrency.md +0 -259
  91. package/docs/goals/content-composer.md +0 -609
  92. package/docs/goals/content-parser.md +0 -279
  93. package/docs/goals/database.md +0 -1679
  94. package/docs/goals/document.md +0 -368
  95. package/docs/goals/hybrid-search.md +0 -465
  96. package/docs/goals/mcp.md +0 -1541
  97. package/docs/goals/overview.md +0 -124
  98. package/docs/goals/query-parser.md +0 -373
  99. package/docs/goals/query-result.md +0 -860
  100. package/docs/goals/semantic-dedup.md +0 -233
  101. package/docs/goals/skills.md +0 -810
  102. package/docs/goals/sync.md +0 -217
  103. package/docs/goals/worker-client.md +0 -1005
  104. package/docs/goals/worker-daemon.md +0 -1547
  105. package/docs/modules/overview.md +0 -319
  106. package/docs/modules/rust/embedding/module.md +0 -91
  107. package/docs/modules/rust/fs-database/functions/document.md +0 -48
  108. package/docs/modules/rust/fs-database/functions/integrity.md +0 -79
  109. package/docs/modules/rust/fs-database/functions/io.md +0 -87
  110. package/docs/modules/rust/fs-database/functions/module.md +0 -22
  111. package/docs/modules/rust/fs-database/functions/query-exec.md +0 -44
  112. package/docs/modules/rust/fs-database/functions/section.md +0 -76
  113. package/docs/modules/rust/fs-database/indexes/btree.md +0 -35
  114. package/docs/modules/rust/fs-database/indexes/corpus.md +0 -61
  115. package/docs/modules/rust/fs-database/indexes/inverted.md +0 -60
  116. package/docs/modules/rust/fs-database/indexes/module.md +0 -64
  117. package/docs/modules/rust/fs-database/indexes/positional.md +0 -39
  118. package/docs/modules/rust/fs-database/indexes/vectors.md +0 -110
  119. package/docs/modules/rust/fs-database/module.md +0 -150
  120. package/docs/modules/rust/fs-database/types/catalog.md +0 -53
  121. package/docs/modules/rust/fs-database/types/module.md +0 -12
  122. package/docs/modules/rust/fs-database/types/section.md +0 -127
  123. package/docs/modules/rust/kb-worker/functions/compose.md +0 -57
  124. package/docs/modules/rust/kb-worker/functions/module.md +0 -20
  125. package/docs/modules/rust/kb-worker/functions/retrieve.md +0 -194
  126. package/docs/modules/rust/kb-worker/functions/search.md +0 -173
  127. package/docs/modules/rust/kb-worker/functions/write.md +0 -172
  128. package/docs/modules/rust/kb-worker/module.md +0 -171
  129. package/docs/modules/rust/kb-worker/types/cache.md +0 -90
  130. package/docs/modules/rust/kb-worker/types/context.md +0 -26
  131. package/docs/modules/rust/kb-worker/types/module.md +0 -16
  132. package/docs/modules/rust/kb-worker/types/status.md +0 -29
  133. package/docs/modules/rust/kb-worker/types/token.md +0 -50
  134. package/docs/modules/rust/overview.md +0 -531
  135. package/docs/modules/rust/query-parser/functions/extract.md +0 -56
  136. package/docs/modules/rust/query-parser/functions/module.md +0 -18
  137. package/docs/modules/rust/query-parser/functions/parse.md +0 -33
  138. package/docs/modules/rust/query-parser/functions/pipeline.md +0 -9
  139. package/docs/modules/rust/query-parser/functions/rank.md +0 -85
  140. package/docs/modules/rust/query-parser/module.md +0 -131
  141. package/docs/modules/rust/query-parser/types/cache.md +0 -39
  142. package/docs/modules/rust/query-parser/types/keyphrase.md +0 -71
  143. package/docs/modules/rust/query-parser/types/module.md +0 -18
  144. package/docs/modules/rust/query-parser/types/token.md +0 -46
  145. package/docs/modules/rust/shared/content-composer/functions.md +0 -114
  146. package/docs/modules/rust/shared/content-composer/module.md +0 -147
  147. package/docs/modules/rust/shared/content-composer/types.md +0 -93
  148. package/docs/modules/rust/shared/content-parser/functions.md +0 -72
  149. package/docs/modules/rust/shared/content-parser/module.md +0 -99
  150. package/docs/modules/rust/shared/content-parser/types.md +0 -71
  151. package/docs/modules/rust/shared/corpus/module.md +0 -24
  152. package/docs/modules/rust/shared/corpus/types.md +0 -141
  153. package/docs/modules/rust/shared/document/module.md +0 -25
  154. package/docs/modules/rust/shared/document/types.md +0 -154
  155. package/docs/modules/rust/shared/encode/module.md +0 -22
  156. package/docs/modules/rust/shared/encode/traits.md +0 -304
  157. package/docs/modules/rust/shared/error/module.md +0 -28
  158. package/docs/modules/rust/shared/error/types.md +0 -302
  159. package/docs/modules/rust/shared/kbid/module.md +0 -24
  160. package/docs/modules/rust/shared/kbid/types.md +0 -147
  161. package/docs/modules/rust/shared/memory/functions.md +0 -209
  162. package/docs/modules/rust/shared/memory/module.md +0 -24
  163. package/docs/modules/rust/shared/module.md +0 -196
  164. package/docs/modules/rust/shared/pipeline/functions.md +0 -141
  165. package/docs/modules/rust/shared/pipeline/module.md +0 -62
  166. package/docs/modules/rust/shared/pipeline/types.md +0 -43
  167. package/docs/modules/rust/shared/query/module.md +0 -27
  168. package/docs/modules/rust/shared/query/types.md +0 -236
  169. package/docs/modules/rust/shared/section/module.md +0 -25
  170. package/docs/modules/rust/shared/section/types.md +0 -294
  171. package/docs/modules/rust/shared/term/module.md +0 -25
  172. package/docs/modules/rust/shared/term/types.md +0 -139
  173. package/docs/modules/typescript/cli.md +0 -131
  174. package/docs/modules/typescript/kbdb-worker.md +0 -150
  175. package/docs/modules/typescript/overview.md +0 -400
  176. package/docs/modules/typescript/shared/auto-capture/module.md +0 -73
  177. package/docs/modules/typescript/shared/cli/constants.md +0 -23
  178. package/docs/modules/typescript/shared/cli/functions.md +0 -809
  179. package/docs/modules/typescript/shared/cli/module.md +0 -138
  180. package/docs/modules/typescript/shared/cli/typings.md +0 -197
  181. package/docs/modules/typescript/shared/embedding/functions.md +0 -200
  182. package/docs/modules/typescript/shared/embedding/module.md +0 -77
  183. package/docs/modules/typescript/shared/embedding/typings.md +0 -124
  184. package/docs/modules/typescript/shared/hash/functions.md +0 -20
  185. package/docs/modules/typescript/shared/hash/module.md +0 -21
  186. package/docs/modules/typescript/shared/log/constants.md +0 -82
  187. package/docs/modules/typescript/shared/log/functions.md +0 -131
  188. package/docs/modules/typescript/shared/log/module.md +0 -153
  189. package/docs/modules/typescript/shared/log/typings.md +0 -82
  190. package/docs/modules/typescript/shared/mcp/classes.md +0 -179
  191. package/docs/modules/typescript/shared/mcp/functions.md +0 -386
  192. package/docs/modules/typescript/shared/mcp/module.md +0 -160
  193. package/docs/modules/typescript/shared/mcp/typings.md +0 -529
  194. package/docs/modules/typescript/shared/module.md +0 -110
  195. package/docs/modules/typescript/shared/platform/functions.md +0 -42
  196. package/docs/modules/typescript/shared/platform/module.md +0 -25
  197. package/docs/modules/typescript/shared/runtime/functions.md +0 -26
  198. package/docs/modules/typescript/shared/runtime/module.md +0 -27
  199. package/docs/modules/typescript/shared/runtime/typings.md +0 -13
  200. package/docs/modules/typescript/shared/version/module.md +0 -27
  201. package/docs/modules/typescript/shared/wasm-codec/functions.md +0 -391
  202. package/docs/modules/typescript/shared/wasm-codec/module.md +0 -98
  203. package/docs/modules/typescript/shared/worker-client/classes.md +0 -264
  204. package/docs/modules/typescript/shared/worker-client/functions.md +0 -175
  205. package/docs/modules/typescript/shared/worker-client/module.md +0 -92
  206. package/docs/modules/typescript/shared/worker-client/typings.md +0 -511
  207. package/docs/modules/typescript/shared/worker-daemon/classes.md +0 -239
  208. package/docs/modules/typescript/shared/worker-daemon/constants.md +0 -37
  209. package/docs/modules/typescript/shared/worker-daemon/functions.md +0 -234
  210. package/docs/modules/typescript/shared/worker-daemon/module.md +0 -118
  211. package/docs/modules/typescript/shared/worker-daemon/typings.md +0 -132
  212. package/docs/overview.md +0 -191
  213. package/docs/release-notes/0.1.0.md +0 -189
  214. package/docs/release-notes/0.1.1.md +0 -46
  215. package/docs/release-notes/0.1.2.md +0 -38
  216. package/docs/release-notes/0.1.3.md +0 -42
  217. package/docs/release-notes/0.2.0.md +0 -147
  218. package/docs/release-notes/0.3.0.md +0 -89
  219. package/docs/release-notes/0.3.1.md +0 -121
  220. package/docs/release-notes/0.3.2.md +0 -64
  221. package/docs/release-notes/0.4.0.md +0 -80
  222. package/docs/release-notes/0.4.1.md +0 -149
  223. package/docs/release-notes/0.4.3.md +0 -60
  224. package/docs/release-notes/README.md +0 -13
@@ -1,296 +0,0 @@
1
- # Scale Benchmarking -- Methodology and Performance Targets
2
-
3
- *Quantify search latency, rebuild time, and memory
4
- usage across realistic corpus sizes before trusting
5
- kbdb as a long-lived knowledge base.*
6
-
7
- ## Goal
8
-
9
- kbdb is intended as a long-lived knowledge base for AI
10
- agents. Before trusting it at scale, search latency,
11
- rebuild time, and memory usage must be quantified across
12
- realistic corpus sizes.
13
-
14
- This document specifies the benchmark methodology, corpus
15
- generation, metrics, and regression targets. It addresses
16
- gap #4 from the
17
- [Opus 4.8 Second Brain Review](../issues/2026-06-23-opus-48-second-brain-review.md):
18
-
19
- > Scale of the lexical index at 50k-100k+ sections --
20
- > search latency and rebuild time are worth benchmarking
21
- > before trusting it as a long-lived brain.
22
-
23
- ## Corpus Generation
24
-
25
- A synthetic corpus generator lives in `bench/` and
26
- creates realistic sections for repeatable benchmarks.
27
-
28
- ### Generator Properties
29
-
30
- - **Term distribution** -- Word frequencies follow a
31
- Zipfian distribution. A small vocabulary of high-
32
- frequency terms dominates each section, with a long
33
- tail of rare terms. This matches real-world prose.
34
- - **Title length** -- 3 to 8 words drawn from the
35
- vocabulary.
36
- - **Body length** -- 100 to 500 words, configurable via
37
- `avg body length` parameter.
38
- - **Vocabulary** -- Terms drawn from a 50,000-word
39
- English dictionary subset. The same dictionary is used
40
- for all corpus sizes so cross-size comparisons are
41
- valid.
42
- - **Cross-references** -- Sections reference each other
43
- via `$(link:)` markers at a configurable density
44
- (default: 5% of sections link to one other section).
45
- - **Tags** -- Each section is assigned one to three tags
46
- from a pool of 20 topic tags.
47
- - **Determinism** -- The generator accepts a seed
48
- parameter. Fixed seed produces identical corpus across
49
- runs. Results are reproducible across machines.
50
-
51
- ### Generator Parameters
52
-
53
- | Parameter | Default | Description |
54
- |-----------|---------|-------------|
55
- | `--count` | 1000 | Number of sections to generate |
56
- | `--avg-body-length` | 250 | Average body word count |
57
- | `--ref-density` | 0.05 | Fraction of sections with a cross-reference |
58
- | `--seed` | 42 | RNG seed for reproducibility |
59
- | `--out` | `./bench/corpus/` | Output directory |
60
-
61
- ## Corpus Sizes
62
-
63
- | Label | Sections | Estimated disk size |
64
- |-------|----------|---------------------|
65
- | Small | 1,000 | ~5 MB |
66
- | Medium | 10,000 | ~50 MB |
67
- | Large | 50,000 | ~250 MB |
68
- | XLarge | 100,000 | ~500 MB |
69
-
70
- All corpus sizes use the same generator with the same
71
- seed and vocabulary. The only difference is the
72
- `--count` parameter.
73
-
74
- ## Operations to Benchmark
75
-
76
- | Operation | Description | Variants |
77
- |-----------|-------------|----------|
78
- | `search` | Single-query search | cold cache, warm cache |
79
- | `learn` | Add a single section | with/without embedding |
80
- | `batch-learn` | Add 100 sections | sequential |
81
- | `rebuild` | Full index rebuild | lexical only, hybrid |
82
- | `gc` | Garbage collection | after superseding 10% of sections |
83
- | `check` | Integrity check | full scan |
84
-
85
- ### Variant Definitions
86
-
87
- **Cold cache** -- the worker daemon is started fresh
88
- immediately before the timed operation. The WASM
89
- linear memory page table and any in-process caches
90
- are empty.
91
-
92
- **Warm cache** -- the timed operation is preceded by
93
- 10 identical operations that are not counted. The
94
- daemon's in-process caches are populated.
95
-
96
- **With embedding** -- an embedding provider is
97
- configured. The `learn` operation includes embedding
98
- computation time.
99
-
100
- **After superseding 10%** -- before timing `gc`, 10%
101
- of all sections are superseded (replaced) using the
102
- `replace` flag, leaving their originals as unreferenced
103
- candidates for collection.
104
-
105
- ## Metrics
106
-
107
- For each operation at each corpus size, the harness
108
- collects:
109
-
110
- - **p50, p95, p99 latency** (ms) -- percentiles across
111
- N runs (default N = 10).
112
- - **Throughput** (ops/sec) -- for batch operations
113
- (`batch-learn`), calculated as
114
- `(sections_per_batch * N) / total_elapsed_s`.
115
- - **WASM linear memory high watermark** -- the
116
- `WebAssembly.Memory` buffer byte size sampled
117
- immediately after the operation completes.
118
- - **Index file sizes** -- sizes in bytes of
119
- `terms.idx`, `positions.idx`, `corpus.dat`, and
120
- `vectors.idx` (if present) at each corpus size.
121
- - **Resident memory of the worker daemon** -- OS-
122
- reported RSS of the `kbdb-worker` process, sampled
123
- after warm-up.
124
-
125
- ## Performance Targets
126
-
127
- The targets below define the maximum acceptable latency
128
- for each operation at each corpus size. Results
129
- exceeding a target mark that combination as a
130
- regression.
131
-
132
- | Operation | Corpus | Target |
133
- |-----------|--------|--------|
134
- | `search` (warm) | 1k | < 5 ms |
135
- | `search` (warm) | 10k | < 15 ms |
136
- | `search` (warm) | 50k | < 30 ms |
137
- | `search` (warm) | 100k | < 50 ms |
138
- | `search` (cold) | 100k | < 200 ms |
139
- | `learn` (single) | any | < 100 ms |
140
- | `rebuild` | 1k | < 2 s |
141
- | `rebuild` | 10k | < 10 s |
142
- | `rebuild` | 100k | < 30 s |
143
- | `gc` | 100k | < 10 s |
144
- | `check` | 100k | < 15 s |
145
-
146
- Targets are per-operation p99 latency unless noted.
147
- `learn (single)` and `rebuild` targets apply to p99
148
- of the N-run sample.
149
-
150
- ## Benchmark Harness
151
-
152
- All benchmark tooling lives in `bench/`:
153
-
154
- ```
155
- bench/
156
- generate-corpus.ts corpus generator script
157
- run-benchmark.ts harness: run operations,
158
- collect timing, emit JSON
159
- report.ts format JSON results as
160
- Markdown table
161
- corpus/ generated corpus files
162
- (gitignored)
163
- results/ timestamped JSON result files
164
- baselines/ per-platform baseline files
165
- for regression comparison
166
- ```
167
-
168
- ### Harness Procedure
169
-
170
- 1. Generate the corpus at target size using
171
- `bench/generate-corpus.ts` with the configured
172
- seed.
173
- 2. Run `db init` to create a fresh `.kbdb` directory.
174
- 3. Run `batch-learn` to populate the database with the
175
- full generated corpus.
176
- 4. For each operation variant, run the operation N
177
- times (default N = 10), collecting wall-clock
178
- elapsed time per run.
179
- 5. Compute p50, p95, p99 from the N samples.
180
- 6. Collect WASM memory and daemon RSS after each
181
- operation.
182
- 7. Write a JSON result file to `bench/results/` with
183
- a timestamp suffix.
184
- 8. Optionally compare against the baseline file in
185
- `bench/baselines/` and emit a pass/fail summary.
186
-
187
- The harness uses the public CLI and library API
188
- exclusively. It does not import internal modules or
189
- call WASM exports directly.
190
-
191
- ### Result File Format
192
-
193
- Each run produces one JSON file:
194
-
195
- ```json
196
- {
197
- "timestamp": "2026-06-23T10:00:00Z",
198
- "platform": "linux-x86_64",
199
- "runtime": "node-22",
200
- "corpus_size": "medium",
201
- "results": [
202
- {
203
- "operation": "search",
204
- "variant": "warm",
205
- "n": 10,
206
- "p50_ms": 8,
207
- "p95_ms": 11,
208
- "p99_ms": 14,
209
- "wasm_memory_bytes": 4194304,
210
- "daemon_rss_bytes": 52428800
211
- }
212
- ],
213
- "index_sizes": {
214
- "terms_idx_bytes": 1048576,
215
- "positions_idx_bytes": 524288,
216
- "corpus_dat_bytes": 65536,
217
- "vectors_idx_bytes": null
218
- }
219
- }
220
- ```
221
-
222
- `vectors_idx_bytes` is `null` when no embedding
223
- provider is configured.
224
-
225
- ## Hybrid Search Benchmarks
226
-
227
- When an embedding provider is configured, the harness
228
- adds measurements for the vector path. These are
229
- collected as a separate benchmark suite and not mixed
230
- with the lexical-only results.
231
-
232
- | Additional measurement | Description |
233
- |------------------------|-------------|
234
- | Embedding time per section | Elapsed ms for embedding computation during `learn` |
235
- | Vector search latency | p50/p95/p99 of vector-only retrieval |
236
- | Lexical search latency | p50/p95/p99 of lexical-only retrieval for the same queries |
237
- | RRF fusion overhead | p50/p95/p99 of the fusion step alone (subtract lexical + vector from total) |
238
- | Vector index rebuild time | p50/p95/p99 of `rebuild` with embedding enabled |
239
- | `vectors.idx` size | File size in bytes at each corpus size |
240
-
241
- Hybrid benchmarks require a running embedding provider.
242
- The harness accepts `--embedding-provider` as a CLI
243
- flag. When the flag is absent, hybrid measurements are
244
- skipped and the harness prints a notice.
245
-
246
- ## Regression Testing
247
-
248
- Benchmark results from the current release are stored
249
- in `bench/baselines/`. Baseline files are named by
250
- platform and runtime:
251
-
252
- ```
253
- bench/baselines/
254
- linux-x86_64-node-22.json
255
- linux-x86_64-deno-2.json
256
- ```
257
-
258
- The harness compares fresh results against the
259
- baseline and flags any p99 value that exceeds the
260
- baseline by more than 20%. A flagged regression prints
261
- to stderr and exits with a non-zero code.
262
-
263
- Baselines are updated manually when a performance
264
- improvement is intentional. The update command:
265
-
266
- ```sh
267
- node bench/run-benchmark.ts --update-baseline
268
- ```
269
-
270
- CI runs the full benchmark suite on every release
271
- branch push. Regression failures block the release.
272
-
273
- ## Design Constraints
274
-
275
- - Benchmarks run on a single machine. No distributed
276
- or multi-node testing is in scope.
277
- - Corpus generation is deterministic. A fixed seed
278
- always produces the same sections in the same order.
279
- Results are reproducible across machines with the
280
- same platform and runtime.
281
- - The harness uses the public CLI and library API, not
282
- internal modules. This ensures benchmarks measure the
283
- end-to-end path that production callers experience.
284
- - WASM memory measurement uses the
285
- `WebAssembly.Memory` buffer byte size sampled via
286
- the daemon's status response, which exposes the
287
- current WASM linear memory page count. This is an
288
- approximation of the high watermark, not a
289
- continuous trace.
290
- - Index file sizes are measured after the harness
291
- operation completes by reading file sizes from the
292
- `.kbdb/indexes/` directory. They are informational
293
- and not subject to regression thresholds.
294
- - Baseline files are per-platform and per-runtime.
295
- A Linux x86_64 Node.js baseline is not compared
296
- against a Deno run or a different architecture.