Skip to content

hrx_f16_narrowing: --write refuses to record a guard LOSS without an explicit flag - #2342

Merged
bong-water-water-bong merged 1 commit into
mainfrom
ratchet-guard-loss
Nov 13, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
ratchet-guard-loss

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

#2340 made --check assert the guard set. This closes the other half: --write could launder the very regression the check catches.

--write is what a pin bump runs, and a bump whose .loom conflicts were resolved taking the other side records a smaller guard set as the new baseline. In that diff there are 34 body changes, so five lost guards disappear in the noise — and from then on --check passes, permanently.

--write on llama.cpp#327's draft corpus:
  REFUSING to write: …mul_mat_id_q4k_f16_wmma_projection.loom would lose its guard marker from the baseline
  REFUSING to write: …mul_mat_id_q5k_f16_wmma_projection.loom would lose its guard marker from the baseline
  REFUSING to write: …mul_mat_id_q6k_f16_wmma_projection.loom would lose its guard marker from the baseline
  REFUSING to write: …mul_mat_id_swiglu_f16_f16_accumulate.loom would lose its guard marker from the baseline
  REFUSING to write: …mul_mat_id_swiglu_f16_f16_wmma_body.loom would lose its guard marker from the baseline
  5 guard(s) would disappear. If the merge really did revert them, fix the merge; if the guard genuinely
  moved, re-run with --allow-guard-loss and say why in the commit
  rc=1

--write --allow-guard-loss on the same corpus:
  rc=0 · wrote 85 body(ies) · 21 accumulator(s) · 5 guard(s)

The property this buys: a guard can leave the baseline only by an argument someone typed, on the record, in a commit message — not as a side effect of the command every bump already runs.

Verified: --check at main's pin still passes (51 / 11 / 10, rc 0); tools/copyright.py --check clean; self-test 37 arms, three of them the refuse / allow / "and the baseline now records none" sequence.

Scope, unchanged from #2340: this guards the presence of a marker, not its correctness. A wrong prescale still needs a known-answer row.

…explicit flag (#2244)

The guard set is asserted by --check now, but --write is the command a PIN BUMP runs, and a bump
resolution that took the other side of a .loom conflict would record a smaller guard set as the new
baseline -- 34 body changes in one diff, the five lost guards invisible in the noise, and from then on
--check passes forever. Recording a loss has to be an act, not a side effect.

So write() compares the guard set it is about to record against the one on disk and refuses when it
would drop any, naming each. --allow-guard-loss exists for the case where a guard genuinely moved.

Verified against the corpus that motivated it: --write on llama.cpp#327's draft (rc 1) names
mul_mat_id_{q4k,q5k,q6k}_f16_wmma_projection, mul_mat_id_swiglu_f16_f16_accumulate and
mul_mat_id_swiglu_f16_f16_wmma_body; with --allow-guard-loss it proceeds and records 85 bodies / 21
accumulators / 5 guards. Self-test 37 arms, three of them the refuse/allow/recorded-it sequence.
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

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

Guard Loss Prevention

The new --allow-guard-loss flag introduces a mechanism to prevent unintentional loss of guard markers during --write operations. This is important for maintaining the integrity of the baseline when merges or updates might silently drop guard markers, which could lead to regression undetected by --check. The implementation correctly identifies guard loss and requires explicit opt-in via --allow-guard-loss to proceed.

old_guards = (baseline_paths((root / GUARD_BASELINE).read_text(encoding="utf-8"))
              if (root / GUARD_BASELINE).is_file() else set())
guard_loss = sorted(old_guards - set(guards))
if guard_loss and not allow_guard_loss:
    for rel in guard_loss:
        print(f"hrx_f16_narrowing: REFUSING to write: {rel} would lose its guard marker from the baseline")
    print(f"hrx_f16_narrowing: {len(guard_loss)} guard(s) would disappear. If the merge really did revert them, fix "
          f"the merge; if the guard genuinely moved, re-run with --allow-guard-loss and say why in the commit")
    return 1
Argument Parsing

The addition of the --allow-guard-loss argument to the argument parser ensures that users must explicitly opt into allowing guard loss during a --write operation. This is a good defensive design choice that prevents accidental data loss or misconfiguration.

ap.add_argument("--allow-guard-loss", action="store_true",
                help="let --write record FEWER guarded bodies than the baseline has; without this a write that "
                     "would drop a guard marker is refused, because a merge can revert one silently (engine#2244)")

@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 4dd6bea: READY

This is the distinction between a ratchet and a rubber stamp, and it is one condition.

guard_loss = sorted(old_guards - set(guards))
if guard_loss and not allow_guard_loss:
    for rel in guard_loss:
        print(f"REFUSING to write: {rel} would lose its guard marker from the baseline")

--write is the operation that turns a ratchet into paperwork: it records whatever the tree currently says, so any regression becomes the new baseline in one command. Refusing on a loss is what keeps the baseline a claim rather than a transcript, and three details make the refusal usable:

  • it names each lost path, not a count — so the person running it knows exactly what they are about to accept;
  • it names both remedies and asks for a reason: "if the merge really did revert them, fix the merge; if the guard genuinely moved, re-run with --allow-guard-loss and say why in the commit" — the escape hatch exists, is spelled out, and is named for what it permits;
  • the flag is --allow-guard-loss, not --force, so the command line records the decision in a form a later reader can interpret.

And it pairs with #2340 exactly: #2340 makes which bodies carry a guard part of the baseline, and this makes a loss of that membership something a human has to state out loud. Without this, #2340's baseline would be one --write away from silently accepting the very regression it was built to catch — the failure #2340's own body measured on #327's draft.

Worth noting as the third refusal-shaped fix in this file's neighbourhood tonight (§#2331's merge base, #2323's reachability, this): in each case the fix was not to compute a better number but to make the tool decline when the answer is not what it looks like.

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