[auto] reflect: corpus_scan skips slow or oversized transcripts instead of crashing - #288
Open
EdbertChan wants to merge 1 commit into
Conversation
…ad of crashing _grep_match_files ran `grep -l` per file with timeout=15 and no handler, so one slow transcript (a 146 MB Codex rollout) raised subprocess.TimeoutExpired out of the loop and killed the whole corpus scan. Catch TimeoutExpired per file, print an explicit stderr skip line naming the path and the timeout, and continue. Add a size cap (--max-file-bytes, default 64 MB) that skips oversized files before grep with the same explicit stderr line. The find failure path keeps returning [] but now logs the command and error to stderr instead of swallowing it silently. Tests: TestGrepMatchFilesSkips monkeypatches subprocess.run to raise TimeoutExpired for one path and asserts the other paths still return and the skipped path is named on stderr; also covers the size cap, the 64 MB default, and the find-failure log line. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014NSMiMsTPuon8otdhRaJEq Change-Id: I6b763dad53f9f35f7e4ebe3154816c54ee00fe08
Open
4 tasks
EdbertChan
commented
Sep 8, 2026
OwnerAuthor
This pull request is part of a Mergify stack:
|
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_063a7956-1c3d-45a8-b552-629b411dcf54) |
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
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The reflect corpus scan no longer dies when one transcript is slow to grep. The slow file is skipped with a stderr line naming it, and the scan continues.
Files above a size cap (default 64 MB, flag
--max-file-bytes) are skipped before grep with the same stderr line. The find-failure path now logs instead of swallowing.Review Claim
_grep_match_filessurvives one slow or oversized transcript, names every skip on stderr, and still returns every other match.Review Lane
behavior
Review Unit
engine-runtime
Safety Invariant
No scan result that used to succeed changes: files under the cap that grep in time still match exactly as before. Only the crash case and the new above-cap case turn into named stderr skips. Callers of
discover_localpass no new argument and get the default cap.Assumptions: headless mode, Safety Invariant is unconfirmed by a human.
Slice Rationale
This is the script fix from one reflect pass; its prose sibling (narrow-the-scope) is a separate review unit and sits in the next PR of this stack so each PR carries one Review Unit.
Non-goals
remote_scan_command, or_grep_count.Test Plan
Test Plan
python3 -m unittest engine.skills.reflect.scripts.tests.test_corpus_scan -vBEFORE the fix (test added, script unchanged):python3 -m unittest discover -s engine/skills/reflect/scripts/tests->Ran 155 tests in 17.119s/OKbash scripts/run_all_tests.sh-> exit 0; per-suite results:python3 engine/skills/make-pr/scripts/preflight.py --base origin/main->ok preflight passedpython3 scripts/check_no_new_comments.py --base origin/main->ok no new commentspython3 scripts/check_no_dated_provenance.py --base origin/main->ok no dated provenancepython3 scripts/check_skill_test_coverage.py --base origin/main --head HEAD->ok skill test coveragenode engine/skills/draft-pr/scripts/lint-diff-atomicity.mjs --base origin/main->Diff atomicity validation passed.Revert Plan
Revert Plan
git revert 467f5ec🤖 Generated with Claude Code
https://claude.ai/code/session_014NSMiMsTPuon8otdhRaJEq