mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-08-26 17:31:34 +00:00
refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29)
* fix(fixtures): rewrite capture_fixtures.py to use ephemeral push subscribe
Previous script hardcoded stream="CENTRAL" which does not exist — Central
partitions into domain streams (CENTRAL_QUAKE, CENTRAL_SPACE, etc.). It
also called pull_subscribe_bind() without await, making the fetch a no-op.
Fix: mirror the proven CentralConsumer.start() pattern — use
js.subscribe(subject, cb=..., AckPolicy.NONE, no durable) which auto-
discovers the correct stream via the subject filter, identical to how the
live consumer binds. Messages are funnelled through asyncio.Queue with
an idle-timeout to detect drain completion.
Adds live captured fixtures:
- tests/fixtures/quake/ — 3 envelopes (CENTRAL_QUAKE stream, mode=all)
- tests/fixtures/swpc/ — 40 envelopes (CENTRAL_SPACE, mode=all, proton_flux history)
- tests/fixtures/swpc_last/ — 23 envelopes (mode=last: 21 alert variants + kindex + proton_flux)
Avalanche: confirmed empty off-season (CENTRAL_AVY stream, 0 messages).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(phase1): migrate quake, swpc(Kp+flare), avalanche + staged-cutover gate
First hazards on the source-agnostic formatter+decider path, behind a
staged-cutover gate so deploy = shadow-only (old path still broadcasts; new
path dry-run-diffed) until MESHAI_CUTOVER_CATEGORIES flips a category live.
- formatters/{quake,swpc,avalanche}.py + gating/{quake,swpc,avalanche}.py:
source-agnostic format(event,*,now,budget) + decide(data,*,source,now)->GateResult.
quake (earthquake_event, tier-b: render PAGER + live update-prefix), swpc
(geomagnetic_storm + rf_propagation_alert, Kp+flare only; proton/solar_radiation
_storm stays legacy; geomag 600s window re-homed off the module-global into
gating/swpc with a deferred stamp; tier-b scale-based severity), avalanche
(avalanche_warning/watch; centralseverity->NAADS 1-5 remap; synthetic fixtures
off-season).
- central/{quake,swpc,avy}_handler.py bridges: cutover -> new decide()+canonical
data; not-cutover -> exact legacy behavior. env/{usgs_quake,swpc,avalanche}.py
emit canonical Event.data (avalanche stops precomposing). env/store.py generic
native decider hook (cutover-gated).
- notifications/cutover.py (is_cutover via MESHAI_CUTOVER_CATEGORIES); composer
dispatch + shadow hooks are cutover-aware (shadow no-ops once a category is live).
- scripts/capture_fixtures.py fixed (per-domain streams e.g. CENTRAL_QUAKE, await
bind); real quake/swpc fixtures captured; avalanche synthetic.
Tests: +~150 (quake/swpc/avalanche parity+cross-source+gate-sequence+cutover);
0 new failures (34 baseline, 1426 passed).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Matt Johnson <mj@k7zvx.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f06bf3ce92
commit
4e23fc737d
96 changed files with 7000 additions and 267 deletions
82
work/tests/fixtures/quake/0000.json
vendored
Normal file
82
work/tests/fixtures/quake/0000.json
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
"envelope": {
|
||||
"id": "uu80143601",
|
||||
"source": "central.echo6.co",
|
||||
"type": "central.quake.event.minor.v1",
|
||||
"time": "2026-06-28T19:19:56.050000+00:00",
|
||||
"datacontenttype": "application/json",
|
||||
"centralschemaversion": "1.0",
|
||||
"centralcategory": "quake.event.minor",
|
||||
"centralseverity": 0,
|
||||
"specversion": "1.0",
|
||||
"data": {
|
||||
"id": "uu80143601",
|
||||
"adapter": "usgs_quake",
|
||||
"category": "quake.event.minor",
|
||||
"time": "2026-06-28T19:19:56.050000Z",
|
||||
"expires": null,
|
||||
"severity": 0,
|
||||
"geo": {
|
||||
"centroid": [
|
||||
-112.206666666667,
|
||||
42.2111666666667
|
||||
],
|
||||
"bbox": [
|
||||
-112.206666666667,
|
||||
42.2111666666667,
|
||||
-112.206666666667,
|
||||
42.2111666666667
|
||||
],
|
||||
"regions": [],
|
||||
"primary_region": null,
|
||||
"geometry": null
|
||||
},
|
||||
"data": {
|
||||
"magnitude": 1.23,
|
||||
"place": "4 km ENE of Malad City, Idaho",
|
||||
"time_ms": 1782674396050,
|
||||
"updated_ms": 1782742438530,
|
||||
"tz": null,
|
||||
"url": "https://earthquake.usgs.gov/earthquakes/eventpage/uu80143601",
|
||||
"detail": "https://earthquake.usgs.gov/earthquakes/feed/v1.0/detail/uu80143601.geojson",
|
||||
"felt": null,
|
||||
"cdi": null,
|
||||
"mmi": null,
|
||||
"alert": null,
|
||||
"status": "reviewed",
|
||||
"tsunami": 0,
|
||||
"sig": 23,
|
||||
"net": "uu",
|
||||
"code": "80143601",
|
||||
"ids": ",uu80143601,",
|
||||
"sources": ",uu,",
|
||||
"types": ",origin,phase-data,",
|
||||
"nst": 10,
|
||||
"dmin": 0.1939,
|
||||
"rms": 0.1,
|
||||
"gap": 160,
|
||||
"magType": "md",
|
||||
"type": "earthquake",
|
||||
"title": "M 1.2 - 4 km ENE of Malad City, Idaho",
|
||||
"longitude": -112.206666666667,
|
||||
"latitude": 42.2111666666667,
|
||||
"depth": 3.06,
|
||||
"_enriched": {
|
||||
"geocoder": {
|
||||
"name": null,
|
||||
"city": null,
|
||||
"county": null,
|
||||
"state": null,
|
||||
"country": null,
|
||||
"postal_code": null,
|
||||
"timezone": "America/Boise",
|
||||
"landclass": "Deep Creek Roadless Area",
|
||||
"elevation_m": 1752.28515625
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"subject": "central.quake.event.minor.unknown",
|
||||
"captured_epoch": 1783196478
|
||||
}
|
||||
82
work/tests/fixtures/quake/0001.json
vendored
Normal file
82
work/tests/fixtures/quake/0001.json
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
"envelope": {
|
||||
"id": "uu80143651",
|
||||
"source": "central.echo6.co",
|
||||
"type": "central.quake.event.minor.v1",
|
||||
"time": "2026-06-29T12:09:25.630000+00:00",
|
||||
"datacontenttype": "application/json",
|
||||
"centralschemaversion": "1.0",
|
||||
"centralcategory": "quake.event.minor",
|
||||
"centralseverity": 0,
|
||||
"specversion": "1.0",
|
||||
"data": {
|
||||
"id": "uu80143651",
|
||||
"adapter": "usgs_quake",
|
||||
"category": "quake.event.minor",
|
||||
"time": "2026-06-29T12:09:25.630000Z",
|
||||
"expires": null,
|
||||
"severity": 0,
|
||||
"geo": {
|
||||
"centroid": [
|
||||
-111.2065,
|
||||
42.7483333333333
|
||||
],
|
||||
"bbox": [
|
||||
-111.2065,
|
||||
42.7483333333333,
|
||||
-111.2065,
|
||||
42.7483333333333
|
||||
],
|
||||
"regions": [],
|
||||
"primary_region": null,
|
||||
"geometry": null
|
||||
},
|
||||
"data": {
|
||||
"magnitude": 2.37,
|
||||
"place": "17 km WSW of Auburn, Wyoming",
|
||||
"time_ms": 1782734965630,
|
||||
"updated_ms": 1782764579010,
|
||||
"tz": null,
|
||||
"url": "https://earthquake.usgs.gov/earthquakes/eventpage/uu80143651",
|
||||
"detail": "https://earthquake.usgs.gov/earthquakes/feed/v1.0/detail/uu80143651.geojson",
|
||||
"felt": null,
|
||||
"cdi": null,
|
||||
"mmi": null,
|
||||
"alert": null,
|
||||
"status": "reviewed",
|
||||
"tsunami": 0,
|
||||
"sig": 86,
|
||||
"net": "uu",
|
||||
"code": "80143651",
|
||||
"ids": ",uu80143651,",
|
||||
"sources": ",uu,",
|
||||
"types": ",origin,phase-data,",
|
||||
"nst": 21,
|
||||
"dmin": 0.07998,
|
||||
"rms": 0.18,
|
||||
"gap": 100,
|
||||
"magType": "ml",
|
||||
"type": "earthquake",
|
||||
"title": "M 2.4 - 17 km WSW of Auburn, Wyoming",
|
||||
"longitude": -111.2065,
|
||||
"latitude": 42.7483333333333,
|
||||
"depth": 4.18,
|
||||
"_enriched": {
|
||||
"geocoder": {
|
||||
"name": null,
|
||||
"city": null,
|
||||
"county": null,
|
||||
"state": null,
|
||||
"country": null,
|
||||
"postal_code": null,
|
||||
"timezone": "America/Boise",
|
||||
"landclass": "Stump Creek Roadless Area",
|
||||
"elevation_m": 2198.1875
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"subject": "central.quake.event.minor.unknown",
|
||||
"captured_epoch": 1783196478
|
||||
}
|
||||
82
work/tests/fixtures/quake/0002.json
vendored
Normal file
82
work/tests/fixtures/quake/0002.json
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
"envelope": {
|
||||
"id": "us6000t9bn",
|
||||
"source": "central.echo6.co",
|
||||
"type": "central.quake.event.light.v1",
|
||||
"time": "2026-07-01T00:35:15.247000+00:00",
|
||||
"datacontenttype": "application/json",
|
||||
"centralschemaversion": "1.0",
|
||||
"centralcategory": "quake.event.light",
|
||||
"centralseverity": 1,
|
||||
"specversion": "1.0",
|
||||
"data": {
|
||||
"id": "us6000t9bn",
|
||||
"adapter": "usgs_quake",
|
||||
"category": "quake.event.light",
|
||||
"time": "2026-07-01T00:35:15.247000Z",
|
||||
"expires": null,
|
||||
"severity": 1,
|
||||
"geo": {
|
||||
"centroid": [
|
||||
-112.6108,
|
||||
44.46
|
||||
],
|
||||
"bbox": [
|
||||
-112.6108,
|
||||
44.46,
|
||||
-112.6108,
|
||||
44.46
|
||||
],
|
||||
"regions": [],
|
||||
"primary_region": null,
|
||||
"geometry": null
|
||||
},
|
||||
"data": {
|
||||
"magnitude": 3.3,
|
||||
"place": "19 km S of Lima, Montana",
|
||||
"time_ms": 1782866115247,
|
||||
"updated_ms": 1782867341040,
|
||||
"tz": null,
|
||||
"url": "https://earthquake.usgs.gov/earthquakes/eventpage/us6000t9bn",
|
||||
"detail": "https://earthquake.usgs.gov/earthquakes/feed/v1.0/detail/us6000t9bn.geojson",
|
||||
"felt": null,
|
||||
"cdi": null,
|
||||
"mmi": null,
|
||||
"alert": null,
|
||||
"status": "reviewed",
|
||||
"tsunami": 0,
|
||||
"sig": 168,
|
||||
"net": "us",
|
||||
"code": "6000t9bn",
|
||||
"ids": ",us6000t9bn,",
|
||||
"sources": ",us,",
|
||||
"types": ",origin,phase-data,",
|
||||
"nst": 52,
|
||||
"dmin": 0.159,
|
||||
"rms": 0.61,
|
||||
"gap": 45,
|
||||
"magType": "ml",
|
||||
"type": "earthquake",
|
||||
"title": "M 3.3 - 19 km S of Lima, Montana",
|
||||
"longitude": -112.6108,
|
||||
"latitude": 44.46,
|
||||
"depth": 11.169,
|
||||
"_enriched": {
|
||||
"geocoder": {
|
||||
"name": null,
|
||||
"city": null,
|
||||
"county": null,
|
||||
"state": null,
|
||||
"country": null,
|
||||
"postal_code": null,
|
||||
"timezone": "America/Boise",
|
||||
"landclass": "Upper Snake Field Office",
|
||||
"elevation_m": 2225.02734375
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"subject": "central.quake.event.light.unknown",
|
||||
"captured_epoch": 1783196478
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue