Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
dffb13b
feat(minvmd): audit no-switch expose reports and ask yes admissions
minimal-foundry[bot] Nov 4, 2026
f4c131d
Merge remote-tracking branch 'origin/main' into agent/2929-expose-dec…
minimal-foundry[bot] Nov 4, 2026
f892bb1
Merge remote-tracking branch 'origin/main' into agent/2929-expose-dec…
minimal-foundry[bot] Nov 4, 2026
6d4b0c6
fix(minvmd): keep a cap window per box for boxes with no switch
minimal-foundry[bot] Nov 4, 2026
4ae1d17
Merge remote-tracking branch 'origin/main' into agent/2929-expose-dec…
minimal-foundry[bot] Nov 4, 2026
0dfb559
feat(minimald): report a no-switch box's expose decision by id
minimal-foundry[bot] Nov 4, 2026
291c81d
Merge remote-tracking branch 'origin/main' into agent/2929-expose-dec…
minimal-foundry[bot] Nov 4, 2026
bee53e2
Merge remote-tracking branch 'origin/main' into agent/2929-expose-dec…
minimal-foundry[bot] Nov 4, 2026
928f2de
fix(minvmd): flush a no-switch box's audit window when it ends
minimal-foundry[bot] Nov 4, 2026
0991384
Merge remote-tracking branch 'origin/main' into agent/2929-expose-dec…
minimal-foundry[bot] Nov 4, 2026
8da17e8
test(minimald): report a none box's denied expose by box id
minimal-foundry[bot] Nov 4, 2026
9114e44
test(minvmd): seed a none box through the host-door name hold
minimal-foundry[bot] Nov 4, 2026
ae01543
fix(minimald): always give the host report the box id
minimal-foundry[bot] Nov 4, 2026
97cab73
feat(minimal): hold a none box's name with the VM host at create
minimal-foundry[bot] Nov 4, 2026
f1e89da
Merge remote-tracking branch 'origin/main' into agent/2929-expose-dec…
minimal-foundry[bot] Nov 4, 2026
0f3afdb
Merge remote-tracking branch 'origin/main' into agent/2929-expose-dec…
minimal-foundry[bot] Nov 4, 2026
ef9ba67
fix(minimald): report by box id only for a box with no switch
minimal-foundry[bot] Nov 4, 2026
42590fe
test(minimal): move the none-box test above the BEP doc block
minimal-foundry[bot] Nov 4, 2026
3e3ac08
Merge remote-tracking branch 'origin/main' into agent/2929-expose-dec…
minimal-foundry[bot] Nov 4, 2026
15cf459
docs(minimal): name the none-box hold paths that skip it
minimal-foundry[bot] Nov 4, 2026
e38a0bc
fix(minimal): release, move and re-hold a none box's name hold
minimal-foundry[bot] Nov 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 49 additions & 4 deletions crates/minimal/src/cmd/boxes/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,19 @@ fn refuse_unhonourable_grants(
Ok(plan.warnings)
}

/// Whether the activation holds the box's name on the VM host daemon once
/// the box is active. A `host_ip` box holds it for the zone (NET-128). A
/// `none` box holds it so the host can name the box by its id when the
/// in-VM daemon reports an expose decision (NET-046). An own-address box
/// has a row, and a native host has no VM host daemon.
pub(crate) fn holds_name_with_vm_host(kind: paths::HostKind, network: boxes::NetworkMode) -> bool {
Comment thread
norrietaylor marked this conversation as resolved.
Resolved
kind == paths::HostKind::Minvmd
&& matches!(
network,
boxes::NetworkMode::HostNet | boxes::NetworkMode::NoNet
)
}
Comment thread
norrietaylor marked this conversation as resolved.
Resolved

/// Whether a box with `network` on a host of `kind` has its lookups go
/// through a switch that steers the credential module's names (BEP-017,
/// BEP-062). This is a host fact and does not read the steering. On the VM
Expand Down Expand Up @@ -2635,8 +2648,7 @@ pub(crate) async fn activate_box(
// A kept session is active: it gets the `host_ip` name hold
// an activation that succeeded makes below.
if outcome == CleanupOutcome::Kept
&& kind == paths::HostKind::Minvmd
&& request.config.network == boxes::NetworkMode::HostNet
&& holds_name_with_vm_host(kind, request.config.network)
&& let Some(name) = box_name.as_deref()
{
hold_box_name_with_vm_host(control_sock.clone(), name, Some(id), true).await;
Expand Down Expand Up @@ -2689,10 +2701,19 @@ pub(crate) async fn activate_box(
// attaches to or execs into is dropped once the daemon's reconfirm
// bound passes, and the name answers NXDOMAIN until the session's
// next attach or exec.
//
// A `none` box on a VM host takes the same hold (NET-046): it has no
// switch row, so the hold is the host's one record of its box id, and
// the in-VM daemon's expose decision report names the box by that id.
// Its name answers NODATA, as a `host_ip` box's does while it is not
// resident. `min session destroy` and the dashboard's destroy release
// it, `min session rename` moves it, and an attach or exec re-holds it
// after a VM host daemon restart, because `holds_name` (vm_host.rs) is
// true for a `none` box as for a `host_ip` box. An unnamed `none` box
// holds nothing, and the host refuses its report.
ActivationStep::HoldName
.run(async {
if kind == paths::HostKind::Minvmd
&& request.config.network == boxes::NetworkMode::HostNet
if holds_name_with_vm_host(kind, request.config.network)
Comment thread
norrietaylor marked this conversation as resolved.
Resolved
&& let Some(name) = box_name.as_deref()
{
hold_box_name_with_vm_host(control_sock.clone(), name, Some(id), true).await;
Expand Down Expand Up @@ -3800,6 +3821,30 @@ mod tests {
assert_eq!(refused.exit_code(), 3);
}

/// NET-046: a `none` box on a VM host holds its name with the host, as
/// a `host_ip` box does, so the host can name it by its box id.
#[test]
Comment thread
norrietaylor marked this conversation as resolved.
Resolved
fn none_box_holds_its_name_with_the_vm_host() {
use boxes::NetworkMode;
use paths::HostKind;
assert!(holds_name_with_vm_host(
HostKind::Minvmd,
NetworkMode::NoNet
));
assert!(holds_name_with_vm_host(
HostKind::Minvmd,
NetworkMode::HostNet
));
assert!(!holds_name_with_vm_host(
HostKind::Minvmd,
NetworkMode::OwnIp
));
assert!(!holds_name_with_vm_host(
HostKind::Minimald,
NetworkMode::NoNet
));
}

/// BEP-017, BEP-062, BEP-080: a GitHub grant box with `dns` steering,
/// declared or by default, or with `both`, is created where the VM
/// host's switch resolves its names, and `min box spec` shows it. On a
Expand Down
96 changes: 75 additions & 21 deletions crates/minimal/src/cmd/boxes/vm_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,12 @@ pub(crate) async fn release_held_name_after_attach(
/// a persisted registry failed to carry, its write a warn line — may be
/// gone by the time the attach lands; the re-hold is idempotent, so it
/// remakes the hold and the name answers NODATA through the attach
/// either way. Only a named `host_ip` session without a box row needs
/// it: a box that registered a row owns its name through the row, which
/// `resume_box_row` re-sends, and a `none` or `own_ip` session holds
/// nothing.
/// either way. Only a named `host_ip` or `none` session without a box
/// row needs it: a box that registered a row owns its name through the
/// row, which `resume_box_row` re-sends, and an `own_ip` session holds
/// nothing. A `none` box's hold is the host's record of its box id, so a
/// hold lost to a restart leaves the host refusing its expose decision
/// reports (NET-046). Only a `host_ip` box has egress to re-admit.
///
/// The record was read before the hold, so a destroy another client
/// issues in between can release the session's holds first and leave
Expand Down Expand Up @@ -347,7 +349,8 @@ pub(crate) async fn rehold_held_name_before_attach(
let Some(record) = record else {
return;
};
if record.network != boxes::NetworkMode::HostNet {
let host_net = record.network == boxes::NetworkMode::HostNet;
if !host_net && !holds_name(record) {
return;
}
// The box's egress, re-admitted before the attach or the exec for the
Expand All @@ -360,13 +363,15 @@ pub(crate) async fn rehold_held_name_before_attach(
// The session is looked up again once the admit is made, and a session
// gone by then has its rules retired, as the name re-hold below undoes
// its hold. A destroy that lands after that lookup retires them itself.
if host_ip_box_with_vm_host(
control_sock_beside(sock),
id,
record.policy.egress.clone(),
true,
)
.await
// A `none` box has no egress to admit, so only its name is re-held.
if host_net
&& host_ip_box_with_vm_host(
control_sock_beside(sock),
id,
record.policy.egress.clone(),
true,
)
.await
{
match attached_box_record(sock, id).await {
Ok(None) => {
Expand Down Expand Up @@ -413,29 +418,32 @@ pub(crate) async fn rehold_held_name_before_attach(

/// The undo of a re-hold made for session `id`, found gone since, from the
/// lookup of its name (`by_name`): the session to send the verb for and
/// whether the verb is a hold. A live `host_ip` session without a row that
/// answers to the name now is handed the hold back; no such session, and
/// whether the verb is a hold. A live session that holds its name
/// ([`holds_name`]) and answers to the name now is handed the hold back; no such session, and
/// the hold is released by `id`. A lookup that failed tells neither, so
/// nothing is undone (`None`): a release there could take the name from a
/// live session, and a hold left standing blocks nothing.
fn rehold_undo(
id: boxes::SessionId,
by_name: anyhow::Result<Option<boxes::Record>>,
) -> Option<(boxes::SessionId, bool)> {
let taken_over_by = by_name.ok()?.filter(|other| {
other.id != id
&& other.network == boxes::NetworkMode::HostNet
&& other.box_addresses.is_none()
});
let taken_over_by = by_name
.ok()?
.filter(|other| other.id != id && holds_name(other));
Some(taken_over_by.map_or((id, false), |other| (other.id, true)))
}

/// Whether this box holds its name at the VM host instead of registering
/// an address there. A `host_ip` box uses the host's own address, so the
/// host only reserves the name for it (a lookup returns no address), and
/// the record carries no `box_addresses`.
/// the record carries no `box_addresses`. A `none` box holds its name too
/// (NET-046): the hold is the host's one record of its box id, which the
/// in-VM daemon's expose decision report names.
pub(crate) fn holds_name(record: &boxes::Record) -> bool {
record.network == boxes::NetworkMode::HostNet && record.box_addresses.is_none()
matches!(
record.network,
boxes::NetworkMode::HostNet | boxes::NetworkMode::NoNet
) && record.box_addresses.is_none()
}

/// Withdraws a box's host row (T66) on the VM host daemon beside `sock`,
Expand Down Expand Up @@ -2152,6 +2160,52 @@ mod tests {
assert_eq!(request.session_id, Some(id));
}

/// NET-046: a named `none` box's hold is the VM host's record of its
/// box id, so an attach or exec re-holds it after a VM host daemon
/// restart, as a `host_ip` box's is. A `none` box has no egress, so
/// nothing is re-admitted for it.
#[tokio::test]
async fn an_attach_reholds_a_none_box_name_and_admits_no_egress() {
let dir = tempfile::TempDir::new().unwrap();
let ssh_sock = dir.path().join("ssh.sock");
let (requests, residency) = fake_vm_host_with_residency(
dir.path().join(minvmd::control::CONTROL_SOCK_FILE),
r#"{"name":"web","held":false}"#.to_string(),
)
.await;
let server = minimald::test_harness::TestServer::new().await;
server.listen_on_uds(&ssh_sock).await;
let project = tempfile::TempDir::new().unwrap();
let mut daemon = server.connect().await;
let id = minimald::test_harness::create_configured_session(
&mut daemon,
"web",
project.path().to_str().unwrap(),
)
.await;
let mut record = attached_box_record(&ssh_sock, id)
.await
.expect("the lookup does not fail")
.expect("the session's record is read");
record.network = boxes::NetworkMode::NoNet;
assert!(record.box_addresses.is_none());

rehold_held_name_before_attach(paths::HostKind::Minvmd, &ssh_sock, id, Some(&record)).await;
let seen = requests.lock().unwrap();
assert_eq!(seen.len(), 1, "one hold, one request");
let minimald_rpc::BoxControlRequest::HoldBoxName(request) =
serde_json_lenient::from_str(&seen[0]).expect("the request is the wire type")
else {
panic!("the re-hold is carried by the hold verb");
};
assert_eq!(request.name, "web");
assert_eq!(request.session_id, Some(id));
assert!(
residency.lock().unwrap().is_empty(),
"a `none` box has no egress to re-admit"
);
}

/// A stand-in VM host daemon at `control_sock` that answers `host_ip`
/// retires, and drops the first `unanswered` of them unanswered: their
/// connection closes, so the exchange fails. Returns the count of
Expand Down
60 changes: 60 additions & 0 deletions crates/minimal/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6831,3 +6831,63 @@ async fn box_first_slice_list_show_stop_rm_end_to_end() {
assert_eq!(spans, ran, "{span} spans\n{transcript}\n{log}");
}
}

/// A session record carrying `mode` and `box_addresses`, with everything
/// else at its default.
fn hold_record(
mode: boxes::NetworkMode,
box_addresses: Option<boxes::BoxAddresses>,
) -> boxes::Record {
boxes::Record {
id: boxes::SessionId::nil(),
name: Some("web".to_string()),
username: None,
project_path: paths::HostAbsPath::try_new("/tmp/project").unwrap(),
network: mode,
policy: boxes::BoxPolicy::default(),
task_addresses: Vec::new(),
box_addresses,
status: boxes::BoxState::Active,
reason: None,
exit_code: None,
signal: None,
hooks_enabled: true,
host_ip_enforcement: None,
box_id: None,
host_row_bound: false,
bound_ports: std::collections::BTreeSet::new(),
ends_with_run: false,
sealed_deliveries: Vec::new(),
root_certificate: None,
box_type: None,
parent: None,
project_root: None,
attrs: Default::default(),
}
}

/// NET-046: a named `none` box holds its name on the VM host, so the
/// paths that release or move a hold treat it as a `host_ip` box. The
/// dashboard's destroy (`dash/rpc.rs`) releases a hold only for a record
/// `holds_name` accepts, and `min session rename` and the dashboard's
/// rename move a hold only for such a record. An own-address box owns
/// its name through its row, and holds nothing.
#[test]
fn none_box_hold_is_released_by_destroy_and_moved_by_rename() {
assert!(
crate::holds_name(&hold_record(boxes::NetworkMode::NoNet, None)),
"the dashboard's destroy releases a `none` box's hold, and a rename moves it"
);
assert!(
crate::holds_name(&hold_record(boxes::NetworkMode::HostNet, None)),
"a `host_ip` box's hold is released and moved as before"
);
let row = boxes::BoxAddresses {
switch_address: std::net::Ipv4Addr::new(10, 0, 0, 2),
loopback_address: std::net::Ipv4Addr::new(127, 0, 0, 2),
};
assert!(
!crate::holds_name(&hold_record(boxes::NetworkMode::NoNet, Some(row))),
"a box with a row owns its name through the row"
);
}
19 changes: 15 additions & 4 deletions crates/minimald-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,12 +1114,23 @@ pub enum ExposeDecisionOutcome {
///
/// Fixed and size-bounded like the port reports: the row key, the port, and
/// three closed enums. The box is named by the host from the row at
/// `switch_address`, never by a string the guest sends. A report keyed at
/// no row is refused and leaves no record.
/// `switch_address`, never by a string the guest sends. A box with no
/// switch has no row key, so its report carries its box id instead, and
/// the host names the box from what it holds under that id. A report keyed
/// at no box the host holds is refused and leaves no record.
///
/// Both keys are serde-defaulted, so an older guest's report, which always
/// carries a switch address and never a box id, still reads.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
pub struct ExposeDecisionReport {
/// The switch address of the row the decision is about.
pub switch_address: std::net::Ipv4Addr,
/// The switch address of the row the decision is about. `None` for a
/// box with no switch, which [`Self::box_id`] names instead.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub switch_address: Option<std::net::Ipv4Addr>,
/// The box the decision is about, by its id. The host reads it only
/// when the report carries no switch address.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub box_id: Option<BoxId>,
/// The port the box asked to publish.
pub port: u16,
/// The decision the box's `dynamic_ingress` setting made.
Expand Down
Loading
Loading