You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(scripts): scope the flaky-test ratchet to check:changed's --base merge base - #33782
pnpm check:changed --base=upstream/main is supposed to check only your changes against the branch you named. One of its sub-checks, the flaky-test ratchet, ignored that and compared against origin/main anyway. If your origin is an older fork, that pulled in a pile of files you never touched, and the run could fail on them. Now the ratchet compares against the same base as everything else.
What Changed
Before:check-changed.mjs turned --base=<ref> into a merge base and used it for the gates it runs itself. The ratchets run as separate pnpm run check:<name> subprocesses, though, and listChangedFiles() in check-flaky-test-pattern-ratchet.mjs ran its own git merge-base HEAD origin/main. On a fork checkout with an old origin/main, its scope included unrelated upstream files.
After:check:changed puts its resolved merge base in ORCA_CODE_QUALITY_BASE in the env it passes to every subprocess. That variable is already the base override that check-changed-code-quality.mjs and check-react-doctor-changed.mjs read. The ratchet's listChangedFiles() now takes its merge base from ORCA_CODE_QUALITY_BASE and falls back to origin/main when it isn't set. Run on its own (for example from pnpm lint), the ratchet behaves as before.
Why
This reuses the base-override env var the other changed-code gates already honor, so we don't add a second one (ORCA_CHANGED_MERGE_BASE, as the original version did). Passing --base as a CLI argument wouldn't fit: the ratchet's only positional argument is already update, and the ratchets are spawned generically from plan.checks. Guessing other refs (such as upstream/main) was ruled out too. Using a ref nobody asked for is the same kind of surprise this bug is about.
N/A. This only changes developer tooling scripts, so there's no UI or visible app behavior. The regression test below covers the behavior change directly.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New regression test in check-flaky-test-pattern-ratchet.test.mjs. It builds a throwaway git repo whose origin/main sits behind an upstream commit. With no override, the scope includes both the upstream-drift file and the contribution. With ORCA_CODE_QUALITY_BASE set to the upstream commit, the scope is only the contribution.
pnpm test config/scripts/check-flaky-test-pattern-ratchet.test.mjs config/scripts/check-changed*: 4 files and 49 tests pass.
Static gates on the touched files are clean: anti-slop oxlint, native code-quality oxlint, ast-grep, check-changed-code-quality.mjs, and oxfmt.
Platforms: macOS arm64. The change is plain Node and git plumbing with no platform-specific paths.
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Security: the env var is only read inside the process tree that check:changed spawns. No new external input.
Cross-platform: pure Node script change.
Remote/SSH/mobile: not affected, since this is local dev tooling only.
Backwards compatibility: without the env var, the ratchet's standalone behavior is unchanged.
Performance: no extra git calls.
Original fix by @eatmoreduck in #33782. Maintainer follow-up switched to the existing ORCA_CODE_QUALITY_BASE override and made the test hermetic.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
The changed-file check now passes its resolved merge base to subprocesses through ORCA_CODE_QUALITY_BASE. The flaky-test ratchet uses that value when set and otherwise uses origin/main. A new test checks both cases using a Git fixture with a stale origin/main reference.
Priority: Normal
Severity of issue fixed: Medium
Merge Risk: Low · up to 156bb
The reported standalone ratchet command can check the wrong files, and the test fixture may fail or touch another repository when Git location variables are inherited. The main check:changed path remains functional; these bounded issues should be fixed or explicitly accepted before merging.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surv…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: aligning the flaky-test ratchet with check:changed's resolved base.
Description check
The description covers the required sections, linked issue, behavior before and after, rationale, testing, platform considerations, and checklist status. It is sufficiently complete despite the full r…
Linked Issues check
Issue #33763 requires the flaky-test ratchet to use the base selected by check:changed --base=<ref>. The PR sets ORCA_CODE_QUALITY_BASE to the resolved merge base for spawned checks. `listChangedF…
Out of Scope Changes check
The changes are limited to base forwarding, ratchet base selection, and focused regression coverage. Each change supports issue #33763. No unrelated change is established.
Full details: Description check
Explanation
The description covers the required sections, linked issue, behavior before and after, rationale, testing, platform considerations, and checklist status. It is sufficiently complete despite the full repository command checklist remaining unchecked because CI may cover it.
Full details: Linked Issues check
Explanation
Issue #33763 requires the flaky-test ratchet to use the base selected by check:changed --base=<ref>. The PR sets ORCA_CODE_QUALITY_BASE to the resolved merge base for spawned checks. listChangedFiles() reads that variable and retains origin/main as the standalone fallback. The regression test verifies that a stale origin/main includes upstream drift, while the forwarded base includes only the contribution.
Full details: Docstring Coverage
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 3 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
56-56: Trivial · Maintainability & Code Quality · Heavy lift
Make the base-selection tests deterministic.
The first test distinguishes the bases in this checkout, but it relies on the live repository state. It does not guarantee different file sets in every test checkout. The second test does not clear ORCA_FLAKY_TEST_RATCHET_ALL and accepts null; an inherited override can therefore bypass base selection.
Use a controlled Git fixture with different expected file sets for HEAD and the fallback base. Clear ORCA_FLAKY_TEST_RATCHET_ALL in the fallback test. The first test already clears it.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 10788bb6-b6c7-4260-a3bc-2fd4142250f6
Commits
Reviewing files that changed from the base of the PR and between 44ac5e2 and e48a08b.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Addressed the fallback-test gap in cfb9f74 — it now clears ORCA_FLAKY_TEST_RATCHET_ALL alongside the base var, so an inherited override can no longer bypass base selection and pass vacuously.
On determinism for the first test: it compares the ratchet's scope against an independently recomputed git diff over the same base, so it cannot false-pass through checkout drift — and the two paths genuinely diverge in both live states (an empty working tree makes the env path return an empty set while the origin/main path returns the full fork delta; a dirty tree recomputes both sides from the same state). A dedicated git fixture would pin the states further, but for these two properties the live-repo assertion is already discriminating in either checkout shape, so I kept it light rather than adding fixture scaffolding to the scripts test suite.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
…d base
check:changed --base=<ref> resolved a merge base for the gates it drives
directly, but the flaky-test ratchet subprocess re-derived its scope from
origin/main. On a checkout whose origin is a stale fork that pulled in
unrelated files and could fail the run. check:changed now forwards its
merge base via ORCA_CODE_QUALITY_BASE (the env the other changed-code
gates already honor), and the ratchet uses it before falling back to
origin/main.
Fixesstablyai#33763
Co-authored-by: yu.xia <yuxianice@163.com>
nwparker
changed the title
fix(scripts): scope the flaky-test ratchet to check:changed's resolved base
fix(scripts): scope the flaky-test ratchet to check:changed's --base merge base
Oct 27, 2026
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Data Integrity & Integration · Quick win
Supported by static analysis
Script executed:
sed -n '275,320p' config/scripts/check-changed.mjs
rg -n 'spawn|env:|ORCA_CODE_QUALITY_BASE|ORCA_CHANGED_MERGE_BASE' config/scripts/check-changed.mjs
Repository: stablyai/orca
Length of output: 2131
Support both base variables without changing check:changed precedence.
The standalone command sets ORCA_CHANGED_MERGE_BASE, but the ratchet reads only ORCA_CODE_QUALITY_BASE and otherwise uses origin/main. Add the documented variable after ORCA_CODE_QUALITY_BASE, so an inherited value cannot override check:changed's resolved base.
Keep the fallback test clear of both base variables.
Committable suggestion
IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Stability & Availability · Quick win
Clear inherited Git repository variables for the fixture.
If a Git hook starts this test with GIT_DIR or related variables set, cwd: fixture does not ensure that Git uses the temporary repository. The fixture commands can target the caller’s repository instead, and the test can fail or alter its index. Clear repository-location variables for both the fixture commands and the listChangedFiles calls, then restore the test environment. Git documents this requirement for commands run against a different repository. (git-scm.com)
Based on learnings, Git subprocesses targeting temporary repositories must clear inherited repository-location variables.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
pnpm check:changed --base=upstream/mainis supposed to check only your changes against the branch you named. One of its sub-checks, the flaky-test ratchet, ignored that and compared againstorigin/mainanyway. If youroriginis an older fork, that pulled in a pile of files you never touched, and the run could fail on them. Now the ratchet compares against the same base as everything else.What Changed
check-changed.mjsturned--base=<ref>into a merge base and used it for the gates it runs itself. The ratchets run as separatepnpm run check:<name>subprocesses, though, andlistChangedFiles()incheck-flaky-test-pattern-ratchet.mjsran its owngit merge-base HEAD origin/main. On a fork checkout with an oldorigin/main, its scope included unrelated upstream files.check:changedputs its resolved merge base inORCA_CODE_QUALITY_BASEin the env it passes to every subprocess. That variable is already the base override thatcheck-changed-code-quality.mjsandcheck-react-doctor-changed.mjsread. The ratchet'slistChangedFiles()now takes its merge base fromORCA_CODE_QUALITY_BASEand falls back toorigin/mainwhen it isn't set. Run on its own (for example frompnpm lint), the ratchet behaves as before.Why
This reuses the base-override env var the other changed-code gates already honor, so we don't add a second one (
ORCA_CHANGED_MERGE_BASE, as the original version did). Passing--baseas a CLI argument wouldn't fit: the ratchet's only positional argument is alreadyupdate, and the ratchets are spawned generically fromplan.checks. Guessing other refs (such asupstream/main) was ruled out too. Using a ref nobody asked for is the same kind of surprise this bug is about.Linked Issue
Fixes #33763
Visual Proof
N/A. This only changes developer tooling scripts, so there's no UI or visible app behavior. The regression test below covers the behavior change directly.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New regression test in
check-flaky-test-pattern-ratchet.test.mjs. It builds a throwaway git repo whoseorigin/mainsits behind an upstream commit. With no override, the scope includes both the upstream-drift file and the contribution. WithORCA_CODE_QUALITY_BASEset to the upstream commit, the scope is only the contribution.pnpm test config/scripts/check-flaky-test-pattern-ratchet.test.mjs config/scripts/check-changed*: 4 files and 49 tests pass.Static gates on the touched files are clean: anti-slop oxlint, native code-quality oxlint, ast-grep,
check-changed-code-quality.mjs, and oxfmt.Platforms: macOS arm64. The change is plain Node and git plumbing with no platform-specific paths.
Review
Agent skill upstream boundary
Notes
check:changedspawns. No new external input.Original fix by @eatmoreduck in #33782. Maintainer follow-up switched to the existing
ORCA_CODE_QUALITY_BASEoverride and made the test hermetic.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)