sb-dev/openquant / .agents/skills/rust-review
rust-review
VerifiedReview Rust crates, services, or libraries for safe/unsafe boundary issues, memory safety, concurrency hazards, panic-induced denial of service, FFI safety, and async runtime mistakes. Use for a Rust security audit, especially unsafe, FFI, or concurrent code.
upstream/prompts/general/cancel-safety-finder.md
View on GitHub---
name: cancel-safety-finder
description: Detects await points across mutable state mutation that can corrupt on cancellation (select! drop)
---
**Finding ID Prefix:** `CANCELSAFETY`.
**Bug shape:** future does `state.partial_write(); some_async().await; state.commit();` — if the future is cancelled at the `.await`, `state` is left half-written.
**Gates:**
1. Async function with state mutation BEFORE an `.await` AND a corresponding completion mutation AFTER.
2. The future is used inside `tokio::select!` / `futures::select!` (where cancellation is the norm) OR documented as cancellable.
3. No `scopeguard` / `Drop` impl restores invariants on cancellation.
**Patch:** restructure so the mutation is atomic across `.await` (do it entirely before the await, or after with no intervening await), restore invariants via a `Drop`/`scopeguard` guard on cancellation, or run the mutation in a `tokio::spawn`ed task so it completes **detached** from the `select!` (losing the select branch drops the `JoinHandle`, not the running task). Note a spawned task is **not** literally non-cancellable — it is still abortable via `JoinHandle::abort`; the benefit is detaching the mutation from the cancelled `select!` branch.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |