refactor: remove dead DeclaredContract/TypeConstraint infrastructure#14
Merged
Conversation
DeclaredContract and TypeConstraint were defined in models/annotations.py and exported from models/__init__.py, but the data they carried was pure redundancy with existing fields on CodeUnit: - TypeConstraint(parameter_name, declared_type) == Parameter.name + Parameter.type_ref.name, both already on CodeUnit. - DeclaredContract.return_constraint == CodeUnit.return_type.name. - DeclaredContract.parameter_types iterates Parameter entries we already have via CodeUnit.parameters. The 14 tree-sitter parsers all called build_contract(params, return_type) and bound the result to `contract`, then used it purely as a boolean in `if contract is not None: graph.annotations.setdefault(func_id, [])`. setdefault with an empty list adds nothing observable (preanalysis later prunes empty annotation lists), so the entire pipeline was dead. Zero consumers in QueryEngine, zero CLI surface, zero skill references. Decision: kill it. If type-level queries become necessary later, they can read Parameter.type_ref and CodeUnit.return_type directly, or a dedicated QueryEngine method can be added then with real semantics. Removed: - models.DeclaredContract, models.TypeConstraint (deleted from annotations.py and the models/__init__.py exports/__all__). - _common.build_contract (helper and its imports). - 14 per-parser `contract = build_contract(...)` calls and the dead `if contract is not None: ... setdefault(...)` blocks. - The TestContractBuilding test class; the useful sub-assertions (return_type capture, parameter count) moved to TestTypeCapture. 842 tests pass, lint/format/type check clean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
DeclaredContract and TypeConstraint were defined in models/annotations.py and exported from models/init.py, but the data they carried was pure redundancy with existing fields on CodeUnit:
The 14 tree-sitter parsers all called build_contract(params, return_type) and bound the result to
contract, then used it purely as a boolean inif contract is not None: graph.annotations.setdefault(func_id, []). setdefault with an empty list adds nothing observable (preanalysis later prunes empty annotation lists), so the entire pipeline was dead.Zero consumers in QueryEngine, zero CLI surface, zero skill references. Decision: kill it. If type-level queries become necessary later, they can read Parameter.type_ref and CodeUnit.return_type directly, or a dedicated QueryEngine method can be added then with real semantics.
Removed:
contract = build_contract(...)calls and the deadif contract is not None: ... setdefault(...)blocks.842 tests pass, lint/format/type check clean.