[codex] introduce BaseDiskID typed base-disk ID flow#346
Merged
DorianZheng merged 1 commit intomainfrom Mar 4, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change introduces a new strongly typed base disk ID model and propagates it through the base disk domain and storage flow. The implementation adds
BaseDiskID/BaseDiskIDMint, switches base disk ID generation to the same Base62 random algorithm used byBoxIDMint, and replaces rawStringIDs in the base disk lifecycle with typed IDs.User Impact
Users benefit from stronger ID correctness guarantees in clone/rootfs base disk handling, especially in code paths that read, track, and garbage-collect base disks. This reduces the risk of accidentally passing malformed or wrong ID values between layers while keeping serialized/DB representations as text.
Problem
Base disk IDs were previously represented as plain strings and generated using
nanoid!(8). That allowed broad string usage across APIs and made it easy to accidentally mix unrelated values or pass invalid IDs without compile-time checks.Root Cause
The base disk path had no dedicated ID type, unlike box IDs (
BoxID). Without a semantic newtype, domain boundaries (disk manager, DB store, GC/ref tracking, rootfs install, migration) relied on unconstrained&str/StringIDs.Fix
The fix applies a typed-ID refactor across the base disk flow:
BaseDiskIDandBaseDiskIDMintinruntime/id.rswith strict Base62 validation (8 chars), plusDisplay,Debug,AsRef<str>,Borrow<str>, andToSql.BoxIDMintandBaseDiskIDMintto avoid duplicate generation logic.lib.rs.BaseDisk.idfromStringtoBaseDiskID.BaseDiskIDMint::mint():BaseDiskManager::create_base_diskGuestRootfsManager::installBaseDiskInfo::id() -> &BaseDiskIDfind_by_id(&BaseDiskID)delete(&BaseDiskID)add_ref(&BaseDiskID, box_id: &str)has_dependents(&BaseDiskID)dependent_boxes(&BaseDiskID)remove_all_refs_for_box(...) -> Vec<BaseDiskID>Validation
I validated formatting, linting, and tests with the following commands:
cargo fmtcargo fmt --checkcargo clippy -p boxlite --tests -- -D warnings(passed)cargo test -p boxlite565 passed; 0 failed; 5 ignored).clone_export_importfailed in this environment due unavailable runtime engine registration (Engine Libkrun is not registered. Available engines: []), which is an environment/runtime availability issue rather than a compile/type error from this refactor.