Data Contracts
MinxiongHydroCast treats data contracts as the boundary between upstream collection, cleaning,
modeling, and product usage. Every live dataset includes source metadata and an explicit
資料模式 value. Operational collection prefers official machine-readable sources; a page scraper
is only a degraded request-failure fallback.
Dataset Artifacts
The formal radar manifest is validated by a strict Pydantic schema before any event is downloaded. It requires exactly event-based train, validation, and test splits with minimum real event counts of 2/1/2, including two held-out Minxiong test events. Demo IDs and sources, unassigned events, duplicate assignment, invalid timestamps, and unknown fields fail the build.
CWA history indexes, event plans, collection manifests, Persistence evaluations, Tiny U-Net training and comparison reports, the dataset catalog, and the checksum verification report are also validated through Pydantic before JSON serialization. The external catalog records relative artifact paths, byte sizes, SHA-256, provenance, event time ranges, and aggregate and lead-time metrics. Artifact resolution rejects absolute data paths and attempts to escape the configured data root. See data_assets.md.
Event Evidence Catalog
EventEvidenceCatalog is the strict boundary for continuous radar discovery. It stores the
incremental cursor, immutable discovery configuration, checksummed history indexes, candidate
trigger metrics, full radar-window artifacts, and synchronized QPE/gauge/warning captures. Unknown
fields, naive timestamps, duplicate candidates or trigger times, inconsistent frame counts, and
artifact paths outside the data root fail validation.
Discovery configuration includes a cadence-aligned maximum candidate window, defaulting to 480 minutes and including the before/after context. A trigger that would exceed the bound starts a new candidate. Older catalogs without the field parse with that default; an already overlong candidate is preserved instead of being rewritten.
Every candidate is constrained to candidate_only with formal_split_membership=not_added.
Catalogs require automatic_formal_split_updates=false and
retraining_policy=only_after_human_approved_new_events. A complete frame window can only become
awaiting_review; it cannot become a formal dataset event through discovery. See
continuous_event_evidence.md.
An approved candidate additionally requires a Pydantic EventReviewRecord with reviewer identity,
timezone-aware review time, a classified weather regime, official HTTPS context references,
checksummed OfficialContextArtifact records, and a complete synchronized QPE/gauge/warning
capture. Each official-context record preserves publisher, source URL, published and fetched times,
and an external artifact path, byte size, and SHA-256. The formal manifest must reference its origin
with evidence_candidate_id. event-split-check and dataset-build share one gate that verifies
all external catalog checksums and rejects any candidate whose approval, source data ID, time
window, or reviewed regime does not match the formal event. The build runs this gate before source
downloads or model training.
Rainfall Alerts
Required fields:
雨量站代碼縣市代碼鄉鎮代碼地區水情時間水情時間ISO警戒警戒級別影響村落10分鐘雨量mm1小時雨量mm3小時雨量mm6小時雨量mm12小時雨量mm24小時雨量mm抓取時間資料模式資料來源
The primary source is the WRA OpenApiv3 GET /v2/Rainfall/Warning contract. The API key is sent
only in the apikey request header. Its top-level UpdataTime and Data payload, warning fields,
numeric ranges, and timestamps are validated with strict Pydantic schemas; missing, unexpected, or
wrongly typed fields are schema drift and fail the collection without scraper fallback.
This product contains only warnings that are currently in effect. A validated response with
Data=[] is therefore a successful no-active-warning result, represented by zero records and
outcome=empty. The collector uses its fetch time for freshness, so a fresh official empty result
is healthy and ready. It must not be converted into an error row or a fabricated "no warning"
record.
Rain Gauges
Required fields:
排序行政區雨量站雨量站代碼水情時間水情時間ISO1小時累積雨量1小時累積雨量mm24小時累積雨量24小時累積雨量mm緯度經度資料產出時間資料產出時間ISO抓取時間資料模式資料來源
The CWA O-A0002-001 adapter populates the official station ID and WGS84 coordinates. Scraper
fallback records retain these fields as empty rather than fabricating identifiers or coordinates.
Operational Source Provenance
Every immutable operational dataset records:
source_kind:api,scraper_fallback, ordemo_fixtureoutcome:ok,empty,stale, orfallbackauthoritydataset_idsource_urlwith credentials redactedfetched_atschema_versioncontent_sha256- optional
fallback_reason_kindandfallback_reason
scraper_fallback datasets are always degraded and never ready. Expected empty API products must
use the explicit empty outcome; unexpected empty observation datasets fail the collection.
In auto source mode, only authentication, transport, HTTP, timeout, and rate-limit request
failures can invoke a scraper fallback. Upstream Pydantic schema drift, invalid timestamps, unit
changes, join failures, and unexpected empty observation sets fail closed.
The flood-sensor adapter retries transient empty/invalid JSON inside each request, repeated full
pages inside pagination, and malformed or inconsistent measurement/catalog joins by rerunning the
bounded join transaction. Exhausted retries still fail closed as schema_drift. Each collection
attempt records retry count, retry layer, and reason in immutable snapshot metadata, run summary
metrics, and the minxionghydrocast_last_attempt_source_retries Prometheus gauge.
Flood Sensors
Required fields:
排序感測器代碼觀測站代碼縣市代碼鄉鎮代碼縣市鄉鎮感測器名稱觀測站名稱維運單位類別地址緯度經度啟用狀態水情時間水情時間ISO目前感測值目前感測值數值目前感測值單位資料產出時間資料產出時間ISO抓取時間資料模式資料來源
The official adapter joins the WRA IoW latest flood-depth measurements from government Open Data
dataset 142980 with sensor metadata from dataset
142979 by sensorid. It requires matching county/town codes,
official observatory identifiers, WGS84 coordinates, enabled state, category 淹水深度, and unit
cm. A measurement without matching metadata, duplicate sensor IDs, conflicting location codes,
negative target depth, or an unexpected empty target set fails closed as an upstream contract
error. A malformed page, duplicate ID, missing metadata, or metadata mismatch may trigger a bounded
full measurement/catalog transaction retry first; a repeatable inconsistency remains a contract
error. Dataset 142979 does
not provide a street address, so official API records leave 地址 empty instead of fabricating one.
Disabled sensors remain in the source dataset for auditability but do not contribute to the
Minxiong feature or determine source freshness; a target with no enabled sensor is not ready.
These endpoints are official public Open Data snapshots updated approximately hourly. They are not the bearer-protected, station-origin real-time feed, so the operational freshness threshold is 90 minutes and the service must not claim sub-hour sensor latency. The source can be official and healthy while still having a slower publication cadence than the original measuring station.
River Water Levels
Government Open Data dataset 25768 contains river and regional
drainage water-level observations. It is not a street/community flood-depth sensor product, and its
records are not fully quality-controlled. MinxiongHydroCast therefore does not map it into
flood_sensors, derive Minxiong flood-sensor features from it, or expose it as an operational
dataset today. A future integration must use a separate river_water_levels contract and retain
the upstream checkresult, checkdesc, observation timestamp, and explicit freshness state.
Region Feature Coverage
The profile-driven region_features row includes coverage_ready and coverage_gaps. For the
Minxiong reference profile, live readiness requires at least one Minxiong rain gauge and one
enabled Minxiong flood-depth sensor. A healthy Chiayi County feed with no Minxiong records is
coverage_missing, not ready. A valid empty rainfall warning remains healthy and contributes an
alert count of zero; it is not a coverage gap.
Shelters
Required fields:
鄉鎮市避難所名稱避難所地址避難所聯絡人收容人數來源檔案抽取時間
Shelter source files often include contact information. Keep real exports in data/raw/ and do
not commit them without a privacy review.
Location Reference
Required fields:
location_idsource_typesource_namecountytownshipvillageaddresslatitudelongitudecrscoordinate_sourceadmin_unit_key
location_id remains a snapshot-stable derived hash. Keep the official station and sensor IDs in
their source datasets for authoritative cross-system joins; do not present the derived hash as a
WRA or CWA identifier.
Grid Specs
Required fields:
namecrswestsoutheastnorthresolution_degreesrowscolsdescription
Grid cells should be referenced by stable cell IDs from GridSpec.cell_id().
Event Weather Context
Required fields in data/samples/event_weather_context.json:
event_idwindow_startwindow_endradar_candidate_typeofficial_weather_typeofficial_evidenceminimum_required_evidencestatus
Use official_context_pending until CWA weather maps, warnings, daily reports, or equivalent
official sources are attached.
Weather Context Source Review
Required top-level fields in data/samples/weather_context_source_review.json:
schema_versionverified_atofficial_sources_reviewedeventsnext_actions
Each event entry should include event_id, official_weather_type, label_status,
needed_sources, and next_probe_urls. Use a blocked_* label status until an event-time CWA
weather map, warning, daily report, or equivalent official product is attached.
QPE/Gauge Validation Reports
Required top-level fields:
event_idqpe_sourcegauge_sourcesummarymatches
Each station match should include station ID/name, coordinates, gauge rainfall, nearest QPE value, difference, absolute error, grid row/column, status, and exclusion reason when applicable.
QPE/Gauge Validation Status
Required top-level fields in data/samples/qpe_gauge_validation_status.json:
schema_versionverified_atrequired_productsavailability_findingseventsnext_actions
Each event status should include event_id, validation_time, gauge_status, gauge station
counts, qpe_status, a redacted QPE endpoint, and report_status. Use
blocked_missing_event_time_qpe_grid until a matching O-B0045-001 QPE grid exists for that
event time.