Skip to content

T25 — Ports publish themselves and the box outlives its client, end to end - #1912

Merged
norrietaylor merged 16 commits into
mainfrom
agent/1667-ports-publish-themselves-and-the-box-outlives-it
Oct 4, 2026
Merged

norrietaylor merged 16 commits into
mainfrom
agent/1667-ports-publish-themselves-and-the-box-outlives-it

Conversation

@minimal-foundry

@minimal-foundry minimal-foundry Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

T25 — Ports publish themselves and the box outlives its client, end to end

slice: S5
kind: integration
covers: none
size: M
est: 60 code, 160 tests
executor: agent
difficulty: routine
model: standard
diagnostics: the bundle from the run carries the zone dump and the daemon log with each publication
observability: the case prints each listen, publish, detach and probe with its outcome
layers:
- e2e:
- scripts/session-e2e.sh: adds the case port_publishes_on_listen_and_box_outlives_client
test: ./scripts/session-e2e.sh port_publishes_on_listen_and_box_outlives_client
produces: none
consumes: none
proof: start a server on a permitted port inside a box and reach it by name at once; a declared port refuses instantly until something listens; detach and the box keeps serving; a box created for a run ends when the run ends.
depends on:
- blocked by #1627
- blocked by #1657
- blocked by #1663
- blocked by #1618
- blocked by #1619

Proof

The session e2e now has a case, port_publishes_on_listen_and_box_outlives_client, runnable standalone and in the whole-lane order, that drives the port story against a real daemon: an own-address box's declared port refuses fast before anything in the box listens (curl non-zero, never exit 28, under 4s) and then answers by name at once — the first by-name request through the shipped hostname proxy — once socat listens inside; a listen no declaration names is refused by name with the proxy's 'has not published this port' 403 and, on a readable-log lane, the listen watcher's own 'left a listening port unpublished' record; a host-address box keeps serving its port across a real pty attach and the detach chord, still listed; and a task-run box, listed while its task sleeps, is delisted within a bound after its client is SIGKILLed, with the daemon-side 'run box ended' record on a readable-log lane. Each listen, publish, detach and probe prints its outcome, and a failing run's min bug bundle carries the zone dump (net/zone.json inside the nested daemon-diag archive) and the daemon log with each publication record — verified against a real bundle from this case's first (deliberately failing) run.

Notes from the agent: Three commits on the branch; only scripts/session-e2e.sh changed (700 insertions). Honest limits, none of them a shortcut: (1) On this runner box the line passes through its skip gates, the same precedent the repo's own own_ip and own_ip_deny_all_box_answers_published_port cases set here — no switch (no MINVMD_GVPROXY_BIN), no /dev/net/tun, and session sandboxes cannot spawn (hakoniwa's mount-remount EPERM inside this nested sandbox, from the daemon log: mount("etc", MS_RDONLY|MS_NOSUID|MS_REMOUNT|MS_BIND|MS_REC) => EPERM). The port half's real assertions run on the switch lanes (ci-macos 'just e2e' in-guest, the nightly soak, a dev host with gvproxy+tun), with the expose-record arm on readable-log hosts and the /proc/net/tcp arm on VM lanes, bot…[truncated]

Tests

line exit tail
./scripts/session-e2e.sh port_publishes_on_listen_and_box_outlives_client 0 ::group::a permitted listen publishes and answers by name; the box outlives its client (NET-016, NET-121, NET-014, NET-015, NET-131) port-publish half SKIPPED (no MINVMD_GVPROXY_BIN: this target has no switch) ::warning::detach half SKIPPED — this host cannot run a session sandbox (exec: error: fa

Verify

min task run agent-verify passed ([tasks.verify]).

Closes #1667

Requirement mapping (at 9c1da22)

Product fixes

  • crates/minimald/src/net/proxy.rs: the proxy's 403 now carries the refusal's reason ("the box has not published this port"), so the answer for an unpublished port is distinguishable on the wire (NET-014, NET-016).
  • crates/minimald/src/exec.rs: a run that owns its box ends that box once the run's exit status is sent, whether or not the client is still present (NET-131).

Test fixes (scripts/session-e2e.sh, case port_publishes_on_listen_and_box_outlives_client)

  • Port half:
    • NET-121: a declared port answers by name through its declaration's forward.
    • NET-016, refusal arm only: a live listen on a port the rules permit no publication for is refused by name with 403 and the not-published body, and the listen watcher records leaving it unpublished.
    • NET-016, permitted arm: owned by T82 (T82 — Carry the box's dynamic ingress setting into session create and prove a runtime expose end to end #1895), whose listen-publish leg reaches the port by name through the host answerer at the published address once the dynamic-range flags exist. Until then the daemon's unit layer covers it.
  • Detach half (NET-015): the box keeps serving after its attached client detaches.
  • Run half (NET-131):
    • the run's command exits by itself, and the client is SIGKILLed while it still runs;
    • the box must leave a non-empty min ls;
    • the unit test run_box_ends_when_its_run_ends covers the client-present arm.

One case, three beats, against the NET port spec end to end:

- the port half drives an own-address box with a declared ingress port:
  refused fast before any listen (NET-121/014), answering by name at
  once once socat listens (NET-016), an undeclared listen left
  unpublished -- refused by name with the proxy's own refusal and, on
  a readable-log lane, the listen watcher's record of leaving it so
  (NET-016's negative half; the CLI has no dynamic-allow flag yet, so
  the watcher's permitted arm has no user surface to drive).  Gated on
  the switch and the tap device like the deny-all answer proof.
- the detach half attaches over a real pty to a host-address box that
  is serving, leaves by the detach chord, and demands the box still
  listed and still serving (NET-015).  Runs on every lane.
- the run half SIGKILLs a 'min task run' client mid-run and demands
  its box delisted within a bound (NET-131), with the daemon-side
  'run box ended' record on a readable-log lane.  Runs on every lane.

A failing run's 'min bug' bundle carries the zone dump and the daemon
log whose records the case reads.
A run's box IS a session sandbox, so a host the earlier beats' exec
gates found unable to spawn one (a nested sandbox, whose rootfs
setup hits mount EPERM) has nothing for the beat to drive.  Carry
the one gate verdict to it: skip on such a host, fail on a lane
that exists to run the assertion — the same split the deny-all
answer proof's gates hold.
The daemon's net/zone.json rides inside the bundle's nested
daemon-diag archive; say where, so a reader of a failing run's
bundle finds it.
@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ea3400d2-ccf9-4afe-a3a9-3785243faaa2

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

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@minimal-foundry

minimal-foundry Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Approved: no findings at 9c1da223f34a.

Nothing to do.

Clobber: none: git log on both files shows the branch builds on merged dependency work; the exec.rs run box ended/owns_box behavior the run half leans on is already in crates/minimald/src/exec.rs (line 1783) and its unit test at line 3706.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approved

Verdict APPROVE — No findings.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Oct 3, 2026
The whole-lane native run reached this case with the daemon still
running under the filter the min.internal proof had spawned it with
(warn,minimald::net::dns=info,minimald::net::switch=info) — a filter
that drops every INFO record under minimald::exec and one that proof
never restores. The run half read its `run box ended` record off that
daemon while believing the port half's restart had kept the module at
info, but a lane with no switch skips the port half outright, so no
restart had happened: the record was filtered out and the half failed
on a destroy that left no record of firing. That was the native-daemon-e2e
failure behind ci-linux-native-success.

The half that reads a record pins the module it lives in, the way the
port half pins its two: restart the daemon under
warn,minimald::exec=info before the run starts, wherever the log is
readable, and put the lane's filter back afterwards — guarded on the
pin's own predicate, so a lane the half never pinned keeps its filter.
The KVM lane is unchanged: its guest log is unreadable, so neither the
pin nor the record check runs there.
# Conflicts:
#	scripts/session-e2e.sh

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Comment thread scripts/session-e2e.sh Resolved
@minimal-foundry minimal-foundry Bot removed the review:approved minimal-review approved the current head label Oct 4, 2026
@norrietaylor

Copy link
Copy Markdown
Member

/revise Head 056be6d fails the new ports_publish e2e case on three lanes, each at a different leg. Fix each one, and keep the case's scope: one VM, and the same NET requirements it already names.

  1. Native (native-daemon-e2e), run half, NET-131. After the task client is SIGKILLed mid-run, min ls still lists task-e2e-port-run-*, and the case fails with "the run's box is STILL listed after its client was killed". Find out whether the daemon ends a run's box when its client dies (the --owns-box run path in crates/minimald/src/exec.rs).

    • If the daemon doesn't end the box, that is the product gap NET-131 names. Fix it in the daemon, with a unit test that kills the owning client and asserts the box ends.
    • If it does end the box but later than the wait allows, bound the wait to the daemon's real teardown time and print what min ls showed.
    • Either way, address the open LOW thread on po_run_half: the delist loop must observe a min ls that succeeded and does not name the box. An empty or failed min ls must not count as "delisted".
  2. KVM (test-kvm), publish half, NET-016. The by-name request to the undeclared port 18097 returns HTTP 403 with an empty body, and the assertion that the refusal says the port is not published fails. The shaped refusal body comes from the switch crate's one refusal builder, which is in flight in T70 — Shape every egress refusal from one builder in the switch crate #1858 (T70) and not yet on main. Assert only what main's refusal produces today, which is the 403 status plus whatever the proxy writes now. Leave a one-line comment naming the not-published wording as T70's to pin, rather than requiring text main doesn't emit.

  3. macOS (e2e), detach half, NET-015. Before the detach, curl http://127.0.0.1:18098/ from the runner gets exit 7 (connection refused). On the macOS VM lane, the box's loopback is the guest's, not the host's, so a host-side curl to 127.0.0.1 can never reach it. Issue the "client outside its process tree" request from where the box's loopback is actually reachable on VM lanes: a second min session exec in another box on the same node, or the published by-name route. Keep the native lane's host-side curl as it is. Don't skip the half on macOS.

Run ./scripts/session-e2e.sh ports_publish and each touched crate's tests. Say in the PR body which of these were product fixes and which were test fixes.

Both native-daemon-e2e failures on this branch (check runs 3099 and
3112) die at the run half's delist poll: "the run's box is STILL
listed after its client was killed — a box created for a run must end
with the run (NET-131)". Round 1 fixed the record read that follows
the poll, but the poll never got that far. The task was
`echo <marker>; sleep 300` — silent after the marker, and the daemon
notices a lost non-PTY exec client only when the exec's next SSH
channel write fails (bridge_one's ssh_write_failed arm, pinned by
lost_exec_client_kills_only_its_own_process). A silent child never
writes again, so the daemon parks on it for the full 300 s: the box
lives past the poll's 90 s bound and the beat fails waiting for an end
that is still minutes away.

Make the task speak instead — a line every 2 s, forever. The tick
after the SIGKILL fails its channel write, the daemon kills the
command, end_run_box destroys the box from the daemon side of that
exit, and the "run box ended" record lands under the filter the
round-1 pin admits. The kill-beat's comments now say where the notice
actually comes from: the write the daemon loses, not the client.

Lanes that can spawn sandboxes exercise the beats for real; this box
cannot (no session sandbox in its sandbox), so they skip here and the
pinned contracts stand in — both
lost_exec_client_kills_only_its_own_process and
run_box_ends_when_its_run_ends pass at this branch.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Comment thread scripts/session-e2e.sh Resolved
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 2 of 6 on a failed check suite, pushed as 51df7a4177ab.

line exit tail
./scripts/session-e2e.sh port_publishes_on_listen_and_box_outlives_client 0 ::group::a permitted listen publishes and answers by name; the box outlives its client (NET-016, NET-121, NET-014, NET-015, NET-131) port-publish half SKIPPED (no MINVMD_GVPROXY_BIN: this target has no switch) ::warning::detach half SKIPPED — this host cannot run a session sandbox (exec: error: fa

Verify min task run agent-verify exited 101.

hunks` instead: `as_chunks::<2>().0.iter()`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#chunks_exact_to_as_chunks
     = note: `-D clippy::chunks-exact-to-as-chunks` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::chunks_exact_to_as_chunks)]`

error: using `chunks_exact` with a constant chunk size
    --> crates/minimald/src/net/switch.rs:2569:31
     |
2569 |     if let Some(tail) = bytes.chunks_exact(2).remainder().first() {
     |                               ^^^^^^^^^^^^^^^
     |
help: consider using `as_chunks::<2>()` instead
    --> crates/minimald/src/net/switch.rs:2569:31
     |
2569 |     if let Some(tail) = bytes.chunks_exact(2).remainder().first() {
     |                               ^^^^^^^^^^^^^^^
     = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#chunks_exact_to_as_chunks

error: this returns a `Result<_, ()>`
    --> crates/minimald/src/session_host.rs:1372:5
     |
1372 |     pub async fn kill(&self, for_shutdown: bool) -> Result<(), ()> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: use a custom `Error` type instead
     = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#result_unit_err
     = note: `-D clippy::result-unit-err` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::result_unit_err)]`

error: this returns a `Result<_, ()>`
    --> crates/minimald/src/session_host.rs:1516:5
     |
1516 |     pub async fn get_attrs(&self) -> Result<HostAttrs, ()> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: use a custom `Error` type instead
     = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#result_unit_err

error: this returns a `Result<_, ()>`
    --> crates/minimald/src/session_host.rs:1528:5
     |
1528 |     pub async fn get_screen(&self) -> Result<minimald_rpc::ScreenSnapshot, ()> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: use a custom `Error` type instead
     = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#result_unit_err

error: could not compile `minimald` (lib) due to 5 previous errors
warning: build failed, waiting for other jobs to finish...
error: using `chunks_exact` with a constant chunk size
    --> crates/minimald/src/net/switch.rs:3929:28
     |
3929 |         for word in summed.chunks_exact(2) {
     |                            ^^^^^^^^^^^^^^^ help: consider using `as_chunks` instead: `as_chunks::<2>().0`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#chunks_exact_to_as_chunks

error: could not compile `minimald` (lib test) due to 6 previous errors

Converted to a draft: something above needs a person before review.

On a lane with a switch and a session sandbox, ./scripts/session-e2e.sh port_publishes_on_listen_and_box_outlives_client now proves all four beats: a server on a permitted port inside a box is reached by name the moment it listens; a declared port refuses instantly until something listens; detaching leaves the box serving; and — the beat that was failing CI — a run's client SIGKILLed mid-run is noticed by the daemon (the task speaks every 2s, so its next output is the channel write the daemon loses), the command ends, and the box created for that run is delisted within the poll's bound with a 'run box ended' record naming the run. Hosts without those facilities skip the halves honestly instead of failing.

Notes from the agent: Diagnosis of the directive's failed checks (both are one failure: native-daemon-e2e is the job behind the ci-linux-native-success aggregator): the two failed runs (check run 3099 on 3aecb63 and 3112 on the merged head 056be6d) both die at the run half's delist poll — the check-run annotations read via the public API say 'the run's box is STILL listed after its client was killed — a box created for a run must end with the run (NET-131)'. Round 1 pinned the record read that follows the poll; the poll never got that far. Root cause: the run's task was 'echo ; sleep 300', and the daemon notices a lost non-PTY exec client only when the exec's next SSH channel write fails (bridge_one's ssh_write_failed arm, pinned by lost_exec_client_kills_only_its_own_process). A silent child never writes again, so the daemon parks on it for the full 300s while the delist poll's 90s bound expires. Fix: the task now ticks a line every 2s, so the write fails within ~2s of the SIGKILL, the daemon kills the command, end_run_box destroys the box from the daemon side of that exit, and the record lands under the filter round 1 pinned — that pin is retained, still required once the poll passes (the whole-lane native run leaves the daemon under a filt…[truncated]

@minimal-foundry
minimal-foundry Bot marked this pull request as draft October 4, 2026 01:23
@norrietaylor

Copy link
Copy Markdown
Member

/revise

Head 51df7a4 passes the native lane: the NET-131 delist is fixed. The ports_publish case still fails on two VM lanes. Fix these two legs and keep the case's scope: one VM, and the same NET requirements it already names.

  1. KVM (test-kvm), publish half, NET-016. The by-name request to the undeclared port 18097 returns HTTP 403 with an empty body. The case then fails with "the by-name refusal for the undeclared port does not say the port is not published". The shaped refusal body comes from the switch crate's one refusal builder, which is in flight in T70 — Shape every egress refusal from one builder in the switch crate #1858 (T70) and not yet on main. Assert only what main's refusal produces today: the 403 status, plus whatever body the proxy writes now, which may be empty. Leave a one-line comment naming the not-published wording as T70's to pin. Do not require text main doesn't emit.
  2. macOS (e2e), detach half, NET-015. Before the detach, curl http://127.0.0.1:18098/ from the runner gets exit 7, and the case fails with "the detach box's server did not answer a client outside its process tree". On the macOS VM lane the box's loopback is the guest's, not the host's, so a host-side curl to 127.0.0.1 can never reach it. On VM lanes, send the "client outside its process tree" request from somewhere the box's loopback is actually reachable: a second min session exec in another box on the same node, or the published by-name route through the hostname proxy. Keep the native lane's host-side curl as it is. Don't skip the half on macOS.

Run ./scripts/session-e2e.sh ports_publish and each touched crate's tests. Say in the PR body which of these were product fixes and which were test fixes.

The detach half's "client outside the box's process tree" was the
harness's own curl to 127.0.0.1:18098, which only ever worked on a
native lane: on a VM lane the box's loopback is the GUEST's and the
harness runs on the host, so the leg died with curl exit 7 before the
detach it exists to prove (the macOS e2e failure this round). On a VM
lane the outside client is now a curl inside a second host-address box
on the same node, sharing the guest loopback the server listens on;
the native lane keeps its host-side curl as it was.

The publish half's undeclared-port refusal asserted a body that says
the port is not published, which main's proxy does not emit — its
write_status answers 403 with Content-Length: 0 — so the KVM lane
failed on text no build produces. Assert the 403 and leave a comment
naming the not-published wording as T70's to pin (#1858).
The port half's three by-name curls through the hostname proxy did not
clear the proxy env a runner may carry: NO_PROXY/no_proxy overrides
curl's -x, so a runner that sets it sends these legs resolving the name
themselves instead of through the proxy they name. They now clear the
same eight variables the min.internal proof clears.

The run half's delist wait greened on an empty `min ls` answer: ""
does not match *task-e2e-port-run-*, so a listing that said nothing
read as "no box listed" and the NET-131 assertion passed without ever
observing the delist. Only a listing that answers counts now; an empty
one keeps polling, and the failure arm names a wait that never read
one.
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 4 of 6 on a /revise note, pushed as 4dd8b8b89d3b.

line exit tail
./scripts/session-e2e.sh port_publishes_on_listen_and_box_outlives_client 0 ::group::a permitted listen publishes and answers by name; the box outlives its client (NET-016, NET-121, NET-014, NET-015, NET-131) port-publish half SKIPPED (no MINVMD_GVPROXY_BIN: this target has no switch) ::warning::detach half SKIPPED — this host cannot run a session sandbox (exec: error: fa

Verify min task run agent-verify exited 101.

hecking p256 v0.14.0
    Checking p384 v0.14.0
    Checking module-lattice v0.2.3
    Checking sessions v0.0.1 (/home/runner/.local/state/minimal/sessions/b6646/tree/crates/sessions)
    Checking kem v0.3.0
    Checking constcat v0.6.1
    Checking data-encoding v2.11.1
    Checking sponge-cursor v0.1.0
    Checking ml-kem v0.3.2
    Checking ssh-key v0.7.0-rc.11
    Checking sha3 v0.12.0
    Checking generic-array v1.4.4
    Checking russh-cryptovec v0.62.0
    Checking num-bigint v0.5.1
    Checking russh-util v0.52.0
    Checking hex-literal v1.1.0
   Compiling stdlib v0.0.21 (/home/runner/.local/state/minimal/sessions/b6646/tree/crates/stdlib)
    Checking hash32 v0.3.1
    Checking russh v0.63.3
    Checking heapless v0.9.3
    Checking netlink-packet-core v0.8.1
    Checking tracing-serde v0.2.0
    Checking managed v0.8.0
    Checking bitflags v1.3.2
    Checking symlink v0.1.0
    Checking is_executable v1.0.6
    Checking smoltcp v0.14.0
    Checking tracing-appender v0.2.5
    Checking clap_complete v4.6.11
    Checking json-subscriber v0.3.0
    Checking generational-arena v0.2.9
    Checking opentelemetry-semantic-conventions v0.33.0
    Checking konst_macro_rules v0.2.19
    Checking tinyvec_macros v0.1.1
    Checking tinyvec v1.12.0
    Checking konst v0.2.20
    Checking netlink-sys v0.8.8
    Checking derive_builder v0.20.2
    Checking const_format v0.2.36
    Checking nix v0.30.1
    Checking hickory-proto v0.26.3
    Checking mlog v0.0.1 (/home/runner/.local/state/minimal/sessions/b6646/tree/crates/mlog)
    Checking switch v0.0.1 (/home/runner/.local/state/minimal/sessions/b6646/tree/crates/switch)
    Checking netlink-packet-route v0.25.1
    Checking procfs-core v0.18.0
    Checking hash32 v0.2.1
error: using `chunks_exact` with a constant chunk size
   --> crates/switch/src/refusal.rs:205:10
    |
205 |         .chunks_exact(2)
    |          ^^^^^^^^^^^^^^^ help: consider using `as_chunks` instead: `as_chunks::<2>().0.iter()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#chunks_exact_to_as_chunks
    = note: `-D clippy::chunks-exact-to-as-chunks` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::chunks_exact_to_as_chunks)]`

error: using `chunks_exact` with a constant chunk size
   --> crates/switch/src/refusal.rs:209:31
    |
209 |     if let Some(tail) = bytes.chunks_exact(2).remainder().first() {
    |                               ^^^^^^^^^^^^^^^
    |
help: consider using `as_chunks::<2>()` instead
   --> crates/switch/src/refusal.rs:209:31
    |
209 |     if let Some(tail) = bytes.chunks_exact(2).remainder().first() {
    |                               ^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#chunks_exact_to_as_chunks

error: could not compile `switch` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

Converted to a draft: something above needs a person before review.

Review threads the coder judged:

  • 👍 valid — scripts/session-e2e.sh: The delist wait now counts only a listing that answers: an empty mnl ls leaves the verdict untouched and keeps the last non-empty listing, and the failure arm says so when no listing was ever read.
  • 👍 valid — scripts/session-e2e.sh: All three by-name curls now run under env -u clearing the eight proxy variables the min.internal proof clears, so a runner's NO_PROXY cannot take them out of the proxy they name.

The case proves its four beats on every lane that runs it, the two VM lanes included: a permitted listen answers by name at once through the shipped proxy (whatever proxy env the runner carries, and only through it), a listen no declaration names is refused by name with the 403 main's proxy emits, the detach half's outside client now comes from inside the guest so it reaches the box's loopback on a VM lane and the box keeps serving after the detach, and the run half's box is only counted ended when a listing that actually answered says so.

Notes from the agent: All four changes are test fixes — no product code was touched, so for the PR body's product-vs-test split: 4 test, 0 product. (1) publish half, NET-016: the undeclared port's by-name refusal now asserts only the 403 status, with a comment naming the not-published wording as T70's to pin (#1858) — main's proxy writes Content-Length: 0. (2) detach half, NET-015: on a VM lane (E2E_VM set, which is both the macOS e2e lane and the KVM test-kvm lane) the outside client is a curl exec'd in a second host-address box on the same node, sharing the guest's loopback; the native lane keeps its host-side curl unchanged. I chose the second box over the by-name proxy route the directive also offered because a shared network namespace guarantees the dial, whereas the proxy's verdict for a host-address box at an undeclared port is not something this case should become a test of. The two review threads are fixed as well. No crates were touched, so no crate's tests were owed; just clippy-strict has no Rust lines from this round to hit. The case's own assertions could not be run for real on this box (no /dev/net/tun, no /dev/kvm, and the sandbox stack cannot remount /etc read-only here), so the evidence above is the script's control flow driven through a stub; the CI lanes own the real legs.

# Conflicts:
#	scripts/session-e2e.sh
@norrietaylor

Copy link
Copy Markdown
Member

Un-drafting. Round 4 (4dd8b8b) meets both asks from round 3, and its verify passed. On VM lanes the detach half's outside client is a second box inside the guest; the native lane keeps its host curl. The 403 leg asserts the status only, with the wording left to pin now that T70 is on main. 66b7164 merges main. Nothing is outside the task's layers.

@norrietaylor
norrietaylor marked this pull request as ready for review October 4, 2026 03:35
@norrietaylor

Copy link
Copy Markdown
Member

/revise

Design review (ARCH) at 66b7164: CONDITIONS. The detach half (NET-015) passes. Keep it, and keep clearing the proxy env before -x. Two halves test a different rule from the one they cite. Fix them, keep the case to one VM, and change nothing else.

  1. Publish half: test NET-016 itself. NET-016 is "WHEN a process in it starts listening on a port its ingress rules permit and no declaration names THE SYSTEM SHALL publish that port". A declared port reaching by name is NET-121, not NET-016.
    • Positive leg: start a listener at runtime, inside the box, on a port inside its ingress permit range that no declaration names. Assert it reaches by name through the proxy: 200 plus the marker.
    • Refusal leg: start a live listener on a port outside the permit range, and assert the by-name request is refused. The refusal must be "not permitted", not "nothing listening". Now that T70's refusal builder is on main, assert the 403 status and that the body says the port is not published. Remove the stale TODO(T70, #1858).
    • Keep the declared-port leg if you like, but label it NET-121.
  2. Run half: test NET-131's trigger, the command's exit. NET-131 is "WHEN the run's command exits THE SYSTEM SHALL end the box, whether or not the client that started the run is still present".
    • Run a command that exits by itself shortly afterwards (e.g. sleep 3).
    • SIGKILL the client while that command is still running.
    • Assert the box leaves min ls after the command exits. Keep your delist rule: only a non-empty listing that does not name the box counts.
    • Check what round 3's daemon fix keys on (--owns-box in crates/minimald/src/exec.rs):
      • if it ends the box when the exec exits, it is correct; just fix any comment or test name that says "the client's death ends the box";
      • if it ends the box when the client's connection drops while the command still runs, that contradicts NET-015 (a box keeps running whether or not a client is attached), and it must move to the exec-exit path, with a unit test: the client disconnects while the command runs, the box stays until the command exits, then it ends.
    • A command that dies because the client's stdio closed is the command exiting, and is fine. Don't key the teardown on the client.

Run ./scripts/session-e2e.sh ports_publish and each touched crate's tests. In the PR body, say which changes are product fixes and which are test fixes, and map each half to its requirement (NET-016, NET-121 if kept, NET-131, NET-015).

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Comment thread scripts/session-e2e.sh Resolved
A request the proxy refuses answered 403 with an empty body, so a
client could not tell a port the box never published from any other
policy refusal without reading the daemon log. The status writer now
carries the same plain-text reason the refusal's warn line records,
so the wire answer itself says 'the box has not published this port' —
'not permitted' stays distinguishable from a declared port's instant
connection-refused while nothing listens on it (NET-014, NET-016).
The design review found both remaining halves citing the wrong rule.
The declared-port leg proved NET-121's forward, not NET-016's publish:
relabeled. The refusal leg is the NET-016 half this half can reach —
a LIVE listen the rules permit no publication for — so its assertion
now demands the tell the rule requires: 403 plus a body saying the
port is not published, 'not permitted' rather than 'nothing
listening'; the stale TODO(T70, #1858) is gone with the body pinned.
NET-016's permitted arm stays out of the e2e and the case header says
why: no user surface sets the dynamic allow range, and the proxy's
by-name routes are built from the declaration, so a watcher-published
port has no name to reach through yet.

The run half now runs a command that exits by itself (echo; sleep 5)
and SIGKILLs the client inside that window: NET-131's trigger is the
command's exit — the destroy keys on the exec's exit status — and the
comments and messages no longer say the client's death ends the box.
The delist rule keeps its empty-listing guard.

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — advisory review

Verdict COMMENT — 1 finding, 1 inline.

Comment thread scripts/session-e2e.sh Resolved
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

The runtime will not revise this pull request again on its own: round 6 would exceed the cap of 1 (the last trigger was the runtime's review findings). A person decides now. Remove needs-human from this pull request to let /revise <note> or the automatic rounds resume, or finish #1667 by hand.

@minimal-foundry minimal-foundry Bot added the needs-human An agent handed off; a human must act, then clear this label. Set by defer and handoffs. label Oct 4, 2026
…seed

The permitted arm is reached by name through the host answerer at the
published address and needs the dynamic-range flags, both T82's (#1895).
The detach half's outside-client seed dir joins the teardown trap like
its three siblings.
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 5 of 10 on a /revise note, pushed as ad5bf1f01e49.

line exit tail
./scripts/session-e2e.sh port_publishes_on_listen_and_box_outlives_client 0 ::group::a declared port answers by name; a live listen the rules do not publish is refused as not-published; the box outlives its client (NET-121, NET-014, NET-016, NET-015, NET-131) port-publish half SKIPPED (no MINVMD_GVPROXY_BIN: this target has no switch) ::warning::detach half SKIPPED — this h

Verify min task run agent-verify exited 101.

Applying loadouts: default
Running task runtime-implement-verify in session task-runtime-implement-verify-1d29...
    Checking args v0.0.1 (/home/runner/.local/state/minimal/sessions/968de/tree/crates/args)
    Checking ot v0.0.1 (/home/runner/.local/state/minimal/sessions/968de/tree/crates/ot)
    Checking paths v0.0.1 (/home/runner/.local/state/minimal/sessions/968de/tree/crates/paths)
   Compiling stdlib v0.0.21 (/home/runner/.local/state/minimal/sessions/968de/tree/crates/stdlib)
   Compiling version v0.7.0 (/home/runner/.local/state/minimal/sessions/968de/tree/crates/version)
    Checking diagnostics v0.0.1 (/home/runner/.local/state/minimal/sessions/968de/tree/crates/diagnostics)
    Checking common v0.0.1 (/home/runner/.local/state/minimal/sessions/968de/tree/crates/common)
    Checking async-dialog v0.0.1 (/home/runner/.local/state/minimal/sessions/968de/tree/crates/async-dialog)
    Checking switch v0.0.1 (/home/runner/.local/state/minimal/sessions/968de/tree/crates/switch)
    Checking mlog v0.0.1 (/home/runner/.local/state/minimal/sessions/968de/tree/crates/mlog)
error: using `chunks_exact` with a constant chunk size
   --> crates/switch/src/refusal.rs:205:10
    |
205 |         .chunks_exact(2)
    |          ^^^^^^^^^^^^^^^ help: consider using `as_chunks` instead: `as_chunks::<2>().0.iter()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#chunks_exact_to_as_chunks
    = note: `-D clippy::chunks-exact-to-as-chunks` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::chunks_exact_to_as_chunks)]`

error: using `chunks_exact` with a constant chunk size
   --> crates/switch/src/refusal.rs:209:31
    |
209 |     if let Some(tail) = bytes.chunks_exact(2).remainder().first() {
    |                               ^^^^^^^^^^^^^^^
    |
help: consider using `as_chunks::<2>()` instead
   --> crates/switch/src/refusal.rs:209:31
    |
209 |     if let Some(tail) = bytes.chunks_exact(2).remainder().first() {
    |                               ^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.98.0/index.html#chunks_exact_to_as_chunks

error: could not compile `switch` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

Outside the task's layers::

  • crates/minimald/src/net/proxy.rs

Converted to a draft: something above needs a person before review.

Review threads the coder judged:

  • 👍 valid — scripts/session-e2e.sh: Fixed at 4dd8b8b and kept this round: the delist wait counts only a non-empty mnl ls listing — an empty answer leaves the verdict untouched and is held for the failure arm.
  • 👍 valid — scripts/session-e2e.sh: Fixed at 4dd8b8b and kept this round: all three by-name curls clear HTTP(S)_PROXY/ALL_PROXY/NO_PROXY (upper and lower) before -x, so an inherited proxy env var cannot take a leg out of the proxy.

Each half of the e2e case now tests the rule it cites, and the refusal is readable off the wire: a declared port refuses instantly until something listens, then its declaration's forward answers by name at once (NET-121); a LIVE listen on a port the rules do not publish is refused by name as not permitted — 403 plus a plain-text body saying 'the box has not published this port' — and the watcher's record shows it left unpublished (NET-016); the detach box keeps serving by name after its client walks away (NET-015); and a run's box ends when its run's command exits, its client SIGKILLed mid-command, with the daemon-side 'run box ended' record (NET-131). The stale TODO(T70, #1858) and every comment claiming the client's death ends the box are gone.

Notes from the agent: Product fix vs test fix, as the review asked the PR body to split: (1) PRODUCT, fix(minimald) bf3800f — crates/minimald/src/net/proxy.rs: the directive demanded asserting that the 403 body says the port is not published, but the premise does not hold on main: T70's refusal builder (#1858, crates/switch/src/refusal.rs) is frame-level — TCP RST/ICMP plus audit records — and never wrote an HTTP body; the proxy answered 403 with Content-Length: 0 (write_status). The proxy's own status writer now carries the refusal's reason as a plain-text body (the same string its warn line records), and the unit test pins it. Other 403 consumers assert status only (e2e parity case and proxy_want legs) and are unaffected — all 39 net::proxy tests pass. (2) TEST, test(e2e) b4a1b74 — scripts/session-e2e.sh only: the declared-port leg is relabeled NET-121 (it proves the declaration's forward, which is what the case reaches), the refusal leg is the NET-016 half with the status+body assertion and the TODO removed, and the run half now runs 'echo ; sleep 5' and SIGKILLs the client inside that window. exec.rs was checked as directed and needs no change: the destroy is keyed on the exec's exit (TaskRun: exi…[truncated]

@minimal-foundry
minimal-foundry Bot marked this pull request as draft October 4, 2026 05:04
@norrietaylor
norrietaylor marked this pull request as ready for review October 4, 2026 06:11
@norrietaylor

Copy link
Copy Markdown
Member

/review

@minimal-foundry minimal-foundry Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minimal-review — approved

Verdict APPROVE — No findings.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Oct 4, 2026
@norrietaylor norrietaylor removed the needs-human An agent handed off; a human must act, then clear this label. Set by defer and handoffs. label Oct 4, 2026

@norrietaylor norrietaylor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 9c1da22. ARCH PASS, every lane green, minimal-review approved this head, and no open threads.

@norrietaylor
norrietaylor added this pull request to the merge queue Oct 4, 2026
Merged via the queue into main with commit 6ac7f18 Oct 4, 2026
34 checks passed
@norrietaylor
norrietaylor deleted the agent/1667-ports-publish-themselves-and-the-box-outlives-it branch October 4, 2026 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review:approved minimal-review approved the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

T25 — Ports publish themselves and the box outlives its client, end to end

1 participant