Merge feat/voice-geometry onto main

Both stack parents (#837, #842) are on main, so the voice geometry branch
now builds on main directly. Conflict resolutions keep main's behaviour and
add the geometry work on top: osm_query gating on every provider, restored
admin identity for Nominatim outlines, merged analyst follow-up memory, and
the cancelled Globe View reset instruction ahead of the generic cancellation.
This commit is contained in:
Manjunath committed 2026-11-03 14:33:34 +05:30
commit ecaddd838b
102 files changed
+12925 -1006

No files matched your search

+120 -6
View File
@@ -1,10 +1,18 @@
/**
* The action runner wired to fakes that behave like the real services:
* aircraft records, an annotation board, the referent registry and a turn
* pointer. Shared by the cross-feature voice contract tests.
* The action runner with every cross-feature workflow wired to fakes that
* behave like the real services: aircraft records, an annotation board, OSM
* places, the real Recent Imagery layer over a manual catalog, the outline
* ladder with Kathmandu and an ambiguous "Punjab", the referent registry and
* a turn pointer. Shared by the cross-feature voice contract tests.
*/
import { createGevActionRunner } from './gevActions.js';
import { createReferentRegistry } from './referents.js';
import { createRecentImageryLayer } from '../layers/recentImagery/index.js';
import {
fakeCatalog,
fakeRenderer,
fakeThumbnails,
} from '../layers/recentImagery/testDoubles.mjs';
globalThis.window = globalThis.window || {
clearTimeout,
@@ -12,6 +20,55 @@ globalThis.window = globalThis.window || {
requestIdleCallback: null,
};
const square = (w, s, e, n) => [
[w, s],
[e, s],
[e, n],
[w, n],
[w, s],
];
const punjab = (country, box) => ({
kind: 'state',
name: 'Punjab',
country,
source: 'natural-earth',
polygons: [[square(...box)]],
});
/** Bundled units sharing a name, as data/adminBoundaries.js lists them. */
const PUNJABS = [
punjab('India', [73.9, 29.5, 76.9, 32.5]),
punjab('Pakistan', [69.3, 27.7, 73.8, 34.0]),
];
/**
* The annotation outline ladder: Kathmandu comes back from the guarded
* Nominatim route; any other name anchors with no outline.
*/
async function resolveAnnotationTarget({ target }) {
if (/kathmandu/i.test(target || ''))
return {
lat: 27.7,
lon: 85.3,
label: 'Kathmandu', // i18n-ignore: harness fixture place name
ring: null,
resolveOutline: async () => ({
ring: square(85.2, 27.6, 85.4, 27.8),
polygons: [[square(85.2, 27.6, 85.4, 27.8)]],
synthesized: false,
outlineSource: 'nominatim',
}),
};
return { lat: 37.795, lon: -122.393, ring: null };
}
const HOSPITALS = [
{ id: 'node/1', lat: 27.7, lon: 85.31, tags: { name: 'Bir Hospital' } },
{ id: 'node/2', lat: 27.71, lon: 85.33, tags: { name: 'Military Hospital' } },
{ id: 'node/3', lat: 27.72, lon: 85.35, tags: {} },
];
/** An annotation board that marks every spec it is given. */
function fakeAnnotations() {
const marks = [];
@@ -22,8 +79,11 @@ function fakeAnnotations() {
const results = specs.map((spec) => {
const mark = {
id: `anno-${(seq += 1)}`,
ring: spec.ring,
label: spec.label,
target: spec.target,
areaId: spec.areaId || null,
origin: spec.manual ? spec.origin || 'drawn' : 'voice',
createdAt: seq,
};
marks.push(mark);
@@ -32,15 +92,47 @@ function fakeAnnotations() {
return { drawn: results.length, failed: 0, results };
},
list: () => marks,
generation: () => 0,
};
}
/** The runner with aircraft, annotations, referents and a turn pointer wired. */
function osmPlacesModule() {
let records = [];
return {
setResults(next) {
records = next.slice();
},
getAnalystRecords: (max = 2000) => records.slice(0, max),
getStats: () => ({ count: records.length, lastUpdate: Date.now() }),
};
}
function realImageryLayer() {
const catalog = fakeCatalog();
const layer = createRecentImageryLayer({
catalog,
renderer: fakeRenderer(),
thumbnails: fakeThumbnails(),
host: () => ({ collection: {}, kind: 'globe' }),
now: () => new Date('2026-09-23T12:00:00Z'),
});
layer.init({ camera: {} });
layer.enable();
return { layer, catalog };
}
/**
* The runner with every workflow wired: aircraft, annotations, OSM places,
* imagery, areas, the referent registry and a turn pointer.
*/
export function harness({
flights = null,
pointer = null,
on = ['flights'],
osmHits = HOSPITALS,
osmSearch = null,
on = ['flights', 'recent-imagery'],
} = {}) {
const imagery = realImageryLayer();
const modules = {
flights: flights || {
getStats: () => ({ count: 3, lastUpdate: Date.now() }),
@@ -50,6 +142,8 @@ export function harness({
{ id: 'SWA3', icao24: 'a3', callsign: 'SWA3', lat: 30.2, lon: -97 },
],
},
'osm-places': osmPlacesModule(),
'recent-imagery': imagery.layer,
};
const enabled = new Set(on);
const viewer = {
@@ -57,6 +151,13 @@ export function harness({
scene: { canvas: { addEventListener() {}, removeEventListener() {} } },
camera: {
moveEnd: { addEventListener() {} },
// The view: a box over Kathmandu, in radians.
computeViewRectangle: () => ({
west: (85.2 * Math.PI) / 180,
south: (27.6 * Math.PI) / 180,
east: (85.4 * Math.PI) / 180,
north: (27.8 * Math.PI) / 180,
}),
positionCartographic: {
height: 300_000,
latitude: 0.52,
@@ -66,14 +167,25 @@ export function harness({
};
const referents = createReferentRegistry();
let snapshot = pointer;
const osmCalls = [];
const runner = createGevActionRunner({
viewer,
styleManager: {},
annotations: fakeAnnotations(),
annotationResolver: {
resolveRegionRingForQuery: async () => null,
resolveAnnotationTarget: async () => ({ lat: 37.795, lon: -122.393 }),
resolveAnnotationTarget,
},
areaOptions: {
findRegion: async () => null,
findAdminCandidates: async (q) => (/^punjab$/i.test(q) ? PUNJABS : []),
},
osmSearch:
osmSearch ||
(async (request) => {
osmCalls.push(request);
return { ok: true, features: osmHits, truncated: false };
}),
deixis: {
pointer: { activeSnapshot: () => snapshot },
referents,
@@ -101,6 +213,8 @@ export function harness({
return {
runner,
referents,
imagery,
osmCalls,
setPointer: (next) => (snapshot = next),
};
}