Repository navigation
fix(test): stop migration script exit assertion from flaking on slow runners - #1536
Conversation
…runners CleanupScript_CompletedReceiptPreservesFilesWithoutCallingWsl gave the uninstall script 30 seconds to exit. A local five-iteration reproduction shows the lock-contention path deciding and exiting in about 0.6 seconds, but CI timed out a correct exit-2 run with empty stdout while the script's own log already held the contention line, so the runner stalled while the failure path created its small log and result files rather than the script doing slow work. Give that caller 120 seconds and leave the helper default at 30 so the other call sites still fail fast; neither runs a script that creates files on the path this stall depends on. Also fix the timeout diagnostic. It seeded the cleanup message with "Root process exit confirmed." and only replaced it when cleanup threw, so every timeout report claimed a confirmed exit no matter what happened. Sample HasExited before killing, report the observed state, append rather than overwrite when cleanup races the process exiting, and add the final exit code once it is known. Note that killing discards PowerShell's buffered stdout so a future reader does not mistake an empty output section for a silent script. Cache the process id up front to keep the diagnostic path off live process state. scripts/Uninstall-LocalGateway.ps1 is intentionally unchanged; it already aborts and exits under contention, and its shared read lock is required by the sibling parentShare: Read case. Co-authored-by: Copilot <[email protected]> Copilot-Session: b5aa05ec-0a5a-461e-aef9-52c6a9c92ba2
|
🦞👀 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. |
|
Codex review: blocked before merge. Reviewed September 28, 2026, 6:55 PM ET / 22:55 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch gives the migration cleanup test a 120-second subprocess deadline, improves its timeout report, and updates the test-coverage guide. Merge readiness⛔ Blocked before merge - 3 items remain Keep this PR open. Current main still has the 30-second test deadline, and the follow-up commit resolves the earlier documentation finding. The timeout diagnostic retains a small kill-race error, and the required full build has not completed on this head. Priority: P3 Review scores
Verification
How this fits togetherThe connection test suite launches the real Windows PowerShell uninstall script with isolated migration files and a held lock. It checks the script’s exit and preservation behavior before reporting a test result to CI. flowchart LR
A[Migration test fixture] --> B[Held preparation lock]
B --> C[PowerShell uninstall script]
C --> D[Process deadline]
D --> E{Exited in time?}
E -->|Yes| F[Assert exit and preserved files]
E -->|No| G[Terminate process and report diagnostics]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the scoped deadline, make the diagnostic distinguish a kill attempt from confirmed termination, and complete the required build on a host that can restore the package. Do we have a high-confidence way to reproduce the issue? No independent slow-runner reproduction was established in this read-only review. Current main has the reported 30-second path, and the PR supplies the failing CI observation and Windows PowerShell test runs. Is this the best way to solve the issue? Mostly yes. A caller-scoped deadline preserves the other tests’ fast failure, but the kill-result wording should reflect what cleanup actually confirmed. Full review comments:
Overall correctness: patch is correct AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 19d317e5398a. LabelsLabel changes: No label changes. Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
The coverage guide still described a flat 30-second subprocess deadline for MigrationRecordTests. The helper default is still 30 seconds, but the cleanup lock-contention theory now overrides it to 120 seconds because its failure path writes log and result files a loaded runner can stall on. Record both, and note that timeout reports now include the observed process state. Co-authored-by: Copilot <[email protected]> Copilot-Session: b5aa05ec-0a5a-461e-aef9-52c6a9c92ba2
Summary
CleanupScript_CompletedReceiptPreservesFilesWithoutCallingWslflakes on CI. TheparentShare: None, expectedExit: 2case timed out on a correct run of the uninstall script. This raises that caller's deadline and fixes a timeout diagnostic that was reporting the wrong thing.The test and its 30-second budget were added in #1461 (the migration foundation). No production code changes.
What actually happened
The case deliberately holds
prepare.lockwithFileShare.Nonesoscripts/Uninstall-LocalGateway.ps1fails to acquire it and exits 2. In the failing CI run:Starting local gateway cleanupwas absent, proving cleanup correctly did not continue.So the script reached its failure handler almost immediately and then the run stalled before its output and result files landed.
Reproduction
A five-iteration local harness mirroring the test exactly (same env vars, same args, same
FileShare.Noneparent lock):The script is correct and prompt. The 30 s budget was not sized for its work; it was being asked to absorb a
windows-latestI/O stall on the small log and result files the failure path creates.Changes
1. Scope the larger budget to the one affected caller. The helper default stays at 30 s so the other 23 call sites keep failing fast. Only the lock-contention theory passes
TimeSpan.FromSeconds(120).The other default call sites cannot hit this stall structurally, not just by luck:
Test-InnoMigration.ps1(the L244 caller) contains noSet-Content,Out-File,New-Item,Add-Content, orStart-Transcriptat all, and the L348 caller runs an AST-extracted predicate over in-memory ACLs. Neither creates the files the stall depends on, and neither holds aFileShare.Nonehandle in the directory the child touches.2. Fix the timeout diagnostic. It seeded
cleanupwith"Root process exit confirmed."and only overwrote it when cleanup threw, so every timeout report claimed a confirmed exit regardless of what happened. Now it samplesHasExitedbefore killing, reports the observed state, appends rather than overwrites when the kill races the process exiting, and adds the final exit code once known. It also notes that killing discards PowerShell's buffered stdout, so a future reader does not mistake an empty output section for a silent script. The process id is cached up front to keep the diagnostic path off live process state.What is deliberately not changed
scripts/Uninstall-LocalGateway.ps1is untouched.An automated suggestion on the original failure proposed rewriting its lock acquisition to use
FileShare.Noneand a hardcodedexit 2. That was rejected:FileAccess.Read, FileShare.Readto join the Inno parent's read lock. Switching toFileShare.Nonewould break the siblingparentShare: Read, expectedExit: 10case, which passed in the same CI run - trading an intermittent flake for a deterministic regression.exit 2would discard$script:MigrationAdmissionPhase, which selects exit 1 vs 2.Required proof pools
none. This is a test-only change to a timeout budget and a diagnostic message. It touches no installer artifact, WSL gateway, MXC containment, ARM64 path, or WinUI surface, so no named pool indocs/PROOF_POOLS.mdapplies.Validation
Run in a clean worktree off
mainat19d317e5:dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --filter "FullyQualifiedName~MigrationRecordTests"- 53 passed, 0 failed (32 s), including all five cases of the affected theory.dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj- 4145 passed, 0 failed, 34 skipped.dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj- 3180 passed, 0 failed.Also
dotnet test .\tests\OpenClaw.Connection.Tests\OpenClaw.Connection.Tests.csproj --filter "FullyQualifiedName~MigrationRecordTests"re-run after the review fixes - 53 passed, 0 failed, and.\scripts\validate-docs.ps1- passed, 51 Markdown files and 7 named proof pools checked.Full build: blocked, not skipped
.\build.ps1did not complete on this head. It fails at restore withNU1100resolvingMicrosoft.WindowsAppSDK 2.5.1, whichmainbumped in #1522.The cause is environmental and confirmed at the network layer, not a repository break:
2.4.0is present in the local NuGet cache;2.5.1is not.curl.exereturnsschannel: SEC_E_ILLEGAL_MESSAGE(TLS alert, handshake failed) and PowerShell reportsHandshakeFailure, so this is TLS interception on the network path rather than a NuGet orNuGet.Configproblem. Source mapping is a singlenuget.orgsource with a*pattern.OpenClaw.Shared,OpenClaw.Connection,OpenClaw.SetupEngine,OpenClaw.Cli, andOpenClaw.WinNode.Cliall restored and built.This PR changes one test file and one documentation table. It references no WinUI type, so the unbuilt projects cannot be affected by it, and the suites above cover every project that can be. CI's own
change-classificationjob evaluated this head and skipped the build and publish jobs for the same reason.I cannot clear this locally without network access to nuget.org. Any machine that can reach nuget.org, including CI, resolves
2.5.1normally.Dual-model adversarial review was run on the change and re-run after fixes; both models report no remaining issues.
Real behavior proof
The reproduction table above is the behavioral evidence: five consecutive runs of the exact failing scenario, each exiting 2 in ~0.6 s with full stdout. That is what establishes the script is correct and the CI timeout was environmental rather than a hang.