@vostride/agent-qa-knowledge-local 0.2.2 → 0.2.4

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.
@@ -0,0 +1,556 @@
1
+ import { EmbeddingProfile, QuarantineLedgerEvent, QuarantineEntryState, VerdictClass, Verdict, RecordFrontmatter, BundleManifest, BundleProvenance, BundleRelations, BundleOutcomeEvent, ArtifactsIndex, ScreenState, MeasurementBaseline, MeasurementObservation, DerivedTrustState, GateLine, RecordId, Anchor, BundleStatus, ScopeKey, IndexEntry, AuthoringBrief, ServedRetrievalTraceV1, InspectFilter, InspectRecordView, RecordChange, KnowledgeRecordShowResult, EvidenceToken, MarkReceipt, CompletedRunHandoff } from '@vostride/agent-qa-schema';
2
+ import { AuthoringReadPort } from '@vostride/agent-qa-agent';
3
+ import { KnowledgeHintReader } from '@vostride/agent-qa-runner';
4
+ import { DatabaseSync } from 'node:sqlite';
5
+
6
+ interface EmbedderPort {
7
+ embedDocument(rendering: string): Promise<Float32Array>;
8
+ embedQuery(rendering: string): Promise<Float32Array>;
9
+ }
10
+
11
+ declare const INDEX_DB_FILE = "knowledge.db";
12
+ /** Any other stamp resets the index. */
13
+ declare const INDEX_SCHEMA_VERSION = 2;
14
+ declare const INDEX_RENDERING_SCHEMA_VERSION = 2;
15
+ /**
16
+ * Projection tables every readable index must expose.
17
+ *
18
+ * Per-profile vec tables are deliberately excluded: vec0 is a conditional
19
+ * capability, while operation-time failover and the next rebuild heal a lost
20
+ * capability-specific table.
21
+ */
22
+ declare const REQUIRED_INDEX_TABLES: readonly ["records", "fts_records", "anchors", "graph_nodes", "graph_edges", "meta"];
23
+ declare const WRITER_BUSY_TIMEOUT_MS = 2000;
24
+ declare const READER_BUSY_TIMEOUT_MS = 500;
25
+ declare const CHECKPOINT_EVERY_N_BUNDLES = 32;
26
+ type VecCapability = 'vec0' | 'brute';
27
+ interface IndexWriterHandle {
28
+ db: DatabaseSync;
29
+ vec: VecCapability;
30
+ readonly renderingEpochStale: boolean;
31
+ completeRenderingEpoch(): void;
32
+ checkpointPassive(): void;
33
+ close(): void;
34
+ }
35
+ interface IndexReaderConnection {
36
+ db: DatabaseSync;
37
+ vec: VecCapability;
38
+ }
39
+ /** Durable writer work that can be inspected without opening a mutable index connection. */
40
+ interface IndexMaintenanceState {
41
+ indexAbsent: boolean;
42
+ pendingEmbeddings: number;
43
+ renderingEpochStale: boolean;
44
+ vectorReconciliationOutstanding: boolean;
45
+ }
46
+ type IndexHealth = {
47
+ ok: true;
48
+ } | {
49
+ ok: false;
50
+ probe: 'quick-check' | 'projection-schema' | 'schema-version';
51
+ reason: string;
52
+ };
53
+ interface IndexOpenOptions {
54
+ vecLoadablePath?: string;
55
+ }
56
+ interface IndexReaderOpenOptions extends IndexOpenOptions {
57
+ inspectCheckpointedImmutably?: boolean;
58
+ }
59
+ declare function indexDbPath(knowledgeRoot: string): string;
60
+ /**
61
+ * Inspect bounded durable maintenance facts without bootstrapping, migrating, or restamping.
62
+ *
63
+ * Absence is a valid schedulable state. Once the database exists, malformed or incomplete
64
+ * projection schemas throw so callers cannot mistake an unreadable index for convergence.
65
+ */
66
+ declare function readIndexMaintenanceState(knowledgeRoot: string): IndexMaintenanceState;
67
+ declare function resolveVecCapability(db: DatabaseSync, loadablePath?: string): VecCapability;
68
+ declare function vecTableName(profile: EmbeddingProfile): string;
69
+ /** Stable identity persisted in meta and used to select a closed-list profile. */
70
+ declare function embeddingProfileKey(profile: EmbeddingProfile): string;
71
+ declare function resolveActiveProfile(db: DatabaseSync): EmbeddingProfile;
72
+ declare function openIndexWriter(knowledgeRoot: string, opts?: IndexOpenOptions): IndexWriterHandle;
73
+ declare function openIndexReaderConnection(knowledgeRoot: string, opts?: IndexReaderOpenOptions): IndexReaderConnection;
74
+ declare function probeIndexHealth(db: DatabaseSync): IndexHealth;
75
+
76
+ /** The ledger's fixed name directly under the committed knowledge root — never caller-supplied. */
77
+ declare const QUARANTINE_LEDGER_FILENAME = "quarantine.jsonl";
78
+ /** One line the read refused, surfaced as data so a caller can print or audit it. */
79
+ interface RefusedQuarantineLine {
80
+ /** 1-based, so it matches what an editor shows the human who has to fix the file. */
81
+ lineNumber: number;
82
+ reason: string;
83
+ }
84
+ interface QuarantineLedgerRead {
85
+ events: readonly QuarantineLedgerEvent[];
86
+ refusedLines: readonly RefusedQuarantineLine[];
87
+ }
88
+ /** The ledger's absolute path under one knowledge root. */
89
+ declare function quarantineLedgerPath(knowledgeRoot: string): string;
90
+ declare function readQuarantineLedger(knowledgeRoot: string): QuarantineLedgerRead;
91
+ declare function foldQuarantineLedgerState(events: readonly QuarantineLedgerEvent[], now: string): QuarantineEntryState[];
92
+ /** What an append answers: how many lines it wrote. */
93
+ type QuarantineAppendOutcome = {
94
+ kind: 'appended';
95
+ lines: number;
96
+ };
97
+
98
+ declare const QUARANTINE_FLAG_FLOOR = 2;
99
+ declare const QUARANTINE_ESCALATE_THRESHOLD = 3;
100
+ declare const QUARANTINE_AUTO_EXIT_PASSES = 5;
101
+ declare const QUARANTINE_DEFAULT_EXPIRY_DAYS = 30;
102
+ /** What escalation does with a verdict class. */
103
+ type QuarantineDisposition = 'auto-quarantine' | 'escalate-only';
104
+ declare const QUARANTINE_CLASS_DISPOSITIONS: {
105
+ readonly flake: "auto-quarantine";
106
+ readonly environment: "auto-quarantine";
107
+ readonly timeout: "auto-quarantine";
108
+ readonly app_bug: "escalate-only";
109
+ readonly test_bug: "escalate-only";
110
+ readonly config_error: "escalate-only";
111
+ readonly llm_error: "escalate-only";
112
+ readonly unknown: "escalate-only";
113
+ };
114
+ declare const AUTO_QUARANTINE_CLASSES: readonly VerdictClass[];
115
+ type QuarantineFloorEligibility = 'floor-eligible' | 'authored-required';
116
+ declare const QUARANTINE_FLOOR_ELIGIBILITY: {
117
+ readonly flake: "floor-eligible";
118
+ readonly environment: "authored-required";
119
+ readonly timeout: "floor-eligible";
120
+ readonly app_bug: "authored-required";
121
+ readonly test_bug: "authored-required";
122
+ readonly config_error: "authored-required";
123
+ readonly llm_error: "authored-required";
124
+ readonly unknown: "authored-required";
125
+ };
126
+ interface QuarantineDetectionFailure {
127
+ product: string;
128
+ filePath: string;
129
+ testName: string;
130
+ fingerprint: string;
131
+ verdictClass: VerdictClass;
132
+ producer: Verdict['producer'];
133
+ sameBuildPassAndFail: boolean;
134
+ /** DISTINCT build ordinals inside the window carrying this fingerprint. */
135
+ occurrenceOrdinals: number;
136
+ /** DISTINCT build ordinals inside the window carrying ANY failure — the honest denominator. */
137
+ windowOrdinals: number;
138
+ }
139
+ /** One recorded outcome, ordinal-keyed. Mirrors the projection's per-test outcome window entry. */
140
+ interface QuarantineOrdinalOutcome {
141
+ buildOrdinal: number;
142
+ passed: boolean;
143
+ }
144
+ /** One quarantined test's recent outcome window — the auto-exit's only input. */
145
+ interface QuarantineDetectionTestWindow {
146
+ product: string;
147
+ filePath: string;
148
+ testName: string;
149
+ /** May carry several entries per ordinal (two runs in one build); order is irrelevant. */
150
+ ordinals: readonly QuarantineOrdinalOutcome[];
151
+ }
152
+ interface EvaluateQuarantineDetectionInput {
153
+ failures: readonly QuarantineDetectionFailure[];
154
+ testWindows: readonly QuarantineDetectionTestWindow[];
155
+ /** The ledger folded against this same `now` — the suppression and exit input. */
156
+ entries: readonly QuarantineEntryState[];
157
+ /** ISO-8601 instant. The ONLY way wall clock enters this rule. */
158
+ now: string;
159
+ }
160
+ /** A crossing the caller must SHOW: flagged, or escalated-and-deliberately-not-quarantined. */
161
+ interface QuarantineDetectionSighting {
162
+ product: string;
163
+ filePath: string;
164
+ testName: string;
165
+ fingerprint: string;
166
+ verdictClass: VerdictClass;
167
+ producer: Verdict['producer'];
168
+ occurrenceOrdinals: number;
169
+ windowOrdinals: number;
170
+ }
171
+ interface QuarantineDetectionResult {
172
+ /** Lifecycle events to append, entered-then-released, each group identity-sorted. */
173
+ events: QuarantineLedgerEvent[];
174
+ /** At the flag floor: suspected flaky, no state change, no ledger write. */
175
+ flagged: QuarantineDetectionSighting[];
176
+ /** Escalated but class-gated away from auto-quarantine — the build keeps failing. */
177
+ escalatedNotQuarantined: QuarantineDetectionSighting[];
178
+ }
179
+ declare function evaluateQuarantineDetection(input: EvaluateQuarantineDetectionInput): QuarantineDetectionResult;
180
+
181
+ interface LoadedBundle {
182
+ frontmatter: RecordFrontmatter;
183
+ summary: string;
184
+ body: string;
185
+ manifest: BundleManifest;
186
+ provenance: BundleProvenance;
187
+ relations: BundleRelations;
188
+ events: BundleOutcomeEvent[];
189
+ artifactsIndex: ArtifactsIndex;
190
+ screenStates: ScreenState[];
191
+ }
192
+ type LoadBundleOutcome = {
193
+ kind: 'loaded';
194
+ bundle: LoadedBundle;
195
+ } | {
196
+ kind: 'not-found';
197
+ } | {
198
+ kind: 'incomplete';
199
+ } | {
200
+ kind: 'version-error';
201
+ reason: string;
202
+ } | {
203
+ kind: 'invalid';
204
+ reason: string;
205
+ };
206
+ interface IntegrityReport {
207
+ ok: boolean;
208
+ violations: string[];
209
+ }
210
+ declare const GATES_REL_PATH = "evidence/gates.jsonl";
211
+ interface Measurements {
212
+ baseline: MeasurementBaseline;
213
+ observations: MeasurementObservation[];
214
+ }
215
+ declare function readMeasurements(bundleDir: string): Measurements | undefined;
216
+ declare function readGateReceipts(bundleDir: string, bundleId: string): GateLine[] | undefined;
217
+ declare function loadBundle(bundleDir: string): LoadBundleOutcome;
218
+ declare function verifyBundleIntegrity(bundleDir: string): IntegrityReport;
219
+ declare function deriveBundleTrust(loaded: LoadedBundle): DerivedTrustState;
220
+
221
+ interface KnowledgeHit {
222
+ bundleId: string;
223
+ product: string;
224
+ kind: LoadedBundle['frontmatter']['kind'];
225
+ subtype: string | null;
226
+ status: BundleStatus;
227
+ trust: number;
228
+ validity: DerivedTrustState['validity'];
229
+ summary: string;
230
+ embeddingInput: string;
231
+ }
232
+ interface ScanBundlesOptions {
233
+ knowledgeRoot: string;
234
+ text?: string;
235
+ anchor?: Anchor;
236
+ product?: string;
237
+ k?: number;
238
+ }
239
+ interface ScanBundleByIdOptions {
240
+ knowledgeRoot: string;
241
+ bundleId: string;
242
+ }
243
+ type CanonicalBundleAnchorLookup = {
244
+ kind: 'resolved';
245
+ bundleId: RecordId;
246
+ product: string;
247
+ anchors: Anchor[];
248
+ } | {
249
+ kind: 'unresolved';
250
+ reason: 'not-found';
251
+ } | {
252
+ kind: 'unresolved';
253
+ reason: 'invalid';
254
+ detail: string;
255
+ };
256
+ interface EnumeratedBundleDir {
257
+ product: string;
258
+ dir: string;
259
+ }
260
+ /** Enumerate bundle directories in stable product-then-directory order. */
261
+ declare function enumerateBundleDirs(knowledgeRoot: string): EnumeratedBundleDir[];
262
+ /** The single withdrawn-fact firewall reused by degraded and indexed reader paths. */
263
+ declare function isServable(trust: Pick<DerivedTrustState, 'status' | 'validity'>): boolean;
264
+ declare function scanBundles(opts: ScanBundlesOptions): KnowledgeHit[];
265
+ declare function scanBundleById(opts: ScanBundleByIdOptions): KnowledgeHit | undefined;
266
+ /**
267
+ * Trusted, read-only lookup for post-verdict attribution. Unlike scanBundleById this deliberately
268
+ * ignores serving lifecycle state: a handoff may outlive a candidate's promotion, supersession, or
269
+ * deprecation. Canonical bytes still have to parse and pass the complete integrity oracle.
270
+ */
271
+ declare function readCanonicalBundleAnchors(input: {
272
+ knowledgeRoot: string;
273
+ bundleId: RecordId;
274
+ }): CanonicalBundleAnchorLookup;
275
+
276
+ declare const REBUILD_MARKER_FILE = ".rebuild-requested";
277
+ type RebuildReason = 'absent' | 'corrupt' | 'locked' | 'schema-version';
278
+ interface RebuildRequest {
279
+ reason: RebuildReason;
280
+ detail: string;
281
+ requestedAt: string;
282
+ }
283
+ interface RequestRebuildOptions {
284
+ knowledgeRoot: string;
285
+ reason: RebuildReason;
286
+ detail: string;
287
+ }
288
+ type ReadRebuildRequestOutcome = {
289
+ present: false;
290
+ } | {
291
+ present: true;
292
+ request: RebuildRequest | undefined;
293
+ };
294
+ /**
295
+ * Write the first rebuild signal atomically; later signals never overwrite its diagnostic cause.
296
+ */
297
+ declare function requestRebuild(opts: RequestRebuildOptions): void;
298
+ /** Read a marker through a strict disk-boundary guard; malformed bytes remain a bare signal. */
299
+ declare function readRebuildRequest(knowledgeRoot: string): ReadRebuildRequestOutcome;
300
+ /** Consume the durable rebuild signal. Clearing an absent marker is intentionally a no-op. */
301
+ declare function clearRebuildRequest(knowledgeRoot: string): void;
302
+
303
+ interface KnowledgeSearchOptions {
304
+ product?: string;
305
+ k?: number;
306
+ }
307
+ interface DenseSearchOptions extends KnowledgeSearchOptions {
308
+ k: number;
309
+ }
310
+ type DenseHit = KnowledgeHit & {
311
+ distance: number;
312
+ };
313
+ interface KnowledgeReader {
314
+ /** Current serving face; permanently changes to scan after an index operation failure. */
315
+ readonly source: 'index' | 'scan';
316
+ /** Current vector capability; changes to none when the serving face degrades to scan. */
317
+ readonly vec: VecCapability | 'none';
318
+ getById(bundleId: string): KnowledgeHit | undefined;
319
+ searchLexical(text: string, opts?: KnowledgeSearchOptions): KnowledgeHit[];
320
+ lookupAnchor(anchor: Anchor, opts?: KnowledgeSearchOptions): KnowledgeHit[];
321
+ searchDense(embedding: Float32Array, opts: DenseSearchOptions): DenseHit[];
322
+ recheck(hits: readonly KnowledgeHit[]): KnowledgeHit[];
323
+ close(): void;
324
+ }
325
+ interface OpenKnowledgeReaderOptions {
326
+ vecLoadablePath?: string;
327
+ }
328
+ type IndexFace = {
329
+ source: 'index';
330
+ } | {
331
+ source: 'scan';
332
+ reason: RebuildReason;
333
+ detail: string;
334
+ filePresent: boolean;
335
+ };
336
+ interface ClassifyIndexFaceOptions extends OpenKnowledgeReaderOptions {
337
+ /** `IndexReaderOpenOptions.inspectCheckpointedImmutably`: the probe only, never the facade. */
338
+ inspectCheckpointedImmutably?: boolean;
339
+ }
340
+ declare function classifyIndexFace(knowledgeRoot: string, opts?: ClassifyIndexFaceOptions): IndexFace;
341
+ declare function openKnowledgeReader$1(knowledgeRoot: string, opts?: OpenKnowledgeReaderOptions): KnowledgeReader;
342
+
343
+ interface OpenServingKnowledgeReaderConfig {
344
+ knowledgeRoot: string;
345
+ product?: string;
346
+ scopeDefaults?: {
347
+ asOfBuild?: number;
348
+ /** Known containing scopes for member requests (for example, the owning suite). */
349
+ parentScopes?: readonly ScopeKey[];
350
+ };
351
+ budgets?: {
352
+ recordCap?: number;
353
+ };
354
+ }
355
+ interface IndexRow {
356
+ bundle_id: string;
357
+ product: string;
358
+ scope_tier: string;
359
+ scope_key: string;
360
+ }
361
+ interface HydratedEntry {
362
+ dir: string;
363
+ bundle: LoadedBundle;
364
+ entry: IndexEntry;
365
+ }
366
+ /** @deprecated The safe serving reader reports misses as `undefined` and never throws this. */
367
+ declare class KnowledgeRecordNotFoundError extends Error {
368
+ readonly recordId: RecordId;
369
+ constructor(recordId: RecordId);
370
+ }
371
+ /** Shared serving internal: scope-laddered index rows (also feeds the authoring reader). */
372
+ declare function readIndexRows(config: OpenServingKnowledgeReaderConfig, scope?: ScopeKey): IndexRow[];
373
+ /** Shared serving internal: integrity-checked bundle hydration (also feeds the authoring reader). */
374
+ declare function hydrateRows(config: OpenServingKnowledgeReaderConfig, rows: readonly IndexRow[], audit: boolean): HydratedEntry[];
375
+ declare function openKnowledgeReader(config: OpenServingKnowledgeReaderConfig): KnowledgeHintReader;
376
+ declare function openKnowledgeReader(knowledgeRoot: string, opts?: OpenKnowledgeReaderOptions): KnowledgeReader;
377
+
378
+ /**
379
+ * The bundle facts the matcher folds. `LoadedBundle` satisfies this structurally, so the reader
380
+ * passes hydrated entries straight through; tests construct the narrow shape directly.
381
+ */
382
+ interface ProcedureMatchCandidate {
383
+ entry: IndexEntry;
384
+ bundle: {
385
+ summary: string;
386
+ body: string;
387
+ events: readonly BundleOutcomeEvent[];
388
+ provenance: BundleProvenance;
389
+ };
390
+ }
391
+
392
+ declare const AUTHORING_EXEMPLAR_CAP = 4;
393
+ declare const AUTHORING_PROCEDURE_CAP = 5;
394
+ declare const AUTHORING_EXCERPT_CHAR_BUDGET = 240;
395
+ /** Hydrated store entry: `LoadedBundle`-backed entries satisfy this structurally. */
396
+ type AuthoringEntryCandidate = ProcedureMatchCandidate;
397
+ interface AuthoringExemplarRow {
398
+ filePath: string;
399
+ testName: string;
400
+ passes: number;
401
+ failures: number;
402
+ heals: number;
403
+ flakeCount: number;
404
+ /** Resolved by the hydrating reader from the committed quarantine ledger. */
405
+ quarantined: boolean;
406
+ /** Last-N window entries — ordinals only, wall-clock never. */
407
+ lastOutcomes: readonly {
408
+ buildOrdinal: number;
409
+ passed: boolean;
410
+ }[];
411
+ anchorKeys: readonly string[];
412
+ }
413
+ /** A test reference in the caller-supplied discovery universe (refs only, never content). */
414
+ interface AuthoringTestRef {
415
+ filePath: string;
416
+ testName: string;
417
+ }
418
+ interface AssembleAuthoringBriefInput {
419
+ /** Already-hydrated entries; the reader's SQL scope ladder has applied the scope walls. */
420
+ entries: readonly AuthoringEntryCandidate[];
421
+ /** Per-test outcome counters + exercised-anchor sets from the run-outcome projection. */
422
+ projectionRows: readonly AuthoringExemplarRow[];
423
+ knownTests?: readonly AuthoringTestRef[];
424
+ intent: string;
425
+ scope: ScopeKey;
426
+ /** `page:`/`flow:` anchors derived from scope + intent by the caller — never a ScreenState. */
427
+ targetAnchors: readonly Anchor[];
428
+ budget: number;
429
+ /** Optional additive dense-leg scores keyed by record id, present only when an embedder is up. */
430
+ denseScoreByRecordId?: ReadonlyMap<string, number>;
431
+ }
432
+ interface AssembledAuthoringBrief {
433
+ readonly brief: AuthoringBrief;
434
+ readonly trace: ServedRetrievalTraceV1;
435
+ }
436
+ /**
437
+ * Pure screenless assembly over already-loaded snapshot inputs. Retrieval SQL, hydration,
438
+ * budgets-as-plain-numbers, and the projection read all live at the composition boundary
439
+ * (`createAuthoringReader`); nothing here touches a connection, the clock, or the filesystem.
440
+ *
441
+ * The trace's `rank` is the candidate's 1-based position in the ONE admission walk below —
442
+ * caution, then procedure, then exemplar, then fact — which is the actual total order this
443
+ * assembly serves in. Everything the ledger admits becomes a served line; everything it sheds
444
+ * becomes a cut candidate, bounded by the pinned top-K.
445
+ */
446
+ declare function assembleAuthoringBrief(input: AssembleAuthoringBriefInput): AssembledAuthoringBrief;
447
+
448
+ declare const AUTHORING_BRIEF_DEFAULT_BUDGET = 2000;
449
+ /** PROVISIONAL dense candidate cap pending authoring-channel retrieval telemetry. */
450
+ declare const AUTHORING_DENSE_K = 32;
451
+ interface AuthoringReaderDependencies {
452
+ /** Consumer-owned test inventory crossing this boundary as identity refs only. */
453
+ discoverKnownTests?: () => readonly AuthoringTestRef[];
454
+ /** Test/integration seam; production omission uses denseLeg's automatic acquisition ladder. */
455
+ embedder?: EmbedderPort;
456
+ now?: () => string;
457
+ }
458
+ /** Open the screenless authoring channel over the same store config as the serving reader. */
459
+ declare function createAuthoringReader(config: OpenServingKnowledgeReaderConfig, deps?: AuthoringReaderDependencies): AuthoringReadPort;
460
+
461
+ interface InspectRecordsOptions {
462
+ knowledgeRoot: string;
463
+ filter: InspectFilter;
464
+ }
465
+ type InspectionTrustState = Pick<DerivedTrustState, 'status' | 'counters' | 'validity'>;
466
+ /**
467
+ * Project ONE loaded bundle and its already-derived trust into the maintenance view.
468
+ *
469
+ * The fold below and `showRecord` both render through this, so a record's row and detail agree.
470
+ * `bundle.events` is taken as given: an as-of caller narrows the visible events first.
471
+ */
472
+ declare function toInspectRecordView(entry: EnumeratedBundleDir, bundle: LoadedBundle, trust: InspectionTrustState): InspectRecordView;
473
+ /**
474
+ * Fold canonical committed bundles into maintenance views. Explicit non-live status filters and
475
+ * as-of queries enable audit visibility; an unqualified query retains the serving firewall.
476
+ */
477
+ declare function inspectRecords(options: InspectRecordsOptions): InspectRecordView[];
478
+
479
+ interface DiffSinceOptions {
480
+ knowledgeRoot: string;
481
+ sinceOrdinal: number;
482
+ }
483
+ /** Pure build-ordinal fold over committed bundle outcomes and content-free purge receipts. */
484
+ declare function diffSince(options: DiffSinceOptions): RecordChange[];
485
+
486
+ interface ShowRecordOptions {
487
+ knowledgeRoot: string;
488
+ recordId: string;
489
+ }
490
+ declare function showRecord(options: ShowRecordOptions): KnowledgeRecordShowResult;
491
+
492
+ type KnowledgeMaintenanceScanIssue = 'directory-read' | 'non-directory-entry' | 'bundle-load' | 'bundle-integrity' | 'receipt-read' | 'receipt-invalid';
493
+ /** Fail-closed maintenance read error: callers must never render a partial clean-looking view. */
494
+ declare class KnowledgeMaintenanceScanError extends Error {
495
+ readonly name = "KnowledgeMaintenanceScanError";
496
+ readonly issue: KnowledgeMaintenanceScanIssue;
497
+ readonly path: string;
498
+ constructor(issue: KnowledgeMaintenanceScanIssue, path: string, detail: string);
499
+ }
500
+
501
+ declare const MARK_EVIDENCE_TOKEN_PREFIX = "mark:";
502
+ interface PlanMarkEvidenceInput {
503
+ knowledgeRoot: string;
504
+ /** markId is optional: a preview plans ephemeral effects; a resumed writer supplies it to see durable ones. */
505
+ mark: Pick<MarkReceipt, 'runId' | 'kind'> & {
506
+ markId?: string;
507
+ };
508
+ servedRecordIds: readonly string[];
509
+ /** Historical observation hashes require the original member/step coordinates. */
510
+ handoff?: CompletedRunHandoff;
511
+ /** Host-derived chainJobIdsForRun(runId, idSource).curateMemory; never guessed here. */
512
+ curationJobIds?: readonly string[];
513
+ }
514
+ type MarkEvidenceEffect = {
515
+ direction: 'confirm';
516
+ alreadyAppended: boolean;
517
+ } | {
518
+ direction: 'overturn';
519
+ overturnsEvidenceToken: EvidenceToken;
520
+ overturnsCurationJobId: string;
521
+ alreadyAppended: boolean;
522
+ };
523
+ type MarkEvidenceTarget = {
524
+ recordId: string;
525
+ kind: 'unreadable';
526
+ } | {
527
+ recordId: string;
528
+ kind: 'effects';
529
+ productKey: string;
530
+ served: boolean;
531
+ buildOrdinal: number;
532
+ effects: MarkEvidenceEffect[];
533
+ };
534
+ interface MarkEvidencePlan {
535
+ targets: MarkEvidenceTarget[];
536
+ /** Without the handoff, opaque historical canary hashes cannot all be correlated. */
537
+ correlationIncomplete?: true;
538
+ }
539
+ type AppendMarkEvidenceOutcome = {
540
+ confirmed: number;
541
+ overturned: number;
542
+ skipped: {
543
+ recordId: string;
544
+ reason: 'bundle-unreadable' | 'already-appended';
545
+ }[];
546
+ /** Without the handoff, opaque historical canary hashes cannot all be correlated. */
547
+ correlationIncomplete?: true;
548
+ };
549
+ declare function markEvidenceEvent(effect: MarkEvidenceEffect, markId: string, buildOrdinal: number): BundleOutcomeEvent;
550
+ declare function planMarkEvidence(input: PlanMarkEvidenceInput): MarkEvidencePlan;
551
+ /** The outcome an append executing this plan reports, with duplicates counted only on resume. */
552
+ declare function projectMarkEvidenceOutcome(plan: MarkEvidencePlan, options: {
553
+ includeAlreadyAppended: boolean;
554
+ }): AppendMarkEvidenceOutcome;
555
+
556
+ export { type OpenServingKnowledgeReaderConfig as $, type AppendMarkEvidenceOutcome as A, type IndexHealth as B, CHECKPOINT_EVERY_N_BUNDLES as C, type DenseHit as D, type EmbedderPort as E, type IndexWriterHandle as F, GATES_REL_PATH as G, type InspectRecordsOptions as H, type IndexReaderConnection as I, type IntegrityReport as J, type KnowledgeReader as K, type LoadedBundle as L, type KnowledgeHit as M, KnowledgeMaintenanceScanError as N, type KnowledgeMaintenanceScanIssue as O, KnowledgeRecordNotFoundError as P, type QuarantineAppendOutcome as Q, type RefusedQuarantineLine as R, type KnowledgeSearchOptions as S, type LoadBundleOutcome as T, MARK_EVIDENCE_TOKEN_PREFIX as U, type VecCapability as V, type MarkEvidenceEffect as W, type MarkEvidencePlan as X, type MarkEvidenceTarget as Y, type Measurements as Z, type OpenKnowledgeReaderOptions as _, type IndexFace as a, readIndexRows as a$, type PlanMarkEvidenceInput as a0, QUARANTINE_AUTO_EXIT_PASSES as a1, QUARANTINE_CLASS_DISPOSITIONS as a2, QUARANTINE_DEFAULT_EXPIRY_DAYS as a3, QUARANTINE_ESCALATE_THRESHOLD as a4, QUARANTINE_FLAG_FLOOR as a5, QUARANTINE_LEDGER_FILENAME as a6, type QuarantineDetectionFailure as a7, type QuarantineDetectionResult as a8, type QuarantineDetectionTestWindow as a9, loadBundle as aA, markEvidenceEvent as aB, openIndexReaderConnection as aC, openIndexWriter as aD, openKnowledgeReader as aE, planMarkEvidence as aF, probeIndexHealth as aG, projectMarkEvidenceOutcome as aH, quarantineLedgerPath as aI, readCanonicalBundleAnchors as aJ, readGateReceipts as aK, readMeasurements as aL, readQuarantineLedger as aM, requestRebuild as aN, resolveActiveProfile as aO, resolveVecCapability as aP, scanBundleById as aQ, scanBundles as aR, showRecord as aS, toInspectRecordView as aT, vecTableName as aU, verifyBundleIntegrity as aV, type HydratedEntry as aW, type IndexRow as aX, QUARANTINE_FLOOR_ELIGIBILITY as aY, type QuarantineFloorEligibility as aZ, hydrateRows as a_, type QuarantineDisposition as aa, type QuarantineLedgerRead as ab, type QuarantineOrdinalOutcome as ac, READER_BUSY_TIMEOUT_MS as ad, REBUILD_MARKER_FILE as ae, REQUIRED_INDEX_TABLES as af, type ReadRebuildRequestOutcome as ag, type RebuildReason as ah, type RequestRebuildOptions as ai, type ScanBundleByIdOptions as aj, type ScanBundlesOptions as ak, type ShowRecordOptions as al, WRITER_BUSY_TIMEOUT_MS as am, assembleAuthoringBrief as an, classifyIndexFace as ao, clearRebuildRequest as ap, createAuthoringReader as aq, deriveBundleTrust as ar, diffSince as as, embeddingProfileKey as at, enumerateBundleDirs as au, evaluateQuarantineDetection as av, foldQuarantineLedgerState as aw, indexDbPath as ax, inspectRecords as ay, isServable as az, type QuarantineDetectionSighting as b, readIndexMaintenanceState as c, type RebuildRequest as d, AUTHORING_BRIEF_DEFAULT_BUDGET as e, AUTHORING_DENSE_K as f, AUTHORING_EXCERPT_CHAR_BUDGET as g, AUTHORING_EXEMPLAR_CAP as h, AUTHORING_PROCEDURE_CAP as i, AUTO_QUARANTINE_CLASSES as j, type AssembleAuthoringBriefInput as k, type AssembledAuthoringBrief as l, type AuthoringEntryCandidate as m, type AuthoringExemplarRow as n, openKnowledgeReader$1 as o, type AuthoringReaderDependencies as p, type AuthoringTestRef as q, readRebuildRequest as r, type CanonicalBundleAnchorLookup as s, type DenseSearchOptions as t, type DiffSinceOptions as u, type EnumeratedBundleDir as v, type EvaluateQuarantineDetectionInput as w, INDEX_DB_FILE as x, INDEX_RENDERING_SCHEMA_VERSION as y, INDEX_SCHEMA_VERSION as z };