Why
CompilationModel.lean is the single largest file in the codebase at 5,404 lines. It contains:
- Type definitions (Expr, Stmt, CompilationModel, etc.)
- The entire compiler logic (compileExpr, compileStmt, compile)
- Validation walkers
- ABI encoding
- 201 error messages
This is the #1 obstacle for:
- LLM comprehension: models struggle with 5k+ line files and lose context
- Build times: changes to any part of the file trigger full recompilation of everything downstream
- Code review: PRs touching this file are hard to review
Solution
Split into separate modules:
Compiler/
CompilationModel/
Types.lean -- Expr, Stmt, CompilationModel, Field, StorageSlot, etc.
ExprCompiler.lean -- compileExpr and expression-level compilation
StmtCompiler.lean -- compileStmt and statement-level compilation
Compile.lean -- top-level compile function, contract assembly
Validation.lean -- validation walkers, field checks
AbiEncoding.lean -- ABI JSON generation, selector computation
Errors.lean -- error message constants and formatting (optional)
CompilationModel.lean -- re-exports all submodules for backwards compatibility
Effort
1 week
Acceptance
- All content from the monolith distributed across well-named submodules
- A single
CompilationModel.lean re-export file for backwards compatibility
- No regressions in build or proofs
- Incremental build time improvement measurable on the compiler target
Why
CompilationModel.leanis the single largest file in the codebase at 5,404 lines. It contains:This is the #1 obstacle for:
Solution
Split into separate modules:
Effort
1 week
Acceptance
CompilationModel.leanre-export file for backwards compatibility