/** * @fileoverview Generic registry — the single base class for every * registry in the workspace. * * Replaces the ten registry classes catalogued in * `docs/plans/ready/architecture-runscope-and-registry/phase-0-audit-and-design.md`. * * Owns: by-id Map, by-name Map, the closed `DuplicatePolicy` branch, * the orthogonal `nameCollisionMode` guard, and the structured-event * emitter. Domain-specific indices (extension, alias, slug, scope) * live in thin subclasses or alongside; the base must stay * tool-agnostic. */ import { type Logger } from './logger.js'; /** * Closed union of duplicate-handling policies. * * - `warn-first-wins` — log warning, keep incumbent (ToolRegistry, * LanguageRegistry, graph rules). * - `throw` — throw `ValidationError` on duplicate id/name * (FitnessRecipeRegistry, SimulationRecipeRegistry). * - `overwrite` — replace incumbent silently (graph lang-adapter * registry). * - `silent-skip` — ignore the second registration (CheckRegistry, * TargetRegistry, scenarios). * - `allow-internal` — first call bypasses the guard; subsequent * duplicates throw unless `{ internal: true }` is passed. Reserved * for "register builtins without flag" patterns; current consumers * use per-call `{ internal: true }` against a strict default. */ export type DuplicatePolicy = 'warn-first-wins' | 'throw' | 'overwrite' | 'silent-skip' | 'allow-internal'; /** Minimum shape any registry item must satisfy. */ export interface Registerable { readonly id: string; readonly name: string; readonly tags?: readonly string[]; } /** Constructor options for `Registry`. */ export interface RegistryOptions { /** Human-readable module label used in structured events / errors. */ readonly module: string; readonly duplicatePolicy: DuplicatePolicy; /** Event prefix — events emit as `.duplicate` etc. */ readonly evtPrefix: string; /** Validation-error code surfaced when policy === 'throw'. */ readonly validationCode?: string; /** * Name-collision policy (orthogonal to `duplicatePolicy`). When set * to `'throw'`, registering an item whose `name` is already used by * a DIFFERENT id throws a `ValidationError`. Default `'allow'` * falls through to `duplicatePolicy`. */ readonly nameCollisionMode?: 'allow' | 'throw'; /** Logger override — defaults to the workspace singleton. */ readonly logger?: Logger; } /** Per-call options. */ export interface RegisterCallOptions { /** * Bypass the duplicate guard for this single call. Use for * built-in seeding. Ignored if no duplicate condition is reached. */ readonly internal?: boolean; /** * Source package id — included in structured events for * third-party warnings. */ readonly sourcePackage?: string; } /** * Generic id+name+tag registry with a closed duplicate-handling * policy and structured-event emission. Use composition (one * `Registry` instance per registry) or inheritance (extend * the class) — both are supported. */ export declare class Registry { private readonly byId; private readonly byName; private readonly module; private readonly duplicatePolicy; private readonly evtPrefix; private readonly validationCode; private readonly nameCollisionMode; private readonly logger; constructor(opts: RegistryOptions); register(item: T, callOpts?: RegisterCallOptions): void; registerAll(items: readonly T[], callOpts?: RegisterCallOptions): void; get(idOrName: string): T | undefined; getById(id: string): T | undefined; getByName(name: string): T | undefined; has(idOrName: string): boolean; getAll(): readonly T[]; getByTag(tag: string): readonly T[]; remove(id: string): boolean; clear(): void; get size(): number; } //# sourceMappingURL=registry.d.ts.map