threading-not-external-body

threading-not-external-body is a cursor rule for Cursor from briangmilnes/APAS-VERUS. It costs 519 tokens per session, scanned A, original, MIT.

A Verus rule for verifying parallel Rust algorithms, which use multiple threads at once. It separates the algorithm's provable structure from the small boundary where threads are created.

In plain words
What is it for?
Use it when verifying algorithms that split work across threads, combine results, maintain invariants, or use thread spawning and joining.
Why use it?
It prevents developers from hiding an entire threaded algorithm from verification just because thread creation itself cannot be checked.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when verifying algorithms that split work across threads, combine results, maintain invariants, or use thread spawning and joining.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/briangmilnes/apas-verus/threading-not-external-body
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/briangmilnes/APAS-VERUS

Made for: Cursor.

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 threading-not-external-body

README.md
[![agentmods](https://agentmods.dev/badge/rules/briangmilnes/apas-verus/threading-not-external-body/github.svg)](https://agentmods.dev/rules/briangmilnes/apas-verus/threading-not-external-body)
Your own site
<a href="https://agentmods.dev/rules/briangmilnes/apas-verus/threading-not-external-body"><img src="https://agentmods.dev/badge/rules/briangmilnes/apas-verus/threading-not-external-body/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 threading-not-external-body

Your own site · 80×15
<a href="https://agentmods.dev/rules/briangmilnes/apas-verus/threading-not-external-body"><img src="https://agentmods.dev/badge/rules/briangmilnes/apas-verus/threading-not-external-body.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 519 This file is loaded in full into every session.
When invoked 519 The same file — it is already loaded in full.
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.00519 $0.00519
Opus 5 $0.00260 $0.00260
Sonnet 5 $0.00104 $0.00104
Haiku 4.5 $0.00052 $0.00052

Measured 5d ago against content hash 6c099ae7bd83, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

threading-not-external-body 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 5d ago.

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.

.cursor/rules/verus/threading-not-external-body.mdc · 53 lines

How it starts

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

Threading Is Not an Excuse for external_body

Do NOT slap #[verifier::external_body] on a function just because it uses threads.

The Pattern

A parallel algorithm has two parts:

  1. Structural logic — splitting, combining, maintaining invariants. This is verifiable.
  2. Thread spawning — the actual spawn, join, Arc, ParaPair! calls. This is not verifiable in Verus.

Wrap only the thread-spawning boundary in external_body, not the whole algorithm. The structural logic (preconditions, postconditions, loop invariants, combination proofs) should be verified.

The Only Acceptable Hole

The only proof hole a threaded algorithm should have at the spawn boundary is:

#[verifier::external_body]
fn parallel_wrapper(args: ...) -> (result: ...)
    requires ...
    ensures ...
{
    // exec code that spawns threads and calls verified inner functions
}

The only acceptable proof hole for threading is at the thread-divergence boundary — where a spawned thread might not return. Use:

{ assume(false); diverge(); }

The assume(false) introduces the contradiction; diverge() satisfies Verus's return-type obligation so the function body type-checks. This is strictly for modeling thread divergence (a thread that never joins), not a general-purpose escape hatch.

Do NOT

  • Do NOT mark an entire recursive algorithm external_body because one level uses ParaPair!.
  • Do NOT use external_body to avoid writing loop invariants or combination proofs.
  • Do NOT treat "parallel" as synonymous with "unverifiable."

Do

  • Use HFSchedulerMtEph (help-first scheduler, Chap02) as the default threading primitive. Its join function handles fork-join parallelism directly inside verus! with named closures (see fork-join-inside-verus rule). Reach for ParaPair! or raw thread::spawn only when the scheduler doesn't fit.
  • Extract f64 arithmetic into small external_body helpers with tight ensures.
  • Keep the structural proof (splitting, combining, invariants) inside verus!.
  • Audit every external_body — ask: "Is this truly unverifiable, or am I being lazy?"

Read the full file on GitHub · 53 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. 5d ago First seen · 53 lines · 519 tokens per session scan A 6c099ae7bd83

Subscribe to this mod's changes

threading-not-external-body is a cursor rule published in the GitHub repository briangmilnes/APAS-VERUS (10 stars, last pushed 1mo ago), licensed MIT. It adds 519 tokens to every session, about $0.0026 per session on Opus 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-09-03.