import { type EntityIndex } from './entity-composition.js'; import { CanonicalNameRegistry } from './canonical-names.js'; import { type ManifestNamingInput, type ResolvedNamingConfig } from './naming-config.js'; import { IR, IRDiagnostic, CompileToIRResult } from './ir'; import { type IRCache } from './ir-cache.js'; /** * Compute SHA-256 hash of the IR for runtime integrity verification * This creates a canonical representation by sorting keys and excluding the irHash itself */ export declare function computeIRHash(ir: IR): Promise; export interface CommandIntentRegistryEntry { entity?: string; command: string; sourcePath?: string; line?: number; column?: number; } export declare function validateCommandIntentRegistry(entries: CommandIntentRegistryEntry[]): IRDiagnostic[]; export declare class IRCompiler { private diagnostics; private cache; /** Declared event names, populated before command transform for action-emit validation. */ private declaredEventNames; /** Entity name → its declared property names, for compute-as-mutate detection. */ private entityPropertyNames; constructor(cache?: IRCache); /** * Emit a semantic diagnostic during IR compilation. * This is the compiler's mechanism for reporting semantic errors * beyond what the parser catches (e.g., duplicate constraint codes). */ private emitDiagnostic; compileToIR(source: string, options?: { useCache?: boolean; sourcePath?: string; compositionContext?: EntityIndex; skipReactionCompleteness?: boolean; /** Project-wide spelling registry (multi-file). When set, cache is bypassed. */ nameRegistry?: CanonicalNameRegistry; /** Resolved or raw naming config. Default: normalization off. */ naming?: ManifestNamingInput | ResolvedNamingConfig; /** Config G4 — fixed compiledAt when true. */ deterministicProvenance?: boolean; }): Promise; private transformProgram; private transformModule; private transformValueObject; private transformTenant; private transformEntity; private transformTransition; private transformApproval; private transformApprovalStage; private transformEnum; /** Nullary builtins recognized as a "current time on create" default. */ private static readonly AUTO_NOW_FNS; private transformProperty; private isDefaultCompatible; private static readonly MASK_STRATEGY_ARITY; private transformMaskStrategy; private transformComputedProperty; private transformRelationship; /** * Validate many-to-many `through` joins once every entity is in IR * (semantics.md § Many-to-many via through). */ private validateThroughRelationships; private validateThroughRelationship; private transformConstraint; /** * Validate that constraint codes are unique within a scope (entity or command). * Per spec (manifest-vnext.md, Constraint Blocks): "Within a single entity, * code values MUST be unique. Within a single command's constraints array, * code values MUST be unique. Compiler MUST emit diagnostic error on duplicates." * * Uses the AST nodes for source location (line/column) and IR constraints * for the resolved code values (which default to name if not explicit). */ private validateConstraintCodeUniqueness; private transformStore; private transformEvent; private transformReaction; private transformSaga; private transformWebhook; private transformCommand; /** * Reject guards/constraints that reference a computed property of the owning * entity. Computed values are not materialized into the guard/constraint eval * context, so such references silently resolve to `undefined` and produce wrong * results. Detects both bare (`isRich`) and explicit (`self.isRich` / * `this.isRich`) references. (G8) */ private checkComputedRefsInGuardsAndConstraints; /** * Types that receive a non-null zero fill when unset on a draft. Other non-null * types stay absent until command ownership / defaults / ownership fill them — * a required final field with none of those sources is a contradictory definition. */ private static readonly ZERO_FILLABLE_TYPES; /** * Flag initialization commands whose final document cannot satisfy a required * non-null field. Command-owned fields (via the initialization plan) are NOT * contradictions — they are assigned during atomic construction before persist. */ private checkRequiredFieldsSetOnCreate; /** * Flag duplicate event names — two declarations of the same event name collide in * the event registry (one shadows the other). Warning, not error: surfaces in the * IDE/lint without breaking a build. * * Deliberately NOT checked: event-never-emitted (events are routinely emitted by * reactions and hand-written runtime middleware the compiler cannot see) and * mutate-to-undeclared-field (the runtime supports dynamic instance fields, so such * a write is valid, not a no-op — it is a lint smell, not a guaranteed error). */ private checkEventDeclarations; private transformParameter; private transformAction; /** * Semantic validation of command actions (action-kind contract): * - `emit`/`publish` MUST name a declared event → EMIT_ACTION_UNKNOWN_EVENT (error). * - `compute = …` where `` is a declared property of the bound * entity is almost certainly a mis-used `mutate` (compute no longer persists) * → COMPUTE_USED_AS_MUTATE (warning) so no silent data-loss reaches production. */ private validateCommandActions; private transformPolicy; private transformRole; /** * Resolve the role inheritance graph: * 1. Validate: no duplicate names, no unknown parents, no cycles * 2. Flatten inheritance: root-first union of allows * 3. Apply deny: any (action, target) that appears in ANY level's deny is removed * 4. Sort roles by name for deterministic output */ private resolveRoleGraph; private transformType; private transformExpression; private transformExprToValue; private literalToValue; private transformRetry; private transformRateLimit; private parseWindowDuration; private transformSchedule; private transformTrigger; } export declare function compileToIR(source: string, options?: { useCache?: boolean; sourcePath?: string; naming?: ManifestNamingInput | ResolvedNamingConfig; /** Config G4 — fixed compiledAt when true. */ deterministicProvenance?: boolean; }): Promise; export { checkDomainCompleteness, resolveEntityForFkField } from './domain-completeness.js'; export { checkReactionCompleteness } from './reaction-completeness.js'; //# sourceMappingURL=ir-compiler.d.ts.map