Skip to content

Emit emergency-squawk events from local ADS-B adapter (M2)#12

Merged
kninetimmy merged 1 commit into
mainfrom
m2-emergency-squawk-events
Jun 17, 2026
Merged

Emit emergency-squawk events from local ADS-B adapter (M2)#12
kninetimmy merged 1 commit into
mainfrom
m2-emergency-squawk-events

Conversation

@kninetimmy

Copy link
Copy Markdown
Owner

Closes out the last partial Milestone 2 (Local RF baseline) deliverable from PRD §32: emergency-squawk templates. The local ADS-B adapter already recognized emergency squawks but only tagged the track — it never surfaced a discrete event. It now emits a critical EventRecord on the onset edge, rendered by the existing EventFeed.

What changed

  • ThrottleGate.admit() now returns Admission(publish, emergency_onset). The not-emergency → 7500/7600/7700 (or explicit transponder emergency) edge was already computed for the immediate-publish bypass; it's now exposed rather than discarded.
  • On that edge, local_adsb_records() yields a critical EventRecord (event_type=emergency_squawk, severity=critical, subject_id=track, geometry=last position, local_rf provenance copied from the track). Fires once per onset — a steady stream of the same squawk does not re-fire.
  • EMERGENCY_SQUAWK_MEANINGS maps each code to plain language (e.g. 7700 → general emergency).
  • No frontend changeEventFeed already renders event_type + summary.

This is the event substrate the M4 alert-rule engine will later consume — not the rule engine itself.

Tests / verification

  • New unit tests: onset detection, generator emits the event, steady-state no-refire.
  • New integration test (aircraft_emergency.json) exercises the full path adapter → MQTT → backend → websocket and asserts a event frame with critical severity, 7700 in the summary, Point geometry, and local_rf: true.
  • Adjusts one pre-existing test whose item ordering shifts because the standard fixture already carries a 7700 aircraft (so the onset event now correctly fires for it too).
  • scripts/check.sh green — ruff + mypy (strict) + 125 tests passed.

🤖 Generated with Claude Code

Close out the last partial Milestone 2 deliverable (PRD §32): the local
ADS-B adapter recognized emergency squawks but only tagged the track. It
now also emits a discrete critical EventRecord on the onset edge.

- ThrottleGate.admit() returns Admission(publish, emergency_onset); the
  not-emergency -> 7500/7600/7700 (or explicit transponder emergency)
  edge was already computed for the immediate-publish bypass and is now
  exposed rather than discarded.
- On that edge local_adsb_records() yields a critical EventRecord
  (event_type=emergency_squawk, subject_id=track, geometry=last
  position, local_rf provenance copied from the track). Fires once per
  onset; a steady stream of the same squawk does not re-fire.
- EMERGENCY_SQUAWK_MEANINGS maps each code to plain language.

No frontend change: the existing EventFeed already renders events.

Tests: unit onset detection + generator event + steady no-refire;
integration aircraft_emergency.json exercises adapter -> MQTT -> backend
-> websocket end to end. Adjusts one pre-existing test whose item
ordering shifts because the standard fixture already carries a 7700
aircraft. scripts/check.sh green (125 passed).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements the M2 emergency-squawk event template. It updates the local ADS-B adapter to detect when an aircraft transitions into an emergency state (e.g., squawking 7500, 7600, or 7700) and emits a discrete critical EventRecord on the stream. To support this, ThrottleGate.admit now returns an Admission named tuple indicating both whether to publish and whether an emergency onset occurred. New integration and unit tests have been added to verify this behavior. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@kninetimmy kninetimmy merged commit 3dd7cc8 into main Jun 17, 2026
5 checks passed
@kninetimmy kninetimmy deleted the m2-emergency-squawk-events branch June 17, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant