Skip to content

T44 — Give the proxy an attachment per box from outside the VM - #1871

Merged
norrietaylor merged 4 commits into
mainfrom
agent/1660-give-the-proxy-an-attachment-per-box-from-outsid
Oct 3, 2026
Merged

norrietaylor merged 4 commits into
mainfrom
agent/1660-give-the-proxy-an-attachment-per-box-from-outsid

Conversation

@minimal-foundry

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

Copy link
Copy Markdown
Contributor

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 attachment cannot 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 and just clippy-strict are clean on the changed lines…[truncated]

Tests

line exit tail
cargo nextest run -p minvmd proxy_attachment_given_before_first_connection 0 Applying loadouts: default Running task runtime-implement-test-0 in session task-runtime-implement-test-0-1d6f... Compiling ot v0.0.1 (/home/runner/.local/state/minimal/sessions/3858f/tree/crates/ot) Compiling args v0.0.1 (/home/runner/.local/state/minimal/sessions/3858f/tree/crates/args) C
cargo nextest run -p minvmd proxy_attachment_never_sourced_from_guest 0 Applying loadouts: default Running task runtime-implement-test-1 in session task-runtime-implement-test-1-22a9... Compiling version v0.7.0 (/home/runner/.local/state/minimal/sessions/1dd61/tree/crates/version) Compiling mlog v0.0.1 (/home/runner/.local/state/minimal/sessions/1dd61/tree/crates/
cargo nextest run -p minvmd proxy_attachment_withdrawn_within_60s_of_box_end 0 Applying loadouts: default Running task runtime-implement-test-2 in session task-runtime-implement-test-2-27a5... Compiling version v0.7.0 (/home/runner/.local/state/minimal/sessions/5d6f1/tree/crates/version) Compiling mlog v0.0.1 (/home/runner/.local/state/minimal/sessions/5d6f1/tree/crates/
cargo nextest run -p minvmd mismatched_box_id_in_delivery_header_is_refused 0 Applying loadouts: default Running task runtime-implement-test-3 in session task-runtime-implement-test-3-3f94... Compiling version v0.7.0 (/home/runner/.local/state/minimal/sessions/bb553/tree/crates/version) Compiling mlog v0.0.1 (/home/runner/.local/state/minimal/sessions/bb553/tree/crates/

Verify

min task run agent-verify passed ([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_creation and colliding_box_id_refuses_creation.

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.
@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: 1538d76f-56ec-4bdb-8f88-138750f763e1

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 6724f184114b.

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. git log on all four touched files shows only the three new commits on top of the switch crate's delivery-header work (#1810); no recent fix is reverted.

@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.

@norrietaylor

Copy link
Copy Markdown
Member

/revise Round 1.

Scope: T44 / NET-133. You may change these files:

  • the plan's vmhost layers: crates/minvmd/src/bep_attach.rs, lib.rs, box_registry.rs, net/bep_stub.rs, cmd/run.rs;
  • crates/switch/src/bep_host.rs, the corrected path of the stale crates/minvmd/src/net/bep_host.rs layer, which the architecture check approved;
  • the box-control registration in crates/minimald-rpc/src/lib.rs (RegisterBoxRequest) and its sender in crates/minimal (min session activate), for ask 1 only. The architecture check approved this edit because both ends are host-side.

Do not touch anything else.

  1. Make the box id a real per-creation UUIDv7. A name digest is not acceptable.
    • Remove mint_box_id's FNV digest. The attachment's box id must be one UUIDv7 per creation, minted host-side with random bits from the OS CSPRNG (never counters), and it must be the box's id: the same value the CLI and the sealed member carry.
    • If min session activate already holds such an id for the box, send it in RegisterBoxRequest and use it.
    • If it doesn't, mint it in minvmd at register, return it in the registration reply, and have the CLI record it as the box's id. Either way, there is one id per box and no second, attachment-only id.
    • Registration refuses an id that collides with any retained row or attachment.
    • Tests:
      • box_id_is_unique_per_creation: recreating the same name on the same addresses yields a different id.
      • colliding_box_id_refused.
      • attachment_carries_the_registered_box_id: the id the CLI holds equals the attachment's.
  2. Fill the delivery header's box id, and refuse zero.
    • Add a box-id lookup by source address to BepBoxSource, implemented on RegisteredBoxes over Attachments.
    • In crates/switch/src/bep_host.rs, DeliveryHeader::for_flow fills box_id from the attachment when the pool accepts a flow. A box-plane source with no attachment is aborted; never send a zero id.
    • In bep_stub.rs, drop the "all-zero id is no claim" branch: a zero box id is refused and audited, like a mismatch.
    • Flip the switch test that pins [0; 16] so it asserts the attachment's id.
    • Test delivered_header_box_id_matches_attachment: with two boxes, each flow carries its own box's id, and a source with no attachment is aborted with nothing delivered.
    • proxy_attachment_given_before_first_connection asserts the stand-in received the non-zero id.
  3. Keep host-address boxes working as the cohort. Host-address boxes arrive from the cohort address and are cohort-attributed by design. Either give the cohort address a cohort attachment, or apply the no-attachment abort to box-plane sources only. The node namespace stays excluded.
    • Test host_address_box_still_delivers_as_cohort: a host-address box's flow is delivered and attributed as the cohort, not aborted.
  4. Keep the four plan test lines passing.

Context, not asks:

  • The header cross-check guards only against stale state; it does not catch a spoofed source. The comparison that carries the design's weight is redemption step 2 (the sealed member's box id equals the attachment's box id for the arriving source). That lives in the proxy's redemption, not in this PR.
  • Withdrawal keyed on guest frame sources is tracked in minvmd: withdraw box rows and proxy attachments on host events, not guest frame sources #1873; do not change it here.

The PR body is edited by hand; do not rewrite it.

@norrietaylor
norrietaylor added this pull request to the merge queue Oct 3, 2026
Merged via the queue into main with commit 2b9b218 Oct 3, 2026
34 checks passed
@norrietaylor
norrietaylor deleted the agent/1660-give-the-proxy-an-attachment-per-box-from-outsid branch October 3, 2026 09:44
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.

T44 — Give the proxy an attachment per box from outside the VM

1 participant