ChaosSloth: Autonomous Bayesian Concurrency Interleaver & Race Exorcist
Description and use
ChaosSloth — автономная система для investigation аконсусорных баных баглов в Python asyncio. Она sampling 25 естественных циков, использует TabPFN-3.5 для обратного поиска временного разрыва (240.1 мкс при 69.64% уверенности),FORCE reproduction 100%, локально диагонирует Gemma 2B, синтезирует AST-патч с asyncio.Lock вокругshared-состояния, и проверяет через adversarial bytecode — флакейность
Problem
Flaky asyncio concurrency bugs are intermittent, timing-dependent, and difficult to reproduce. A test fails once, passes on rerun, and the defect remains unproven—costing hours while occupying only a few hundred microseconds.
Outcome
Flakiness reduced from 68.0% to 0.0% in 9.07 seconds. The repair was verified by deterministic reproduction (10/10) and adversarial bytecode execution under the reconstructed schedule.
Workflow
- Sample 25 natural coroutine scheduling cycles and record yield deltas, event-loop latency, and context switches
- Invert the temporal boundary using TabPFN-3.5 Bayesian inference to identify a 240.1 µs delay at 69.64% posterior confidence
- Force the candidate interleaving to reproduce the race 100% of the time (10/10)
- Audit lock acquisition dependencies as a directed graph for circular wait (DAG condition) and check for event-loop starvation
- Diagnose the unsynchronized read-modify-write path locally using Google Gemma 2B via Ollama on Apple M4 (52.91 tokens/sec)
- Synthesize an atomic AST patch using ast.NodeTransformer that wraps the shared-state transition in asyncio.Lock while leaving unrelated delays outside the critical section
- Compile the transformed AST into in-memory bytecode and execute through adversarial cycles against the reconstructed schedule
- Verify the invariant holds post-patch; report verified repair if yes, repeat from step 3 if no
Evidence
The benchmark begins with 25 natural sampling cycles. The observed execution exhibits 68.0% natural intermittent flakiness. TabPFN-3.5 inverts the scheduling telemetry and identifies a 240.1 µs delay at 69.64% posterior confidence. ChaosSloth then forces the candidate interleaving and reproduces the race 100.0% of the time (10/10).
A local Google Gemma 2B model diagnoses the unsynchronized read-modify-write path at 52.91 tokens/sec on Apple M4 via Metal/Ollama. ChaosSloth synthesizes a Python AST transformation that places the shared-state transition inside an asyncio.Lock, while leaving non-blocking delays and yields outside the critical section.
Sandboxed bytecode verification reduces flakiness from 68.0% to 0.0% in 9.07 seconds.
Race Predicate: ¬(e₁ ≼ e₂) ∧ ¬(e₂ ∼ e₁) ∧ (Write(e₁) ∨ Write(e₂)) ⟹ Data Race
Graph Liveness Condition: G is a DAG ⟺ there is no directed cycle in G
- Record date: 2026-10-20T18:41:14.401Z