Repository navigation
scripts: billing reconciliation sandbox (#3623 prep) - #3643
Merged
Merged
Conversation
…rep) Idempotent setup that creates a 6-fixture matrix in Stripe test mode + local Postgres covering the failure modes the cron auto-remediator must handle: Lina-class missed-webhook, multi-sub data[0] bug, email mismatch, orphan customer, WorkOS no-resolution, and a healthy control. setup-sandbox.ts is idempotent (Stripe customers tagged via metadata.aao_sandbox_id; DB rows by org-id prefix). Refuses to run unless STRIPE_SECRET_KEY is sk_test_* and DATABASE_URL is local — protects prod from accidental sandbox writes. verify-sandbox.ts runs the stripe-sub-reflected-in-org-row invariant (merged in #3627) against the local sandbox and prints the violations. Lets reconciliation work be observed end-to-end without exercising real member accounts. Companion infrastructure for #3623. No production code touched; pure dev tooling. Also serves as the substrate for future billing-flow work that needs reproducible cross-system fixtures. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This was referenced Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a deterministic, idempotent fixture set for the cron auto-remediation work in #3623. Pure dev tooling — no production code touched.
Why
Building the cron auto-remediator (Path B of #3623) needs to exercise several edge cases that are hard to reproduce on demand:
customer.subscription.createdwebhook (the Lina case)data[0]bug in/sync)The sandbox sets these up in Stripe test mode + local Postgres so each can be observed end-to-end against the real Stripe wire format and real DB state — per repo CLAUDE.md preference for not over-mocking.
What it does
server/scripts/setup-sandbox.tscreates 6 fixtures:lina_classsubscription_status=NULL, owner inorganization_membershipshealthysubscription_status='active'email_mismatchmulti_subdata[0]bug fix verificationorphanworkos_no_resolutionorganization_membershipsrowserver/scripts/verify-sandbox.tsruns thestripe-sub-reflected-in-org-rowinvariant (merged in #3627) against the local sandbox and prints the violations.Safety
STRIPE_SECRET_KEYstarts withsk_test_DATABASE_URLhostname ends with.fly.dev,.flycast, or.internalmetadata.aao_sandbox_fixture=true(trivial cleanup)AAO Sandbox -and useaao-sandbox.testemail domain--teardownflag removes everythingVerified locally
healthycorrectly produces no violation ✓multi_subcorrectly picks the membership sub only (not the event-ticket non-membership sub) ✓Test plan
npx tsc --noEmit--teardownremoves everythingRefs
🤖 Generated with Claude Code