cargo-anneal
Use when running cargo-anneal setup or verify, preparing a request or starter proof, diagnosing verification exits, or interpreting a Receipt v3 file. Not for authoring or auditing specs at length (use spec-authoring), scaling Lean proofs past OOM or Tabu cliffs (use proof-scaling), or editing Anneal itself.
Verify Rust code with Anneal
Anneal verifies a subset of Rust. Support depends on the installed version,
target triple, compilation flags, and scope. Check cargo anneal --version and
run the intended request to verify what that build accepts.
On Linux, ExecSeal sandboxes target Lean preflight, elaboration, and audit
by default (linux_bwrap or linux_landlock_seccomp, recorded in
elaboration_sandbox), whereas Rust compilation (rustc) runs as the caller.
Run the verifier in an isolated environment for untrusted Rust inputs or build
scripts, on non-Linux hosts, or when passing --allow-unsandboxed-elaboration.
Companion skills
cargo-anneal bundles three companion skills; run cargo anneal skill list to
list every bundled topic.
- Authoring, translating, or auditing specifications (
Spec.lean/Spec.*, vacuity, anti-echo, Intent Decisions): usespec-authoring(cargo anneal skill spec-authoring). - Scaling proofs past bounded
execProg, reducing Lean RSS/timeouts, or escaping verification cliffs: useproof-scaling(cargo anneal skill proof-scaling). - Pre-ship boundary audit:
boundary-audit(cargo anneal skill boundary-audit).
Run the project's verification
Identify the Rust function or crate scope, intended property, and caller
preconditions. If setup is needed, run cargo anneal setup (reuses an existing
cached toolchain for that version) or cargo anneal setup --local-archive <path>
to install a local archive. Pass --clear-old (or redirect stdin from
/dev/null) in non-interactive shells so cleanup prompts cannot block. Use the
same user and XDG_CACHE_HOME across setup and verify. Builds compiled with
--no-default-features omit setup and require --capture, --sysroot, and
--lean.
To reuse compiled .olean files across crates and invocations (for example,
in a hermetic build system or CI), point verify at one shared cache with
--olean-cache-dir <DIR> or ANNEAL_OLEAN_CACHE_DIR=<DIR>. The flag overrides
the variable, an empty variable counts as unset, and either one replaces the
per-user default under XDG_CACHE_HOME (or HOME). Entries are keyed by
content (<DIR>/v2/<merkle_key>/) and published atomically, so concurrent runs
can share a directory. A cache hit is trusted on the strength of the entry's
own recorded digests, which detect corruption but not a malicious writer, so
everything that can write <DIR> must be trusted as much as the runs that read
it: keep it outside any checkout (verify refuses a root inside or containing
the working directory or any input directory: manifest, proof, request, or
rustc source directories, but accepts a root under the per-user cache base
(XDG_CACHE_HOME, ~/.cache, or ~/Library/Caches), as for the default,
when run from a directory such as HOME that strictly contains it), and give
runs on untrusted Rust inputs or with --allow-unsandboxed-elaboration their
own directory. --olean-cache-dir cannot be combined with --no-cache, and
--receipt-out must not point inside the cache directory in use.
When the prebuilt .olean bundle is not beside the Lean toolchain (for
example, in Nix or Bazel layouts, or with a cargo-anneal built separately
from its Lean tree), name it with --prebuilt-dir <DIR>, the directory holding
the bundle's manifest.json. It replaces the installed bundle's and the
--lean prefix's share/anneal/prebuilt, and works with explicit --lean and
--no-default-features builds. There is no environment variable. Like a shared
cache, the bundle is trusted as stored: verify refuses a directory inside or
containing the working directory or any input directory, a missing directory or
manifest, a symlinked directory, or a manifest for another cache format, and
fails rather than recompiling a module the bundle lists with different inputs.
Modules the bundle does not list still use the disk cache or compile.
--prebuilt-dir cannot be combined with --no-cache, and --receipt-out must
not point inside it.
Run verification (defaults to --format human on stdout), atomically write a
Receipt Schema v3 JSON file via --receipt-out (or pass --format json to
stream JSON on stdout), and treat the process exit code (0 verified, 1
verification failure, 2 operational/argument error, 3 --fast-check
elaboration passed without kernel replay) as authoritative alongside the
receipt file (--receipt-out clears any pre-existing non-input
regular file once inputs are validated so interrupted or failed runs cannot
leave a stale pass behind, while early argument/alias rejections exit 2
without touching the destination):
cargo anneal verify --request path/to/request.json --receipt-out path/to/receipt.json
Output and diagnostic flags:
--format human|json|auto: defaults tohuman, rendering a five-tier verdict card ([OK]only for untainted, warning-free whole-crate runs;[SCOPED]forselected_unit;[WARN]whenspec_warningsare present;[TAINTED]under--allow-*;[FAIL]on failure). Pass--format jsonwhen piping Receipt v3 JSON on stdout, or--receipt-out <path>to persist JSON atomically alongside human output.--color auto|always|never,-q/--quiet, and-v/--verbose: control ANSI styling (autofollows streamisatty,CARGO_TERM_COLOR,NO_COLOR, andTERM=dumb), quiet summaries (never hiding taint or warning caveats), and untruncated diagnostics/line progress.--timing-sidecar-out <path>: atomically writes per-phase timing, cache-hit, and subprocess-count JSON strictly outside Receipt Schema v3 (cleared once verification inputs pass aliasing checks; written on completed verifications and post-preflight verification failures unless artifact retention or output writing fails or is suppressed; conflicts with--fast-checkand--batch).
Other entrypoints:
- Cargo packages:
cargo anneal verify --manifest-path path/to/Cargo.toml --proof-dir path/to/proofs [--exclude-trait <trait> ...] [--no-default-features] [--features <list>] [--all-features] - Build systems with explicit inputs:
cargo anneal verify rustc <crate_root> --crate-name <name> [--exclude-trait <trait> ...] [--env KEY=VALUE ...] --spec-file <Mod>=<path> --proof-file <Mod>=<path> ... - Multi-unit batch runs:
cargo anneal verify --batch path/to/manifest.json(with optional--batch-jobs <k>) verifies multiple request units in one process (amortizing read-only toolchain caches while keeping per-unit staging,Checker, and Receipt v3 isolation). The manifest ({"schema_version": 1, "units": [...]}) lists each unit'sid,request, and optionalreceipt_out,timing_sidecar_out, andartifacts; relative unit paths resolve against the canonicalized manifest directory. Pre-stage validation fails closed (exit2, leaving existing files untouched) on invalid unit outputs, non-UTF-8 or omittedartifactsunder--overwrite-artifactsor--export-lean-lib, duplicate IDs, control characters, any cross-unit output, input, artifact, or manifest aliasing, or--olean-cache-dir/--prebuilt-diroverlap with the manifest or any unit's inputs; each unit clears its own pre-existingreceipt_outandtiming_sidecar_outonce all of its verification inputs pass aliasing checks. Batch exit codes aggregate unit outcomes (0if all pass,2if any operational/tool error occurs, else1if any verification fails).
Create a request and starter proof
Run cargo anneal init inside a Cargo package to scaffold proof/Spec.lean
and proof/Proof.lean (note: package-mode init intentionally emits exact ?_
placeholders in Proof.lean that you must prove before verify exits 0; use
cargo anneal init --standalone for a complete, immediately passing 4-file
zero() example, or cargo anneal skill --example to print it). Pass
--profile v2 (default v1; not with --standalone) for a SpecsV2
starter when capture emits MIR Profile v2. Save standalone
files in a temporary directory to test your environment; it proves termination
and a zero return for a safe no-argument function in the captured MIR model.
- For request schema
1, setscopeto{"kind": "selected_unit", "roots": ["mod::fn"]}(UnitTheorem) or{"kind": "crate"}(CrateTheorem). Crate scope also accepts an optional"excluded_traits"list (or repeatable--exclude-trait) from the closed allowlistcore::fmt::Debug,core::fmt::Display, andcore::error::Error; capture excludes local impls of those traits only after proving they are unreachable from every verified body (items containingunsafecode or inline assembly stay required), and Receipt v3 discloses the excluded census items inexcluded_itemsand appends an explicit unverified/unreachable note toassumptions. If capture emits MIR Profile v2 (capture.json,program.mir_profile_version = 2, e.g. for references, raw pointers, or slices), the roots areUnitTheoremV2/CrateTheoremV2overTrusted.CrateV2, sospecificationmust name aTrusted.MirSemantics.SpecsV2. Setedition,target,cfg, optionalenv(KEY -> VALUEmap forenv!/option_env!), andsource_files(includingcrate_root) inside clean relative paths undersource_root. Only when verifyinglibrary/coreitself, set"stdlib_crate": "core"(verify rustc --stdlib-crate core) with--allow-stdlib-crate(taints receipt),crate_namecore, selected roots, and every stagedlibrary/filecorereads; this admitscore's own language items, and the receipt'sconfigurationrecords it. - Write the contract in
specificationmodules (defaultsSpec.specs,Specs.safety,Specs.property) and proofs inproofmodules (Proof.verify). Forunsafefunctions, express real caller preconditions inSpecs.safety;Falsevacuously admits zero callers. Keepscope,cfg, and specs fixed during proof debugging, and followspec-authoringbefore any spec change. - Author Lean targets in
modulemode (matchingcargo anneal skill --example, or omitmodulefor legacy non-modulefiles): startSpecwithmodule,prelude,public import Trusted.MirSemantics, and@[expose] public section ... end, and startProofwithmodule,prelude,public import Expected, non-publicimport Anneal.*, andpublic theorem Proof.verify : Expected.claim. Proof modules (neverspecificationmodules) may import bundled 3-axiomAnneal.*libraries shipped withcargo anneal(Anneal.MirWp,Anneal.LoopInv,Anneal.BitVec,Anneal.LinearArith,Anneal.BitTrieLrat; category guide incargo anneal skill proof-scaling, authoritative list inbundle-manifest.jsonunder the installedshare/anneal/theory/dir), compiled and audited on demand when imported. - Keep Lean imports tight: import
preludeplus only targetedInit.*modules (~4imports,~152 MiBpeak RSS). Monolithicimport Init(~473 MiB) fails closed in pinnedverifyunless--allow-unpinned-leanis passed. Pass--lean-memory-mb <MB>(or run inside a host cgroup memory cap such assystemd-run --user --scope -p MemoryMax=...), and pass--max-inspector-output-bytes <BYTES>(up to1 GiB) if a whole-crate inspectorresult.jsonexceeds the default64 MiBcap. If a Lean child exceeds its wall-clock limit (600seconds by default), raise it with--child-timeout-secs <SECS>(up to86400).
When adapting the example, pass --artifacts <new-dir>. Inspect selected and
program in capture/capture.json plus the goal in generated/Expected.lean.
Retention never writes into an existing path; to rerun into the same path, add
--overwrite-artifacts, which replaces only an empty directory or one carrying
the .cargo-anneal-artifacts marker that verify writes (never a symlink, a
directory containing the working directory or a verification input, or one
with unexpected entries) and first drops any earlier result.json and
lean-lib/.
Move to proof-scaling as soon as direct execProg / simp stalls.
Scale crate proofs with Tarjan SCC sharding
When captured MIR exceeds --shard-min-bodies (default 20), cargo anneal
automatically shards Captured along strongly connected components in
callee-first topological order (Captured.Shard_000 .. Captured.Shard_<K-1>)
and emits generated/Proof/IdTree.lean (Proof.IdTree.idDecisionTree) plus
capture/capture_shards.json. Sharding is transparent for Proof unless
Proof/Shard_<k>.lean is authored for incremental per-shard .olean caching:
- Tune thresholds with
--shard-min-bodies <N>(default20),--shard-max-bodies <N>(default20,>= 1), and--shard-max-ast-nodes <NODES>(default2500,>= 1). - Reserved top-level namespaces (
Captured.*,Expected.*,Trusted.*,Anneal.*,Init,Std,Lean,Lake,TrustedBoundary) cannot be shadowed by authored files (which covers generatedCaptured.Shard_*). When sharding is active,cargo annealgeneratesgenerated/Proof/IdTree.lean(Proof.IdTree), and authors may provideProof/Shard_<k>.leanmodules to organize and cache per-shard proofs. Existing>20-body proofs referencingCaptured.body_Nor positional indices must switch toBody.identitykeys or per-shard imports (or pass--shard-min-bodiesto adjust the threshold). - Generate or verify a static-DAG topology plan (
anneal-shards.json) withcargo anneal shard-plan(--requestor--manifest-path, plus--writeor--check), and gatecargo anneal verifyon a checked-in plan using--verify-shard-plan <PATH>:
cargo anneal shard-plan --manifest-path Cargo.toml --write anneal-shards.json
cargo anneal verify --manifest-path Cargo.toml --proof-dir proof --verify-shard-plan anneal-shards.json
Edits that preserve shard identities, callee_shards, has_cycle,
oversized_scc, and shard packing bounds keep anneal-shards.json unchanged,
whereas structural SCC or cross-shard edge changes or AST/body shard
re-packing fail closed with regeneration instructions. Sharded captures reorder
program.bodies into canonical callee-first Tarjan SCC order with
entryDefId := 0 selecting canonical body 0, so specs in sharded crates
should identify target bodies by Body.identity rather than entryDefId or
positional body indices. When sharding is active, Receipt v3 adds
capture_shards_sha256 and shards (total_sccs, cyclic_sccs,
total_shards, id_tree_sha256, and per-shard metadata).
Diagnose failures and read Receipt v3 honestly
Inspect status, phase, detail, and any actionable hint together; check
stderr if stdout is empty.
unsupported: Fix invalid request/selector/path errors, or report exactly which target or Rust construct this version refused.compiler_failed: Fix the reported Rust diagnostics first.tool_failed: Diagnose the named setup, capture, sandbox, or artifact phase.proof_failed: Step 0 — Day-2 Rust bug triage before proof hacking. First check whether the receipt carries a structured"reason"("heartbeat_limit_exceeded"or"recursion_depth_exceeded"): aproof_failedcarrying"reason"is a deterministic Lean resource limit in an authoredProofmodule, not a proof or specification rejection, and must never be credited as a mutant kill. Otherwise, comparegenerated/Expected.leanandcapture/Captured.lean(orcapture/Captured/Shard_*.leanwhen sharded) against the Rust implementation to check whether the Rust code actually violates its specification (missing bounds/overflow guard, off-by-one, or unintended panic path). Never silently weakenSpecs.safetyorSpecs.propertyto make a proof pass; escalate any implementation-vs-intent mismatch to the user.
For diagnostics, rerun with --artifacts <dir> (add --export-lean-lib to
copy Door-1-verified .olean files to <dir>/lean-lib/, omitting proof
.oleans on proof_failed exit 1 and exporting nothing on tool_failed exit
2). Receipt Schema v3 ("schema_version": 3) enforces a Uniform Flag-Driven
Taint Law across --allow-unpinned-lean (records unpinned_lean),
이 스킬의 파일
이 스킬에는 보조 파일이 없습니다.