Files
NODEDC_MISSION_CORE/docs/CESIUM_SERVICES.md

187 lines
12 KiB
Markdown

# Cesium services and NAS outage routing
Implemented 2026-11-17. Cesium remains at 1.147.0. This change does not migrate,
reindex, clear or copy Synology tiles. Existing cache identity and upgrade rules
remain in [CESIUM_UPGRADE.md](CESIUM_UPGRADE.md).
## Operator surface
Profile → Settings → Services contains a service selector. Select **Cesium ion**
to reveal its connection mode and token field. Check access and Save are canonical
circular icon buttons at the top right of the service card. Saved credentials are
never filled back into the browser. Clear-token appears only when configured.
Product copy names the cache host **Сервер хранения локальных данных**; Synology is
an infrastructure detail. Persistent missing-token, last-route and saved-success
lines are intentionally absent. Explicit verification results and actionable
errors are retained. A canonical StatusBadge indicator precedes Cesium ion in the
selector: neutral for absent/unverified credentials, pulsing yellow while checking,
yellow for a failed check, green for confirmed asset permissions. Selecting Cesium
or saving credentials checks access automatically; details appear only after an
explicit Check access. The tooltip explains the state. This is token permission
status, not a claim that every provider tile is reachable.
This is installation-wide service configuration, not a per-map/project setting
or a hardware entry in System. The admitted composition uses Environment Settings,
SettingsCard, Select, TextField, Description, IconButton and registry icons. An
individual map settings panel was rejected because it would duplicate credentials
and leave Fleet, Observation Center and architectural maps with divergent routes.
The state grammar is: no service selected, loading, editable, checking/saving,
success, missing token, explicit safe error, revision conflict. No token means the
existing NAS route still works; it cannot enable the independent online route.
## Routing contract
All consumers retain the existing Core `/api/v1/map/gateway/*` URLs and endpoint
contract (`credentialMode: gateway`). `MapServiceRoutes` chooses the backend:
| Mode | Behavior |
| --- | --- |
| auto | Probe NAS, use it while reachable; otherwise use the original provider through Core. |
| direct | Use the original provider through Core, without the NAS cache. |
| gateway | Use NAS only; unavailable NAS remains an explicit error. |
NAS health has a two-second timeout and a single shared probe with a 15-second
cooldown. Successful NAS recovery returns subsequent requests to its existing
route. A transport failure opens the fallback cooldown. An upstream HTTP 502/503
falls back for that request without marking the cache server unavailable: warm
tiles must remain usable when only its internet exit is down. NAS 401, 403,
404 and 504 are preserved: these can represent authorization, absent data or an
offline-cache policy refusal, not a broken NAS connection. Existing tile URLs and
cache query parameters are forwarded unchanged. No administrative cache endpoint
is called. Response header `x-nodedc-map-route` identifies the chosen transport.
Direct transport resolves ion assets 1 (terrain), 2 (Bing imagery) and 96188
(buildings). Only metadata and short-lived credentials are retained in RAM.
Binary tiles stream to the browser; Core creates no persistent tile store and
returns `Cache-Control: no-store`. Range and HEAD requests remain supported.
Provider URLs are allowlisted and ion credentials are restricted to their asset
directory. Redirects are refused. Credentials stay on the server, including the
Bing query key; HTTPX provider URL logging is redacted.
Provider contract changes, unavailable assets and rejected credentials are
reported explicitly. This is not a fallback for private imported Gaussian
products: their existing local ready-product lifecycle is unchanged.
## Secret storage and activation
Core owns `data_dir/services/cesium-ion/settings.json` (0600 file, 0700 service
directory), outside Git and browser profile JSON. Writes use an atomic replace,
fsync and revision checks. Corrupt configuration fails closed instead of silently
replacing it with defaults. API reads expose only configuration status, not the
token. Mutations require a loopback caller and same-origin JSON requests.
The operator enters the token directly in the UI. Check access verifies the three
asset endpoint permissions. Saving a new token repeats this validation before
replacing a working token. It does not prove every tile can be downloaded. URL-
restricted ion tokens must permit the canonical operator origin
`http://127.0.0.1:8000/`, which Core sends as a fixed provider Referer.
The Core token supplies the independent online route for every Core map. Existing
NAS credentials remain owned by Map Gateway and are **not** remotely replaced by
this form. When NAS is available it uses its current credential/cache policy.
There is no dependency on Ops, SMB or Synology for reading/saving Core settings.
After a save, subsequent requests use the new policy. Observation maps with the
recovery hook are notified; an already failed map may need reopening/retry. Do
not forcibly remount an architectural editor with unsaved placement edits.
## Original token/outage acceptance · 17 November 2026
- 30 backend tests: old BFF contract, NAS outage/recovery, unchanged cache URLs,
concurrent single-probe behavior, credential redaction, path/host restrictions,
private storage, revision conflicts and same-origin API boundaries.
- Four focused frontend adapter/indicator tests, existing 1619 frontend tests, application
architecture checks, typecheck, Ruff, focused mypy and production build passed.
- Final selector/header-button adjustment passed the production build/typecheck
and typography gate; UI selection and saving were exercised on port 8000.
- With the real NAS off and no configured Core token, the real service returns
`cesium_token_required` promptly. The Settings UI is usable without NAS.
- The operator saved a valid token (revision 4). With NAS off, real health and
all three asset endpoints succeed via `direct`; terrain layer.json, Bing imagery
metadata and buildings tileset.json return 200. A quantized-mesh terrain tile
returns 200 (15,069 bytes). No test tile was retained on disk.
- UI acceptance confirms the green token indicator and existing local Gaussian
rendering. Full satellite rendering is **not accepted**: the Bing tile host
`ecn.t0.tiles.virtualearth.net` is unreachable from this Mac (direct HTTPS
reports `No route to host`; Core reports `cesium_provider_unavailable`, 503).
Metadata/token success does not establish satellite tile connectivity. No VPN,
DNS or route changes were made to bypass this failure.
- Real NAS recovery/cache reuse has not been tested while the owner's NAS is off.
## Real acceptance after token/NAS availability
1. Save a valid token; with NAS off, inspect imagery, terrain and buildings in
architectural maps and Observation Center. Confirm `x-nodedc-map-route: direct`
and absence of new Core tile storage.
2. Turn NAS on. Allow the 15-second probe cooldown to expire, then move the map.
Confirm `x-nodedc-map-route: gateway` and the existing NAS cache-hit headers.
3. Compare a bounded set of previously cached physical files and existing cache
counters before/after a repeat view; inspect only, do not request a refresh,
purge, import or full cache walk. Confirm a new area follows the NAS's existing
read-through write policy.
4. Disable NAS again and verify recovery with the same map open. No cache rebuild
is an acceptable substitute for diagnosing a routing regression.
## Rollback
Selecting **Сервер хранения локальных данных** disables the new direct transport without
altering cache contents or deleting the saved token. For a source rollback, revert
only the Cesium services changes (especially the `settings_path` wiring in
`web/app.py`), preserving unrelated work in shared files. `MapGatewayProxy`
without `settings_path` retains its previous NAS-only behavior. Never reset the
whole dirty checkout or touch NAS storage as part of this rollback.
## Selectable VPS transport · 17 November 2026
System → VPS can install and pair **Маршрутизация трафика** alongside the existing
services. Profile → Settings → Services → Cesium ion → Routing selects a connected
service or **Текущий маршрут**. The choice is installation-wide, shared by Fleet,
Observation Center and architectural maps. It does not change the machine's
default route, VPN, DNS or application URLs. The initial transport profile only
allows Cesium/Bing GET/HEAD; unrelated external services require their own scoped
profile and client integration.
The independent `egress_vps` package lives in `NODEDC_MISSION_CORE_ARNAVI-VPS`;
its operating contract is `docs/EGRESS_SERVICE.md` in that repository. Core stores
paired credentials in the private Fleet `egress.sqlite3`. TLS 1.3 and an exact
certificate fingerprint are checked before sending credentials. Provider and
relay credentials are separate. Binary responses stream without a Core/VPS tile
store. Disconnecting a route used by Cesium is guarded.
For direct mode the selected relay carries Core's provider requests. For NAS
cache mode the prepared Gateway adapter accepts a separately signed, short-lived
`nodedc.map-egress/v1` request binding. Cache lookup still precedes external fetch;
canonical URLs, keys and physical objects remain unchanged. Gateway deployment
and private signing-key provisioning are required before selecting this mode.
Missing signing material blocks activation even while NAS is offline, preventing
a route that works only until the cache server returns. The prepared adapter is
documented in `platform/services/map-gateway/EGRESS.md`.
**Live state:** routing service 0.1.0 is installed on McHost at port 19446 and
paired with the canonical Core on port 8000. The installer is published in the
Fleet catalog. The NAS adapter is prepared and tested but **not deployed**;
no delegation key has been provisioned. Cesium's selected route remains unchanged.
Real authenticated checks from McHost received CloudFront country-block 403 for
assets 1, 2 and 96188. Core reports `cesium_egress_region_denied`, rather than an
invalid-token error. An attempted save returns 422 and leaves both saved route
and revision unchanged. UI acceptance exercised the route selector, yellow
indicator and explicit per-asset errors, then discarded the draft selection.
The owner has no other VPS. A working external exit channel remains a prerequisite;
installing a relay on the same blocked public IP cannot supply it. No automatic
switch to an unqualified transport is allowed.
Validation: 24 VPS tests; 58 focused Core tests followed by 8 focused egress tests
after the stream-cleanup regression fix; 4 frontend Cesium tests, typography
gate, typecheck and production build. Gateway delegation tests and the existing
credential-boundary, live-cache-fallback and streaming-cache-fill smoke checks
passed. Live wrong relay credential returns 403, private target returns 400, and
wrong certificate pin is rejected. All five McHost services remain active; the
new unit reports zero restarts. These checks do not constitute live NAS-to-VPS or
successful Cesium tile acceptance.
Activation requires a reachable provider exit, real asset and representative
tile checks, then canonical Gateway plan/apply deployment and secret provisioning.
Recheck warm hits, a bounded cold fill, NAS outage/recovery and unchanged cache
objects. The current route remains the rollback until those checks pass.