test(workflow): gate windows cli timing on model-call hook - #15
Conversation
The workflow CLI pause/stop/slow-run contracts raced a wall-clock sleep hook against background-worker startup on loaded Windows CI runners, so pause and stop observed an already-terminal task and exited non-zero. The source contract also compared the reported path against a `canonicalize`d path, which diverges on Windows by adding the `\\?\` verbatim prefix and expanding short names. Replace the sleep with a deterministic pre_model_call gate: the hook records a start marker and blocks until the test writes a release file, so the workflow is provably mid-run when the test observes it. Compare the source path after canonicalizing both sides. Co-authored-by: TRAE CLI <noreply@bytedance.com>
|
Warning Review limit reached
Next review available in: 3 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughWorkflow CLI contract tests now canonicalize source paths and replace fixed sleeps with deterministic mock-provider delays. Tests poll workflow activity before completion, stop, or pause operations and include diagnostic state output on failure. ChangesWorkflow CLI test synchronization
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The Windows CI still failed the three timing gates after the first fix, so mirror the shell_session_contract.rs marker-wait pattern exactly (Set-Content marker + Test-Path poll, no custom deadline expression) and surface the workflow show state plus a hook activity log on failure to pin down why the run leaves its active state before release. Co-authored-by: TRAE CLI <noreply@bytedance.com>
CI diagnostics showed the release-file gate could not work on Windows: the pre_model_call hook has a hard 30s timeout, and the worker's hook process file writes were not observable to the test until the hook was reaped, so the gate always hit the timeout and the run failed. Replace the gate with the proven approach: a fixed 8s Start-Sleep/sleep hold (well under the 30s hook timeout, matching session_server_contract) plus test-side polling for the queued/running state. This removes the background-worker startup race without depending on cross-process file visibility or the hook lifecycle. Co-authored-by: TRAE CLI <noreply@bytedance.com>
CI diagnostics proved the shell sleep hook could not reliably hold the workflow worker on Windows: the pre_model_call hook either hit its 30s timeout (blocking gate) or failed to delay the run at all, so the CLI control commands raced an already-terminal task. Drive the delay from inside the mock provider instead. A `mock_stream_delay_ms <n>` agent prompt performs a real, cancellable, platform-neutral delay in the streaming provider path, with no shell, hook, or cross-process file dependency. Tests poll for the active state before issuing run/stop/pause, removing the background-worker startup race that the fixed sleeps were guarding against. Co-authored-by: TRAE CLI <noreply@bytedance.com>
The workflow CLI contracts no longer need platform-specific shell sleep hooks. They now use the mock provider's cancellable cross-platform delay and poll persisted active state, which avoids both worker-startup races and the 30-second hook timeout. Keep the dialect-aware hook assertion for the remaining hook-based fixtures and require the stronger workflow pattern explicitly. Co-authored-by: TRAE CLI <noreply@bytedance.com>
Problem
The native Windows CI (
windows-ci.yml) has been red onmainbecause fourtests/workflow_cli_contract.rscontracts fail deterministically on both Windows x64 and ARM64:workflow_run_returns_before_slow_workflow_completesworkflow_stop_requests_real_background_stopworkflow_pause_resume_and_clone_control_persisted_runworkflow_source_command_prints_saved_workflow_sourceRoot causes:
pre_model_callhook that ransleep/Start-Sleep, then raced a fixedthread::sleepin the test against it. The workflow runs in a separate background worker process; on loaded Windows runners the worker startup + first model call outran the short (150–250 ms) test waits, soworkflow pause/stopobserved an already-terminal task and exited1(Some(1)vsSome(0)in CI).workflow sourcereports the path resolved from the working directory (notcanonicalized), so on Windows the test'sscript.canonicalize()expectation added the\\?\verbatim prefix and expanded 8.3 short names, e.g.C:\Users\RUNNER~1\...vs\\?\C:\Users\runneradmin\....Fix (test-only)
startedmarker and blocks until the test writes areleasefile (condition-based waiting, matching the provenshell_session_contract.rspattern). The workflow is provably mid-run when the test observes it, independent of CI scheduling. The hook self-releases after ~25 s to stay within the 30 s hook timeout.The product behavior is unchanged and correct; only the test expectations were platform-fragile.
Verification
cargo fmt --all -- --checkcargo test -p blade-deepseek --test workflow_cli_contract— 10/10, deterministic across 4 runs on macOScargo test --workspace --all-targets --locked -- --test-threads=1green (aside from a pre-existing intermittenttui_pty_contractrender flake that passes in isolation)toml+HookConfigparser (backslash paths preserved, quotes balanced)node scripts/validate-windows-platform-boundaries.mjsWindows x64 + ARM64 CI on this PR is the authoritative check.
Summary by CodeRabbit