Skip to content

improve(ci): new tests can pass once on their pull request and then fail intermittently on main - #2191

Merged
bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-new-test-soak
Nov 13, 2026
Merged

bkudiess merged 1 commit into
openclaw:mainfrom
bkudiess:bkudiess-new-test-soak

Conversation

@bkudiess

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: a new or changed test can pass its single pull request run and then fail intermittently on main. #1681's DesktopCompanionWindowTests.Notification_UsesExistingMascot... did exactly that: it passed its one PR run (43475422208) and then failed on main fbc0287.

User Impact

No product change. Contributors now see an intermittent new or changed test fail on their own pull request, where it is cheap to fix, instead of on main for everyone. Pull requests that change tests gain one Windows job (new-test-soak) that CI Gate requires; pull requests that change no tests pass it after a short selection step.

Why This Change Was Made

A new pull-request-only job runs the tests the pull request adds or changes ten times, three of them while CPU burner processes load the runner. Any failed run fails the job, and CI Gate requires it.

  • Selection (scripts/Get-CiChangedTests.ps1, scripts/CiChangedTests.ps1): diffs the merge commit against its first parent and maps changed lines in Shared, Tray and Tray UI test files to xUnit methods. A line inside a test (including a string or comment edit) selects that test. A helper change selects the tests of the nearest enclosing type with tests, or the whole file. Removed code counts, so deleting or commenting out helper code is not missed. Tray UI tests are soaked only for method-level hits (a helper edit in a large UI file would otherwise run many native tests the PR did not write). Caps: 30 tests per project and 8 UI tests; anything left out is listed with a reason.
  • Runner (scripts/Invoke-CiTestSoak.ps1): builds each project once the way its lane does, then runs dotnet test --no-build with a name filter plus the existing lane exclusions. Each run gets fresh OPENCLAW_TRAY_* data folders and must produce exactly one TRX. Hang detection is on, without dumps. A 40-minute step budget is shared fairly: every selected project gets its first run, and repeat runs stop at the project's share of the time left. A budget-limited soak passes with a warning.
  • Promotion compatibility (same rules as fix(ci): alpha promotion fails because older candidates don't accept -StepTimeoutMinutes #2154): every knob is a step environment variable (OPENCLAW_CI_SOAK_*); the runner takes only -SelectionPath and -ResultsDirectory. The job is skipped outside pull_request, so alpha promotion is unaffected.

The workflow contract pins the job shape, the runner parameters and tokens, the UI preparation steps (identical to the UI lane), and the CI Gate wiring. docs/TEST_COVERAGE.md documents selection, settings, budget, exclusions and blind spots.

Known limits (documented)
  • Changes the soak cannot map to tests are not soaked: helpers in other files, partial classes split across files, non-C# fixture data, product code, and test projects other than Shared, Tray and Tray UI.
  • Tests that need their own lane environment (production resources, animation preference, native onboarding, accessibility, native keyboard proof) are excluded and still run in their lanes. The soak warns about selected tests that did not run.
  • Deleting a whole test may select the test right next to it, and deleting a whole test class may select the other tests in its file (extra selection only; nothing is missed).
  • There is no per-PR opt-out; settings change only by editing the workflow.

Evidence

  • Mutation proof (caught): in a disposable worktree, an added Shared test that fails every third run (SoakMutationProbeTests.IntermittentProbe) was selected (has_tests=true, method level) and the soak failed: ::error title=New-test soak::shared run 3 of 10 failed: OpenClaw.Shared.Tests.SoakMutationProbeTests.IntermittentProbe (run 2 ran under CPU contention).
  • Skip proof: a docs-only commit gave has_tests=false, ui_tests=false, and the runner exited successfully with "no added or changed tests were selected"; no build or test ran.
  • Two-project stable soak: one Shared and one Tray test, 2 runs each (run 1 contended). Tray built with -r win-x64 after its WinUI prebuild; both projects passed 2 of 2. The step used 1.8 of 40 minutes, and no burner processes were left afterwards.
  • UI path (earlier revision, under the native-desktop lock): one fixture UI test passed 2 runs (1 contended) with the UI lane's preparation.
  • Parser accuracy: test discovery equals vstest --ListFullyQualifiedTests for the current tree: Shared 3557, Tray 4310, Tray UI 899 names, 0 differences.
  • Contract negatives: each of these fails test-ci-workflow-contract.ps1 at its intended check: an extra runner parameter, removing the job from CI Gate needs, removing the PR-only if, and removing --blame-hang-dump-type none from the runner.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • none: CI workflow and runner scripts only. No product behavior or capacity-dependent Windows proof is affected.

Validation

Local, head 6dd3bf3 on main bf61595, PowerShell 7, isolated OPENCLAW_TRAY_* profile:

Command Result
scripts\test-ci-changed-tests.ps1 (new) ✅ pass: parsing (strings, raw/verbatim/interpolated, comments, combined and spaced attributes, generic constraints, expression bodies with lambdas), selection (method/class/file, nested types, string/comment edits, removed code, pure deletions), diff map, end-to-end CLI in a temp repo (caps, UI method-only and UI cap, outputs, invalid cap), runner setting validation, contention spread (runs 2, 5, 8), budget function
scripts\test-ci-workflow-contract.ps1 ✅ pass; each negative under Evidence fails at its intended check
scripts\test-ci-gate-results.ps1 ✅ pass (new soak required/skipped cases)
scripts\test-alpha-promotion.ps1, test-ci-change-classifier.ps1, validate-test-timing-patterns.ps1 ✅ pass
validate-docs.ps1, validate-agent-skills.ps1, test-agent-skills-validator.ps1, git diff --check ✅ pass
./build.ps1 ✅ pass
dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore ✅ 5864 passed, 29 skipped, 0 failed
dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore ✅ 6496 passed, 0 failed (includes CiNugetCacheWorkflowTests at 12 cache lanes)

Review: Hanselman dual review (claude-opus-5.5 high; gpt-6-astra long_context high), a first pass plus four delta passes; both models confirmed the final head 6dd3bf3 with no open CRITICAL, HIGH or MEDIUM findings. The accepted findings were fixed and have regression tests:

  • Expression-bodied tests ended at a lambda's semicolon (both models flagged it).
  • The budget did not check between builds and could starve later projects.
  • Removed code next to blank or comment lines selected nothing.
  • Spaced attributes and generic constraints before a block body were not parsed.
  • Removed code was judged line by line: inline or block comments, string data, and a test deleted together with a helper were misread. It is now judged by parsing the removed lines (code inside a whole deleted test does not count).
  • First-pass findings: deletions, string-only edits, missing or extra TRX files, UI fallbacks, hang dumps, burner cleanup, combined attributes, Tray runtime and prebuild, nested-type fallback.

The LOW items not fixed are listed under Known limits.

Real Behavior Proof

  • Environment tested: Windows 11 dev host, PowerShell 7, .NET 10 SDK; isolated OPENCLAW_TRAY_* roots; disposable git worktree for the mutation and skip proofs.
  • PR head or commit tested: 6dd3bf3 (the mutation, skip and two-project proofs ran on this runner and selection code).
  • Exact steps or command run: scripts\Get-CiChangedTests.ps1 -BaseRef <base> -OutputPath <json> then scripts\Invoke-CiTestSoak.ps1 -SelectionPath <json> -ResultsDirectory <dir>, with default soak settings for the mutation proof.
  • Evidence after fix: see Evidence (the error annotation for run 3 of 10, the skip output, and the two-project summary table).
  • Observed result: the intermittent test is caught on its pull request; a test-free change skips; stable tests pass under contention.
  • Screenshot or artifact links verified? N/A
  • Not verified or blocked: the first real GitHub Actions run of the job happens on this PR. This PR changes no tests, so in CI it exercises the skip path.

Security Impact

  • New permissions or capabilities? No (the job inherits the workflow's contents: read and actions: read, checks out with persist-credentials: false, and only restores the NuGet cache).
  • Secrets or tokens handling changed? No
  • New or changed network calls? No
  • Command or tool execution surface changed? No (it runs the pull request's own tests, as the other lanes do; test names in annotations are escaped).
  • Data access scope changed? No
  • If any answer is Yes, explain the risk and mitigation: N/A

Compatibility and Migration

  • Backward compatible? Yes (alpha promotion skips the job; settings are env-only).
  • Config or environment changes? Yes: new optional OPENCLAW_CI_SOAK_* step variables with defaults; see docs/TEST_COVERAGE.md.
  • Migration needed? No
  • If yes, list the exact upgrade steps: N/A

Review Conversations

  • I replied to or resolved every bot review conversation addressed by this PR.
  • I left unresolved only conversations that still need maintainer judgment.

…ail intermittently on main

Add a pull-request-only new-test-soak job. It selects the Shared, Tray and
Tray UI tests that the pull request adds or changes (method level, with type
and file fallbacks; UI tests method level only) and runs them ten times, three
under CPU contention. Any failure blocks CI Gate. Pull requests that change no
tests skip it. Settings are environment variables only, and the step keeps a
shared 40-minute budget.

Co-authored-by: Copilot App <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

🦞👀
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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement 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. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 13, 2026
@clawsweeper

clawsweeper Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge.

What this changes

Adds a required pull-request job that repeatedly runs selected changed tests, including runs under CPU contention.

Example: SoakMutationProbeTests.IntermittentProbe fails every third execution.

  • Before: One successful PR execution can let the intermittent failure reach main.
  • After: The reported Windows mutation run fails the soak on execution 3 of 10.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused CI coverage with reported Windows execution and a successful real soak job; the remaining full CI checks were still running when inspected.
Proof confidence 🐚 platinum hermit (4/6) CI-only maintainer-authored work needs no product-runtime proof; supplied Windows runner output covers mutation detection, skip selection, and stable contended execution, and the exact-head Actions soak step succeeded.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Maintenance · Worth it: Yes · Fix scope: Complete
User problem: Contributors can merge a test after one passing run and expose everyone on main to its intermittent failures.
Reason: The collaborator-authored direction has concrete operational value, explicit coverage limits, and no product behavior change.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR adds useful CI coverage absent from main, and no blocking introduced defect was found.

Priority: P2
Reviewed head: 6dd3bf3fd0a755a5baf601fc017103e87d5d1106

Before merge

None.

Findings

None.

Agent review details

How this fits together

GitHub Actions passes the PR merge diff through test selection, builds selected projects, collects repeated test results, and feeds the job outcome into CI Gate.

flowchart LR
  A[PR merge diff] --> B[Changed test selector]
  B --> C[Selected project builds]
  C --> D[Repeated test runs]
  E[CPU contention workers] --> D
  D --> F[TRX results]
  F --> G[CI Gate]
Loading

Technical review

Best possible solution:

Land the supplemental changed-test soak with its documented limits while preserving all existing required test lanes.

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

This is preventive CI coverage rather than a deterministic product bug; the supplied mutation scenario demonstrates a test passing initially and failing on its third execution.

Is this the best way to solve the issue?

The selector and bounded runner form a coherent supplemental lane, reuse the existing budget helper and gate, and retain ordinary coverage instead of retrying failed tests into success.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • CI Gate and supplemental lane admission keeps the original intent (5d19239: Provide a stable fail-closed gate while allowing classified fast paths.)
  • Promotion-safe runner settings and budget contracts keeps the original intent (435f4fe: Current workflows must not pass unsupported runner options to older promotion candidates.)
  • Fixture shards and shared cache inventory keeps the original intent (22deecc: Parallelize costly fixture coverage while retaining required lanes and accurate cache contracts.)
  • Timed-step workflow validation keeps the original intent (ee8edbc: Expose approaching step timeouts and prevent new timing-sensitive test patterns.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Barbara Kudiess: Raw commit 22deecc adds scripts/Assert-CiGateResults.ps1:21 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 22deecc6ea8e; files: scripts/Assert-CiGateResults.ps1)
  • Scott Hanselman: Raw commit 969fe6d adds scripts/Assert-CiGateResults.ps1:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 969fe6dad230; files: scripts/Assert-CiGateResults.ps1)
  • Dallin Romney: Raw commit cb757b3 adds scripts/Assert-CiGateResults.ps1:19 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: cb757b3af5b4; files: scripts/Assert-CiGateResults.ps1)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Infrastructure and coverage growth Infrastructure +816/-1 lines; tests +328/-7; documentation +45 Growth implements source selection, bounded repeated execution, workflow integration, and distinct parser/gate regressions; no unrelated production feature was added.

Labels

Label changes:

  • add P2: Improves contributor CI reliability by detecting some intermittent changed tests before merge, with no urgent product outage.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Improves contributor CI reliability by detecting some intermittent changed tests before merge, with no urgent product outage.
  • 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.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 13, 2026, 4:18 PM ET / 21:18 UTC.

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

Labels

P2 Normal priority bug or improvement 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant