8000 vivarium: review by domain, 2026-11-17 · Issue #1444 · nixidae/nixidae · GitHub
[go: up one dir, main page]

Skip to content

vivarium: review by domain, 2026-11-17 #1444

Open

Description

@Lillecarl

A review of vivarium in six domains. One review agent per domain ran in series, read-only, at nixidae a260990.

Domains:

  1. Architecture and boundaries
  2. Robustness: teardown, cancellation, agent RPC failure, isolation
  3. Speed
  4. UX and DX: CLI, ctl, MCP, error text, docs and skill truth
  5. Maintainability and house rules
  6. Tests and CI coverage

Each domain gets one comment with its full findings. A last comment gives a verdict for every finding (fix or not, with the reason). A finding marked "fix" gets its own issue, linked from the verdict comment.


Assisted-By: Claude Opus 5.5

Activity

  1. added
    source: vivarium
    on Nov 17, 2026
  2. Lillecarl commented on Nov 17, 2026

    @Lillecarl
    ContributorAuthor

    Domain 1: architecture and boundaries

    The review agent's findings, not yet verified. The verdict comment checks each one before an issue is opened.

    A1 A guest kind's assertions never run, so .uml, .krun and .container of a kind test evaluate and boot the wrong thing (high)

    • Where:
      • lib.nix:248-253: the toplevel is forced only for kind == "nixos".
      • lib.nix:530-540: only the run's cfg.assertions are read.
      • The kind modules: routeros-guest.nix:91, vyos-guest.nix:241, sonic-guest.nix:52, image-guest.nix:258, appliance.nix:115, dinix-guest.nix:196.
    • Evidence:
      • Each kind guards its backend with a node assertion, for example "vivarium.routeros boots under QEMU only".
      • Node assertions throw only when system.build.toplevel is forced, and machineSpec forces it only for NixOS guests.
      • nix eval --file . checks.routeros.uml.drvPath evaluates. The node's failed assertions are ["vivarium.routeros boots under QEMU only; this guest is uml."].
      • Control: checks.screen.uml.drvPath (a NixOS guest) throws as it should.
    • Impact:
      • For the ten kind tests, three of the four backend variants are wrong runs that evaluate cleanly.
      • Each fails only after a build and a 180 s boot timeout.
    • Fix:
      • Add every node's failed assertions and warnings to failed in lib.nix:530, whatever the guest kind.
      • Optionally, onBackend leaves a kind that pins its backend alone.

    A2 Every guest runs its agent from the host's runner package, so a change to a host-side runner file rebuilds every guest (high; related to #1182)

    • Where:
      • modules/guest.nix:348;
      • modules/default.nix:1040-1042;
      • pkgs/vivarium-runner/default.nix:11-18.
    • Evidence:
      • The agent's ExecStart is vivarium-runner/bin/vivarium-agent. This is the same store path as packages.runner.
      • The guest closure holds vivarium-runner-0.2.0.drv, which carries backend.py, machine.py, container.py, nixos_test.py, ocr.py, the runner tests and qemu-qmp.
    • Impact:
      • An edit to backend.py, to machine.py or to a runner test rebuilds every guest's toplevel, root image and store database.
      • This holds in every consumer: pynixd, nixkube and easykubenix.
    • Fix:
      • Make a separate vivarium-agent package that holds agent.py, arpyc.py, channel.py and the guest half of cloud.py.
      • The host runner depends on it, not the reverse.
      • No ./tests in a src that a guest reads.

    A3 The backend abstraction leaks: the core branches on backend names, and the entry-point registry cannot be used (high)

    • Where:
      • machine.py:11-12, 448, 644, 648, 666, 1334, 1473, 1483, 1597-1604;
      • backend.py:1522, 1545, 1770-1773;
      • modules/default.nix:208-215, 956-963, 1126-1131;
      • lib.nix:254-263, 815-818;
      • modules/guest.nix:34-61, 300.
    • Evidence:
      • Machine branches on the backend name for these:
        • the krun allowlist;
        • the writable container view;
        • drop_caches;
        • host_memory_kib;
        • the screen error.
      • MemoryControl = Mconsole | Qmp is a closed union.
      • Krun.launch calls Qemu._scratch_disk and Qemu._passt, two private methods of another backend.
      • backend.py:1770 says other packages add backends through vivarium.backends entry points. On the Nix side, three things stand in the way:
        • vivarium.backend is a closed enum;
        • machineSpec picks boot by backend name;
        • onBackend special-cases qemu and krun.
      • No modules/uml.nix exists. UML-only and qemu/krun-only settings live in default.nix and guest.nix, against the rule.
    • Impact:
      • A third-party backend fails in three places.
      • A change to one backend touches the core files.
    • Fix:
      • Add these capabilities to the backend protocol:
        • a store mode;
        • host_memory_kib;
        • a hook that adds paths;
        • a screen capability.
      • Move the shared helpers into a helpers module.
      • Add modules/uml.nix.
      • Make the enum open, or drop the claim that a backend can be added.

    A4 --kernel edits backend-private JSON from the session, and krun silently ignores it (high for the code path; not run)

    • Where:
      • session.py:168-187, 427-434;
      • backend.py:1502-1510, 1568-1572;
      • cli.py:158-166.
    • Evidence:
      • _with_kernel swaps launch.config.kernel and boot.kernel, but krun boots --vmlinux={boot['vmlinux']}.
      • Krun's kernel check compares the swapped value with itself.
      • The session still logs "booting {kernel}, not the kernel Nix built".
    • Impact: krun boots the old kernel, and the run says it booted the new one.
    • Fix:
      • Make the override a backend operation.
      • A backend that cannot take a kernel refuses the override.

    A5 The spec's top level is strict, and its machines are not checked (high evidence, medium impact)

    • Where:
      • spec.py:29-38, 143-146;
      • machine.py:95-107, 196-226, 307-404;
      • session.py:425-437;
      • lib.nix:214-263.
    • Evidence:
      • Strict forbids unknown fields, because of a measured skew: an older runner ignored pythonPath.
      • machines is a list of plain JSON objects, cast to a TypedDict with total=False and read with .get(default).
      • Nix and Python each hold their own copy of the defaults.
      • boot is a second launch channel beside launch.config, and it mixes boot data with features (nested, display, acpi, efi).
    • Impact:
      • A skew in a machine field fails late, or not at all.
      • A backend has two inputs, and they follow different rules.
    • Fix:
      • One strict pydantic model for a machine.
      • Move boot into launch.config, and give each feature a field of its own.

    A6 A guest kind is bound to one backend through a differently named, shape-detected config section (medium)

    • Where:
      • backend.py:93-149, 227-246, 765-793, 1096-1179;
      • the kind modules' launch.config.{root,disk,boot} lines.
    • Evidence:
      • The section has a different name on each backend: UML root, QEMU disk, krun boot.
      • UmlRoot.of tells the kinds apart by the shape of the value ("initrd" in value).
      • QEMU has a second launch path, _launch_disk, with its own copy of the NIC loop.
    • Impact: a kind needs a new config section and a new parser to run on another backend.
    • Fix:
      • One boot description that does not depend on the backend: disks, an optional kernel, initrd and command line, and a seed.
      • Each backend maps it to its argv, or refuses it.

    A7 The agent's RPC surface is written twice, joined by a cast, and half the agent blocks the channel (medium)

    • Where:
      • machine.py:452-468;
      • agent.py:115-170, 250-254;
      • arpyc.py:250-264.
    • Evidence:
      • The AgentRpc Protocol restates the agent's exposed_* methods by hand, and cast(AgentRpc, conn.root) joins the two. No check compares them.
      • arpyc._dispatch runs a sync handler inline on the loop. Four handlers call _sh(..., 30) synchronously:
        • unit_state;
        • unit_info;
        • list_units;
        • journal.
    • Impact:
      • The contract between host and guest has no single source.
      • A slow systemctl call stalls every call to that guest, cloud replies included.
    • Fix:
      • Declare the Protocol once, in channel.py, with a test against the exposed_ signatures.
      • Make these handlers async, or run them in a thread.

    A8 Two remote-control surfaces, and one makes all of Machine a wire API (medium)

    • Where:
      • remote.py:35-67;
      • control.py:1-25;
      • pytest_host.py:372-419;
      • vivarium_eval/cli.py:262-268, 375-377.
    • Evidence:
      • machines.sock (arpyc) runs getattr on any public Machine attribute, and pytest_host calls methods on it by string.
      • vivarium switch sends generated Python as Op.EXEC, while reload has its own op, Op.RELOAD.
    • Impact:
      • Every public Machine member is an unlisted remote API, so a rename breaks only at run time.
      • Two protocols do one job.
    • Fix:
      • Give machines.sock a typed allow-list, or fold its calls into control.sock.
      • Add Op.SWITCH.

    A9 Backend.launch is synchronous and blocks the event loop that boots guests in parallel (medium; extends #949)

    • Where:
      • backend.py:564-572, 605-634, 781-785, 1207, 1308, 1360, 1465-1478, 1651;
      • machine.py:648, 680;
      • session.py:1120-1138.
    • Evidence: these steps block the loop:
      • time.sleep polls, up to 10 s for the egress and up to 5 s for gvproxy;
      • qemu-img convert of a whole cloud image;
      • qemu-img create;
      • shutil.copytree of a container root file system;
      • storeview.build.
    • Impact:
      • The "parallel" launches run one after another.
      • The console pumps, the control socket and agent calls stall meanwhile.
    • Fix: make launch async, or call it through to_thread. The cost of each call is not measured.

    A10 Machine is one 2,000-line class with six jobs (medium)

    • Where:

      • machine.py: 2,019 lines, Machine at 490-1873;
      • backend.py: 1,798 lines.
    • Evidence: Machine covers six areas:

      • lifecycle and reboot;
      • console;
      • agent RPC wrappers;
      • store views;
      • memory;
      • screen and input.

      Screen and memory exist on every guest, and on most backends they fail at run time.

    • Fix:

      • Split machine.py into spec, guest, agent client, store, screen and memory modules.
      • Make screen and memory capability objects that a backend gives or does not.
      • Split backend.py into a backends/ package.
      • Keep Machine as a facade.

    A11 Run assembly sits in the session, and a second, UML-only entry builds its own spec (medium)

    • Where:
      • session.py:420-527, 547-605;
      • vivarium_runner/cli.py:1-40, 91-98;
      • modules/image.nix:142-146;
      • default.nix:228, 245.
    • Evidence:
      • Session.prepare does mechanism work: segment membership, LAN fds, forward resolution, router wiring.
      • Its own comment says the shared taken set is wrong for an MCP server that holds several runs.
      • vivarium-run is UML-only and builds a LaunchSpec by hand. It is still wired in as system.build.vivariumRunner and in the speedtest app.
    • Fix:
      • A runner-side Run that owns segments, forwards, routing and instances.
      • Remove vivarium-run, or rebuild it on mkTest.

    A12 Nits

    • Socket path length: four mechanisms handle it. Krun._gvproxy checks > 107, but macOS's limit is 104, so a 105-107-byte path passes the check and then fails at bind. Use one helper. Confidence: medium.
    • Duplicated code in backend.py:
      • the subordinate-id error text, at 849-855 and 1493-1499;
      • the cleanup after a failed launch, where only the QEMU copy checks poll();
      • the NIC loop.
    • Stale text:
      • backend.py:8 says "Both backends";
      • __init__.py:3 says "three backends";
      • machine.py:197, 304 say "mkTest in flake.nix";
      • machine.py:3-7 says "the same three fds";
      • pkgs/vivarium-runner/default.nix:43 says "under User-Mode Linux";
      • vivarium_runner/cli.py:24 says the agent "serves one request at a time".
    • Names used twice:
      • vivarium-runner is both the mechanism package and the session's executable;
      • control.py, cloud.py and cli.py exist in two packages;
      • the uml- prefix is on the run directory and the crun names of every backend.
    • Rule breaks:
      • session.py:384 reads vm._history. A public console_tail would replace it.
      • machine.py:527 falls back to report.RUN, a per-run module global.

    Assisted-By: Claude Opus 5.5

  3. Lillecarl commented on Nov 17, 2026

    @Lillecarl
    ContributorAuthor

    Domain 3: speed

    These are the review agent's findings. They are not verified yet.

    The numbers come from three sources:

    • Run reports: 1,624 report.json files and their events.jsonl on disk, from runs between 2026-11-01 and 2026-11-17 on one Linux host, across several revisions of main.
    • Backend comparison: three runs of the same two-guest uplink test on 2026-11-17, one per backend, named vs-uml, vs-qemu and vs-krun.
    • nix eval timings: one or two samples each.

    S1 Guest launches run one after another, about 0.3 s each; half of a container launch is a host probe that repeats for every guest (high; extends A9)

    • Where:
      • backend.py:1644: container.probe runs on every launch.
      • backend.py:1671: tap_fails.
      • backend.py:1715: container.scope, a second cgroup probe.
      • machine.py:680: the launch is synchronous.
    • Evidence:
      • A pynixd run with 5 container guests and 1 QEMU guest shows the exec: lines at 0.28, 0.58, 0.89, 1.22, 1.49 and 1.88 s.
      • Timed inside unshare:
        • container.probe() takes 82–112 ms;
        • tap_fails() takes 26 ms;
        • scope() takes 31–39 ms.
      • The three probes are 140–175 ms of each 0.3 s step.
      • These are not the cause: copytree takes 1 ms, and storeview.build takes 19–35 ms.
    • Impact:
      • With N guests, the last guest starts about 0.3 × N s late.
      • The event loop blocks during the launches.
    • Fix:
      • Probe the host once per session and cache the result.
      • Then make launch async. Do not use a thread; see R7.

    S2 report.json misreports boot time and leaves out launch and teardown (high)

    • Where:
      • machine.py:738: the boot clock starts only after the process is created.
      • cli.py:627-628: write_output runs before teardown.
      • report.py:136.
    • Evidence:
      • In the run in S1, all six boot steps have at: 1.88.
      • One guest is reported at 0.15 s. Its exec was at 0.28 s and its ready line at 2.03 s, so the real time is 1.75 s.
      • Container boot_seconds has a p50 of 1.0 s (n=4,225). The real time is about 1.8 s.
      • In vs-uml, total_seconds is 94.3 s, but the summary says 96.4 s. The 2.0 s difference is the teardown, which is not in the report.
    • Impact: this file is the instrument behind "never guess at slowness". It hides the serial launches and never shows teardown.
    • Fix:
      • Start the clock before backend.launch, and record launch as its own step.
      • Record the teardown steps, and write the report after them.

    S3 Stage 1 costs QEMU and krun guests 3.75–3.89 s per boot, with an idle 1.00 s inside (high for the numbers; medium for the fix)

    • Where:
      • modules/qemu.nix:184: the systemd initrd.
      • modules/qemu.nix:269-274: the root file system, with fsck.
      • modules/qemu.nix:354-362: the /nix overlay.
    • Evidence, from the console, since Nov 1 (QEMU n=1,066, krun n=77):
      • From the initrd banner to "Welcome", p50: 3.89 s on QEMU, 3.75 s on krun.
      • Whole boot to "Startup finished", p50: QEMU 8.78 s, krun 8.13 s, UML 8.77 s. UML has no initrd.
      • Inside stage 1, p50 QEMU / krun:
        • fsck of a disk that is new on every run: 0.20 / 0.14 s;
        • from "Mounting /sysroot" to "Mounting /sysroot/nix": 1.00 / 1.00 s (p90 1.02 / 1.00);
        • from switch root to "Welcome": 1.21 / 1.19 s.
      • About 2.2 s of this is specific to the initrd.
    • The cause of the 1.00 s gap is an unmeasured hypothesis: a timer, or a daemon-reload. The early journal is lost (J1), so it cannot be traced.
    • Fix:
      • Set fileSystems."/".noCheck = true. The disk comes from mkfs and is new on every run.
      • Boot once with initrd debug logging to find the 1.00 s.
      • Longer term: boot QEMU and krun without an initrd, which saves about 2.2 s per boot. That reverses the decision recorded in qemu.nix:3-7.

    S4 Teardown takes 18 s p50 for a seven-guest container and QEMU run, and up to 9 s of it has no event (medium; extends #1182)

    • Where:

      • session.py:1082-1094;
      • machine.py:891-940, with POWEROFF_GRACE = 20;
      • storeview.py:126-148: one bind mount for each closure path;
      • cli.py:568-574: the drain waits up to 5 s.
    • Evidence: time from run_finished to the summary, since Nov 14:

      guests p50 p90 n
      1 3.4 s 5.0 s 226
      2–4 2.3 s 7.3 s 75
      5 or more 18.0 s 25.3 s (max 31.5 s) 53
      • The runs with 5 or more guests are mostly pynixd's suite. Pure UML runs with 5–7 guests take 7–8 s.
      • Two runs on Nov 17:
        • each container guest's systemd stops about 770 store mount units, which takes 1.7–5.0 s;
        • one guest's /artifacts unmount took 7.5 s;
        • after that, 7.4–8.7 s pass with no event at all.
    • Impact: about 18 s after the verdict, in CI too, for a guest disk that is thrown away.

    • Fix:

      • In a check (--no-control), send SIGKILL after the final drain, or power off with a grace of about 2 s.
      • Keep the orderly power-off for --hold and interactive runs.
      • Add events for the reap, the cleanup and the drain.
      • Present the store to container guests as fewer mounts.

    S5 Every phase spends 0.34–0.55 s after its body (medium for the numbers; low for the cause)

    • Where:

      • session.py:678-717: settle sends one token RPC to each guest in series, then polls every 20 ms until the token comes back through the journal stream.
      • session.py:978-981.
    • Evidence: p50 overhead per phase, by backend, for one guest and for two or more:

      backend 1 guest 2 or more
      container 0.37 s 0.39 s
      UML 0.43 s 0.52 s
      QEMU 0.43 s 0.54 s
      krun 0.34 s 0.55 s
      • The RPC itself takes 4–39 ms. The rest is a wait on the journal path, which is not split further.
    • Impact: 20 phases cost 7–11 s.

    • Fix:

      • Send the tokens in parallel.
      • Measure where the wait goes.
      • Settle only on failure, at a pause and at the end of the run.

    S6 Nits

    • Poll intervals (Test waits: watch for progress instead of long fixed deadlines #1092):
      • wait_for_unit polls every 0.5 s, and wait_until_succeeds, until and never poll every 1.0 s.
      • A round trip to the guest takes 10–14 ms.
      • Of 5,082 waits since Nov 1, 3,812 polled more than once.
      • Fix: loop inside the agent, or watch the unit through D-Bus.
    • Evaluation:
      • checks.lan.driver takes 4.5–4.9 s, checks.k8s.driver 10.0 s, and an extend of one node 3.4–3.7 s.
      • reload builds the whole .driver, so a reload of phases alone pays 4.5–10 s.
      • .phases costs 4.0–4.8 s because checkedConfig forces every node's vivarium.nics.
    • Root image size:
      • The image in the store is diskSize, 512 MiB, for about 17 MiB of content.
      • nix-hash of one image takes 0.55 s, and every change to a guest's closure rebuilds the image.
      • Fix: build the image at its content size, and grow it at launch.
    • UML userspace (extends vivarium: UML speed with less isolation inside the guest, and SMP #1412): systemd's userspace phase has a p50 of 7.14 s on UML, against 4.28 s on QEMU and 3.54 s on krun.
    • Agent import (evidence for A2):
      • Importing vivarium_runner.agent takes 104–119 ms. It loads 17 modules, because __init__ pulls in machine, backend, qmp and ocr.
      • It is not on the critical path.

    J1 The journal stream drops everything logged before it starts (high; outside speed)

    • Where: modules/guest.nix:379-397.
    • Evidence:
      • The comment says --boot carries everything logged earlier. But journalctl --follow starts with only the last 10 entries, and journalctl(1) says --no-tail shows all of them.
      • In vs-uml, the first entry in journal.jsonl has __SEQNUM 275.
      • None of 5,609 journal.jsonl files starts at sequence number 1.
    • Impact:
      • The early-boot and initrd journal never reaches events.jsonl.
      • A boot failure before the stream starts leaves only the console.
    • Fix: add --no-tail to the journalctl arguments.

    Assisted-By: Claude Opus 5.5

  4. Lillecarl commented on Nov 17, 2026

    @Lillecarl
    ContributorAuthor

    Domain 4: UX and DX

    These are the review agent's findings. They are not verified yet.

    U1 Commands in the docs that pass no --out fail at argument parsing (high)

    • Where:
      • README.md:48: checks.lan.driverInteractive;
      • docs/reference.md:218 and :677.
    • Evidence:
      • The runner requires --out (vivarium/cli.py:132-138).
      • driverInteractiveHere passes none (lib.nix:796).
      • The parser, run on these flags, prints the following arguments are required: --out and exits 2.
    • Impact: the third line of the README's "Try it" block fails.
    • Fix:
      • Add -- --out ./out to the three lines, or give driverInteractive a temporary --out by default.
      • Add a docs test that parses each nix run line with the runner's parser.

    U2 vivarium run --help hides every runner flag, and run with no --out evaluates and builds before it fails (high)

    • Where: vivarium_eval/cli.py:101-124, 149-170, 435-462.
    • Evidence:
      • run --help lists only --file and --until-pause, and up --help lists only --file.
      • The pass-through flags appear on no vivarium help screen:
        • --out, --break, --break-on-failure, --hold, --only;
        • --offline, --serial, --kernel, --cpus, -v/-q.
      • Plain run with no --out evaluates, builds, execs the runner, and only then fails. up and --until-pause check --out first.
    • Impact:
      • An agent cannot find --break-on-failure or --hold through --help.
      • A forgotten --out costs a whole evaluation and build.
    • Fix:
      • Share the runner's options into run and up, the way add_ctl and add_monitor already are.
      • Require --out before evaluating.

    U3 Exit codes collide, and six places list them differently (high)

    • Where:
      • monitor.py:142-154;
      • vivarium/cli.py:735-737, 750-755, 766, 789-791;
      • vivarium_eval/cli.py:320-321, 364-366, 475-477, 541-559.
    • Evidence:
      • Exit 1 has three meanings:
        • the run failed (for ctl continue --wait);
        • no run is listening;
        • the run refused the request. So a continue --wait on a running run reads as a failed run.
      • Exit 2 has two meanings: no verdict, and argparse's usage error. Several CLI refusals also use 2.
      • down gives 1 both for "no run" and for "a phase failed".
      • Six places list the codes, and they disagree:
        • run --until-pause help: 0 1 2 4 5;
        • ctl --wait help: 0 1 4 5 6;
        • monitor: 0-6;
        • howto.md:64-70: 0-4;
        • howto.md:133-135: 0 1 4 5 6;
        • the MCP instructions: no 5.
    • Impact: the docs tell agents to act on the exit code alone. A transport error then reads as a verdict.
    • Fix:
      • One IntEnum, with separate codes for "no run listening" and "refused", outside the verdict range.
      • Render every help text, the MCP instructions and the howto table from it.

    U4 Machine.succeed returns stdout and stderr joined, so the howto's json.loads(await vm.succeed(...)) breaks on any warning (high)

    • Where:
      • agent.py:57-69, 131-132: done.stdout + done.stderr;
      • machine.py:1233-1243;
      • docs/howto.md:379.
    • Evidence:
      • The nixos-test shim works around this with exec 2>/dev/console (nixos_test.py:107-112). Native phase scripts get no such protection.
      • The monorepo has 14 call sites of the form json.loads(await …succeed(.
    • Impact: a phase that parses output fails with JSONDecodeError on the first deprecation warning.
    • Fix:
      • Return stdout only, and send stderr to the event stream.
      • Or return a result type.
      • At the least, document the join.

    U5 .driver is documented as stopping at the first failure, but it runs every independent phase (high)

    • Where:
      • README.md:110;
      • skill/vivarium/SKILL.md:16;
      • the comment at lib.nix:788.
    • Evidence:
      • phases.py:7: "a failed phase skips what depends on it and nothing else".
      • _schedule keeps launching phases.
      • README.md:98-100 contradicts line 110.
    • Fix: say "runs every phase that does not depend on a failed one, then exits 1".

    U6 MCP replies, channel events and failure lines have no size bound, and tools pass raw socket errors (medium-high)

    • Where:
      • server.py:507-535, 592-627, 653-683;
      • monitor.py:118-121;
      • session.py:927-944;
      • machine.py:1242.
    • Evidence:
      • Nothing on the path truncates text. SKILL.md:101 records a 233k-character reply as a usage rule instead of fixing it.
      • A failed succeed puts its whole output into the phase error. That error is then:
        • printed twice;
        • one monitor line;
        • one channel event.
      • Most tools call request() directly. Before control.sock exists, they fail with a bare FileNotFoundError.
      • state on an exited run gives only exited N, although phases.json holds the verdict.
    • Fix:
      • Keep the head and tail, and write "N bytes elided; full text in ".
      • Cap limit=0.
      • Wrap request() with "still evaluating or building".
      • Make state read phases.json.

    U7 The MCP server cannot reach runs it did not start, against what the howto says (high)

    • Where: server.py:338-342; howto.md:314-315.
    • Evidence:
      • Runs.get knows only the runs this server process started.
      • The howto says the MCP server reaches pytest-plugin runs "as any run".
    • Impact: through MCP, an agent cannot reach these runs:
      • a vivarium up environment;
      • a pytest-plugin run;
      • a run started from the shell;
      • any run, after the server restarts.
    • Fix:
      • Accept an --out path or a registry.runs() id, and add an attach tool.
      • Until then, correct the howto.

    U8 Progress goes to stdout from the runner and to stderr from the CLI, and stderr is never quiet (medium)

    • Where:
      • vivarium/sinks.py:46-48;
      • vivarium/cli.py:391;
      • vivarium_eval/cli.py:323-374, 407-409, 444-454, 495-497.
    • Evidence:
      • vivarium run X prints evaluate and build lines on stderr, then execs the runner. The runner sends every phase line to stdout.
      • switch and reload print progress on stderr on every success.
      • up has to redirect the monitor to keep its stdout clean.
    • Impact: this breaks the CLI rule that stdout carries the result and stderr stays quiet.
    • Fix:
      • The terminal sink writes to stderr.
      • stdout carries only a result.
      • Success lines appear only with -v.
      • If stdout for the runner is deliberate, write it down as an exception.
    • Confidence: medium.

    U9 The pytest-host guest proxy fails silently on a property and cannot run the waits the howto prescribes (medium; not run)

    • Where:
      • pytest_host.py:90-110;
      • remote.py:58-68;
      • howto.md:292-295, 371-395.
    • Evidence:
      • Every public name becomes a coroutine function. So vm.uplink_ip == "10.0.2.15" is always false, and if vm.ip: is always true.
      • until, never, vms.until and waiting() cannot cross the proxy, and the howto prescribes exactly those.
      • The proxy is typed Any, so zuban catches nothing.
    • Fix:
      • A typed Protocol of the allowed calls.
      • Raise an error on a property or on a method that is not a coroutine.
      • Run until and never on the host side, or document the limit.

    U10 The first-test path has gaps for a user outside nixidae (low-medium; not run)

    • Where:
      • README.md:34, 55-81, 217-226;
      • docs/getting-started.md:12-16, 53-55;
      • nix/sources.nix:17-18;
      • default.nix:14-19.
    • Evidence:
      • The README's test example uses sources.vivarium and an unbound pkgs.
      • "Read more" does not link getting-started.md.
      • getting-started uses import <nixpkgs> { }, which default.nix warns against. A first test may compile the UML kernel.
      • builtins.fetchTree needs the fetch-tree feature outside flakes, and no page says so.
      • test-options.md and guest-options.md are dead links on GitHub.
      • The CLI is said to be "on PATH in the dev shell", but an outside user has no such shell.
      • The README says the host is Linux on x86_64 only. The howto documents macOS.
    • Fix:
      • Link getting-started first.
      • Give a standalone snippet.
      • State the cost of the first build and the feature it needs.
      • Show how to get the CLI.
      • Use absolute links for the option pages.

    U11 Nits

    • The printed-commands sample in howto.md:20-26 is stale: control.commands() also prints stop, and reload and switch for a run the CLI started.
    • The MCP start docstring (server.py:453-454) tells agents to set UMBRELLA_DEV: nothing reads that variable.
    • monitor's description says it follows a run that vivarium-mcp started: it follows any run.
    • Overloaded names:
      • "reload" names three things;
      • ctl --wait is a flag, while monitor --wait takes seconds;
      • the CLI and MCP names differ: continue/resume, ctl run/run_phase, ctl pytest/run_pytest, --break/breaks;
      • --break-on-start duplicates --break start.
    • driver -- --help is misleading: it prints usage: vivarium run … --spec SPEC, with --spec required, although the wrapper already sets it.
    • Machine's positional arguments differ:
      • The third positional of execute is label, but the third of succeed is env.
      • timeout=0 silently means the default.
    • The README's CLI list (README.md:188-189) is incomplete: it omits up, down, ls and closure.
    • SKILL.md:21 omits driver flags: --hold, --serial, --interactive, --kernel and -q.

    Assisted-By: Claude Opus 5.5

  5. Lillecarl commented on Nov 17, 2026

    @Lillecarl
    ContributorAuthor

    Domain 5: maintainability and house rules

    These are the review agent's findings. They are not verified yet. The ruff numbers come from the root's ruff 0.16.10, run with vivarium's own ruff.toml and --exclude docs/design.

    M1 No gate runs ruff on vivarium, and the code has drifted from its own rules (high)

    • Where: tests/check-python/default.nix:22-27 (zuban only), ci/workflows.nix:522-528, ruff.toml:1-7.
    • Evidence:
      • No vivarium check and no root check runs ruff over vivarium.
      • ruff check reports 25 findings: 20 I001, SIM300, RUF022, RUF043 and RUF059.
      • ruff format --check would reformat 24 files.
      • ruff.toml extends the shared ruff.toml, not ruff-anyio.toml. So the anyio ban is not configured.
      • A new gate would fail at once on docs/design/macos-guest-spike/: 3.14 syntax under a py312 target.
    • Fix:
      • Add a checks.lint that runs ruff check with the anyio config and ruff format --check, and run it in the checks CI job.
      • Exclude docs/design and lab.
      • Apply the safe fixes first.

    M2 vivarium-eval (the vivarium CLI and vivarium-mcp) has no gate (high)

    • Where: default.nix:110-114, 250-256, pkgs/vivarium-eval/default.nix:55-72, tests/check-python/default.nix:23.
    • Evidence:
      • Neither checks nor CI names vivarium-eval.tests (zuban strict and pytest) or internal.mcp-check. The stated reason is that CI would have to build nanopynix.
      • check-python loops over the other three packages only.
      • So 1,312 lines in server.py and cli.py that agents use are untested in CI.
    • Impact: a change in the runner or the session that breaks the CLI lands green.
    • Fix: add both to a CI job. nanopynix is already cached for the other sources.

    M3 The shared ban list misses three asyncio spellings, so #949 sees a quarter of the sites; cloud.py adds new bare asyncio (high; extends #949)

    • Where:
      • machine.py:36, 710, 728, 778, 847-848;
      • arpyc.py:261, 325;
      • vivarium/cloud.py:11-215;
      • vivarium_runner/cloud.py:138;
      • nix/shared/ruff-anyio.toml.
    • Evidence:
      • Not banned: asyncio.ensure_future (7 sites), start_unix_server and open_unix_connection.
      • from asyncio import subprocess dodges the create_subprocess_exec ban.
      • The anyio config gives 13 TID251 findings in pkgs/. The 10 unstructured sites above are invisible to it.
      • machine.py:728, 778, 848 have no comment saying why they stay unstructured, which the rules require.
      • vivarium/cloud.py is new code (vivarium: guests created at run time, through a cloud API that guests call #1408) and uses asyncio.Event, asyncio.timeout, asyncio.sleep and ensure_future.
    • Fix:
      • Extend nix/shared/ruff-anyio.toml through shared-config-update.
      • Comment or restructure the three machine.py sites.
      • Write cloud.py with anyio primitives now.

    M4 Library modules print, and their output reaches events.jsonl without its machine, or not at all (medium)

    • Rule: "Never print in the runner: Session.emit is the one way in."
    • Where:
      • vivarium_k8s/__init__.py: 13 sites;
      • forward.py:441, 443, 472, 474;
      • net.py:342;
      • session.py:1147;
      • machine.py:1084.
    • Evidence:
      • The captured stdout becomes OUTPUT events with phase= only, so a filter on the k8s guest's name misses every progress line.
      • net.py:342 and session.py:1147 run at teardown, outside any capture. Their output never reaches log or events.jsonl. That includes the warning for a guest that did not shut down cleanly.
    • Fix:
      • Give Machine and the recipes an emit callback.
      • Route these sites through Session.emit with machine=.
      • Enforce it with ruff T201, with per-file ignores for the CLIs and the tests.

    M5 monitor.py reads events as raw dicts and string literals, beside the typed Event and Kind (medium)

    • Where:
      • monitor.py:84-177, 242-270, 334-343;
      • server.py:105, 327-330;
      • events.py:51-81.
    • Evidence:
      • The monitor compares kind with string literals.
      • Pause, resume and ready are all kind == "note", told apart by which data key is present.
      • The channel events carry booleans as the strings "true" and "false".
      • events.py has no parse function.
    • Impact:
      • A rename breaks the monitor and the MCP server silently.
      • This is the same root cause as the exit-code drift in U3.
    • Fix:
      • Add Event.from_dict and a phase-state StrEnum.
      • Give pause, resume and ready their own kinds.
      • Type the channel events.
      • Add a meta test that no module compares a Kind value as a string.

    M6 pytestCheck is documented as vivarium.lib.pytestCheck but is not exported (high)

    • Where: lib.nix:369-386, default.nix:143-165.
    • Evidence: nix eval --file vivarium lib --apply builtins.attrNames does not list pytestCheck.
    • Impact: another project cannot use the pytest-plugin path of vivarium: a pytest plugin, so plain pytest drives guests #1413 as documented.
    • Fix:
      • Export it.
      • Add a check that every vivarium.lib.X named in a /** */ example exists.

    M7 Ten checks interpolate all of tests/checks/, so an edit to one check script reruns all ten guest checks (medium)

    • Rule: every src is a lib.fileset allow-list.
    • Where:
      • ${../checks}/<script>.py in ten tests/*/default.nix;
      • tests/check-python/default.nix:23: the whole package directories;
      • pkgs/vivarium-eval/default.nix:66-67;
      • tests/check-scripts/default.nix:28.
    • Impact: minutes of guest time per edit, locally and in the CI sessions job.
    • Fix: one fileset helper in tests/default.nix that gives harness.py plus the one script.

    M8 run.sh is dead, and it is bash (high)

    • Where: run.sh:11, kept by .gitignore:24.
    • Evidence:
      • It builds vivariumRunner. nix eval says that attribute does not exist; it lives at internal.vivariumRunner.
      • It writes to fixed paths in /tmp.
      • Nothing references it.
    • Fix: delete it.

    M9 Values written twice (medium)

    • Uplink addresses: forward.py:387-394, 430 hard-codes 10.0.2.15/.2/.3 and fd00:10:0:2::2, and modules/router.nix:28-33, 125, 326 declares them again. Fix: put them in the spec.
    • Wait loop:
      • vivarium_k8s._until (160-200) reimplements Machine.until.
      • wait_until_succeeds is its own loop, while wait_until_fails calls until.
      • Fix: give until a progress callback.
    • Verdict reader: the bash verdict reader exists twice, at lib.nix:432-444 and lib.nix:880-906. Fix: one Python script.
    • Spec defaults (extends A5):
      • The defaults are written three times: in MachineSpec, in from_json and in Nix.
      • backend, kind, seccomp and uplink_proxy are typed str and should be StrEnum.
    • Lower bound: pyedit index finds 4 exact duplicates in the test helpers. The index is stale.

    M10 Exported library attributes lack /** */ doc comments (medium)

    • Where: runner (lib.nix:33), k8s (:52), typeCheck (:127), mkNode (:340), cacheFacts (:446).
    • Impact: nixdoc drops these comments, and typeCheck and mkNode are the functions outside callers call.
    • Fix:
      • Convert the five.
      • Add a meta check that every lib name has a /** comment.

    M11 Comments that tell history, or have gone stale (medium)

    • A regex finds about 12 real history comments beyond A12, among them:
      • lib.nix:3;
      • sinks.py:43;
      • modules/default.nix:603;
      • modules/guest.nix:285, 415;
      • vivarium_k8s/__init__.py:62, 262;
      • session.py:339, 1014;
      • backend.py:1303.
    • Stale text:
    • Comments and docstrings are 26 % of the non-blank lines in pkgs/, and 46 % in vivarium_k8s/__init__.py.
    • Fix:
      • Rewrite these comments in the present tense.
      • Add a meta test for the banned phrases.

    M12 Nits (each one a lint can enforce)

    • from __future__ import annotations: 121 of 219 files lack it. The library files among them:
      • vivarium_k8s/__init__.py;
      • crun_launch.py;
      • vyos-footer.py;
      • modules/instance.py;
      • three __init__.py.
    • assert outside the tests: 6 sites, in machine.py, forward.py, container.py and backend.py. S101 catches them.
    • Imports inside functions: 5 that break no import cycle, in backend.py:345 and container.py:776-777, 877. PLC0415 catches them.
    • Suppressions:
      • 4 have no reason, in sinks.py:178, session.py:1146 and pytest_plugin.py:195, 200.
      • 25 noqa directives name rules that vivarium does not select.
    • os.path and plain open(): 41 PTH findings in pkgs/. kernel and image at machine.py:98, 112, 203 are host paths typed str.
    • Bash left:
      • typeCheck's loop (lib.nix:196-205);
      • vivarium-k8s-cni and vivarium-k8s-join (modules/k8s.nix:372, 436). The join script uses sed on values the user supplies.
    • lab/router/*.py: these scripts use a shebang for one person's host, and they are in the ruff tree.
    • No problems found:
      • No // that should be lib.mkMerge.
      • No dead Python modules beyond run.sh.
      • The search could not prove any Nix option dead.

    Assisted-By: Claude Opus 5.5

  6. Lillecarl commented on Nov 17, 2026

    @Lillecarl
    ContributorAuthor

    Domain 6: tests and CI coverage

    These are the review agent's findings. They are not verified yet.

    T1 CI publishes every test verdict and replays it later, so a green run can boot no guest, and a flake stays red (high)

    • Where:
      • ci/lib.nix:67: pushFilter = "(-vivarium-test-)";
      • lib.nix:839-854: the attempt is named vivarium-session-${name}-attempt;
      • lib.nix:880: the reader.
    • Evidence:
      • No test output is named vivarium-test-*, so the filter excludes nothing. Neither derivation sets allowSubstitutes.
      • test-forward (run 44104177551) logged Pushing …-vivarium-session-forward-attempt.
      • In the green run 43862556000 (main, 2026-11-16), 37 jobs together substituted 40 attempts from lillecarl.cachix.org. No job logged building '…-attempt.drv', so that green run booted no guest.
      • Two dispatches on commit 554ceb3 both copied uplink-iperf-attempt from the cache.
    • Impact:
      • A daily run on unchanged inputs proves nothing.
      • A cached attempt with status 1 keeps a flake red until an input changes.
      • A developer who has the cache configured gets CI's verdict from nix build.
      • The ssh-ng builder store, which is also a trusted substituter, receives every attempt as a build input.
    • Fix:
      • Set allowSubstitutes = false on the attempt.
      • Correct the filter to -vivarium-session-.
      • Upload a failed attempt as a CI artifact. The accidental cachix push is today the only way to fetch one.
      • Document nix build --rebuild … <test>.attempt.

    T2 Most red jobs in the daily run fail for reasons outside vivarium, and UML tests run on the remote builder (high)

    • Where:
      • nix/ci.nix:58: the remote builder is added to every job when the actor is Lillecarl;
      • ci/workflows.nix:428: a step gets the job's limit minus 10 minutes;
      • lib.nix:880-900.
    • Evidence: the one scheduled run, 44104177551, had 49 jobs and 33 of them red.
      • test-lan and sessions failed with pynixd: store local did not answer QueryValidPathsRequest within 300 s.
      • test-artifacts, test-reboot, test-reboot-krun and test-screen printed [vivarium] passed. Their step then timed out while it copied a 512 MiB root image to the builder, to build a reader that only runs cat status.
      • test-container timed out in its 5-minute probe step.
      • UML attempts and the typecheck derivations build on the remote builder.
    • Impact:
      • A red daily run is mostly noise.
      • The UML results describe the builder host, not the runner.
      • CI behaves differently for other actors.
    • Fix:
      • Set preferLocalBuild = true; allowSubstitutes = false; on both readers.
      • Decide on purpose where UML attempts run.
      • Report the pynixd stall as a pynixd issue.

    T3 A failed CI run keeps no evidence, and nothing reports it beyond GitHub's default mail (medium)

    • Evidence:
      • The workflow has no if: failure() step and no upload-artifact step. pynixd-tests.yml:57 has both.
      • The build uses --no-link, so the attempt dies with the runner.
      • The daily run costs 713 runner-minutes.
    • Fix:
      • On failure, upload <attr>.attempt.
      • Add a final job that opens or updates one issue when a scheduled run is red.

    T4 22 checks run in no CI job, and no list says which ones are by hand on purpose (high)

    • Evidence: the checks that no workflow builds, in three groups:
      • UML, which fits the sessions job: cloud and launch (vivarium: guests created at run time, through a cloud API that guests call #1408, the newest feature), python-packages, cache, lan-router, nixos-compat, nixos-tests and suse.
      • kvm plus uid-range, which the QEMU and container jobs already have:
        • store-view: store isolation on all four backends;
        • segments;
        • backends;
        • mixed: its file says "the session job has no /dev/kvm", but other jobs have it.
      • By hand, with a reason in the file: nested, kata, kata-containerd, nixos-screen-tests, appliance, vyos, routeros-route, crio and containerd-zero-layers.
    • Impact:
      • These areas can break unnoticed: the cloud API, template launch, the nixos-test shim (a public API), and store isolation.
      • A new check lands outside CI silently.
    • Fix:
      • Move the first two groups into jobs.
      • Add byHand = { name = "reason"; } in ci/workflows.nix.
      • Add a check that every name in checks is either in CI or in byHand, in both directions.

    T5 The container backend and macOS hardly run in CI, and no contract test runs on all four backends (medium)

    • Evidence:
      • No job builds a .container variant. The container backend runs only checks.container and container-lan: one guest each, with no uplink and a read-only store.
      • forward, artifacts and fuse run on QEMU only.
      • lan runs on UML and krun-vsock only.
      • The session rules run on UML only.
      • No vivarium job runs on macOS. forward.py's darwin branches have only a unit test that patches sys.platform.
    • Impact: CI never proves "a test never knows the backend" (compare vivarium: checks.memory fails on the container backend #1188).
    • Fix:
      • A matrix of artifacts, forward and fuse on all four backends.
      • Name the darwin gap in byHand.

    T6 No negative control for the verdict reader, and a guest that will not stop never fails a check (medium; extends #1165)

    • Where:
      • lib.nix:433-445, 852-853, 880-900;
      • cli.py:627-628: status is written before teardown;
      • session.py:1141-1147: teardown swallows each failure.
    • Evidence:
      • No check builds a failing <test> and expects the build to fail.
      • No check covers a runner that dies before it writes status.
      • vivarium has no leaks phase like pynixd's.
    • Impact:
    • Fix:
      • Run testers.testBuildFailure over a failing session and over pytestCheck.
      • Add a check that kills the runner before write_output.
      • Count the guest processes left after teardown, and fail or emit ERROR if any remain.

    T7 The offline guarantee is printed, never asserted (medium)

    • Where: tests/phases/uplink.py:1-41, pkgs/vivarium/tests/test_namespace.py:26.
    • Evidence:
    • Fix: make uplink.py assert the expected answer, and run it in a job with --offline, as test-k8s-pull runs its driver.

    T8 Unit tests miss pure logic that only guest tests reach (medium)

    • forward.py:
      • The string to_args/_spec builds for passt is never asserted.
      • No test runs _assign for two Linux guests with a non-empty taken.
    • vivarium-egress:
      • encode/decode has no round-trip test.
      • parse_spec has no test against what egress_args produces.
      • uml-passt-bridge (298 lines) has no tests.
    • spec.py: the _one_kind validator is untested.
    • monitor.channel_event: its only direct tests are in vivarium-eval, which no gate runs (M2).
    • phases.py:
      • No test covers passed() with INTERRUPTED.
      • passed({}) is True.
    • Fix:
      • Add these unit tests.
      • Move the channel_event tests into pkgs/vivarium/tests.

    T9 No local equivalent of the CI matrix (medium)

    • Evidence:
      • The set of attributes CI builds exists only in ci/workflows.nix.
      • A local "what CI runs" means typing 51 job lines.
    • Fix: derive internal.ci, a linkFarm of every CI attr, from the same data that renders the workflow. T4's check can reuse it.

    T10 Nits

    • ci/workflows.nix:496: test-k8s-pull waits on kernel, but k8s-pull is a QEMU test. Its comment at 476-490 is stale.
    • ci/workflows.nix:537: the comment says "five checks in one job", but the job lists 18.
    • The step limit: a 15-minute job leaves 5 minutes for the step (see T2).
    • Attempt names (lib.nix:840): every backend variant has the same attempt name. Add the backend to the name.
    • test_monitor.py:348, 369: both prove an absence by waiting out a timeout. A slow wrong answer passes.
    • test_forward.py:18-27: free_port_above checks a port and binds it later, so it can race other processes on darwin.

    Assisted-By: Claude Opus 5.5

  7. Lillecarl commented on Nov 17, 2026

    @Lillecarl
    ContributorAuthor

    Verdicts

    The main session checked these findings against the code at a260990: A1, A4, J1, M6, M8, R3 (the mechanism only), T1, U1, U4, and U3 (in part). The others are taken on the review's evidence. Each issue repeats what it carries.

    Fix: one issue per theme

    Issue Findings
    #1474 the kind assertions never run A1
    #1475 a separate agent package A2, S6 agent import
    #1476 --kernel on krun A4
    #1477 arpyc channel hardening R3, R4, R5, R10 _pending, A7
    #1478 typed guest timeouts; the pytest deadline R6, R9
    #1479 lifetime-chain gaps R7, R8, R10 OOMScoreAdjust
    #1480 the journal drops early entries J1
    #1481 report.json, serial launch, teardown, settle S1, S2, S4, S5
    #1482 stage 1 cost; root image size S3, S6 image
    #1483 exit codes and the typed event model U2, U3, M5, U11 vocabulary
    #1484 docs and exports that are not true U1, U5, U10, U11, M6, M8, M10, R10 cloud limits (docs)
    #1485 MCP bounds and attach U6, U7
    #1486 a typed remote Machine surface U9, A8
    #1487 lint gates and house rules M1, M2, M3, M4, M7, M9, M11, M12, A12
    #1488 one strict machine spec A5, M9 spec and uplink constants
    #1489 CI verdict caching and evidence T1, T2, T3, T10
    #1490 CI coverage and internal.ci T4, T5, T9
    #1491 negative controls, leak check, offline assertion, unit tests T6, T7, T8

    Security, in the private tracker:

    • R1 is nixidae/security#45.
    • R2 is nixidae/security#46.
    • R10's access/ mode, socket window and host-loopback reach are nixidae/security#47.

    Needs a decision

    Covered by an existing issue, no new one

    Will not fix

    Order

    First the ones that make every later measurement and verdict true:

    1. vivarium CI: verdicts are cached and replayed, readers build on the remote builder, and failures keep no evidence #1489, CI replays its verdicts.
    2. vivarium: the journal stream drops everything logged before it starts #1480, the journal.
    3. vivarium: a guest kind's assertions never run, so wrong backend variants evaluate and boot #1474, the kind assertions.
    4. vivarium: docs and exports that are not true #1484, the docs.

    Then #1487, the gates, so that the rest lands under a lint.


    Assisted-By: Claude Opus 5.5

  8. Lillecarl commented on Nov 17, 2026

    @Lillecarl
    ContributorAuthor

    Domain 2: robustness

    These are the review agent's findings. They are not verified yet. The verdict comment checks each one before an issue is opened.

    R1 Host isolation of UML guests in impure runs (high)

    • The finding gives a path from local access on the host to the runner user's files. It works while an impure run or a vivarium up environment is up. Sandboxed checks are not affected.
    • It has two causes:
      • a guest-side file system feature that is not confined;
      • a guest login whose credentials are well known.
    • Details: nixidae/security#45 (private).
    • Fix direction:
      • confine the host-side mount to a directory for each guest;
      • give each run its own login key.
    • Confidence: high for the two mechanisms. The chain is not run end to end.

    R2 QEMU guests: host-side trust of guest-written data (medium)

    • Three places trust data that the guest controls more than they should:
      • the virtiofs daemon runs without its sandbox;
      • a guest-written boot description is used without validation;
      • screenshots are written into a directory the guest can modify.
    • Details: nixidae/security#46 (private).
    • Fix direction:
      • run the sandboxed virtiofs mode;
      • accept only boot files from the store;
      • write host-side files outside the shared directory.
    • Confidence: medium.

    R3 After the agent channel closes, a call writes to a closed or reused file descriptor (high; not run)

    • Where:
      • arpyc.py: FdStream.write at 125-130, call at 245-246, 277-283 and 329-340, close at 344-354.
      • machine.py: _reboot at 817-834, crash at 1032-1058, and 1213-1223.
    • Evidence:
      • close() runs os.close(fd). It does not stop the _answering tasks, and nothing checks _closed before a write.
      • Reboot keeps the old AgentControl in _control for up to 180 s.
      • _boot's socket.socketpair() most likely gets the freed descriptor number back.
      • So, depending on timing, an execute in that window does one of two things:
        • raises EBADF;
        • writes into the new guest's channel and waits out its full timeout. Its stale reply carries the old sequence number.
      • tests/reboot.py:38 already catches OSError while it polls.
      • The same happens after crash() or a UML panic, and when a guest deletes its own instance through the cloud API.
    • Impact:
      • Errors name the wrong cause.
      • A command can reach the wrong guest.
      • Junk can be written to an unrelated descriptor.
    • Fix:
      • call and _send raise EOFError at once when the connection is closed.
      • close() cancels the _answering tasks.
      • _reboot and crash clear _control.
      • FdStream.write refuses to write after close.

    R4 arpyc writes with a blocking os.write on the event loop (medium-high)

    • Where:
      • arpyc.py:85-87, 125-130;
      • machine.py:676, 770: the socketpair is blocking, and no code calls set_blocking.
    • Evidence:
      • A scratch script:
        • a detached socketpair end is blocking;
        • a 4 MiB write that nobody reads blocks.
      • The docstring assumes that every frame is small. A command can carry file contents, and cloud replies are host writes too.
    • Impact:
      • A slow guest stalls every console pump, the control socket and the journal follower.
      • A guest that wedges in the middle of a frame freezes the loop:
        • fail_after cannot fire;
        • SIGTERM is not handled;
        • only SIGKILL ends the run, and it loses the evidence.
    • Fix: make the descriptor non-blocking. Write through add_writer with a send lock for each connection, or through an anyio stream.

    R5 arpyc trusts the peer's frame length, and reports protocol errors as a dead guest (medium)

    • Where:
      • arpyc.py:154-158, 285-325;
      • remote.py:71-76.
    • Evidence:
      • A 4-byte length leads straight to readexactly(length), which buffers up to 4 GiB.
      • serve_forever catches only EOF and OSError.
      • A brine or zlib error ends the loop inside _serving, a task that nothing awaits. Pending calls then get "connection closed", and _ask says "guest went away".
      • On machines.sock, the same exception stops listener.serve. This is the shape of vivarium: a ctl client that disconnects mid-exec ends the run #1166 on the other socket.
    • Fix:
      • Cap the frame length and raise a ProtocolError that names the guest.
      • Pass the real exception to the pending calls.
      • Keep a client's failure inside its handler.

    R6 A timeout inside the guest reaches the host as the wrong error (high)

    • Where:
      • agent.py:57-69, 97, 131, 138;
      • machine.py:1164-1180, 1792-1809;
      • recipes/boot.py:24.
    • Evidence: a scratch round trip showed two things:
      • A guest TimeoutError arrives as a real TimeoutError. So:
        • a slow dinit boot reads as "guest stopped answering during: system_state";
        • an execute past its timeout raises a generic exception, not MachineError.
      • A guest subprocess.TimeoutExpired arrives as a generic rpyc exception with the message ('sleep 5', 0.2). So a systemd boot stuck in starting fails with ('systemctl is-system-running --wait', 180) and lists no failed units.
      • wait_until_succeeds(cmd, timeout=600) catches only its own TimeoutError. One slow attempt ends the whole wait.
      • subprocess.run kills only sh, so a pipeline or a backgrounded child keeps running.
    • Fix:
      • The agent returns a typed timeout result.
      • The agent runs each command in its own process group and kills the group.
      • The host raises MachineError("... timed out after Ns").
      • _ask does not treat a timeout raised in the guest as silence.

    R7 The UML bridge's children have no parent-death signal, and _reap signals only the bridge's group (medium)

    • Where:
      • pkgs/uml-passt-bridge/src/main.rs:125-158, 171, 295-296;
      • machine.py:985-1008, 1032-1058.
    • Evidence:
      • The prctl(2) man page says a fork clears the parent-death signal. Neither forked child sets one again.
      • crash()'s own comment says killing the group alone left the kernel running. Its SIGKILL step therefore also kills the guest's pid. _reap's SIGKILL step does not.
    • A trap for A9's fix: the parent-death signal follows the thread that forked. With launch in anyio.to_thread, every helper that uses die_with_parent gets SIGKILL when its worker thread retires, after 10 s idle.
    • Fix:
      • Call prctl(PR_SET_PDEATHSIG, SIGKILL) in both forked children.
      • Kill the guest's pid in _reap too.
      • Spawn helpers from a thread that lives as long as the run.

    R8 A run the MCP server started does not die with the server, and a paused run waits forever (medium)

    • Where:
      • vivarium_eval/server.py:278-291, 344-381, 705-722;
      • control.py:669-670.
    • Evidence:
      • The child gets no parent-death signal. break_on_failure is on by default, and the pause has no time bound.
      • stop_all stops runs one after another. Each stop takes up to 70 s.
      • The 60 s kill fires before one guest's worst-case teardown ends.
    • Impact: when the MCP server dies, its paused runs stay up with nobody attached to them (compare Stalled guest runs leak crun guests and exhaust the kernel keyring #1165).
    • Fix:
      • Give each run a parent-death signal, or have the run watch the server's pidfd.
      • Stop all runs at the same time.

    R9 A pytest phase's timeout and a stop do not reach code that blocks in the worker thread (medium)

    • Where:
      • session.py:837;
      • pytest_plugin.py:106-109, 148-159;
      • cli.py:812-824.
    • Evidence:
      • The deadline applies only to awaits on the loop. A sync test, a sync fixture, or a blocking call inside an async test ignores it.
      • to_thread.run_sync cannot be cancelled. A stop then waits until STOP_WAIT (300 s) runs out.
      • After a cancel, every later async test fails at once, and the async-generator teardowns do not run.
    • Fix:
      • At the deadline, set session.shouldstop and interrupt the worker. pytest-timeout's thread method shows one way.
      • Document that the timeout covers awaits only.

    R10 Nits

    • Stop and continue can be lost: control.py:705-718 acts on _stopping and _continuing only after the reply is sent. A client that leaves early loses its stop or continue. Extends vivarium: a ctl client that disconnects mid-exec ends the run #1166.
    • The agent can die without a trace: the vivarium-agent unit has no OOMScoreAdjust and no Restart=. The OOM killer picks the agent first, and a run then looks hung. That is the known CLAUDE.md trap; OOMScoreAdjust = -1000 removes the common cause.
    • The cloud API has no limits:
      • With no capacity entry, it has no limit at all.
      • Any guest can delete any instance.
      • If this is intended, the docs should say so.
    • _pending leaks: a cancelled call leaves its _pending entry for the connection's lifetime.
    • Local exposure: three items about file and socket permissions and about what a guest can reach on the host. Details: nixidae/security#47 (private).

    Assisted-By: Claude Opus 5.5

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    source: vivarium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0