Skip to content

_calc_safety: systems_buffer_ratio keyed on fc<1.0 makes tier-2/3 files score SAFER than tier 1 above 6/15 attack hits #2717

Closed

Description

@squid-protocol

Found during the #2653 design pass. Independent of the tier redesign — a defect under any model.

What happens

_calc_safety (signal_processor.py ~L1404) lets the tier in three times with conflicting signs:

systems_buffer_ratio = t.get("systems_buffer_ratio", 0.75) if fc < 1.0 else 1.0
attack  = ((attack_hits + irc) / smoothed_loc) * mp * mem_mp * systems_buffer_ratio
defense = (defense_hits / smoothed_loc) * fc

+irc raises attack, × 0.75 lowers it, × fc lowers defence. Net exposure with defence = 0 is (a + irc) × 0.75 for tier 2/3 vs a for tier 1, so tier 2 crosses below tier 1 at 6 attack-weighted hits and tier 3 at 15, and stays below forever:

attack hits tier 1 tier 2 tier 3
2 2.00 3.00 5.25
6 6.00 6.00 8.25
15 15.00 12.75 15.00
40 40.00 31.50 33.75

Identical evidence scores safest in the language the correction calls loosest, and tier 2 sits below tier 3 at every value.

On real code

Crucible, correction on vs off (TIER_VARS flattened): of the tier-2 files moved on Error & Exception Exposure, 139 are scored safer and 97 more dangerous; tier 3, 453 of 1,335 scored safer. Ten languages have a net-negative safety mean: php −4.89, yacc −3.92, agc_assembly −2.62, c −2.37, javascript −2.15, perl −2.04, cpp −1.85, fortran −1.25, ruby −0.83, scheme −0.19. C and C++ — the languages with the most real implicit memory hazard — get a net discount from the implicit-risk correction. YAML and Makefiles get a memory-safety buffer; Rust does not.

Cause

systems_buffer_ratio (#1055) is a per-language precision discount — C's pointer syntax over-fires the risk rules (36.5 pointer hits / 100 LOC on real C) — that got keyed on fc < 1.0, i.e. "not tier 1", because the tier was the only per-language knob available. Same shape as the rest of #2716: one dial doing a job it wasn't designed for.

Fix

Retire the buffer in #2718, where fc becomes a measured per-signal fidelity coefficient and the over-firing it was compensating for is scaled at the source. Do not re-key the buffer on a systems_language flag as a standalone fix — that keeps a second hand list alive.

Activity

  1. added
    bug
    metrics
    core-engine
    on Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-enginemetrics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions