arcbox / virt
AGENTS.md4.3k starsChanged 4 months agoApache-2.0View on GitHub
Invariants distilled from the HV fix campaign (Linear project "HV Backend"). Each was violated once and cost a multi-session debugging hunt. VZ is the oracle backend (see Debugging): if you can only fix one thing, keep these invariants intact. Every VirtIO device has two coexisting queue datapaths. Know which one the failing backend drives before you edit anything. - HV production hot path — arcbox-virtio-core::SplitQueue, built per-call from a QueueConfig (no persistent ring object). This is what a real HV…
Trending
Quiet since September.thin dataabout the whole repository
Who's talking about arcboxlabs/arcbox
- A Hacker News story“ArcBox: From-Scratch Container Runtime for macOS in Rust (Docker, K8s, MicroVMs)”Hacker News · Jul 20, 2026 · 3 points
- @github-trending-rs.bsky.social“🚀 Skyrocketing! 🚀 (200+ new stars) 📦 arcboxlabs / arcbox ⭐ 3,352 (+360) 🗒 Rust Run AI agents on real …”Bluesky · Sep 6, 2026
- @githubprojects.bsky.social“arcboxlabs/arcbox Agents need powerful system access. Giving them your actual machine is the uncomfortable …”Bluesky · Sep 6, 2026
- @github-trending-rs.bsky.social“🎉 Celebrating! 🎉 (500+ new stars) 📦 arcboxlabs / arcbox ⭐ 2,448 (+506) 🗒 Rust Run AI agents on real and …”Bluesky · Sep 2, 2026
- 1Password/for-open-source“Application for ArcBox”GitHub · Apr 18, 2026
The biggest 5 of 6 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 6
Talked about on Bluesky, GitHub and Hacker News (6 times).
On Bluesky · 3
- Sep 6, 2026🚀 Skyrocketing! 🚀 (200+ new stars) 📦 arcboxlabs / arcbox ⭐ 3,352 (+360) 🗒 Rust Run AI agents on real and isolated machines — own… — @github-trending-rs.bsky.social0 likes and reposts · 1 reply
- Sep 6, 2026arcboxlabs/arcbox Agents need powerful system access. Giving them your actual machine is the uncomfortable part. ArcBox gives agents… — @githubprojects.bsky.social0 likes and reposts · 1 reply
- Sep 2, 2026🎉 Celebrating! 🎉 (500+ new stars) 📦 arcboxlabs / arcbox ⭐ 2,448 (+506) 🗒 Rust Run AI agents on real and isolated machines — own kernel,… — @github-trending-rs.bsky.social0 likes and reposts · 1 reply
On GitHub · 2
- Apr 18, 2026Application for ArcBox — 1Password/for-open-source0 reactions · 2 comments
- Mar 23, 2026feat: remove daemon plist log paths (companion to arcbox#99) — arcboxlabs/arcbox-desktop0 reactions
On Hacker News · 1
- Jul 20, 2026ArcBox: From-Scratch Container Runtime for macOS in Rust (Docker, K8s, MicroVMs)3 points
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- app/AGENTS.mdAGENTS.md
- common/AGENTS.mdAGENTS.md
- computer/AGENTS.mdAGENTS.md
- engine/AGENTS.mdAGENTS.md
- guest/AGENTS.mdAGENTS.md
- rpc/AGENTS.mdAGENTS.md
- runtime/AGENTS.mdAGENTS.md
- xtask/AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
The file
We split this AGENTS.md into the rules it gives an agent
6 rules. About 0 are common, 1 is distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Every VirtIO device has two coexisting queue datapaths.
- Very specific: line 56
Every split-virtqueue operation — avail walk, used publish, notify decision, EVENT_IDX math — goes through arcbox-virtio-core::SplitQueue.
- Very specific: line 58
Never hand-roll ring walks or used-ring writes in device/worker code.
- Very specific: line 93
Every guest-programmed value (ring GPA, queue size, descriptor field, index) is arbitrary bits.
- Very specific: line 119
Before theorizing, read the forensics a failed e2e run already preserves on disk (it keeps the data dir): virtio-debug.json (snapshot …
- Very specific: line 169
Guest TLS/cert validation fails immediately after boot: Not a net or DNS bug — HV exposes no RTC, so the guest sits at the kernel default …
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
virt/ — VirtIO & Hypervisor Agent Guidance
Invariants distilled from the HV fix campaign (Linear project "HV Backend"). Each was violated once and cost a multi-session debugging hunt. VZ is the oracle backend (see Debugging): if you can only fix one thing, keep these invariants intact.
Datapath map — open the right file first
Every VirtIO device has two coexisting queue datapaths. Know which one the failing backend drives before you edit anything.
- HV production hot path —
arcbox-virtio-core::SplitQueue, built per-call from aQueueConfig(no persistent ring object). This is what a real HV boot runs:- net RX injection:
RxInjectThreadinvirt/arcbox-net-inject/src/inject.rsis the production RX engine — spawned wheneverrx_inject_channelis set, which the standard HV NAT datapath always does (set_rx_inject_channel); the spawn lives invirt/arcbox-vmm/src/device/net_worker.rs(note thedevice/subdir, unlikenet_rx_worker.rswhich sits directly insrc/).virt/arcbox-vmm/src/net_rx_worker.rsis the legacy kqueue fallback, reached only when that channel is unset; a default HV boot never enters it, so do not "fix HV RX" there. The bridge NIC uses its ownset_bridge_host_fddatapath, also not net_rx_worker. - net drain/poll:
virt/arcbox-virtio-net/src/device/hot_path.rs. - blk:
virt/arcbox-vmm/src/blk_worker.rs(independent parser — seearcbox-vmm/AGENTS.md). - vsock RX injection:
poll_rx_injectioninvirt/arcbox-virtio-vsock/src/device/rx_injection.rs, driven by thevsock-iothread (virt/arcbox-vmm/src/vsock_rx_worker.rs). One round drains every queued stream as far as the peer's credit and the posted RX descriptors allow — RW stays pending after a full read, round-robin across connections — and the worker then raises INT_VRING once, only if the guest'sused_eventasks for it (the round returnsRxRound { wrote, raise }). Asserting the SPI is the whole wake; no worker kicks vCPUs (arcbox-vmm/AGENTS.md"Async-Worker Completion Contract").RxOpsranks CreditRequest above Rw so the half-window refresh is not starved behind the data. VZ never runs this: its vsock is Apple's.
- net RX injection:
- VZ + unit-test / local-sim path —
queue.rs::VirtQueuelocal rings, driven throughVirtioDevice::process_queue(memory: &mut [u8], ..)invirt/arcbox-virtio-core/src/lib.rs, which returns aVec<(head, bytes)>completions list the VMM publishes. Net'sprocess_tx_queue/poll_backend_batchinvirt/arcbox-virtio-net/src/device/tx_rx.rsand each device'sactivate()live here. Queue sizing is per-device, not a blanket 256: blk/net/vsock RX+TX useVirtQueue::new(256), but vsock's event queue isVirtQueue::new(64)and VirtioFS usesVirtQueue::new(self.config.queue_size).
WHY it matters: editing tx_rx.rs/process_queue to fix an HV throughput
or hang bug touches code that is dead for HV. Fix HV bugs in the SplitQueue
files above.
One SplitQueue
- Every split-virtqueue operation — avail walk, used publish, notify
decision, EVENT_IDX math — goes through
arcbox-virtio-core::SplitQueue. Never hand-roll ring walks or used-ring writes in device/worker code.queue.rs::VirtQueuestays only for the VZ/test path above; do not add new consumers. WHY: one implementation means one place to get the memory ordering and EVENT_IDX handshake right. - The
should_notifySeqCst StoreLoad fence is load-bearing — never remove or weaken it (split_queue.rs,should_notify). Under EVENT_IDX theused.idxstore must be ordered before theused_eventload; on ARM64 the load otherwise reorders ahead, reads a staleused_event, suppresses a needed IRQ, and the guest sleeps in WFI forever. WHY: this is the root-cause class of the HV cold-boot completion-notification hang. - Worker drain loops must call
SplitQueue::enable_notificationbefore sleeping (the EVENT_IDX re-arm handshake; used byblk_worker.rsasif !queue.enable_notification()). It publishesavail_event, inserts a SeqCst barrier, re-readsavail.idx, and returnstrueif the guest added more — the caller must then drain again. WHY: skip it and a buffer the guest posted-but-suppressed-the-kick-for strands the queue forever. - Notify semantics are asymmetric by design: TX publishes the consumed
cursor (
write_avail_event), RX polling consumers publish the guest's current avail.idx (write_avail_event_current). Do not "unify" them. - RX invariant:
last_avail_idx == used.idx— one used entry per consumed avail entry. Speculative gathers must rewind the avail cursor on every early-exit path (short read, WouldBlock, EOF, validation failure); never rewind used.idx. - MRG_RXBUF:
num_buffersmust equal the count of used entries the frame spans, and only the head carries thevirtio_net_hdr(stamped at bytes 10..12; trailing buffers are pure payload). A wrong count silently drops every multi-buffer (bulk/GSO) frame while single-buffer traffic (ping) still flows — the classic "ping works, iperf reads zero" signature. Stamp sites:inject.rs(HV RX injection,num_buffers = num_used) andtx_rx.rs(VZ,num_buffers = chains.len()). WHY: the guest reassembles exactlynum_buffersconsecutive used entries into one packet.
Guest-controlled input
- Every guest-programmed value (ring GPA, queue size, descriptor field,
index) is arbitrary bits. All arithmetic on them must be checked
(
checked_add/checked_sub→ bail), and bounds must be verified before anyunsafeguest-memory access. Debug builds panic on overflow while release wraps past bounds checks — both are bugs; tests must cover near-u64::MAXinputs.
vmnet relay (bridge NIC, arcbox-vmnet)
- The vmnet → guest read path is event-driven via
vmnet_interface_set_event_callback(ABX-517) — do not reintroduce a polling/blocking read thread; the deleted 1 kHz poll cost ~half of the daemon's idle CPU and its cancel-then-join teardown could hangRuntime::drop. The callback context is owned by the handler block (copy retains, dispose releases) and must never be freed manually;Vmnet::clear_event_callback— called from bothVmnet::stopand the relay's exit path, idempotent — is what breaks the interface → block → ctx →Arc<Vmnet>cycle. Keep both call sites.
Debugging — failure signature → first commands → likely cause
Triage rule first: re-run the same scenario under
ARCBOX_VM_BACKEND=vz. HV-only red points at the HV SplitQueue/worker
implementation; double red (VZ also fails) points above the hypervisor
(device logic, guest, image).
Before theorizing, read the forensics a failed e2e run already preserves on
disk (it keeps the data dir): virtio-debug.json (snapshot captured while
the VM was alive), metrics.json (phase timings). Readiness is observed
only via WatchSetupStatus — never log-grep or sleep for it. Console-log
archaeology produced multiple wrong root causes in this tree.
Those two feeds are queue-state and readiness. The guest-side view below
complements them — use it when a boot is wedged before it ever reports
readiness (nothing to snapshot, nothing on WatchSetupStatus), not as a
readiness signal.
- Interactive serial shell into a hung HV guest. On the custom-HV
backend,
resolve_desired_boot(engine/arcbox-engine/src/vm_lifecycle/boot.rs, theDEBUG_CONSOLE_KEYblock) always appendsarcbox.debug_console=<data_dir>/run/console.sockto the kernel cmdline; the guest rcS spawns a root shell keyed on the same token (DEBUG_CONSOLE_KEY = "arcbox.debug_console=",common/arcbox-constants). Attach withsocat - UNIX-CONNECT:<data_dir>/run/console.sock. It reaches the guest even when early boot hangs before networking — the dominant historical HV cold-boot failure shape — because it rides the virtio-console device (virt/arcbox-vmm/src/console_rx_worker.rs+arcbox-virtio::console::SocketConsole), not the net stack.ARCBOX_NO_DEBUG_CONSOLE=1strips the token (host attaches no console, guest spawns no shell) to A/B-test whether the console itself perturbs the flaky boot. HV-only — the token targets the HV console wiring; VZ owns its console internally. The socket lives under the per-user data dir, so same-user access only. - Guest boot output lands on two tracing targets, both already in the
daemon's
default_filter(app/arcbox-daemon/src/main.rs, so noRUST_LOGneeded):guest_serial(PL011 earlycon, pre-handoff early kernel messages —virt/arcbox-vmm/src/vmm/darwin_hv/pl011.rs) andguest_console(VirtioConsolehvc0, post-handoff kernel console plus anything the agent writes tohvc0—virt/arcbox-virtio-console/src/device.rs). The handoff between them is the kernel linelegacy console [hvc0] enabled. Symptom: a wedged boot shows nothing under either target -> confirm the run is HV (guest_serialis HV-only) and thatRUST_LOGisn't set — it replaces the default filter rather than adding to it, so a strayRUST_LOGsilently drops both guest targets. - >8-vCPU guest boot wedge / PID 1 in D-state. First: capture the live
snapshot (
Vmm::debug_snapshot/SystemService.GetVirtioDebug: per-queue kicks, live avail/used indices, per-vCPU exit counters) while the VM is alive; then bisectARCBOX_HV_E2E_VCPUS. Likely cause: virtio MMIO per-queue register file too small — virtio-blk configures one queue per vCPU, so a register file smaller than the queue count silently drops queue config (ABX-386,MAX_VIRTQUEUES; seearcbox-vmm/AGENTS.md). Already fixed by raisingMAX_VIRTQUEUESto 64: the old limit wedged at exactly 8 vCPUs, but that is the historical signature, not a live threshold — an 8-vCPU boot no longer wedges, so don't expect a bisect to break at 8 unless the register file has regressed below the queue count. - Guest TLS/cert validation fails immediately after boot. Not a net or
DNS bug — HV exposes no RTC, so the guest sits at the kernel default epoch
until the post-readiness agent ping sets
clock_settime(AgentPingRequest.timestamp_secs; ABX-416, PL031 RTC pending). Do not chase it in the DNS/net stack. - HV host→guest vsock bulk is slow (multi-second per 100 MiB) while the
guest sits idle; VZ is fine. Diff the vsock device's
interruptsand RXused_idxfromGetVirtioDebugacross one transfer: ~1 interrupt per ≤3776-byte packet means the injection round is back to one packet per connection (19–20 s per GiB before 2026-09-29, 5.4–5.9 s after). A non-zerokicks_receiveddelta on any vCPU means a worker is callinghv_vcpus_exitagain (removed 2026-09-30; it cost ~0.5 ms per RPC). Details inarcbox-vmm/AGENTS.md"Async-Worker Completion Contract". - Queue stall that appears only under an EVENT_IDX guest. Suspect a
dropped
enable_notificationre-arm in a worker drain loop, or a weakenedshould_notifySeqCst fence. Diff against the "One SplitQueue" rules above. - Daemon SIGSEGV at shutdown after an otherwise successful run. Known-benign teardown crash (ABX-415), not a boot/queue regression you introduced. Do not open a false-alarm investigation on the queue path.
To localize any config-dependent failure, bisect the hv_e2e probe one
dimension at a time from the minimal probe toward the daemon shape
(ARCBOX_HV_E2E_VCPUS / _MEMORY_MB / _BALLOON / _NETWORKING /
_DATA_IMG_MB / _EXTRA_SHARES / _BRIDGE / _BOOT_ONLY / _LOGLEVEL;
full list in the tests/e2e/src/bin/hv_e2e.rs header). This is how ABX-386
was localized to "vCPU count, threshold exactly 8".
Validation ladder (cheapest first)
- crate unit tests for the touched crate;
- bare probe:
cargo test -p arcbox-e2e --test hv_vmm -- --ignored; - daemon level:
cargo test -p arcbox-e2e --test virtio_debug -- --ignoredand--test boot_assets -- --ignoredwithARCBOX_VM_BACKEND=hv; - race-class fixes:
cargo xtask e2e --repeat N.
The e2e targets are #[ignore]d: without -- --ignored the run reports
"0 tests run" and validates nothing (cargo xtask e2e passes it for you).
The broadcast counters R2/R3 acceptance used to be read from
(kick_broadcasts / unpark_broadcasts) are retired and read 0: no worker
kicks vCPUs and nothing unparks them (arcbox-vmm/AGENTS.md "Diagnostic
Counters"). Judge a wake-path change by kicks_received (must stay flat in
steady state), the vsock RPC latency probe, and xtask idle.
Pointers (reference material, not duplicated here)
virt/arcbox-vz/AGENTS.md— the VZ backend's Swift shim (ArcBoxVZShim): the C ABI boundary contract (normative symbol order, link-time drift detection, handle and callback conventions), queue-affinity design, and build.rs landmines. VZ has no Rust-side ObjC interop anymore; fix VZ bugs there.virt/arcbox-tap-net/README.md— the sandbox TAP network (pool, TAP ioctls, invariant NAT via eBPF TCX or iptables, quarantine ledger) is its own crate, the Linux adapter ofarcbox-vm-driver'sGuestNetworkport. The sandbox runtime reaches it only through that port and no longer re-exports it (R3 PR-G5), so a consumer wanting this crate's own vocabulary —invariant::GUEST_IP,ExposeTarget— depends on it directly. Not part of the HV/VZ VirtIO datapath above.docs/benchmarks/virtiofs.md— the settled VirtioFS story: the per-op cross-vCPU IPI mechanism, the kernelfuse-spin-waitfix (+58% metadata_stat), everything ruled out en route (dax was never active on VZ; idle=poll, sched features, kernel version all measured), and the measurement discipline (same-context/same-day pairing; only the in-process trio is ratio-safe). Read this before any "make file I/O faster" work. VZ runs Apple's virtio-fs device — the custom VirtioFS is HV-only and still unmeasured.docs/benchmarks/network.md— the settled multi-flow Host→VM ceiling (~10–12 Gbps combined vs ~22–29 Gbps single-flow) and its root cause (per-IRQ host-side cost:hv_vcpus_exit/hv_gic_set_spi/pthread_cond_signal), with multi-queue / more-CPU / ring-size explicitly ruled out by profiling. Read this before any "make net faster" work. NOTE: two of its recommendations have since shipped — EVENT_IDX IRQ suppression (write_avail_event_currentinflush_interrupt) and the removal of thehv_vcpus_exithop (c3004580) — so its "unconditionally fire" claim and itshv_vcpus_exitrows are history; thepthread_cond_signalit saw is the framework waking the target vCPU insidehv_vcpu_run, i.e. the wake itself, not a redundant hop.docs/architecture/virtio-queue-convergence.md— historical rationale for the SplitQueue unification only. ItsStatus: Plannedand the targetVirtioDevicetrait it describes (droppingmemory: &mut [u8]) no longer match the shipped code; treat it as history.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

