refactor(tools): decompose the DSL language-evaluation checker - #1162
Open
doublewhy wants to merge 4 commits into
Open
refactor(tools): decompose the DSL language-evaluation checker#1162doublewhy wants to merge 4 commits into
doublewhy wants to merge 4 commits into
Conversation
check_dsl_language_evaluation.py was the last 3,000-line governance checker (3,096 lines; single functions of ~700 and ~635 lines). Any future edit would trip the strict Sonar gate's file and function thresholds the way the other three checkers did. It is now an import-stable entry point over a tools/dsl_language_evaluation/ support package (keys, shape primitives, claim scope/binding, measure recomputation, protocol validation with a plans sibling, snapshot validation with a subjects/review/completion sibling, analysis validation), every module under the 500-line cap. _protocol_records_by_id moves to the shape module where its consumers expect it. Pure restructuring: the checker emits byte-identical output and exit status on this repo in both text and --json modes, and the import surface the test suite relies on is re-exported unchanged. Verification: test_dsl_language_evaluation (40 tests) and the full hermetic suite pass with the coverage gate green; ruff format and lint clean; check_repo_policy pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…sholds Split every moved mega-function into single-purpose helpers so the relocated code meets the raes-strict new-code gate: cognitive complexity <=15, <=100 lines, <=7 parameters, <=3 returns per function, and <=500 lines per module. - _measures/_claims/_protocol/_protocol_plans: helper-per-concern rewrites of the recompute, scope, catalog, and plan validators - _snapshot: not-started, record-id, attempt, observation, and opportunity-coverage sections extracted; the execution-record joins now live in _snapshot_execution.py to stay under the module cap - _snapshot_completion: review, disagreement, and completion coverage split into scoped helpers - _analysis: section helpers plus an _AnalysisContext bundle; drops the unused catalogs parameter Verified byte-identical behavior: the checker exits 0 with empty text and JSON output on the real bundles, all 40 suite tests pass, and a 73-scenario differential harness (mutating every record type across protocol, snapshot, and analysis) produces identical failure lists on the old and new implementations. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ackage The raes-strict gate also caps plain cyclomatic complexity at 10, which the first decomposition round exceeded in thirteen helpers. Flatten wide or-chains into any()/all() tuples over pre-normalized operands (behavior preserved: every operand is pure, and each normalized fallback is reachable only when its is-None guard already decides the outcome), extract the remaining hot loops into named helpers, cap returns at three, wrap the two over-long diagnostic strings, and hoist the duplicated analysis-path literal into a constant. The claim-stratum expansion cluster moves to _claim_strata.py to keep _claims.py under the 500-line module cap. Same evidence as the previous round: checker exits 0 with byte-identical text and JSON output, all 40 suite tests pass, the 73-scenario differential harness matches exactly, and nox -s tests passes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…lpers Sonar S5864 flagged the two helpers whose object-annotated parameters were iterated directly. Pass the snapshot and resolve the record list inside each helper, which is exactly how the pre-split code read them. Checker output, the 40-test suite, and the 73-scenario differential harness all remain byte-identical. Co-Authored-By: Claude Fable 5 <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.
Plain-language summary
check_dsl_language_evaluation.pywas the last 3,000-line governance checker (3,096 lines, with single ~700- and ~635-line validator functions). It escaped the ci(sonar): clear mechanical new-code violations in tools and exempt false positives #1152/refactor(tools): decompose oversized governance checkers below the strict Sonar thresholds #1154 Sonar burn-down only because it sat outside the new-code window — the next edit to it would trip the strict gate exactly the way the other three checkers did.tools/dsl_language_evaluation/support package — keys, shape primitives, claim scope/binding, measure recomputation, protocol validation (+ plans sibling), snapshot validation (+ subjects/review/completion sibling with a joins dataclass), analysis validation — every module under the 500-line cap.Summary
REQUIRED_DIMENSION_IDS,REQUIRED_PERSONA_IDS,load_bundle,load_bundles,recompute_*,validate_bundle) unchanged;test_dsl_language_evaluation.pyneeds no edits (no monkeypatching in this suite)._protocol_records_by_idmoves into the shape-primitives module alongside its peers.Verification
--jsonmodes.test_dsl_language_evaluation.py: 40 passed;nox -s testsgreen with the coverage gate.tools/check_repo_policy.pypass.🤖 Generated with Claude Code