Skip to content

[BUG/APPSEC] Dev Agent Firewall's Agentic Black Hole check reads "max_big_o" off file_data, but it only ever lives on a networkx graph node #372

Closed

Description

@squid-protocol

🛑 Problem Statement

Found by the dead key auditor (#325). gitgalaxy/tools/ai_guardrails/dev_agent_firewall.py:42:

max_big_o = file_data.get("max_big_o") or 1

This is used in the "Context Window Exhaustion (Agentic Black Hole)" rule:

if token_mass is not None and token_mass > 8000 and max_big_o >= 3:

The only producer of max_big_o is gitgalaxy/core/network_risk_sensor.py:191, which sets it as a networkx graph node attribute:

G.add_node(path, ..., max_big_o=max_big_o, ...)

That value never gets copied back onto file_data/self.parsed_files -- network_risk_sensor.py itself reads it back correctly (G.nodes[path].get("max_big_o", 1), line 284), but dev_agent_firewall.py is a different consumer reading a different object (file_data, not the graph) at a later pipeline phase. max_big_o is always 1 there, so the max_big_o >= 3 half of this guardrail's condition can never be true -- the Agentic Black Hole rule only ever fires on token_mass alone.

🎯 Objective

The Agentic Black Hole guardrail should be able to fire on genuinely high-complexity files, not just high-token-count ones.

🛠️ Proposed Implementation

Thread max_big_o from the networkx graph node back onto each file's file_data dict (similar to how telemetry/network_metrics are already copied back after build_dependency_graph() runs), before DevAgentFirewall.evaluate_ecosystem() reads it in Phase 5.

✅ Acceptance Criteria

  • A file with real O(N^3)+ complexity and high token mass triggers is_agentic_black_hole, proven by a test using the real pipeline (not a hand-built mock file_data dict).
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

    appsecbugpriority: medium

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions