Skip to content

refactor(ci): narrow stale-build pattern matching to ninja error lines (#3129 A2) - #3202

Merged
zackees merged 1 commit into
masterfrom
refactor/3129-a2-narrow-stale-patterns
Jun 16, 2026
Merged

zackees merged 1 commit into
masterfrom
refactor/3129-a2-narrow-stale-patterns

Conversation

@zackees

@zackees zackees commented Jun 16, 2026 •

Copy link
Copy Markdown
Member

Summary

is_stale_build_error() in ci/meson/compile.py lowercased the entire combined compile output and ran a substring check across the whole blob. Routine phrases like "file not found", "does not exist", "target not found" are common in legitimate compiler errors — each false positive triggered a full artifact-wipe + reconfigure on retry, costing ~20–30 s.

New matching rule

A line counts as a stale-build trigger only if EITHER:

  • it starts with ninja: error: AND contains one of the substring patterns, OR
  • it matches a ninja-graph-specific phrase ("manifest contains a cycle" / "failed: regen"), OR
  • it contains the clang PCH-staleness phrase "has been modified since the precompiled header" (which survives without ninja's prefix).

The narrow patterns still catch every real ninja stale-build complaint (they all start with ninja: error:). User typos no longer pay the artifact-wipe tax.

Compat

STALE_BUILD_PATTERNS is kept as a re-export for any external script that imported the name directly. Its contents now match _NINJA_STALE_BUILD_PATTERNS + ["has been modified since the precompiled header"].

Follow-up (out of scope)

ci/wasm_build.py::_is_stale_build_error has the same loose substring pattern (plus its own extras like "undefined symbol") and should get the same treatment. Left for a separate PR to keep this change focused on the audit's exact ask.

1 file changed, 43 insertions(+), 8 deletions(-).

Part of #3129 (Section A2).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved accuracy of stale build error detection to reduce false positives during the build process.

#3129 A2)

The previous is_stale_build_error implementation lowercased the entire
combined compile output and ran a substring check across the whole
blob. Phrases like "file not found", "does not exist", and "target not
found" are routine in legitimate compiler errors (user typo'd a
header, missing include, etc.). Each false positive triggered a full
artifact-wipe + reconfigure on retry, costing ~20-30s.

New rule:
- a line counts only if it starts with "ninja: error:" AND contains
  one of the substring patterns, OR
- it matches a ninja-graph-specific phrase ("manifest contains a
  cycle" / "failed: regen"), OR
- it contains the clang PCH-staleness phrase "has been modified since
  the precompiled header" (which survives without ninja's prefix).

The narrow patterns still catch legitimate stale-build cases — every
real ninja stale-build complaint starts with "ninja: error:" — but
user typos no longer pay the wipe tax.

STALE_BUILD_PATTERNS is kept as a re-export for any external script
that imported it directly.

Follow-up (out of scope): ci/wasm_build.py:_is_stale_build_error has
the same loose substring pattern and should get the same treatment.

Part of #3129 (Section A2).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

is_stale_build_error() in ci/meson/compile.py is rewritten to scan output line-by-line with prefix-gated matching: stale-file keywords only trigger on ninja: error: lines, while PCH staleness and Ninja-graph phrases match anywhere. STALE_BUILD_PATTERNS is preserved as a backwards-compatible re-export derived from the new internal keyword groups.

Changes

Stale-build detection refactor

Layer / File(s) Summary
Keyword groups and constrained line-by-line matching
ci/meson/compile.py
Splits the single keyword list into _NINJA_STALE_BUILD_PATTERNS (for ninja: error: lines) and Ninja-graph phrase constants; re-exports STALE_BUILD_PATTERNS for backwards compatibility; rewrites is_stale_build_error() to apply per-line prefix-gated checks instead of a broad case-insensitive substring scan across the entire output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A rabbit once chased every shadow and sound,
But stale build errors were too oft falsely found.
Now ninja: error: must prefix the clue,
Or graph-level phrases must ring plainly true.
With line-by-line hops, the false alarms are few!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: narrowing stale-build pattern matching to ninja error lines, which is the core refactoring in ci/meson/compile.py.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/3129-a2-narrow-stale-patterns

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ci/meson/compile.py`:
- Around line 105-107: The condition on line 105 in the stale-error detection
logic is too strict: it requires the line to start with "ninja: error:" using
startswith(), but output lines can have formatter prefixes (such as timestamps)
that prevent matching of real Ninja stale errors. Replace the startswith("ninja:
error:") check with a pattern that allows for optional prefixes before the error
message, such as checking if "ninja: error:" is contained anywhere in the line
rather than only at the start, so that stale-build recovery can trigger
correctly in the downstream retry gate in ci/meson/streaming_runner.py.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9085bf07-7e01-4308-b728-efcfa9344b80

📥 Commits

Reviewing files that changed from the base of the PR and between 1b29f5b and 8bc6077.

📒 Files selected for processing (1)
  • ci/meson/compile.py

Comment thread ci/meson/compile.py
Comment on lines +105 to +107
if line_lower.startswith("ninja: error:") and any(
pattern in line_lower for pattern in _NINJA_STALE_BUILD_PATTERNS
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Allow timestamp-prefixed Ninja lines in stale-error detection

On Line 105, requiring line_lower.startswith("ninja: error:") is too strict for this pipeline: output lines can carry formatter prefixes, so real Ninja stale errors may no longer match and stale-build recovery won’t trigger downstream (ci/meson/streaming_runner.py retry gate).

Suggested fix
-        if line_lower.startswith("ninja: error:") and any(
+        ninja_idx = line_lower.find("ninja: error:")
+        if ninja_idx != -1 and any(
             pattern in line_lower for pattern in _NINJA_STALE_BUILD_PATTERNS
         ):
             return True
📝 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.

Suggested change
if line_lower.startswith("ninja: error:") and any(
pattern in line_lower for pattern in _NINJA_STALE_BUILD_PATTERNS
):
ninja_idx = line_lower.find("ninja: error:")
if ninja_idx != -1 and any(
pattern in line_lower for pattern in _NINJA_STALE_BUILD_PATTERNS
):
return True
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ci/meson/compile.py` around lines 105 - 107, The condition on line 105 in the
stale-error detection logic is too strict: it requires the line to start with
"ninja: error:" using startswith(), but output lines can have formatter prefixes
(such as timestamps) that prevent matching of real Ninja stale errors. Replace
the startswith("ninja: error:") check with a pattern that allows for optional
prefixes before the error message, such as checking if "ninja: error:" is
contained anywhere in the line rather than only at the start, so that
stale-build recovery can trigger correctly in the downstream retry gate in
ci/meson/streaming_runner.py.

@zackees
zackees merged commit fe5c638 into master Jun 16, 2026
12 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 16, 2026
@zackees
zackees deleted the refactor/3129-a2-narrow-stale-patterns branch August 21, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant