mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 02:44:02 +00:00
Merge remote-tracking branch 'origin/main' into german/hal-642-ja
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
c493eb0126
78 files changed
+3326
-303
No files matched your search
@@ -728,6 +728,8 @@ for (const phase of ['timer', 'move-end', 'approach', 'orbit']) {
|
||||
viewer,
|
||||
_sceneSeekGeneration: 0,
|
||||
_loadGeneration: 0,
|
||||
_bumpSceneSeekGeneration:
|
||||
SceneDirector.prototype._bumpSceneSeekGeneration,
|
||||
_cancelActiveSceneTravel:
|
||||
SceneDirector.prototype._cancelActiveSceneTravel,
|
||||
_setSceneMediaPlayback: SceneDirector.prototype._setSceneMediaPlayback,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/** Pure proximity helpers for Global Context. No capability modeling. */
|
||||
|
||||
import { t } from '../i18n/index.js';
|
||||
import { msg, t } from '../i18n/index.js';
|
||||
import { UNNAMED_PLACE_NAMES } from './installationNames.js';
|
||||
|
||||
const UNNAMED_NAMES = new Set(UNNAMED_PLACE_NAMES);
|
||||
@@ -84,7 +84,8 @@ export function formatAwarenessLabel(value) {
|
||||
/**
|
||||
* Summarize sorted nearby results without promoting missing/stale feeds to a
|
||||
* negative finding. `UNKNOWN` is an input-data state, never an out-of-range
|
||||
* claim in this MVP.
|
||||
* claim in this MVP. `reason` is English data; the awareness panel shows it
|
||||
* in the UI language.
|
||||
*/
|
||||
export function summarizeAwarenessCohort(
|
||||
items,
|
||||
@@ -95,14 +96,14 @@ export function summarizeAwarenessCohort(
|
||||
relationship: AWARENESS_RELATIONSHIP.UNKNOWN,
|
||||
count: null,
|
||||
nearest: [],
|
||||
reason: t('feed unavailable'),
|
||||
reason: msg('feed unavailable'),
|
||||
};
|
||||
if (stale)
|
||||
return {
|
||||
relationship: AWARENESS_RELATIONSHIP.UNKNOWN,
|
||||
count: null,
|
||||
nearest: [],
|
||||
reason: t('feed stale'),
|
||||
reason: msg('feed stale'),
|
||||
};
|
||||
const normalized = (Array.isArray(items) ? items : [])
|
||||
.filter(
|
||||
@@ -119,8 +120,8 @@ export function summarizeAwarenessCohort(
|
||||
count: normalized.length,
|
||||
nearest: normalized.slice(0, limit),
|
||||
reason: normalized.length
|
||||
? t('observed or mapped nearby context')
|
||||
: t('no observed or mapped objects in current feeds'),
|
||||
? msg('observed or mapped nearby context')
|
||||
: msg('no observed or mapped objects in current feeds'),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { setLocale, translateKnown } from '../i18n/index.js';
|
||||
import {
|
||||
AWARENESS_RELATIONSHIP,
|
||||
findByDoublingRadius,
|
||||
@@ -47,6 +48,25 @@ test('unavailable and stale feeds remain unknown', () => {
|
||||
assert.equal(summarizeAwarenessCohort([], { stale: true }).reason, 'feed stale');
|
||||
});
|
||||
|
||||
test('cohort reasons stay English in data and translate where the panel shows them', (t) => {
|
||||
t.after(() => setLocale('en'));
|
||||
setLocale('ru');
|
||||
const reasons = [
|
||||
summarizeAwarenessCohort([], { available: false }).reason,
|
||||
summarizeAwarenessCohort([], { stale: true }).reason,
|
||||
summarizeAwarenessCohort([{ id: 'near', distanceM: 10 }]).reason,
|
||||
summarizeAwarenessCohort([]).reason,
|
||||
];
|
||||
assert.deepEqual(reasons, [
|
||||
'feed unavailable',
|
||||
'feed stale',
|
||||
'observed or mapped nearby context',
|
||||
'no observed or mapped objects in current feeds',
|
||||
]);
|
||||
// The awareness panel shows a reason through translateKnown().
|
||||
for (const reason of reasons) assert.notEqual(translateKnown(reason), reason);
|
||||
});
|
||||
|
||||
test('navigation prioritizes nearby targets from the selected cohort', () => {
|
||||
const cohorts = [
|
||||
{ id: 'flights', summary: { nearest: [{ icao24: 'a1', distanceM: 1000 }, { icao24: 'a2', distanceM: 2000 }] } },
|
||||
|
||||
@@ -107,7 +107,10 @@ export function terrainRetryAfterMs(value, nowMs = Date.now()) {
|
||||
/**
|
||||
* Fetch one upstream chunk with jittered exponential backoff. Network errors,
|
||||
* 429, and 5xx retry; other HTTP failures and malformed successes fail fast.
|
||||
* Retry sleeps and retry attempts share a 10s budget after attempt one.
|
||||
* Retry sleeps and retry attempts share a 10s budget after attempt one. A
|
||||
* Retry-After longer than the budget left ends the retries at once: sleeping
|
||||
* out the budget cannot reach the time the upstream asked for, and it would
|
||||
* delay the caller's own back-off (the proxy's 429 pause) by up to 10 s.
|
||||
*
|
||||
* Dependencies are injectable for deterministic offline tests.
|
||||
* @param {Array<[number, number]>} points
|
||||
@@ -145,6 +148,7 @@ export async function fetchTerrainChunkWithRetry(
|
||||
const res = await fetchImpl(url, signal ? { signal } : {});
|
||||
if (!res.ok) {
|
||||
const error = new Error(`HTTP ${res.status}`);
|
||||
error.status = res.status;
|
||||
error.retryable = res.status === 429 || res.status >= 500;
|
||||
error.retryAfter = res.headers?.get?.('retry-after') ?? null;
|
||||
throw error;
|
||||
@@ -167,6 +171,7 @@ export async function fetchTerrainChunkWithRetry(
|
||||
if (remaining <= 0) break;
|
||||
|
||||
const retryAfterMs = terrainRetryAfterMs(error?.retryAfter, now());
|
||||
if (retryAfterMs != null && retryAfterMs > remaining) break;
|
||||
const backoffMs = Math.round(
|
||||
350 * 2 ** attempt * (0.75 + random() * 0.5),
|
||||
);
|
||||
|
||||
@@ -91,6 +91,36 @@ test('429 retry honors Retry-After before the next attempt', async () => {
|
||||
assert.equal(results[0].id, 'recovered');
|
||||
});
|
||||
|
||||
test('a Retry-After longer than the retry budget ends the retries without sleeping', async () => {
|
||||
let clock = 3_000_000;
|
||||
let attempts = 0;
|
||||
const sleeps = [];
|
||||
await assert.rejects(
|
||||
fetchTerrainChunkWithRetry([[1, 1]], {
|
||||
now: () => clock,
|
||||
random: () => 0.5,
|
||||
makeSignal: () => undefined,
|
||||
sleep: async (ms) => {
|
||||
sleeps.push(ms);
|
||||
clock += ms;
|
||||
},
|
||||
fetchImpl: async () => {
|
||||
attempts += 1;
|
||||
return {
|
||||
ok: false,
|
||||
status: 429,
|
||||
headers: {
|
||||
get: (name) => (name.toLowerCase() === 'retry-after' ? '30' : null),
|
||||
},
|
||||
};
|
||||
},
|
||||
}),
|
||||
(error) => error.status === 429 && error.retryAfter === '30',
|
||||
);
|
||||
assert.equal(attempts, 1);
|
||||
assert.deepEqual(sleeps, [], 'no sleep that cannot reach the Retry-After');
|
||||
});
|
||||
|
||||
test('permanently failing upstream exhausts retries and returns 502 without fake results', async () => {
|
||||
let clock = 2_000_000;
|
||||
let attempts = 0;
|
||||
|
||||
@@ -9,9 +9,18 @@ const sourceSlot = createSourceSlot(
|
||||
{
|
||||
getFlowSessionStats: () => ({ tilesFetched: 0 }),
|
||||
resetFlowTileCache: () => {},
|
||||
// The layer reads stale cached tiles through this; a source without it
|
||||
// answers with fresh segments only.
|
||||
fetchFlowDetail: async (...args) => ({
|
||||
segments: await sourceSlot.source.fetchFlowForBounds(...args),
|
||||
stale: false,
|
||||
oldestTileAt: null,
|
||||
}),
|
||||
},
|
||||
);
|
||||
export const configureTrafficSource = sourceSlot.configure;
|
||||
/** The source the traffic layer reads, as configured. */
|
||||
export const trafficSource = sourceSlot.source;
|
||||
const layer = createApplicationTraffic({
|
||||
source: sourceSlot.source,
|
||||
});
|
||||
|
||||
+105
-19
@@ -22,7 +22,10 @@ import { DataLayerManager, layerFeedState } from './manager.js';
|
||||
const LIVE_CLAIM = /\bLIVE\b|\bGPS\b|\breal[- ]?time\b/;
|
||||
|
||||
test('a superseded flow fetch is not an outage', () => {
|
||||
assert.equal(deriveTrafficFlowError({ name: 'AbortError', message: 'aborted' }), null);
|
||||
assert.equal(
|
||||
deriveTrafficFlowError({ name: 'AbortError', message: 'aborted' }),
|
||||
null,
|
||||
);
|
||||
assert.equal(deriveTrafficFlowError(null), null);
|
||||
assert.equal(deriveTrafficFlowError(undefined), null);
|
||||
});
|
||||
@@ -30,10 +33,22 @@ test('a superseded flow fetch is not an outage', () => {
|
||||
test('flow failures map onto short, specific reasons', () => {
|
||||
const reason = (message) => deriveTrafficFlowError(new Error(message));
|
||||
assert.equal(reason('flow tile 12/1/1: HTTP 503'), 'TomTom key unavailable');
|
||||
assert.equal(reason('flow tile 12/1/1: HTTP 429'), 'TomTom daily budget reached');
|
||||
assert.equal(reason('flow tile 12/1/1: HTTP 502'), 'TomTom upstream unreachable');
|
||||
assert.equal(reason('flow tile 12/1/1: HTTP 504'), 'TomTom upstream unreachable');
|
||||
assert.equal(reason('flow tile 12/1/1: HTTP 418'), 'TomTom flow error (HTTP 418)');
|
||||
assert.equal(
|
||||
reason('flow tile 12/1/1: HTTP 429'),
|
||||
'TomTom daily budget reached',
|
||||
);
|
||||
assert.equal(
|
||||
reason('flow tile 12/1/1: HTTP 502'),
|
||||
'TomTom upstream unreachable',
|
||||
);
|
||||
assert.equal(
|
||||
reason('flow tile 12/1/1: HTTP 504'),
|
||||
'TomTom upstream unreachable',
|
||||
);
|
||||
assert.equal(
|
||||
reason('flow tile 12/1/1: HTTP 418'),
|
||||
'TomTom flow error (HTTP 418)',
|
||||
);
|
||||
assert.equal(reason('flow fetch failed'), 'TomTom flow unavailable');
|
||||
});
|
||||
|
||||
@@ -56,19 +71,32 @@ test('no keyless label ever implies a live feed', () => {
|
||||
trafficFeedPresentation({ liveMode: false, fetching: false }),
|
||||
trafficFeedPresentation({ liveMode: false, fetching: true }),
|
||||
trafficFeedPresentation({ statusUnavailable: true }),
|
||||
trafficFeedPresentation({ liveMode: true, flowError: 'TomTom flow unavailable' }),
|
||||
trafficFeedPresentation({ liveMode: true, fetching: true, flowError: 'TomTom flow unavailable' }),
|
||||
trafficFeedPresentation({
|
||||
liveMode: true,
|
||||
flowError: 'TomTom flow unavailable',
|
||||
}),
|
||||
trafficFeedPresentation({
|
||||
liveMode: true,
|
||||
fetching: true,
|
||||
flowError: 'TomTom flow unavailable',
|
||||
}),
|
||||
].map((feed) => feed.loadingLabel);
|
||||
for (const label of labels) {
|
||||
assert.ok(!LIVE_CLAIM.test(label), `label implies live data: ${label}`);
|
||||
assert.ok(label.startsWith('SIMULATED'), `fallback label must lead with the mode: ${label}`);
|
||||
assert.ok(
|
||||
label.startsWith('SIMULATED'),
|
||||
`fallback label must lead with the mode: ${label}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test('simulating because the status probe failed reads differently from keyless by design', () => {
|
||||
const probeDown = trafficFeedPresentation({ statusUnavailable: true });
|
||||
assert.equal(probeDown.mode, 'sim');
|
||||
assert.equal(probeDown.loadingLabel, 'SIMULATED — traffic service unreachable');
|
||||
assert.equal(
|
||||
probeDown.loadingLabel,
|
||||
'SIMULATED — traffic service unreachable',
|
||||
);
|
||||
});
|
||||
|
||||
test('a healthy keyed layer reports live flow with its real coverage', () => {
|
||||
@@ -76,7 +104,8 @@ test('a healthy keyed layer reports live flow with its real coverage', () => {
|
||||
assert.deepEqual(idle, {
|
||||
mode: 'live',
|
||||
error: null,
|
||||
loadingLabel: 'LIVE · Roads: OpenStreetMap · Flow: TomTom · 87% cov · Unmatched: simulated',
|
||||
loadingLabel:
|
||||
'LIVE · Roads: OpenStreetMap · Flow: TomTom · 87% cov · Unmatched: simulated',
|
||||
});
|
||||
assert.equal(
|
||||
trafficFeedPresentation({ liveMode: true, fetching: true }).loadingLabel,
|
||||
@@ -100,7 +129,11 @@ test('a mid-session flow outage degrades instead of reporting stale live coverag
|
||||
fetching: true,
|
||||
flowError: 'TomTom daily budget reached',
|
||||
});
|
||||
assert.deepEqual(busy, down, 'the degraded state reads the same whether or not a load is in flight');
|
||||
assert.deepEqual(
|
||||
busy,
|
||||
down,
|
||||
'the degraded state reads the same whether or not a load is in flight',
|
||||
);
|
||||
});
|
||||
|
||||
test('the rendered steady-state meta line carries the SIMULATED copy', () => {
|
||||
@@ -116,10 +149,12 @@ test('the rendered steady-state meta line carries the SIMULATED copy', () => {
|
||||
assert.equal(
|
||||
mgr._buildMetaText({
|
||||
source: 'OpenStreetMap',
|
||||
stats: stats(trafficFeedPresentation({
|
||||
liveMode: true,
|
||||
flowError: 'TomTom daily budget reached',
|
||||
})),
|
||||
stats: stats(
|
||||
trafficFeedPresentation({
|
||||
liveMode: true,
|
||||
flowError: 'TomTom daily budget reached',
|
||||
}),
|
||||
),
|
||||
}),
|
||||
'DEGRADED · OpenStreetMap · SIMULATED — TomTom daily budget reached',
|
||||
);
|
||||
@@ -128,17 +163,26 @@ test('the rendered steady-state meta line carries the SIMULATED copy', () => {
|
||||
test('the manager reads keyless as FALLBACK and an outage as DEGRADED', () => {
|
||||
const settled = { count: 4200, lastUpdate: Date.now() };
|
||||
assert.equal(
|
||||
layerFeedState({ ...settled, ...trafficFeedPresentation({ liveMode: false }) }),
|
||||
layerFeedState({
|
||||
...settled,
|
||||
...trafficFeedPresentation({ liveMode: false }),
|
||||
}),
|
||||
'fallback',
|
||||
);
|
||||
assert.equal(
|
||||
layerFeedState({ ...settled, ...trafficFeedPresentation({ liveMode: true }) }),
|
||||
layerFeedState({
|
||||
...settled,
|
||||
...trafficFeedPresentation({ liveMode: true }),
|
||||
}),
|
||||
'nominal',
|
||||
);
|
||||
assert.equal(
|
||||
layerFeedState({
|
||||
...settled,
|
||||
...trafficFeedPresentation({ liveMode: true, flowError: 'TomTom flow unavailable' }),
|
||||
...trafficFeedPresentation({
|
||||
liveMode: true,
|
||||
flowError: 'TomTom flow unavailable',
|
||||
}),
|
||||
}),
|
||||
'degraded',
|
||||
);
|
||||
@@ -148,7 +192,10 @@ test('the shipped layer boots keyless-honest before any status check', () => {
|
||||
const stats = trafficLayer.getStats();
|
||||
assert.equal(stats.mode, 'sim');
|
||||
assert.equal(stats.error, null);
|
||||
assert.ok(!LIVE_CLAIM.test(stats.loadingLabel), `boot label implies live data: ${stats.loadingLabel}`);
|
||||
assert.ok(
|
||||
!LIVE_CLAIM.test(stats.loadingLabel),
|
||||
`boot label implies live data: ${stats.loadingLabel}`,
|
||||
);
|
||||
assert.equal(layerFeedState(stats), 'fallback');
|
||||
});
|
||||
|
||||
@@ -167,3 +214,42 @@ test('zero matched dots never claims live coverage', () => {
|
||||
assert.match(feed.loadingLabel, /TomTom \(no matches\)/);
|
||||
assert.ok(!LIVE_CLAIM.test(feed.loadingLabel));
|
||||
});
|
||||
|
||||
test('the traffic layer source passes fetchFlowDetail through, so stale tiles reach the layer', async () => {
|
||||
const { trafficSource, configureTrafficSource } =
|
||||
await import('./traffic.js');
|
||||
assert.equal(typeof trafficSource.fetchFlowDetail, 'function');
|
||||
const base = {
|
||||
requestRoads: async () => ({}),
|
||||
getStatus: async () => ({}),
|
||||
fetchFlowForBounds: async () => ['segment'],
|
||||
};
|
||||
let release = configureTrafficSource({
|
||||
...base,
|
||||
fetchFlowDetail: async () => ({
|
||||
segments: ['segment'],
|
||||
stale: true,
|
||||
oldestTileAt: 1000,
|
||||
}),
|
||||
});
|
||||
try {
|
||||
assert.deepEqual(await trafficSource.fetchFlowDetail({}), {
|
||||
segments: ['segment'],
|
||||
stale: true,
|
||||
oldestTileAt: 1000,
|
||||
});
|
||||
} finally {
|
||||
release();
|
||||
}
|
||||
// A source without fetchFlowDetail answers with fresh segments.
|
||||
release = configureTrafficSource(base);
|
||||
try {
|
||||
assert.deepEqual(await trafficSource.fetchFlowDetail({}), {
|
||||
segments: ['segment'],
|
||||
stale: false,
|
||||
oldestTileAt: null,
|
||||
});
|
||||
} finally {
|
||||
release();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user