/** * The sensorium — Soma's immune system. * * Compares observed phenotypic signals against accumulated profiles * for a committed genome. Like the immune system distinguishing "self" * from "not-self," except the definition of "self" is the genome commitment. * * Two independent detection channels work in parallel: * - Behavioral landscape: catches sudden changes (historical, profile-based) * - Phenotype atlas: catches slow drift (memoryless, reference-based) * * Mutations are testable claims: each mutation adds a verification obligation, * not a profile reset. More mutations = more checks the attacker must pass. * * Outputs one of four signals: * - GREEN (confidence > 0.8) — behavior matches committed genome * - AMBER (0.4–0.8 or < minObservations) — partial match or still learning * - RED (< 0.4) — behavior inconsistent with genome * - UNCANNY (0.6–0.8, high variance) — almost matches but subtly wrong. * MORE suspicious than a clean mismatch — the uncanny valley. */ import { type PhenotypicSignals } from "../experiment/signals.js"; import { type BehavioralLandscape, type LandscapeMatchResult } from "./landscape.js"; import { PhenotypeAtlas, type AtlasClassification, type SenseFeatures } from "./atlas.js"; export type VerdictStatus = "GREEN" | "AMBER" | "RED" | "UNCANNY"; export interface Verdict { status: VerdictStatus; confidence: number; observationCount: number; /** Per-feature z-scores from the latest observation. */ featureDeviations: Array<{ feature: string; zScore: number; }>; /** Fraction of features within acceptable range. */ matchRatio: number; /** Variance in match ratios across recent observations — high = UNCANNY territory. */ consistencyScore: number; } /** Enhanced verdict with landscape awareness, drift detection, atlas, and heart verification. */ export interface EnhancedVerdict extends Verdict { /** Rate of profile change — low = healthy, sudden spike = suspicious. */ driftVelocity: number; /** Profile maturity based on observation depth. */ profileMaturity: "embryonic" | "juvenile" | "adult" | "elder"; /** Number of task categories observed. */ landscapeDepth: number; /** Whether a category-specific profile was used (vs flat). */ usedCategoryProfile: boolean; /** Did the heart seed verification pass? (set externally) */ heartSeedVerified: boolean; /** Is the data provenance chain intact? (set externally) */ birthCertificateChain: boolean; /** Atlas classification result — reference profile match. */ atlasClassification: AtlasClassification | null; /** How well mutations explain observed changes (0.0–1.0). */ mutationConsistency: number; } /** Running statistics for a single feature — Welford's online algorithm. */ export interface FeatureStats { count: number; mean: number; m2: number; } /** Accumulated phenotypic profile for a genome. */ export interface PhenotypicProfile { genomeHash: string; features: Record; /** Match ratios from recent observations — used for consistency scoring. */ recentMatchRatios: number[]; } /** Tracks a genome mutation and its expected behavioral impact. */ export interface MutationRecord { /** Genome hash before mutation. */ fromHash: string; /** Genome hash after mutation. */ toHash: string; /** Which genome fields changed. */ changedFields: string[]; /** When the mutation occurred. */ timestamp: number; /** Consistency score: did observed behavior match the declared change? (0.0–1.0). */ consistency: number; /** Number of post-mutation observations used for consistency measurement. */ postMutationObservations: number; } /** Create an empty profile for a genome. */ export declare function createProfile(genomeHash: string): PhenotypicProfile; /** Update a profile with a new observation using Welford's online algorithm. */ export declare function updateProfile(profile: PhenotypicProfile, signals: PhenotypicSignals): void; /** * Compare an observation against a phenotypic profile. * * Like the immune system checking if a cell's surface proteins match * the expected pattern — each feature is a protein, the z-score measures * how far off it is from "self." */ export declare function match(profile: PhenotypicProfile, signals: PhenotypicSignals, minObservations?: number): Verdict; /** * Compare an observation against a behavioral landscape with atlas cross-check * and mutation verification. * * Uses category-specific profiles when available, includes drift detection, * cross-references against the phenotype atlas for slow-drift detection, * and validates any recent mutations as testable claims. */ export declare function matchEnhanced(landscape: BehavioralLandscape, signals: PhenotypicSignals, category: string, recentResults?: LandscapeMatchResult[], minObservations?: number, options?: { heartSeedVerified?: boolean; birthCertificateChain?: boolean; atlas?: PhenotypeAtlas; declaredGenome?: string; senseFeatures?: SenseFeatures; mutationRecords?: MutationRecord[]; }): EnhancedVerdict; /** * Verify a genome mutation as a testable claim. * * A mutation is a claim: "I changed X. Everything else is the same." * The sensorium verifies: * 1. Did the declared changes produce expected behavioral shifts? * 2. Did undeclared dimensions remain stable? * * Returns a consistency score (0.0–1.0). */ export declare function verifyMutation(preMutationProfile: PhenotypicProfile, postMutationObservation: PhenotypicSignals, changedFields: string[]): { consistency: number; details: string; }; //# sourceMappingURL=matcher.d.ts.map