Skip to content

fix(ci): run static analysis for every tree the repo-wide audits scan - #20918

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/audit-scan-roots-gate-mobile
Sep 16, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/audit-scan-roots-gate-mobile

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​36 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​31
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​58 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​57

Problem

A diff touching only mobile/ is classified desktop-irrelevant, so should_run is false — and every job is shouldRun && (...), so all PR checks skip, including the three in ALWAYS_ON_CODE_JOBS. Being "always on" does not survive should_run being false.

But the repo-wide audits lint mobile:

audit trees it scans
audit:code-quality:native src config tests mobile
audit:anti-slop src config tests mobile
audit:code-quality:type-aware src config tests

So a mobile-only PR can land a violation that no check ever evaluated, and because CI lints the merge ref, it then fails static analysis on every later PR until someone sweeps it. Mobile Checks does not cover the gap: its Lint step runs with working-directory: mobile, and mobile's own lint script is plain oxlint, without these plugin configs.

Measured today — two incidents, both from mobile-only PRs whose static analysis was SKIPPED, each blocking the whole queue until a standalone sweep:

What changed

static_analysis is now triggered by whether a changed path falls under a tree the audits actually scan, derived from those commands' own argv in package.json rather than from a second hand-maintained list. mobile_dependencies follows it, because the changed-code pass needs mobile types.

should_run is untouched, so a mobile-only diff still skips typecheck, test, package, e2e and the rest — this adds one job, not the desktop suite.

Deriving rather than adding 'mobile/' to a list is the point: the defect is two copies of "which trees the gate reads" disagreeing. Read off the commands, adding a tree to an audit widens the trigger by itself, and a ratchet test asserts exactly that. Parsing that finds no roots fails closed and keeps the gate.

Visual Proof

N/A — CI job classification, no runtime or UI change.

Testing

  • pnpm test config/scripts/pr-code-change-scope.test.mjs — 34 passed.
  • Ablation: neutering the one production line drops exactly 3 tests (the mobile-only case, the per-root ratchet, and the mobile-dependency case) while the control case — diffs the audits never read — stays green. The new tests fail on the pre-fix code rather than pinning current behaviour.
  • Shipped CLI, real output:
    • mobile/src/.../adapters/a.ts → static_analysis=true, mobile_dependencies=true, should_run=false, typecheck=false, test=false, package=false
    • cloud/apps/relay/src/index.ts → static_analysis=false (unchanged)
    • README.md → static_analysis=false (unchanged)
  • oxlint and oxfmt --check clean on both files.

Complementary to #20912, which teaches the changed-code gate the focused import plugins so an author catches these before pushing; that gate is a step inside this same job, so it needed this change to run at all on a mobile-only diff.

Note: this PR's own static analysis will fail on main's current tip until #20907 lands — an unrelated duplicate import in src/shared/agent-status-store-snapshot-budget.ts.

A mobile-only diff is desktop-irrelevant, so should_run was false and every PR check skipped -- including the audits that do lint mobile/. The violation then landed on main and failed the same gate on every later PR's merge ref. Derive the trigger from the audit commands' own scan roots so the two cannot drift.
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b92fc795-2571-4576-89cd-7c72a1045068

📥 Commits

Reviewing files that changed from the base of the PR and between 3520e8e and 8a00f22.

📒 Files selected for processing (2)
  • config/scripts/pr-code-change-scope.mjs
  • config/scripts/pr-code-change-scope.test.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The script now derives static-analysis scan roots from the configured oxlint audit commands in package.json. classifyPrJobs enables static_analysis for changed files under those roots and enables mobile_dependencies when required. Tests cover mobile-only changes, configured roots, and files outside the audit scope.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to f9481

The updated CI classification correctly includes scanned mobile and repository paths without enabling audits for excluded paths.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description clearly explains the problem, change, rationale, testing, and lack of UI changes. However, it omits required template sections, including the Linked Issue with a Fixes # reference, E… Add the missing template sections. Include a linked issue using Fixes #<issue>, complete or mark applicable sections as not applicable, and complete the required checklist items.
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: running static analysis for all repository trees scanned by the repo-wide audits.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description clearly explains the problem, change, rationale, testing, and lack of UI changes. However, it omits required template sections, including the Linked Issue with a Fixes # reference, ELI5, AI Disclosure, Review, Agent skill upstream boundary, Notes, and the Checklist.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Derived audit scan roots — pr-code-change-scope.mjs now parses the three STATIC_ANALYSIS_AUDIT_SCRIPTS out of package.json's argv (oxlintScanRoots) to compute STATIC_ANALYSIS_SCAN_ROOTS / _PREFIXES, with a fail-closed fallback when no roots parse.
  • static_analysis gate widened past should_run — classifyPrJobs ORs in changedFiles.some(isStaticAnalysisScannedPath), so a mobile-only (desktop-irrelevant) diff still runs the always-on static analysis without starting the desktop suite.
  • mobile_dependencies follows it — now (shouldRun || jobs.static_analysis) && needsMobileDependencies(changedFiles) so the changed-code pass gets mobile types on mobile-only diffs.
  • Test updates — re-pointed mobile_dependencies expectations, added a mobile-only classification test, a per-root ratchet over STATIC_ANALYSIS_SCAN_ROOTS, and a control asserting README/cloud paths stay out.

Verified locally: pnpm test config/scripts/pr-code-change-scope.test.mjs (34 passed) plus the wiring contract tests (pr-e2e-gate-contract, pr-workflow-parallelism, pr-workflow-lint-parity, 61 passed); CLI spot-checks match the PR body (mobile/src/a.ts → static_analysis=true, mobile_dependencies=true, should_run=false, desktop jobs false; cloud/... and README.md unchanged); oxlint/oxfmt --check clean. config/oxlint-code-quality-native-plugins.json includes a mobile/** override, confirming the premise that the audits lint mobile. The mobile-only gap is the only desktop-irrelevant tree any of the static_analysis steps read, so the change closes it fully.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review status: ready after review; no fixes required.

  • Same-model review loop: clean; no proven functional, architectural, regression, or performance issues in the two-file diff.
  • Final readiness checklist: PASS with zero proven P0/P1/P2 findings. No mobile-facing API/UI surface, SSH/remoting path, or persisted state is touched.
  • Validation passed on the current head: 65 targeted tests (pr-code-change-scope and Windows lane registration), pnpm tc:node, changed-code quality, oxlint with denied warnings, formatting, and diff checks.
  • The earlier static-analysis failure was from the stale merge ref's duplicate import; the fix is now on main and the PR has been synchronized, so checks are queued for the updated head.
  • Electron validation is not applicable: this is a GitHub Actions path classifier with no renderer/runtime behavior. No screenshot was attached because one would not represent the change.

No scope expansion or production edits were made during review.

@brennanb2025
brennanb2025 merged commit 170ebce into main Sep 16, 2026
28 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…stablyai#20918)

A mobile-only diff is desktop-irrelevant, so should_run was false and every PR check skipped -- including the audits that do lint mobile/. The violation then landed on main and failed the same gate on every later PR's merge ref. Derive the trigger from the audit commands' own scan roots so the two cannot drift.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant