fix(manifest): presence-aware runtime merge for nested_containers
test / integration-docker (pull_request) Successful in 17s
test / unit (pull_request) Successful in 44s
lint / lint (push) Successful in 57s
test / integration-firecracker (pull_request) Successful in 3m31s
test / coverage (pull_request) Successful in 19s
test / publish-infra (pull_request) Has been skipped
tracker-policy-pr / check-pr (pull_request) Successful in 13s
test / integration-docker (pull_request) Successful in 17s
test / unit (pull_request) Successful in 44s
lint / lint (push) Successful in 57s
test / integration-firecracker (pull_request) Successful in 3m31s
test / coverage (pull_request) Successful in 19s
test / publish-infra (pull_request) Has been skipped
tracker-policy-pr / check-pr (pull_request) Successful in 13s
The runtime merge (merge_bottles_runtime / _fold_two_bottles) was using OR semantics for nested_containers, which meant `nested_containers: false` in a later bottle could never override an earlier `true`. Fix: add `nested_containers_explicit: bool` to ManifestBottle, set to True only when the key is present in the source dict. The runtime merge functions now use the override's value only when it was explicitly supplied; otherwise the base's value is preserved. This matches the documented last-wins / presence-aware semantics used by supervise and agent_provider, and aligns with _merge_bottles (the file-based extends path) which already did presence checks via `"nested_containers" in child_raw`. Tests: rename existing test to clarify the preserved-when-omitted case, add explicit-false-overrides-true and explicit-true-overrides-false cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,16 +56,27 @@ class TestMergeBottlesRuntime(unittest.TestCase):
|
||||
result = merge_bottles_runtime([base, override])
|
||||
self.assertFalse(result.supervise)
|
||||
|
||||
def test_nested_containers_survives_a_later_bottle(self):
|
||||
"""OR, not replace: a resolved bottle that never mentioned the key is
|
||||
indistinguishable from one that set it false, so `--bottle with-docker
|
||||
--bottle claude-dev` must not silently drop the capability."""
|
||||
def test_nested_containers_survives_a_later_bottle_that_omits_the_key(self):
|
||||
"""A bottle that never mentions nested_containers must not silently
|
||||
drop the capability: `--bottle with-docker --bottle claude-dev`."""
|
||||
enabled = _bottle(nested_containers=True)
|
||||
quiet = _bottle(env={"X": "1"})
|
||||
self.assertTrue(merge_bottles_runtime([enabled, quiet]).nested_containers)
|
||||
self.assertTrue(merge_bottles_runtime([quiet, enabled]).nested_containers)
|
||||
self.assertFalse(merge_bottles_runtime([quiet, quiet]).nested_containers)
|
||||
|
||||
def test_nested_containers_explicit_false_overrides_earlier_true(self):
|
||||
"""An explicit nested_containers: false in a later bottle must win
|
||||
over an earlier true (last-wins, presence-aware)."""
|
||||
enabled = _bottle(nested_containers=True)
|
||||
disabled = _bottle(nested_containers=False)
|
||||
self.assertFalse(merge_bottles_runtime([enabled, disabled]).nested_containers)
|
||||
|
||||
def test_nested_containers_explicit_true_overrides_earlier_false(self):
|
||||
enabled = _bottle(nested_containers=True)
|
||||
disabled = _bottle(nested_containers=False)
|
||||
self.assertTrue(merge_bottles_runtime([disabled, enabled]).nested_containers)
|
||||
|
||||
def test_three_bottles_merged_left_to_right(self):
|
||||
b1 = _bottle(env={"A": "1", "B": "1", "C": "1"})
|
||||
b2 = _bottle(env={"B": "2", "C": "2"})
|
||||
|
||||
Reference in New Issue
Block a user