Unsafe Rust Authoring and Audit
Treat each safety contract as an English-language theorem and each safety
comment as its proof. Reject hand-waving, folklore, hidden assumptions, and
proof by testing.
Establish the Exact Claim
Unless the user specifies a narrower claim, establish:
For the exact audited source snapshot, every supported compilation
configuration, every valid in-scope use in a context satisfying all
out-of-scope safety obligations preserves freedom from Rust undefined behavior
under the documented Rust abstract semantics, and every mandatory in-scope
documented postcondition holds, assuming only the explicitly recorded trusted
computing base (TCB).
Interpret valid use as follows:
- For a safe API, quantify over every well-typed safe use. Impose no hidden
safety precondition.
- For an unsafe API, quantify over every use satisfying all documented initial,
ongoing, and terminal safety obligations.
- For a binary or other entrypoint, quantify over executions satisfying the
explicitly recorded deployment assumptions. Do not transfer those
assumptions silently to a safe library API.
Prove every documented postcondition of each unsafe API in scope and every
documented guarantee consumed by an in-scope soundness proof. Include broader
safe-API robustness only when the user or audit scope requests it.
Prove source-level Rust soundness first. State claims about a particular
compiler backend, binary, platform, security property, probability, or
deployment separately with their additional premises.
Recover the Required Domain
Before proving the claim body or issuing a full verdict, derive the exact
domain quantified by the claim. Let a case retain every relevant dimension of
one valid use or execution: artifact, toolchain, configuration, input, state,
time, and any other dimension on which an obligation or premise can vary. Let
Required(case) denote the cases the claim requires and Covered(case) hold
exactly where every obligation the claim requires for that case has a complete
derivation from applicable premises. A local argument may project onto fewer
dimensions only when it proves the lemma for every required case in each
omitted-dimension fiber—parametrically or by proving those dimensions
irrelevant—and must restore the full case before claim-level closure.
Within one obligation, valid case lemmas may be unioned. Across distinct
obligations, claim-level coverage is their pointwise conjunction—not a union of
regions in which different obligations happened to be proved.
- Preserve the controlling domain expressions symbolically, including ranges,
unions, exclusions, quantifiers, and conditional or moving policies. Record
their exact sources and audit cutoff.
- If applicable project sources conflict or materially underdetermine support,
obtain an authorized resolution, derive an explicit conservative audit
domain containing every materially supported candidate predicate, or leave
the affected combined claim
UNPROVED. Do not call a conservative audit
domain the resolved project promise.
- Treat every asserted set relationship, normalization, enumeration,
partition, exclusion, and policy merge as a proof step. Prove the definition
of the exact relation asserted. For example,
A = B needs A ⊆ B and
B ⊆ A; A ⊊ B needs A ⊆ B and a witness w ∈ B \ A;
incomparability needs witnesses a ∈ A \ B and b ∈ B \ A, with each
membership and nonmembership proved. Equivalent symbolic derivations are
acceptable, but required witnesses must remain explicit. Prove the
required containment before using a conservative superset and
Required ⊆ Covered before concluding PROVED.
- A finite inventory requires evidence both that every listed member belongs
and that no required member is omitted. Endpoints, one representative per
apparent category, CI jobs, lockfiles, and other samples do not prove an
interval or set inventory.
- Prefer a parametric proof over the symbolic predicate when enumeration would
be large or its exact membership is unavailable. Otherwise report proved
regions and the unresolved remainder; do not turn it into an implicit
exclusion.
- An audit cutoff limits the temporal scope of a claim. It does not establish
semantic continuity, enumerate releases before the cutoff, or make sampled
documentation applicable between samples.
Apply
configuration recovery
to derive supported compilation cases and prove every transformation of that
predicate.
Use Only Applicable Premises
- Bottom out Rust-language and standard-library facts in exact applicable text
from versioned Rust Reference or standard-library documentation.
- Quote and link the smallest sufficient set of passages whose explicitly
stated propositions, together with justified inference steps, entail the
fact. Open each citation and verify its wording, qualifications, version, and
scope. A page, allowlist entry, broad label such as “cfg semantics,” or nearby
cited clause does not supply a material proposition the proof never states.
- Attach an applicability domain to every claim and premise, whether stated
locally or inherited from an identified project policy or canonical entry. A
derivation proves only the cases covered by all premises it consumes.
- Apply a guarantee documented for an older Rust release to a later stable
release only when an exact applicable Rust backwards-compatibility
commitment preserves that exact proposition throughout the later release's
relevant domain. An API's stability badge does not by itself preserve every
behavioral statement in its current documentation. Record a
non-authoritative compatibility premise explicitly in the TCB. Never infer
an earlier-version guarantee merely from later documentation.
- Do not promote this skill, the Rustonomicon, Unsafe Code Guidelines, RFCs,
blogs, issue discussions, implementation behavior, Miri, or common practice
to Rust axioms. Use them to discover risks and authoritative text, or record
the exact additional proposition as a TCB assumption.
- Trust a deliberately selected safe dependency API to behave as documented
only when that exact trust is explicit in the TCB. Do not extend this
exception to caller-controlled safe code, callbacks, values, or safe trait
implementations.
- Audit a third-party unsafe API through to admissible premises or record its
exact implementation and contract as an additional TCB assumption.
When no admissible direct or derived proof can be completed because
authoritative documentation is ambiguous or insufficient, identify the
smallest missing proposition. Do not repair it with intuition. Report a
documentation gap and suggest an upstream improvement when appropriate.
Close an Evidence-Bearing Proof Kernel
Before certifying any conclusion, expose a minimal, reviewable kernel of this
form:
artifact facts
+ applicable Rust/stdlib axioms, verified tool theorems,
or explicit TCB premises
+ earlier proved lemmas or invariants
+ explicit logic or mathematics
-> derived proposition
-> consumer, postcondition, or verdict
An artifact fact is only a literal property of the exact inspected source,
expansion, generated output, or other artifact: for example, that a declaration,
operator, type annotation, branch, tail expression, or attribute occurs at a
location. Inspection alone does not establish what that construct means when
compiled or executed. Branch selection, expression evaluation, function return,
arithmetic behavior, type value domains, configuration selection, name access,
typing/coherence, and caller-side unsafe obligations are semantic propositions;
derive each from exact applicable authority or record the needed TCB premise.
For every proof edge consumed by a certified conclusion, state the exact
proposition and applicability, identify its premises and their sources, justify
why they entail it, and identify its consumer. Quote the narrow text that
entails each Rust axiom; a URL or topic label is not a proposition. Check
direction explicitly: reject an unjustified converse, inverse, strengthened
conclusion, or widened domain, and state any contrapositive step with its exact
negation and domain. Canonical checked entries may be reused by identifier, but
the local proof must show the proposition and inference being reused.
Before treating a counterexample or caller path as a valid use, separately
close its accessibility and selected-source path, well-typedness and coherence,
every applicable caller and implementer contract owned outside the audited
scope—including contracts imposed on witness-supplied code—and every
corresponding compiler-enforced unsafe-context obligation needed to form the
use. Do not assume an in-scope audited safety assertion merely because it
appears on an unsafe impl, declaration, API boundary, or internal operation;
that assertion may be the proposition an UNSOUND certificate later proves
false. A declaration that looks safe is not, by inspection alone, proof that
calling or implementing it carries no unsafe obligation.
Do not issue PROVED, UNSOUND, CONTRACT-BROKEN, or an affirmative regional
result until its required certificate closes. If a universal kernel remains
incomplete, remove or qualify every dependent conclusion, record the smallest
root gap and its dependent conclusions, search for an admissible indirect
derivation, determine whether a separate existential certificate closes, and
otherwise issue UNPROVED.
Compose Proofs Locally and Literally
- Identify the controlling contract independently of the existing safety
comment. Distinguish normative contract text from examples, rationale,
implementation comments, and inferred design intent.
- Read the controlling contract according to its actual text. Decompose every
applicable conjunction, implication, quantifier, temporal clause,
precondition, and postcondition into separately reviewable obligations. Do
not replace a literal requirement with an operationally similar property.
Give every normative clause a disposition even when no known consumer uses
it.
- Reify every fact used nonlocally as a named contract or invariant carried by a
type, field, function boundary, guard, typestate, lock, token, or other
locally checkable mechanism. A function contract about global state is an
acceptable degenerate case.
- Prove that each state transition establishes, preserves, transfers,
deliberately suspends under an explicit obligation, or discharges every
applicable invariant. At each consumer, prove that the current invariant
entails the exact needed precondition.
- Trace dataflow across calls and time rather than limiting review to lexical
unsafe blocks. Account for every producer, transition, and consumer.
- Do not promote a producer's preconditions into a universal invariant of its
output type. Any type- or abstraction-wide conclusion needs a complete
derivation independent of that invalid reversal—for example, applicable
authoritative premises, construction-and-preservation closure under an
enforced boundary, or an admissible explicit TCB premise. Local checks and
other applicable derivations may instead prove the proposition for the
particular consumed values or quantified subset.
- For new code, place invariant-bearing representation in the smallest
practical leaf module, keep safely accessible representation fields private
to it, and treat safe code outside that module—including the rest of the same
crate—as untrusted.
Follow the Proof Workflow
- Frame the claim. Record the artifact identity, exact scope, valid uses or
executions, mandatory postconditions, TCB, exclusions, and whether design
alternatives are requested.
- Frame the full case domain. Identify every relevant dimension and
preserve the controlling expressions, sources, candidate relationships, and
unresolved conflicts. State the proposed
Required domain and how proof
cases will retain every dimension.
- Inventory surfaces and transformations. Enumerate every in-scope safe
and unsafe API surface, obligation site, invariant
producer/transition/consumer, and each material stage and alternative exit
by which build or generation inputs can affect the theorem domain, a
consumed premise, shipped artifacts or selected source, reachability, or an
in-scope postcondition.
- State atomic obligations and kernels. Obtain each controlling contract,
decompose it literally, and state the exact proposition and applicability to
prove. Classify artifact facts, semantic premises, derived lemmas, and TCB
admissions; identify their exact sources and consumers.
- Construct the derivation. Derive
Required, every asserted domain
relationship, and every claim conjunct through the evidence-bearing kernel
above. Unfold definitions and composite transformations; preserve material
operation order and alternative exits; seek indirect multi-premise
derivations; and justify every intermediate inference.
- Close, lint, and challenge. Give every literal contract clause and safe
surface a disposition and establish domain closure. Reverse-trace each
certificate, verify every semantic edge and implication direction, and
ensure no later-stage fact is consumed on a path that exited earlier. Then
try to falsify the domain recovery, contract reading, derivations, and
coverage with boundary and adversarial cases derived from the actual
clauses.
- Certify and report. Apply the quantifier-sensitive certificates below.
Keep every unresolved obligation visible and state the smallest missing
implication. Record proofs, TCB, coverage, findings, postcondition failures,
documentation gaps, and residual scope without optimism.
Write and Review Proof-Grade Documentation
Read proof-obligations.md before authoring,
reviewing, or auditing unsafe Rust and before certifying any proof, contract,
invariant, SAFETY comment, or verdict.
Keep each proof adjacent to the smallest cohesive unsafe operation or assertion.
State the exact operation and its preconditions, cite checked artifact facts
and proved lemmas or invariants, show the derivation, and prove resulting
postconditions and invariant state on every applicable exit.
When existing code can be validated only by reconstructing a material
derivation absent from its safety comment, do not accept it silently. Include
the reconstructed derivation—or the smallest missing portion—in the review,
with its citations and applicability. Classify implementation correctness
separately from proof-documentation quality. If changes are authorized, improve
the adjacent proof; otherwise provide proposed wording. Do not use a
reconstructed implementation proof to invent or strengthen a caller-facing
contract retroactively.
Close API and Configuration Boundaries
Read
api-boundaries-and-evolution.md
for fields, constructors, methods, traits, sealing, macros, public or hidden
APIs, robustness, or contract evolution.
Apply this mandatory safe-surface checklist: public fields, constructors, safe
methods, safe trait methods, and macro-generated APIs all count as safe API
surfaces. Include language-reachable #[doc(hidden)] safe items for soundness
even when excluded from documentation or compatibility promises.
Treat caller-provided safe code as adversarial within the behaviors permitted
by safe Rust and its types. Seal a trait or make it unsafe when soundness
requires an unenforced implementer behavior.
Read
configurations-and-generated-code.md
for every full audit and whenever supported-toolchain policy, conditional
compilation, targets, generated code, FFI, assembly, SIMD, allocators, linking,
or build tooling is relevant.
Every supported combination of compilation options that can ship downstream
must be sound. Use parametric proofs or exhaustive partitions when literal
enumeration would explode; do not substitute a tested sample.
Evaluate Trust and Evidence
Read tcb-and-evidence.md for every full audit
and whenever a proof uses dependencies, external specifications, tools,
testing, formal verification, environmental restrictions, or cryptographic or
probabilistic assumptions.
Judge evidence by the exact proposition it establishes, its artifact and model,
its quantified domain and bounds, its premises, and its residual trust—not by a
label such as testing, static analysis, model checking, or formal verification.
Design for Provability When Requested
Read abstraction-design.md when the user asks
to design, refactor, or reconsider an unsafe abstraction, or when authoring a
new unsafe abstraction.
Judge existing code under its current source and controlling contract. Inferred
intent or a preferable model may guide a separate proposal but may not narrow,
reinterpret, or discharge a current obligation. Treat implemented changes as a
new artifact and audit them anew.
Use Exact Verdicts
Read audit-reporting.md before delivering a
persistent or full audit.
| Verdict |
Required certificate |
| PROVED |
Every obligation for the exact named claim has a checked derivation over its complete applicability, Required ⊆ Covered, and every premise is proved from admissible sources or appears as an accepted entry in the stated TCB. |
| UNPROVED |
A required derivation, premise, applicability or domain-closure argument, postcondition proof, or citation remains missing, ambiguous, circular, or unverifiable, and no applicable existential refutation below is complete. |
| UNSOUND |
There exists a proved valid in-scope use or execution—with accessibility/source selection, well-typedness/coherence, every applicable caller and implementer contract owned outside the audited scope (including contracts imposed on witness-supplied code), and every corresponding unsafe-context obligation needed to form the use satisfied—which reaches an executed operation or semantic event, an exact in-scope audited safety proposition (whether internal or attached to an impl, declaration, or API boundary) is false there, and applicable authoritative semantics—possibly together with an explicit TCB premise about the implementation—entails undefined behavior. |
| CONTRACT-BROKEN |
There exists a proved valid in-scope execution which, considered as a whole, contains no undefined behavior and falsifies a documented postcondition. |
Failure to prove a universal obligation is enough for UNPROVED; do not invent
a counterexample. Conversely, once all parts of an existential UB certificate
are proved, report the scoped soundness claim UNSOUND; do not continue to
demand a universal positive lemma and dilute the result to UNPROVED. A
violation of user-authored safety prose is not by itself a runtime UB event:
trace the certificate through applicable contracts to the exact authoritative
or explicitly trusted UB consequence.
An existential certificate closes the universal verdict but does not excuse
omitting another in-scope surface, operation, contract clause, or mandatory
postcondition. Continue the inventory and give each independent obligation a
disposition. Do not claim that a proved or affected region is exact or maximal
unless its full case-domain equality is established; maximal positive remainder
characterization is required only when the audit scope requests it.
Classify a witness using the execution as a whole, not observations from a
prefix of an execution that later reaches undefined behavior. An
undefined-behavior-containing execution can witness UNSOUND but cannot
establish the existential claim required for CONTRACT-BROKEN. If it is the
only behavioral evidence, report soundness as UNSOUND and the postcondition
as UNPROVED. An independent UB-free witness or equivalent existence proof
may establish CONTRACT-BROKEN; separate proofs may therefore establish both
verdicts.
Apply verdicts separately to soundness, documented postconditions, and
conditional application claims. State exact scope, applicability, and TCB
beside every verdict. For every affirmative claim spanning multiple Rust
releases, identify a parametric proof, an exhaustive applicable partition, or
an exact proposition-preserving compatibility premise whose covered domain
contains the claimed release set. Never substitute endpoints, sparse samples,
an audit cutoff, “looks sound,” “probably sound,” or test success.
For a persistent audit, complete:
- tcb-audit-log-template.md
- unsafe-code-audit-report-template.md
For an inline review, provide the equivalent material compactly. Reuse an
existing canonical project log rather than creating a competing trust model.
1---2name: unsafe-rust3description: Author, document, review, audit, or redesign unsafe Rust with proof-grade rigor. Use for unsafe blocks and functions, unsafe traits and impls, raw pointers, FFI, inline assembly, intrinsics, layout or validity reasoning, concurrency and atomics, SIMD and target features, allocators, invariant-bearing fields, safety comments or `# Safety` documentation, soundness reviews, TCB audits, generated unsafe code, changes to safety or behavioral contracts, and proof-oriented redesign of unsafe abstractions.4---56# Unsafe Rust Authoring and Audit78Treat each safety contract as an English-language theorem and each safety9comment as its proof. Reject hand-waving, folklore, hidden assumptions, and10proof by testing.1112## Establish the Exact Claim1314Unless the user specifies a narrower claim, establish:1516> For the exact audited source snapshot, every supported compilation17> configuration, every valid in-scope use in a context satisfying all18> out-of-scope safety obligations preserves freedom from Rust undefined behavior19> under the documented Rust abstract semantics, and every mandatory in-scope20> documented postcondition holds, assuming only the explicitly recorded trusted21> computing base (TCB).2223Interpret valid use as follows:2425- For a safe API, quantify over every well-typed safe use. Impose no hidden26 safety precondition.27- For an unsafe API, quantify over every use satisfying all documented initial,28 ongoing, and terminal safety obligations.29- For a binary or other entrypoint, quantify over executions satisfying the30 explicitly recorded deployment assumptions. Do not transfer those31 assumptions silently to a safe library API.3233Prove every documented postcondition of each unsafe API in scope and every34documented guarantee consumed by an in-scope soundness proof. Include broader35safe-API robustness only when the user or audit scope requests it.3637Prove source-level Rust soundness first. State claims about a particular38compiler backend, binary, platform, security property, probability, or39deployment separately with their additional premises.4041## Recover the Required Domain4243Before proving the claim body or issuing a full verdict, derive the exact44domain quantified by the claim. Let a `case` retain every relevant dimension of45one valid use or execution: artifact, toolchain, configuration, input, state,46time, and any other dimension on which an obligation or premise can vary. Let47`Required(case)` denote the cases the claim requires and `Covered(case)` hold48exactly where every obligation the claim requires for that case has a complete49derivation from applicable premises. A local argument may project onto fewer50dimensions only when it proves the lemma for every required case in each51omitted-dimension fiber—parametrically or by proving those dimensions52irrelevant—and must restore the full case before claim-level closure.5354Within one obligation, valid case lemmas may be unioned. Across distinct55obligations, claim-level coverage is their pointwise conjunction—not a union of56regions in which different obligations happened to be proved.5758- Preserve the controlling domain expressions symbolically, including ranges,59 unions, exclusions, quantifiers, and conditional or moving policies. Record60 their exact sources and audit cutoff.61- If applicable project sources conflict or materially underdetermine support,62 obtain an authorized resolution, derive an explicit conservative audit63 domain containing every materially supported candidate predicate, or leave64 the affected combined claim `UNPROVED`. Do not call a conservative audit65 domain the resolved project promise.66- Treat every asserted set relationship, normalization, enumeration,67 partition, exclusion, and policy merge as a proof step. Prove the definition68 of the exact relation asserted. For example, `A = B` needs `A ⊆ B` and69 `B ⊆ A`; `A ⊊ B` needs `A ⊆ B` and a witness `w ∈ B \ A`;70 incomparability needs witnesses `a ∈ A \ B` and `b ∈ B \ A`, with each71 membership and nonmembership proved. Equivalent symbolic derivations are72 acceptable, but required witnesses must remain explicit. Prove the73 required containment before using a conservative superset and74 `Required ⊆ Covered` before concluding `PROVED`.75- A finite inventory requires evidence both that every listed member belongs76 and that no required member is omitted. Endpoints, one representative per77 apparent category, CI jobs, lockfiles, and other samples do not prove an78 interval or set inventory.79- Prefer a parametric proof over the symbolic predicate when enumeration would80 be large or its exact membership is unavailable. Otherwise report proved81 regions and the unresolved remainder; do not turn it into an implicit82 exclusion.83- An audit cutoff limits the temporal scope of a claim. It does not establish84 semantic continuity, enumerate releases before the cutoff, or make sampled85 documentation applicable between samples.8687Apply88[configuration recovery](references/configurations-and-generated-code.md#recover-the-required-supported-set)89to derive supported compilation cases and prove every transformation of that90predicate.9192## Use Only Applicable Premises9394- Bottom out Rust-language and standard-library facts in exact applicable text95 from versioned Rust Reference or standard-library documentation.96- Quote and link the smallest sufficient set of passages whose explicitly97 stated propositions, together with justified inference steps, entail the98 fact. Open each citation and verify its wording, qualifications, version, and99 scope. A page, allowlist entry, broad label such as “cfg semantics,” or nearby100 cited clause does not supply a material proposition the proof never states.101- Attach an applicability domain to every claim and premise, whether stated102 locally or inherited from an identified project policy or canonical entry. A103 derivation proves only the cases covered by all premises it consumes.104- Apply a guarantee documented for an older Rust release to a later stable105 release only when an exact applicable Rust backwards-compatibility106 commitment preserves that exact proposition throughout the later release's107 relevant domain. An API's stability badge does not by itself preserve every108 behavioral statement in its current documentation. Record a109 non-authoritative compatibility premise explicitly in the TCB. Never infer110 an earlier-version guarantee merely from later documentation.111- Do not promote this skill, the Rustonomicon, Unsafe Code Guidelines, RFCs,112 blogs, issue discussions, implementation behavior, Miri, or common practice113 to Rust axioms. Use them to discover risks and authoritative text, or record114 the exact additional proposition as a TCB assumption.115- Trust a deliberately selected safe dependency API to behave as documented116 only when that exact trust is explicit in the TCB. Do not extend this117 exception to caller-controlled safe code, callbacks, values, or safe trait118 implementations.119- Audit a third-party unsafe API through to admissible premises or record its120 exact implementation and contract as an additional TCB assumption.121122When no admissible direct or derived proof can be completed because123authoritative documentation is ambiguous or insufficient, identify the124smallest missing proposition. Do not repair it with intuition. Report a125documentation gap and suggest an upstream improvement when appropriate.126127## Close an Evidence-Bearing Proof Kernel128129Before certifying any conclusion, expose a minimal, reviewable kernel of this130form:131132```text133artifact facts134 + applicable Rust/stdlib axioms, verified tool theorems,135 or explicit TCB premises136 + earlier proved lemmas or invariants137 + explicit logic or mathematics138 -> derived proposition139 -> consumer, postcondition, or verdict140```141142An artifact fact is only a literal property of the exact inspected source,143expansion, generated output, or other artifact: for example, that a declaration,144operator, type annotation, branch, tail expression, or attribute occurs at a145location. Inspection alone does not establish what that construct means when146compiled or executed. Branch selection, expression evaluation, function return,147arithmetic behavior, type value domains, configuration selection, name access,148typing/coherence, and caller-side unsafe obligations are semantic propositions;149derive each from exact applicable authority or record the needed TCB premise.150151For every proof edge consumed by a certified conclusion, state the exact152proposition and applicability, identify its premises and their sources, justify153why they entail it, and identify its consumer. Quote the narrow text that154entails each Rust axiom; a URL or topic label is not a proposition. Check155direction explicitly: reject an unjustified converse, inverse, strengthened156conclusion, or widened domain, and state any contrapositive step with its exact157negation and domain. Canonical checked entries may be reused by identifier, but158the local proof must show the proposition and inference being reused.159160Before treating a counterexample or caller path as a valid use, separately161close its accessibility and selected-source path, well-typedness and coherence,162every applicable caller and implementer contract owned outside the audited163scope—including contracts imposed on witness-supplied code—and every164corresponding compiler-enforced unsafe-context obligation needed to form the165use. Do not assume an in-scope audited safety assertion merely because it166appears on an unsafe impl, declaration, API boundary, or internal operation;167that assertion may be the proposition an `UNSOUND` certificate later proves168false. A declaration that looks safe is not, by inspection alone, proof that169calling or implementing it carries no unsafe obligation.170171Do not issue `PROVED`, `UNSOUND`, `CONTRACT-BROKEN`, or an affirmative regional172result until its required certificate closes. If a universal kernel remains173incomplete, remove or qualify every dependent conclusion, record the smallest174root gap and its dependent conclusions, search for an admissible indirect175derivation, determine whether a separate existential certificate closes, and176otherwise issue `UNPROVED`.177178## Compose Proofs Locally and Literally179180- Identify the controlling contract independently of the existing safety181 comment. Distinguish normative contract text from examples, rationale,182 implementation comments, and inferred design intent.183- Read the controlling contract according to its actual text. Decompose every184 applicable conjunction, implication, quantifier, temporal clause,185 precondition, and postcondition into separately reviewable obligations. Do186 not replace a literal requirement with an operationally similar property.187 Give every normative clause a disposition even when no known consumer uses188 it.189- Reify every fact used nonlocally as a named contract or invariant carried by a190 type, field, function boundary, guard, typestate, lock, token, or other191 locally checkable mechanism. A function contract about global state is an192 acceptable degenerate case.193- Prove that each state transition establishes, preserves, transfers,194 deliberately suspends under an explicit obligation, or discharges every195 applicable invariant. At each consumer, prove that the current invariant196 entails the exact needed precondition.197- Trace dataflow across calls and time rather than limiting review to lexical198 unsafe blocks. Account for every producer, transition, and consumer.199- Do not promote a producer's preconditions into a universal invariant of its200 output type. Any type- or abstraction-wide conclusion needs a complete201 derivation independent of that invalid reversal—for example, applicable202 authoritative premises, construction-and-preservation closure under an203 enforced boundary, or an admissible explicit TCB premise. Local checks and204 other applicable derivations may instead prove the proposition for the205 particular consumed values or quantified subset.206- For new code, place invariant-bearing representation in the smallest207 practical leaf module, keep safely accessible representation fields private208 to it, and treat safe code outside that module—including the rest of the same209 crate—as untrusted.210211## Follow the Proof Workflow2122131. **Frame the claim.** Record the artifact identity, exact scope, valid uses or214 executions, mandatory postconditions, TCB, exclusions, and whether design215 alternatives are requested.2162. **Frame the full case domain.** Identify every relevant dimension and217 preserve the controlling expressions, sources, candidate relationships, and218 unresolved conflicts. State the proposed `Required` domain and how proof219 cases will retain every dimension.2203. **Inventory surfaces and transformations.** Enumerate every in-scope safe221 and unsafe API surface, obligation site, invariant222 producer/transition/consumer, and each material stage and alternative exit223 by which build or generation inputs can affect the theorem domain, a224 consumed premise, shipped artifacts or selected source, reachability, or an225 in-scope postcondition.2264. **State atomic obligations and kernels.** Obtain each controlling contract,227 decompose it literally, and state the exact proposition and applicability to228 prove. Classify artifact facts, semantic premises, derived lemmas, and TCB229 admissions; identify their exact sources and consumers.2305. **Construct the derivation.** Derive `Required`, every asserted domain231 relationship, and every claim conjunct through the evidence-bearing kernel232 above. Unfold definitions and composite transformations; preserve material233 operation order and alternative exits; seek indirect multi-premise234 derivations; and justify every intermediate inference.2356. **Close, lint, and challenge.** Give every literal contract clause and safe236 surface a disposition and establish domain closure. Reverse-trace each237 certificate, verify every semantic edge and implication direction, and238 ensure no later-stage fact is consumed on a path that exited earlier. Then239 try to falsify the domain recovery, contract reading, derivations, and240 coverage with boundary and adversarial cases derived from the actual241 clauses.2427. **Certify and report.** Apply the quantifier-sensitive certificates below.243 Keep every unresolved obligation visible and state the smallest missing244 implication. Record proofs, TCB, coverage, findings, postcondition failures,245 documentation gaps, and residual scope without optimism.246247## Write and Review Proof-Grade Documentation248249Read [proof-obligations.md](references/proof-obligations.md) before authoring,250reviewing, or auditing unsafe Rust and before certifying any proof, contract,251invariant, `SAFETY` comment, or verdict.252253Keep each proof adjacent to the smallest cohesive unsafe operation or assertion.254State the exact operation and its preconditions, cite checked artifact facts255and proved lemmas or invariants, show the derivation, and prove resulting256postconditions and invariant state on every applicable exit.257258When existing code can be validated only by reconstructing a material259derivation absent from its safety comment, do not accept it silently. Include260the reconstructed derivation—or the smallest missing portion—in the review,261with its citations and applicability. Classify implementation correctness262separately from proof-documentation quality. If changes are authorized, improve263the adjacent proof; otherwise provide proposed wording. Do not use a264reconstructed implementation proof to invent or strengthen a caller-facing265contract retroactively.266267## Close API and Configuration Boundaries268269Read270[api-boundaries-and-evolution.md](references/api-boundaries-and-evolution.md)271for fields, constructors, methods, traits, sealing, macros, public or hidden272APIs, robustness, or contract evolution.273274Apply this mandatory safe-surface checklist: public fields, constructors, safe275methods, safe trait methods, and macro-generated APIs all count as safe API276surfaces. Include language-reachable `#[doc(hidden)]` safe items for soundness277even when excluded from documentation or compatibility promises.278279Treat caller-provided safe code as adversarial within the behaviors permitted280by safe Rust and its types. Seal a trait or make it unsafe when soundness281requires an unenforced implementer behavior.282283Read284[configurations-and-generated-code.md](references/configurations-and-generated-code.md)285for every full audit and whenever supported-toolchain policy, conditional286compilation, targets, generated code, FFI, assembly, SIMD, allocators, linking,287or build tooling is relevant.288Every supported combination of compilation options that can ship downstream289must be sound. Use parametric proofs or exhaustive partitions when literal290enumeration would explode; do not substitute a tested sample.291292## Evaluate Trust and Evidence293294Read [tcb-and-evidence.md](references/tcb-and-evidence.md) for every full audit295and whenever a proof uses dependencies, external specifications, tools,296testing, formal verification, environmental restrictions, or cryptographic or297probabilistic assumptions.298299Judge evidence by the exact proposition it establishes, its artifact and model,300its quantified domain and bounds, its premises, and its residual trust—not by a301label such as testing, static analysis, model checking, or formal verification.302303## Design for Provability When Requested304305Read [abstraction-design.md](references/abstraction-design.md) when the user asks306to design, refactor, or reconsider an unsafe abstraction, or when authoring a307new unsafe abstraction.308309Judge existing code under its current source and controlling contract. Inferred310intent or a preferable model may guide a separate proposal but may not narrow,311reinterpret, or discharge a current obligation. Treat implemented changes as a312new artifact and audit them anew.313314## Use Exact Verdicts315316Read [audit-reporting.md](references/audit-reporting.md) before delivering a317persistent or full audit.318319| Verdict | Required certificate |320|---|---|321| **PROVED** | Every obligation for the exact named claim has a checked derivation over its complete applicability, `Required ⊆ Covered`, and every premise is proved from admissible sources or appears as an accepted entry in the stated TCB. |322| **UNPROVED** | A required derivation, premise, applicability or domain-closure argument, postcondition proof, or citation remains missing, ambiguous, circular, or unverifiable, and no applicable existential refutation below is complete. |323| **UNSOUND** | There exists a proved valid in-scope use or execution—with accessibility/source selection, well-typedness/coherence, every applicable caller and implementer contract owned outside the audited scope (including contracts imposed on witness-supplied code), and every corresponding unsafe-context obligation needed to form the use satisfied—which reaches an executed operation or semantic event, an exact in-scope audited safety proposition (whether internal or attached to an impl, declaration, or API boundary) is false there, and applicable authoritative semantics—possibly together with an explicit TCB premise about the implementation—entails undefined behavior. |324| **CONTRACT-BROKEN** | There exists a proved valid in-scope execution which, considered as a whole, contains no undefined behavior and falsifies a documented postcondition. |325326Failure to prove a universal obligation is enough for `UNPROVED`; do not invent327a counterexample. Conversely, once all parts of an existential UB certificate328are proved, report the scoped soundness claim `UNSOUND`; do not continue to329demand a universal positive lemma and dilute the result to `UNPROVED`. A330violation of user-authored safety prose is not by itself a runtime UB event:331trace the certificate through applicable contracts to the exact authoritative332or explicitly trusted UB consequence.333334An existential certificate closes the universal verdict but does not excuse335omitting another in-scope surface, operation, contract clause, or mandatory336postcondition. Continue the inventory and give each independent obligation a337disposition. Do not claim that a proved or affected region is exact or maximal338unless its full case-domain equality is established; maximal positive remainder339characterization is required only when the audit scope requests it.340341Classify a witness using the execution as a whole, not observations from a342prefix of an execution that later reaches undefined behavior. An343undefined-behavior-containing execution can witness `UNSOUND` but cannot344establish the existential claim required for `CONTRACT-BROKEN`. If it is the345only behavioral evidence, report soundness as `UNSOUND` and the postcondition346as `UNPROVED`. An independent UB-free witness or equivalent existence proof347may establish `CONTRACT-BROKEN`; separate proofs may therefore establish both348verdicts.349350Apply verdicts separately to soundness, documented postconditions, and351conditional application claims. State exact scope, applicability, and TCB352beside every verdict. For every affirmative claim spanning multiple Rust353releases, identify a parametric proof, an exhaustive applicable partition, or354an exact proposition-preserving compatibility premise whose covered domain355contains the claimed release set. Never substitute endpoints, sparse samples,356an audit cutoff, “looks sound,” “probably sound,” or test success.357358For a persistent audit, complete:359360- [tcb-audit-log-template.md](assets/tcb-audit-log-template.md)361- [unsafe-code-audit-report-template.md](assets/unsafe-code-audit-report-template.md)362363For an inline review, provide the equivalent material compactly. Reuse an364existing canonical project log rather than creating a competing trust model.