feat(vessels): key vessels by their source's stable id, and share a selected vessel

AIS Vessels are keyed by the id their live source gives, with the MMSI as an
attribute: an MMSI can be shared, spoofed or reused, so two vessels with one
MMSI are now two vessels. Looking a vessel up or selecting it by MMSI still
finds it.

A share link made while a vessel is selected opens that vessel. A UUID vessel
id travels as 16 bytes in a new thing field (13). A shared thing that is not
reporting now says so in a sentence per kind, with its id (ICAO, NORAD, MMSI
or vessel UUID) on a second line.
This commit is contained in:
Sameh Khamis committed 2026-11-10 18:12:53 -08:00
1 parent 57ff81f723
commit cbbf55cacd
74 files changed
+2481 -586

No files matched your search

+11 -4
View File
@@ -2824,7 +2824,7 @@ async function trackEntity(
() => {
let trackedOk = false;
if (family.kind === 'vessel') {
trackedOk = !!module.selectById?.(found.mmsi);
trackedOk = !!module.selectById?.(found.id ?? found.mmsi);
flyToLandmark(viewer, found.latitude, found.longitude, {
range: 6000,
pitch: -45,
@@ -4003,8 +4003,13 @@ function locateLayerEntity(dataManager, { layerId, id, lat, lon }) {
?.module?.getAnalystRecords?.()
.filter(
(item) =>
String(item.icao24 ?? item.mmsi ?? item.noradId ?? item.id) ===
String(id),
String(
item.icao24 ??
item.vesselId ??
item.mmsi ??
item.noradId ??
item.id,
) === String(id),
) || [];
// Bikeshare uses station names as IDs: retain the coordinate identity
// even if a namesake disappears. Moving records use their fresh fix.
@@ -5344,6 +5349,7 @@ function cameraViewBox(viewer) {
/** Identity fields every compact analyst item keeps when present. */
const ANALYST_IDENTITY_FIELDS = Object.freeze([
'icao24',
'vesselId',
'mmsi',
'registration',
'label',
@@ -5361,6 +5367,7 @@ const ANALYST_CANONICAL_FIELDS = new Set([
'layerKey',
'id',
'icao24',
'vesselId',
'mmsi',
'noradId',
'registration',
@@ -5373,7 +5380,7 @@ const ANALYST_CANONICAL_FIELDS = new Set([
* follow-up can fly to it), distance, and that layer's manifest fields with
* times as ISO text. The full record set stays engine-side for follow-ups.
*
* `icao24`/`mmsi` ride along because the tool instructions tell the model to
* `icao24`/`vesselId`/`mmsi` ride along because the tool instructions tell the model to
* hand this result straight to track_entity, and `id` is a DISPLAY label
* (callsign, else registration, else hex). A callsign-less contact therefore
* handed track_entity a tail number the lookup could not resolve, and the
+25
View File
@@ -245,6 +245,31 @@ test('P2-7: duplicate callsigns and names resolve by canonical identity', () =>
);
});
test('vessels sharing an MMSI resolve by their vessel id', () => {
const referents = createReferentRegistry();
referents.recordResult('analyst_query', {
ok: true,
items: ['hull-a', 'hull-b'].map((vesselId) => ({
layerKey: 'ais-live-vessels',
id: 'EVER GIVEN',
vesselId,
mmsi: '353136000',
name: 'EVER GIVEN',
})),
});
assert.deepEqual(
[1, 2].map(
(n) =>
resolveDeicticArgs(
'track_entity',
{ query: 'x', referent: n },
{ referents },
).args.query,
),
['hull-a', 'hull-b'],
);
});
test('P1-1: a result from before the last clear cannot repopulate the registry', () => {
const referents = createReferentRegistry();
const since = referents.generation();
+10 -3
View File
@@ -23,10 +23,17 @@ function finite(value) {
function normalize(entry, index) {
if (!entry || typeof entry !== 'object') return null;
// Identity is the canonical key (transponder hex, MMSI, NORAD id); a
// Identity is the canonical key (transponder hex, vessel id, NORAD id); a
// display `id` such as a callsign is only a label, and two contacts can
// share one.
const id = entry.icao24 ?? entry.mmsi ?? entry.noradId ?? entry.id ?? null;
// share one. Vessels can share an MMSI too, so a vessel's key is its
// `vesselId` when the row names one.
const id =
entry.icao24 ??
entry.vesselId ??
entry.mmsi ??
entry.noradId ??
entry.id ??
null;
const label = String(
entry.label ?? entry.callsign ?? entry.name ?? entry.id ?? id ?? '',
).trim();
+1 -1
View File
@@ -501,7 +501,7 @@ function frameOverhead(result) {
.filter((entry) => entry?.label || entry?.id)
.map((entry, index) => ({
n: index + 1,
id: entry.icao24 || entry.mmsi || entry.id || null,
id: entry.icao24 || entry.id || entry.mmsi || null,
label: spokenLabel(entry.label || entry.id),
layerId: result.layerId,
}));