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
@@ -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.