Skip to content

[BUG/METRICS] Double-counting of high_risk_execution between cognitive_load and safety_score #1052

Closed

Description

@squid-protocol

Problem

The high_risk_execution raw signal is being counted twice in the risk exposure calculations, artificially inflating cumulative risk without adding new information:

Cognitive Load Dimension (_calc_cog_load):

  • Small-file path (line ~1299): Included directly in the total_density sum alongside branch/state_mutation/concurrency/reflection_metaprogramming
  • Main path (lines ~1319, 1326): Computed as danger_density = raw_signals.get("high_risk_execution", 0) / safe_loc, then weighted by danger_mult (default 5.0) and added to heavy_logic uncapped

Safety Score Dimension (_calc_safety):

  • Line ~1355: high_risk_execution is weighted highest at danger_weight (default 4.0)
  • Lines ~1365-1366: Function short-circuits to 0.0 if attack_hits == 0, making high_risk_execution the gating signal; without it, safety_score literally doesn't exist
  • This is the signal's "home" dimension by design

Impact: A single dangerous call (e.g., eval(), exec(), shell execution) gets counted heavily in both cognitive_load and safety_score. When these dimensions are summed in generate_forensic_report's get_cumulative_risk (lines ~1787-1794), the evidence is double-weighted, compressing the risk axis and reducing signal fidelity on other structural dangers that should be independently significant.

Proposed Fix

Remove high_risk_execution/danger_density from _calc_cog_load:

  1. Delete from small-file early-return density sum (~line 1299)
  2. Delete from main-path heavy_logic sum (~lines 1323-1327)

Note: verification dimension's minor use of high_risk_execution as an unweighted addend (see _calc_verification) was reviewed and accepted as out-of-scope; only the cognitive_load usage is the problem.

Test & Verification

Per the Differential Scan protocol (CLAUDE.md), any change to signal_processor.py's risk equations must:

  1. Be verified locally with python tests/tools/crucible_check.py before pushing
  2. Include a golden-master re-bless via python tests/tools/update_golden_master.py with explanation in the PR description
  3. This will shift cognitive_load and cumulative_risk scores across the golden-master test corpus

References

  • signal_processor.py lines 1278-1348 (_calc_cog_load)
  • signal_processor.py lines 1350-1388 (_calc_safety)
  • CLAUDE.md "Differential Scan" section

Activity

  1. added
    bug
    metrics
    on Aug 5, 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

    bugmetrics

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions