/** * Near-duplicate body signatures — MinHash + LSH primitives. * * Single source of truth for signature constants and the digest tail used by * both tree-sitter adapters and the TypeScript inventory path. Signatures are * derived from the same canonical body string that feeds `bodyHash`. */ import { type BodyDigest } from './body-digest.js'; /** Number of MinHash values per body signature. */ export declare const NEAR_DUP_SIGNATURE_K = 128; /** Default LSH band count — co-tuned with {@link NEAR_DUP_LSH_ROWS}. */ export declare const NEAR_DUP_LSH_BANDS = 8; /** Rows per band; `bands × rows === k`. Knee ≈ 0.878 at threshold 0.85. */ export declare const NEAR_DUP_LSH_ROWS = 16; /** * Signature ALGORITHM version. Bump on ANY change to shingling, hashing, or the * permutation scheme that alters signature VALUES. Feeds the `sig=` cache-key * segment so catalogs built with an older algorithm invalidate — mixing old- and * new-algorithm signatures across an incremental build (some occurrences cached, * some re-walked) would corrupt every cross-occurrence Jaccard estimate. * * v1 = k independent SHA-256 hashes per (shingle, seed). v2 = one SHA-256 base * hash per shingle + k cheap 32-bit mixers (~k× fewer hashes, identical MinHash * semantics). */ export declare const NEAR_DUP_SIGNATURE_VERSION = 2; /** Digest including hash, size, and optional near-duplicate MinHash signature. */ export type BodyDigestWithSignature = BodyDigest; /** * Character k-grams from canonical body text. Bodies shorter than `gramSize` * yield a single shingle of the whole string when non-empty. */ export declare function shingle(canonical: string, gramSize?: number): ReadonlySet; /** * Deterministic MinHash signature over char shingles. Stable across runs and * machines (SHA-256 base hash + fixed permutation seeds). * * Each shingle is hashed ONCE with SHA-256 (the only expensive step); the k * MinHash values are then derived by mixing that base hash with k fixed 32-bit * seeds. This is ~k× fewer SHA-256 computations than hashing every * (shingle, seed) pair while preserving MinHash semantics (each of the k mixers * is an independent hash of the shingle universe, so the per-position min * estimates Jaccard exactly as before). Algorithm {@link NEAR_DUP_SIGNATURE_VERSION}. */ export declare function bodySignature(canonical: string, k?: number): readonly number[]; /** MinHash Jaccard estimate: equal-position fraction. */ export declare function estimateJaccard(a: readonly number[], b: readonly number[]): number; /** LSH band hashes for candidate-pair generation. */ export declare function lshBandHashes(signature: readonly number[], bands: number, rows: number): readonly string[]; /** * Hash + size + signature for an already-normalized canonical body string. * Skips `signature` when the canonical text yields no shingles. */ export declare function digestCanonicalBody(canonical: string): BodyDigestWithSignature; //# sourceMappingURL=near-duplicate-signature.d.ts.map