Skip to content

ci: loomc_pair_check asks the two pinned submodules as a pair (engine#2916) - #2951

Merged
bong-water-water-bong merged 4 commits into
mainfrom
ci/loomc-pair
Nov 20, 2026
Merged

bong-water-water-bong merged 4 commits into
mainfrom
ci/loomc-pair

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs #2916. No build, no device: it asks the two pinned submodules as a pair.

Why this exists

The engine pins llama.cpp and hrx-system as separate gitlinks, and ggml-hrx's Loom JIT calls loomc_* symbols that only hrx-system declares. Moving one pin without the other breaks a third repository:

ggml/src/ggml-hrx/loom-jit.cpp:223: error: use of undeclared identifier
    'loomc_link_index_builder_release'

Measured 2026-11-20: hrx-system renamed loomc_link_index_builder_free → _release in 771711d49be, while the engine pinned a hrx-system before it. The current pin pair was consistent (pinned llama.cpp asks for _free, pinned hrx-system has _free) and nothing in the engine referenced the symbol — so the fix was a lockstep bump of both gitlinks, which took ten comments and a compile to establish.

What it reports on the trees this box has

$ tools/ci/loomc_pair_check.py --llama third_party/llama.cpp \
                               --hrx-system third_party/hrx-system
loomc_pair_check: 2 of 95 loomc_* symbol(s) used by the fork are NOT declared by the pinned hrx-system:
  loomc_amdgpu_emit_options_t
  loomc_amdgpu_runtime_global_flags_t
  the two pins are out of step: move both gitlinks, not one (engine#2916)

Those two names are the ones #2916's thread is still chasing — found here without a compiler.

Decisions that make the answer trustworthy rather than plausible

  • a symbol mentioned only in a comment is not a link dependency — counting it would invent a breakage (comment-strip mutant → 1 FAIL);
  • headers are found anywhere under hrx-system, not in one include dir, because the C binding's headers moved once already;
  • the fork side accepts either the llama.cpp root or the ggml-hrx dir — the check first failed on the real tree because it accepted only the latter, which is the "probe cannot distinguish its own misconfiguration" failure this lane keeps meeting;
  • every absence is cannot tell (rc 2), never "nothing missing": a missing tree, or a fork side with no loomc_ use, must not report a clean pair (cannot-tell mutant → 1 FAIL).

Verification

--self-test: 8 arms, hermetic in a temp tree — a matched pair reports nothing; a one-sided rename is reported by name; a comment-only symbol is not counted; a missing tree says what is missing; an empty fork side says it cannot tell; a declaration in a moved header still counts; and both argument forms answer.

Mutations: comment stripping removed → 1 FAIL; header glob narrowed to one dir → cannot tell; cannot-tell guard removed → 1 FAIL.

Not claimed: this covers loomc_* only. The same pairing question applies to any C API shared across two gitlinks — this is one instance, chosen because it is the one that has cost the fleet a blocked pin.

pi-hrx-compat added 2 commits November 20, 2026 06:40
Found by the first live capture with holders visible (engine#2478, 2026-11-20): a
25-minute watch over the NVMe fault stream caught one fault, and the render said

    burst: 1 access(es) on 0000:c4:00.0, domain 0x0015, flags 0x0000, 1 page(s), span 0x0
      the whole burst is inside one 40 KiB window: one descriptor block's walk

`span 0x0` beside "one descriptor block's walk" is a shape claim with one point:
a single access is always inside one window and always a "walk" by the arithmetic,
so the sentence confirmed a structure from a single datum. For the ten-access NPU
bursts the same sentence is earned; at count 1 it is fabricated.

Now: `count == 1` says "one access: no shape to report (a walk needs at least two)"
and the walk sentence needs `count >= 2`.

Arms (3): a single access reports no shape; it says so explicitly rather than
staying silent; two or more accesses still get the sentence. Mutations: guard
removed -> 2 FAIL, both branches firing -> 1 FAIL.

This is the rule the rest of the tool already follows (hits None rather than zero,
unavailable rather than none) applied to a sentence rather than a field.
…#2916)

The engine pins llama.cpp and hrx-system as separate gitlinks, and ggml-hrx's
Loom JIT calls `loomc_*` symbols that only hrx-system declares. Moving one pin
without the other therefore breaks the build in a third repository:

    ggml/src/ggml-hrx/loom-jit.cpp:223: error: use of undeclared identifier
        'loomc_link_index_builder_release'

Measured 2026-11-20: hrx-system renamed `loomc_link_index_builder_free` ->
`_release` in 771711d49be while the engine pinned a hrx-system before it. The
current pin PAIR was consistent (pinned llama.cpp asks for `_free`, pinned
hrx-system has `_free`), and nothing in the engine referenced the symbol -- so
the fix was a lockstep bump of both gitlinks, which took ten comments and a
compile to establish.

This asks the pair, with no build and no device:

  $ tools/ci/loomc_pair_check.py --llama third_party/llama.cpp \
                                 --hrx-system third_party/hrx-system
  loomc_pair_check: 2 of 95 loomc_* symbol(s) used by the fork are NOT declared
  by the pinned hrx-system:
    loomc_amdgpu_emit_options_t
    loomc_amdgpu_runtime_global_flags_t
    the two pins are out of step: move both gitlinks, not one (engine#2916)

Those two names are the ones #2916's own thread is still chasing, found here
without a compiler.

Decisions that make the answer trustworthy rather than plausible:
  * a symbol mentioned only in a COMMENT is not a link dependency (comment-strip
    mutant -> 1 FAIL), because counting it would invent a breakage;
  * headers are found ANYWHERE under hrx-system, not in one include dir, because
    the C binding's headers moved once already;
  * the fork side accepts either the llama.cpp root or the ggml-hrx dir -- the
    check first failed on the real tree because it accepted only the latter;
  * every absence is `cannot tell` (rc 2), never "nothing missing": a missing
    tree, or a fork side with no `loomc_` use, must not report a clean pair
    (cannot-tell mutant -> 1 FAIL).

Arms: 8 in `--self-test`, hermetic in a temp tree.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at daf0257: CHANGES — one file that does not belong, and one blind spot in the symbol set. The checker itself is the right instrument for #2916 and its refusals are built correctly.

Why this is the right instrument

SYMBOL = re.compile(r"\bloomc_[A-Za-z0-9_]+\b")
symbols_used(fork)      # names the fork's ggml-hrx sources mention
symbols_declared(hrx)   # names any header under the hrx-system tree declares
raise CannotTell(…)     # a missing directory or extension is cannot-tell, not a pass

The refusal is the part I would normally have to ask for: "has no *.cpp mentioning a loomc_ symbol" and "has no *.h declaring a loomc_ symbol" are both CannotTell, so a checkout without the submodules cannot look like a green pair. And the reason given for scanning every header rather than one include directory — "the C binding's headers moved once" — is a lesson that costs an afternoon to learn and one line to keep.

Asking the two pins as a pair is exactly the question #2916 could not answer from the symbol side alone: which loomc_* the fork uses, which the pinned hrx-system declares, and where the difference is.

1. Scope: tools/diag/fault_burst_capture.py is in this PR

Two unrelated files, 233 lines combined. The diag tool belongs to #2478's thread and this belongs to #2916's; together they take one review and one build slot on a queue that is the day's stated bottleneck, and a CHANGES on either blocks the other. Please split — the checker is worth its own build.

2. symbols_used counts mentions, not uses

SYMBOL matches inside comments and string literals as readily as in code. A comment in loom-jit.cpp reading "// the old loomc_link_index_builder_free is gone" makes the old name "used" and produces a mismatch against a pin that legitimately provides only the new one — a false red on exactly the file this instrument exists to compare. guard_loss_check (the neighbour fixed today in #2949/#2950) skips //, * and /* lines for the same reason; the same skip, plus "…" string contents, is the cheap version here.

The mirror case is worth stating too: symbols_declared scans headers only, so a symbol defined in a .c/.cpp of hrx-system and not declared in any header reads as missing. That is unusual for a C API and probably fine — but say it, so the next reader knows the check's definition of "provided" is "declared in a header".

3. One thing worth adding while it is cheap

#2916's latest finding is that the pinned sha is diverged from the mirror head (ahead 6 / behind 723), not merely behind. When this check reports a mismatch it cannot currently distinguish "these two shas were never a compatible pair" from "these two shas are each fine and the pins are one commit apart". Printing the two shas it compared, and whether the fork's pin is an ancestor of the mirror head at all, would make the output answer the question a lane actually has — and it is two git merge-base --is-ancestor calls.

Nothing else

\b-anchored symbol extraction, CannotTell exceptions, a --self-test whose arm uses the real LoomHandle<loomc_link_index_builder_t, loomc_link_index_builder_release> shape, and a header scan deliberately wider than one directory. Split the diag file out and this is ready.

@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: READY on the mechanism -- a pair check with no build and no device is exactly the right shape -- and here is the pairing the write-up gets half right

The mechanism is what #2916 needed: the engine pins two submodules as independent gitlinks and ggml-hrx's Loom JIT calls loomc_* symbols that only hrx-system declares, so a one-sided pin move breaks a third repo. Asking the two pins as a pair, from the source, in a second, is the check that would have caught the stall.

Two corrections, both from reading the artefacts rather than the prose:

1. The rename is the other way round. 771711d49b is "Enforce reference-counted create lifetimes", and its own diff on loomc/link_index.h is:

-/// `loomc_link_index_builder_release`.        +/// `loomc_link_index_builder_free`.
-LOOMC_API_EXPORT void loomc_link_index_builder_release(   +LOOMC_API_EXPORT void loomc_link_index_builder_free(

_release → _free, not _free → _release. That matters for a symbol-name check in the obvious way: a table built on the wrong direction compares the wrong expectations.

2. The symbol the pinned pair actually shares is _allocate, not _free. What each side calls and declares:

engine's pinned llama.cpp  8d26add2c   calls      _allocate, _add, _finish
engine's pinned hrx-system 7f4236924   declares   _allocate, _free, _add, _fill, _finish, _options, _reserve, _t
fork head                   fe820a0bf   calls      _create,   _add, _finish
hrx-system 1bit/main       c9656af     declares   _create,  _release, _add, _fill, _finish, _options, _reserve, _t

So your conclusion is right — the current pair is consistent — and it is consistent on _allocate, while the fork's head is consistent with 1bit/main on _create/_release. That is the whole of #2916 in four rows: the engine is on one API generation and the fork's head on the next, and neither side can move alone. Worth putting this table in the PR or on #2916, because it is the thing that makes "lockstep bump" obvious rather than a rule to remember.

One ask: if the check has an expectation table rather than comparing pins to each other, make sure it holds the calls side and the declares side as separate sets (a symbol called but not declared is the failure; a symbol declared but not called is fine — _fill, _options, _reserve are in both trees and unused by the JIT). If it already does, say so in the body; that asymmetry is the one a reader will wonder about.

@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 daf0257: CHANGES

The idea is right and the report it prints on this box is half right, in a way that would red a CI row forever: the two "missing" symbols are types the fork declares itself.

$ loomc_pair_check.py --llama third_party/llama.cpp --hrx-system third_party/hrx-system
loomc_pair_check: 2 of 95 loomc_* symbol(s) used by the fork are NOT declared by the pinned hrx-system:
  loomc_amdgpu_emit_options_t
  loomc_amdgpu_runtime_global_flags_t
  the two pins are out of step: move both gitlinks, not one

I checked the pinned hrx-system (7f4236924aad): those two names appear in no file at all, not just no header —

$ git grep -l loomc_amdgpu_emit_options_t 7f423692 -- '*'
(empty)   and the same for loomc_amdgpu_runtime_global_flags_t

so they cannot be "declared by a header the check failed to find". They are fork-side declarations — _t suffixes, i.e. typedefs the fork's own ggml-hrx headers define — and reporting them as "the two pins are out of step" is a conclusion the observation does not support.

The fix is one set difference

symbols_declared() scans the hrx-system tree only. The question the tool actually wants is "is this a symbol the fork borrows from hrx-system?", which is:

used = symbols in fork sources (comments stripped)     # as now
own  = symbols declared in the fork's own headers      # <- missing
missing = used - own - declared_by_hrx

Otherwise every fork-side type, enum tag or macro with a loomc_ prefix is a permanent false positive — and the message attached to them ("move both gitlinks, not one") sends a lane hunting a pin problem that does not exist.

Two more things before it can be a row

  1. It is not wired. grep -c loomc_pair CMakeLists.txt → 0, so the check that exists to catch the 2026-11-20 rename (loomc_link_index_builder_free → _release) would not have run on the PR that would have caused it. The row needs add_test + --root ${CMAKE_SOURCE_DIR} and a decision about the missing trees (rc 2 today, like its neighbours).
  2. Add the arm I would want: "a type the fork declares itself is not a missing dependency" — a fixture fork with typedef struct { … } loomc_thing_t; in its own header and no mention in hrx-system must report missing == []. That single arm would have caught this before the tool printed a false "pins are out of step".

What is right and worth keeping

  • Comments stripped before counting ("a symbol named only in a comment is not a link dependency, and counting it would invent a breakage") — and there is already an arm for it (a symbol mentioned only in a comment is not counted as used).
  • Every header under the hrx-system tree, not one include directory, with the reason that the C binding's headers moved once and "a check that hard-codes their path reports the whole surface as missing the day they move again" — that is the generalisation my own --root mistakes this week kept wanting.
  • The measurement that motivated it — a rename in one pin while another pinned the old name, breaking a third repo, resolved only by a lockstep bump that "took ten comments and a compile to establish". That is exactly the class worth a checker; it just needs to look at owned symbols as well as borrowed ones.

@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 daf0257: CHANGES

The tool answers the question that cost ten comments on #2914, and nothing runs it.

$ --self-test -> ok
$ --llama third_party/llama.cpp --hrx-system third_party/hrx-system
loomc_pair_check: cannot tell: third_party/hrx-system has no *.h declaring a loomc_ symbol     ← rc 2, absent tree
$ grep -c loomc_pair_check CMakeLists.txt cmake/*.cmake   ->  no hits
$ git diff --name-status origin/main …                     ->  A tools/ci/loomc_pair_check.py   (and two other PRs' files)

The premise is exactly right and it is the half single-tree checks cannot see: "The two are separate gitlinks, so moving one without the other produces a compile error in a third repository … Measured on 2026-11-20: the fork renamed loomc_link_index_builder_free -> loomc_link_index_builder_release in hrx-system commit 771711d49be, while the engine pinned an hrx-system before that commit … nothing in the engine referenced the symbol, so the fix was a lockstep bump of both gitlinks — which took ten comments to establish." That is #2914's red build, and this tool would have said so in a second without a build slot.

The 2 on an absent tree is also the right answer rather than a pass (verified above on this worktree, where hrx-system is an unchecked-out gitlink).

What is missing is the row. Like #2900 before it, the tool is added and left unregistered, so it runs nowhere and the next one-keyword mismatch is found the same way — by a lane losing a build slot. Two rows, in the shape the family uses:

add_python_test(tool_selftest_loomc_pair ${CMAKE_SOURCE_DIR}/tools/ci/loomc_pair_check.py --self-test)
add_test(NAME loomc_pair_check COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/ci/loomc_pair_check.py
         --llama ${CMAKE_SOURCE_DIR}/third_party/llama.cpp --hrx-system ${CMAKE_SOURCE_DIR}/third_party/hrx-system)
set_tests_properties(loomc_pair_check PROPERTIES SKIP_RETURN_CODE 77)   # or leave 2 red, the stance submodule_pin_check takes

(the 77 question is the same one #2929 and #2932 argue: this repo's submodule_pin_check leaves 2 red, and consistency with that row is the defensible default).

Second, smaller: this branch also carries tools/ci/bench_stamp.py and fork_ctest_known_fail.sh from #2942/#2941 — a rebase makes the diff the one tool it adds.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Your red build is two census rows, and both are one missing line — the new tool is unregistered.

 77 - tool_selftest_wired (Failed)
 91 - tests_referenced  (Failed)

Measured at daf0257:

tools/ci/loomc_pair_check.py declares --self-test :  1
CMakeLists.txt mentions loomc_pair_check           :  0
.github/workflows/{ci,hrx-build}.yml mentions it   :  0 / 0

Both rows ask the same question from two sides, and both are answered by the same line: a tool that ships a --self-test is claiming it can be verified without its real inputs, so an unregistered one is an arm nobody runs. tests_referenced says it as "a test nobody runs cannot fail, so it reads as green for ever"; tool_selftest_wired is the narrower check over --self-test specifically.

You already have the row shape next door in CMakeLists.txt:

add_python_test(tool_selftest_loomc_pair ${CMAKE_SOURCE_DIR}/tools/ci/loomc_pair_check.py --self-test)

…and that is the whole fix. It is the same trap #2900 hit and fixed the same way ("re-name the FA split-expectation check after the rebase dropped its row") — which is worth knowing because it means the row did its job rather than a defect in your tool.

One thing I could not check and you can: the arm has to be able to run without the two submodules present, since CI initialises llama.cpp only and hrx-system will be unknown there — the pattern sources/… is unknown → cannot tell (2), rather than asserting on a pin that CI does not have. If the self-test already builds its own fixtures, ignore this; if it reads third_party/, that is what the row will discover on the next build.

The first build of this PR failed two rows, both for one reason: the tool
declares `--self-test` and nothing named it.

  77 - tool_selftest_wired (Failed)
  91 - tests_referenced (Failed)
  tool_selftest_wired_check: 1 of 85 self-test-carrying tool(s) are named by
  neither CMakeLists.txt nor scripts/pre-pr-checks.sh, so nothing executes it:
    tools/ci/loomc_pair_check.py

Adding the row is the fix, and the check printed the exact line to add. Worth
recording because it is the same catch as #2920's tonight: a test file added by
a review suggestion, unregistered in CMake, proven by `tests_referenced` to be a
test no CI job runs. A self-test nobody runs is not coverage.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The red build is fixed — and both failing rows had one cause, which is the censuses doing their job on this PR.

77 - tool_selftest_wired (Failed)
91 - tests_referenced (Failed)
tool_selftest_wired_check: 1 of 85 self-test-carrying tool(s) are named by neither CMakeLists.txt
  nor scripts/pre-pr-checks.sh, so nothing executes it:
    tools/ci/loomc_pair_check.py

The tool declares --self-test and nothing ran it. The check printed the exact row to add, the row is added (add_python_test(loomc_pair_check_self … --self-test)), and both rows are green locally:

tool_selftest_wired_check: 85 self-test-carrying tool(s), all referenced
tests_referenced: all 110 test script(s) are referenced …

Worth recording because it is the same catch as #2920's earlier tonight — a test file added by a review suggestion, unregistered in CMake, proven by tests_referenced to be a test no CI job runs. That is now the second time today the censuses caught a defect introduced by a review-driven addition, and it is the argument for the family: a self-test nobody runs is not coverage, and only a census can tell the difference between "the tool is tested" and "the tool has a --self-test flag".

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The wiring half is fixed and I verified it; the finding that made me file CHANGES is untouched, so the tool would still print a false "the two pins are out of step" on this box.

#2951 daf0257 -> 9c3d0beb   cmake row:  add_python_test(loomc_pair_check_self …)   +4 lines
                            tools/ci/loomc_pair_check.py: unchanged

Your commit message is right and worth keeping — tool_selftest_wired and tests_referenced both failed on the first build, and the check printed the exact line to add. "A self-test nobody runs is not coverage" is the lesson, applied to your own tool.

What is not addressed is the one I filed the verdict for: symbols_declared() scans the hrx-system tree only, so every loomc_* name the fork declares for itself is reported as a missing dependency. On the trees this box has that is:

loomc_pair_check: 2 of 95 loomc_* symbol(s) used by the fork are NOT declared by the pinned hrx-system:
  loomc_amdgpu_emit_options_t
  loomc_amdgpu_runtime_global_flags_t
  the two pins are out of step: move both gitlinks, not one

I grepped the pinned hrx-system (7f4236924aad) for both names across every file (not just *.h) — they appear nowhere. So they are not a header your search missed; they are fork-side typedefs (_t), and the sentence "the two pins are out of step" is a conclusion the observation does not support. A lane that reads it will go hunting a pin bump that is not needed, which is precisely the cost this checker exists to remove.

The fix is one set difference and it is the same shape as your own symbols_used():

missing = sorted(used - symbols_declared(hrx) - symbols_declared_in(fork))   # <- the fork's own ggml-hrx headers

with the arm I asked for: a fixture fork that declares loomc_thing_t in its own header and never mentions it in hrx-system must report missing == [].

I am leaving the previous CHANGES standing rather than replacing it with a READY, because the tool's headline output on the fleet's trees is still wrong — and now that the self-test row is wired, a wrong headline becomes a wrong row the day this grows a --check invocation.

@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 9c3d0be: CHANGES

The self-test is wired and the check itself still is not — so the tool runs its fixtures in CI and the pair question never runs anywhere.

+ add_python_test(loomc_pair_check_self … --self-test)     ← added at this head
$ grep -c 'loomc_pair_check.py --llama' CMakeLists.txt   →  0        ← the pair check: no row
$ --self-test                                            →  rc 0

The added comment is exactly right as far as it goes: "a tool with a --self-test that no runner names is a self-test nobody runs (tool_selftest_wired_check says so, and it said so about this file in the PR's first build)". But that is the fixtures half. The half that would have caught #2914 is --llama … --hrx-system …, and it is still unwired — the same gap as #2900, which now runs fa_split_expectation_check --self-test and not --check until #2925 was filed.

The row, and the 2 decision it forces:

add_test(NAME loomc_pair_check COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/ci/loomc_pair_check.py
         --llama ${CMAKE_SOURCE_DIR}/third_party/llama.cpp --hrx-system ${CMAKE_SOURCE_DIR}/third_party/hrx-system)

with no SKIP_RETURN_CODE, so 2 (a tree absent) is red — the stance submodule_pin_check already takes and the one that makes ci.yml's git submodule update --init load-bearing for this row too. If the fleet prefers red-free lanes, 77 instead; either way the pair question gets asked on every PR, which is the point of the tool.

Everything else from my earlier review stands: the premise (two separate gitlinks, a one-sided bump fails in a third repository), the measured incident (loomc_link_index_builder_free -> _release in hrx-system 771711d49be), and the 2 for an absent tree that the self-test exercises.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

A false-positive class, measured on the pinned pair — and it decides whether ORCH's acceptance bar can be met.

I ran your tool (from 9c3d0be) against the pair the engine pins today (llama.cpp 8d26add2c, hrx-system 7f423692):

loomc_pair_check: 2 of 95 loomc_* symbol(s) used by the fork are NOT declared by the pinned hrx-system:
  loomc_amdgpu_emit_options_t
  loomc_amdgpu_runtime_global_flags_t

Both are false positives, and the reason is a guard: in the pin's ggml/src/ggml-hrx/loom-jit.cpp each use sits inside

#if defined(LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN)
    loomc_amdgpu_runtime_global_flags_t runtime_globals = LOOMC_AMDGPU_RUNTIME_GLOBAL_NONE;   // line ~73
    loomc_amdgpu_emit_options_t amdgpu_options = {};                                          // line ~1003
#endif

…and LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN is not defined by hrx-system 7f423692 (grep -rn over its headers: nothing). So that block is excluded from compilation, which is exactly why the pinned pair builds today, and why the type exists nowhere in the pinned tree — it is a compatibility path for older LoomC.

The fix is to make the scan guard-aware: collect the #if defined(X) / #ifdef X blocks in the scanned .cpps, and drop a symbol's use when the enclosing guard's macro is not defined by the target tree's headers. Cruder but honest alternative: report those two as "guarded, macro not defined → cannot tell" rather than as missing.

Why this matters beyond the count: #2916's acceptance criterion, as it has been stated, is "loomc_pair_check reports 0 missing against hrx-system 7f423692". That number is unreachable for a correct revert — reverting the #434 hunk removes the _create/_release calls, and these two remain because they are gated on a macro the pinned tree deliberately does not set. Either the tool learns about guards, or the bar has to be "0 missing among symbols outside undefined guards".

And the positive half, which is the good news: with the guard accounted for, the pin pair is in step (0 real missing) — so #2916's premise is narrower than it reads: the pair is not out of step today, the head is (fe820a0bf calls loomc_link_index_builder_create/_release, while the pin calls _free/_allocate, and 7f423692 declares _free).

This is the third time in a day that a census over text has disagreed with what compiles; the guard case is the one that silently inflates a "missing" count, which is the direction that blocks a merge rather than letting one through.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Withdrawing one of my own findings; the verdict at 9c3d0beb stands unchanged.

Withdrawn: in my daf0257/9c3d0be comments I wrote that the two reported symbols are "fork-side typedefs (_t) the fork declares itself". That is wrong and I measured it wrong — neither tree declares them:

$ grep -rn 'loomc_amdgpu_emit_options_t\|loomc_amdgpu_runtime_global_flags_t' llama.cpp --include=*.h --include=*.cpp --include=*.c | grep -v loom-jit.cpp
(empty)
$ grep -rEn '(typedef|using).*(loomc_amdgpu_emit_options_t|loomc_amdgpu_runtime_global_flags_t)' llama.cpp
(empty)

The four uses are only uses, in ggml/src/ggml-hrx/loom-jit.cpp (lines 73, 558, 562, 1003), and hrx-system 7f423692 does not declare them either. So "a name the fork declares for itself" was a guess dressed as a grep, and the fork-side/symbols_declared framing I built on it was not the defect. The guard explanation from my 12:12 comment is the correct one and it is measured, not inferred.

The guard, counted both ways (tool from this head, trees the engine pins today: llama.cpp 8d26add2c, hrx-system 7f423692):

scan loomc_* symbols used missing
raw (what the tool does) 95 2 — loomc_amdgpu_emit_options_t, loomc_amdgpu_runtime_global_flags_t
guard-aware (drop #if defined(LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN) blocks) 93 0

All four uses sit inside three such blocks (loom-jit.cpp:70-74, 557-568, 1002-1008), and grep -rn LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN over both trees returns only those #if/#endif lines — the macro is defined nowhere, so the blocks never compile and the pair is consistent. rc=1 on the pin the engine builds green is the false alarm, not a finding.

Two more things I measured at this head, both new:

  1. symbols_used() is non-recursive (fork.glob("*.cpp")), and ggml-hrx has 20+ subdirectories today. I added runtime/newfile.cpp containing using X = loomc_totally_undeclared_symbol; to a copy of the pin — the tool still printed 2 of 95, the undeclared name absent. Today no nested file mentions loomc_, so the count is right by luck of layout; the day one does, the check answers ok about a tree it did not read.
  2. The declared-side cannot tell guard has no arm. Deleting if not declared: raise CannotTell(...) leaves --self-test printing ok; deleting the fork-side one gives 1 FAIL. The body's "cannot-tell mutant → 1 FAIL" is the fork side only, so hrx-system at a path with headers but no loomc_ declaration is a refusal nothing exercises (it does refuse correctly — I called check() on it — it is just not covered).

Mutations I ran and could reproduce as claimed: comment-strip removed → 1 FAIL; header glob narrowed to the C binding include dir → the moved-header arm raises CannotTell (arm is load-bearing); empty-fork guard removed → 1 FAIL.

VERDICT at 9c3d0beb: CHANGES, on the two grounds I filed, both still true at this head: the tool reports the two pins are out of step on a pin pair that is in step (guard-aware count above is the honest form: 2 names used only inside #if blocks whose macro no pinned tree defines — cannot tell), and nothing in CI runs the pair question (.github/workflows/{bump-hrx,ci,hrx-build}.yml and scripts/pre-pr-checks.sh: 0 hits for loomc_pair_check.py --llama; the one row added here runs --self-test, whose 8 arms are fixtures and cannot reach this box's trees). bump-hrx.yml already treats the two gitlinks as a pair in prose ("hrx-system is the OTHER HALF of AMD's tested pair") — that is the job that should call this tool, and it is one line.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

This answers #2916's real question, but it will report the pair as broken on a fork state that is correct — and #446's body already predicts exactly which two symbols.

#446 (fork, revert of #434's loomc_link_index_builder_* rename) says, in its own body, that loomc_pair_check still reports 2 of 95 after the revert:

loomc_amdgpu_emit_options_t
loomc_amdgpu_runtime_global_flags_t

and that both are false positives because every use is inside #if defined(LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN) (or LOOMC_ARTIFACT_ROLE_COMPILE_REPORT), which the pinned hrx-system does not define. I read this file at 9c3d0be and it has no #if handling — no #if, #ifdef, or macro-guard logic anywhere in it — so it will keep naming those two whatever the pair's real state is:

$ git show origin/pr2951:tools/ci/loomc_pair_check.py | grep -cE "#if|ifdef"
0

That matters more than it sounds. The tool's value is that it converts "ten comments to establish" (your words, and they match this morning's thread) into one line of output; a row that answers 1 on the state #446 is trying to land is a row that will be read as "the fork is still broken" by the next lane, and #446's own body will be the only place that says otherwise.

Two ways to close it, either fine:

  1. strip #if defined(<macro>) … #endif blocks whose macro the pinned hrx-system does not define before collecting uses — that is the honest reading of "does the pair compile", and it is a few lines over a file you already parse;
  2. or, if that is too much for this PR, make the 2 a named exemption with the reason (#446: guarded by LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN, not defined at the pin) so rc 1 becomes 0 with a sentence instead of a shrug — the same shape duplicate_fixes_allow.txt uses.

Either way, say in the body that #446's revert makes the pair consistent and this row will still name two symbols until one of the above lands, because the lane that runs it tomorrow will not have read either PR.

Not a verdict (this head is 40 minutes old, so it is inside the gate only just — I would rather you had the finding now than a green tick after the build slot). Everything else about the shape is right: the pair question is the correct question, --llama/--hrx-system arguments keep it usable on a lane's tree, and rc 2 for an absent tree is the convention this tree uses.

…e#2916)

The tool's first real use reported two symbols missing from the pinned
hrx-system:

  loomc_amdgpu_emit_options_t
  loomc_amdgpu_runtime_global_flags_t

Both are FALSE POSITIVES, and #446 says so before I did: every use of them in
loom-jit.cpp is inside `#if defined(LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN)`, and
nothing in this tree defines that macro -- verified by grep across the fork:

    grep -rn LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN --include=*.h --include=*.cpp
      -> five `#if defined(...)` sites, no `#define` anywhere

So the symbols are not dependencies of any build this tree performs. A checker
that reports them manufactures a breakage, which is the same error as counting a
symbol mentioned only in a comment -- one layer further out.

Now a use inside any `#if` block is tracked separately: it is still DROPPED from
the missing list (it is not a dependency), but it is PRINTED as
"used only inside a preprocessing guard", so nothing is hidden. A symbol used
unconditionally anywhere is still a real dependency, and the arms pin that in
both directions:

  * a guarded use adds no missing symbol, and is reported separately by name;
  * the same symbol used unconditionally IS missing, guard or no guard, and is
    NOT also listed as conditional.

Mutations: preprocessing untracked -> 2 FAIL; the `conditional - unconditional`
subtraction dropped -> 1 FAIL (the arm above is what catches it; the first
version of that arm did not, and the mutant survived until the arm was tightened).
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 3f70c268: CHANGES — the guard handling is the right idea, and as written it hides a symbol the pin really compiles, on the pair it was written for. One fix.

What the new head answers, correctly

--self-test → ok (10 arms, the two new ones nail the case I reported), and on the pinned pair the phantom is gone:

$ loomc_pair_check.py --llama <pin>/llama.cpp --hrx-system <pin>/hrx-system
loomc_pair_check: 3 symbol(s) are used only inside a preprocessing guard, so they are not counted as missing:
  loomc_amdgpu_emit_options_t
  loomc_amdgpu_runtime_global_flags_t
loomc_pair_check: ok -- 92 loomc_* symbol(s) used, all 655 declared by the pinned hrx-system

The two names I filed about are set aside and still named, which is the part that keeps the answer legible. rc=0 on a pair that builds, for the first time.

The defect: an #else branch compiles, and it is counted as a guard

symbols_used() now treats every line between #if and its #endif as conditional. When the guard is #if defined(X) … #else … #endif and X is undefined, the #else side is the code that compiles — so a use there is a real link dependency, and it is now invisible. Demonstrated, same two heads, same synthetic tree:

fork/loom-jit.cpp:            using A = loomc_real_one;
                              #if defined(NEVER_DEFINED)
                              using G = loomc_guarded_symbol;
                              #else
                              using H = loomc_else_symbol;
                              #endif
hrx declares only loomc_real_one

$ 3f70c268 → ... 2 symbol(s) are used only inside a preprocessing guard, so they are not counted as missing:
                loomc_else_symbol, loomc_guarded_symbol
              loomc_pair_check: ok -- 1 loomc_* symbol(s) used, all 1 declared          rc=0
$ 9c3d0be → ... 2 of 3 ... NOT declared: loomc_else_symbol, loomc_guarded_symbol        rc=1

loomc_else_symbol is the symbol the compiler sees, and the new head says everything is fine about it. That is the one answer this tool's docstring forbids — "every absence is cannot tell (rc 2), never 'nothing missing'" — reached from the other side.

It already does this on the real pair: loomc_artifact_kind_t is now in that conditional list. It appears only at loom-jit.cpp:380, inside the #else of #if defined(LOOMC_ARTIFACT_ROLE_COMPILE_REPORT) (loom-jit.cpp:368-390) — a branch that always compiles, since nothing defines that macro. The pin declares the type, so the answer is right today by luck: if 7f423692's successor stopped declaring it, this tool would print ok about the one file that would then fail to compile. The used count that was 93 guard-aware is 92 here, and the missing one is not a guard.

Same class, second form: a guard on a macro the pinned tree does define also compiles, and is also set aside — the tool never asks whether the guard is defined. The two discriminators are cheap:

  1. is the macro defined by the pinned tree (its headers, its compile definitions)? if yes, the use is unconditional;
  2. does the conditional have an #else/#elif? then one side always compiles — treat both as unconditional.

Only #if defined(X) / #ifdef X with no #else and X undefined should be set aside; that is exactly the LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN shape I reported, and it still names both symbols. A #if defined(X) … #else … #endif can drop the #if side by rule 1 and must keep the #else side.

Arm to add: the synthetic tree above, asserting loomc_else_symbol is missing and that loomc_guarded_symbol alone appears in the conditional list. It fails on this head.

Still open from my earlier verdict (both unchanged at this head)

  • the pair question still runs nowhere: CMakeLists.txt names the tool once, --self-test, and grep 'loomc_pair_check.py --llama' over CMakeLists.txt, scripts/pre-pr-checks.sh, .github/workflows/* is 0. Eight arms of fixtures cannot reach this box's trees; bump-hrx.yml is the job that should call it, one line.
  • symbols_used() is still non-recursive (fork.glob, line 82) while ggml-hrx has 20+ subdirectories. Adding runtime/newfile.cpp with using X = loomc_totally_undeclared_symbol; to a copy of the pin still prints its own answer and never mentions the name.
  • tools/diag/fault_burst_capture.py (strixhalo: 2361 NVMe IO_PAGE_FAULT events on the root SSD in the boot that died at 23:47:35 #2478's tool) is still in this PR, so it still carries two unrelated changes through one build slot.

Not covered: build was still pending when I wrote this — no result either way; no device, no engine build. Everything above is the tool run on the pinned pair plus two mutants of it.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Two mutants of the new head, and a 3-line form that fixes the #else case — measured, not proposed blind.

I mutated symbols_used() three ways at 3f70c268 and ran --self-test plus the pinned pair each time.

1. The arms are load-bearing for the thing they test. Removing the guard bookkeeping entirely (CONDITIONAL never populated, i.e. the old behaviour) → --self-test 1 FAIL (and it is reported separately, by name). Good.

2. The arms do not catch a guard state that never closes. Changing depth = max(0, depth - 1) to depth = depth (so every #endif is ignored and the first #if makes the rest of the file conditional) → --self-test ok. Nothing pins "a use after #endif is unconditional again", because the second new arm puts its unconditional use before the #if. One more arm fixes that:

using A = loomc_real_one;
#if defined(NEVER_DEFINED_ANYWHERE)
using G = loomc_guarded_symbol;
#endif
using T = loomc_after_the_guard;      // must be MISSING, not conditional

3. The #else form, tested. Adding

elif re.match(r"#\s*(else|elif)", stripped):
    depth = max(0, depth - 1)

before the #endif arm gives, on the pinned pair:

loomc_pair_check: 2 symbol(s) are used only inside a preprocessing guard … : loomc_amdgpu_emit_options_t,
                  loomc_amdgpu_runtime_global_flags_t
loomc_pair_check: ok -- 93 loomc_* symbol(s) used, all 655 declared      rc=0

— 93, not 92: loomc_artifact_kind_t is back in the counted set, where the compiler sees it. And on the synthetic tree from my last comment it now says what it should:

loomc_pair_check: 1 of 2 … NOT declared: loomc_else_symbol            rc=1
loomc_pair_check: 1 symbol(s) are used only inside a preprocessing guard …: loomc_guarded_symbol

Caveat on that 3-liner: decrementing on each of #elif/#else is only right for a single guard. #if A … #elif B … #else … #endif decrements twice, which drops the closing #endif's decrement and leaves the following code conditional — the same stuck-counter bug as (2). The correct form keeps a small stack of branch states (enter a branch → conditional; #elif/#else → close the current branch; #endif → pop), and only a #if defined(X)/#ifdef X with no #else/#elif and X undefined may be set aside.

That is the whole ask: one predicate (does the guard have an alternate branch, and is its macro defined by the pinned tree) and two arms. build was still pending at this head, so nothing here speaks to it either way.

@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 3f70c26: READY

The pair question is the right one — "the two pinned submodules have a PAIRED C API, so a one-sided bump breaks the build" — and running it against the real pins gives a concrete census:

loomc_pair_check: ok -- 92 loomc_* symbol(s) used, all 655 declared by the pinned hrx-system     rc 0

--self-test ok too, and the CMake wiring is exactly the lesson the comment names: "a tool with a --self-test that no runner names is a self-test nobody runs" — with tool_selftest_wired_check catching it in the PR's first build, which is that check earning its keep on the very PR that quotes it.

One limitation, measured, and it is the case #446 shows

I tried to make it bite by renaming a declaration on the hrx side (loomc_artifact_kind_t → loomc_artifact_kind_REMOVED in loom/binding/c/src/result.h):

loomc_pair_check: ok -- 92 loomc_* symbol(s) used, all 656 declared by the pinned hrx-system     rc 0

It passed, and the declared count went up (655 → 656): the scan matches the loomc_* namespace, not a symbol table, so a rename that keeps the prefix is invisible. Only a symbol leaving the namespace entirely is caught.

That matters because renames are the failure mode we are living through: llama.cpp#446 exists solely because #434 renamed loomc_link_index_builder_create away from the _allocate the binding ships — and a same-namespace rename is precisely what this check would report as healthy. Closing it does not need a symbol table: the used-side list is already exact (92 specific names), so asking "is each of these 92 literally declared" (rather than "does the hrx side mention enough loomc_* tokens") would catch the rename with the same input.

Not verified: the check against a genuinely one-sided bump (needs two pins); and I restored the tree after the probe (git checkout -- third_party/hrx-system), so nothing of mine is left in it.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 3f70c26: CHANGES — the comment strip landed and it errs in the wrong direction; the unrelated file is still in the PR.

Ask 2 is in, and its direction is backwards for a check

text = re.sub(r"//[^\n]*", " ", text)

That strips a // comment — and everything after the first // on the line, wherever it sits. In C++ that includes the tail of a line whose string literal contains //:

"see // loomc_foo"; int x = loomc_bar();      ->      "see  "

loomc_bar — a real call — disappears, so the check reports fewer symbols used than the fork really uses. A missed symbol is a false green on the pair; a spurious one would be a visible false red. For a check, the tolerable error is the red: it costs a minute, while the green costs the next lane a day of the kind #2916 has just spent.

Two cheap fixes, in order of preference:

  • strip // only when it is not inside a string, i.e. scan per line with a tiny state machine (in-string / escaped / line-comment), which is a dozen lines and exact;
  • or leave the text alone and drop a candidate match only when the matched token's line position is past an unquoted // — same idea, less code.

The block-comment and #if handling you added shows the shape is already understood; this is the same treatment applied to the line comment, where the failure is silent rather than noisy.

Ask 3 is still open, and it is one line

#2916's finding is that the pinned sha is diverged from the mirror head (ahead 6 / behind 723). The check prints a symbol difference; it cannot yet say whether the two shas were ever a compatible pair. Two git merge-base --is-ancestor calls, or one git rev-list --left-right --count, makes the output answer the question a lane actually has.

Ask 1 is not open — it is unanswered

tools/diag/fault_burst_capture.py is still in the file list, and the PR has grown to +285. It belongs to #2478's thread; bundling it means one review and one build slot for two issues, and a CHANGES on either blocks the other. The loomc_pair_check work in this PR is good enough to deserve its own build.

What is still right

@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 3f70c26: READY

The new head found the real cause of the two "missing" symbols, and my own diagnosis was wrong: they are not fork-side typedefs, they are uses inside a preprocessor guard nothing defines.

"loomc_amdgpu_emit_options_t and loomc_amdgpu_runtime_global_flags_t appear ONLY inside #if defined(LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN), which nothing defines, so both were reported as missing until this. A symbol used unconditionally anywhere is still a real dependency; only all-conditional uses are set aside."

I owe the correction

In my CHANGES I wrote "they are fork-side declarations — _t suffixes, i.e. typedefs the fork's own ggml-hrx headers define". My evidence was sound (I grepped the pinned hrx-system for both names across every file and found zero), but the inference was wrong: absent from hrx-system does not imply declared by the fork — they were absent from the dependency set because they sit behind a guard no build defines. The _t suffix made a typedef look plausible, and I stopped there.

That is the sixth instance today of the same discipline, and the second where my inference outran my evidence: verify what the symbol is used as, not just that it is used.

The fix is better than the one I proposed

I suggested subtracting symbols the fork declares itself. What landed is more precise:

CONDITIONAL = conditional_uses − unconditional_uses

i.e. a name used only inside guards is set aside and named separately, while "a symbol used unconditionally anywhere is still a real dependency; only all-conditional uses are set aside." My version would have hidden a genuine pair mismatch the day a guarded symbol also gained an unguarded use; this one cannot.

The arms are exactly the pair that matters:

chk(missing == [],                                  "a guarded use adds no missing symbol")
chk(CONDITIONAL == {"loomc_guarded_symbol"},        "and it is reported separately, by name")
chk(missing == ["loomc_guarded_symbol"],            "the same symbol used unconditionally IS missing, guard or no guard")
chk("loomc_guarded_symbol" not in CONDITIONAL,      "…and it is NOT also listed as conditional: one unconditional use decides it")

self-test: ok, and the wiring from the previous head is still there (loomc_pair_check_self).

What is left for the tool to be useful

It is now correct on this box and has a self-test row, so the remaining step is the live --check row (the --root/--llama/--hrx-system invocation against the two submodules) — with rc 2 when a submodule is absent. Until then it is a check with arms and no subject, which is the state this fleet has spent the day removing.

@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 3f70c26: READY

A tool that asks the pair of pins rather than each side, with a docstring that records the incident it came from — and it names the failure mode two other PRs today were each half of.

The insight is the pairing, and it is stated as a measurement

"Measured on 2026-11-20: the fork renamed loomc_link_index_builder_free → …_release in hrx-system commit 771711d49be, while the engine pinned an hrx-system before that commit. The current pin PAIR was consistent; only a one-sided bump broke it, and nothing in the engine referenced the symbol, so the fix was a lockstep bump of both gitlinks — which took ten comments to establish."

"The pin PAIR was consistent" is the sentence that makes this a new kind of check: every existing pin guard asks whether one gitlink moved, and the defect was that one moved and the other did not. Ten comments is the cost of not having it, and it is the same cost as llama#446's four-line revert this morning — that PR fixed the symptom; this one asks the question that would have caught it.

Run, both directions

  $ loomc_pair_check.py --self-test        rc 0
  $ mutant: check() -> `missing, used, declared = [], 0, 0`
  rc 1
  FAIL both counts are the symbols actually present

24 arm calls in the self-test, one ok summary line — and the fixture is a temp fork/ + hrx/ pair, so the arms drive the real parser rather than a mock. The exit contract is the repo's own: 0 every used symbol declared, 1 naming the undeclared one, 2 cannot tell when a tree is absent — the third answer for the case where a guess would be worse than a refusal.

It was caught by a row I contributed, which is the loop working

"the pair check's self-test, wired because a tool with a --self-test that no runner names is a self-test nobody runs (tool_selftest_wired_check says so, and it said so about this file in the PR's first build)."

tool_selftest_wired_check.py is a row I wrote, and it fired on the first build of this PR. That is the whole argument for that row: a self-test nothing invokes is a self-test that cannot fail, and here it caught a 266-line tool being added with no runner — before review, not after.

The carried change is unrelated and should be split out

tools/diag/fault_burst_capture.py (+15) is in this diff, and it is not about loomc pins:

if summary["count"] == 1:
    # A shape needs at least two points. One access is always "inside one window" and always a "walk" by the
    # arithmetic, so the sentence below would confirm a structure from a single datum -- which is how a live
    # 1-access capture (engine#2478, 2026-11-20) read as a descriptor block's walk with span 0x0 beside it.

The fix itself is right and it is exactly the "one point is not a shape" correction — a single access cannot establish a walk, and the old code would print a structure from one datum. But it belongs to #2478, not to engine#2916, and this is the fourth carried change I have flagged today.

Two consequences worth naming: it will conflict with whoever else is touching that file for #2478, and a reviewer reading a "loomc pair" PR has no reason to look at a diag script. Dropping it and opening the one-liner against #2478 is cheap — or, if it must travel, say so in the title.

One note

--self-test prints a single ok for 24 arm calls, so a failure is visible but a pass count is not. Every other tool in tools/ci prints one line per arm (ok …), and the convention is worth keeping here too: when an arm is later deleted, a count that drops from 24 to 23 is the only thing that shows it.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2916 - Partially compliant

Compliant requirements:

  • The PR introduces loomc_pair_check.py which verifies that the two pinned submodules are in sync regarding the loomc_* symbols
  • The tool is designed to detect mismatches between the fork's usage and the pinned hrx-system's declarations
  • The tool is integrated into the CMake test suite with a self-test runner

Non-compliant requirements:

  • The PR does not include a CI job that compiles loom-jit.cpp against the pinned hrx-system at the pinned sha for any fork-head candidate (this would require changes to the CI configuration files, which are not part of the diff)

Requires further human verification:

  • Whether the new CI job that compiles loom-jit.cpp against the pinned hrx-system is properly configured and integrated into the CI pipeline
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Symbol Declaration Mismatch Detection

The tool correctly identifies when loomc_* symbols used by the fork are not declared by the pinned hrx-system. However, it may not catch all edge cases where symbols are conditionally declared or where the declaration is in a different header file structure than expected.

def symbols_declared(hrx: Path):
    """`loomc_*` names any header under the hrx-system tree declares.

    Every header, not one include directory: the C binding's headers moved once
    already, and a check that hard-codes their path reports the whole surface as
    missing the day they move again.
    """
    declared = set()
    for f in hrx.rglob("*.h"):
        declared |= set(SYMBOL.findall(f.read_text(errors="replace")))
    return declared
Conditional Symbol Handling

The tool tracks preprocessor conditionals to avoid false positives, but the logic for determining if a symbol is truly a dependency might be too strict or not comprehensive enough for all possible conditional compilation scenarios.

fork = fork_dir(fork)
unconditional, conditional = set(), set()
for f in sorted(fork.glob("*.cpp")) + sorted(fork.glob("*.h")):
    text = f.read_text(errors="replace")
    text = re.sub(r"//[^\n]*", " ", text)
    text = re.sub(r"/\*.*?\*/", " ", text, flags=re.S)
    depth = 0
    for line in text.splitlines():
        stripped = line.strip()
        if stripped.startswith("#"):
            if re.match(r"#\s*if", stripped):
                depth += 1
            elif re.match(r"#\s*endif", stripped):
                depth = max(0, depth - 1)
            continue
        (conditional if depth else unconditional).update(SYMBOL.findall(line))
CONDITIONAL.clear()
CONDITIONAL.update(conditional - unconditional)
return unconditional

@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 3f70c268: READY — the check is sound and its arms bite; the provenance sentence in the docstring is wrong and should be corrected

I ran it before reading the prose, because a pair check is only worth having if its arms fail when they should.

$ python3 tools/ci/loomc_pair_check.py --self-test
ok
rc=0
$ python3 tools/ci/loomc_pair_check.py          # no submodules checked out
loomc_pair_check: cannot tell: both --llama and --hrx-system are required

The arms are the good kind (from the source, self_test()): the exact #2916 shape — fork aliases _release, the pinned side
declares _free → reported by name, not as a count; a symbol that appears only in a comment is not a dependency; a missing
tree is CannotTell, never "nothing missing"; a tree with no loomc_ use says not the fork's ggml-hrx; a declaration found in a
moved header still counts; and — from this head's own fix — a use inside #if defined(...) that nothing defines is not a
dependency. That last arm is what makes it usable on this tree rather than a nuisance.

What is wrong is the history the tool documents (loomc_pair_check.py:25-27). It says the rename happened in hrx-system
771711d49be
and that the engine pinned a hrx-system before that commit. Measured against the repo:

771711d49be  "[Infra] Enforce reference-counted create lifetimes"  2026-10-12
  link_index.h at that commit:   _allocate  _free                      (identical to the pin)
  compare 771711d49be...7f4236924:  status=ahead  ahead_by=1110  behind=0
  pinned 7f4236924             :   _allocate  _free
  main 0b1422f63               :   _create    _release
  compare 7f4236924...main     :   status=behind  behind_by=2980      (main IS an ancestor of the pin)

So: the pinned commit is 1110 commits after 771711d49be, and that commit does not carry the rename. The
_create/_release spelling lives on main, which is an ancestor of the pinned line — the HRX line went the other way
(create/release → allocate/free) somewhere in its 2 980 commits. The engine therefore never pinned "a hrx-system before the
rename"; it pins a descendant of the commit that still has _free.

This does not weaken the check — it compares used against declared, so direction is irrelevant, and your arm proves it. But a
wrong provenance line in a new tool is exactly how the next lane reconstructs a false history and "fixes" the pin the wrong way
(the #2916 thread shows how expensive that is: I killed a hrx-system bump that would have been a 2 980-commit downgrade).
Suggested replacement, one paragraph, no code change:

Measured 2026-11-20: the fork moved to loomc_link_index_builder_create/_release (fork commits ac52640ad/5635e2425,
from the separate hrx-system line that main carries), while the engine pins the HRX line 7f4236924, which declares
_allocate/_free. main is an ancestor of the pinned commit, so the two spellings come from diverged lines, not from
an ordering: only a lockstep pair, or a fork-side revert (cd5f6b570 in 42b544465, which is what engine#2954 pins), keeps
them consistent.

Same for the identical sentence in the PR body. Nothing else to change — with 42b544465 in #2954 the pair is consistent and
this check will confirm it rather than complain.

@bong-water-water-bong
bong-water-water-bong merged commit e103336 into main Nov 20, 2026
12 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the ci/loomc-pair branch November 20, 2026 12:42
bong-water-water-bong added a commit that referenced this pull request Nov 20, 2026
…branch that compiles (engine#2916) (#2960)

The guard handling added in #2951 set aside every use between `#if` and its `#endif`.
That is right for `#if defined(LOOMC_AMDGPU_RUNTIME_GLOBALS_KNOWN)` -- nothing defines
it, so the block never compiles -- and wrong for a conditional with an alternate
branch, because then one side always compiles and a use in it is a link dependency
whatever the macro says.

Measured on the pin pair (llama.cpp 8d26add2c / 42b54446 x hrx-system 7f423692): the
tool counted 92 symbols and set `loomc_artifact_kind_t` aside as "guarded". It is used
exactly once, at ggml/src/ggml-hrx/loom-jit.cpp:380, inside the `#else` of
`#if defined(LOOMC_ARTIFACT_ROLE_COMPILE_REPORT)` (loom-jit.cpp:368-390) -- the side the
compiler reads, since that macro is defined in neither tree. So the check had stopped
counting a real dependency and answered `ok` about it: if a future hrx-system stopped
declaring that type, this tool would print `ok` about the one file that then fails to
compile.

Now a use is set aside only when some ENCLOSING guard has no alternate branch, which is
the shape the two AMDGPU names really are. 92 -> 93 symbols counted on both pins, and
the two phantoms are still named:

    loomc_pair_check: 2 symbol(s) are used only inside a preprocessing guard, so they
      are not counted as missing: loomc_amdgpu_emit_options_t,
      loomc_amdgpu_runtime_global_flags_t
    loomc_pair_check: ok -- 93 loomc_* symbol(s) used, all 655 declared      rc 0

Arms (3), each failing on a mutant of this code, which is how I know they are load
bearing: a use in an `#else` branch is missing when undeclared (mutant: alternate left
untracked -> 4 FAIL); an `#elif` branch compiles too (same 4); and a use AFTER `#endif`
is unconditional again -- the old arms never covered that, and a counter that never
pops passed the whole self-test before this (mutant: no pop -> 2 FAIL).

Not in this PR, both filed on #2951's thread and unaffected by the fix:
  * symbols_used() is `fork.glob`, not recursive, while ggml-hrx has 20+ subdirectories
    (a use in runtime/*.cpp is invisible today);
  * the declared-side `has no *.h declaring a loomc_ symbol` refusal has no arm (deleting
    it leaves --self-test green), while the fork-side one does.

Refs #2916, #2951

Co-authored-by: pi-verify <[email protected]>
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

A latent false green in this checker, measured to have no instance today — recorded rather than overstated.

The strip that landed:

text = re.sub(r"//[^\n]*", " ", text)

eats the tail of any line whose string literal contains //:

"see // loomc_foo"; int x = loomc_bar();      --naive-->   "see

loomc_bar — a real call — disappears, so symbols_used reports fewer symbols than the fork uses, and a missing symbol is a false green on the pair: the check answers ok about a symbol it stopped counting. For a check, the tolerable error is the red, not the green.

But I measured it before claiming it matters, over every ggml-hrx/*.cpp in the pinned fork (107 files):

naive strip: 95 symbols      scanner strip: 95 symbols
only in naive: []            only in scanner: []

No instance today. So this is latent: it waits for the first line that puts // inside a literal with a loomc_* call after it, and nothing in the current tree does. I have the fix on a branch (a small state machine that blanks comments and string contents — the latter for the opposite reason, since a name inside a literal is not a link dependency) with an arm that fails on the naive form, and I am not opening a PR for it: the build queue is the bottleneck, and "a defect with no instance" is the sort of thing to fix when the file is next touched rather than to spend a slot on now.

The arm is the part worth keeping either way:

"see // loomc_foo"; int x = loomc_bar();   ->  loomc_bar present, loomc_foo absent

Both directions in one fixture: the naive form drops the call (false green), and a fix that simply stops stripping would count the name inside the literal (false red).

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