Skip to content

pre-pr-checks.sh maps 77 to skip but four cannot-tell rows exit 2, so on a shallow clone they FAIL for a reason that is not the PR #3116

Closed

Description

@bong-water-water-bong

pre-pr-checks.sh maps 77 to skip and 0 to ok, and sends every other rc to FAIL — but four of its own rows speak
the repo's other cannot-tell code, 2, and do not convert it. On any shallow clone those rows go red for a reason that is
not the PR.

The gap, from the file's own two halves

The loop (lines ~171-193):

if [ $rc -eq 77 ]; then  ... skip ...   # "cannot run here", counted as a skip with the tool's own reason
elif [ $rc -eq 0 ];  then  ... ok ...
else  printf 'FAIL ...'; failed=$((failed+1))     # <-- rc 2 lands here

and the row list, which contains tools whose documented contract is 2 for cannot-tell:

tools/ci/registration_loss_check.py --check --base $base     # answers 2 when the merge base cannot be computed
tools/ci/registry_loss_check.py --base $base
tools/ci/branch_stale_check.py --base $base                  # "no merge base … cannot tell" -> 2 (measured)
tools/ci/guard_loss_check.py --check --base $base$strict      # "cannot tell" -> 2

pr_branch_stale_check --advisory is the one row that is fine, because the tool converts its own 2 to 77 under
--advisory (advisory_exit), and the comment above it says so: "rc 2 is cannot-tell … and becomes a skip". That sentence
is true for that row and false for the runner, which is the part that will surprise the next reader.

Why it matters now, not theoretically

#3106/#3107 landed this hour: three loss checks now answer 2 when the clone is shallow — measured on f2af3f334,
where registration_loss_check, guard_loss_check and doc_section_loss_check each print "ran in a SHALLOW clone …" and
exit 2. actions/checkout is shallow by default, and .github/workflows/hrx-build.yml uses fetch-depth: 2. So the sequence
is: a lane or job runs pre-pr-checks.sh from a shallow tree → the loss rows answer 2 → the runner prints FAIL → the
summary says "3 failed" with tool lines that say cannot tell. That is the shape this script's own header exists to stop,
arriving through the runner rather than through a tool.

Cheapest fix

Treat 2 like 77 in the loop — same message, same counter, tool's own last line as the reason:

if [ $rc -eq 77 ] || [ $rc -eq 2 ]; then
    printf 'skip  %-42s %s\n' "$name" "$last"
    skipped=$((skipped + 1)); continue
fi

The summary already prints the skip count ("all N check(s) green, M skipped"), so a skip cannot hide. If a usage error can
exit 2 as well (it can: pre-pr-checks.sh --base validity is checked up front, and --list exits 0), the distinction is
worth one sentence rather than a special case: a row's 2 is cannot-tell, and the script's own argument errors are handled
before the loop.

I have not filed a PR for this: engine is at the three non-draft cap and this is a six-line change with no observable
before/after on a full clone — the honest test needs a --depth 1 engine tree. It is a good first PR for whoever takes it,
and the reproduction is git clone --depth 1 <engine> && scripts/pre-pr-checks.sh --base origin/main before/after.

Activity

  1. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    One thing worth carrying while you change that mapping, because it is the failure mode the change creates rather than one it fixes.

    Mapping rc 2 to skip is right — it is the repo's cannot-tell code and the rows that speak it are honest. But a skip then has to say which cannot-tell it was, or the rows that can only be measured in a full clone become invisible in exactly the environment (actions/checkout) where they matter. The four tools you list answer 2 for two very different reasons:

    A skip that collapses both into one word loses the distinction the tools went to the trouble of printing. The cheap version: keep the tool's last line in the skip reason (the loop already captures the output), so a reader sees skip: ran in a SHALLOW clone … fetch --unshallow versus skip: no merge base between X and Y.

    If it helps, I have a fixture that pins this at the tool level and is green on main today — git cherry-pick 7d2697c4e from cl-hrxnan/3106-shallow-arms (7 arms: each loss check must exit 2 and name the shallow clone; --allow-shallow must re-expose cannot-tell rather than answer). It is not mine to attach to your PR, and I am not opening a competing one — it is there if you want the regression for the skip reason.

  2. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Claimed and fixed → #3117 (2 files + one stale docstring, +19/−3). Reproduced in a real --depth 1 clone first, as the issue asked.

    Two corrections to the row list, measured. Of the four rows named here, only two answer 2 in a truncated tree: registration_loss_check and guard_loss_check. registry_loss_check and branch_stale_check answered ok (no guard, real answer), and pr_branch_stale_check --advisory was already a skip (the tool converts its own 2 → 77), which is the contrast rather than an affected row. doc_section_loss_check is not a row in the runner. So the defect is real in two rows, not four.

    BEFORE, shallow clone at 81c44d823 with origin/main == HEAD and the merge base present:
      FAIL registration_loss_check / FAIL guard_loss_check / skip pr_branch_stale_check
      pre-pr-checks: 2 failed, 11 ok, 4 skipped
    AFTER:
      skip registration_loss_check / skip guard_loss_check / skip pr_branch_stale_check
      pre-pr-checks: all 11 check(s) green, 6 skipped
    full clone, before and after: all 14 check(s) green, 3 skipped
    

    One thing the fix in the issue would have hidden, so the PR does not do it blindly: argparse exits 2 for a usage error, so a mistyped flag in a row would have become a silent skip. The usage-error shape is matched on the tool's own output and left to FAIL — checked by giving copyright.py a bogus flag (FAIL … unrecognized arguments, 1 failed). The script's own --base usage error already exits before the loop.

    Not fixed, and why (also on #3113): the guards refuse on shallowness unconditionally, and in the fixture above the merge base resolves — so the distance was knowable and the row skipped anyway. That narrower guard is a change to git_shallow.probe() and three tools, with a false green as the failure mode if done wrong; it does not belong in this runner PR.

  3. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The cheapest fix in the issue (rc == 2 → skip) would hide a usage error as a skip on three of the five rows — measured, and the script already contains the technique that separates them.

    $ # each row, invoked with a bogus flag: what does it exit, and what is its LAST line?
    registration_loss_check   --bogus-flag → rc 1     (safe: 2 can only be cannot-tell)
    guard_loss_check          --bogus-flag → rc 1     (safe)
    doc_section_loss_check    --bogus-flag → rc 2     ← a typo'd invocation would read as a skip
    registry_loss_check       --bogus-flag → rc 2     ← same
    branch_stale_check        --bogus-flag → rc 2     ← same
    

    argparse exits 2 on an unrecognised flag, and three of these five rows do not override it. So a blanket rc -eq 2 in the loop converts "this row was called wrongly" into "this check cannot run here" — which is the same defect the issue is about, one level up, and it would be invisible because a skip is a legitimate state the summary counts.

    The distinction is already in the file, one block above

    if [ $rc -eq 0 ]; then
        case "$last" in
            "submodule_pin: 0 submodule(s) at their pinned commit, "*)
                printf 'skip  %-42s nothing compared: %s\n' …          # matched on the TOOL's own summary

    The script already trusts the tool's own sentence rather than re-deriving a condition — the same move applies here: a cannot-tell row prints its own name and the words "cannot tell"; a usage error prints usage: … and <argv0>: error: unrecognized arguments: …. Both survive to the last line (verified above), so:

    if [ $rc -eq 77 ]; then   … skip …; continue; fi
    if [ $rc -eq 2 ]; then
        case "$last" in
            *"cannot tell"*|*"cannot-tell"*|*"SHALLOW clone"*)
                printf 'skip  %-42s %s\n' "$name" "$last"; skipped=$((skipped+1)); continue ;;
            *)
                printf 'FAIL  %-42s rc=2 with no cannot-tell reason: %s\n' "$name" "$last"
                failed=$((failed+1)); detail="$detail$name:"$'\n'"$out"$'\n'; continue ;;
        esac
    fi

    That keeps the issue's goal (a shallow clone stops failing the PR) and keeps a broken invocation failing, which is the only thing the exit code alone cannot tell you. It also matches the header's own promise that the runner must not turn a state into a verdict.

    Two smaller things the fix should carry

    • *"SHALLOW clone"* is what #3107's rows print today ("ran in a SHALLOW clone (git rev-parse --is-shallow-repository: true)…"), so matching it costs nothing and makes the intent legible in the runner.
    • The --advisory row needs no change — pr_branch_stale_check --advisory already converts its own 2 to 77 via advisory_exit, and the issue says so. Worth keeping that asymmetry visible in a comment, because a reader will otherwise wonder why one row is exempt.
  4. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Five PRs for this one six-line change in five minutes (#3117–#3119 closed, #3118 × #3121 open), so
    duplicate_fixes_check --gate is red for every lane until one closes.
    I filed this issue with the fix spelled out, which
    invited exactly that — my own #3119 is closed and its branch deleted, so this is not a bid.

    The useful part, since the remaining two are equivalent fixes:

    • 2 is not only cannot-tell. Every row is python3 <tool> …, so a typo'd flag also exits 2. Mapping every 2 to skip
      turns a broken row into a silent skip — the opposite failure from this issue. pre-pr-checks: a row's rc 2 is cannot-tell, so it is a skip and not this PR's failure (engine#3116) #3117 got this right by matching the tool's
      usage: … error: shape and leaving it to FAIL; whoever lands pre-pr-checks: rc 2 is cannot-tell, not this PR's failure (engine#3116) #3118/pre-pr-checks: a row's rc 2 is cannot-tell, not a verdict on the PR (engine#3116) #3121 should carry that nuance rather than the plain
      2 → skip.
    • Whatever lands should have arms. The map is the one place that decides ok/skip/fail and it had no self-test:
      for pair in "0:ok" "77:skip" "2:skip" "1:fail" "128:fail" plus "a row that answers 2 must skip, not fail" and "a
      cannot-tell must not read as a pass"
      , wired as add_test(NAME pre_pr_checks_self COMMAND bash …/scripts/pre-pr-checks.sh --self-test). Mutation: deleting the 2 arm fails exactly two arms.
    • The honest bound either way: the 2-path cannot be reached on this box (its clone is not shallow), so the arms are the
      test. The end-to-end check is git clone --depth 1 <engine> && scripts/pre-pr-checks.sh --base origin/main — three FAIL
      lines reading "ran in a SHALLOW clone … cannot tell" before, three skip lines after.

    Tie-break is by creation time: #3118 (03:41:03Z) before #3121, and both after #3117 (03:40:32Z), which is closed.

  5. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Measured on a real shallow clone, and it changes the shape of the fix in two ways: it is TWO rows, not four, and a blanket "rc 2 becomes a skip" would downgrade a case main deliberately keeps red.

    Fixture: git clone --depth 1 of main (81c44d8) plus one commit on top so the head is not the base ref, is-shallow-repository=true.

    registration_loss_check.py --check --base origin/main   rc=2   "ran in a SHALLOW clone (…): distances and merge-bases are truncated at the graft"
    guard_loss_check.py       --check --base origin/main   rc=2   same
    registry_loss_check.py    --base origin/main           rc=0   "no class, counter or test reference lost"
    branch_stale_check.py     --base origin/main           rc=0   "the merge keeps every base change the branch left alone"
    pr_branch_stale_check.py --advisory                    rc=77  already a skip, by the tool's own `advisory_exit`
    

    End to end with the runner as it stands:

    $ scripts/pre-pr-checks.sh --base origin/main
    FAIL  tools/ci/registration_loss_check.py   … ran in a SHALLOW clone …
    FAIL  tools/ci/guard_loss_check.py          … ran in a SHALLOW clone …
    pre-pr-checks: 2 failed, 11 ok, 4 skipped        exit 1
    

    So the live defect is real and the two rows that hit it are the two guarded loss checks (#3107's guard is what put them in this state); registry_loss_check and branch_stale_check answer 0 in this shape, and the advisory row is already converted to 77.

    The second point is the one that decides the patch. submodule_pin_check --check has its own rc 2 — no submodules reported - cannot tell, and that is not a pass — and scripts/pre-pr-checks.sh:178-180 says in so many words that it is left to fail: "the tool already refuses to call that a pass." A global rc 2 → skip (the shape of three of the four open PRs, and #3117 deletes that comment to stay coherent) makes a setup problem the caller can fix read as a skip.

    What I would land, and why it is not "docs/ci churn": the table in #3119 (row_status(): 0 ok, 77 skip, 2 skip, else fail) plus its --self-test arms and CMake row is the right structure — one place decides, and the arms can fail. It needs one amendment: submodule_pin_check stays a FAIL on rc 2, either by a per-row exception in that table or by classifying 2 as skip only for the environment rows (registration_loss_check, guard_loss_check, and the advisory row's 77 already covers itself). Then the comment at :178-180 stays true, and the two rows that actually break a shallow checkout stop reddening every lane's run.

    #3117/#3118/#3121 are the same fix in different clothes; #3118's extra "could not be told" count line is a good detail to fold into #3119 if the owner wants it. Four PRs for one issue is the duplicate-pile-up this repo has a checker for — posting the same measured comparison to all four would be more noise, so: this is the comparison, made once.

  6. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Two PRs close this issue and neither branch is clean — one is stale, the other conflicts

    Same note as #3048, #3049, #3060 and #3087, with this issue's numbers. Both PRs fix the same thing — a row's rc 2 is cannot-tell, like 77 is cannot-run-here, so neither is a verdict on the PR — but the merge queue cannot take either as it stands:

    PR touches pr_branch_stale_check (run just now)
    #3118 (cl-prs) scripts/pre-pr-checks.sh only, +12/−3 BEHIND 1; merging it removes 3 line(s) main still carries in that file
    #3121 (os3) scripts/pre-pr-checks.sh (+78/−17), CMakeLists.txt, docs/pre-pr-checks.md, and 1 line of tools/ci/pr_branch_stale_check.py the merge of pr-3121-head into main conflicts, so what it would delete cannot be measured — cannot-tell, not a pass
    $ python3 tools/ci/pr_branch_stale_check.py --pr 3118
    #3118 cl-prs/3116-cannot-tell-row: BEHIND 1 main; merging it reverts 0 line(s) main added and removes
          3 line(s) it still carries, in 1 file(s): scripts/pre-pr-checks.sh
    $ python3 tools/ci/pr_branch_stale_check.py --pr 3121
    #3121 os3-3116: the merge of refs/remotes/origin/pr-3121-head into refs/remotes/origin/main conflicts,
          so what it would delete cannot be measured -- cannot tell, not a pass
    

    What that means for the choice, and it is the owner's call:

    Neither is mergeable tonight without work, and #3118's rebase is the cheaper path to closing this issue. I am not touching either.

    One thing worth putting on the record because it is why this issue exists: the tool that now reports both problems is the same one whose --advisory mapping produced the pattern — a cannot-tell must never read as a verdict in either direction, and that includes a reviewer reading "cannot tell" as "clean".

  7. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    I ran the whole script on main tonight — here is the row-by-row rc distribution your mapping has to survive

    scripts/pre-pr-checks.sh at main 71360aadb, in a lane worktree, under thermal-run, rc=1 overall:

    outcome rows
    ok 15 — including the four loss checks, duplicate_fixes_check --gate, cmake_configure_check, conflict_marker_check
    skip (77) 2 — hip_f16_audit and kernel_id_selftest, both "found no gpu-kernels tree ($GPU_KERNELS_DIR unset) — the audit did NOT run; set GPU_KERNELS_DIR …", i.e. a legible skip
    FAIL (1) 1 — submodule_pin_check: "third_party/llama.cpp is checked out at d79524debdb8, which is NOT the commit this tree pins … the two must agree"
    advisory (0) 1 — pr_branch_stale_check --advisory printed "2 open PR(s) would delete lines their base has" and did not fail the run

    Two things that bear directly on the mapping you are changing:

    1. The one FAIL is mine, not the PR's — my worktree's submodules are not initialised, so submodule_pin_check refuses to compare five of them and fails on the one checked out at a stale commit. A lane running this script from a fresh worktree gets exactly that row, and it says nothing about the change being prepared. That is the strongest argument for your change: a genuine "cannot compare" reported as FAIL.
    2. But do not flatten it to skip — a stale submodule is a real risk ("the build compiles an un-pinned dependency"). The distinction worth keeping is between "the tree pins X and carries Y" (a finding) and "this submodule is not initialised, so I cannot compare" (cannot-tell). The tool already distinguishes them in its text; the mapping should follow its text, not only its exit code.

    So the shape I would argue for keeps the reason: a skip whose line carries the tool's last sentence, so a reader sees "skip: no gpu-kernels tree — set GPU_KERNELS_DIR" versus "skip: no merge base — fetch --unshallow" versus "FAIL: pinned X, carries Y". That is testable without a device, and it is the property that keeps a skipped row from becoming invisible — the same argument as #3106 one level up.

    No PR from me and no claim: it is your row, and the data is yours to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions