Files
NODEDC_DEVICE_CORE/docs/CONTINUOUS_DEPLOYMENT.md
T
DCCONSTRUCTIONS e912e6ffaf
Device Core qualification / qualify (push) Successful in 8m54s
Document ordered release delivery and restart recovery
2026-09-29 21:40:51 +03:00

12 KiB

Device Core: deploy from main

Decision, 2026-09-29: a push to SILVER/NODEDC_DEVICE_CORE:main must trigger qualification and automatic deployment after the gates pass. No separate DEPLOY branch or approval for each release. This decision is specific to Device Core; other repositories keep their existing policy until onboarded.

Current implementation status

The source qualification workflow is implemented in .gitea/workflows/ci.yml. It does not deploy. Gitea Actions and the persistent Synology build runner are installed. The normal device-core-release transition accepted r7, and the outbound deployment controller bootstrap was accepted on 2026-09-29 at18:35:52Z (canonical ledger386). The first automatic end-to-end release is under acceptance. A green qualification is not a deployment receipt.

The installed root runner SHA is c1301d1072f3d5d39ba422a09847a05a5aad8a753c816d7fb6916d1f1cadd9c6, from Platform f7416bc59a19a9ac53c4f4591eaf50a7f4a41641. Controller bootstrap device-core-autodeploy-v1-20260929-001 has artifact SHA fe9298baa5f41a35c2705ee9946b730ff2de7d5b5c9b2b8eb1b4cca0bc8ed12b. Its first eligible run is8; historical failed and already installed runs are excluded. The accepted baseline is r7 / edf69068ec64e3d105d5324d39b8eaeface21215.

Pushes can originate from any computer. Gitea, the build runner and the controller on Synology perform the complete pipeline; an operator Mac does not participate. Native nodedc-device-autodeploy.timer invokes the root-owned canonical worker 30seconds after its previous cycle completes, with no additional inbound port. The separate read token, SQLite queue and private status belong to root under /var/lib/nodedc-device-autodeploy, outside build jobs and application artifacts.

On 2026-09-29, canonical bootstrap gitea-ci-bootstrap-v4-20260929-005 completed with deploy-ok, no published ports and production deploy disabled. The repo-scoped runner synology-device-core-build (id 1) is online. The first real workflow run started successfully but failed while fetching the pinned Launcher commit: it existed locally and had never been pushed. The dependency was published unchanged as ci/device-core-integration-20260929 in the Launcher repository. Its main branch and running service were not changed. The full commit in sources.lock.json remains the authority, not the branch tip.

Host and network

The first runner lives on Synology. No additional listening ports, DSM reverse proxy route, firewall opening or webhook receiver are required. It polls the existing Gitea HTTPS endpoint. Disable the runner cache server and metrics listener initially. Start with one job at a time and an explicit CPU/RAM limit, chosen after reading the live host baseline.

Use container jobs, no host-execution labels, no privileged jobs, no arbitrary host volumes and no Docker socket inside jobs. The runner daemon's own Docker access is privileged infrastructure and belongs to Platform. Repository jobs must not receive production paths, databases, runtime secrets or deploy keys.

Build qualification and production installation are separate responsibilities. A Platform-owned controller polls completed Gitea runs and drives the canonical root-owned nodedc-deploy on the same NAS. It does not expose an HTTP server. The application workflow cannot supply shell commands, target paths or service names to this controller. Adding another repo requires an explicit registry entry, branch policy, release contract and acceptance tests.

Reproduce source qualification

Runner label: nodedc-node22-build; Node 22.21.0, npm 10.9.4, Python >=3.9 and Git must be available in the reviewed build image. The workflow fetches the exact pushed SHA from our Gitea. After qualification it uses the upstream Gitea-compatible ChristopherHX/gitea-upload-artifact v4 implementation pinned to commit 81f940d004763f986ba3582c007fd842dd5cb0d7 to retain the bundle in our Gitea. The upload uses the job's short-lived artifact credential, not a production credential. The workflow's repository token has read-only content access. infra/ci/sources.lock.json pins Design Guideline, Platform and Launcher to full commits; following their current main branches would make old releases unreproducible. Launcher sources are required by the existing Hub trust/session artifact tests; the Launcher application is not installed or deployed by this workflow. Every pinned commit must be published to its declared remote before a Device Core revision depending on it is pushed. A local checkout passing tests does not prove that a clean Linux worker can fetch its dependencies. Dependencies are fetched into fresh sibling directories. Existing directories are rejected, never reset or deleted by the qualification script.

From a fresh exact Device Core checkout in a disposable parent directory:

python3 infra/ci/qualify.py fetch-dependencies --commit <full-device-core-sha>
python3 infra/ci/qualify.py check --commit <full-device-core-sha> --report ../qualification.json

The checks reject dirty or wrong checkouts and mismatched toolchain versions. They install lockfile dependencies, build the two required Design Guideline packages, run Device Core unit and CI tests, compile the UI and run the existing artifact contract suite against the pinned Platform runner source. The report is created only after all checks pass and records all source SHAs, lockfile hashes and the UI output hash. It contains deployed: false deliberately. The qualification report is evidence, not an authorization token or substitute for independently checking Gitea job identity and the deploy artifact.

infra/ci/package_release.py runs only after all qualification steps pass. It checks the source and build hashes again, then emits a deterministic .tgz and release.json receipt. The archive declares device-core-release.v1 with the exact source SHA, run id/number and file digests. It cannot choose Compose files, host roots, install commands or database operations. This artifact type is accepted only by the registered Platform recurring-release domain. Run 3 (commit 415d5e73d7ca0cc283deb9b79a9f5f99fec54ed7) passed all qualification steps on Synology. Its legacy v3 upload succeeded but is not returned by the Gitea REST artifact API. Therefore the publication step now uses the Gitea-compatible v4 uploader; successful REST retrieval and digest verification are separate acceptance gates.

Bundles remain in Gitea for 30 days; installed releases will additionally be retained by the canonical NAS journal/archive. Expiry is not a successful deployment and must never be silently ignored by the controller.

Linux qualification also exercises the standalone Edge/VPS archive readers. These materialize validated regular files explicitly, without extractall, so they work with the pinned image's Python while retaining path/link/mode checks. No Edge/VPS runtime is changed by running these tests.

Local focused tests: python3 -m unittest discover -s infra/ci -p 'test_*.py'. The full artifact suite belongs on the bounded Linux build worker; there is no requirement to start Docker or run load tests on an operator Mac.

Installed production contract

  1. The root installer verifies its installed identity, applied journals, current manager/core release descriptors and preserved runtime state on Synology.
  2. The versioned normal update transition handles repeat releases. Historical recovery descriptors and fixed predecessor guards remain intact. Reusing the v13 manager or v4 core recovery identity is not a CI strategy.
  3. Persist each admitted main revision, run identity and artifact digest in a durable queue. Serialize production transitions. Handle duplicate events idempotently; never install an older revision after a newer one. A missed poll must not lose a push. Do not depend on Gitea job completion order.
  4. Link exact source commits to immutable data-only deploy artifacts. Retain existing manifest.env, files.txt, payload/... validation and fixed component/service selection. Exclude secrets, DB state and executable hooks.
  5. Obtain a fresh canonical plan, reserve the verified artifact in the durable queue, then apply with predecessor and payload checks under the deploy lock. Record commit, run, artifact, plan, receipt and backup. The controller's allowlist is root-owned and cannot be expanded by a workflow artifact.
  6. Source tests cover wrong SHA/repo/branch, failed/pending checks, duplicate events, pagination changes, overlapping runs, restart reconciliation and canonical rollback. Bootstrap acceptance proves timer identity, private token import and unchanged existing applications. Live automatic release acceptance is recorded separately in Ops; unit tests alone do not prove NAS delivery.

Build/test failures leave production untouched. Runtime installation failures follow the canonical runner's rollback policy; an ambiguous or failed rollback stops subsequent applies for diagnosis. Never call an unconfirmed release deployed. User/device data and tokens survive application updates.

Operator view

Normal use: push to main, then watch Gitea Actions for qualification. /volume1/docker/nodedc-device-autodeploy/runtime-status.json is a sanitized controller observation available through the existing SMB share. Canonical nodedc-deploy/state/applied.jsonl, its matching archive and backup establish the installed release. A waiting status does not replace the latest applied receipt. A red qualification means the candidate did not qualify; it is not a deployment. For emergency pause, stop admitting new deployments without cancelling an in-progress apply. Recovery/rollback remains a recorded canonical transition.

Track shared infrastructure in Ops DCPLATFORM-37, root deploy contracts in DCPLATFORM-21, and B2 server/contour integration in MISSIONCOR-86. This deployment mechanism does not mix Device Core and Mission Core inventories.

References: Gitea Actions, runner configuration.

Release ordering and interruptions

Each successful main push keeps its own source SHA and CI run identity. A pending older run holds the delivery queue; a later successful run cannot overtake it. After a clean CI failure, the next qualified revision may proceed. Multiple pushes are therefore admitted in order, including pushes from different machines. The build runner and production installer each execute one job at a time.

A network outage before installation retains the queued candidate. Before apply, the controller records its reservation in SQLite. After restart it reconciles that reservation with the canonical journal, archive checksum and backup. A confirmed applied release is never installed again. A confirmed rollback is terminal for that artifact; a new corrected commit gets a new release identity. An uncertain outcome or failed rollback blocks later installs for diagnosis.

The installed revision must be an ancestor of the candidate, and the candidate must remain an ancestor of current main. Divergent/force-pushed history does not silently replace production. CI artifacts expire after30days; an expired artifact raises an explicit source error rather than being credited as delivered. Keep qualified artifacts available until delivery has a canonical receipt.

The sanitized status file can return to waiting after delivery. Read the latest matching device-core-release row in the canonical applied journal to identify the installed source; do not infer deployment solely from a green CI run or from a single polling status. Infrastructure changes, schema migrations and another repository's onboarding still require their own registered deployment contract.