albex 0.3.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +466 -0
  2. package/README.md +32 -19
  3. package/dist/albex-worker.d.ts +65 -2
  4. package/dist/albex-worker.d.ts.map +1 -1
  5. package/dist/albex-worker.js +97 -20
  6. package/dist/albex-worker.js.map +1 -1
  7. package/dist/albex.d.ts +359 -55
  8. package/dist/albex.d.ts.map +1 -1
  9. package/dist/albex.js +766 -312
  10. package/dist/albex.js.map +1 -1
  11. package/dist/errors.d.ts +47 -2
  12. package/dist/errors.d.ts.map +1 -1
  13. package/dist/errors.js +41 -3
  14. package/dist/errors.js.map +1 -1
  15. package/dist/persistence.js +1 -1
  16. package/dist/pool/coordinator.d.ts +14 -6
  17. package/dist/pool/coordinator.d.ts.map +1 -1
  18. package/dist/pool/coordinator.js +65 -28
  19. package/dist/pool/coordinator.js.map +1 -1
  20. package/dist/profile.d.ts +11 -6
  21. package/dist/profile.d.ts.map +1 -1
  22. package/dist/profile.js +6 -13
  23. package/dist/profile.js.map +1 -1
  24. package/dist/resource-manager.js +1 -1
  25. package/dist/tiered-store.js +1 -1
  26. package/dist/wasm-bindings.d.ts +96 -6
  27. package/dist/wasm-bindings.d.ts.map +1 -1
  28. package/dist/wasm-bindings.js +110 -7
  29. package/dist/wasm-bindings.js.map +1 -1
  30. package/dist/worker-protocol.d.ts +23 -2
  31. package/dist/worker-protocol.d.ts.map +1 -1
  32. package/dist/worker-protocol.js +1 -1
  33. package/dist/worker-runtime.js +27 -3
  34. package/dist/worker-runtime.js.map +1 -1
  35. package/package.json +13 -9
  36. package/src/albex-worker.ts +103 -18
  37. package/src/albex.ts +2937 -2292
  38. package/src/errors.ts +63 -2
  39. package/src/pool/coordinator.ts +61 -34
  40. package/src/profile.ts +11 -10
  41. package/src/wasm-bindings.ts +225 -10
  42. package/src/worker-protocol.ts +12 -2
  43. package/src/worker-runtime.ts +28 -3
  44. package/wasm/pkg/albex_pdf.wasm +0 -0
  45. package/wasm/pkg/albex_wasm.wasm +0 -0
  46. package/wasm/pkg/albex_wasm_bg.wasm +0 -0
  47. package/wasm/pkg/albex_wasm_simd.wasm +0 -0
  48. package/wasm/pkg/albex_wasm_mini.wasm +0 -0
  49. package/wasm/pkg/albex_wasm_mini_simd.wasm +0 -0
  50. package/wasm/pkg/albex_wasm_pro.wasm +0 -0
  51. package/wasm/pkg/albex_wasm_pro_simd.wasm +0 -0
  52. package/wasm/pkg/albex_wasm_std.wasm +0 -0
  53. package/wasm/pkg/albex_wasm_std_simd.wasm +0 -0
package/dist/albex.d.ts CHANGED
@@ -13,7 +13,6 @@
13
13
  * const results = engine.search('contrato marco');
14
14
  * ```
15
15
  */
16
- import { type Tier } from './profile.js';
17
16
  export { AlbexError, AlbexInitError, AlbexUnsupportedFormatError, AlbexParseError, AlbexCapacityError, } from './errors.js';
18
17
  export { listPersisted, deletePersisted } from './persistence.js';
19
18
  export { detectProfile, pickTier, pickWorkerCount, shouldUseGpu } from './profile.js';
@@ -25,27 +24,64 @@ export type { AlbexPoolOptions } from './pool/coordinator.js';
25
24
  export { BloomGpu, packBloomsFromChunks } from './gpu/bloom-runtime.js';
26
25
  export { TieredStore } from './tiered-store.js';
27
26
  export type { TieredStoreOptions } from './tiered-store.js';
27
+ /**
28
+ * Explicit engine capacity configuration. All fields optional — anything
29
+ * missing is completed from the std defaults, scaled to keep the std
30
+ * ratios when a related field IS provided (documented per field).
31
+ *
32
+ * Estimated WASM memory ≈ `maxChunks × 64 B` (32 B descriptor + 32 B
33
+ * trigram signature) `+ textPoolBytes + namePoolBytes + maxDocs × 28 B`,
34
+ * on top of the engine's fixed ~80 KB of scratch buffers. The std preset
35
+ * is ~22 MB; `'large'` is ~180 MB. WASM linear memory never shrinks: the
36
+ * high-water mark of the largest capacity ever initialised in a given
37
+ * engine stays committed until the engine is disposed.
38
+ */
39
+ export interface AlbexCapacityConfig {
40
+ /** Maximum number of live documents. Default 128. Range 1–65 536. */
41
+ maxDocs?: number;
42
+ /** Maximum number of indexed chunks (≈ paragraphs; long paragraphs split
43
+ * every 512 bytes). Default `max(maxDocs × 782, 1024)` — the std ratio
44
+ * (100 000 chunks / 128 docs). Range maxDocs–4 194 304. */
45
+ maxChunks?: number;
46
+ /** Text pool size in bytes (total UTF-8 text the index can hold).
47
+ * Default `max(maxChunks × 168, 64 KiB)` — the std ratio (16 MiB /
48
+ * 100 000 chunks). Range 4 KiB–1 GiB. */
49
+ textPoolBytes?: number;
50
+ /** Filename pool size in bytes. Default `max(maxDocs × 256, 4 KiB)` —
51
+ * the std ratio (32 KiB / 128 docs). Range 256 B–16 MiB. */
52
+ namePoolBytes?: number;
53
+ }
54
+ /**
55
+ * Engine capacity (decision A16 — runtime capacity, single binary):
56
+ * `'std'` — 128 docs · 100k chunks · 16 MB text · 32 KB names (~22 MB).
57
+ * The default, identical to every previous release.
58
+ * `'large'` — 1 024 docs · 800k chunks · 128 MB text · 256 KB names
59
+ * (~180 MB) — the old compile-time "pro" tier.
60
+ * object — explicit {@link AlbexCapacityConfig}.
61
+ */
62
+ export type AlbexCapacity = 'std' | 'large' | AlbexCapacityConfig;
28
63
  export interface AlbexOptions {
29
64
  /**
30
- * Explicit URL to the main WASM binary.
31
- *
32
- * If you want automatic tier selection (mini/std/pro chosen from
33
- * `deviceMemory`), pass `wasmBaseUrl` instead — the engine will fetch
34
- * `albex_wasm_<tier>.wasm` from that directory.
65
+ * Explicit URL to the main WASM binary. If omitted, the baseline (or
66
+ * SIMD, when supported) binary packaged with albex is used.
35
67
  */
36
68
  wasmUrl?: string;
37
69
  /**
38
- * Base directory containing tiered binaries (`albex_wasm_mini.wasm`,
39
- * `_std.wasm`, `_pro.wasm`). Used when `wasmUrl` is omitted.
70
+ * Base directory containing the two binaries (`albex_wasm.wasm`,
71
+ * `albex_wasm_simd.wasm`). Used when `wasmUrl` is omitted.
40
72
  */
41
73
  wasmBaseUrl?: string;
42
74
  /** URL to albex_pdf.wasm. Required only if you call indexFile() with PDFs. */
43
75
  pdfWasmUrl?: string;
44
76
  /**
45
- * Override the tier auto-detection. Pass `'auto'` (default), or an
46
- * explicit tier when you know the constraints of your target environment.
77
+ * Engine capacity. `'std'` (default) keeps the historical limits;
78
+ * `'large'` raises them to 1 024 docs / 800k chunks / 128 MB text; an
79
+ * object configures each pool explicitly (see {@link AlbexCapacityConfig}
80
+ * for defaults, ranges and the memory cost model). Replaces the removed
81
+ * compile-time `tier` option — capacity is now a runtime parameter of a
82
+ * single binary (`initWithCapacity`, ABI 7).
47
83
  */
48
- tier?: 'auto' | 'mini' | 'std' | 'pro';
84
+ capacity?: AlbexCapacity;
49
85
  /**
50
86
  * SIMD selection. When `'auto'` (default), Albex probes for v128 support
51
87
  * and fetches the `_simd.wasm` variant when available. Pass `'off'` to
@@ -66,6 +102,16 @@ export interface AlbexOptions {
66
102
  * the upload + dispatch overhead is bigger than the speedup. Default: 20_000.
67
103
  */
68
104
  gpuThreshold?: number;
105
+ /**
106
+ * Maximum size (in bytes) of a file accepted by `indexFile`. Checked
107
+ * against `File.size` BEFORE the file is read, so an oversized input is
108
+ * rejected with a typed `AlbexCapacityError` (`limit: 'file'`) without
109
+ * ever being buffered or hashed. Default: 256 MiB — above any default
110
+ * text pool (16 MB std / 128 MB large), so this only stops pathological
111
+ * inputs (e.g. a 2 GB log file) from exhausting tab memory. Raise it if
112
+ * you configure a custom `capacity` with a text pool beyond 256 MiB.
113
+ */
114
+ maxFileBytes?: number;
69
115
  }
70
116
  export interface IndexedDocument {
71
117
  name: string;
@@ -78,27 +124,77 @@ export interface IndexedDocument {
78
124
  /** 64-bit FNV-1a hex of the source file bytes. Stable across runs. */
79
125
  contentHash: string;
80
126
  }
127
+ /**
128
+ * One authoritative chunk of an indexed document — the exact unit Albex
129
+ * indexed and searches over. Returned by {@link AlbexEngine.listChunks} so a
130
+ * host can mirror Albex's chunking (e.g. to build a parallel vector index over
131
+ * the same units). A long paragraph is split into several ≤512-byte chunks that
132
+ * share a `location` but differ in `sub`.
133
+ */
134
+ export interface AuthoritativeChunk {
135
+ /** WASM-side stable document id (survives compact()). */
136
+ docId: number;
137
+ /** Paragraph index (DOCX/TXT) or page number (PDF, 1-based). */
138
+ location: number;
139
+ /** Ordinal of this chunk within its document (0-based, compact()-stable). */
140
+ ord: number;
141
+ /** Ordinal of this chunk within its `location` group (0-based, informational). */
142
+ sub: number;
143
+ /** The exact UTF-8 text Albex indexed for this chunk. */
144
+ text: string;
145
+ /** Byte length of `text`. */
146
+ byteLen: number;
147
+ /**
148
+ * Canonical shared id `"<docId>::<ord>"`. Identical to the matching
149
+ * {@link SearchResult.chunkId}, and stable across compact() and snapshot
150
+ * save/load — so it is safe to persist alongside parallel structures
151
+ * (unlike the absolute chunk index, which compact() renumbers).
152
+ */
153
+ id: string;
154
+ }
81
155
  export interface MatchSpan {
82
- /** Byte offset within `snippet` where this matched token begins. */
156
+ /** UTF-8 **byte** offset within `snippet` where this matched token begins.
157
+ * NOT a JS string index — for `snippet.slice()` use the UTF-16
158
+ * {@link SearchResult.snippetStart}/{@link SearchResult.snippetEnd} of the
159
+ * primary span instead. */
83
160
  start: number;
84
- /** Byte offset within `snippet` where this matched token ends (exclusive). */
161
+ /** UTF-8 **byte** offset within `snippet` where this matched token ends
162
+ * (exclusive). See the note on `start`. */
85
163
  end: number;
86
164
  }
87
165
  export interface SearchResult {
88
166
  documentName: string;
167
+ /** WASM-side stable document id (survives compact()). Matches
168
+ * `AuthoritativeChunk.docId` from {@link AlbexEngine.listChunks}. */
169
+ docId: number;
89
170
  /** Paragraph index (DOCX/TXT) or page number (PDF, 1-based). */
90
171
  location: number;
172
+ /** Canonical chunk id `"<docId>::<ord>"` — identical to the matching
173
+ * {@link AuthoritativeChunk.id}, so a host can fuse search hits with a
174
+ * parallel index (e.g. embeddings) on this key. Stable across compact(). */
175
+ chunkId: string;
91
176
  /** Relevance score 0–1000. */
92
177
  score: number;
93
178
  /** Snippet text. With `windowed` search options this is a substring with
94
179
  * ASCII ellipsis sentinels (`"... "` / `" ..."`) the UI should render
95
180
  * as `…`. Without windowing, the full chunk text. */
96
181
  snippet: string;
97
- /** Primary token match (kept for backwards compatibility). Equal to `matches[0]`. */
182
+ /** Primary token match as UTF-8 **byte** offsets within the encoded
183
+ * snippet (kept for backwards compatibility; equal to `matches[0]`).
184
+ * Byte offsets drift from JS string indices as soon as the snippet
185
+ * contains accents/ñ/emoji — use {@link snippetStart}/{@link snippetEnd}
186
+ * for `snippet.slice()` / UI highlighting. */
98
187
  matchStart: number;
99
188
  matchEnd: number;
100
- /** All matched token spans within `snippet`, in query order. Length 1–4. */
189
+ /** All matched token spans within `snippet` as UTF-8 **byte** offsets,
190
+ * in query order. Length 1–4. */
101
191
  matches: MatchSpan[];
192
+ /** Primary token match start as a UTF-16 code-unit index into `snippet` —
193
+ * safe to pass directly to `snippet.slice(snippetStart, snippetEnd)`. */
194
+ snippetStart: number;
195
+ /** Primary token match end (exclusive) as a UTF-16 code-unit index into
196
+ * `snippet`. */
197
+ snippetEnd: number;
102
198
  }
103
199
  /**
104
200
  * Options that change how snippets are produced. Both fields are optional.
@@ -125,15 +221,17 @@ export interface SearchOptions {
125
221
  export interface EngineStats {
126
222
  documents: number;
127
223
  chunks: number;
224
+ /** Bytes of indexed text currently in the text pool. */
128
225
  textUsed: number;
226
+ /** RUNTIME text pool capacity in bytes (= resolved `textPoolBytes`). */
129
227
  textCapacity: number;
130
228
  wasmMemoryBytes: number;
131
- /** Tier loaded at init time (mini/std/pro). */
132
- tier: Tier | null;
133
- /** Compile-time chunk capacity for the loaded tier. */
229
+ /** RUNTIME chunk capacity the engine was initialised with. */
134
230
  maxChunks: number;
135
- /** Compile-time document capacity for the loaded tier. */
231
+ /** RUNTIME document capacity the engine was initialised with. */
136
232
  maxDocs: number;
233
+ /** RUNTIME filename pool capacity in bytes. */
234
+ namePoolBytes: number;
137
235
  }
138
236
  export interface SearchStats {
139
237
  query: string;
@@ -142,6 +240,33 @@ export interface SearchStats {
142
240
  bloomTested: number;
143
241
  bloomPassed: number;
144
242
  bitapMatched: number;
243
+ /** True if the query had more than 8 OR branches — the extras were
244
+ * discarded and did not contribute results. */
245
+ truncatedBranches?: boolean;
246
+ /** True if tokens were dropped (more than 4 per branch) or clipped
247
+ * (longer than 64 bytes). */
248
+ truncatedTokens?: boolean;
249
+ /** True if the raw query exceeded 1024 bytes and was cut. */
250
+ truncatedQuery?: boolean;
251
+ }
252
+ /**
253
+ * One structured warning recorded by the engine during indexFile or
254
+ * load. Replaces the pre-0.5.0 pattern of scattered `console.warn`
255
+ * calls. Inspect via `engine.takeDiagnostics()` after the operation.
256
+ */
257
+ export interface AlbexDiagnostic {
258
+ /** Coarse kind. `'recovered'` means the engine handled the issue and
259
+ * kept going; `'skipped'` means content was dropped; `'fallback'` means
260
+ * an alternate code path was used (e.g. lopdf after pdf-extract trap). */
261
+ kind: 'recovered' | 'skipped' | 'fallback' | 'info';
262
+ /** Where in the pipeline this happened. Free-form short tag. */
263
+ stage: 'pdf' | 'ocr' | 'gpu' | 'persistence' | 'network';
264
+ /** Human-readable message safe to surface in a UI. */
265
+ message: string;
266
+ /** Optional file the issue belongs to. */
267
+ file?: string;
268
+ /** Optional page number (1-based for PDFs). */
269
+ page?: number;
145
270
  }
146
271
  /**
147
272
  * Result shape returned by an attached OCR module. Kept structural here so
@@ -157,6 +282,36 @@ export interface OcrAttachedOptions {
157
282
  lang?: string;
158
283
  hint?: string;
159
284
  }
285
+ /**
286
+ * Contract the engine accepts from an OCR plugin. `@albex/ocr` is the
287
+ * canonical implementation, but any module that satisfies this interface
288
+ * can be attached via `engine.attachOcr(adapter)`.
289
+ */
290
+ export interface OcrAdapter {
291
+ /** Invoked by the engine to OCR a single image. Receives whatever the
292
+ * caller passes (Blob, ArrayBuffer, etc.); the adapter is responsible
293
+ * for accepting that input. Must return text + confidence. */
294
+ recognize(image: unknown, opts?: OcrAttachedOptions): Promise<OcrAttachedResult>;
295
+ /** Engine-side switches the adapter wants honoured. The only one
296
+ * defined today is `alwaysExtractEmbeddedImages`, which turns on the
297
+ * hybrid PDF OCR pass. New flags can be added without breaking the
298
+ * adapter interface. */
299
+ options?: {
300
+ /** When true, every PDF (native or scanned) is walked for embedded
301
+ * images and each qualifying image is sent to `recognize`. Off by
302
+ * default to keep performance predictable on native PDFs. */
303
+ alwaysExtractEmbeddedImages?: boolean;
304
+ };
305
+ }
306
+ /** Returned by `attachOcr`. Holds the lifecycle handles for the plugin.
307
+ * Calling `dispose()` removes the adapter from the engine; subsequent
308
+ * `engine.ocrImage` access returns `undefined` again. */
309
+ export interface OcrHandle {
310
+ /** Detach the plugin and tear down any resources it holds. After this,
311
+ * the engine reverts to "no OCR" — scanned PDFs go back to registering
312
+ * with zero chunks. */
313
+ dispose(): Promise<void>;
314
+ }
160
315
  export declare class AlbexEngine {
161
316
  private _wasm;
162
317
  private _mem;
@@ -166,61 +321,83 @@ export declare class AlbexEngine {
166
321
  * runtime dependency on OCR — this is a structural slot that the optional
167
322
  * companion package fills.
168
323
  */
169
- ocrImage?: (image: unknown, opts?: OcrAttachedOptions) => Promise<OcrAttachedResult>;
170
324
  /**
171
- * Optional OCR-side configuration set by `@albex/ocr::enableOcr`. Read
172
- * by the engine to decide whether to invoke OCR on top of the text it
173
- * already extracted from a PDF (hybrid PDFs: native text + images that
174
- * also contain text, like stamps, scanned annexes, or diagrams with
175
- * labels).
176
- *
177
- * When `alwaysExtractEmbeddedImages` is true, every page of every PDF
178
- * passes through `extractPageImages` after the normal text extraction;
179
- * any image that meets the size filter (200×200 in Rust) is fed to
180
- * `ocrImage`. Performance cost: 1–3 s per qualifying image.
181
- *
182
- * Off by default — set this opt-in via the OCR module's options.
325
+ * Public OCR entry point. Forwards to the attached OCR adapter installed
326
+ * via `attachOcr()`. Reading this property is a feature-detect for
327
+ * integrators: `if (engine.ocrImage) { ... OCR available ... }`. Writing
328
+ * to it directly is no longer supported in 0.5.0+ — use `attachOcr`.
183
329
  */
184
- ocrConfig?: {
185
- alwaysExtractEmbeddedImages?: boolean;
186
- };
330
+ get ocrImage(): ((image: unknown, opts?: OcrAttachedOptions) => Promise<OcrAttachedResult>) | undefined;
331
+ /** Private adapter slot. Holds the OCR plugin contract installed by
332
+ * `attachOcr()`. The engine reads `recognize` and `options` here; the
333
+ * caller never gets a reference to this object directly. */
334
+ private _ocrAdapter;
187
335
  private _pdfWasm;
188
336
  private _pdfMem;
189
337
  private _docs;
190
338
  private _lastSearch;
191
- private _tier;
339
+ /** Raw truncation bitflags from the most recent prepareQuery (ABI 5):
340
+ * 1 = branches dropped, 2 = tokens dropped/clipped, 4 = query bytes cut.
341
+ * Captured right after prepareQuery so every _lastSearch built for that
342
+ * query (including per-branch OR runs) reports the same flags. */
343
+ private _lastTruncFlags;
344
+ /** Structured diagnostics collected during the most recent operation.
345
+ * Drained by `takeDiagnostics()`. Capped at 256 entries to avoid
346
+ * unbounded memory growth in pathological cases (very corrupted
347
+ * corpora producing thousands of recovery warnings). */
348
+ private _diagnostics;
349
+ /** Resolved runtime capacity (set in init(); reused by reset()). */
350
+ private _capacity;
192
351
  private _simd;
193
352
  private _profile;
194
353
  private _resources;
195
354
  private _gpu;
196
- private _gpuChunkCountUploaded;
355
+ /** True when the GPU-resident Bloom array no longer mirrors the WASM
356
+ * chunk array. Set by EVERY index mutation (indexFile, removeDocument,
357
+ * compact, reset, load) and cleared after a successful upload. A plain
358
+ * chunk-count comparison is NOT enough: compact() can reorder blooms
359
+ * while keeping the count identical, which would silently filter the
360
+ * wrong chunks (audit 1.5). */
361
+ private _gpuUploadDirty;
197
362
  private _unsubscribeResources;
198
363
  private readonly _opts;
199
- constructor(opts: AlbexOptions);
200
- /** Load and initialise the main WASM module. Must be called before any other method. */
364
+ private _opChain;
365
+ private _busy;
366
+ constructor(opts?: AlbexOptions);
367
+ /** Serialize an async engine operation behind any in-flight one. */
368
+ private _exclusive;
369
+ /** Guard a synchronous mutator/search: refuse to run mid-async-operation
370
+ * rather than silently corrupt the shared WASM state. */
371
+ private _assertIdle;
372
+ /** Compact opportunistically when tombstones pile up under text pressure,
373
+ * so repeated removeDocument/replaceDocument don't exhaust the pool. */
374
+ private _autoCompactIfNeeded;
375
+ /**
376
+ * Load and initialise the main WASM module. Must be called before any
377
+ * other method.
378
+ *
379
+ * Resolves `opts.capacity` ('std' default · 'large' · explicit object)
380
+ * and sizes the WASM pools accordingly via `initWithCapacity` (ABI 7).
381
+ * Memory cost ≈ `maxChunks × 64 B + textPoolBytes + namePoolBytes` —
382
+ * ~22 MB for 'std', ~180 MB for 'large'. Throws `AlbexInitError` if the
383
+ * requested capacity is out of range or the allocation fails.
384
+ */
201
385
  init(): Promise<void>;
202
386
  /**
203
387
  * Decide which `.wasm` binary to fetch. Order of precedence:
204
- * 1. `opts.wasmUrl` if provided — used verbatim.
205
- * 2. `opts.tier` if explicit — joined with `wasmBaseUrl`.
206
- * 3. `opts.wasmBaseUrl` + tier picked from the device profile.
207
- *
208
- * Order of precedence:
209
388
  * 1. `opts.wasmUrl` literal → use verbatim
210
- * 2. `opts.wasmBaseUrl` + tier suffix → fetched from that directory
389
+ * 2. `opts.wasmBaseUrl` + simd suffix → fetched from that directory
211
390
  * 3. zero-config default → `albex_wasm_bg.wasm` packaged
212
391
  * next to this file, resolved
213
392
  * via `import.meta.url`
214
393
  *
215
- * The zero-config default loads the std-baseline binary. Tier auto-detection
216
- * is only active when `wasmBaseUrl` is given, because picking a tier in
217
- * runtime would defeat any bundler's static asset rewriting. Users who want
218
- * tier optimisation must serve the six variants themselves and pass the
219
- * directory through `wasmBaseUrl`.
394
+ * There are exactly two main binaries (baseline + SIMD); capacity is a
395
+ * RUNTIME parameter since ABI 7, so it never affects which file is
396
+ * fetched. SIMD auto-detection is only active when `wasmBaseUrl` is
397
+ * given, because picking a URL at runtime would defeat any bundler's
398
+ * static asset rewriting.
220
399
  */
221
400
  private _resolveWasmUrl;
222
- /** The tier that was actually loaded. `null` until `init()` resolves. */
223
- get tier(): Tier | null;
224
401
  /** True if the SIMD-accelerated binary was loaded. */
225
402
  get simdEnabled(): boolean;
226
403
  /** True if a WebGPU device is acquired and the next search will use it. */
@@ -243,13 +420,33 @@ export declare class AlbexEngine {
243
420
  * No-op if the GPU device hasn't been acquired yet — first call attempts
244
421
  * `init()` lazily; if that fails, the candidate path is permanently
245
422
  * disabled for this engine instance.
423
+ *
424
+ * IMPORTANT: this method CLOBBERS the scratchpad (the candidate bitset
425
+ * is pushed through it via `setCandidateMask`). Any pattern previously
426
+ * staged by `selectQueryBranch` is destroyed — the caller MUST re-select
427
+ * the active branch before calling `searchBegin`, which snapshots the
428
+ * pattern from the scratchpad (audit 1.2).
246
429
  */
247
430
  private _gpuPreFilter;
248
431
  private _u8;
249
432
  private _writePad;
250
433
  private _writeStr;
251
434
  private _readPad;
435
+ /** Copy `n` scratchpad bytes out of WASM memory. The copy is private to
436
+ * JS, so it survives later WASM calls (and memory growth) — used when the
437
+ * caller needs both the raw bytes (UTF-16 span mapping) and the decoded
438
+ * string of the same payload. */
439
+ private _readPadBytes;
252
440
  private _feedText;
441
+ /**
442
+ * Compute the FNV-1a 64-bit content hash of `bytes` via the WASM
443
+ * streaming API. Returns a 16-character hex string identical in shape
444
+ * to what the TS implementation in 0.3.x returned, so all callers
445
+ * stay unchanged. Single source of truth — same hash whether we use
446
+ * it for indexFile dedup, for snapshot v2 persistence, or anywhere
447
+ * else. Large inputs are chunked at FEED_SIZE just like _feedText.
448
+ */
449
+ private _contentHash;
253
450
  private _feedXmlBytes;
254
451
  private _ensurePdfWasm;
255
452
  private _indexDocx;
@@ -336,10 +533,13 @@ export declare class AlbexEngine {
336
533
  private _indexRtf;
337
534
  private static readonly _INDEXERS;
338
535
  /**
339
- * Index a file. Supported formats: DOCX, XLSX, PDF, TXT, XML.
536
+ * Index a file. Supported formats (11, with varying depth): DOCX, XLSX, PDF,
537
+ * HTML, MD, JSON, CSV, EML, RTF, TXT, XML. Several are deliberately "lite"
538
+ * (CSV is RFC-4180-lite, EML is MIME-lite, RTF is regex-stripped).
340
539
  * Throws for unsupported formats or parse errors.
341
540
  */
342
541
  indexFile(file: File): Promise<IndexedDocument>;
542
+ private _indexFileInner;
343
543
  /**
344
544
  * Mark a previously indexed document as removed. Searches no longer return
345
545
  * its chunks. Storage is reclaimed only after `compact()`.
@@ -348,6 +548,7 @@ export declare class AlbexEngine {
348
548
  * Returns `true` if a matching document was found and tombstoned.
349
549
  */
350
550
  removeDocument(id: string): boolean;
551
+ private _removeDocumentInner;
351
552
  /**
352
553
  * Replace a previously indexed document with new content. Equivalent to
353
554
  * `removeDocument(name)` + `indexFile(newFile)` but does not trigger the
@@ -362,6 +563,21 @@ export declare class AlbexEngine {
362
563
  * references (e.g. in a UI) remain valid.
363
564
  */
364
565
  compact(): void;
566
+ /**
567
+ * Enumerate the authoritative chunks Albex indexed for a document, in order.
568
+ * Lets a host mirror Albex's exact chunking — e.g. embed the same units for a
569
+ * parallel semantic index keyed on the same {@link AuthoritativeChunk.id}
570
+ * (`"<docId>::<ord>"`, identical to {@link SearchResult.chunkId}). `docId` is
571
+ * `IndexedDocument.docId` from {@link indexFile}; returns `[]` if no live
572
+ * document has that id.
573
+ *
574
+ * The returned `id`/`ord`/`sub` are stable across {@link compact} and
575
+ * snapshot save/load. Never key persistent structures on a search result's
576
+ * absolute `chunkIdx`, which {@link compact} renumbers.
577
+ */
578
+ listChunks(docId: number): AuthoritativeChunk[];
579
+ /** Doc-table slot (0..getDocCount) whose stable id is `docId`, or -1. */
580
+ private _docSlotOf;
365
581
  /**
366
582
  * Search the index. Supports:
367
583
  * - Simple queries: `contrato` (AND of tokens, accent-insensitive)
@@ -370,8 +586,17 @@ export declare class AlbexEngine {
370
586
  *
371
587
  * Pass `{ windowed: true }` to receive cropped snippets with ASCII ellipsis
372
588
  * markers instead of full chunk text. Defaults: 60 bytes before, 120 after.
589
+ *
590
+ * Note: this synchronous path never uses the GPU pre-filter — the WebGPU
591
+ * scan is asynchronous by nature. Only `searchCooperative` (the budgeted
592
+ * path) engages the GPU; `search()` always runs the CPU Bloom pre-filter,
593
+ * regardless of the `gpu` option.
373
594
  */
374
595
  search(query: string, opts?: SearchOptions): SearchResult[];
596
+ /** Read the WASM-compiled tokens of branch `i` for phrase post-filter.
597
+ * The bytes returned are exactly what the WASM tokenizer produced —
598
+ * no TS re-tokenization. */
599
+ private _branchTokens;
375
600
  /**
376
601
  * Cooperative search. Processes the corpus in slices, yielding to the
377
602
  * event loop between them so the host UI thread keeps a chance to paint
@@ -387,6 +612,9 @@ export declare class AlbexEngine {
387
612
  * Pass `opts.frameBudgetMs` to control the slice size (default 8 ms).
388
613
  */
389
614
  searchCooperative(query: string, opts?: SearchOptions): AsyncIterable<SearchResult>;
615
+ /** Materialise a cooperative search to a sorted result array. Runs inside
616
+ * the exclusivity lock. Frame-budget yielding lives in _runSearchBudgeted. */
617
+ private _searchCooperativeCollect;
390
618
  /**
391
619
  * @deprecated Renamed to `searchCooperative` in 0.3.0. The original name
392
620
  * was misleading — this method does not stream incremental results, it
@@ -404,11 +632,34 @@ export declare class AlbexEngine {
404
632
  * may eat the entire budget, which is also fine.
405
633
  */
406
634
  private _runSearchBudgeted;
407
- /** Materialise results [0..count) into the public SearchResult shape. */
635
+ /** Truncation booleans for SearchStats, decoded from the flags the WASM
636
+ * reported for the most recent prepareQuery (audit 1.6 — the engine used
637
+ * to drop OR branches past 8 and tokens past 4 in silence). */
638
+ private _truncStats;
639
+ /** Materialise results [0..count) into the public SearchResult shape.
640
+ * When `phraseTokens` is given, each result is kept only if those tokens
641
+ * appear adjacently in the FULL chunk text — independent of any display
642
+ * windowing — so phrase queries stay correct under `{ windowed: true }`.
643
+ *
644
+ * Frontier discipline (audit 2.1): all numeric fields of every result are
645
+ * read in ONE DataView pass over the `#[repr(C)]` RESULTS array
646
+ * (`getResultsPtr`/`getResultStride`, ABI 6) — the old path made 12-15
647
+ * frontier calls per result. Strings still need calls, minimised to one
648
+ * snippet read per result plus one doc-name read per DISTINCT document
649
+ * (the old `getResultDocName` was additionally O(doc_count) inside WASM
650
+ * for every single result). */
408
651
  private _collectResults;
652
+ /** Run all OR branches and merge dedup-by-(chunkId, matchStart). The
653
+ * branches are already compiled inside the WASM (by prepareQuery); we
654
+ * iterate them with selectQueryBranch. The "rawQuery" param is kept
655
+ * only for the lastSearch.query field. */
409
656
  private _searchOr;
657
+ /** Execute a single search using whichever query branch is currently
658
+ * active (set via selectQueryBranch). Returns the materialised
659
+ * SearchResult[]. Caller is responsible for activating a branch first. */
410
660
  private _runSearch;
411
- /** Returns current engine statistics. */
661
+ /** Returns current engine statistics (capacities are the RUNTIME values
662
+ * the engine was initialised with via the `capacity` option). */
412
663
  getStats(): EngineStats;
413
664
  /** Returns stats from the most recent search, or null. */
414
665
  getLastSearchStats(): SearchStats | null;
@@ -433,6 +684,57 @@ export declare class AlbexEngine {
433
684
  setLanguage(lang: 'off' | 'es'): void;
434
685
  /** Full reset — clears all indexed documents and chunks. */
435
686
  reset(): void;
687
+ private _resetInner;
688
+ /**
689
+ * Drain and return the diagnostics collected since the last call (or
690
+ * since the engine was created). Use this to surface recoverable
691
+ * issues to the caller after `indexFile`, `load`, or any other
692
+ * operation that may run into a "best-effort" path.
693
+ *
694
+ * Example diagnostics:
695
+ * - `{kind:'fallback', stage:'pdf', message:'pdf-extract crashed,
696
+ * attempting OCR-only fallback', file:'invoice.pdf'}`
697
+ * - `{kind:'skipped', stage:'ocr', message:'Tesseract abort on page
698
+ * 3 image 1; remaining images on this page skipped', file:'...',
699
+ * page:3}`
700
+ * - `{kind:'fallback', stage:'gpu', message:'GPU pre-filter failed,
701
+ * using CPU'}`
702
+ *
703
+ * The buffer is cleared on each call; callers should consume the
704
+ * returned array immediately (e.g. log to their telemetry, surface
705
+ * a UI banner). After `reset()` the buffer is also cleared.
706
+ */
707
+ takeDiagnostics(): AlbexDiagnostic[];
708
+ /** Internal: record a diagnostic. Capped at 256 to bound memory. */
709
+ private _diag;
710
+ /**
711
+ * Install an OCR adapter. Returns a handle whose `dispose()` removes the
712
+ * adapter from the engine.
713
+ *
714
+ * The contract: the adapter must provide `recognize(image, opts)` that
715
+ * returns `Promise<OcrAttachedResult>`. The engine validates the
716
+ * contract at attach time and refuses adapters that don't expose a
717
+ * recognise function. Only one adapter can be attached at a time; a
718
+ * second call to `attachOcr` while one is active throws — the caller
719
+ * must dispose the previous one first.
720
+ *
721
+ * @example
722
+ * ```ts
723
+ * import { enableOcr } from '@albex/ocr';
724
+ * const handle = enableOcr(engine); // internally calls attachOcr
725
+ * // ... later ...
726
+ * await handle.dispose();
727
+ * ```
728
+ *
729
+ * Direct use without the companion package:
730
+ * ```ts
731
+ * const handle = engine.attachOcr({
732
+ * recognize: async (blob) => myCustomOcr(blob),
733
+ * options: { alwaysExtractEmbeddedImages: false },
734
+ * });
735
+ * ```
736
+ */
737
+ attachOcr(adapter: OcrAdapter): OcrHandle;
436
738
  /**
437
739
  * Persist the current index to OPFS (or IndexedDB as fallback) under `name`.
438
740
  *
@@ -441,12 +743,14 @@ export declare class AlbexEngine {
441
743
  * state in roughly O(total bytes), bypassing re-parsing.
442
744
  */
443
745
  save(name: string): Promise<void>;
746
+ private _saveInner;
444
747
  /**
445
748
  * Restore an index previously saved with `save(name)`. Returns `true` on
446
749
  * success, `false` if the snapshot is missing or has an incompatible
447
750
  * header (wrong magic, version, or struct sizes).
448
751
  */
449
752
  load(name: string): Promise<boolean>;
753
+ private _loadInner;
450
754
  /**
451
755
  * Convenience: load if the snapshot exists, otherwise leave the engine
452
756
  * empty. Returns whether a load actually happened.
@@ -1 +1 @@
1
- {"version":3,"file":"albex.d.ts","sourceRoot":"","sources":["../src/albex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAoBH,OAAO,EAAyC,KAAK,IAAI,EAAsB,MAAM,cAAc,CAAC;AAIpG,OAAO,EACL,UAAU,EACV,cAAc,EACd,2BAA2B,EAC3B,eAAe,EACf,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,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