Skip to content

fix(ci): prevent large source selection stalls - #157900

Merged
steipete merged 1 commit into
mainfrom
deslop/l39-ci-source-scan
Sep 25, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/l39-ci-source-scan

Conversation

@steipete

@steipete steipete commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Related: #157748

What Problem This Solves

CI manifest generation can exhaust preflight's 20-minute budget when changed-test discovery expands to large import frontiers.

User Impact

Developers retain the selected tests and existing CI budgets while source matching does less repeated work. There is no application runtime or configuration change.

Why This Change Was Made

The native selector previously searched each file again for every literal term, then allocated a complete token set. A request-scoped multi-pattern matcher scans each source once while preserving literal UTF-16 substring semantics, complete ASCII-token references, request order, and duplicates. File match state stays separate. The extracted PR wrapper inventory includes the matcher.

Fixes found along the way

Investigation also found that an unterminated Unicode escape could reset the source lexer cursor to zero. Requiring a real closing-brace position prevents that infinite loop. The native scanner regression covers the original malformed input without weakening existing assertions.

Evidence

Blacksmith Testbox, Node 24.19.0, exact failed CI merge 18dbb7a59b035ea953ac1c05b2f649e903774380, captured native requests:

Workload Baseline A1 Candidate B1 Candidate B2 Baseline A2
40,322 files / 1,486 terms 102.687 s 5.276 s 5.574 s 105.510 s
9,475 files / 21 terms 2.019 s 1.818 s 1.768 s 1.922 s

Each A-B-B-A group produced byte-identical JSON. The large request improved about 95%; this is a measured workload result, not a worst-case complexity guarantee. Overlap, empty/duplicate term, Unicode, and reference-boundary controls also matched. The malformed-escape baseline hit its 2-second diagnostic bound; the candidate completed in 64 ms.

The complete CI manifest replay, with the original 115 changed paths and hybrid attempt-2 inputs, completed in 258.288 seconds, emitting 109 changed-test rows. It retained selection rules, runner placement, limits, and the original manifest code. This replay proves the original failing workload; the separate hosted run below uses this PR's narrower changed-file scope.

Diagnostic provider: blacksmith-testbox, lease tbx_01m3b5jwg1dd6pbr4hcgvvn3ta, run, stopped after successful proof. Commands used the repository Crabbox wrapper with an exact-source checkout and one command at a time.

Fresh P0–P2 managed Codex review of the final rebased four-file diff is clean. On fresh main 0515cb8d70c1e3bdc46fd2bb9801a48c5ee28b25, the original native scanner fails the new regression with ETIMEDOUT; the fixed scanner passes all 1,654 owner tests. The exact clean base also reproduced both consumer failures in the original file order (250.527 s); the repaired ten-file consumer selection passed (249.381 s).

Validation Result
pnpm test test/scripts/test-projects.test.ts --maxWorkers=1 1,654 passed; 72.016 s wall
Cross-consumer and extracted-wrapper selection Ten files passed; 249.381 s
node scripts/check-changed.mjs -- <changed paths> Passed on the validated superset; 217.360 s
pnpm build Passed; 506.947 s
Isolated pnpm openclaw --help and --version Passed

The existing owner files cover real test selection, Git/file inventory, native scanner behavior, and complete planner inventories; the new scanner regression reuses the existing native process. The changed owner file remains above 30 seconds because it retains the broad selector contract suite, with no extra process per corpus item. The owner file passed in hosted CI with 1,662 cases in the tested merge tree, taking 71.599 s in checks-node-compact-small-6. The candidate is rebased onto e4414b6146d52326f1e42aaa612c5f046f23ad63. Main already repaired the two unrelated consumer failures, so duplicate inventory and packing-test edits were removed. All four remaining complete files, the selector dependencies, and package inputs match the validated snapshot. Hosted CI verified the new merge context.

Final proof provider: blacksmith-testbox, lease tbx_01m3b99ny3ktv3yfk8dj3m0j67, run. Owner/cross tests, changed checks, build and CLI commands run sequentially through node scripts/crabbox-wrapper.mjs run --provider blacksmith-testbox --id … --idle-timeout 180m --timing-json -- OPENCLAW_TESTBOX=1 OPENCLAW_TESTBOX_REMOTE_RUN=1 …; fresh dependencies were installed with pnpm install --frozen-lockfile. The lease is stopped. Exact-head hosted CI passed for 7596257062b1a200e34de176f2e56b575dcee187, including openclaw/ci-gate; this PR's manifest step took 29 seconds. READY-TO-LAND; not merged.

@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M labels Sep 25, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 25, 2026
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 25, 2026, 1:37 AM ET / 05:37 UTC (Revision 3).

ClawSweeper review

What this changes

The branch makes CI’s native source scanner match requested terms in one pass, prevents an unterminated Unicode escape from stalling it, and updates its regression tests and PR wrapper inventory.

Merge readiness

✅ Ready for maintainer review

Keep this PR open. Current main still performs the repeated source scans, while the branch has focused tests and measured proof that it preserves selection results and substantially reduces the large workload’s runtime. I found no blocking defect.

Priority: P2
Reviewed head: 7596257062b1a200e34de176f2e56b575dcee187

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused implementation, native-boundary regression coverage, measured before/after behavior, and exact-head CI support a strong review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The changed native source scanner was exercised on a Blacksmith Testbox with the recorded 40,322-file request: candidate output matched the baseline byte for byte while runtime fell from about 104 seconds to about 5.4 seconds. A complete manifest replay emitted 109 rows, and exact-head hosted preflight completed its manifest step in 29 seconds. No stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The changed native source scanner was exercised on a Blacksmith Testbox with the recorded 40,322-file request: candidate output matched the baseline byte for byte while runtime fell from about 104 seconds to about 5.4 seconds. A complete manifest replay emitted 109 rows, and exact-head hosted preflight completed its manifest step in 29 seconds. No stored-data contract changes.
Evidence reviewed 8 items Introduced patch: The pinned merge-base-to-head diff changes only the scanner, matcher, wrapper inventory, and selector tests.
Production boundary: The request creates one matcher and applies it to each file read by the native scanner; the caller uses its matches and references for changed-test planning.
Scanner regression: The native-boundary test compares literal matches and whole-token references with the previous contract and includes malformed-escape input.
Findings None None.
Security None None.

How this fits together

CI preflight reads changed files and scans source text to decide which tests to run. Those selections feed the CI manifest and its test jobs.

flowchart LR
  A[Changed files] --> B[Source facts scanner]
  C[Requested terms] --> D[Term matcher]
  B --> D
  D --> E[Test selection]
  E --> F[CI manifest]
  F --> G[Test jobs]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +59, Other +117. Total +176 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 61 2 +59
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 122 5 +117
Total 4 183 7 +176

Review metrics

Metric Value Why it matters
Large selection workload 102.7–105.5 s baseline; 5.3–5.6 s candidate The measured native request targets the manifest-generation stall.
Tooling and test LOC production/tooling +117 net; tests +59 net The new matcher accounts for the growth and has measured runtime benefit.

Technical review

Best possible solution:

Land the selector repair through the normal PR gates so large import frontiers retain complete test selection within the existing CI budget.

Do we have a high-confidence way to reproduce the issue?

Yes. The PR records the original large native request, baseline and candidate timings, byte-identical outputs, and a malformed-escape baseline timeout; current main still contains the slower scan.

Is this the best way to solve the issue?

Yes. The patch changes the existing scanner owner, retains its output contract, and includes the new dependency in the extracted wrapper.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 63944b8a1df1.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded CI planning reliability fix with measured benefit and no application runtime change.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The changed native source scanner was exercised on a Blacksmith Testbox with the recorded 40,322-file request: candidate output matched the baseline byte for byte while runtime fell from about 104 seconds to about 5.4 seconds. A complete manifest replay emitted 109 rows, and exact-head hosted preflight completed its manifest step in 29 seconds. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The changed native source scanner was exercised on a Blacksmith Testbox with the recorded 40,322-file request: candidate output matched the baseline byte for byte while runtime fell from about 104 seconds to about 5.4 seconds. A complete manifest replay emitted 109 rows, and exact-head hosted preflight completed its manifest step in 29 seconds. No stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-25T04:50:38.769Z sha 4b1b50181c67fb4e975b7108d7b83932111a0063 :: blocked before merge. :: none
  • reviewed 2026-09-25T05:11:44.138Z sha 7596257 :: needs maintainer review before merge. :: none

Match literal terms and whole-token references in one native source pass,
retaining UTF-16 semantics, requested ordering, and duplicate terms.
Prevent malformed Unicode escapes from rewinding the source lexer and
include the matcher in the copied PR wrapper dependency inventory.
@steipete
steipete force-pushed the deslop/l39-ci-source-scan branch from 4b1b501 to 7596257 Compare September 25, 2026 05:00
@steipete
steipete marked this pull request as ready for review September 25, 2026 05:05
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 25, 2026
@steipete
steipete merged commit 24827cd into main Sep 25, 2026
172 checks passed
@steipete
steipete deleted the deslop/l39-ci-source-scan branch September 25, 2026 09:30
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
Match literal terms and whole-token references in one native source pass,
retaining UTF-16 semantics, requested ordering, and duplicate terms.
Prevent malformed Unicode escapes from rewinding the source lexer and
include the matcher in the copied PR wrapper dependency inventory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant