Repository navigation
[AI-2092][AI-2102] De-flake two CI-only flaky tests - #645
Conversation
Both failed on a transient/environmental CI race, not a real regression. - AI-2092 (AgentVerbDispatchTests.Start_without_a_server, ubuntu): RunCli cleared only KCAP_URL, but the child inherits the assembly's SHARED KCAP_CONFIG_DIR (IntegrationGlobalSetup) and the CLI resolves the server from a persisted profile too. A sibling integration test writing a server_url into that shared config defeated clearServerUrl, so "no server configured" never fired. Give RunCli a fresh per-call KCAP_CONFIG_DIR so the test-controlled KCAP_URL is the only server signal. - AI-2102 (CursorHookCommandTests.CancelledFetch_leaves_lease_uncommitted, windows): the 250ms memory budget was started before the request entered the handler, so under load the token could fire before SendAsync ran and handler.Entered stayed false. Make cancellation deterministic: the handler signals entry (EnteredSignal) and the test triggers Release() only after awaiting it, so entry always precedes cancellation. The request still binds to and honours its own budget/deadline token. Note: no Linear IDs in .cs per scripts/check-linear-ids.sh (verified green). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
PR Summary by QodoDe-flake CLI tests via per-run config isolation and deterministic cancellation
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1.
|
- Bug (Correctness, High): CancelAwareHandler now records ct.CanBeCanceled on entry and the test asserts TokenWasCancelable — so the test fails if the production code stops plumbing the budget/deadline token into the request (CancellationToken.None), restoring the regression it guards. - Bug (Reliability): the EnteredSignal await is now bounded (WaitAsync 30s) so a future change that skips the fetch fails fast instead of hanging until the runner kills the job. - Rule violation (Maintainability): trimmed the narrative comment blocks in CursorHookCommandTests and AgentVerbDispatchTests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The prior deterministic rewrite cancelled via a handler-private token, so the test no longer proved the memory-BUDGET token governs the request (it would pass even if production passed the outer deadline or any cancelable token). Restore that guard deterministically via a TimeProvider seam: - HandleCore/HandleCoreInner/RunMemoryOrchestrationAsync take an optional TimeProvider (default: system clock, production unchanged) that drives the memory-budget CancellationTokenSource. - The test passes a FakeTimeProvider with the original 250ms budget + 15s outer deadline, waits (bounded) for the request to ENTER the handler, then advances the clock 250ms. Cancellation now flows through the production budget token, so a passing test proves that token governs the fetch — with no entry race. Removed the handler-private _release / TokenWasCancelable scaffolding. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
De-flakes two CI-only flaky tests, each a transient/environmental race rather than a real regression. Test-only changes.
Fixes
AgentVerbDispatchTests.Start_without_a_server…(ubuntu)RunClicleared onlyKCAP_URL; the child inherits the assembly's sharedKCAP_CONFIG_DIR, and the CLI resolves the server from a persisted profile too — a sibling test writing aserver_urlthere defeatsclearServerUrlRunClia fresh per-callKCAP_CONFIG_DIRso the test-controlledKCAP_URLis the only server signalCursorHookCommandTests.CancelledFetch_leaves_lease_uncommitted(windows)SendAsyncran (Enteredfalse)EnteredSignal) and the test triggersRelease()only after awaiting it; the request still binds to and honours its own budget/deadline tokenVerification (local, macOS arm64)
AgentVerbDispatchTests: 11 passed / 0 failed.CursorHookCommandTests.CancelledFetch_leaves_lease_uncommitted: passes.CursorHookCommandTestsfailures locally are a pre-existing baseline (coordination-notice injection with no isolated config) — identical on unmodifiedorigin/mainin a detached baseline worktree, and untouched by this diff.scripts/check-linear-ids.sh: green (issue IDs kept out of.cs).🤖 Generated with Claude Code