refactor(host_agent): extract metric-query helpers to a model-free module
The previous commit's integration test failed at collection-time import:
importing plugins.host_agent.routes (which imports the host_agent ORM models at
top level) double-registers host_agent_registrations against the app-loaded
plugin's metadata ("Table already defined").
Move the two pure read helpers (_latest_metrics_for_host, _history_for_host)
plus SOURCE_MODULE / HISTORY_METRICS into plugins/host_agent/metrics_query.py,
which imports only the core PluginMetric model — no plugin models. routes.py
imports them back. The integration test now imports from metrics_query and no
longer trips the loader's registration guard. No behavior change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016Jg27rgypiW2efULXJDtMC
This commit is contained in:
@@ -34,7 +34,7 @@ def app():
|
||||
def test_latest_distinct_on_and_sql_bucketed_history(app):
|
||||
from sqlalchemy import text
|
||||
from steward.models.metrics import PluginMetric
|
||||
from plugins.host_agent.routes import (
|
||||
from plugins.host_agent.metrics_query import (
|
||||
SOURCE_MODULE, _history_for_host, _latest_metrics_for_host,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user