import { TotemError } from '@mmnto/totem'; import { type CompiledHookRule } from './schema.js'; /** * Compiled-hooks manifest loader (ADR-104 § Decision 3 staleness check + a * forward-compat warn-and-skip path for an evolving manifest schema). * * The loader is a pure function over `(manifestPath, installedPackVersions)`. * It does NOT read `package.json` itself — callers (typically a * bootstrap helper) resolve installed pack versions once and pass them in. * Keeps the loader testable in isolation; mirrors the substrate-wiring * pattern from `bootstrapEngine` (1.25.0 wiring lesson). * * Three failure modes are surfaced via the `warnings` array, not by * throwing: * * 1. Manifest file missing — empty result, no warnings (a fresh repo without * installed pack hooks is a valid state). * 2. Manifest schemaVersion is not the runner's expected version — warn and * skip the entire manifest (no hooks loaded). Composes with ADR-104 * § Decision 4's forward-compat ethos. * 3. Pack version drift — for each pack whose installed version differs from * the compiled-against version, emit a `[totem:hook-stale]` warning per * the format in ADR-104 § Decision 3. Hooks still load (Tenet 4 carve-out: * hooks are best-effort; staleness is signal, not a fail-closed condition). * * Structural errors (corrupt JSON, schema-validation failure on a manifest * claiming the supported schemaVersion) populate `errors` and yield an empty * hooks array — distinct from a missing manifest. */ export interface LoadCompiledHooksOptions { manifestPath: string; installedPackVersions: Record; } export interface LoadCompiledHooksResult { hooks: CompiledHookRule[]; warnings: string[]; /** * Errors carry the original cause via `Error.cause` so debug consumers * can traverse the chain (per the codebase styleguide rule against * concatenating `err.message` into new strings — destroys the stack). * Callers that just need to log can use `err.message`; debug tooling * walks `err.cause` recursively. */ errors: TotemError[]; } export declare function loadCompiledHooks(options: LoadCompiledHooksOptions): LoadCompiledHooksResult; //# sourceMappingURL=loader.d.ts.map