Files
NODEDC_PLATFORM/infra/device-core-deploy/README.md

15 KiB

Device Core recurring deployment

Status: 2026-09-30. Push-to-main qualification and automatic installation work on Synology. The outbound controller bootstrap is recorded in ledger386. Runs11 and12 were accepted automatically in sequence (ledgers388/389), followed by runs13 and14 (ledgers391/392). Current accepted application source is 6ca6738bab22d0fdef714b90c68959363106ee5b. A real npm ECONNRESET during run12 recovered through the bounded CI install retry. Earlier run9 failed Manager runtime configuration acceptance and rolled back; its exact cause remains unresolved. The installed runner retains per-field diagnostics without weakening acceptance. See the evidence report. An independently reproduced equal-priority Compose network-selection defect now has a tested correction. Runner014's first metadata plan exposed a null-endpoint parser case. Corrected runner015 and metadata002 are now accepted; two subsequent automatic application releases, r13 and r14, passed canonical installation and separate authenticated UI/public-health acceptance. See the exact network-priority transition. DCPLATFORM-21 owns the deployment contract; DCPLATFORM-37 tracks acceptance.

Release domain

The root-owned infra/deploy-runner/nodedc-deploy adds device-core-release. Device Core's infra/ci/package_release.py creates the only accepted nine-entry, data-only package. It binds repository 38, main, full source commit, CI run ID and number, completed qualification, every source file, and the served UI digest. The served digest uses lexically sorted relative POSIX paths, with 8-byte big-endian path/data lengths; it excludes source maps independently of the full build digest.

The first deployment proves the exact applied sequence: Edge channel v4 (023), Control Core v4 (047), Manager v13 (051). Later deployments prove the most recent normal-release archive, journal and complete installed file map. Stale runs, repeated source commits, source drift and unresolved rollback failures fail closed. Historical transition rules are unchanged.

Only device-control-core and device-manager are built and recreated, using the existing effective Compose project/files and --no-deps --no-build --pull never. The database, Gateway, backhaul, volumes, existing ports, mounts, identities and all other persistent Compose services remain unchanged. Migration files and build recipes must match the installed foundation; changes need a separately reviewed migration/topology transition. Build jobs never receive installation credentials.

Apply backs up the exact replaced source and old image IDs before writing. Failed builds restore source and tags without restarting services. Failed activation restores both old images without rebuilding, recreates only the selected services, then verifies health, source, configuration and preservation before recording a successful rollback. A failed rollback blocks further releases for reconciliation. Successful apply requires new selected container generations, correct images, healthy dependencies, unchanged topology and source hashes before deploy-ok.

Durable queue foundation

deployment_queue.py supplies transactional SQLite ordering and restart recovery. It has no network or runtime authority. It rejects mismatched run identity, waits for earlier pending runs, records artifact reservation before installation, skips duplicate/already superseded sources, and requires a canonical journal/archive receipt after a crash. It does not discover API pages or prove Git ancestry.

Outbound controller v1

gitea_source.py verifies complete stable API pagination, exact repository/run/job identity and successful qualification steps. Commit-parent traversal proves installed → candidate → current main. Downloads accept only the API origin and Gitea's exact signed /zip/raw?sig&expires redirect for the same artifact ID; the persistent Authorization token is removed from that redirected request. ZIP entries, uncompressed bounds and release receipt are checked before the canonical TGZ loader independently validates the release.

controller.py refreshes discovery, enforces queue order, stages and plans through an injected canonical installer, rechecks qualification/ancestry, durably reserves, then invokes apply. It reconciles canonical journal + archive digest + backup after success, failure or restart. Missing/contradictory evidence stops further installs; network errors before reservation preserve the ready queue. Failed CI is skipped, pending CI retains its place, and completed releases are never installed twice.

embed_library.py deterministically places these pure modules inside the reviewed standalone root runner as ordinary Python in a private lexical scope. There is no runtime import from SMB, dynamic exec or script payload. Tests compare embedded bytes against source modules.

The device-core-autodeploy bootstrap contains only deployment/device-core-autodeploy-v1.json. Its fixed identity is device-core-autodeploy-v1-20260929-001. The root installer creates exactly two previously absent native units under /usr/local/lib/systemd/system: nodedc-device-autodeploy.service and .timer. The timer starts 120s after boot (or immediately when installed after that point), then 30s after each worker completion. There is one worker, protected by flock, plus the existing canonical deployment lock. It opens no listener and requires no Mac to remain online. Commits from any computer qualify through the same Gitea main branch.

Native systemd, trusted Python/systemctl paths and absence of unit collisions are preconditions, checked in plan before mutation. No unsupported CFS/Pids controls or fallback schedulers are assumed. The service invokes only the internal fixed /usr/bin/python3 /usr/local/sbin/nodedc-deploy --device-core-autodeploy-tick entry. Its worker requires a successful canonical bootstrap receipt/archive before any release installation, preventing an early timer firing from bypassing acceptance.

The dedicated read:repository token is imported from a bounded operator handoff under nodedc-deploy/runtime/device-core-autodeploy/enrollment.pending.json into /var/lib/nodedc-device-autodeploy/gitea-read-token (root:root 0600, directory0700). It is absent from artifacts/build jobs/logs. The operator staging file is removed only after private-copy verification. SQLite and private status live in the same private directory. A sanitized runtime-status.json under the bootstrap descriptor root gives SMB-readable operational status; it never authorizes installation. Gitea's scope applies to repositories visible to that account; the controller's API route allowlist is fixed to repository38.

Bootstrap preserves all existing containers and the accepted r7 application tree. It verifies unit bytes, effective FragmentPath/no drop-ins, enabled/active timer, private credential metadata, API qualification and health. Rollback removes only its new units and descriptor; it retains private credentials/queue and all apps. The activation floor is run8, so historical r5/r6 cannot enter automatic delivery.

The frozen generic run_compose function is byte-identical to the previous Engine canon. Device Core uses its own exact Core+Manager Compose entry with unchanged --pull never --no-build --no-deps, including rollback.

Activation and acceptance

  • Runner012 was promoted and verified as c1301d1072f3d5d39ba422a09847a05a5aad8a753c816d7fb6916d1f1cadd9c6.
  • Runner013 subsequently passed operator verify-install as 3eefc75591bb08339d79c6a484912d7d6a8881fe8729e966b6f0bf32da21da80.
  • Current runner015 passed operator verify-install as 7a213b7d086225ac9677f52e1bde99dd4b57d77da7c548aadb11793336911cf2. Metadata002 was accepted at2026-09-30T09:12:12Z, canonical journal390. See the network-priority report for its immutable artifact and backup identity.
  • The data-only bootstrap built by build_autodeploy.py passed fresh plan/apply; artifact SHA is fe9298baa5f41a35c2705ee9946b730ff2de7d5b5c9b2b8eb1b4cca0bc8ed12b.
  • NAS imported its root-private credential and removed enrollment staging. The temporary Mac credential was removed after acceptance. Neither a Mac nor SMB needs to remain connected for recurring delivery.
  • Ordered automatic releases r11/r12 and then r13/r14 were verified against their CI receipts, archive digests, unique canonical journal rows and backups. Failed-check and crash/reconciliation tests are source qualification, not a claim that the NAS was deliberately crashed during production acceptance.

No helper from this directory is executed on NAS or installed by an application release. User-facing NAS deployment commands remain canonical plan/apply.

Validation

Run9 was rejected for a Manager runtime configuration difference and rolled back successfully to run8. Its failed archive must not be replayed. The initial snapshots retained only an aggregate configuration hash, so the specific field was not available after rollback removed the failed container.

Diagnostics introduced in runner013 add field hashes to new before snapshots. Each observation is bound to the checked container/image/configuration identity. On a mismatch, the canonical failed receipt retains changed field names and their hashes before the failed generation is removed. Raw environment values, inspect payloads and external exception text are not included. The v2 comparison, network/mount semantics, selected services and rollback checks are unchanged. Old snapshots still use their original aggregate hash. This instrumentation is not by itself a fix for an as-yet-unidentified configuration difference.

See live acceptance and the run9 incident.

python3 -m unittest discover -s infra/device-core-deploy -p 'test_*.py'
python3 -m unittest discover -s infra/deploy-runner -p test_device_core_release.py
python3 -m unittest discover -s infra/deploy-runner -p test_device_core_runtime_evidence.py
python3 -m unittest discover -s infra/gitea-ci -p 'test_*.py'

The Device Core repository's full infra/deploy-runner suite must also pass against the changed canonical runner. Its historical skipped tests remain reported as skipped, not as live acceptance.

Initial r5 health-contract incident

The first normal release (run 5, source 67b2ae586399eb1eb7d3a6c074a292e0dbb7b406) failed acceptance and rollback acceptance because the new domain selected the old generic disabled-foundation health expectations. The current preserved foundation reports discovery and management enabled and typed-service-ping-v1. The release now uses an explicit contract before build, after activation and during rollback. Legacy transition contracts remain unchanged. Device Core's test_device_release_health_contract.py runs the actual Core and Manager HTTP handlers against the pinned installer; it fails on the original installer and passes on this correction, including negative dependency/auth/capability cases.

build_reconciliation.py packages one fixed data descriptor for device-core-release-reconciliation. Its plan and apply prove the exact failed journal/archive, six backup digests, restored sources, old image IDs, runtime configuration, Compose and preserved services. No build, restart, secret repair, port or database action exists in this domain. Apply writes only a marker and a separate canonical receipt; failure removes only that marker. It never rewrites the original failed journal. Later releases require marker + applied archive + receipt + original incident evidence. Other rollback failures remain blocked.

The r5 archive must never be replayed. Reconciliation does not install a release or activate automatic deployment. Only after its live acceptance may a NEW successful CI run become the next normal-release candidate.

Read-only diagnosis after rejected reconciliation

Reconciliation001 stopped in plan on the saved Core runtime configuration hash. No apply ran. The initial rejection alone did not prove harmless ordering or actual drift. The original backup stores only an aggregate hash, and the legacy snapshot retains HostConfig.Binds/Mounts order. The diagnostic kept acceptance unchanged.

build_drift_audit.py creates a separate device-core-release-drift-audit bundle. Its only entry is deployment/device-core-release-r5-drift-audit-v1.json. Only canonical plan can execute this diagnostic; apply refuses before any application/backup action. It proves original incident evidence and reports all five service image/hash comparisons over three observations, source/Compose, health, secret/mount/network boundaries and unrelated Compose preservation. No raw inspect, environment values or secrets are printed.

The diagnostic searches at most 20,000 exact legacy hash candidates, changing only the order of observed HostConfig.Binds/Mounts (up to eight each) and NetworkMode among attached network names. It preserves every other value. A matching old NetworkMode is reported as a difference, never accepted as harmless. Exhaustion, changing samples or no match remains unresolved. No diagnostic result creates a reconciliation marker or bypasses the original acceptance barriers. A subsequent recovery decision requires the actual NAS report.

Proven mount-order recovery and runtime fingerprint v2

The NAS audit on 2026-09-29 found an exact old hash preimage for Core and Manager by reordering only HostConfig.Mounts (7 and 3 entries). All three observations were stable; image IDs, source, topology, health, runtime boundaries and preserved services matched. The audit output SHA is cf687c8bf550fa8c7d1125a3297e04c3d0d81a704b1d6ad17dbddc66470a1189. This evidence does not itself create a canonical recovery receipt.

The recurring release domain now records runtimeFingerprintVersion: 2 in new before snapshots. Version 2 sorts complete HostConfig.Mounts objects, requiring unique absolute normalized Target paths, and preserves every value and option. Binds and NetworkMode are unchanged. Old snapshots without a version retain the legacy comparison; generic Compose and historical transition guards are unchanged. Docker 24.0.2 registers mount points by unique destination, independently of this input list order: https://github.com/moby/moby/blob/v24.0.2/daemon/volumes.go.

Build the NEW data-only recovery package with:

python3 infra/device-core-deploy/build_reconciliation.py --version 2 --output-dir /tmp/recovery-v2

The fixed identity is device-core-release-r5-reconciliation-v2-20260929-002, with only deployment/device-core-release-r5-reconciliation-v2.json. Version 1 remains strict and byte-identical. V2 proves the old digest with at most 5,041 candidates per service by permuting only existing HostConfig.Mounts (at most seven); it never uses the broader diagnostic probe. Three identical observations, old images and exact preserved service rows are required. After proving equivalence it derives a v2 baseline and rechecks every existing acceptance guard. Plan, locked preflight and post-copy acceptance all repeat this proof. Conflicting v1/v2 markers fail.

Apply only writes the marker, backup and canonical journal. Original incident files and the failed receipt remain unchanged. Marker plus unique applied receipt, archive digest/identity and original evidence are required to acknowledge r5. A failure removes only the marker. This package performs no application deployment and does not activate automatic deployment. Live plan/apply are still required; the old r5 artifact and the rejected v1 reconciliation must not be replayed.