Skip to content

fix(test): drain late mock registrations - #126037

Merged
steipete merged 1 commit into
mainfrom
codex/fix-main-mock-resolution
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-main-mock-resolution

Conversation

@steipete

@steipete steipete commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a problem where the non-isolated CLI test shard could split mocked imports across module instances, producing 35 false src/cli/update-cli.test.ts failures even though focused update CLI behavior remained green. Vitest 4.1.11's restored global lifecycle concurrency limit made the existing scheduling race recur in cleanup CI run https://github.com/openclaw/openclaw/actions/runs/32950521368.

Why This Change Was Made

The serialized mock resolver now drains IDs queued during its final in-flight pass before allowing that caller to continue. This keeps later module fetches from invalidating mocks midway through an import graph and adds the no-second-caller case missing from the existing resolver coverage. It does not change production CLI behavior or downgrade Vitest.

User Impact

There is no end-user CLI behavior change. Maintainers get reliable non-isolated CLI CI after the Vitest 4.1.11 upgrade, unblocking unrelated command cleanup work.

Evidence

AI-assisted: yes. No agent transcript attached.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Aug 18, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. 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 Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 6:16 AM ET / 10:16 UTC.

ClawSweeper review

What this changes

The PR makes the shared non-isolated Vitest runner drain mock registrations added during an in-flight resolver pass and adds a regression test for the no-second-caller case.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review: the focused runner change and regression test address the stated late-registration path, but exact Vitest private-queue contract confirmation and exact-head CI remain required before merge.

Priority: P2
Reviewed head: 8bb6fa7d74e7e681a67b01cd3b0d718e5fe81bbc
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is narrowly scoped with a credible owner-boundary regression test; direct upstream contract confirmation and completion of exact-head CI remain merge checks.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored test-infrastructure PR is exempt from the external-contributor real-behavior-proof gate; the PR body nevertheless records before/after shard results.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored test-infrastructure PR is exempt from the external-contributor real-behavior-proof gate; the PR body nevertheless records before/after shard results.
Evidence reviewed 5 items Changed owner boundary: The runner wraps the mocker during collection, then invokes the original resolver in a loop until the current queue is empty; this is the changed test-support owner rather than production CLI code.
Focused regression coverage: The new test holds the first resolver pass open, adds a late registration, and verifies that the original caller drains two passes without a second caller.
Dependency signal and limitation: The changed runner imports Vitest and the lockfile pins Vitest 4.1.11, so this repair depends on Vitest’s private resolver behavior. The checkout has no inspectable installed Vitest source and GitHub DNS was unavailable, preventing direct verification of that upstream implementation in this review.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs test/non-isolated-runner.resolve-mocks.test.ts

Result: PASS (completed)

[test] starting test/vitest/vitest.unit-fast.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-126037-fl9Avx/target

 ✓  unit-fast  test/non-isolated-runner.resolve-mocks.test.ts (7 tests) 18ms

 Test Files  1 passed (1)
      Tests  7 passed (7)
   Start at  10:17:36
   Duration  407ms (transform 179ms, setup 94ms, import 139ms, tests 18ms, environment 0ms)

[test] passed 1 Vitest shard in 12.09s
[test] starting test/vitest/vitest.unit-fast.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-126037-fl9Avx/target

 ✓  unit-fast  test/non-isolated-runner.resolve-mocks.test.ts (7 tests) 18ms

 Test Files  1 passed (1)
      Tests  7 passed (7)
   Start at  10:17:49
   Duration  267ms (transform 54ms, setup 32ms, import 62ms, tests 18ms, environment 0ms)

[test] passed 1 Vitest shard in 11.75s

Assertions:

  • NOT OBSERVED expect_output: drains ids queued during the final pass without requiring another caller — command exited successfully; expected output was not observed in the captured pane

How this fits together

OpenClaw’s non-isolated Vitest runner serializes mock resolution between test files so each module import observes its declared mock registrations. It sits between test-file setup and Vitest’s module loader, affecting test-shard reliability rather than product runtime behavior.

flowchart LR
  A[Non-isolated test file] --> B[Mock registration queue]
  B --> C[Shared test runner]
  C --> D[Serialized resolver pass]
  D --> E[Vitest module loader]
  E --> F[Test shard result]
Loading

Decision needed

Question Recommendation
After the exact-head checks finish, should this private-Vitest-contract repair be accepted with direct 4.1.11 source confirmation? Verify then merge: Confirm the 4.1.11 resolver queue behavior and accept the PR if exact-head CI is green.

Why: The PR is maintainer-authored and changes shared test infrastructure whose correctness depends on an upstream private implementation unavailable in this review environment.

Before merge

  • Resolve merge risk (P1) - The loop relies on Vitest’s private static queue-reset behavior; direct upstream source was unavailable in this review, so confirm that contract and the exact-head required CI before merge.
  • Complete next step (P2) - A maintainer should verify the private Vitest contract and exact-head CI; there is no discrete automated repair remaining.
Agent review details

Security

None.

PR surface

Tests +27. Total +27 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 36 9 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 36 9 +27

Review metrics

Metric Value Why it matters
Production versus test LOC production 0; test support +5 net; tests +22 The change is confined to shared test infrastructure and focused regression coverage, with no shipped-runtime growth.

Merge-risk options

Maintainer options:

  1. Confirm the Vitest contract before merge (recommended)
    Inspect the pinned Vitest 4.1.11 resolver source and require the exact-head non-isolated CI shard to complete green.
  2. Pause this private-internals repair
    Defer the change if the upstream queue lifecycle cannot be confirmed or no longer supports the drain-loop assumption.

Technical review

Best possible solution:

Keep one serialized runner path, verify the pinned Vitest 4.1.11 queue contract directly, and merge only after the exact-head CI run confirms the affected non-isolated shard remains stable.

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

Yes, from source: the regression test deterministically adds an ID while the final resolver pass is held open and establishes the prior single-pass omission. I did not execute it because this read-only checkout lacks installed dependencies.

Is this the best way to solve the issue?

Unclear; the loop is the narrowest apparent repair for registrations stranded in the replaced queue, but its correctness still depends on direct confirmation of the pinned Vitest resolver contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This addresses a bounded CI reliability failure in shared test infrastructure rather than an end-user runtime regression.
  • merge-risk: 🚨 automation: The changed non-isolated runner executes across CI test shards and depends on private Vitest mock-resolution behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored test-infrastructure PR is exempt from the external-contributor real-behavior-proof gate; the PR body nevertheless records before/after shard results.

Evidence

What I checked:

  • Changed owner boundary: The runner wraps the mocker during collection, then invokes the original resolver in a loop until the current queue is empty; this is the changed test-support owner rather than production CLI code. (test/non-isolated-runner.ts:367, 8bb6fa7d74e7)
  • Focused regression coverage: The new test holds the first resolver pass open, adds a late registration, and verifies that the original caller drains two passes without a second caller. (test/non-isolated-runner.resolve-mocks.test.ts:101, 8bb6fa7d74e7)
  • Dependency signal and limitation: The changed runner imports Vitest and the lockfile pins Vitest 4.1.11, so this repair depends on Vitest’s private resolver behavior. The checkout has no inspectable installed Vitest source and GitHub DNS was unavailable, preventing direct verification of that upstream implementation in this review. (test/non-isolated-runner.ts:3, 8bb6fa7d74e7)
  • Feature history: The repository history identifies the original serialization work as commit b2e34b0 by Peter Steinberger; later runner work also remains concentrated in this area. (test/non-isolated-runner.ts:367, b2e34b03b5cb)
  • Codex boundary: This change uses Vitest’s test-runner internals and has no import, protocol, harness, or behavioral claim tied to OpenAI Codex Code Mode; the sibling Codex gate is therefore not applicable. (test/non-isolated-runner.ts:3, 8bb6fa7d74e7)

Likely related people:

  • steipete: History attributes the original mock-resolution serialization and several subsequent non-isolated runner repairs to Peter Steinberger. (role: original feature owner and recent area contributor; confidence: high; commits: b2e34b03b5cb, e7a2d1758afe, 75b736c25263; files: test/non-isolated-runner.ts)

Rank-up moves

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

  • Inspect the pinned Vitest 4.1.11 resolver implementation that owns the static queue lifecycle.
  • Wait for the exact-head non-isolated CI checks to finish green.

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 (3 earlier review cycles)
  • reviewed 2026-08-18T21:59:47.211Z sha db410b0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T23:52:16.656Z sha db410b0 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T00:34:37.057Z sha db410b0 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 23, 2026
@steipete
steipete force-pushed the codex/fix-main-mock-resolution branch from db410b0 to 8bb6fa7 Compare August 26, 2026 10:10

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready at exact head 8bb6fa7d74e7e681a67b01cd3b0d718e5fe81bbc.

Classification: a shared test-harness contention race exposed by Vitest 4.1.11 lifecycle concurrency, not a production update CLI defect or a dependency regression requiring downgrade. Vitest 4.1.11's BareModuleMocker.resolveMocks reads the static queue, awaits ID resolution, then replaces the queue with []; the 4.1.11 lifecycle-concurrency change exposes the late-registration window. This fulfills ClawSweeper's direct-contract rank-up move.

Before/after proof:

  • Before: node scripts/run-vitest.mjs test/non-isolated-runner.resolve-mocks.test.ts -t 'drains ids queued during the final pass without requiring another caller' --reporter=verbose failed with expected ['mock-a', 'mock-late'], received ['mock-a'].
  • After: resolver owner suite 7/7; src/cli/update-cli.test.ts 247/247; full two-worker CLI shard 231 files / 5,506 tests passed.
  • node scripts/check-changed.mjs -- test/non-isolated-runner.ts test/non-isolated-runner.resolve-mocks.test.ts passed (format, test types, dependency guards, script lint).

Reviews and hosted proof:

  • Fresh structured autoreview: no actionable findings, confidence 0.99.
  • Separate exact-head Codex review: no concrete blockers.
  • ClawSweeper exact-head run: patch correct, no findings; independently ran the resolver owner suite 7/7 twice.
  • Full exact-head CI: green, including the non-isolated CLI shards. This fulfills ClawSweeper's exact-head CI rank-up move.
  • Native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 126037: passed with hosted exact-head gates; prepared head remained unchanged.

Production LOC delta: 0. Test support +5 net; regression test +22. No CLI output, side effect, dependency, docs, or changelog change. Known proof gaps: none.

@steipete
steipete merged commit f649017 into main Aug 26, 2026
116 checks passed
@steipete
steipete deleted the codex/fix-main-mock-resolution branch August 26, 2026 10:32

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

2 participants