Skip to content

fix(test): route native changed runs through the CI affected-test owner - #162671

Closed
LiuwqGit wants to merge 2 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-162615-changed-test-scope
Closed

LiuwqGit wants to merge 2 commits into
openclaw:mainfrom
LiuwqGit:feat/issue-162615-changed-test-scope

Conversation

@LiuwqGit

@LiuwqGit LiuwqGit commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Closes #162615

What Problem This Solves

A native pnpm test --changed <base> run selected tests through the local planner's unrestricted import graph instead of the maintained CI affected-test owner, so a focused source change could resolve to thousands of targets: selecting src/plugins/runtime/types.ts resolved 11,789 targets and 59 plans. Because the concrete selection never became explicit file arguments, the runner also admitted no automatic inter-plan overlap — independent plans ran serially even when the selection satisfied the existing CI host, output-safety, and cache-ownership admission checks.

Why This Change Was Made

The CI changed-test owner (resolveChangedNodeTestTargets) already encodes the maintained selection policy: bounded owners, alias resolution, runtime-only import edges, sibling coverage, protected runtime tests, policy watches, and fixed PR smoke coverage. Reusing that owner for native non-watch --changed runs is narrower and more maintainable than re-filtering the local graph — filtering type-only edges alone still leaves ~10,196 targets through the unrestricted runtime graph. Feeding the owner's concrete files into the run's effective target arguments also lets the existing exact-target admission treat a changed selection exactly like an explicit selector invocation, unlocking the existing bounded scheduler without scheduler changes.

Watch mode, explicit test/source selectors, and the OPENCLAW_TEST_CHANGED_BROAD=1 escape hatch keep their established planner route. Exclusive-suite barriers, output isolation, cache ownership, and the explicit serial override are unchanged, as they live downstream of the admission gate.

User Impact

Developers running pnpm test:changed now get the same focused scope CI uses for changed files — bounded selections with protected and smoke coverage instead of unbounded fan-out — and eligible plans execute through the bounded scheduler with joined barriers instead of forced serialization. Compiled runner entries also retain the wrapper-component inventory the reused policy watch reads at module load, so prepared-layout CLI startup keeps working.

Evidence

Real environment tested: yes — real scripts/test-projects.mts --changed <base> CLI invocations at the PR head in an isolated worktree (docs-only change fixture as the changed set), plus regression tests driving runTestProjects end to end with mocked child processes.

Exact steps or commands run after this patch:

  • node --import ./scripts/tsx.mjs scripts/test-projects.mts --changed HEAD^ --reporter=dot --coverage.enabled=false with CI=1 (changed set: docs/help/testing.md only)
  • Same command with OPENCLAW_TEST_PROJECTS_SERIAL=1 (explicit serial override)
  • Same command with OPENCLAW_TEST_CHANGED_BROAD=1 (broad escape hatch)
  • Selection comparison for the issue's reproduction input src/plugins/runtime/types.ts: local planner vs CI affected-test owner
  • bash skills/fix-pr/scripts/validate.sh (oxfmt + oxlint + same-directory tests + tsgo:core) on all changed files; full runs of test/scripts/test-projects-build-admission.test.ts (178 passed, including 4 new regression tests), test-projects.test.ts, test-projects-routing.test.ts, ci-changed-node-test-plan.selection.test.ts, vitest-plan-scheduling.test.ts (341 passed across the four)

Evidence after fix:

$ CI=1 node --import ./scripts/tsx.mjs scripts/test-projects.mts --changed HEAD^ --reporter=dot --coverage.enabled=false
[test] running 3 exact-target plans with parallelism 1 and joined exclusive barriers
...
 Test Files  3 passed (3)
      Tests  34 passed (34)
[test] passed 3 Vitest shards in 229.32s   (exit 0)

# Before this patch, the same invocation selected through the local planner:
 Test Files  4 passed (4)
      Tests  376 passed (376)
[test] passed 2 Vitest shards in 248.42s   (serial: no exact-target admission)

# Selection comparison for src/plugins/runtime/types.ts:
native local-planner targets: 11789  (59 plans)
CI affected-test owner targets: 98  (11 plans)   <- now used by the native route

# Explicit serial override stays serial:
OPENCLAW_TEST_PROJECTS_SERIAL=1 ... -> [test] passed 3 Vitest shards in 165.22s (no exact-target admission)

# Broad escape hatch keeps the planner route:
OPENCLAW_TEST_CHANGED_BROAD=1 ... -> [test] skipped 0 Vitest shards in 536ms

Observed result after fix: The native non-watch changed run resolves through the CI affected-test owner (6 fixed smoke tests for the docs-only fixture instead of 376 test-projects tests), its concrete selection is admitted by the existing exact-target gate ("running 3 exact-target plans ... joined exclusive barriers"), the explicit serial policy and the broad escape hatch keep their established behavior, and all regression tests pass. The evidence host is resource-constrained, so the admitted plan concurrency resolved to 1 there; the admission suite with a 24 GiB / 8-CPU host observes peak 2 concurrent plans, matching the explicit-selector behavior.

What was not tested: Full CI lanes (test-projects --changed, full check:test-types, pnpm check:changed) were not run locally — they are left to GitHub Actions (CI lanes pending). Concurrency above 2 and non-Linux process-group admission rely on CI hosts, exercised only through the mocked admission suite.

Native non-watch --changed selections resolved through the local planner's
unrestricted import graph and ran their concrete plans serially. Reuse the
maintained CI changed-test owner for selection and feed its concrete files
into the existing exact-target admission so independent plans overlap.

Fixes openclaw#162615
@clawsweeper

clawsweeper Bot commented Oct 1, 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 Oct 1, 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 Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed October 1, 2026, 8:22 AM ET / 12:22 UTC (Revision 2).

ClawSweeper review

What this changes

The PR makes non-watch changed-test runs reuse CI’s affected-test selection and existing bounded scheduler, preserves a required compiled-runner asset, and adds regression coverage.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This remains a useful fix: current main still uses the divergent changed-test route. No blocking code defect was found, and the supplied CLI evidence supports the integration. The earlier test-cost reporting request remains unresolved.

Likely related people: Peter Steinberger and Vincent Koc, based on recent selector and scheduler history.

Priority: P2
Reviewed head: 65e5f7df932c0b83082893578ce3046159280e11

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused integration with meaningful CLI evidence and regression coverage; the remaining follow-up is required test-cost reporting.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The captured isolated-worktree trace exercises the real test-projects CLI with a docs-only changed fixture, observes the CI-owner selection reaching exact-target admission, and records successful completion plus serial and broad controls. Actual overlapping children are covered supplementally by mocked admission tests; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured isolated-worktree trace exercises the real test-projects CLI with a docs-only changed fixture, observes the CI-owner selection reaching exact-target admission, and records successful completion plus serial and broad controls. Actual overlapping children are covered supplementally by mocked admission tests; no stored-data contract changes.
Evidence reviewed 8 items Verified introduced changes: Inspected the pinned merge-base-to-head patch. The verified test merge records the supplied base followed by the exact PR head and retains the same four-path change, without dropping base-only work.
Current main still needs the integration: Current main resolves native changed arguments through resolveChangedTargetArgs without invoking the CI selector. Automatic overlap still requires explicit target arguments, so the central repair remains absent.
Existing selection and scheduling owners: The CI selector applies bounded owners, runtime import edges, sibling coverage, protected coverage, policy watches, and fixed smoke tests. The PR carries its concrete files into existing admission; process joining, exclusive barriers, output checks, cache ownership, and serial controls remain downstream.
Findings None None.
Security None None.

How this fits together

OpenClaw’s test runner turns developer arguments and changed Git paths into test selections owned by different Vitest projects. Its scheduling gate then decides whether those projects can overlap safely.

flowchart TD
 A[Developer test command] --> B[Invocation mode]
 B -->|Native changed run| C[CI affected-test selector]
 B -->|Watch or explicit selectors or broad mode| D[Existing local planner]
 C --> E[Concrete test files]
 D --> F[Owned test plans]
 E --> F
 F --> G[Scheduling and isolation checks]
 G --> H[Vitest results]
Loading

Before merge

  • Complete next step (P2) - Record the measured wall time for pnpm test test/scripts/test-projects-build-admission.test.ts --maxWorkers=1 in the PR body.
Agent review details

Security

None.

PR surface

Tests +155, Other +51. Total +206 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 159 4 +155
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 57 6 +51
Total 4 216 10 +206

Review metrics

Metric Value Why it matters
Production versus regression coverage production/tooling net +51 lines; tests net +155 lines; test support net 0 The production growth integrates existing selection ownership rather than adding another selector or scheduler.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #162615
Summary: This PR is the explicit implementation candidate for the linked selector and scheduling defect.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep one maintained affected-test selection policy feeding the existing scheduler, with watch, explicit-selector, and broad-mode contracts preserved.

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

Yes, current-main source establishes both the divergent native changed selector and the explicit-target prerequisite that prevents its automatic overlap. This read-only review did not execute tests.

Is this the best way to solve the issue?

Yes, reusing the existing CI selector and scheduler is the narrowest repair, and the supplied real CLI trace demonstrates the changed entry point reaching scheduling admission.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ab1b93295ad0.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs developer test-scope fan-out and lost scheduling eligibility without establishing an urgent product-runtime failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The captured isolated-worktree trace exercises the real test-projects CLI with a docs-only changed fixture, observes the CI-owner selection reaching exact-target admission, and records successful completion plus serial and broad controls. Actual overlapping children are covered supplementally by mocked admission tests; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured isolated-worktree trace exercises the real test-projects CLI with a docs-only changed fixture, observes the CI-owner selection reaching exact-target admission, and records successful completion plus serial and broad controls. Actual overlapping children are covered supplementally by mocked admission tests; no stored-data contract changes.

Evidence

What I checked:

  • Verified introduced changes: Inspected the pinned merge-base-to-head patch. The verified test merge records the supplied base followed by the exact PR head and retains the same four-path change, without dropping base-only work. (scripts/test-projects-run.mts:359, 65e5f7df932c)
  • Current main still needs the integration: Current main resolves native changed arguments through resolveChangedTargetArgs without invoking the CI selector. Automatic overlap still requires explicit target arguments, so the central repair remains absent. (scripts/test-projects-run.mts:339, ab1b93295ad0)
  • Existing selection and scheduling owners: The CI selector applies bounded owners, runtime import edges, sibling coverage, protected coverage, policy watches, and fixed smoke tests. The PR carries its concrete files into existing admission; process joining, exclusive barriers, output checks, cache ownership, and serial controls remain downstream. (scripts/lib/ci-changed-node-test-plan.mts:464, 65e5f7df932c)
  • Compiled-layout asset: The newly imported selection owner reaches a policy inventory that reads wrapper-components.txt at module load. Adding that existing text asset to the prepared-layout inventory preserves the required source-relative input. (scripts/lib/vitest-worker-build-entries.mts:261, 65e5f7df932c)
  • Captured real CLI proof: The supplied body snapshot, sourceRevision 089f15d0b3d4b54544ad670c8ea8b51a92888c8cf83908a3123cd8b89a13b539, records isolated-worktree CLI execution with a docs-only changed fixture: three exact-target plans completed successfully in 229.32 seconds, with serial and broad controls also exercised. Concurrency resolved to one on that host; peak-two overlap is supplemental mocked scheduling evidence rather than a claimed live observation. A REST read confirmed the same body and pinned head. (65e5f7df932c)
  • Prior follow-up remains applicable: The previous completed review requested the measured single-worker admission-suite wall time. The current body reports passing test counts and separate CLI timings, but still omits that suite measurement. Root policy and the testing guide require measured cost for materially changed test files. Public docs: docs/help/testing/writing-tests.md. (docs/help/testing/writing-tests.md, 65e5f7df932c)

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the measured wall time for pnpm test test/scripts/test-projects-build-admission.test.ts --maxWorkers=1 in the PR body.

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 (1 earlier review cycle)
  • reviewed 2026-10-01T12:00:24.680Z sha 44bb1fefe5958db33cd19106408c004616cded18 :: needs changes before merge. :: none

…tries

The runtime worker layout now imports the CI changed-test owner, whose
policy watch inventory reads scripts/pr-lib/wrapper-components.txt at
module load. Preserve those bytes in the prepared layout so compiled
runner entries keep starting without the source checkout.
@shakkernerd

Copy link
Copy Markdown
Contributor

Thanks for the investigation and patch. I narrowed #162615 to the confirmed scheduling defect, and #162701 has now landed that fix while preserving existing changed-test selection behavior.

My original report conflated that defect with the difference between broad local selection and CI's bounded selection. The target-count comparison did not establish that the additional coverage was unnecessary. This PR also changes the default native selection policy, so I have closed it as outside the corrected issue's scope. Changing that default needs a separate coverage justification and discussion.

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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: M 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.

[Bug]: Changed-test runs serialize independent test groups

2 participants