Files
NODEDC_DEVICE_CORE/docs/CONTINUOUS_DEPLOYMENT.md
T
2026-09-29 17:52:20 +03:00

121 lines
7.0 KiB
Markdown

# 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 are enabled and the persistent Synology
runner is installed. The deployment controller, normal recurring release
transition and live end-to-end deployment acceptance are still pending.
A green qualification is not a deployment receipt.
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 does not
download third-party Actions. It fetches the exact pushed SHA from our Gitea.
`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:
```sh
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.
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.
## Production activation contract still to implement
1. Verify the installed runner digest, applied journals, current manager/core
release descriptors and preserved runtime state on Synology.
2. Introduce a versioned **normal update** transition for 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. Under the deploy lock, check the current predecessor, obtain and validate a
fresh canonical plan, then apply that exact digest automatically. Record
commit, run, artifact, plan, receipt and backup. The controller's allowlist
is root-owned and cannot be expanded by a workflow artifact.
6. Before activation verify push success, failed tests, wrong SHA/repo/branch,
duplicate events, overlapping pushes, restart recovery and failed-health
rollback. Verify that no new host ports or production mounts are exposed.
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 after activation: push to `main`, then watch Gitea **Actions**.
Deployment status must separately show the installed commit and receipt. A red
check means the candidate did not qualify; it must not show a green deploy.
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](https://docs.gitea.com/usage/actions/overview/),
[runner configuration](https://docs.gitea.com/runner/configuration/).