Repository navigation
refactor(slm-backend): retire the 7 dead SLM monitoring modules whose function is live elsewhere (#16282) - #16308
Conversation
…ction is live elsewhere (#16282) advanced_apm_system, ai_performance_analytics, claude_api_monitor, comprehensive_monitoring_controller, metrics_adapter, monitor_control, performance_dashboard and performance_monitor had no live importer, and each one's function already lives in the SLM API or the shared Prometheus recorders. Their launcher (start_monitoring.sh), monitor_control's config, the test that exercised only claude_api_monitor, and their size, hardcoded-value and flake8 baseline entries go with them. The README now maps each retired module to its live equivalent. The operator scripts that imported them now record through the metrics manager, and the phase-5 check asserts that claude_api_monitor is gone and its successor is still defined. performance_benchmark, performance_optimizer and business_intelligence_dashboard stay: they are being wired in under #16305, #16306 and #16307.
… monitor's log (#16282) quick-deploy-verification.sh read logs/performance_monitor.log, which only the SLM's monitoring/performance_monitor.py wrote (its line 159). That module never imported (it needed the main backend's config.ConfigManager) and is retired in this PR, so both checks read a file nothing writes.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 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. Comment |
|
Review at
Verified, and it holds for the other seven (
|
|
Addendum to the finding above: this PR's CI will go green even though the three kept modules can't import, so a green run is not evidence the deletion is safe.
Nothing in CI can see the break. It has to be settled in the diff (keep the module, or move the three symbols), and the tests for #16305–#16307 should import the real dependency rather than a stub. |
…eing wired in still import (#16282) business_intelligence_dashboard, performance_benchmark and performance_optimizer import performance_monitor by its bare name, and #16305, #16306 and #16307 wire those three in rather than retiring them. Deleting it would leave them one more import to replace. So it stays until the last of the three lands, along with its size-baseline entries and the two quick-deploy-verification.sh checks that read its log. The README records who removes it.
|
Delta re-review since my changes-requested review at
Everything from my first review of the seven stands: no code references, and all 12 cited live equivalents verified at their lines on base. |
✅ SSOT Configuration Compliance: Passing🎉 No new hardcoded values of either class — Known backlog in |
…e count, so deleting unique code can't fail it (#16319) (#16323) * chore(claim): helper-02 takes the duplication-guard unit fix (#16319) * ci(duplication-guard): gate each scope on its absolute duplicated-line count, so deleting unique code can't fail it (#16319) The guard pinned jscpd's duplicated-lines percentage a hair above its measurement. #16308 deleted about 4.5k unique lines and failed it. It kept the same 135 clones and 4,729 duplicated lines, but a smaller denominator moved the ratio from 1.82% to 1.85%. The rule is "no new duplication", so the count is what gets pinned now. - scripts/duplication_gate.py reads jscpd's Total row and applies the pin. It is the only parser: both gate steps and "Explain failure" call it, and the awk parser in "Explain failure" is gone. - The pins come from base run 34581036896 (d5a0c6d, jscpd 5.0.6): MAX_DUP_LINES 11723 and SLM_MAX_DUP_LINES 4729. The main pin tightens: its 1.05% was never lowered as duplication fell to 0.74%. - The report-only pre-scan of the SLM trees is gone, since the gate prints the figure on every run. - The tests cover the parser on the verbatim #16163 row, #16308's figures passing, one added duplicated line failing, and the unmeasured, non-count and unreadable cases. The repo test now pins each gate's scanned trees, and "Explain failure" reports the overage in lines. - RATCHET_BASELINES.md gains rule 7: pin the quantity the rule limits, not a ratio of it. * fix(ci): drop a stray escaped space that passed jscpd an extra argument in the SLM gate (#16319) The SLM gate's -i line ended in `\\ \\`: the rewrite appended a line continuation to a line that already carried one, so jscpd received a one-space string as an extra argument. Review finding on #16323.
…DFATHERED list (#16308) This PR deletes autobot-slm-backend/tests/test_claude_api_monitor.py along with the rest of the legacy monitoring module it tested, so the file no longer exists for the sweep to scan. It drops out of the offenders set and the GRANDFATHERED entry goes stale -- test_the_grandfathered_list_has_not_gone_stale catches exactly this: an entry that no longer offends must be removed, since the list only shrinks. The other two GRANDFATHERED files this PR touches (test_api_request_counter.py, test_prometheus_registry_endpoint.py) only had a stale comment reference fixed and still carry their unrestored sys.modules writes, so they stay grandfathered.
… after the launcher's retirement (#16282)
|
Content review: approve. Verified independently against base ([] no manual link, body is Refs-only): grepped for live importers of all 7 retired modules across autobot-slm-backend — none found outside the retired set itself (metrics_adapter.py imports claude_api_monitor, but metrics_adapter is also being retired in this same PR, so that's not an external dependency). Spot-checked two of the table's line-number claims against base: Good boundary discipline: performance_monitor stays because all 3 modules the owner chose to wire in (#16305/16306/16307) still import it by bare name — retiring it here would break work in flight elsewhere. The README documents which sub-issue removes it last, so that decision isn't lost. closingIssuesReferences=[] matches body (Refs #16282 only). CI green, no missing required contexts. Ready. |
…pulation (#17142) RATCHET_BASELINES.md rule 7 says "pin the quantity the rule limits, not a ratio of it", and #17142 replaces two absolute floors with fractions. A reviewer reading that rule would reasonably flag it, so the rule gains the discriminator rather than this change claiming an exception -- because the question rule 7 already asks is the right question, and this change passes it. The discriminator is whether numerator and denominator are the SAME population. jscpd failed because they were not: duplicated lines over all scanned lines, so deleting unique code moved the denominator alone and #16308 failed by removing 4.5k lines of dead code. The reach floor passes because they are: the sweep's own suffix-matched files over an independent count of the same set, so `.md`/`.ts`/`.vue` churn moves neither side and adding or splitting a `.py` file moves both. The part worth recording is that rule 7 was ALREADY WRITTEN when the first version of #17142 got this wrong. That version took a fraction of the whole tracked tree as a floor on a counted subset -- precisely the failure the rule describes -- and the rule did not fire, because I did not read it before freezing a ratio. So the entry says "ask the question for the ratio you are about to freeze, not for ratios in general", which is the form that would have caught it. Rule 8 is new and is the one 50 asked to be made durable: a migration assertion inherits the baseline it records. #17142's `_SUPERSEDED` recorded the tracked-file count as the denominator for a guard that bounds a subset. Fix the declaration, leave the baseline, and the test written to stop the claim drifting certifies the drift -- failing in the one direction nobody re-checks, because a passing migration test reads as a faithful migration. Hence: change the recorded baseline in the same commit, and state which quantity the number is of.
…pulation (#17142) RATCHET_BASELINES.md rule 7 says "pin the quantity the rule limits, not a ratio of it", and #17142 replaces two absolute floors with fractions. A reviewer reading that rule would reasonably flag it, so the rule gains the discriminator rather than this change claiming an exception -- because the question rule 7 already asks is the right question, and this change passes it. The discriminator is whether numerator and denominator are the SAME population. jscpd failed because they were not: duplicated lines over all scanned lines, so deleting unique code moved the denominator alone and #16308 failed by removing 4.5k lines of dead code. The reach floor passes because they are: the sweep's own suffix-matched files over an independent count of the same set, so `.md`/`.ts`/`.vue` churn moves neither side and adding or splitting a `.py` file moves both. The part worth recording is that rule 7 was ALREADY WRITTEN when the first version of #17142 got this wrong. That version took a fraction of the whole tracked tree as a floor on a counted subset -- precisely the failure the rule describes -- and the rule did not fire, because I did not read it before freezing a ratio. So the entry says "ask the question for the ratio you are about to freeze, not for ratios in general", which is the form that would have caught it. Rule 8 is new and is the one 50 asked to be made durable: a migration assertion inherits the baseline it records. #17142's `_SUPERSEDED` recorded the tracked-file count as the denominator for a guard that bounds a subset. Fix the declaration, leave the baseline, and the test written to stop the claim drifting certifies the drift -- failing in the one direction nobody re-checks, because a passing migration test reads as a faithful migration. Hence: change the recorded baseline in the same commit, and state which quantity the number is of.
Refs #16282. #16305, #16306 and #16307 (its sub-issues) carry the three modules that stay, and
performance_monitor, which they still import.Thinking Path
autobot-slm-backend/monitoring/have no live importer.monitoring/__init__.py:12imports onlyprometheus_metrics.d5a0c6dcb. For 8 of them, the function already runs elsewhere, in the SLM API or the shared Prometheus recorders.performance_monitorby its bare name, so it stays until the last of them lands (review finding; commit 3). This PR retires the other 7. The README records that whichever sub-issue lands last removesperformance_monitor.performance_monitoritself can't be imported in the SLM, because it needsconfig.ConfigManager, which exists only in the main backend (autobot-backend/config/manager.py:51).d5a0c6dcb)advanced_apm_system(877)middleware/api_request_counter.py:35withautobot_shared/monitoring/metrics/api_requests.py:39record_request;api/performance.py:610get_traces,:743create_alert_ruleai_performance_analytics(830)api/npu.py:457GET /metrics; inautobot_shared/monitoring/metrics/:performance.py:295update_npu_metrics,knowledge_base.py:225record_search,llm_provider.py:26LLMProviderMetricsRecorderclaude_api_monitor(596)autobot_shared/monitoring/prometheus_metrics.py:428record_claude_api_request;autobot_shared/monitoring/metrics/claude_api.py:17ClaudeAPIMetricsRecorder. It was already marked DEPRECATED (#348).comprehensive_monitoring_controller(588),monitor_control(680)main.py:688-689run the monitoring and performance routers in-process, behinddependencies=_SM, so no separate monitoring process remains to controlmetrics_adapter(222)get_metrics_manager(), which callers use directlyperformance_dashboard(724)api/monitoring.py:695/dashboard,:354/metrics/fleetWhat Changed
Deleted (10 files)
monitoring/start_monitoring.sh. It launched only the controller (:191,:209) and individual modules (:225-228), none of which can run: the controller and APM/analytics are retired, and the monitor and BI can't be imported.monitoring/monitoring_config.yaml. Its only reader wasmonitor_control.py:186.tests/test_claude_api_monitor.py. It exercised onlyclaude_api_monitor.Baselines
scripts/python_file_size_known_large.pyandrepo_tests/python_file_size_ratchet_baseline.py.performance_monitor's entry stays.performance_dashboardline dropped frompipeline-scripts/hardcoded_values_baseline.txt..flake8:159(performance_dashboard) dropped.Operator scripts in
autobot-infrastructure/shared/scripts/(pytest'stestpathsreach onlyshared/scripts/hooks, so CI collects none of these)test_phase2_migration.pyrecords Claude calls through the metrics manager instead ofClaudeAPIMonitor.test_prometheus_metrics.py: removed theMetricsAdapterblock, because its Prometheus writes are already exercised at:61-70. Also removed a duplicateloggerassignment and a hardcoded IP.test_phase5_cleanup.py: the ClaudeAPIMonitor check now asserts that the file is absent and thatrecord_claude_api_requestis still defined. It reads this through the AST, the way the compat check does. Removed the SLMsys.pathinsertion, which existed only for that import, and the now-unusedasyncio,Callableand_emits_deprecation.Docs
monitoring/README_PERFORMANCE_MONITORING.mdis rewritten. It covers the live equivalents, the 3 modules being wired in, and who removesperformance_monitor. The old internal addresses are gone.CONFIG_REMEDIATION_PLAN.md(the 3 retired-module lines only),system-state.md,CLAUDE_API_OPTIMIZATION_SUITE.mdandssot_config_shell_library_14041.md.test_api_request_counter.pyandtest_prometheus_registry_endpoint.pyno longer name the retired module.Commits
547e111bc: the retirement.c0c647809: removed thequick-deploy-verification.shchecks onlogs/performance_monitor.log.performance_monitor.py, its baseline entries, its doc lines and those log checks, so relative to base, commit 2 nets out to nothing.Not touched (boundary)
performance_monitor,business_intelligence_dashboard,performance_benchmarkandperformance_optimizer, their tests, andCostModelConfig(slm(monitoring): wire performance_benchmark in as a fleet benchmark, and fix its import of a module that does not exist #16305, slm(reconciler): fold performance_optimizer's tuning logic into the reconciler, then remove the module #16306, company-os: fold business_intelligence_dashboard's cost and ROI analysis into Company OS, and system-wide stats into the SLM #16307).utils.performance_monitorfamily.shared/scripts/performance_dashboard.py, a different script.api.ts, which only matches the names as words.Verification
git grep -wEover the retired names (bare name and path form) turns up only the README, the phase-5 constant, and the boundary items above.performance_monitor.py's own imports (:12-30) include none of the 7.performance_monitor.py,quick-deploy-verification.shandREADME_ASYNC_VALIDATION.mdare identical to base.Model Used
Claude Opus 5 (
claude-opus-5)Single-issue rationale
The owner split off #16282's three remaining modules as #16305, #16306 and #16307. They're different scopes (an SLM feature, the reconciler, and Company OS), and each lands in its own PR. What's left of #16282 is retiring the 7 modules whose function is already live elsewhere, and no other open issue shares that scope.