Ratchet Cesium-shaped viewer access in files off the Cesium list

A second ratchet beside the Cesium allow-list: files off that list (and
outside the Cesium adapter) may no longer reach Cesium through the viewer
either. src/render/viewerAccessAllowList.json records, per file, how many
such accesses it still makes (the viewer's entities, dataSources, scene,
camera, clock, imageryLayers, terrainProvider, trackedEntity and canvas;
the scene's primitives, pick, drillPick, pickPosition, globe, frame
events, canvas, requestRender and camera), read from the parsed source in
their plain, optional, bracketed, call-result and destructured forms.
viewer.container, comments and tests do not count.

The test fails when a file makes more accesses than recorded, when a
recorded count is higher than the file now needs or names a file gone or
back on the Cesium list, and when the record grows against origin/main.
scripts/viewer-access-baseline.mjs lowers the record to what the files
hold; it never adds or raises an entry. The record starts with 25 files
and 50 accesses.
This commit is contained in:
Sameh Khamis committed 2026-11-07 19:44:15 -08:00
1 parent 0f9bd23829
commit 396e7f0deb
7 files changed
+557

No files matched your search

+28
View File
@@ -72,6 +72,34 @@ and each capability member present without its capability.
`contract.test.mjs` type-checks the contract under strict TypeScript, and
fails when `PORTS` and the types disagree on a single member.
## Moving code onto the contract
Two ratchet tests keep code that has moved onto the contract from drifting
back to Cesium. Both lists only ever shrink.
- `src/render/cesiumAllowList.json` lists the files outside the Cesium
adapter (`src/render/cesium/`) that may still import or be handed Cesium
(`src/render/noCesiumOutsideRender.test.mjs`). A file leaves the list
when it no longer drives Cesium at all; nothing is added.
- `src/render/viewerAccessAllowList.json` counts, per file off that list,
the Cesium-shaped accesses through the viewer it still makes
(`src/render/viewerAccess.test.mjs`): the viewer's `entities`,
`dataSources`, `scene`, `camera`, `clock`, `imageryLayers`,
`terrainProvider`, `trackedEntity` and `canvas`, and the scene's
`primitives`, `pick`, `drillPick`, `pickPosition`, `globe`, `preRender`,
`postRender`, `preUpdate`, `postUpdate`, `canvas`, `requestRender` and
`camera`, written plainly, with `?.`, in brackets or destructured.
`viewer.container` is a DOM element and does not count; reach the canvas
through `canvasOf(viewer)`. Comments and tests do not count.
`src/testSupport/viewerAccess.mjs` is the matcher.
A file may not make more accesses than recorded (a file not listed may
make none), and a count higher than the file now needs fails too. So a
file that leaves the Cesium list must port its viewer accesses in the
same change: it cannot be added to the count. After
porting accesses away, run `node scripts/viewer-access-baseline.mjs` (or
`--check` to see what it would change): it lowers counts and drops
entries, and never adds or raises one.
## The stub renderer
`createStubRenderer({ capabilities, viewport, time })` implements every port