Weekly newsletter journey test (agent-hub "critical journey")
agent-hub's Monday job (factory smoke newsletter scotthavird.com, part of factory smoke --all) signs up a
throwaway address on the dev API, confirms it and checks the emails arrived. Contract: agent-hub
docs/smoke.md ("Critical journeys").
Flow
| Step | What happens |
|---|---|
| start | POST <dev api>/subscribe with X-Smoke-Token, body {email} (no Turnstile token) |
| check | reads the pending token from scotthavird-dev-tokens, POSTs the token to the real /confirm (a GET only renders a Confirm button), passes when the subscriber is confirmed and flagged is_test |
| emails | agent-hub expects 2 mails to the smoke address: "Confirm your subscription — Scott Havird's blog" and "You're subscribed to Scott Havird's blog" |
| cleanup | deletes that address's is_test rows from the dev subscribers and tokens tables |
| live | counts confirmed, non-test subscribers in prod over 30 days (read-only) |
scripts/smoke-newsletter implements these (bash + curl + jq + the AWS CLI; no node_modules). The address is
smoke+<slug>-newsletter-<run>@hublabsllc.com.
The smoke token
Turnstile stays on for everyone. iac/lambda/src/smoke.js treats a request as a smoke run only when all hold:
ENVIRONMENT is dev; the Lambda has SMOKE_TOKEN; the X-Smoke-Token header equals it (constant-time compare
of SHA-256 digests); the address matches ^smoke\+[a-z0-9-]+@hublabsllc\.com$. A smoke run skips only the
Turnstile check. Validation, rate limits (including the daily email cap), storage and the user's emails run as
normal. Smoke rows get is_test: true (subscribers and tokens), the owner's "New subscriber pending
confirmation" notice is not sent, and the daily digest ignores is_test rows. In prod the header does nothing
(SMOKE_TOKEN is never set there; var.smoke_token is only applied when environment == "dev").
Terraform: sensitive variable smoke_token (default ""), set only on the dev Lambda. agent-hub runs
scripts/smoke-newsletter provision with SMOKE_TOKEN in the environment (factory smoke token). That runs a
-target=aws_lambda_function.subscribe plan in the dev workspace with dev.tfvars and applies it only if the
plan changes nothing else: for aws_lambda_function.subscribe the only allowed differences are
environment.variables.SMOKE_TOKEN plus the code hash / last_modified fields; any other difference, in that
resource or another, aborts without applying ({"ok":false}, exit 0). No workflow applies dev (applies are
manual), so the token cannot live in CI yet; if one is added, switch the registry token to "actions": true. It needs the R2 backend file (iac/README.md) and AWS credentials on the owner's Mac.
Notes
- The dev SES account is in sandbox mode, so
hublabsllc.com(or the smoke addresses) must be verified in dev SES. agent-hub reads the received mail from its Hub, so mail tosmoke+…@hublabsllc.commust reach it. - The per-IP rate limit (5 signups/hour) applies to smoke runs too; the ratelimit table holds hashed IPs only and is not cleaned up (it expires by TTL).