Skip to content

Dampen Silent Mutation Risk with real test coverage (#373) - #384

Merged
squid-protocol merged 1 commit into
mainfrom
fix/373-has-tests-real-coverage-map
Jul 24, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/373-has-tests-real-coverage-map

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Closes #373. dev_agent_firewall.py's "Cascading State Flux (Silent Mutation Risk)" rule read telemetry["has_tests"], a key no producer anywhere ever wrote -- so not has_tests was always True, and a high-flux, high-in-degree file could never have this guardrail dampened by genuine test coverage, no matter how thoroughly tested it actually was. Unlike most of #325's other findings, this was a false-positive risk, not a false-negative one.

file_data["test_coverage_map"] (galaxyscope.py, backed by network_risk_sensor.py's outbound-call mapping from test files to the production functions they actually invoke) is a real, already-computed signal for exactly this: a non-empty map means at least one function in this file is genuinely exercised by a test. Swapped the dead telemetry read for bool(file_data.get("test_coverage_map", {})).

Test plan

  • The existing Silent Mutation Risk test updated to use test_coverage_map (empty, matching the "still triggers" case it was already proving).
  • New test (test_silent_mutation_risk_dampened_by_real_test_coverage) proving the mirror case -- identical high-flux/high-in-degree conditions, but with real coverage now correctly suppressing the guardrail.
  • Clean Baseline test updated to grant real coverage via test_coverage_map instead of the dead telemetry flag; dropped the now-inert has_tests field from the short-vectors edge case test.
  • tests/dead_key_audit_baseline.json: "has_tests" removed now that it's fixed (python tests/dead_key_audit.py --ci confirmed clean at 5 baselined keys, zero regressions).
  • python -m pytest tests/ -q -- full suite, 860 passed, 1 pre-existing xfail.
  • flake8 . --count --select=E9,F63,F7,F82 -- 0.

🤖 Generated with Claude Code

dev_agent_firewall.py's "Cascading State Flux (Silent Mutation Risk)"
rule read telemetry["has_tests"], a key no producer anywhere ever wrote
-- so `not has_tests` was always True, and a high-flux, high-in-degree
file could never have this guardrail dampened by genuine test coverage,
no matter how thoroughly tested it actually was. Unlike most of #325's
other findings, this was a false-positive risk, not a false-negative one.

file_data["test_coverage_map"] (galaxyscope.py, backed by
network_risk_sensor.py's outbound-call mapping from test files to the
production functions they actually invoke) is a real, already-computed
signal for exactly this: a non-empty map means at least one function in
this file is genuinely exercised by a test. Swapped the dead telemetry
read for bool(file_data.get("test_coverage_map", {})).

Tests: the existing Silent Mutation Risk test updated to use
test_coverage_map (empty, matching the "still triggers" case it was
already proving), plus a new test proving the mirror case -- identical
high-flux/high-in-degree conditions, but with real coverage now
correctly suppressing the guardrail. Also updated the Clean Baseline
test to grant real coverage via test_coverage_map instead of the dead
telemetry flag, and dropped the now-inert has_tests field from the
short-vectors edge case test.

tests/dead_key_audit_baseline.json: "has_tests" removed now that it's
fixed (`python tests/dead_key_audit.py --ci` confirmed clean at 5
baselined keys, zero regressions).

Full suite: 860 passed, 1 pre-existing xfail.

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 849ed4c into main Jul 24, 2026
22 of 23 checks passed
@squid-protocol
squid-protocol deleted the fix/373-has-tests-real-coverage-map branch July 24, 2026 16:17
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.

[BUG/APPSEC] Dev Agent Firewall's Silent Mutation Risk dampener can never be satisfied -- nothing writes telemetry["has_tests"]

1 participant