Skip to content

ci: a registry CONTENT row, so a hand-edited architectures.json stops merging green (engine#2698) - #2699

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-game/2698-registry-content
Nov 16, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-game/2698-registry-content

Conversation

@bong-water-water-bong

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

Copy link
Copy Markdown
Collaborator

Fixes #2698.

What was missing

registry/architectures.json has two axes, and only one had a row:

row reads catches
registry_pins (--check-pins) the sources sha and the gitlink a pin bump that did not regenerate
registry_gaps (--check-gaps) the 44 reviewed classes a reviewed class mapped without a reason
nothing the file's content a hand-edited architecture list or backend

--check is the form that regenerates from the pinned fork and compares; it ran only in the daily census, which opens a PR when the file differs (and exits early when that day's branch already exists) instead of failing the PR that made the edit.

The repository already says so in passing: .github/workflows/hrx-pins-guard.yml:23-25 explains what that workflow does not cover with "ctest registry_pins only checks that the registry matches the gitlinks, not that the two pins compile together". The content half is the same blind spot, one axis over.

The content is not cosmetic: CMakeLists.txt:138-151 reads gguf_architectures.hrx out of this file and writes build/generated/hrx_archs.h, and app/serve.cpp refuses an architecture that is not in it. A backends edit changes what the registry claims the product runs.

Measured on main 3e591b1 (fork checked out at the pin 148e7f329)

Control: --check rc 0, --check-pins rc 0.

Arm 1 — delete one entry from the compiled list (gguf_architectures.hrx, 171 -> 170, sources untouched):

$ tools/registry_build.py --check-pins   -> rc 0  "records the committed pins"     <- the only registry row in CI
$ tools/registry_build.py --check        -> rc 1  "is stale: run tools/registry_build.py"

Arm 2 — clear one per-architecture backends row (AfmoeForCausalLM, one line):

$ tools/registry_build.py --check-pins   -> rc 0
$ tools/registry_build.py --check-gaps   -> rc 0  "none of the 44 reviewed significant classes ..."
$ tools/registry_build.py --check        -> rc 1

What this changes

  • registry_content = tools/registry_build.py --check, next to registry_pins. It runs in the build job, which already does git submodule update --init --depth 1 third_party/llama.cpp (ci.yml:77), so it costs a submodule read and no new checkout.
  • Skip, not pass: --check exits 77 where the fork is not checked out (the same shape as hrx_f16_narrowing_check, engine#1962), with a message naming the checkout. A fork checked out at a different commit than the pin stays rc 1 — that is a failure, not a skip, because the content would come from a tree the registry does not name.
  • registry_content_fire — tests/registry_content_test.py: a fake fork, a fake gitlink, the real tool, in a scratch repo. Arms: a freshly generated file passes; the content edit that made every other row green makes --check red while --check-pins stays green; a missing fork is 77 and not 0; a moved fork is 1.
  • One paragraph in docs/registry.md, beside the sentence that describes registry_pins, and the --check line in the Commands block.

On this branch: --check rc 0 with the fork at the pin, rc 77 without it.

$ python3 tests/registry_content_test.py
registry_content_test: 13/13 passed

$ bash scripts/pre-pr-checks.sh
pre-pr-checks: all 12 check(s) green, 3 skipped

Mutants, so the arms are shown to fire (each reverted after the run):

mutant new test
content comparison removed (old != text -> False) 3 checks FAIL
the skip returned as 1 1 check FAILS
the HEAD-vs-pin guard removed 2 checks FAIL

Not covered here

  • The test's fork is synthetic (one architecture), so it pins the behaviour of --check, not the real fork's content; the real content is what the row asserts on every PR.
  • registry/checked.json (written by registry_check.py on Strix Halo, i.e. which models were actually run and checked) is a different axis and remains unguarded by any PR job — out of scope for this issue, said plainly rather than silently.

The exit-code change, checked against every caller

--check (and plain generation) now returns 77 instead of 1 where the fork is not checked out. Callers, audited:

caller guard effect
scripts/registry-regen.sh set -euo pipefail still aborts; and its first step regenerates, which needs the tree anyway
.github/workflows/census.yml set -euo pipefail in the step still aborts; that job does git submodule update --init --depth 1 third_party/llama.cpp itself
ctest registry_content (new) SKIP_RETURN_CODE 77 reports a skip
ctest registry_gaps / registry_pins --check-gaps / --check-pins never reach build(), unaffected
tests/registry_{gaps,pin_index,pin_staged}_test.py drive the tool directly all three still pass on this branch

No caller treats 77 as success: both scripts abort on any non-zero, and the one row that does interpret it is the one that must.

`registry_pins` (the only registry row in a PR job) compares `sources["llama.cpp (hrx)"]` with the
gitlink and never reads the fork, so a hand-edited CONTENT passed every check: measured on main
3e591b1, deleting one entry from `gguf_architectures.hrx` -- the list CMakeLists.txt compiles into
hrx_archs.h, which is what `1bit serve` refuses architectures against -- left `--check-pins` at rc 0
while `--check` said "is stale". A per-architecture `backends` edit is the same: rc 0 for
`--check-pins` and for `--check-gaps`.

So this adds ctest `registry_content` = `tools/registry_build.py --check`, in the job that already
checks out third_party/llama.cpp, and `registry_content_fire` (a fake fork and a fake gitlink in a
scratch repo) so the row's own mutant is in the suite. `--check` now exits 77 (CTest's skip) instead
of 1 when the fork is not checked out: the content cannot be known there, and a skip must not read as
a pass. Arm 4 of the new test pins the other direction -- a fork checked out at a commit other than
the pin is a failure (rc 1), not a skip.

Mutants run against the new test: content comparison removed -> 3 checks fail; the skip returned as
1 -> 1 fails; the pin guard removed -> 2 fail. 13/13 pass on the branch.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at 5633652 — engine#2698. The row this adds asserts the axis registry_pins cannot see; the two are complementary, not duplicates, and the new test's arms fail when either half of the guard is weakened (3 / 1 / 2 checks, table in the body).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

CI cost, since this row runs on every PR: 0.58-0.62 s with the fork checked out at the pin (three runs, /usr/bin/time), on top of a submodule the build job already initialises for its own reasons. It reads gguf-py/gguf/constants.py, the converter file(s) and two src/ files; nothing is compiled and nothing is fetched.

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

The defect is real, the new row catches exactly the edit that was green, and all three mutants fire as claimed. I reproduced both arms on this box with my own edits, not by reading the diff.

The hole, reproduced on this head's base content

Arm 1 — one entry out of the compiled list (I removed hrx from AfmoeForCausalLM's backends, sources untouched):

$ tools/registry_build.py --check-pins        → rc 0   "records the committed pins"     <- the only registry row in CI
$ tools/registry_build.py --check             → "…/architectures.json is stale: run tools/registry_build.py"

Arm 2 — the same shape with the whole backends row cleared: --check-pins rc 0, --check-gaps rc 0, --check stale. Both edits would have merged green before this PR, which is the claim.

The row and its mutants

$ python3 tests/registry_content_test.py
registry_content_test: 13/13 passed
$ time python3 tools/registry_build.py --check
…/architectures.json matches the pinned sources     rc=0     0.626 s
$ bash scripts/pre-pr-checks.sh
pre-pr-checks: all 13 check(s) green, 2 skipped

Mutants, each reverted (tools/registry_build.py restored, git status clean afterwards):

mutant result
old != text → False (comparison removed) 3 checks FAIL
raise SystemExit(77) → 1 (skip as a failure) 1 check FAILS
if head and head != pin(HRX) → False (HEAD guard removed) 2 checks FAIL

Exactly the table in the body.

Why the row will really run in CI, and cannot dirty the tree

ci.yml:77 inits third_party/llama.cpp shallow at the pin before the build job's ctest --test-dir build (ci.yml:161), so --check sees a fork at the pin rather than skipping; SKIP_RETURN_CODE 77 is set on registry_content in CMakeLists.txt, so the no-checkout case reports as a skip and not as a pass. --check writes nothing (open(…, "w") is in the regenerate path only, registry_build.py:283), so it cannot race a parallel ctest row or leave the tree dirty, and at 0.6 s the 600 s per-test timeout is not in question. The Apache notice is on the new test file and tools/copyright.py --check is rc 0.

Two notes, neither a change request

  1. The row goes quiet — skip, green — if the submodule step ever stops running in the build job (a rename, a conditional, a matrix change). That is the same property hrx_f16_narrowing_check already has, and the skip message does name the checkout, so this is consistent with the house pattern. If you want it airtight, one line before the ctest step asserting the directory exists turns "the row I just added checked nothing today" into a red run. Your call; I would not hold the PR for it.
  2. pre-pr-checks here says 13 green, 2 skipped, where the body says 12 green, 3 skipped — the difference is submodule_pin_check, which passes for me because this worktree has the submodule initialised. Nothing to fix, just so the counts in the body do not look wrong to the next reader.

Fixes #2698 matches the issue as written (registry_pins compares only the recorded sha). Green gates plus my own verification at 56336526.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 2699

The table is the argument, and it is the right one: two axes existed, a third did not —

row reads catches
registry_pins the sources sha and the gitlink a pin bump that did not regenerate
registry_gaps the 44 reviewed classes a reviewed class mapped without a reason
nothing the file's content a hand-edited architecture list or backend

And the sentence that makes the gap consequential rather than theoretical: "--check … ran only in the daily census, which opens a PR when the file differs (and exits early when that day's branch already exists) instead of failing the PR that made the edit." A check that files a complaint for someone else to triage tomorrow is not a gate on the change that caused it — and "exits early when that day's branch already exists" means the second edit of a day is never reported at all.

Plus the content is load-bearing: CMakeLists.txt:138-151 generates build/generated/hrx_archs.h from it, and app/serve.cpp refuses unknown architectures.

Three asks:

  1. say what the new row does when the fork is unavailable — --check regenerates from the pinned fork, so in a clone without it (which hw-gate: an arm for provenance(), which tells four cases apart and had none (engine#2643) #2661 hit: "the pinned 148e7f329 is not in ~/engine/third_party/llama.cpp at all") the row must be UNVERIFIABLE, not pass. That is the same distinction the hw-gate's provenance() grew arms for tonight, and it is the one failure mode a content check has;
  2. a hand edit that matches a stale fork still passes — worth one line: this row catches drift between the file and the pinned fork, not a wrong-but-consistent registry. Saying so prevents the row being read as "the architecture list is correct";
  3. the daily census's early-exit is a separate defect and should be named as such — if the census skips when the branch exists, the second differing edit in a day goes unreported even now; this PR removes the need for that path but the census still has it.

And one thing worth keeping: naming the two existing rows and their --check-* flags is what makes the new row's place obvious — the registry now has three axes with three names, which is the same "one classifier, two consumers" discipline the placement work has been converging on.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

CTest's own verdict on the row, which the tool's return codes alone do not prove — the SKIP_RETURN_CODE 77 wiring is the part that could be wrong, so I configured the tree and ran the row in three states:

(a) fork NOT checked out
    2/2 passed ... The following tests did not run:
        182 - registry_content (Skipped)          <- a skip, not a failure and not a pass

(b) fork checked out at the pin 148e7f329
    100% tests passed, 0 tests failed out of 2    <- registry_content Passed, registry_content_fire Passed

(c) one entry deleted from gguf_architectures.hrx (170), the edit every other row passes
    ... registry/architectures.json is stale: run tools/registry_build.py
    0% tests passed, 1 tests failed out of 1
        182 - registry_content (Failed)

Configure: 21 s (cmake -S . -B … -DCMAKE_BUILD_TYPE=Release, 0 errors). The tree was restored after (c); git status clean.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The row ran in CI, in the job that matters, and it is the row it claims to be — not a local run, and not a skip:

Start 181: registry_pins
181/371 Test #181: registry_pins ............................   Passed    0.05 sec
Start 182: registry_content
182/371 Test #182: registry_content .........................   Passed    0.36 sec
Start 183: registry_content_fire
183/371 Test #183: registry_content_fire ....................   Passed    0.49 sec
...
100% tests passed, 0 tests failed out of 371

(build job 133428021789, run 43904058598, head 5633652, 23m03s, 0 Failed lines in the log.) So on a green tree the content row executes in 0.36 s beside registry_pins' 0.05 s, and the arm that proves it can fail costs 0.49 s. The skip path is the one I verified locally with ctest (no fork -> (Skipped)), since CI always checks the fork out.

@bong-water-water-bong
bong-water-water-bong merged commit 46c405b into main Nov 16, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-game/2698-registry-content branch November 16, 2026 16:42
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2698 - Partially compliant

Compliant requirements:

  • CI now checks the content of registry/architectures.json with a new registry_content ctest row
  • The new test runs tools/registry_build.py --check in the build job where third_party/llama.cpp is checked out
  • The test correctly skips (rc 77) when the fork is not checked out
  • Documentation has been updated to explain the new content checking
  • A hermetic test registry_content_test.py has been added to verify the behavior

Non-compliant requirements:

  • None

Requires further human verification:

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

Test Coverage

The test registry_content_test.py provides good coverage for the new registry content checking functionality, but it relies on a complex setup involving temporary directories and git operations. While this is necessary for hermetic testing, it could be made more robust by ensuring all temporary files and directories are properly cleaned up even in case of test failures.

with tempfile.TemporaryDirectory() as tmp:
    repo = os.path.join(tmp, "engine")
    fork = os.path.join(repo, "third_party", "llama.cpp")
    os.makedirs(os.path.join(repo, "tools"))
    shutil.copy(TOOL, os.path.join(repo, "tools", "registry_build.py"))
    # the reviewed not-an-alias list the tool reads beside the check; empty here, the gaps row owns it
    write(os.path.join(repo, "registry", "significant.json"), json.dumps({"classes": {}}) + "\n")

    write(os.path.join(fork, "gguf-py", "gguf", "constants.py"), CONSTANTS)
    write(os.path.join(fork, "convert_hf_to_gguf.py"), CONVERTER)
    write(os.path.join(fork, "src", "llama-arch.cpp"), ARCH_CPP)
    write(os.path.join(fork, "src", "llama-model.cpp"), MODEL_CPP)
    git(fork, "init", "-q")
    git(fork, "add", "-A")
    git(fork, "-c", "user.name=t", "-c", "[email protected]", "commit", "-qm", "fork at the pin")
    pinned = git(fork, "rev-parse", "HEAD").stdout.strip()
    if not pinned:
        print("could not build the fixture fork", file=sys.stderr)
        return 1

    # the gitlink, staged only: pin() reads the index first, which is how a lane runs this before committing
    git(repo, "init", "-q")
    staged = git(repo, "update-index", "--add", "--cacheinfo", f"160000,{pinned},third_party/llama.cpp")
    if staged.returncode != 0:
        print(f"could not stage the gitlink: {staged.stderr}", file=sys.stderr)
        return 1

    tool = os.path.join(repo, "tools", "registry_build.py")
    registry = os.path.join(repo, "registry", "architectures.json")

    def run(*flags):
        return subprocess.run([sys.executable, tool, *flags], capture_output=True, text=True)

    wrote = run()
    check_that(wrote.returncode == 0 and os.path.exists(registry),
               "the fixture registry generates (the arm is only meaningful on a real file)")
    check_that(pinned in open(registry).read(),
               "the fixture registry records the indexed gitlink as its pin")

    arm1 = run("--check")
    check_that(arm1.returncode == 0, "arm 1: a freshly generated registry passes --check (rc 0)")

    # arm 2: the mutation. Remove the one architecture from the COMPILED list and keep `sources` as it is --
    # exactly what a hand edit looks like, and what every row but this one passed on main.
    before = json.load(open(registry))
    after = json.loads(json.dumps(before))
    dropped = after["gguf_architectures"]["hrx"].pop(0)
    write(registry, json.dumps(after, indent=1) + "\n")
    pins = run("--check-pins")
    content = run("--check")
    check_that(pins.returncode == 0,
               f"arm 2: --check-pins still passes after dropping {dropped!r} from gguf_architectures.hrx "
               "(the gap this row closes)")
    check_that(content.returncode == 1,
               f"arm 2: --check FAILS on the same edit (rc {content.returncode})")
    check_that("stale" in content.stdout, "arm 2: --check names the generated file, not just a return code")

    # a per-architecture edit too: the other content axis, still green for --check-pins
    write(registry, json.dumps(before, indent=1) + "\n")
    after = json.loads(json.dumps(before))
    name = sorted(after["architectures"])[0]
    after["architectures"][name]["backends"] = []
    write(registry, json.dumps(after, indent=1) + "\n")
    check_that(run("--check-pins").returncode == 0,
               "arm 2b: --check-pins passes after clearing an architecture's backends")
    check_that(run("--check").returncode == 1,
               "arm 2b: --check fails on the per-architecture edit")

    # arm 3: no fork checked out -> 77 (skip), never 0
    write(registry, json.dumps(before, indent=1) + "\n")
    shutil.rmtree(os.path.join(fork, "src"))
    skipped = run("--check")
    check_that(skipped.returncode == 77,
               f"arm 3: without the fork --check skips (rc {skipped.returncode}), it does not pass")
    check_that("not checked out" in skipped.stdout + skipped.stderr,
               "arm 3: the skip says which checkout it needs")

    # arm 4: the fork is checked out, but not at the pin the registry names
    write(os.path.join(fork, "src", "llama-arch.cpp"), ARCH_CPP)
    write(os.path.join(fork, "src", "llama-model.cpp"), MODEL_CPP)
    # a real second commit (an added marker file), so HEAD is a different tree from the pinned one
    write(os.path.join(fork, "MARKER-LATER-COMMIT"), "later\n")
    git(fork, "add", "-A")
    moved_commit = git(fork, "-c", "user.name=t", "-c", "[email protected]", "commit", "-qm",
                       "a later fork commit")
    check_that(moved_commit.returncode == 0 and git(fork, "rev-parse", "HEAD").stdout.strip() != pinned,
               "arm 4: the fixture fork really moved off the pin (an empty commit would prove nothing)")
    moved = run("--check")
    check_that(moved.returncode == 1,
               f"arm 4: a fork at another commit than the pin fails (rc {moved.returncode})")
    check_that("before regenerating" in moved.stdout,
               "arm 4: the failure says the content would come from the wrong tree")

for c in checks:
    print(f"ok   {c}")
for f in fails:
    print(f"FAIL {f}", file=sys.stderr)
print(f"registry_content_test: {len(checks) - len(fails)}/{len(checks)} "
      f"{'passed' if not fails else 'FAILED'}")
return 1 if fails else 0
Skip Code Consistency

The change to use SystemExit(77) instead of sys.exit() for skipping when the fork is not checked out is good for consistency with CTest's expected behavior. However, it's important to ensure that all exit codes are properly handled by the calling environment and that this change doesn't introduce any unexpected behavior in other parts of the system.

def build():
    if not os.path.isdir(os.path.join(ROOT, HRX, "src")):
        # 77, not 1: the content comes from a submodule, so a checkout without it cannot tell, and "cannot tell"
        # must never read as clean. CTest reports 77 as a skip with this message (engine#2698).
        print(f"registry_build: {HRX} is not checked out (git submodule update --init {HRX}): the content "
              f"checks skip here, they do not pass")
        raise SystemExit(77)

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.

ci: registry content is never checked — a hand-edited architectures.json merges green (registry_pins compares only the recorded sha)

1 participant