Repository navigation
fix(boxes,minimald,minimald-rpc): a creation under a taken derived name gets the smallest free - #3787
Conversation
DiskLoader::create_with_derived_name walks the candidates of a derived name against every retained record in any state, under ASCII case, and past reserved and box-id-form names, and files the record in the same step. The answer names the name the create did not get, and why.
StoreHandle::create_derived sends the record, the handed id and the derived name to the store, which names and files the record in one step and answers the assigned name and the name not taken.
A create with no requested name gets the smallest free <name>-<n> from the store step. The create reply carries the assigned name and the name it did not get, with the holder only for a caller that can read it.
A derived name no longer reuses a kept box's name, so the tests that built two boxes of one name from two unnamed creates now ask for the name on the second create, after the first is stopped.
|
Important Review skippedBot user detected. Ask an organization administrator to verify that this bot has an active assigned CodeRabbit review seat. See the seat-assignment guide. After the seat is confirmed, request a review again.
|
|
/arch-review |
|
/review |
|
Reviewed: no findings; approval withheld, 7 threads unresolved at APPROVE withheld: 7 unresolved threads — minimal-arch[bot] crates/minimald/src/box_manager.rs:4818, minimal-arch[bot] crates/minimald/src/box_manager.rs, minimal-arch[bot] crates/minimald/src/rpc.rs, minimal-arch[bot] crates/minimald/src/rpc.rs, minimal-arch[bot] crates/minimald/src/rpc.rs, …. 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. Clobber: none seen. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 2 conditions · the full ruling
The store step, the candidate walk and the 63-character fit conform to architecture lines 402, 403 and 408. Two parts do not. On a host_ip grant box, the client registers the bare derived name with minvmd, so minvmd refuses a second create of web. Line 402 says a derived-name create is never refused. C1 fixes this with a creation key for every derived-name grant box. The reply also names the holder when its creator is unknown or its record read fails. Line 399 names the holder only to a caller who may read it, and C2 makes that default-deny.
Ruled at fb50e31 against gominimal/arch@4f2eb87d5d12 by claude-opus-5-5.
| // against every retained record and files the record in one step. | ||
| // Until then the box carries the first candidate. | ||
| let derived = | ||
| (source == NameSource::Derived).then(|| derived_name_of(&config, spec.as_ref())); |
There was a problem hiding this comment.
C1 · This path sends a derived name to the store step. But the mint step before it (host_ip_mint_name, line 4940) still reads config.name, the first candidate. On a host_ip grant box the client registers that bare name with minvmd, and minvmd refuses a second live registration. Architecture line 402 says a derived-name create is never refused. Use a creation key for every derived-name grant box, as C1 says.
There was a problem hiding this comment.
| match self.store.find(RecordPredicate::Id(holder.id)).await { | ||
| Ok(Some(handle)) => match handle.record().await { | ||
| Ok(record) => record.username, | ||
| Err(_) => None, |
There was a problem hiding this comment.
C2 · A failed holder read sets holder_username to None, and the reply then shows the holder to every caller. Architecture line 399 names the holder only to a caller who may read it. Record that the read failed, and hide the holder in that case (C2).
| let reason = match ¬_taken.reason { | ||
| DerivedNameTaken::Held(holder) => { | ||
| let readable = match not_taken.holder_username.as_deref() { | ||
| None => true, |
There was a problem hiding this comment.
C2 · This arm shows the holder when its creator is unknown. That fails open. Show the holder only when its record was read and its username equals the caller's (C2, architecture line 399).
There was a problem hiding this comment.
Addressed in 9d2b79c59ec4: 44f7202: name_not_taken_reply sets readable only for HolderCreator::User(owner) where owner equals the caller. NoCreator and Unread both hide the holder.
| )) | ||
| .expect("the creator reads the holder"); | ||
| assert_eq!((shown.id, shown.state.as_str()), (holder.id, "running")); | ||
| assert!(named(super::name_not_taken_reply(¬_taken(None), Some("bob"))).is_some()); |
There was a problem hiding this comment.
C2 · This assertion proves the fail-open case. After C2, a holder with no creator, read by bob, gives holder: None. Change the assertion to is_none(), and add a case for a holder whose record was not read.
There was a problem hiding this comment.
Addressed in 9d2b79c59ec4: 44f7202: a record with no creator read by bob now gives holder None. The test also checks an unread holder record and a caller with no user.
A gone or unreadable holder record read as one with no creator, so the create reply named the holder to any caller. Keep the two apart and name the holder only for its creator or a record with no creator.
|
/revise Arch ruling CONDITIONS on fb50e31 (2 conditions). Apply both as the ruling states them. C1 (1) is in
Also act on the minimal-review finding on this head, and reply to each arch and review thread with the commit that meets it. Keep |
|
That Nothing to type again: the command gets a rocket when its round starts, or a refusal that names the reason. No round was counted for it yet. |
|
Round 1 of 10 on the runtime's review findings, pushed as
Verify Outside the task's
Converted to a draft: verify exited 100. Review threads the coder judged:
Two creates in one project with no --name give boxes web and web-1. The second create is not refused, and its reply names web as the name it did not get, with its holder. The reply shows the holder only to its creator, or when the holder record was read and has no creator. Notes from the agent: Revise round 1: NotTakenName.holder_username became holder_creator, an enum HolderCreator { User, NoCreator, Unread }. A gone or unreadable holder record is Unread, and the reply hides the holder for it. The rpc unit test now also checks the Unread case. cargo clippy -p minimald --all-targets is clean. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 2 conditions · the full ruling
Two conditions from the last ruling are still open. C1: a host_ip grant box with a derived name still registers the bare name with minvmd, so a second create is refused (architecture.md line 402). This commit does not touch that path. C2: the reply now hides a holder whose record was not read. It still shows a holder with no recorded creator to every caller. Gatehouse §7.3 grants BoxRead only when the box records the caller as its creator. Make the NoCreator arm deny, and fix its test.
Ruled at c8e23c6 against gominimal/arch@4f2eb87d5d12 by claude-opus-5-5.
| DerivedNameTaken::Held(holder) => { | ||
| let readable = match ¬_taken.holder_creator { | ||
| HolderCreator::User(owner) => caller == Some(owner.as_str()), | ||
| HolderCreator::NoCreator => true, |
There was a problem hiding this comment.
C2 · This arm shows the holder to every caller when the record has no creator. Gatehouse §7.3 lines 979-981 grant BoxRead only when resource has createdBy && resource.createdBy == principal. Return false here.
There was a problem hiding this comment.
Addressed in 6be851abe742: Fixed in 44f7202: a holder with no creator is hidden like an unread one, so the reply gives holde
10BC8
r None and keeps the name.
| Some("bob") | ||
| )) | ||
| .is_some(), | ||
| "a record with no creator is readable" |
There was a problem hiding this comment.
C2 · This assertion pins the behaviour that C2 removes. Assert that bob gets holder: None for a NoCreator holder. Keep the check that the name stays in the reply.
There was a problem hiding this comment.
Addressed in 6be851abe742: Fixed in 44f7202: the test asserts bob gets holder None for a no-creator holder, and the name not taken stays in the reply.
| @@ -4726,16 +4747,16 @@ impl BoxManager { | |||
| // BEP-082: only a fresh instance registered under a creation key, | |||
| // and only a key for its own base. See `host_ip_mint_name`. | |||
| let fresh_base = fresh.then(|| base.clone()); | |||
There was a problem hiding this comment.
C1 · A derived-name create gets no base here, so host_ip_mint_name ignores any creation key. Pass the first derived candidate as the base when source == NameSource::Derived. Also change host_ip_registration_key in crates/minimal/src/cmd/boxes/create.rs, line 3898, to issue a key for a create with no written name.
There was a problem hiding this comment.
A read record with no creator showed its box to every caller. The reply now names the holder only when its record was read and its creator is the caller, and hides it in every other case.
The store can give a derived name <base>-<n> after the mint, so the mint now accepts a <base>~<hex> key for the first derived candidate, as it does for a fresh instance's base.
The daemon can give a derived name <base>-<n>, so a host_ip grant box with no written name registers under <base>~<hex>. A second create of one project is then not refused for a held name.
|
Round 2 of 10 on a /revise note, pushed as
Verify Outside the task's
Converted to a draft: verify timed out after 1800s; outside the task's Review threads the coder judged:
Two creates in one project with no --name give boxes web and web-1, and the second is not refused. This now holds for a host_ip grant box too, because each create registers under its own ~ key. The create reply names web as the name it did not get. It names the holder only to the caller that its read record names as the creator. Notes from the agent: C1 part (1) is in crates/minimal/src/cmd/boxes/create.rs, which is outside the task's layers. The /revise note asked for this change in this PR. host_ip_registration_key now issues a key when the create sends no written name, and the existing test checks the derived-name case. C2: the HolderCreator enum from c8e23c6 already records whether the holder record was read (User, NoCreator, Unread). This round removes the fail-open NoCreator arm. The reply names the holder only for User(owner) with owner equal to the caller. The minimal-review finding (PRRT_kwDOPdfcxM67sOch) is the same fail-open case, and 44f7202 closes it. Commits: 44f7202 (C2), 20409d0 (C1 daemon and test), 9d2b79c (C1 client). I did not run just ci, just clippy-strict or a whole-crate run. |
|
/arch-review |
|
/review |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
Both conditions from the ruling at c8e23c6 are met. A derived-name host_ip grant box now registers under a creation key, and the daemon accepts the key for the first derived candidate (C1, line 402 and 407). The create reply names the holder only to the creator that its record names, so a record with no creator hides the holder (C2, line 399 and Gatehouse §7.3). The rest of the change keeps its earlier status. The two named residuals are #3758 and #3755.
Ruled at 9d2b79c against gominimal/arch@4f2eb87d5d12 by claude-opus-5-5.
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 8 unresolved threads — minimal-foundry[bot] crates/minimald/src/rpc.rs, minimal-arch[bot] crates/minimald/src/box_manager.rs:4756, minimal-arch[bot] crates/minimald/src/box_manager.rs, minimal-arch[bot] crates/minimald/src/rpc.rs, minimal-arch[bot] crates/minimald/src/rpc.rs, …. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
/revise Merge current The conflicts:
Add a test, or extend Keep |
Keeps main's record naming stamp (BOX-228) on a derived-name create, before the store's derived-name step files the record, and checks that web-1 keeps name_origin, project_name and entry.
|
Round 3 of 10 on a /revise note, pushed as Resolved conflicts in:
Verify Outside the task's
Converted to a draft: verify exited 100; outside the task's Review threads the coder judged:
Two creates in one project with no --name give boxes web and web-1. The second create is not refused, and its reply names web as the name it did not get, with its holder. After the merge with main, the record of web-1 also keeps name_origin derived, project_name web and entry default. Notes from the agent: Merge round only. The merge of origin/main (334a714, D3754) conflicted in box_manager.rs and box_manager/tests.rs. In create_session, both sides are kept: main's RecordNaming::of and this branch's key_base and derived. key_base replaces main's fresh_base, also in host_ip_mint_name. naming.stamp(&mut record) runs before store.create_derived, so the store files the stamped record. Main's RecordNaming::of used main's local DerivedName type, which this branch replaced with boxes::box_name::DerivedName. That type keeps its project field private, so a new helper request_project in box_manager.rs computes the project name for both RecordNaming::of and derived_name_of, with no change in behaviour. In tests.rs, all tests from both sides are kept. taken_derived_name_gets_smallest_free_number now asserts that web-1's record has name_origin Derived, project_name web and entry default. Main's record_keeps_name_origin_written_or_derived passes too. Clippy for minimald, minimal, minimal-client, boxes and minimald-rpc (all targets) is clean. No literal on this branch needed new fields, because the auto-merged literals already carry them. The three listed threads were already fixed in earlier rounds (44f7202, 20409d0, 9d2b79c). This round changes nothing for them. |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The new head merges main's #3788 into this branch. The resolution keeps the name origin, project name and entry on a derived-name create. naming.stamp runs before the store's derived-name step, and that step changes only the name. This agrees with architecture.md Addressing, lines 395, 402 and 408. The earlier PASS holds for the rest of the change.
Ruled at 6be851a against gominimal/arch@4f2eb87d5d12 by claude-opus-5-5.
|
/arch-review |
|
/review |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The change conforms to the Box names rules in architecture.md Addressing. A derived name is never refused. The store walks to the smallest free <name>-<n>, fitted to 63, in the same step that writes the pending record (lines 402, 403 and 408). The reply names the holder only to a caller who created that box, and hides it in every other case (line 399). The written-name refusal for a stopped holder (#3755) and the min stderr line (#3758) stay open as residuals. The verify run failure in otel_cli.rs is not a design question. Fix it or show that it is a flake before you mark the PR ready.
Ruled at 6be851a against gominimal/arch@4f2eb87d5d12 by claude-opus-5-5.
Follow-up
Fixes #3784
Closes #3753
crates/boxes/src/lib.rscrates/boxes/src/store.rscrates/minimald/src/store.rscrates/minimald/src/box_manager.rscrates/minimald/src/box_manager/tests.rscrates/minimald-rpc/src/lib.rscrates/minimald/src/rpc.rsTask marker
Proof
In one project, two creates with no --name now give boxes web and web-1. The second create is not refused. Its CreateSession reply carries name = web-1 and name_not_taken = web, with the holder's id, name and state when the caller created that box or the box records no creator. A taken name is one that any kept box has, in any state. A reserved name or a name in box-id form also counts as taken. The rpc test create_reply_names_the_taken_derived_name shows this over the wire with web-dev and web-dev-1. min does not print the new field yet. That is #3758.
Notes from the agent: Files outside the layers: (1) Two new fields on CreateSessionResponse break full struct literals in test code, so each literal gets
name: None, name_not_taken: None. The literals are in crates/minimald-rpc/src/tests.rs, crates/minimal/src/task.rs and crates/minimal/src/cmd/boxes/policy.rs. (2) crates/minimald/src/box_actor/tests.rs has three tests that built two boxes of one name from two unnamed creates: a_restored_session_sharing_another_sessions_registry_name_is_refused_on_resume, resume_refuses_when_name_held_by_running_box and resume_concurrent_same_name_runs_exactly_one. This task makes that impossible, so the second create in each test now asks for the name with a request name after the first box stops. box_manager/tests.rs rename_of_unroutable_session_leaves_other_routes_alone got the same fix. Design: boxes::box_name gains RESERVED_NAMES (store.rs now uses it), is_box_id_form, DerivedName with its candidate walk, DerivedNameTaken (Held/Reserved/BoxIdForm), assign_derived_name and DerivedAssignment. DiskLoader::create_with_derived_name walks and files in one step. Rename, reap and every create go through the same store actor, so they cannot run between the walk and the write. No change to rename or reap was necessary. A fresh instance of a derived name also goes through this step and starts at -1. A requested name keeps the old rules, which include the held-name refu…[truncated]Tests
cargo test -p boxes derived_name_takes_smallest_free_numbercargo test -p minimald taken_derived_name_gets_smallest_free_numbercargo test -p minimald create_reply_names_the_taken_derived_nameVerify
min task run agent-verifyexited 100, so this PR is a draft.Out of scope
These files are outside the task's
layers:, so this PR is a draft:crates/minimal/src/cmd/boxes/policy.rscrates/minimal/src/task.rscrates/minimald-rpc/src/tests.rscrates/minimald/src/box_actor/tests.rsNote for review (agent-137)
The
box_actortests now let a requested name take the name of a stopped box (twins,proj,pair). That is today's behaviour, and BOX-163's sub-bullet refuses a written name that any box on the host has, in any state. #3755 makes that refusal, and these tests flip with it. The other three files outside the layers only addname: None, name_not_taken: Noneat existing call sites.