Repository navigation
refactor(ci): narrow stale-build pattern matching to ninja error lines (#3129 A2) - #3202
Conversation
#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]>
📝 WalkthroughWalkthrough
ChangesStale-build detection refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
ci/meson/compile.py
| if line_lower.startswith("ninja: error:") and any( | ||
| pattern in line_lower for pattern in _NINJA_STALE_BUILD_PATTERNS | ||
| ): |
There was a problem hiding this comment.
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.
| 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.
Summary
is_stale_build_error()inci/meson/compile.pylowercased 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:
ninja: error:AND contains one of the substring patterns, OR"manifest contains a cycle"/"failed: regen"), OR"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_PATTERNSis 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_errorhas 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