Introducing a new way to review your PRs.

Read the announcement

arcboxlabs / arcbox

Run AI agents on real and isolated machines — own kernel, filesystem, and network — with <100ms boot. Local first, OCI compatible, pure Rust.

View on GitHub

32 documents · Updated Nov 6, 2026

docs / storage-recovery

Storage recovery

Storage recovery protects ArcBox workloads when the System VM's persistent data or metadata volume cannot safely accept writes. It combines guest health reports with startup checks, durable holds, preserved disk copies, offline diagnostics, limited repair, and final write verification before it admits workloads again. See Workload engine, Engine orchestration, Images and snapshots, Computer runtime, Guest agent integration, and VM lifecycle and backends for the surrounding systems.

Storage health

Storage health gives the host an early signal about the two persistent volumes. It is an observation, not a write test and not a replacement for startup readiness.

Guest volume observations

The guest agent checks that the expected data and metadata filesystems are mounted on the expected devices. It also reads their live mount mode, so a filesystem that changed to read-only after an error is visible even when the mount table still shows read-write flags. The agent sends changed observations and periodic heartbeats only while a host subscriber is present.

The host treats these states as follows:

ObservationMeaning for workloads
MOUNTED_READ_WRITEThe expected mount is present and currently writable. Future writes are not guaranteed.
READ_ONLYThe filesystem is present but writes are not available.
UNAVAILABLEThe expected volume is missing, unmounted, or mounted with the wrong device or filesystem.
NOT_CONFIGUREDThe optional metadata volume is not part of this guest layout.
Unspecified or missingThe host does not have enough evidence to classify a storage fault.

References: guest/…/storage_health.rs• L1-5 guest/…/storage_health.rs• L60-149 rpc/…/common.proto• L71-104

Health stream and admission

The daemon forwards the guest observations through the agent client and ties each snapshot to the current System VM generation. A stopped VM or a late frame from an older VM clears the usable observation, which prevents an old fault from blocking a new guest and prevents unknown state from being treated as writable.

The Docker boundary uses this information in two ways. A known read-only or unavailable required volume blocks storage-changing requests, while a missing observation does not invent a fault. An active recovery or durable recovery hold blocks mutations even when no current guest observation exists; read requests and control actions such as stop remain available so an operator can inspect or contain the workload.

References: app/…/storage_health.rs• L17-109 app/…/storage_health.rs• L7-47 app/…/storage_admission.rs• L14-86

Startup protection

Startup protection keeps a storage fault from becoming an unsafe automatic boot. The runtime distinguishes a normal VM startup error from a failure that the guest has linked to a required persistent volume.

Startup diagnosis

The runtime first checks whether a storage hold already exists. A held operation keeps the control plane available but does not recreate or start the System VM. This lets an operator inspect the saved recovery state and choose a new check or recovery action.

If the guest starts but the runtime cannot become ready, the runtime asks the guest for a fresh status. Only a READ_ONLY or UNAVAILABLE observation for the data or metadata volume creates storage protection. The status and the original startup error are saved in the recovery directory before the System VM is stopped.

References: app/…/runtime.rs• L1139-1177 app/…/startup.rs• L16-128

Durable storage holds

The hold is the safety boundary between an interrupted operation and a later boot. The runtime writes an operation record and a hold marker before it begins disk work. On restart, an incomplete record or a marker without a record becomes a failed, protected operation with an unknown outcome. The hold stays until a recovery operation has completed its final verification and committed its result.

This rule favors protection over automatic progress. A failed journal write, worker failure, cleanup failure, shutdown interruption, or verification failure keeps the storage reservation and leaves workloads stopped. The recovery status can be replayed after a client disconnect or daemon restart.

References: app/…/state.rs• L34-153 app/…/owner.rs• L11-85 app/…/storage_recovery.rs• L131-157

Recovery operation

The explicit recovery operation owns the System VM storage while it runs. Both CHECK_ONLY and RECOVER stop workloads and preserve the paired data and metadata disks before they inspect them.

Recovery stages

The recovery flow turns the live disk pair into preserved evidence, checks that evidence in an isolated guest, and only then decides whether the original pair may be admitted again.

flowchart TD
    A[Storage fault or operator request] --> B[Stop workloads and System VM]
    B --> C[Preserve data disk, metadata disk, and manifest]
    C --> D[Offline check in disposable recovery guest]
    D -->|Failure| E[Save diagnostics and keep hold]
    D -->|Only stale data free-space tree| F[Repair a writable data copy]
    F --> G[Install repaired data copy]
    D -->|Passed| H[Rebind paired disks]
    G --> H
    H -->|CHECK_ONLY| I[Report complete with VM stopped and hold kept]
    H -->|RECOVER| J[Restart System VM]
    J --> K[Verify durable writes and Docker lifecycle]
    K -->|Passed| L[Remove hold and admit workloads]
    K -->|Failed| E

The recovery guest receives preserved copies rather than the live disks. Its check action reports one result for each required volume. Cleanup of the disposable guest must also succeed; a check result without confirmed cleanup is not a safe terminal outcome.

References: app/…/storage_recovery.rs• L53-128 app/…/storage_recovery.rs• L160-283 app/…/guest.rs• L37-137

Preserved disk state

Preservation includes both persistent images and the storage manifest that describes their pairing. The original images remain available as evidence even if a later repair replaces the live data image. The repair path makes a new writable copy, leaves the preserved copy unchanged, and installs the repaired result only after the repair guest passes its checks.

The engine rebuilds or replaces the System VM record when needed so the recovery guest can boot the current recovery environment. It does not format missing or unverified storage, and it keeps an existing record when boot assets cannot be verified but the record is still needed to inspect the disks.

References: app/…/preserve.rs• L7-90 engine/…/storage.rs• L7-54 guest/…/storage_volume.rs• L11-63

Repairable findings

Recovery repairs only one known, narrow case: the data volume has stale Btrfs free-space tree entries and the metadata volume passes. Any other finding remains a failure because the system cannot prove that a controlled repair is safe.

For this finding, the recovery guest checks the copied data image, rebuilds its free-space tree on another copy, and requires a clean read-only check before installation. A metadata fault, an unknown finding, or a failed repair leaves the original pair protected and records the check details for inspection.

References: app/…/guest.rs• L23-30 app/…/guest.rs• L140-159 rpc/…/agent.proto• L762-795

Runtime verification

CHECK_ONLY ends after the offline checks and keeps the System VM stopped. It answers whether the preserved pair can pass inspection without claiming that the runtime is safe to use.

RECOVER continues only after the checks pass. It restarts the System VM, waits for the guest runtime, writes and syncs a temporary probe on the persistent storage, and checks a Docker container lifecycle. The probe removes only the file it created. A pass clears the hold; any uncertain result stops the unverified runtime and restores the hold before another boot can race the outcome.

References: app/…/storage_recovery.rs• L200-283 app/…/guest.rs• L161-204 guest/…/storage_probe.rs• L7-45

Recovery interface

The recovery interface exposes one operation with streamed progress and a durable last result. This separates the client connection from the daemon-owned work, so a disconnected client does not cancel an operation and a later client can inspect its outcome.

Progress stream

The System service accepts CHECK_ONLY or RECOVER and streams the phases STOPPING, PRESERVING, CHECKING, RESTARTING, VERIFYING, and a terminal COMPLETE or FAILED. Each update carries an operation ID, a human-readable message, the recovery directory, and the current storage protection state.

The CLI reports a success only for COMPLETE. If the stream ends early, it reports an unknown outcome and directs the operator to inspect storage status instead of guessing that the operation failed or passed.

References: app/…/system.rs• L243-290 app/…/recovery.rs• L7-54 rpc/…/api.proto• L1143-1175

Diagnostic records

The recovery directory keeps the evidence needed to understand the decision. Startup failures save the guest runtime status, offline checks save per-volume results, repair saves its own report, and final verification saves the write and container checks. These records remain useful after the operation reaches FAILED or after the daemon restarts.

References: app/…/startup.rs• L86-112 app/…/guest.rs• L249-270 tests/…/storage_recovery.rs• L129-166

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the guest volume states, host admission rules, and startup fault classification aligned. A new state must not silently become writable or protected by only one layer.
  • Keep the storage hold, recovery journal, and System VM storage reservation as one commit boundary. A path that removes one without the others can reopen admission with an unverified pair.
  • Keep the storage-check actions aligned across the public API, agent protocol, recovery guest, and host verdict logic. In particular, repair must continue to target a copy rather than the live data image.
  • Keep progress phase publication and terminal handling aligned across the runtime, System service stream, CLI, and reconnect status. A new phase that is not streamed can make clients wait forever or report an unknown result.
  • Keep health observations fenced to the current VM generation. Late frames from a stopped guest must not affect a newly started guest.

Important failure modes

TriggerConsequenceGuard
Recovery is interrupted after it startsThe next daemon could boot disks with an unknown resultDurable hold and journal replay mark the operation failed and keep storage protected
A required volume reports read-only or unavailable during runtime startupWorkloads could start against storage that cannot persist writesFresh guest status is saved, the System VM is stopped, and the hold remains
Offline check finds a metadata fault or an unknown data faultAutomatic repair could worsen or hide filesystem damageOnly the classified stale data free-space tree case is repairable
Final write or Docker verification failsThe guest may be running without proven durable storageThe runtime reinstates the hold, stops the unverified System VM, and reports failure
A client disconnects during recoveryThe operator may mistake a lost stream for a failed operationThe daemon owns the worker and persists progress for replay

Key files

FileWhy to read it
app/…/storage_recovery.rsMain operation flow, protection rules, phase changes, restart, and final commit
app/…/guest.rsDisposable recovery guest checks, repair verdicts, and runtime verification
app/…/preserve.rsPreserved pair and copy-based repair boundary
app/…/state.rsDurable status, hold replay, and progress delivery
app/…/startup.rsStartup fault diagnosis and saved diagnostics
guest/…/storage_health.rsGuest view of volume mount state and health watch
engine/…/storage_check.rsHost-to-recovery-guest check contract and cancellation behavior
app/…/storage_admission.rsStorage-aware Docker request admission
app/…/system.rsPublic streamed recovery operation
tests/…/storage_recovery.rsEnd-to-end contract for holds, restart recovery, repair boundaries, and diagnostics