/** * Effect type registry — maps effect names to their argument and return types. * * Effect declarations like `effect @llm.complete(String) -> String` register * here. During inference, `perform(@llm.complete, prompt)` checks the arg * type and returns the declared return type (instead of Unknown). * * For Phase C (Step 7), this also informs handler clause typing: * - The handler parameter gets the effect's arg type * - `resume` gets the effect's return type as its parameter type */ import type { Type } from './types'; export interface EffectDeclaration { /** The argument type passed to perform. */ argType: Type; /** The return type — what perform() returns, what resume() accepts. */ retType: Type; } export interface EffectRegistrySnapshot { entries: [string, EffectDeclaration][]; builtinNames: string[]; } /** * Register an effect's type declaration. * * Silently skips names in `builtinEffectNames` so that user-level * `effect @name(T) -> U` declarations cannot overwrite a builtin * effect's signature. HandlerWrapperInfo for wrappers like * `effectHandler.chooseRandom` captures arg/ret types by value at * module-registration time, but the active handled signatures pushed * at perform sites are also derived from the registry — letting users * stomp on those would mis-type perform calls inside handler wrappers. * `initBuiltinEffects` uses `declareBuiltinEffect` below to install the * builtins without going through this guard. */ export declare function declareEffect(name: string, argType: Type, retType: Type): void; /** Look up an effect's declaration. Returns undefined if not declared. */ export declare function getEffectDeclaration(name: string): EffectDeclaration | undefined; /** Get the return type of a declared effect, or Unknown if not declared. */ export declare function getEffectReturnType(name: string): Type; /** Get the argument type of a declared effect, or Unknown if not declared. */ export declare function getEffectArgType(name: string): Type; /** Snapshot the current registry so nested import typechecking can restore it. */ export declare function snapshotEffectRegistry(): EffectRegistrySnapshot; /** Restore a previously captured registry snapshot. */ export declare function restoreEffectRegistry(snapshot: EffectRegistrySnapshot): void; /** Reset user-declared effects (called at the start of each typecheck pass). * Builtin effects are preserved. */ export declare function resetUserEffects(): void; /** Reset the entire registry (for testing). */ export declare function resetEffectRegistry(): void; /** Register built-in Dvala effects with known types. */ export declare function initBuiltinEffects(): void;