rust-deterministic-concurrency-tests
Skill0 starsChanged 39 days agoMITView on GitHub
Use when Rust concurrent data structures pass stress tests intermittently, lose updates despite atomics, or need reproducible interleaving tests; applies to Loom or Shuttle instrumentation, sequential-model oracles, replay, and bounded schedule exploration.
In this repository66 other files it gives its agents.
- AGENTS.mdAGENTS.md
- postgres-locking-joinsSkill
- ai-bug-patternsSkill
- compressed-ndjson-boundariesSkill
- http-resume-integritySkill
- linux-io-latency-triageSkill
- macos-disk-space-recoverySkill
- minimal-sufficient-evidenceSkill
- modularize-large-filesSkill
- patch-reproducer-validitySkill
- prompt-cache-boundariesSkill
- proton-drive-selective-backupSkill
- transactional-outbox-deliverySkill
- conventional-commitsSkill
- git-advanced-mergingSkill
- git-bisect-forensicsSkill
- git-data-recoverySkill
- git-hooksSkill
- git-rerereSkill
- git-reset-mechanicsSkill
- git-revisions-syntaxSkill
- git-rewriting-historySkill
- git-submodulesSkill
- git-worktreesSkill
- github-ssh-keysSkill
- npm-publish-ci-pitfallsSkill
- sapling-stacked-pr-workflowSkill
- go-concurrency-patternsSkill
- go-data-idiomsSkill
- go-error-handlingSkill
- go-interfaces-embeddingSkill
- go-pprof-profilingSkill
- marketing-funnel-diagnosisSkill
- marketing-geo-experimentsSkill
- marketing-incrementalitySkill
- marketing-positioning-testsSkill
- python-descriptors-mroSkill
- python-logging-cookbookSkill
- python-scaling-regression-testsSkill
- python-unicode-gotchasSkill
- rust-compile-time-invariantsSkill
- rust-error-identity-boundariesSkill
- rust-regex-search-contractsSkill
- rust-runtime-bug-classesSkill
- rust-tokio-actor-deliverySkill
- rust-tokio-cancellation-safetySkill
- sales-discovery-qualificationSkill
- sales-mutual-action-plansSkill
- sales-pipeline-forecast-calibrationSkill
- sales-value-negotiationSkill
- ai-triage-evaluationSkill
- container-image-patchingSkill
- dependency-artifact-integritySkill
- dnssec-sentinel-diagnosticsSkill
- iam-policy-change-replaySkill
- rbvm-applicabilitySkill
- rbvm-asset-evidenceSkill
- rbvm-guarded-remediationSkill
- rbvm-priority-decisionsSkill
- rbvm-risk-exceptionsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Treat the schedule as test input.
- Distinctive: line 17
Use maintained tooling rather than copying an educational scheduler.
- Distinctive: line 22
Start with two actors and few operations.
- Very specific: line 32
Run the ordinary build separately to catch conditional-import drift.
- Distinctive: line 41
Do not replace the implementation with a simplified test-only algorithm.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Rust Deterministic Concurrency Tests
Treat the schedule as test input. Even sequentially consistent loads and stores do not make a compound read-modify-write atomic. More threads and sleeps increase opportunities for failure without making the failing execution reproducible.
Choose a scheduler
| Tool | Good fit | Boundary |
| Loom 0.7 | Small synchronization algorithms; explore interleavings and modeled memory behaviors | State-space growth and configured bounds limit coverage |
| Shuttle 0.9 | Larger scenarios with randomized/PCT exploration and deterministic replay | Passing sampled schedules does not establish correctness |
Use maintained tooling rather than copying an educational scheduler. Keep production logic shared with the instrumented build.
Build a meaningful model
- Route synchronization and thread creation through a small conditional-import module. Replace the primitives used by the implementation itself, not only the test. Reset state inside every scheduler invocation.
- Start with two actors and few operations. For a counter, compare completed increments with the final value. For queues/maps, specify permitted histories and ordering; final-state equality alone does not prove linearizability.
- Control other nondeterminism. Mock I/O, clocks, and system calls; use scheduler-supported randomness or fixed inputs. Uncontrolled randomness prevents reliable replay.
- Capture the failing input and schedule before shrinking. Reduce actors/operations while retaining the same invariant violation, then keep the small regression case.
For a project wired with Loom's documented cfg(loom) dependency/import scheme and an integration test named loom_counter:
RUSTFLAGS="${RUSTFLAGS:+$RUSTFLAGS }--cfg loom" cargo test --release --test loom_counterRun the ordinary build separately to catch conditional-import drift. For Shuttle failures, preserve the emitted schedule string and replay it with shuttle::replay; record the tool version alongside it.
Sources: matklad, 2024-07-05, Loom 0.7.2, Shuttle 0.9.5.
Pitfalls
- Any uninstrumented synchronization can hide behaviors from the scheduler.
- A bounded or randomized pass covers the explored model, not every production execution or memory-model behavior.
- Spin loops can exhaust exploration without progress; use the tool's modeled yield where its documented fairness requirements apply.
- Do not replace the implementation with a simplified test-only algorithm; that proves the substitute, not the shipped code.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

