fix(checker): skip built-in guard narrowing when its callee is rebound #803
All Vouch review confidence checks passed
Residual risk 0.37 = Change Risk (0.52) × (1 − Review Confidence (0.28)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 58% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #803"
general
weight: 0.35
github-actions[bot]
Built-in guards narrowed by the bare callee name, so
is.null <- function(x) FALSEstill made!is.null(x)drop a NULL default, hiding the RY001 R raises. One gate at the top ofextract_type_narrowingnow walks the guard shapes of the condition (!, binary operators, call heads) and returns no narrowing when one of the built-in callees may be rebound. Condition aliases (has_x <- !is.null(x), #788) and the compound path go through the same function. Other callees, the project's ownis.<class>predicates, and qualified heads are unchanged. The RY032length(x) == 1Lscreen uses the same helper, so a backtick `lengthmask is seen. Lenient resolution keeps guards working underlibrary()and in packages, as in #372. A local data binding namedmissingorlengthkeeps the guard, because R skips non-functions when it looks up a call head.Evidence (CONTRIBUTING):
(narrow.rs),guard_callee_resolves_to_base(resolve.rs),base_length(binop.rs).redefinition, a localis.null<-inside the function, a top-levellength<- function(x) 1Lwithx <- NULL; if (length(x) == 1). RY032 now fires in a package with the backticklengthmask.cases,null_default_guards.RRY001 cases.+!is.null(min) && !is.null(max), the length guards), plus a new no-diag case with localmissing <- "none"; length <- 0L.reports both the tidyverse and the Posit manifests current with the fixed release binary, so no ledger changes and no new diagnostics. In those corpora only roxygen2 rebinds one of these names (a localinherits <- function(type)inR/rd-inherit.R), and none of its findings move.(the CI perf gate) passes: 10/10, same slopes. The gate does hash lookups, plus oneformat!only for a built-in callee name.Proof: the three new null_default_guards.R
cases failed before the fix (expected Codes(["RY001"]), got {}) and pass after. The new quoted-lengthassertion inscalar_guard_packagesmatches a package repro that went from 0 to 1 RY032 withry check. The issue'sisnull.Rwent from 0 findings to4:9 RY001. Under the same redefinition, ahas_x <- !is.null(x); if (has_x)alias and an!is.null(a) && !is.null(b)guard each went from silent to one RY001. The new oracle fixturerebound_guard_predicate.R(must-warn RY001) hasRscript --vanillaconfirmf()errors withargument is of length zerowhilef(1)returns. The pre-fix binary is silent on it and the fixed one warns. I ran locally:cargo test -p ry-checker --lib --test corpus --test scalar_guard_packages --test invariants --test metamorphic --test rule_evidence --test projectpassed. The full oracle matrix (--include-ignored) passed except the known localops_plain_vector_fallback.R(R 4.5structure(NULL)deprecation).cargo fmt --all -- --checkis clean. I did not run workspace tests or clippy locally; CI covers them. Not covered: the scope-free collection pre-pass (missingincollect_parameter_uses_in_stmt, #773) and thestopifnotscalar-fact screens inscalar_assertion_subject, which still match raw spellings.Closes #802
Claude Opus 5.5 on behalf of Max
<!-- greptile_comment -->
<!-- greptile_summary -->
<h2><a href="https://app.greptile.com/api/retrigger?id=87502838"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/RetriggerDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2"><img alt="Retrigger" src="https://greptile-static-assets.s3.amazonaws.com/badges/Retrigger.svg?v=2" align="right"></picture></a><a href="https://app.greptile.com/m0hawk/github/sims1253/ry/-/pull/803"><picture><source media="(prefers-color-scheme: dark)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptileDark.svg?v=2"><source media="(prefers-color-scheme: light)" srcset="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2"><img alt="View in Greptile" src="https://greptile-static-assets.s3.amazonaws.com/badges/ViewInGreptile.svg?v=2" align="right"></picture></a>Confidence Score: 4/5</h2>
<!-- greptile-risk -->
The PR appears safe to merge, with two non-blocking false-warning cases worth fixing.
<h2>Findings</h2>
1. <img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"> Data disables valid guards <a href="https://github.com/sims1253/ry/pull/803#discussion_r4369198108">▶</a>
2. <img alt="P2" src="https://greptile-static-assets.s3.amazonaws.com/badges/p2.svg?v=9" align="top"> Independent NULL facts disappear <a href="https://github.com/sims1253/ry/pull/803#discussion_r4369198112">▶</a>
<h3>Summary</h3>
The PR stops trusting built-in guards when a project or local function replaces their callee.
could lie.Acknowledged scope: sims1253 explicitly deferred scope-free missing
collection andscalar_assertion_subject` in the PR description. sims1253 also explicitly left custom and qualified predicate heads unchanged.<!-- greptile_confidence_score:4 -->
<sub>Reviews (1) · Last reviewed commit: "fix(checker): skip built-in guard narrow..." · Reviewed by Greptile</sub>
<!-- /greptile_comment -->