Skip to content

refactor: split aces_sdl.validator into a per-seam mixin package - #557

Merged
Brad-Edwards merged 2 commits into
devfrom
42-split-validator
Jun 15, 2026
Merged

refactor: split aces_sdl.validator into a per-seam mixin package#557
Brad-Edwards merged 2 commits into
devfrom
42-split-validator

Conversation

@Brad-Edwards

Copy link
Copy Markdown
Collaborator

Summary

Split the oversized aces_sdl.validator module (4,139 lines, ~7x the ADR-015 600-line cap) into a package of per-validation-seam mixin modules, each under the cap, behind an API-stable SemanticValidator re-export. Pure refactor: methods moved verbatim (git-detected moves), no validation behavior, diagnostics, pass ordering, exception type, or public-API change — the existing test suite is the regression contract. The #38 cycle break (PR #53) ordering prerequisite is satisfied. The error-vs-advisory boundary lint (test_sdl_diagnostic_boundary) is adapted to scan the package and aggregate methods across the composed mixins; its rules and synthetic negative test are unchanged so the IMP-3/#505 control keeps full teeth (the only test touched — engineering decision recorded on the issue). Removed from the oversized-source allowlist.

Requirement UIDs

  • (none — bug/refactor/maintenance run; see Traceability section below)

Related Issues

Closes #42

ADR Impact

  • ADR-015
  • ADR-016

Changes

  • Convert validator.py to a validator/ package: _core (validate() coordinator + shared ref/index/named-ref helpers), _nodes_infra_network, _runtime_services, _runtime_identity_data, _runtime_platform, _runtime_mail, _relationships, _content_objectives, _workflows_analysis, _workflows_verify, _sections mixins, plus _support (shared module-level helpers); __init__ composes SemanticValidator(*mixins, _ValidatorCore).
  • Methods moved verbatim via an AST splitter (exhaustiveness-checked, comment-preserving); relative-import depth bumped to .. for aces_sdl siblings; per-file imports trimmed by ruff.
  • Adapt test_sdl_diagnostic_boundary to read the package source and aggregate methods across all classes; the 5 boundary rules and the synthetic negative-path fixture are unchanged.
  • Remove validator.py from tools/policy/oversized_allowlist.yaml; repoint the F821 forward-reference per-file-ignore to validator/_sections.py.
  • Repoint stale validator.py references: the ADR-016 semantic-coverage matrix -> validator/__init__.py (compat-aware integration check passes); specs/formal prose -> package. CHANGELOG/ADR-015 historical references left intact.
  • Add changelog.d/42.changed.md.

Test Plan

  • Unit tests pass (make test)
  • Integration tests pass if applicable (make integration)
  • make check passes (Spotless, SpotBugs, Error Prone, Checkstyle, JaCoCo)
  • No coverage regression

Pure refactor — the existing test suite is the behavior contract. nox -s verify -- --skip-requirement passes: hygiene, policy (incl. ADR-015 size cap after de-allowlisting + ADR-016 semantic-coverage integration), ruff, full pytest (2,545 passed) + integration, and the Sphinx docs build. The adapted boundary lint passes on both the live package source and the synthetic negative fixture. No external aces_sdl.validator import line changed (verified by diff); the aces.core.sdl.validator compat re-export still exposes SemanticValidator.

Ground Control Checks

  • make policy passes
  • gc_evaluate_quality_gates passes or is unchanged by this repo-only change
  • gc_run_sweep reviewed; findings fixed or recorded with rationale

Traceability

  • IMPLEMENTS: (none — bug/refactor/maintenance run)
  • TESTS: (none — documentation/configuration/structural-invariant run)

Checklist

  • Code follows project coding standards (docs/CODING_STANDARDS.md)
  • No business logic in API layer
  • Domain layer has no framework imports
  • Envers @Audited on new entities if applicable
  • Changelog fragment added at changelog.d/42.changed.md
  • Architectural docs updated if stack, package structure, or key behaviors changed

- Convert validator.py (4,139 lines) into a package of <=600-line per-seam mixin modules (core, runtime families, relationships, content/objectives, workflows, sections) behind an API-stable SemanticValidator re-export (#42).
- Pure refactor: methods moved verbatim; no validation behavior, diagnostics, pass ordering, exception type, or public-API change. The #38 cycle break (PR #53) is the satisfied ordering prerequisite.
- Adapt the error-vs-advisory boundary lint (test_sdl_diagnostic_boundary) to scan the package and aggregate methods across the composed mixins; its rules and synthetic negative-path fixture are unchanged, so the IMP-3/#505 control keeps full teeth. Rationale recorded on the issue.
- Remove validator.py from tools/policy/oversized_allowlist.yaml; repoint the F821 forward-ref per-file-ignore to validator/_sections.py.
- Repoint stale validator.py references in the semantic-coverage matrix (-> validator/__init__.py) and specs/formal prose (-> package) to the new layout.
Behavior-preserving extraction across the validator mixin package to clear the new-code complexity violations (cognitive/cyclomatic/nesting/too-many-returns/too-many-params/make-static) SonarCloud raised on the verbatim-moved validators. No validation behavior, diagnostics, pass ordering, or public-API change; guarded by the existing test suite. Adds shared context dataclasses (_WorkflowBuildState, _CompensationState, _AvailableStateContext) and per-concern helpers; drops the now-unnecessary F821 per-file-ignore.
@sonarqubecloud

Copy link
Copy Markdown

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