Repository navigation
weekly: sign the sealed NPU kernel sets between build and package - #648
Merged
Merged
Conversation
A single `weekly.sh` invocation - which is exactly what the Sunday wrapper runs
(`weekly.sh $W` = bumps build test package release) - cannot produce a package:
sealed set 1024x3072x16x8 has no manifest.json: it was never signed
(tools/seal_manifest.py write ... --build/npu/kernels/1024x3072x16x8/ --key <release key>)
`build` rebuilds $BUILD/npu/kernels and wipes their manifests; the manifest is the authenticity half of a
sealed set (engine #574 - sealing is confidentiality) and `package-linux.sh` refuses to pack a set without
one. This script only *verifies* manifests, in package_checks, and nothing signed them: the release lane
signs by hand between two separate invocations (`build test`, then `package`), which is why ten candidates
went out green while the automated path was broken. It has not bitten yet only because the crontab line is
commented out and the last real rehearsal predates #574.
Add `sign_npu_sets()` and call it at the top of `stage_package`:
- drops `layer1.work/` (plaintext MLIR, .o, intermediate ELFs) so the manifest describes the shipped
allowlist and nothing else;
- `tools/seal_manifest.py write` with $ONEBIT_SEAL_KEY (default ~/.config/1bit-npu-key/seal.key), then
`verify --pub` when the public key is there;
- exports $ONEBIT_SEAL_PUB when it is found, so `package-linux.sh` verifies each signature too instead of
reporting "digests only: no ONEBIT_SEAL_PUB";
- fails with one clear sentence when the release key is missing, because a box without it cannot make a
shippable package at all - better here than half way through the packer.
Checked on strixhalo by running the *real* package stage of this script against a workspace whose build
had just produced unsigned sets, twice, under thermal-run, both exit 0:
ok : 11 file(s) signed, manifest 1514 bytes, sha256 8e1a2ae516ce4f2c
ok 1024x3072x16x8: 11 file(s), each listed with the sha256 of its ciphertext, manifest.sig verified
(same for 2048x6144x16x8 and 2560x9728x32x8)
[06:46:45] package rehearsal-sign-test: the engine (into the Lemonade + onebit package)
[06:50:48] package rehearsal-sign-test: 1bit OS
-> lemonade tar 37,145,508 B, img.zst 395,747,240 B, .efi 105,665,664 B, SHA256SUMS
and the second run, with the public key exported, makes the packer say
"npu/kernels: 3 sets, 30 sealed kernels, 3 signed manifests" with no "digests only" caveat (it said it in
the first run).
Not covered: a full all-stages rehearsal (bumps build test package release) on main - that needs this merged
first, since the wrapper copies main's weekly.sh. The signing step itself is the only new code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why — this is the second thing that stops the Sunday release
weekly.shcannot package after it has built. One invocation, which is exactly what the Sunday wrapper runs(
~/.local/bin/1bit-weekly→"$W/weekly.sh" "$W"=bumps build test package release), dies in the package stage:stage_buildrebuilds$BUILD/npu/kernelsand wipes the manifests. The manifest is the authenticity half of asealed set (engine #574 — sealing is confidentiality, the manifest is authenticity) and
scripts/package-linux.shrefuses to pack a set that has none.
weekly.shonly verifies manifests (inpackage_checks, lines 392-418); nothingin the automated path signs them.
This has been invisible because the release lane signs by hand between two separate invocations
(
weekly.sh <work> build test, thenweekly.sh <work> package) — that is how candidates 3 through 15 were built. TheSunday wrapper runs a single invocation, so it cannot package at all. It has not bitten yet only because the crontab
line is commented out and the last real rehearsal predates #574. I found it by running the rehearsal this brief asked for
(
~/zp-rehearse.sh, dry run): it built and tested fine (48/48 ctest) and then failed here after 9m34s.What changes
One helper,
sign_npu_sets(), called at the top ofstage_package(beforerm -rf "$OUT", so a failure leaves nothinghalf-written):
layer1.work/(plaintext MLIR,.o, intermediate ELFs) so the manifest describes the shipped allowlist only;tools/seal_manifest.py write <set> --key $ONEBIT_SEAL_KEY(default~/.config/1bit-npu-key/seal.key), thenverify --pubwhen the public key is present;$ONEBIT_SEAL_PUBwhen it is found, sopackage-linux.shverifies each manifest's signature too instead ofthe weaker
digests only: no ONEBIT_SEAL_PUB, so no release public key to verify the signature with;said before the packer than half way through it;
$BUILD/npu/kernelsreturns 0, so a tree without NPU sets is unaffected.29 added lines, no other behaviour touched.
bash -nclean,tools/copyright.py --checkrc=0.Testing — the real package stage, twice, on strixhalo
Ran this script's
packagestage (underthermal-run,WEEKLY_DRY_RUN=1,KVER=7.3.0-rc4-1bit-perfopt, the MOK key)against
~/.cache/1bit-weekly, whosebuildhad just produced unsigned sets — i.e. precisely the state the Sunday runis in when it reaches
package. Both runs exit 0:(
package_checksinside that stage passed:npu/kernels: 3 sets, 30 sealed kernels, 3 signed manifests.) The second runis the same stage with
ONEBIT_SEAL_PUBexported by the new code, and the packer's line loses the "digests only" caveat —it verifies the signatures itself.
Not run: a full all-stages rehearsal (
bumps build test package release) onmain. That needs this merged first,because the wrapper copies
main'sweekly.sh; the plan is to run it immediately after the squash-merge and recordpass/fail + duration in
~/briefs/TRELEASE-3-STATE.md.Not merged
Opened for the orchestrator; nothing pushed to
main. The Sunday crontab line stays commented until the owner says go.