Make Device Core primary network selection deterministic

This commit is contained in:
Codex
2026-09-30 11:03:58 +03:00
parent aba78dea98
commit 93b91a4b1e
7 changed files with 747 additions and 7 deletions
@@ -0,0 +1,138 @@
# Stable primary network for recurring Device Core releases
Status: source-qualified on 2026-09-30; root promotion, NAS metadata acceptance
and two subsequent automatic releases remain pending. Production remains r12.
DCPLATFORM-21 owns this exact registry addition; DCPLATFORM-37 tracks acceptance.
## Reproduced defect and evidence limits
Docker Compose 2.20.3 chooses `HostConfig.NetworkMode` from the first result of
`NetworksByPriority`. Its compose-go 1.18.1 dependency builds that result from a
Go map and sorts only by priority. Equal priorities have no deterministic tie
breaker. Reordering YAML keys is therefore insufficient.
Primary sources:
- [Compose 2.20.3 create.go](https://github.com/docker/compose/blob/v2.20.3/pkg/compose/create.go)
- [Compose dependency pin](https://github.com/docker/compose/blob/v2.20.3/go.mod)
- [compose-go network ordering](https://github.com/compose-spec/compose-go/blob/v1.18.1/types/types.go)
The official Darwin ARM64 Compose 2.20.3 binary was independently checksum
verified as `51cd66bf94923ec8668f1a78c8740abb6cfbe1189da5720a8051a97be527372b`.
Tests used local Docker Desktop Engine29.1.3 through API1.44, an existing pinned
Node image and isolated synthetic services. They used no NAS access, ports,
host mounts, credentials or production data. All test containers/networks were
removed by their exact project after each test; cleanup inventories are empty.
| Check | Result |
| --- | --- |
| Equal priorities, 32 fresh creates | Private primary28; secondary primary4 |
| Explicit private100 / secondary0, 32 fresh creates | Private primary32 |
| Exact candidate override, 16 Core+Manager recreations | All32 containers kept private primary and both attached networks |
| Original private-primary baseline to exact override, 8 Core+Manager recreations | All16 containers retained every canonical v2 configuration field digest |
Local reports and executable reproductions are retained under
`outputs/device-core-stability-20260930/compose-reproducer/` in the NODEDC
workspace: `result.json`, `rollout-result.json`, `fingerprint-result.json` and
their corresponding Python scripts. These are test evidence, never NAS payload.
The NAS foundation identifies the Compose2.20 family; its exact installed patch
version is reported by the new canonical preflight. The local Engine is newer
than NAS Docker24.0.2, so these checks do not replace NAS acceptance.
The old r9 receipt retained only an aggregate Manager configuration hash, and
rollback removed the rejected container. This reproduces a real defect capable
of causing that class of rejection; it does not prove which field differed in r9.
The existing r9 failure record remains unresolved historical evidence, not a
reason to replay r9 or waive configuration acceptance.
## Exact registered transition
Component: `device-core-network-priority`, type `app-overlay`, fixed identity
`device-core-network-priority-v1-20260930-001`. Both live and Compose roots are
`/volume1/docker/nodedc-device-plane`. The package permits exactly:
1. `docker-compose.device-release-network-priority.yml`
2. `deployment/device-core-network-priority-v1.json`
The existing base Compose files are unchanged. The new override specifies
private-network priority100 and secondary-network priority0 for Core and Manager.
It does not add/remove a network, change network properties, control the default
gateway or change endpoint settings. In particular, `priority` is not a
`gw_priority` substitute. The first installed primary must already be
`nodedc-device-plane-private` for both services.
This initial installation writes metadata only: no build, pull, restart,
recreation, database change, network creation or secret repair; services are
empty. No new ports, listeners or runtime dependencies are introduced.
Required predecessor is the exact accepted r12 source
`b2660df9e26afe977bfa62efd35a8397eac4898b`, release identity
`device-core-release-v1-r12-b2660df9e26afe977bfa62efd35a8397eac4898b`, archive SHA
`44c62036967c3ed26bd6c82f94e6f4103ccad06f45c383498210b43ad80c9d7c`.
Preflight proves journal/archive identity and every installed release file,
rejects unresolved rollback failures, requires both new paths absent, checks
health and existing secret/mount/network boundaries, then captures all five
Device Plane services and other persistent Compose services.
Canonical `docker compose config --format json` is read before and with the
candidate override. An in-memory comparison proves that ONLY the two primary
priority values change. Environment values and complete config never enter
logs or receipts. Only config hashes, version, file hashes and runtime evidence
are saved in `device-network-priority-before.json` with mode0600.
Apply verifies the copied files, effective configuration, original Compose/source,
health and exactly unchanged container identities/images/configuration for all
five services and other Compose projects. It emits `deploy-ok` only after those
checks. Failure removes/restores only the two new metadata paths, verifies the
original config and runtime again, and records the rollback result. An uncertain
rollback blocks further application releases even when marker files are absent.
## Future normal releases and rollback
Only the recurring `device-core-release` domain appends this override to its
effective Compose files. Activation requires both exact files plus a unique
successful canonical receipt and its checked immutable archive; copying a marker
does not activate it. Generic/Engine executors and historical Device Plane
transitions are unchanged.
Normal release acceptance now hashes the complete effective Compose set,
including the accepted override. Build policy, service selection and
`--no-deps --no-build --pull never` remain unchanged. Normal activation and
automatic rollback call the same domain executor, so both receive the override.
Rollback still restores exact prior image IDs without rebuilding.
The runtime fingerprint stays v2: only complete uniquely addressed mount objects
are order-normalized. `HostConfig.NetworkMode`, all its other fields, environment,
mount options and attached network names remain strict. There is no retry-until-
accepted loop and no acceptance of a switched primary network.
## Reproducible qualification and operator sequence
Source checks:
```sh
python3 -m unittest discover -s infra/deploy-runner -p 'test_device_core_*.py'
python3 -m unittest discover -s infra/device-core-deploy -p 'test_*.py'
```
Also run the Platform/Device Plane registry suites and the Device Core
repository's artifact/real HTTP-health tests against this candidate runner.
Seventeen focused network-priority tests cover exact payload, deterministic
packaging, configuration-diff boundaries, initial predecessor, secret redaction,
receipt/archive activation, actual release command construction, no-runtime
metadata application and rollback failure. Python3.8 syntax is required.
Promote the reviewed root runner through the separate atomic SHA-pinned gate,
then require its `verify-install`. Build with the committed canonical builder:
```sh
python3 infra/device-core-deploy/build_network_priority.py --output-dir /tmp/device-network-priority
```
Audit and stage the resulting immutable TGZ through SMB, inspect lifecycle,
then review a fresh NAS `plan`. Only the matching new plan authorizes the
already-requested `apply`. No raw Docker/diagnostic shell acceptance follows
`deploy-ok`: the runner owns that gate.
After metadata acceptance, update Device Core's Platform source pin to the
published reviewed commit. Submit two ordered normal main updates and verify
their CI qualification, automatic applied receipts, archives/backups, runtime
evidence and separate authenticated UI/public-health checks. Until then this
correction is source-qualified, not accepted in production. Do not advance
Device Core main before the fixed r12 metadata transition has been accepted.