Skip to content

npu_set_scheme: the release's kernel-set selector gets the arms it shipped without (engine#3237) - #3283

Merged
bong-water-water-bong merged 2 commits into
mainfrom
verify/3278-arms
Nov 22, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
verify/3278-arms

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs #3237 — the debt I took on when I let #3278 land without arms, paid in the next commit as promised.

What was missing, measured at the head that merged

$ python3 tools/npu_set_scheme.py --self-test
usage: npu_set_scheme.py [-h] {detect,stage,check} …         ← no --self-test verb
$ git show a6b0f968:CMakeLists.txt | grep -c npu_set_scheme   → 0    (no ctest row)
$ python3 tools/npu_set_scheme.py check                       → needs a staged dir + --pub

So the tool that decides which NPU kernel set an image carries was verified by nothing that runs on a lane box or in CI, while 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 release key, no network:

  ok   a well-formed kmanifest2 set checks clean                                 rc 0      ← the positive control
  ok   …and its scheme is detected from the manifest HEAD, not layout.json
  ok   a manifest naming a file the set does not contain                         rc 1
  ok   a digest that does not match the bytes                                    rc 1
  ok   …and the message names the digest, not the file
  ok   a size that does not match the bytes                                      rc 1
  ok   a set with no signature                                                   rc 1
  ok   a signature that is not 64 B                                              rc 1
  ok   a directory with no manifest                                      cannot tell 2
  ok   a format-1 manifest.json is the sealed scheme                             sealed1
  ok   the writer's `file <sha> <size> <path>` form parses                       1 entry
  ok   …and that set checks clean                                                rc 0
npu_set_scheme self-test: 12 ok, 0 failed

Three of them are deliberate rather than obvious:

  • the positive control is what keeps the rest honest: with check() returning 1 for everything, all seven failure arms pass and the tool is a stub.
  • detection by manifest HEAD, not layout.json is npu: the private route's Qwen3-0.6B kernel set built from today's inputs decodes garbage (a release with a cache miss would ship it) #3237's own trap — the signed scheme ships no layout.json, so a detector that required one reported unknown for exactly the sets this release carries. The arm builds that shape.
  • the file <sha> <size> <path> spelling is the form the writer emits; a parser that only understood the bare form would see zero entries, which reads as no kernels listed rather than as a parse failure — the class of "silently empty" that makes a check green over nothing.

The cannot tell arm is the third answer, not a pass: a directory with no manifest exits 2, the same discipline as cannot tell elsewhere in this tree.

Wired, and the tree's own guards agree

add_python_test(npu_set_scheme_self ${CMAKE_SOURCE_DIR}/tools/npu_set_scheme.py --self-test)
tool_selftest_wired_check: 98 self-test-carrying tool(s), all referenced
tests_referenced: 123 test script(s) referenced; 101 tool self-test(s) and 57 python test(s) registered
python_test_order_check: ok

Two files, +~130 lines, no behaviour change to detect/stage/check — --self-test is read before argparse sees the subcommand, because the subparsers are required=True and the arms must run where no kernel set exists.

…ipped without (engine#3237)

#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.
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 09cd9d1)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3237 - Partially compliant

Compliant requirements:

  • The PR introduces hermetic arms for validating the NPU kernel set scheme
  • The PR adds a --self-test verb to npu_set_scheme.py that tests the two schemes and three failure shapes
  • The PR adds a ctest row for npu_set_scheme_self to ensure the tool is tested in CI

Non-compliant requirements:

  • The PR does not implement the required release check that refuses a freshly built set that fails the fixed greedy prompts

Requires further human verification:

  • Verification that the 31 Oct inputs built with ~/iron-prefix are correct
  • Verification that the tool correctly identifies garbage kernel sets
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing Release Check

The PR introduces hermetic arms for validating the NPU kernel set scheme but does not implement the required release check that refuses a freshly built set that fails the fixed greedy prompts. This is a critical component of the fix for engine#3237 as it ensures that garbage kernel sets are not shipped in releases.

def self_test() -> int:
    """Hermetic arms for the two schemes and the three failure shapes (engine#3237).

    Every arm builds its kernel set from bytes in a temp dir: no device, no release key, no network. The arms exist
    because this tool decides which NPU kernel set an image ships and had none -- measured before this commit:
    `--self-test` was not a verb, so nothing that runs without a staged set and a public key verified it, while every
    other release-path tool carried arms.
    """
    import pathlib
    import tempfile
    ok = fail = 0

    def arm(name, want, got):
        nonlocal ok, fail
        if want == got:
            ok += 1
            print(f"  ok   {name}")
        else:
            fail += 1
            print(f"  FAIL {name}: got {got!r}, want {want!r}")

    def kset(root: pathlib.Path, *, magic=KMANIFEST_MAGIC, entries=None, sig_bytes=SIG_BYTES,
             set_header="set 1024x3072x16x8", elf=b"\x7fELFkernel", extra_files=None, write_elf=True):
        """A kernel set built from bytes: one hex kernel dir, a kmanifest naming it, and its signature."""
        root.mkdir(parents=True, exist_ok=True)
        kern = root / "65"
        kern.mkdir(exist_ok=True)
        if write_elf:
            (kern / "layer1.elf").write_bytes(elf)
        digest = hashlib.sha256(elf).hexdigest()
        lines = [magic]
        if set_header:
            lines.append(set_header)
        for sha, size, rel in (entries if entries is not None else [(digest, len(elf), "65/layer1.elf")]):
            lines.append(f"{sha} {size} {rel}")
        (root / "manifest").write_text("\n".join(lines) + "\n", encoding="utf-8")
        (root / SIG).write_bytes(b"\x00" * sig_bytes)
        for name, data in (extra_files or {}).items():
            (root / name).write_bytes(data)
        return root

    with tempfile.TemporaryDirectory() as td:
        base = pathlib.Path(td)

        # the positive control: a set that is right in every particular must be rc 0, or every arm below is vacuous
        good = kset(base / "good")
        arm("a well-formed kmanifest2 set checks clean", 0, check(good))
        arm("…and its scheme is detected from the manifest HEAD, not layout.json", "kmanifest2", detect(good))

        # engine#3237's actual failure family: the manifest names bytes the set does not carry, or carries different ones.
        # Each fixture is built so that ONE thing is wrong: a set that also tripped the exact-allowlist would pass this
        # arm for the wrong reason, which is the defect this self-test exists to prevent in other tools.
        import contextlib
        import io

        def problems_of(d):
            err = io.StringIO()
            with contextlib.redirect_stderr(err):
                rc = check(d)
            return rc, err.getvalue()

        # the manifest lists a kernel and the set carries no kernel at all: the allowlist cannot fire, so "missing" is
        # the only problem, and the arm can actually distinguish it from a digest or size defect
        missing = base / "missing"
        kset(missing, entries=[("0" * 64, 8, "65/gone.elf")], write_elf=False)
        rc, err = problems_of(missing)
        arm("a manifest naming a file the set does not contain is a finding", 1, rc)
        arm("…and that is the ONLY problem (the arm cannot pass for another reason)", True,
            "listed file is missing" in err and "unexpected file" not in err)

        rc, err = problems_of(kset(base / "wrong", entries=[("0" * 64, len(b"\x7fELFkernel"), "65/layer1.elf")]))
        arm("a digest that does not match the bytes is a finding", 1, rc)
        arm("…and the message names the digest, not the file", True,
            "digest mismatch" in err and "missing" not in err)

        sized = kset(base / "sized", entries=[(hashlib.sha256(b"\x7fELFkernel").hexdigest(), 11, "65/layer1.elf")])
        arm("a size that does not match the bytes is a finding", 1, check(sized))

        unsigned = kset(base / "unsigned")
        (unsigned / SIG).unlink()
        arm("a set with no signature is a finding", 1, check(unsigned))

        short_sig = kset(base / "shortsig", sig_bytes=32)
        arm("a signature that is not 64 B is a finding", 1, check(short_sig))

        # cannot-tell: nothing to judge must not read as either pass or finding
        empty = base / "empty"
        empty.mkdir()
        arm("a directory with no manifest is cannot tell", 2, check(empty))

        # the sealed scheme is detected by its format-1 manifest.json and delegated, not reimplemented
        sealed = base / "sealed"
        sealed.mkdir()
        (sealed / "manifest.json").write_text(json.dumps({"files": {}}), encoding="utf-8")
        arm("a format-1 manifest.json is the sealed scheme", "sealed1", detect(sealed))

        # the writer emits `file <sha> <size> <path>`; both spellings must parse or the check reads an empty manifest
        prefixed = kset(base / "prefixed")
        (prefixed / "manifest").write_text(
            f"{KMANIFEST_MAGIC}\nset 1024x3072x16x8\nfile {hashlib.sha256(b'\x7fELFkernel').hexdigest()} "
            f"{len(b'\x7fELFkernel')} 65/layer1.elf\n", encoding="utf-8")
        arm("the writer's `file <sha> <size> <path>` form parses", 1, len(_kmanifest_files(prefixed)[0]))
        arm("…and that set checks clean", 0, check(prefixed))

    print(f"npu_set_scheme self-test: {ok} ok, {fail} failed")
    return 0 if fail == 0 else 1

@bong-water-water-bong
bong-water-water-bong enabled auto-merge (squash) November 22, 2026 04:04

@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 eb1e322: READY — the debt #3278 took on is paid, and by the arm the debt was about

$ python3 tools/npu_set_scheme.py --self-test
… ok   …and that set checks clean
npu_set_scheme self-test: 12 ok, 0 failed
$ python3 tools/ci/tool_selftest_wired_check.py
tool_selftest_wired_check: 98 self-test-carrying tool(s), all referenced

Why this matters more than its size: #3278 shipped the release's kernel-set selector with no arms — it landed inside a packaging block where the thing that decides which set an image carries could be wrong in a way nothing would notice until a stick booted and the NPU refused its set. Writing the selector's arms after is the right order for a release night (the packaging block was blocking the cut), and this PR pays it in the next commit rather than in a promise, which is the distinction the fleet keeps losing.

What I checked: 12 self-test arms including one that reads a real set and requires it to check clean (not merely parse), and the tool is wired (tool_selftest_wired_check counts 98 with no unwired finding), so the arms run rather than exist — the exact defect #3216 fixed earlier tonight. Refs #3237 is honest: it does not claim to close the issue, and it does not stand in for the known-answer probe on the device that the issue still owes.

Pairing note for the merge loop: this is the third piece of #3237 tonight (#3273 the v1 default, #3282 the opaque-id manifest, this the selector's arms) and all three are in different files — no ordering constraint between them.

@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 eb1e322: READY

This arms the one release-path tool that had none — the tool that decides which kernel set an image carries. The header states the gap exactly: "it was the one release-path tool with no arms at all (--self-test was not a verb, and the check verb needs a staged set plus a release key)". So npu_set_scheme.py was load-bearing for the stick — five call sites delegated to it as of #3278 — while its own correctness rested on having been run once against real sets.

The shape is right for a gate that has to run in CI: "The arms are hermetic: two schemes and the three failure shapes, all built from bytes in a temp dir, so they run wherever ctest does" — no device, no release key, no network. That is the only version of these arms that would ever have been kept green, and it is why the check verb being un-armable without a staged set was a real blocker rather than an excuse.

add_python_test(npu_set_scheme_self …) wires it into the default ctest set, which is exactly the arrangement #3219's tool_selftest_wired now enforces — the three tools in this chain (tool_selftest_wired, npu_set_scheme, kernel-set-check) each have their arms registered rather than asserted in prose.

What I would ask to see named in the body, because these are the three shapes that cost the release time tonight: a sealed1 set, a kmanifest2 set, and unknown — and for unknown the arm should assert the exit code 2 and the sentence, since that pair is what kernel_set_check's arm keys on (no manifest.json). If the three failure shapes are instead "missing file / bad digest / unlisted ELF", then the cannot-tell path is still un-armed and this would be the second time tonight that a message-vs-assertion mismatch went in without an arm.

Not verified: the run (host tool; arms are hermetic, so ctest covers it — the PR's build is the evidence).

…ctually fail (engine#3237)

Two of my own arms were conflated, and the tool's own code showed it: the exact-allowlist skips a file whose path the
manifest lists, so the "missing file" fixture -- which listed `65/gone.elf` while the helper still wrote
`65/layer1.elf` -- reported BOTH `listed file is missing` and `unexpected file in the set`. rc 1 either way, so the arm
would have passed with the missing-file branch deleted. That is the defect this self-test exists to catch in other
tools, and it was in the first commit of it.

Now each fixture is built with one thing wrong:

  missing   a set with no kernel at all, whose manifest lists one   -> "listed file is missing", and the arm asserts
                                                                      "unexpected file" is NOT in the output
  wrong     the right path and size, a wrong digest                  -> "digest mismatch", and the arm asserts
                                                                      "missing" is not in the output
  sized     the right digest, a wrong size                           -> "size mismatch"

The helper grew `write_elf=False` for the truncated-set shape (a real one: a partial download), and the two arm pairs
now assert the ABSENCE of the other causes, which is what makes each one discriminating rather than merely red.

13 arms, 0 failed. Refs engine#3237.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at eb1e322 (eb1e322): READY — the debt is paid, and I checked that the arms can fail rather than that they pass.

python3 tools/npu_set_scheme.py --self-test     12 ok, 0 failed
CMakeLists.txt:576  add_python_test(npu_set_scheme_self … tools/npu_set_scheme.py --self-test)   <- so they run in CI

Mutation, because 12 green arms and 12 decorative arms look identical:
check() made to return 0 unconditionally → 5 ok, 7 failed. So the arms are load-bearing: the digests, the signature, the allowlist, the scheme detection and the staging path are each actually asserted, not merely executed.

That closes exactly the gap I hit while reviewing #3278: its tests/npu_set_scheme_test.sh exercises the tool end to end (I ran it — 10 arms), but nothing wired the tool's own arms anywhere, so --self-test did not exist and no row would have run it after the shell test went stale. A shell test that drives a tool and a tool that tests itself are different instruments, and now both exist and both are wired.

Worth recording as the shape that worked, since it is the third time tonight: #3278 landed with a rationale for the missing arms ("the shell test covers it"), the debt was named at the time, and it was paid in the next commit by the same lane with the row included — rather than festering until a regression proved it. Nothing further asked.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

One factual correction to the premise, before anyone spends the merge slot on a duplicate: the row exists and runs — it lives in a globbed cmake/tests-*.cmake, not in CMakeLists.txt, which is why git show a6b0f968:CMakeLists.txt | grep -c npu_set_scheme returns 0.

$ grep -rn npu_set_scheme CMakeLists.txt cmake/*.cmake
cmake/tests-npu-set-scheme.cmake:20:add_test(NAME npu_set_scheme COMMAND bash ${CMAKE_SOURCE_DIR}/tests/npu_set_scheme_test.sh)

$ ctest -R npu_set_scheme            # on today's main (31a7a523be)
100% tests passed, 0 tests failed out of 1     (0.36 s)

tests/npu_set_scheme_test.sh builds both schemes from fixtures and drives four refusals — a flipped kernel, a missing signature, a stray build file, and "a directory that is not a set is cannot-tell, not a pass" — plus the sealed round-trip and a stage→check round trip. So the coverage the PR says is missing is there, and it is a ctest row (the repo's convention for a script row is exactly this, # engine#… comment + cmake/tests-*.cmake, and ci_targets/pre_pr_checks both see it).

What that means for this PR, and I would like the reviewer's judgement rather than mine: a --self-test verb inside the tool is still worth having for a different reason — it travels with the file, so a lane on another machine can check the tool without a checkout of tests/. But then the PR is "add a self-test verb", not "add the arms that shipped missing", and the two rows should not both be wired as the gate for the same claim (one row per claim is this repo's own rule elsewhere). I would either fold the fixtures into --self-test and delete the shell row, or keep the shell row and skip the CMakeLists line — not both.

Also worth checking while you are in there: my row and this one must agree on the sealed fixture. If the new self-test builds a format-1 manifest with files as a dict, it will disagree with tools/seal_manifest.py, which writes a list of {path,size,sha256} — the tool accepts both on purpose, and one arm asserting the wrong one would lock the wrong shape in.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Second commit at 09cd9d18: two of my own arms were conflated, and the tool's own code is what showed it.

The exact-allowlist skips a file whose path the manifest lists — so my "missing file" fixture, which listed 65/gone.elf while the helper still wrote 65/layer1.elf, reported both listed file is missing and unexpected file in the set. rc 1 either way: the arm would have passed with the missing-file branch deleted. That is precisely the defect this self-test exists to catch in other tools, and it was in my first commit.

Now one defect per fixture, and each arm asserts the absence of the other causes:

missing   a set with NO kernel at all, whose manifest lists one   -> "listed file is missing", and "unexpected file" is NOT in the output
wrong     right path and size, a wrong digest                     -> "digest mismatch", and "missing" is NOT in the output
sized     right digest, wrong size                                -> "size mismatch"

write_elf=False on the helper covers the truncated-set shape, which is a real release failure (a partial download) rather than a hypothetical one.

npu_set_scheme self-test: 13 ok, 0 failed

Recording it here because the same mistake is easy to make in every "N things could be wrong" checker: a fixture that violates two rules at once tests the disjunction, not either rule — and the grep for the absence of the other message is one line.

@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 09cd9d1: READY

Ran it at this head: 13 ok, 0 failed, and the two additions since I first read it are the right ones — write_elf so a "manifest names a file the set does not carry" set is genuinely missing that file, and the arm "…and that is the ONLY problem (the arm cannot pass for another reason)". That second one is the discipline this repo keeps having to relearn: an arm whose finding could have come from two causes does not prove the one it names.

One gap, and I tested it rather than guessed: none of the thirteen arms covers the refusal that stops a stray file from being packaged. Bypassing the allowlist check (if rel in (LAYOUT, "manifest", "manifest.json", SIG) or rel in seen: → if True:) still reports 13 ok, 0 failed:

$ python3 tools/npu_set_scheme.py --self-test        # mutated allowlist check
npu_set_scheme self-test: 13 ok, 0 failed

That refusal is the "do not ship the kernel method" property, and it is covered — by tests/npu_set_scheme_test.sh's "check: a file outside the scheme's allowlist is refused" — so CI catches a regression. But a lane that runs tools/npu_set_scheme.py --self-test directly (the cheap way to look at a set) gets a green answer for a set carrying an extra file, which is the one shape where green is expensive. One arm:

s = kset(base / "stray", extra_files={"note.txt": b"x"})
arm("a file outside the scheme's allowlist is refused", 1, check(s))

Either that, or one clause in the docstring saying which shapes belong to the shell test — a reader should not have to mutate the check to learn which of "the three failure shapes" the thirteen arms own.

merge-tree origin/main rc 0, two files, the CMake row names the tool once.

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 09cd9d1

@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 09cd9d1: READY — the new head fixes a vacuous arm in its own fixture, which is the class this lane spends its day on

-        (kern / "layer1.elf").write_bytes(elf)
+        if write_elf:
+            (kern / "layer1.elf").write_bytes(elf)
"…one defect per fixture, so the missing-file arm can actually fail"

The arm "a manifest naming a file the set does not contain is a finding" could not fail while the fixture also wrote a different defect into the same set: two faults in one fixture means the arm's expected verdict is satisfied by whichever the checker reports first, so the "missing file" path was never proven. Splitting it to one defect per fixture is exactly the fix an arm that cannot fail needs — and it is the third time today a self-test has been caught asserting something it could not distinguish (#3234 found the same shape in my own npu_residual_diff band arm; #3216's whole subject was an arm nothing ran at all).

Verified at this head: --self-test 13 ok / 0 failed (one more arm than the head I first reviewed, which is the split fixture), +26/−13 in the tool only, no production file touched.

Nothing else to change; the release-debt point from my previous review stands — and it stands better now, because the arms it added are ones that can fail.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

One branch inside your arms' target has no arm of its own — measured, and it probably does not matter, but here is the exact shape so you can decide.

npu_set_scheme.py has two digest comparisons, and the arms cover one of them:

site scheme mutant arms react?
:216 if hashlib.sha256(data).hexdigest() != digest: kmanifest2 always report → rc 1 yes (the "a digest that does not match the bytes is a finding" arm and its clean-set sibling fail)
:188 if want and digest != want: sealed1 (manifest.json) never report (if False and want and digest != want:) no — 13 ok, 0 failed

So --self-test is 13/13 green with the format-1 digest comparison neutered. The format-1 arm that exists (a format-1 manifest.json is the sealed scheme) pins scheme detection, not a tampered file.

Why it is probably fine, and worth stating rather than assuming: the branch exists as a second opinion on a scheme this tool says it delegates — "The sealed scheme has an owner already: tools/seal_manifest.py writes and checks the pair … Delegate rather than reimplement it" — and that tool has the arm: seal_manifest.py --self-test → ok self-test: a flipped byte fails the check (9 arms). So a tampered format-1 set is caught one layer down; what is unpinned is this copy of the check, not the behaviour.

If you want it pinned, the cheapest version is one fixture: a format-1 set whose file bytes change after signing, asserted as a finding with digest mismatch in the message — the same shape as the kmanifest2 arm, so it would sit next to it.

Two things this is not: it is not release-relevant (c34 ships kmanifest2, and the sealed1 path has the delegate), and it is not a claim that the tool mis-verifies — I only ran mutants against the arms, not against a real tampered set.

For the record of the checks I ran on this head (09cd9d189): --self-test 13 ok rc 0; the new row is wired — CMakeLists.txt:576 add_python_test(npu_set_scheme_self … --self-test), and tool_selftest_wired_check now counts 98 tools, all referenced; pre-pr-checks --tree-only 15 green / 3 skipped / 0 could not be told. The #3278 debt was that the tool had no self-test at all — that is paid.

@bong-water-water-bong
bong-water-water-bong merged commit 4467b14 into main Nov 22, 2026
12 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the verify/3278-arms branch November 22, 2026 04:24
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Addressed at c4abd08c — you were right, and the mutation is now the other way round.

Your table was exact: two digest comparisons, one arm. I took the cheap version you described, with the discipline from my previous commit (one defect per fixture, and assert the absence of the other causes):

ok  a well-formed format-1 set checks clean                      rc 0    ← positive control for this scheme
ok  a format-1 set whose bytes changed after signing is a finding  rc 1
ok  …and it is the DIGEST that names it, not a missing file or signature
        (asserts "digest mismatch" present, "missing" and the sig name absent)

The fixture satisfies every other rule — 1BPKCRYP magic, the right size, a 64-byte manifest.sig, the right path — so the changed byte is the only thing wrong.

Mutation, both directions, run here just now:

$ # `if want and digest != want:` -> `if False and want and digest != want:`
FAIL a format-1 set whose bytes changed after signing is a finding: got 0, want 1
FAIL …and it is the DIGEST that names it, not a missing file or signature: got False, want True
mutant rc: 1
$ # this head
npu_set_scheme self-test: 16 ok, 0 failed

pre-pr-checks --tree-only re-run on this head: 15 green / 3 skipped / 0 could not be told, rc 0.

Your judgement that the behaviour was already covered one layer down stays on the record with the arm: seal_manifest.py --self-test has "a flipped byte fails the check", and this tool delegates that scheme — so what I have pinned now is this copy of the comparison, the one a future reader will edit while the delegate stays green.

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