refactor: resolve sonar complexity and length violations in package modules - #1156
Open
doublewhy wants to merge 2 commits into
Open
refactor: resolve sonar complexity and length violations in package modules#1156doublewhy wants to merge 2 commits into
doublewhy wants to merge 2 commits into
Conversation
…odules Part of turning the dev Sonar quality gate green (raes-strict fails on any new-code violation). Fifteen recently-touched package modules each carried one violation: two files exactly one line over the 500-line cap (S104), four functions over 100 lines (S138), and nine functions with cyclomatic complexity 11-13 against the 10 threshold. All changes are behavior-preserving extractions with no public API, contract, or schema change: - raes/composition/_expand.py: move per-import provenance assembly into _import_provenance_additions - raes/phase_contracts.py: hoist the two constraint-pointer shape predicates out of _validate_constraint - raes_backend_libvirt/capability_envelope.py: split the operating-system identity probe out of _out_of_envelope_terms - raes_backend_protocols/provisioner_capabilities.py: extract operating-system row and artifact-kind validation helpers - raes_backend_stubs/stubs.py: extract the operations fold from apply - raes_conformance/snapshot_semantics.py: extract entry and disclosure builders from _snapshot_from_envelope - raes_contracts/apparatus.py, contracts/capabilities.py, realization_envelope_carrier.py: extract validator helper functions - raes_contracts/contracts/bundle.py: move _runtime_schema_bundle and its imports into contracts/bundle_runtime.py (bundle output verified identical by tools/check_generated_schemas.py) - raes_processor/planner/operations.py: extract ordered apply/delete op builders - raes_processor/semantics/realization_runtime_evaluation.py: hoist the observation-corroboration predicate - raes_runtime/backend_calls.py: move the ApplyResult shape validators into backend_call_contracts.py - raes_runtime/control_plane_api_participant_retrieval.py: fold the three governed-view routes onto one shared resolve/audit flow - raes_runtime/control_plane_store.py: move snapshot payload builders into control_plane_store_payloads.py (also keeps the file under the repo's own 500-line policy cap) Verification: nox -s tests (7,005 passed, coverage gate green), ruff format and lint clean, tools/check_generated_schemas.py identical, tools/check_repo_policy.py pass. Closes #1153 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The extracted _realization_observations_payload had a token-identical twin inside control_plane_api_models._snapshot_model, which the PR analysis surfaced as new-code duplication once the store copy moved. The API model now calls the shared builder; behavior is unchanged (both sites operate on the same RuntimeSnapshot disclosure objects). 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
devSonar quality gate green (raes-strictfails on any new-code violation); thetools/slice is PR ci(sonar): clear the tools new-code violations and exempt false positives #1155.Issue mapping
Summary
raes/composition/_expand.py: per-import provenance assembly moves into_import_provenance_additions.raes/phase_contracts.py: the two constraint-pointer shape predicates hoist out of_validate_constraint.raes_backend_libvirt/capability_envelope.py: the operating-system identity probe splits out of_out_of_envelope_terms.raes_backend_protocols/provisioner_capabilities.py: operating-system row and artifact-kind validation extract to module helpers (mirroring the existing_validate_account_supportpattern).raes_backend_stubs/stubs.py: the operations fold extracts fromapplyinto_applied_entries.raes_conformance/conformance/snapshot_semantics.py: entry and disclosure builders extract from_snapshot_from_envelope.raes_contracts/apparatus.py,contracts/capabilities.py,realization_envelope_carrier.py: validator bodies split into focused helper functions.raes_contracts/contracts/bundle.py(501 → 413 lines):_runtime_schema_bundleand its imports move to newcontracts/bundle_runtime.py.raes_processor/planner/operations.py: ordered apply/delete op builders extract from_build_provisioning_plan.raes_processor/semantics/realization_runtime_evaluation.py: the observation-corroboration predicate hoists out of_corroboration_diagnostic.raes_runtime/backend_calls.py(501 → 438 lines): the sevenApplyResultshape validators move to newbackend_call_contracts.py.raes_runtime/control_plane_api_participant_retrieval.py: the three governed-view routes fold onto one shared resolve/audit flow (_resolved_governed_view), removing triplicated logic while landing under the length threshold.raes_runtime/control_plane_store.py(→ 430 lines): snapshot payload builders move to newcontrol_plane_store_payloads.py— this also keeps the file under the repo's own 500-line policy cap, whichtools/check_repo_policy.pyenforces.Compatibility
tools/check_generated_schemas.py) despite thebundle.pysplit.backend_calls(_call_backend_apply,_RealizationApplyContext,_call_backend_diagnostics) are untouched.Verification
nox -s tests: 7,005 passed, 1 skipped; branch-aware coverage gate green.tools/check_generated_schemas.py: schema bundle identical.tools/check_repo_policy.py: pass (including the 500-line source-file policy).packages/.🤖 Generated with Claude Code