Repository navigation
Fix all 22 S110 findings; network metrics report None instead of a fake 0.0 on failure (#473) - #476
Merged
Conversation
…t None instead of a fake 0.0 on failure (#473) Two different fixes, chosen per-site based on what the swallowed exception actually means for the downstream consumer: ROOT-CAUSE FIX (network_risk_sensor.py, both macro_metrics producers): modularity/assortativity/cyclic_density/avg_path_length/articulation_points defaulted to 0.0/0.0/0.0/0.0/0, and each was independently computed inside its own try/except Exception: pass. If a computation failed (or was skipped for scale on graphs >5000 nodes) that key silently kept its 0.0 default -- and 0.0 is a real, meaningful modularity score (no community structure), not an obviously-wrong sentinel. A failed computation was indistinguishable from a genuine measurement of zero, with zero trace anywhere that it had failed. This is the same "explicitly missing, not a specific observation" problem record_keeper.py already solves correctly for zero_dependency_mode (ai_score/pagerank_score/etc default to None, not 0.0, flowing through to a real SQL NULL) -- just not applied to this one set of values. Fixed the same way: both macro_metrics producers (the real networkx computation and the zero-dependency-mode fallback) now default every key to None, and record_keeper.py/llm_recorder.py's consumers no longer paper over that with their own `, 0.0` `.get()` fallback, which would have silently undone the fix one hop downstream. REAL columns already accept NULL fine (confirmed: zero_dependency_mode's ai_score/pagerank_score already flow through the identical INSERT statement this way). tests/golden_master_zero_dep_audit.json regenerated via the sanctioned tests/tools/update_golden_master.py -- the 5 expected diffs are exactly this change (0.0/0.0/0.0/0.0/0 -> null for the five network metrics under zero-dependency mode). golden_master_audit.json has zero drift (confirmed): every computation succeeds in that fixture, so the None defaults never surface there. OBSERVABILITY FIX (the other 17 S110 sites): these are soft-skip patterns (one file fails to parse in a batch, one regex rule times out, a .env file is locked) where the existing behavior is already correct -- degrade gracefully, don't crash the whole scan -- but failures were completely untraceable. Added `logger.debug(...)` inside each except block. Two files (security_lens.py, cobol_jcl_auditor.py/full_api_network_map.py/binary_anomaly_detector.py/ vault_sentinel.py) had no logger at all; added a minimal module-level or local logger rather than plumbing a parent_logger param through every call site. binary_anomaly_detector.py's run_xray_audit() specifically avoids its existing `quiet_logger` (deliberately WARNING-level, muting ApertureFilter's init noise) for this new debug line, since routing through it would silently drop every message again. licensing.py's single site got a `# noqa: S110` instead -- no logging infrastructure exists in that file, and the existing comment already documents the deliberate rationale. Also fixes 1 SIM105 as a fan-out: one of the touched sites was a pure try/except/pass shape that stopped matching once it gained a debug call. Baseline: 241 -> 217 unique entries.
Contributor
This was referenced Jul 25, 2026
Closed
squid-protocol
added a commit
that referenced
this pull request
Jul 25, 2026
…841) (#480) * Fix remaining 33 findings in #473 (ARG001/ARG002/RUF012/B007/RUF059/F841) Closes the ARG/B007/RUF012/RUF059/F841 remainder of #473 (S110 was already closed out in #476). Three findings turned out to be real bugs where a parameter was accepted but never wired into an established sibling formula, confirmed with the user before fixing: - signal_processor.py: _calc_concurrency/_calc_state_flux ignored the tier risk floor `irc`, unlike 4 sibling _calc_* methods that fold it into their density formula. Wired it in identically. - language_lens.py: _tier_3_lexical_scan ignored `claimed_lang` while its sibling `gravity_lang` gets a 1.25x consensus boost. Gave claimed_lang the same boost. - cobol_jcl_forge.py: generate_zero_trust_jcl ignored `corporate_header` while its sibling forge_schemas (called two lines earlier by the same caller) prepends it as a comment block. Mirrored that for JCL output. Everything else was dead parameters removed outright (call sites and tests updated to match), genuine shared-interface params marked with `# noqa: ARG002 -- reason` (matching the repo's existing noqa convention), or mutable class-level constants annotated ClassVar. Baseline regenerated: 241 -> 152 findings in ruff_audit_baseline.json. Full test suite passes (866 passed, 1 pre-existing xfail). Closes #473 Co-Authored-By: Claude Sonnet 5 <[email protected]> * Fix irc calibration in _calc_concurrency/_calc_state_flux, regenerate golden masters CI's golden-crucible regression test caught a miscalibration in the irc wiring from the previous commit: I mirrored _calc_cog_load's `irc/loc` pattern, but concurrency/state_flux compute density on a pre-scaled x100 percentage basis, so dividing irc by loc there blew up scores for small files (e.g. one file jumped from 34.63% to 99.48%). analysis_lens.py's tuning config already had an `irc_mult` key for both categories (concurrency: 0.1, state_flux: 0.15), with threshold_base/ sigmoid_slope comments like "Lowered from 4.0" that only make sense if irc_mult was meant to be consumed -- this was the actually-intended formula, matching tech_debt's flat `irc * irc_weight` pattern rather than cog_load's loc-divided one. Switched both to `density += irc * tuning.get("irc_mult", ...)`, which produces the modest, proportional deltas the tuning was calibrated for. Verified locally against the language-crucible corpus in both zero-dependency and full-precision mode (test_golden_crucible.py -m golden_crucible), regenerated both golden masters, and reran the full suite (866 passed, 1 pre-existing xfail). Co-Authored-By: Claude Sonnet 5 <[email protected]> * Regenerate ruff baseline for line-shift from the irc calibration fix The previous commit added two lines to signal_processor.py, shifting an already-baselined PERF401 finding from line 2457 to 2459 -- the known line-shift false-positive tests/ruff_audit.py's docstring describes, not a new finding. No other findings changed. Co-Authored-By: Claude Sonnet 5 <[email protected]> --------- Co-authored-by: Joe Esquibel <[email protected]> Co-authored-by: Claude Sonnet 5 <[email protected]>
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.
Summary
Starts on #473, the exception-hygiene sub-issue of the ruff epic (#469) -- specifically the
S110(try/except/pass) cluster, prioritized after tracing one instance all the way through and finding a real, if subtle, data-integrity issue.Root-cause fix (
network_risk_sensor.py):modularity/assortativity/cyclic_density/avg_path_length/articulation_pointsdefaulted to0.0/0.0/0.0/0.0/0, each computed independently inside its owntry/except Exception: pass. If a computation failed (or was skipped for scale on graphs >5000 nodes), that key silently kept its0.0default -- and0.0is a real, meaningful modularity score (no community structure), not an obviously-wrong sentinel. A failed computation was indistinguishable from a genuine measurement of zero, with no trace anywhere that it had failed.This is the exact same problem
record_keeper.pyalready solves correctly forzero_dependency_mode(ai_score/pagerank_score/etc default toNone, not0.0, flowing through to a real SQLNULL) -- it just wasn't applied to this one set of values. Fixed the same way: bothmacro_metricsproducers (the real networkx computation and the zero-dependency-mode fallback) now default every key toNone, andrecord_keeper.py/llm_recorder.py's consumers no longer paper over that with their own, 0.0.get()fallback (which would silently undo the fix one hop downstream).tests/golden_master_zero_dep_audit.jsonregenerated via the sanctionedtests/tools/update_golden_master.py-- the 5 expected diffs are exactly this change.golden_master_audit.jsonhas zero drift (confirmed): every computation succeeds in that fixture, so theNonedefaults never surface there.Observability fix (the other 17
S110sites): soft-skip patterns (one file fails to parse in a batch, one regex rule times out, a.envfile is locked) where the existing behavior is already correct -- degrade gracefully, don't crash the whole scan -- but failures were completely untraceable. Addedlogger.debug(...)inside each. A few files had no logger at all; added a minimal one rather than plumbing aparent_loggerparam through every call site.licensing.py's single site got a# noqa: S110instead -- no logging infra exists there, and the existing comment already documents the deliberate rationale.Also fixes 1
SIM105as a fan-out (one touched site stopped matching that pattern once it gained a debug call).Baseline: 241 -> 217 unique entries.
Test plan
mypy gitgalaxy/ --ignore-missing-imports(fresh.mypy_cache):Success: no issues found in 65 source filespython tests/ruff_audit.py --ci: passes against the regenerated 217-entry baselinepython tests/mypy_audit.py --ci/python tests/dead_key_audit.py --ci: no new findingspython -m pytest tests/test_golden_crucible.py -m golden_crucible: passes against the regenerated zero-dep fixturepytest tests/ -q: 866 passed, 1 deselected, 1 xfailed -- identical to pre-change🤖 Generated with Claude Code