Handle Compose null endpoints in exact network-priority proof

This commit is contained in:
Codex
2026-09-30 11:33:56 +03:00
parent 93b91a4b1e
commit 50dc3b1a2c
8 changed files with 252 additions and 11 deletions
@@ -0,0 +1,25 @@
# Actual Compose 2.20.3 config output
`base.json` is an isolated synthetic two-service configuration, with no secrets,
mounts or published ports. `config.json` contains the full parsed JSON output of
the official Darwin ARM64 Compose v2.20.3 binary, SHA256
`51cd66bf94923ec8668f1a78c8740abb6cfbe1189da5720a8051a97be527372b`.
Reproduce without creating containers or contacting Docker Engine:
```sh
COMPOSE=/absolute/path/to/docker-compose-2.20.3
FIXTURE=infra/deploy-runner/fixtures/device-core-network-priority-compose220/base.json
"$COMPOSE" -p nodedc-ci-null-endpoint-repro -f "$FIXTURE" config --format json
"$COMPOSE" -p nodedc-ci-null-endpoint-repro -f "$FIXTURE" \
-f infra/device-core-deploy/docker-compose.network-priority.yml config --format json
```
The first output contains `null` for bare attachments. The second contains `{}`
for explicit zero-priority endpoints and `{"priority":100}` for private networks.
Do not replace nulls with hand-written fixture objects: that omission caused
runner014 to reject the initial NAS plan. The fixture regression reproduces
`Device Core network priority endpoint is invalid` on014 and passes on015.
It compares the full config, preserves raw config hashes and exercises negative
endpoint-type/property changes separately. This is synthetic source evidence;
it does not claim access to the NAS effective config or its exact Compose version.
@@ -0,0 +1 @@
{"services": {"device-control-core": {"image": "sha256:968df39aedcea65eeb078fb336ed7191baf48f972b4479711397108be0966920", "pull_policy": "never", "command": ["node", "-e", "setInterval(()=>{},1000)"], "read_only": true, "cap_drop": ["ALL"], "security_opt": ["no-new-privileges:true"], "stop_grace_period": "1s", "mem_limit": "96m", "pids_limit": 32, "networks": ["device-plane-private", "device-plane-egress"]}, "device-manager": {"image": "sha256:968df39aedcea65eeb078fb336ed7191baf48f972b4479711397108be0966920", "pull_policy": "never", "command": ["node", "-e", "setInterval(()=>{},1000)"], "read_only": true, "cap_drop": ["ALL"], "security_opt": ["no-new-privileges:true"], "stop_grace_period": "1s", "mem_limit": "96m", "pids_limit": 32, "networks": ["device-plane-private", "platform-edge"]}}, "networks": {"device-plane-private": {"internal": true}, "device-plane-egress": {}, "platform-edge": {}}}
@@ -0,0 +1,148 @@
{
"base": {
"name": "nodedc-ci-null-endpoint-repro",
"networks": {
"device-plane-egress": {
"name": "nodedc-ci-null-endpoint-repro_device-plane-egress",
"ipam": {},
"external": false
},
"device-plane-private": {
"name": "nodedc-ci-null-endpoint-repro_device-plane-private",
"ipam": {},
"external": false,
"internal": true
},
"platform-edge": {
"name": "nodedc-ci-null-endpoint-repro_platform-edge",
"ipam": {},
"external": false
}
},
"services": {
"device-control-core": {
"cap_drop": [
"ALL"
],
"command": [
"node",
"-e",
"setInterval(()=>{},1000)"
],
"entrypoint": null,
"image": "sha256:968df39aedcea65eeb078fb336ed7191baf48f972b4479711397108be0966920",
"mem_limit": "100663296",
"networks": {
"device-plane-egress": null,
"device-plane-private": null
},
"pids_limit": 32,
"pull_policy": "never",
"read_only": true,
"security_opt": [
"no-new-privileges:true"
],
"stop_grace_period": "1s"
},
"device-manager": {
"cap_drop": [
"ALL"
],
"command": [
"node",
"-e",
"setInterval(()=>{},1000)"
],
"entrypoint": null,
"image": "sha256:968df39aedcea65eeb078fb336ed7191baf48f972b4479711397108be0966920",
"mem_limit": "100663296",
"networks": {
"device-plane-private": null,
"platform-edge": null
},
"pids_limit": 32,
"pull_policy": "never",
"read_only": true,
"security_opt": [
"no-new-privileges:true"
],
"stop_grace_period": "1s"
}
}
},
"candidate": {
"name": "nodedc-ci-null-endpoint-repro",
"networks": {
"device-plane-egress": {
"name": "nodedc-ci-null-endpoint-repro_device-plane-egress",
"ipam": {},
"external": false
},
"device-plane-private": {
"name": "nodedc-ci-null-endpoint-repro_device-plane-private",
"ipam": {},
"external": false,
"internal": true
},
"platform-edge": {
"name": "nodedc-ci-null-endpoint-repro_platform-edge",
"ipam": {},
"external": false
}
},
"services": {
"device-control-core": {
"cap_drop": [
"ALL"
],
"command": [
"node",
"-e",
"setInterval(()=>{},1000)"
],
"entrypoint": null,
"image": "sha256:968df39aedcea65eeb078fb336ed7191baf48f972b4479711397108be0966920",
"mem_limit": "100663296",
"networks": {
"device-plane-egress": {},
"device-plane-private": {
"priority": 100
}
},
"pids_limit": 32,
"pull_policy": "never",
"read_only": true,
"security_opt": [
"no-new-privileges:true"
],
"stop_grace_period": "1s"
},
"device-manager": {
"cap_drop": [
"ALL"
],
"command": [
"node",
"-e",
"setInterval(()=>{},1000)"
],
"entrypoint": null,
"image": "sha256:968df39aedcea65eeb078fb336ed7191baf48f972b4479711397108be0966920",
"mem_limit": "100663296",
"networks": {
"device-plane-private": {
"priority": 100
},
"platform-edge": {}
},
"pids_limit": 32,
"pull_policy": "never",
"read_only": true,
"security_opt": [
"no-new-privileges:true"
],
"stop_grace_period": "1s"
}
}
}
}
+8 -3
View File
@@ -32346,7 +32346,7 @@ def rollback_gitea_ci(root, backup_dir, entries, current_stamp, runtime_started)
# Recurring application releases: a separate domain from immutable historical
# Device Plane transitions. No Compose, database, secret or controller payload.
DEVICE_PRIORITY_ID = "device-core-network-priority-v1-20260930-001"
DEVICE_PRIORITY_ID = "device-core-network-priority-v1-20260930-002"
DEVICE_PRIORITY_ENTRY = "deployment/device-core-network-priority-v1.json"
DEVICE_PRIORITY_COMPOSE = "docker-compose.device-release-network-priority.yml"
DEVICE_PRIORITY_ENTRIES = (DEVICE_PRIORITY_COMPOSE, DEVICE_PRIORITY_ENTRY)
@@ -32458,14 +32458,19 @@ def device_priority_config_proof(base, candidate):
expected = json.loads(json.dumps(base))
actual = json.loads(json.dumps(candidate))
for service, networks in DEVICE_PRIORITY_NETWORKS.items():
for config in (expected, actual):
for side, config in (("base", expected), ("candidate", actual)):
edges = config.get("services", {}).get(service, {}).get("networks")
if not isinstance(edges, dict) or set(edges) != set(networks):
die("Device Core network priority changes attached networks")
for name in networks:
edge = edges[name]
# Compose 2.20 serializes a bare attachment as null; an explicit
# empty endpoint (including zero priority) becomes {}. Only
# these four expected endpoints share that empty representation.
if edge is None:
edge = edges[name] = {}
if not isinstance(edge, dict) or type(edge.get("priority", 0)) is not int:
die("Device Core network priority endpoint is invalid")
die("Device Core network priority endpoint is invalid: " + side + "/" + service + "/" + name)
# Compose 2.20 omits the zero default in config JSON.
if edge.get("priority") == 0:
edge.pop("priority")
@@ -74,8 +74,9 @@ class PriorityTests(unittest.TestCase):
R.component_services('device-core-network-priority', entries)
def test_payload_rejects_identity_descriptor_and_yaml_changes(self):
with self.assertRaises(R.DeployError):
R.validate_device_priority_payload(self.payload, self.entries, 'arbitrary-id')
for identity in ('arbitrary-id', 'device-core-network-priority-v1-20260930-001'):
with self.subTest(identity=identity), self.assertRaises(R.DeployError):
R.validate_device_priority_payload(self.payload, self.entries, identity)
descriptor = self.payload / R.DEVICE_PRIORITY_ENTRY
original = descriptor.read_bytes()
changed = json.loads(original)
@@ -100,6 +101,44 @@ class PriorityTests(unittest.TestCase):
candidate['services']['device-manager']['networks']['platform-edge']['priority'] = 0
R.device_priority_config_proof(base, candidate)
def test_real_compose220_config_with_null_endpoints_passes_without_changing_raw_digests(self):
fixture = Path(__file__).parent / 'fixtures/device-core-network-priority-compose220/config.json'
value = json.loads(fixture.read_text())
before = copy.deepcopy(value)
self.assertIsNone(value['base']['services']['device-manager']['networks']['platform-edge'])
proof = R.device_priority_config_proof(value['base'], value['candidate'])
self.assertEqual(value, before)
self.assertEqual(proof['baseConfigSha256'], R.device_release_drift_digest(before['base']))
self.assertEqual(proof['candidateConfigSha256'], R.device_release_drift_digest(before['candidate']))
def test_null_endpoint_support_does_not_accept_other_types_or_missing_primary_priority(self):
for value in (False, True, 0, '', [], 'null', {'priority': None}, {'priority': 0.0}, {'priority': False}):
for side in ('base', 'candidate'):
base, candidate = effective(), prioritized()
config = base if side == 'base' else candidate
config['services']['device-manager']['networks']['platform-edge'] = value
with self.subTest(side=side, endpoint=value), self.assertRaises(R.DeployError):
R.device_priority_config_proof(base, candidate)
candidate = prioritized()
candidate['services']['device-manager']['networks']['device-plane-private'] = None
with self.assertRaises(R.DeployError):
R.device_priority_config_proof(effective(), candidate)
def test_null_equivalence_is_local_and_preserves_endpoint_options(self):
base, candidate = effective(), prioritized()
base['services']['device-manager']['networks']['platform-edge'] = None
candidate['services']['device-manager']['networks']['platform-edge'] = {'aliases': ['foreign']}
with self.assertRaises(R.DeployError):
R.device_priority_config_proof(base, candidate)
base, candidate = effective(), prioritized()
candidate['services']['device-postgres']['networks']['device-plane-private'] = None
with self.assertRaises(R.DeployError):
R.device_priority_config_proof(base, candidate)
base, candidate = effective(), prioritized()
for config in (base, candidate):
config['services']['device-manager']['networks']['platform-edge'] = {'aliases': ['unchanged']}
R.device_priority_config_proof(base, candidate)
def test_network_and_nonnetwork_changes_remain_rejected(self):
mutations = (
lambda c: c['services']['device-manager'].update(ports=['8080:80']),