fix: correct ConfigMerger merge rules for booleans and arrays#14
Merged
Conversation
Fix two spec-compliance bugs in ConfigMerger::merge_two_configs(): 1. Boolean OR semantics for `privileged` and `init`: previously used Option::or() (last-wins), now uses OR semantics — `true` if either source is `true`. Fixes Features requiring privileged access from silently losing that capability during merge. 2. Array union for `mounts` and `forwardPorts`: previously replaced the base array with the overlay if non-empty, now unions both with deduplication — all unique entries from both sources are preserved. Fixes Features that add mounts/ports from silently dropping the user's own entries. Implementation: - Replace union_json_arrays + union_port_arrays with generic union_arrays<T> - Simplify merge_bool_or to a concise 2-arm match - Derive Eq for PortSpec (zero-cost type hygiene) - Add clarifying comment on run_services (Compose-specific, not in spec) - Add 5 missing tests: bool true+true, string-vs-object mount edge case, forwardPorts overlay-empty, init both-None integration, forwardPorts 3-config chain merge (FR-008) All 1784 tests pass. Zero clippy warnings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Fix two categories of spec-compliance bugs in
ConfigMerger::merge_two_configs()to match the upstream containers.dev implementors spec:privilegedandinit: previously usedOption::or()(last-wins); now uses OR semantics — result istrueif any source setstrue. Fixes Features requiring privileged access from silently losing that capability during merge.mountsandforwardPorts: previously replaced the base array with the overlay when non-empty; now unions both with deduplication — all unique entries from all sources are preserved. Fixes Features that add mounts/ports from silently dropping the user's own entries.Changes
union_json_arrays+union_port_arrayswith genericunion_arrays<T: Clone + PartialEq>merge_bool_orto a concise 2-arm matchEqforPortSpec(zero-cost type hygiene)run_services(Compose-specific, confirmed not in upstream merge spec)true+truetruth-table row, string-vs-object mount edge case,forwardPortsoverlay-empty scenario,initboth-None integration test,forwardPorts3-config chain merge (FR-008)Test plan
cargo fmt --all -- --check— cleancargo clippy --all-targets -- -D warnings— zero warningsmake test-nextest-fast— 1784 tests passed, 0 failurestest_merge_other_categories_unchangedguards all unmodified merge categories🤖 Generated with Claude Code