From 0e8505d6654e023ec3c63fec9a4028a1ef40617f Mon Sep 17 00:00:00 2001 From: wjames111 Date: Mon, 30 Nov 2026 10:42:30 -0500 Subject: [PATCH 1/8] AIGS-26 Add stage smoke test, rollback runbook and alert map --- .github/workflows/stage-smoke-test.yml | 27 +++++++++ docs/safety-nets.md | 80 ++++++++++++++++++++++++++ scripts/safety-nets/README.md | 2 + scripts/stage-smoke-test.sh | 45 +++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 .github/workflows/stage-smoke-test.yml create mode 100644 docs/safety-nets.md create mode 100755 scripts/stage-smoke-test.sh diff --git a/.github/workflows/stage-smoke-test.yml b/.github/workflows/stage-smoke-test.yml new file mode 100644 index 0000000000..ec0d33e4b7 --- /dev/null +++ b/.github/workflows/stage-smoke-test.yml @@ -0,0 +1,27 @@ +name: Stage smoke test + +on: + # update-staging pushes with GITHUB_TOKEN, which never fires a push event, so follow its run instead + workflow_run: + workflows: [Update staging] + types: [completed] + push: + branches: [staging] + workflow_dispatch: + +concurrency: + group: stage-smoke-test + cancel-in-progress: true + +jobs: + smoke: + if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - uses: actions/checkout@v7 + - name: Find the staging commit + id: sha + run: echo "sha=$(git ls-remote origin refs/heads/staging | cut -f1)" >> "$GITHUB_OUTPUT" + - name: 🔥 Smoke test stage + run: scripts/stage-smoke-test.sh "${{ steps.sha.outputs.sha }}" diff --git a/docs/safety-nets.md b/docs/safety-nets.md new file mode 100644 index 0000000000..f0a04ca9f0 --- /dev/null +++ b/docs/safety-nets.md @@ -0,0 +1,80 @@ +# Safety nets: alerts, self-healing, rollback, smoke test + +What catches a bad deploy, who hears about it, and how to undo it. + +## Who gets told + +| What breaks | What notices | Who hears | +| --------------------------------------- | -------------------------------------------------------- | ---------------------------------------- | +| Users hit errors on mpdx.org | Datadog RUM monitors `MPDX React ... [prod]` | Caleb Cox, by email | +| One prod page makes users rage-click | `MPDX React frustration rate by page [prod]` | Caleb, plus the self-healing agent | +| Someone runs the alert-path check below | `MPDX React safety-net test [stage]` | Caleb, plus the self-healing agent | +| mpdx.org sign-in or main pages break | Datadog synthetic `MPDX React Production Synthetic Test` | PagerDuty `MPDX` | +| A stage deploy breaks sign-in | GitHub workflow `Stage smoke test` | Whoever started the run, by GitHub email | + +Real stage errors (about a dozen a day, mostly hydration warnings and crawlers) alert no one. The stage monitor only fires on the test error, so it proves the alert path without daily noise. + +The monitors and synthetics live in `cru-terraform` at `applications/mpdx/web-react/datadog.tf`. Change who gets told there (`local.rum_alert_handle`), not in the Datadog UI. + +Errors reach Datadog two ways: the browser RUM SDK (`pages/_document.page.tsx`) and Rollbar (`pages/_app.page.tsx`, `pages/api/utils/rollBar.ts`). The monitors read RUM. Thresholds come from `yarn calibrate-safety-nets`; see `scripts/safety-nets/README.md`. + +## Self-healing agent + +Caleb's agent runs outside this repo. Monitors that mention `@webhook-self-healing-agent` send it the alert. It looks into the cause and opens a PR here as `app/cru-self-healing-agent`, titled `[No ticket — safety-net monitor ] ...`. Review those PRs like any other. + +## Check the alert path + +Run this after changing a monitor, a webhook, or the RUM setup. + +1. Open https://stage.mpdx.org/login. +2. In the browser console run `DD_RUM.addError(new Error('Safety net test'))`. +3. Within 5 minutes Caleb gets a `MPDX React safety-net test [stage]` email and the agent opens one PR. Close that PR without merging. + +The monitor matches the words `Safety net test` exactly (`local.rum_canary_search` in `datadog.tf`). Change both together. + +## Smoke test after each stage deploy + +`.github/workflows/stage-smoke-test.yml` runs after every staging update. It waits for stage.mpdx.org to serve the new commit (Amplify takes about 10 minutes), then runs `scripts/stage-smoke-test.sh`, which checks: + +- `/login` renders a Sign In button +- the build's JavaScript loads +- Okta sign-in is offered +- the stage GraphQL API answers + +Run it by hand from the Actions tab, or locally: + +```bash +scripts/stage-smoke-test.sh "$(git ls-remote origin refs/heads/staging | cut -f1)" +``` + +It stops at the Okta button because CI has no test account. The prod synthetic signs in and opens Contacts, Tasks and Donations every 15 minutes, so a broken logged-in page is caught within 15 minutes of reaching mpdx.org. + +## Roll back + +Amplify (app `d3dytjb8adxkk5`) builds `main` to mpdx.org and `staging` to stage.mpdx.org. Each push builds and deploys in about 10 minutes. + +**Fastest: redeploy the last good build.** Needs AWS console access to the Amplify account. + +1. AWS console > Amplify > mpdx-react > the `main` (or `staging`) branch. +2. Open the last build that worked and choose **Redeploy this version**. +3. The site serves the old build in a few minutes. `main` still has the bad commit, so revert it next or the next merge ships it again. + +**Always works: revert the commit.** Anyone who can merge a PR can do this. + +1. `git revert -m 1 ` on a new branch, push, open a PR. +2. Once it merges to `main`, Amplify rebuilds mpdx.org and `update-staging.yml` carries the revert to stage. + +**Stage only.** If the bad change only went to stage through the `On Staging` label, remove the label and revert its merge on `staging`: + +```bash +git switch staging && git pull +git revert -m 1 +git push origin staging +``` + +Stage is a shared branch. Revert only the merge you mean to, and never force-push it. + +## Drill log + +| Date | Env | What | Time to roll back | Notes | +| ---- | --- | ---- | ----------------- | ----- | diff --git a/scripts/safety-nets/README.md b/scripts/safety-nets/README.md index 5760abb812..65d3005f45 100644 --- a/scripts/safety-nets/README.md +++ b/scripts/safety-nets/README.md @@ -43,3 +43,5 @@ caveats). - **Alerting is email, not paging.** Critical breaches notify `local.rum_alert_handle` in `datadog.tf`; warnings are visible in Datadog but notify no one. + +Who gets alerted, the self-healing agent, the stage smoke test and how to roll back: see `docs/safety-nets.md`. diff --git a/scripts/stage-smoke-test.sh b/scripts/stage-smoke-test.sh new file mode 100755 index 0000000000..fb7a27b392 --- /dev/null +++ b/scripts/stage-smoke-test.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Post-deploy smoke test for stage: waits for the new build, then checks the sign-in path end to end. +# Usage: scripts/stage-smoke-test.sh [site url] [api url] +set -euo pipefail + +SHA="${1:?commit sha required}" +SITE="${2:-https://stage.mpdx.org}" +API="${3:-https://api.stage.mpdx.org/graphql}" +WAIT_SECONDS="${WAIT_SECONDS:-2400}" +POLL_SECONDS="${POLL_SECONDS:-30}" + +fail() { + echo "::error::$1" + exit 1 +} + +echo "Waiting up to ${WAIT_SECONDS}s for ${SITE} to serve ${SHA}" +deadline=$((SECONDS + WAIT_SECONDS)) +until curl -fsS "${SITE}/login" | grep -q "${SHA}"; do + if ((SECONDS >= deadline)); then + fail "${SITE} never served ${SHA}. Check the Amplify build for the staging branch." + fi + sleep "${POLL_SECONDS}" +done +echo "Live: ${SITE} is serving ${SHA}" + +login_html="$(curl -fsS "${SITE}/login")" || fail "GET /login failed" +grep -qi "sign in" <<<"${login_html}" || fail "/login rendered without a Sign In button" +echo "OK: /login renders" + +manifest="$(grep -oE '/_next/static/[^"]+/_buildManifest\.js' <<<"${login_html}" | head -1)" +[[ -n "${manifest}" ]] || fail "/login has no build manifest script" +curl -fsS -o /dev/null "${SITE}${manifest}" || fail "Build assets did not load: ${manifest}" +echo "OK: build assets load" + +curl -fsS "${SITE}/api/auth/providers" | grep -q '"okta"' || + fail "/api/auth/providers has no Okta provider, so nobody can sign in" +echo "OK: Okta sign-in is offered" + +curl -fsS -X POST "${API}" -H 'content-type: application/json' \ + -d '{"query":"{__typename}"}' | grep -q '"Query"' || + fail "The GraphQL API at ${API} did not answer" +echo "OK: GraphQL API answers" + +echo "Smoke test passed for ${SHA}" From fee4a992cc8bc3ec194905d1962cc89b93f9c2c3 Mon Sep 17 00:00:00 2001 From: wjames111 Date: Mon, 30 Nov 2026 10:59:51 -0500 Subject: [PATCH 2/8] fix: address agent-review findings 1 2 3 5 6 7 8 10 11 --- .github/workflows/stage-smoke-test.yml | 14 +++++++++---- scripts/stage-smoke-test.sh | 27 +++++++++++++++----------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/.github/workflows/stage-smoke-test.yml b/.github/workflows/stage-smoke-test.yml index ec0d33e4b7..1f780a8b78 100644 --- a/.github/workflows/stage-smoke-test.yml +++ b/.github/workflows/stage-smoke-test.yml @@ -9,19 +9,25 @@ on: branches: [staging] workflow_dispatch: -concurrency: - group: stage-smoke-test - cancel-in-progress: true +permissions: + contents: read jobs: smoke: if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' + # Job level, so a skipped run never cancels one that is checking a deploy + concurrency: + group: stage-smoke-test + cancel-in-progress: true runs-on: ubuntu-latest timeout-minutes: 45 steps: - uses: actions/checkout@v7 - name: Find the staging commit id: sha - run: echo "sha=$(git ls-remote origin refs/heads/staging | cut -f1)" >> "$GITHUB_OUTPUT" + run: | + sha="$(git ls-remote origin refs/heads/staging | cut -f1)" + [ -n "$sha" ] || { echo "::error::Could not read the staging branch"; exit 1; } + echo "sha=$sha" >> "$GITHUB_OUTPUT" - name: 🔥 Smoke test stage run: scripts/stage-smoke-test.sh "${{ steps.sha.outputs.sha }}" diff --git a/scripts/stage-smoke-test.sh b/scripts/stage-smoke-test.sh index fb7a27b392..a8d708a81c 100755 --- a/scripts/stage-smoke-test.sh +++ b/scripts/stage-smoke-test.sh @@ -14,32 +14,37 @@ fail() { exit 1 } +fetch() { + curl -fsS --max-time 30 "$@" +} + echo "Waiting up to ${WAIT_SECONDS}s for ${SITE} to serve ${SHA}" deadline=$((SECONDS + WAIT_SECONDS)) -until curl -fsS "${SITE}/login" | grep -q "${SHA}"; do +login_html="" +while true; do + login_html="$(fetch "${SITE}/login" || true)" + [[ "${login_html}" == *"${SHA}"* ]] && break if ((SECONDS >= deadline)); then - fail "${SITE} never served ${SHA}. Check the Amplify build for the staging branch." + fail "${SITE} never served ${SHA}. Check the Amplify build for the staging branch, and that the page still embeds the build SHA in its Datadog RUM config." fi sleep "${POLL_SECONDS}" done echo "Live: ${SITE} is serving ${SHA}" -login_html="$(curl -fsS "${SITE}/login")" || fail "GET /login failed" -grep -qi "sign in" <<<"${login_html}" || fail "/login rendered without a Sign In button" +[[ "${login_html}" == *">Sign In<"* ]] || fail "/login rendered without a Sign In button" echo "OK: /login renders" -manifest="$(grep -oE '/_next/static/[^"]+/_buildManifest\.js' <<<"${login_html}" | head -1)" +manifest="$(grep -oE '/_next/static/[^"]+/_buildManifest\.js' <<<"${login_html}" | head -1 || true)" [[ -n "${manifest}" ]] || fail "/login has no build manifest script" -curl -fsS -o /dev/null "${SITE}${manifest}" || fail "Build assets did not load: ${manifest}" +fetch -o /dev/null "${SITE}${manifest}" || fail "Build assets did not load: ${manifest}" echo "OK: build assets load" -curl -fsS "${SITE}/api/auth/providers" | grep -q '"okta"' || - fail "/api/auth/providers has no Okta provider, so nobody can sign in" +providers="$(fetch "${SITE}/api/auth/providers" || true)" +[[ "${providers}" == *'"okta"'* ]] || fail "/api/auth/providers has no Okta provider, so nobody can sign in" echo "OK: Okta sign-in is offered" -curl -fsS -X POST "${API}" -H 'content-type: application/json' \ - -d '{"query":"{__typename}"}' | grep -q '"Query"' || - fail "The GraphQL API at ${API} did not answer" +graphql="$(fetch -X POST "${API}" -H 'content-type: application/json' -d '{"query":"{__typename}"}' || true)" +[[ "${graphql}" == *'"Query"'* ]] || fail "The GraphQL API at ${API} did not answer" echo "OK: GraphQL API answers" echo "Smoke test passed for ${SHA}" From ac8d6fe2f96898a18e13be93844a44aac91ca71f Mon Sep 17 00:00:00 2001 From: wjames111 Date: Mon, 30 Nov 2026 11:00:28 -0500 Subject: [PATCH 3/8] chore(review): record finding outcomes --- .../address-2320-20261130T160028Z-f58f88.jsonl | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .claude/review/learnings/feedback/address-2320-20261130T160028Z-f58f88.jsonl diff --git a/.claude/review/learnings/feedback/address-2320-20261130T160028Z-f58f88.jsonl b/.claude/review/learnings/feedback/address-2320-20261130T160028Z-f58f88.jsonl new file mode 100644 index 0000000000..94c4e65b92 --- /dev/null +++ b/.claude/review/learnings/feedback/address-2320-20261130T160028Z-f58f88.jsonl @@ -0,0 +1,11 @@ +{"ts":"2026-11-30T16:00:28.237Z","reviewId":"address-2320","id":"f1","signature":"74a10e299fb7","agent":"code-review","category":"correctness","severity":7,"file":".github/workflows/stage-smoke-test.yml","message":"Workflow-level concurrency with cancel-in-progress lets a skipped or failed Update staging run cancel a real smoke test in progress. The new run then skips its own job, so the new staging build is never checked and no failure email goes out.","outcome":"accepted"} +{"ts":"2026-11-30T16:00:28.238Z","reviewId":"address-2320","id":"f2","signature":"607d24de024a","agent":"testing","category":"determinism","severity":4,"file":"scripts/stage-smoke-test.sh","message":"`curl ... | grep -q` under `set -o pipefail` can report failure even when grep matched, because grep -q exits early and curl may die with exit 23 (SIGPIPE/write error). The same pattern is used for the Okta and GraphQL checks, so the smoke test can flake red or time out after 40 minutes on a healthy deploy.","outcome":"accepted"} +{"ts":"2026-11-30T16:00:28.238Z","reviewId":"address-2320","id":"f3","signature":"9b3b55d34e90","agent":"code-review","category":"correctness","severity":4,"file":"scripts/stage-smoke-test.sh","message":"No curl call sets a timeout, so a hung connection runs into the 45-minute job timeout instead of the script's own error message.","outcome":"accepted"} +{"ts":"2026-11-30T16:00:28.238Z","reviewId":"address-2320","id":"f5","signature":"fd774164337c","agent":"code-review","category":"correctness","severity":4,"file":"scripts/stage-smoke-test.sh","message":"The Sign In check greps case-insensitively for 'sign in', which also matches help text, so it passes even if the button is gone.","outcome":"accepted"} +{"ts":"2026-11-30T16:00:28.238Z","reviewId":"address-2320","id":"f6","signature":"fc6b4aa71c5f","agent":"security","category":"supply-chain-ci","severity":3,"file":".github/workflows/stage-smoke-test.yml","message":"The workflow has no `permissions:` block, so the GITHUB_TOKEN gets the repo default scope, which may be write. The job only needs to read the repo.","outcome":"accepted"} +{"ts":"2026-11-30T16:00:28.238Z","reviewId":"address-2320","id":"f7","signature":"98b64c25f95a","agent":"code-review","category":"security","severity":3,"file":".github/workflows/stage-smoke-test.yml","message":"The workflow has no permissions block, so it gets the default token scope though it only reads.","outcome":"accepted"} +{"ts":"2026-11-30T16:00:28.238Z","reviewId":"address-2320","id":"f8","signature":"d2d88a145952","agent":"code-review","category":"correctness","severity":3,"file":".github/workflows/stage-smoke-test.yml","message":"A git ls-remote failure inside the echo is swallowed, so the next step fails with a misleading 'commit sha required' message.","outcome":"accepted"} +{"ts":"2026-11-30T16:00:28.238Z","reviewId":"address-2320","id":"f10","signature":"f05ff3ccc280","agent":"code-review","category":"correctness","severity":3,"file":"scripts/stage-smoke-test.sh","message":"Page checks run on a second /login fetch that is not verified to be the new build.","outcome":"accepted"} +{"ts":"2026-11-30T16:00:28.238Z","reviewId":"address-2320","id":"f11","signature":"a066efd6ac71","agent":"code-review","category":"correctness","severity":3,"file":"scripts/stage-smoke-test.sh","message":"If the manifest is missing, grep exits 1 under pipefail and set -e kills the script before the fail message prints.","outcome":"accepted"} +{"ts":"2026-11-30T16:00:28.238Z","reviewId":"address-2320","id":"f4","signature":"0cabc3708852","agent":"code-review","category":"correctness","severity":4,"file":"scripts/stage-smoke-test.sh","message":"The build-live check depends on the commit SHA appearing in /login HTML, which reportedly only happens through the Datadog RUM config. If that config changes, every run waits 40 minutes and blames Amplify.","outcome":"dismissed","dismissalReason":"intentional","dismissalDetail":"the page embeds the build SHA through the RUM config and the error message now says to check that too"} +{"ts":"2026-11-30T16:00:28.238Z","reviewId":"address-2320","id":"f9","signature":"4816ecf45c4b","agent":"code-review","category":"correctness","severity":3,"file":"scripts/stage-smoke-test.sh","message":"On busy days the 40-minute wait may be shorter than Amplify's queue, causing false failures.","outcome":"dismissed","dismissalReason":"intentional","dismissalDetail":"WAIT_SECONDS is configurable and 40 minutes is well past normal Amplify build time"} From f308347b90fff7bc6cc8ed813869843de7a23d29 Mon Sep 17 00:00:00 2001 From: wjames111 Date: Mon, 30 Nov 2026 11:12:40 -0500 Subject: [PATCH 4/8] fix: address agent-review findings 12 13 14 15 18 --- .github/workflows/stage-smoke-test.yml | 4 ++-- scripts/stage-smoke-test.sh | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/stage-smoke-test.yml b/.github/workflows/stage-smoke-test.yml index 1f780a8b78..20c77cce87 100644 --- a/.github/workflows/stage-smoke-test.yml +++ b/.github/workflows/stage-smoke-test.yml @@ -15,10 +15,10 @@ permissions: jobs: smoke: if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' - # Job level, so a skipped run never cancels one that is checking a deploy + # Job level so skipped runs never join; queue instead of cancel so every deploy gets checked concurrency: group: stage-smoke-test - cancel-in-progress: true + cancel-in-progress: false runs-on: ubuntu-latest timeout-minutes: 45 steps: diff --git a/scripts/stage-smoke-test.sh b/scripts/stage-smoke-test.sh index a8d708a81c..d0ad6b1cf2 100755 --- a/scripts/stage-smoke-test.sh +++ b/scripts/stage-smoke-test.sh @@ -15,17 +15,21 @@ fail() { } fetch() { - curl -fsS --max-time 30 "$@" + curl -fsS --max-time 30 --retry 3 --retry-all-errors "$@" } echo "Waiting up to ${WAIT_SECONDS}s for ${SITE} to serve ${SHA}" deadline=$((SECONDS + WAIT_SECONDS)) login_html="" +last_status="" while true; do - login_html="$(fetch "${SITE}/login" || true)" - [[ "${login_html}" == *"${SHA}"* ]] && break + if html="$(curl -fsS --max-time 30 "${SITE}/login")"; then + login_html="${html}" + [[ "${login_html}" == *"${SHA}"* ]] && break + fi + last_status="$(curl -s -o /dev/null -w '%{http_code}' --max-time 30 "${SITE}/login" || true)" if ((SECONDS >= deadline)); then - fail "${SITE} never served ${SHA}. Check the Amplify build for the staging branch, and that the page still embeds the build SHA in its Datadog RUM config." + fail "${SITE} never served ${SHA} (last /login status: ${last_status}). Check the Amplify build for the staging branch, and that the page still embeds the build SHA in its Datadog RUM config." fi sleep "${POLL_SECONDS}" done @@ -39,11 +43,12 @@ manifest="$(grep -oE '/_next/static/[^"]+/_buildManifest\.js' <<<"${login_html}" fetch -o /dev/null "${SITE}${manifest}" || fail "Build assets did not load: ${manifest}" echo "OK: build assets load" -providers="$(fetch "${SITE}/api/auth/providers" || true)" +providers="$(fetch "${SITE}/api/auth/providers")" || fail "GET /api/auth/providers failed" [[ "${providers}" == *'"okta"'* ]] || fail "/api/auth/providers has no Okta provider, so nobody can sign in" echo "OK: Okta sign-in is offered" -graphql="$(fetch -X POST "${API}" -H 'content-type: application/json' -d '{"query":"{__typename}"}' || true)" +graphql="$(fetch -X POST "${API}" -H 'content-type: application/json' -d '{"query":"{__typename}"}')" || + fail "The GraphQL API request to ${API} failed" [[ "${graphql}" == *'"Query"'* ]] || fail "The GraphQL API at ${API} did not answer" echo "OK: GraphQL API answers" From 5b040e090f08fc3bff33818125ab9045d0b5bb58 Mon Sep 17 00:00:00 2001 From: wjames111 Date: Mon, 30 Nov 2026 11:13:18 -0500 Subject: [PATCH 5/8] chore(review): record finding outcomes --- .../feedback/address-2320-20261130T161318Z-4ed56e.jsonl | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .claude/review/learnings/feedback/address-2320-20261130T161318Z-4ed56e.jsonl diff --git a/.claude/review/learnings/feedback/address-2320-20261130T161318Z-4ed56e.jsonl b/.claude/review/learnings/feedback/address-2320-20261130T161318Z-4ed56e.jsonl new file mode 100644 index 0000000000..2ec172d865 --- /dev/null +++ b/.claude/review/learnings/feedback/address-2320-20261130T161318Z-4ed56e.jsonl @@ -0,0 +1,7 @@ +{"ts":"2026-11-30T16:13:18.334Z","reviewId":"address-2320","id":"f1","signature":"da048dd7501d","agent":"code-review","category":"correctness","severity":5,"file":"scripts/stage-smoke-test.sh","message":"The poll loop keeps partial /login HTML when curl fails (for example a timeout after the head arrives), so a matching SHA can break the loop and later checks fail with a misleading reason.","outcome":"accepted"} +{"ts":"2026-11-30T16:13:18.339Z","reviewId":"address-2320","id":"f2","signature":"3ebdb3f4d4b6","agent":"code-review","category":"correctness","severity":4,"file":".github/workflows/stage-smoke-test.yml","message":"A newer non-skipped run still cancels an older run that is checking a real deploy, so the author of the earlier breaking change gets no failure email.","outcome":"accepted"} +{"ts":"2026-11-30T16:13:18.339Z","reviewId":"address-2320","id":"f3","signature":"4694d0edf24a","agent":"code-review","category":"correctness","severity":4,"file":"scripts/stage-smoke-test.sh","message":"Because fetch uses curl -f, a /login that returns 5xx yields no body, so the loop waits the full WAIT_SECONDS and blames the Amplify build.","outcome":"accepted"} +{"ts":"2026-11-30T16:13:18.339Z","reviewId":"address-2320","id":"f4","signature":"8ca2ef11a134","agent":"code-review","category":"correctness","severity":4,"file":"scripts/stage-smoke-test.sh","message":"The post-live checks now have a 30 second timeout with a single try, so one slow cold start or brief 502 fails an otherwise healthy deploy.","outcome":"accepted"} +{"ts":"2026-11-30T16:13:18.339Z","reviewId":"address-2320","id":"f7","signature":"d6d4ff2deda8","agent":"code-review","category":"correctness","severity":3,"file":"scripts/stage-smoke-test.sh","message":"Network failures on the providers and GraphQL checks become empty strings, so the error annotation describes a content problem instead of a request failure.","outcome":"accepted"} +{"ts":"2026-11-30T16:13:18.339Z","reviewId":"address-2320","id":"f5","signature":"1587f4304d08","agent":"code-review","category":"conventions","severity":3,"file":".github/workflows/stage-smoke-test.yml","message":"Commit fee4a992c bundles about nine unrelated fixes, which goes against the one-logical-change-per-commit rule.","outcome":"dismissed","dismissalReason":"intentional","dismissalDetail":"one commit per review round keeps the fix commits easy to find"} +{"ts":"2026-11-30T16:13:18.339Z","reviewId":"address-2320","id":"f6","signature":"de2a7ea7a436","agent":"code-review","category":"correctness","severity":3,"file":"scripts/stage-smoke-test.sh","message":"The exact `>Sign In<` match fails on non-Okta sites where the button text differs, giving a misleading no-button error.","outcome":"dismissed","dismissalReason":"intentional","dismissalDetail":"stage.mpdx.org always uses Okta and its button text is Sign In"} From 7ea39ea7cf5910c3e0cdc1cce3a0c91d5e94e241 Mon Sep 17 00:00:00 2001 From: wjames111 Date: Mon, 30 Nov 2026 12:57:28 -0500 Subject: [PATCH 6/8] AIGS-26 Record the stage rollback drill --- docs/safety-nets.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/safety-nets.md b/docs/safety-nets.md index f0a04ca9f0..aa7468d210 100644 --- a/docs/safety-nets.md +++ b/docs/safety-nets.md @@ -76,5 +76,6 @@ Stage is a shared branch. Revert only the merge you mean to, and never force-pus ## Drill log -| Date | Env | What | Time to roll back | Notes | -| ---- | --- | ---- | ----------------- | ----- | +| Date | Env | What | Time to roll back | Notes | +| ---------- | ----- | ---------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| 2026-11-30 | stage | `git revert` of the latest AIGS-26 merge on `staging` (6594f88b4), then a revert of the revert (34ad2b97d) | 9 min to live (17:38:54 push, 17:47:57 live and smoke test passed, UTC). Restore took 8.5 min | Both "Stage smoke test" workflow runs passed on their own. No Amplify console access needed. | From c34bfb65e6dc4c43d9a7f896cc67fb596bde9621 Mon Sep 17 00:00:00 2001 From: wjames111 Date: Tue, 1 Dec 2026 12:20:14 -0500 Subject: [PATCH 7/8] AIGS-26 Correct runbook notes on Rollbar, the prod synthetic, squash reverts and the pending monitor --- docs/safety-nets.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/safety-nets.md b/docs/safety-nets.md index aa7468d210..9787477f3c 100644 --- a/docs/safety-nets.md +++ b/docs/safety-nets.md @@ -14,18 +14,20 @@ What catches a bad deploy, who hears about it, and how to undo it. Real stage errors (about a dozen a day, mostly hydration warnings and crawlers) alert no one. The stage monitor only fires on the test error, so it proves the alert path without daily noise. -The monitors and synthetics live in `cru-terraform` at `applications/mpdx/web-react/datadog.tf`. Change who gets told there (`local.rum_alert_handle`), not in the Datadog UI. +The RUM monitors live in `cru-terraform` at `applications/mpdx/web-react/datadog.tf`. Change who gets told there (`local.rum_alert_handle`), not in the Datadog UI. The prod synthetic is not in Terraform: it is managed in the Datadog UI as test [`dbu-dqa-6nj`](https://app.datadoghq.com/synthetics/details/dbu-dqa-6nj). -Errors reach Datadog two ways: the browser RUM SDK (`pages/_document.page.tsx`) and Rollbar (`pages/_app.page.tsx`, `pages/api/utils/rollBar.ts`). The monitors read RUM. Thresholds come from `yarn calibrate-safety-nets`; see `scripts/safety-nets/README.md`. +For mpdx.org, Datadog sees front-end errors only through the browser RUM SDK (`pages/_document.page.tsx`), and the monitors read RUM. The app also reports errors to Rollbar (`pages/_app.page.tsx`, `pages/api/utils/rollBar.ts`), but those stay in Rollbar: the Rollbar alerts Datadog gets come from the `mpdx_api` project, not this app. Thresholds come from `yarn calibrate-safety-nets`; see `scripts/safety-nets/README.md`. ## Self-healing agent -Caleb's agent runs outside this repo. Monitors that mention `@webhook-self-healing-agent` send it the alert. It looks into the cause and opens a PR here as `app/cru-self-healing-agent`, titled `[No ticket — safety-net monitor ] ...`. Review those PRs like any other. +Caleb's agent runs outside this repo. Monitors that mention `@webhook-self-healing-agent` send it the alert. It looks into the cause and opens a PR here as `app/cru-self-healing-agent`, with the safety-net monitor id in its title. Review those PRs like any other. ## Check the alert path Run this after changing a monitor, a webhook, or the RUM setup. +The `MPDX React safety-net test [stage]` monitor comes from [CruGlobal/cru-terraform#13703](https://github.com/CruGlobal/cru-terraform/pull/13703). Until that PR is applied, step 3 below gets no email and no agent PR. + 1. Open https://stage.mpdx.org/login. 2. In the browser console run `DD_RUM.addError(new Error('Safety net test'))`. 3. Within 5 minutes Caleb gets a `MPDX React safety-net test [stage]` email and the agent opens one PR. Close that PR without merging. @@ -61,7 +63,7 @@ Amplify (app `d3dytjb8adxkk5`) builds `main` to mpdx.org and `staging` to stage. **Always works: revert the commit.** Anyone who can merge a PR can do this. -1. `git revert -m 1 ` on a new branch, push, open a PR. +1. On a new branch, revert the commit the PR landed as: `git revert ` for a squash merge, or `git revert -m 1 ` for a merge commit. Push and open a PR. 2. Once it merges to `main`, Amplify rebuilds mpdx.org and `update-staging.yml` carries the revert to stage. **Stage only.** If the bad change only went to stage through the `On Staging` label, remove the label and revert its merge on `staging`: @@ -74,6 +76,8 @@ git push origin staging Stage is a shared branch. Revert only the merge you mean to, and never force-push it. +To bring the change back to stage later, revert the revert (`git revert `) and push. Re-adding the label does not work: git sees the PR as already merged. + ## Drill log | Date | Env | What | Time to roll back | Notes | From ab8ed5fefbf8888cc3811cb413c81437a5f8248f Mon Sep 17 00:00:00 2001 From: wjames111 Date: Tue, 1 Dec 2026 12:20:16 -0500 Subject: [PATCH 8/8] AIGS-26 Fail fast on a broken /login and pin the checkout action --- .github/workflows/stage-smoke-test.yml | 6 +++--- scripts/stage-smoke-test.sh | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stage-smoke-test.yml b/.github/workflows/stage-smoke-test.yml index 20c77cce87..f7a664d27f 100644 --- a/.github/workflows/stage-smoke-test.yml +++ b/.github/workflows/stage-smoke-test.yml @@ -15,14 +15,14 @@ permissions: jobs: smoke: if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' - # Job level so skipped runs never join; queue instead of cancel so every deploy gets checked + # Job level so skipped runs never join. GitHub keeps one pending run, so a burst of deploys gets the newest one checked concurrency: group: stage-smoke-test cancel-in-progress: false runs-on: ubuntu-latest - timeout-minutes: 45 + timeout-minutes: 50 steps: - - uses: actions/checkout@v7 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - name: Find the staging commit id: sha run: | diff --git a/scripts/stage-smoke-test.sh b/scripts/stage-smoke-test.sh index d0ad6b1cf2..a4b8181c11 100755 --- a/scripts/stage-smoke-test.sh +++ b/scripts/stage-smoke-test.sh @@ -22,12 +22,22 @@ echo "Waiting up to ${WAIT_SECONDS}s for ${SITE} to serve ${SHA}" deadline=$((SECONDS + WAIT_SECONDS)) login_html="" last_status="" +server_errors=0 while true; do if html="$(curl -fsS --max-time 30 "${SITE}/login")"; then login_html="${html}" + server_errors=0 [[ "${login_html}" == *"${SHA}"* ]] && break + else + last_status="$(curl -s -o /dev/null -w '%{http_code}' --max-time 30 "${SITE}/login" || true)" + if [[ "${last_status}" == 5* ]]; then + server_errors=$((server_errors + 1)) + # A deploy swap can blip once; ten in a row means /login itself is broken + ((server_errors >= 10)) && fail "/login keeps returning ${last_status}, so the page is broken, not the Amplify build" + else + server_errors=0 + fi fi - last_status="$(curl -s -o /dev/null -w '%{http_code}' --max-time 30 "${SITE}/login" || true)" if ((SECONDS >= deadline)); then fail "${SITE} never served ${SHA} (last /login status: ${last_status}). Check the Amplify build for the staging branch, and that the page still embeds the build SHA in its Datadog RUM config." fi