Skip to content

fix(infra): infrastructure scripts stop depending on the caller's PYTHONPATH, one guard for the class, and one monitoring launcher (#18288, #17906) - #18292

Merged
mrveiss merged 5 commits into
mainfrom
issue-18288-infra-script-imports
Oct 11, 2026
Merged

mrveiss merged 5 commits into
mainfrom
issue-18288-infra-script-imports

Conversation

@mrveiss

@mrveiss mrveiss commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Thinking Path

#18288: infrastructure scripts imported backend internals (utils.* and others) and resolved them only when the caller's PYTHONPATH already held the backend. Run standalone, they failed. The owner asked for the fix as soon as possible. Two of the ten scripts are edited by open #18230 (same-file rule), so they follow on this branch after it merges. Two others share files with the unfinished local branch for #17906 (merging the two monitoring launchers), so that work rides here too.

A class guard written for this PR found the problem is 104 modules, not 10. The 94 not audited here are frozen in its allowlist and filed as #18289.

What Changed

Script Clean python -I import before Why a backend tool
performance_dashboard.py No module named 'utils' drives monitoring_system, which needs the backend's config and constants
validation_dashboard_generator.py No module named 'project_state_tracker' reports on backend project-state modules; called by phase_validation.yml
test_phase5_cleanup.py lazy import, so it failed only when run checks backend metrics collectors
test_long_running_operations.py No module named 'autobot_shared' demo of the backend long-running framework, which always fell back to "unavailable"
apply_memory_optimizations.py No module named 'utils' utils.memory_optimization needs psutil, which autobot_shared does not declare
analysis/test_service_registry.py lazy import deliberately exercises the backend registry
monitoring/start_monitoring.py + monitoring_backends.py No module named 'autobot_shared' drives backend monitors

All of them now return 0 on a clean import.

Behaviour changes

  • start_hardware_monitoring.py is gone. Anyone invoking it by hand on a host switches to start_monitoring.py --backend hardware.
  • test_long_running_operations.py now really loads the framework instead of always reporting it unavailable.

Verification

  • New guard plus the 17906 and 15643 tests: 34 passed. Infra tests (apply_memory_optimizations, validation_dashboard_generator): 6.
  • reach_scope_claim_17844 alone 10, guard-reach meta 23, reach_declarations 411, symbol-fork 17, size ratchet 31, ceiling parity 11.
  • flake8 is clean. No script was run against a live system; the checks are import-only.

Not done, stated rather than implied

So this PR is Refs #18288, and Closes #17906.

Closes #17906
Refs #18288

Model Used

Claude Opus 5.5 (master session: brief, review of the report, PR). Implementation by a Claude Opus subagent.

🤖 Generated with Claude Code

…e is the one entry point, monitoring floors lowered to 1 (#17906)
…d one guard holds every infrastructure module to it (#18288)
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: mrveiss/AutoBot-AI/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e9873621-dcb2-4fd5-ad99-5a1c3ad64e28

📥 Commits

Reviewing files that changed from the base of the PR and between 1349f43 and 48d1a9f.


📒 Files selected for processing (24)
  • .github/workflows/ci.yml
  • .github/workflows/coverage.yml
  • .github/workflows/marker-tests.yml
  • .github/workflows/test-durations.yml
  • autobot-infrastructure/shared/scripts/analysis/test_service_registry.py
  • autobot-infrastructure/shared/scripts/apply_memory_optimizations.py
  • autobot-infrastructure/shared/scripts/monitoring/monitoring_backends.py
  • autobot-infrastructure/shared/scripts/monitoring/start_hardware_monitoring.py
  • autobot-infrastructure/shared/scripts/monitoring/start_monitoring.py
  • autobot-infrastructure/shared/scripts/monitoring/start_monitoring_category_default_test.py
  • autobot-infrastructure/shared/scripts/performance_dashboard.py
  • autobot-infrastructure/shared/scripts/test_long_running_operations.py
  • autobot-infrastructure/shared/scripts/test_phase5_cleanup.py
  • autobot-infrastructure/shared/scripts/validation_dashboard_generator.py
  • docs/architecture/LONG_RUNNING_OPERATIONS_ARCHITECTURE.md
  • pytest.ini
  • repo_tests/_infra_backend_names.py
  • repo_tests/_reach_policy.py
  • repo_tests/infra_backend_imports_allowlist_18288.py
  • repo_tests/infra_monitoring_import_path_15643_test.py
  • repo_tests/infra_scripts_no_backend_imports_18288_test.py
  • repo_tests/monitoring_launcher_single_17906_test.py
  • repo_tests/reach_scope_claim_17844_test.py
  • repo_tests/test_infra_scripts_import_14129.py

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No new hardcoded values of either class — ssot and other both block.

Known backlog in pipeline-scripts/hardcoded_values_baseline.txt is suppressed and tracked in #14371.

@mrveiss

mrveiss commented Oct 11, 2026

Copy link
Copy Markdown
Owner Author

Merger review at 995d41b: BLOCKED. Two must-fix items, then two guard tightenings.

These check out:

Sev Where (at 995d41b) Finding Fix
HIGH repo_tests/test_infra_scripts_import_14129.py:84 _OPERATOR_ENTRYPOINTS still lists monitoring/start_hardware_monitoring.py, which this PR deletes. Its test asserts script.is_file(), so it goes red. It is a test-side caller that the "no caller" sweep missed. Point it at monitoring/start_monitoring.py, and update the docstring mentions at :8-10, :42 and :142.
HIGH #17906 AC4 / pytest.ini testpaths autobot-infrastructure/shared/scripts/monitoring/start_monitoring_category_default_test.py runs nowhere: testpaths includes only autobot-infrastructure/shared/scripts/hooks. The AC asks for it to run, or for its not running to be tracked. The PR says Closes #17906. Wire the directory into testpaths the way hooks was (#13880), and measure it green. Otherwise file the tracking issue and change the PR to Refs #17906.
MED infra_monitoring_import_path_15643_test.py:~160 (the change you asked about) Accepting any sibling <name>.py as resolvable admits false negatives. The launcher inserts its own directory at index 0, so a future utils.py or constants.py beside it would shadow the backend module and still pass. Accept a sibling only when the root is the script's own directory and the name is not in backend_only_names(). Also insert the monitoring directory after the backend root, not at index 0.
MED infra_scripts_no_backend_imports_18288_test.py _own_tree_names A backend name is suppressed when any ancestor directory up to autobot-infrastructure/ has a same-named entry, but Python only puts the script's own directory on the path. Twelve top-level names are shared between infra and backend (api, knowledge, monitoring, security, tools, user_management, …), so a real backend import of one of those names would be hidden. Suppress only names that exist in the script's own directory or in a directory the script inserts into sys.path.
LOW the guard's AST scan importlib.import_module("x") and __import__("x") calls with a constant first argument are not scanned. Add them with a contrast fixture, or record them on #18289.
LOW start_monitoring.py main() About 65 lines, over the 30-line rule; it was already long. Extract the dispatch and config loading.

Unverified: whether hardware_metrics.py's Redis client is created lazily. The launcher now imports backend modules that build singletons at import time (gpu_acceleration_optimizer.py:363, hardware_metrics.py:1332, performance_monitor.py:135).

…s are scanned, the monitoring test runs in CI, and the 14129 entry point follows the launcher (#18288, #17906)
@mrveiss
mrveiss merged commit 23289f9 into main Oct 11, 2026
52 of 73 checks passed
@mrveiss
mrveiss deleted the issue-18288-infra-script-imports branch October 11, 2026 17:21
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.

refactor(infrastructure): consolidate the two near-duplicate monitoring launchers into one

1 participant