← all branches

fix/tariff-cov

needs attentionviewing older commit
5f2213e · incrementalpre-PRreviewed 2026-08-09 05:35 UTC1H · 6M · 10L · 8I
The branch
Purpose
Fix a series of correctness and data-integrity bugs in the CFE tariff rate scrape pipeline found via review panels and mutation testing.
Goal
Close all prior review-panel findings: assertApplied read-back, honest denominator, Finalize idempotency, FailJob Catch→ExecutionFailed, CI unit-test filter discipline.
Sub-goals
  • SG-1: assertApplied verification (year/month/state/division) on every CFE cascade response
  • SG-2: honest denominator via expectedPairsFor from request, not survivors
  • SG-3: decideFinalizeJob idempotency (terminal job = redelivery, not InvalidTransition)
  • SG-4: FailJob Catch → ExecutionFailed in SFN definition
  • SG-5: CI unit filter uses ONE rule (no per-file exclusions)
  • SG-6: Tariff watchdog security guard (non-main refs → staging only)
  • SG-7: Admin gate tests for tariff-jobs handler
  • SG-8: Issue references point at real Linear issues (BAT-316, BAT-317)
The changes (whole branch)
What
assertApplied function verifies year/month/state/division from CFE read-back; missing 'selected' marker no longer treated as failure. decideFinalizeJob returns stored result on redelivery of terminal job. FailJob Catch→ExecutionFailed added to SFN. CI pr-checks.yml removes per-file exclusion for lazy-db-client.test.ts (renamed to integration). Watchdog workflow gates non-main refs to staging matrix leg only. Admin gate tests added for tariff-jobs. Issue references corrected.
Why
Prior review panels found 8+ correctness bugs in the CFE rate pipeline; this window closes the last set of panel findings and tightens the security posture of the watchdog.
Areas
domains/utility+59727services/utility+2214230.github/workflows+33513apps/platform+1250infra/cdk+284103packages/api+182.claude/rules+1290scripts/db+1040
Blast
33 files across 8 areas, +3807/−375 (full branch). No public API changes. No DB migrations. No prod data writes. CFE-domain only.
CFE no-migration no-api-change
typecheckunit-testscoderabbit· no .coderabbit.yamlgh-ci· no open PR

Findings · 15

correctness3

medium

decideFinalizeJob null-result fallback silently substitutes input data on corrupt-terminal redelivery

domains/utility/src/tariff-job/tariff-job.decisions.ts:217

low

assertApplied skips municipality despite comment claiming state+municipality+division

services/utility/tariffs/cfe/src/handlers/tariff-collector.lambda.ts:511

low

StubClient year-mismatch test cannot isolate which assertApplied leg fires

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

security4

high

if: guard bypassable — PROD_POSTGRES_URL is repo-level secret (BAT-316, documented)

.github/workflows/tariff-coverage-watchdog.yml:46

medium

GITHUB_OUTPUT newline-injection safety relies on two separate stripping steps

.github/workflows/tariff-coverage-watchdog.yml:120

low

DB-derived detail in issue body — cosmetic markdown injection possible

.github/workflows/tariff-coverage-watchdog.yml:143

low

set -uo pipefail without -e in evaluate step

.github/workflows/tariff-coverage-watchdog.yml:84

conventions2

medium

finalizeTariffJobShell emits JOB_COMPLETED on status='failed' (pre-existing)

domains/utility/src/tariff-job/tariff-job.shells.ts:231

low

decideStartJob idempotent path doesn't suppress duplicate JOB_STARTED (pre-existing)

domains/utility/src/tariff-job/tariff-job.decisions.ts:132

tests3

medium

lazy-db-client 'unit' test still requires live DB connection in practice

domains/utility/src/__tests__/lazy-db-client.test.ts:23

medium

Municipality mismatch not covered in assertApplied tests

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

low

UNKNOWN_DIVISION test doesn't assert divisionsDiscovered includes the unknown in denominator

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

improvement3

medium

runPersist spurious block scope removed but not mentioned in commit message

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

low

Admin-gate test boilerplate duplicated from catalog-admin-gate.test.ts verbatim

apps/platform/src/api/handlers/__tests__/tariff-jobs-admin-gate.test.ts:1

low

reapStaleActiveJob calls Date.now() twice — partially defeats shouldReap extraction

services/utility/tariffs/cfe/src/handlers/tariff-transition.lambda.ts:151

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:35current
  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: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