refactor: split oversized modules and cut function complexity (MOD-001) - #743
Merged
Conversation
The dev->main promotion (PR #740) failed SonarCloud's aces-strict quality gate with 9 new violations: 5 files over the 500-line S104 cap and 4 functions over cyclomatic complexity 10. Split each oversized module along a cohesive seam and decomposed each over-complex function into helpers. Moved symbols are re-imported into their original modules so every public import path and __all__ stays stable. No behaviour change; full nox verify green. Splits: - aces_sdl.parser -> _model_diagnostics (pydantic-error diagnostic rendering) - aces_sdl._runtime_service_families -> _runtime_service_family_registry (registry data) - aces_sdl._yaml_loader -> _mapping_key_analyzer (mapping-key validation walker) - aces_operations._evidence_run_validation -> _evidence_run_realization - aces_operations.libvirt_evidence_run -> _evidence_run_native (EvidenceCheck / LibvirtEvidenceRunConfig relocated to _evidence_run_types to break the cycle) - aces_backend_libvirt.techvault_concerns -> techvault_plan_admission - aces_backend_libvirt.techvault_native -> _techvault_native_ops Complexity reductions (all now <=10): - _evidence_run_realization._validate_unrealized_substrate (11) - _mapping_key_analyzer._walk_mapping_entry (13) - techvault_native.TechVaultNativeLibvirtDriver.__post_init__ (12) - provisioner.LibvirtProvisioner._drive (14)
The extracted _active_addresses helper does not use instance state; SonarCloud flagged python:S2325. Make it a staticmethod (called via the instance in _drive).
|
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.



Why
The
dev→mainpromotion (PR #740) fails SonarCloud'saces-strictquality gate with
new_violations = 9(threshold 0). Every other conditionpasses (coverage 92.6%, duplication 0.4%, all ratings A). The 9 issues are
accumulated modularity debt on
devsurfaced by the aggregatemain..devdiff:(Note: the repo's own ADR-015 cap is 600 lines, which is why local
verifypassed; SonarCloud independently caps at 500.) Per the project review standards,
these are fixed by real decomposition — not by relaxing the Sonar threshold or
adding per-file ignores.
What
Each oversized module is split along a cohesive seam; moved symbols are
re-imported into their original module so every public import path and
__all__stays byte-for-byte stable (zero changes at ~30 call sites). Each over-complex
function is decomposed into small helpers.
Module splits (S104):
aces_sdl/parser.py_model_diagnostics.py(pydantic-error rendering)aces_sdl/_runtime_service_families.py_runtime_service_family_registry.py(registry data)aces_sdl/_yaml_loader.py†_mapping_key_analyzer.py(key-validation walker)aces_operations/_evidence_run_validation.py_evidence_run_realization.pyaces_operations/libvirt_evidence_run.py_evidence_run_native.py‡aces_backend_libvirt/techvault_concerns.pytechvault_plan_admission.pyaces_backend_libvirt/techvault_native.py†_techvault_native_ops.py‡
EvidenceCheck/LibvirtEvidenceRunConfigrelocated to the existing_evidence_run_types.pyto break an import cycle; both re-exported.†
_yaml_loader.pyandtechvault_native.pywere not S104 "new" (already >500 onmain); they were split because the complexity fixes below pushed them over the600-line ADR-015 repo cap.
Complexity reductions (all now ≤10):
_validate_unrealized_substrate(11) — extract_unrealized_daemon_leak_walk_mapping_entry(13) — extract_validate_entry_identifiersTechVaultNativeLibvirtDriver.__post_init__(12) — split into two validatorsLibvirtProvisioner._drive(14) — extract_active_addresses/_realize_active/_delete_targetsVerification
nox -s verifygreen locally (ruff, requirement governance, repo policyincl. the 600-line cap, all pytest + integration, contracts, docs).
dev, PR Dev #740's SonarCloud gate goes tonew_violations = 0.Requirement: MOD-001 (Codebase Modularity And Layering).