fix(flights): address review — quotable squawk only, all military tint sites, no test churn

- aircraftEmergency: `source` is 'squawk' only when the Mode A code itself
  names the status; the Cockpit HUD no longer quotes an unrelated squawk
  (e.g. SQUAWK 1200 on an ADS-B `downed` status).
- military: new billboards and the untrack restore use the fleet tint, so an
  emergency stays red instead of snapping back to amber; tint helpers take the
  record already in hand instead of a second lookup.
- cockpit/cyber CSS: emergency colour via a custom property / theme token,
  meta line bolded so the status does not rely on colour alone in the HUD.
- tests: revert Prettier churn in unscoped test files; only semantic edits.
- docs/CURRENT-STATE.md: transponder emergency highlighting section.
- qa-emergency-squawk: (iv) RELEASE check; new files added to format scope.

Co-Authored-By: Claude <[email protected]>
This commit is contained in:
Leo PechnickiandClaude authored and Mazeyar Moeini Feizabadi committed 2026-10-13 17:23:19 +02:00
1 parent eb7f059750
commit 15b13e947b
16 files changed
+543 -1600

No files matched your search

+20
View File
@@ -814,6 +814,26 @@ use the supplied asset resolver, including the preload path. Enrichment receives
an abort signal and cannot update a later lifecycle after destruction. Existing an abort signal and cannot update a later lifecycle after destruction. Existing
camera, terrain floor, trail, selection and measured model-size policies remain. camera, terrain floor, trail, selection and measured model-size policies remain.
## Transponder emergency highlighting
`src/data/aircraftEmergency.js` derives one status per poll from the Mode A
squawk (7500 unlawful interference, 7600 radio failure, 7700 general emergency;
ICAO-standard worldwide) and, where the feed carries it, the readsb ADS-B
`emergency` field (adsb.lol; OpenSky state vectors carry the squawk only). An
explicit ADS-B status wins over the squawk. `general`, `unlawful`, `nordo` and
`downed` are emergencies; `minfuel` and `lifeguard` are priorities.
Both aircraft layers keep `squawk` and `emergency` on each record and replace
them on every poll, so the status is never sticky. Civil and military fleet
billboards and Cockpit far-contact dots are tinted `EMERGENCY_TINT_CSS` red
only for emergencies; priorities keep the normal tint. The military layer uses
the same tint when a billboard is first created and when a tracked contact is
released. While a broadcasting aircraft is tracked, the Cockpit aircraft-meta
line reads `SQUAWK 7700 · GENERAL EMERGENCY` when the code names the status,
else `ADS-B EMERGENCY · …` or `ADS-B PRIORITY · …`, in red. Analyst records and
the voice query fields expose `squawk`, `emergency` (flag) and `emergencyKind`.
`scripts/qa-emergency-squawk.mjs` proves the tint, HUD line and clearing.
## Browser live-source observations ## Browser live-source observations
Flights, Military Flights and AIS Vessels obtain snapshots and optional history Flights, Military Flights and AIS Vessels obtain snapshots and optional history
+3
View File
@@ -18,6 +18,9 @@
"src/tooling/panelStorageDocs.test.mjs", "src/tooling/panelStorageDocs.test.mjs",
"src/tooling/packageBoundaries.test.mjs", "src/tooling/packageBoundaries.test.mjs",
"src/data/infrastructure.js", "src/data/infrastructure.js",
"src/data/aircraftEmergency.js",
"src/data/aircraftEmergency.test.mjs",
"scripts/qa-emergency-squawk.mjs",
"src/data/infrastructure.test.mjs", "src/data/infrastructure.test.mjs",
"src/data/localGeojsonCore.js", "src/data/localGeojsonCore.js",
"src/data/localGeojsonLod.js", "src/data/localGeojsonLod.js",
+27
View File
@@ -14,6 +14,8 @@
* the broadcast code on the aircraft-meta line, in red. * the broadcast code on the aircraft-meta line, in red.
* (iii) CLEAR — the next poll drops the code: the HUD line returns to its * (iii) CLEAR — the next poll drops the code: the HUD line returns to its
* normal wording (the status is not sticky). * normal wording (the status is not sticky).
* (iv) RELEASE — the code returns and tracking stops: the restored fleet
* billboard is red, not the plain military amber.
* *
* Screenshots saved to qa-shots/emergency-*.png (gitignored). * Screenshots saved to qa-shots/emergency-*.png (gitignored).
* *
@@ -410,6 +412,31 @@ async function main() {
JSON.stringify(after), JSON.stringify(after),
); );
await shoot(page, 'cockpit-cleared'); await shoot(page, 'cockpit-cleared');
// ── (iv) RELEASE ──────────────────────────────────────────────────────
console.log('\n(iv) RELEASE — the code returns, then tracking stops...');
await page.evaluate(async () => {
window.__squawkQaPhase = 'emergency';
const dm = window.__godsEyeView.dataManager;
await dm.refreshLayer('military');
dm.layers.get('military').module.stopTracking({ origin: 'user' });
});
const releaseProbe = `(${billboardColors})(["ae7700"])`;
const released = await page
.waitForFunction(`Boolean((${releaseProbe}).ae7700)`, {
timeout: 20000,
polling: 250,
})
.then(
() => true,
() => false,
);
const releasedColor = (await page.evaluate(releaseProbe)).ae7700;
record(
'RELEASE: untracked emergency billboard is red',
released && isRed(releasedColor),
JSON.stringify(releasedColor ?? null),
);
record( record(
'no uncaught browser errors', 'no uncaught browser errors',
errors.length === 0, errors.length === 0,
+9 -3
View File
@@ -85,8 +85,11 @@ export function cockpitAltitudeDisplayFt(altitudeM, onGround) {
/** /**
* HUD wording for a tracked aircraft's transponder emergency, or null. * HUD wording for a tracked aircraft's transponder emergency, or null.
* States the broadcast code, never a conclusion about the flight. * States what was broadcast, never a conclusion about the flight: the Mode A
* @param {{label?: string, squawk?: string|null}|null|undefined} emergency * code when it names the status, else the ADS-B field it came from (an
* unrelated squawk is dropped).
* @param {{label?: string, squawk?: string|null, source?: string,
* severity?: string}|null|undefined} emergency
* @returns {string|null} * @returns {string|null}
*/ */
export function formatCockpitEmergency(emergency) { export function formatCockpitEmergency(emergency) {
@@ -94,7 +97,10 @@ export function formatCockpitEmergency(emergency) {
.trim() .trim()
.toUpperCase(); .toUpperCase();
if (!label) return null; if (!label) return null;
return emergency.squawk ? `SQUAWK ${emergency.squawk} · ${label}` : label; if (emergency.source === 'squawk' && emergency.squawk)
return `SQUAWK ${emergency.squawk} · ${label}`;
const field = emergency.severity === 'priority' ? 'PRIORITY' : 'EMERGENCY';
return `ADS-B ${field} · ${label}`;
} }
/** Format the cockpit Context scope without overstating installation coverage. */ /** Format the cockpit Context scope without overstating installation coverage. */
+50 -108
View File
@@ -10,10 +10,10 @@ import {
cockpitGroundSafeHeight, cockpitGroundSafeHeight,
cockpitSurfaceWaitExpired, cockpitSurfaceWaitExpired,
cockpitUiUpdateDue, cockpitUiUpdateDue,
formatCockpitEmergency,
compassDivisions, compassDivisions,
formatAltitudeRulerTick, formatAltitudeRulerTick,
formatCockpitContextScope, formatCockpitContextScope,
formatCockpitEmergency,
formatCompassDivision, formatCompassDivision,
formatSpeedRulerTick, formatSpeedRulerTick,
normalizeHeading, normalizeHeading,
@@ -42,11 +42,7 @@ test('cockpit anchor correction cannot turn a forward step into a reversal', ()
const speedMps = 200; const speedMps = 200;
const dtSec = 0.1; const dtSec = 0.1;
const forwardStepM = speedMps * dtSec; const forwardStepM = speedMps * dtSec;
const backwardCorrectionM = cockpitAnchorCorrectionStep( const backwardCorrectionM = cockpitAnchorCorrectionStep(1000, speedMps, dtSec);
1000,
speedMps,
dtSec,
);
assert.ok(backwardCorrectionM > 0); assert.ok(backwardCorrectionM > 0);
assert.ok(backwardCorrectionM < forwardStepM); assert.ok(backwardCorrectionM < forwardStepM);
}); });
@@ -82,7 +78,10 @@ test('cockpit Context scope distinguishes radius-complete feeds from viewport in
}); });
test('cockpit Context scope preserves zero and replaces missing values intentionally', () => { test('cockpit Context scope preserves zero and replaces missing values intentionally', () => {
assert.equal(formatCockpitContextScope('', 0), '— · 0 KM AIR/SEA WINDOW'); assert.equal(
formatCockpitContextScope('', 0),
'— · 0 KM AIR/SEA WINDOW',
);
assert.equal( assert.equal(
formatCockpitContextScope(undefined, Number.NaN, {}), formatCockpitContextScope(undefined, Number.NaN, {}),
'— · — KM AIR/SEA WINDOW', '— · — KM AIR/SEA WINDOW',
@@ -170,29 +169,26 @@ test('relative bearing stays on the shortest signed arc', () => {
}); });
test('HUD rail layout centers between intersecting upper and lower obstacles', () => { test('HUD rail layout centers between intersecting upper and lower obstacles', () => {
assert.deepEqual( assert.deepEqual(resolveHudRailLayout({
resolveHudRailLayout({ viewportHeight: 1000,
viewportHeight: 1000, panelHeight: 200,
panelHeight: 200, laneLeft: 50,
laneLeft: 50, laneRight: 410,
laneRight: 410, baseTop: 280,
baseTop: 280, baseBottom: 940,
baseBottom: 940, gap: 10,
gap: 10, obstacles: [
obstacles: [ { left: 40, right: 240, top: 320, bottom: 460 },
{ left: 40, right: 240, top: 320, bottom: 460 }, { left: 300, right: 1000, top: 780, bottom: 930 },
{ left: 300, right: 1000, top: 780, bottom: 930 }, { left: 900, right: 1100, top: 300, bottom: 700 },
{ left: 900, right: 1100, top: 300, bottom: 700 }, ],
], }), {
}), top: 520,
{ maxHeight: 300,
top: 520, safeTop: 470,
maxHeight: 300, safeBottom: 770,
safeTop: 470, constrained: false,
safeBottom: 770, });
constrained: false,
},
);
}); });
test('HUD rail layout constrains an oversized panel to the safe corridor', () => { test('HUD rail layout constrains an oversized panel to the safe corridor', () => {
@@ -246,10 +242,7 @@ function contextSnapshot(subject, extra = {}) {
} }
test('Contact panel hides only when there is no snapshot at all', () => { test('Contact panel hides only when there is no snapshot at all', () => {
const readout = resolveCockpitContextReadout({ const readout = resolveCockpitContextReadout({ snapshot: null, info: TRACKED_INFO });
snapshot: null,
info: TRACKED_INFO,
});
assert.equal(readout.visible, false); assert.equal(readout.visible, false);
assert.equal(readout.mode, 'standby'); assert.equal(readout.mode, 'standby');
assert.equal( assert.equal(
@@ -265,22 +258,14 @@ test('Contact panel survives NEXT onto a vessel or installation subject', () =>
// camera: "click next... whole left panel disappears"). // camera: "click next... whole left panel disappears").
for (const subject of [ for (const subject of [
{ layerId: 'ais-live-vessels', id: '353136000', label: 'MAERSK DETROIT' }, { layerId: 'ais-live-vessels', id: '353136000', label: 'MAERSK DETROIT' },
{ { layerId: 'military-installations', id: 'fort-hood', label: 'FORT CAVAZOS' },
layerId: 'military-installations',
id: 'fort-hood',
label: 'FORT CAVAZOS',
},
{ layerId: 'military', id: 'ae01ce', label: 'RCH451' }, { layerId: 'military', id: 'ae01ce', label: 'RCH451' },
]) { ]) {
const readout = resolveCockpitContextReadout({ const readout = resolveCockpitContextReadout({
snapshot: contextSnapshot(subject), snapshot: contextSnapshot(subject),
info: TRACKED_INFO, info: TRACKED_INFO,
}); });
assert.equal( assert.equal(readout.visible, true, `${subject.layerId} subject must keep the panel up`);
readout.visible,
true,
`${subject.layerId} subject must keep the panel up`,
);
assert.equal(readout.mode, 'foreign'); assert.equal(readout.mode, 'foreign');
assert.equal(readout.subjectMatchesTracked, false); assert.equal(readout.subjectMatchesTracked, false);
} }
@@ -288,11 +273,7 @@ test('Contact panel survives NEXT onto a vessel or installation subject', () =>
test('a foreign subject dashes the aircraft-relative fields and keeps the rest live', () => { test('a foreign subject dashes the aircraft-relative fields and keeps the rest live', () => {
const readout = resolveCockpitContextReadout({ const readout = resolveCockpitContextReadout({
snapshot: contextSnapshot({ snapshot: contextSnapshot({ layerId: 'ais-live-vessels', id: '353136000', label: 'MAERSK DETROIT' }),
layerId: 'ais-live-vessels',
id: '353136000',
label: 'MAERSK DETROIT',
}),
info: TRACKED_INFO, info: TRACKED_INFO,
}); });
assert.equal(readout.visible, true); assert.equal(readout.visible, true);
@@ -301,20 +282,12 @@ test('a foreign subject dashes the aircraft-relative fields and keeps the rest l
// frame while every other row value is measured from the subject; rendering // frame while every other row value is measured from the subject; rendering
// both live would present one mixed-frame reading as a single measurement. // both live would present one mixed-frame reading as a single measurement.
assert.equal(readout.aircraftRelative, false); assert.equal(readout.aircraftRelative, false);
assert.equal( assert.equal(readout.contactLost, false, 'subject-frame values still refresh');
readout.contactLost,
false,
'subject-frame values still refresh',
);
}); });
test('the tracked aircraft as subject keeps every field in its own frame', () => { test('the tracked aircraft as subject keeps every field in its own frame', () => {
const readout = resolveCockpitContextReadout({ const readout = resolveCockpitContextReadout({
snapshot: contextSnapshot({ snapshot: contextSnapshot({ layerId: 'flights', id: 'aaa077', label: 'SWA1234' }),
layerId: 'flights',
id: 'aaa077',
label: 'SWA1234',
}),
info: TRACKED_INFO, info: TRACKED_INFO,
}); });
assert.equal(readout.visible, true); assert.equal(readout.visible, true);
@@ -333,11 +306,7 @@ test('a fast-culled subject keeps the panel up as CONTACT LOST instead of collap
snapshot: contextSnapshot(subject, { subjectPresent: false }), snapshot: contextSnapshot(subject, { subjectPresent: false }),
info: TRACKED_INFO, info: TRACKED_INFO,
}); });
assert.equal( assert.equal(readout.visible, true, 'a lost contact must not take the panel down');
readout.visible,
true,
'a lost contact must not take the panel down',
);
assert.equal(readout.mode, 'lost'); assert.equal(readout.mode, 'lost');
assert.equal(readout.contactLost, true, 'last-known values stay on screen'); assert.equal(readout.contactLost, true, 'last-known values stay on screen');
} }
@@ -345,10 +314,7 @@ test('a fast-culled subject keeps the panel up as CONTACT LOST instead of collap
test('an explicitly present subject is never reported lost', () => { test('an explicitly present subject is never reported lost', () => {
const present = resolveCockpitContextReadout({ const present = resolveCockpitContextReadout({
snapshot: contextSnapshot( snapshot: contextSnapshot({ layerId: 'flights', id: 'aaa077' }, { subjectPresent: true }),
{ layerId: 'flights', id: 'aaa077' },
{ subjectPresent: true },
),
info: TRACKED_INFO, info: TRACKED_INFO,
}); });
assert.equal(present.contactLost, false); assert.equal(present.contactLost, false);
@@ -367,36 +333,20 @@ test('the tracked flight layer is resolved by normalized tracked identity', () =
// Both layers describe a tracked aircraft during a cross-layer handoff; // Both layers describe a tracked aircraft during a cross-layer handoff;
// civilian-first precedence would hand the cockpit the wrong aircraft. // civilian-first precedence would hand the cockpit the wrong aircraft.
assert.equal( assert.equal(
resolveTrackedAircraftInfo({ resolveTrackedAircraftInfo({ civilian, military, trackedId: 'military:ae01ce' }).layerId,
civilian,
military,
trackedId: 'military:ae01ce',
}).layerId,
'military', 'military',
); );
assert.equal( assert.equal(
resolveTrackedAircraftInfo({ resolveTrackedAircraftInfo({ civilian, military, trackedId: 'military:ae01ce' }).icao24,
civilian,
military,
trackedId: 'military:ae01ce',
}).icao24,
'ae01ce', 'ae01ce',
); );
assert.equal( assert.equal(
resolveTrackedAircraftInfo({ resolveTrackedAircraftInfo({ civilian, military, trackedId: 'flights:aaa077' }).layerId,
civilian,
military,
trackedId: 'flights:aaa077',
}).layerId,
'flights', 'flights',
); );
// Case-insensitive: layers stamp lowercase hex, callers may not. // Case-insensitive: layers stamp lowercase hex, callers may not.
assert.equal( assert.equal(
resolveTrackedAircraftInfo({ resolveTrackedAircraftInfo({ civilian, military, trackedId: 'MILITARY:AE01CE' }).layerId,
civilian,
military,
trackedId: 'MILITARY:AE01CE',
}).layerId,
'military', 'military',
); );
}); });
@@ -406,37 +356,29 @@ test('tracked-identity resolution falls back to layer precedence', () => {
const military = { icao24: 'ae01ce' }; const military = { icao24: 'ae01ce' };
// No stamped identity (or one that matches neither layer) keeps the historic // No stamped identity (or one that matches neither layer) keeps the historic
// civilian-first order so tracking paths without gevTrackedId still work. // civilian-first order so tracking paths without gevTrackedId still work.
assert.equal(resolveTrackedAircraftInfo({ civilian, military }).layerId, 'flights');
assert.equal( assert.equal(
resolveTrackedAircraftInfo({ civilian, military }).layerId, resolveTrackedAircraftInfo({ civilian, military, trackedId: 'satellites:25544' }).layerId,
'flights', 'flights',
); );
assert.equal( assert.equal(resolveTrackedAircraftInfo({ military, trackedId: '' }).layerId, 'military');
resolveTrackedAircraftInfo({ assert.equal(resolveTrackedAircraftInfo({ trackedId: 'flights:aaa077' }), null);
civilian,
military,
trackedId: 'satellites:25544',
}).layerId,
'flights',
);
assert.equal(
resolveTrackedAircraftInfo({ military, trackedId: '' }).layerId,
'military',
);
assert.equal(
resolveTrackedAircraftInfo({ trackedId: 'flights:aaa077' }),
null,
);
assert.equal(resolveTrackedAircraftInfo(), null); assert.equal(resolveTrackedAircraftInfo(), null);
}); });
test('cockpit emergency wording states the broadcast code, not a conclusion', () => { test('cockpit emergency wording states the broadcast code, not a conclusion', () => {
assert.equal( assert.equal(
formatCockpitEmergency({ label: 'General emergency', squawk: '7700' }), formatCockpitEmergency({ label: 'General emergency', squawk: '7700', source: 'squawk', severity: 'emergency' }),
'SQUAWK 7700 · GENERAL EMERGENCY', 'SQUAWK 7700 · GENERAL EMERGENCY',
); );
assert.equal( assert.equal(
formatCockpitEmergency({ label: 'Minimum fuel', squawk: null }), formatCockpitEmergency({ label: 'Downed aircraft', squawk: '1200', source: 'ads-b', severity: 'emergency' }),
'MINIMUM FUEL', 'ADS-B EMERGENCY · DOWNED AIRCRAFT',
'an unrelated squawk is not quoted beside an ADS-B status',
);
assert.equal(
formatCockpitEmergency({ label: 'Minimum fuel', squawk: null, source: 'ads-b', severity: 'priority' }),
'ADS-B PRIORITY · MINIMUM FUEL',
); );
assert.equal(formatCockpitEmergency(null), null); assert.equal(formatCockpitEmergency(null), null);
assert.equal(formatCockpitEmergency({ label: '' }), null); assert.equal(formatCockpitEmergency({ label: '' }), null);
+4 -2
View File
@@ -43,7 +43,9 @@ export function normalizeSquawk(value) {
* 7x00 squawk counts even when the ADS-B field says `none`. * 7x00 squawk counts even when the ADS-B field says `none`.
* @param {{squawk?: unknown, emergency?: unknown}} [observation] * @param {{squawk?: unknown, emergency?: unknown}} [observation]
* @returns {{kind: string, label: string, severity: 'emergency'|'priority', * @returns {{kind: string, label: string, severity: 'emergency'|'priority',
* squawk: string|null, source: 'ads-b'|'squawk'}|null} * squawk: string|null, source: 'ads-b'|'squawk'}|null} `source` is
* 'squawk' when the Mode A code itself names the status (so it can be
* quoted), else 'ads-b'.
*/ */
export function aircraftEmergency({ squawk, emergency } = {}) { export function aircraftEmergency({ squawk, emergency } = {}) {
const code = normalizeSquawk(squawk); const code = normalizeSquawk(squawk);
@@ -57,7 +59,7 @@ export function aircraftEmergency({ squawk, emergency } = {}) {
kind, kind,
...KINDS[kind], ...KINDS[kind],
squawk: code, squawk: code,
source: fromAdsb ? 'ads-b' : 'squawk', source: SQUAWK_KINDS[code] === kind ? 'squawk' : 'ads-b',
}; };
} }
+9
View File
@@ -39,6 +39,15 @@ test('the ADS-B emergency field wins, and `none` defers to the squawk', () => {
aircraftEmergency({ squawk: '7700', emergency: 'none' }).source, aircraftEmergency({ squawk: '7700', emergency: 'none' }).source,
'squawk', 'squawk',
); );
assert.equal(
aircraftEmergency({ squawk: '7700', emergency: 'general' }).source,
'squawk',
'a code that names the status stays quotable',
);
assert.equal(
aircraftEmergency({ squawk: '1200', emergency: 'general' }).source,
'ads-b',
);
assert.equal(aircraftEmergency({ emergency: 'downed' }).kind, 'downed'); assert.equal(aircraftEmergency({ emergency: 'downed' }).kind, 'downed');
assert.equal(aircraftEmergency({ emergency: 'none' }), null); assert.equal(aircraftEmergency({ emergency: 'none' }), null);
assert.equal(aircraftEmergency({ emergency: 'reserved' }), null); assert.equal(aircraftEmergency({ emergency: 'reserved' }), null);
+63 -285
View File
@@ -1,89 +1,18 @@
import { test } from 'node:test'; import { test } from 'node:test';
import assert from 'node:assert/strict'; import assert from 'node:assert/strict';
import { import { createAnalystEngine, applyScope, haversineKm } from './analystEngine.js';
createAnalystEngine,
applyScope,
haversineKm,
} from './analystEngine.js';
// Stub world: a square "Texland" region, flights + ships + fires around it. // Stub world: a square "Texland" region, flights + ships + fires around it.
const TEXLAND = { const TEXLAND = { name: 'Texland', ring: [[-100, 28], [-94, 28], [-94, 33], [-100, 33]] };
name: 'Texland',
ring: [
[-100, 28],
[-94, 28],
[-94, 33],
[-100, 33],
],
};
const FLIGHTS = [ const FLIGHTS = [
{ { id: 'SWA1', lat: 30.2, lon: -97.7, altitudeM: 11000, speedMps: 240, military: false, onGround: false, routeOrigin: 'AUS', routeDestination: 'LAX' },
id: 'SWA1', { id: 'RCH01', lat: 31.0, lon: -97.0, altitudeM: 13500, speedMps: 250, military: true, onGround: false, routeOrigin: null, routeDestination: null },
lat: 30.2, { id: 'N123', lat: 45.0, lon: -122.0, altitudeM: 2000, speedMps: 80, military: false, onGround: false, squawk: '7700', emergency: true, emergencyKind: 'general', routeOrigin: null, routeDestination: null },
lon: -97.7, { id: 'GND1', lat: 30.19, lon: -97.66, altitudeM: 150, speedMps: 5, military: false, onGround: true, routeOrigin: null, routeDestination: null },
altitudeM: 11000,
speedMps: 240,
military: false,
onGround: false,
routeOrigin: 'AUS',
routeDestination: 'LAX',
},
{
id: 'RCH01',
lat: 31.0,
lon: -97.0,
altitudeM: 13500,
speedMps: 250,
military: true,
onGround: false,
routeOrigin: null,
routeDestination: null,
},
{
id: 'N123',
lat: 45.0,
lon: -122.0,
altitudeM: 2000,
speedMps: 80,
military: false,
onGround: false,
squawk: '7700',
emergency: true,
emergencyKind: 'general',
routeOrigin: null,
routeDestination: null,
},
{
id: 'GND1',
lat: 30.19,
lon: -97.66,
altitudeM: 150,
speedMps: 5,
military: false,
onGround: true,
routeOrigin: null,
routeDestination: null,
},
]; ];
const SHIPS = [ const SHIPS = [
{ { id: 'EVERGIVEN', lat: 29.5, lon: -94.9, speedKts: 12, shipType: 'Cargo', destination: 'OAKLAND', navStatus: 'under way' },
id: 'EVERGIVEN', { id: 'SLOWBOAT', lat: 29.6, lon: -95.0, speedKts: 0.2, shipType: 'Tanker', destination: 'HOUSTON', navStatus: 'anchored' },
lat: 29.5,
lon: -94.9,
speedKts: 12,
shipType: 'Cargo',
destination: 'OAKLAND',
navStatus: 'under way',
},
{
id: 'SLOWBOAT',
lat: 29.6,
lon: -95.0,
speedKts: 0.2,
shipType: 'Tanker',
destination: 'HOUSTON',
navStatus: 'anchored',
},
]; ];
const FIRES = [ const FIRES = [
{ id: 'FIRE-1', lat: 30.5, lon: -98.2, frp: 1500 }, { id: 'FIRE-1', lat: 30.5, lon: -98.2, frp: 1500 },
@@ -93,10 +22,7 @@ const FIRES = [
function makeEngine() { function makeEngine() {
return createAnalystEngine({ return createAnalystEngine({
getRecords: (key) => getRecords: (key) => ({ flights: FLIGHTS, 'ais-live-vessels': SHIPS, 'local-firms': FIRES }[key] || []),
({ flights: FLIGHTS, 'ais-live-vessels': SHIPS, 'local-firms': FIRES })[
key
] || [],
resolveRegionRing: async (name) => (/texland/i.test(name) ? TEXLAND : null), resolveRegionRing: async (name) => (/texland/i.test(name) ? TEXLAND : null),
getViewContext: () => ({ lat: 30.27, lon: -97.74, viewRadiusKm: 150 }), getViewContext: () => ({ lat: 30.27, lon: -97.74, viewRadiusKm: 150 }),
}); });
@@ -105,10 +31,7 @@ function makeEngine() {
/** Same world, but Contacts is up with a subject far from the parked camera. */ /** Same world, but Contacts is up with a subject far from the parked camera. */
function makeContactsEngine(subject) { function makeContactsEngine(subject) {
return createAnalystEngine({ return createAnalystEngine({
getRecords: (key) => getRecords: (key) => ({ flights: FLIGHTS, 'ais-live-vessels': SHIPS, 'local-firms': FIRES }[key] || []),
({ flights: FLIGHTS, 'ais-live-vessels': SHIPS, 'local-firms': FIRES })[
key
] || [],
resolveRegionRing: async (name) => (/texland/i.test(name) ? TEXLAND : null), resolveRegionRing: async (name) => (/texland/i.test(name) ? TEXLAND : null),
// Parked far away, as a high-altitude camera often is. // Parked far away, as a high-altitude camera often is.
getViewContext: () => ({ lat: 45.0, lon: -122.0, viewRadiusKm: 150 }), getViewContext: () => ({ lat: 45.0, lon: -122.0, viewRadiusKm: 150 }),
@@ -129,11 +52,7 @@ test('analyst: a radius query centers on the active contact, not the parked came
assert.equal(r.ok, true); assert.equal(r.ok, true);
// Austin-area flights, not the Oregon one the camera is parked over. // Austin-area flights, not the Oregon one the camera is parked over.
assert.equal(r.count, 3); assert.equal(r.count, 3);
assert.equal( assert.equal(r.centeredOn, 'SWA1', 'the answer names the centre it measured from');
r.centeredOn,
'SWA1',
'the answer names the centre it measured from',
);
assert.ok(r.coverage.scope.includes('@SWA1')); assert.ok(r.coverage.scope.includes('@SWA1'));
}); });
@@ -144,11 +63,7 @@ test('analyst: an explicit center still wins over the active contact', async ()
scope: { kind: 'radius', km: 250, center: { lat: 45.0, lon: -122.0 } }, scope: { kind: 'radius', km: 250, center: { lat: 45.0, lon: -122.0 } },
limit: 50, limit: 50,
}); });
assert.equal( assert.equal(r.count, 1, 'only the Oregon flight is within 250 km of the given center');
r.count,
1,
'only the Oregon flight is within 250 km of the given center',
);
assert.equal(r.centeredOn, undefined, 'an explicit center is not relabelled'); assert.equal(r.centeredOn, undefined, 'an explicit center is not relabelled');
}); });
@@ -158,11 +73,7 @@ test('analyst: with Contacts off, radius still centers on the view', async () =>
scope: { kind: 'radius', km: 250 }, scope: { kind: 'radius', km: 250 },
limit: 50, limit: 50,
}); });
assert.equal( assert.equal(r.count, 1, 'view-centred behaviour is unchanged outside Contacts');
r.count,
1,
'view-centred behaviour is unchanged outside Contacts',
);
assert.equal(r.centeredOn, undefined); assert.equal(r.centeredOn, undefined);
assert.equal(r.coverage.scope, 'radius:250km'); assert.equal(r.coverage.scope, 'radius:250km');
}); });
@@ -172,25 +83,13 @@ test('analyst: a subject without usable coordinates cannot lend its name to a ca
// number. A subject present but position-less fell back to the camera and // number. A subject present but position-less fell back to the camera and
// kept the contact's name on the answer, so a camera-centred count read as // kept the contact's name on the answer, so a camera-centred count read as
// contact-centred with nothing in the payload to catch it. // contact-centred with nothing in the payload to catch it.
const r = await makeContactsEngine({ const r = await makeContactsEngine({ lat: null, lon: null, label: 'SWA1' }).query({
lat: null,
lon: null,
label: 'SWA1',
}).query({
layers: ['flights'], layers: ['flights'],
scope: { kind: 'radius', km: 250 }, scope: { kind: 'radius', km: 250 },
limit: 50, limit: 50,
}); });
assert.equal( assert.equal(r.count, 1, 'the count is the camera-centred one it actually measured');
r.count, assert.equal(r.centeredOn, undefined, 'and it must not claim a centre it did not use');
1,
'the count is the camera-centred one it actually measured',
);
assert.equal(
r.centeredOn,
undefined,
'and it must not claim a centre it did not use',
);
assert.equal(r.coverage.scope, 'radius:250km'); assert.equal(r.coverage.scope, 'radius:250km');
assert.equal(r.scopeLabel, 'within 250 km'); assert.equal(r.scopeLabel, 'within 250 km');
}); });
@@ -200,47 +99,33 @@ test('analyst: every scope names itself in words', async () => {
// answers look like a contradiction, so each scope carries its own phrasing. // answers look like a contradiction, so each scope carries its own phrasing.
const subject = { lat: 30.2, lon: -97.7, label: 'DYNO11' }; const subject = { lat: 30.2, lon: -97.7, label: 'DYNO11' };
const centred = await makeContactsEngine(subject).query({ const centred = await makeContactsEngine(subject).query({
layers: ['flights'], layers: ['flights'], scope: { kind: 'radius', km: 250 }, limit: 1,
scope: { kind: 'radius', km: 250 },
limit: 1,
}); });
assert.equal(centred.scopeLabel, 'within 250 km of DYNO11'); assert.equal(centred.scopeLabel, 'within 250 km of DYNO11');
const plainRadius = await makeContactsEngine(null).query({ const plainRadius = await makeContactsEngine(null).query({
layers: ['flights'], layers: ['flights'], scope: { kind: 'radius', km: 250 }, limit: 1,
scope: { kind: 'radius', km: 250 },
limit: 1,
}); });
assert.equal(plainRadius.scopeLabel, 'within 250 km'); assert.equal(plainRadius.scopeLabel, 'within 250 km');
const inView = await makeEngine().query({ const inView = await makeEngine().query({
layers: ['flights'], layers: ['flights'], scope: { kind: 'view' }, limit: 1,
scope: { kind: 'view' },
limit: 1,
}); });
assert.equal(inView.scopeLabel, 'in view'); assert.equal(inView.scopeLabel, 'in view');
const region = await makeEngine().query({ const region = await makeEngine().query({
layers: ['flights'], layers: ['flights'], scope: { kind: 'region', name: 'Texland' }, limit: 1,
scope: { kind: 'region', name: 'Texland' },
limit: 1,
}); });
assert.equal(region.scopeLabel, 'over Texland'); assert.equal(region.scopeLabel, 'over Texland');
const anywhere = await makeEngine().query({ const anywhere = await makeEngine().query({
layers: ['flights'], layers: ['flights'], scope: { kind: 'anywhere' }, limit: 1,
scope: { kind: 'anywhere' },
limit: 1,
}); });
assert.equal(anywhere.scopeLabel, 'anywhere in the loaded data'); assert.equal(anywhere.scopeLabel, 'anywhere in the loaded data');
}); });
test('analyst: count flights over a region', async () => { test('analyst: count flights over a region', async () => {
const r = await makeEngine().query({ const r = await makeEngine().query({ layers: ['flights'], scope: { kind: 'region', name: 'Texland' }, limit: 50 });
layers: ['flights'],
scope: { kind: 'region', name: 'Texland' },
limit: 50,
});
assert.equal(r.ok, true); assert.equal(r.ok, true);
assert.equal(r.count, 3, 'Oregon flight excluded'); assert.equal(r.count, 3, 'Oregon flight excluded');
assert.ok(r.coverage.scope.includes('Texland')); assert.ok(r.coverage.scope.includes('Texland'));
@@ -248,65 +133,32 @@ test('analyst: count flights over a region', async () => {
test('analyst: attribute filter — above 40,000 ft (~12,192 m)', async () => { test('analyst: attribute filter — above 40,000 ft (~12,192 m)', async () => {
const r = await makeEngine().query({ const r = await makeEngine().query({
layers: ['flights'], layers: ['flights'], scope: { kind: 'anywhere' },
scope: { kind: 'anywhere' },
filters: [{ field: 'altitudeM', op: 'gt', value: 12192 }], filters: [{ field: 'altitudeM', op: 'gt', value: 12192 }],
}); });
assert.deepEqual( assert.deepEqual(r.items.map((i) => i.id), ['RCH01']);
r.items.map((i) => i.id),
['RCH01'],
);
}); });
test('analyst: military flag + region compose', async () => { test('analyst: military flag + region compose', async () => {
const r = await makeEngine().query({ const r = await makeEngine().query({
layers: ['flights'], layers: ['flights'], scope: { kind: 'region', name: 'Texland' },
scope: { kind: 'region', name: 'Texland' },
filters: [{ field: 'military', op: 'eq', value: true }], filters: [{ field: 'military', op: 'eq', value: true }],
}); });
assert.equal(r.count, 1); assert.equal(r.count, 1);
assert.equal(r.items[0].id, 'RCH01'); assert.equal(r.items[0].id, 'RCH01');
}); });
test('analyst: aircraft broadcasting an emergency are filterable by flag and code', async () => {
const flagged = await makeEngine().query({
layers: ['flights'],
scope: { kind: 'anywhere' },
filters: [{ field: 'emergency', op: 'eq', value: true }],
});
assert.deepEqual(
flagged.items.map((i) => i.id),
['N123'],
);
const coded = await makeEngine().query({
layers: ['flights'],
scope: { kind: 'anywhere' },
filters: [{ field: 'squawk', op: 'eq', value: '7700' }],
});
assert.deepEqual(
coded.items.map((i) => i.id),
['N123'],
);
});
test('analyst: ships headed to Oakland (destination contains)', async () => { test('analyst: ships headed to Oakland (destination contains)', async () => {
const r = await makeEngine().query({ const r = await makeEngine().query({
layers: ['ais-live-vessels'], layers: ['ais-live-vessels'], scope: { kind: 'anywhere' },
scope: { kind: 'anywhere' },
filters: [{ field: 'destination', op: 'contains', value: 'oakland' }], filters: [{ field: 'destination', op: 'contains', value: 'oakland' }],
}); });
assert.deepEqual( assert.deepEqual(r.items.map((i) => i.id), ['EVERGIVEN']);
r.items.map((i) => i.id),
['EVERGIVEN'],
);
}); });
test('analyst: superlative — biggest fire in view radius', async () => { test('analyst: superlative — biggest fire in view radius', async () => {
const r = await makeEngine().query({ const r = await makeEngine().query({
layers: ['local-firms'], layers: ['local-firms'], scope: { kind: 'view' }, sortBy: 'frp', limit: 1,
scope: { kind: 'view' },
sortBy: 'frp',
limit: 1,
}); });
assert.equal(r.items[0].id, 'FIRE-1', 'BC monster is out of view scope'); assert.equal(r.items[0].id, 'FIRE-1', 'BC monster is out of view scope');
assert.equal(r.summary.frpMax, 1500); assert.equal(r.summary.frpMax, 1500);
@@ -314,10 +166,7 @@ test('analyst: superlative — biggest fire in view radius', async () => {
test('analyst: nearest sorting attaches distanceKm ascending', async () => { test('analyst: nearest sorting attaches distanceKm ascending', async () => {
const r = await makeEngine().query({ const r = await makeEngine().query({
layers: ['flights'], layers: ['flights'], scope: { kind: 'view' }, sortBy: 'distance', limit: 3,
scope: { kind: 'view' },
sortBy: 'distance',
limit: 3,
}); });
assert.ok(r.items[0].distanceKm <= r.items[1].distanceKm); assert.ok(r.items[0].distanceKm <= r.items[1].distanceKm);
assert.ok(Number.isFinite(r.items[0].distanceKm)); assert.ok(Number.isFinite(r.items[0].distanceKm));
@@ -417,10 +266,7 @@ test('analyst: failed pre-commit work cannot replace follow-up memory', async ()
}); });
test('analyst: unresolved region is an honest failure, not empty success', async () => { test('analyst: unresolved region is an honest failure, not empty success', async () => {
const r = await makeEngine().query({ const r = await makeEngine().query({ layers: ['flights'], scope: { kind: 'region', name: 'Atlantis' } });
layers: ['flights'],
scope: { kind: 'region', name: 'Atlantis' },
});
assert.equal(r.ok, false); assert.equal(r.ok, false);
assert.match(r.error, /Atlantis/); assert.match(r.error, /Atlantis/);
}); });
@@ -428,17 +274,10 @@ test('analyst: unresolved region is an honest failure, not empty success', async
test('analyst: a region lookup timeout is reported as region-timeout', async () => { test('analyst: a region lookup timeout is reported as region-timeout', async () => {
const eng = createAnalystEngine({ const eng = createAnalystEngine({
getRecords: () => FLIGHTS, getRecords: () => FLIGHTS,
resolveRegionRing: async (name) => ({ resolveRegionRing: async (name) => ({ name, ring: null, error: 'region-timeout' }),
name,
ring: null,
error: 'region-timeout',
}),
getViewContext: () => ({ lat: 30.27, lon: -97.74, viewRadiusKm: 150 }), getViewContext: () => ({ lat: 30.27, lon: -97.74, viewRadiusKm: 150 }),
}); });
const r = await eng.query({ const r = await eng.query({ layers: ['flights'], scope: { kind: 'region', name: 'Texas' } });
layers: ['flights'],
scope: { kind: 'region', name: 'Texas' },
});
assert.equal(r.ok, false); assert.equal(r.ok, false);
assert.equal(r.code, 'region-timeout'); assert.equal(r.code, 'region-timeout');
assert.match(r.error, /Texas/); assert.match(r.error, /Texas/);
@@ -480,84 +319,45 @@ test('analyst: region lookup receives and obeys the owning action signal', async
test('analyst: route fields queryable from cached enrichment only', async () => { test('analyst: route fields queryable from cached enrichment only', async () => {
const r = await makeEngine().query({ const r = await makeEngine().query({
layers: ['flights'], layers: ['flights'], scope: { kind: 'anywhere' },
scope: { kind: 'anywhere' },
filters: [{ field: 'routeDestination', op: 'eq', value: 'LAX' }], filters: [{ field: 'routeDestination', op: 'eq', value: 'LAX' }],
}); });
assert.deepEqual( assert.deepEqual(r.items.map((i) => i.id), ['SWA1'], 'null route fields never match');
r.items.map((i) => i.id), });
['SWA1'],
'null route fields never match', test('analyst: aircraft broadcasting an emergency are filterable by flag and code', async () => {
); const flagged = await makeEngine().query({
layers: ['flights'], scope: { kind: 'anywhere' },
filters: [{ field: 'emergency', op: 'eq', value: true }],
});
assert.deepEqual(flagged.items.map((i) => i.id), ['N123']);
const coded = await makeEngine().query({
layers: ['flights'], scope: { kind: 'anywhere' },
filters: [{ field: 'squawk', op: 'eq', value: '7700' }],
});
assert.deepEqual(coded.items.map((i) => i.id), ['N123']);
}); });
test('analyst: satellites and local infrastructure are queryable layers', async () => { test('analyst: satellites and local infrastructure are queryable layers', async () => {
const SATS = [ const SATS = [
{ { id: 'ISS (ZARYA)', noradId: '25544', name: 'ISS (ZARYA)', lat: 30.3, lon: -97.7, altitudeM: 410000, satelliteClass: 'STATION · ISS', group: 'stations' },
id: 'ISS (ZARYA)', { id: 'GPS BIIR-2', noradId: '24876', name: 'GPS BIIR-2', lat: 51.0, lon: 0.0, altitudeM: 20200000, satelliteClass: 'NAV · GPS', group: 'gps-ops' },
noradId: '25544',
name: 'ISS (ZARYA)',
lat: 30.3,
lon: -97.7,
altitudeM: 410000,
satelliteClass: 'STATION · ISS',
group: 'stations',
},
{
id: 'GPS BIIR-2',
noradId: '24876',
name: 'GPS BIIR-2',
lat: 51.0,
lon: 0.0,
altitudeM: 20200000,
satelliteClass: 'NAV · GPS',
group: 'gps-ops',
},
]; ];
const DAMS = [ const DAMS = [
{ { id: 'Austin Dam', name: 'Austin Dam', lat: 30.27, lon: -97.74, operator: 'LCRA', river: 'Colorado', output: '2 MW' },
id: 'Austin Dam', { id: 'Far Dam', name: 'Far Dam', lat: 45.0, lon: -122.0, operator: 'USACE', river: 'Columbia', output: '1000 MW' },
name: 'Austin Dam',
lat: 30.27,
lon: -97.74,
operator: 'LCRA',
river: 'Colorado',
output: '2 MW',
},
{
id: 'Far Dam',
name: 'Far Dam',
lat: 45.0,
lon: -122.0,
operator: 'USACE',
river: 'Columbia',
output: '1000 MW',
},
]; ];
const DCS = [ const DCS = [
{ { id: 'AUS-1', name: 'AUS-1', lat: 30.28, lon: -97.75, operator: 'Example Cloud', capacity: '27 MW' },
id: 'AUS-1',
name: 'AUS-1',
lat: 30.28,
lon: -97.75,
operator: 'Example Cloud',
capacity: '27 MW',
},
]; ];
const eng = createAnalystEngine({ const eng = createAnalystEngine({
getRecords: (key) => getRecords: (key) => ({ satellites: SATS, 'local-dams': DAMS, 'local-datacenters': DCS }[key] || []),
({ satellites: SATS, 'local-dams': DAMS, 'local-datacenters': DCS })[
key
] || [],
resolveRegionRing: async (name) => (/texland/i.test(name) ? TEXLAND : null), resolveRegionRing: async (name) => (/texland/i.test(name) ? TEXLAND : null),
getViewContext: () => ({ lat: 30.27, lon: -97.74, viewRadiusKm: 150 }), getViewContext: () => ({ lat: 30.27, lon: -97.74, viewRadiusKm: 150 }),
}); });
const sats = await eng.query({ const sats = await eng.query({
layers: ['satellites'], layers: ['satellites'], scope: { kind: 'view' }, sortBy: 'distance', limit: 2,
scope: { kind: 'view' },
sortBy: 'distance',
limit: 2,
}); });
assert.equal(sats.ok, true); assert.equal(sats.ok, true);
assert.equal(sats.count, 1, 'GPS sat is out of the Austin view radius'); assert.equal(sats.count, 1, 'GPS sat is out of the Austin view radius');
@@ -565,28 +365,20 @@ test('analyst: satellites and local infrastructure are queryable layers', async
assert.ok(Number.isFinite(sats.items[0].distanceKm)); assert.ok(Number.isFinite(sats.items[0].distanceKm));
const nav = await eng.query({ const nav = await eng.query({
layers: ['satellites'], layers: ['satellites'], scope: { kind: 'anywhere' },
scope: { kind: 'anywhere' },
filters: [{ field: 'satelliteClass', op: 'contains', value: 'NAV' }], filters: [{ field: 'satelliteClass', op: 'contains', value: 'NAV' }],
}); });
assert.deepEqual( assert.deepEqual(nav.items.map((i) => i.id), ['GPS BIIR-2']);
nav.items.map((i) => i.id),
['GPS BIIR-2'],
);
const dams = await eng.query({ const dams = await eng.query({
layers: ['local-dams'], layers: ['local-dams'], scope: { kind: 'view' }, sortBy: 'distance', limit: 5,
scope: { kind: 'view' },
sortBy: 'distance',
limit: 5,
}); });
assert.equal(dams.count, 1); assert.equal(dams.count, 1);
assert.equal(dams.items[0].id, 'Austin Dam'); assert.equal(dams.items[0].id, 'Austin Dam');
assert.equal(dams.items[0].river, 'Colorado'); assert.equal(dams.items[0].river, 'Colorado');
const dcs = await eng.query({ const dcs = await eng.query({
layers: ['local-datacenters'], layers: ['local-datacenters'], scope: { kind: 'region', name: 'Texland' },
scope: { kind: 'region', name: 'Texland' },
filters: [{ field: 'operator', op: 'contains', value: 'cloud' }], filters: [{ field: 'operator', op: 'contains', value: 'cloud' }],
}); });
assert.equal(dcs.count, 1); assert.equal(dcs.count, 1);
@@ -596,11 +388,7 @@ test('analyst: satellites and local infrastructure are queryable layers', async
test('helpers: haversine sanity + scope radius', () => { test('helpers: haversine sanity + scope radius', () => {
const km = haversineKm(30.2672, -97.7431, 29.7604, -95.3698); // Austin→Houston const km = haversineKm(30.2672, -97.7431, 29.7604, -95.3698); // Austin→Houston
assert.ok(km > 200 && km < 280, `Austin-Houston ~235km, got ${km}`); assert.ok(km > 200 && km < 280, `Austin-Houston ~235km, got ${km}`);
const scoped = applyScope( const scoped = applyScope(FLIGHTS, { kind: 'radius' }, { center: { lat: 30.27, lon: -97.74 }, km: 50 });
FLIGHTS,
{ kind: 'radius' },
{ center: { lat: 30.27, lon: -97.74 }, km: 50 },
);
assert.deepEqual(scoped.map((f) => f.id).sort(), ['GND1', 'SWA1']); assert.deepEqual(scoped.map((f) => f.id).sort(), ['GND1', 'SWA1']);
}); });
@@ -610,11 +398,7 @@ test('capped cohorts report returned/total/truncated and keep it on follow-up',
getRecordCoverage: () => ({ total: 3000, truncated: true }), getRecordCoverage: () => ({ total: 3000, truncated: true }),
getViewContext: () => ({ lat: 0, lon: 0, viewRadiusKm: 25 }), getViewContext: () => ({ lat: 0, lon: 0, viewRadiusKm: 25 }),
}); });
const result = await engine.query({ const result = await engine.query({ layers: ['local-dams'], scope: { kind: 'anywhere' }, sortBy: 'distance' });
layers: ['local-dams'],
scope: { kind: 'anywhere' },
sortBy: 'distance',
});
assert.equal(result.count, 1); assert.equal(result.count, 1);
const layer = result.coverage.layersQueried[0]; const layer = result.coverage.layersQueried[0];
assert.deepEqual({ returned: layer.returned, total: layer.total, truncated: layer.truncated }, { returned: 1, total: 3000, truncated: true }); assert.deepEqual({ returned: layer.returned, total: layer.total, truncated: layer.truncated }, { returned: 1, total: 3000, truncated: true });
@@ -735,15 +519,12 @@ test('time fields filter by ISO and derive ageHours; the feed window is exposed'
assert.equal(age.coverage.layersQueried[0].window, 'last 24 h'); assert.equal(age.coverage.layersQueried[0].window, 'last 24 h');
}); });
test('follow-up provenance stays attached to old rows after a feed recovers', async () => { test('follow-up provenance stays attached to old rows after a feed recovers', async () => {
let state = 'stale'; let state = 'stale';
const engine = createAnalystEngine({ const engine = createAnalystEngine({
getRecords: () => [{ id: 'A', lat: 0, lon: 0 }], getRecords: () => [{ id: 'A', lat: 0, lon: 0 }],
getLayerSnapshot: () => ({ getLayerSnapshot: () => ({ id: 'flights', enabled: true, feedState: state }),
id: 'flights',
enabled: true,
feedState: state,
}),
getViewContext: () => ({ lat: 0, lon: 0, viewRadiusKm: 25 }), getViewContext: () => ({ lat: 0, lon: 0, viewRadiusKm: 25 }),
}); });
const first = await engine.query(); const first = await engine.query();
@@ -753,10 +534,7 @@ test('follow-up provenance stays attached to old rows after a feed recovers', as
assert.equal(followUp.coverage.feedProvenance.overall, 'stale'); assert.equal(followUp.coverage.feedProvenance.overall, 'stale');
engine.reset(); engine.reset();
assert.equal(engine.hasMemory(), false); assert.equal(engine.hasMemory(), false);
assert.equal( assert.equal((await engine.query()).coverage.feedProvenance.overall, 'nominal');
(await engine.query()).coverage.feedProvenance.overall,
'nominal',
);
}); });
test('a large loaded set sorts and summarizes without overflowing the stack', async () => { test('a large loaded set sorts and summarizes without overflowing the stack', async () => {
+236 -879
View File
File diff suppressed because it is too large. Load diff
+93 -298
View File
@@ -24,12 +24,8 @@ test('share-Follow absence requires an accepted adsb.lol snapshot', async () =>
(await militaryFlightsLayer.resolveTrackingRestoreTarget('ae1234')).status, (await militaryFlightsLayer.resolveTrackingRestoreTarget('ae1234')).status,
'source-unavailable', 'source-unavailable',
); );
_setMilitaryTrackingRefreshOutcomeForTest({ _setMilitaryTrackingRefreshOutcomeForTest({ status: 'accepted', ids: ['different'] });
status: 'accepted', const missing = await militaryFlightsLayer.resolveTrackingRestoreTarget('ae1234');
ids: ['different'],
});
const missing =
await militaryFlightsLayer.resolveTrackingRestoreTarget('ae1234');
assert.equal(missing.status, 'missing'); assert.equal(missing.status, 'missing');
assert.equal(missing.reason, 'target-absent-from-snapshot'); assert.equal(missing.reason, 'target-absent-from-snapshot');
}); });
@@ -105,14 +101,8 @@ test('military analyst record: military is ALWAYS true, routes/country always nu
}); });
test('military analyst record: no callsign falls back to registration, then icao24', () => { test('military analyst record: no callsign falls back to registration, then icao24', () => {
assert.equal( assert.equal(mapAnalystRecord('ae01ce', { ...FULL_INFO, callsign: '' }).id, '05-8152');
mapAnalystRecord('ae01ce', { ...FULL_INFO, callsign: '' }).id, assert.equal(mapAnalystRecord('ae01ce', { callsign: '', registration: ' ' }).id, 'ae01ce');
'05-8152',
);
assert.equal(
mapAnalystRecord('ae01ce', { callsign: '', registration: ' ' }).id,
'ae01ce',
);
}); });
test('military analyst record: empty info yields nulls, never NaN/undefined', () => { test('military analyst record: empty info yields nulls, never NaN/undefined', () => {
@@ -121,8 +111,7 @@ test('military analyst record: empty info yields nulls, never NaN/undefined', ()
assert.equal(r.onGround, false); assert.equal(r.onGround, false);
for (const [key, value] of Object.entries(r)) { for (const [key, value] of Object.entries(r)) {
assert.notEqual(value, undefined, `${key} must not be undefined`); assert.notEqual(value, undefined, `${key} must not be undefined`);
if (typeof value === 'number') if (typeof value === 'number') assert.ok(Number.isFinite(value), `${key} must not be NaN`);
assert.ok(Number.isFinite(value), `${key} must not be NaN`);
} }
}); });
@@ -134,17 +123,12 @@ test('military analyst record: output is JSON-safe (no Cesium types)', () => {
test('military first update forwards caller cancellation into the feed request', async () => { test('military first update forwards caller cancellation into the feed request', async () => {
const realFetch = globalThis.fetch; const realFetch = globalThis.fetch;
let observedSignal = null; let observedSignal = null;
globalThis.fetch = (_url, options = {}) => globalThis.fetch = (_url, options = {}) => new Promise((_resolve, reject) => {
new Promise((_resolve, reject) => { observedSignal = options.signal;
observedSignal = options.signal; options.signal?.addEventListener('abort', () => {
options.signal?.addEventListener( reject(new DOMException('aborted', 'AbortError'));
'abort', }, { once: true });
() => { });
reject(new DOMException('aborted', 'AbortError'));
},
{ once: true },
);
});
try { try {
const controller = new AbortController(); const controller = new AbortController();
const work = militaryFlightsLayer.update({}, { signal: controller.signal }); const work = militaryFlightsLayer.update({}, { signal: controller.signal });
@@ -174,22 +158,11 @@ test('nonempty adsb.lol payload with zero usable rows cannot prove share target
json: async () => ({ ac: [null, {}, { hex: 'ae1234' }] }), json: async () => ({ ac: [null, {}, { hex: 'ae1234' }] }),
}); });
try { try {
await militaryFlightsLayer.update({ await militaryFlightsLayer.update({ camera: { positionCartographic: null }, scene: {} });
camera: { positionCartographic: null }, const resolution = await militaryFlightsLayer.resolveTrackingRestoreTarget('ae1234');
scene: {},
});
const resolution =
await militaryFlightsLayer.resolveTrackingRestoreTarget('ae1234');
assert.equal(resolution.status, 'source-unavailable'); assert.equal(resolution.status, 'source-unavailable');
assert.match( assert.match(militaryFlightsLayer.getStats().error, /Malformed adsb\.lol aircraft rows/);
militaryFlightsLayer.getStats().error, assert.equal(militaryFlightsLayer.getAnalystRecords().length, 1, 'warm aircraft data is preserved');
/Malformed adsb\.lol aircraft rows/,
);
assert.equal(
militaryFlightsLayer.getAnalystRecords().length,
1,
'warm aircraft data is preserved',
);
} finally { } finally {
globalThis.fetch = realFetch; globalThis.fetch = realFetch;
} }
@@ -235,26 +208,21 @@ test('military poll refreshes tracked callsign/altitude/kts and marks a missed p
ok: true, ok: true,
status: 200, status: 200,
json: async () => ({ json: async () => ({
ac: ac: poll++ === 0 ? [{
poll++ === 0 hex: icao24,
? [ lon: -96.9,
{ lat: 31.1,
hex: icao24, alt_baro: 28_000,
lon: -96.9, alt_geom: 28_100,
lat: 31.1, track: 95,
alt_baro: 28_000, gs: 400,
alt_geom: 28_100, seen: 0,
track: 95, seen_pos: 0,
gs: 400, flight: 'RCH451 ',
seen: 0, t: 'C17',
seen_pos: 0, r: '05-8152',
flight: 'RCH451 ', ownOp: 'United States Air Force',
t: 'C17', }] : [],
r: '05-8152',
ownOp: 'United States Air Force',
},
]
: [],
}), }),
}); });
@@ -279,10 +247,7 @@ test('cached military snapshots retain their observation time and expose stale f
_setTrackedMilitaryRefreshStateForTest({ _setTrackedMilitaryRefreshStateForTest({
icao24: 'ae01ce', icao24: 'ae01ce',
entity: { gevLabelModel: { title: 'RCH451', details: [] } }, entity: { gevLabelModel: { title: 'RCH451', details: [] } },
billboard: { billboard: { position: Cesium.Cartesian3.fromDegrees(-97, 31, 8000), show: false },
position: Cesium.Cartesian3.fromDegrees(-97, 31, 8000),
show: false,
},
billboardCollection: { show: false, remove() {} }, billboardCollection: { show: false, remove() {} },
viewer, viewer,
history, history,
@@ -320,18 +285,11 @@ test('cached military snapshots retain their observation time and expose stale f
await militaryFlightsLayer.update(viewer); await militaryFlightsLayer.update(viewer);
assert.equal(history.length, 1); assert.equal(history.length, 1);
assert.equal(history[0].epochMs, receivedAt - 2000); assert.equal(history[0].epochMs, receivedAt - 2000);
for (const [status, age] of [ for (const [status, age] of [['HIT', 5000], ['STALE', 45000]]) {
['HIT', 5000],
['STALE', 45000],
]) {
cache = status; cache = status;
now = receivedAt + age; now = receivedAt + age;
await militaryFlightsLayer.update(viewer); await militaryFlightsLayer.update(viewer);
assert.equal( assert.equal(history.length, 1, 'replayed positions cannot create a new fix');
history.length,
1,
'replayed positions cannot create a new fix',
);
assert.equal(militaryFlightsLayer.getStats().lastUpdate, receivedAt); assert.equal(militaryFlightsLayer.getStats().lastUpdate, receivedAt);
assert.equal(militaryFlightsLayer.getStats().stale, status === 'STALE'); assert.equal(militaryFlightsLayer.getStats().stale, status === 'STALE');
assert.equal(militaryFlightsLayer.getStats().error, null); assert.equal(militaryFlightsLayer.getStats().error, null);
@@ -358,18 +316,14 @@ test('real military track path creates no native label and publishes every cache
trackedEntityChanged, trackedEntityChanged,
clock: { currentTime: now }, clock: { currentTime: now },
camera: { camera: {
cancelFlight() { cancelFlight() { cancelledFlights += 1; },
cancelledFlights += 1;
},
position: new Cesium.Cartesian3(0, -10_000, 7_000), position: new Cesium.Cartesian3(0, -10_000, 7_000),
positionWC: new Cesium.Cartesian3(0, -10_000, 7_000), positionWC: new Cesium.Cartesian3(0, -10_000, 7_000),
direction: Cesium.Cartesian3.UNIT_Y, direction: Cesium.Cartesian3.UNIT_Y,
transform: Cesium.Matrix4.IDENTITY, transform: Cesium.Matrix4.IDENTITY,
viewMatrix: Cesium.Matrix4.IDENTITY, viewMatrix: Cesium.Matrix4.IDENTITY,
frustum: { projectionMatrix: Cesium.Matrix4.IDENTITY }, frustum: { projectionMatrix: Cesium.Matrix4.IDENTITY },
lookAtTransform() { lookAtTransform() { appliedFrames += 1; },
appliedFrames += 1;
},
}, },
scene: { scene: {
canvas: { clientWidth: 1600, clientHeight: 900 }, canvas: { clientWidth: 1600, clientHeight: 900 },
@@ -408,12 +362,9 @@ test('real military track path creates no native label and publishes every cache
const realFetch = globalThis.fetch; const realFetch = globalThis.fetch;
globalThis.window = new EventTarget(); globalThis.window = new EventTarget();
const selectionEvents = []; const selectionEvents = [];
globalThis.window.addEventListener( globalThis.window.addEventListener('gev:awareness-subject-selected', (event) => {
'gev:awareness-subject-selected', selectionEvents.push(event.detail);
(event) => { });
selectionEvents.push(event.detail);
},
);
globalThis.fetch = async () => ({ ok: false }); globalThis.fetch = async () => ({ ok: false });
_setTrackedOverlayHostForTest(host); _setTrackedOverlayHostForTest(host);
try { try {
@@ -425,15 +376,13 @@ test('real military track path creates no native label and publishes every cache
billboardCollection: { show: true, remove() {} }, billboardCollection: { show: true, remove() {} },
viewer, viewer,
tracked: false, tracked: false,
history: [ history: [{
{ time: now,
time: now, epochMs: Date.now(),
epochMs: Date.now(), position,
position, velocity: 231.5,
velocity: 231.5, track: 92.1,
track: 92.1, }],
},
],
meta: { meta: {
...FULL_INFO, ...FULL_INFO,
type: 'C17', type: 'C17',
@@ -443,72 +392,34 @@ test('real military track path creates no native label and publishes every cache
}, },
}); });
assert.equal( assert.equal(militaryFlightsLayer.trackById(icao24, { origin: 'programmatic' }), true);
militaryFlightsLayer.trackById(icao24, { origin: 'programmatic' }),
true,
);
const entity = viewer.trackedEntity; const entity = viewer.trackedEntity;
assert.ok( assert.ok(entity instanceof Cesium.Entity, 'trackById must create the real Cesium entity');
entity instanceof Cesium.Entity,
'trackById must create the real Cesium entity',
);
assert.equal(entity.label, undefined); assert.equal(entity.label, undefined);
assert.ok( assert.ok(entities.values.every((candidate) => candidate.label === undefined));
entities.values.every((candidate) => candidate.label === undefined),
);
assert.deepEqual(entity.gevLabelModel, { assert.deepEqual(entity.gevLabelModel, {
title: 'RCH451', title: 'RCH451',
details: ['C17 · 05-8152', 'United States Air Force · 28000 ft · 450 kt'], details: [
'C17 · 05-8152',
'United States Air Force · 28000 ft · 450 kt',
],
accent: '#ffd166', accent: '#ffd166',
}); });
viewer.scene.preUpdate.raiseEvent(); viewer.scene.preUpdate.raiseEvent();
const initialAppliedFrames = appliedFrames; const initialAppliedFrames = appliedFrames;
const initialCancelledFlights = cancelledFlights; const initialCancelledFlights = cancelledFlights;
assert.equal( assert.equal(militaryFlightsLayer.trackById(icao24, { origin: 'user' }), true);
militaryFlightsLayer.trackById(icao24, { origin: 'user' }), assert.equal(cancelledFlights, initialCancelledFlights, 'ordinary repeated tracking stays camera-idempotent');
true, assert.equal(selectionEvents.at(-1)?.origin, 'user', 'same-target selection upgrades durable authority');
);
assert.equal(
cancelledFlights,
initialCancelledFlights,
'ordinary repeated tracking stays camera-idempotent',
);
assert.equal(
selectionEvents.at(-1)?.origin,
'user',
'same-target selection upgrades durable authority',
);
assert.equal(entity.gevSelectionOrigin, 'user'); assert.equal(entity.gevSelectionOrigin, 'user');
assert.equal( assert.equal(militaryFlightsLayer.refocusTrackedById('different-flight'), false);
militaryFlightsLayer.refocusTrackedById('different-flight'), assert.equal(militaryFlightsLayer.refocusTrackedById(icao24, { origin: 'voice' }), true);
false, assert.equal(selectionEvents.at(-1)?.origin, 'voice', 'same-target refocus forwards explicit authority');
);
assert.equal(
militaryFlightsLayer.refocusTrackedById(icao24, { origin: 'voice' }),
true,
);
assert.equal(
selectionEvents.at(-1)?.origin,
'voice',
'same-target refocus forwards explicit authority',
);
assert.equal(militaryFlightsLayer.refocusTrackedById(icao24), true); assert.equal(militaryFlightsLayer.refocusTrackedById(icao24), true);
viewer.scene.preUpdate.raiseEvent(); viewer.scene.preUpdate.raiseEvent();
assert.equal( assert.equal(viewer.trackedEntity, entity, 'refocus must retain the exact tracked entity');
viewer.trackedEntity, assert.equal(appliedFrames, initialAppliedFrames + 1, 'repeated refocus keeps one camera-frame owner');
entity, assert.equal(cancelledFlights, initialCancelledFlights + 2, 'only explicit refocus requests cancel camera flights');
'refocus must retain the exact tracked entity',
);
assert.equal(
appliedFrames,
initialAppliedFrames + 1,
'repeated refocus keeps one camera-frame owner',
);
assert.equal(
cancelledFlights,
initialCancelledFlights + 2,
'only explicit refocus requests cancel camera flights',
);
const publication = publications.at(-1); const publication = publications.at(-1);
assert.equal(publication.sourceId, 'tracked'); assert.equal(publication.sourceId, 'tracked');
const entry = publication.entries[0]; const entry = publication.entries[0];
@@ -519,40 +430,23 @@ test('real military track path creates no native label and publishes every cache
const display = entity.position.getValue(now); const display = entity.position.getValue(now);
assert.ok(display, 'tracked position callback must seed its frame cache'); assert.ok(display, 'tracked position callback must seed its frame cache');
assert.equal( assert.equal(entry.position(), display, 'host must reuse the exact cached display Cartesian');
entry.position(),
display,
'host must reuse the exact cached display Cartesian',
);
militaryFlightsLayer.setParams( militaryFlightsLayer.setParams(
{ selectedMilitaryTrackingId: 'late001' }, { selectedMilitaryTrackingId: 'late001' },
{ origin: 'share-restore' }, { origin: 'share-restore' },
); );
assert.equal(_pendingMilitaryTrackingRestoreForTest(), 'late001'); assert.equal(_pendingMilitaryTrackingRestoreForTest(), 'late001');
assert.equal( assert.equal(militaryFlightsLayer.trackById(icao24, { origin: 'user' }), true);
militaryFlightsLayer.trackById(icao24, { origin: 'user' }), assert.equal(_pendingMilitaryTrackingRestoreForTest(), null, 'new user selection cancels stale restore');
true,
);
assert.equal(
_pendingMilitaryTrackingRestoreForTest(),
null,
'new user selection cancels stale restore',
);
_addMilitaryTrackingCandidateForTest({ _addMilitaryTrackingCandidateForTest({
icao24: 'late001', icao24: 'late001',
billboard: { billboard: { ...billboard, position: Cesium.Cartesian3.fromDegrees(-96.9, 31.1, 8_000) },
...billboard,
position: Cesium.Cartesian3.fromDegrees(-96.9, 31.1, 8_000),
},
meta: { ...FULL_INFO, callsign: 'LATE1', rawLat: 31.1, rawLon: -96.9 }, meta: { ...FULL_INFO, callsign: 'LATE1', rawLat: 31.1, rawLon: -96.9 },
history: [], history: [],
}); });
_applyPendingMilitaryTrackingRestoreForTest(); _applyPendingMilitaryTrackingRestoreForTest();
assert.equal( assert.equal(militaryFlightsLayer.getParams().selectedMilitaryTrackingId, icao24);
militaryFlightsLayer.getParams().selectedMilitaryTrackingId,
icao24,
);
militaryFlightsLayer.stopTracking(); militaryFlightsLayer.stopTracking();
militaryFlightsLayer.setParams( militaryFlightsLayer.setParams(
@@ -561,25 +455,15 @@ test('real military track path creates no native label and publishes every cache
); );
assert.equal(_pendingMilitaryTrackingRestoreForTest(), 'late002'); assert.equal(_pendingMilitaryTrackingRestoreForTest(), 'late002');
militaryFlightsLayer.stopTracking({ origin: 'user' }); militaryFlightsLayer.stopTracking({ origin: 'user' });
assert.equal( assert.equal(_pendingMilitaryTrackingRestoreForTest(), null, 'explicit clear cancels stale restore');
_pendingMilitaryTrackingRestoreForTest(),
null,
'explicit clear cancels stale restore',
);
_addMilitaryTrackingCandidateForTest({ _addMilitaryTrackingCandidateForTest({
icao24: 'late002', icao24: 'late002',
billboard: { billboard: { ...billboard, position: Cesium.Cartesian3.fromDegrees(-96.8, 31.2, 7_000) },
...billboard,
position: Cesium.Cartesian3.fromDegrees(-96.8, 31.2, 7_000),
},
meta: { ...FULL_INFO, callsign: 'LATE2', rawLat: 31.2, rawLon: -96.8 }, meta: { ...FULL_INFO, callsign: 'LATE2', rawLat: 31.2, rawLon: -96.8 },
history: [], history: [],
}); });
_applyPendingMilitaryTrackingRestoreForTest(); _applyPendingMilitaryTrackingRestoreForTest();
assert.equal( assert.equal(militaryFlightsLayer.getParams().selectedMilitaryTrackingId, null);
militaryFlightsLayer.getParams().selectedMilitaryTrackingId,
null,
);
militaryFlightsLayer.setParams( militaryFlightsLayer.setParams(
{ selectedMilitaryTrackingId: 'late003' }, { selectedMilitaryTrackingId: 'late003' },
@@ -594,18 +478,12 @@ test('real military track path creates no native label and publishes every cache
); );
_addMilitaryTrackingCandidateForTest({ _addMilitaryTrackingCandidateForTest({
icao24: 'late003', icao24: 'late003',
billboard: { billboard: { ...billboard, position: Cesium.Cartesian3.fromDegrees(-97.3, 30.6, 7_000) },
...billboard,
position: Cesium.Cartesian3.fromDegrees(-97.3, 30.6, 7_000),
},
meta: { ...FULL_INFO, callsign: 'LATE3', rawLat: 30.6, rawLon: -97.3 }, meta: { ...FULL_INFO, callsign: 'LATE3', rawLat: 30.6, rawLon: -97.3 },
history: [], history: [],
}); });
_applyPendingMilitaryTrackingRestoreForTest(); _applyPendingMilitaryTrackingRestoreForTest();
assert.equal( assert.equal(militaryFlightsLayer.getParams().selectedMilitaryTrackingId, null);
militaryFlightsLayer.getParams().selectedMilitaryTrackingId,
null,
);
militaryFlightsLayer.setParams( militaryFlightsLayer.setParams(
{ selectedMilitaryTrackingId: 'late004' }, { selectedMilitaryTrackingId: 'late004' },
@@ -614,27 +492,18 @@ test('real military track path creates no native label and publishes every cache
assert.equal(_pendingMilitaryTrackingRestoreForTest(), 'late004'); assert.equal(_pendingMilitaryTrackingRestoreForTest(), 'late004');
_addMilitaryTrackingCandidateForTest({ _addMilitaryTrackingCandidateForTest({
icao24: 'late004', icao24: 'late004',
billboard: { billboard: { ...billboard, position: Cesium.Cartesian3.fromDegrees(-97.2, 30.7, 6_000) },
...billboard,
position: Cesium.Cartesian3.fromDegrees(-97.2, 30.7, 6_000),
},
meta: { ...FULL_INFO, callsign: 'LATE4', rawLat: 30.7, rawLon: -97.2 }, meta: { ...FULL_INFO, callsign: 'LATE4', rawLat: 30.7, rawLon: -97.2 },
history: [], history: [],
}); });
assert.equal(_applyPendingMilitaryTrackingRestoreForTest(), true); assert.equal(_applyPendingMilitaryTrackingRestoreForTest(), true);
assert.equal( assert.equal(militaryFlightsLayer.getParams().selectedMilitaryTrackingId, 'late004');
militaryFlightsLayer.getParams().selectedMilitaryTrackingId,
'late004',
);
militaryFlightsLayer.setParams( militaryFlightsLayer.setParams(
{ selectedMilitaryTrackingId: 'late005' }, { selectedMilitaryTrackingId: 'late005' },
{ origin: 'local-restore' }, { origin: 'local-restore' },
); );
assert.equal( assert.equal(militaryFlightsLayer.trackById(icao24, { origin: 'programmatic' }), true);
militaryFlightsLayer.trackById(icao24, { origin: 'programmatic' }),
true,
);
assert.equal( assert.equal(
_pendingMilitaryTrackingRestoreForTest(), _pendingMilitaryTrackingRestoreForTest(),
'late005', 'late005',
@@ -642,18 +511,12 @@ test('real military track path creates no native label and publishes every cache
); );
_addMilitaryTrackingCandidateForTest({ _addMilitaryTrackingCandidateForTest({
icao24: 'late005', icao24: 'late005',
billboard: { billboard: { ...billboard, position: Cesium.Cartesian3.fromDegrees(-96.6, 31.4, 5_000) },
...billboard,
position: Cesium.Cartesian3.fromDegrees(-96.6, 31.4, 5_000),
},
meta: { ...FULL_INFO, callsign: 'LATE5', rawLat: 31.4, rawLon: -96.6 }, meta: { ...FULL_INFO, callsign: 'LATE5', rawLat: 31.4, rawLon: -96.6 },
history: [], history: [],
}); });
assert.equal(_applyPendingMilitaryTrackingRestoreForTest(), true); assert.equal(_applyPendingMilitaryTrackingRestoreForTest(), true);
assert.equal( assert.equal(militaryFlightsLayer.getParams().selectedMilitaryTrackingId, 'late005');
militaryFlightsLayer.getParams().selectedMilitaryTrackingId,
'late005',
);
} finally { } finally {
militaryFlightsLayer.stopTracking(); militaryFlightsLayer.stopTracking();
viewer.scene.preUpdate.raiseEvent(); viewer.scene.preUpdate.raiseEvent();
@@ -698,47 +561,21 @@ test('a callsign-less contact is findable by the tail number the app displays',
// The identity analyst_query hands back for this contact. // The identity analyst_query hands back for this contact.
const analystId = mapAnalystRecord(icao24, { const analystId = mapAnalystRecord(icao24, {
callsign: null, callsign: null, registration: '6606', rawLat: 40.71, rawLon: -74.01,
registration: '6606',
rawLat: 40.71,
rawLon: -74.01,
}).id; }).id;
assert.equal( assert.equal(analystId, '6606', 'the analyst names a callsign-less contact by its tail');
analystId,
'6606',
'the analyst names a callsign-less contact by its tail',
);
const found = militaryFlightsLayer.findByQuery(analystId); const found = militaryFlightsLayer.findByQuery(analystId);
assert.equal( assert.equal(found?.icao24, icao24, 'and the tracker must resolve that same identity');
found?.icao24, assert.equal(militaryFlightsLayer.findByQuery('660')?.icao24, icao24, 'prefix match too');
icao24, assert.equal(militaryFlightsLayer.findByQuery(icao24)?.icao24, icao24, 'hex still wins outright');
'and the tracker must resolve that same identity',
);
assert.equal(
militaryFlightsLayer.findByQuery('660')?.icao24,
icao24,
'prefix match too',
);
assert.equal(
militaryFlightsLayer.findByQuery(icao24)?.icao24,
icao24,
'hex still wins outright',
);
}); });
test('the analyst record carries the hex key the tracker keys on', () => { test('the analyst record carries the hex key the tracker keys on', () => {
const record = mapAnalystRecord('ae7f01', { const record = mapAnalystRecord('ae7f01', {
callsign: null, callsign: null, registration: '6606', rawLat: 40.71, rawLon: -74.01,
registration: '6606',
rawLat: 40.71,
rawLon: -74.01,
}); });
assert.equal( assert.equal(record.icao24, 'ae7f01', 'a resolvable key must ride along with the display label');
record.icao24,
'ae7f01',
'a resolvable key must ride along with the display label',
);
}); });
test('a registration never outranks another contact’s exact callsign', () => { test('a registration never outranks another contact’s exact callsign', () => {
@@ -751,35 +588,18 @@ test('a registration never outranks another contact’s exact callsign', () => {
show: true, show: true,
}); });
const base = { const base = {
type: 'C17', type: 'C17', operator: 'USAF', altitudeFt: 25000, speedMps: 180,
operator: 'USAF', track: 90, klass: 'widebody', onGround: false,
altitudeFt: 25000,
speedMps: 180,
track: 90,
klass: 'widebody',
onGround: false,
}; };
// Registered FIRST, so insertion order favours it. // Registered FIRST, so insertion order favours it.
_addMilitaryTrackingCandidateForTest({ _addMilitaryTrackingCandidateForTest({
icao24: 'ae0aa1', icao24: 'ae0aa1',
meta: { meta: { ...base, callsign: null, registration: 'ZULU777', rawLat: 31.0, rawLon: -97.0 },
...base,
callsign: null,
registration: 'ZULU777',
rawLat: 31.0,
rawLon: -97.0,
},
billboard: billboardAt(-97.0, 31.0), billboard: billboardAt(-97.0, 31.0),
}); });
_addMilitaryTrackingCandidateForTest({ _addMilitaryTrackingCandidateForTest({
icao24: 'ae0bb2', icao24: 'ae0bb2',
meta: { meta: { ...base, callsign: 'ZULU777', registration: '05-9999', rawLat: 31.2, rawLon: -97.2 },
...base,
callsign: 'ZULU777',
registration: '05-9999',
rawLat: 31.2,
rawLon: -97.2,
},
billboard: billboardAt(-97.2, 31.2), billboard: billboardAt(-97.2, 31.2),
}); });
@@ -802,49 +622,24 @@ test('two contacts matching at the same strength resolve deterministically', ()
show: true, show: true,
}); });
const base = { const base = {
type: 'C130', type: 'C130', operator: 'USAF', altitudeFt: 21000, speedMps: 150,
operator: 'USAF', track: 45, klass: 'turboprop', onGround: false,
altitudeFt: 21000,
speedMps: 150,
track: 45,
klass: 'turboprop',
onGround: false,
}; };
// Both registrations begin with QQ7 — a same-tier prefix tie. Registered // Both registrations begin with QQ7 — a same-tier prefix tie. Registered
// highest-hex first so insertion order would pick the wrong one. // highest-hex first so insertion order would pick the wrong one.
_addMilitaryTrackingCandidateForTest({ _addMilitaryTrackingCandidateForTest({
icao24: 'aef002', icao24: 'aef002',
meta: { meta: { ...base, callsign: null, registration: 'QQ7-222', rawLat: 32.0, rawLon: -98.0 },
...base,
callsign: null,
registration: 'QQ7-222',
rawLat: 32.0,
rawLon: -98.0,
},
billboard: billboardAt(-98.0, 32.0), billboard: billboardAt(-98.0, 32.0),
}); });
_addMilitaryTrackingCandidateForTest({ _addMilitaryTrackingCandidateForTest({
icao24: 'aef001', icao24: 'aef001',
meta: { meta: { ...base, callsign: null, registration: 'QQ7-111', rawLat: 32.1, rawLon: -98.1 },
...base,
callsign: null,
registration: 'QQ7-111',
rawLat: 32.1,
rawLon: -98.1,
},
billboard: billboardAt(-98.1, 32.1), billboard: billboardAt(-98.1, 32.1),
}); });
const first = militaryFlightsLayer.findByQuery('QQ7')?.icao24; const first = militaryFlightsLayer.findByQuery('QQ7')?.icao24;
const second = militaryFlightsLayer.findByQuery('qq7')?.icao24; const second = militaryFlightsLayer.findByQuery('qq7')?.icao24;
assert.equal( assert.equal(first, 'aef001', 'the stable key (lowest hex) wins, not the feed order');
first, assert.equal(second, first, 'and the same query resolves the same way every time');
'aef001',
'the stable key (lowest hex) wins, not the feed order',
);
assert.equal(
second,
first,
'and the same query resolves the same way every time',
);
}); });
+8 -8
View File
@@ -58,23 +58,23 @@ export function createRendering({
/** True while this contact's latest poll broadcast an emergency code. */ /** True while this contact's latest poll broadcast an emergency code. */
function _isEmergency(icao24) { function _isEmergency(icao24, info = flightState.records.data.get(icao24)) {
return isEmergency(flightState.records.data.get(icao24)?.emergency); return isEmergency(info?.emergency);
} }
/** Fleet (untracked) billboard tint: red while broadcasting an emergency, /** Fleet (untracked) billboard tint: red while broadcasting an emergency,
* amber for known-military, white otherwise. * amber for known-military, white otherwise.
* Ground traffic gets NO special tint (owner verdict 2026-07-03 field test). */ * Ground traffic gets NO special tint (owner verdict 2026-07-03 field test). */
function _fleetBillboardColor(icao24) { function _fleetBillboardColor(icao24, info) {
if (_isEmergency(icao24)) return EMERGENCY_TINT; if (_isEmergency(icao24, info)) return EMERGENCY_TINT;
return isMilitaryIcao(icao24) ? MIL_TINT : Cesium.Color.WHITE; return isMilitaryIcao(icao24) ? MIL_TINT : Cesium.Color.WHITE;
} }
/** Cockpit far-contact dot tint: the emergency red outranks the category tint. */ /** Cockpit far-contact dot tint: the emergency red outranks the category tint. */
function _cockpitContactColor(icao24) { function _cockpitContactColor(icao24, info) {
if (_isEmergency(icao24)) return EMERGENCY_TINT; if (_isEmergency(icao24, info)) return EMERGENCY_TINT;
return isMilitaryIcao(icao24) ? MIL_TINT : COCKPIT_CIVILIAN_COLOR; return isMilitaryIcao(icao24) ? MIL_TINT : COCKPIT_CIVILIAN_COLOR;
} }
@@ -1024,8 +1024,8 @@ export function createRendering({
flightState._cockpitNearContacts.has(icao24); flightState._cockpitNearContacts.has(icao24);
const layerBaseColor = const layerBaseColor =
flightState._cockpitContactMode && !isCockpitNear flightState._cockpitContactMode && !isCockpitNear
? _cockpitContactColor(icao24) ? _cockpitContactColor(icao24, info)
: _fleetBillboardColor(icao24); : _fleetBillboardColor(icao24, info);
const baseColor = layerBaseColor; const baseColor = layerBaseColor;
const treatment = applyAircraftBillboardTreatment({ const treatment = applyAircraftBillboardTreatment({
billboard: bb, billboard: bb,
+6 -5
View File
@@ -197,10 +197,11 @@ export function createRendering({
/** Fleet (untracked) tint: red while the latest poll broadcast an emergency, /** Fleet (untracked) tint: red while the latest poll broadcast an emergency,
* amber otherwise. Cockpit far-contact dots use it too. */ * amber otherwise. Cockpit far-contact dots use it too. */
function _fleetBillboardColor(icao24) { function _fleetBillboardColor(
return isEmergency(flightState.records.data.get(icao24)?.emergency) icao24,
? EMERGENCY_ICON_COLOR info = flightState.records.data.get(icao24),
: MIL_ICON_COLOR; ) {
return isEmergency(info?.emergency) ? EMERGENCY_ICON_COLOR : MIL_ICON_COLOR;
} }
/** The FLEET's 3D-model regime: models3d enabled AND the camera zoomed in past the altitude /** The FLEET's 3D-model regime: models3d enabled AND the camera zoomed in past the altitude
@@ -976,7 +977,7 @@ export function createRendering({
const isCockpitNear = const isCockpitNear =
flightState._cockpitContactMode && flightState._cockpitContactMode &&
flightState._cockpitNearContacts.has(icao24); flightState._cockpitNearContacts.has(icao24);
const baseColor = _fleetBillboardColor(icao24); const baseColor = _fleetBillboardColor(icao24, info);
const treatment = applyAircraftBillboardTreatment({ const treatment = applyAircraftBillboardTreatment({
billboard: bb, billboard: bb,
baseScale: baseScale:
+4 -7
View File
@@ -7,12 +7,7 @@ import {
} from '../../data/motionModel.js'; } from '../../data/motionModel.js';
import { aircraftIcon } from '../../data/aircraftIcons.js'; import { aircraftIcon } from '../../data/aircraftIcons.js';
import { POSITION_HISTORY_LIMIT } from './recordPolicy.js'; import { POSITION_HISTORY_LIMIT } from './recordPolicy.js';
import { import { BILLBOARD_SCALE, GROUND_SCALE, TRACKED_ICON_COLOR } from './policy.js';
BILLBOARD_SCALE,
GROUND_SCALE,
TRACKED_ICON_COLOR,
MIL_ICON_COLOR,
} from './policy.js';
/** Apply military record changes to Cesium resources and existing follow operations. */ /** Apply military record changes to Cesium resources and existing follow operations. */
export function createMilitarySnapshotRenderer({ export function createMilitarySnapshotRenderer({
@@ -161,7 +156,9 @@ export function createMilitarySnapshotRenderer({
// Screen-projected rotation lands on the next fleet tick. // Screen-projected rotation lands on the next fleet tick.
rotation: 0, rotation: 0,
alignedAxis: Cesium.Cartesian3.ZERO, alignedAxis: Cesium.Cartesian3.ZERO,
color: isTracked ? TRACKED_ICON_COLOR : MIL_ICON_COLOR, color: isTracked
? TRACKED_ICON_COLOR
: rendering._fleetBillboardColor(icao24, meta),
sizeInMeters: false, sizeInMeters: false,
scaleByDistance: rendering._normalBillboardScaleByDistance(), scaleByDistance: rendering._normalBillboardScaleByDistance(),
// Grounded/near-surface planes sit at/below the photoreal tile // Grounded/near-surface planes sit at/below the photoreal tile
+6 -3
View File
@@ -21,7 +21,6 @@ import {
TRAIL_COLOR, TRAIL_COLOR,
BILLBOARD_SCALE, BILLBOARD_SCALE,
GROUND_SCALE, GROUND_SCALE,
MIL_ICON_COLOR,
AMBER_TRANSPARENT, AMBER_TRANSPARENT,
TRACKED_ICON_COLOR, TRACKED_ICON_COLOR,
} from './policy.js'; } from './policy.js';
@@ -780,12 +779,16 @@ export function createTracking({
bb.width = 20; bb.width = 20;
bb.height = 20; bb.height = 20;
// Ground-aware restore (a plane untracked while taxiing comes back at // Ground-aware restore (a plane untracked while taxiing comes back at
// ground scale; tint is full amber on the ground and in the air). // ground scale; the fleet tint is amber, or red while broadcasting an
// emergency, on the ground and in the air).
bb.scale = bb.scale =
BILLBOARD_SCALE * BILLBOARD_SCALE *
(CLASS_SCALE_2D[meta?.klass] || 1) * (CLASS_SCALE_2D[meta?.klass] || 1) *
(meta?.onGround ? GROUND_SCALE : 1); (meta?.onGround ? GROUND_SCALE : 1);
bb.color = MIL_ICON_COLOR; bb.color = parts.rendering._fleetBillboardColor(
flightState._trackedIcao,
meta,
);
bb.rotation = flightState._lastTrackedRotation; bb.rotation = flightState._lastTrackedRotation;
} }
flightState._lastCamPoseSig = ''; // force a fleet rotation pass on the next tick flightState._lastCamPoseSig = ''; // force a fleet rotation pass on the next tick
+4 -1
View File
@@ -43,6 +43,8 @@
#cockpit-hud { #cockpit-hud {
--cockpit-accent: #00dcff; --cockpit-accent: #00dcff;
/* Matches EMERGENCY_TINT_CSS in src/data/aircraftEmergency.js. */
--cockpit-emergency: #ff4444;
--cockpit-side-panel-width: min(340px, 28vw); --cockpit-side-panel-width: min(340px, 28vw);
/* HUD bottom offset + tallest scaled telemetry block + 20px clear border. */ /* HUD bottom offset + tallest scaled telemetry block + 20px clear border. */
--cockpit-bottom-rail-safe: calc(clamp(84px, 11vh, 118px) + 100px); --cockpit-bottom-rail-safe: calc(clamp(84px, 11vh, 118px) + 100px);
@@ -497,7 +499,8 @@ body.cockpit-mode:has(#left-panel-stack > .panel-collapsible:not(.collapsed))
letter-spacing: 0.16em; letter-spacing: 0.16em;
} }
.cockpit-aircraft-meta.emergency { .cockpit-aircraft-meta.emergency {
color: #ff4444; color: var(--cockpit-emergency);
font-weight: 600;
} }
.cockpit-mode-chip { .cockpit-mode-chip {
margin-top: 2px; margin-top: 2px;
+1 -1
View File
@@ -2273,7 +2273,7 @@
:root[data-ui-theme='cyber'] :root[data-ui-theme='cyber']
body.cockpit-mode body.cockpit-mode
.cockpit-aircraft-meta.emergency { .cockpit-aircraft-meta.emergency {
color: #ff4444; color: var(--cyber-red-bright);
} }
:root[data-ui-theme='cyber'] body.cockpit-mode .cockpit-vision-controls { :root[data-ui-theme='cyber'] body.cockpit-mode .cockpit-vision-controls {