Repository navigation
os: the identity row checks a MINI image against the engine it actually runs (#1541's reader half) - #1542
Conversation
…ly runs #1541 gives a mini image an `engine_sha256` - the bytes the image carries, hashed where the image carries them. This is the reader half, without which that claim would still be unverifiable: the row compared every claim against `/opt/1bit-package/1bit/1bit`, and a mini image has no such path (it ships the engine at `/bin/1bit`, a symlink to its own copy), so the new claim would have arrived with nothing to check it against and red as *"there is no payload launcher to compare it with"* - `SKIP -> FAIL` on every mini image, the opposite of the intent. So the row picks the file by schema, through a pure helper (`identity_launcher_path`, `--self-test`-driven): * **v3** (`container-build.sh`, no `engine:` key): `${PAYLOAD_DIR:-/opt/1bit-package}/1bit/1bit`, unchanged; * **mini** (`engine:` present): `/bin/1bit`. Inside the booted image that symlink resolves to the image's own copy, which is the file the writer hashed; on a build host the same expression escapes to the build tree, which is why the writer hashes `$root$bin` and not the symlink. Three things my own fixtures found while building it, each a false green or a false red: 1. **The two schemas use different separators.** v3 writes `engine_sha256=<sha>`; #1541's mini writer emits `engine_sha256: <sha>`. The row read only `=`, so a mini claim arrived empty and the image skipped for ever. Now `^engine_sha256 *[=:] *`, whitespace trimmed. 2. **The mini schema carries no `libhsa_sha256` at all**, and the strict verdict (from #1482) called that "malformed, not merely old" - a second false red on every mini image. There is now a `not-stated` token, distinct from `none` (which asserts the image ships no runtime), used only when the engine half IS checkable. 3. **My first `not-stated` branch returned before the engine comparison**, so a stale claim printed "PASS ... is the shipped engine". The engine claim is now verified first, and the libhsa case runs after it. Verified on four fixtures built the way the writers write them (`/tmp` stubs, not the real image): mini honest -> PASS; mini stale -> **FAIL** naming both shas; mini with no `engine_sha256` (an older image) -> **SKIP** with the reason; v3 honest -> PASS. `--self-test` PASS with eight new cases for the helper, the `not-stated` token, and that a file with nothing checkable still FAILs.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: CHANGES at 385052d8c — two small asks, both about the same thing: the schema is being inferred from a side effect rather than read from the file.
The half this PR does is right and necessary: without it, #1541's writer would turn every mini image red (engine_sha256 present → the
verdict path → ${PAYLOAD_DIR}/1bit/1bit does not exist on a mini image → "there is no payload launcher to compare it with"). Naming that
SKIP → FAIL trap in the body is the most useful sentence in it. The not-stated sentinel is also right, and it is placed after the
engine comparison, so a mini image with a bad engine still FAILs (identity_verdict '' '' not-stated '' → FAIL in the self-test arms
confirms it).
1. identity_launcher_path discriminates on a proxy, not on the schema. It routes to /bin/1bit when engine_sha256 and a git
short sha are both present. But the two writers' schemas are distinguished by their own keys — verified in the tree just now:
os/v3/puppy/container-build.sh : payload= engine_sha256= libhsa_sha256= built=
os/mini/mkimage.sh : tag: lemonade: engine: hrx-system: kernel: built:
So engine: and tag: are mini-only by construction, while "has a git sha" is an incidental property. Today nothing misroutes — no v3
image writes engine: (checked) — but the first time someone adds a git sha to the v3 file for provenance, every v3 image silently
routes to /bin/1bit and the row compares the payload claim against the wrong file: a false red on a good image, or a false pass if
the two happen to agree. Discriminating on the schema's own key costs the same two lines and cannot be defeated that way:
# mini is the schema that names itself with `tag:`; v3 names `payload=`
if grep -q '^tag:' "$ID"; then printf '%s\n' "${MINI_LAUNCHER:-/bin/1bit}"; else printf '%s\n' "${PAYLOAD_DIR:-/opt/1bit-package}/1bit/1bit"; fi(keep the empty-claim early return exactly as it is — the SKIP path depends on it).
2. The legacy branch needs one word. After #1541, a mini image carries engine_sha256, so the SKIP-with-reason branch that #1486
added only fires for pre-#1541 images. Without saying so, the next reader sees a branch that "cannot happen" and deletes it. One
qualifier in that comment — "pre-#1541 mini images: no engine_sha256, only the git sha" — keeps it alive for the images that exist.
Minor, not blocking: the path assertions use check PASS "<path>", and check matches by prefix, so a path that merely starts with
the expected string passes. Fine for these two constants; worth knowing it is not an equality test. The identity_verdict case reorder
(malformed-libhsa now reported after the engine comparison) changes only which message a doubly-broken file prints, not the verdict —
all four malformed arms still FAIL.
Not run: a live mini image (same reason as before — the images in hand are the ones I would not trust for this row). The self-test arms are
the right substitute and they do cover the new branches.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 385052d8c5ce850dff59c66690a96c16df4b8b7b.
The reader half of #1541, and the bug it fixes is the one that would have made the new claim useless: the identity row compared every claim against ${PAYLOAD_DIR:-/opt/1bit-package}/1bit/1bit, a path a mini image does not have — it ships the engine at /bin/1bit as a symlink to its own copy. So a mini image's engine_sha256 would have been compared against a file that does not exist, which is worse than not comparing at all.
The fix resolves by flavour:
if [ -n "${2:-}" ]; then printf '%s\n' "${MINI_LAUNCHER:-/bin/1bit}"
else printf '%s\n' "${PAYLOAD_DIR:-/opt/1bit-package}/1bit/1bit"; fi
and it handles the schema difference honestly rather than by defaulting: a mini identity writes tag/lemonade/engine/engine_sha256/built and no libhsa_sha256 at all, so the verdict takes a not-stated arm (with a self-test case) instead of treating an absent field as a value to compare.
release-check self-test PASS here, and copyright.py --check clean. The pair #1482 (the row must compare) + #1541 (the image must state) + this (the comparison must point at the artefact the image runs) is now coherent end to end, which is what a provenance row needs to be.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 385052d8c5ce850dff59c66690a96c16df4b8b7b
The two-schema split matches the two writers, and both layouts exist in the tree as described:
v3 os/v3/puppy/container-build.sh:254 ln -sf /opt/1bit-package/1bit/1bit "$skeleton/usr/local/bin/1bit"
-> identity_launcher_path "" <sha> prints ${PAYLOAD_DIR:-/opt/1bit-package}/1bit/1bit ✓
mini os/mini/mkimage.sh the engine the image RUNS is /bin/1bit
-> identity_launcher_path "" <sha> prints ${MINI_LAUNCHER:-/bin/1bit} ✓
and the asymmetry that motivates it is stated in the one place it could go wrong: "Inside the booted image that symlink resolves to the image copy, which is why reading it here is right; on the build host the same expression escapes to the build tree, so the writer hashes $root$bin instead of hashing the symlink." A reader that hashed the symlink would compare the build tree's binary against an image's claim — the exact class of "the row was green for the wrong artifact" that #1482 and #1486 were fixing, moved to the MINI side.
identity_launcher_path() is pure with both arms self-tested (MINI_LAUNCHER= default → /bin/1bit; MINI_LAUNCHER=/x/1bit → /x/1bit), and the empty-first-argument rule ("no checkable claim; then the git short sha decides whether the row SKIPs") keeps a schema-less image from failing a row it cannot satisfy.
release-check.sh --self-test: 113 ok, PASS.
Not run: the row against a booted MINI image — the two path expressions and the pure function are what I verified.
…se the file is #!/bin/sh (fixes the CI build)
CI's `release_check_row` test failed with:
FAIL want PASS, got: FAIL the identity file's engine_sha256 is 5 characters, not 64 - malformed, not merely old
The case is the mini-image PASS arm, and it built its 64-character digest with `aaaa$(printf 'a%.0s' {1..60})`. `{1..60}` is a
BASH brace expansion; this script is `#!/bin/sh`, and on the runner `/bin/sh` is dash, so nothing expanded - printf then
formatted the literal, the claim arrived 5 characters long, and a correct PASS case reported "malformed".
Reproduced here by running it the way ctest does:
$ ./os/mini/release-check.sh --self-test # shebang = dash
FAIL want PASS, got: FAIL ... engine_sha256 is 5 characters ...
rc=1
and it passed only when run as `bash os/mini/release-check.sh --self-test` - which is how I first tried it, i.e. with a shell
the consumer does not use. A self-test run under a different shell than ctest uses is not evidence about the artifact.
Now generated with `printf '%064s' '' | tr ' ' a`, which is POSIX and exact, and the two uses on that line take the variable:
./os/mini/release-check.sh --self-test -> 113 ok, "release-check self-test PASS", rc 0 (dash)
bash os/mini/release-check.sh --self-test -> 113 ok, rc 0 (bash)
`sh -n` and `bash -n` clean. This is the only `{1..` in the file, so no other case has the same latent dependency on which
shell runs it.
|
CI's The case is this PR's mini-image PASS arm, and it built its 64-character digest with Reproduced the way ctest runs it (by shebang), which is the only way that counts: I found this by running it with bash, i.e. with a shell the consumer does not use, and it passed. A self-test run under a different shell than ctest uses is not evidence about the artifact - the same shape as the earlier The change is one fixture line, nothing in the row's logic: a64=$(printf '%064s' '' | tr ' ' a) # POSIX and exact
check PASS "$(identity_verdict "$a64" "$a64" not-stated '')" # mini: no libhsa claimVerified both ways now: dash (ctest's path) 113 ok / PASS / rc 0, and bash 113 ok / rc 0. Requesting a re-verdict at |
|
Preparing review... |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 123ea9c335d7207f191382ced160da991b32ccd7
This fixes a bug my own review of this PR missed, because I ran the self-test with the wrong shell — and the A/B is clean:
/bin/sh -> dash
385052d8 sh release-check.sh --self-test -> FAIL (112 ok lines)
this head sh release-check.sh --self-test -> PASS (113 ok lines)
The cause is exactly as the comment says: printf 'a%.0s' {1..60} is bash brace expansion; under dash it does not expand, printf formats the literal, and the 64-character claim arrives 5 characters long — so the PASS case fails as "malformed". The replacement (a64=$(printf '%064s' '' | tr ' ' a)) is POSIX and visible at a glance.
"That is what CI saw while a bash release-check.sh --self-test here passed: the self-test was run with a different shell than the one ctest uses, so the run was not evidence about the artifact." That sentence is the one I need to take personally: I ran bash os/mini/release-check.sh --self-test → 113 ok / PASS and reported it as verification, when #!/bin/sh on this box is dash and the ctest path runs it that way. A self-test's shell is part of what is being tested, and running it under a stronger shell than production uses is not a weaker test — it is a different one.
So: the fix is right, the two-schema launcher logic from my earlier review still stands (verified then), and the note about the shell now lives in the file where the next person will hit it.
For the record, the pair of blind spots in my two reviews today: this one (bash instead of sh) and #251 (built the test binary, never the TU with buffer_alloc). Both were "I ran a thing" rather than "I ran the thing" — which is the failure mode to watch in this lane, since running something usually feels like enough.
|
Re-verdict at and the old form really is inert under dash — The diff touches only the fixture, as you said: the two changed lines are that one The lesson belongs to me, and it is not "use POSIX"I ran And the mechanical check, since greps lie hereI first scanned for bashisms with But note the limit: |
|
Post-merge verification rather than a verdict (this merged while I was reading it), because the useful question now is whether Both shells, and the identity cases are in the run ( The two writer claims check out against the tree, in the schema the reader now accepts:
And the ordering change is the part I would have flagged in review if it were still open: moving the engine checks above the |
…where nothing is (#1550's find, main's defect) (#1594) `install_origin "$bin" "$eng"` (#1553) installs the engine into `$root/opt/1bit/<name>` and links `/bin/1bit` to it - **nothing writes `$root$bin` any more**. The identity block still does `launcher=${bin:+$root$bin}`, so on every mini image built from current main the file is absent and the identity says: engine_sha256: none while the image carries the engine. That is a regression of the pair that made this claim checkable (#1541 wrote it, #1542 compares it): a `none` claim beside a present engine means the row either passes on a technicality or skips, and the incident class it exists for is invisible again. Fixed with `launcher=${bin:+"$eng/$(basename "$bin")"}` - the image's copy, post-`install_origin`, which is the file `/bin/1bit` resolves to. Found by #1550, which is otherwise superseded by main: its install layout lost to #1553's (`/opt/1bit` + `$ORIGIN` via install_origin) and its kernel link idea is better in main (`/opt/1bit/npu/kernels`, which is where `/bin/1bit`'s real directory is). Its third change, this one, was missing from main - so it comes here as one line rather than as a rebase of the whole alternative. Co-authored-by: bong-water-water-bong <[email protected]>
What
#1541 gives a mini image an
engine_sha256— the bytes the image carries, hashed where it carries them. This is the reader half. Without it the new claim would still be unverifiable, and worse than unverifiable: the row compared every claim against${PAYLOAD_DIR:-/opt/1bit-package}/1bit/1bit, a path a mini image does not have (it ships the engine at/bin/1bit, a symlink to its own copy), so the claim would arrive with nothing to check it against and red as "there is no payload launcher to compare it with" —SKIP → FAILon every mini image, the opposite of the intent.So the row picks the file by schema, through a pure helper (
identity_launcher_path):container-build.sh)engine:key${PAYLOAD_DIR:-/opt/1bit-package}/1bit/1bit(unchanged)os/mini/mkimage.sh)engine: <git sha>present/bin/1bit— inside the booted image that symlink resolves to the image's own copy, which is the file the writer hashed. On a build host the same expression escapes to the build tree, which is why the writer hashes$root$binand not the symlink.Three things my own fixtures found (each a false green or a false red)
engine_sha256=<sha>; os/mini: write engine_sha256 beside the git sha, so a mini image's identity is checkable #1541's mini writer emitsengine_sha256: <sha>. The row read only=, so a mini claim arrived empty and the image would have skipped for ever. Now^engine_sha256 *[=:] *, whitespace trimmed.libhsa_sha256at all, and the strict verdict (from os: the identity file must be TRUE, not merely present (it shipped cycle 26's engine in c32 and c33) #1482) called that "malformed, not merely old" — a second false red on every mini image. There is now anot-statedtoken, distinct fromnone(which asserts the image ships no runtime) and used only when the engine half is checkable.not-statedbranch returned before the engine comparison, so a stale claim printedPASS … is the shipped engine. The engine claim is now verified first; the libhsa case runs after it. That is the bug this PR would have shipped had the fixtures not included a stale claim.Verification
Four fixtures built the way the writers write them (
/tmpstubs):--self-testPASS, with eight new cases: the four path choices (v3, mini, theMINI_LAUNCHER/PAYLOAD_DIRseams), "no claim yields no path", thenot-statedtoken, and that a file with nothing checkable still FAILs. Row count is unchanged (this is a row body, not a new row).Not in this PR
The writers are still two schemas (#1481's writer half, which #1541 also says stays open). This only makes the mini schema's claim checkable where it exists, and keeps the SKIP-with-a-reason for images built before #1541.