Skip to content

refactor(tools): decompose the DSL language-evaluation checker - #1162

Open
doublewhy wants to merge 4 commits into
devfrom
refactor/dsl-language-evaluation-split
Open

refactor(tools): decompose the DSL language-evaluation checker#1162
doublewhy wants to merge 4 commits into
devfrom
refactor/dsl-language-evaluation-split

Conversation

@doublewhy

Copy link
Copy Markdown

Plain-language summary

Summary

  • Entry script keeps its path (nox invokes it by path) and re-exports the test-facing surface (REQUIRED_DIMENSION_IDS, REQUIRED_PERSONA_IDS, load_bundle, load_bundles, recompute_*, validate_bundle) unchanged; test_dsl_language_evaluation.py needs no edits (no monkeypatching in this suite).
  • _protocol_records_by_id moves into the shape-primitives module alongside its peers.
  • Pure restructuring — no validation rule changes.

Verification

  • Byte-identical checker output and exit status on this repo before and after, in both text and --json modes.
  • test_dsl_language_evaluation.py: 40 passed; nox -s tests green with the coverage gate.
  • Ruff 0.15.9 format and lint clean; tools/check_repo_policy.py pass.

🤖 Generated with Claude Code

doublewhy and others added 4 commits August 14, 2026 17:04
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant