style: format remaining runtime ES module files

This commit is contained in:
Sameh Khamis committed 2026-09-15 07:26:53 -07:00
1 parent 17dc37b529
commit b7c2c47b41
3 files changed
+557 -268

No files matched your search

+61 -37
View File
@@ -51,11 +51,13 @@ function resolveWindowsNativeTools(environment, fileSystem, architecture) {
if (configured.length === 0) return null; if (configured.length === 0) return null;
const roots = configured.map((value) => { const roots = configured.map((value) => {
if (value !== value.trim() || !/^[A-Za-z]:\\Windows\\?$/i.test(value)) return null; if (value !== value.trim() || !/^[A-Za-z]:\\Windows\\?$/i.test(value))
return null;
return value.endsWith('\\') ? value.slice(0, -1) : value; return value.endsWith('\\') ? value.slice(0, -1) : value;
}); });
if (roots.some((root) => !root)) return null; if (roots.some((root) => !root)) return null;
if (roots.some((root) => root.toLowerCase() !== roots[0].toLowerCase())) return null; if (roots.some((root) => root.toLowerCase() !== roots[0].toLowerCase()))
return null;
const systemRoot = roots[0]; const systemRoot = roots[0];
const systemDirectory = architecture === 'ia32' ? 'Sysnative' : 'System32'; const systemDirectory = architecture === 'ia32' ? 'Sysnative' : 'System32';
@@ -80,14 +82,23 @@ function resolveWindowsNativeTools(environment, fileSystem, architecture) {
for (const executable of Object.values(expected)) { for (const executable of Object.values(expected)) {
const entry = fileSystem.lstatSync(executable); const entry = fileSystem.lstatSync(executable);
if (!entry.isFile() || entry.isSymbolicLink()) return null; if (!entry.isFile() || entry.isSymbolicLink()) return null;
const canonicalExecutable = realpath.call(fileSystem.realpathSync, executable); const canonicalExecutable = realpath.call(
fileSystem.realpathSync,
executable,
);
const canonicalCandidates = [executable]; const canonicalCandidates = [executable];
if (architecture === 'ia32') { if (architecture === 'ia32') {
canonicalCandidates.push(executable.replace('\\Sysnative\\', '\\System32\\')); canonicalCandidates.push(
executable.replace('\\Sysnative\\', '\\System32\\'),
);
} }
if (!canonicalCandidates.some( if (
(candidate) => candidate.toLowerCase() === canonicalExecutable.toLowerCase(), !canonicalCandidates.some(
)) return null; (candidate) =>
candidate.toLowerCase() === canonicalExecutable.toLowerCase(),
)
)
return null;
} }
} catch { } catch {
return null; return null;
@@ -99,17 +110,22 @@ function resolveWindowsNativeTools(environment, fileSystem, architecture) {
* Restrict a credential file before any secret is written to it. * Restrict a credential file before any secret is written to it.
* Dependencies are injectable so every fail-closed branch is unit-testable. * Dependencies are injectable so every fail-closed branch is unit-testable.
*/ */
export function hardenCredentialFile(filepath, { export function hardenCredentialFile(
platform = process.platform, filepath,
architecture = process.arch, {
spawn = spawnSync, platform = process.platform,
fileSystem = fs, architecture = process.arch,
environment = process.env, spawn = spawnSync,
} = {}) { fileSystem = fs,
environment = process.env,
} = {},
) {
if (platform !== 'win32') { if (platform !== 'win32') {
try { try {
if (platform === 'darwin') { if (platform === 'darwin') {
const aclRemoval = spawn('chmod', ['-N', filepath], { stdio: 'ignore' }); const aclRemoval = spawn('chmod', ['-N', filepath], {
stdio: 'ignore',
});
if (!commandCompletedSuccessfully(aclRemoval)) return false; if (!commandCompletedSuccessfully(aclRemoval)) return false;
} }
fileSystem.chmodSync(filepath, 0o600); fileSystem.chmodSync(filepath, 0o600);
@@ -119,7 +135,11 @@ export function hardenCredentialFile(filepath, {
} }
} }
const tools = resolveWindowsNativeTools(environment, fileSystem, architecture); const tools = resolveWindowsNativeTools(
environment,
fileSystem,
architecture,
);
if (!tools) return false; if (!tools) return false;
try { try {
@@ -135,14 +155,18 @@ export function hardenCredentialFile(filepath, {
: null; : null;
if (!sid) return false; if (!sid) return false;
const applied = spawn(tools.icacls, [ const applied = spawn(
filepath, tools.icacls,
'/inheritance:r', [
'/grant:r', filepath,
`*${sid}:F`, '/inheritance:r',
'*S-1-5-18:F', '/grant:r',
'*S-1-5-32-544:F', `*${sid}:F`,
], { stdio: 'ignore', windowsHide: true }); '*S-1-5-18:F',
'*S-1-5-32-544:F',
],
{ stdio: 'ignore', windowsHide: true },
);
if (!commandCompletedSuccessfully(applied)) return false; if (!commandCompletedSuccessfully(applied)) return false;
// Command success is not proof of the resulting DACL. Query it back and // Command success is not proof of the resulting DACL. Query it back and
@@ -173,20 +197,20 @@ export function hardenCredentialFile(filepath, {
([name]) => name.toLowerCase() !== 'psmodulepath', ([name]) => name.toLowerCase() !== 'psmodulepath',
), ),
); );
const verified = spawn(tools.powershell, [ const verified = spawn(
'-NoProfile', tools.powershell,
'-NonInteractive', ['-NoProfile', '-NonInteractive', '-Command', WINDOWS_ACL_VERIFY_SCRIPT],
'-Command', WINDOWS_ACL_VERIFY_SCRIPT, {
], { env: {
env: { ...verifyEnvironment,
...verifyEnvironment, GEV_ACL_FILE: filepath,
GEV_ACL_FILE: filepath, GEV_ACL_USER_SID: sid,
GEV_ACL_USER_SID: sid, PSModulePath: powershellModuleDirectory,
PSModulePath: powershellModuleDirectory, },
stdio: 'ignore',
windowsHide: true,
}, },
stdio: 'ignore', );
windowsHide: true,
});
return commandCompletedSuccessfully(verified); return commandCompletedSuccessfully(verified);
} catch { } catch {
return false; return false;
+108 -32
View File
@@ -18,7 +18,8 @@ export const KEY_SETUP_VALUE_LIMIT = 512;
export const KEY_SETUP_UPDATE_LIMIT = 16; export const KEY_SETUP_UPDATE_LIMIT = 16;
/** Header line written above keys the panel appends to a .env file. */ /** Header line written above keys the panel appends to a .env file. */
export const KEY_SETUP_APPEND_HEADER = '# Keys added by the in-app POWER UP panel'; export const KEY_SETUP_APPEND_HEADER =
'# Keys added by the in-app POWER UP panel';
/** /**
* Provider credentials, in display order — most magic per * Provider credentials, in display order — most magic per
@@ -42,7 +43,8 @@ export const KEY_SETUP_KEYS = Object.freeze([
id: 'google-maps-server', id: 'google-maps-server',
title: 'GOOGLE MAPS — SERVER', title: 'GOOGLE MAPS — SERVER',
unlocks: 'Places context + Street View fallback; optional separate key', unlocks: 'Places context + Street View fallback; optional separate key',
getUrl: 'https://developers.google.com/maps/documentation/places/web-service/get-api-key', getUrl:
'https://developers.google.com/maps/documentation/places/web-service/get-api-key',
envVars: Object.freeze(['GOOGLE_MAPS_SERVER_API_KEY']), envVars: Object.freeze(['GOOGLE_MAPS_SERVER_API_KEY']),
tier: 'metered', tier: 'metered',
hidden: true, hidden: true,
@@ -113,12 +115,17 @@ const LOOPBACK_ADDRESSES = new Set(['127.0.0.1', '::1', '::ffff:127.0.0.1']);
/** Parse an exact local request authority from a Host header. */ /** Parse an exact local request authority from a Host header. */
function localAuthority(hostHeader, protocol) { function localAuthority(hostHeader, protocol) {
const raw = String(hostHeader || '').trim().toLowerCase(); const raw = String(hostHeader || '')
.trim()
.toLowerCase();
const scheme = String(protocol || '').toLowerCase(); const scheme = String(protocol || '').toLowerCase();
if (!raw || !['http:', 'https:'].includes(scheme) || /[\s/?#@]/.test(raw)) return null; if (!raw || !['http:', 'https:'].includes(scheme) || /[\s/?#@]/.test(raw))
return null;
try { try {
const parsed = new URL(`${scheme}//${raw}`); const parsed = new URL(`${scheme}//${raw}`);
return LOCAL_HOSTNAMES.has(parsed.hostname.toLowerCase()) ? parsed.origin : null; return LOCAL_HOSTNAMES.has(parsed.hostname.toLowerCase())
? parsed.origin
: null;
} catch { } catch {
return null; return null;
} }
@@ -131,7 +138,9 @@ export function commandCompletedSuccessfully(result) {
/** Parse one RFC-4180-shaped CSV record, sufficient for `whoami /fo csv`. */ /** Parse one RFC-4180-shaped CSV record, sufficient for `whoami /fo csv`. */
function parseCsvRecord(text) { function parseCsvRecord(text) {
const source = String(text || '').replace(/^\uFEFF/, '').trim(); const source = String(text || '')
.replace(/^\uFEFF/, '')
.trim();
if (!source || /[\r\n]/.test(source)) return null; if (!source || /[\r\n]/.test(source)) return null;
const fields = []; const fields = [];
let field = ''; let field = '';
@@ -210,9 +219,25 @@ export function admitKeySetupRequest({
// on this machine, whatever its socket says. Refuse them outright as defense // on this machine, whatever its socket says. Refuse them outright as defense
// in depth — the shipped tunnel (Pinokio) is force-closed at boot, so these // in depth — the shipped tunnel (Pinokio) is force-closed at boot, so these
// only appear when someone has deliberately fronted the dev server. // only appear when someone has deliberately fronted the dev server.
const PROXY_SIGNALS = ['forwarded', 'via', 'x-forwarded-for', 'x-forwarded-host', 'x-forwarded-port', 'x-forwarded-proto', 'x-real-ip', 'cf-connecting-ip', 'cf-ray']; const PROXY_SIGNALS = [
if (PROXY_SIGNALS.some((name) => String(proxyHeaders[name] || '').trim() !== '')) { 'forwarded',
return { ok: false, status: 403, error: 'Provider Settings does not answer proxied requests' }; 'via',
'x-forwarded-for',
'x-forwarded-host',
'x-forwarded-port',
'x-forwarded-proto',
'x-real-ip',
'cf-connecting-ip',
'cf-ray',
];
if (
PROXY_SIGNALS.some((name) => String(proxyHeaders[name] || '').trim() !== '')
) {
return {
ok: false,
status: 403,
error: 'Provider Settings does not answer proxied requests',
};
} }
// Every sharing signal the launcher recognizes (scripts/pinokio-preflight.mjs) // Every sharing signal the launcher recognizes (scripts/pinokio-preflight.mjs)
// also disables this surface — so the gate's set is complete, not a subset the // also disables this surface — so the gate's set is complete, not a subset the
@@ -225,21 +250,42 @@ export function admitKeySetupRequest({
// below independently refuse LAN/tunnel traffic, and under Pinokio the launcher // below independently refuse LAN/tunnel traffic, and under Pinokio the launcher
// refuses to boot at all when sharing is genuinely on. // refuses to boot at all when sharing is genuinely on.
const shareVar = String(env.PINOKIO_SHARE_VAR ?? '').trim(); const shareVar = String(env.PINOKIO_SHARE_VAR ?? '').trim();
const sharingEnabled = ['PINOKIO_SHARE_CLOUDFLARE', 'PINOKIO_SHARE_LOCAL'] const sharingEnabled =
.some((name) => /^(1|true)$/i.test(String(env[name] || '').trim())) ['PINOKIO_SHARE_CLOUDFLARE', 'PINOKIO_SHARE_LOCAL'].some((name) =>
|| (shareVar !== '' && shareVar !== '__gev_sharing_disabled__'); /^(1|true)$/i.test(String(env[name] || '').trim()),
) ||
(shareVar !== '' && shareVar !== '__gev_sharing_disabled__');
if (sharingEnabled) { if (sharingEnabled) {
return { ok: false, status: 403, error: 'Provider Settings is disabled while sharing is enabled' }; return {
ok: false,
status: 403,
error: 'Provider Settings is disabled while sharing is enabled',
};
} }
if (!LOOPBACK_ADDRESSES.has(String(remoteAddress || ''))) { if (!LOOPBACK_ADDRESSES.has(String(remoteAddress || ''))) {
return { ok: false, status: 403, error: 'Provider Settings answers only the machine running the server' }; return {
ok: false,
status: 403,
error: 'Provider Settings answers only the machine running the server',
};
} }
const authority = localAuthority(hostHeader, protocol); const authority = localAuthority(hostHeader, protocol);
if (!authority) { if (!authority) {
return { ok: false, status: 403, error: 'Provider Settings answers only local hostnames' }; return {
ok: false,
status: 403,
error: 'Provider Settings answers only local hostnames',
};
} }
if (method === 'POST' && (origin === undefined || origin === null || origin === '')) { if (
return { ok: false, status: 403, error: 'Provider Settings requires an exact local Origin' }; method === 'POST' &&
(origin === undefined || origin === null || origin === '')
) {
return {
ok: false,
status: 403,
error: 'Provider Settings requires an exact local Origin',
};
} }
if (origin !== undefined && origin !== null && origin !== '') { if (origin !== undefined && origin !== null && origin !== '') {
let parsedOrigin; let parsedOrigin;
@@ -248,18 +294,32 @@ export function admitKeySetupRequest({
} catch { } catch {
return { ok: false, status: 403, error: 'Unrecognized Origin refused' }; return { ok: false, status: 403, error: 'Unrecognized Origin refused' };
} }
const exactOrigin = parsedOrigin.username === '' const exactOrigin =
&& parsedOrigin.password === '' parsedOrigin.username === '' &&
&& parsedOrigin.pathname === '/' parsedOrigin.password === '' &&
&& parsedOrigin.search === '' parsedOrigin.pathname === '/' &&
&& parsedOrigin.hash === '' parsedOrigin.search === '' &&
&& parsedOrigin.origin === authority; parsedOrigin.hash === '' &&
parsedOrigin.origin === authority;
if (!exactOrigin) { if (!exactOrigin) {
return { ok: false, status: 403, error: 'Cross-origin requests are refused' }; return {
ok: false,
status: 403,
error: 'Cross-origin requests are refused',
};
} }
} }
if (method === 'POST' && !String(contentType || '').toLowerCase().startsWith('application/json')) { if (
return { ok: false, status: 415, error: 'Content-Type must be application/json' }; method === 'POST' &&
!String(contentType || '')
.toLowerCase()
.startsWith('application/json')
) {
return {
ok: false,
status: 415,
error: 'Content-Type must be application/json',
};
} }
return { ok: true }; return { ok: true };
} }
@@ -337,12 +397,18 @@ export function keySetupStatus(env = {}) {
*/ */
export function validateKeySetupUpdates(body) { export function validateKeySetupUpdates(body) {
if (!body || typeof body !== 'object' || Array.isArray(body)) { if (!body || typeof body !== 'object' || Array.isArray(body)) {
return { ok: false, error: 'Body must be a JSON object of {ENV_VAR: value}' }; return {
ok: false,
error: 'Body must be a JSON object of {ENV_VAR: value}',
};
} }
const entries = Object.entries(body); const entries = Object.entries(body);
if (entries.length === 0) return { ok: false, error: 'No keys provided' }; if (entries.length === 0) return { ok: false, error: 'No keys provided' };
if (entries.length > KEY_SETUP_UPDATE_LIMIT) { if (entries.length > KEY_SETUP_UPDATE_LIMIT) {
return { ok: false, error: `At most ${KEY_SETUP_UPDATE_LIMIT} keys per save` }; return {
ok: false,
error: `At most ${KEY_SETUP_UPDATE_LIMIT} keys per save`,
};
} }
const known = knownKeySetupEnvVars(); const known = knownKeySetupEnvVars();
const updates = {}; const updates = {};
@@ -352,14 +418,21 @@ export function validateKeySetupUpdates(body) {
updates[name] = null; updates[name] = null;
continue; continue;
} }
if (typeof raw !== 'string') return { ok: false, error: `${name} must be a string` }; if (typeof raw !== 'string')
return { ok: false, error: `${name} must be a string` };
const value = raw.trim(); const value = raw.trim();
if (!value) return { ok: false, error: `${name} is empty` }; if (!value) return { ok: false, error: `${name} is empty` };
if (value.length > KEY_SETUP_VALUE_LIMIT) { if (value.length > KEY_SETUP_VALUE_LIMIT) {
return { ok: false, error: `${name} is longer than any real key (${KEY_SETUP_VALUE_LIMIT} max)` }; return {
ok: false,
error: `${name} is longer than any real key (${KEY_SETUP_VALUE_LIMIT} max)`,
};
} }
if (!/^[\x21-\x7e]+$/.test(value)) { if (!/^[\x21-\x7e]+$/.test(value)) {
return { ok: false, error: `${name} may only contain printable characters with no spaces` }; return {
ok: false,
error: `${name} may only contain printable characters with no spaces`,
};
} }
// Reject the dotenv metacharacters that would round-trip WRONG when written // Reject the dotenv metacharacters that would round-trip WRONG when written
// unquoted (# starts a comment, quotes redelimit, $ expands, backslash and // unquoted (# starts a comment, quotes redelimit, $ expands, backslash and
@@ -367,7 +440,10 @@ export function validateKeySetupUpdates(body) {
// parseEnv and Vite's expansion read back. Real provider keys never contain // parseEnv and Vite's expansion read back. Real provider keys never contain
// these; they are base64url / hex / JWT alphabets. // these; they are base64url / hex / JWT alphabets.
if (/[#"'$\\`]/.test(value)) { if (/[#"'$\\`]/.test(value)) {
return { ok: false, error: `${name} contains a character that is not valid in a key (#, quotes, $, \\, or backtick)` }; return {
ok: false,
error: `${name} contains a character that is not valid in a key (#, quotes, $, \\, or backtick)`,
};
} }
updates[name] = value; updates[name] = value;
} }
+388 -199
View File
@@ -103,7 +103,8 @@ const WARMUP_FRAMES = Number(process.env.GEV_ALLOC_WARMUP) || 3000;
// tightest sound estimate of the steady rate. // tightest sound estimate of the steady rate.
const CHUNK_FRAMES = Number(process.env.GEV_ALLOC_CHUNK) || 48; const CHUNK_FRAMES = Number(process.env.GEV_ALLOC_CHUNK) || 48;
const CHUNK_COUNT = Number(process.env.GEV_ALLOC_CHUNKS) || 10; const CHUNK_COUNT = Number(process.env.GEV_ALLOC_CHUNKS) || 10;
const STABILIZATION_CHUNKS = Number(process.env.GEV_ALLOC_STABILIZATION_CHUNKS) || 6; const STABILIZATION_CHUNKS =
Number(process.env.GEV_ALLOC_STABILIZATION_CHUNKS) || 6;
const FRAME_MS = 16; const FRAME_MS = 16;
const VIEWPORT_WIDTH = 1600; const VIEWPORT_WIDTH = 1600;
const VIEWPORT_HEIGHT = 900; const VIEWPORT_HEIGHT = 900;
@@ -124,7 +125,9 @@ function silentContext() {
filter: 'none', filter: 'none',
globalAlpha: 1, globalAlpha: 1,
globalCompositeOperation: 'source-over', globalCompositeOperation: 'source-over',
measureText(text) { return { width: String(text).length * 6 }; }, measureText(text) {
return { width: String(text).length * 6 };
},
setTransform() {}, setTransform() {},
clearRect() {}, clearRect() {},
save() {}, save() {},
@@ -188,7 +191,9 @@ function installMockEnvironment({ width, height, dpr }) {
return child; return child;
} }
insertBefore(child) { return this.appendChild(child); } insertBefore(child) {
return this.appendChild(child);
}
setAttribute(name, value) { setAttribute(name, value) {
if (name === 'id') this.id = String(value); if (name === 'id') this.id = String(value);
@@ -196,9 +201,13 @@ function installMockEnvironment({ width, height, dpr }) {
if (this.id) byId.set(this.id, this); if (this.id) byId.set(this.id, this);
} }
getBoundingClientRect() { return this._rect; } getBoundingClientRect() {
return this._rect;
}
getContext() { return this.tagName === 'CANVAS' ? ctx : null; } getContext() {
return this.tagName === 'CANVAS' ? ctx : null;
}
querySelector(selector) { querySelector(selector) {
const wanted = selector.slice(1); const wanted = selector.slice(1);
@@ -208,24 +217,40 @@ function installMockEnvironment({ width, height, dpr }) {
remove() { remove() {
if (this.parentElement) { if (this.parentElement) {
this.parentElement.children = this.parentElement.children.filter((child) => child !== this); this.parentElement.children = this.parentElement.children.filter(
(child) => child !== this,
);
} }
if (this.id) byId.delete(this.id); if (this.id) byId.delete(this.id);
this.parentElement = null; this.parentElement = null;
} }
get nextSibling() { return null; } get nextSibling() {
return null;
}
} }
const body = new MockElement('body'); const body = new MockElement('body');
body.classList = { contains() { return false; } }; body.classList = {
contains() {
return false;
},
};
const document = { const document = {
body, body,
createElement(tagName) { return new MockElement(tagName); }, createElement(tagName) {
getElementById(id) { return byId.get(id) || null; }, return new MockElement(tagName);
querySelector(selector) { return byId.get(selector.slice(1)) || null; }, },
getElementById(id) {
return byId.get(id) || null;
},
querySelector(selector) {
return byId.get(selector.slice(1)) || null;
},
querySelectorAll(selector) { querySelectorAll(selector) {
const element = selector.startsWith('#') ? byId.get(selector.slice(1)) : null; const element = selector.startsWith('#')
? byId.get(selector.slice(1))
: null;
return element ? [element] : []; return element ? [element] : [];
}, },
}; };
@@ -234,11 +259,19 @@ function installMockEnvironment({ width, height, dpr }) {
devicePixelRatio: dpr, devicePixelRatio: dpr,
addEventListener() {}, addEventListener() {},
removeEventListener() {}, removeEventListener() {},
getComputedStyle() { return { display: 'block', visibility: 'visible', opacity: '1' }; }, getComputedStyle() {
return { display: 'block', visibility: 'visible', opacity: '1' };
},
}; };
globalThis.ResizeObserver = class { observe() {} disconnect() {} }; globalThis.ResizeObserver = class {
globalThis.MutationObserver = class { observe() {} disconnect() {} }; observe() {}
disconnect() {}
};
globalThis.MutationObserver = class {
observe() {}
disconnect() {}
};
globalThis.document = document; globalThis.document = document;
globalThis.window = window; globalThis.window = window;
@@ -249,11 +282,15 @@ function installMockEnvironment({ width, height, dpr }) {
// Array-backed so raising a frame allocates nothing: the harness floor has // Array-backed so raising a frame allocates nothing: the harness floor has
// to stay far below the budget the gate asserts. // to stay far below the budget the gate asserts.
class MockEvent { class MockEvent {
constructor() { this.listeners = []; } constructor() {
this.listeners = [];
}
addEventListener(listener) { addEventListener(listener) {
this.listeners.push(listener); this.listeners.push(listener);
return () => { this.listeners.length = 0; }; return () => {
this.listeners.length = 0;
};
} }
raise() { raise() {
@@ -269,7 +306,9 @@ function installMockEnvironment({ width, height, dpr }) {
positionWC: new Cesium.Cartesian3(0, 0, 10_000_000), positionWC: new Cesium.Cartesian3(0, 0, 10_000_000),
positionCartographic: { height: 1000 }, positionCartographic: { height: 1000 },
viewMatrix: Cesium.Matrix4.clone(Cesium.Matrix4.IDENTITY), viewMatrix: Cesium.Matrix4.clone(Cesium.Matrix4.IDENTITY),
frustum: { projectionMatrix: Cesium.Matrix4.clone(Cesium.Matrix4.IDENTITY) }, frustum: {
projectionMatrix: Cesium.Matrix4.clone(Cesium.Matrix4.IDENTITY),
},
moveEnd: new MockEvent(), moveEnd: new MockEvent(),
}, },
scene: { postRender, requestRender() {} }, scene: { postRender, requestRender() {} },
@@ -278,7 +317,9 @@ function installMockEnvironment({ width, height, dpr }) {
return { return {
viewer, viewer,
postRender, postRender,
advanceTime(ms) { currentTime += ms; }, advanceTime(ms) {
currentTime += ms;
},
}; };
} }
@@ -334,16 +375,18 @@ function buildLocalInfrastructureWorkload(count) {
id: `${isDatacenter ? 'dc' : 'dam'}-${index}`, id: `${isDatacenter ? 'dc' : 'dam'}-${index}`,
layerId: sourceId, layerId: sourceId,
position: workload.entries[index].position, position: workload.entries[index].position,
properties: isDatacenter ? { properties: isDatacenter
tags: { ? {
name: `DC ${1000 + index}`, tags: {
operator: `Operator ${index % 17}`, name: `DC ${1000 + index}`,
'capacity:it_load': `${20 + index % 40} MW`, operator: `Operator ${index % 17}`,
}, 'capacity:it_load': `${20 + (index % 40)} MW`,
} : { },
name: `Dam ${1000 + index}`, }
tags: { associated_river: `River ${index % 23}` }, : {
}, name: `Dam ${1000 + index}`,
tags: { associated_river: `River ${index % 23}` },
},
priority: index % 7, priority: index % 7,
accent: isDatacenter ? '#00ffff' : '#0088ff', accent: isDatacenter ? '#00ffff' : '#0088ff',
}); });
@@ -360,12 +403,18 @@ function buildLocalInfrastructureWorkload(count) {
{ {
sourceId: 'local-datacenters', sourceId: 'local-datacenters',
entries: datacenters, entries: datacenters,
options: { collisionCapacity: 96, cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT }, options: {
collisionCapacity: 96,
cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT,
},
}, },
{ {
sourceId: 'local-dams', sourceId: 'local-dams',
entries: dams, entries: dams,
options: { collisionCapacity: 96, cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT }, options: {
collisionCapacity: 96,
cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT,
},
}, },
], ],
}; };
@@ -374,7 +423,8 @@ function buildLocalInfrastructureWorkload(count) {
function buildPhase3FirmsWorkload(count) { function buildPhase3FirmsWorkload(count) {
const localCount = LOCAL_OVERLAY_COHORT_LIMIT * 2; const localCount = LOCAL_OVERLAY_COHORT_LIMIT * 2;
const expectedCount = localCount + FIRMS_AMBIENT_COHORT_LIMIT; const expectedCount = localCount + FIRMS_AMBIENT_COHORT_LIMIT;
if (count !== expectedCount) throw new Error(`phase3-firms requires ${expectedCount} entries`); if (count !== expectedCount)
throw new Error(`phase3-firms requires ${expectedCount} entries`);
const workload = buildWorkload(count); const workload = buildWorkload(count);
const datacenters = []; const datacenters = [];
const dams = []; const dams = [];
@@ -389,8 +439,13 @@ function buildPhase3FirmsWorkload(count) {
layerId: sourceId, layerId: sourceId,
position, position,
properties: isDatacenter properties: isDatacenter
? { tags: { name: `DC ${index}`, operator: `Operator ${index % 17}` } } ? {
: { name: `Dam ${index}`, tags: { associated_river: `River ${index % 23}` } }, tags: { name: `DC ${index}`, operator: `Operator ${index % 17}` },
}
: {
name: `Dam ${index}`,
tags: { associated_river: `River ${index % 23}` },
},
priority: index % 7, priority: index % 7,
accent: isDatacenter ? '#00ffff' : '#0088ff', accent: isDatacenter ? '#00ffff' : '#0088ff',
}); });
@@ -399,16 +454,21 @@ function buildPhase3FirmsWorkload(count) {
continue; continue;
} }
const fireIndex = index - localCount; const fireIndex = index - localCount;
firms.push(applyFirmsOverlayPolicy({ firms.push(
id: `fire:${fireIndex}`, applyFirmsOverlayPolicy(
position, {
gapPx: 10, id: `fire:${fireIndex}`,
accent: '224, 82, 82', position,
title: `▲ ${50 + fireIndex} MW`, gapPx: 10,
details: ['high · 2h · N20'], accent: '224, 82, 82',
selected: false, title: `▲ ${50 + fireIndex} MW`,
priority: 100 - fireIndex, details: ['high · 2h · N20'],
}, 12_000_000)); selected: false,
priority: 100 - fireIndex,
},
12_000_000,
),
);
firms.at(-1).horizonCull = false; firms.at(-1).horizonCull = false;
} }
return { return {
@@ -417,12 +477,18 @@ function buildPhase3FirmsWorkload(count) {
{ {
sourceId: 'local-datacenters', sourceId: 'local-datacenters',
entries: datacenters, entries: datacenters,
options: { collisionCapacity: 96, cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT }, options: {
collisionCapacity: 96,
cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT,
},
}, },
{ {
sourceId: 'local-dams', sourceId: 'local-dams',
entries: dams, entries: dams,
options: { collisionCapacity: 96, cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT }, options: {
collisionCapacity: 96,
cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT,
},
}, },
{ {
sourceId: FIRMS_OVERLAY_SOURCE_ID, sourceId: FIRMS_OVERLAY_SOURCE_ID,
@@ -439,9 +505,14 @@ function buildPhase3FirmsWorkload(count) {
function buildPhase3VesselsWorkload(count) { function buildPhase3VesselsWorkload(count) {
const localCount = LOCAL_OVERLAY_COHORT_LIMIT * 2; const localCount = LOCAL_OVERLAY_COHORT_LIMIT * 2;
const vesselAmbientCount = vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); const vesselAmbientCount = vesselOverlayCohortLimit(
const expectedCount = localCount + FIRMS_AMBIENT_COHORT_LIMIT + vesselAmbientCount + 1; VIEWPORT_WIDTH,
if (count !== expectedCount) throw new Error(`phase3-vessels requires ${expectedCount} entries`); VIEWPORT_HEIGHT,
);
const expectedCount =
localCount + FIRMS_AMBIENT_COHORT_LIMIT + vesselAmbientCount + 1;
if (count !== expectedCount)
throw new Error(`phase3-vessels requires ${expectedCount} entries`);
const workload = buildWorkload(count); const workload = buildWorkload(count);
const datacenters = []; const datacenters = [];
const dams = []; const dams = [];
@@ -457,8 +528,13 @@ function buildPhase3VesselsWorkload(count) {
layerId: sourceId, layerId: sourceId,
position, position,
properties: isDatacenter properties: isDatacenter
? { tags: { name: `DC ${index}`, operator: `Operator ${index % 17}` } } ? {
: { name: `Dam ${index}`, tags: { associated_river: `River ${index % 23}` } }, tags: { name: `DC ${index}`, operator: `Operator ${index % 17}` },
}
: {
name: `Dam ${index}`,
tags: { associated_river: `River ${index % 23}` },
},
priority: index % 7, priority: index % 7,
accent: isDatacenter ? '#00ffff' : '#0088ff', accent: isDatacenter ? '#00ffff' : '#0088ff',
}); });
@@ -469,34 +545,40 @@ function buildPhase3VesselsWorkload(count) {
const firmsEnd = localCount + FIRMS_AMBIENT_COHORT_LIMIT; const firmsEnd = localCount + FIRMS_AMBIENT_COHORT_LIMIT;
if (index < firmsEnd) { if (index < firmsEnd) {
const fireIndex = index - localCount; const fireIndex = index - localCount;
const entry = applyFirmsOverlayPolicy({ const entry = applyFirmsOverlayPolicy(
id: `fire:${fireIndex}`, {
position, id: `fire:${fireIndex}`,
gapPx: 10, position,
accent: '224, 82, 82', gapPx: 10,
title: `▲ ${50 + fireIndex} MW`, accent: '224, 82, 82',
details: ['high · 2h · N20'], title: `▲ ${50 + fireIndex} MW`,
selected: false, details: ['high · 2h · N20'],
priority: 100 - fireIndex, selected: false,
}, 12_000_000); priority: 100 - fireIndex,
},
12_000_000,
);
entry.horizonCull = false; entry.horizonCull = false;
firms.push(entry); firms.push(entry);
continue; continue;
} }
const vesselIndex = index - firmsEnd; const vesselIndex = index - firmsEnd;
const selected = vesselIndex === vesselAmbientCount; const selected = vesselIndex === vesselAmbientCount;
const entry = applyVesselOverlayPolicy({ const entry = applyVesselOverlayPolicy(
id: selected ? 'vessel:selected' : `vessel:${vesselIndex}`, {
position, id: selected ? 'vessel:selected' : `vessel:${vesselIndex}`,
gapPx: selected ? 12 : 10, position,
accent: '57, 213, 255', gapPx: selected ? 12 : 10,
title: selected ? 'SELECTED VESSEL' : `VESSEL ${vesselIndex}`, accent: '57, 213, 255',
details: selected title: selected ? 'SELECTED VESSEL' : `VESSEL ${vesselIndex}`,
? ['CARGO · 14.5KT · 231°', 'MMSI 353136000 · POS: LIVE'] details: selected
: ['CARGO · 14.5KT · 231°'], ? ['CARGO · 14.5KT · 231°', 'MMSI 353136000 · POS: LIVE']
selected, : ['CARGO · 14.5KT · 231°'],
priority: selected ? 100000 : vesselAmbientCount - vesselIndex, selected,
}, 12_000_000); priority: selected ? 100000 : vesselAmbientCount - vesselIndex,
},
12_000_000,
);
entry.horizonCull = false; entry.horizonCull = false;
vessels.push(entry); vessels.push(entry);
} }
@@ -506,12 +588,18 @@ function buildPhase3VesselsWorkload(count) {
{ {
sourceId: 'local-datacenters', sourceId: 'local-datacenters',
entries: datacenters, entries: datacenters,
options: { collisionCapacity: 96, cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT }, options: {
collisionCapacity: 96,
cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT,
},
}, },
{ {
sourceId: 'local-dams', sourceId: 'local-dams',
entries: dams, entries: dams,
options: { collisionCapacity: 96, cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT }, options: {
collisionCapacity: 96,
cohortLimit: LOCAL_OVERLAY_COHORT_LIMIT,
},
}, },
{ {
sourceId: FIRMS_OVERLAY_SOURCE_ID, sourceId: FIRMS_OVERLAY_SOURCE_ID,
@@ -524,7 +612,10 @@ function buildPhase3VesselsWorkload(count) {
{ {
sourceId: VESSEL_OVERLAY_SOURCE_ID, sourceId: VESSEL_OVERLAY_SOURCE_ID,
entries: vessels, entries: vessels,
options: { collisionCapacity: vesselAmbientCount, cohortLimit: vesselAmbientCount }, options: {
collisionCapacity: vesselAmbientCount,
cohortLimit: vesselAmbientCount,
},
}, },
], ],
ambientCardCapacity: AMBIENT_CARD_COLLISION_CAPACITY, ambientCardCapacity: AMBIENT_CARD_COLLISION_CAPACITY,
@@ -533,14 +624,21 @@ function buildPhase3VesselsWorkload(count) {
function buildPhase3TrackedWorkload(count) { function buildPhase3TrackedWorkload(count) {
const localCount = LOCAL_OVERLAY_COHORT_LIMIT * 2; const localCount = LOCAL_OVERLAY_COHORT_LIMIT * 2;
const vesselAmbientCount = vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT); const vesselAmbientCount = vesselOverlayCohortLimit(
const expectedCount = localCount + FIRMS_AMBIENT_COHORT_LIMIT + vesselAmbientCount + 1; VIEWPORT_WIDTH,
if (count !== expectedCount) throw new Error(`phase3-tracked requires ${expectedCount} entries`); VIEWPORT_HEIGHT,
);
const expectedCount =
localCount + FIRMS_AMBIENT_COHORT_LIMIT + vesselAmbientCount + 1;
if (count !== expectedCount)
throw new Error(`phase3-tracked requires ${expectedCount} entries`);
const workload = buildPhase3VesselsWorkload(count); const workload = buildPhase3VesselsWorkload(count);
const vesselRegistration = workload.registrations.find( const vesselRegistration = workload.registrations.find(
({ sourceId }) => sourceId === VESSEL_OVERLAY_SOURCE_ID, ({ sourceId }) => sourceId === VESSEL_OVERLAY_SOURCE_ID,
); );
const selectedIndex = vesselRegistration.entries.findIndex(({ selected }) => selected); const selectedIndex = vesselRegistration.entries.findIndex(
({ selected }) => selected,
);
const selected = vesselRegistration.entries.splice(selectedIndex, 1)[0]; const selected = vesselRegistration.entries.splice(selectedIndex, 1)[0];
const trackedEntity = { const trackedEntity = {
gevTrackedId: 'flights:allocation-probe', gevTrackedId: 'flights:allocation-probe',
@@ -566,10 +664,14 @@ function buildPhase3TrackedWorkload(count) {
} }
function buildPhase4CctvWorkload(count) { function buildPhase4CctvWorkload(count) {
const phase3Count = LOCAL_OVERLAY_COHORT_LIMIT * 2 + FIRMS_AMBIENT_COHORT_LIMIT const phase3Count =
+ vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) + 1; LOCAL_OVERLAY_COHORT_LIMIT * 2 +
FIRMS_AMBIENT_COHORT_LIMIT +
vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) +
1;
const expectedCount = phase3Count + CCTV_AMBIENT_CARD_MAX + 1; const expectedCount = phase3Count + CCTV_AMBIENT_CARD_MAX + 1;
if (count !== expectedCount) throw new Error(`phase4-cctv requires ${expectedCount} entries`); if (count !== expectedCount)
throw new Error(`phase4-cctv requires ${expectedCount} entries`);
const workload = buildPhase3TrackedWorkload(phase3Count); const workload = buildPhase3TrackedWorkload(phase3Count);
const cctv = []; const cctv = [];
for (let index = 0; index <= CCTV_AMBIENT_CARD_MAX; index++) { for (let index = 0; index <= CCTV_AMBIENT_CARD_MAX; index++) {
@@ -616,11 +718,16 @@ function buildPhase4CctvWorkload(count) {
} }
function buildPhase5EarthquakesWorkload(count) { function buildPhase5EarthquakesWorkload(count) {
const phase4Count = LOCAL_OVERLAY_COHORT_LIMIT * 2 + FIRMS_AMBIENT_COHORT_LIMIT const phase4Count =
+ vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) + 1 LOCAL_OVERLAY_COHORT_LIMIT * 2 +
+ CCTV_AMBIENT_CARD_MAX + 1; FIRMS_AMBIENT_COHORT_LIMIT +
vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) +
1 +
CCTV_AMBIENT_CARD_MAX +
1;
const expectedCount = phase4Count + EARTHQUAKE_OVERLAY_COHORT_LIMIT; const expectedCount = phase4Count + EARTHQUAKE_OVERLAY_COHORT_LIMIT;
if (count !== expectedCount) throw new Error(`phase5-earthquakes requires ${expectedCount} entries`); if (count !== expectedCount)
throw new Error(`phase5-earthquakes requires ${expectedCount} entries`);
const workload = buildPhase4CctvWorkload(phase4Count); const workload = buildPhase4CctvWorkload(phase4Count);
const earthquakes = []; const earthquakes = [];
for (let index = 0; index < EARTHQUAKE_OVERLAY_COHORT_LIMIT; index++) { for (let index = 0; index < EARTHQUAKE_OVERLAY_COHORT_LIMIT; index++) {
@@ -640,7 +747,8 @@ function buildPhase5EarthquakesWorkload(count) {
id: `quake-${index}`, id: `quake-${index}`,
position, position,
magnitude: 2.5 + (index % 45) / 10, magnitude: 2.5 + (index % 45) / 10,
accent: index % 3 === 0 ? '#ff0000' : index % 3 === 1 ? '#ffa500' : '#ffff00', accent:
index % 3 === 0 ? '#ff0000' : index % 3 === 1 ? '#ffa500' : '#ffff00',
}); });
entry.horizonCull = false; entry.horizonCull = false;
earthquakes.push(entry); earthquakes.push(entry);
@@ -657,11 +765,17 @@ function buildPhase5EarthquakesWorkload(count) {
} }
function buildPhase5BikeshareWorkload(count) { function buildPhase5BikeshareWorkload(count) {
const earthquakeCount = LOCAL_OVERLAY_COHORT_LIMIT * 2 + FIRMS_AMBIENT_COHORT_LIMIT const earthquakeCount =
+ vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) + 1 LOCAL_OVERLAY_COHORT_LIMIT * 2 +
+ CCTV_AMBIENT_CARD_MAX + 1 + EARTHQUAKE_OVERLAY_COHORT_LIMIT; FIRMS_AMBIENT_COHORT_LIMIT +
vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) +
1 +
CCTV_AMBIENT_CARD_MAX +
1 +
EARTHQUAKE_OVERLAY_COHORT_LIMIT;
const expectedCount = earthquakeCount + 1; const expectedCount = earthquakeCount + 1;
if (count !== expectedCount) throw new Error(`phase5-bikeshare requires ${expectedCount} entries`); if (count !== expectedCount)
throw new Error(`phase5-bikeshare requires ${expectedCount} entries`);
const workload = buildPhase5EarthquakesWorkload(earthquakeCount); const workload = buildPhase5EarthquakesWorkload(earthquakeCount);
const position = new Cesium.Cartesian3(0.12, -0.08, 0); const position = new Cesium.Cartesian3(0.12, -0.08, 0);
workload.positions.push(position); workload.positions.push(position);
@@ -687,11 +801,18 @@ function buildPhase5BikeshareWorkload(count) {
} }
function buildPhase5SatellitesWorkload(count) { function buildPhase5SatellitesWorkload(count) {
const bikeshareCount = LOCAL_OVERLAY_COHORT_LIMIT * 2 + FIRMS_AMBIENT_COHORT_LIMIT const bikeshareCount =
+ vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) + 1 LOCAL_OVERLAY_COHORT_LIMIT * 2 +
+ CCTV_AMBIENT_CARD_MAX + 1 + EARTHQUAKE_OVERLAY_COHORT_LIMIT + 1; FIRMS_AMBIENT_COHORT_LIMIT +
vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) +
1 +
CCTV_AMBIENT_CARD_MAX +
1 +
EARTHQUAKE_OVERLAY_COHORT_LIMIT +
1;
const expectedCount = bikeshareCount + 1; const expectedCount = bikeshareCount + 1;
if (count !== expectedCount) throw new Error(`phase5-satellites requires ${expectedCount} entries`); if (count !== expectedCount)
throw new Error(`phase5-satellites requires ${expectedCount} entries`);
const workload = buildPhase5BikeshareWorkload(bikeshareCount); const workload = buildPhase5BikeshareWorkload(bikeshareCount);
const position = new Cesium.Cartesian3(-0.42, 0.54, 0); const position = new Cesium.Cartesian3(-0.42, 0.54, 0);
workload.positions.push(position); workload.positions.push(position);
@@ -707,9 +828,15 @@ function buildPhase5SatellitesWorkload(count) {
} }
function buildPhase5CctvProjectionWorkload(count) { function buildPhase5CctvProjectionWorkload(count) {
const satelliteCount = LOCAL_OVERLAY_COHORT_LIMIT * 2 + FIRMS_AMBIENT_COHORT_LIMIT const satelliteCount =
+ vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) + 1 LOCAL_OVERLAY_COHORT_LIMIT * 2 +
+ CCTV_AMBIENT_CARD_MAX + 1 + EARTHQUAKE_OVERLAY_COHORT_LIMIT + 2; FIRMS_AMBIENT_COHORT_LIMIT +
vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) +
1 +
CCTV_AMBIENT_CARD_MAX +
1 +
EARTHQUAKE_OVERLAY_COHORT_LIMIT +
2;
const expectedCount = satelliteCount + 1; const expectedCount = satelliteCount + 1;
if (count !== expectedCount) { if (count !== expectedCount) {
throw new Error(`phase5-cctv-projection requires ${expectedCount} entries`); throw new Error(`phase5-cctv-projection requires ${expectedCount} entries`);
@@ -738,7 +865,8 @@ function buildPhase5CivilWorkload(count) {
({ sourceId }) => sourceId === TRACKED_OVERLAY_SOURCE_ID, ({ sourceId }) => sourceId === TRACKED_OVERLAY_SOURCE_ID,
); );
const entry = registration?.entries[0]; const entry = registration?.entries[0];
if (!entry) throw new Error('phase5-civil requires the protected tracked entry'); if (!entry)
throw new Error('phase5-civil requires the protected tracked entry');
entry.title = 'ALLOC01 · FL350 · 451 kts'; entry.title = 'ALLOC01 · FL350 · 451 kts';
entry.details = ['TEST AIR · A320', 'AUS → LAX']; entry.details = ['TEST AIR · A320', 'AUS → LAX'];
return workload; return workload;
@@ -750,7 +878,8 @@ function buildPhase5MilitaryWorkload(count) {
({ sourceId }) => sourceId === TRACKED_OVERLAY_SOURCE_ID, ({ sourceId }) => sourceId === TRACKED_OVERLAY_SOURCE_ID,
); );
const entry = registration?.entries[0]; const entry = registration?.entries[0];
if (!entry) throw new Error('phase5-military requires the protected tracked entry'); if (!entry)
throw new Error('phase5-military requires the protected tracked entry');
entry.id = 'military:allocation-probe'; entry.id = 'military:allocation-probe';
entry.title = 'RCH451'; entry.title = 'RCH451';
entry.details = ['C17 · 05-8152', 'USAF · 28000 ft · 400 kt']; entry.details = ['C17 · 05-8152', 'USAF · 28000 ft · 400 kt'];
@@ -773,12 +902,17 @@ function appendRocketMissionAmbientWorkload(workload, count) {
phase: index * 0.33, phase: index * 0.33,
rate: 0.3 + (index % 6) * 0.06, rate: 0.3 + (index % 6) * 0.06,
}); });
const entry = createRocketMissionMarkerOverlayEntry({ const entry = createRocketMissionMarkerOverlayEntry(
id: `allocation-${index}`, {
name: `MISSION ${1000 + index} | PAYLOAD`, id: `allocation-${index}`,
launchSite: `Launch Complex ${index}`, name: `MISSION ${1000 + index} | PAYLOAD`,
launchTime: new Date(Date.UTC(2026, 6, 31) - index * 60_000).toISOString(), launchSite: `Launch Complex ${index}`,
}, () => position); launchTime: new Date(
Date.UTC(2026, 6, 31) - index * 60_000,
).toISOString(),
},
() => position,
);
entry.horizonCull = false; entry.horizonCull = false;
entries.push(entry); entries.push(entry);
} }
@@ -799,19 +933,29 @@ function buildRocketMissionAmbientWorkload(count) {
`rocket-missions requires ${ROCKET_MISSION_AMBIENT_OVERLAY_COHORT_LIMIT} entries`, `rocket-missions requires ${ROCKET_MISSION_AMBIENT_OVERLAY_COHORT_LIMIT} entries`,
); );
} }
return appendRocketMissionAmbientWorkload({ return appendRocketMissionAmbientWorkload(
entries: [], {
positions: [], entries: [],
drifts: [], positions: [],
registrations: [], drifts: [],
}, count); registrations: [],
},
count,
);
} }
function buildPhase5RocketMissionWorkload(count) { function buildPhase5RocketMissionWorkload(count) {
const phase5Count = LOCAL_OVERLAY_COHORT_LIMIT * 2 + FIRMS_AMBIENT_COHORT_LIMIT const phase5Count =
+ vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) + 1 LOCAL_OVERLAY_COHORT_LIMIT * 2 +
+ CCTV_AMBIENT_CARD_MAX + 1 + EARTHQUAKE_OVERLAY_COHORT_LIMIT + 3; FIRMS_AMBIENT_COHORT_LIMIT +
const expectedCount = phase5Count + ROCKET_MISSION_AMBIENT_OVERLAY_COHORT_LIMIT; vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) +
1 +
CCTV_AMBIENT_CARD_MAX +
1 +
EARTHQUAKE_OVERLAY_COHORT_LIMIT +
3;
const expectedCount =
phase5Count + ROCKET_MISSION_AMBIENT_OVERLAY_COHORT_LIMIT;
if (count !== expectedCount) { if (count !== expectedCount) {
throw new Error(`phase5-rockets requires ${expectedCount} entries`); throw new Error(`phase5-rockets requires ${expectedCount} entries`);
} }
@@ -822,23 +966,42 @@ function buildPhase5RocketMissionWorkload(count) {
} }
function buildAllLiveRadioWorkload(count) { function buildAllLiveRadioWorkload(count) {
const phase5Count = LOCAL_OVERLAY_COHORT_LIMIT * 2 + FIRMS_AMBIENT_COHORT_LIMIT const phase5Count =
+ vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) + 1 LOCAL_OVERLAY_COHORT_LIMIT * 2 +
+ CCTV_AMBIENT_CARD_MAX + 1 + EARTHQUAKE_OVERLAY_COHORT_LIMIT + 3 FIRMS_AMBIENT_COHORT_LIMIT +
+ ROCKET_MISSION_AMBIENT_OVERLAY_COHORT_LIMIT; vesselOverlayCohortLimit(VIEWPORT_WIDTH, VIEWPORT_HEIGHT) +
1 +
CCTV_AMBIENT_CARD_MAX +
1 +
EARTHQUAKE_OVERLAY_COHORT_LIMIT +
3 +
ROCKET_MISSION_AMBIENT_OVERLAY_COHORT_LIMIT;
// 2026-08-18: "every shared-host source" includes the migrated // 2026-08-18: "every shared-host source" includes the migrated
// submarine-cable cohort, so the aggregate exercises cable labels // submarine-cable cohort, so the aggregate exercises cable labels
// interacting with Radio/earthquake/mission quotas and allocation. // interacting with Radio/earthquake/mission quotas and allocation.
const expectedCount = phase5Count + RADIO_OVERLAY_COHORT_LIMIT + 1 const expectedCount =
+ CABLE_REFERENCE_LABEL_WINNER_CAP; phase5Count +
if (count !== expectedCount) throw new Error(`all-live-radio requires ${expectedCount} entries`); RADIO_OVERLAY_COHORT_LIMIT +
1 +
CABLE_REFERENCE_LABEL_WINNER_CAP;
if (count !== expectedCount)
throw new Error(`all-live-radio requires ${expectedCount} entries`);
const workload = buildPhase5RocketMissionWorkload(phase5Count); const workload = buildPhase5RocketMissionWorkload(phase5Count);
appendSubmarineCableWorkload(workload, CABLE_REFERENCE_LABEL_WINNER_CAP); appendSubmarineCableWorkload(workload, CABLE_REFERENCE_LABEL_WINNER_CAP);
const entries = []; const entries = [];
for (let index = 0; index < RADIO_OVERLAY_COHORT_LIMIT; index += 1) { for (let index = 0; index < RADIO_OVERLAY_COHORT_LIMIT; index += 1) {
const position = new Cesium.Cartesian3(-0.72 + (index % 8) * 0.18, -0.64 + Math.floor(index / 8) * 0.16, 0); const position = new Cesium.Cartesian3(
-0.72 + (index % 8) * 0.18,
-0.64 + Math.floor(index / 8) * 0.16,
0,
);
workload.positions.push(position); workload.positions.push(position);
workload.drifts.push({ baseX: position.x, baseY: position.y, phase: index * 0.21, rate: 0.35 }); workload.drifts.push({
baseX: position.x,
baseY: position.y,
phase: index * 0.21,
rate: 0.35,
});
const entry = createRadioClusterOverlayEntry({ const entry = createRadioClusterOverlayEntry({
id: `cluster-${index}`, id: `cluster-${index}`,
position: () => position, position: () => position,
@@ -851,12 +1014,20 @@ function buildAllLiveRadioWorkload(count) {
} }
const selectedPosition = new Cesium.Cartesian3(0.08, 0.12, 0); const selectedPosition = new Cesium.Cartesian3(0.08, 0.12, 0);
workload.positions.push(selectedPosition); workload.positions.push(selectedPosition);
workload.drifts.push({ baseX: selectedPosition.x, baseY: selectedPosition.y, phase: 0.5, rate: 0.4 }); workload.drifts.push({
const selectedEntry = createRadioSelectedOverlayEntry({ baseX: selectedPosition.x,
id: 'selected', baseY: selectedPosition.y,
name: 'ALLOCATION RADIO', phase: 0.5,
tags: ['news'], rate: 0.4,
}, () => selectedPosition); });
const selectedEntry = createRadioSelectedOverlayEntry(
{
id: 'selected',
name: 'ALLOCATION RADIO',
tags: ['news'],
},
() => selectedPosition,
);
selectedEntry.horizonCull = false; selectedEntry.horizonCull = false;
entries.push(selectedEntry); entries.push(selectedEntry);
workload.registrations.push({ workload.registrations.push({
@@ -895,7 +1066,8 @@ function appendSubmarineCableWorkload(workload, count) {
const entry = createCableOverlayEntry({ const entry = createCableOverlayEntry({
id: `${kind}-reference-${index}-alloc`, id: `${kind}-reference-${index}-alloc`,
kind, kind,
label: kind === 'cable' ? `Cable System ${index}` : `Landing Point ${index}`, label:
kind === 'cable' ? `Cable System ${index}` : `Landing Point ${index}`,
tip: position, tip: position,
distanceM: 200_000 + index * 40_000, distanceM: 200_000 + index * 40_000,
}); });
@@ -919,7 +1091,9 @@ function appendSubmarineCableWorkload(workload, count) {
function buildSubmarineCablesWorkload(count) { function buildSubmarineCablesWorkload(count) {
if (count !== CABLE_REFERENCE_LABEL_WINNER_CAP) { if (count !== CABLE_REFERENCE_LABEL_WINNER_CAP) {
throw new Error(`submarine-cables requires ${CABLE_REFERENCE_LABEL_WINNER_CAP} entries`); throw new Error(
`submarine-cables requires ${CABLE_REFERENCE_LABEL_WINNER_CAP} entries`,
);
} }
return appendSubmarineCableWorkload( return appendSubmarineCableWorkload(
{ entries: [], positions: [], drifts: [], registrations: [] }, { entries: [], positions: [], drifts: [], registrations: [] },
@@ -943,8 +1117,8 @@ function buildPhase6DetectionWorkload(count) {
const row = Math.floor(index / columns); const row = Math.floor(index / columns);
const baseX = -700_000 + column * spanX; const baseX = -700_000 + column * spanX;
const baseY = -525_000 + row * spanY; const baseY = -525_000 + row * spanY;
const normalizedHorizontal = (baseX * baseX + baseY * baseY) const normalizedHorizontal =
/ (equatorialRadiusM * equatorialRadiusM); (baseX * baseX + baseY * baseY) / (equatorialRadiusM * equatorialRadiusM);
const z = polarRadiusM * Math.sqrt(Math.max(0, 1 - normalizedHorizontal)); const z = polarRadiusM * Math.sqrt(Math.max(0, 1 - normalizedHorizontal));
const position = new Cesium.Cartesian3(baseX, baseY, z); const position = new Cesium.Cartesian3(baseX, baseY, z);
positions.push(position); positions.push(position);
@@ -959,7 +1133,10 @@ function buildPhase6DetectionWorkload(count) {
position, position,
sourceId: `detect-${index}`, sourceId: `detect-${index}`,
id: `D${String(index).padStart(4, '0')}`, id: `D${String(index).padStart(4, '0')}`,
metric: index % 5 === 0 ? '' : `FL${String(180 + (index % 220)).padStart(3, '0')}`, metric:
index % 5 === 0
? ''
: `FL${String(180 + (index % 220)).padStart(3, '0')}`,
type: ['AIR', 'SAT', 'SEA', 'VEH'][index % 4], type: ['AIR', 'SAT', 'SEA', 'VEH'][index % 4],
tier: index % 17 === 0 ? 'military' : undefined, tier: index % 17 === 0 ? 'military' : undefined,
}); });
@@ -970,7 +1147,9 @@ function buildPhase6DetectionWorkload(count) {
drifts, drifts,
detectionLayer: { detectionLayer: {
id: 'flights', id: 'flights',
getDetectableObjects() { return observations; }, getDetectableObjects() {
return observations;
},
}, },
}; };
} }
@@ -996,39 +1175,40 @@ function main() {
dpr: 2, dpr: 2,
}); });
initWorldOverlay(env.viewer); initWorldOverlay(env.viewer);
const workload = PROFILE === 'phase6-detection' const workload =
? buildPhase6DetectionWorkload(ENTRY_COUNT) PROFILE === 'phase6-detection'
: PROFILE === 'local-infrastructure' ? buildPhase6DetectionWorkload(ENTRY_COUNT)
? buildLocalInfrastructureWorkload(ENTRY_COUNT) : PROFILE === 'local-infrastructure'
: PROFILE === 'phase3-firms' ? buildLocalInfrastructureWorkload(ENTRY_COUNT)
? buildPhase3FirmsWorkload(ENTRY_COUNT) : PROFILE === 'phase3-firms'
: PROFILE === 'phase3-vessels' ? buildPhase3FirmsWorkload(ENTRY_COUNT)
? buildPhase3VesselsWorkload(ENTRY_COUNT) : PROFILE === 'phase3-vessels'
: PROFILE === 'phase3-tracked' ? buildPhase3VesselsWorkload(ENTRY_COUNT)
? buildPhase3TrackedWorkload(ENTRY_COUNT) : PROFILE === 'phase3-tracked'
: PROFILE === 'phase4-cctv' ? buildPhase3TrackedWorkload(ENTRY_COUNT)
? buildPhase4CctvWorkload(ENTRY_COUNT) : PROFILE === 'phase4-cctv'
: PROFILE === 'phase5-earthquakes' ? buildPhase4CctvWorkload(ENTRY_COUNT)
? buildPhase5EarthquakesWorkload(ENTRY_COUNT) : PROFILE === 'phase5-earthquakes'
: PROFILE === 'phase5-bikeshare' ? buildPhase5EarthquakesWorkload(ENTRY_COUNT)
? buildPhase5BikeshareWorkload(ENTRY_COUNT) : PROFILE === 'phase5-bikeshare'
: PROFILE === 'phase5-satellites' ? buildPhase5BikeshareWorkload(ENTRY_COUNT)
? buildPhase5SatellitesWorkload(ENTRY_COUNT) : PROFILE === 'phase5-satellites'
: PROFILE === 'phase5-cctv-projection' ? buildPhase5SatellitesWorkload(ENTRY_COUNT)
? buildPhase5CctvProjectionWorkload(ENTRY_COUNT) : PROFILE === 'phase5-cctv-projection'
: PROFILE === 'phase5-civil' ? buildPhase5CctvProjectionWorkload(ENTRY_COUNT)
? buildPhase5CivilWorkload(ENTRY_COUNT) : PROFILE === 'phase5-civil'
: PROFILE === 'phase5-military' ? buildPhase5CivilWorkload(ENTRY_COUNT)
? buildPhase5MilitaryWorkload(ENTRY_COUNT) : PROFILE === 'phase5-military'
: PROFILE === 'rocket-missions' ? buildPhase5MilitaryWorkload(ENTRY_COUNT)
? buildRocketMissionAmbientWorkload(ENTRY_COUNT) : PROFILE === 'rocket-missions'
: PROFILE === 'phase5-rockets' ? buildRocketMissionAmbientWorkload(ENTRY_COUNT)
? buildPhase5RocketMissionWorkload(ENTRY_COUNT) : PROFILE === 'phase5-rockets'
: PROFILE === 'all-live-radio' ? buildPhase5RocketMissionWorkload(ENTRY_COUNT)
? buildAllLiveRadioWorkload(ENTRY_COUNT) : PROFILE === 'all-live-radio'
: PROFILE === 'submarine-cables' ? buildAllLiveRadioWorkload(ENTRY_COUNT)
? buildSubmarineCablesWorkload(ENTRY_COUNT) : PROFILE === 'submarine-cables'
: buildWorkload(ENTRY_COUNT); ? buildSubmarineCablesWorkload(ENTRY_COUNT)
: buildWorkload(ENTRY_COUNT);
const { entries, positions, drifts } = workload; const { entries, positions, drifts } = workload;
const solveIntervalMs = Number(process.env.GEV_ALLOC_SOLVE_MS) || 125; const solveIntervalMs = Number(process.env.GEV_ALLOC_SOLVE_MS) || 125;
const detectionActive = !!workload.detectionLayer; const detectionActive = !!workload.detectionLayer;
@@ -1080,9 +1260,15 @@ function main() {
} }
const warm = getWorldOverlayDiagnostics(); const warm = getWorldOverlayDiagnostics();
const detectionWarm = detectionActive ? getDetectionDiagnostics() : null; const detectionWarm = detectionActive ? getDetectionDiagnostics() : null;
const painted = detectionActive ? detectionWarm.visibleCount : warm.paintedCount; const painted = detectionActive
const candidates = detectionActive ? detectionWarm.observationCount : warm.candidateCount; ? detectionWarm.visibleCount
const solveRevisionBefore = detectionActive ? detectionWarm.solveRevision : warm.solveRevision; : warm.paintedCount;
const candidates = detectionActive
? detectionWarm.observationCount
: warm.candidateCount;
const solveRevisionBefore = detectionActive
? detectionWarm.solveRevision
: warm.solveRevision;
const chunkRates = []; const chunkRates = [];
for (let chunk = 0; chunk < CHUNK_COUNT; chunk++) { for (let chunk = 0; chunk < CHUNK_COUNT; chunk++) {
@@ -1101,31 +1287,34 @@ function main() {
const medianBytesPerFrame = sorted[Math.floor(sorted.length / 2)]; const medianBytesPerFrame = sorted[Math.floor(sorted.length / 2)];
const perCandidate = (value) => value / Math.max(1, candidates); const perCandidate = (value) => value / Math.max(1, candidates);
process.stdout.write(`${JSON.stringify({ process.stdout.write(
ok: true, `${JSON.stringify({
profile: PROFILE, ok: true,
ambientCardCapacity: workload.ambientCardCapacity ?? null, profile: PROFILE,
entryCount: ENTRY_COUNT, ambientCardCapacity: workload.ambientCardCapacity ?? null,
warmupFrames: WARMUP_FRAMES, entryCount: ENTRY_COUNT,
stabilizationChunks: STABILIZATION_CHUNKS, warmupFrames: WARMUP_FRAMES,
chunkFrames: CHUNK_FRAMES, stabilizationChunks: STABILIZATION_CHUNKS,
chunkCount: CHUNK_COUNT, chunkFrames: CHUNK_FRAMES,
measuredFrames: CHUNK_FRAMES * CHUNK_COUNT, chunkCount: CHUNK_COUNT,
paintedCount: painted, measuredFrames: CHUNK_FRAMES * CHUNK_COUNT,
paintedBySource: warm.paintedBySource, paintedCount: painted,
candidateCount: candidates, paintedBySource: warm.paintedBySource,
detectionSelectedCount: detectionWarm?.selectedCount ?? null, candidateCount: candidates,
detectionCollectiveLabelBudget: detectionWarm?.collectiveLabelBudget ?? null, detectionSelectedCount: detectionWarm?.selectedCount ?? null,
solveCount: solveRevisionAfter - solveRevisionBefore, detectionCollectiveLabelBudget:
// Frame cost is the primary signal; the per-candidate rate is the detectionWarm?.collectiveLabelBudget ?? null,
// scale-invariant one. Neither is normalized by paintedCount, which solveCount: solveRevisionAfter - solveRevisionBefore,
// saturates at the domain collision capacity. // Frame cost is the primary signal; the per-candidate rate is the
maxBytesPerFrame, // scale-invariant one. Neither is normalized by paintedCount, which
medianBytesPerFrame, // saturates at the domain collision capacity.
maxBytesPerCandidatePerFrame: perCandidate(maxBytesPerFrame), maxBytesPerFrame,
medianBytesPerCandidatePerFrame: perCandidate(medianBytesPerFrame), medianBytesPerFrame,
chunkBytesPerFrame: chunkRates, maxBytesPerCandidatePerFrame: perCandidate(maxBytesPerFrame),
})}\n`); medianBytesPerCandidatePerFrame: perCandidate(medianBytesPerFrame),
chunkBytesPerFrame: chunkRates,
})}\n`,
);
if (detectionActive) destroyDetection(); if (detectionActive) destroyDetection();
destroyWorldOverlay(); destroyWorldOverlay();