/** * AST Schema Validation — validates IRNode shape after parsing, before codegen. * * Defines required/optional props and allowed child types per node type. * Catches malformed ASTs (missing required props, wrong children) at the * parse boundary instead of scattering validation across 76 codegen functions. * * Props are classified by kind: * - 'identifier' → validated by emitIdentifier * - 'typeAnnotation' → validated by emitTypeAnnotation * - 'importPath' → validated by emitImportSpecifier * - 'rawExpr' → intentional escape hatch (handler code, expressions) * - 'rawBlock' → intentional escape hatch (<<<...>>> blocks) * - 'string' → free-form string value * - 'boolean' → 'true'/'false' * - 'number' → numeric value */ import { type KernTarget } from './config.js'; import { type KernRuntime } from './runtime.js'; import type { IRNode } from './types.js'; export type PropKind = 'identifier' | 'typeAnnotation' | 'importPath' | 'rawExpr' | 'rawBlock' | 'string' | 'boolean' | 'number' | 'expression' | 'regex'; export interface PropSchema { required?: boolean; kind: PropKind; values?: readonly string[]; } export interface NodeSchema { props: Record; allowedChildren?: string[]; description?: string; example?: string; } export declare const NODE_SCHEMAS: Record; export interface SchemaViolation { nodeType: string; message: string; line?: number; col?: number; } /** * Validate an IR tree against the schema definitions (required props, allowed children, cross-prop rules). * * Walks the full tree recursively. Returns an empty array when the tree is valid. * Node types without a registered schema are silently accepted. * * @param root - The root IRNode to validate * @returns Array of {@link SchemaViolation} — empty means valid */ export declare function validateSchema(root: IRNode): SchemaViolation[]; export interface KernSchemaJSON { version: string; nodeTypes: readonly string[]; schemas: Record; unschemaed: string[]; targets: readonly KernTarget[]; styleShorthands: Record; valueShorthands: Record; multilineBlockTypes: string[]; propKinds: readonly PropKind[]; evolvedTypes?: string[]; } /** * Export the full KERN schema as a JSON-serializable object. * * Designed for LLM consumption — an LLM can call `kern schema --json` * and use the output to generate valid `.kern` files. * * @param runtime - Optional KernRuntime instance (includes evolved types) */ export declare function exportSchemaJSON(runtime?: KernRuntime): KernSchemaJSON;