fix/tariff-cov
needs attentionviewing older commiteec3b04 · incrementalpre-PRreviewed 2026-08-07 18:27 UTC2H · 1M · 4L · 1I- Purpose
- Close four holes in the CFE tariff rate pipeline identified by the second review panel
- Goal
- Ensure all nine tariffs are always named explicitly in repair operations and the e2e gate cannot be bypassed by a file rename
- Sub-goals
- SG-1: Make rateTypes required in CreateTariffJobApiInputSchema — remove GDMTH-only default
- SG-2: Fix e2e smoke-test to track previous_filename on renamed files
- SG-3: Improve watchdog issue body with full rateTypes repair instructions
- SG-4: Strengthen config-integrity test to assert exact positional order for containedDivisions
- What
- rateTypes field made required in the API schema (breaking), jq filter extended in e2e.yml to capture renamed file paths, watchdog issue body now shows the full nine-tariff repair command, Valle de México config integrity test asserts exact zone order instead of sorted set.
- Why
- The previous GDMTH-only default was the same silent-failure pattern as the original pipeline incident — operators following the watchdog repair instructions would fix only one of nine tariffs. The renamed-file bug allowed a real prod scenario (middleware move) to skip the required smoke check.
- Areas
- .github/workflows+57−10packages/api/src/schemas+18−2services/utility/tariffs/cfe/__tests__+9−1domains/utility+108−14infra/cdk/src/stacks/services/utility/tariffs/cfe+246−101services/utility/tariffs/cfe/src+689−185scripts/db+104−0.claude/rules+95−0
- Blast
- 28 files, +1431/−314 across the branch. Core changes in tariff Lambda handlers and SFN stack; this increment is 4 files, +40/−9 (schema, CI, and test hardening only).
Findings · 8
correctness1
Hardcoded tariff list in watchdog may drift from rate-pages.json
.github/workflows/tariff-coverage-watchdog.yml:108
The repair instruction embeds a literal list of nine rate types; adding or retiring a tariff without updating this list silently gives operators a wrong repair command.
conventions2
JSDoc on rateTypes describes WHAT as well as WHY
packages/api/src/schemas/tariff-job.schemas.ts:22
Opening line restates what the schema already makes self-evident. The WHY and BAT-308 reference are valuable; the WHAT portion can be trimmed.
Watchdog hardcodes tariff list that duplicates registry
.github/workflows/tariff-coverage-watchdog.yml:108
Same drift risk as correctness lens; worth tracking in BAT-308 which already covers making the registry shareable.
tests4
No schema test verifying omitting rateTypes is rejected at API layer
packages/api/src/schemas/tariff-job.schemas.ts:39
tariff-job.schemas.test.ts does not exist in packages/api/src/__tests__/schemas/. The domain decision test verifies an empty array is rejected but doesn't cover the API parse layer. A body without rateTypes must parse-error with a 422 — this invariant is untested.
No double-parse idempotency test for CreateTariffJobApiInputSchema
packages/api/src/schemas/tariff-job.schemas.ts:39
Project convention (cfe-job.schemas.test.ts) requires a double-parse idempotency check when a schema has .default() values (ts-rest materialises defaults before the handler re-parses). divisions still has .default(null); no idempotency test exists for this schema.
Order test doesn't verify config→scraper column mapping
services/utility/tariffs/cfe/__tests__/config-integrity.test.ts:81
The test pins exact order ['DL','DM','DN'] correctly. But if extractRateCellTables is refactored, the test still passes while prices cross-pollinate. A companion test verifying index-0 maps to the first table column would close this.
Rename-detection jq change has no automated test
.github/workflows/e2e.yml:74
The jq expression is correct but untested. A mock fixture exercised by a shell script in scripts/ would prevent regression.
improvement1
Watchdog tariff list could be derived from rate-pages.json at runtime
.github/workflows/tariff-coverage-watchdog.yml:108
If the workflow reads rate-pages.json via jq at runtime, the list stays authoritative without manual sync.
History · 14 commits
- 1ed035eneeds attentionincremental0H · 2M · 5L2026-08-11 02:03
- fcbe80dblockedfull6H · 12M · 14L2026-08-10 22:02
- 92353bdblockedincremental1H · 9M · 7L2026-08-10 19:32
- 5f2213eneeds attentionincremental1H · 6M · 10L2026-08-09 05:35
- c30da44needs attentionincremental1H · 4M · 2L2026-08-09 04:54
- 5940f56needs attentionincremental0H · 3M · 7L2026-08-07 19:15
- f222512needs attentionfull2H · 9M · 15L2026-08-07 18:58
- eec3b04needs attentionincremental2H · 1M · 4L2026-08-07 18:27current
- 0b43396needs attentionincremental0H · 2M · 6L2026-08-07 01:39
- 3eb9789needs attentionincremental0H · 3M · 5L2026-08-06 18:30
- 87fc06aneeds attentionincremental0H · 4M · 9L2026-08-06 01:21
- 76bcc76needs attentionincremental0H · 1M · 5L2026-08-06 00:51
- 8948608needs attentionincremental0H · 3M · 4L2026-08-05 23:49
- e44f6bbneeds attentionfull3H · 6M · 9L2026-08-05 19:29