Skip to content

release: the manifest names the image's digests and SBOMs (060 3.4.1) - #494

Merged
bartekus merged 1 commit into
mainfrom
impl/060-image-manifest
Nov 4, 2026
Merged

bartekus merged 1 commit into
mainfrom
impl/060-image-manifest

Conversation

@bartekus

@bartekus bartekus commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Spec 060 increment 4a (3.1.1, 3.3.2, 3.4.1): the manifest names the image.

  • Release set: optional image entry (image::ImageMember: repository, platforms). check_set refuses a repository other than ghcr.io/statecrafting/rustev-serve, platforms other than linux/amd64, linux/arm64 in that order, or an image beside an absent entry of kind image. The committed set is unchanged (the image stays absent).
  • Manifest (rustev.release-manifest/2): optional image (image::ImageRelease: repository, tag = family version, layer 7, index digest, per-platform media type, digest, size, optional variant and SBOM file, SLSA build level 2). Serialized only when present, so earlier manifests keep their bytes and digests.
  • image::platform_manifest reads a verified OCI archive with a small ustar reader (no new dependency): exactly one image manifest in index.json, its blob hashing to digest and size, its config naming the platform. image::index_bytes is the OCI index over the two descriptors in fixed order (compact JSON in field order), so the index digest is a pure function of the platform digests (3.3.2) and is known when the manifest is attested, before any push.
  • collect_family: with the image a member of a release given its artifacts, requires image/<archive> + .sha256 sidecar and sbom/<archive>.cdx.json per platform, names the image and adds the two SBOMs as layer-8 sbom artifacts (release assets, in SHA256SUMS). The archives are checked but are not release assets. A member without them is refused.
  • validate: refuses a manifest image missing a platform digest or SBOM, out of order, at another tag/repository/build level, or whose index digest is not the index of its platform descriptors; refuses any candidate manifest naming an image (053 3.4.2). An image as a plain artifact stays refused.
  • Tests: tools/rustev-release/tests/image.rs (7 tests) cover section 5's manifest row and the candidate refusal.

verify-release against the registry follows (stacked on this). Stacked on release/bump-0.4.0 (#480); appends to 060's implementation record like #487 and #491 (keep all paragraphs on rebase).

Checks: cargo test -p rustev-release --locked passed; clippy -D warnings passed; spec-spine verify 031 passed (4 commands); make gate passed; check-authored-content.sh clean.

Review round 1: the index's platform object now follows the OCI image-spec order (os, architecture, then variant). The exact bytes golden in tests/image.rs is updated. verify-image still compares the registry's bytes with these exact bytes and their digest.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

AI review (findings)

Reviewing the diff across specs/060-the-service-image-in-the-release/spec.md, tools/rustev-release/src/image.rs, family_artifacts.rs, lib.rs, main.rs, manifest.rs, and tests/image.rs.

image.rs — tar_files
The ustar tar reader correctly advances at before the type dispatch, correctly handles GNU L long-names and PAX x path records, bounds-checks blob sizes via checked_add, and uses div_ceil(512) * 512 correctly for padding. PAX record parsing via lines() → split_once(' ') → strip_prefix("path=") handles the "<len> path=<value>\n" format correctly after lines() strips newlines.

image.rs — platform_manifest
Digest validation is thorough: format checked by digest_ok, blob fetched by SHA-256 path, content re-hashed and compared to name, and manifest size independently verified against the descriptor. Config parsed to verify the platform (os/architecture) matches the caller's expectation. All error paths return early correctly.

image.rs — index_bytes
serde_json serializes struct fields in declaration order (documented, stable behavior), so the output is deterministic. The IndexPlatform struct has fields architecture, os, variant. The OCI image index spec conventionally orders these as os, architecture, variant. The index_bytes JSON therefore differs in platform-object field order from what OCI tools (buildx, containerd) write when they push the multi-platform index to the registry. The spec text explicitly defines this as "compact JSON in field order" and states the index digest is known before push — the intent is that verify-release (deferred) must reconstruct the same bytes using index_bytes, not compare against the registry-served index. This design is load-bearing: the future verify-release PR must use the same function, or the index digest in the manifest will never match what it fetches from the registry. The spec does not make this constraint explicit enough to guard a future implementor.

family_artifacts.rs — collect_family / compare_files
The also set correctly excludes image archives and sidecar files from the unexpected-file check while still requiring their content to be valid (sidecar hash match, then platform_manifest via release). Image SBOMs are included in m for the compare_files pass via the .oci.tar.cdx.json suffix. The existing collect wrapper correctly discards the image return value for callers that don't need it.

family_artifacts.rs — validate
The candidate check gates on candidate before calling image::validate, so a candidate with an image in the manifest always returns the 053 3.4.2 error regardless of the image fields — correct. The SBOM list is built from manifest artifacts and passed to image::validate, which cross-checks each platform's declared SBOM name against it.

manifest.rs / main.rs
#[serde(default, skip_serializing_if = "Option::is_none")] on image correctly makes the field absent in serialized prior manifests and candidates. The destructuring (m.artifacts, m.image) = collect_family(...) is valid Rust since 1.59. m.image = None in manifest::build ensures the field starts unset before collect_family populates it.

tests/image.rs
Covers the round-trip, platform mismatch, bad-blob hash, single-manifest requirement, missing SBOM/archive, candidate refusal, and index-digest recomputation. The synthetic tar/oci helpers stay within the 100-byte name field limit for all paths used (longest: blobs/sha256/<64 hex> = 77 bytes). Checksum computation in the helper is correct (spaces placeholder → sum → 6-digit octal + NUL over 7 bytes of the 8-byte field).

Concrete finding

The IndexPlatform struct serialises as {"architecture":…,"os":…} (declaration order), which differs from the OCI image index specification's conventional order {"os":…,"architecture":��}. Because index_bytes is the sole definition of the index format used for the manifest's index_digest, any future verify-release path that fetches the pushed index from the registry (which will use OCI-conventional field order) will compute a different digest and fail. The spec text defers this problem to a future PR but does not document the constraint that verify-release must call index_bytes rather than compare against the registry — a silent trap for the next implementor.

{"head": "7b8c0b28bc76c63eca0ecb80502b673b490b9ab8", "verdict": "findings", "findings": [{"path": "tools/rustev-release/src/image.rs", "line": 282, "summary": "IndexPlatform serialises architecture before os, diverging from OCI index field order; any verify-release path that fetches the pushed registry index to compare digests will find a mismatch, since the registry (and OCI tools) place os first."}]}

Subject: e3f6b9a...7b8c0b2, diff digest c3a012910139b018e3a4950ba7d433ca6149171e9247308b8e75df04399a1900, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across image.rs (new), family_artifacts.rs, manifest.rs, lib.rs, main.rs, and the test file.

image.rs — tar_files

The hand-rolled ustar/PAX reader correctly handles b'L' (GNU long-name), b'x' (file-local PAX), b'g' (global PAX) and b'0'/0 (regular files). One minor edge-case: when b'g' is encountered the function just continues without clearing long_name, so a preceding b'L' long-name would still apply to the next regular file through an intervening global PAX header. This combination doesn't appear in OCI archives produced by standard tooling, so it has no practical impact.

Blob verification in platform_manifest is thorough: digest format, presence in archive, SHA-256 hash, manifest-to-config chain, and platform field cross-check all checked.

index_bytes

Uses serde_json::to_vec over declared-order structs, which is deterministic. The test asserts the exact compact JSON string including field order and the optional variant field. ✓

family_artifacts.rs — collect_family

Sidecar format (sha256hex name\n) is consistent between writer (member_fixture) and reader. The also BTreeSet correctly pre-populates expected in compare_files so archive files and their .sha256 sidecars are not flagged as unexpected, while SBOM files enter expected through the normal artifact path (.oci.tar.cdx.json suffix added to the filter). ✓

validate

The image arm now returns a correctly updated error referencing 060 3.4.1. The candidate-carries-no-image guard fires before image::validate, so the SLSA/tag/index-digest checks are not applied to candidate manifests. ✓

manifest.rs

#[serde(default, skip_serializing_if = "Option::is_none")] on image preserves byte-identical serialization of all earlier manifests. ✓

main.rs

Tuple destructuring assignment (m.artifacts, m.image) = collect_family(...) is valid Rust 1.59+. ✓

Tests

Cover the specified scenarios: index-is-pure-function (with an exact JSON assertion), platform mismatch, blob hash tamper, two-manifest/no-manifest index, all validate refusal paths, member-without-archives, candidate-naming-image, and image-as-plain-artifact.

No concrete bugs or security defects found.

{"head": "99f0a714918faaa535ca067570cddfa15bf262fc", "verdict": "no-findings", "findings": []}

Subject: e3f6b9a...99f0a71, diff digest 91007453542b3a0a054b54abac6cf3a7d8ad3f7c8554070606ec5ee465958283, 1 call(s). An AI comment is not an approval.

Base automatically changed from release/bump-0.4.0 to main November 4, 2026 00:26
…d SBOMs, refused without them or in a candidate (060 3.4.1)
@bartekus
bartekus force-pushed the impl/060-image-manifest branch from 99f0a71 to 2a368e2 Compare November 4, 2026 00:31
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the diff across all seven changed paths.

tools/rustev-release/src/image.rs — tar_files

The PAX extended-header body is parsed with .lines() split and split_once(' '). The PAX record format is <decimal-length><SP><key>=<value><NL>; using .lines() to delimit records and splitting on the first space is correct for path-only records. Values that contain embedded \n or \r\n would be mis-split, but OCI-layout archive paths never contain those bytes, so this is an acceptable simplification.

tar_files — PAX header clears GNU long name

b'x' => {
    long_name = records.lines().find_map(|r| {
        r.split_once(' ')
            .and_then(|(_, kv)| kv.strip_prefix("path="))
            .map(str::to_string)
    });
    continue;
}

If the PAX header contains no path= record, find_map returns None and clears any previously accumulated GNU long name. Mixing GNU long-name and PAX headers in the same archive is non-standard and unreachable in OCI layouts; not a concrete defect.

collect_family — also correctly prevents archive/sidecar from being reported as unexpected

The image archive keys and their .sha256 sidecars are added to also before compare_files is called, and compare_files pre-seeds expected from also. The archives exist in files at that point (they were just successfully read), so they will be in both expected and files and will not be flagged either as unexpected or as missing. Correct.

collect wrapper discards image

pub fn collect(...) -> Result<Vec<WorkflowArtifact>, String> {
    collect_family(set, evidence, artifacts).map(|(a, _)| a)
}

For the current committed release-set.json where the image is absent, member(set)? returns Ok(None) and collect_family returns (artifacts, None); discarding None is correct. The manifest command calls collect_family directly. No current concrete defect.

family_artifacts::validate — candidate check precedes image::validate

The candidate check (if candidate { return Err("053 3.4.2 …") }) is inside if let Some(image) = &m.image, before image::validate is called. A candidate manifest with an image is refused before tag/digest checks run. Correct.

index_bytes serialization order

Field declaration order on the serde structs (os, architecture, variant; mediaType, digest, size, platform) matches the OCI image-spec ordering, and serde_json::to_vec uses declaration order. The index is a pure function of the platform descriptors. Correct.

validate in image.rs — index_digest recomputation

if !digest_ok(&image.index_digest)
    || image.index_digest != format!("sha256:{}", sha256_hex(&index_bytes(&image.platforms)))
{
    return refuse("index digest is not the index of its platform digests");
}

Both format and value are checked. Modifying any platform's digest or size causes the recomputed index to differ. Correct.

manifest.rs — skip_serializing_if = "Option::is_none"

The image field is omitted from serialized bytes when absent, preserving the byte identity and digest of every earlier manifest. Correct.

No concrete defect is supported by the available evidence.

{"head": "2a368e239936043e763a32e2193887a5e33abf7e", "verdict": "no-findings", "findings": []}

Subject: 983b4ac...2a368e2, diff digest 91007453542b3a0a054b54abac6cf3a7d8ad3f7c8554070606ec5ee465958283, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit adcaa4c Nov 4, 2026
38 checks passed
@bartekus
bartekus deleted the impl/060-image-manifest branch November 4, 2026 02:37
bartekus added a commit that referenced this pull request Nov 5, 2026
…0 3.1) [held for owner decision] (#499)

Spec 060 increment 5 (3.1): membership. DRAFT, DO NOT MERGE until the
owner decides 060 decision 2 and the other prerequisites below hold.

- `tools/rustev-release/release-set.json` names the image under `image`
(`ghcr.io/statecrafting/rustev-serve`, `linux/amd64`, `linux/arm64`) and
drops its `absent` entry. This is the switch that makes the next release
name the image in its manifest, gate its scan through
`image-exceptions.json`, push and attest it (`publish-image`), verify it
and qualify it.
- Tests that are not about the image (`tests/family.rs`,
`tests/tagged.rs` fixtures) set `image` to none; `tests/npm.rs` and
`tests/image.rs` no longer read an image absence from the committed set.

Prerequisites before merging:
1. The base move to `gcr.io/distroless/cc-debian13:nonroot` (#502),
decided by the owner on 2026-11-03.
2. The owner's ruling on each of the 44 findings on that base (one
decision row and one `image-exceptions.json` entry per (id, package), at
most 90 days). With the image a member, any uncovered finding fails
`image-checks`.
3. The image qualification of 060 3.4.3 as amended (#500 harness, #501
workflow).
4. Spec 042 is complete (#477), so 3.1.1's condition holds. The owner
makes the ghcr package public after the first push.

Stacked on #498 (on #496, #494).

Checks: `cargo test -p rustev-release --locked` passed (all binaries);
`make gate` passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

statecraft:stacked-ci Run the full CI matrix on a stacked pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant