Repository navigation
Description
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_archetypeagainstself.GLOBAL_ARCHETYPES, sourced fromGENERAL_FILE_INFERENCE_MODEL'sARCHETYPES_K18inanalysis_lens.py) uses generic keys like"file_cluster_0","file_cluster_1", etc. -- not descriptive names.local_archetype(per-language classification againstSPECIFIC_FILE_INFERENCE_MODEL[lang]'s ownARCHETYPES_KN) does use descriptive"Cluster N: <name>"strings, but each language has its own distinct set (e.g. python'sARCHETYPES_K6has"Cluster 1: Declarative Glue & Initialization", not the config-node name above). A repo-widegrep -n "High-Dependency Config" gitgalaxy/standards/analysis_lens.pyturns up exactly one hit: theCONTEXT_VIOLATION_MATRIXdefinition 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:
- Decide which classification (
global_archetypeor a specific language'slocal_archetype) is the right match target -- given the "config nodes never execute logic" framing, this is likely meant to key offlocal_archetypefor config-heavy languages (JSON/YAML/TOML), or a semantic match rather than an exact archetype-name lookup. - Fix the key mismatch described above so a real code path can actually produce a hit.
- Consume
self.CONTEXT_VIOLATION_MATRIX[...]["secrets_risk_multiplier"]incalculate_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 themem_mppattern [BUG/METRICS] SignalProcessor's ecosystem-context risk multiplier subsystem is dead code #1053 added to_calc_safety. - 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_safetyintests/core_engine/test_signal_processor.py. - Per the Differential Scan protocol (CLAUDE.md), verify via
python tests/tools/crucible_check.pyand re-bless golden masters if output changes.
(Option B) Remove dead code:
- Delete the
self.CONTEXT_VIOLATION_MATRIXassignment (signal_processor.py:136). - Remove or repurpose
CONTEXT_VIOLATION_MATRIXingitgalaxy/standards/analysis_lens.py:919-925-- it shouldn't exist as "documented but unreachable and mis-keyed" config.
References
gitgalaxy/metrics/signal_processor.py:136(dead assignment),:1719(_calc_secrets_risk, the natural consumer)gitgalaxy/standards/analysis_lens.py:903-925(CONTEXT_VIOLATION_MATRIXdefinition + intent comment)- Related: [BUG/METRICS] SignalProcessor's ecosystem-context risk multiplier subsystem is dead code #1053 (ecosystem-mismatch subsystem, same class of dead-config bug, resolved mismatch-only), [METRICS] Wire ECOSYSTEM_MISMATCH_WEIGHTS injection penalty into security_auditor.py taint tracking #1089 (follow-up on that fix's deferred
injectionkey)
Activity
Signal hygiene: #1090 + #4238 + #4239 (#4258)