Refactor canonical IR authoring with typed algebraic contracts - #10
Merged
Conversation
- Introduce algebraic data type framework in schema/ (deriving, result, frozen, diagnostics) - Replace legacy synthesizer/ir/ with typed stage modules (stages/model, stages/distributed_task, etc.) - Add @adt/@variant/@record decorators for closed-world codec and structural validation - Add Result/Checked type for diagnostic-accumulating error handling - Add PassContract with typed rules, analysis cache invalidation, and TransitionVerifier - Separate IO-free derivation from stateful synthesis (passes/authoring, passes/deriving) - Add typed scalar expression ADT with symbolic substitution and evaluation - Add dialect-specific semantics and derivation modules (transformer/semantics, inference_derivation, training_derivation) - Add runtime contract compilation (schema/contracts, contracts.py) - Add ADR documents for wire identities, expression schemas, and progressive typed contracts - Update docs, tests, and examples to match the new API
reiase
marked this pull request as ready for review
August 12, 2026 02:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Canonical contracts previously mixed raw dataclasses, low-level codec decorators, handwritten single-field validation, and repeated domain facts. That made the schema shape harder to audit, allowed authoring styles to drift, and left some runtime contract changes outside the digest.
This refactor establishes one typed algebraic authoring path. Mechanical structure is derived; independent semantic relations remain executable and visible.
Impact
__post_init__methods are reduced from 110 to 49; the remainder are relational invariants or intentional boundary normalizationValidation
.venv/bin/pytest -q— passed; one optional pyarrow test skipped because pyarrow is not installed.venv/bin/mypy src/blueprinting— passed for 97 source files.venv/bin/ruff check src tests examples/calculon_calibration.py— passed.venv/bin/ruff format --check src tests examples/calculon_calibration.py— passed.venv/bin/python scripts/check_docs_i18n.py— validated 49 bilingual page pairs.venv/bin/mkdocs build --strict— passed.venv/bin/python scripts/check_rendered_code_docs.py— passedgit diff --check— passed