diff --git a/apps/control-station/package-lock.json b/apps/control-station/package-lock.json index ea5a510c..f1d50d4a 100644 --- a/apps/control-station/package-lock.json +++ b/apps/control-station/package-lock.json @@ -42,9 +42,9 @@ }, "../../../NODEDC_DESIGN_GUIDELINE/packages/map-cesium-react": { "name": "@nodedc/map-cesium-react", - "version": "0.1.1", + "version": "0.1.2", "dependencies": { - "cesium": "1.143.0" + "cesium": "1.147.0" }, "devDependencies": { "@types/react": "^19.1.0", diff --git a/apps/control-station/vite.config.ts b/apps/control-station/vite.config.ts index bc67c14e..62c93190 100644 --- a/apps/control-station/vite.config.ts +++ b/apps/control-station/vite.config.ts @@ -1,4 +1,4 @@ -import { createReadStream, cpSync, existsSync, statSync } from "node:fs"; +import { createReadStream, cpSync, existsSync, readFileSync, statSync } from "node:fs"; import { createRequire } from "node:module"; import { dirname, resolve, sep } from "node:path"; import { fileURLToPath } from "node:url"; @@ -9,6 +9,8 @@ import wasm from "vite-plugin-wasm"; const mapAdapterEntry = fileURLToPath(import.meta.resolve("@nodedc/map-cesium-react")); const cesiumPackageJson = createRequire(mapAdapterEntry).resolve("cesium/package.json"); +const cesiumRuntimeVersion = JSON.parse(readFileSync(cesiumPackageJson, "utf8")).version as string; +const cesiumAssetBase = `/cesium/${cesiumRuntimeVersion}`; const cesiumBuildRoot = resolve( dirname(cesiumPackageJson), "Build", @@ -21,11 +23,11 @@ function cesiumRuntimeAssets(): Plugin { name: "mission-core-cesium-runtime-assets", config: () => ({ define: { - CESIUM_BASE_URL: JSON.stringify("/cesium"), + CESIUM_BASE_URL: JSON.stringify(cesiumAssetBase), }, }), configureServer(server) { - server.middlewares.use("/cesium", (request, response, next) => { + server.middlewares.use(cesiumAssetBase, (request, response, next) => { const pathname = new URL(request.url ?? "/", "http://localhost").pathname; const target = resolve(cesiumBuildRoot, `.${decodeURIComponent(pathname)}`); if (!target.startsWith(`${cesiumBuildRoot}${sep}`) || !existsSync(target)) { @@ -54,6 +56,7 @@ function cesiumRuntimeAssets(): Plugin { process.cwd(), typeof options.dir === "string" ? options.dir : "dist", "cesium", + cesiumRuntimeVersion, ); cesiumRuntimeDirectories.forEach((directory) => { cpSync( diff --git a/docs/BIM_MODULE.md b/docs/BIM_MODULE.md index 2b31668a..f530749b 100644 --- a/docs/BIM_MODULE.md +++ b/docs/BIM_MODULE.md @@ -5,9 +5,11 @@ Portable client **0.2.47**, host **0.2.15**, Worker unchanged **0.2.12**. Exact source identities and artifact hashes are in `vendor/bim/*release.json`. The map Layers menu now selects **Libre / Cesium**. Cesium uses the existing -`@nodedc/map-cesium-react` adapter (0.1.1), CesiumJS **1.143.0**, runtime BFF and +`@nodedc/map-cesium-react` adapter (0.1.2), CesiumJS **1.147.0**, runtime BFF and Map Gateway. Terrain, imagery and buildings retain their existing server/cache ownership. No browser credentials, separate Viewer service or new cache. +The 1.143 → 1.147 upgrade, cache-byte verification and exercised runtime rollback +are recorded in [CESIUM_UPGRADE.md](CESIUM_UPGRADE.md). All configured project markers remain available. Multiple nearby ready BIM previews are admitted by distance and memory budgets, independently of catalog diff --git a/docs/CESIUM_UPGRADE.md b/docs/CESIUM_UPGRADE.md new file mode 100644 index 00000000..1487842e --- /dev/null +++ b/docs/CESIUM_UPGRADE.md @@ -0,0 +1,181 @@ +# Cesium upgrade and cache-preserving rollback + +## Delivered on 16 November 2026 + +The canonical Mission Core service on `127.0.0.1:8000` now uses **CesiumJS +1.147.0**, supplied by Design Guideline `@nodedc/map-cesium-react` **0.1.2**. +The prior release was CesiumJS 1.143.0 / adapter 0.1.1. BIM client 0.2.47, +host 0.2.15 and Worker 0.2.12 did not require new distributions. + +Latest stable was checked against the official +[release history](https://github.com/CesiumGS/cesium/releases), +[1.147 package](https://raw.githubusercontent.com/CesiumGS/cesium/1.147/package.json) +and [changelog](https://raw.githubusercontent.com/CesiumGS/cesium/1.147/CHANGES.md). +It was released on 2 November 2026. Pin the exact version; do not resolve a future +release implicitly when reproducing this delivery. + +Only the shared client dependency, matching BFF version declaration, runtime +asset paths, tests and documentation changed. The NAS Gateway was **not deployed +or reconfigured**. Updating the DG catalog diagnostic in source does not establish +that the separately deployed Foundry application has upgraded. + +## Preserve this boundary + +```text +Mission Core / BIM map + -> /api/v1/map/runtime-config + -> /api/v1/map/gateway/ion/assets/{id}/endpoint + -> /api/v1/map/gateway/cache?url=... + -> existing Map Gateway on Synology + -> existing persistent TileCache / upstream on a real miss +``` + +At acceptance the Core internal Gateway URL was `http://127.0.0.1:18103`, an +existing SSH tunnel to DC_1221RP (`100.109.216.21:18103`). The operator identity, +asset allowlist (terrain 1, imagery 2, buildings 96188) and credential boundary +are unchanged. Credentials remain server-side. + +Live cache host path: +`/volume1/docker/nodedc-platform/map-gateway/live-tile-cache`, mounted at +`/var/lib/nodedc-map-live-cache`. The sibling offline snapshot is read-only and +reported zero entries at this acceptance. The live cache reports persistence, +append-only/no-eviction writes and a 20 GiB quota. These are Gateway/runtime +observations and the existing deployment contract; root-level NAS filesystem +inventory was not available to the operator account. + +The index remains v1. Objects retain their content-key paths. Credential-free +canonical URL hashing, sorted query parameters, Bing host normalization and +removal of client revision/cache-intent parameters remain Gateway responsibilities. +Do not inject a Cesium version into tile URLs, replace provider revisions, change +mounts, delete the index or switch to an empty cache to make an upgrade appear +healthy. A changed resource URL must first be compared with its previous +canonical identity. Fix the binding or roll back the client before considering +any separate data migration. + +Client **code assets** now use `/cesium/1.147.0/{Workers,Assets,Widgets,ThirdParty}`. +This prevents a stale tab from mixing an old JS bundle with new workers. It is +independent of tile identities. During this transition, the existing unversioned +1.143 assets and previous hashed frontend chunks were retained in the live dist +without overwriting new files. Only one previous generation is retained; retire +it after old tabs have reloaded and the rollback retention decision is made. + +## Pipeline used + +1. Record clean committed source baselines and inspect unrelated work in the + shared checkouts. Do not reset another task's changes or create a second Core. +2. Record BFF runtime configuration, Gateway health/counts and representative + cached metadata/binary hashes before changing the client. Check available disk + and active imports before restarting the canonical Core process. +3. Pin the previous built interface with a hash manifest. Keep the previous lock + files and version declaration. No tile archive, NAS snapshot or new cache is + required for this client-only rollback. +4. Update the shared adapter dependency and version contract together; refresh + exact lock files. Core continues importing this adapter. Review upstream API, + Resource/proxy behavior and Camera changes; do not introduce a second viewer. +5. Build/test DG, Core frontend and Map BFF; publish the matched frontend and + server declaration on the existing service. Retain previous code assets for + already-open tabs. Never interrupt active uploads to run a smoke test. +6. Check Libre/Cesium switching, existing terrain/imagery/buildings, project focus, + restored camera and the browser console. Compare warmed resource bytes and + Gateway counters; an ordinary cache miss may append data but is not a reason + to rebuild the cache. +7. Actually restore the old interface and BFF declaration, restart the same Core, + verify 1.143 from HTTP and render the map. Then reapply the matched 1.147 pair, + restart and verify again. This rehearsal was completed successfully. +8. Preserve the bounded rollback archive and compact evidence; remove only the + task's extracted duplicate builds/npm scratch. Commit only owned paths and + record current delivery, limitations and rollback in Ops. + +## Acceptance evidence + +Evidence directory (local, not a second checkout): +`.runtime/cesium-upgrade-20261116/`. + +- Initial Gateway cache: **72,624 entries / 1,694,493,925 bytes**. +- After normal missing-resource reads: **72,627 / 1,694,980,798 bytes**. + There was no reset or decrease. Further UI exploration can append more tiles. +- Six warmed resources before/after activation had identical SHA-256 values: + terrain `layer.json`, building `tileset.json`, child metadata, terrain binary, + building `.b3dm` and Bing imagery. The first four were already cached at the + initial probe; the last two were first warmed before client activation. +- During the controlled six-read comparison: egress **774 -> 774**, upstream + **774 -> 774**, misses **323 -> 323**, refreshes **0 -> 0**; hit +3 and stale-hit + +3. Responses were `live-cache-hit` / `live-cache-stale`. +- `cache-verification.json` retains exact public resource identities, hashes and + before/after counters. `rollback-runtime-verified.json` records the old runtime + declaration after the real rollback. The pinned manifest verifies old artifacts. +- Shared adapter: **12 tests**; Gateway/cache Resource contract: **2 tests**; + registry valid. Core frontend: **1,608 tests**, typecheck and production build; + focused Python Map checks passed. New tests exercise actual Cesium Resource + derived URLs, incompatible runtime rejection and Camera focus/persistence. +- UI rendered existing imagery, terrain and buildings. Libre/Cesium switching + and project focus were exercised. Both old and new runtime worker URLs returned + JavaScript successfully. A one-off too-close camera transition was observed; + controlled repeats on old and new versions both focused correctly. No proven + root cause or camera fix is claimed. + +Limits: no NAS-wide Internet interruption, expired-Ion-endpoint/new-session +offline test or complete filesystem hash inventory was performed. Warm cached +reads without additional egress are established; uncached coverage still requires +the upstream. At final UI verification all current projects had `map_product_id` +unset, so project markers were checked; ready BIM mesh placement acceptance +remains the earlier dated qualification in `docs/BIM_MODULE.md`, not a fresh +1.147 mesh rendering claim. Do not mark the separately deployed Foundry upgraded. + +## Rollback artifact and procedure + +Pinned directory: +`.runtime/cesium-upgrade-20261116/rollback-1.143.0/`. + +`control-station-dist.tar.gz` is **120,787,409 bytes** (about 121 MB), containing +the previous built `dist/`, with SHA-256: + +```text +5eae647f1e326936428851f9ae2cff8e53b711d928d67018fbe69cffb32bf049 +``` + +`manifest.json` contains hashes of the archive, old DG/Core locks, adapter +package and old `map_api.py`. This is a copy of client code, **not tile data**. +Keep it pinned until explicitly superseded by another qualified rollback. + +Source baselines already published before the upgrade: + +| Repository | Baseline | +| --- | --- | +| Mission Core | `a80e3a8ff53b6d351d05bd1381a2f8033de6a202` | +| Design Guideline | `f4e7369eeccc9745c30ddf6476810ddc1efd523d` | +| BIM Mod | `581666957ed3855906be34081f5ebdfe04307b1a` | + +For an immediate runtime rollback: + +1. Verify the archive hash against `manifest.json`; confirm there are no active + browser uploads before the managed Core restart. Record the current matched + version and retain its built dist temporarily for reapplication. +2. Extract the archive into a **new empty task scratch directory**, using safe + tar extraction. Rename the current `apps/control-station/dist` to a bounded + candidate path, then rename the extracted `dist` into that canonical location. + Do not overlay files from two bundles or touch `.runtime/mission-core` data. +3. Change only `CESIUM_RENDERER_VERSION` in `src/k1link/web/map_api.py` back to + `1.143.0`. Do not replace the entire source file if it has newer unrelated + changes. The built old frontend already contains the matched adapter. +4. Restart the existing managed service (operator Mac): + + ```sh + launchctl kickstart -k gui/$(id -u)/com.nodedc.mission-core.local + ``` + +5. Verify `/api/v1/map/runtime-config` reports 1.143.0; reload the map and verify + known cached imagery/terrain/buildings through the unchanged Gateway. A stale + incompatible tab must reload, not bypass the version check. +6. To reapply, restore the saved 1.147 dist, set the BFF declaration to 1.147.0, + restart the same service and repeat HTTP/UI checks. Retire extracted duplicate + directories only after verifying the pinned rollback archive remains intact. + +An archive rollback changes the served runtime only. Before a subsequent source +build, either reapply the matching source release or revert the **owned upgrade +commits** in DG/Core and reinstall their matching locks. Never reset the shared +checkouts wholesale. No rollback step modifies NAS cache mounts/index/objects, +provider metadata, project JSON, Worker sources or prepared BIM products. + +Ops records: [MISSIONCOR-100](https://ops.nodedc.ru/nodedc/browse/MISSIONCOR-100) +and [DCPLATFORM-61](https://ops.nodedc.ru/nodedc/browse/DCPLATFORM-61). diff --git a/src/k1link/web/map_api.py b/src/k1link/web/map_api.py index a837babe..d248a0dc 100644 --- a/src/k1link/web/map_api.py +++ b/src/k1link/web/map_api.py @@ -17,7 +17,7 @@ MAP_SANDBOX_HIDE_CREDITS_ENV: Final = "MISSIONCORE_MAP_SANDBOX_HIDE_CREDITS" MAP_SCHEMA_VERSION: Final = "missioncore.map-gateway/v1" MAP_RUNTIME_SCHEMA_VERSION: Final = "missioncore.map-runtime/v1" MAP_PAGE_VERSION: Final = "0.1.0" -CESIUM_RENDERER_VERSION: Final = "1.143.0" +CESIUM_RENDERER_VERSION: Final = "1.147.0" MAP_GATEWAY_SUBJECT: Final = "mission-core-loopback-operator" ALLOWED_ION_ASSET_IDS: Final = frozenset({1, 2, 96188}) SAFE_ERROR_CODE = re.compile(r"^[a-z][a-z0-9_]{0,95}$") diff --git a/tests/test_map_api.py b/tests/test_map_api.py index 649739aa..c20b7b9c 100644 --- a/tests/test_map_api.py +++ b/tests/test_map_api.py @@ -117,7 +117,7 @@ def test_runtime_config_exposes_only_same_origin_contract_and_hides_internal_ori lambda request: httpx.Response( 200, headers={"content-type": "application/json"}, - json={"ok": True, "rendererVersion": "1.143.0"}, + json={"ok": True, "rendererVersion": "1.147.0"}, ) ) router = build_map_router(service) @@ -130,7 +130,7 @@ def test_runtime_config_exposes_only_same_origin_contract_and_hides_internal_ori document = json.loads(_response_body(response)) assert document["schema_version"] == "missioncore.map-runtime/v1" assert document["map_page_version"] == "0.1.0" - assert document["renderer"] == {"id": "cesium", "version": "1.143.0"} + assert document["renderer"] == {"id": "cesium", "version": "1.147.0"} assert document["gateway"]["cache_proxy_prefix"].startswith("/api/v1/map/") assert document["assets"] == { "imagery": 2,