Skip to content

[METRICS] SignalProcessor's CONTEXT_VIOLATION_MATRIX (archetype secrets-risk multiplier) is dead config #1090

Closed

Description

@squid-protocol

Summary

Spotted while resolving #1053 (a related but separate dead-code cluster in the same class). self.CONTEXT_VIOLATION_MATRIX is assigned in SignalProcessor.__init__ (gitgalaxy/metrics/signal_processor.py:136) but never read anywhere after that assignment -- confirmed via grep -rn "CONTEXT_VIOLATION_MATRIX" gitgalaxy/, which only turns up the assignment itself and its source definition.

Details

Dead assignment: gitgalaxy/metrics/signal_processor.py:136

self.CONTEXT_VIOLATION_MATRIX = security_profiles.get("CONTEXT_VIOLATION_MATRIX", {})

Source config: gitgalaxy/standards/analysis_lens.py:919-925

"CONTEXT_VIOLATION_MATRIX": {
    "Cluster 1: High-Dependency Config & Object Nodes": {
        "secrets_risk_multiplier": 2.0,
    },
},

The comment above it (gitgalaxy/standards/analysis_lens.py:903-910) describes the intent: multiply threat mass based on how anomalous a file's behavior is for its "physical DNA" (its ML-classified archetype) -- e.g. a config/JSON/interface-node archetype should never execute logic or hold secrets casually, so if one does, the secrets-risk score should be amplified.

Extra wrinkle found while investigating (not just "unwired," possibly also mis-keyed): the matrix's only key, "Cluster 1: High-Dependency Config & Object Nodes", does not match any archetype name actually produced anywhere in the engine today:

  • global_archetype (SignalProcessor._classify_archetype against self.GLOBAL_ARCHETYPES, sourced from GENERAL_FILE_INFERENCE_MODEL's ARCHETYPES_K18 in analysis_lens.py) uses generic keys like "file_cluster_0", "file_cluster_1", etc. -- not descriptive names.
  • local_archetype (per-language classification against SPECIFIC_FILE_INFERENCE_MODEL[lang]'s own ARCHETYPES_KN) does use descriptive "Cluster N: <name>" strings, but each language has its own distinct set (e.g. python's ARCHETYPES_K6 has "Cluster 1: Declarative Glue & Initialization", not the config-node name above). A repo-wide grep -n "High-Dependency Config" gitgalaxy/standards/analysis_lens.py turns up exactly one hit: the CONTEXT_VIOLATION_MATRIX definition itself.

So even a naive self.CONTEXT_VIOLATION_MATRIX.get(archetype_name, {}) lookup would never fire for any file with today's data -- the key doesn't correspond to a real, classifiable archetype. Whoever picks this up needs to either (a) find/add a real archetype (global or per-language) that actually represents "config/object/interface nodes" and re-key the matrix to it, or (b) decide the matrix should match on something else entirely (e.g. a fingerprint-distance/similarity threshold rather than literal name equality).

Proposed Resolution

Choose one of:

(Option A) Wire it in for real:

  1. Decide which classification (global_archetype or a specific language's local_archetype) is the right match target -- given the "config nodes never execute logic" framing, this is likely meant to key off local_archetype for config-heavy languages (JSON/YAML/TOML), or a semantic match rather than an exact archetype-name lookup.
  2. Fix the key mismatch described above so a real code path can actually produce a hit.
  3. Consume self.CONTEXT_VIOLATION_MATRIX[...]["secrets_risk_multiplier"] in calculate_risk_vector, feeding it into _calc_secrets_risk (gitgalaxy/metrics/signal_processor.py:1719, currently _calc_secrets_risk(loc, raw_signals, mp)) as a new multiplier parameter -- mirroring the mem_mp pattern [BUG/METRICS] SignalProcessor's ecosystem-context risk multiplier subsystem is dead code #1053 added to _calc_safety.
  4. Add a regression test proving an archetype-flagged file gets a different (higher) secrets-risk score than an unflagged one, analogous to test_signal_processor_ecosystem_mismatch_penalizes_safety in tests/core_engine/test_signal_processor.py.
  5. Per the Differential Scan protocol (CLAUDE.md), verify via python tests/tools/crucible_check.py and re-bless golden masters if output changes.

(Option B) Remove dead code:

  • Delete the self.CONTEXT_VIOLATION_MATRIX assignment (signal_processor.py:136).
  • Remove or repurpose CONTEXT_VIOLATION_MATRIX in gitgalaxy/standards/analysis_lens.py:919-925 -- it shouldn't exist as "documented but unreachable and mis-keyed" config.

References

Activity

  1. added
    bug
    metrics
    refactor
    on Aug 6, 2026
  2. added a commit that references this issue on Oct 3, 2026
  3. added
    scope:infra
    on Oct 16, 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

    bugmetricsrefactorscope:infra

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions