feat(deploy): preserve immutable release manifests and restore pinned images
This commit is contained in:
1 parent
4ee53d9a74
commit
7df521bd89
7 files changed
+1417
-110
No files matched your search
@@ -461,6 +461,10 @@ Referencing a version (planned): tables that record a decision built under a pol
|
||||
|
||||
Test fixtures use their own values. Since `product` is the only family, the integration tests give every case its own database, and no fixture stands in for the demo policy.
|
||||
|
||||
## Release artifacts and restoration
|
||||
|
||||
The local release manifest separates core image verification from product data availability. It records immutable release IDs, source and Compose file hashes, exact built image IDs, registry digests for pulled images, and bounded hashes for versioned data artifacts. Restoration checks these references and hashes before Compose starts and never resolves a moving tag again. The bundled demo policy source is version 1, but that does not establish which policy row is active in PostgreSQL. The assessment bank and demo seed remain unavailable until accepted snapshots exist, so `product_data_status` is partial. Named Compose volumes persist across a release restart, but the manifest is not a database backup or data snapshot. See [DEPLOY.md](DEPLOY.md#release-manifest) for the commands and manifest schema.
|
||||
|
||||
## Repository map and package purpose
|
||||
|
||||
```text
|
||||
|
||||
+19
-14
@@ -540,36 +540,41 @@ The backend builds with Go 1.26.8; its runtime image is selected in backend/Dock
|
||||
|
||||
## Release manifest
|
||||
|
||||
A release manifest records what a verified local release consists of: the commit, the toolchain versions, the lockfile hashes, the image of every service with its actual digest, and which components a check really ran. Moving `latest` and `alpine` tags stay in Compose and in the Dockerfiles by agreement; the manifest pins what they resolved to at release time. The interface is `make -C deploy release-manifest`; the other `release-*` targets prepare its inputs and check its result:
|
||||
A release manifest records the source, toolchains, lockfile hashes, Compose file hashes, image IDs and digests, and versioned data inputs for one local delivery. Compose may keep moving `latest` and `alpine` tags; restoring a release uses the image IDs or repository digests recorded in its manifest, never a fresh lookup of those tags. The default release ID is the commit-based tag. Use a short `RELEASE_ID` when the same source has more than one delivery or when its data or stage changes:
|
||||
|
||||
make -C deploy release-build
|
||||
make -C deploy release-smoke
|
||||
make -C deploy release-e2e
|
||||
make -C deploy release-manifest
|
||||
make -C deploy release-manifest-check
|
||||
make -C deploy release-manifest RELEASE_ID=demo-stage-1
|
||||
make -C deploy release-manifest-check RELEASE_ID=demo-stage-1
|
||||
|
||||
- `release-build` builds `backend`, `frontend`, and `ml` from their Dockerfiles and lockfiles through Compose and tags them `lincodex.invalid/<service>:<tag>`. The `.invalid` domain never resolves, and the release overlays set `pull_policy: never`, so a missing release image is never pulled from a registry. Each Dockerfile takes its base images as `*_IMAGE` build arguments whose defaults are the agreed tags; the target resolves each base to its repository digest in the local image store and builds with `<tag>@<digest>`. A base image used through `COPY --from` or `RUN --mount=from` that is not an earlier stage is refused, because it could not be pinned. Base and core service images are pulled only when missing locally; `RELEASE_PULL=always` refreshes every tag first. The target reads the source state again after the build and writes `build.json` (build arguments, base digests, image IDs) only if the commit and the working tree did not change during the build.
|
||||
- `release-smoke` and `release-e2e` run `deploy/scripts/smoke.sh` and `deploy/scripts/e2e.sh` with `LINCODEX_RELEASE_TAG`, which only these targets set: the stack starts from the release images with `--no-build --pull never`, and only after every check passes does the script write `evidence-smoke.json` or `evidence-e2e.json` with the release tag, commit, working tree fingerprint, and the image IDs of the running containers. A failed run writes nothing. Evidence written after the checks passed stays even if the stack cleanup fails afterwards; the script still exits with an error then.
|
||||
- `release-manifest` reads only local images, the build record, and the evidence; it pulls nothing. A missing image is listed as not present. Evidence or a build record that is malformed or was recorded for another tag, commit, or working tree state is not used; the manifest lists the rejected evidence under `rejected_checks`.
|
||||
- `release-manifest-check` checks the structure of the manifest and scans it for secrets and machine data.
|
||||
- `release-up` and `release-down` run the core stack from the release images with `ENV_FILE` and `APP_PROJECT`, without building or pulling. `make -C deploy release-manifest-verify RELEASE_VERIFY_PROJECT=<project>` compares every running container of that Compose project with the manifest of the current tag, or with `RELEASE_MANIFEST=<path>`, by image ID. It prints the release status and exits with status 1 on a different digest, a missing service, or a service the manifest does not list.
|
||||
- `release-clean` removes the local `lincodex.invalid/*` images and keeps the files in `deploy/release/`.
|
||||
- `release-manifest` reads local images, the build record, evidence, and optionally a data descriptor. It pulls nothing. `RELEASE_DATA_MANIFEST=<path>` selects a repository-relative JSON file using schema `lincodex.release-data/v1`; it describes `bank`, `policy`, and `seed` as either available with a version and artifact paths, or unavailable with a reason. Artifact paths must be normalized repository-relative paths without symlinks or environment files. The manifest stores their SHA-256 hashes and sizes; restore checks the files still match. Descriptors, artifact counts, and sizes have explicit limits.
|
||||
- Without a data descriptor, the manifest records bundled demo policy source version `1` and hashes `backend/internal/domain/policy_demo.go`. This identifies the shipped definition only; it does not report the policy row currently stored in PostgreSQL, because startup leaves an existing row unchanged. The assessment bank has no accepted release snapshot and the demo seed is not yet versioned, so both remain unavailable and `product_data_status` is `partial`. This is not a full MVP readiness result.
|
||||
- The manifest is published once at `deploy/release/<release-id>/manifest.json`. A release ID is a validated 1-64 character slug. A second run with identical content leaves the original bytes and modification time unchanged; changed data or stage under the same ID fails and requires a new ID. Publication is serialized per ID and creates the file atomically, without replacing an existing manifest. Build and evidence records remain under `deploy/release/<source-tag>/`.
|
||||
- `release-manifest-check` checks the manifest location and structure and scans it for secrets and machine data. `RELEASE_MANIFEST=<path>` selects an exact artifact for check, verify, restore, or down; otherwise `RELEASE_ID` selects it, falling back to the current commit-based ID.
|
||||
- `release-up` verifies the Compose file hashes, data artifact hashes, local built image IDs, pulled image digests, and recorded image IDs for verified checks before starting Compose. It writes a private temporary Compose override with each built service pinned directly to its image ID, then uses `--no-build --pull never`; the retained image tag is not used to resolve the service. After startup it checks each running container against the manifest. Use the same `APP_PROJECT`, `ENV_FILE`, and manifest for `release-down`. Named volumes remain in the project and are not database backups or snapshots.
|
||||
- `make -C deploy release-manifest-verify RELEASE_VERIFY_PROJECT=<project>` compares running container image IDs with the selected manifest and exits with status 1 on a mismatch, missing service, or unknown service.
|
||||
- `release-clean` removes local release image references that no immutable manifest retains and keeps the files in `deploy/release/`.
|
||||
|
||||
The release tag is the first 12 characters of the commit, with `-dirty` when the working tree differs from it. The working tree fingerprint is the Git tree ID written from a temporary index (seeded from HEAD, then `git add -A`), with line ending, file mode, symlink, and fsmonitor settings pinned. It covers modified, deleted, and untracked files, does not depend on diff settings, and leaves the real index untouched. All files go to `deploy/release/<tag>/`, which Git and the root `.dockerignore` ignore. Manifests are not committed: built image IDs depend on the machine, platform, and build time, and the manifest describes what this machine built and checked. Attach the manifest to the release instead.
|
||||
The source tag is the first 12 characters of the commit, with `-dirty` when the working tree differs from it. The working tree fingerprint is the Git tree ID written from a temporary index (seeded from HEAD, then `git add -A`), with line ending, file mode, symlink, and fsmonitor settings pinned. It covers modified, deleted, and untracked files, does not depend on diff settings, and leaves the real index untouched. Build and evidence records go to `deploy/release/<source-tag>/`; immutable manifests go to `deploy/release/<release-id>/`. Git and the root `.dockerignore` ignore these local artifacts. Manifests are not committed: built image IDs depend on the machine, platform, and build time, and each manifest describes what this machine built and checked. Attach a manifest to the delivery when needed.
|
||||
|
||||
### Format
|
||||
|
||||
The manifest is JSON with sorted keys and schema `lincodex.release-manifest/v1`:
|
||||
The manifest is JSON with sorted keys and schema `lincodex.release-manifest/v2`:
|
||||
|
||||
| Key | Content |
|
||||
| --- | --- |
|
||||
| `schema`, `generated_at` | Schema version and UTC generation time |
|
||||
| `release` | `tag`, `status` (`verified` or `unverified`), `scope` (`core`), `required_checks` (`smoke`, `e2e`), and the `reasons` that keep it unverified |
|
||||
| `release` | Immutable `id`, source `tag`, core `status` (`verified` or `unverified`), `product_data_status` (`versioned`, `partial`, or `unavailable`), `required_checks` (`smoke`, `e2e`), and reasons |
|
||||
| `restore` | Whether the core Compose project can be restored, its command, and any preflight blocking reasons |
|
||||
| `source` | `commit`, `dirty`, the working tree `fingerprint` (`git-tree:<id>`, or null for a clean tree), and `build_matches_source` |
|
||||
| `toolchains` | Go from go.mod, its `toolchain` directive, the `GO_IMAGE` default, `GOTOOLCHAIN=local`, the base image version, and the version recorded in the backend binary; Node and pnpm from `.node-version`, `packageManager`, the Dockerfile, and the base image; Python and uv from `.python-version`, `requires-python`, the Dockerfile, and the base image; `matches_version_file` for Node and Python; the Playwright package version |
|
||||
| `lockfiles` | SHA-256 of `backend/go.mod`, `backend/go.sum`, `frontend/package.json`, `frontend/pnpm-lock.yaml`, `ml/pyproject.toml`, and `ml/uv.lock` |
|
||||
| `checks`, `rejected_checks` | Accepted evidence with its scope, finish time, commit, fingerprint, and tool image, such as the Playwright image; rejected evidence with the reason |
|
||||
| `components` | Each Compose service of core, ML, and monitoring and each missing component: `group`, `kind` (`built`, `pulled`, `absent`), the image (`reference`, `present`, `image_id`, `repo_digest` for the tag's repository, all `repo_digests`, `platform`, and allowlisted `versions`), for built images the Dockerfile, its hash, build arguments, and base images, and `verification` |
|
||||
| `configuration`, `data_versions` | SHA-256 hashes of the core Compose files; bank, policy, and seed versions with bounded artifact paths, hashes, sizes, or an explicit unavailable reason |
|
||||
| `checks`, `rejected_checks` | Accepted evidence with its scope, finish time, commit, fingerprint, tool image, and image IDs; rejected evidence with the reason |
|
||||
| `components` | Each Compose service of core, ML, and monitoring and each missing component: `group`, `kind` (`built`, `pulled`, `absent`), image metadata, exact `restore_reference`, optional built-image retention reference, build details, and `verification` |
|
||||
|
||||
`verification.status` is one of:
|
||||
|
||||
@@ -588,7 +593,7 @@ The release is `verified` only when all of the following hold; otherwise `releas
|
||||
|
||||
A Python version that differs from `ml/.python-version` is reported in `matches_version_file` but does not block the release, because ML is outside the verified scope. A moving `node:alpine` tag can therefore make a release unverified until `.node-version` is updated. A dirty tree is not refused: the manifest is written with `unverified` and the reason, so a local candidate can be checked before the commit.
|
||||
|
||||
Generating the manifest again for the same source, images, and evidence gives the same document apart from `generated_at`; the target says whether anything else changed since the previous manifest of the tag. Version fields are copied only from an allowlist of image variables and OCI labels. The manifest never contains environment values, `.env` content, container labels, mounts, local paths, user or host names; every file is scanned for those, for values of variables whose names suggest secrets (also as substrings and in base64), and for secret patterns before it is written, and `release-manifest-check` repeats the scan.
|
||||
Generating the manifest again for the same ID, source, images, evidence, and data leaves the submitted file unchanged. A new data snapshot or stage gets a new ID. Version fields are copied only from an allowlist of image variables and OCI labels. The manifest never contains environment values, `.env` content, container labels, mounts, local paths, user or host names; every file is scanned for those, for values of variables whose names suggest secrets (also as substrings and in base64), and for secret patterns before it is written, and `release-manifest-check` repeats the scan.
|
||||
|
||||
### Go pin
|
||||
|
||||
@@ -596,7 +601,7 @@ go.mod declares `go 1.26.8` without a separate `toolchain` line, the default `GO
|
||||
|
||||
### Not covered
|
||||
|
||||
- The manifest is not an SBOM, a license inventory, a signature, or a provenance attestation, and it is not pushed to a registry.
|
||||
- The manifest is not an SBOM, a license inventory, a signature, or a provenance attestation, and it is not pushed to a registry. A restore reinstates images and Compose configuration; it does not restore or validate database contents or persistent volume backups.
|
||||
- The files in `deploy/release/` are local and not tamper-proof; evidence is not signed and proves only what this machine recorded.
|
||||
- Git-ignored files are not part of the fingerprint. A build context still receives such files unless `.dockerignore` excludes them.
|
||||
- Images are built for the local platform only. Versions without an image variable or label, such as Kafka, are identified only by digest.
|
||||
|
||||
Reference in new issue
Block a user