8000 fix(minimal,minimald,minimald-rpc): on a VM-backed host, min box stop frees declared ingress ports by minimal-foundry[bot] · Pull Request #3710 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix(minimal,minimald,minimald-rpc): on a VM-backed host, min box stop frees declared ingress ports - #3710

Draft
minimal-foundry[bot] wants to merge 6 commits into
mainfrom
agent/3689-on-a-vm-backed-host-min-box-stop-frees-declared
Draft

minimal-foundry[bot] wants to merge 6 commits into
mainfrom
agent/3689-on-a-vm-backed-host-min-box-stop-frees-declared

Conversation

@minimal-foundry
Copy link
Copy Markdown
Contributor

Follow-up

Fixes #3689

  • Epic: charged to Box networking — preview by name, bounded egress, and secure reach across hosts #1437
  • Size: M; estimated 260 code, 220 tests
  • May touch:
    • crates/minimald-rpc/src/lib.rs
    • crates/minvmd/src/control.rs
    • crates/minvmd/src/box_registry.rs
    • crates/minvmd/src/net/egress_gate.rs
    • crates/minimald/src/rpc.rs
    • crates/minimal/src/cmd/boxes/vm_host.rs
    • crates/minimal/src/cmd/boxes/lifecycle.rs
    • crates/minimald/src/box_actor/setup.rs
    • crates/minimald/src/box_actor/tests.rs
    • docs/specs/18-spec-box-networking/18-spec-box-networking.md
Task marker
### D3689 — On a VM-backed host, min box stop frees declared ingress ports through a host-side release, and a box with no switch address never binds its forwards after its name is published
  kind: task
  size: M
  est: 260 code, 220 tests
  executor: agent
  origin: residual
  epic: 1437
  layers:
    - vmhost:
      - crates/minimald-rpc/src/lib.rs: adds a host-door BoxControlRequest verb that releases a stopped box's declared ingress forwards, with its request type
      - crates/minvmd/src/control.rs: answers the new verb on the Host door only, and replies after the gate unbinds the row's declared forwards, without a withdrawal of the row
      - crates/minvmd/src/box_registry.rs: lets a caller ask for a release of a live row's forwards and wait for the result, beside subscribe_row_withdrawals
      - crates/minvmd/src/net/egress_gate.rs: runs the revoke_box_forwards unbind and connection resets for a release request, then reports the result to the waiting caller
      - crates/minimald/src/rpc.rs: adds the new verb to the list that the native control socket refuses
      test: cargo test -p minvmd stopped_box_declared_forwards_released_before_stop_returns
    - cli:
      - crates/minimal/src/cmd/boxes/vm_host.rs: adds a call that asks the VM host daemon to release the stopped box's declared forwards and waits for the reply
      - crates/minimal/src/cmd/boxes/lifecycle.rs: cmd_box_stop calls the host-side release before it returns
      test: cargo test -p minimal box_stop_releases_declared_ports_on_vm_host
    - activation:
      - crates/minimald/src/box_actor/setup.rs: the (true, None) arm fails the finalize with a reason when a VM-backed box declares ingress but has no switch address
      - crates/minimald/src/box_actor/tests.rs: adds a test that a VM-backed box with declared ingress and no switch address fails activation with the reason and binds no forward
      test: cargo test -p minimald activation_refused_when_vm_host_hands_no_switch_address
    - spec:
      - docs/specs/18-spec-box-networking/18-spec-box-networking.md: removes the two VM-backed residual notes from the NET-121 sub-requirement and adds verify lines for the two new tests
      test: cargo test -p minvmd stopped_box_declared_forwards_released_before_stop_returns
  proof: On a VM-backed host, a min box stop and then a start of the same box binds its declared port again at once, and a box with declared ingress and no switch address fails activation with a reason.

Proof

On a VM-backed host, min box stop now sends the new release_box_forwards verb to the VM host daemon. It returns only after the daemon's egress gate unbinds the box's declared forwards and resets their connections. The row stays, so a start right after the stop binds the declared port again. The minvmd test shows the forward is unbound when the wait returns and that the same listener can be bound again at once. Separately, a VM-backed box that declares ingress and has no switch address now fails activation with this message: "box declares ingress ports, but its VM did not assign it a network address. No port can be forwarded to it. The box did not start." No forward is bound, and the cleanup leaves no record.

Notes from the agent: Spec layer: the NET-121 block at the branch head had no VM-backed residual notes to remove, either on the sub-requirements or elsewhere in the NET-121 entry. I added three verify lines to NET-121 for the new tests and extended its comment to describe the VM-backed behaviour. Vale is not installed on this box, so just lint-prose did not run on the spec. The control handler takes no ApplyOrder ticket for the new verb, because the release changes no row and can wait up to 30 s (FORWARD_RELEASE_WAIT) for the gate. The CLI waits 35 s. A release that the host does not confirm does not fail the stop. It prints one line to stderr: "The VM did not confirm that the ports of are free. min box start <box> can fail while a port is still in use." Only min box stop (cmd_box_stop) calls the release. min session stop (crates/minimal/src/cmd/session.rs:427) and min box stop --exec are outside the layers and do not call it yet. The minimald activation test sets the daemon's switch to the VM host transport after the create, because box_actor tests had no VM-backed finalize fixture. The minvmd test drives the registry and the gate directly. It does not go through the control socket, so the wrapper in control.rs (release_box…[truncated]

Tests

line exit tail
cargo test -p minvmd stopped_box_declared_forwards_released_before_stop_returns 0
cargo test -p minimal box_stop_releases_declared_ports_on_vm_host 0 led; 0 ignored; 0 measured; 1060 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 43 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 18 filtered out; finished in 0.00s runni
cargo test -p minimald activation_refused_when_vm_host_hands_no_switch_address 0 running 1 test test box_actor::tests::activation_refused_when_vm_host_hands_no_switch_address ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1546 filtered out; finished in 2.30s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 13 filtered out; fini
cargo test -p minvmd stopped_box_declared_forwards_released_before_stop_returns 0

Verify

min task run agent-verify exited 101, so this PR is a draft.

49.rlib --extern paths=/work/build-cache/cargo-home/build/debug/deps/libpaths-38d338f2d2882e54.rlib --extern proptest=/work/build-cache/cargo-home/build/debug/deps/libproptest-44d491d1a8aa49a0.rlib --extern ratatui=/work/build-cache/cargo-home/build/debug/deps/libratatui-1fc20dde22a8a62b.rlib --extern reqwest=/work/build-cache/cargo-home/build/debug/deps/libreqwest-5de86acda4cea8f4.rlib --extern russh=/work/build-cache/cargo-home/build/debug/deps/librussh-ed15d7ff509bfc78.rlib --extern russh_sftp=/work/build-cache/cargo-home/build/debug/deps/librussh_sftp-c0dd194e0f0fbcdd.rlib --extern serde=/work/build-cache/cargo-home/build/debug/deps/libserde-a2d31a39ef0e3ca2.rlib --extern serde_json_lenient=/work/build-cache/cargo-home/build/debug/deps/libserde_json_lenient-d40e6f0e7b3e9eef.rlib --extern sha2=/work/build-cache/cargo-home/build/debug/deps/libsha2-c9bcb32104c3d8ae.rlib --extern switch=/work/build-cache/cargo-home/build/debug/deps/libswitch-89cccedb7487721f.rlib --extern tempfile=/work/build-cache/cargo-home/build/debug/deps/libtempfile-a0e916d9301e1bc8.rlib --extern tokio=/work/build-cache/cargo-home/build/debug/deps/libtokio-13fd64194b408f82.rlib --extern tokio_stream=/work/build-cache/cargo-home/build/debug/deps/libtokio_stream-f2be74d61837d3fa.rlib --extern toml=/work/build-cache/cargo-home/build/debug/deps/libtoml-2aea33601fef026d.rlib --extern toml_edit=/work/build-cache/cargo-home/build/debug/deps/libtoml_edit-c70767a08866b85f.rlib --extern tracing=/work/build-cache/cargo-home/build/debug/deps/libtracing-83feaaf26e80a884.rlib --extern tracing_subscriber=/work/build-cache/cargo-home/build/debug/deps/libtracing_subscriber-b9d261067ec6d0c0.rlib --extern unicode_width=/work/build-cache/cargo-home/build/debug/deps/libunicode_width-b88ae913615e5a0f.rlib --extern url=/work/build-cache/cargo-home/build/debug/deps/liburl-7dfaaabb254cca5f.rlib --extern uuid=/work/build-cache/cargo-home/build/debug/deps/libuuid-2ad4c678aa627cb6.rlib --extern version=/work/build-cache/cargo-home/build/debug/deps/libversion-26aec4f378b53f65.rlib --extern zeroize=/work/build-cache/cargo-home/build/debug/deps/libzeroize-839e2912eb255706.rlib -L native=/work/build-cache/cargo-home/build/debug/build/zstd-sys-0d91391d9ed43bde/out -L native=/work/build-cache/cargo-home/build/debug/build/ring-43aedddb25fbb121/out -L native=/work/build-cache/cargo-home/build/debug/build/aws-lc-sys-467e076f78a0a3c4/out -L native=/work/build-cache/cargo-home/build/debug/build/tree-sitter-6abcf750100a3ada/out -L native=/work/build-cache/cargo-home/build/debug/build/tree-sitter-nickel-4d55240ed02e956b/out -L native=/work/build-cache/cargo-home/build/debug/build/blake3-493bdc0df5a171ff/out -L native=/work/build-cache/cargo-home/build/debug/build/blake3-493bdc0df5a171ff/out` (exit status: 101)
error: command `/usr/bin/cargo '--color=auto' test --no-run --message-format json-render-diagnostics --package minimal --package minimald --package minimald-rpc --package minvmd --locked` exited with code 101

A VM-backed host binds a declared forward toward the box's switch
address. A box the host handed none published its name with every
declared port dead. The finalize now fails with the reason first.
Adds the release_box_forwards control verb on the host socket. The
egress gate unbinds the row's declared forwards and resets their
connections, and the row stays live. The caller waits for the result,
so a stop can return only after the ports are free (NET-121).
min box stop now asks the VM host daemon to release the stopped box's
declared forwards and waits for the reply. A start right after the
stop binds the ports again. A release the host does not confirm
prints one line that a start can fail on a port in use.
@coderabbitai
coderabbitai Bot commented Nov 20, 2026 •
Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

Ask an organization administrator to verify that this bot has an active assigned CodeRabbit review seat. See the seat-assignment guide. After the seat is confirmed, request a review again.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2b90738c-91dd-45c4-8e5b-6fcdd93a156d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@github-actions
Copy link
Copy Markdown
Contributor

Spec lint

docs/specs/18-spec-box-networking/18-spec-box-networking.md — 10 finding(s)

docs/specs/18-spec-box-networking/18-spec-box-networking.md:171: P004 NET-009 names test 'native_resolution_without_proxy_env', which was not found in the repository
docs/specs/18-spec-box-networking/18-spec-box-networking.md:378: P004 NET-040 names test 'fresh_install_own_ip_ingress_publishes_loopback', which was not found in the repository
docs/specs/18-spec-box-networking/18-spec-box-networking.md:388: P004 NET-041 names test 'installer_switch_binary_executable', which was not found in the repository
docs/specs/18-spec-box-networking/18-spec-box-networking.md:435: P004 NET-048 names test 'linux_amd64_manifest_ships_vm_stack', which was not found in the repository
docs/specs/18-spec-box-networking/18-spec-box-networking.md:440: P004 NET-049 names test 'fresh_linux_kvm_activate_local_minvmd', which was not found in the repository
docs/specs/18-spec-box-networking/18-spec-box-networking.md:445: P004 NET-050 names test 'linux_arm64_manifest_ships_vm_stack', which was not found in the repository
docs/specs/18-spec-box-networking/18-spec-box-networking.md:450: P004 NET-051 names test 'fresh_arm64_kvm_activate_local_minvmd', which was not found in the repository
docs/specs/18-spec-box-networking/18-spec-box-networking.md:966: P004 NET-132 names test 'proxy_sees_each_vm_box_by_its_switch_address', which was not found in the repository
docs/specs/18-spec-box-networking/18-spec-box-networking.md:992: P004 NET-134 names test 'deny_all_box_reaches_proxy_and_no_other_host_port', which was not found in the repository
docs/specs/18-spec-box-networking/18-spec-box-networking.md:1016: P004 NET-107 names test 'session_outbound_request', which was not found in the repository

Advisory. None of this blocks the merge; the review decides.

Advisory, and never a merge gate. Linter: gominimal/foundry@8acb0663, spec format: How Minimal Writes Specs.

@norrietaylor
Copy link
Copy Markdown
Member

/revise
test-kvm fails on this head, and main's KVM lane is green. The failing line is scripts/session-e2e.sh:8204: ::error::an uninstalled SHELL did not fall back to bash, at 2026-11-20T22:58:48Z in the test-kvm job, followed by exit 1. Find why this PR's change makes a box with an uninstalled SHELL stop falling back to bash on a VM host: check the box stop/start and activation paths you changed, since that case starts a box. Fix it, and run that e2e case on the KVM lane path if you can. Then record the results.

@minimal-foundry
Copy link
Copy Markdown
Contributor Author

That /revise is held, not dropped. The container platform had no instance to give the coder: its pool of prepared containers was full, which happens most just after a deploy. Your note is kept and asked again every 10 minutes for up to 30; a wait that outlives that is refused here with the reason.

What the platform said

could not start the coder: Error: there is no container instance that can be provided to this durable object

Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet.

The release_box_forwards handler landed between rename_box and its doc
comment, so the comment described the wrong function.
@minimal-foundry
Copy link
Copy Markdown
Contributor Author

Round 1 of 10 on a /revise note, pushed as 8b9646e3a23c.

line exit tail
cargo test -p minvmd stopped_box_declared_forwards_released_before_stop_returns 0
cargo test -p minimal box_stop_releases_declared_ports_on_vm_host 0 led; 0 ignored; 0 measured; 1061 filtered out; finished in 0.01s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 43 filtered out; finished in 0.00s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 18 filtered out; finished in 0.00s runni
cargo test -p minimald activation_refused_when_vm_host_hands_no_switch_address 0 running 1 test test box_actor::tests::activation_refused_when_vm_host_hands_no_switch_address ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1547 filtered out; finished in 2.28s running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 13 filtered out; fini
cargo test -p minvmd stopped_box_declared_forwards_released_before_stop_returns 0

Verify min task run agent-verify exited 101.

49.rlib --extern paths=/work/build-cache/cargo-home/build/debug/deps/libpaths-38d338f2d2882e54.rlib --extern proptest=/work/build-cache/cargo-home/build/debug/deps/libproptest-44d491d1a8aa49a0.rlib --extern ratatui=/work/build-cache/cargo-home/build/debug/deps/libratatui-1fc20dde22a8a62b.rlib --extern reqwest=/work/build-cache/cargo-home/build/debug/deps/libreqwest-5de86acda4cea8f4.rlib --extern russh=/work/build-cache/cargo-home/build/debug/deps/librussh-ed15d7ff509bfc78.rlib --extern russh_sftp=/work/build-cache/cargo-home/build/debug/deps/librussh_sftp-c0dd194e0f0fbcdd.rlib --extern serde=/work/build-cache/cargo-home/build/debug/deps/libserde-a2d31a39ef0e3ca2.rlib --extern serde_json_lenient=/work/build-cache/cargo-home/build/debug/deps/libserde_json_lenient-d40e6f0e7b3e9eef.rlib --extern sha2=/work/build-cache/cargo-home/build/debug/deps/libsha2-c9bcb32104c3d8ae.rlib --extern switch=/work/build-cache/cargo-home/build/debug/deps/libswitch-89cccedb7487721f.rlib --extern tempfile=/work/build-cache/cargo-home/build/debug/deps/libtempfile-a0e916d9301e1bc8.rlib --extern tokio=/work/build-cache/cargo-home/build/debug/deps/libtokio-13fd64194b408f82.rlib --extern tokio_stream=/work/build-cache/cargo-home/build/debug/deps/libtokio_stream-f2be74d61837d3fa.rlib --extern toml=/work/build-cache/cargo-home/build/debug/deps/libtoml-2aea33601fef026d.rlib --extern toml_edit=/work/build-cache/cargo-home/build/debug/deps/libtoml_edit-c70767a08866b85f.rlib --extern tracing=/work/build-cache/cargo-home/build/debug/deps/libtracing-83feaaf26e80a884.rlib --extern tracing_subscriber=/work/build-cache/cargo-home/build/debug/deps/libtracing_subscriber-b9d261067ec6d0c0.rlib --extern unicode_width=/work/build-cache/cargo-home/build/debug/deps/libunicode_width-b88ae913615e5a0f.rlib --extern url=/work/build-cache/cargo-home/build/debug/deps/liburl-7dfaaabb254cca5f.rlib --extern uuid=/work/build-cache/cargo-home/build/debug/deps/libuuid-2ad4c678aa627cb6.rlib --extern version=/work/build-cache/cargo-home/build/debug/deps/libversion-26aec4f378b53f65.rlib --extern zeroize=/work/build-cache/cargo-home/build/debug/deps/libzeroize-839e2912eb255706.rlib -L native=/work/build-cache/cargo-home/build/debug/build/zstd-sys-0d91391d9ed43bde/out -L native=/work/build-cache/cargo-home/build/debug/build/ring-43aedddb25fbb121/out -L native=/work/build-cache/cargo-home/build/debug/build/aws-lc-sys-467e076f78a0a3c4/out -L native=/work/build-cache/cargo-home/build/debug/build/tree-sitter-6abcf750100a3ada/out -L native=/work/build-cache/cargo-home/build/debug/build/tree-sitter-nickel-4d55240ed02e956b/out -L native=/work/build-cache/cargo-home/build/debug/build/blake3-493bdc0df5a171ff/out -L native=/work/build-cache/cargo-home/build/debug/build/blake3-493bdc0df5a171ff/out` (exit status: 101)
error: command `/usr/bin/cargo '--color=auto' test --no-run --message-format json-render-diagnostics --package minimal --package minimald --package minimald-rpc --package minvmd --locked` exited with code 101

Converted to a draft: verify exited 101.

On a VM-backed host, min box stop asks the VM host daemon to unbind the box's declared ports and waits for the answer, so a min box start of the same box right after binds its declared port again. A box that declares ingress ports and gets no network address from its VM fails activation with a message that says why, and no forward is bound for it.

Notes from the agent: Revise round 1 (test-kvm failure at scripts/session-e2e.sh:8204, 'an uninstalled SHELL did not fall back to bash'). I found no code path in this PR that the failing case runs. (1) The case starts a box with [stack] use = "shell" and no ingress section, attaches, and exits. It never runs min box stop. (2) The new activation refusal in setup.rs is inside if let (OwnIp, Some(ingress)) and fires only with declared ingress and no switch address. If it had fired, min session start would fail and the script would report line 8188, not 8204. (3) The CLI change runs only in cmd_box_stop, and the new release asks the VM host only when the record declares port mappings. (4) The new BoxControlRequest variant is JSON-tagged by verb (#[serde(tag = "verb")]), so its position in the enum does not shift any other verb on the wire. (5) The new egress-gate select arm only handles release requests. It does not change how the gate handles withdrawals. (6) The shell choice is made in crates/minimald/src/attach_shell.rs resolve, which this PR does not change. It reads only SHELL and the rootfs. The CI excerpt in the directive does not include the attach transcript. That leaves one likely cause, which I did not observe: a timing race in scripts/e2e-attach-pty.py. The driver writes the printf and the exit lines to the pty after a fixed 1.5 s sleep, before the shell starts. If the first line is lost while exit still arrives, the attach exits 0 and the transcript has no SESSION_SHELL_IS line, which is exactly this failure. scripts/ is outside this task's layers, so I did not change it. I was not able to…[truncated]

@norrietaylor
Copy link
Copy Markdown
Member

/arch-review

This branch has not been deployed

No deployments
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.

On a VM-backed host, box stop frees declared ingress ports only after the detach grace, and a box without a switch address binds them at first attach

1 participant

0