Files
NODEDC_DEVICE_CORE/docs/CONTINUOUS_DEPLOYMENT.md
DCCONSTRUCTIONS 6ca6738bab
Device Core qualification / qualify (push) Successful in 5m55s
Record accepted automatic r13 with network priority evidence
2026-09-30 12:28:29 +03:00

243 lines
15 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
As of 2026-09-30, the first automatic application release using the accepted
network-priority override is r13/source
`33cd08c7ab4b1ee87e8c943fca4a30f38c782aae`, accepted at09:25:33Z in canonical
ledger391 with archive SHA
`5fa322be2619ddfe2ad91f9e7d2c9d2cd1b3f8d91d34b7a2e5650eb9b617fc98`.
Backup:
`device-core-release-device-core-release-v1-r13-33cd08c7ab4b1ee87e8c943fca4a30f38c782aae-20260930-122207`.
Its predecessor was accepted r12; earlier r11/r12 remain canonical ledgers388/389.
Gitea qualification alone is not a deployment receipt.
The installed root runner015 has SHA
`7a213b7d086225ac9677f52e1bde99dd4b57d77da7c548aadb11793336911cf2`,
from published Platform `50dc3b1a2cb1191484f5b90de2d2702b14127425`.
The operator confirmed its exact verify-install receipt and Python3.8.15.
Source qualification now pins this same Platform commit. The branch containing
that commit is `fix/device-core-network-priority-20260930`; the full SHA, not
its moving branch tip, remains the source identity.
Canonical metadata transition `device-core-network-priority-v1-20260930-002`
was accepted at09:12:12Z on30September (ledger390), archive SHA
`5ee23f440ef4a5ef7593c5c35b27b17d93d556453df69e152caee1ddd41e8c7b`.
Backup:
`device-core-network-priority-device-core-network-priority-v1-20260930-002-20260930-121204`.
Its plan identified the actual NAS Compose as `2.20.1-6047-g6817716`.
The installer proved unchanged running services, databases, volumes, ports and
secrets; it wrote only the exact descriptor and recurring-release Compose override.
The installed private primary network is now explicitly preferred for both Core
and Manager on future normal updates and their automatic rollback. NetworkMode,
all other configuration fields and runtime fingerprint v2 remain strict.
Run13 passed265 application tests,25 CI tests and170 artifact cases
(17 historical skips), then installed without manual NAS commands. Its before
snapshot names r12 and hashes the accepted override; canonical apply retained
strict runtime fingerprint v2, including both private primary networks.
The independent CI receipt, applied archive and unique journal record agree;
backup exists, lifecycle is terminal_success, with no failed record/warnings.
After installation, public GET health returned HTTP200 and all three health
flags true. The authenticated UI retained DC SUDO, DCTOUCH and
Robot2B — Moscow Trike Delivery. No user/device data was changed in this check.
This documentation update triggers the second ordered application release.
Its future result must be recorded in Ops and the Platform acceptance report;
this commit does not claim its own unobserved deployment succeeded.
Earlier r9 passed CI but failed Manager runtime-configuration acceptance and
successfully rolled back to r8. Its exact differing field was not retained, so
it remains unproven historical evidence. Runner013 introduced field-level hashes
before rollback. Subsequent work independently reproduced Compose's random
primary-network choice at equal priorities and corrected that contract. This
reproduction does not retroactively establish the precise r9 cause.
The first metadata plan001, under014, also exposed a parser coverage gap:
Compose emits a bare network endpoint as null. Version015 includes a regression
using full real Compose JSON, preserves exact raw config hashes and accepts only
the local null/empty-endpoint equivalence. Old001 was never applied and must not
be replayed. See Platform `infra/device-core-deploy/NETWORK_PRIORITY_20260930.md`.
The controller bootstrap was accepted on29September at18:35:52Z (ledger386),
artifact `device-core-autodeploy-v1-20260929-001`, SHA
`fe9298baa5f41a35c2705ee9946b730ff2de7d5b5c9b2b8eb1b4cca0bc8ed12b`.
Its baseline was r7/source `edf69068ec64e3d105d5324d39b8eaeface21215`;
run8 was the first eligible automatic run. Historical terminal runs are not replayed.
An actual Gitea API interruption before r8 reservation recovered without operator
intervention. Run10 failed in npm installation before creating an artifact.
Frozen dependency installation now retries at most three times for explicit
ECONNRESET/ETIMEDOUT/EAI_AGAIN only, with5/10second pauses; integrity, auth,
lockfile, other/mixed errors and test/build failures still fail immediately.
A real ECONNRESET in r12 recovered through that rule, then qualification and
installation passed. An exhausted install cannot produce a qualification receipt.
Pushes may originate from any computer. The Mac, SMB session, SSH session and
Worker006 are not dependencies of recurring delivery. The native outbound timer
runs30seconds after the previous cycle completes. The root-private read token,
SQLite queue and status live under `/var/lib/nodedc-device-autodeploy`, outside
build jobs and application artifacts. No extra inbound port was introduced.
The repo-scoped `synology-device-core-build` runner is id1. Its dependency pins
must all exist in their remotes: the initial Launcher failure was resolved by
publishing its exact existing commit without changing Launcher main or runtime.
Canonical receipts, archive digests, backups and separate product checks are
recorded in Ops DCPLATFORM-37; DCPLATFORM-21 defines the deployment contract.
The full historical report is Platform `infra/device-core-deploy/ACCEPTANCE_20260929.md`.
## 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:
```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.
`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](https://docs.gitea.com/usage/actions/overview/),
[runner configuration](https://docs.gitea.com/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.