Repository navigation
fix: add determinism test for min init package ordering - #1391
Conversation
The init test module covered match_stack and generate_mfile behaviour but never asserted the ordering property the generated minimal.toml depends on: with only single-item package lists, an unordered collection in the build/runtime detection path would go unnoticed until users saw their minimal.toml churn between runs. Add a test that drives match_stack with several matching build and runtime packages and asserts each list comes out in a fixed order, so a future switch away from an order-preserving collection fails here rather than silently.
|
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 (1)
Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. 📝 WalkthroughWalkthroughThe change adds a test in Changesmatch_stack ordering
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~10 minutes Change: Other Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change adds deterministic-ordering coverage without introducing an identified merge risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
A rabbit checked the package trail 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 title: a single unit test in crates/op/src/project/init.rs locking the order in which match_stack emits detected build and runtime packages. Clobber none: git log -- crates/op/src/project/init.rs shows only the PR's own commit on top of the previous head (0faf940, #1345); nothing reverted. Correctness the test is deterministic and does what it claims. decode::StackMatcher::build_package_matchers/runtime_package_matchers are IndexMaps (crates/decode/src/stacks.rs:227,230), so iteration order is insertion order and the assertions reflect exactly what match_stack emits for the constructed stack. The guard is not easily dodged: the asserted runtime order (openssl, zlib, sqlite) is deliberately non-alphabetical, so a swap to either std::collections::HashMap (randomized order) or a key-sorted map (would emit openssl, sqlite, zlib) fails the runtime assertion, and a reversed iteration fails both. The PR body's premise checks out — the prior tests only ever assert single-element output lists, so multi-package order was unpinned. Not reported: the asserted order is synthetic and differs from the real rust stack in gominimal/pkgs (runtime packages there are openssl, bzip2, zstd, zlib), but the test's purpose is to pin the in-repo ordering mechanism, and the pkgs config is a pinned network checkout the test cannot depend on, so I judged that limitation below the reporting bar. Not checked: compiling or running the test, which is out of scope here.
What ran
5 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 -n 'build_package_matchers|runtime_package_matchers' crates/decode/src/stacks.rs — exit 0 · self-reported
Both fields are IndexMap<String, Vec>, so match_stack iteration order equals insertion order; the test's assertions match the emission order for its constructed stack.
2. git log --oneline -15 -- crates/op/src/project/init.rs — exit 0 · self-reported
Only the PR's own commit (20595f5) touches this file on top of the prior head; no recent fix reverted. HEAD equals the PR head_sha.
3. git show HEAD --format= -- crates/op/src/project/init.rs | rg -i 'pass|secret|token|api[-_]?key|password|BEGIN .*PRIVATE' — exit 1 · self-reported
No secret-shaped content in the diff; rg found no matches (exit 1).
4. python3 -c sorted-order comparison on asserted lists — exit 0 · self-reported
Asserted runtime order [openssl, zlib, sqlite] is not alphabetical (sorted would be [openssl, sqlite, zlib]), so a swap to a key-sorted map fails the runtime assertion; the build list [cc, pkg-config] happens to be sorted but the runtime list catches that regression.
5. WebFetch gominimal/pkgs stacks/rust/stack.ncl — self-reported
Real rust stack uses build_package_if_any/runtime_package_if_any with runtime order openssl, bzip2, zstd, zlib — differs from the test's synthetic order; noted as a limitation in the summary, not raised as a finding.
minimal-review · schema minimal-review/v1 · persona generalist · model deepseek/deepseek-v4-flash-0731:nitro via claude-code · prompt review-prompt/v2 · head 20595f5000d9 · 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_kwDOSUhdos8AAAABPk6b2A
min initdetects a project's build and runtime packages by iterating the matched stack's package matchers, and theminimal.tomlit writes is expected to be byte-identical across runs. The unit tests incrates/op/src/project/init.rsonly exercised single-item package lists, so nothing pinned that ordering: swapping the detection path to an unordered collection would reorder the emitted lists and churn a user'sminimal.tomlbetween runs, with no test to catch it.This adds one unit test that drives
match_stackwith several matching build and runtime packages and asserts each list comes out in a fixed order, so any move away from an order-preserving collection fails here instead of silently.Verification
cargo fmt --all --check --manifest-path target/Cargo.toml— cleancargo clippy --workspace --locked --manifest-path target/Cargo.toml -- -D warnings— passedcargo build --workspace --locked --manifest-path target/Cargo.toml— passedcargo test --workspace --locked --manifest-path target/Cargo.toml— passed, 0 failed (newmatch_stack_emits_packages_in_a_stable_orderincluded)Summary by CodeRabbit