feat: effective tariff rate source (#1790)

* feat: effective tariff rate source

* fix(trade): extract parse helpers, fix tests, add health monitoring

- Extract htmlToPlainText/toIsoDate/parseBudgetLabEffectiveTariffHtml
  to scripts/_trade-parse-utils.mjs so tests can import directly
- Fix toIsoDate to use month-name lookup instead of fragile
  new Date(\`\${text} UTC\`) which is not spec-guaranteed
- Replace new Function() test reconstruction with direct ESM import
- Add test fixtures for parser patterns 2 and 3 (previously untested)
- Add tariffTrendsUs to health.js STANDALONE_KEYS + SEED_META
  (key trade:tariffs:v1:840:all:10, maxStaleMin 900 = 2.5x the 6h TTL)

* fix(test): update sourceVersion assertion for budgetlab addition

---------

Co-authored-by: Elie Habib <elie.habib@gmail.com>
This commit is contained in:
Fayez Bast
2026-03-19 01:45:32 +02:00
committed by GitHub
parent 5ba0d8db83
commit cf1fdefe92
17 changed files with 560 additions and 20 deletions

View File

@@ -334,6 +334,8 @@ components:
upstreamUnavailable:
type: boolean
description: True if upstream fetch failed and results may be stale/empty.
effectiveTariffRate:
$ref: '#/components/schemas/EffectiveTariffRate'
description: Response containing tariff trend datapoints.
TariffDataPoint:
type: object
@@ -363,6 +365,26 @@ components:
type: string
description: WTO indicator code used for this datapoint.
description: Single tariff data point for a reporter-partner-product combination.
EffectiveTariffRate:
type: object
properties:
sourceName:
type: string
description: Source name for the effective-rate estimate.
sourceUrl:
type: string
description: Canonical source URL for the estimate/methodology.
observationPeriod:
type: string
description: Human-readable observation period (for example "December 2025").
updatedAt:
type: string
description: ISO 8601 date when the source page was last updated, if known.
tariffRate:
type: number
format: double
description: Effective tariff rate (percentage).
description: Current effective tariff estimate for countries with coverage beyond WTO MFN baselines.
GetTradeFlowsRequest:
type: object
properties: