← all branches

fix/tariff-cov

needs attentionviewing older commit
3eb9789 · incrementalpre-PRreviewed 2026-08-06 18:30 UTC0H · 3M · 5L · 14I
The branch
Purpose
Harden the CFE tariff pipeline against silent data-loss: three real incidents (Valle de México month lost, DL/DM got Sur's prices, July 2026 missed with no failed job) all shared the pattern of the pipeline reporting 'completed' while data was silently lost or wrong.
Goal
Close four distinct silent-failure vectors in the tariff pipeline and add a blocking CI unit-test gate so regression pins can actually fail a PR.
Sub-goals
  • SG-1: Refuse to overwrite a month with a scrape carrying no energy price (hasEnergyComponent guard)
  • SG-2: Make every skipped zone visible as a pipeline failure (not swallowed as a no-op)
  • SG-3: Report every unresolved TOU zone in the seed and exit non-zero
  • SG-4: Make unit tests blocking (remove continue-on-error) with a clean quarantine list
  • SG-5: Add behavioral pin suites for persist and transition stages
The changes (whole branch)
What
Added hasEnergyComponent guard in persistScrapedRatesShell; moved table-count check inside retry loop; extracted runPersist with PersistDeps injection for testability; exported helper functions from tariff-transition for testability; fixed seed-tou-schedules to report all unresolved zones and exit(1); added 358-line test suite (persist + transition); made CI unit gate blocking with quarantine list.
Why
Three incidents traced to the pipeline reporting success while data was silently wrong or missing. The common thread: no failure was surfaced, so no alert fired and no repair ran.
Areas
services/utility/tariffs/cfe/src/handlers+689185services/utility/tariffs/cfe/__tests__+3580domains/utility/src/tariff-rate+802packages/database+10339.github/workflows+16910infra/cdk/src/stacks/services/utility/tariffs/cfe+246101
Blast
27 files, +1655/−377 across tariff pipeline, domain scrape layer, TOU seed, CI config, and new test suites. No schema migrations. No API surface changes.
pipeline-behavior-change ci-gate-now-blocking
typecheck· not run in review contextunit-tests· not run in review contextgh-ci· GitHub auth unavailable on runnercoderabbit· no .coderabbit.yaml

Findings · 8

correctness2

medium

ZONE_SKIPPED error message misleading for no_energy_component skips

services/utility/tariffs/cfe/src/handlers/tariff-persist.lambda.ts:134

Message says 'no pricing zone resolved' but the zone WAS resolved — scrape lacked energy price. Operator looks for missing pricing-zone row when issue is scrape data quality.

low

no_energy_component skip may undercount divisionsPersisted in multi-rate-type scenarios

services/utility/tariffs/cfe/src/handlers/tariff-persist.lambda.ts:166

Conservative (safe) but inconsistent: ratesPersisted grows while divisionsPersisted does not when a zone passes GDMTH but fails PDBT on energy check. No test covers this interaction.

tests2

medium

persist.test.ts: no_energy_component skip path not exercised through runPersist

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

collected() hardcodes genCost: '1.5' — no_energy_component branch in shell is unreachable. A regression removing hasEnergyComponent from persistScrapedRatesShell would pass all persist tests.

medium

persist.test.ts: schedule-shell success path and error path not pinned

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

schedulesPersisted > 0 never tested. schedule-shell !result.ok path unpinned — mirrors the failure-swallowing pattern this branch was written to fix.

improvement4

low

Superfluous nested block inside runPersist — leftover from withDb refactor

services/utility/tariffs/cfe/src/handlers/tariff-persist.lambda.ts:82

Remove bare { on line 82 and its matching } on line 176. No behavioral effect.

low

hasEnergyComponent cast to Record<string,...> unnecessary

domains/utility/src/tariff-rate/tariff-rate.scrape.ts:128

ENERGY_FIELDS values are already valid keyof RateComponents. Remove cast to keep type checker in the loop.

low

test:unit --exclude node_modules redundant

package.json:19

Vitest excludes node_modules by default. Drop to keep meaningful exclusions readable.

low

process.exit(0) on seed success path unnecessary

packages/database/src/seed-tou-schedules.ts:180

Async main exits 0 on natural return. Keep exit(1) on error/skip paths; remove exit(0) on success.

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:54
  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:30current
  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