Repository navigation
Scope dampener correlation to real function boundaries (#346 phase 1) - #349
Merged
squid-protocol merged 1 commit intoJul 24, 2026
Merged
Conversation
detector.py's three dampener-pair correlations -- "2. The Silencer Region" (safety mitigating high_risk_execution), the sync_locks half of "3. The Race Condition Radar", and "5. The Memory Leak / UAF Tracker" (cleanup mitigating memory_alloc) -- all used a flat character-radius proximity check as their only notion of "nearby". A safety/cleanup call in a completely different function could silently cancel real risk in this one, as long as it fell within the (500/300/800-char) radius -- a false negative, not just noise, since these blocks reduce reported risk rather than add to it. None of the six correlate() calls in coding_analysis() had access to real function boundaries, because coding_analysis() (where they ran) executed before _function_slice() (which computes satellite/function ranges) in splice(). Fixed by: - Extracting _correlate_signals into gitgalaxy/core/spatial_correlation.py as a shared, reusable primitive (StructuralExtractor._correlate_signals is now a thin delegating wrapper, kept for existing callers). - Adding a scope-aware correlate_scoped(): a target/dampener pair must fall within the same satellite range to correlate; a target outside every known satellite range falls back to the pre-scoping flat behavior, so nothing that correlated before this change stops correlating -- module-level/unsliced code is unaffected. - Relocating the three dampener blocks out of coding_analysis() into apply_dampener_correlations(), called from _function_slice()'s own per-segment loop, right after that segment's satellites are computed -- the one place spatial_map and real satellite ranges already coexist, with no new cross-referencing needed. - Adding start_idx/end_idx to each satellite (FunctionNode), computed but previously discarded in _calculate_block_metrics. - Removing _function_slice()'s early MAX_SATELLITES break: that cap bounds stored function *metadata*, not which code gets correlated -- letting it silently skip correlating the remainder of an unusually large file would have been a regression this fix specifically exists to prevent. Only matters for files with 250+ functions. The three amplifier-only pairs (RCE/IO taint corroboration, active secret-leak amplification, and the concurrency-amplifying half of the Race Condition Radar) are intentionally left on the flat radius -- a false positive there costs one extra review item, an accepted tradeoff, not the false-negative risk this phase targets. Persisting a satellite-aware ledger for post-hoc tools (#105/#106) and scoping the amplifier pairs is tracked separately in #348. Co-Authored-By: Claude Sonnet 5 <[email protected]>
5 tasks
Contributor
squid-protocol
deleted the
feature/346-satellite-scoped-dampener-correlation
branch
July 24, 2026 02:19
This was referenced Jul 24, 2026
Closed
squid-protocol
added a commit
that referenced
this pull request
Jul 26, 2026
…alc_cog_load) (#506) Found via CodeQL's py/redundant-comparison + py/unreachable-statement alerts (#347, #349): `if safe_loc < 15: ... return 5.0, total_density` returns unconditionally for any 1-14 LOC file, so the later `if safe_loc <= 2 and total_density == 0: return 0.0, total_density` could never execute -- safe_loc is always >= 15 by the time execution reaches it. Every tiny file, including a provably empty stub (e.g. a near-blank __init__.py), was forced to a cognitive_load score of 5.0. The dead code itself documents the original intent: a truly empty <=2 LOC file shouldn't get even the small-file floor. Moved that exact check inside the reachable `< 15` branch rather than inventing new behavior, and removed the now-fully-dead duplicate below it. The carve-out only fires for tier1 languages (irc == 0) since irc feeds into total_density too -- tier2/3 files always carry a nonzero floor from irc alone. Verified against the language-crucible corpus in both zero-dependency and full-precision mode: exactly one file (rust/tokio/fuzz.rs, tier1) changed from a phantom 5.0% to a correct 0.0%, rippling into its directory/global averages. Regenerated both golden masters and added two unit tests (empty tiny file -> true 0.0, small file with real signal -> unchanged 5.0 floor). Full suite: 869 passed, 1 pre-existing xfail. Baseline regenerated for line-shift from removing the dead duplicate (no new findings). 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
Fixes #346 (phase 1 -- see the issue for the split; phase 2, persisting a satellite-aware ledger for post-hoc tools and scoping the amplifier pairs, is tracked separately in #348).
detector.py's three dampener-pair correlations -- "2. The Silencer Region" (safetymitigatinghigh_risk_execution), thesync_lockshalf of "3. The Race Condition Radar", and "5. The Memory Leak / UAF Tracker" (cleanupmitigatingmemory_alloc) -- all used a flat character-radius proximity check as their only notion of "nearby". Asafety/cleanupcall in a completely different function could silently cancel real risk in this one, as long as it fell within the radius (500/300/800 chars respectively) -- a false negative, not just noise, since these blocks reduce reported risk rather than add to it.correlate()calls incoding_analysis()had access to real function boundaries, becausecoding_analysis()(where they ran) executed before_function_slice()(which computes satellite/function ranges) insplice()._correlate_signalsintogitgalaxy/core/spatial_correlation.pyas a shared, reusable primitive (StructuralExtractor._correlate_signalsis now a thin delegating wrapper, kept for existing callers).correlate_scoped(): a target/dampener pair must fall within the same satellite range to correlate; a target outside every known satellite range falls back to the pre-scoping flat behavior, so nothing that correlated before this change stops correlating -- module-level/unsliced code is unaffected.coding_analysis()intoapply_dampener_correlations(), called from_function_slice()'s own per-segment loop right after that segment's satellites are computed -- the one placespatial_mapand real satellite ranges already coexist, with no new cross-referencing needed.start_idx/end_idxto each satellite (FunctionNode), computed but previously discarded in_calculate_block_metrics._function_slice()'s earlyMAX_SATELLITESbreak: that cap bounds stored function metadata, not which code gets correlated -- letting it silently skip correlating the remainder of an unusually large file would have been a regression this fix specifically exists to prevent. Only matters for files with 250+ functions.Test plan
tests/core_engine/test_spatial_correlation.py(12 tests) covering the new primitives in isolation: baselinecorrelate_signalsparity,filter_positions_in_range,correlate_scoped(cross-function rejection, same-function acceptance, module-level fallback, mixed covered/uncovered), andapply_dampener_correlationsfor all three relocated blocks.test_detector_dampeners_do_not_cross_function_boundariesandtest_detector_dampeners_still_apply_within_same_functionintest_detector.py, exercising the fix through the realStructuralExtractor.splice()path. Verified the cross-function test fails on the pre-fix code (0 == 1, proving the false-negative) and passes after.python -m pytest tests/core_engine/ tests/security_auditing/ -q-- 433 passed, 1 xfailed (pre-existing, unrelated).python -m pytest tests/ -q-- full suite, 826 passed, 1 xfailed.🤖 Generated with Claude Code