Skip to content

[BUG] dev_agent_firewall.py's Metaprogramming Hallucination Risk check reads a doc_density telemetry key that no producer ever writes #345

Closed

Description

@squid-protocol

🛑 Problem Statement

dev_agent_firewall.py's rule 3 ("Metaprogramming Hallucination Risk") is dead code today:

doc_density = file_data.get("telemetry", {}).get("doc_density", 1.0)
if meta_heavy and doc_density < 0.2:

No module anywhere in the codebase ever writes telemetry["doc_density"]. .get() always falls back to its default of 1.0, so doc_density < 0.2 is always False, and guardrails["hallucination_zone"] can never be set to True, regardless of input. This has presumably been silently inert since it was written — no exception, no crash, it just never fires.

This is the same failure shape already tracked in #325 ("keys read by a consumer that no producer ever writes") — filing as a new instance of that pattern, found while scoping #106.

🎯 Objective

Either wire up a real doc_density producer, or (preferred, since #106 is already replacing this rule's logic) retire this dead condition entirely as part of #106's rework rather than carry the phantom key forward.

🛠️ Proposed Implementation

#106 already proposes replacing this rule with a spatially-verified undocumented_metaprogramming metric. Recommend folding this fix into that work rather than patching doc_density in isolation — there's no value in making the old global check "work" if it's about to be replaced by a scoped one. This issue exists mainly to (a) document that the current behavior is fully inert, not just imprecise, so #106 is scoped as "build the first working check," not "improve an existing one," and (b) feed the instance count back into #325.

✅ Acceptance Criteria

Activity

  1. added
    bug
    appsec
    on Jul 24, 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

    appsecbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions