central/sql/migrations/025_add_wzdx_adapter_and_traffic_stream.sql
Matt Johnson 7eab5fc1b1 feat(wzdx): WZDx adapter + CENTRAL_TRAFFIC family bootstrap (v0.9.0)
Opens Phase 4 transportation aggregation (Design B, Central-direct). New
registry-driven wzdx adapter polls the FHWA WZDx Feed Registry, fetches each
eligible v4.x GeoJSON feed concurrently, and emits work_zone events into the new
CENTRAL_TRAFFIC stream. Production code; central-supervisor AND central-gui
restart (new adapter class + stream + ADAPTER_GROUPS). Ships disabled.

First adapter to use the category/subject split: category="work_zone.wzdx" (GUI
event_type "work_zone" via split_part) while the NATS subject is
central.traffic.work_zone.{state}. Subject state from the registry row, geocoder
state as fallback. Severity from vehicle_impact (all-lanes-closed=3,
some-lanes-closed=2, all-lanes-open=1, unknown/missing=1). Feed filter
geojson + active + needapikey=false + version 4.x (21 of 39 feeds). 600s cadence.
Dedup composite <data_source_id>:<feature_id> in the shared cursors.db; stateless
discovery (no conftest isolation entry). enrichment_locations uses the canonical
("latitude","longitude") paths.

Full suite: 739 passed, 1 skipped (central and unprivileged zvx, 3x each).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 20:35:08 +00:00

23 lines
883 B
SQL

-- Migration: 025_add_wzdx_adapter_and_traffic_stream
-- Adds the CENTRAL_TRAFFIC JetStream stream row AND the WZDx adapter row.
-- Folded into one migration because the adapter publishes onto
-- central.traffic.> -- both rows ship together (mirrors 023 nwis/hydro).
--
-- Stream retention mirrors CENTRAL_DISASTER / CENTRAL_HYDRO (7 days, 1 GiB).
-- Adapter ships disabled; operator enables via GUI. settings {"states": null}
-- = poll every eligible feed; an allowlist of 2-letter codes narrows it.
--
-- Additive-only: both inserts are idempotent via ON CONFLICT DO NOTHING.
INSERT INTO config.streams (name, max_age_s, max_bytes)
VALUES ('CENTRAL_TRAFFIC', 604800, 1073741824)
ON CONFLICT (name) DO NOTHING;
INSERT INTO config.adapters (name, enabled, cadence_s, settings)
VALUES (
'wzdx',
false,
600,
'{"states": null}'::jsonb
)
ON CONFLICT (name) DO NOTHING;