/** * vigiles — Evolution engine for self-evolving specifications. * * @internal Research-stage / experimental — NOT exported from any public entry * point and NOT part of the frozen public surface (pre-1.0). Kept for the * self-evolving-specs line; `proofs.ts` (used by ncd / covering-array) stays. * * AI agents propose mutations. The engine applies them, runs the proof suite, * and only accepts mutations that pass all proofs AND improve fitness. * * Pattern: "LLM proposes, deterministic algorithm disposes." */ import type { Rule } from "./spec.js"; import { MerkleHistory, type ProofReceipt, type FitnessResult, type ReadonlyMerkleHistory } from "./proofs.js"; export interface AddRuleMutation { type: "add"; ruleId: string; rule: Rule; } export interface RemoveRuleMutation { type: "remove"; ruleId: string; } export interface StrengthenMutation { type: "strengthen"; ruleId: string; /** For guidance→enforce, provide the linter rule to enforce. */ linterRule?: string; } export interface WeakenMutation { type: "weaken"; ruleId: string; justification: string; } export interface MergeRulesMutation { type: "merge"; sourceIds: [string, string]; mergedId: string; mergedRule: Rule; } export interface RewordMutation { type: "reword"; ruleId: string; newText: string; } export type SpecMutation = AddRuleMutation | RemoveRuleMutation | StrengthenMutation | WeakenMutation | MergeRulesMutation | RewordMutation; export interface MutationError { mutation: SpecMutation; reason: string; } /** * Apply a mutation to a spec's rules, producing a new rule map. * Returns null + error if the mutation is invalid. */ export declare function applyMutation(rules: Record, mutation: SpecMutation): { rules: Record; error?: MutationError; }; export interface ProofSuiteResult { passed: boolean; receipts: ProofReceipt[]; fitness: FitnessResult; } /** * Run all proofs on a candidate spec mutation. * * Proofs: * 1. Monotonicity — rules don't weaken (unless explicitly allowed) * 2. NCD deduplication — no near-duplicate rules introduced * 3. Bloom filter overlap — fast cross-check for token similarity */ export declare function runProofSuite(before: Record, after: Record, options?: { allowWeaken?: Set; ncdThreshold?: number; maxTokens?: number; }): ProofSuiteResult; export interface EvolutionResult { accepted: boolean; mutation: SpecMutation; proofs: ProofSuiteResult; beforeFitness: FitnessResult; afterFitness: FitnessResult; historyHash?: string; error?: string; } /** * The evolution engine: the core of the self-evolving spec system. * * Maintains a spec, a proof suite, and a Merkle history. * Accepts mutations that pass all proofs and improve (or maintain) fitness. */ export declare class EvolutionEngine { private rules; private readonly history; private readonly options; constructor(initialRules: Record, options?: { allowWeaken?: Set; ncdThreshold?: number; maxTokens?: number; acceptNeutral?: boolean; history?: MerkleHistory; }); /** * Get current rules as a deep defensive copy. Callers cannot mutate * engine state through the returned map because every rule is cloned — * otherwise a JS caller or a TS cast could silently alter accepted * state without running proofs or appending to history. */ getRules(): Record; /** * Get a snapshot of the Merkle history. * * Returns a freshly deserialized copy so even a JS caller that casts * to MerkleHistory and calls `.append()` cannot inject nodes into the * engine's real chain. The snapshot is read-only at the TS level * (ReadonlyMerkleHistory) and isolated at the runtime level (separate * instance via toJSON/fromJSON). */ getHistory(): ReadonlyMerkleHistory; /** Get current fitness. */ getFitness(): FitnessResult; /** * Propose a mutation. The engine applies it, runs proofs, and accepts or rejects. * * Returns a detailed result including proof receipts and fitness comparison. */ propose(mutation: SpecMutation): EvolutionResult; /** * Propose multiple mutations in sequence. * Stops at the first rejection unless `continueOnReject` is true. */ proposeAll(mutations: SpecMutation[], options?: { continueOnReject?: boolean; }): EvolutionResult[]; } //# sourceMappingURL=evolve.d.ts.map