Skip to content

fix(tests): stop SessionLogActor diagnostic test racing the FlushTick - #1927

Merged
Aaronontheweb merged 1 commit into
devfrom
fix/session-log-diagnostic-flake
Aug 13, 2026
Merged

fix(tests): stop SessionLogActor diagnostic test racing the FlushTick#1927
Aaronontheweb merged 1 commit into
devfrom
fix/session-log-diagnostic-flake

Conversation

@Aaronontheweb

Copy link
Copy Markdown
Collaborator

Problem

SessionLogActorTests.Dispatcher_writes_audit_and_diagnostic_to_same_session_log is flaky on Windows CI. It failed on run 31715544081 (job 94499226187, 2026-08-13): after the full ~3s AwaitAssertAsync budget, the file contained the assistant line but not the diagnostic line, even though the write was correct.

Root cause (confirmed by dotnet-concurrency-specialist + akka-net-specialist):

  • The test sent the durable audit TextOutput first (flushed immediately via WriteDurable), then the buffered SessionLogDiagnostic (Write only — no flush).
  • Buffered diagnostics only reach the OS at a flush point: the 1s FlushTick (real wall-clock scheduler, not the test's FakeTimeProvider), the 256-write threshold, a later durable write, or PostStop.
  • On a loaded 2-core Windows runner the tick can land past the 3s assert budget → flake. The test predates the batching refactor (refactor(logging): partition the log stream by session — session.log per session, daemon.log sparse, OTEL the union (#1472) #1499) that introduced the buffered diagnostic path.

Fix (test-only, deterministic)

Send the buffered diagnostic first, then the durable audit line — the audit write's WriteDurableFlush() drains the buffered diagnostic synchronously in the same mailbox turn. This is the exact behavior documented in SessionLogActor.cs: "audit lines are natural flush points."

No production change: the buffered-diagnostic path is deliberate (batching, per #1499) and bounded in production.

Verification

  • 10/10 stress runs pass in 433–702ms (previously ~1s every run, gated on the tick).
  • Full SessionLogActorTests class: 4/4 pass.
  • Fix removes the wall-clock dependency entirely, so the loaded-runner failure mode cannot resurface.

Notes

  • Test-only change; no OpenSpec, no system-skill change.

Dispatcher_writes_audit_and_diagnostic_to_same_session_log sent the
buffered diagnostic AFTER the durable audit line, so the diagnostic
only became visible when the actor's 1s wall-clock FlushTick fired.
On loaded Windows CI runners the tick can land past the 3s
AwaitAssertAsync budget, failing the test even though the write was
correct (seen on run 31715544081, job 94499226187).

Send the buffered diagnostic first; the durable audit write drains it
synchronously via WriteDurable — the documented natural flush point.
The test no longer depends on the wall-clock timer (verified: passes
in ~0.5s, previously ~1s gated on the tick).
@Aaronontheweb Aaronontheweb added platform:windows Windows-specific issues and support tests All issues related to testing, quality assurance, and smoke testing. labels Aug 13, 2026
@Aaronontheweb
Aaronontheweb enabled auto-merge (squash) August 13, 2026 20:33
@Aaronontheweb
Aaronontheweb merged commit e02f211 into dev Aug 13, 2026
23 checks passed
@Aaronontheweb
Aaronontheweb deleted the fix/session-log-diagnostic-flake branch August 13, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform:windows Windows-specific issues and support tests All issues related to testing, quality assurance, and smoke testing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant