refactor(lab): move execution to Worker and manage replay and transfer lifecycles
This commit is contained in:
@@ -0,0 +1,160 @@
|
||||
# Worker LAB service
|
||||
|
||||
This deployment moves the existing LAB evidence readers, bounded visualization
|
||||
preparation and evaluation adapters off the operator. It preserves their API and
|
||||
viewer contracts. It does not add another scheduler, model-training orchestrator,
|
||||
or UI. New packaged LAB jobs keep using the installed-package Worker executor.
|
||||
|
||||
## Reproducible runtime
|
||||
|
||||
`Dockerfile` pins the Python base image by digest; `requirements.lock` pins Python
|
||||
artifacts and hashes. Build from the repository source, plugin SDK and `config`:
|
||||
copy `Dockerfile` and `requirements.lock` to a bounded build context containing
|
||||
`src/`, `packages/plugin-sdk/python/`, and `config/`. Seal a manifest of source
|
||||
paths, sizes and SHA-256 values; pass its identity as `NODEDC_SOURCE_TREE_SHA256`.
|
||||
Use the resulting immutable image digest in Compose, not a mutable `latest` tag.
|
||||
The image has no models, private evidence, host credential or Docker socket.
|
||||
|
||||
Configure these deployment bindings, separately from artifact identities:
|
||||
|
||||
| Variable | Meaning |
|
||||
| --- | --- |
|
||||
| `LAB_IMAGE` | Built `sha256:…` image identity |
|
||||
| `LAB_RUNTIME` | Existing portable Worker LAB directory, mounted at `/lab` |
|
||||
| `LAB_ARCHIVE` | Dedicated LAB archive volume, `/lab-archive` |
|
||||
| `LAB_AI_JOBS` | Admitted AI executor jobs/sources volume, `/ai-jobs` |
|
||||
| `LAB_TGS_JOBS` | Admitted TGS executor volume, `/tgs-jobs` |
|
||||
| `LAB_CONFIGURATION` | That release's verified `config/`, mounted read-only at `/lab/config` |
|
||||
| `LAB_TOKEN_FILE` | Private bearer credential file, mounted read-only |
|
||||
| `LAB_FFMPEG_ROOT` | Sealed Linux FFmpeg/FFprobe asset tree with `bin/ffmpeg` and `bin/ffprobe` |
|
||||
| `LAB_PORT` | Host loopback port, default 19087 |
|
||||
|
||||
The existing deployment uses the independently verified FFmpeg 7.0.2 asset.
|
||||
Validate its tree manifest/digests before binding it. It is an external portable
|
||||
runtime asset, not an implicit host-installed executable. Requalification on a
|
||||
new CPU/OS requires the matching Linux image/asset architecture.
|
||||
|
||||
Run `docker compose -f compose.yaml up -d --pull never` with those bindings.
|
||||
The service is `ndc-laboratory-evidence` in project `ndc-laboratory`. It runs with a
|
||||
read-only root, 2 CPU / 4 GiB / 128 PID limits, a 512 MiB tmpfs, dropped
|
||||
capabilities and rotating logs. It is reachable only on host loopback; the token
|
||||
is required for health and API calls. Never publish the bearer token in command
|
||||
arguments or logs. Persist its host file with owner-only access.
|
||||
|
||||
## Volume and migration
|
||||
|
||||
The existing immutable archive is **not** the mutable working volume. Explicit
|
||||
one-time materialization uses:
|
||||
|
||||
```
|
||||
python -m k1link.laboratory.materialize_archive --archive /archive --target /lab
|
||||
```
|
||||
|
||||
Run only as Worker with the archive read-only and the intended LAB volume writable.
|
||||
The module verifies every file and seals `state/materialization.json`. Existing
|
||||
conflicting files stop migration; they are not overwritten. Resume is by verified
|
||||
content. The volume remains separate from both source releases and image layers.
|
||||
For legacy catalogs ordered by mtime, preserve the reviewed original directory
|
||||
metadata separately; hash-valid contents alone do not preserve result ordering.
|
||||
|
||||
Recorded camera preparation uses the existing Worker source CAS, never a Core
|
||||
fallback. `materialize_recorded_sources` accepts a digest-bound import manifest,
|
||||
checks source members and prepared-media timelines, and publishes bindings only
|
||||
after validation. Replacing bindings requires the previous digest. Original
|
||||
camera archives and accepted operator recordings stay preserved. Ready canonical
|
||||
RRDs are indexed by `recorded-sources/canonical-recordings.json` and verified before
|
||||
use. Host filesystem paths are deployment bindings, not source identities.
|
||||
|
||||
The legacy evidence volume layout retains `.runtime/compute-*` paths to reuse
|
||||
validated readers. They are under **Worker `/lab`**, not the operator checkout.
|
||||
Generated viewing products go to `/lab/presentation`; manual annotations have
|
||||
separate provenance. No automatic age-based deletion is admitted.
|
||||
|
||||
## Operator connection
|
||||
|
||||
Core reads `.runtime/mission-core/laboratory-worker-gateway.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"schema_version": "missioncore.laboratory-worker-gateway/v1",
|
||||
"base_url": "http://127.0.0.1:19087",
|
||||
"token_file": "laboratory-worker.token"
|
||||
}
|
||||
```
|
||||
|
||||
Keep the credential separate (mode 0600 on POSIX). For a remote Worker use the
|
||||
existing authenticated SSH alias with a loopback-only forward, or a verified
|
||||
HTTPS endpoint. Plain remote HTTP, redirects and proxy-environment substitution
|
||||
are rejected. The Mac managed SSH link uses `com.nodedc.mission-core.laboratory-worker-link`
|
||||
with bounded logging and automatic reconnect; it does not change VPN/routes.
|
||||
`install_operator_link.py` writes this versioned binding on macOS. It refuses to
|
||||
overwrite a different existing definition. Other platforms can provide the same
|
||||
loopback transport with their service manager; macOS launchd is not baked into
|
||||
the Worker image.
|
||||
|
||||
Core forwards LAB/LiDAR requests and the perception recording/media endpoints.
|
||||
Transport limits: 8 concurrent requests, 8 MiB request body, 2 GiB response,
|
||||
5-second connect timeout, 60-second read timeout (360 for bounded RRD preparation).
|
||||
Range, ETag, compressed points and Rerun headers are preserved. No automatic retry
|
||||
of writes and no staging of whole responses on Core. Worker unavailable means
|
||||
503; never run a local reader/model as fallback.
|
||||
|
||||
## Acceptance, rollback and lifecycle
|
||||
|
||||
1. Verify ownership, immutable archive, camera and supplemental evidence receipts.
|
||||
2. Start the exact image; authenticate `/health`; compare existing catalog choices.
|
||||
3. Run `verify_runtime.py` inside the installed container. Its tiny synthetic
|
||||
clips verify that 20 selected frames stay 20 with correct Rerun timestamps.
|
||||
4. Verify real camera frames, segmentation video ranges, full RRD transfer and
|
||||
3D timeline chunks (start/middle/end). Inspect Play/seek in the existing UI.
|
||||
5. Switch only the canonical Core service. Preserve its data and UI; never start
|
||||
an alternate Core on another port.
|
||||
6. Retire only archived local working files whose current hashes still match,
|
||||
after the previous local process has stopped. Leave changed/unknown files and
|
||||
all scans/maps/captures/accepted operator recordings. Record actual freed disk.
|
||||
|
||||
Rollback selects the previous verified service image/configuration on the same
|
||||
volume. Do not rollback or overwrite annotations, sources or accepted results.
|
||||
Keep one verified rollback release; retire only this deployment's superseded
|
||||
build contexts/images after no container or active task uses them. Never use a
|
||||
global Docker prune. The archive can restore explicitly selected files if needed.
|
||||
|
||||
The 128 GiB restore-admission budget and 40 GiB free reserve are not a hard volume
|
||||
quota. Existing per-product cache publication budgets apply; exhaustion refuses
|
||||
new copies rather than evicting recovery data. Active jobs and unknown ownership
|
||||
block cleanup. Long-term retained experiment growth still requires explicit
|
||||
retention decisions on Worker. The operator must not become the spillover disk.
|
||||
|
||||
## Explicit user deletion
|
||||
|
||||
The authenticated `POST /api/v1/laboratory/data-deletions` accepts only opaque
|
||||
`owner_ids`. `MISSIONCORE_LAB_DELETION_ROOTS` is supplied by Compose, mapping
|
||||
`lab`, `archive`, `ai`, `tgs` to bound volumes. All bindings must be present.
|
||||
It inventories only admitted producer layouts, protects references shared with
|
||||
retained owners, validates paths and deletes owned files. Failed operations are
|
||||
retryable; receipts in `/lab/state/data-ownership` contain identities/status.
|
||||
`/lab-archive/deleted-members.json` prevents legacy restore from resurrecting
|
||||
explicitly deleted results. These are bounded metadata, not retained LAB bytes.
|
||||
|
||||
The archive mount is writable only because this service now owns explicit LAB
|
||||
destruction. There is no age-based archive purge. Generic runtime roots, source
|
||||
CAS, images, plugins and unrelated datasets are outside the deletion bindings.
|
||||
The low-disk reserve must not block authorized cleanup itself. Requalification
|
||||
must cover shared content, interrupted deletion and actual playback of keepers.
|
||||
|
||||
|
||||
## Retiring the fixed LAB V1 agent
|
||||
|
||||
`retire_fixed_lab_v1.ps1` is the reviewed one-time migration for the standalone
|
||||
EoMT+DDRNet agent. Core must first remove its setup from admission and verify that
|
||||
no old job is active. The script checks the exact predecessor container ID/image,
|
||||
current modular/TGS agents and absence of a separate scheduled legacy launcher.
|
||||
It persists a retirement receipt under the supplied runtime root before removal.
|
||||
It never prunes images, mounts, models, environments or experiment data.
|
||||
|
||||
Applied on Worker 006 on 8 November 2026. Do not rerun the predecessor migration
|
||||
against another container. The active modular builder reads shared model assets
|
||||
from `k1link.observatory.modular_model_assets`; its legacy promotion CLI is retired.
|
||||
Rollback of compute admission requires a deliberate versioned registry/runtime
|
||||
change; do not launch the frozen compatibility fixtures as current configuration.
|
||||
See `outputs/lab-retirement-transport-20261108/REPORT.md` for IDs and evidence.
|
||||
Reference in New Issue
Block a user