Repository navigation
feat(serving): alert history + alert-rule repository behind ControlPlaneStore (ADR 0010 slice 2) - #132
Merged
Conversation
…aneStore (ADR 0010 slice 2) Second rollout slice of ADR 0010: alert delivery history and the alert-rule repository (including mutable runtime state — state, fired_at, last_escalation_level, flap window, cooldown) move behind the ControlPlaneStore port. Pure extraction — table DDL, the YAML file format, and the dispatcher/router behavior are byte-compatible; no behavior change on the embedded (default) profile. - ControlPlaneStore gains log_alert_delivery / get_alert_delivery_history (mirrors the webhook attempt-log shape) and load_alert_rules / save_alert_rules (JSON-shaped records — the port doesn't import the AlertRule pydantic model, avoiding a cycle with alerts.dispatcher, which imports get_control_plane_store to resolve the store). - EmbeddedControlPlaneStore gains ensure_alert_history_table (moved verbatim from alerts/history.py, same catalog_ddl_lock discipline as its webhook siblings) and alert_rules_path_provider (mirrors conn_provider — resolved per call so app.state.alert_config_path swaps in tests keep working). - alerts/escalation.py and routers/alerts.py no longer reach query_engine._conn (structural ratchet test extended); create_alert / list_alerts / get_alert / update_alert / deactivate_alert now take the FastAPI app (resolving the store internally) instead of a bare Path. - src/serving/api/alerts/history.py removed; its DB-plumbing backwards-compat re-exports (get_alert_history, ensure_alert_history_table) retired from the alert_dispatcher.py shim — internal plumbing, not public SDK surface. Tests: tests/unit/test_control_plane_store.py gains alert history log + YAML rule-repository round-trip coverage; test_catalog_ddl_concurrency, test_alert_dispatcher_backcompat, test_alerts_router_unit, test_blocking_routes_offloaded and integration test_alert_dedup rewired to the new module/signatures. Verified: full unit+property 1561 passed, mypy strict clean, ruff clean, integration (docker/live excluded) 206 passed/19 skipped. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
DORA Metrics
|
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
Second rollout slice of ADR 0010: alert delivery history and the alert-rule repository (including mutable runtime state —
state,fired_at,last_escalation_level, flap window, cooldown) move behind theControlPlaneStoreport. Pure extraction — table DDL, the YAML file format, and dispatcher/router behavior are byte-compatible; no behavior change on the embedded (default) profile.ControlPlaneStoregainslog_alert_delivery/get_alert_delivery_history(mirrors the webhook attempt-log shape) andload_alert_rules/save_alert_rules(JSON-shaped records — the port doesn't import theAlertRulepydantic model, avoiding a cycle withalerts.dispatcher, which importsget_control_plane_storeto resolve the store).EmbeddedControlPlaneStoregainsensure_alert_history_table(moved verbatim fromalerts/history.py, samecatalog_ddl_lockdiscipline as its webhook siblings) andalert_rules_path_provider(mirrorsconn_provider— resolved per call soapp.state.alert_config_pathswaps in tests keep working).alerts/escalation.pyandrouters/alerts.pyno longer reachquery_engine._conn(structural ratchet test extended);create_alert/list_alerts/get_alert/update_alert/deactivate_alertnow take the FastAPIapp(resolving the store internally) instead of a barePath.src/serving/api/alerts/history.pyremoved; its DB-plumbing backwards-compat re-exports (get_alert_history,ensure_alert_history_table) retired from thealert_dispatcher.pyshim — internal plumbing, not public SDK surface.Test plan
tests/unit/test_control_plane_store.py— new alert-history-log + YAML rule-repository round-trip coverage, structural ratchet extended to the alerts subsystemtest_catalog_ddl_concurrency,test_alert_dispatcher_backcompat,test_alerts_router_unit,test_blocking_routes_offloaded, integrationtest_alert_deduprewired to the new module/signatures🤖 Generated with Claude Code