← all branches

fix/tariff-cov

needs attentionviewing older commit
c30da44 · incrementalpre-PRreviewed 2026-08-09 04:54 UTC1H · 4M · 2L · 1I
The branch
Purpose
Close mutation-testing gaps in the CFE tariff scraper pipeline and fix a script injection in e2e.yml
Goal
Every test assertion that the previous review panel found was decorative is now load-bearing — the mutation that each test claims to kill actually causes it to fail
Sub-goals
  • SG-1: Shell-level wiring test for persistScrapedRatesShell (never-shrink + energy guards)
  • SG-2: Zone ordering vs distinctness fix in collector tests
  • SG-3: Tariff→page name binding test in config-integrity
  • SG-4: Recorded deps + TOU schedule + divisionsPersisted in persist tests
  • SG-5: GitHub Actions script injection fix (HEAD_REF via env:)
The changes (whole branch)
What
5 test files changed (+312/-11 lines). No production code modified. New shell-level mock test file. Strengthened 4 existing test suites. CI workflow security fix.
Why
Mutation testing on 5940f564 proved several assertions were decorative — reversing zone pairing, swapping guard args, and skipping the schedule loop all passed the full suite.
Areas
.github/workflows+973domains/utility/src/tariff-rate/__tests__+1360services/utility/tariffs/cfe/__tests__+16511
Blast
5 files, +312/-11. Test and CI only — zero production code changed.
CI· pre-PR branch, no CI rollupCodeRabbit· no .coderabbit.yaml

Findings · 8

correctness2

medium

rateComponents value not asserted — component-swap mutation survives

domains/utility/src/tariff-rate/__tests__/persist-scraped-rates.test.ts:81

The 'writes normally' test checks batchUpsert was called with 1 command but not that cmd.rateComponents equals the incoming components. A mutation substituting existing.rateComponents for rate.components writes stale data undetected.

medium

${{ vars.PLATFORM_PREVIEW_URL }} still inline in gate run: step

.github/workflows/e2e.yml

Admin-set only, low practical risk, but inconsistent with the env: routing stated in the comments.

conventions4

high

vi.mock factory references `q` without vi.hoisted — TDZ hazard in Vitest ESM

domains/utility/src/tariff-rate/__tests__/persist-scraped-rates.test.ts:22

vi.mock() factories are hoisted and run before the module body. `const q` is in the TDZ when the factory runs. Fix: `const q = vi.hoisted(() => ({ ... }))`.

medium

`as never` casts on db/actor instead of `as unknown as T`

domains/utility/src/tariff-rate/__tests__/persist-scraped-rates.test.ts:46

`as never` bypasses type checker entirely. Codebase pattern is `as unknown as Database`.

medium

Opaque casts in RecordedDeps — PersistScrapedRatesInput is importable

services/utility/tariffs/cfe/__tests__/persist.test.ts:73

Three `(input as { field: type })` casts instead of importing PersistScrapedRatesInput from @batu/utility-domain.

low

File name deviates from {entity}.{layer}.test.ts convention

domains/utility/src/tariff-rate/__tests__/persist-scraped-rates.test.ts:1

Should be tariff-rate.shells.test.ts per canonical-form.md.

tests1

low

Ordering assertion relies on ascending stub arithmetic

services/utility/tariffs/cfe/__tests__/collector.test.ts:404

Correctly kills reversal/rotation mutations. Fragile only to stub refactoring, not production bugs. Acceptable.

improvement1

info

Orphaned JSDoc comment

services/utility/tariffs/cfe/__tests__/collector.test.ts:146

Floating JSDoc with no attached declaration. Cosmetic.

History · 14 commits

  1. 1ed035eneeds attentionincremental0H · 2M · 5L2026-08-11 02:03
  2. fcbe80dblockedfull6H · 12M · 14L2026-08-10 22:02
  3. 92353bdblockedincremental1H · 9M · 7L2026-08-10 19:32
  4. 5f2213eneeds attentionincremental1H · 6M · 10L2026-08-09 05:35
  5. c30da44needs attentionincremental1H · 4M · 2L2026-08-09 04:54current
  6. 5940f56needs attentionincremental0H · 3M · 7L2026-08-07 19:15
  7. f222512needs attentionfull2H · 9M · 15L2026-08-07 18:58
  8. eec3b04needs attentionincremental2H · 1M · 4L2026-08-07 18:27
  9. 0b43396needs attentionincremental0H · 2M · 6L2026-08-07 01:39
  10. 3eb9789needs attentionincremental0H · 3M · 5L2026-08-06 18:30
  11. 87fc06aneeds attentionincremental0H · 4M · 9L2026-08-06 01:21
  12. 76bcc76needs attentionincremental0H · 1M · 5L2026-08-06 00:51
  13. 8948608needs attentionincremental0H · 3M · 4L2026-08-05 23:49
  14. e44f6bbneeds attentionfull3H · 6M · 9L2026-08-05 19:29