meshai/work/tests/fixtures/swpc_last
malice 4e23fc737d
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>
2026-07-04 15:58:46 -06:00
..
0000.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0001.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0002.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0003.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0004.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0005.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0006.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0007.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0008.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0009.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0010.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0011.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0012.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0013.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0014.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0015.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0016.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0017.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0018.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0019.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0020.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0021.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00
0022.json refactor(phase1): quake + swpc(Kp+flare) + avalanche, behind staged-cutover gate (#29) 2026-07-04 15:58:46 -06:00