Repository navigation
fix(audit-script): filter test_*.py + detect router_registry callers (#7128, #7109) - #7168
Merged
Merged
Conversation
…7128, #7109) The 2026-05-06 audit run produced 252 findings, ~all false positives. Two heuristic gaps caused them: 1. Pytest's test_*.py prefix-style modules were flagged as unwired production code. The existing TEST_PATH_FRAGMENTS only covered the _test.py / .test.ts suffix style, /tests/ + /__tests__/ directories. Files like agent_loop/test_loop_repetition.py slipped through. 2. Modules wired via the autobot-backend/initialization/router_registry/ tuple-based runtime lookup (e.g. ("api.captcha", "", [...], "captcha")) look caller-less to the import-grep heuristic. captcha, enhanced_memory, etc. — all live FastAPI routers — were reported as orphaned. Fixes: - is_test_path() now also returns True when path.name starts with "test_" AND has .py extension. Basename check (not substring) — pytest's tmp_path embeds `test_<id>/` directory names that would otherwise short-circuit the audit walker on its own test fixtures. - New load_router_registry_modules() parses every router_registry/*.py for ("module.path", ...) tuples and returns the set of registered dotted paths. Found 144 modules registered this way in the current codebase. - New derive_module_path() converts a file path like autobot-backend/api/captcha.py to the dotted name api.captcha. - scan() now skips files whose derived module path is in the registry set. Result: re-running the audit goes from 252 findings → 0. All previously reported "unwired" modules either (a) had test_*.py basenames or (b) were runtime-registered routers. Tests: - 4 new is_test_path cases (test_*.py prefix style + edge cases) - 5 new derive_module_path parametrized cases - load_router_registry_modules: extracts dotted paths + handles missing dir - scan: end-to-end registry-skip + sanity test for true orphans - 51 / 51 audit-script tests pass Closes #7128 Closes #7109
Contributor
✅ SSOT Configuration Compliance: Passing🎉 No hardcoded values detected that have SSOT config equivalents! |
mrveiss
pushed a commit
that referenced
this pull request
May 8, 2026
…ve path check (#7128b) #7168 (originally tagged #7128) closed with a stale "0 findings" proof — the script was being run from inside a worktree where every file's absolute path contains `/.worktrees/`, hitting the SKIP_PATH_FRAGMENTS filter and silently dropping ALL findings. Real count post-#7168 was ~165, not 0. Two bugs fixed here: 1. **Worktree-relative skip check.** `should_skip_path()` matched against `str(path)` (absolute), so any audit run with REPO_ROOT under `.worktrees/` filtered out everything. Now matches against the path relative to REPO_ROOT, so `.worktrees/` segments in REPO_ROOT itself are no longer false-positives, and nested worktree clones inside the repo are still excluded as before. 2. **Entry-point script filter.** Runner conventions like `intelligence/demos/run_intelligent_agent.py` (created by #7127) cite their tracker in the docstring and have 0 callers by design — they're designed to be invoked from CLI, not imported. New helper `is_entry_point_script(path)` skips files whose name starts with `run_` OR whose path contains a `demos/`, `scripts/`, or `bin/` directory segment. Test deltas: - `test_should_skip_path` parametrize cases switched from absolute paths to REPO_ROOT-relative inputs (matches the contract; prevents the same bug recurring). - New `test_should_skip_path_handles_running_from_worktree` regression test pins the fix. - New `test_is_entry_point_script` (10 cases) and `test_scan_skips_entry_point_runners` (end-to-end) cover the entry-point filter. 63/63 audit-script tests pass. Audit count dropped from 165 → 110 in local re-run; remaining 110 are real-or-different-FP-class candidates (lazy imports, dataclass field refs, importlib string lookups — separate follow-ups out of scope). Refs #7128 #7109 #6872
mrveiss
added a commit
that referenced
this pull request
May 8, 2026
…ve path check (#7128b) (#7244) #7168 (originally tagged #7128) closed with a stale "0 findings" proof — the script was being run from inside a worktree where every file's absolute path contains `/.worktrees/`, hitting the SKIP_PATH_FRAGMENTS filter and silently dropping ALL findings. Real count post-#7168 was ~165, not 0. Two bugs fixed here: 1. **Worktree-relative skip check.** `should_skip_path()` matched against `str(path)` (absolute), so any audit run with REPO_ROOT under `.worktrees/` filtered out everything. Now matches against the path relative to REPO_ROOT, so `.worktrees/` segments in REPO_ROOT itself are no longer false-positives, and nested worktree clones inside the repo are still excluded as before. 2. **Entry-point script filter.** Runner conventions like `intelligence/demos/run_intelligent_agent.py` (created by #7127) cite their tracker in the docstring and have 0 callers by design — they're designed to be invoked from CLI, not imported. New helper `is_entry_point_script(path)` skips files whose name starts with `run_` OR whose path contains a `demos/`, `scripts/`, or `bin/` directory segment. Test deltas: - `test_should_skip_path` parametrize cases switched from absolute paths to REPO_ROOT-relative inputs (matches the contract; prevents the same bug recurring). - New `test_should_skip_path_handles_running_from_worktree` regression test pins the fix. - New `test_is_entry_point_script` (10 cases) and `test_scan_skips_entry_point_runners` (end-to-end) cover the entry-point filter. 63/63 audit-script tests pass. Audit count dropped from 165 → 110 in local re-run; remaining 110 are real-or-different-FP-class candidates (lazy imports, dataclass field refs, importlib string lookups — separate follow-ups out of scope). Refs #7128 #7109 #6872 Co-authored-by: t <t@t>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The 2026-05-06 `audit-unwired-trackers.py` run on the live codebase produced 252 findings (filed as evidence on #6872). Two heuristic gaps made them all false positives:
This PR closes both gaps in one place since they share the same file.
Changes
Result
Re-running the audit on Dev_new_gui:
```bash
$ python3 pipeline-scripts/audit-unwired-trackers.py
✅ No unwired-tracker findings.
```
252 → 0. All prior findings were either pytest test files or registry-wired routers.
Test plan
Closes #7128
Closes #7109
🤖 Generated with Claude Code