← all branches

fix/bf-rollback

safeviewing older commit
baca7af · incrementalPR #259reviewed 2026-07-03 21:27 UTC0H · 0M · 3L
The branch
Purpose
Add a safe, idempotent rollback for the derived-bill-concepts backfill and extract shared ops guards/SQL helpers into a tested, reusable module.
Goal
PR #259 — fix/bf-rollback: rollback script + shared ops-guards module with CI-covered unit tests
Sub-goals
  • SG-1: Add rollback-derived-bill-concepts.ts (exact inverse of the backfill via DERIVED_CONCEPT_KEYS)
  • SG-2: Extract ops guards + SQL helpers into @batu/database/ops-guards (tested in CI)
  • SG-3: Refactor backfill to use shared module (eliminate duplication)
  • SG-4: Fix --rpu / --key array binding bug (ANY(jsArray) → scalar params via sql.join)
  • SG-5: Fix uuid cursor + restore console.error spy between parseLimit tests
The changes (whole branch)
What
Added afterEach(() => vi.restoreAllMocks()) to parseLimit describe block, closing a console.error spy leak that existed in two exit-path tests.
Why
Previous parseLimit exit-path tests called exit.mockRestore() inline but never restored the console.error spy, leaving it live across subsequent tests. This commit addresses loop-review feedback (#259).
Areas
packages/database+2740scripts+12174
Blast
6 files, +395/−74 — scripts + @batu/database only; no app/domain/migration changes
ops-script-only no-migrations no-domain-changes
typecheck· CI unavailable on runnertests· CI unavailable on runnercoderabbit· no .coderabbit.yaml

Findings · 3

tests2

low

afterEach is additive — inline exit.mockRestore() calls are now redundant

packages/database/src/__tests__/ops-guards.test.ts:40

afterEach restoreAllMocks() covers all spies including process.exit, making per-test exit.mockRestore() calls redundant (harmless but noisy). The real fix is closing the console.error spy leak.

low

console.error spy not asserted in exit-path tests

packages/database/src/__tests__/ops-guards.test.ts:54

Both exit-path tests suppress console.error but never assert it was called. Minor coverage gap.

improvement1

low

Two-tier teardown: afterEach + inline mockRestore create redundant pattern

packages/database/src/__tests__/ops-guards.test.ts:40

Unifying on afterEach alone removes duplicated teardown and prevents future divergence.

History · 5 commits

  1. cbdca09safeincremental0H · 0M · 0L2026-07-03 22:30
  2. baca7afsafeincremental0H · 0M · 3L2026-07-03 21:27current
  3. efb8a4fneeds attentionincremental0H · 1M · 7L2026-07-03 21:20
  4. b62fb9aneeds attentionincremental3H · 4M · 5L2026-07-03 21:04
  5. 0fd71fbneeds attentionfull0H · 4M · 2L2026-07-03 20:49