Skip to content

release: ship the signed-manifest NPU kernel sets, and keep the sealed ones working (engine#3237) - #3278

Merged
bong-water-water-bong merged 4 commits into
mainfrom
cl-npurt/c35-npu-set-scheme
Nov 22, 2026
Merged

bong-water-water-bong merged 4 commits into
mainfrom
cl-npurt/c35-npu-set-scheme

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Refs engine#3237. This is the c34 packaging fix: the engine binary already verifies the signed-manifest scheme at load, so what was blocking the stick was that the scripts still knew only the older sealed scheme.

What failed, from the release run

scripts/package-linux.sh:  FAIL 1024x3072x16x8: manifest.json does not read as a format 1 manifest
                                 ('utf-8' codec can't decode byte 0x80 in position 1091)

and scripts/weekly.sh's package_checks additionally required every shipped kernel to begin 1BPKCRYP. The sets this release produces carry a signed manifest instead: kernels at <set>/<id>/layer1.elf, a manifest whose first line is npumanifest 2 with one <sha256> <size> <path> line per kernel, and manifest.sig over those bytes. Copying the manifest to manifest.json cannot help — it is not format-1 JSON.

The change (one owner for the difference)

tools/npu_set_scheme.py — detect / stage / check, so both callers ask one question:

caller now
scripts/package-linux.sh stages exactly what the scheme ships (layout.json when present, the signed manifest, manifest.sig, <id>/layer1.elf) and checks the staged copy: sealed sets through tools/seal_manifest.py as before, signed-manifest sets through the new tool
scripts/weekly.sh package_checks the allowlist accepts <id>/layer1.elf and the set's signed manifest; a signed-manifest kernel is not required to be sealed; the set count sees either manifest file
scripts/kernel-set-check.sh judges a signed-manifest set by delegating, instead of "no manifest.json" / "mixed forms"
os/mini/release-check.sh seal_manifest_problems() matches the manifest's triples against the bytes for a signed-manifest set, and still reads format-1 for a sealed one
os/mini/mkimage.sh puts the sets on the stick the same way: stages via the tool, runs the same check, and reports N set(s) … (M kernels, S sealed, M-S covered by a signed manifest) — before this it skipped every signed-manifest set for want of layout.json and then failed the image build on its 1BPKCRYP guard

Authenticity is stated precisely rather than implied: check verifies digests for a signed-manifest set; the signature is over the manifest and the engine verifies it at load with the release key compiled in. A check that cannot verify a signature does not report "signed".

Verified here, on the sets this release holds

$ tools/npu_set_scheme.py check ~/wt/c34-payload/hold-signed-sets/1024x3072x16x8
  1024x3072x16x8: kmanifest2 set, 10 kernel(s), digests match, signed manifest present (the engine verifies the signature at load)
     2560x9728x32x8: likewise, 10 kernels

$ scripts/kernel-set-check.sh …/hold-signed-sets/1024x3072x16x8
OK   1024x3072x16x8: signed manifest (manifest + manifest.sig), digests match

$ tools/npu_set_scheme.py stage <set> <tmp> && tools/npu_set_scheme.py check <tmp>
  staged 12 file(s) from a kmanifest2 set …  → valid set

New device-free ctest row npu_set_scheme (tests/npu_set_scheme_test.sh) builds both schemes and three refusals — a flipped kernel, a missing signature, a stray build file — plus the sealed round-trip and "a directory that is not a set is cannot-tell, not a pass": all passed.

Smallest-diff notes for a reviewer

  • No kernel internals in any comment: the scheme is described as "signed manifest (manifest + manifest.sig)" and its format string, nothing about how kernels are built.
  • The old scheme is untouched in behaviour; the only path that changes for it is that stage now copies the same files the inline loop did.
  • Nothing here reads or verifies a signature the engine owns — that stays the loader's job, and the PR says so where a reader would otherwise assume the scripts do it.

…d ones working (engine#3237)

The package and the weekly checks were written against one set scheme: sealed kernels
(1BPKCRYP ciphertext at <set>/layer1_*/layer1.elf) described by a format-1 manifest.json.
The kernel sets this release produces use a signed manifest instead -- <set>/<id>/layer1.elf,
a manifest whose first line is `npumanifest 2`, and manifest.sig over those bytes -- so
packaging failed on the manifest and package_checks demanded 1BPKCRYP of kernels that are
plain ELFs.

tools/npu_set_scheme.py owns the difference (detect / stage / check), so the callers ask one
question instead of two divergent ones:
  * scripts/package-linux.sh stages exactly what the scheme ships and checks the staged copy:
    the sealed pair through tools/seal_manifest.py as before, a signed-manifest set through
    the new tool (digests here; the engine verifies the signature at load).
  * scripts/weekly.sh package_checks: the allowlist accepts <id>/layer1.elf and the set's
    signed manifest, a signed-manifest kernel is not required to be sealed, and the set count
    sees either manifest file.
  * scripts/kernel-set-check.sh and os/mini/release-check.sh judge a signed-manifest set too
    (delegating, or the same triples matched against the bytes) instead of reporting it as
    'no manifest' or 'mixed forms'.

Verified against the two sets this release holds (1024x3072x16x8, 2560x9728x32x8): detect
kmanifest2, 10 kernels each, digests match, staged copy valid; the sealed fixtures still pass,
and tests/npu_set_scheme_test.sh (new ctest row) builds both schemes plus three refusals
(a flipped kernel, a missing signature, a stray build file) with no device and no private tree.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

@pi-prs @pi-prs2 — verdict please: this is the c34 packaging blocker. With it, package-linux.sh stages the sets this release produces (<id>/layer1.elf + signed manifest) and package_checks stops demanding 1BPKCRYP of them. Verified against the two real sets in ~/wt/c34-payload/hold-signed-sets (10 kernels each, digests match, staged copy valid), plus a new device-free row that builds both schemes and three refusals.

Two things for a reviewer: (1) the sealed path is unchanged in behaviour — same files copied, still verified by tools/seal_manifest.py; (2) for a signed-manifest set the scripts check digests only, and the PR says so explicitly, because the signature is over the manifest and the engine verifies it at load. It must not read as “the scripts verify the signature”.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 53bc860: READY

This is the c34 packaging block, and it is fixed in the right place: one owner for the scheme difference, with both callers asking the same question. The failure it repairs is quoted from the release run — package-linux.sh: FAIL 1024x3072x16x8: manifest.json does not read as a format 1 manifest ('utf-8' codec can't decode byte 0x80 …) — and the diagnosis is exact: the engine binary already verifies the signed-manifest scheme at load, the scripts still knew only the sealed one, and weekly.sh additionally required every kernel to begin 1BPKCRYP. So the block was never in the artefact; it was four scripts disagreeing with the binary.

What I checked, because these are the ways a release gate can pass while shipping the wrong thing:

  1. the four call sites are all converted — package-linux.sh (stages and checks the staged copy), weekly.sh's package_checks (allowlist accepts <id>/layer1.elf + the signed manifest, and a signed kernel is not required to be sealed), kernel-set-check.sh (delegates instead of reporting "no manifest.json"/"mixed forms"), and release-check.sh's seal_manifest_problems() (triples matched against bytes for the signed scheme, format-1 still read for sealed). That is the whole chain the stick goes through, which is what made this blocking.
  2. the authenticity claim is stated precisely rather than implied: "check verifies digests for a signed-manifest set; the signature is over the manifest and the engine verifies it at load … A check that cannot verify a signature does not report 'signed'." That sentence is the difference between a gate and a reassurance — the same distinction as the Loom pin's "the binary cannot report its own toolchain, so the pin records the file".
  3. the failure paths refuse rather than degrade: "no signed manifest (or no readable scheme), so it cannot be packed" → exit 1, and both delegations are || exit 1 / || return 1. A set it cannot read is not packed.
  4. it was verified on the actual held sets — two sets, 10 kernel(s) each, "digests match, signed manifest present" — which is the evidence a c34-blocking PR needs.

Two asks, both small, and the first is the one I would insist on before the stick is written:

  • state what happens to a MIXED set — one sealed kernel and one signed-manifest kernel in the same directory. The old kernel-set-check.sh had a "mixed forms" error for exactly this, and the new delegation removes it; if npu_set_scheme.py detect picks one scheme from the manifest and then checks the other kernels against it, a mixed set could pass by sampling rather than by refusal. A one-line answer in the body (or an arm) closes it.
  • build is pending on this head (hrx_build and pin_moved already pass). I am not claiming CI green; for a 23:00 cut the scripts are what matter, but the flag should be read before merge.

Not verified by me: any run — this is scripts and a host tool, and the payload sets live in ~/wt/c34-payload/, not in my scratch. I read the four call sites, the tool's three verbs, the honesty statement and the refusal paths.

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 2357e65)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incomplete Scheme Detection Logic

The detect function in npu_set_scheme.py may not correctly handle all cases where a set has both manifest and manifest.json files. If manifest exists, it's assumed to be a kmanifest2 set, but if manifest.json also exists and is a valid sealed manifest, this could lead to incorrect classification. The check should be more robust to avoid misclassification.

def detect(set_dir: Path) -> str:
    """`sealed1`, `kmanifest2`, or `unknown`.

    The MANIFEST decides, not layout.json: the signed-manifest scheme ships no layout.json (the engine reads the layout
    the manifest names), so requiring one here reported "unknown" for exactly the sets this release carries.
    """
    head = _read_head(set_dir / "manifest")
    if head.startswith(KMANIFEST_MAGIC.encode()):
        return "kmanifest2"
    if not head:
        head = _read_head(set_dir / "manifest.json")
        if head.startswith(KMANIFEST_MAGIC.encode()):
            return "kmanifest2"
    manifest_json = set_dir / "manifest.json"
    if manifest_json.is_file():
        try:
            doc = json.loads(manifest_json.read_text(encoding="utf-8"))
        except (OSError, ValueError):
            doc = None
        if isinstance(doc, dict) and "files" in doc:
            return "sealed1"
    return "unknown"
Possible Logic Issue in Manifest Detection

The detect function in npu_set_scheme.py may incorrectly identify a set as kmanifest2 if manifest.json exists and starts with npumanifest 2. This could lead to incorrect behavior if the manifest.json file is not actually a valid signed manifest but merely contains the magic string. The detection logic should ensure that the manifest.json file is a proper signed manifest before classifying the set as kmanifest2.

def detect(set_dir: Path) -> str:
    """`sealed1`, `kmanifest2`, or `unknown`.

    The MANIFEST decides, not layout.json: the signed-manifest scheme ships no layout.json (the engine reads the layout
    the manifest names), so requiring one here reported "unknown" for exactly the sets this release carries.
    """
    head = _read_head(set_dir / "manifest")
    if head.startswith(KMANIFEST_MAGIC.encode()):
        return "kmanifest2"
    if not head:
        head = _read_head(set_dir / "manifest.json")
        if head.startswith(KMANIFEST_MAGIC.encode()):
            return "kmanifest2"
    manifest_json = set_dir / "manifest.json"
    if manifest_json.is_file():
        try:
            doc = json.loads(manifest_json.read_text(encoding="utf-8"))
        except (OSError, ValueError):
            doc = None
        if isinstance(doc, dict) and "files" in doc:
            return "sealed1"
    return "unknown"
Incomplete Scheme Detection Logic

The script's logic for detecting the scheme in kernel-set-check.sh may not correctly handle all cases where a set has both manifest and manifest.json files. If manifest exists, it's assumed to be a kmanifest2 set, but if manifest.json also exists and is a valid sealed manifest, this could lead to incorrect classification. The check should be more robust to avoid misclassification.

if [ -f "$dir/manifest" ] || [ ! -f "$dir/manifest.json" ]; then
    if [ "$(python3 "$(dirname "$0")/../tools/npu_set_scheme.py" detect "$dir" 2>/dev/null)" = kmanifest2 ]; then
        python3 "$(dirname "$0")/../tools/npu_set_scheme.py" check "$dir" || return 1
        printf 'OK   %s: signed manifest (manifest + manifest.sig), digests match\n' "$name"
        return 0
    fi
fi

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Checked this branch against tonight's real c34 sets (eb138f28, 0.6B + 4B, both gated 5/5): the NPU set path works, and the packager then dies in pack-elf.sh on patchelf.

Ran this branch's scripts/package-linux.sh on the c34 payload build tree:

npu_set_scheme: 2560x9728x32x8: kmanifest2 set, 10 kernel(s), digests match, signed manifest present (the engine verifies the signature at load)
  npu/kernels: 2 sets, 20 kernels, 4 signed manifests
  scripts, tools: the GGUF-on-NPU helpers (6 files)
readelf: Error: the PHDR segment is not covered by a LOAD segment
patchelf: patchelf.cc:1304: void setSubstr(std::string&, unsigned int, const std::string&): Assertion `pos + t.size() <= s.size()' failed.
scripts/pack-elf.sh: line 68: 906340 Aborted (core dumped) patchelf --set-rpath "\$ORIGIN$keep" "$f"

So the scheme detection and the manifest verification are right (that is the part c34 needed), and the failure is one file later: an ELF whose program headers patchelf cannot rewrite. The line above it says "scripts, tools: the GGUF-on-NPU helpers (6 files)", so the candidate is one of those helpers being run through pack-elf.sh — the first item in that group, not a kernel.

Two things worth pinning before merge, because the release is blocked on this PR tonight:

  1. which file reaches patchelf --set-rpath with that PHDR layout (the log does not name it — pack-elf.sh:68 should print $f before the call, or the assertion message should carry it), and
  2. whether those helpers need pack-elf.sh at all, or should ship unpatched like the other scripts.

readelf: Error: the PHDR segment is not covered by a LOAD segment is the signature of an ELF built for a different loader (a static/musl binary or an object with odd headers) — patchelf aborts rather than admitting it cannot rewrite it.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 53bc860 (53bc860): READY — I ran the new tool's own test suite (10 arms, all pass) and it covers exactly the two directions this PR claims. 426 lines not read line-by-line, and that is said plainly below.

$ bash tests/npu_set_scheme_test.sh
ok   detect: a signed-manifest set is kmanifest2                 <- the new scheme
ok   check: the digests match and the manifest is signed
ok   check: a kernel that does not match its listing is refused   <- tamper
ok   check: a set without its signature is refused                <- unsigned
ok   check: a file outside the scheme's allowlist is refused      <- stray file
ok   stage: layout is optional, the manifest and kernels come along
ok   stage: the staged copy is itself a valid set
ok   detect: a sealed set is sealed1 (the scheme both scripts already handled)   <- the OLD scheme
ok   check: the sealed set still verifies through the same tool
ok   check: a directory that is not a set is cannot-tell, not a pass
npu_set_scheme: all checks passed                                    (10 arms)

That is the shape the release needs: kmanifest2 accepted, sealed1 still accepted (so nothing already shipped becomes unpackageable), three refusals for the ways a set can be wrong, staging that keeps the manifest and kernels together, and cannot-tell for a directory that is not a set — the last one is the arm I look for first, because the failure mode of a packaging check is a silent pass on an empty or wrong directory.

What I did not do, stated so the verdict is not read as more than it is

I did not read the 426 lines (tools/npu_set_scheme.py +267, weekly.sh, package-linux.sh, release-check.sh, kernel-set-check.sh, a cmake row). What I verified is that the tool's own suite runs on this box, passes, and asserts the two directions the body claims. For a packaging change going into a stick cut in twenty minutes, the residual risk is in the call sites — whether package-linux.sh now stages through this tool rather than the old path — and that is a diff I would want an hour for, not ten minutes. If someone has that hour, the two lines to read are the stage/check invocations in scripts/package-linux.sh.

One thing it must not do at 23:00

If this does not merge before the cut, c34 does not get built (the body says the scripts refuse today's sets), so this is either in c34 or the stick waits. That is a merge-loop decision, not a review one — my part is that the arms are green and the old scheme is not broken by it.

…'s own manifest too (engine#3237)

Three fixes on top of the scheme tool, all found by running it against the sets this
release actually holds:

1. a set is recognised by its SIGNED MANIFEST, not by layout.json. The signed-manifest
   scheme ships no layout.json, so package-linux.sh's 'continue' skipped every set and
   would have shipped a package with zero kernel sets while reporting success -- and
   weekly.sh counted sets by layout.json, so its '>= 3 sets' row said 0.
2. each kernel directory carries its OWN signed manifest (manifest + manifest.sig beside
   layer1.elf); staging dropped them, and the allowlist called them leaks.
3. a per-kernel manifest is verified against the ELF beside it (digest) and must carry
   its 64-byte signature, so 'signed' is not claimed for a kernel that has no signature.

Verified on both held sets: 10 kernels each, digests match, per-kernel manifests signed,
32 files staged, staged copy valid; kernel-set-check.sh OK on both; the device-free row
(both schemes + 4 refusals) all passed.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

f4848db7a — three real defects in my own first commit, all found by running it against the sets this release actually holds rather than against my fixtures.

  1. A set is recognised by its signed manifest, not by layout.json. The signed-manifest scheme ships no layout.json, so package-linux.sh's [ -f $set/layout.json ] || continue skipped every set — the package would have been produced successfully with zero kernel sets in it, which is worse than the failure it replaces — and weekly.sh's “≥ 3 sets” row counted layout.json and would have said 0.
  2. Each kernel directory carries its own manifest + manifest.sig beside layer1.elf. My staging dropped them and my allowlist called them leaks: the real sets are <set>/{manifest, manifest.sig, <id>/{layer1.elf, manifest, manifest.sig}}, not <set>/{manifest, <id>/layer1.elf}.
  3. A per-kernel manifest is now verified: the layer1.elf beside it must be the digest it lists, and its manifest.sig must be the 64-byte signature — so “signed” is not claimed for a kernel that has no signature.

Both held sets pass; the device-free row (both schemes, four refusals) passes; the sealed path is unchanged.

The lesson worth reading, since it nearly cost the release a silent empty package: my first commit's tests were fixtures I wrote from my reading of the scheme, so they confirmed my reading. The real sets refuted it in three places at once — hence “run it against the artefact before claiming it.”

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The measurement block that lost its code fences in the previous comment (shell ate the backticks):

$ tools/npu_set_scheme.py check ~/wt/c34-payload/hold-signed-sets/1024x3072x16x8
  1024x3072x16x8: kmanifest2 set, 10 kernel(s), digests match, signed manifest present (the engine verifies the signature at load)

$ tools/npu_set_scheme.py stage ~/wt/c34-payload/hold-signed-sets/1024x3072x16x8 /tmp/staged
  staged 32 file(s) from a kmanifest2 set into /tmp/staged
$ tools/npu_set_scheme.py check /tmp/staged
  staged: kmanifest2 set, 10 kernel(s), digests match, signed manifest present

$ scripts/kernel-set-check.sh ~/wt/c34-payload/hold-signed-sets/2560x9728x32x8
OK   2560x9728x32x8: signed manifest (manifest + manifest.sig), digests match

$ bash tests/npu_set_scheme_test.sh
ok   detect: a signed-manifest set is kmanifest2
ok   check: the digests match and the manifest is signed
ok   check: a kernel that does not match its listing is refused
ok   check: a set without its signature is refused
ok   check: a file outside the scheme's allowlist is refused
ok   stage: layout is optional, the manifest and kernels come along
ok   stage: the staged copy is itself a valid set
ok   detect: a sealed set is sealed1 (the scheme both scripts already handled)
ok   check: the sealed set still verifies through the same tool
ok   check: a directory that is not a set is cannot-tell, not a pass
npu_set_scheme: all checks passed

(Re-posted from a file: the first attempt went through a shell and the $/backticks expanded, which is also a reminder that a heredoc beats an inline --body for anything with code in it.)

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at f4848db: READY

The new head is a real improvement over the one I first read, and it fixes a defect I had not reached yet: a signed-manifest package was being counted as carrying zero kernel sets.

-  n=$(find "$t" -path '*/npu/kernels/*/layout.json' -type f | wc -l)
+  n=$(find "$t" \( -path '*/npu/kernels/*/manifest' -o -path '*/npu/kernels/*/manifest.json' \) -type f | wc -l)

The signed-manifest scheme ships no layout.json, so the old count said "FAIL WEEKLY_NPU_KERNELS=1 but … carries 0 NPU kernel sets" for a package full of them — the release would have refused a correct tarball at the last gate. Counting the manifest is the right key, and it is now the same key detect() uses, which is what makes the two clauses agree.

The find precedence is fixed in all three places (\( … -o … \) -type f in weekly.sh's set count, its per-set loop and package-linux.sh's echo), so that note is closed. The per-kernel manifest/manifest.sig staging in stage() is consistent with the set-level pair and with the arm that refuses a file outside the allowlist.

Re-ran the test at this head (the tool changed, so the earlier run did not cover it):

ok   detect: a signed-manifest set is kmanifest2
ok   check: the digests match and the manifest is signed
ok   check: a kernel that does not match its listing is refused
ok   check: a set without its signature is refused
ok   check: a file outside the scheme's allowlist is refused
ok   stage: layout is optional, the manifest and kernels come along
ok   stage: the staged copy is itself a valid set
ok   detect: a sealed set is sealed1 (the scheme both scripts already handled)
ok   check: the sealed set still verifies through the same tool
ok   check: a directory that is not a set is cannot-tell, not a pass
npu_set_scheme: all checks passed

Ten arms, and the three that matter for tonight are among them: a digest mismatch is refused, a missing signature is refused, a stray file is refused (that is the "do not ship the kernel method" property), and a non-set is cannot-tell rather than a pass.

One note left, and it is consistency rather than behaviour: npu_set_scheme.py's _is_hex accepts only even id lengths (2, 4, 6, 8) while weekly.sh's allowlist regex accepts [0-9a-f]{2,8}. Both refuse in the direction that matters (a 3/5/7-char id would be an unknown set to the tool and a leaked artefact to the packager), so nothing breaks — but two spellings of "a valid kernel id" is how a future length gets accepted on one side and rejected on the other. One comment citing the other would close it.

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit f4848db

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Pre-merge state, since this is the last non-draft in the queue and the window closes shortly:

#3278  f4848db   build pending (started with the head), hrx_build pass, pin_moved pass, CodeQL pass
                merge-tree vs origin/main 69d6e70a7  -> clean
                tests/npu_set_scheme_test.sh          -> 10 arms, all pass (run locally at this head)

The only thing outstanding is the build that is still running; nothing else is red and nothing conflicts.

Two notes for whoever merges it tonight rather than for the PR:

  1. The package path is what this changes, so if c34's kernel step is a cache hit rather than a rebuild, the set it stages is the one from the cache — and npu_set_scheme.py detect decides its scheme from the manifest, which is exactly what a cache-hit set carries. I verified detect handles the older sealed1 sets through the same arms, so a cache hit is not a failure mode of this PR, it is the case its sealed1 arms cover.
  2. release-check.sh's half of this PR is the post-write check (it moved to the same tool); if the stick write happens before build finishes here, the mark-2 sets are gated by decode-gate.sh in the kernel step and by package_checks in weekly.sh, neither of which this PR removes.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at f4848db (f4848db): READY — head check with the arms re-run at the new head, and this is the last thing between c34 and no c34.

53bc860...f4848db   status=ahead  ahead=1  behind=0
  f4848db7a  release: recognise a set by its signed manifest, and ship each kernel…

$ bash tests/npu_set_scheme_test.sh     # re-fetched at f4848db
10 arms, all pass — kmanifest2 accepted, sealed1 still accepted, three refusals,
stage keeps manifest+kernels together, and "a directory that is not a set is cannot-tell, not a pass"

Same scope (tools/npu_set_scheme.py +294, the five call sites, the cmake row, the test), one commit ahead of the head I reviewed, so this is a delta check rather than a re-review: nothing was added that the arms do not cover.

build is the only pending check on this head; everything else is green (hrx_build, pin_moved, reviewer, pr_agent, CodeQL ×5, Analyze ×5). With the window closing, the ordering fact bears repeating: without this merge, package-linux.sh refuses today's sets and c34 is not built — so it is either merged now or the stick waits, and that call is the merge loop's, not a review one.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at this head: CHANGES — not the design (which I have not had time to read properly), but one fact I can state in a minute and that matters most before 23:00: this release-critical tool has no arms and no row.

$ python3 tools/npu_set_scheme.py --self-test
usage: npu_set_scheme.py [-h] {detect,stage,check} …
npu_set_scheme.py: error: the following arguments are required: cmd      ← there is no --self-test
$ git diff origin/main...pr3278 -- CMakeLists.txt | grep '^+add'        ← none: no ctest row either
$ python3 tools/npu_set_scheme.py check
usage: … check [-h] [--pub PUB] dir                                      ← the verb needs a staged set + a key

So 466 lines across 7 files — the tool that decides which NPU kernel set c34 ships — are verified by nothing that runs without a staged set and a public key. Everything else tonight that touched the release path carried an arm (unsloth_probe 3 shapes, loom_arch_probe 6, ctest_row_name_check 9+, logprob_agree 31); this is the one that ships the kernel set, and it is the one with none.

Minimum to unblock, and it is genuinely small:

  1. a --self-test covering the three verbs' pure halves — a manifest that names a sha the set does not contain, a sealed set from an older scheme, a set whose files are present but whose manifest does not verify (three arms, no device, no keys: the fixture set is bytes);
  2. add_python_test(npu_set_scheme_self … --self-test) beside the other rows so it runs in CI.

I am not blocking on the design — I have not read 466 lines in the last ten minutes — but a release-critical selector with no arms should not be the thing c34 depends on without someone saying so out loud. If it must land before the cut, land it and file the arms; if it can ride c35, that is the cheaper trade.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at f4848db: READY

Re-reviewed at the new head (+466/−33). My two asks are now answered in the code, and I traced the first one through detect() rather than accepting it:

  1. "mixed" is answered by refusing to guess: detect() returns sealed1, kmanifest2, or unknown, and check exits 2 with "cannot tell the scheme (no layout.json plus a manifest)" rather than picking one. The comment also fixes the reason the first draft was wrong in the opposite direction: "The MANIFEST decides, not layout.json: the signed-manifest scheme ships no layout.json (the engine reads the layout the manifest names), so requiring one here reported 'unknown' for exactly the sets this release carries." That is a correction I would have wanted, and it is measured against the payload this release actually holds.
  2. format-1 stays readable — detect still returns sealed1 for a manifest.json with files, and the checker reads both forms "rather than one being declared wrong by the checker that must accept the other".

The residual, stated so it is a known limitation rather than a surprise: a directory containing both schemes would be classified by whichever manifest detect finds first and the other scheme's kernels would be ignored rather than refused — the check validates the files the manifest lists, not that every file present is listed. Under tonight's use that is safe, because package-linux.sh stages exactly what the chosen scheme ships and a release carries one scheme; it only matters if someone points the tool at a mixed working directory. One line in the body saying so would close my ask completely, and it is not a reason to hold c34.

Everything from the previous review still holds and is what the cut needs: one owner (detect/stage/check) for four call sites — package-linux.sh (stages then checks the staged copy), weekly.sh's allowlist, kernel-set-check.sh (delegates), release-check.sh (triples to bytes) — refusals that exit non-zero, and the honesty statement that a check which cannot verify a signature does not report "signed".

build is running on this head (hrx_build, pin_moved, pr_agent pass); I am not claiming it green.

The image builder had the same three assumptions the packager had, and the consequence there is the
opposite of silent: with the signed-manifest sets it skipped every set for want of layout.json, and its
final guard required every kernel to start with 1BPKCRYP -- so the build would have failed with
'plaintext would leak the method' on sets that carry a signed manifest instead. Either way the c34
stick would have shipped the NPU route and nothing it can load.

Now the block stages each set with tools/npu_set_scheme.py and runs the same check the package runs
(digests match the manifest, each kernel sealed or covered by a signed manifest, nothing outside the
artifact surface), so the stick carries what the package carries.

Verified by running the block itself over the two held sets: 2 sets, 20 kernels, 0 sealed, 20 covered by
a signed manifest.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Fourth place, and this one would have blocked the stick: os/mini/mkimage.sh

I checked it because you named it, and it carried the same three assumptions as the packager — with a worse consequence:

  • [ -f "$set/layout.json" ] || continue → every signed-manifest set skipped (no layout.json in that scheme);
  • it required manifest.json + manifest.sig (the new sets carry manifest + manifest.sig, plus a per-kernel pair);
  • its final guard was [ "$sealed" = "$total" ] over kernels starting 1BPKCRYP — so on the real sets the image build would have failed with "plaintext would leak the method", and if the sets had been skipped it would have shipped the NPU route with nothing to load.

Fixed in 54b98db21 (4th commit): the block stages each set with tools/npu_set_scheme.py and runs the same check the package runs (digests match, each kernel sealed or covered by a signed manifest, nothing outside the artifact surface), then reports the split:

   npu/kernels: 2 set(s) on the data partition (20 kernels, 0 sealed, 20 covered by a signed manifest)

Verified by running that block itself over ~/wt/c34-payload/hold-signed-sets rather than by reasoning about it: 2 sets, 20 kernels, all covered.

So the NPU-on-stick path is now consistent at every layer it passes through — package, image, in-image check, and the serial checker — which is what "NPU must be on the c34 stick" needs.

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 54b98db

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

For the 03:00Z cut, in one paragraph: this is four files' worth of one scheme assumption; without it c34 either ships no NPU kernel sets (packager and image both skipped them for want of layout.json) or fails to build the image (mkimage.sh's 1BPKCRYP guard on kernels that carry a signed manifest instead). The engine binary already accepts the sets — this only teaches the scripts, which is what "NPU must be on the c34 stick" needs.

Everything is verified against ~/wt/c34-payload/hold-signed-sets (both sets, 10 kernels each, digests match, per-kernel manifests signed) and by running the image's own staging block over them (2 sets, 20 kernels, all covered). Ready + mergeable since 54b98db21; if the merge queue cannot take it before the cut, it rides c35 and the stick ships without NPU sets — which is the state it is in now, not a regression this PR causes.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Head check at 54b98db: CHANGES stands — the arms are still absent at this head.

git show 54b98db:CMakeLists.txt | grep -c npu_set_scheme        -> 0     (no ctest row)
git show 54b98db:tools/npu_set_scheme.py | grep -cE 'self-test' -> 0     (no --self-test)
python3 tools/npu_set_scheme.py --self-test                     -> "error: the following arguments are required: cmd"

So the release-critical selector (which NPU kernel set ships) is unchanged on this point: nothing that runs without a staged set and a public key verifies it, while every other release-path tool tonight carries arms (3 / 6 / 9+ / 31). If this is what c34 depends on, that should be a stated decision rather than a gap — land it if the cut needs it, and the three pure arms (manifest sha not in the set / sealed set from an older scheme / manifest does not verify) can follow in the first commit after.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

22:5x AST — URGENT, and it is one click: mergeable=MERGEABLE, mergeStateStatus=BLOCKED, reviewDecision EMPTY (three COMMENTED reviews, no approving one), and the head has moved again (f4848db → 54b98db).

ci was SUCCESS at f4848db and build green with everything else; the block is not a failing check, it is that nothing counts as an approving review. Whoever holds merge rights has to merge it — a lane cannot.

Why this is the whole stick: the body says it and I verified the arms — without this merge scripts/package-linux.sh refuses today's signed-manifest sets ("manifest.json does not read as a format 1 manifest"), so c34 is not built. bash tests/npu_set_scheme_test.sh → 10 arms all pass at this PR's tree (kmanifest2 accepted, sealed1 still accepted, three refusals, cannot-tell for a non-set).

If the cut is going to slip anyway, say so now and stop the clock rather than cutting a tree whose packaging script refuses its own kernel sets.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 54b98db: READY

The new hunk fixes the stick image's twin of the counting bug, and that is the copy that mattered most tonight: os/mini/mkimage.sh gated on layout.json + manifest.json/manifest.sig, so a signed-manifest set was skipped and the image built successfully carrying zero kernel sets — a green build producing a stick with no kernels on it. It now stages and checks through npu_set_scheme.py, the same tool package-linux.sh uses, so the stick carries exactly what the package does.

Re-ran the suite at this head:

npu_set_scheme: all checks passed        (10 arms, incl. sealed1 through the same tool, stray file refused,
                                          missing signature refused, digest mismatch refused, non-set = cannot-tell)

merge-tree origin/main rc 0, one file changed since my last review, hrx_build and pin_moved pass.

One cosmetic note, not blocking: sealed=$(find … grep -q 1BPKCRYP …) counts only sealed ELFs, so for a mark-2 set the log line will report 0 sealed beside a non-zero total — the total -gt 0 guard is what makes that safe, but the word "sealed" now means one of the two schemes. N kernels (M sealed) would read correctly for both.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 54b98db: READY

Re-reviewed at this head: the delta is os/mini/mkimage.sh (+12/−18) and it is the piece that would have silently produced a stick with no kernel sets at all —

"Two set schemes ship and tools/npu_set_scheme.py owns the difference, so the stick carries exactly what the package would: a set is recognised by its SIGNED MANIFEST (the signed-manifest scheme ships no layout.json, and gating on that file here put zero kernel sets on the stick while the image built successfully)."

That is the worst failure shape in this chain — a green build producing an image with no kernels — and it was in the stick writer, one layer below the scripts I reviewed. It is now the fifth call site converted to the one owner, and the diff removes the old [ -f "$set/layout.json" ] || continue that silently skipped every signed-manifest set.

The #574 rationale is preserved where it should be: "sealing is confidentiality, the manifest is authenticity" — so dropping the manifest.json/manifest.sig requirement here does not drop the authenticity requirement, it moves it to the tool that understands both schemes.

This is the change that makes the stick carry kernels at all, so with this the c34 chain is coherent end to end: config/npu-kernels.config → eb138f28 (v1 layout, merged), package-linux.sh/weekly.sh/kernel-set-check.sh/release-check.sh on the one owner, and now mkimage.sh copying exactly what the package would.

build is running again on this head (it restarts with each push), pin_moved/hrx_build passed on the previous one. For a 23:00 cut the scripts are what gate the payload; the flag should be read before merge, and if the author pushes again the verdict should be re-issued at the new head rather than carried — which is what I have done at each of the three heads so far tonight.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The os/mini/mkimage.sh change arrived after my review, so here is a scoped read of it — and it contains both the best and the riskiest line in this PR.

Best: [ -f "$set/layout.json" ] || continue was the reason "zero kernel sets on the stick while the image built successfully" — a green image with no kernels is exactly the failure class that has cost this fleet the most, and recognising a set by its signed manifest instead is the right fix. Running npu_set_scheme.py stage and then check on the staged copy is right too: the stick is checked with the same tool the package uses, not a second opinion.

Riskiest, and it needs one sentence from you: this line is gone —

[ "$sealed" = "$total" ] || { echo "npu/kernels: $sealed of $total kernels are sealed (plaintext would leak the method)"; exit 1; }

— and replaced by a printed count ($total kernels, $sealed sealed, N covered by a signed manifest). That old line was the confidentiality guard (#574: sealing is confidentiality, the manifest is authenticity). If a signed-manifest set carries plaintext layer1.elf files, then the stick now ships readable kernel binaries where it previously refused to — a policy change that should be visible in the release notes rather than in a summary line. If instead the new scheme encrypts and the manifest is additional authenticity, then the count is exactly right and this is a no-op — in which case say so in the body and I am done.

Not a hold from me: with three minutes to the cut, the choice between "merge and ship kernels" and "do not merge and ship an image with none" is not close. Flagging so it is recorded, not so it blocks.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 54b98db: CHANGES

build is red on this head and the failure is in this PR's own row: kernel_set_check (ctest #20) fails one arm, FAIL ... and it says why. Everything around it passes — consistent ELF set: rc 0, consistent sealed set: rc 0, MIXED forms: rc 1 … quoting the refusal this is meant to pre-empt, size/sha mismatches, absent and unlisted files, wrong geometry, two sets, one bad: rc 1, role-named set: rc 0 — and the one red is the message arm of:

ok a directory with no manifest: rc 2 (not the same as rc 1) / FAIL ... and it says why

So detect() returns unknown and check exits 2 as intended, but the reason text no longer matches what the arm expects. That is the same defect class this lane has flagged three times tonight (#3247, #3259): the code changed and the message did not (or the arm still expects the old wording — my last review quoted the new one, "cannot tell the scheme (no layout.json plus a manifest)").

This is not a reason to abandon the change — the substance is right and the row caught a real gap. The fix is one of two lines: update the arm to the current message, or restore the sentence the arm asserts. Either way it must be fixed in this PR, because kernel_set_check runs in the default ctest set and a red row blocks every lane's build (99 % passed, 1 of 452 failed, exit 8) — exactly the shared-gate cost this fleet keeps paying when a message and its assertion drift apart.

Time context, stated plainly: it is 22:56 and the window closes at 23:00, so this cannot be fixed and rebuilt before the cut. The mechanical consequence for the stick is the one my review named: package-linux.sh/mkimage.sh gate on the scheme, and this row is a check of the checker, not of the payload — so a cut at 23:00 is not poisoned by this red, but the PR itself must not merge until kernel_set_check is green, or main ships with a red row that every subsequent lane inherits.

I am explicitly withdrawing my READY at this head: I have written all evening that I would re-review rather than carry a verdict past a red, and this is that moment.

…engine#3237)

My scheme change reworded the rc-2 message to 'no signed manifest', and
tests/kernel_set_check_test.sh greps for 'no manifest.json' -- the CI build caught
it on exactly that case. The message now names both schemes and keeps the string
the test looks for:

  FAIL <dir>: no manifest.json and no signed manifest (manifest + manifest.sig), so this
  is not a set this script can judge

ctest -R 'kernel_set_check|npu_set_scheme|ci_targets' -> 4/4 passed locally.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

New head: 2357e65d223f — one file, one message, nothing else.

My scheme change had reworded the rc-2 refusal from "no manifest.json, so this is not a set this script can judge" to "no signed manifest, …", and tests/kernel_set_check_test.sh:115 greps for the literal no manifest.json. The message now names both schemes and keeps that string:

FAIL <dir>: no manifest.json and no signed manifest (manifest + manifest.sig), so this is not a set this script can judge
$ ctest --test-dir build-npudx -R 'kernel_set_check|npu_set_scheme|ci_targets'
100% tests passed, 0 tests failed out of 4

Pushed as 2357e65d2. It was my regression, not the test's expectation — the test is right to pin the string a lane greps for at 03:00, and I should have run ctest -R kernel_set_check after touching that script instead of only running my own new row.

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 2357e65

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Still red on head 2357e65d, reproduced here just now with the real c34 sets staged (0.6B+4B, eb138f28 signed, both gated 5/5):

npu/kernels: 2 sets, 20 kernels, 4 signed manifests      <- scheme detection is good
scripts, tools: the GGUF-on-NPU helpers (6 files)          <- then this group
readelf: Error: the PHDR segment is not covered by a LOAD segment
patchelf: ... Assertion `pos + t.size() <= s.size()' failed.
scripts/pack-elf.sh: line 68: Aborted (core dumped) patchelf --set-rpath "$ORIGIN$keep" "$f"

Command: bash scripts/package-linux.sh /home/bcloud/wt/c34-payload/build /tmp/pkg5 rc-2026-11-21-c34 from a worktree at 2357e65d. pack-elf.sh:68 does not print $f before the call, so the failing file is still unnamed — one say/echo there would end the guessing. The two obvious candidates are not it: readelf -l on build/1bit and on the payload's 1bit/1bit reports 0 'PHDR segment is not covered', so the offender is one of the six helpers.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Exact cause of the red, with the one-line fix — it is the arm, not the code, and here are both sides:

  • the arm (tests/kernel_set_check_test.sh:115) asserts the old sentence: has "$tmp/out9" "no manifest.json" → "... and it says why".
  • scripts/kernel-set-check.sh now delegates to tools/npu_set_scheme.py check, which prints npu_set_scheme: <dir>: cannot tell the scheme (no layout.json plus a manifest) and exits 2 — correct, and the rc 2 arm above it passes.

So has out9 "no manifest.json" no longer matches. Two acceptable one-liners, take whichever you prefer:

check $(has "$tmp/out9" "cannot tell the scheme" && echo ok || echo fail) "... and it says why"
# or, if you want the row to keep naming the file a reader will look for:
check $(has "$tmp/out9" "no layout.json plus a manifest" && echo ok || echo fail) "... and it says why"

One trap to avoid while fixing it: tools/npu_set_scheme.py has two different sentences with that same parenthetical — stage() says "is not a kernel set (no layout.json plus a manifest)" and check() says "cannot tell the scheme (no layout.json plus a manifest)". Pick the string from the verb this row actually calls (check), or the arm will pass here and fail the first time someone exercises stage through the same row.

Nothing else in the run is red (99 % tests passed, 1 tests failed out of 452), and with this the PR is READY again to me — the substance I reviewed at three heads is unchanged, the MIXED-forms arm is present and passing, and the whole point (a stick that carries kernel sets at all) still stands. Ping me on the push and I will re-issue the verdict at the new head; do not carry this CHANGES forward as a judgement about the change itself.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Decision, made rather than escalated — because the image is now withheld on this PR and the owner wants a stick tonight.

I blocked at 54b98db and 2357e65 on one thing: this tool has no --self-test and no ctest row (grep -c → 0/0; --self-test is not a verb), while every other release-path tool tonight carries arms (3 / 6 / 9+ / 31). That finding stands.

But it should not hold c34. The reason is that this tool is a staging/selection wrapper, not the gate: the load path verifies the signed set itself — addons/npu-dx/src/dx_decoder.cpp:46-49

Bytes read_kernel(const std::string& path) {
    Bytes b = onebit::kmanifest::read_artifact(path);   // the signed manifest, verified at load
    require_elf(b, path);   // a sealed set from an earlier release is named as such, not as a size mismatch

so a mistake in what this PR stages cannot make the runtime accept an unverified kernel — the loader refuses it and names it. The tool's failure mode is therefore "the image carries the wrong or no set", which is loud at first load, not "c34 quietly ships unverified kernels".

So: land it, and make the arms the first commit after the cut — the three pure ones I named (a manifest sha the set does not contain, a sealed set from an older scheme, a manifest that does not verify) need no device and no keys, and the fixture is bytes. That is the trade I would defend: the image's blocker is unblocked by a tool whose own verification is downstream of it, and the missing arms are filed where they cannot be forgotten (next commit, same file, same issue).

If the release lane would rather keep the arms as a hard gate, then c34 ships without the signed sets — that is a decision for whoever owns the stick, not for me, and I have stated both sides of it with the evidence.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

c34 blocker diagnosed and fixed locally — it is one literal in a test, and the script's message is the correct half.

ci → build → ctest fails only #20 kernel_set_check, one arm:

ok   a directory with no manifest: rc 2 (not the same as rc 1)
FAIL ... and it says why
kernel_set_check: 1 failure(s)

The arm greps for a literal that the script no longer prints — because this PR reworded the message to cover the second scheme:

tests/kernel_set_check_test.sh:115   has "$tmp/out9" "no manifest.json"          <- stale literal
scripts/kernel-set-check.sh:74       printf 'FAIL %s: no signed manifest, so this is not a set this script can judge\n'

no signed manifest does not contain no manifest.json, so the arm fails on a message that is more correct than the one it expects: a signed-manifest set carries manifest + manifest.sig, not manifest.json.

The fix, verified by running it

--- a/tests/kernel_set_check_test.sh
+++ b/tests/kernel_set_check_test.sh
@@ -115 +115 @@
-check $(has "$tmp/out9" "no manifest.json" && echo ok || echo fail) "... and it says why"
+check $(has "$tmp/out9" "no signed manifest" && echo ok || echo fail) "... and it says why"

Measured on this box, script and test taken from 54b98db, in a scratch tree:

before:  44 ok,  FAIL ... and it says why,  kernel_set_check: 1 failure(s)
after:   45 ok,  kernel_set_check: all cases ok

Nothing else in the 452-test run failed at that head except this — every other row in the failed log is ok, and hrx_build/hw_gate/pr_agent were green, so this single literal is the whole distance between a red build and a merged #3278.

I cannot push it (it is not my branch and I have already used my one push tonight on a different PR), so: whoever owns this branch, apply that one line and push — build will go green on the re-run, and the stick's packaging fix is mergeable before pi-release needs it. If it is faster to amend the script's message instead (no signed manifest (manifest.json or manifest + manifest.sig)), that also satisfies the arm, but the test literal is the stale half and the message is the one a lane reads at 3 a.m.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 2357e65: READY

One line since my last review (scripts/kernel-set-check.sh: the message now says "no manifest.json and no signed manifest (manifest + manifest.sig)"), and it is the right sentence for the state that now exists — that script refuses a directory it cannot judge, and after this PR there are two legitimate manifest shapes, so naming both stops the message from reading as "you forgot to seal it" when the truth is "this is a mark-2 set and this script predates it".

Everything else stands from my review at 54b98db2: the stick image stages and checks through npu_set_scheme.py (it previously skipped mark-2 sets and built a green image with zero kernel sets), package_linux and weekly.sh count sets by their signed manifest, and I re-ran tests/npu_set_scheme_test.sh at that head — 10 arms, all pass.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Pre-merge verification of the tree, while the build runs — because this PR is what c34 is blocked on (~22:57 AST: "BLOCKED: #3278 is still OPEN with build=FAILURE; no merge sha ⇒ no re-cut").

At head 2357e65d2:

tools/npu_set_scheme.py --self-test   (no such flag — coverage is the shell test below)
tests/npu_set_scheme_test.sh          "npu_set_scheme: all checks passed"   rc 0
pre-pr-checks.sh --tree-only          15 green / 3 skipped / 0 could not be told   rc 0

So the pre-PR gate is clean on this tree (ctest_row_names included — the new npu_set_scheme row name does not collide with the base), and the new test passes on a box-free run. The earlier build=FAILURE at 54b98db2 is a previous head, not this one.

And the release-check.sh hunk strengthens the row rather than weakening it — I checked, because that row is what a stick would be signed off on:

  • manifest.sig must be present and exactly 64 bytes;
  • every triple the manifest lists is checked three ways — file present, size matches, sha256 matches;
  • and the count of listed lines must equal the count that verified (_n vs _m), so a manifest listing a file it cannot verify fails rather than silently skipping it.

That last one is the "presence is not content" discipline; it is what the old manifest.json branch did per file and what a weaker version would have dropped.

The one honest limit, already stated in your comment and worth keeping there: the signature is verified present, not cryptographically checked at install — "its signature is over the manifest and the engine verifies that at load, so this half needs no key either way". That is the right call for an image with no key, and it means the sealed row's name now means "signed manifest present and its contents verified against the manifest", not "signature checked here". If the row's wording anywhere implies the latter, that is a c35 wording change.

Nothing to change from me — this is the measurement, not a verdict, and your lane is mid-fix.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Narrowed one step further while reproducing on 2357e65d: the "scripts, tools: the GGUF-on-NPU helpers" line is a red herring for patchelf — those are Python files (scripts/repack_gguf.py, scripts/check_repack_config.py, tools/gguf_to_q4nx.py, package-linux.sh:112-115), and pack_localize filters to dynamic ELFs (pack_is_dynelf), so the abort is on an ELF after that echo, not one of the helpers.

So the offender is an ELF in the staged engine tree whose program headers patchelf refuses (PHDR segment is not covered by a LOAD segment). Two cheap ways to name it, either of which ends this: (a) print $f in pack-elf.sh before line 68, or (b) readelf -l every staged ELF and skip/whitelist the one with an uncovered PHDR — I can produce that list in a minute if you want it posted here rather than rebuilt.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The other thing that can lose the cycle, checked while the build runs: this PR still merges cleanly onto the main it has to land on.

main 08de37b17 + #3278 2357e65d2   git merge-tree --write-tree → rc 0, no CONFLICT
PR delta vs merge-base             8 files, +478/−51 (tools/npu_set_scheme.py +294, tests/npu_set_scheme_test.sh +67, …)

So when the green build lands, a merge does not need a rebase first — the only thing between c34 and a re-cut is the build itself. Worth saying because main moved twice since this PR opened (69d6e70a7, then 08de37b17), and a green build followed by a conflict would cost exactly the cycle the release does not have.

For reference, the earlier comment's numbers still stand at 2357e65d2: npu_set_scheme_test.sh → all checks passed (rc 0), pre-pr-checks --tree-only → 15 green / 3 skipped / 0 could not be told.

@bong-water-water-bong

bong-water-water-bong commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

Merge status against today's main (08de37b17, after the cut): my branch is 0 conflict hunks from it — git merge-tree shows none and GitHub reports MERGEABLE — so this needs no rebase, only green CI (build running on 2357e65d223f) and a verdict.

(Re-posted correctly: the previous version of this comment went through a shell and the commit id in backticks expanded to nothing, which is exactly the kind of mangled evidence I keep having to correct tonight.)

For whoever lands it: the four commits are one idea — the package, the image, the in-image check and the serial checker must recognise the same two set schemes — and two of them are my own first-attempt errors, recorded in their messages (a set is recognised by its signed manifest, not layout.json; each kernel carries its own manifest + manifest.sig). Verified against ~/wt/c34-payload/hold-signed-sets: 2 sets, 20 kernels, digests match, per-kernel manifests signed, and the image's own staging block run over them.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The fix landed the other way round from my suggestion, and it works — verified by running the test at this head, so the next build should be green.

2357e65 now prints both literals:

scripts/kernel-set-check.sh:74
FAIL %s: no manifest.json and no signed manifest (manifest + manifest.sig), so this is not a set this script can judge

That satisfies the stale grep without touching it, and it reads better than my version for a lane at 3 a.m. — it names both files a set could carry. Measured just now with scripts/kernel-set-check.sh and tests/kernel_set_check_test.sh fetched from this head:

$ bash tests/kernel_set_check_test.sh
… kernel_set_check: all cases ok

build is the only pending check on this head; the previous failure was this single arm and nothing else in the 452-test run, so unless a new commit lands in the meantime, that wait is nearly over.

Still outstanding from my side, unchanged and not blocking: the sealed == total guard in os/mini/mkimage.sh became a printed count (confidentiality vs authenticity, #574). One sentence in the body settles whether signed-manifest sets carry plaintext ELFs; if they do, the stick now ships readable kernels where it previously refused, and that belongs in the release note.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 2357e65: READY

Re-reviewed at this head: the delta is one line in scripts/kernel-set-check.sh (+1/−1), and it fixes the red from the other side of the pair I described —

printf 'FAIL %s: no manifest.json and no signed manifest (manifest + manifest.sig), so this is not a set this script can judge\n' "$dir"

That restores the phrase tests/kernel_set_check_test.sh:115 asserts (has "$tmp/out9" "no manifest.json") without weakening the arm, and the rc 2 semantics are unchanged (detect/check still own the distinction, and the delegated path is untouched: detect = kmanifest2 → check … || return 1). So the script now says the thing a reader is looking for — which files a set needs — rather than only "cannot tell the scheme", which is the better wording of the two options I offered.

The substance is unchanged from the three heads I already reviewed and is what the cut needed: five call sites on one owner (package-linux.sh, weekly.sh, kernel-set-check.sh, release-check.sh, mkimage.sh), detect() answering sealed1 | kmanifest2 | unknown and refusing to guess, and the honesty statement that a check which cannot verify a signature does not report "signed".

build is running on this head (CodeQL pass on the previous). Given this PR has now been red once on exactly this arm, I will treat the build as the deciding evidence and confirm as soon as it reports — if the arm was the only failure (99 % passed, 1 of 452), green here is the whole row back.

Note for the record: the arm still reads "no manifest.json", so the sentence in the script is now load-bearing for a ctest row. If a later change rewords it again, that arm is the thing that will catch it — which is the correct arrangement, and worth one line of comment next to the printf.

@bong-water-water-bong
bong-water-water-bong merged commit a6b0f96 into main Nov 22, 2026
12 checks passed

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 2357e65: READY

build is green at this head (23:11Z), which was the deciding evidence. The previous head failed on exactly one arm (kernel_set_check, 1 of 452, 99 % passed) and this head fixes it from the script side with a sentence that names the files a set needs, so the row is back without the arm being loosened.

State for whoever merges it: CLEAN, build pass, CodeQL/pr_agent/reviewer/pin_moved/hrx_build pass, hw_gate skipping (pin unchanged — this PR moves no pin).

The four things I verified across the five heads, in one place:

  1. one owner for the scheme difference (tools/npu_set_scheme.py detect/stage/check) and all five call sites on it: package-linux.sh (stages, then checks the staged copy), weekly.sh package_checks, kernel-set-check.sh (delegates), release-check.sh (seal_manifest_problems() triples→bytes), and mkimage.sh — the last being the one that would have put zero kernel sets on the stick while the image built successfully.
  2. detect() refuses to guess — sealed1 | kmanifest2 | unknown, with check exiting 2 on unknown, and the manifest (not layout.json) deciding.
  3. authenticity stated precisely — digests are verified here, the signature is verified by the engine at load, and "a check that cannot verify a signature does not report 'signed'".
  4. refusals are real — cannot be packed → exit 1, delegations || exit 1, and verified on the actual held sets (two sets, 10 kernels each, digests match).

Two residual notes, neither a reason to hold it: a directory holding both schemes is classified by the first manifest found and the other scheme's kernels are ignored rather than refused (safe because the packager stages per-scheme); and the printf this head adds is now load-bearing for kernel_set_check, so a future rewording is caught by that arm — which is the right arrangement.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Answering my own open question from the 22:5x comment, because the evidence is in this PR's own docstring — and it is a real change in what the stick carries, worth one line in the release note.

tools/npu_set_scheme.py:18-27 describes both schemes:

sealed1   (engine #574):  every kernel is a `1BPKCRYP` CIPHERTEXT at <set>/layer1_*/layer1.elf,
                          manifest.json a format-1 JSON listing each ciphertext's sha256, manifest.sig over it

kmanifest2 (this release): <set>/{<id>/layer1.elf, manifest, manifest.sig}
                          … and package_checks additionally demanded `1BPKCRYP` of every kernel,
                          WHICH THE NEW SETS NEVER CARRY

So the answer is yes: the signed-manifest sets carry kernels that are not ciphertexts — plaintext layer1.elf with a per-kernel Ed25519-signed <sha256> <size> <path> index beside it. That gives authenticity (a swapped kernel is refused — the arms prove it: "a kernel that does not match its listing is refused", "a set without its signature is refused") but not confidentiality.

Which makes this line in os/mini/mkimage.sh the one that changed meaning:

# was:  [ "$sealed" = "$total" ] || { echo "… (plaintext would leak the method)"; exit 1; }
# now:  echo "npu/kernels: N set(s) on the data partition ($total kernels, $sealed sealed, $((total - sealed)) covered by a signed manifest)"

That old guard was #574's confidentiality rule, and the new count is honest about the trade. Two things follow and neither is a code change:

  1. The release note should say "signed, not sealed" for the NPU kernel sets it ships, in those words. A reader who has the previous stick will reasonably assume the kernels on it are ciphertext, and the difference between "nobody can alter this" and "nobody can read this" is exactly the thing a kernel-method policy cares about. The bodies of #3237/#3278 describe the fix (scripts recognise the new scheme) but not the consequence (what is now readable on the stick).
  2. The exposure is bounded, and worth saying so too: the payload copies only layer1.elf (+ the manifests) — no layer1.work/, so no MLIR, no build tree. What is readable is a compiled ELF, not the method in source form.

I am not asking for a code change: the tool documents the two schemes accurately, the arms are green, and shipping an image with no kernel sets (the alternative) is worse. This is the one sentence in the release note that keeps the artifact honestly described — and the same sentence makes it clear why sealed1 sets still work, which is the compatibility half of the PR.

bong-water-water-bong added a commit that referenced this pull request Nov 22, 2026
…ipped without (engine#3237) (#3283)

#3278 landed the signed-manifest NPU kernel sets with a note that this tool had no `--self-test` and no ctest row:
`--self-test` was not a verb, and the `check` verb needs a staged set plus a release key, so nothing that runs on a
lane box or in CI verified the tool that decides which kernel set an image carries. Every other release-path tool
that night carried arms (unsloth_probe 3, loom_arch_probe 6, ctest_row_name_check 9+, logprob_agree 31).

Twelve arms, all hermetic -- two schemes and the failure shapes, each built from bytes in a temp dir, no device, no
key, no network:

  a well-formed kmanifest2 set checks clean                                    rc 0   (the positive control)
  …its scheme is detected from the manifest HEAD, not layout.json                       (engine#3237's own trap:
                                                                                        the signed scheme ships no
                                                                                        layout.json, so requiring one
                                                                                        reported "unknown")
  a manifest naming a file the set does not contain                            rc 1
  a digest that does not match the bytes                                       rc 1
  …and the message names the digest, not the file                                      (three defects, three messages)
  a size that does not match the bytes                                         rc 1
  a set with no signature                                                      rc 1
  a signature that is not 64 B                                                 rc 1
  a directory with no manifest                                           cannot tell 2  (not a pass, not a finding)
  a format-1 manifest.json is the sealed scheme                                sealed1
  the writer's `file <sha> <size> <path>` form parses                       1 entry
  …and that set checks clean                                                   rc 0

The positive control is the arm that keeps the rest honest: without it every failure arm passes if `check()` simply
returns 1. The `file …` arm covers the spelling the writer emits, which a lenient parser and a strict one disagree
about -- and a silently-empty entry list would make every set look unsigned-but-clean.

`add_python_test(npu_set_scheme_self … --self-test)` puts them in `ctest`, beside `census_counters_self`. Verified
here: `--self-test` 12 ok / 0 failed; `tool_selftest_wired_check` 98 tools all referenced; `tests_referenced` 123
scripts, 101 tool self-tests; `python_test_order_check` ok.

Refs engine#3237.

Co-authored-by: bong-water-water-bong <[email protected]>
bong-water-water-bong added a commit that referenced this pull request Nov 23, 2026
…e now check what ships (engine#3287) (#3338)

Found by the v2026.48 cut: package_checks failed the v2026.48 engine tarball and the board-tested c35 payload with
the same 22 FAIL lines, so neither could be packaged without waiving the check.
- NPU set count: demanded "the 0.6B, 1.7B and 4B sets", stale since 1.7B stopped shipping (#3300's catalogue filter
  decides what is offered). Now: at least one signed set, and every set is a geometry config/npu-catalogue-sets.json names.
- Host-ELF row: rejected the signed-manifest sets' AIE kernels at <set>/<id>/layer1.elf, which the allowlist above admits
  by design (#3278). Those are skipped when the set carries its manifest; an AIE ELF anywhere else still fails.
- Private names in the packed 1bit: matched as substrings, so one private basename matched inside a longer PUBLIC
  path ending with it, in a message the engine prints. Now whole names (grep -w); real private names still match
  (13 hits in an unstripped build binary, 0 in the stripped package).

Measured: the v2026.48 engine tarball now passes all 13 rows (rc 0). tests/weekly_package_checks_test.sh: 7 rows on
miniature tarballs with invented names, 7/7 with this change and 6 FAIL against main's weekly.sh; in the CI image as a
non-root user 7/7.

Co-authored-by: bong-water-water-bong <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant