Repository navigation
chore(tests): block new timing-sensitive test patterns and warn near CI step timeouts - #2141
Conversation
…CI step timeouts Adds a ratchet over literal short hang guards, fixed delays and one-shot UI Automation lookups in test code, run in Tray tests and always-on fast validation; a CI step budget report that warns at 80% of timeout-minutes; and deterministic-test rules in TEST_COVERAGE.md and the test-audit skill. Moves misplaced FileWorker coverage out of 'Writing a regression test'. Co-authored-by: Copilot App <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
…n be lowered Pull requests that remove timing-sensitive patterns stay green; the validator emits a warning annotation with the -LowerBaseline command instead. Co-authored-by: Copilot App <[email protected]>
|
Codex review: needs changes before merge. What this changesThis PR adds a timing-pattern baseline guard and warnings when CI test steps consume most of their timeout. Example: A contributor adds Task.Delay(250) to a test file whose fixed-delay baseline is zero.
Review scores
ProductKind: Maintenance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this collaborator-authored PR adds useful CI safeguards absent from main and needs a narrow documentation repair. Priority: P3 Before merge
Findings
Agent review detailsHow this fits togetherRepository test source enters a shared scanner used by fast validation and Tray tests; existing CI runners separately report elapsed time against workflow step budgets. flowchart LR
A[Test source] --> B[Shared scanner]
C[Checked in baseline] --> B
B --> D[Fast validation and Tray tests]
E[CI test runners] --> F[Step budget reporter]
F --> G[Console and warning annotations]
Technical reviewBest possible solution: Retain the shared scanner and existing runner owners, with incident-linked guidance and accurate timeout defaults. Do we have a high-confidence way to reproduce the issue? This is preventive CI work supported by recorded timing failures; this read-only review executed no target code. Is this the best way to solve the issue? The problem is recurring timing-sensitive additions and unnoticed budget growth; the invariant is to preserve existing test execution and failure handling, and the shared scanner plus additive runner reporting is a focused solution. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8d5e27bd8d3a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 12, 2026, 11:03 PM ET / November 13, 2026, 04:03 UTC. |
Use the ui-tests job's desktop-step guard for the native disclosure proof step, as main's Automations, animation, Axe and Local AI proof steps do, so an unrelated Tray UI failure no longer hides it, and pin the guard in the workflow contract. Mark the screenshot-only chevron settle for the timing-pattern ratchet from openclaw#2141; assertions wait for native expansion state.
What Problem This Solves
Fixes: new flaky test patterns keep landing on
mainafter each flake is fixed, and a CI step can drift toward its timeout without anyone noticing until passing runs start timing out.User Impact
No user-visible change. Contributors get an immediate CI failure that names the safe helper when a pull request adds a literal short hang guard, a fixed delay, or a one-shot UI Automation lookup to test code. CI also shows a warning annotation when a test step uses 80% or more of its timeout.
Why This Change Was Made
The November 2026 flake investigation found the same few root patterns behind most intermittent failures. Fixing individual tests did not stop new ones: while this branch was open, #2137 added 15 new one-shot lookups. This change makes the patterns visible and ratcheted, without breaking existing code:
Ratchet guard. A dependency-free C# scanner,
tests/OpenClaw.Tray.Tests/TestTimingPatternGuard.cs, masks comments and strings, then counts three rules per test file:Task.Delay,Thread.Sleep, andSettleAsyncused as readiness;Find*(...)!and throwingFind(root, id)lookups in Tray UI Automation tests.Current counts are recorded in
TestTimingPatternBaseline.json. Growth fails. A shrunk count only emits a warning annotation with the command that lowers the baseline (-LowerBaselineorOPENCLAW_UPDATE_TEST_TIMING_BASELINE=1, which never raise a count), so in-flight PRs that remove patterns stay green. A deliberate case can use// test-timing-exception: <reason>. The guard runs in Tray tests and, throughscripts/validate-test-timing-patterns.ps1(Add-Type), in always-on fast validation. That matters because the change classifier sends UI-test-only PRs only to the UI lane.Step budget.
scripts/CiStepBudget.ps1adds-StepTimeoutMinutestoInvoke-CiTest.ps1,Invoke-CiE2e.ps1, andtest-gateway-fixture.ps1. The 12 timed single-runner steps inci.ymlpass theirtimeout-minutes, including the new Tray UI shard. Each runner prints the share of its budget it used, warns at 80% or more, and also reports on failure.test-ci-workflow-contract.ps1rejects drift fromtimeout-minutes, and a multi-command runner step must be listed as an explicit exception.Docs. New "Deterministic native and timing-sensitive tests" rules in
docs/TEST_COVERAGE.md, pointing at real helpers, and a matching checklist in thetest-auditskill. The misplaced FileWorker coverage block moves verbatim from "Writing a regression test" to "Coverage highlights".Baseline at introduction (current main)
short-literal-hang-guardfixed-delay-readinessone-shot-uia-lookupIf another PR adds occurrences before this merges, this PR's ratchet will fail on rebase. Update only the named entries to match
main.Evidence
The clean tree passes both entry points. A deliberate new violation (one of each rule in
NativeUiOwnership.cs, and at.Wait(3000)in a Shared test) fails with file, line, and helper. Removing oneTask.Delaypasses with a "baseline can be lowered" warning annotation.38 focused detector tests cover:
$$""") strings;_/_5000identifiers;ValueTask SettleAsyncdeclarations;Changing a step's
-StepTimeoutMinutes 25to24fails the workflow contract with the step name.An adversarial dual-model review (Claude Opus 5.5 + GPT-6 Astra, high effort) found no critical or high issues. Fixed:
_crash;ValueTaskfalse positive;Deferred, documented as limits: interpolation format-specifier text, extra equivalent forms (target-typed
CancellationTokenSource,Task.WaitAll), and remove-one/add-one in the same file.Change Type
Scope
winnodeRequired proof pools
none: test-code static analysis, CI runner reporting, and docs only. No product behavior, UI, Gateway, installer, or native capability changes.Validation
Run on the final rebased head with an isolated tray profile (
OPENCLAW_TRAY_DATA_DIR,OPENCLAW_TRAY_APPDATA_DIR,OPENCLAW_TRAY_LOCALAPPDATA_DIRset to a temporary directory):./build.ps1: passed (all builds succeeded)dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restore: passed 5,849, skipped 29 (environment-gated), failed 0dotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restore: passed 6,402, failed 0 (includes 38TestDeterminismGuardTests; rerun on9a6822633: 6,402 passed)./scripts/validate-test-timing-patterns.ps1: passed (about 5 s)./scripts/test-ci-workflow-contract.ps1: passed (12 budgeted steps; 7 E2E harness cases including budget on success and failure)./scripts/test-ci-gate-results.ps1,test-ci-change-classifier.ps1,test-alpha-promotion.ps1,test-ci-native-failure-metadata.ps1,test-proof-evidence.ps1,test-native-animation-preference.ps1,test-ci-test-host-exit.ps1: passed./scripts/validate-docs.ps1,validate-agent-skills.ps1,test-agent-skills-validator.ps1,git diff --check: passedReal Behavior Proof
9a68226334c875b012e63730881d663ea66027ad(based onorigin/main8d5e27bd8); full build and Shared suite ran on its parent3d138e97, which differs only in the guard, its tests and docs.pwsh -File scripts/validate-test-timing-patterns.ps1and theTestCode_DoesNotAddTimingSensitivePatternstest; changed a step budget, then ranscripts/test-ci-workflow-contract.ps1.::error title=Timing-sensitive test pattern::tests/OpenClaw.Shared.Tests/SingleFlightDownloadTests.cs: short-literal-hang-guard has 1 occurrence(s), baseline 0. Lines: 138. Use a named, environment-overridable timeout ...;CI step 'Run Tray UI Tests' must pass -StepTimeoutMinutes 25 to match its timeout-minutes.Test timing pattern ratchet passed.Every budgeted step printed its share, for exampleCI step budget: OpenClaw.Tray.UITests.Shard.trx used 9.6 of 25 minutes (38%),OpenClaw.Tray.UITests.trx used 3.5 of 25 minutes (13%),Gateway fixture checks used 19.9 of 30 minutes (66%), andE2E shard 'setup-connect' used 7.4 of 20 minutes (37%). No step reached the 80% warning.::warningannotation was not triggered in CI (no step was near its budget); its format is covered by the workflow contract tests.Security Impact
Yes, explain the risk and mitigation: N/ACompatibility and Migration
-StepTimeoutMinutesdefaults to 0, which skips the report.OPENCLAW_UPDATE_TEST_TIMING_BASELINE=1for local baseline lowering)Review Conversations