feat(schemas): column-node anti-pattern validator — Track G G1#187
Open
ronsse wants to merge 1 commit into
Open
feat(schemas): column-node anti-pattern validator — Track G G1#187ronsse wants to merge 1 commit into
ronsse wants to merge 1 commit into
Conversation
…ntities Adds the structural-leaf anti-pattern blocklist (Column / column / TableColumn / table_column) plus a structlog-based advisory validator. The validator is wired into EntityRule (extract/json_rules.py) and the core EntityDraft (schemas/extraction.py) via model_validators that fire at construction time. With allow_structural_leaf=False (default), constructing one of these emits a WARNING with a recommendation pointing at the properties.columns shape; with allow_structural_leaf= True the regulated-column opt-in is acknowledged via an INFO event for audit purposes. Soft enforcement only — never raises, never rejects. Open-string contract preserved (CLAUDE.md, adr-graph-ontology.md). Updates the 3 existing EntityRule(entity_type="column", ...) cases in tests/unit/extract/test_json_rules.py (test_nested_path, test_column_to_enclosing_table, test_missing_ancestor_skips) to set the opt-in flag so they no longer emit spurious warnings during the test run; test_closest_ancestor_wins uses entity_type="group"/"item" and is not on the blocklist, so it needs no update (see Deferred Findings). Adds tests/unit/schemas/test_anti_pattern_validator.py with parametrised coverage of all four blocklist values across the WARNING / INFO / silent paths plus a blocklist-membership pin so drift is caught. Co-Authored-By: Claude Opus 4.7 (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.
Summary
ENTITY_TYPE_ANTI_PATTERNSfrozenset +validate_entity_type_not_anti_pattern()helper tosrc/trellis/schemas/well_known.py(+92 LOC).allow_structural_leaf: bool = Falsefield toEntityDraft(insrc/trellis/schemas/extraction.py) andEntityRule(insrc/trellis/extract/json_rules.py). Both wire a Pydanticmodel_validator(mode="after")that calls the helper at construction time.entity_type in {"Column", "column", "TableColumn", "table_column"}whenallow_structural_leaf=False; INFO when the operator opts in. Never raises; never rejects.tests/unit/extract/test_json_rules.pyto setallow_structural_leaf=True(regulated-column exception scenario from a test perspective).tests/unit/schemas/test_anti_pattern_validator.py(+174 LOC, 22 tests) covering WARNING / INFO / silent paths, parametrized over the blocklist + drift pin.Test plan
pytest tests/unit/extract/ tests/unit/schemas/ -v→ 615 passed, 0 failedpytest tests/(full unit suite) → 3572 passed, 41 skipped, 319 deselectedruff check src/ tests/ eval/→ All checks passedmypy src/→ no issues in 241 source filesadr-source-modeling-discipline.md)EntityDraftdeliberately NOT modified — see Deferred Findings in agent report; G2/follow-up may revisitDeferred follow-ups
test_json_rules.py(test_node_role_preserved,test_field_reference_scalar,test_unknown_target_skipped,test_no_source_matches_yields_no_edges) emit spurious WARNING in test runs (validator is advisory; tests still pass). Addallow_structural_leaf=Truein a hygiene follow-up.EntityDraftinsrc/trellis_wire/extract.pydoesn't carry the flag. Today, wire-submitted column drafts trigger server-side WARNING — arguably correct default but worth an explicit ADR call.🤖 Generated with Claude Code