Skip to content

fix: correct ConfigMerger merge rules for booleans and arrays#14

Merged
pofallon merged 1 commit into
mainfrom
013-fix-merge-rules
Feb 22, 2026
Merged

fix: correct ConfigMerger merge rules for booleans and arrays#14
pofallon merged 1 commit into
mainfrom
013-fix-merge-rules

Conversation

@pofallon
Copy link
Copy Markdown
Contributor

Summary

Fix two categories of spec-compliance bugs in ConfigMerger::merge_two_configs() to match the upstream containers.dev implementors spec:

  • Boolean OR semantics for privileged and init: previously used Option::or() (last-wins); now uses OR semantics — result is true if any source sets true. Fixes Features requiring privileged access from silently losing that capability during merge.
  • Array union for mounts and forwardPorts: 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

  • Replace duplicate union_json_arrays + union_port_arrays with generic union_arrays<T: Clone + PartialEq>
  • 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, confirmed not in upstream merge spec)
  • Add 5 missing tests: true+true truth-table row, string-vs-object mount edge case, forwardPorts overlay-empty scenario, init both-None integration test, forwardPorts 3-config chain merge (FR-008)

Test plan

  • cargo fmt --all -- --check — clean
  • cargo clippy --all-targets -- -D warnings — zero warnings
  • make test-nextest-fast — 1784 tests passed, 0 failures
  • All 5 new tests pass (verified individually)
  • Regression test test_merge_other_categories_unchanged guards all unmodified merge categories

🤖 Generated with Claude Code

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>
@pofallon pofallon merged commit 9c29f85 into main Feb 22, 2026
7 checks passed
@pofallon pofallon deleted the 013-fix-merge-rules branch February 22, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants