Skip to content

Remove db_complexity metric from the Structural Extractor - #1021

Merged
squid-protocol merged 2 commits into
mainfrom
fix-db-complexity-metric-1013
Aug 4, 2026
Merged

Remove db_complexity metric from the Structural Extractor#1021
squid-protocol merged 2 commits into
mainfrom
fix-db-complexity-metric-1013

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

  • db_complexity didn't measure database complexity at all -- it summed unrelated io (x3), serialization_parsing (x2), and state_mutation (x1) signature hits, so any IO-heavy or mutation-heavy function scored as "DB complex" with zero database/ORM involvement.
  • Removed from detector.py (schema + calculation) and every downstream consumer it had spread to beyond what the issue's checklist covered: network_risk_sensor.py (dead graph-node attribute, never read), signal_processor.py (DoS-score amplifier + max_db_complexity telemetry), ai_appsec_sensor.py (was an alternate trigger condition in the "Over-Permissioned Agent" security rule -- now gated on the real arch_io signal instead), and the SQLite schemas/report sections in record_keeper.py and llm_recorder.py.
  • Per the linked issue, deliberately did not replace it with another AST-less regex heuristic for database complexity -- that would just trade one false-positive generator for another.

Test plan

  • python -m pytest tests/ -- 5451 passed, 0 failed
  • python tests/tools/audit_check.py -- clean (ruff baseline regenerated, all pure line-shifts; mypy/dead-key unaffected)
  • ruff format --check -- clean
  • Updated fixtures/assertions in test_signal_processor.py, test_ai_appsec_sensor.py, test_record_keeper.py, test_llm_recorder.py to match; one DoS-score threshold recalibrated since it was tuned assuming the now-removed amplifier

Closes #1013.

🤖 Generated with Claude Code

db_complexity never actually looked for databases -- it summed unrelated
io (x3), serialization_parsing (x2), and state_mutation (x1) signature hits
and called the result "database complexity," so any IO-heavy or
mutation-heavy function scored as DB-complex regardless of whether a
database or ORM was involved.

Removes the metric from detector.py (FunctionNode schema + calculation)
and every downstream consumer it had spread to: the dead graph-node
attribute in network_risk_sensor.py, the DoS-score amplifier and
max_db_complexity telemetry in signal_processor.py, the
"Over-Permissioned Agent" security heuristic in ai_appsec_sensor.py (now
gated on the real arch_io signal instead), and the SQLite schemas/report
sections in record_keeper.py and llm_recorder.py.

Closes #1013.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

Fixes Muninn scan findings on PR #1021:
- GHSA-g6cj-pr64-35w5 (CVE-2026-69247): PKCS#7 EnvelopedData decryption
  exposed a Bleichenbacher oracle through distinguishable errors/timing
- GHSA-jwv3-5hgf-82ww (CVE-2026-69249): duplicate self-signed
  intermediates could cause exponential path-building
- GHSA-m2h6-j472-rp4c (CVE-2026-69248): verifier accepted wildcard DNS
  names that escape permittedSubtrees constraints

No code in this repo imports the cryptography package directly (only a
keyword-string reference in analysis_lens.py's security lexicon), so
this is a transitive-dependency bump with no API surface to verify.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@squid-protocol
squid-protocol merged commit 9b0614c into main Aug 4, 2026
26 of 28 checks passed
@squid-protocol
squid-protocol deleted the fix-db-complexity-metric-1013 branch August 4, 2026 13:51
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.

Remove db_complexity metric from the Structural Extractor

1 participant