Repository navigation
Description
Description
Issue #1055 exposed a concrete, empirically-proven miscalibration in _calc_safety(): the
systems_buffer = 0.25 flat subtraction causes identical attack evidence (same danger-signal
hit count, same file size) to score 52-66 in tier1 languages (Rust) but only 5-8 in tier2/tier3
languages (Python, Bash) — an 8-10x distortion driven purely by language tier, not actual risk.
This was proven by calling SignalProcessor._calc_safety() directly with controlled synthetic
inputs, not by code-reading or reverse-engineering the golden-master fixture.
Given that one of roughly 14 tier-aware risk-exposure equations in SignalProcessor already had
a proven tier-driven distortion this large, the other tier-aware equations have not been checked
the same way and may have similar (or differently-shaped) miscalibrations — e.g., a constant
dimensionally mismatched with what it's combined with, the way systems_buffer was.
This epic tracks a systematic audit of all tier-aware equations using the same empirical method
that found #1055, to identify and flag real miscalibrations before they warp the risk scores for
real-world scans.
Equations in Scope
Tier-aware risk-exposure equations in gitgalaxy/metrics/signal_processor.py:
_calc_cog_load(lines ~1200–1250)_calc_safety(lines ~1350–1388) — known miscalibration via [BUG/METRICS] safety_score's tier2/tier3 systems_buffer flat subtraction wipes attack signal #1055_calc_tech_debt(lines ~1400–1440)_calc_documentation(lines ~1450–1490)_calc_verification(lines ~1500–1540)_calc_graveyard(lines ~1550–1590)_calc_api_exposure(lines ~1600–1640)_calc_concurrency(lines ~1650–1690)_calc_state_flux(lines ~1700–1740)_calc_spec_alignment(lines ~1750–1790)_calc_civil_war(lines ~1800–1840)_calc_secrets_risk(lines ~1850–1890)- (Temporal/ownership functions do not take tier inputs, excluded from this audit)
Correction (post-audit): 5 of the equations above (_calc_graveyard, _calc_api_exposure,
_calc_spec_alignment, _calc_civil_war, _calc_secrets_risk) turned out, on reading the actual
code rather than this list's approximate line ranges, to take no fc/irc/ot at all — they
cannot exhibit tier-driven distortion by construction. See the Progress Checklist for the
per-equation breakdown.
Audit Methodology
For each risk-exposure equation in scope:
-
Direct method invocation: Call the actual
_calc_*()method as a standalone script or
pytest parametrized test with controlled syntheticraw_signals/locinputs held identical
acrosstier1,tier2, andtier3language assignments — not by trying to reverse-engineer
scores from recorder/fixture output. -
Sweep realistic ranges: For each equation's relevant input signals:
- File LOC: 50, 150, 500 (small, medium, large)
- Signal-hit counts: low/medium/high density appropriate to that equation's domain
- Test each tier1/tier2/tier3 combination with identical raw inputs
-
Compare scores across tiers: For the same synthetic evidence, flag any equation where
tier alone causes:- A large score swing (e.g., >5x distortion for identical signals)
- Non-linear or discontinuous behavior not attributable to an intentional, clearly-documented
design choice (as opposed to a stray constant or dimensional mismatch likesystems_buffer)
-
File sub-issues for real miscalibrations: For each equation found to have a tier-driven
miscalibration, open a focused bug issue (following the [BUG/METRICS] safety_score's tier2/tier3 systems_buffer flat subtraction wipes attack signal #1055 pattern: empirical proof table- root cause + proposed fix direction), linked back to this epic.
-
Mark equations as audited: For equations that check out fine (proportional, sensible tier
scaling), briefly note that in this epic's checklist as "audited, no issue found" so the
epic's progress reflects completed vs. remaining work.
Verification & Integration
Per CLAUDE.md's Differential Scan protocol:
- Any fix to
signal_processor.py's risk equations requires verification via
python tests/tools/crucible_check.pybefore pushing - Golden-master re-blessing via
python tests/tools/update_golden_master.pywith explanation
in each PR description - Scores for tier2/tier3 languages will likely shift in the golden-master corpus
Progress Checklist
Complete. All 11 equations audited; both real miscalibrations found (#1055, #1098) have
shipped fixes.
Audited via tests/tools/audit_risk_equations.py (#1097): direct-invocation sweep, LOC ∈
{10,20,50,150,500} × hit-density {1,3,8} × tier1/2/3, checking both DIRECTION (tier1 must never
score above tier2/tier3 for identical evidence — the specific shape #1055 got backwards) and
MAGNITUDE (>5x ratio flag). Equations with an Fc-gated defense term got a second "defense-only"
scenario, not just risk-only. See the audit comment below for full results.
-
_calc_cog_load— audited, no issue found (direction correct, ratios ≤2.6x, small-file
floor at LOC<15 works as designed) -
_calc_safety— miscalibration found (see [BUG/METRICS] safety_score's tier2/tier3 systems_buffer flat subtraction wipes attack signal #1055, fixed in PR fix(metrics): safety_score tier2/tier3 systems_buffer is now proportional, not a flat subtraction #1067) -
_calc_tech_debt— audited, no issue found (direction correct, ratios ≤1.9x) -
_calc_documentation— miscalibration found (see [BUG/METRICS] documentation_risk lacks LOC-smoothing, causing up to 8.4x tier1-vs-tier3 divergence at small files #1098, fixed in PR metrics: add small-file smoothing to _calc_documentation density #1100): defense
scenario swung up to 8.4x at small files — missing LOC-smoothing, unlike its
_calc_safety/_calc_concurrency/_calc_state_fluxsiblings -
_calc_verification— audited, no hard issue found; soft observation:ot(opacity tax)
only produces a 1.0–1.6x spread even at its most sensitive inputs and gets fully swallowed
by the shared 80.0 breach-cap at high severity — may be under-differentiating relative to
the documented "significantly more defensive effort" framing. Not filing a sub-issue for
this alone; flagging for awareness/future revisit. -
_calc_graveyard— N/A: confirmed tier-blind by construction (nofc/irc/otin
signature — only takesmp, which is path-derived, not tier-derived) -
_calc_api_exposure— N/A: confirmed tier-blind by construction (same as above) -
_calc_concurrency— audited, no issue found (direction correct viairc, ratios ≤1.4x) -
_calc_state_flux— audited, no issue found (direction correct viairc, ratios ≤1.3x) -
_calc_spec_alignment— N/A: confirmed tier-blind by construction (same as above) -
_calc_civil_war— N/A: confirmed tier-blind by construction (takes onlyraw_signals,
no tier or path modifier at all) -
_calc_secrets_risk— N/A: confirmed tier-blind by construction (same as above)
References
- File:
gitgalaxy/metrics/signal_processor.py - Tier classification: based on
fc(feature-count ratio) incalculate_risk_vector - Related: [BUG/METRICS] safety_score's tier2/tier3 systems_buffer flat subtraction wipes attack signal #1055 (concrete safety_score miscalibration that motivated this audit)
- Root pattern: similar to epic Epic: Remove overreaching AST-less heuristic metrics (post-db_complexity wave) #1025 (removing overreaching metrics) — don't fake precision the
architecture can't support
Activity
squid-protocol commentedon Aug 6, 2026
Audit complete for all 11 remaining equations
Ran the direct-invocation methodology this epic specifies against every equation in scope, using
a new reusable harness:
tests/tools/audit_risk_equations.py(PR #1097).Methodology note beyond what's in the epic body: a pure magnitude-ratio check isn't enough to
catch what actually matters here. Per the documented Universal Exposure Framework philosophy
(
08-01-methodology,03-02-claim-2-explicitness,08-03-transforming-regex-counts):Ircis meant as an additive opacity baseline (implicit languages should carry residual riskeven absent detected danger), and
Fcis meant to discount defense credit for implicitlanguages ("a 'Safe' rating in Shell requires significantly more defensive effort than in Go").
That means the real correctness bar is direction: tier1 (explicit) should never score above
tier2/tier3 for identical evidence, in either a risk-only or a defense-only scenario. #1055's bug
was exactly a direction violation — Rust scored 52-66 while Python scored 5-8 for the same
attack evidence, backwards from what Irc/Fc are supposed to do. So the harness checks direction
explicitly (tier1 ≤ tier2 ≤ tier3, flagged as
DIRECTION VIOLATIONif broken) as a separate,more important signal than the magnitude ratio — a magnitude flag says "big swing," a direction
flag says "swing points the wrong way, like #1055 did." It also stress-tests down to 10-20 LOC,
not just the 50-500 range, since #1055's flat constant was most severe exactly at the small-file
end.
Results
No direction violations anywhere — all 6 genuinely tier-aware equations correctly keep
tier1 ≤ tier2 ≤ tier3 for identical evidence, in every scenario tested. Nothing else is
backwards the way
_calc_safetywas.One real magnitude miscalibration found:
_calc_documentation's defense scenario swings upto 8.38x between tier1 and tier3 for identical documentation evidence at small files (10-20
LOC) — filed as #1098, with a concrete root cause (it's the only tier-aware equation of the
six lacking a
_calc_safety-style LOC-smoothing term) and fix direction.One soft observation, not filed as its own issue:
_calc_verification'sot(opacity tax)only produces a 1.0–1.6x tier spread even at its most sensitive inputs, and gets fully swallowed
by the shared 80.0 breach-cap at high severity. That's the opposite failure mode from #1055
(under- rather than over-differentiation) and a much softer harm (weak signal, not false
confidence), so I'm flagging it here for awareness rather than opening a bug — worth a revisit if
this epic's methodology gets reused later.
5 of the 11 equations turned out not to be tier-parameterized at all
(
_calc_graveyard,_calc_api_exposure,_calc_spec_alignment,_calc_civil_war,_calc_secrets_risk) — confirmed by reading the actual code (not the epic's approximate lineranges) plus a mechanical
inspect.signaturecheck the harness runs automatically. They take nofc/irc/ot, so tier cannot influence their output by construction. Checklist updated toreflect this correction.
Full per-equation results and the empirical proof tables are in PR #1097 and issue #1098
respectively. This closes out audit coverage for the whole epic scope — the only open follow-up
work is #1098's fix itself.
tools: add direct-invocation tier-parity audit harness for epic #1056 (…
squid-protocol commentedon Aug 6, 2026
Epic complete
Audit coverage (documented in the comment above, via
tests/tools/audit_risk_equations.py,PR #1097) found exactly two real tier-driven miscalibrations across all 11 in-scope equations,
and both now have shipped fixes:
_calc_safety— [BUG/METRICS] safety_score's tier2/tier3 systems_buffer flat subtraction wipes attack signal #1055, fixed in PR fix(metrics): safety_score tier2/tier3 systems_buffer is now proportional, not a flat subtraction #1067 (systems_bufferflat-subtraction bug — directionviolation, Rust scoring above Python/Bash for identical attack evidence).
_calc_documentation— [BUG/METRICS] documentation_risk lacks LOC-smoothing, causing up to 8.4x tier1-vs-tier3 divergence at small files #1098, fixed in PR metrics: add small-file smoothing to _calc_documentation density #1100 (missing small-file LOC-smoothing, up to8.4x tier1-vs-tier3 magnitude divergence at 10-20 LOC files). Also added the zero-return guard
noted in [BUG/METRICS] documentation_risk lacks LOC-smoothing, causing up to 8.4x tier1-vs-tier3 divergence at small files #1098 so a genuinely risk-free file returns a true
0.0instead of the sigmoid's~11.92 floor, matching the convention already used by
_calc_safety/_calc_concurrency/_calc_graveyard/_calc_secrets_risk. Golden masters re-blessed for both fixes per theDifferential Scan protocol.
The remaining 9 equations checked out clean (correct tier1 ≤ tier2 ≤ tier3 direction, no
magnitude flags beyond documented design choices), or are confirmed tier-blind by construction
(
_calc_graveyard,_calc_api_exposure,_calc_spec_alignment,_calc_civil_war,_calc_secrets_risk— none takefc/irc/ot).One soft, non-blocking observation was logged rather than filed as a bug:
_calc_verification'sot(opacity tax) only produces a 1.0–1.6x tier spread even at its most sensitive inputs andgets fully swallowed by the shared 80.0 breach-cap at high severity — worth a revisit if this
audit methodology gets reused, but it's under- rather than over-differentiation (the opposite,
softer failure mode from #1055/#1098).
tests/tools/audit_risk_equations.py(PR #1097) stays in the repo as a reusable harness forfuture tier-aware equation work.
Closing.