feat(core): persist viewer state and integrate Cesium services and profiles

This commit is contained in:
DCCONSTRUCTIONS
2026-11-17 17:20:15 +03:00
parent 9cbdd4ea5c
commit 29ef038a43
52 changed files with 2943 additions and 72 deletions
+8
View File
@@ -544,6 +544,14 @@ buttons share individual Glass V4, with no common capsule. Tree rows have both
visibility eyes and plain `i` actions. Visibility applies to complete IFC
subtrees without repeating a spatial traversal for each already known ID.
2026-11-17 visibility persistence: client 0.2.74 / host 0.2.30 stores sparse
`viewer.hidden_nodes` in the per-project workspace. Project/category/product/IFC
branch eyes are independent masks; turning a parent back on preserves children.
Absent/null masks migrate legacy `hidden_layers`; explicit `[]` means all gates
open. Eye intent writes before React unmount and is reapplied as models load.
Temporary isolation does not overwrite the saved choices. Previously unsaved
IFC choices cannot be reconstructed. Acceptance: `outputs/view-visibility-20261117/RESULT.md`.
Navigation Cube settings include face/edge colors and independent transparency,
text and hover colors; selection color is configurable. Host 0.1.4 validates and
merges nested preferences, preserving new fields when old clients save.
+186
View File
@@ -0,0 +1,186 @@
# 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.
@@ -17,6 +17,68 @@ Do not start a second backend on another port. Do not use
`launchctl kickstart -k` for this service: it combines termination and restart
without proving that the old process group has released the singleton lease.
## Local HTTPS operator address
The operator-facing alias is `https://nodedc.missioncore`. The canonical
application remains the single backend on `127.0.0.1:8000`; no second Core
process is launched and Worker/provider routes keep their existing endpoints.
The macOS-only installer is `scripts/local_https/install.py`. It uses the
system Apache, a loopback-only listener on ports 80/443, one hosts entry and a
single-host SSL leaf certificate. Administrator authorization is required.
The single-host certificate is trusted for SSL in the operator login keychain
and cannot sign other certificates. It expires after 365 days. `receipt.json` records
its exact validity/fingerprint. Renewal needs explicit administrator action;
the installer refuses to silently replace a certificate nearing expiry.
After the administrator installer prepares the certificate, configure trust
from the operator login session (macOS may show its authorization dialog):
```bash
security add-trusted-cert -r trustRoot -p ssl \
-k "$HOME/Library/Keychains/login.keychain-db" \
"/Library/Application Support/NODE.DC/MissionCoreHTTPS/server.crt"
```
Do not add a policy-string (`-s`) constraint: native certificate verification
accepted it, but curl and Chromium rejected that trust record during qualification.
The leaf itself has exactly one DNS SAN and `CA:FALSE`. Do not run the trust step
inside a background root AppleScript; macOS refuses the interactive authorization
there. The installed gateway's own acceptance pins the certificate; final operator
acceptance must use the login trust store without `--cacert` or insecure flags.
Installed ownership:
- `/Library/Application Support/NODE.DC/MissionCoreHTTPS`: root-owned
configuration, private key, certificate and compact install receipt.
- `/Library/LaunchDaemons/com.nodedc.mission-core.https.plist`: durable
HTTPS gateway; Apache workers drop to `_www`.
- `/Library/Logs/NODE.DC/MissionCoreHTTPS`: bounded two-file 1 MiB error log.
- `/private/etc/hosts`: only the marked `nodedc.missioncore` loopback entry.
The gateway validates the public Host and Origin before mapping them to
Core's existing local boundary. It strips caller-supplied forwarding headers,
rejects foreign origins/cross-site API calls, streams uploads/responses, and
supports Range and WebSocket upgrades. It has no body-size cap or disk cache;
Core retains its own validation/quotas. HTTP redirects to HTTPS. The system
Apache build supports TLS 1.2; no weakened browser security flags are used.
Qualification: `python scripts/local_https/qualify.py` runs a small isolated
transport fixture, verifies forwarded-header stripping, host/origin rejection,
upload hash, Range, a WebSocket frame and redirect. It removes its exact
scratch/processes on exit. It never uploads production files or mutates Core.
Acceptance: `/usr/bin/curl --noproxy '*' https://nodedc.missioncore/api/health`
must pass without insecure flags, and a browser must report a secure context.
Do not restart Core to repair the HTTPS entry. Inspect only
`launchctl print system/com.nodedc.mission-core.https` and its bounded logs.
Rollback is limited to this gateway: boot out that exact system label, remove
its exact plist and marked hosts line, and remove trust for the exact certificate
fingerprint in the receipt. Keep the existing Core listener/data and unrelated
hosts/certificates intact. Never restore the complete hosts backup over later
changes. This alias is local to the configured Mac, not public DNS.
## Recovery contract
The installed LaunchAgent and application form one bounded recovery ladder:
@@ -0,0 +1,12 @@
# Observation view persistence
The operator's map camera/layer choices and selected rover model belong to Core presentation, not the vehicle's control authority. They use the existing scene profile store (`scene-profiles/<kind>/<owner hash>/meta.json`) with the vehicle ID as owner:
- `observation-map`: camera longitude/latitude/height/heading/pitch/roll and five layer visibility flags.
- `rover-view`: chosen model ID only.
The browser record is only a one-time migration input after an acknowledged empty profile read. Reopening waits for writes queued by the previous view. Atomic revisioned writes retain meta.previous.json; read errors cannot publish defaults. Browser cache clearing does not erase these profiles.
Tracker centering is automatic only when no camera has been saved or chosen. “Показать аппарат на карте” deliberately recenters. Renderer recovery uses the latest camera, not the mount-time value.
PlayCanvas scene materials, layout and its own camera remain in the separate existing `rover` profile. Arming and input ownership are never restored by either presentation profile.