Fixed a critical bug in crates/wx-bet/src/resolve.rs (resolve_one) where ~half of all markets would silently never resolve due to IEM’s publish lag and per-station flakiness.
Symptoms
- Roughly half of all markets skip resolution entirely
- No resolution rows written for affected markets
- Particularly bad for non-US ICAO stations (e.g. Paris/LFPB never published on IEM)
Root Cause
resolve_one fetched IEM ASOS as the primary source. If IEM failed, the market was skipped entirely. IEM has two fatal properties that make it unsuitable as a gating dependency:
- ~2-day publish lag — data is not available until well after the resolution window
- Per-station flakiness — many international stations (e.g. LFPB) never publish to IEM at all
Meanwhile, TWC (Weather.com) is the source Polymarket actually resolves on, making IEM’s unavailability doubly wrong: it blocked resolution on a source that is both more reliable and authoritative.
Fix
Rewrote resolve_one in crates/wx-bet/src/resolve.rs:
- Fetch TWC first as primary (when configured)
- Fetch IEM as cross-check/fallback — never gates resolution on its own
- Log reconciliation only when both are present (delta > 2°C →
warn, elseinfo) - Use TWC value if present, else IEM; only skip the market if both fail
- Store
iem_celsius/twc_celsiusasOption<i32>— whichever sources are present
Source authority
TWC is what Polymarket resolves on. IEM is a secondary cross-check. Never gate resolution on IEM availability.
Tests Added
File: crates/wx-bet/tests/resolve.rs
| Test | What it covers |
|---|---|
iem_unavailable_twc_present_resolves_on_twc | Regression: IEM 500 errors, TWC valid → market resolves on TWC value |
both_sources_present_twc_wins_and_reconciles | Both present → reconciles log emitted, TWC value used |
both_sources_unavailable_skips_resolution | Both fail → no resolution row written |
Refactored test helper from past_market() → past_market_with_slug(slug) for DRY setup across all three tests.
Verification
cargo fmt --check # clean
cargo clippy (lib+tests) # 0 warnings
cargo test -p wx-bet --features wx-core/testkit # 25/25 passed (5 resolve tests green)
Known pre-existing issue
cargo clippy --all-targetsfails due to abuild.rs+-D warningsflag interaction that predates this change. Not caused by this fix.