Repository navigation
T44 — Give the proxy an attachment per box from outside the VM - #1871
norrietaylor merged 4 commits into
Conversation
NET-133: the host-side creator gives the node-local Box Egress Proxy one attachment per box, from outside the VM, before the box's first connection. The table is that gift's carrier: it mints a deterministic box id from the host's own facts -- the name, the switch address and the loopback address of the same row the registry already writes host-side (NET-138) -- and holds the id with the box's addressing, keyed by the source address the box's connections arrive from. An attachment is withdrawn when the box ends, and the withdrawal is what makes an ended box's values refused even when its revocation was never recorded anywhere: with the attachment gone, the address is nothing's, whatever a delivery claims. One info line per attachment issued and one per withdrawal, naming the box id, the switch address and the time since the box ended, so a bundle's daemon log tail carries both events.
The registry is now the attachment table's one writer, so the two move together: registering a box issues its attachment before the row is visible -- an address with a row always has an attachment, and the egress pool only grows from rows, so the attachment is ahead of the box's first connection -- and retiring the row withdraws it first, so a delivery racing the box's end finds no attachment and is refused rather than attributed to a box the table no longer holds. The node namespace is not a box and holds no attachment, the same one address the row table's own view excludes. The creator-driven withdrawal retires the attachment inside the row lock's critical section: the single path that nests the two locks, with every other path taking them one at a time, so the order never inverts, and a registration landing after the withdrawal cannot retire the new box's attachment.
The proxy's acceptor now holds the host's attachment table and looks every delivery's source address up in it: an address with no live attachment is nothing's and its delivery is refused, and a delivery header whose box id disagrees with the attachment's own is refused and audited. An all-zero id is no claim rather than a mismatch, so the switch pool's unfilled header travels as a non-claim until its own task fills it. The run command owns the table for the VM's life, hands it to the registry as its writer and to the stand-in acceptor as its reader, so the proxy side never writes a box's identity, only reads the host's.
…roxy-an-attachment-per-box-from-outsid
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
|
Approved: no findings at Nothing to do. Verdict APPROVE, posted as a comment: the App cannot review its own pull request; the check and the label carry it. Clobber: none. |
|
/revise Round 1. Scope: T44 / NET-133. You may change these files:
Do not touch anything else.
Context, not asks:
The PR body is edited by hand; do not rewrite it. |
T44 — Give the proxy an attachment per box from outside the VM
slice: S10
kind: task
covers: NET-133
size: L
est: 350 code, 180 tests
executor: agent
difficulty: needs care
model: strongest
diagnostics: the bundle's daemon log tail carries each attachment issued and withdrawn with the box id and address
observability: one info log line per attachment issued and withdrawn with the box id, the address and the time since the box ended
layers:
- vmhost:
- crates/minvmd/src/bep_attach.rs (new): the attachment table: box id, addressing and source address, issued before the box's first connection and withdrawn within 60 s of its end
- crates/minvmd/src/lib.rs: declares the attachment module
- crates/minvmd/src/box_registry.rs: feeds attachments from the host-side table only
- crates/minvmd/src/net/bep_host.rs: attributes an accepted socket only to a live box with an attachment, fills the delivery header's box id from the attachment, and aborts the rest
- crates/minvmd/src/net/bep_stub.rs: cross-checks a present box id against its own facts and refuses and audits a mismatch; an all-zero id is no cross-check
- crates/minvmd/src/cmd/run.rs: owns the table for the VM's life
test: cargo nextest run -p minvmd proxy_attachment_given_before_first_connection
test: cargo nextest run -p minvmd proxy_attachment_never_sourced_from_guest
test: cargo nextest run -p minvmd proxy_attachment_withdrawn_within_60s_of_box_end
test: cargo nextest run -p minvmd mismatched_box_id_in_delivery_header_is_refused
produces:
- crates/minvmd/src/bep_attach.rs
consumes:
- crates/minvmd/src/box_registry.rs
- crates/minvmd/src/net/bep_host.rs
proof: A new box's attachment reaches the proxy before its first connection, an address-to-box claim from inside the VM changes nothing, a delivery header whose box id disagrees with the acceptor's facts is refused, and an ended box's attachment is gone within a minute.
depends on:
- blocked by #1640
- blocked by #1794
Proof
A new box's attachment now exists the moment its host-side registration returns — while the proxy's pool is still empty, so it is ahead of the box's first connection — and is keyed by the source address its connections arrive from; an address-to-box claim sent from inside the VM changes nothing in the table and a made-up address buys nothing; a delivery header whose box id disagrees with the attachment the host holds is refused and audited (an all-zero id reads as no claim); and an ended box's attachment is withdrawn with its row in the same event that observed the end, so within the minute the proxy attributes nothing to the box.
Notes from the agent: Stale layer path: crates/minvmd/src/net/bep_host.rs does not exist at the branch head — T43 (#1801, commit ee56dc9) moved the Box Egress Proxy's listener pool and delivery header into the switch crate (crates/switch/src/bep_host.rs), which is outside this task's layers. Everything that layer named is done on the acceptor side inside bep_stub.rs except one piece:
fills the delivery header's box id from the attachmentcannot be done here — the header still leaves with an all-zero box id, which the acceptor reads as no claim (so deliveries are still attributed and answered), and a switch-crate test pins header.box_id == [0u8; 16] with the message "the box id stays zero until T44". The mint in bep_attach.rs is deterministic over the host's own facts (name, switch address, loopback address — 16 salted FNV-1a lanes, first byte forced odd so the all-zero no-claim id is unreachable) precisely so the switch-crate follow-up can derive the same id and fill the header; no hashing dependency was added because Cargo.toml is outside the layers. Verification beyond the four test lines: cargo nextest run -p minvmd (one end-of-run pass) is 234 passed, 0 failed; cargo clippy -p minvmd --all-targets is warning-free, so CI's -D warnings gate holds; cargo fmt -p minvmd andjust clippy-strictare clean on the changed lines…[truncated]Tests
cargo nextest run -p minvmd proxy_attachment_given_before_first_connectioncargo nextest run -p minvmd proxy_attachment_never_sourced_from_guestcargo nextest run -p minvmd proxy_attachment_withdrawn_within_60s_of_box_endcargo nextest run -p minvmd mismatched_box_id_in_delivery_header_is_refusedVerify
min task run agent-verifypassed ([tasks.verify]).Base
The base branch moved while the coder worked; it was merged in before the tests ran.
Closes #1660
Follow-ups
minvmd: withdraw box rows and proxy attachments on host events, not guest frame sources #1873 (residual: an escapee can force withdrawal of a sibling's attachment, which fails closed)
This PR supplies the per-box attachment that spec 24's BEP-020 reads at redemption: the sealed value's box must equal the attachment's box for the arriving source, and host-address boxes are admitted as the cohort (BEP-028). No open task in either repo renders BEP-020 against these attachments yet. The old BEP tree was retired, so that is a gap for the spec 24 re-plan under Local box egress proxy — sealed GitHub credentials and host-store secrets without Gatehouse #1501.
The box id this PR mints renders spec 24's BEP-070: a per-creation UUIDv7 whose random fields come from the OS CSPRNG, minted host-side, with collisions refused. BEP-070 is not rendered on main, so this PR's tests take its names:
box_id_is_a_csprng_uuidv7_per_creationandcolliding_box_id_refuses_creation.