Skip to content

fix(local): isolate native disk state and preserve startup ownership - #814

Merged
earakely-scale merged 4 commits into
scaleapi:mainfrom
hqhq1025:fix/local-native-disk-state
Nov 23, 2026
Merged

earakely-scale merged 4 commits into
scaleapi:mainfrom
hqhq1025:fix/local-native-disk-state

Conversation

@hqhq1025

@hqhq1025 hqhq1025 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Local native-disk preparation can reject a usable KVM device because the CLI
user cannot open it directly, even though Docker can. VM overlays also need
an owned host directory and reliable cleanup when container startup finishes
late or times out.

This change:

  • Detects the KVM character device and lets Docker enforce device access.
  • Stores each guest's writable state under its sandbox work directory, runs
    the launcher with the directory owner's UID/GID, and grants its KVM group.
  • Separates startup and query deadlines, records ownership before launch,
    and preserves state when creation or cleanup has an unknown outcome.

This is a generic local Docker disk change and has no HCU or model dependency.

Validation

  • make lint passes.
  • Full framework and protocol unit suites: 17,292 passed, 8 skipped.
  • Focused preparation and disk regressions: 119 passed.
  • Plugin API check reports no breaking change.
  • A real local Windows desktop boots and tears down with these provider
    changes. Its staged driver installation, AX query and screenshot complete.

The docs should describe Docker's KVM access
and the sandbox-owned VM state directory.

RetriggerView in GreptileConfidence Score: 4/5

Fix thin-disk file access before merging; users with umask 077 otherwise lose Windows and Omarchy startup.

Fix All in CursorFindings

  1. P1 Thin disks cannot boot ▶
Fix with agent prompt
### Issue 1
src/agent_env/providers/sandbox_providers/local_docker/provider.py:870-871
If a user composes a thin disk under `umask 077`, the new `--user` prevents the launcher from reading its `guest` file. `thin_disk.pack` writes that file with the host's permissions, then copies it into the image as UID 107 without changing its mode. The usual host UID cannot read it, so `launch` exits at `guest=$(cat "$folder/guest")` before booting Windows or Omarchy. Make the required disk files readable by the launcher before switching users.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR moves writable VM state into each sandbox's work directory and records ownership before Docker starts.

  • Local disk support checks for a KVM device, not the CLI user's device permissions.
  • Each local disk keeps writable guest files in its sandbox folder.
  • Timed-out disk launches keep their folder until Docker settles.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Create sandbox work directory] --> B[Create owned VM state directory]
    B --> C[Write ownership and pending markers]
    C --> D[Start Docker launcher as host user]
    D --> E{Launch outcome}
    E -->|Success| F[Clear pending marker]
    E -->|Failure or cancellation| G[Attempt teardown]
    G --> H{Removal confirmed?}
    H -->|Yes| I[Remove work directory]
    H -->|No| J[Keep state for retry]
Loading

Reviews (7) · Last reviewed commit: "revert(bundle): leave prepare_bundle wit..." · Reviewed by Greptile

hqhq1025 and others added 4 commits November 23, 2026 10:37
… an unconfirmed one settles

The start marker stayed when `docker run` exited with an error before creating the container (the daemon
unreachable, or unable to pass /dev/kvm), so every teardown after it failed with "not confirmed" and the
sandbox folder could never be removed. A docker that exits with an error has made its container already,
which teardown lists, or never will, so its marker goes; one a signal killed keeps it. A marker with no
container behind it settles ten minutes after the launch, so a timed-out start can be torn down then.

The computers README says the device must be group-writable, as the launcher now runs as the user with its
group, and AGENTS.md's teardown paragraph says what a missing Docker CLI and an unconfirmed launch do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Docker reads --mount's value as one CSV row, so a sandbox folder or state root whose path held a comma split
into another option and the launcher refused to start. Its state and trust mounts quote a field that needs it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Composing a computer env native-only is a computer-specific knob that nothing in the repository passes to
prepare_bundle; this pull request is about how local Docker boots disks. run_bundle and dry_run_bundle keep theirs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale force-pushed the fix/local-native-disk-state branch from d93f5e0 to be850c8 Compare November 23, 2026 18:38
@earakely-scale
earakely-scale merged commit b56cd72 into scaleapi:main Nov 23, 2026
34 of 36 checks passed
Comment on lines +870 to +871
state_args = ("--mount", _bind(state, "/var/lib/agentenv-vm"),
"--user", f"{os.getuid()}:{os.getgid()}", "--group-add", str(os.stat(KVM).st_gid))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Thin disks cannot boot

If a user composes a thin disk under umask 077, the new --user prevents the launcher from reading its guest file. thin_disk.pack writes that file with the host's permissions, then copies it into the image as UID 107 without changing its mode. The usual host UID cannot read it, so launch exits at guest=$(cat "$folder/guest") before booting Windows or Omarchy. Make the required disk files readable by the launcher before switching users.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/agent_env/providers/sandbox_providers/local_docker/provider.py
Line: 870-871

Comment:
**Thin disks cannot boot**

If a user composes a thin disk under `umask 077`, the new `--user` prevents the launcher from reading its `guest` file. `thin_disk.pack` writes that file with the host's permissions, then copies it into the image as UID 107 without changing its mode. The usual host UID cannot read it, so `launch` exits at `guest=$(cat "$folder/guest")` before booting Windows or Omarchy. Make the required disk files readable by the launcher before switching users.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Cursor Fix in Claude Code Fix in Codex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants