Skip to content

fix(infra)!: enforce alert channel bindings and rollout stability - #859

Merged
lahlfors merged 3 commits into
mainfrom
fix/alert-routing-and-rollout
Nov 22, 2026
Merged

lahlfors merged 3 commits into
mainfrom
fix/alert-routing-and-rollout

Conversation

@lahlfors

Copy link
Copy Markdown
Collaborator

Summary

Implements POAM-2026-230 (plan-time & runtime Cloud Monitoring channel validity, compliance-bridge notifier startup validity + observed delivery, synthetic heartbeat destination observation, and an independent scheduled CI verification workflow), folds in adopter-facing Findings A & B discovered during the 35-message cage-staging Pub/Sub read-back, and records the 67-second live delivery-log corroboration on POAM-2026-231:

  1. Reference-Architecture Terminal Sink Amendment (POAM-2026-230 Property 3):
    • Documents in docs/POAM.md that because CAGE is a reference architecture rather than a deployed production service, GCP Cloud Pub/Sub (topics/cage-staging-alerts -> subscriptions/cage-staging-alerts-verify) is the verified terminal destination by design; personal email, SMS, and commercial paging fan-out are out of scope rather than permanently unmet work.
  2. Target-Wide Plan-Time Channel Resolution & Preconditions (POAM-2026-230 Property 1 / AL-01):
    • Renames lula_alert_notification_channels (list(string)) and lula_alert_owner to target-wide alert_notification_channels (list(object({ display_name, type, labels, name }))) and alert_owner_label across infra/targets/gcp-gke/.
    • Resolves channels at plan time via data.google_monitoring_notification_channel.bound in infra/targets/gcp-gke/alert_routing.tf and enforces lifecycle { precondition { condition = local.alert_channels_valid } } directly on all 9 google_monitoring_alert_policy resources (including the new synthetic alert_pipeline_heartbeat policy), with expect_failures runs in lula_cron.tftest.hcl for empty channel list, disabled channel (enabled = false), and mismatched channel ID.
  3. compliance-bridge Notifier Startup Validity, PubSubNotifier, & Observed Delivery (POAM-2026-230 Property 1b & 2):
    • Adds PubSubNotifier (ALERT_CHANNEL=pubsub, COMPLIANCE_ALERT_PUBSUB_TOPIC=projects/<project>/topics/<topic>), allows pubsub.googleapis.com egress, and grants topic-scoped roles/pubsub.publisher to cage-compliance-bridge.
    • Enforces external notifier configuration at both Terraform plan time (kubernetes_deployment.compliance_bridge precondition) and pod startup (validate_notifier_config() in lifespan() + create_notifier() raising NotifierConfigError with zero silent fallback to ConsoleNotifier).
    • Returns bool from send_critical_alert() and send_remediation_followup() (ConsoleNotifier returns False), records alerted / remediation_sent strictly from observed destination acknowledgement (delivered is True), and emits periodic non-paging SLA heartbeats (ALERT_HEARTBEAT_INTERVAL_SECONDS).
  4. Adopter-Facing Alert-Stability Fixes (POAM-2026-230 Findings A & B):
    • Finding A (Orphaned Pod-Series Incidents): Adds cross_series_reducer = "REDUCE_SUM" ("REDUCE_MAX" on uptime) on lula_audit_pod_restart and gateway_canary_pod_health plus alert_strategy { auto_close = "1800s" } across all 9 policies so ReplicaSet rotation never holds per-pod incidents open for GCP's 7-day default (3/35 queued messages).
    • Finding B (Single-Replica Rolling-Deploy Scrape Alert Fatigue): Updates prometheus_metrics_scrape_liveness to aggregate up across replicas via max by (job, namespace) (up{...}) == 0, widens absent_over_time from [5m] to [10m], and sets duration = "600s" (10m > 6-7m single-replica turnover; accounted for 24/35 = 69% of queued messages across 6 rolling deploys).
  5. Destination Verification Script & Independent Scheduled CI Workflow (POAM-2026-230 Properties 2, 3, 4):
    • Adds pure-stdlib scripts/verify_alert_delivery.py and scheduled keyless OIDC workflow .github/workflows/alert-delivery-check.yml (google_service_account.alert_verifier in infra/targets/gcp-gke/wif.tf) to assert runtime channel-set equality across all >= 9 cluster policies, trip & reset custom.googleapis.com/cage/alert_heartbeat_probe, and observe both Cloud Monitoring and compliance-bridge heartbeats on the terminal Pub/Sub subscription while returning all operational alerts untouched (modifyAckDeadline=0).
  6. Citation Corrections, 35-Message Read-Back, & POAM-2026-231 67-Second Corroboration:
    • Corrects Terraform comments/documentation strings (lula_alerting.tf, metrics_alerting.tf) and compliance/lula/lula-validation-ir6.yaml L21 & L46.
    • Records the complete 35-message cage-staging Pub/Sub read-back in POAM-2026-230 (leaving POAM-2026-230 Open pending merge, cage-staging rollout + live heartbeat verification, and v4.1.0 GitHub release-body edit) and records in POAM-2026-231 that cage-staging-alerts-pubsub bound at 2026-11-19T16:07:46Z — 67 seconds before POAM-2026-238's 16:08:53Z-16:09:00Z total execute_trade wedge (seq=2187..2191) — with 0 notifications emitted by gateway_sustained_refusal_ratio.

BREAKING CHANGE: lula_alert_notification_channels (list(string)) and lula_alert_owner are replaced by alert_notification_channels (list(object)) and alert_owner_label; enforcing postures require compliance_alert_channel (pubsub, slack, webhook, or pagerduty) at plan time and pod startup; and notifier send_critical_alert() / send_remediation_followup() return bool (AL-01 in docs/BREAKING_CHANGES.md).

Verification

  • terraform fmt -check -recursive infra/ — passed
  • terraform -chdir=infra/targets/gcp-gke test -var-file=staging.tfvars -var-file=tests/fixtures/image_digests.tfvars — 156 passed, 0 failed (including 13/13 runs in tests/lula_cron.tftest.hcl)
  • terraform -chdir=infra/modules/compliance_bridge test — 14 passed, 0 failed
  • terraform -chdir=infra/modules/app_secrets test — 5 passed, 0 failed
  • uv run pytest tests/ -m "local or unit" -n auto --dist loadscope --no-cov -p no:langsmith -p no:langsmith_plugin --tb=short — 12,442 passed, 98 skipped, 0 failed
  • uv run bandit -r src/ scripts/ -c pyproject.toml -ll -ii — 0 High / 0 Medium issues (159,813 LOC scanned across src/ and scripts/)

Remediate POAM-2026-230 across Cloud Monitoring alert policies and the compliance-bridge notifier, fold in adopter-facing Findings A and B from the 35-message Pub/Sub read-back, and record the 67-second live delivery-log corroboration on POAM-2026-231:

- Rename lula_alert_notification_channels and lula_alert_owner to target-wide alert_notification_channels and alert_owner_label, resolve bound channels at plan time via data.google_monitoring_notification_channel.bound, and enforce lifecycle preconditions on all 9 google_monitoring_alert_policy resources (including synthetic alert_pipeline_heartbeat).
- Add PubSubNotifier (CAGE reference-architecture terminal sink), refuse unset/console/mock/incomplete notifier configs at Terraform plan time and compliance-bridge startup (NotifierConfigError), record alerted and remediation_sent strictly from observed destination acknowledgement (bool), and emit periodic non-paging SLA heartbeats.
- Fix Finding A (REDUCE_SUM/REDUCE_MAX pod-series aggregation and alert_strategy.auto_close = 1800s so ReplicaSet rotation never leaves per-pod incidents open for 7 days) and Finding B (max by (job, namespace) (up == 0), [10m] absent_over_time lookback, and duration = 600s on prometheus_metrics_scrape_liveness so 6-7m single-replica rolling deploys do not page).
- Add pure-stdlib scripts/verify_alert_delivery.py and scheduled keyless-WIF workflow .github/workflows/alert-delivery-check.yml (cage-alert-verifier GSA) for independent destination-delivery verification.
- Correct Terraform alert documentation strings and compliance/lula/lula-validation-ir6.yaml, and update POAM-2026-230 and POAM-2026-231 in docs/POAM.md.

BREAKING CHANGE: lula_alert_notification_channels (list(string)) and lula_alert_owner are replaced by alert_notification_channels (list(object)) and alert_owner_label; enforcing postures require compliance_alert_channel (pubsub, slack, webhook, or pagerduty) at plan time and pod startup; and notifier send_critical_alert() / send_remediation_followup() return bool (AL-01).
Make the POAM-2026-230 plan-time and startup error messages and AL-01 breaking-change entry self-explanatory for adopters:

- Consolidate all 9 AlertPolicy precondition messages onto local.alert_channels_error_message in alert_routing.tf, covering migration from lula_alert_notification_channels, Pub/Sub channel creation, re-enabling disabled channels, and passing -var='alert_notification_channels=[]' during terraform destroy when a channel was deleted out-of-band.
- Add concrete terraform.auto.tfvars guidance to kubernetes_deployment.compliance_bridge's precondition and validate_notifier_config().
- Expand AL-01 in docs/BREAKING_CHANGES.md with exact Terraform diagnostics ('Value for undeclared variable' and 'Cannot find notification channel') and a before/after terraform.auto.tfvars migration snippet.
@lahlfors
lahlfors force-pushed the fix/alert-routing-and-rollout branch from 2460103 to 5f469f1 Compare November 22, 2026 22:25
- Add google_pubsub_topic_iam_member.compliance_bridge_alert_publisher to module.compliance_bridge depends_on so Terraform creates the roles/pubsub.publisher binding before rolling out compliance-bridge.
- Link tracked terraform.auto.tfvars.example instead of gitignored infra/targets/gcp-gke/terraform.auto.tfvars in docs/BREAKING_CHANGES.md so clean-checkout Gate G9 passes in CI.
@lahlfors

Copy link
Copy Markdown
Collaborator Author

Pre-merge required-check verification

  • PR: fix(infra)!: enforce alert channel bindings and rollout stability #859 into main (state: OPEN; review decision: REVIEW_REQUIRED)
  • Head SHA: c65f50804f5082757e0a55f0e6e3f5cbb2d2254d
  • Required checks: GET /repos/google/cybernetic-agent-governance-engine/rules/branches/main plus classic branch protection
  • Results: REST commits/{sha}/check-runs?filter=all and commits/{sha}/status, not gh pr checks
  • Verified: 2026-11-22T22:58:25Z by scripts/check_pr_mergeable.sh
Required check Source Reports Result
AI 600-1 Unit Tests app 15368 1 success
Approved review or recorded bypass app 15368 1 success
Lint app 15368 1 success
OPA Rego Policy Lint and Test (Universal — NIST CM-6/SI-7 reporting: US_FED only) app 15368 1 success
Pytest Logic Tests app 15368 1 success
Quickstart Bootstrap & First-DENY Smoke Gate app 15368 1 success
Secret Scanning (Gitleaks) app 15368 1 success
Terraform Tests (gcp-gke, mock providers) app 15368 1 success
license-check app 15368 2 success

9 required check(s), verified against 60 check-run(s) and 0 commit status(es) on this SHA.

Result: every required check passed on this exact SHA.

@lahlfors
lahlfors merged commit fc0152a into main Nov 22, 2026
60 checks passed
@lahlfors
lahlfors deleted the fix/alert-routing-and-rollout branch November 22, 2026 23:07
lahlfors added a commit that referenced this pull request Nov 23, 2026
Close POAM-2026-230 (2026-11-23) following live rollout and two-envelope + keyless-WIF verification across #859 (fc0152a), #860 (e382278), #861 (6f63b58), and #862 (5fa4180):
- Enforcing-posture plan-time NotificationChannel resolution (var.alert_notification_channels + data.google_monitoring_notification_channel.bound preconditions across 9/9 policies) and pod-startup NotifierConfigError validation (PubSubNotifier observed boolean delivery)
- Folded Finding A (REDUCE_SUM/REDUCE_MAX + auto_close = 1800s; verified live via gateway_canary_pod_health incident 0.ofbqxms0ka30 auto-closing in 124s) and Finding B ([10m]/600s operational scrape-liveness tolerance; 0 false alerts during fc0152a rolling deploy vs. 24 across 6 prior deploys)
- Criterion 5 citation sweep (#862) + v4.1.0 GitHub release-body erratum (2026-11-22)
- Independent keyless-WIF failure surfacing (run 45086730009) followed by back-to-back green runs on main (run 45093811570 incident 0.ofcas2dn1itq and run 45094311801 incident 0.ofcawbsajse8, 37 operational messages preserved, 0 Terraform drift)
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