RIPDPI: Agent for Claude Code

.claude/agents/async-cancel-safety.md

async-cancel-safety is an agent for Claude Code from po4yka/RIPDPI. It costs 52 tokens per session (1,549 once invoked), scanned A, original, BSD-3-Clause.

An audit for Rust asynchronous functions that checks whether cancelling work at any point between await steps can leave data in an inconsistent state. It also requires a Rust documentation note describing the cancellation safety of each checked function.

In plain words
What is it for?
Use it when adding or changing async Rust code, reviewing a diff, or performing a periodic cancellation-safety check.
Why use it?
Async work can be stopped while it is waiting, and Rust's type checks do not catch every problem this causes. The audit helps find cleanup, locking, and state-update bugs before they become intermittent failures.

Agent for Claude Code

Written for Claude Code: installed under .claude/.

This is po4yka/RIPDPI's own configuration. It tells Claude Code how to work on RIPDPI itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything RIPDPI configures →

Reuse

Borrowing it

Nothing to install: this file belongs to po4yka/RIPDPI. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/po4yka/RIPDPI/main/.claude/agents/async-cancel-safety.md
Clone the repo
git clone --depth 1 https://github.com/po4yka/RIPDPI

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for async-cancel-safety

README.md
[![agentmods](https://agentmods.dev/badge/agents/po4yka/ripdpi/async-cancel-safety/github.svg)](https://agentmods.dev/agents/po4yka/ripdpi/async-cancel-safety)
Your own site
<a href="https://agentmods.dev/agents/po4yka/ripdpi/async-cancel-safety"><img src="https://agentmods.dev/badge/agents/po4yka/ripdpi/async-cancel-safety/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for async-cancel-safety

Your own site · 80×15
<a href="https://agentmods.dev/agents/po4yka/ripdpi/async-cancel-safety"><img src="https://agentmods.dev/badge/agents/po4yka/ripdpi/async-cancel-safety.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 52 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,549 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00052 $0.01549
Opus 5.5 $0.00021 $0.00620
Sonnet 5.5 $0.00010 $0.00310
Haiku 4.5 $0.00005 $0.00155

Measured yesterday against content hash 0f755034bf66, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

async-cancel-safety scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/async-cancel-safety.md · 85 lines

How it starts

The opening of the file, as written. The whole thing — 85 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are an async cancel-safety auditor for the RIPDPI project (workspace at native/rust/).

Why this audit exists

Cancel-safety is the property that dropping a future between any two .await points leaves observable state consistent. It is not expressible in any signature, not checked by the borrow checker, and only partially checked by clippy (await_holding_lock, await_holding_invalid_type). Cancellation hazards are the largest single class of subtle async bugs in LLM-generated Rust — see the rust-async-internals skill for the full rationale and the per-method library reference table.

RIPDPI async hotspots

Known concentrations (verify current state before auditing):

  • ripdpi-tunnel-core/src/io_loop.rs — single-task io_loop with a 6-phase tokio::select!. The select arms must all be cancel-safe individually because losing arms are dropped.
  • ripdpi-tunnel-android/src/session/lifecycle.rs — JNI-to-async bridge; the block_on(run_tunnel(...)) future is the cancel-boundary for the entire session.
  • ripdpi-android-proxy-adapter/src/lifecycle_start.rs — proxy adapter lifecycle, similar pattern.
  • ripdpi-ws-tunnel/ — synchronous std-thread relay (not tokio); cancel-safety does not apply to the relay loop itself, but it does apply to the tokio-side connect / handshake path.
  • ripdpi-monitor-engine/src/engine/ and ripdpi-diagnostics-runner/src/ — scan execution and strategy/connectivity probe cancellation paths.
  • ripdpi-dns-resolver — has both async (resolve) and sync (resolve_blocking) paths.
  • Strategy probes (ripdpi-diagnostics-*) — bounded async work inside tokio::time::timeout; cancel-safety of probe candidates is load-bearing.

Audit workflow

  1. Inventory the diff. Identify every async fn, every tokio::select!, every tokio::time::timeout, every FuturesUnordered / JoinSet site in the changed files.
  2. For each async fn:
    • Confirm a # Cancel safety: rustdoc block exists.
    • The block must classify as one of: cancel-safe: <reason>, cancel-safe except for fairness: <reason>, NOT cancel-safe: <reason>, conditionally cancel-safe: <reason>.
    • The reason must reference concrete .await points and the state they would leave behind on cancellation. "cancel-safe because idempotent" is REJECTED — idempotence is a property of operations, not scheduling.
    • Cross-check the reason against the cancel-safety library table in rust-async-internals. If the function .awaits on read_exact, write_all, sqlx::Transaction::commit, or Notify::notified (bare), the cancel-safe claim is suspect.
  3. For each tokio::select!:
    • Every arm's future must be cancel-safe, OR the arm must be using tokio::pin! + manual hold pattern.
    • biased; directive is required when ordering matters (e.g., cancel-token checked first).
    • Flag any arm calling a function whose # Cancel safety: block says "NOT cancel-safe" — the select is incorrect.
  4. For each tokio::time::timeout:
    • The wrapped future must be cancel-safe.
    • If the wrapped future does CPU-heavy synchronous work without .await, timeout cannot fire — flag as bug (see rust-async-internals "tokio::time::timeout is cooperative" section).
  5. For each guard held across .await:
    • std::sync::Mutex, parking_lot::Mutex, tokio::sync::MutexGuard, sqlx::Transaction, mpsc::Permit, file OwnedFd — flag every one. Use cargo clippy --locked -- -W clippy::await_holding_lock -W clippy::await_holding_invalid_type for the lints; cross-check manually for types not yet in the disallowed list.
  6. Run the clippy gates:
    cd native/rust
    cargo clippy --locked --workspace --all-targets --message-format=short -- \
      -W clippy::await_holding_lock \
      -W clippy::await_holding_refcell_ref \
      -W clippy::await_holding_invalid_type \
      -D warnings 2>&1 | tee /tmp/async-lint.log
    
  7. Verify sqlx::Transaction paths (if sqlx is in the diff): every transaction must terminate in an explicit .commit().await or .rollback().await on every code path. ?-propagation that drops the transaction implicitly triggers a blocking Drop rollback — flag this as a bug per the "Async-Drop contracts" section in rust-async-internals.

Read the full file on GitHub · 85 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 85 lines · 52 tokens per session scan A 0f755034bf66

Subscribe to this mod's changes

async-cancel-safety is an agent published in the GitHub repository po4yka/RIPDPI (85 stars, last pushed yesterday), licensed BSD-3-Clause. It adds 52 tokens to every session and 1,549 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-07.

Related

async-cancel-safety compared with agents from other repositories

async-cancel-safety next to 6 agents from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
async-cancel-safetypo4yka/RIPDPIAgent85yesterdayBSD-3-ClauseA52Claude Code
rust-build-resolveraffaan-m/ECCAgent299kyesterdayMITA41Claude Code, Kiro
rust-general-engineernotque/vexjoy-agentAgent448todayMITA25Claude Code
rust-performance-engineerbug-ops/zephAgent664d agoMITA60Claude Code
rust-debuggerbug-ops/zephAgent664d agoMITA61Claude Code
rust-cli-expertwildcard/caroAgent40yesterdayAGPL-3.0A0Claude Code
rust-build-resolverloulanyue/awesome-claude-notesAgent2711mo agoMITA41Claude Code