mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #291] [MERGED] Decouple firecracker #322
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#322
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/291
Author: @RuoqingHe
Created: 9/15/2026
Status: ✅ Merged
Merged: 9/16/2026
Merged by: @yingdi-shan
Base:
main← Head:decouple-firecracker📝 Commits (3)
0b6f25arefactor(sandbox): decouple snapshot manifest from Firecracker0860af5refactor(sandbox): carry manifest on captured snapshot01db5darefactor(template): build templates on any sandbox backend📊 Changes
21 files changed (+254 additions, -164 deletions)
View changed files
📝
crates/e2e-tests/tests/snapshot_oss_e2e_test.rs(+3 -3)📝
src/orchestrator/tests.rs(+2 -2)📝
src/sandbox/backend.rs(+29 -15)📝
src/sandbox/firecracker/config.rs(+9 -0)📝
src/sandbox/firecracker/mod.rs(+1 -3)📝
src/sandbox/firecracker/sandbox.rs(+13 -38)📝
src/sandbox/manifest.rs(+60 -27)📝
src/sandbox/mock.rs(+15 -1)📝
src/sandbox/mod.rs(+5 -3)📝
src/snapshot/manager.rs(+5 -12)📝
src/snapshot/mock.rs(+5 -4)📝
src/snapshot/repository/backends/oss/repository.rs(+6 -6)📝
src/snapshot/repository/backends/oss/resolver.rs(+1 -1)📝
src/snapshot/repository/backends/posixfs/artifacts.rs(+3 -3)📝
src/snapshot/repository/backends/posixfs/backend.rs(+8 -7)📝
src/snapshot/repository/backends/posixfs/runtime.rs(+1 -1)📝
src/snapshot/repository/interfaces.rs(+2 -2)📝
src/snapshot/runtime_support.rs(+5 -5)📝
src/snapshot/types/snapshot.rs(+5 -5)📝
src/snapshot/types/version.rs(+14 -9)...and 1 more files
📄 Description
What
Move the snapshot manifest out of the
firecrackermodule and make the capturepath generic over the sandbox backend. Three commits: the manifest and its types
lose the
Firecrackerprefix and gain abackendfield;CapturedSandboxSnapshotcarries that manifest instead of an opaque payload the snapshot layer had to
downcast;
SnapshotRuntimeVersions::probeandrun_template_buildstop naming aconcrete VMM type.
No behavior changes for Firecracker beyond one new guard: a snapshot whose
manifest names another backend is now refused at config time instead of being
misread.
Why
Three places in the snapshot and template layers were written against
FirecrackerSandboxandFirecrackerSnapshotManifesteven though nothing aboutthem is Firecracker-specific.
SnapshotManager::publish_captureddowncast thecapture to a Firecracker type and returned
RepositoryError::Unsupportedforanything else, so a second backend could run a sandbox but never publish a
snapshot from it.
SnapshotRuntimeVersions::probereached intoFirecrackerSandboxfor the binary to version and the tools drive it was given,and
run_template_buildconstructed that type itself.This is the groundwork for a second VMM backend. Landing it on its own keeps that
change reviewable and keeps this one free of any new backend's code.
Scope and non-goals
Included — the manifest move and rename, the
backendfield, the capturepayload split, and the two generalizations in
probe/run_template_build.Excluded — any second backend. No new VMM, no config keys, no factory
selection, no changes under
src/bin/server.rsorsrc/cfg.rs.LINGCORE_BACKENDand the widened visibilities a second backend needs are deliberately left out and
belong with that backend.
Unrelated refactor, called out —
run_template_buildtook eight argumentsafter the generalization, which clippy rejects. The five that describe the build
now travel as
TemplateBuildInputsrather than an#[allow].Design and behavior changes
SandboxSnapshotManifestgainsbackend: String, carrying the name of the VMMthat wrote the capture.
FirecrackerSnapshotConfig::from_snapshotrefuses amanifest naming a different backend; previously such a manifest would have been
read as Firecracker's own.
CapturedSandboxSnapshotsplits into two parts: the manifest, which every backendproduces and
SnapshotManagerreads directly, and the artifacts a backend mustkeep alive until publication finishes, which stay
Box<dyn Any>. TheRepositoryError::Unsupportedbranch inpublish_captureddisappears — there isno longer a downcast that can fail.
FirecrackerCapturedSnapshotis deleted.SandboxBackendgainscapture_to_dir(&mut self, at: &Path), which captures intoa directory and leaves the guest held. The template build takes its snapshot
through it, so the build no longer needs the concrete type. Firecracker implements
it in terms of the existing
pause_to_dir, so the capture and recovery paths areunchanged.
Compatibility and operations
FirecrackerSnapshotManifest→
SandboxSnapshotManifest, the fourFirecracker*Artifacts→Snapshot*Artifacts,and
agentenv::sandbox::FirecrackerCapturedSnapshotis removed. The onlyin-tree consumer outside
src/iscrates/e2e-tests, updated in the firstcommit. No OpenAPI, protobuf or generated client changes.
MANIFEST_FORMAT_VERSIONstays
1and the on-disk name staysfirecracker-manifest.json. The one wirechange is the added
backendfield, which is#[serde(default)]to"firecracker", so a manifest written before this change reads as a Firecrackercapture. Artifact layout is untouched.
snapshots deserialize with
backend = "firecracker"and restore unchanged.Rolling back, no struct in the snapshot layer sets
deny_unknown_fields, so anolder binary ignores the extra key and reads the manifest as it always did.
dependency, binary, port or capability.
Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetCommands and results:
Skipped checks and reasons:
make test-agent-integrationboots real microVMsand needs host state this change does not touch. The paths it covers are
exercised by the unit suite above; a maintainer with a VM host should run it
before merge.
make -C services test— nothing underservices/changes.internal Rust API.
gains or loses work.
Risks and reviewer notes
The riskiest commit is the second:
SnapshotManager::publish_capturedpreviouslydowncast the capture and returned
Unsupportedwhen the downcast failed, and nowreads the manifest off the capture directly. Worth confirming the deleted error
branch was genuinely unreachable for Firecracker.
Read in commit order.
refactor(sandbox): decouple snapshot manifest from Firecrackeris large but almost entirely a rename — the substance issrc/sandbox/manifest.rs(thebackendfield) and the guard added insrc/sandbox/firecracker/config.rs; the ten files undersrc/snapshot/repository/are the rename rippling outward.
Two naming inconsistencies are left deliberately: the persisted file is still
firecracker-manifest.jsonandSNAPSHOT_ARTIFACT_LAYOUT.firecracker_manifeststill says so. Renaming either would change the on-disk layout, which this PR
avoids. Worth a follow-up once a second backend exists.
capture_to_diris added toSandboxBackendwith no default, so any out-of-treeimplementor of the trait must add it.
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.