/** * SemanticCorpusIndex — the scalable corpus path for the semantic novelty advisory * (scope 2026-05-23_holoembed-semantic-encoder, P3). * * THE PROBLEM IT SOLVES: `assessSemanticNovelty` (SemanticNoveltyEncoder.ts) embeds EVERY * corpus entry on EVERY query — O(N) model calls per assessment. Fine for the 12-entry seed, * hopeless for the 10^3+ real-abstract corpus P3 ingests. This module PRE-EMBEDS the corpus * once into a vector index, so each query embeds ONCE and does an O(N) cosine scan (cheap * arithmetic, no model). That is the difference between a usable hub and a toy (D.060). * * DETERMINISM NOTE (resolved by the P1 finding): the cached vectors are built on one machine * and the model is not byte-reproducible cross-fleet — but the divergence is ~1e-7 (float32 * ULP), which moves a cosine similarity by ~1e-7, utterly negligible against the 0.5 advisory * threshold. So a one-machine cache is valid fleet-wide FOR ADVISORY COSINE QUERIES. Still * ADVISORY only — never receipt-binding (same constraint as the rest of the semantic layer). * * The nearest-neighbour search is PURE (no model), so it is fully testable offline. */ import type { ConjecturePriorArtEntry } from './ConjectureEngine'; import { SEMANTIC_NOVELTY_MODEL, type SemanticNoveltyAssessment, type SemanticNoveltyMatch } from './SemanticNoveltyEncoder'; export declare const SEMANTIC_CORPUS_INDEX_VERSION: 1; export interface EmbeddedCorpusEntry extends ConjecturePriorArtEntry { /** L2-normalized embedding of `statement`, from the advisory model. */ vector: ReadonlyArray; } export interface SemanticCorpusIndex { indexVersion: typeof SEMANTIC_CORPUS_INDEX_VERSION; modelId: typeof SEMANTIC_NOVELTY_MODEL; dim: number; entries: ReadonlyArray; } export interface BuildIndexOptions { /** Called after each entry is embedded — for progress on a large corpus. */ onProgress?: (done: number, total: number) => void; } /** * Embed every corpus entry's `statement` once into a queryable index. Async (runs the model * N times, once per entry). Do this ONCE, then serve many queries via assessSemanticNoveltyIndexed. */ export declare function buildSemanticCorpusIndex(corpus: ReadonlyArray, options?: BuildIndexOptions): Promise; /** * PURE nearest-neighbour by cosine over a pre-embedded index. Deterministic tie-break by * ascending id (matches assessSemanticNovelty). No model required → fully testable offline. */ export declare function nearestByCosine(queryVector: ReadonlyArray, index: SemanticCorpusIndex): SemanticNoveltyMatch | null; /** * ADVISORY semantic novelty assessment against a PRE-EMBEDDED index. Embeds the query once, * scans the cached vectors, flags `near-duplicate` if the nearest is >= threshold. Same return * shape and semantics as assessSemanticNovelty, but scales to a large corpus. NOT receipt-binding. */ export declare function assessSemanticNoveltyIndexed(query: string, index: SemanticCorpusIndex, threshold?: number): Promise; /** Serialize the index to a JSON-safe object (for an on-disk runtime cache). */ export declare function serializeIndex(index: SemanticCorpusIndex): string; /** Parse + validate a serialized index. Throws on shape/version/model mismatch. */ export declare function deserializeIndex(json: string): SemanticCorpusIndex; //# sourceMappingURL=SemanticCorpusIndex.d.ts.map