arc-deref-pattern

arc-deref-pattern is a cursor rule for Cursor from briangmilnes/APAS-VERUS. It costs 793 tokens per session, scanned A, original, MIT.

A Verus and Rust pattern for keeping the proof logic in a helper function while using Arc to pass a function into parallel code.

In plain words
What is it for?
It helps verify parallel algorithms whose callbacks are stored in Arc while retaining their specifications.
Why use it?
It addresses verification difficulties caused by concurrent closures and shared function references.

Cursor rule for Cursor

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.

agentmods
npx agentmods add rules/briangmilnes/apas-verus/arc-deref-pattern
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 arc-deref-pattern

README.md
[![agentmods](https://agentmods.dev/badge/rules/briangmilnes/apas-verus/arc-deref-pattern.svg)](https://agentmods.dev/rules/briangmilnes/apas-verus/arc-deref-pattern)
Your own site
<a href="https://agentmods.dev/rules/briangmilnes/apas-verus/arc-deref-pattern"><img src="https://agentmods.dev/badge/rules/briangmilnes/apas-verus/arc-deref-pattern.svg" alt="Measured on agentmods" height="20"></a>
Per session 793 This file is loaded in full into every session.
When invoked 793 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
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 $0.00793 $0.00793
Opus 5 $0.00396 $0.00396
Sonnet 5 $0.00159 $0.00159
Haiku 4.5 $0.00079 $0.00079

Measured yesterday against content hash 1c4d27117e85, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

arc-deref-pattern 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.

.cursor/rules/verus/arc-deref-pattern.mdc · 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.

Anti-Pattern: "Closures Can't Capture Data with Specs"

The Wrong Assumption

When implementing parallel (Mt) algorithms in Verus, do NOT assume:

  • "Closures can't capture ArraySeqMtEphS<T> with specs"
  • "Arc prevents verification because Verus can't deref it"
  • "Send + 'static closures can't reference ghost variables like spec_f"
  • "The only way to verify this is to make it sequential"

These are FALSE. The pattern below solves all of them.

The Pattern: Factor Verification Away from Concurrency

Problem

join closures need Send + 'static. The verified algorithm needs f: &F (for direct Fn trait spec access). Arc<F> is opaque to Verus — you can't deref it with spec guarantees.

Solution

  1. Factor the verified algorithm into a helper that takes f: &F:

    fn reduce_contract_verified<T, F>(a: &ArraySeqMtEphS<T>, f: &F, ...) -> (result: T)
        requires f.requires(...), ...
        ensures result == ...
        decreases a.spec_len(),
    { /* Full proof here — identical to StEph version */ }
    
  2. The trait impl delegates through Arc deref:

    fn reduce_contract_parallel(a, f: Arc<F>, ...) -> (result: T) {
        reduce_contract_verified(a, &*f, Ghost(spec_f), id)
    }
    
  3. Small external_body helpers for Arc-specific operations:

    #[verifier::external_body]
    pub fn call_f<T, F>(f: &Arc<F>, a: &T, b: &T) -> (result: T)
        requires f.requires((a, b)),
        ensures f.ensures((a, b), result),
    { (**f)(a, b) }
    
  4. Parallel primitives as external_body with strong specs:

    #[verifier::external_body]
    pub fn contract_parallel<T, F>(a, f: &Arc<F>, Ghost(spec_f), half) -> (b: ArraySeqMtEphS<T>)
        ensures b.spec_index(j) == spec_f(a.spec_index(2*j), a.spec_index(2*j+1)),
    { /* Uses join internally */ }
    

Trust Boundaries

Helper Trust Obviousness
call_f Arc deref preserves function Trivially correct
contract_parallel Parallel loop computes pairs Auditable in 10 lines

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 · 793 tokens per session scan A 1c4d27117e85

Subscribe to this mod's changes

arc-deref-pattern is a cursor rule published in the GitHub repository briangmilnes/APAS-VERUS (10 stars, last pushed 1mo ago), licensed MIT. It adds 793 tokens to every session, about $0.0040 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.