Skip to content

fix(worker): backup scheduler covers hobby_plus + *_yearly + refunds quota on failure - #27

Merged
mastermanas805 merged 1 commit into
masterfrom
fix-h-worker
May 14, 2026
Merged

mastermanas805 merged 1 commit into
masterfrom
fix-h-worker

Conversation

@mastermanas805

Copy link
Copy Markdown
Member

Summary

Worker companion to InstaNode-dev/api#107 (FIX-H). Closes the worker-side BugBash B36 backup items:

Test plan

  • +3 new test cases: TestScheduler_HobbyPlus_OnSlotInserts, TestScheduler_YearlyVariants_BackupHourly, TestCanonicalTier
  • TestRunner_* updated for the new backup_kind + sha256 row shape
  • go test ./... green (worker module)
  • go build ./... green

Deploy notes

🤖 Generated with Claude Code

…quota on failure

Wave FIX-H worker companion to InstaNode-dev/api#107. Closes the worker-
side gaps in BugBash B36.

#56/#R6 — scheduler tier set
  The hardcoded `tier IN ('hobby','pro','growth','team')` silently
  excluded hobby_plus and every _yearly variant: paying hobby_plus /
  hobby_plus_yearly / pro_yearly customers received zero scheduled
  backups. The fix widens the IN list to every tier whose plans.yaml
  row has backup_retention_days > 0 (hobby, hobby_plus, pro, growth,
  team plus all _yearly counterparts) and treats hobby/hobby_plus as
  daily-slot cadence (canonicalTier strips _yearly).

#59 — SHA-256 integrity
  pg_dump → gzip output is now teed through a sha256.Hash via
  io.MultiWriter; the hex digest is stamped into the new
  resource_backups.sha256 column (migration 043 ships in api PR
  #107) at finalize. On failure the digest is NOT written so the
  restore handler treats it as "unknown integrity, skip the check".

#65/#Q47 — refund manual-backup counter on failure
  New WithRefundClient wires the runner to call
  POST /internal/teams/:id/backup-quota/refund (HS256 with
  WORKER_INTERNAL_JWT_SECRET) when a MANUAL backup row fails
  terminally. Scheduled-row failures skip the refund. Idempotent on
  the api side — a worker restart that re-processes the same backup
  id is a no-op.

Tests
  - TestScheduler_HobbyPlus_OnSlotInserts (regression for #56/#R6)
  - TestScheduler_YearlyVariants_BackupHourly
  - TestCanonicalTier
  - Existing TestRunner_HappyPath / _PgDumpFails / _ClaimRace updated
    to expect backup_kind + sha256 in the row shape

DO NOT TOUCH list respected — no edits to circuit/, apiclient internals
beyond using New() at the boundary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mastermanas805
mastermanas805 merged commit d9d409d into master May 14, 2026
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