Skip to content

Rewrite/p12 v1 - #1

Merged
kgpp34 merged 97 commits into
developfrom
rewrite/p12-v1
Oct 20, 2026
Merged

kgpp34 merged 97 commits into
developfrom
rewrite/p12-v1

Conversation

@kgpp34

@kgpp34 kgpp34 commented Sep 16, 2026

Copy link
Copy Markdown
Owner

No description provided.

The four identity packages were near-identical copies of one another and the
architecture test package duplicated what a linter should do (DEC-012,
DEC-015). Nothing here is reused; the specs govern the rewrite.
Cocoon-shaped layout: main.go at the root, cmd/ with a cobra command tree
(cmd/doctor), and flat capability packages at the top level (config/, layout/,
host/, version/) instead of an internal/ tree of abstract packages.

doctor judges each requirement against the phase being worked on, so KVM,
Cloud Hypervisor and CNI show as not-required on a laptop while the root and
free-space checks decide the exit code. --fix only creates KumaBox-owned
directories; installing packages stays in the install script (DEC-014).

Tests run on macOS with no root and no KVM.
doctor/check.sh is Cocoon's doctor/check.sh with Cocoon's parts replaced:
KumaBox root, run and log directories, kumabox0 bridge and 10-kumabox.conflist,
the KumaBox database and staging directories, and the KumaBox version floors
(cloud-hypervisor >= v43, erofs-utils >= 1.8).

Sections that do not apply to KumaBox are gone: firecracker, ch-remote, zstd,
the JSON metadata backend and the JSON snapshot inspection. Store health now
reports rows stuck mid-flight and stray staging entries, which is what
'kumabox gc' reclaims.

doctor/check_test.sh tests the checker against a throwaway root and a PATH of
fake tools, so it needs no root, no KVM and no Cloud Hypervisor. Two knobs,
KUMABOX_KVM_DEVICE and KUMABOX_NETNS_DIR, exist so the checks can run off-host;
arm64 is accepted alongside aarch64.

The Go side keeps only the CLI skeleton in Cocoon's shape: main.go, cmd/root.go
and version/. The Go doctor command is removed -- doctor is the script, as in
Cocoon.
Restores Makefile and doctor/ to the state that matches Cocoon's README: the
checker is doctor/check.sh, built into bin/kumabox-check, installed next to the
kumabox binary, and covered by 'make test' through doctor/check_test.sh.

The Go rewrite of doctor (cmd/doctor) is dropped: it duplicated the script,
changed the command surface, and clobbered the Makefile targets that build and
install the checker.
Move dependency assembly to core and organize CLI commands and image adapters by responsibility. Keep metadata contract tests in their owning package and preserve SQLite cancellation errors after automatic rollback.

Validated with make verify, Linux/macOS make lint, and 30 repeated cancellation regression runs.
Add aligned image tables, indented JSON, and terminal-aware progress for import, pull, verification, and removal.

Document module responsibilities, API contracts, resource ownership, and workflow boundaries with ASCII diagrams.
Measure cold boot, disk restart, snapshot clone, hibernate restore, and steady-state exec with separate CLI-return and guest-ready clocks. Record raw samples, failures, cgroup readings, and environment metadata; clean only benchmark-owned artifacts.

Validate the harness with stateful contract tests and a real KVM-host baseline across no-NIC and one-NIC lanes.
Support persisted E2B metadata, environment defaults, filtered sandbox listing and cursor pagination.

Add SDK resource options, streaming output callbacks, HTTP timeouts and cancellation, plus server-side command deadlines. Cover protocol and transport behavior with regression tests and Python static checks.
Load snapshot memory before applying the runtime CPU quota, and refuse to
resume if the quota cannot be applied. Share immutable directory memory by
hard link while copying writable disks and falling back to owned copies
across filesystems.

Unify clone and restore memory policy with auto/copy/ondemand/mmap options.
Prefer mmap when supported, otherwise eager copy; keep userfaultfd paging
opt-in. Validate explicit modes before stopping a restore target and cache
successful monitor capability probes within each driver.

Same-host first guest command latency, CH v54, Xeon E3-1245 v2, XFS on SATA
SSD RAID1, 2 vCPU, 512 MiB, zero NICs, 20 measured samples per variant:

                       before p95     after p95
in-place restore        127.57 ms       64.74 ms
native clone             66.85 ms       68.12 ms
directory clone         313.96 ms       73.80 ms

Validation: full Go race tests; Linux/macOS lint and vet; amd64/arm64
builds; Linux cgroup/VMM tests; 14 real-VM checks on v53 without NICs and
v54 with one NIC. Preserve complete benchmark samples, including v53
outliers, in ignored local reports. No documentation artifacts are staged.
@kgpp34
kgpp34 merged commit 1ab3c9e into develop Oct 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant