Skip to content

feat(observability): add alert rule toggle APIs - #14269

Open
ThisIsMani wants to merge 3 commits into
feat/observability-alert-blacklistfrom
feat/observability-alert-rule-toggles
Open

ThisIsMani wants to merge 3 commits into
feat/observability-alert-blacklistfrom
feat/observability-alert-rule-toggles

Conversation

@ThisIsMani

Copy link
Copy Markdown
Contributor

Summary

This is the stacked Rule enable/disable toggles port for the observability plane. It moves only the named domain's mutable-state list/set operations behind authenticated typed APIs and preserves rule identity, disabled-rule behavior, and portal-compatible set responses.

Depends on base PR #14268 (feat/observability-alert-blacklist), which is also the target branch for this PR.

APIs

  • GET /alerts/rule-toggles
  • PUT /alerts/rule-toggles/{rule_id}
  • Both use X-Internal-Api-Key authentication and typed JSON models.
  • PUT preserves the portal response shape: { "ok", "id", "is_enabled" }.

Schema and persistence

  • Adds the reversible alert_rule_toggles PostgreSQL migration.
  • Adds grouped alert-manager API models, Diesel models, schema, and Diesel DSL list/upsert queries.
  • Preserves deterministic listing and rule_id as the natural identity.

Tests

  • cargo fmt --all -- --check
  • cargo check -p observability
  • cargo test -p observability --test rule_toggles (4 passed; 1 database test ignored in the no-database run)
  • cargo test -p observability --test blacklist --test thresholds (12 passed; 2 database tests ignored)
  • cargo test -p observability rule_id_is_trimmed_and_blank_is_rejected
  • diesel migration run --locked-schema against a temporary local PostgreSQL database
  • diesel migration redo --locked-schema --all against a temporary local PostgreSQL database
  • OBSERVABILITY_TEST_DATABASE_URL=... cargo test -p observability --test rule_toggles postgres_repository_replaces_and_lists_toggles -- --ignored
  • git diff --check

Analytical/business reads and users are unchanged. No analytics or user endpoints are added or moved.

@ThisIsMani
ThisIsMani requested review from a team as code owners September 16, 2026 18:40
@semanticdiff-com

semanticdiff-com Bot commented Sep 16, 2026

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  crates/observability/src/db.rs  8% smaller
  crates/observability/tests/blacklist.rs  1% smaller
  crates/observability/tests/thresholds.rs  1% smaller
  crates/api_models/src/observability/alert_manager.rs  0% smaller
  crates/api_models/src/observability/alert_manager/rule_toggles.rs  0% smaller
  crates/diesel_models/src/observability/alert_manager.rs  0% smaller
  crates/diesel_models/src/observability/alert_manager/rule_toggles.rs  0% smaller
  crates/diesel_models/src/observability/query/alert_manager.rs  0% smaller
  crates/diesel_models/src/observability/query/alert_manager/rule_toggles.rs  0% smaller
  crates/diesel_models/src/observability/schema.rs  0% smaller
  crates/observability/migrations/2026-09-15-000004_create_alert_rule_toggles/down.sql Unsupported file format
  crates/observability/migrations/2026-09-15-000004_create_alert_rule_toggles/up.sql Unsupported file format
  crates/observability/src/core.rs  0% smaller
  crates/observability/src/core/rule_toggles.rs  0% smaller
  crates/observability/src/db/rule_toggles.rs  0% smaller
  crates/observability/src/domain_models.rs  0% smaller
  crates/observability/src/domain_models/rule_toggles.rs  0% smaller
  crates/observability/src/routes.rs  0% smaller
  crates/observability/src/routes/app.rs  0% smaller
  crates/observability/src/routes/rule_toggles.rs  0% smaller
  crates/observability/tests/rule_toggles.rs  0% smaller

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d470130cb7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Ok(Self {
rule_id,
is_enabled: request.is_enabled,
updated_by: request.updated_by,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject blank updater identities

When a caller sends "updated_by": " ", this value is persisted and later returned as the audit identity, leaving the toggle change unattributed. The sibling threshold API explicitly rejects blank updated_by values, so validate this field with trim().is_empty() before constructing the row.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest tree: whitespace-only updated_by is rejected before persistence, with route coverage confirming an invalid request does not overwrite stored state.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the latest tree: blank or whitespace-only updated_by values are rejected before persistence, with route and domain coverage.

@ThisIsMani
ThisIsMani force-pushed the feat/observability-alert-rule-toggles branch from d470130 to 8af6c22 Compare September 17, 2026 08:56
@ThisIsMani
ThisIsMani force-pushed the feat/observability-alert-blacklist branch from 4dfa5d9 to e9d5da8 Compare September 17, 2026 13:03
@ThisIsMani
ThisIsMani force-pushed the feat/observability-alert-rule-toggles branch from 8af6c22 to 5af5395 Compare September 17, 2026 13:04
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.

1 participant