feat(squawk): carry emergencySource + observation time into analyst records

Review on #856 (kvnloo): the analyst projection flattened a 7700 squawk and
the readsb ADS-B emergency field into the same emergency/emergencyKind pair.

- mapAnalystRecord (flights, military) adds emergencySource ('squawk' |
  'ads-b' | null, from aircraftEmergency().source), emergencyBroadcast (new
  pure emergencyBroadcastPhrase: "broadcasting squawk 7700 (general
  emergency)" vs "ADS-B reports general emergency") and observedAtMs (the
  record's lastContactEpochMs: last transponder message, epoch ms).
- emergencySource is a queryable analyst text field; the voice payload passes
  it and emergencyBroadcast through, and observedAtMs only for aircraft with
  a status. Tool description asks the model to narrate with the phrase.
- Source-to-analyst fixture test: OpenSky 7700 vs adsb.lol emergency=general
  on squawk 1200 differ in provenance and timestamp; filterable by source.
- Voice tool-payload pins re-derived for the additive description change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Leo PechnickiandClaude Opus 5.5 authored and Mazeyar Moeini Feizabadi committed 2026-10-13 17:23:39 +02:00
1 parent 6c643c8113
commit 7d6f31e54d
10 files changed
+227 -4

No files matched your search

+11 -1
View File
@@ -15,6 +15,7 @@ import {
FOCUS_EVIDENCE_DEV,
FLEET_DR_INTERVAL_MS,
} from './policy.js';
import { emergencyBroadcastPhrase } from '../../data/aircraftEmergency.js';
export function createQueries({
flightState,
@@ -223,7 +224,8 @@ export function createQueries({
* heading: number|null, verticalRateMps: number|null, onGround: boolean,
* military: boolean, aircraftClass: string|null, originCountry: string|null,
* operator: string|null, squawk: string|null, emergency: boolean,
* emergencyKind: string|null, routeOrigin: string|null,
* emergencyKind: string|null, emergencySource: 'squawk'|'ads-b'|null,
* emergencyBroadcast: string|null, observedAtMs: number|null, routeOrigin: string|null,
* routeDestination: string|null}}
*/
@@ -264,6 +266,14 @@ export function createQueries({
// without the flag.
emergency: info?.emergency?.severity === 'emergency',
emergencyKind: text(info?.emergency?.kind),
// Provenance, so a summary can say "broadcasting squawk 7700" rather
// than "ADS-B reports general emergency" (or flatten both): 'squawk'
// when the Mode A code names the status, 'ads-b' for the readsb field.
emergencySource: text(info?.emergency?.source),
emergencyBroadcast: emergencyBroadcastPhrase(info?.emergency),
// Epoch ms of the last transponder message — when this squawk/status
// was heard (OpenSky time_contact; readsb snapshot time minus `seen`).
observedAtMs: num(info?.lastContactEpochMs),
routeOrigin: routeOk ? text(info?.route?.origin?.code) : null,
routeDestination: routeOk ? text(info?.route?.destination?.code) : null,
};