Skip to content

meta['popularity'] is never set before calculate_risk_vector: the popularity terms in documentation, verification, api_exposure and the threat vector are dead #2909

Closed

Description

@squid-protocol

What

SignalProcessor.calculate_risk_vector reads the file's import fan-in as popularity = meta.get("popularity", 0) (signal_processor.py L649) and hands it to four consumers:

consumer term
_calc_documentation network_multiplier = 1.0 + popularity / 10 (L1614)
_calc_verification blast_radius = mp + min(popularity * 0.2, 3.0) (L1712)
_calc_api_exposure network_multiplier = min(1 + log1p(popularity) / 5, 2.0), or the popularity == 0 dampening branch (L1772-1775)
the threat feature vector log_popularity_in = log1p(popularity) (L653, L677)

Nothing ever writes meta["popularity"]. The fan-in lives at meta["telemetry"]["popularity"]: network_risk_sensor.py writes f["telemetry"]["popularity"] = in_d (L441, L580) and galaxyscope.py sets telemetry_payload["popularity"] = self.popularity_scores.get(rel_path, 0) at L2312 — thirty lines after calculate_risk_vector is called at L2282. So every formula above runs with popularity = 0 on every file, every scan.

Evidence

tests/tools/audit_documentation_inputs.py (epic #2908, Phase 0) reproduces every corpus file's recorded risk_documentation from its recorded inputs only with the multiplier off: on the 46-language keyword-rosetta scan, 0 files reproduce with popularity applied and every imported file (a/b/c, DB popularity = 1, score would be ×1.1) reproduces with it at 0. Direct check: data/cpp/a.cpp records 40.61; _calc_documentation with the DB's popularity 1 returns 44.67, with 0 returns 40.61.

_calc_api_exposure is the larger effect: its popularity == 0 branch is a dampener for unimported files, so today every file — imported or not — takes the dampening path, and the "massively popular API surface is amplified" behaviour the docstring describes never happens.

Why it matters for #2908

Decision D4 of the epic removes the popularity multiplier from the documentation formula (blast radius is reported beside the score, not folded into it). This issue means that removal is score-neutral today: the term was never live. For the other three consumers it is a real behaviour change waiting to happen the day someone "fixes" the plumbing, so the fix should be decided per formula, not applied blindly:

  • documentation: drop the term (D4).
  • api_exposure, verification, threat vector: decide whether the multiplier is wanted, then either plumb meta["popularity"] = self.popularity_scores.get(rel_path, 0) before L2282 or delete the dead code. Plumbing it as-is moves risk_api_exposure on every imported file in every golden master, so that is a rosetta:rebless-owed PR with a scoped bless, not a one-liner.

Found while decomposing risk_documentation for #2908; not blocking that epic.

Activity

  1. added
    bug
    metrics
    core-engine
    on Sep 9, 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