/**
 * Single owner of multi-file compilation. Parses every reachable agency
 * file from an entry, builds a shared SymbolTable, runs the per-variable
 * dep graphs (static + global) plus topological sort, and produces an
 * `InitPlan` per module that codegen consumes to drive its centralized
 * init.
 *
 * Both `lib/cli/commands.ts:compile()` (CLI: writes files to disk) and
 * `lib/compiler/compile.ts:compileSource()` (in-memory: returns a string)
 * call this helper, then walk the result's modules and codegen each. The
 * recursive `compile()` cascade that used to re-enter per file is gone —
 * the closure is built once, in one place.
 *
 * Errors surface as exceptions of type `CompileClosureError`. The CLI
 * path turns them into stderr + `process.exit(1)`; the in-memory path
 * returns them as `CompileFailure`.
 */
import type { AgencyProgram } from "../types.js";
import { AgencyConfig } from "../config.js";
import { SymbolTable } from "../symbolTable.js";
import { type ImportAliasResolver, type InitDepGraph } from "./initDepGraph.js";
export declare class CompileClosureError extends Error {
    constructor(message: string);
}
/**
 * The per-module init plan codegen consumes. For Phase A (static) and
 * Phase B (global), captures:
 *   - `localOrder`: the topsort-ordered subset of local var names in
 *     this module. Codegen emits assignments in this order rather than
 *     source order.
 *   - `awaitModules`: other modules whose init must complete before
 *     this module's local init body runs. Computed from cross-module
 *     edges in the dep graph. Codegen emits an `await
 *     <importedModule>.__initializeStatic(ctx)` at the head of this
 *     module's `__initializeStatic` for each entry.
 */
export type ModuleInitPhasePlan = {
    localOrder: string[];
    awaitModules: string[];
};
export type ModuleInitPlan = {
    moduleId: string;
    static: ModuleInitPhasePlan;
    global: ModuleInitPhasePlan;
};
export type CompiledClosure = {
    /** Map from absolute module path to parsed program. */
    programs: Record<string, AgencyProgram>;
    /** Shared symbol table for the entire closure. */
    symbolTable: SymbolTable;
    /** The entry module's absolute path. */
    entryModuleId: string;
    /** Static dep graph (Phase A). */
    staticGraph: InitDepGraph;
    /** Global dep graph (Phase B). */
    globalGraph: InitDepGraph;
    /** Resolver used by codegen for PR-1 thread-through. */
    resolver: ImportAliasResolver;
    /** Topsort-derived per-module init plans. Keyed by moduleId. */
    plans: Record<string, ModuleInitPlan>;
};
/**
 * Parse + analyze the entry's full import closure. Throws
 * `CompileClosureError` for parse failures, cycle errors, or
 * static-references-global violations. The caller decides how to
 * surface the error (CLI: exit; in-memory: collect).
 */
export declare function buildCompiledClosure(entryFile: string, config: AgencyConfig): CompiledClosure;
/**
 * Convenience: build the closure and look up one module's plan, or an
 * empty default if the module isn't in the closure. Used by codegen
 * entry points that already have a CompiledClosure on hand.
 */
export declare function planFor(closure: CompiledClosure, moduleId: string): ModuleInitPlan;
