Skip to content

Complete Schema → IR Compilation Pipeline #5

@Kinflou

Description

@Kinflou

Complete Schema → IR Compilation Pipeline

Priority

P0 (Critical) - Core transformation that enables all downstream features

Labels

  • core
  • compiler
  • ir
  • P0

Estimated Effort

2-3 weeks

Description

The AST → IR compilation pipeline is partially implemented with many todo!() placeholders. This is the core transformation that converts parsed schemas into the intermediate representation used for versioning, diffing, and code generation.

We need to complete:

  • Object stage compilation
  • Import resolution
  • Semantic validation
  • Context management
  • Error reporting

Current State

Location: core/src/schema/ir/compiler/

Basic structure exists but incomplete compilation stages. 15+ TODOs in compiler/interpreter code.

TODO References

  • compiler/mod.rs:25 - Source name tracking
  • ir/context.rs:36,40,70 - Incomplete context methods
  • compiler/interpreter/object_stage/mod.rs:50,55 - Import resolution
  • compiler/interpreter/freezing.rs:47,165,183 - Freezing logic

Acceptance Criteria

  • All AST node types compile to IR (struct, enum, protocol, function, etc.)
  • Import statements resolve correctly across files
  • Semantic validation catches errors:
    • Duplicate names
    • Type mismatches
    • Invalid references
    • Circular dependencies
  • Compilation context tracks all symbols correctly
  • Rich error messages with source locations using ariadne
  • All example schemas in examples/ compile successfully
  • No TODO items remain in compiler code

Tasks

  • Complete object stage compilation for all AST nodes
  • Implement import resolution system
  • Add semantic validation passes (name resolution, type checking)
  • Complete Context implementation for symbol tracking
  • Add source location tracking throughout compilation
  • Implement proper error accumulation (don't stop at first error)
  • Create integration tests for full AST→IR pipeline
  • Profile and optimize compilation speed
  • Document compiler architecture (phases, passes, data structures)

Technical Notes

The compiler uses a multi-stage approach:

  1. Parse - AST generation (handled by parser)
  2. Object Stage - Build intermediate objects
  3. Freezing - Convert to FrozenUnits for CAS
  4. Validation - Semantic checks

Dependencies

Blocks

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Priority 0 - CriticalcompilerCompiler systemcoreCore system componentirIntermediate Representation

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions