Skip to content

loom coverage: self-test the --manifest id -> file resolution (engine#3156) - #3511

Merged
bong-water-water-bong merged 1 commit into
mainfrom
coverage-manifest-selftest
Nov 25, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
coverage-manifest-selftest

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Follow-up to #3510, which was merged-armed while the self-test had no arm for the --manifest path — the exact reason the wrong input shape got through in #3509.

manifest_arm asserts the resolved (device, model) rows and the unresolved list, not only the verdict: a resolution that matches nothing produces zero rows, and zero rows is a state a verdict-only arm cannot see. 11 arms:

arm asserts
the stick's -1bit suffix is the distribution's, not the name hrx GLM-4.7-Flash-1bit → glm-4.7-flash-q4_k_m.gguf
a resolved id earns a real verdict → COVERED on bytes (rc 0)
...and can still be a finding → DIFFERENT-UPLOAD (rc 1)
stem + quant spec, not prefix Qwen3-4B does not claim qwen3-4b-instruct-2507-q4_k_m.gguf
the instruct model resolves to its own file Qwen3-4B-Instruct-2507-1bit
a repo-style id ending -GGUF resolves unsloth/Qwen3-4B-GGUF
a bare .gguf id is a file name passthrough
an id with no pinned file is reported unresolved, never name-matched
npu rows are not this map's business skipped, and not counted unresolved
one id owning several pins one row per file (the REQUANT mechanism)
mode=, comments, blank and junk lines are not rows parser

The card-writing half of arm() is factored into make_card() so both arms build the same tree. No existing arm changes behaviour — all 11 still pass unchanged.

Control (rows_from_manifest reverted to the #3509 resolver, same test file): 17 ok / 5 failed —

FAIL manifest: the stick's -1bit suffix is not part of the model name (rows [], unresolved ['GLM-4.7-Flash-1bit'])
FAIL manifest: an id resolves on stem + quant spec, not on prefix
     (rows [('hrx','qwen3-4b-instruct-2507-q4_k_m.gguf'), ('hrx','qwen3-4b-q4_k_m.gguf')], unresolved [])
FAIL manifest: the instruct model resolves to its own file (rows [], unresolved ['Qwen3-4B-Instruct-2507-1bit'])

Against the fixed resolver: 22 ok, 0 failed.

Real artifact (unchanged by this commit, re-run after the box reboot): --manifest on /etc/1bit/onebit-models.txt as the box generates it (24 hrx ids) resolves 18 of 24, 6 reported unresolved (MiniCPM-V-4.6, Qwen3-Reranker-0.6B, ZAYA1-8B-PM, flint-40b-a2.5b, jina-reranker-v1-tiny-en, nomic-embed-text-v2-moe), 5 rows COVERED on bytes (GLM 29837ed2, Qwen3-0.6B ac2d9771, Qwen3-4B-2507 3605803b, Qwen3-8B 120307ba, Qwen3.8-27B 2a5f3565) plus 4 DIFFERENT-UPLOAD where the byte comparison ran and failed.

scripts/pre-pr-checks.sh --tree-only --base origin/main: 15 green, 3 skipped, 0 could not be told.

…#3156)

#3510 fixed --manifest to resolve the stick's own ids, but the self-test had no arm for that path -- which is
exactly why the wrong input shape shipped in #3509: it was validated against a manifest synthesised from the
issue's row names, and against the real file it resolved 0 of 24 ids and printed an empty map that read like a
clean one.

This adds arm()'s manifest counterpart, manifest_arm, which asserts the resolved (device, model) ROWS and the
unresolved list rather than only the verdict, because "no rows" is a state a verdict-only arm cannot see. 11 arms:

- the stick's -1bit suffix is the distribution's, not the model name (hrx GLM-4.7-Flash-1bit)
- a resolved id earns a real verdict (COVERED on bytes), and can still be DIFFERENT-UPLOAD
- an id resolves on stem + quant spec, not prefix: qwen3-4b must not claim
  qwen3-4b-instruct-2507-q4_k_m.gguf
- a repo-style id ending -GGUF resolves; a bare .gguf id is a file name
- an id we pin nothing for is reported unresolved, never name-matched
- npu rows are skipped, and are not counted as unresolved either
- one id owning several pins yields one row per file (the REQUANT mechanism)
- mode=, comments, blank and junk lines are not rows

The card-writing half of arm() is factored into make_card() so both arms build the same tree; no existing arm
changes behaviour (11/11 still pass unchanged).

Control: with rows_from_manifest reverted to the #3509 resolver, the new self-test reports 17 ok / 5 failed --
the three -1bit arms resolve to nothing (rows [], unresolved ['GLM-4.7-Flash-1bit']), the instruct arm does the
same, and the prefix arm resolves BOTH files for Qwen3-4B (qwen3-4b-instruct-2507-q4_k_m.gguf and
qwen3-4b-q4_k_m.gguf), i.e. it claims the instruct model's bytes for the base model. Against the fixed resolver:
22 ok, 0 failed.

Real artifact, unchanged by this commit: --manifest on /etc/1bit/onebit-models.txt as the box generates it
(24 hrx ids) still resolves 18 of 24, with 6 reported unresolved (MiniCPM-V-4.6, Qwen3-Reranker-0.6B,
ZAYA1-8B-PM, flint-40b-a2.5b, jina-reranker-v1-tiny-en, nomic-embed-text-v2-moe) and 5 rows COVERED on bytes.

pre-pr-checks.sh --tree-only --base origin/main: 15 green, 3 skipped, 0 could not be told.
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 80e5ad5)

Here are some key observations to aid the review process:

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

Manifest Arm Coverage

The manifest_arm function introduces comprehensive testing for the manifest resolution path, which was previously untested. This is crucial for ensuring correctness, especially given that the previous lack of testing led to incorrect behavior in PR #3509. The arms added cover various scenarios including suffix handling, quant spec validation, and resolution of different ID formats. However, the test coverage should be verified to ensure all possible edge cases are handled, particularly around the interaction between manifest parsing, ID normalization, and file resolution.

def manifest_arm(name, manifest, pins, want_rows, want_unresolved=(), cards=None, want_verdict=None,
                 expect_rc=0):
    """Assert what a MANIFEST resolves to, then (optionally) the verdict those rows earn.

    This is the arm --manifest was missing, and its absence is why the wrong input shape shipped: the shipped
    catalogue names MODELS (`hrx GLM-4.7-Flash-1bit`) and every verdict this tool makes is about a FILE, so
    the manifest path's whole job is the id -> file resolution in between. An arm that asserted only the
    verdict would have passed on a resolution that produced zero rows (there is simply nothing to classify),
    so these assert the resolved (device, model) rows and the unresolved list, and the verdict only on top.
    """
    nonlocal fails, total
    total += 1
    with tempfile.TemporaryDirectory() as td:
        root = pathlib.Path(td) / "cards"
        root.mkdir()
        make_card(root, cards or [])
        mpath = pathlib.Path(td) / "onebit-models.txt"
        mpath.write_text(manifest)
        pins_path = pathlib.Path(td) / "pins.json"
        pins_path.write_text(json.dumps({"pins": pins or {}}))
        ours = pin_bytes(pins_path)
        rows, unresolved = rows_from_manifest(read_manifest(mpath), ours)
        ok = sorted(rows) == sorted(want_rows) and sorted(unresolved) == sorted(want_unresolved)
        got = f"rows {rows}, unresolved {unresolved}"
        if ok and want_verdict is not None:
            rc, lines = check(pathlib.Path(td) / "models.tsv", [root], ours, rows)
            verdicts = [line.split()[0] for line in lines]
            ok = rc == expect_rc and want_verdict in verdicts
            got += f" -> verdicts {verdicts} (rc {rc} want {expect_rc})"
        print(f"  {'ok  ' if ok else 'FAIL'} {name} ({got})")
        fails += 0 if ok else 1
✅ Resolved findings

tools/ci/loom_coverage_check.py:68-89

Manifest Resolution Logic

The new _is_quant_spec function and _named_by helper introduce logic to validate quantization specifications and match filenames to catalogue IDs. While the logic appears sound, it's critical that these functions correctly handle edge cases such as malformed quant specs or unexpected filename formats to prevent incorrect resolution of manifest entries. Specifically, the regex-based quant spec matching and the logic for determining if a filename belongs to a given ID must be robust against variations in naming conventions.

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 80e5ad5

@bong-water-water-bong
bong-water-water-bong merged commit 993b6e7 into main Nov 25, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the coverage-manifest-selftest branch November 25, 2026 09:48
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