Skip to content

fix(worker): bug-bash batch 2 — grace close, reaper grace, autopsy dedup, cursor - #78

Merged
mastermanas805 merged 2 commits into
masterfrom
fix/bugbash-worker-batch2-2026-06-02
Jun 2, 2026
Merged

mastermanas805 merged 2 commits into
masterfrom
fix/bugbash-worker-batch2-2026-06-02

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

Four confirmed bugs from the 2026-06-02 platform bug bash.

P1 #5 billing_reconciler: terminal downgrade left the payment_grace_periods row active → perpetual dunning emails + redundant terminate. Added TerminateActiveGracePeriod (status→terminated) to the grace interface, called in the terminal branch.

P1 #8 orphan_sweep PASS 4: customer-namespace reaper excluded pending resources AND had no creation-grace → could delete a live mid-provision namespace. Added pending to the live-token set + a namespace-age grace mirroring PASS 3.

P2 #15 deploy_failure_autopsy: re-inserted a deploy.failed audit row (new id) per reconciler retry → duplicate failure emails (forwarder dedups by audit_id). Now idempotent per deployment (metadata->>'deploy_id').

P2 #18 scanChargeUndeliverable: jumping the cursor to now() on an empty window skipped late-visible rows. Leave it unchanged on empty (rolling 1h look-back, cheap re-scan).

Local: build + vet + full internal/jobs package green. 🤖 Generated with Claude Code

…autopsy dedup, cursor

Four confirmed bugs from the 2026-06-02 platform bug bash:

- #5 (P1) billing_reconciler: a terminal Razorpay status downgraded the team
  but left the active payment_grace_periods row open, so payment_grace_reminder
  emitted dunning emails forever and the terminator later re-acted on an
  already-cancelled subscription. Add TerminateActiveGracePeriod to the
  gracePeriodOpener interface (status→'terminated', terminated_at=now()) and
  call it in the terminal-downgrade branch (fail-open).

- #8 (P1) orphan_sweep PASS 4: the customer-namespace reaper excluded 'pending'
  resources from the live-token set AND had no creation-grace, so a sweep
  during two-phase provisioning could DELETE a live, mid-provision namespace.
  Add 'pending' to fetchLiveResourceTokens and a namespace-age grace check
  (skip if younger than orphanNoDBRowGrace) mirroring PASS 3.

- #15 (P2) deploy_failure_autopsy: emitDeployFailedAudit inserted a new
  deploy.failed audit row (new id) on every reconciler retry, and the forwarder
  dedups by audit_id (not deployment) → duplicate failure emails. Make it
  idempotent: skip the INSERT when a deploy.failed row already exists for the
  deployment (metadata->>'deploy_id'). Fail-open on probe error.

- #18 (P2) billing_reconciler scanChargeUndeliverable: jumping the cursor to
  now() on an empty window skipped rows that became visible a moment later
  (clock skew / late commit). Leave the cursor unchanged on count==0 — the 1h
  look-back re-applies and re-scanning the small indexed window is cheap.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mastermanas805
mastermanas805 enabled auto-merge (squash) June 2, 2026 17:10
- orphan_sweep PASS 4: young-namespace (within grace) + age-lookup-error are
  NOT reaped (#8 grace branches).
- emitDeployFailedAudit: dedup-hit skips the INSERT (#15 idempotency branch).
- dbGracePeriodOpener.TerminateActiveGracePeriod: UPDATE success + error-wrap.
- billing terminal downgrade still succeeds when the grace-close errors (#5
  fail-open warn branch).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mastermanas805
mastermanas805 merged commit 67f9f1f into master Jun 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant