Files
NODEDC_MISSION_CORE/docs/STORAGE_RETENTION.md
T

21 KiB
Raw Blame History

Mission Core storage lifecycle

Policy revision: operator-storage-v2 (2026-10-16). Build-input policy remains two-closed-inputs-per-line-v1. This implements the storage boundaries in AGENTS.md and supplements the artifact policy. It applies only to the canonical operator checkout; other repositories, boards, Worker 006 and Docker storage are separate owners. No system-wide prune or periodic deletion timer is installed. Cache budgets run at publication; service journal rotation runs in the owning writer.

Classes and enforcement

Data Retention and mechanism
Source, configuration, secrets, .git, installed dependencies and active UI Not disposable storage. No generic age-based cleanup.
Imported Gaussian worlds, recordings, evidence, missions, plans, accepted maps, session map versions Durable application data. No TTL. Deletion belongs to the owning product workflow or an explicitly reviewed archive/removal operation.
Simulation qualifications, computation experiments/results, engineering materials Preserve unique evidence and the exact input/configuration/result relationship. An old experiment is not a cache. Archive only with a verified destination and complete dependency inventory.
Qualified releases and rollback artifacts Explicit pins; retain independently of the intermediate count. Retiring a release requires removing its pin by name and recording the reason.
Intermediate Linux build inputs Keep two most recently published, completed, unpinned inputs per line, plus every transitive base of retained inputs. Lines are node/node-only, node/node-core, x4/native, x4/package, x4/owner. Enforced by scripts/packaging/build_retention.py.
Active/disconnected builds, transfers and qualifications Persistent active hold, with owner token. No automatic expiry. Explicit terminal outcome releases the hold. Eight unfinished inputs per archive family block the next publication. Node profiles share this conservative unfinished limit.
Old or unknown inputs Protected as legacy-unreviewed; importing into the registry requires a named protective pin. Neither mtime nor lack of a reference proves that a legacy file is disposable.
General artifact gateway cache Existing LRU/pin implementation: default 8 GiB local quota and 2 GiB free-space reserve; pinned objects survive eviction. Configuration may override these defaults. Not handled by build retention.
Portable replay, integrated/canonical LAB overlays, editor scene assets Existing generations are protected. New publication has a per-owner quota and a 2 GiB free-space reserve; no automatic eviction or TTL. Cache hits and sealed recovery remain available at quota. See the limits below.
Worker source CAS and sealed modular-node results Separate Worker/result ownership. No new deletion or expiry; a source/result can be unique or required by a retained job. Existing source admission/free-space checks remain.
Vite unit-test cache Each server owns a unique .runtime/frontend-unit-tests directory and removes it on close or failed creation. Existing test helper enforces this; tests run sequentially. Abandoned crash files need a separate verified cleanup.
Python check caches scripts/check_python.py pytest/ruff/mypy creates one owned .runtime/python-checks temporary directory, disables persistent pytest/Ruff caches and redirects mypy there. Stop owned helper processes before cleanup, including failed checks. Four active/unreconciled check directories or a 512 MiB admission budget block the next check; 64 MiB of headroom is required before admission. Existing/foreign crash residue is preserved. Direct ad-hoc tool invocation is outside this managed entry point.
Compiler caches and other task scratch Disposable only with no active owner. Node Linux build jobs already place Go/npm state inside their owned build folder; remote staging is a separate lifecycle. Never purge shared toolchains, downloaded offline dependencies or another job’s directory.
Operator monitoring Live-only RAM: one latest snapshot per node, maximum 32 nodes, 192 KiB snapshot plus 32 KiB duplicate-comparison sample per node; 30-second expiry, one-second idle sweep and UTC daily reset. No local history database. UI/API use current observations only. Retire an obsolete replica only after live-mode acceptance with the scoped plan/apply tool; see operator monitoring.
Routine service logs Core, Observatory/Gaussian worker tunnels, telemetry startup/tunnel and Map Gateway link use rotating_process: 8 MiB × (current + 4 backups), at most 40 MiB per service. Legacy journals remain intact and stop growing after migration. Scanner diagnostics use 5 MiB + 5 backups with 16 KiB records and private files after rotation. Existing Docker logs remain local, 5 MiB × 2 per container. Experiment/build/mission calculation logs remain evidence and are excluded.

A 6 GiB build-input soft budget is reported, not used to override pins. A producer checks the uncompressed estimated payload plus ZIP overhead and leaves at least 2 GiB free before staging. Existing Linux/qualification-specific space checks still apply. If protected data consumes the budget, report it and stop creating more inputs when the free-space guard fails; do not delete evidence. The two-input rule is a count policy, not a promise of a total storage ceiling.

Build lifecycle

The four generators (Node Linux, X4 native, X4 package, X4 owner wrapper) publish through the same local helper. They write a uniquely owned temporary file, validate manifest identity and base hashes, then publish without replacing an existing path and persist the active hold. Their existing JSON response adds:

{"retention": {"path": "apps/node-agent/build/mission-core-node-linux-build-<id>.pyz", "owner": "<token>", "state": "active"}}

A failed writer removes only its own temporary file. A crash after publication but before registry commit leaves a protected unknown input. The helper is operator packaging code, not a new board/runtime dependency. Production inputs are not rebuilt just to exercise retention.

After the remote job and every dependent transfer/qualification actually end, the owning engineer/agent must close the hold using the returned path and owner:

.venv/bin/python scripts/packaging/build_retention.py finish "$input" \
  --owner "$owner" --outcome intermediate --reason "Build and transfer completed; no retained release uses this input" \
  > .runtime/build-retention/review-plan.json

Choose failed or cancelled only after the job has stopped. These inputs join the two-input history; failure does not silently delete diagnostic evidence. Choose qualified or rollback to close the active hold and add the named permanent pin. Add another named pin before a later qualification/release starts using an already completed input. Do not close someone else's active build. A disconnected job remains active until terminal state is established.

Review the returned plan (or generate a fresh one) and apply it as the final build-storage step; this is part of build completion, not a user-facing manual maintenance ritual. finish itself never deletes bytes.

.venv/bin/python scripts/packaging/build_retention.py plan \
  > .runtime/build-retention/review-plan.json
.venv/bin/python scripts/packaging/build_retention.py apply \
  --plan .runtime/build-retention/review-plan.json

On a never-initialized checkout, plan is read-only and does not create the control directory; save its output to an existing task-owned directory instead. An older plan is refused if a file, lifecycle state or pin changes. Review and regenerate it. Do not edit the plan to force deletion. A malformed package, missing/changed base, unexplained missing registered input, or unsafe path blocks all deletions in that operation.

Explicit legacy enrollment and release pinning:

.venv/bin/python scripts/packaging/build_retention.py adopt "$input" \
  --pin legacy-review --reason "Retained provenance; exact evidence record path"
.venv/bin/python scripts/packaging/build_retention.py pin "$input" \
  --pin release-0.1.3 --reason "Qualified release and its evidence record"
.venv/bin/python scripts/packaging/build_retention.py unpin "$input" \
  --pin legacy-review --reason "Reviewed as superseded intermediate; no release or rollback depends on it"

unpin is an explicit decision, not an automatic inference from time or a failed build log. All unknown inputs remain protected even without registry enrollment.

Integrity, interruption and audit

Only exact build-input filenames directly under apps/node-agent/build and plugins/insta360-x4/build are eligible. Installers, .deb releases, qualified subdirectories, rollback copies and runtime data are outside the allowlist. Symlinks and traversal paths are refused. Publications and maintenance share an OS file lock; generators cannot race an applied plan. External tools must use the same helper rather than mutating managed inputs in place.

The plan verifies full archive hashes, manifest IDs, profiles and dependency closure. Apply independently recomputes the plan under lock and checks each file again before unlink. Dependants are removed before their bases, so an interrupted operation does not strand a retained delta. Every unlink is journaled under .runtime/build-retention/receipts, including the planned identity, actual removed paths, status and free-space observations. There is no recursive directory delete.

An interrupted apply can be reconciled using the receipt basename:

.venv/bin/python scripts/packaging/build_retention.py recover "$receipt_basename"

Recovery only reconciles already journaled missing files; it performs no deletion. After reviewing the receipt, create a new plan for the remaining files. Receipts and lifecycle records are small engineering evidence, not raw telemetry; preserve them. A crash before an unlink is distinguishable from one after it by the file's presence and verified identity.

candidate_bytes_upper_bound is logical file size, not promised reclaimed space: hardlinks/APFS clones can share blocks. Receipts report filesystem free space before/after; concurrent system activity can affect that delta.

Acceptance

tests/test_build_retention.py covers separate lines, transitive bases, release and rollback pins, legacy protection, active owners and restart, stale/edited plans, unsafe paths, hash changes, publication failure, missing bases, capacity refusal, concurrent publication, partial deletion, crash recovery and hardlinks. It also executes all four real producer wrappers with tiny synthetic input fixtures. Existing delta reuse and artifact-cache tests remain applicable.

The initial live adoption preserves reviewed historical inputs and leaves new unreviewed inputs protected. No old source bundle is declared disposable merely because this policy has been installed.

Local derived-cache budgets

src/k1link/cache_budget.py provides one admission/publication lock across local processes, a full logical-byte inventory and a 2 GiB free-space reserve. Unknown files, existing generations, partial outputs and sidecars count against capacity. Symlink/special-file inventories are refused, never followed or deleted. Up to 10,000 files are admitted by default (4,096 for editor assets). Quotas are conservative logical sizes; hardlinks/APFS clones do not authorize deletion.

Cache owner Publication quota At capacity
Exact camera JPEG frames 256 MiB Return the validated decoded frame without a new disk copy; retained frames still work.
LiDAR validation proofs 16 MiB Validate the original normally; skip the optional proof write.
Prepared camera media sidecars 64 MiB Use the validated manifest in memory; skip the optional sidecar write.
Perception overlays 1 GiB Refuse a new cached generation; retain existing generations.
Calibrated fusion overlays 1 GiB Same.
Integrated perception overlays 4 GiB Same; reconstruct admission in memory if its optional sidecar cannot fit, so an existing sealed overlay remains usable.
Canonical LAB overlays + replay 4 GiB combined Reuse existing admitted output; refuse new publication when insufficient room.
Portable replay + camera proxies 4 GiB combined Same.
Editor scene assets 4 GiB Account for all declared, unfinished transfers before accepting a new manifest or chunk. Do not discard partial uploads or ready assets.

Larger renderers check room before work and again under the publication lock. The final check counts staged bytes already on disk, plus sidecar headroom. This bounds accumulated published copies; it is not an OS filesystem quota or a promise that transient renderer scratch never exceeds the publication budget. Existing bounded renderer inputs/outputs/timeouts and finally cleanup still apply. Crash residue is counted and protected, so it can stop further admission; its owner must be investigated before removal. No broad crash-directory sweep is enabled. A quota cannot both preserve arbitrary unique data and allow unlimited new copies; capacity refusal is intentional and explicit.

General artifact/recording caches retain their established LRU/pin contracts. No new automatic removal is applied to simulation worlds, source media, plans, accepted geometry, qualifications, results, offline dependencies or rollback. The earlier Vite SSR helper still owns/cleans each test cache and disables unnecessary dependency prebundling. Ordinary development sessions and external user commands are not silently enrolled into a global cleanup job.

Bounded service journals and migration

src/k1link/rotating_process.py supervises the exact existing command and drains merged stdout/stderr through a bounded binary writer. Rotation splits even a large single write, retains current + four backups and holds an exclusive lock. It does not copy/truncate a file concurrently written by a service. Binary bytes are preserved within the retention window. Signals reach the child; launchd continues to own the whole process group. If disk writes fail, the pipe is still drained with a bounded loss counter so logging cannot deadlock Core. A recovery marker reports dropped bytes when writing becomes possible again.

The outer uv run --no-sync --project uses the existing Mac execution boundary; no packages are synchronized. Its pre-Python bootstrap stdout/stderr goes to /dev/null; bootstrap failure is diagnosed through launchd exit status and the hash-gated rollback check. Child output, including Python exceptions, goes to *.managed.log. No credentials, SSH arguments, routes or Docker settings change.

The original command/environment/scheduling fields are preserved by scripts/manage_runtime_log_policy.py. Apply requires an exact current plan, saves the original plist under .runtime/storage-maintenance/log-policy, reloads one existing service and verifies Core health or stable helper state. Failed acceptance restores the exact previous declaration and checks it. Plans and receipts contain hashes and service metadata, never environment secrets.

.venv/bin/python scripts/manage_runtime_log_policy.py plan core > .runtime/core-log-plan.json
.venv/bin/python scripts/manage_runtime_log_policy.py apply core --plan .runtime/core-log-plan.json

Other explicit owners: observatory, gaussian, telemetry-startup, telemetry-tunnel, map. Existing journals are left byte-for-byte intact as a one-time legacy baseline; they are not added to the rotating set or compressed in place. Existing launch-agent generators emit the bounded writer declaration, so a subsequent normal update does not restore unbounded output. A fresh plan after installation is unchanged. No new long-running service besides each existing service's output supervisor is introduced.

Cache/log acceptance

Tests cover exact quotas, free-space reserve, protected unknown files, concurrent publication, unfinished editor reservations, optional camera-cache fallback, sealed-overlay recovery at capacity, bounded binary rotation across restart, exclusive writers, linked-path rejection, child exit/signal handling, private rotated diagnostics, stale migration refusal and exact rollback on failed health. The Python-check wrapper is tested on successful and failed child exits while preserving another job's directory. Live acceptance separately verifies all six declarations, Core/API/catalog health, unchanged existing-cache hashes and zero owned test-cache residue. No high-volume live log or renderer load test is run on the operator Mac.

Simulation experiment closeout — owner amendment 2026-10-19

The owner explicitly authorized retiring historical engineering frames, render arrays and simulation trial traces after detailed textual preservation. This supplements the evidence rule above; it does not remove protection from product state, input worlds, working source, offline dependencies, releases or rollback.

For future engineering-owned simulation/infrastructure trials, closeout is part of completing the experiment, not a later request for the owner to free disk:

  1. Before capture/export, declare the exact owned temporary directory, expected bytes and a finite capture limit. Check free space and reuse identical source/observations by identity instead of exporting another complete copy.
  2. Once all writers/remote owners are confirmed terminal, write the hypothesis, inputs/configuration/source identities, observed result, quality/time, failures and next decision. Preserve regression evidence and the small set of images referenced by the final report. A failed experiment also closes.
  3. Store exact textual material once per content hash; preserve the original path-to-hash index. Verify the archive by reading it before deleting originals.
  4. Review the exact file-level list, exclude sources/product data/releases and active or unknown owners, then unlink only unchanged disposable files. Journal removals and available space. No recursive age-based sweep.
  5. Link the archive from the report and relevant Ops card. State explicitly which original media is gone and requires rendering or running again.

The 2026-10-19 operation is recorded in outputs/SIMULATION_EXPERIMENT_ARCHIVE_2026-10-19/README.md, its plan, SHA-256 inventory, archive verification and deletion receipt. Its helper is a one-shot reviewed operation, not a scheduled garbage collector. Ad-hoc engineering scripts have no universal disk quota: they must implement the declared capture bound and perform closeout. Existing cache quotas and service-log rotation keep their separate writer-owned enforcement. This amendment does not claim that a filesystem-wide automatic limit or remote Worker cleanup has been installed.

Imported scan originals — owner amendment, 2026-11-07

For manual Gaussian LCC/LCC2 folder and ZIP/RAR/7z imports, Mission Core owns temporary transfer staging, not permanent original storage. An available Gaussian provider advertising durable-source/v1 is required before allocating an upload project. An outage mid-transfer preserves unfinished staging for retry. On complete transfer the provider verifies every admitted original by size and SHA-256, flushes the bytes and publishes an independent retention receipt. Core persists that receipt, freshly verifies remote hashes and its local hashes, journals verified → retiring → remote, and removes only the declared local source files. Interrupted retirement resumes using that persisted receipt. There is no low-disk exception that deletes an unverified archive.

Conversion then runs from Worker storage. Its failure, job cancellation or job removal does not remove retained originals. Retry uses the receipt; no full local fallback copy is created. Core keeps optimized SOG/LOD/collision artifacts, source identity/receipt, small optional trajectory metadata, and application edits. The user's original file outside the imported project's source directory is not part of staging and is never deleted by this workflow.

Older ready projects can be migrated with POST /api/v1/simulation-worlds/projects/{id}/source/retain. The endpoint verifies that the existing provider job includes every imported file, retains it, then retires staging without changing the world manifest, source bundle identity, viewer settings, artifacts or semantic map. Legacy archives are resolved through the matching Worker ingest record and their original upload descriptor; missing or mismatched ownership is refused. An old job ID alone never authorizes deletion.

Provider receipts and pins live in the existing persistent Gaussian data volume, independent of containers/jobs. Migration needs the entire volume, configuration, secrets and compatible executor, not just a Docker image. Provider address is a hint; receipt identity and hashes permit relocation to a different host. See the provider repository docs/SOURCE_RETENTION.md for its API and portability boundary. This supersedes local-original retention for this narrowly defined import flow; other recordings, unique evidence and application data remain protected above.