mirror of
https://github.com/agent-substrate/substrate.git
synced 2026-11-11 10:23:17 +08:00
Phase 1 of #451, micro-VM only. gVisor support will follow in a separate PR. ## What Adds a `snapshotsConfig.onResume` block to the ActorTemplate, selecting per snapshot situation what supplies the guest state at resume: each field names what is being resumed *from*, the value names the boot source. `onPause`/`onCommit` remain pure capture scopes (`Full | Data`), and the `ActorSnapshot` records plain `Full`/`Data` content; the golden-combine is strictly a restore-time behavior. ```yaml snapshotsConfig: onPause: Data onCommit: Data onResume: fromData: Golden # ColdBoot (default) | Golden — Data snapshots resume as location: gs://… # golden memory + fs delta with the actor's data layered on ``` Under `fromData: Golden`, a data-only restore combines the template's **golden snapshot** (guest memory + full fs delta) with the actor's captured durable data — the actor comes back with the golden's warm state over its own data instead of cold-booting. `fromData` applies to every resume of a Data snapshot — commit or pause checkpoint. Future situations (e.g. resuming a Full snapshot across a template upgrade, #477) get sibling fields under `onResume` rather than overloading this one. ## How - **CRD** (`pkg/api/v1alpha1`): new `OnResumeConfig`/`ResumeSource` types; `fromData: Golden` is CEL-gated to `sandboxClass: microvm`. - **Control plane** (`ateapi`): resume derives the behavior from the template's `onResume` configuration — for a Data durable snapshot or a Data pause checkpoint it resolves the golden snapshot's location and sends the restore-only `DATA_ON_GOLDEN` wire scope, failing early (with an actionable error) if the golden snapshot is missing or not Full. Golden actors always commit `Full` regardless of `onCommit` — their snapshot is the base the combine needs. - **Wire APIs** (`ateletpb`/`ateompb`): restore-only `SNAPSHOT_SCOPE_DATA_ON_GOLDEN`, rejected on checkpoints; `golden_snapshot_uri_prefix` is a top-level `RestoreRequest` field because the actor's snapshot may be a local pause checkpoint while the golden snapshot is always external. - **atelet**: stages a single combined folder — the actor's files (the durable-dir tar) win name collisions, the golden snapshot supplies the rest. External restores download both halves concurrently; local (pause) restores copy the actor's files from the local checkpoint dir while the golden's files download in parallel. The golden manifest's pinned sandbox binaries run the restored guest and are recorded on-node for later checkpoints. - **ateom-microvm**: `DATA_ON_GOLDEN` restores through the existing Full path — cloud-hypervisor relaunches from the golden's guest files while the durable virtio-fs share serves the actor's re-materialized data. gVisor rejects the scope (defense-in-depth behind the CRD gate). ## Testing - Unit: envtest CEL cases, converter tables, atelet request validation (checkpoint rejection, golden-URI rules incl. local+golden), combined-download test against a fake object store, resume-workflow golden-resolution cases for both the durable and pause paths. - e2e (`suites/demo`): OnGolden lifecycle cases for the commit path, the pause path, and a two-durable-volume variant (micro-VM lane only), asserting counters across pause/suspend and the recorded Data content scope. - Manually verified on a live GKE cluster: Data commit and Data pause both resume with the golden guest's memory over the actor's data, on different pods. 🤖 Generated with [Claude Code](https://claude.com/claude-code)