Skip to content

Email outbox follow-ups from the #254 second reviews #273

Closed

Description

@JOY

Why

Non-blocking findings from the PO's second reviews of the #254 email outbox (DOS/DOS.Me#1782 merged at 82f01409, #257 merged at 3108be3). None blocks beta; fix before mail volume grows.

Items

  1. Purge scan cost (DOS.Me purge_outbox step 2). Rows are never deleted, so every batch scans all settled rows sequentially. Once a call passes PostgREST's 8 s statement_timeout, it rolls back and repeats daily. Add a partial index on updated_at for settled rows that still hold payload, recipient_email, to_email or recipient_user_id. Consider deleting rows older than N years.
  2. Email hashes kept forever. to_email_hash and email_suppressions.email_hash are unsalted SHA-256, which can be reversed by guessing addresses. Clear to_email_hash for deleted accounts in purge step 1, or switch to a keyed hash (HMAC with a server secret).
  3. Purge vs an in-flight send (step 1). Leave rows that are sending with an unexpired lease, so a mid-send row is not marked skipped/no_recipient.
  4. A held payment request has no terminal state while its campaign stays stopped. It is retried hourly forever. Also recompute the reminder day in the payload on refresh.
  5. An aborted claim can still commit (Give outbox.ts claim with its 10 s abort). The leased rows burn an attempt and can go dead (lease_expired) unsent on the last attempt. Log it, or lengthen the claim timeout.
  6. Production host list. PRODUCTION_SUPABASE_HOSTS must be updated by hand if a custom Supabase domain is added. Consider asking the DB which environment it is.
  7. Migration comment. The header of 20261123090000_give_email_outbox.sql says no shared environment ran the first draft. The PR's Supabase Preview branch did. Correct it in a later migration's notes, or leave a note here (comment-only edits to merged migrations are not allowed).

Done when

Items 1–5 are fixed with pgTAP or vitest coverage; 6–7 are decided and noted.

Activity

  1. added theissue type on Nov 19, 2026
  2. JOY commented on Nov 19, 2026

    @JOY
    ContributorAuthor

    Item from the #254 Brevo follow-up (Give PO, 2026-11-19): send-time credit check. Not for now.

    When the Brevo account runs out of email credits, Brevo does not refuse SMTP sends. It accepts them (250) and holds them in its own queue until credits come back (help.brevo.com article 115000188150, "All email credits have been used"). Give then records the row sent, nothing shows on /admin/emails, and Give's maximum ages do not apply, so a pledge reminder could arrive after its deadline. The 10k-emails-a-month plan is shared with the rest of DOS.

    Proposal: before claiming, send-outbox reads the remaining email credits through Brevo's account API (GET /v3/account, plan credits). At 0 (or below a small floor) it claims nothing and reports it, so rows stay in our outbox and our max-age rules apply. Show the remaining credits on /admin/emails.

    • Needs a Brevo API key, a separate secret from the SMTP key (owner step).
    • Brevo's API rate limits apply.
    • Cache the value for a minute or two.
    • Applies only while the provider is Brevo.
  3. JOY commented on Nov 19, 2026

    @JOY
    ContributorAuthor

    Update to the Brevo credits item above (issuecomment-7000161949): no longer applies. JOY chose AWS SES for Give, not Brevo (#279). SES refuses a send once the 24-hour quota is used up (454 Throttling failure: Daily message quota exceeded), and Give now holds those emails visibly on /admin/emails, so no separate credit check is needed.

  4. added
    po:agyOwned by Antigravity PO (mutual-exclusion parallel PO label)
    on Nov 22, 2026
  5. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    claim: executor=Antigravity session=f288dd9f-af9e-42ae-b0d8-f40b2c2a731f scope="DOS/DOS.Me + DOS/Give #273 email outbox follow-ups" branch=antigravity/give-273-outbox-followups target=2026-11-23

  6. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    checkpoint: session=f288dd9f-af9e-42ae-b0d8-f40b2c2a731f Phase 1 DB PR opened: https://github.com/DOS/DOS.Me/pull/1870 (head ae021cca57cdc00e8e41e26580e0a4672a4c7824, migration 20261130110000_give_outbox_followups.sql + give_outbox_followups.test.sql). Waiting on required CI checks and fresh-context review.

  7. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    checkpoint: session=f288dd9f-af9e-42ae-b0d8-f40b2c2a731f Phase 1 DB PR https://github.com/DOS/DOS.Me/pull/1870 is green on final head b1ee7daf374ef5c328c649711bc3b1adbbe75e52: all 4 required CI checks pass (Give pgTAP tests (dev) 48/48 suites including 31/31 give_outbox_followups.test.sql, Supabase migration replay (dev), Repository integrity, Validate pnpm lockfile), dos[bot] approved on final head SHA, gemini-code-assist thread fixed & resolved, and fresh-context verification subagent returned CLEAN_PASS. Ready for PO acceptance; Phase 2 (DOS/Give app PR for Items 5 & 6) will follow after DOS/DOS.Me#1870 merges and Beta turns green.

  8. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    PO acceptance: merge at b1ee7daf374ef5c328c649711bc3b1adbbe75e52 (DOS/DOS.Me#1870 -> dev)

  9. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    checkpoint: session=f288dd9f-af9e-42ae-b0d8-f40b2c2a731f Phase 1 DB PR https://github.com/DOS/DOS.Me/pull/1870 merged into DOS/DOS.Me dev at 0223503c0195725ef56c6618bd229a5af8707468 (after PO acceptance on b1ee7daf374ef5c328c649711bc3b1adbbe75e52). Starting Phase 2 (DOS/Give app PR for Items 5 & 6).

  10. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    Decision notes for Items 6 and 7 (session=f288dd9f-af9e-42ae-b0d8-f40b2c2a731f):

    • Item 6 (PRODUCTION_SUPABASE_HOSTS vs asking the DB): Decided not to store or query an in-DB environment marker. Production, Beta, and Supabase Preview branches all replay the exact same committed migrations from DOS/DOS.Me (manual out-of-band DB edits are forbidden by DOS/DOS.Me/AGENTS.md, and Preview branches inherit migrated rows), so an in-DB flag would be copied into Preview/Beta and fail to isolate environments. Instead, usesProductionDatabase() now checks both PRODUCTION_SUPABASE_HOSTS / PRODUCTION_SUPABASE_REF and the JWT ref claim of SUPABASE_SERVICE_ROLE_KEY / NEXT_PUBLIC_SUPABASE_ANON_KEY, catching unlisted custom domains automatically whenever JWT keys are used while staying synchronous and fail-safe before any RPC touches the DB.
    • Item 7 (20261123090000_give_email_outbox.sql comment): Recorded the historical correction in the header of DOS/DOS.Me migration 20261130110000_give_outbox_followups.sql (merged in DOS/DOS.Me#1870 at 0223503c0195725ef56c6618bd229a5af8707468): lines 138–139 of 20261123090000_give_email_outbox.sql (and lines 90–91 of 20261129180000_give_outbox_and_donation_plans_late_apply.sql) stated no shared environment ran the earlier draft, whereas the PR's Supabase Preview branch did run it (Beta and Production did not). The merged migration files were left untouched.
  11. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    checkpoint: session=f288dd9f-af9e-42ae-b0d8-f40b2c2a731f Phase 2 app PR #305 is green on final head 02f03f1: Lint, Build all apps, Vercel, and DOScout all pass; dos[bot] approved on final head SHA; fresh-context verification subagent returned CLEAN_PASS. Ready for PO acceptance.

  12. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    checkpoint: session=f288dd9f-af9e-42ae-b0d8-f40b2c2a731f Both Phase 1 and Phase 2 merged into dev and verified on Beta:

  13. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    handoff: session=f288dd9f-af9e-42ae-b0d8-f40b2c2a731f to=83b36fa6-8c08-49d6-aeec-63bab02a5e52

    Done:

    Evidence:

    • DOS/DOS.Me#1870 head b1ee7daf374ef5c328c649711bc3b1adbbe75e52: all 4 required CI checks green (Give pgTAP tests (dev) 48/48 suites / 31/31 new tests, Supabase migration replay (dev), Repository integrity, Validate pnpm lockfile), dos[bot] APPROVED, fresh-context reviewer CLEAN_PASS, PO accepted. Beta 0223503c0195725ef56c6618bd229a5af8707468: Supabase Preview success, Beta migration history preparation only success.
    • DOS/Give#305 head 02f03f111ac989f4913476dfdbb33cfe18736bdf: Lint, Build all apps, Vercel, DOScout all green, 180/180 vitest files (2622/2622 tests), dos[bot] APPROVED, fresh-context reviewer CLEAN_PASS, PO accepted. Beta 6c69036641fbffe87be6144324edbaa40678ec0f: Vercel (beta.give.vn) Deployment completed (https://vercel.com/metados/give/55mh7owjxvatPzJjNgq39Lp88MAv).

    Remaining:

    • Promote DOS/DOS.Me (20261130110000_give_outbox_followups.sql) and DOS/Give (6c690366) from dev to main (Production) in the next owner-approved Production release, then close #273.

    Next step:

    • Include DOS/DOS.Me 0223503c0195725ef56c6618bd229a5af8707468 and DOS/Give 6c69036641fbffe87be6144324edbaa40678ec0f in the next dev -> main promotion after JOY's approval.

    Blockers: none (awaiting scheduled Production promotion).
    Branch: merged into DOS/DOS.Me dev (0223503c0195725ef56c6618bd229a5af8707468) and DOS/Give dev (6c69036641fbffe87be6144324edbaa40678ec0f); local worktrees and branches removed.

  14. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    claim: executor=Antigravity session=83b36fa6-8c08-49d6-aeec-63bab02a5e52 scope="Production steps, waiting for next Production promotion (DOS/DOS.Me#1870 + #305 -> main)" branch=antigravity/give-273-outbox-followups target=2026-11-29

  15. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    checkpoint: session=83b36fa6-8c08-49d6-aeec-63bab02a5e52 waiting for next Production promotion (dev -> main after JOY approval); Phase 1 DOS/DOS.Me#1870 merged at 0223503c0195725ef56c6618bd229a5af8707468 (Supabase Preview Beta success) and Phase 2 #305 merged at 6c69036 (Vercel https://beta.give.vn success).

  16. JOY commented on Nov 22, 2026

    @JOY
    ContributorAuthor

    done: session=83b36fa6-8c08-49d6-aeec-63bab02a5e52 agent=antigravity
    Promoted to Production (2026-11-22):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    line:platformProduct line: platformpo:agyOwned by Antigravity PO (mutual-exclusion parallel PO label)

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions