/** * experience/store.ts — the persistence port for experience, and its snapshot format. * * The engine does no I/O (checkpoints are `ArrayBuffer`s the host stores); experience * follows the same rule. `ExperienceStore` is the port every host implements over its own * storage — a JSON file on disk (memory-mcp), IndexedDB, a KV. `InMemoryExperienceStore` * is the reference implementation, and `ExperienceSnapshot` is the one serialized shape, * so a store on one runtime can be read by another. */ import type { Adaptation, Episode, EpisodeSummary, Run, RunStepLog, Skill } from './types.js'; export declare const EXPERIENCE_SCHEMA = "evermind.experience/1"; /** Runs kept, newest first — the audit trail is recent history, not an archive. */ export declare const MAX_RUNS = 500; /** Adaptations kept, newest first — enough history to chart how learning went. */ export declare const MAX_ADAPTATIONS = 200; export interface ExperienceSnapshot { schema: typeof EXPERIENCE_SCHEMA; episodes: Episode[]; skills: Skill[]; runs: Run[]; /** * Which episodes and skills the local Evermind has been adapted on, and by which * adaptation (the N of the model's `+expN` version) — so training reads each * procedure once, and a model rolled back to an earlier N re-learns what the * discarded versions had learned. */ learned: Record; /** Every adaptation's measurements, newest first (capped at {@link MAX_ADAPTATIONS}). */ adaptations: Adaptation[]; } export interface ExperienceStore { putEpisode(episode: Episode): Promise; getEpisode(id: string): Promise; listEpisodes(): Promise; /** Forget a demonstration. Skills compiled from it keep working — they carry their own steps. */ deleteEpisode(id: string): Promise; putSkill(skill: Skill): Promise; getSkill(id: string): Promise; listSkills(): Promise; deleteSkill(id: string): Promise; putRun(run: Run): Promise; /** Append one audit line to a run; false when the run is unknown. */ appendRunStep(runId: string, step: RunStepLog): Promise; getRun(id: string): Promise; listRuns(limit: number): Promise; /** * Record one adaptation: its items join the learned ledger under its index (the * model's `+expN`) and its measurements join the history — one write, so the ledger * and the chart can never disagree. */ recordAdaptation(adaptation: Adaptation): Promise; snapshot(): Promise; /** Delete every episode, skill and run. */ clear(): Promise; } export declare function emptySnapshot(): ExperienceSnapshot; /** Parse a snapshot, tolerating a missing or foreign file as empty. */ export declare function parseSnapshot(raw: unknown): ExperienceSnapshot; /** * The reference store: the snapshot held in memory. Hosts that persist wrap it and * write `snapshot()` after each change (see `onChange`). */ export declare class InMemoryExperienceStore implements ExperienceStore { private readonly onChange?; private data; constructor(initial?: ExperienceSnapshot, onChange?: ((s: ExperienceSnapshot) => void | Promise) | undefined); /** Replace the contents (a host re-reading its file after another process wrote it). */ load(snapshot: ExperienceSnapshot): void; private changed; private static upsert; private static remove; putEpisode(episode: Episode): Promise; getEpisode(id: string): Promise; listEpisodes(): Promise; deleteEpisode(id: string): Promise; putSkill(skill: Skill): Promise; getSkill(id: string): Promise; listSkills(): Promise; deleteSkill(id: string): Promise; putRun(run: Run): Promise; appendRunStep(runId: string, step: RunStepLog): Promise; getRun(id: string): Promise; listRuns(limit: number): Promise; recordAdaptation(adaptation: Adaptation): Promise; snapshot(): Promise; clear(): Promise; } //# sourceMappingURL=store.d.ts.map