Skip to content

Wire supply chain firewall to SignalProcessor's risk_vector - #302

Merged
squid-protocol merged 1 commit into
mainfrom
fix/unwind-duplicate-risk-exposure-p1
Jul 23, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/unwind-duplicate-risk-exposure-p1

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Jul 23, 2026 •

Copy link
Copy Markdown
Owner

The firewall's behavioral scoring (evaluate_risk on SecurityLens) and SignalProcessor's risk scoring were two independent, disagreeing engines computing risk from the same underlying signals. SecurityLens.evaluate_risk() and its self.policy/ThreatPolicy plumbing are now dead, so run_firewall_audit reads the risk score SignalProcessor already computed at Phase 3 instead of recomputing density from raw equations counts.

  • Replace the equations -> local_counts -> evaluate_risk() block with a one-time schema-index lookup (_FIREWALL_RISK_INDEXES) into SignalProcessor.RISK_SCHEMA, keyed by the same five risk categories the firewall previously gated on.
  • Block threshold is 50.0 (SignalProcessor's own sigmoid midpoint), so the firewall defers to SignalProcessor's judgment rather than maintaining a second, independently-tuned threshold.
  • build_time_multiplier (10x for setup.py/package.json/etc.) now scales the post-sigmoid score rather than pre-sigmoid hit counts, since multiplying raw counts pre-sigmoid and multiplying the sigmoid's output are not equivalent (saturates differently). Treated as a deliberate, tested behavior change rather than an assumed equivalence.
  • The firewall previously read a "dependency_network" key that nothing in the codebase ever wrote (network_multiplier was silently always 1.0 in production); this drops that dead read rather than reproducing it.

Rewrote the 5 tests that exercised the old density-based scoring (test_behavioral_threat_evaluation[_strips_prefix], build/density multiplier tests, memory_corruption_detection) against risk_vector fixtures, with the threshold-crossing math spelled out in each docstring. The other 11 tests in the file exercise only import logic and needed no changes.

Not in this change: the SecurityLens(policy=...)/ThreatPolicy cleanup cascade at the remaining call sites (galaxyscope.py x3, vault_sentinel.py, sbom_recorder.py) and actually wiring up network-centrality/blast-radius weighting (previously inert, so out of scope for a behavior-preserving fix).

Description of Structural Changes

Visual Observatory Testing

  • I tested the output JSON on GitGalaxy.io OR the Airgap Observatory.
  • Flexbox constraints, HUD elements, and 3D rendering remain intact.

The Differential Scan Acknowledgement

  • I understand that my PR will be subjected to a Full Differential Scan.
  • I have provided the link to the specific repository this PR addresses so it can be tested alongside the 80-repo calibrated baseline.
  • I believe these changes will measurably improve the engine's Accuracy, Speed, Utility, or Ethos without causing regressions.

The firewall's behavioral scoring (evaluate_risk on SecurityLens) and
SignalProcessor's risk scoring were two independent, disagreeing engines
computing risk from the same underlying signals. SecurityLens.evaluate_risk()
and its self.policy/ThreatPolicy plumbing are now dead, so run_firewall_audit
reads the risk score SignalProcessor already computed at Phase 3 instead of
recomputing density from raw equations counts.

- Replace the equations -> local_counts -> evaluate_risk() block with a
  one-time schema-index lookup (_FIREWALL_RISK_INDEXES) into
  SignalProcessor.RISK_SCHEMA, keyed by the same five risk categories the
  firewall previously gated on.
- Block threshold is 50.0 (SignalProcessor's own sigmoid midpoint), so the
  firewall defers to SignalProcessor's judgment rather than maintaining a
  second, independently-tuned threshold.
- build_time_multiplier (10x for setup.py/package.json/etc.) now scales the
  post-sigmoid score rather than pre-sigmoid hit counts, since multiplying
  raw counts pre-sigmoid and multiplying the sigmoid's output are not
  equivalent (saturates differently). Treated as a deliberate, tested
  behavior change rather than an assumed equivalence.
- The firewall previously read a "dependency_network" key that nothing in
  the codebase ever wrote (network_multiplier was silently always 1.0 in
  production); this drops that dead read rather than reproducing it.

Rewrote the 5 tests that exercised the old density-based scoring
(test_behavioral_threat_evaluation[_strips_prefix], build/density
multiplier tests, memory_corruption_detection) against risk_vector
fixtures, with the threshold-crossing math spelled out in each docstring.
The other 11 tests in the file exercise only import logic and needed no
changes.

Not in this change: the SecurityLens(policy=...)/ThreatPolicy cleanup
cascade at the remaining call sites (galaxyscope.py x3, vault_sentinel.py,
sbom_recorder.py) and actually wiring up network-centrality/blast-radius
weighting (previously inert, so out of scope for a behavior-preserving fix).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 67c1fd6 into main Jul 23, 2026
22 checks passed
@squid-protocol
squid-protocol deleted the fix/unwind-duplicate-risk-exposure-p1 branch July 23, 2026 00:44
squid-protocol added a commit that referenced this pull request Jul 23, 2026
Follow-up to #302 (which deleted SecurityLens.evaluate_risk() and
self.policy). ThreatPolicy existed solely to build the policy dict that
evaluate_risk() consumed; with that method gone, every _active_policy /
ThreatPolicy.get_policy(...) call site is dead code, and SecurityLens's
policy kwarg is silently ignored (the constructor no longer stores or
reads it).

Re-ran a repo-wide grep for ThreatPolicy/SecurityLens(policy= before
touching anything, per the original cleanup plan, to confirm scope:

- galaxyscope.py (3 sites): worker init, Orchestrator.__init__, and the
  CLI args.paranoid path. Dropped the ThreatPolicy import and the
  _active_policy if/else blocks; SecurityLens(policy=_active_policy) ->
  SecurityLens(). The CLI site's "ZERO-TRUST MODE" log line stays under
  args.paranoid -- PARANOID_MODE is still live via
  SignalProcessor.is_paranoid, only the now-dead policy computation goes.
- vault_sentinel.py, sbom_recorder.py: same import + constructor
  simplification. These call SecurityLens.scan_content(), never
  evaluate_risk(), so they were never broken -- just carrying a policy
  kwarg with no effect.

ThreatPolicy the class itself is left in analysis_lens.py; the grep
confirms it's now only self-referential (the class body and its own
get_policy() classmethod), but deleting the class is a separate call
from cleaning up its callers.

Full test suite: 772 passed, 1 xfailed (pre-existing), 0 failures.

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
squid-protocol added a commit that referenced this pull request Jul 23, 2026
Follow-up to #302's discovery that the firewall's old evaluate_risk() read
a "dependency_network" key nothing ever wrote, so network_multiplier was
silently always 1.0 in production -- a previously-inert feature, never
actually live. This wires it up for real, deliberately, as its own
reviewed change rather than folding it into the #302 refactor.

Design decisions (both discussed and confirmed before implementing):

- Formula: reuse the old evaluate_risk multiplier shape -- starts at 1.0,
  += blast_radius * 0.5 if normalized_blast_radius > 1.0, += 0.5 if
  betweenness_score > 0.05 -- applied post-hoc to the risk_vector score
  (same pattern #302 established for build_time_multiplier). This is an
  only-amplify design: a peripheral, low-centrality file is judged on its
  own merits and never gets a discount; only high-centrality "hub" files
  get less tolerance for the same embedded threat signal.
- Rollout: opt-in via a new FIREWALL_NETWORK_WEIGHTING config flag
  (default False), mirroring Phase 10.5's MAX_SYSTEMIC_THREAT gate (also
  off-by-default). Since this feature never actually ran before, flipping
  it on unconditionally would be a silent behavior change for every
  existing firewall user the moment this ships -- opt-in keeps today's
  behavior unchanged until a repo explicitly turns it on.

Reads file_node["telemetry"]["network_metrics"] (normalized_blast_radius,
betweenness_score), written by network_risk_sensor.build_dependency_graph()
at Phase 4 -- well before the firewall runs at Phase 10, same ordering
guarantee #302 relied on for risk_vector from Phase 3.

Added 3 tests: flag-off-by-default regression guard (proves the default
itself, not just behavior under it), hub-file amplification crossing the
block threshold vs. an identical peripheral file that doesn't, and the
betweenness-only bonus in isolation. Full suite: 775 passed, 1 xfailed
(pre-existing), 0 failures.

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant