import { type SkillBundleEntry } from "./skill-bundle.js"; import type { ResolvedSkillProfile, ResolvedSkillSelection } from "../types/skill-selection.js"; export declare class SkillSelectionError extends Error { readonly code: string; constructor(code: string, message: string); } export interface SelectionCacheOptions { cacheDir?: string; now?: () => number; } export interface CachedSelectionProfile { schemaVersion: 1; verifiedAt: string; profile: ResolvedSkillProfile; } export interface SkillSessionParentBinding { sessionId: string; generation: number; receiptSha256: string; } export interface SkillSessionReceipt extends CachedSelectionProfile { sessionId: string; loaded: string[]; /** Monotonic across sanctioned receipt writes. Legacy receipts without it are generation zero. */ generation?: number; /** Private local metadata binding a child receipt to the exact parent snapshot it inherited. */ parent?: SkillSessionParentBinding; } export interface SkillSessionSnapshot extends SkillSessionParentBinding { path: string; bytes: Uint8Array; receipt: SkillSessionReceipt; sha256: string; } export interface SkillSessionWritePrecondition { current: SkillSessionParentBinding | null; parent?: SkillSessionParentBinding; } export declare const MAX_CACHED_PROFILE_AGE_MS: number; export declare const SELECTION_LOCK_FILE = "selection.lock.json"; export declare function selectionCacheRoot(options?: SelectionCacheOptions): string; export declare function selectionKey(selection: ResolvedSkillSelection): string; export declare function validateSelection(selection: ResolvedSkillSelection): void; export declare function validateResolvedProfile(profile: ResolvedSkillProfile, authority?: string): void; export declare function selectionBundlePath(selection: ResolvedSkillSelection, options?: SelectionCacheOptions): string; export declare function writeSelectionJson(path: string, value: unknown): void; export declare function readSelectionJson(path: string): T | null; export declare function readCachedSelection(selection: ResolvedSkillSelection, options?: SelectionCacheOptions): Promise; export declare function cacheSelectionBundle(selection: ResolvedSkillSelection, response: Response | null, options?: SelectionCacheOptions): Promise; export declare function activateSelectionProfile(profile: ResolvedSkillProfile, options?: SelectionCacheOptions): CachedSelectionProfile; export declare function readSelectionProfile(profileId: string, options?: SelectionCacheOptions): CachedSelectionProfile | null; export declare function validateSelectionReceipt(receipt: CachedSelectionProfile): void; export declare function assertFreshCachedProfile(receipt: CachedSelectionProfile, options?: SelectionCacheOptions & { maxAgeMs?: number; }): void; export declare function projectSelectionLockPath(projectDir: string): string; export declare function readProjectSelection(projectDir: string): CachedSelectionProfile | null; export declare function sessionReceiptPath(sessionId: string, options?: SelectionCacheOptions): string; export declare function readSkillSession(sessionId: string, options?: SelectionCacheOptions): SkillSessionReceipt | null; export declare function readSkillSessionSnapshotIfExists(sessionId: string, options?: SelectionCacheOptions): SkillSessionSnapshot | null; export declare function readSkillSessionSnapshot(sessionId: string, options?: SelectionCacheOptions): SkillSessionSnapshot; export declare function skillSessionSnapshotBinding(snapshot: SkillSessionSnapshot): SkillSessionParentBinding; export declare function inspectSessionWriteLock(sessionId: string, options?: SelectionCacheOptions): { sessionId: string; schemaVersion: 2 | 1; pid: number; lockSha256: string; lockMtime: string; receiptSha256: string | null; receiptGeneration: number | null; reviewDigest: string; hostBound: boolean; }; export declare function recoverSessionWriteLock(sessionId: string, reviewDigest: string, options?: SelectionCacheOptions): string; export declare function nextSkillSessionGeneration(generation: number): number; /** Receipt creation and updates are exact-snapshot CAS operations. Child creation also fences its parent. */ export declare function writeSkillSession(receipt: SkillSessionReceipt, expected: SkillSessionWritePrecondition, options?: SelectionCacheOptions): void; /** Preserve both sides before the single atomic replacement; failures retain recovery evidence. */ export declare function replaceSkillSession(expected: SkillSessionParentBinding, replacement: SkillSessionReceipt, plan: unknown, options?: SelectionCacheOptions, beforeCommit?: () => void): { archivePath: string; receiptPath: string; beforeSha256: string; afterSha256: string; };