Skip to content

fix(metrics): safety_score tier2/tier3 systems_buffer is now proportional, not a flat subtraction - #1067

Merged
squid-protocol merged 1 commit into
mainfrom
fix-1055-safety-systems-buffer
Aug 5, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix-1055-safety-systems-buffer

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

  • _calc_safety() in gitgalaxy/metrics/signal_processor.py 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 real files typically have net_exposure well under 0.25, this flat subtraction wiped out nearly all attack signal instead of tempering it — identical dangerous-execution evidence (e.g. one eval()/os.system() call) scored 52-66 on a Rust file but only 5-7 on a Python file of the same size.
  • Replaced the flat subtraction with a proportional discount (systems_buffer_ratio, default 0.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.
  • Renamed the tuning key systems_buffer → systems_buffer_ratio in gitgalaxy/standards/analysis_lens.py's RISK_EQUATION_TUNING["safety"].

Why the fixture diffs

This intentionally shifts safety_score (and cumulative_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 in CLAUDE.md, both golden master fixtures were regenerated with python tests/tools/update_golden_master.py --yes (once per mode, using .crucible_venvs/{full_precision,zero_dependency}) and re-verified clean with python tests/tools/crucible_check.py.

Fixes #1055

Test plan

  • python -m pytest tests/core_engine/test_signal_processor.py -q — 51 passed
  • python -m pytest tests/ -q — 5447 passed, 2 skipped, 11 xfailed, 3 xpassed, 0 failed
  • python tests/tools/crucible_check.py — full_precision PASS, zero_dependency PASS
  • python tests/tools/audit_check.py --regenerate — ruff/mypy/dead-key all clear (2 pure line-shift findings absorbed)
  • ruff format --check on both edited files — already formatted

🤖 Generated with Claude Code

…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]>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit feebeb7 into main Aug 5, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the fix-1055-safety-systems-buffer branch August 5, 2026 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG/METRICS] safety_score's tier2/tier3 systems_buffer flat subtraction wipes attack signal

1 participant