Repository navigation
fix(metrics): safety_score tier2/tier3 systems_buffer is now proportional, not a flat subtraction - #1067
Merged
Conversation
…tional discount, not a flat subtraction _calc_safety() subtracted a flat systems_buffer (0.25) from net_exposure for any language with fc < 1.0 (tier2/tier3: Python, JS, C/C++, Ruby, Kotlin, PHP, and everything else). Since net_exposure for real files is normally well under 0.25, the flat subtraction wiped out nearly all attack signal instead of tempering it -- a Rust file and a Python file with the identical single dangerous-execution hit (eval/os.system/etc.) scored 52-66 vs 5-7 on the same LOC. Replace it with a proportional discount (systems_buffer_ratio, default 0.75) applied directly to the attack density before it's compared against defense, so a small attack signal takes a small absolute hit and a large one takes a proportionally larger one -- neither is erased outright. This intentionally shifts safety_score (and cumulative_risk) upward for a large fraction of non-tier1-language files in the corpus, so both golden master fixtures were re-blessed via update_golden_master.py per the Differential Scan protocol; crucible_check.py passes clean in both modes. Fixes #1055 Co-Authored-By: Claude Sonnet 5 <[email protected]>
Contributor
12 tasks done
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
_calc_safety()ingitgalaxy/metrics/signal_processor.pysubtracted a flatsystems_buffer(0.25) fromnet_exposurefor any language withfc < 1.0(tier2/tier3: Python, JS, C/C++, Ruby, Kotlin, PHP, and everything else). Since real files typically havenet_exposurewell under 0.25, this flat subtraction wiped out nearly all attack signal instead of tempering it — identical dangerous-execution evidence (e.g. oneeval()/os.system()call) scored 52-66 on a Rust file but only 5-7 on a Python file of the same size.systems_buffer_ratio, default0.75) applied to the attack density itself before comparing against defense, so small signal takes a small hit and large signal takes a proportionally larger one — never erased outright.systems_buffer→systems_buffer_ratioingitgalaxy/standards/analysis_lens.py'sRISK_EQUATION_TUNING["safety"].Why the fixture diffs
This intentionally shifts
safety_score(andcumulative_risk) upward for a large fraction of non-tier1-language files in the corpus — that's the whole point of the fix. Per the Differential Scan protocol inCLAUDE.md, both golden master fixtures were regenerated withpython tests/tools/update_golden_master.py --yes(once per mode, using.crucible_venvs/{full_precision,zero_dependency}) and re-verified clean withpython tests/tools/crucible_check.py.Fixes #1055
Test plan
python -m pytest tests/core_engine/test_signal_processor.py -q— 51 passedpython -m pytest tests/ -q— 5447 passed, 2 skipped, 11 xfailed, 3 xpassed, 0 failedpython tests/tools/crucible_check.py— full_precision PASS, zero_dependency PASSpython tests/tools/audit_check.py --regenerate— ruff/mypy/dead-key all clear (2 pure line-shift findings absorbed)ruff format --checkon both edited files — already formatted🤖 Generated with Claude Code