/** * ruv-fann-wsp.ts — optional ruv-FANN weight-space tooling (ADR-528). * * Wraps three exact-pinned optional dependencies: * - `ruv-fann-wsp` fingerprint, inspect, sensitivity * - `ruv-fann-wsp-invariants` finite-domain output-bound checks * - `ruv-fann-wsp-lifecycle` bounded-patch regression gates * * They share the `ruv-fann` core and `ruv-fann-wasm` runtime that agentdb and * @metaharness/darwin already install, so they add no native code and no * install scripts. The `ruv-fann` 0.3.0 facade is deliberately NOT used: it * pulls esbuild (an install script) and a native RVF binding into every * install for capabilities ruflo does not call. * * Every entry point loads the packages lazily. When they are absent the * caller gets `{ available: false, reason }`; nothing else in the CLI * imports this module, so cold start and routing are unchanged. * * Results are hash-bound evidence, not authority: nothing here promotes, * writes or reroutes on its own. * * @module ruv-fann-wsp */ import type { CentroidArtifact } from './centroid-router.js'; export declare const WSP_PACKAGES: readonly ["ruv-fann-wsp", "ruv-fann-wsp-invariants", "ruv-fann-wsp-lifecycle"]; export type WspPackage = (typeof WSP_PACKAGES)[number]; /** Upper bound for any JSON file this module reads (models, suites, patches). */ export declare const MAX_INPUT_BYTES: number; /** INVARIANT_LIMITS.maxCases in ruv-fann-wsp-invariants 0.1.0. */ export declare const MAX_CASES_PER_SUITE = 16; /** Centroids are stored rounded, so a centroid scores slightly below 1 against itself. */ export declare const SELF_SCORE_TOLERANCE = 0.00001; export interface DenseLayer { inputs: number; outputs: number; /** Row-major [outputs, inputs]. */ weights: number[]; bias?: number[] | null; activation: string; steepness: number; } export interface DenseModel { schema: 'ruv-fann.dense-layers/1'; layers: DenseLayer[]; } export interface InvariantCase { name: string; inputs: number[]; rows: number; minimum?: number[]; maximum?: number[]; expected?: number[]; tolerance?: number; } export interface InvariantSuite { schema: 'ruv-fann.invariants/1'; cases: InvariantCase[]; } export interface WspModules { wsp: Record; invariants: Record; lifecycle: Record; } export type WspLoad = { available: true; modules: WspModules; } | { available: false; reason: string; }; export type Importer = (specifier: string) => Promise>; /** Load all three packages once. Never throws. */ export declare function loadWsp(importer?: Importer): Promise; /** * Installed version of each package, or null. `ruv-fann` is not a direct * dependency, so it is looked up where ruv-fann-wsp resolves it: nested * under it (pnpm, npm conflicts) or beside it (flat npm). */ export declare function wspVersions(): Record; /** * The centroid router as a one-layer Linear ruv-FANN model. Output k is the * dot product with centroid k, which is the router's cosine score for a * unit-length query, so the model ranks labels exactly as `classify` does. */ export declare function centroidToDenseModel(artifact: CentroidArtifact): DenseModel; /** * Self-routing invariants: fed its own centroid, each label must score * 1 ± tolerance and every other label at most `1 - minGap`. A failure means * two labels are (near-)duplicates or the artifact is corrupt — the router * could not separate them even on their own means. * * Returned as several suites when there are more labels than one suite allows. */ export declare function centroidSelfRoutingSuites(artifact: CentroidArtifact, opts?: { tolerance?: number; minGap?: number; }): InvariantSuite[]; /** * Read a JSON file the user named. Refuses non-regular files (FIFOs, devices, * directories), symlinks that leave nothing to read, and anything larger * than MAX_INPUT_BYTES, before reading it into memory. */ export declare function readJsonInput(path: string, what: string, maxBytes?: number): unknown; /** Shape check before handing a user model to WSP (which validates fully). */ export declare function assertDenseModel(x: unknown, what?: string): DenseModel; export interface SelfRoutingResult { accepted: boolean; modelHash: string; labels: number; suites: number; checks: number; violations: Array<{ case: string; output: string; constraint: string; actual: number; bound: number; }>; backend: string; ms: number; } /** Run the self-routing invariants against a centroid artifact. */ export declare function checkCentroidSelfRouting(mods: WspModules, artifact: CentroidArtifact, opts?: { tolerance?: number; minGap?: number; }): Promise; /** Test hook. */ export declare function __resetWspForTests(): void; //# sourceMappingURL=ruv-fann-wsp.d.ts.map