Skip to content

weekly: sign the sealed NPU kernel sets between build and package - #648

Merged
bong-water-water-bong merged 1 commit into
mainfrom
1bit/weekly-sign-sealed-sets
Oct 30, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
1bit/weekly-sign-sealed-sets

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Why — this is the second thing that stops the Sunday release

weekly.sh cannot 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:

sealed set 1024x3072x16x8 has no manifest.json: it was never signed
    (tools/seal_manifest.py write /home/bcloud/.cache/1bit-weekly/build/npu/kernels/1024x3072x16x8/ --key <release key>)

stage_build rebuilds $BUILD/npu/kernels and wipes the manifests. The manifest is the authenticity half of a
sealed set (engine #574 — sealing is confidentiality, the manifest is authenticity) and scripts/package-linux.sh
refuses to pack a set that has none. weekly.sh only verifies manifests (in package_checks, lines 392-418); nothing
in 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, then weekly.sh <work> package) — that is how candidates 3 through 15 were built. The
Sunday 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 of stage_package (before rm -rf "$OUT", so a failure leaves nothing
half-written):

  • removes 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), then
    verify --pub when the public key is present;
  • exports $ONEBIT_SEAL_PUB when it is found, so package-linux.sh verifies each manifest's signature too instead of
    the weaker digests only: no ONEBIT_SEAL_PUB, so no release public key to verify the signature with;
  • fails loudly when the release key is missing — a box without it cannot make a shippable package, and that is better
    said before the packer than half way through it;
  • a build with no $BUILD/npu/kernels returns 0, so a tree without NPU sets is unaffected.

29 added lines, no other behaviour touched. bash -n clean, tools/copyright.py --check rc=0.

Testing — the real package stage, twice, on strixhalo

Ran this script's package stage (under thermal-run, WEEKLY_DRY_RUN=1, KVER=7.3.0-rc4-1bit-perfopt, the MOK key)
against ~/.cache/1bit-weekly, whose build had just produced unsigned sets — i.e. precisely the state the Sunday run
is in when it reaches package. Both runs 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
ok : 11 file(s) signed, manifest 1514 bytes, sha256 308209b5498afca2
ok  2048x6144x16x8: …  manifest.sig verified
ok : 11 file(s) signed, manifest 1514 bytes, sha256 a27175596211be8a
ok  2560x9728x32x8: …  manifest.sig verified
[06:46:45] package rehearsal-sign-test: the engine (into the Lemonade + onebit package)
[06:50:48] package rehearsal-sign-test: 1bit OS
  → lemonade-onebit…tar.zst 37,145,508 B · 1bit-os-…img.zst 395,747,240 B · .efi 105,665,664 B · SHA256SUMS 323 B

(package_checks inside that stage passed: npu/kernels: 3 sets, 30 sealed kernels, 3 signed manifests.) The second run
is the same stage with ONEBIT_SEAL_PUB exported 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) on main. That needs this merged first,
because the wrapper copies main's weekly.sh; the plan is to run it immediately after the squash-merge and record
pass/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.

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.
@bong-water-water-bong
bong-water-water-bong merged commit c93f9e2 into main Oct 30, 2026
7 of 8 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/weekly-sign-sealed-sets branch October 30, 2026 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant