Skip to content

Remove big_o_depth and is_recursive complexity metrics from the risk engine - #1032

Merged
squid-protocol merged 1 commit into
mainfrom
fix-big-o-depth-is-recursive-1014
Aug 4, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix-big-o-depth-is-recursive-1014

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

  • Removes the big_o_depth (indentation-based Big-O tracker) and is_recursive (name-occurrence-count heuristic) metrics engine-wide: both generate systematic false positives, since whitespace geometry doesn't measure algorithmic complexity, and counting a function's own name inside its body triggers on docstrings, comments, logging statements, and standard patterns like super().setUp().
  • Deletes both fields from FunctionNode and the indentation/name-scanning logic in detector.py, plus the complexity_multiplier they fed into the function magnitude/impact score (now just (branch_hits + 1) * arg_multiplier + 0.05*effective_loc, no fake complexity term).
  • Removes every downstream consumer beyond the issue's own checklist, found via grep (same discipline as Remove db_complexity metric from the Structural Extractor #1013's PR):
    • network_risk_sensor.py: the whole "Algorithmic Network Bottleneck" feature (max_big_o/is_recursive graph node attrs, is_algorithmic_bottleneck telemetry field) in both the full-precision and Zero-Dependency Mode paths — no other consumer existed for it.
    • signal_processor.py: the max_algorithmic_complexity telemetry string, the Big-O term in the documentation-risk "opaque execution" formula (now gated on impact > 50.0 alone), and the concurrency "resource exhaustion guard" starvation multiplier (removed entirely, along with the now-unused functions parameter on _calc_concurrency).
    • llm_recorder.py / record_keeper.py: the SQLite schema columns and report sections built on these fields (llm_recorder.py's "8.5 ALGORITHMIC & DATABASE BOTTLENECKS" section had already lost its DB half in Remove db_complexity metric from the Structural Extractor #1013's PR — removing the algorithmic half removes the section entirely).
    • dev_agent_firewall.py's Context Window Exhaustion gate — now triggers on token_mass alone, consistent with Remove db_complexity metric from the Structural Extractor #1013's precedent of not inventing a replacement AST-less heuristic.
  • Updates the two wiki pages (08-09-documentation-risk.md, 08-15-concurrency-exposure.md) and the CLAUDE.md/ANTIGRAVITY.md self-scan-DB example queries that referenced these fields.

This is sub-issue #1014 of epic #1025, next after #1015 (merged via #1029) since algorithmic_dos was mathematically built on big_o_depth.

Closes #1014.

Test plan

  • python -m pytest tests/ — 5444 passed, 0 failed, 2 skipped, 11 xfailed, 3 xpassed
  • python tests/tools/audit_check.py --regenerate — clean (ruff/mypy baselines regenerated, all pure line-shifts from removed code)
  • ruff format --check — clean
  • Golden master fixtures regenerated via python tests/tools/update_golden_master.py in both full-precision and zero-dependency venvs (.crucible_venvs/) — diff is magnitude/impact and the concurrency/documentation risk scores shifting downward across the corpus now that the fake complexity multipliers are gone; crucible_check.py passes clean on both modes after blessing.

🤖 Generated with Claude Code

…engine

- Deletes the indentation-based Big-O tracker and the name-occurrence-count
  recursion heuristic in detector.py, plus the FunctionNode fields they fed.
  Both generated systematic false positives: whitespace geometry doesn't
  measure algorithmic complexity, and counting a function's own name inside
  its body triggers on docstrings, comments, logging, and super().setUp()
  patterns.
- Removes every downstream consumer beyond the issue's own checklist, found
  via grep: the magnitude/impact complexity_multiplier in detector.py, the
  "Algorithmic Network Bottleneck" feature in network_risk_sensor.py (a
  networkx graph attribute + telemetry field with no other consumer),
  signal_processor.py's max_algorithmic_complexity telemetry string, the
  big-O term in the documentation-risk "opaque execution" formula, the
  concurrency "resource exhaustion guard" starvation multiplier, and
  dev_agent_firewall.py's Context Window Exhaustion gate (now token_mass
  alone, consistent with #1013's choice not to invent a replacement
  AST-less heuristic).
- Updates the two wiki pages and CLAUDE.md/ANTIGRAVITY.md self-scan-DB
  example queries that referenced these fields.

This is sub-issue #1014 of epic #1025, next after #1015 since algorithmic_dos
(#1015, merged via #1029) was mathematically built on big_o_depth.

Closes #1014.

Test plan:
- python -m pytest tests/ -- 5444 passed, 0 failed, 2 skipped, 11 xfailed, 3 xpassed
- python tests/tools/audit_check.py --regenerate -- clean (ruff/mypy baselines
  regenerated, all pure line-shifts)
- ruff format --check -- clean
- Golden master fixtures regenerated via update_golden_master.py in both
  full-precision and zero-dependency venvs -- diff is magnitude/impact and
  the concurrency/documentation risk scores shifting downward across the
  corpus now that the fake complexity multipliers are gone; crucible_check.py
  passes clean on both modes after blessing.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@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

@squid-protocol
squid-protocol merged commit 92f1eaf into main Aug 4, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the fix-big-o-depth-is-recursive-1014 branch August 4, 2026 16:24
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 big_o_depth and is_recursive complexity metrics

1 participant