Skip to content

[BUG/METRICS] SignalProcessor's ecosystem-context risk multiplier subsystem is dead code #1053

Closed

Description

@squid-protocol

Summary

An entire "ecosystem context violation" subsystem in SignalProcessor is fully implemented but never wired into the active risk calculation path — dead code, not merely unused config.

Details

Dead method: _get_context_multipliers(self, file_lang, folder_lang) (lines 169-211 in gitgalaxy/metrics/signal_processor.py)

This method:

  • Classifies a file's language ecosystem vs. its surrounding folder's ecosystem (via self.ECOSYSTEMS)
  • Detects architectural mismatches (e.g., "systems_in_web" or "web_in_systems")
  • Looks up self.ECOSYSTEM_MISMATCH_WEIGHTS to apply penalty multipliers keyed by "memory", "state_mutation", "injection"
    • Example: ECOSYSTEM_MISMATCH_WEIGHTS["web_in_systems"]["state_mutation"] = 3.0 (described in comment as "JS embedded in C firmware = Bizarre architecture", line 131)
  • Logs a 🚨 CONTEXTUAL MISMATCH DETECTED warning (lines 206-209) that can never fire
  • Is never called anywhere in the codebase (verified via grep -r "_get_context_multipliers")

Dead assignments:

  • self.CONTEXT_VIOLATION_MATRIX is assigned in __init__ at line 136 via security_profiles.get("CONTEXT_VIOLATION_MATRIX", {}) but is never read anywhere after that assignment (verified via grep -r "CONTEXT_VIOLATION_MATRIX")
  • Both CONTEXT_VIOLATION_MATRIX and ECOSYSTEM_MISMATCH_WEIGHTS are defined in gitgalaxy/standards/analysis_lens.py (lines 912 and 920) with accompanying docstrings, implying they should be active

Why this is likely incomplete integration, not scaffolding:

The return dict from _get_context_multipliers shares key overlap with the mp_map dict that _calc_state_flux actually consumes:

  • Line ~465: mp_map = self._get_locational_multipliers(rel_path) (path-regex-based multipliers)
  • Line ~720: mp_map.get("state_mutation", 1.0) passed as the mp arg to _calc_state_flux
  • Both dicts have compatible shapes ({"memory": float, "state_mutation": float, "injection": float} etc.)

The architectural intent appears to be: merge ecosystem-mismatch multipliers into mp_map before downstream consumption, but that wiring was dropped or never completed.

Net effect: The class docstring promises "Context vs. Entity Matrix" risk amplification (e.g., a native systems-language file with memory-unsafe patterns embedded inside a web-ecosystem directory should get its "memory" risk boosted), but it never happens in production — every file is treated identically regardless of cross-ecosystem context.

Proposed Resolution

Choose one of:

(Option A) Wire the subsystem in:

  • Call _get_context_multipliers(file_lang, folder_lang) in calculate_risk_vector
  • Merge its output into mp_map (or replace relevant keys) before passing to _calc_state_flux, _calc_safety, and any injection-relevant risk equation
  • Add a regression test proving ecosystem-mismatch files get different scores than native ones

(Option B) Remove dead code:

  • Delete _get_context_multipliers method (lines 169-211)
  • Remove self.CONTEXT_VIOLATION_MATRIX assignment (line 136)
  • Remove self.ECOSYSTEM_MISMATCH_WEIGHTS assignment (lines 125-133) OR keep it only if it's referenced elsewhere
  • Confirm whether ECOSYSTEM_MISMATCH_WEIGHTS and CONTEXT_VIOLATION_MATRIX in gitgalaxy/standards/analysis_lens.py should also be pruned (they shouldn't exist if the behavior is never implemented)

Golden-Master Impact Note

Per the Differential Scan protocol in CLAUDE.md: if Option A is chosen and _get_context_multipliers output changes calculate_risk_vector's return values for any file in the golden-master corpus, the change requires:

  1. Local verification via python tests/tools/crucible_check.py --update
  2. Re-blessing via python tests/tools/update_golden_master.py
  3. Explanation of the change in the PR description

References

Activity

  1. added
    bug
    metrics
    refactor
    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

    bugmetricspriority: mediumrefactor

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions