Repository navigation
feat(minimal,minimald): one host line at start, classifier advisory only on declared egress - #2145
Conversation
One privileged step for every host need (NET-122, #2127): the user-namespace profile, box names (resolver hook, minzoned, the reserved range on macOS), the classifier tree and KVM group membership, each probed on this host and carried in one script only while it is missing. `--show` names the items, `--show --script` prints the exact script a run executes, `--show --json` reports them under `min/v1/finalize-install`, and `--undo` removes what the step installed. Without a terminal the run goes through `sudo -n` or exits 1 with the file route. BREAKING CHANGE: `min net setup` is removed with no alias; run `min finalize-install` (`--show --script` replaces `--print`). Closes #2127
…inalize-install's exit rules A names item with no daemon port is a waiting item, not a host fact no script can change: it is listed as waiting on a daemon under the summary, the other items still run, and the host is not finished. The classifier item is omitted until the step that renders it exists (#2128), so a native Linux host can finish. A run that added the operator to the kvm group ends with the login note; --undo takes --show only with --script; the no-TTY pointer uses mktemp; the run's summary goes to stdout; a daemon path an AppArmor tunable cannot name blocks the userns item.
…nly on declared egress The session start prints one host line naming the box (NET-018, NET-142): where its name resolves — natively, or via the hostname proxy's port — with the finish-setup clause while any finalize-install item is open, and the NET-020 cause in place of the resolution when the proxy failed to bind. The HOSTNAME PROXY and live-name-surface lines go away on activate; min ls keeps its detail rows and carries the same clause on its NAME SURFACE row. The classifier advisory (NET-079) prints only on a native daemon, only while the box declares egress, as two lines naming min finalize-install or the own-address start; the in-box banner follows the same rule, and every daemon-side remedy names min finalize-install instead of a fetch with placeholders.
|
Reading This comment updates when the review finishes. |
mitodrummer
left a comment
There was a problem hiding this comment.
Checked against the code at this head. Most of what's below is one theme: the advisory's min finalize-install remedy is a no-op, or gets the box refused, in several states. The rest is a nit on the install-fact helper.
| && sudo bash ./install-host-classifier.sh --user {account} \ | ||
| --cohort-address <cohort address> --node-plane-address <node-plane address>" | ||
| ) | ||
| "min finalize-install".to_string() |
There was a problem hiding this comment.
At this head min finalize-install cannot install the classifier: classifier_item_over still returns None on a delegated cgroup2 mount (the #2128 deferral), so on the usual host every surface carrying this hint (create advisory, start-up warn, unenforced notice, pty banner) points at a run that installs nothing for the classifier. It also splits the two surfaces: on a native-DNS host with the classifier missing, the host line has no finish setup clause (no classifier item, so other_items_unfinished is false) while the advisory says Enforce it: min finalize-install. Separately, stale_carve_out_refusal (classifier.rs ~L2286) still appends --answerer-address <ip> --answerer-port <port> to this hint, which now renders min finalize-install --answerer-address …, and FinalizeInstallArgs has no such flags. Its None arm still says "re-run the classifier install with --answerer-address…" too. Suggest landing this after #2144, which adds the Delegated missing item, and rewording both arms of the stale carve-out remedy to drop the installer flags.
There was a problem hiding this comment.
Agreed on the ordering: this PR lands after #2144, which adds the Delegated missing item, and the reconciliation onto it is what makes min finalize-install the install the hint names on the usual host (and what closes the split surface you describe: once the classifier item exists on a delegated mount, other_items_unfinished is true exactly when the advisory fires). Nothing here changes classifier_item_over.
The stale carve-out remedy was already reworded on this branch before this head: f6300db (fix(minimald): say what the stale carve-out remedy does today) drops the installer flags from both arms. The Some(bound) arm now reads re-render the carve-out onto the live bind <bound>: min finalize-install --undo, then min finalize-install re-renders the carve-out for the answerer's default port; a daemon whose answerer is bound elsewhere has no self-service remedy yet, and the None arm says to start the zone answerer on an IPv4 loopback address first, then the same undo-then-install. rendered_remedies_never_append_flags_to_the_install_verb pins that no rendered remedy or advisory appends --answerer-address/--cohort-address (or anything but the verb's own --undo). Verified at 95297e8.
| } else { | ||
| "so the box can still reach the network" | ||
| }; | ||
| let enforce = match cause.install_command() { |
There was a problem hiding this comment.
Following Enforce it: min finalize-install does not enforce the declaration in two cases. (1) An Allow-verdict declaration with allow_subnets/allow_dns_hosts/allow_protocols or deny_subnets entries: once the install lands, the host can decide per box, so refuses_unenforceable_declaration refuses the box at create and launch. Running the advised command gets the box refused instead of enforced. (2) TableNotEffective: the marker is present, so the finalize-install classifier item reads Done and the run is a no-op (the same holds for the "{hint} reloads it" refusal in refused_unenforced_host_address_box). Suggest naming only --network own_ip when unenforceable_rules(egress) is non-empty, and either dropping install_command for TableNotEffective or making the classifier item detect a table that is not in force. Smaller: an [egress] section with no lists or deny entries gets "you asked this box for limited network access", but it asked for nothing restrictive. The egress? gate in rpc.rs is per spec, but the wording should not claim a limit.
There was a problem hiding this comment.
Fixed in 95297e8, all three:
advisory_textnow takes the declaration instead of the folded verdict. Whenunenforceable_rules(declaration)is non-empty (an allow-list ordeny_subnetsentry), the second line names--network own_ipalone and says why:(on a host address the classifier enforces only a deny-all declaration, so a host that finished its install refuses this box rather than enforce its rules).classifier_advisory_prints_only_while_box_declares_egresspins the allow-list text.Cause::install_commandreturnsNoneforTableNotEffective: the marker the finalize-install item reads is present, so the run is a no-op, not a reload. The advisory over that cause falls to the own-address arm withmin finalize-install can't fix this: <detail>; therefused_unenforced_host_address_boxrefusal now says the bare verb is a no-op there and names--undo, then the install, as what reloads it.advisory_over_a_probe_cause_names_the_refusal_not_a_blanket_unenforcedand thedecidetests flip accordingly.- An
[egress]section with no lists or deny entries now readsnote: this box declares egress, but this machine can't enforce it yet, …— no claim of a limit. Deny-all keepsno network access; a declaration with an unenforceable rule keepslimited network access.
The egress? gate in rpc.rs is unchanged.
| let cause = decision | ||
| .as_ref() | ||
| .and_then(crate::net::classifier::Decision::cause) | ||
| .unwrap_or(crate::net::classifier::Cause::StepNotInstalled); |
There was a problem hiding this comment.
advises_unenforced_placement is true whenever no leaf was placed, including on a host whose decision can decide per box. For example, the placement probe fails with PermissionDenied because the daemon sits outside the delegated slice. In that case decision.cause() is None, and this falls back to StepNotInstalled. The banner then says "this machine can't enforce it yet … Enforce it: min finalize-install", but the table is loaded and the marker is present, so finalize-install runs nothing. Suggest emitting the banner only when the decision has a cause, or giving the unplaced-on-a-deciding-host state its own text that names the actual problem (daemon placement) instead of the install.
There was a problem hiding this comment.
Fixed in 95297e8: the banner is written only when the decision names a cause ((advise && !guest, policy.egress.as_ref(), decision.cause()) all present). A box nothing placed on a host that decides per box — the daemon-placement PermissionDenied case — gets the log record (which names the placement failure) but no banner, and no StepNotInstalled fallback remains. That matches the create reply, which carries no advisory without a cause either, so the two surfaces still agree.
| /// carries, probed from this host alone (no daemon read: the names item is | ||
| /// the surface verdict the line already holds). Every item is Linux-only, | ||
| /// so a macOS host reads `false`. | ||
| pub(crate) fn host_install_for_this_host(global: &GlobalArgs) -> crate::resolver::HostInstall { |
There was a problem hiding this comment.
Nit: this repeats plan_for_this_host's per-host scoping (userns unless minvmd, kvm vs classifier). #2144 changes classifier_item_on_this_host to take global and return Item, not Option<Item>, so the copy here breaks on rebase, and the two lists can drift. A shared other_items_for_this_host(global) -> Vec<Item> used by both would keep "same scoping" true by construction. Also nit: session.rs calls this on every activate before knowing whether a host line prints. Moving the call into the if let Some(surface) arm skips the probes when nothing prints.
There was a problem hiding this comment.
Fixed the call placement in 95297e8: host_install_for_this_host(global) is now called inside the if let Some(surface) arm in session.rs, so a start that prints no host line probes nothing.
On the duplicated scoping: agreed. The shared other_items_for_this_host(global) -> Vec<Item> used by both plan_for_this_host and the host line lands in this PR's reconciliation onto #2144 (which is also where classifier_item_on_this_host gains global and returns Item), so the two lists are one by construction at the point they would otherwise diverge.
There was a problem hiding this comment.
The shared helper is in at c2f1ebf (the merge of main with #2144): finalize_install::other_items_for_this_host(global) -> Vec<Item> holds the per-host scoping once (userns unless minvmd; then kvm for minvmd or classifier_item_on_this_host(global) — now #2144's Item — for native), and both plan_for_this_host (which slots the names item in before the last of them) and host_install_for_this_host read it, so the two lists cannot drift. The call placement fix from 95297e8 stands.
The NET-020 cause now replaces the resolution half whatever the surface verdict — the VM host daemon's sibling or a native daemon's own report — instead of printing beside a native verdict as a line of its own or going missing on a native daemon; the install clause stays the pre-fold verdict's. The CLI reference names the shipped host-line forms.
The refusal appended the installer script's --answerer-address and --answerer-port flags to min finalize-install, which takes neither; the CLI reads the answerer's bind itself, so the remedy is the bare verb and a sentence saying so. A test pins that no rendered remedy appends flags to the verb.
The install step reads no live answerer bind: undo then install re-renders the carve-out for the default port, and a daemon whose answerer is bound elsewhere has no self-service remedy yet. The listener-failure proof now also asserts the host line carries the cause.
std::process::exit runs no destructor and a piped stdout is block-buffered, so `min finalize-install --show --json > report.json` on an unfinished host wrote an empty file. Every exit in the command now flushes both streams first, and a CLI test runs the binary with stdout piped and asserts the whole report arrives with exit 1.
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 4 unresolved threads — mitodrummer crates/sandbox2/src/lib.rs:1042, mitodrummer crates/minimald/src/net/classifier.rs:430, mitodrummer crates/minimald/src/session_host.rs:4337, mitodrummer crates/minimal/src/cmd/finalize_install.rs:469. No findings.
… keeps a foreign profile
…e, stock @{HOME} scope
…failure to the end
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 4 unresolved threads — mitodrummer crates/sandbox2/src/lib.rs:1042, mitodrummer crates/minimald/src/net/classifier.rs, mitodrummer crates/minimald/src/session_host.rs, mitodrummer crates/minimal/src/cmd/finalize_install.rs:469. No findings.
…g lines when both apply
…rded member on --undo One operator per line, appended only when absent, so a second user's run no longer overwrites the first's name, and --undo (and the installer's manual remedy) walk every line instead of a single cat. Also renames the installer's test-only root override from MINIMAL_OVERRIDE_NET_SETUP_ROOT to MINIMAL_OVERRIDE_FINALIZE_INSTALL_ROOT to match the command it serves.
mitodrummer
left a comment
There was a problem hiding this comment.
Our review comments are addressed; thanks.
… its detection maybe_remove_finalize_install detected the classifier tree under $_fi_root but printed a remedy against the bare $_cls_root; every other artifact roots both. The remedy now quotes "$_fi_root$_cls_root", and the installer test asserts it names the seeded root.
Root cause
A session start printed two host lines (
HOSTNAME PROXY: listening on …andthe hostname proxy is the live name surface …), neither naming the box, both pointing at setup wherever the proxy served. The classifier advisory (NET-079) printed on every native host-address start, whether or not the box had declared any egress to enforce, and on VM-backed daemons too; its remedy, and every daemon-side remedy that carriedsandbox2::classifier::install_hint(), was acurl | sudo bashcommand with<cohort address>placeholders rather than the verb that finishes the install.Fix
crates/minimal/src/resolver.rs::host_line/host_line_beside, used byactivate_session, which probes the host's items only once a line is going to print):names: <box>.min.internal resolves in any browser on this machinewhen native DNS is deployed,names: <box>.min.internal via 127.0.0.1:<port>otherwise;; finish setup: min finalize-installis appended while any finalize-install item is not done (missing|waiting|cannot, read throughfinalize_install::host_install_for_this_host, which probes the same userns/classifier/kvm items the plan scopes for this host). The two old lines are gone from activate.proxy_down) or a native daemon's ownhostname_routing_unavailablereport (resolver::host_line_proxy_cause) — replaces the resolution half whatever the surface verdict, and the box stays named:names: <box>.min.internal: the hostname proxy is not serving — <cause>, with the install clause after it when the pre-fold verdict and the other items say the install is unfinished (a finished native host grows no clause). The activate path no longer folds the sibling into the verdict or printsproxy_down_line_besideas a separate line; the existingwarning: session hostnames will not route … Remedy …block stays.min lskeeps its fold (ProxyNotServingrow / cause row) unchanged.min lskeepsHOSTNAME PROXY:andZONE ANSWERER:as detail rows and appends the same install clause to itsNAME SURFACE:row, whose words are otherwise unchanged (format_ls_on/format_ls_across_vms_ontake aHostInstall; the existing wrappers default it). The spec is being amended to say "same install clause" for this row.minimald::rpc::create_classifier_advisorytakesreq.config.policy.egress):Nonein a microVM, for an own-address box, or when the box declares no egress. Text is spelled once inminimald::net::classifier::advisory_text(cause, declaration)— the two lines from the issue:no network accessfor a deny-all declaration,limited network accessfor a declaration with a rule the classifier has no subtree for (unenforceable_rules), andthis box declares egressfor an[egress]section that lists nothing (it asked for no limit). The install is named only where running it enforces the declaration:Enforce it: min finalize-install (or start the box with --network own_ip, which enforces it now)over a missing step; a declaration with an unenforceable rule names--network own_ipalone, because a host that finished its install refuses such a box (refuses_unenforceable_declaration) rather than enforce it; a cause no install ends (cannot confine, the guest's table,TableNotEffective— the marker the install item reads is present, so the run is a no-op — and an unreadable probe) names the own-address start alone and saysmin finalize-install can't fix this: <cause>; over the two probe causes with a deny-all declaration (which the launch refuses) the first line says the box is refused rather than that it runs.Cause::install_commandisSomeforStepNotInstalledonly. The in-box pty banner follows the same rule (native daemon, declared egress) and prints the same text, and only when the decision names a cause — a box nothing placed on a host that decides per box (a daemon-placement failure) gets the log record, not a banner that hands out an install that changes nothing; the daemon's log record of an unenforced placement is unchanged, and the host fact still rides the reply formin session policy.sandbox2::classifier::install_hint()returnsmin finalize-install;own_account()(only used to fill the old command) is removed. The stale carve-out refusal (minimald::net::classifier::stale_carve_out_refusal) no longer appends the installer script's--answerer-address/--answerer-portflags to the verb: it names the remedy as it stands —min finalize-install --undo, thenmin finalize-install, re-renders the carve-out for the answerer's default port; a daemon whose answerer is bound elsewhere has no self-service remedy yet — and makes no claim that the step reads the live bind.scripts/session-e2e.shgreps follow the new lines;docs/reference/cli-min.mdnames the shipped host-line forms and clause.Known, pre-existing: zero host lines print when the reply reports no answerer, no proxy cause and no serving proxy port (the VM-backed pre-acquisition state or a daemon predating the fields) — nothing is claimed while nothing serves yet.
Acceptance
-p minimal activate_prints_one_host_line_per_install_stateresolves in any browser on this machine-p minimal activate_host_line_names_native_dns_when_deployed-p minimal activate_host_line_carries_finish_setup_clause_while_items_missingmin lskeeps detail rows, NAME SURFACE row carries the clause (compiled binary against a serving daemon)-p minimal ls_keeps_detail_rows_and_name_surface_clauselimited+ own-address start alone for an allow-list; no claimed limit for an empty section-p minimald classifier_advisory_prints_only_while_box_declares_egressTableNotEffectiveor an unreadable probe-p minimald advisory_over_a_probe_cause_names_the_refusal_not_a_blanket_unenforcedmin finalize-install, names the script or a fetch-p minimald rendered_remedies_never_append_flags_to_the_install_verb(plusnative_deny_all_refused_when_carve_out_target_is_stale)min finalize-installwithout the advisory-p minimal session_start_points_at_finalize_install_without_the_advisory(kept)activate_and_ls_report_native_surface,listener_failure_reported_with_remedy,min_prints_discovered_proxy_port,native_host_advises_classifier_install_without_prompt,own_ip_create_has_no_classifier_advisory,the_install_hint_names_the_installed_verbTest plan
Run in the lima Linux VM:
187df1961(reconciled onto fix(minimal,sandbox2): ship the classifier step from min finalize-install #2144; Rust identical toc2f1ebfbd):cargo nextest run --no-fail-fast -p minimald→Summary [ 30.166s] 955 tests run: 955 passed (1 leaky), 18 skipped. Atc2f1ebfbd:cargo clippy -p sandbox2 -p minimald -p minimal --all-targets --locked -- -D warnings→Finished, no warnings;cargo nextest run --no-fail-fast -p minimal -p sandbox2→Summary [ 7.530s] 582 tests run: 582 passed, 0 skipped.just lint-shell→52 script(s) passed shellcheck.95297e882(review round 2):cargo clippy -p sandbox2 -p minimald -p minimal --all-targets --locked -- -D warnings→Finished, no warnings;cargo nextest run --no-fail-fast -p minimal -p sandbox2→Summary [7.273s] 570 tests run: 570 passed, 0 skipped;cargo nextest run --no-fail-fast -p minimald→Summary [28.780s] 940 tests run: 940 passed (1 leaky), 18 skipped.f6300dbc0:cargo clippy -p sandbox2 -p minimald -p minimal --all-targets --locked -- -D warnings→Finished, no warnings;cargo nextest run --no-fail-fast -p minimald -E "test(/classifier|advis|unenforced|install_hint|finalize|carve|remed/)"→Summary [12.375s] 70 tests run: 70 passed, 888 skipped;-p minimallistener_failure_reported_with_remedy(now also asserting thenames: <box>.min.internal: the hostname proxy is not serving — <reason>line),activate_prints_one_host_line_per_install_state,ls_keeps_detail_rows_and_name_surface_clause,activate_and_ls_report_native_surface→5 tests run: 5 passed.d23c42411(minimal/sandbox2 unchanged since):cargo nextest run --no-fail-fast -p minimal -p sandbox2→Summary [7.224s] 569 tests run: 569 passed, 0 skipped.088c3e087(before the review round, daemon code unchanged since):cargo nextest run --no-fail-fast -p sandbox2 -p minimald→Summary [28.453s] 1004 tests run: 1004 passed (1 leaky), 18 skipped.just lint-prose docs/reference/cli-min.md→ no alerts on the edited lines (the file's pre-existing alerts are untouched).shellcheck -S warning scripts/session-e2e.sh→ clean.just e2e(scripts/session-e2e.sh) on a real host; the updated greps are reviewed by hand.Related
main(feat(minimal)!: replace min net setup with min finalize-install #2142 merged;feat/2127-finalize-installsquashed into it, this branch mergedorigin/mainat 4efc5d7 so only this PR's files differ from main).missingclassifier item andclassifier_item_on_this_host(global) -> Item): the per-host scoping now lives once infinalize_install::other_items_for_this_host(global) -> Vec<Item>, read by bothplan_for_this_hostandhost_install_for_this_host.install_hint()(test renamed tothe_install_hint_names_the_installed_verbto match fix(minimal,sandbox2): ship the classifier step from min finalize-install #2144).Closes #2131