Skip to content

fix(minvmd): a resumed host_ip box gets its egress back after a VM host daemon restart with no new - #3368

Merged
mitodrummer merged 3 commits into
mainfrom
agent/3355-a-resumed-host-ip-box-gets-its-egress-back-after
Nov 13, 2026
Merged

mitodrummer merged 3 commits into
mainfrom
agent/3355-a-resumed-host-ip-box-gets-its-egress-back-after

Conversation

@minimal-foundry

Copy link
Copy Markdown
Contributor

Defect

Fixes #3355

Task marker
### D3015 — A resumed host_ip box gets its egress back after a VM host daemon restart with no new client admit
  kind: task
  size: M
  est: 140 code, 110 tests
  executor: agent
  defect: bug
  epic: 1437
  layers:
    - registry:
      - crates/minvmd/src/box_registry.rs: persists each admitted host_ip box's declared policy and lane beside HOST_IP_IDS_FILE, reloads them as dormant rules at open, and updates the admit_host_ip_box doc
      test: cargo test -p minvmd host_ip_box_rules_survive_a_restart_and_rejoin_on_resume
  proof: After a minvmd restart, a host_ip box that the guest reports running gets its admitted egress from the next reconcile, and no client admits it again.

Proof

After a minvmd restart, the registry reloads each held host_ip box's declared policy and lane from box-host-ip-rules.json as set-aside rules. The first reconcile that finds the guest runs the box puts the same rules back in the gate's union, and the client admit count does not change. The test host_ip_box_rules_survive_a_restart_and_rejoin_on_resume shows this.

Notes from the agent: The new file box-host-ip-rules.json sits beside box-host-ip-ids.json. It holds every box whose rules are held, resident or set aside. It stores the declared policy, and a reload fills it under the current egress default, as an admit does. Rules that a client retired are not persisted. A reconcile that finds the guest no longer lists a box removes it from the file. An unusable file is set aside, and no rules are reloaded. HostIpBoxRules now carries the declared policy, so its equality also compares the declared policy. One effect: two declarations with the same effective rules now count as a change, and the cohort record is rebuilt. Clippy (-p minvmd --all-targets) is clean, and the 20 lib tests that match host_ip pass. One full run of cargo test -p minvmd --lib failed 5 timing tests in bep_attach, net::answerer and sock, which this change does not touch. Each of them passed when I ran it alone or in a small group, so I think the full parallel run's load caused the failures.

Tests

line exit tail
cargo test -p minvmd host_ip_box_rules_survive_a_restart_and_rejoin_on_resume 0

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.

Persist each held host_ip box's declared egress policy and credentialed
lane to box-host-ip-rules.json beside the host_ip id file. A restart
reloads them as set-aside rules, so the next reconcile that finds the
guest runs the box puts its egress back with no client admit.
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

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

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 85d7381a-1772-4898-892e-4ff7f02c840c

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@minimal-foundry

minimal-foundry Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Reviewed: no findings; approval withheld, 2 threads unresolved at f7dd9c115826.

APPROVE withheld: 2 unresolved threads — minimal-arch[bot] crates/minvmd/src/box_registry.rs:4313, minimal-arch[bot] crates/minvmd/src/box_registry.rs:7064. Resolving the last thread releases the approval on this head.

Resolve the open threads. Resolving the last one releases the approval on this head; no new review is required.

Verdict APPROVE, posted as a comment: the App cannot review its own pull request; the check and the label carry it.

Clobber: none seen.

@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 — No findings.

Panel: 1 of 3 personas ran (correctness); did not complete: security, supply-chain.

@minimal-foundry minimal-foundry Bot added the review:approved minimal-review approved the current head label Nov 13, 2026

@minimal-arch minimal-arch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

arch-review: CONDITIONS · 1 condition · the full ruling

The change persists each host_ip box's declared policy and reloads it as set-aside rules after a restart. This fits §7.1 and §4.3 of the egress gateway design. One path fails open. When the rules write fails after a client retires a box, the code only logs a warning, and the earlier file still lists the box. After a restart, a false guest report brings a stopped box's rules back into the union. UC5 and §5.5 forbid this. C1 removes the file on a write failure, so a restart reloads nothing.

Ruled at 1019bcc against gominimal/arch@15b603e6afb8 by claude-opus-5-5.

.collect(),
}
};
if let Err(error) = write_registry_file(&path, &file) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

C1 · A write failure here leaves the earlier file in place. After a retire, that file still lists the stopped box. A restart reloads it, and a false guest report brings its rules back (UC5, §5.5 line 184). Remove HOST_IP_RULES_FILE on this error and log it with error!. Then the next start reloads nothing.

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.

Addressed in f7dd9c115826: persist_host_ip_rules now removes HOST_IP_RULES_FILE on a write error and logs it with error!, so the next start reloads no rules.

.set_published(resident.boxes.keys().copied().collect());
}
drop(resident);
if removed || dormant_rules.is_some() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

C1 · This persist is the one that must not fail open. The test must cover a failed write on this path: retire, restart, report the box Active, and assert that nothing is admitted.

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.

Addressed in f7dd9c115826: Added host_ip_box_rules_write_failure_on_retire_reloads_nothing: the write on retire fails, then restart, report the box Active, and assert that nothing is admitted.

@norrietaylor

Copy link
Copy Markdown
Member

/revise apply the arch condition C1 from the arch-review check at 1019bcc680db (arch_rulings 1219, job 39fef4ab).

Evidence: persist_host_ip_rules() in crates/minvmd/src/box_registry.rs logs a warn! when write_registry_file returns Err, and leaves the earlier HOST_IP_RULES_FILE in place. After retire_host_ip_box drops a stopped box, that stale file still lists it. A restart then reloads the box as set aside, and a guest that reports it Active puts a retired box's rules back in the union. That breaks "Rules a client retired are never set aside".

Do:

  1. In persist_host_ip_rules(), on a write_registry_file error, remove HOST_IP_RULES_FILE with std::fs::remove_file, ignoring NotFound, so the next start reloads nothing (fail closed). Log the failure with tracing::error!, as read_host_ip_rules_file does for an unusable file.
  2. Extend host_ip_box_rules_survive_a_restart_and_rejoin_on_resume, or add a test, for a retire whose rules write fails. Make the rules path unwritable or a directory, retire the box, restart, report the box Active, and assert outcome.admitted is empty.

Change nothing else in the file. The rest of the change was ruled to fit §7.1 and §4.3.

A failed write left the earlier file, which can still list a box a
client retired. A restart then reloaded it, and a guest report brought
its rules back. Remove the file and log an error, so the next start
reloads no rules.
@minimal-foundry

Copy link
Copy Markdown
Contributor Author

Round 1 of 10 on a /revise note, pushed as f7dd9c115826.

line exit tail
cargo test -p minvmd host_ip_box_rules_survive_a_restart_and_rejoin_on_resume 0

Verify min task run agent-verify passed.

Review threads the coder judged:

  • 👍 valid — crates/minvmd/src/box_registry.rs:4313: persist_host_ip_rules now removes HOST_IP_RULES_FILE on a write error and logs it with error!, so the next start reloads no rules.
  • 👍 valid — crates/minvmd/src/box_registry.rs:7064: Added host_ip_box_rules_write_failure_on_retire_reloads_nothing: the write on retire fails, then restart, report the box Active, and assert that nothing is admitted.

After a minvmd restart, a host_ip box that the guest reports running gets its admitted egress from the next reconcile, and no client admits it again. When the rules write fails, the old rules file is removed, so a retired box does not come back after a restart.

Notes from the agent: Revise round 1 applies arch condition C1. persist_host_ip_rules now removes HOST_IP_RULES_FILE on a write error (NotFound is ignored) and logs with tracing::error!. The new test host_ip_box_rules_write_failure_on_retire_reloads_nothing puts a directory at the write's temporary path (box-host-ip-rules.json.tmp), so the write fails. Then it retires the box, restarts, reports the box Active, and asserts that outcome.admitted is empty. A directory at the rules path itself was not used, because remove_file cannot remove a directory, so that case does not exercise the fail-closed path. cargo clippy -p minvmd --all-targets and cargo fmt --check are clean.

@minimal-arch minimal-arch Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

arch-review: PASS · the full ruling

The change conforms to UC5 line 107 and §5.5 lines 184-185. After a restart, reloaded rules stay set aside until the guest reports the box running, as on a resume without a restart. This head closes the open path from the earlier ruling: a failed write now removes the earlier rules file, so a box a client retired does not come back. The new test proves that rule. No conditions.

Ruled at f7dd9c1 against gominimal/arch@15b603e6afb8 by claude-opus-5-5.

@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 — approval withheld

Verdict COMMENT — APPROVE withheld: 2 unresolved threads — minimal-arch[bot] crates/minvmd/src/box_registry.rs:4313, minimal-arch[bot] crates/minvmd/src/box_registry.rs:7064. No findings.

Panel: 3 of 3 personas ran (correctness, security, supply-chain).

@minimal-foundry minimal-foundry Bot removed the review:approved minimal-review approved the current head label Nov 13, 2026

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

@mitodrummer
mitodrummer added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit 9a2ed46 Nov 13, 2026
43 of 45 checks passed
@mitodrummer
mitodrummer deleted the agent/3355-a-resumed-host-ip-box-gets-its-egress-back-after branch November 13, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D3015 — A resumed host_ip box gets its egress back after a VM host daemon restart with no new client admit

2 participants