mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[GH-ISSUE #381] (feature: mock-backend) Add a compile-time mock sandbox backend for KVM-less integration testing #97
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#97
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?
Originally created by @tm-worker on GitHub (Oct 13, 2026).
Original GitHub issue: https://github.com/kvcache-ai/AgentENV/issues/381
Affected component: Orchestrator / sandbox lifecycle
Version: v0.2.3 (commit
4968423)Problem statement
Every sandbox lifecycle operation requires
/dev/kvm, sotests/integration.rs— thefc::*,process::*andublksuites — cannot run on KVM-less CI runners (verified: 21 device-dependent failures on a KVM-less linux/arm64 container). The same limitation blocks any tooling that wants to exercise the agent's REST surface (lifecycle, snapshots, node metrics, data-plane proxy) outside a KVM host.It also holds back end-to-end integration testing of the full stack: an E2E test that boots the agent together with the scheduler-plane / gateway components and drives a real sandbox lifecycle is impossible without provisioning a KVM host first — developers who just want to work on or verify the control plane have to set up virtualization before they can run anything.
Use case
Current behavior and workarounds
Today every backend operation requires
/dev/kvmand the host setup checks enforce it at startup. Workarounds and why they fall short:The in-process
MockSandboxBackend/MockBackendFactoryalready cover exactly what's missing: they implement the fullSandboxBackendFactorytrait includingbuild_from_snapshotandbuild_from_paused_state, andhost_interaction_ip()is configurable so the agent's real/proxyforwarding code can dial a caller-provided target. The only blocker is#[cfg(test)]gating — the release build cannot reach them, andserver.rshard-wiresFirecrackerSandboxFactory.Desired behavior
/dev/kvm.tests/integration.rsrunnable on KVM-less CI runners for everything except the device-dependent tests (unchanged).Proposed approach
A small, inert-by-default test-support patch (13 files, ~+477/-18, verified on linux/arm64):
mock-backendcargo feature. With the feature off, production builds are byte-identical (cargo checkverified both ways).sandbox/mock(stays#[cfg(test)]-compatible) plus two existing test-support constructors that the mock path needs (SandboxSnapshotManifest::for_test,SnapshotPublishMetadata::mock).DefaultBackendFactorytype alias forOrchestrator's defaultF: flips to the mock under the feature; every hardcodedArc<Orchestrator>reference (ObservabilityService, ApiImpl) follows via one switch.server-mockbin: the productionserver.rswiring copied verbatim with four diffs — mock factory (data-plane IP fromAENV_MOCK_HOST_IP, so/proxydials a caller-provided target through the agent's REAL forwarding code), VM-capability/env checks skipped, template seeding via the real publish API (AENV_MOCK_TEMPLATE_IDS; an empty repository 400s before the factory ever runs), shutdown blocks adjusted.snapshot()/capture_to_dirwrite a real artifact set (the same writer the snapshot-manager tests seed with) instead of a danglingfor_testmanifest — the capture → publish → load_runnable loop stays on real code.Dockerfile.agentenv-mockproducing anagentenv-runtime-mockimage (structurally the production image; the mock needs no KVM/ublk).Observed behavior (evidence, KVM-less linux/arm64 container)
load_runnable→ mock backend → real envd access token), status/pause → 204 (idempotent), connect → 201/200, delete → 204GET /snapshotsGET /nodesreturns liveNodeMetrics(allocated CPU/memory counts the mock sandboxes)tests/integration.rsdevice-dependent failures are pre-existing and unrelated.)Compatibility and operational impact
pubitems, one type alias, one new bin (server-mock) and one cargo feature (mock-backend) — all inert with the feature off; no production API changes.Alternatives considered
/dev/kvm; there is no TCG path to fall back to.Non-goals
/dev/kvmexists.Contribution
I can implement it — a local branch with the full change is ready and verified (see Observed behavior); happy to open focused PRs (feature gate + bin, and the capture-fidelity fix, as separate commits/PRs if preferred) once the approach is aligned.