Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3e0bfa7
Refactor autoscaler core (policy.py) and extract shell from cli.py
rlrs Nov 25, 2026
142af5b
Extract pure routing state transitions from RoutingStore
rlrs Nov 25, 2026
a7c379f
Extract pure migration selection and decompose gateway sandbox proxy …
rlrs Nov 25, 2026
429f035
Extract gateway build/migration cores and remove final C901 suppression
rlrs Nov 25, 2026
6be8366
Extract registry prune workflow out of cli.py
rlrs Nov 25, 2026
40a1333
Extract pure relay request canonicalization and lifecycle transitions
rlrs Nov 25, 2026
089f828
Decompose gateway route dispatch and SandboxSpec.validate; lower Ruff…
rlrs Nov 25, 2026
83a27e4
Move ControlPlaneHandler mutable caches and coalescers into GatewayRu…
rlrs Nov 25, 2026
2ddb337
Promote heavily cross-imported gateway, placement, and receipt helper…
rlrs Nov 25, 2026
991865e
Decompose render_vm_init_script into typed context and section builders
rlrs Nov 25, 2026
b447621
Promote remaining gateway internal helpers to public APIs
rlrs Nov 25, 2026
417b0f4
Extract SandboxMigrations imperative shell out of ControlPlaneHandler
rlrs Nov 25, 2026
3502c4f
Extract ImageBuilds imperative shell and pure builder ranking out of …
rlrs Nov 25, 2026
93ac040
Include terminal state in PROGRAM_REQUEST_STATES and update moved tes…
rlrs Nov 25, 2026
c129f92
Extract SandboxProxy imperative shell and pure lifecycle/proxy helper…
rlrs Nov 25, 2026
fbba756
Record locked-in memory-backing, OCI, Rust admission, and relay decis…
rlrs Nov 27, 2026
801ed1b
Remove direct_reflink_memory_restore across Python and Rust
rlrs Nov 27, 2026
7c24dd9
Port file I/O, archive uploads, and environment endpoint to ucloud-no…
rlrs Nov 27, 2026
b7fdf72
Allow disabling registry disk statvfs guard on shared drives
rlrs Nov 27, 2026
9170aae
Default direct_ram_memory_backing to true in SandboxPoolConfig
rlrs Nov 28, 2026
23192c0
Port sandbox listing, deletion pipeline, and teardown primitives to u…
rlrs Nov 28, 2026
90a6782
Port Ed25519 auth, HTTP registry client, cold image materialization, …
rlrs Nov 28, 2026
eda0841
Port host runtime metrics, /healthz, /v1/heartbeat, /v1/drain, and he…
rlrs Nov 28, 2026
fae1917
Port RAM-only park, wake, migration, and commit-export to ucloud-node…
rlrs Nov 28, 2026
f4e18b2
Add standalone Rust ucloud-noded mode, create pipeline, and orphan re…
rlrs Nov 28, 2026
6d482a0
Split builder_agent.py and wire standalone Rust ucloud-noded workers …
rlrs Nov 28, 2026
dd88c05
Keep _check_node_control_authorized name on BuilderAgentHandler
rlrs Nov 28, 2026
89bdf8f
Inline Linux dev major/minor bitshifts for musl static symbol check
rlrs Nov 28, 2026
6e3f366
Match full NodeRuntimeMetrics schema and standalone worker bootstrap …
rlrs Nov 28, 2026
e65f23c
Import boot_config_sha256 from direct_runtime in standalone_noded_config
rlrs Nov 28, 2026
9d6350c
noded: poll storage-native metrics in heartbeats and align storage RP…
rlrs Nov 28, 2026
de062eb
noded: gate standalone split layout and initial claim on spec.parkable
rlrs Nov 28, 2026
467e91c
noded: honor configured exec session limits in standalone ExecFront a…
rlrs Nov 28, 2026
2e334ee
noded: include node_epoch in lifecycle responses, remove captured fil…
rlrs Nov 28, 2026
31a16c4
docs: document standalone Rust ucloud-noded and builder_agent in arch…
rlrs Nov 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 30 additions & 20 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ flowchart LR
**Sandbox nodes**, set up at boot by
[vm_init.py](../sandboxes/vm_init.py):

- `ucloud-sandbox-node`, the Python node agent. Its Warden owns every sandbox
on the node (OCI bundles, cgroups, `runsc` processes, network namespaces,
lifecycle journals, the node registry) and it sends heartbeats.
- `ucloud-sandbox-noded`, the Rust daemon `ucloud-noded`
([runtime/noded](../runtime/noded)), which owns the port, creates, execs
and the pause tier, and behind a flag admission (see
[below](#the-python-agent-and-ucloud-noded)).
and the pause tier, and behind `sandbox.direct_node_standalone_rust`
runs standalone (`--standalone-config`) for every worker route without
`ucloud-sandbox-node` (see [below](#the-python-agent-and-ucloud-noded)).
- `ucloud-sandbox-node`, the legacy Python node agent (omitted when
`sandbox.direct_node_standalone_rust` is enabled). When running alongside
`ucloud-noded`, its Warden handles the remaining lifecycle routes and
heartbeats.
- `ucloud-storage-native`: writable volumes, memory backing, checkpoint
publication.
- `ucloud-environment-io`: serves immutable image roots from the chunk store.
Expand All @@ -86,8 +88,9 @@ Docker never owns a sandbox. Builders pull and build OCI images with it; on
sandbox workers it supplies only `docker-init`, its FORWARD DROP policy and the
quota mount that holds the image cache.

**Builder nodes** run BuildKit for Dockerfile builds that cannot run inside a
sandbox; the autoscaler starts them on build demand. **The store node** sits
**Builder nodes** run BuildKit via the standalone
[builder_agent.py](../sandboxes/builder_agent.py) server for Dockerfile builds
that cannot run inside a sandbox; the autoscaler starts them on build demand. **The store node** sits
outside the pool and caches the content-addressed chunk store from object
storage (workers verify every chunk, so it is untrusted), plus a package
cache for builds. See [images.md](images.md).
Expand Down Expand Up @@ -303,19 +306,26 @@ to the agent's Unix socket; the node registry and the create pipeline
(unsupported creates, such as relay egress, DNS-named egress and migration
imports, go to the agent unchanged); execs on running sandboxes and
managed-job reads, start and signal; and the pause tier: thaw-on-exec, idle
pauses, paused reclaim, escalation decisions and node-local model waits. One
slice is still behind a flag, off by default: `sandbox.direct_node_rust_admission`
moves the transition ledger, slots, growth forecasts and resident sampling.
The flags of the other slices are retired; deployment files may still name
them, as true only.

Always in the Python agent: heartbeats; park, wake, migration and delete
with their lifecycle locks; the drain row; workspace growth. The processes
coordinate through the kernel and files, not a lock manager: per-sandbox
flocks fence execs against parks, and admission claims are tokens bound to
the agent's session, so a restart of either side cannot leak or double a
grant. Managed-job state sits in a host-visible bind mount, so noded serves
job status and logs without entering, thawing or locking the guest.
pauses, paused reclaim, escalation decisions and node-local model waits. Two
flags remain off by default: `sandbox.direct_node_rust_admission` moves the
transition ledger, slots, growth forecasts and resident sampling into
`ucloud-noded`, and `sandbox.direct_node_standalone_rust` launches
`ucloud-noded --standalone-config` as the sole sandbox worker daemon — owning
file I/O, archive upload, image pulls (with pure-Rust Ed25519 manifest
verification), RAM-backed park/wake, snapshot publication, migration,
commit-export, `/healthz`, `/v1/heartbeat` (including `storage-native` metrics),
`/v1/drain`, heartbeat pushing, and boot-time/TTL reconciliation with no Python
node agent process. The flags of the earlier slices are retired; deployment
files may still name them, as true only.

When `sandbox.direct_node_standalone_rust` is off, the Python agent still owns
heartbeats, park/wake/migration/delete with their lifecycle locks, the drain
row, and workspace growth. In that split mode the processes coordinate through
the kernel and files, not a lock manager: per-sandbox flocks fence execs
against parks, and admission claims are tokens bound to the agent's session, so
a restart of either side cannot leak or double a grant. Managed-job state sits
in a host-visible bind mount, so noded serves job status and logs without
entering, thawing or locking the guest.

## Managed agents and the model relay

Expand Down
25 changes: 17 additions & 8 deletions docs/decisions.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ Full record: `git show a04c1ad:docs/managed-process-reads.md`
`runsc pause` takes 9–26 ms; memory goes to swap only under pressure. At 140 rollouts
this cut wake p95 from 14.2 s to 0.13 s; a full checkpoint copies every written byte
(48–96 s after 2.5 GB). The node watches relay TCP headers (NFLOG, never payloads),
saving ~20 PostgreSQL statements per wait; it needs `guest_relay_url`. zswap is off: it
freed ~13 MB per reclaim on incompressible memory.
saving ~20 PostgreSQL statements per wait; trainers set `guest_relay_url`, so the older
relay/gateway-driven park-and-wake protocol is retired. zswap is off: it freed ~13 MB per
reclaim on incompressible memory.

Full record: `git show a04c1ad:docs/rl-scale-architecture-plan.md` (§9 qualification
results, ledger 2026-10-03), `git show a04c1ad:docs/rollout-0.8.0.md` ("0.8.5"),
Expand All @@ -109,12 +110,19 @@ results, ledger 2026-10-03), `git show a04c1ad:docs/rollout-0.8.0.md` ("0.8.5"),
`git show a04c1ad:docs/node-local-model-waits.md`,
`git show a04c1ad:docs/benchmarks/node-local-wake-2026-10-03/README.md`

### Live guest memory is RAM-backed, separate from the workspace volume
### Live guest memory is swappable RAM-backed only; file-active and reflink-restore are retired

Splitting it cut physical writes ~87%; a disk-file split raised them ~6.4×. Backing
capacity is admitted on its own: free host RAM did not prove tmpfs room (16 SIGBUS
deaths at 256 × 1.5 GiB). `O_DIRECT` on the storage upper was rejected: random IOPS
fell from 169,732 to 9,341.
Splitting live guest memory from the workspace volume cut physical writes ~87%, while a
disk-file split raised them ~6.4×. Backing capacity is admitted on its own: free host RAM
did not prove tmpfs room (16 SIGBUS deaths at 256 × 1.5 GiB). `O_DIRECT` on the storage
upper was rejected: random IOPS fell from 169,732 to 9,341.

Swappable RAM-backed (`direct_ram_memory_backing`) is the single memory mode: it pairs
with `ucloud-noded`'s pause tier (`runsc pause` + `memory.reclaim` to NVMe swap) and keeps
running sandboxes at a 64 MiB checkpoint disk claim so RAM + swap rather than disk bounds
density. File-active backing and XFS `reflink-restore` (`direct_reflink_memory_restore`,
which forced dual `ram`/`file` live modes, mode-conversion journals and retention project
IDs to speed up rare cold restores) are retired.

Full record: `git show a04c1ad:docs/benchmarks/split-memory-2026-09-23/README.md`,
`git show a04c1ad:docs/reviews/hybrid-memory-pressure-2026-09-23.md`,
Expand Down Expand Up @@ -152,7 +160,8 @@ Full record: `git show a04c1ad:docs/chunk-store-design.md`,
Kernel EROFS over NBD attaches in ~0.2 s and keeps mtimes (zeroed mtimes made `.pyc`
recompile: 3.74 s against 0.9 s). The chunk dictionary panicked at 254 blobs and
`merge` corrupted images. Our Python NBD reader capped at ~45 MB/s; nydusd took 64 cold
images in 10.6 s against 31.5 s, so the planned custom Rust reader was dropped.
images in 10.6 s against 31.5 s, so the planned custom Rust reader was dropped. Sandbox
workers attach immutable chunk-store environments only; legacy OCI pulls stay on builders.

Full record: `git show a04c1ad:docs/benchmarks/nydus-spike-2026-10-02/README.md`,
`git show a04c1ad:docs/benchmarks/nydusd-spike-2026-10-03/README.md`,
Expand Down
27 changes: 17 additions & 10 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ under [Open decisions](#open-decisions).

## Node daemon (`ucloud-noded`)

- **File writes and archive uploads in noded.** Still served by the Python agent; the
largest setup cost left at 512 rollouts (`node_agent.py`, `runtime/noded/src/exec_front.rs`).
- **Park, wake, migration, commit, reconcile and heartbeats in noded**, then delete the
Python agent (`direct_service.py`, `direct_warden.py`, `hibernation.py`, `node_agent.py`,
`heartbeat_sender.py`).
- **Flip `sandbox.direct_node_standalone_rust` to default on**, then delete the legacy
Python sandbox node daemon (`node_agent.py` direct path, `direct_service.py`,
`direct_warden.py`, `hibernation.py`, `heartbeat_sender.py`, `transition_admission.py`).
Standalone Rust `ucloud-noded --standalone-config` now implements all sandbox worker routes
(create, exec, jobs, files/archive/environment, list/delete, images/pull with pure-Rust
Ed25519 verification, RAM-only park/wake, snapshot publication, migration, commit-export,
`/healthz`, `/v1/heartbeat`, `/v1/drain`, heartbeat pusher, and boot-time/TTL reconciler),
and the builder-only HTTP server is split into `sandboxes/builder_agent.py`.
- **Create-path tails.** `runsc_create`, storage prepare (`mkfs.xfs` per create) and
registry commit set node-side create p95 (`runtime/noded/src/`: `create.rs`, `storage.rs`, `registry/`).
- **CPU QoS for background work** (`cpu.idle`/`cpu.weight` for prefetch, publication, offload, cache fill).
Expand Down Expand Up @@ -79,8 +82,12 @@ under [Open decisions](#open-decisions).

## Open decisions

- **Turn on `sandbox.direct_node_rust_admission`** once the two gates pass.
- **Retire relay-driven park and wake** once every trainer sets `guest_relay_url`.
- **Registry disk guard on a shared drive:** replace `statvfs` percentages with a byte bound, or turn it off.
- **One memory mode:** pick one of split, RAM or reflink-restore backing and delete the rest.
- **A second store node:** removes the ~1.5 h cache-refill window after a loss, at a monthly cost.
- **Second store node (deferred):** removes the ~1.5 h cache-refill window after a loss, at a monthly cost; revisit only if that refill window violates training SLOs.

### Decided (2026-11-27)

- **Single memory mode:** standardize on swappable RAM-backed (`direct_ram_memory_backing`) and delete file-active (`direct_reflink_memory_restore` is removed).
- **No legacy OCI pulls on sandbox workers:** workers attach immutable chunk-store environments only; Docker/OCI pulls stay on builders.
- **Turn on `sandbox.direct_node_rust_admission`** once its two benchmark gates pass, then delete the Python admission ledger.
- **Retire relay-driven park and wake** (`guest_relay_url` + node-local model waits replace it).
- **Registry disk guard on shared drives:** `registry_disk_guard_enabled: false` disables `statvfs` percentage refusal on shared drives.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ select = ["C901", "E4", "E7", "E9", "F"]
[tool.ruff.lint.mccabe]
# Functions above this carry `# noqa: C901`. Lower it, and drop their
# noqa, as functions are split.
max-complexity = 40
max-complexity = 33
Loading
Loading