From 4976c8e83678e6aedc87f26890fd54e7ec008d5b Mon Sep 17 00:00:00 2001 From: Brian McMahon Date: Wed, 20 May 2026 12:30:12 -0700 Subject: [PATCH] refactor(changelog-incident-mirror): smoke test migrates to alpha_engine_lib.alerts CLI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per ROADMAP L146 (SOTA / institutional-approach sub-sub-rule). Second inline-alerts site named in the ROADMAP — sibling PR alpha-engine #200 migrates the alpha-engine/infrastructure/health_checker.sh half. infrastructure/lambdas/changelog-incident-mirror/deploy.sh: raw `aws sns publish` → `python -m alpha_engine_lib.alerts publish`. SNS target stays identical (default `alpha-engine-alerts` topic resolution), so the changelog-incident-mirror Lambda still receives the message and the smoke test still verifies end-to-end. `--no-telegram` keeps the deliberate-per-deploy noise off the operator channel; `severity=info` matches the smoke-test semantics. Lib pin v0.20.0 → v0.21.0 in BOTH requirements.txt AND Dockerfile (lockstep, per the test_lib_pin_lockstep regression test). v0.21.0 is the alerts-module floor; v0.20 → v0.21 is additive (just the alerts module). Suite: 1401 passed (vs 1400 baseline — lib v0.21 doesn't break any existing consumer). Closes alpha-engine-data half of ROADMAP L146 (P2). After both PRs merge, `grep -rE "aws sns publish.*alpha-engine-alerts|api.telegram.org/bot" infrastructure/ deploy/ --include="*.sh"` returns zero hits across both alpha-engine and alpha-engine-data. Co-Authored-By: Claude Opus 4.7 (1M context) --- Dockerfile | 2 +- .../changelog-incident-mirror/deploy.sh | 26 ++++++++++++++----- requirements.txt | 2 +- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index faef76c..e69f9c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ RUN microdnf install -y git && microdnf clean all # requirements file so the [flow_doctor]-only install above isn't # overridden by the [arcticdb,flow_doctor,rag] extras pinned for EC2. COPY requirements.txt ${LAMBDA_TASK_ROOT}/ -RUN pip install --no-cache-dir "alpha-engine-lib[flow_doctor] @ git+https://github.com/cipher813/alpha-engine-lib@v0.20.0" && \ +RUN pip install --no-cache-dir "alpha-engine-lib[flow_doctor] @ git+https://github.com/cipher813/alpha-engine-lib@v0.21.0" && \ grep -vE "^#|^$|^pytest|^python-dotenv|^boto3|^botocore|^s3transfer|^alpha-engine-lib" requirements.txt > /tmp/req-lambda.txt && \ pip install --no-cache-dir -r /tmp/req-lambda.txt && \ rm -rf /root/.cache/pip /tmp/req-lambda.txt diff --git a/infrastructure/lambdas/changelog-incident-mirror/deploy.sh b/infrastructure/lambdas/changelog-incident-mirror/deploy.sh index 8745585..06a3634 100755 --- a/infrastructure/lambdas/changelog-incident-mirror/deploy.sh +++ b/infrastructure/lambdas/changelog-incident-mirror/deploy.sh @@ -102,15 +102,29 @@ aws lambda wait function-updated \ echo "✓ Deployed." # Smoke test: publish a single SNS message and verify the entry lands. +# Migrated 2026-05-20 (ROADMAP L146) from raw ``aws sns publish`` to the +# canonical ``alpha_engine_lib.alerts`` primitive (v0.21.0, lib #52). +# Skips Telegram on purpose: this is a deliberate deploy smoke test, not +# a real failure event, and a per-deploy operator ping would be noise. +# SNS path stays identical (same default topic `alpha-engine-alerts`), +# so the changelog-incident-mirror Lambda still sees the message. SMOKE_ARG="${1:-}" if [[ "${SMOKE_ARG}" == "--smoke" ]]; then - echo "Smoke-testing via SNS publish..." + echo "Smoke-testing via alerts.publish (SNS-only, severity=info)..." TS=$(date -u +%s) - aws sns publish \ - --topic-arn "arn:aws:sns:${REGION}:711398986525:alpha-engine-alerts" \ - --subject "deploy.sh smoke test ${TS}" \ - --message "Verifying changelog-incident-mirror after deploy ${TS}" \ - --query 'MessageId' --output text >/dev/null + # Resolve Python with alpha_engine_lib installed — prefer repo-local + # .venv, fall back to system python3 (mirrors the alpha-engine + # health_checker.sh pattern). + _alert_python="python3" + if [ -x "$(dirname "$0")/../../../.venv/bin/python" ]; then + _alert_python="$(dirname "$0")/../../../.venv/bin/python" + fi + "$_alert_python" -m alpha_engine_lib.alerts publish \ + --severity info \ + --no-telegram \ + --source alpha-engine-data/changelog-incident-mirror/deploy.sh \ + --message "deploy.sh smoke test ${TS}: Verifying changelog-incident-mirror after deploy" \ + > /dev/null echo " → Published. Entry should land in s3://alpha-engine-research/changelog/entries/ within ~3s." echo " → Check with: aws s3 ls s3://alpha-engine-research/changelog/entries/$(date -u +%Y-%m-%d)/ --recursive | tail" fi diff --git a/requirements.txt b/requirements.txt index a64ce73..e60597b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,4 +15,4 @@ arcticdb>=6.11 # flow-doctor is pulled in transitively via alpha-engine-lib[flow_doctor]. # psycopg2-binary + pgvector now come via [rag] (added in lib v0.3.0, # direct pins dropped 2026-05-20 after >2-week soak on v0.20.0). -alpha-engine-lib[arcticdb,flow_doctor,rag] @ git+https://github.com/cipher813/alpha-engine-lib@v0.20.0 +alpha-engine-lib[arcticdb,flow_doctor,rag] @ git+https://github.com/cipher813/alpha-engine-lib@v0.21.0