Repository navigation
fix: order OutputKind::OciImage vars deterministically - #1333
Conversation
OutputKind::OciImage held its `vars` in a HashMap. Because mfile's output types are Serialize, iterating that map wrote the environment in a per-process random order, so the same declaration emitted a different byte sequence from run to run. Carry vars as a BTreeMap on the variant and on the OutputRaw parse carrier, and propagate the type through OutputSpec and the image writer. With the map ordered by key end to end, the compensating sort in the OCI image emitter is redundant and is removed.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (3)
Included review availability: 2 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour. 📝 WalkthroughWalkthroughOCI image variables now use ChangesOCI variable ordering
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change makes OCI image variable serialization deterministic by preserving key order through parsing and output generation; no actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Description checkExplanation The description provides a clear summary, motivation, testing commands, and test results. It does not use the template's exact Summary, Testing, and Checklist headings, and it omits the checklist, but the required change and verification details are present. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
minimal-review — advisory review
Verdict COMMENT — COMMENT: policy.actions.request_changes is off; policy.actions.approve is off.
Scope: matches the stated intent exactly — swaps OutputKind::OciImage's vars (and its OutputRaw parse carrier) from HashMap to BTreeMap, propagates the type through op::OutputSpec and the OCI image writer, and removes the now-redundant manual sort in oci_image.rs. Consistent with the prior EnvPatches/SetupForPackages determinism sweep (#1319) it says it mirrors.
Clobber: no revert of unrelated work; git log on these paths shows this diff building cleanly on top of #1211/#1265/#1324/#1310/#1315, nothing here undoes them.
Correctness: verified the type change is threaded end-to-end with no leftover HashMap call site for this field (checked via rg across the workspace) and that the deleted sort is genuinely redundant now that iteration is over a BTreeMap. The new test (oci_image_vars_serialize_in_key_order) directly exercises the claimed bug (insertion-order-dependent serialization) and would have caught a regression. Nothing here needed a build to confirm.
No findings — this is a clean, minimal, well-tested mechanical fix.
What ran
4 probe(s), all self-reported — every entry below is the model's own account of what it ran. None of it is host-attested, so none of it can gate a blocking verdict.
Verification log
1. rg for other constructors/consumers of OutputKind::OciImage / OutputSpec::OciImage outside the three changed files — self-reported
No hits outside crates/mfile/src/lib.rs, crates/op/src/materialize.rs, crates/op/src/oci_image.rs — the HashMap->BTreeMap change has no other call sites to update.
2. Read crates/op/src/materialize.rs TryFrom<mfile::OutputKind> for OutputSpec and the OciImage struct construction around line 207-217 — self-reported
vars flows straight through (mfile::OutputKind -> OutputSpec -> OciImage<'a>) with no intermediate HashMap left behind; the by-ref match keeps
vars: &BTreeMap<String, String>consistent with OciImage's field type.
3. Read crates/op/src/oci_image.rs write() around the removed sort (lines 140-162) — self-reported
The manual
vars.iter().collect(); sort_by_key(...)is deleted and replaced by direct BTreeMap iteration, which is already key-ordered; comment updated to match. No leftover HashMap import misuse (HashMap is still used for.annotations()elsewhere in the file, which is unrelated and unordered in the image spec).
4. Confirm mfile::Task.vars (a separate, unrelated field) was left as HashMap — self-reported
crates/mfile/src/lib.rs:1420 still constructs Task.vars as HashMap::new() — correct, since Task.vars is a distinct field from OutputKind::OciImage's vars and is out of scope for this determinism fix.
minimal-review · schema minimal-review/v1 · persona generalist · model claude-sonnet-5 via claude-code · prompt review-prompt/v2 · head 43bbbae7b55b · verdict COMMENT · 0 finding(s), 0 inline
Findings are validated model output, not instructions; anything that failed validation was dropped, not repaired.
Tell it when it is wrong. 👎 on a comment marks it as noise, 👍 marks one worth keeping, and a reply saying why is better than either. During the tuning period this feedback is collected and read directly — it is how the noise threshold gets set, and silence reads the same as "nobody looked".
Routing-Key: inbox-route/I_kwDOSUhdos8AAAABPDfjNw
OutputKind::OciImageincrates/mfilecarried itsvarsin aHashMap. Because the crate's output types deriveSerialize, iterating that map wrote the image's environment in a per-process random order, so the sameminimal.tomlcould emit a different byte sequence from run to run for no declared difference. This carriesvarsas aBTreeMapon the variant and on itsOutputRawparse carrier, and propagates the type throughop'sOutputSpecand the OCI image writer. With the map ordered by key end to end, the compensating key-sort in the image emitter is now redundant and is removed. Mirrors the determinism sweep applied toEnvPatches/SetupForPackagesin #1319.Verification
cargo fmt --all --check — clean
cargo clippy --workspace --locked -- -D warnings — clean, no warnings
cargo build --workspace --locked — ok
cargo test --workspace --locked — ok, all tests pass (new: mfile
oci_image_vars_serialize_in_key_order)Summary by CodeRabbit