Skip to content

Add WTO trade policy intelligence service with tariffs, flows, and barriers#364

Merged
koala73 merged 4 commits intomainfrom
claude/add-wto-trade-policy-4gIzU
Feb 25, 2026
Merged

Add WTO trade policy intelligence service with tariffs, flows, and barriers#364
koala73 merged 4 commits intomainfrom
claude/add-wto-trade-policy-4gIzU

Conversation

@koala73
Copy link
Owner

@koala73 koala73 commented Feb 25, 2026

Summary

Adds comprehensive trade policy intelligence from WTO data sources, including trade restrictions, tariff trends, bilateral trade flows, and SPS/TBT barrier notifications. Implements a new TradeService with four RPC endpoints backed by the WTO Timeseries API, includes a new TradePolicyPanel UI component for visualizing trade data, and adds multilingual support across 16 languages.

Type of change

  • New feature
  • New data source / feed
  • API endpoints (/api/*)

Affected areas

  • API endpoints (/api/*)
  • Config / Settings
  • Desktop app (Tauri)
  • Other: New panel component, internationalization

Changes

Backend

  • Proto definitions (proto/worldmonitor/trade/v1/): Service definition and message types for trade restrictions, tariff trends, trade flows, and trade barriers
  • Generated server code (src/generated/server/worldmonitor/trade/v1/service_server.ts): Auto-generated TypeScript server interfaces and route handlers
  • RPC handlers (server/worldmonitor/trade/v1/):
    • get-trade-restrictions.ts: Fetches WTO quantitative restrictions and export controls
    • get-tariff-trends.ts: Fetches applied tariff rates over time
    • get-trade-flows.ts: Fetches bilateral export/import values with YoY changes
    • get-trade-barriers.ts: Fetches SPS/TBT barrier notifications
    • _shared.ts: WTO API integration, member code mappings, and shared utilities
  • Handler (server/worldmonitor/trade/v1/handler.ts): Aggregates RPC implementations

Frontend

  • Generated client code (src/generated/client/worldmonitor/trade/v1/service_client.ts): Auto-generated TypeScript client with circuit breaker support
  • Service (src/services/trade/index.ts): Client-side service with circuit breakers, caching, and error handling
  • UI Component (src/components/TradePolicyPanel.ts): Tabbed panel displaying restrictions, tariffs, flows, and barriers with source attribution
  • Internationalization: Added "Trade Policy" panel category and component strings to all 16 language files (en, ar, de, el, es, fr, it, ja, nl, pl, pt, ru, sv, th, tr, vi, zh)

Configuration

  • Runtime config (src/services/runtime-config.ts): Added WTO_API_KEY secret key support
  • Panel layout (src/app/panel-layout.ts, src/config/panels.ts): Registered TradePolicyPanel in layout and config
  • Data loader (src/app/data-loader.ts): Integrated trade data fetching into app initialization
  • Vite config (vite.config.ts): Added trade service module to API plugin
  • API routes (api/[domain]/v1/[rpc].ts): Registered trade service routes
  • Desktop config (src-tauri/sidecar/local-api-server.mjs, src-tauri/src/main.rs): Added WTO_API_KEY to allowed environment variables
  • Data freshness (src/services/data-freshness.ts): Added 'wto' data source tracking
  • Status panel (src/components/StatusPanel.ts): Added WTO to API list
  • Analytics (src/services/analytics.ts): Added WTO API key tracking
  • Commands (src/config/commands.ts): Added trade policy panel command

Testing

  • TypeScript compilation passes without errors
  • No API keys or secrets committed
  • Circuit breaker pattern ensures graceful degradation if WTO API is unavailable
  • Upstream unavailability is tracked and displayed to users

…cyPanel

Adds a new `trade` RPC domain backed by the WTO API (apiportal.wto.org) for
trade policy intelligence: quantitative restrictions, tariff timeseries,
bilateral trade flows, and SPS/TBT barrier notifications.

New files: 6 protos, generated server/client, 4 server handlers + shared WTO
fetch utility, client service with circuit breakers, TradePolicyPanel (4 tabs),
and full API key infrastructure (Rust keychain, sidecar, runtime config).

Panel registered for FULL and FINANCE variants with data loader integration,
command palette entry, status panel tracking, data freshness monitoring, and
i18n across all 17 locale files.

https://claude.ai/code/session_01HZXyoQp6xK3TX8obDzv6Ye
The delegated click handler was added inside render(), which runs
on every data update (4× per load cycle). Since the listener targets
this.content (a persistent container), each call stacked a duplicate
handler. Moving it to the constructor binds it exactly once.

https://claude.ai/code/session_01HZXyoQp6xK3TX8obDzv6Ye
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@vercel
Copy link

vercel bot commented Feb 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
worldmonitor Ready Ready Preview, Comment Feb 25, 2026 10:51am
worldmonitor-finance Ready Ready Preview, Comment Feb 25, 2026 10:51am
worldmonitor-happy Ready Ready Preview, Comment Feb 25, 2026 10:51am
worldmonitor-startup Ready Ready Preview, Comment Feb 25, 2026 10:51am

Request Review

@koala73 koala73 merged commit fb06f48 into main Feb 25, 2026
2 of 6 checks passed
koala73 added a commit that referenced this pull request Feb 25, 2026
The WTO trade handlers used fabricated indicator codes (QR, SPS, TBT,
HS_M_0010) that don't exist in the WTO Timeseries API, causing all
four RPCs to silently return empty data.

Fixes:
- Tariffs: HS_M_0010 → TP_A_0010; remove partner param (tariff
  indicators lack partner dimension, caused 400 error)
- Trade flows: split comma-separated indicators into parallel
  requests (API truncates combined i= values)
- Restrictions: rewrite to use tariff overview across 15 major
  economies (QR API is a separate subscription product)
- Barriers: rewrite to use agricultural vs non-agricultural tariff
  gap analysis (ePing SPS/TBT API is separate subscription)
- Handle 204 No Content (valid query, no data) instead of treating
  as error

Also: disable Global Giving panel by default for non-happy variants,
update README for BIS + WTO features (PR #363, #364).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants