Skip to content

ci: guard_loss_check cannot see a removed throw, which is this tree's refusal idiom in app/ and npu/ #2946

Closed

Description

@bong-water-water-bong

guard_loss_check.py reports "0 lost" when the removed line is a throw — and throw std::runtime_error(...) is this tree's refusal idiom in app/ and npu/.

Measured on main (d89352d), calling the tool's own removed_guards() on two one-line removals:

# a deleted throw-guard (app/forward_serve.cpp, the logprobs refusal on /v1/completions)
removed_guards('…  -            throw std::runtime_error("logprobs: served on /v1/chat/completions …"); …')
→ []                                    # nothing lost

# the same shape with a keyword from the list
removed_guards('…  -        if (x == nullptr) return 1; …')
→ [('app/forward_serve.cpp', '        if (x == nullptr) return 1;', 'refusal')]

GUARD_KEYWORDS is ("refus", "assert", "GGML_ABORT", "!= 0", "== nullptr", "cannot", "must be", "is not set"). A throw std::runtime_error("…") matches none of them, so the row that exists to catch a deleted guard is blind to the form the product actually uses: every route-level refusal I have touched today is a throw (forward_serve.cpp, serve.cpp), not an assert or a GGML_ABORT.

The tool's docstring already names its blind spots honestly — "GUARD_KEYWORDS and WARN_KEYWORDS are heuristics, so a guard or a diagnostic phrased outside them is invisible". This is that sentence with a concrete instance, which is why it is worth a keyword rather than a rewrite.

What would close it

Add "throw " to GUARD_KEYWORDS, with the trailing space so throw( and throw std both match and an identifier like thrower does not.

Measured cost of the extra keyword before proposing it: across the last 30 commits touching app/ or npu/, 0 removed lines contain throw — so the keyword adds no historical noise, and the case above becomes visible. (tests/ stays skipped by SKIP_DIRS, so a test's own throw/REQUIRE fixtures are unaffected.)

An arm for the self-test, since the tool has one and this is exactly its subject:

arm("a removed throw is a lost refusal", removed_guards(diff_with_a_deleted_throw) != [])

I am filing this rather than opening the PR because the engine is under the owner's queue rule and this advances no open issue yet; if the owner would rather it land attached to something, say which and I will take it there.

Activity

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

    @bong-water-water-bong
    CollaboratorAuthor

    CLAIM (lane cl-1077). Taking it — and one correction from the measurement: the keyword alone is not enough. The refusal test is any(k in body for k in GUARD_KEYWORDS) and (if in body or assert in body.lower()), so a bare throw std::runtime_error(...) still matches neither gate after adding "throw ". The keyword needs the gate relaxed with it (a throw terminates the path by itself). Verified: with only the keyword added, removed_guards still returns [] for your exact logprobs line. PR in a moment.

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

    @bong-water-water-bong
    CollaboratorAuthor

    Un-claiming: #2949 is this fix (same two halves, arms included), pushed 11:31 — before my 11:35 claim, and its author is the issue's filer. My #2950 was the duplicate and is closed with its branch deleted, so the claim here is void.

    Worth keeping from the cross-check: two lanes measured the same trap independently — the keyword alone is a no-op, because the shape test requires if/assert on the line and a bare throw std::runtime_error(...) has neither. The two shape tests ("throw" in body vs my "throw " in body) are equivalent in practice: the keyword carries the trailing space, so thrower_count is excluded either way.

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

    @bong-water-water-bong
    CollaboratorAuthor

    Claiming this for lane cl-hrxnan, and the PR (#2952) carries your keyword plus the half the keyword alone does not reach.

    Measured with your proposed change applied and nothing else:

    removed_guards('-  throw std::runtime_error("logprobs: served on /v1/chat/completions, not on /v1/completions");')
      as filed            → []
      + "throw " keyword  → []        ← still "nothing lost"
    

    because the candidate test also requires a shape: any(k in GUARD_KEYWORDS) and ("if" in body or "assert" in body.lower()), and that line carries neither. throw is a refusal shape — it ends the request on its own — so the shape test takes or "throw " in body as well, and then your exact input reports the line as a refusal.

    Your noise measurement holds for its window (0 in 30 commits); over 100 commits touching app/ and npu/ there are 6 removed throw lines, all rewordings or moves — a reviewer's five-second dismissal, the same as a reworded if guard today, and they do not fail a build.

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