# The Capability Enforcer

The enforcer is the on-chain component that makes ChainRender apps **safe by construction**. It walks a composition
and either passes it (with an honest grade) or *refuses* it — so an unsafe app cannot be registered in the first
place. Safety isn't a warning you might ignore; it's a gate you cannot pass.

## What it refuses (the hard rails)

- **R1 — no arbitrary code.** An escape hatch to unanalyzable code refuses the whole composition. Unanalyzable =
  unsafe.
- **R2 — no dishonest envelope.** An app that under-declares what it actually does (hiding a capability it reaches)
  is refused. You cannot claim to be safer than you are.
- **R3 — no out-of-envelope actions.** An action requiring a capability the app never declared is blocked.
- **R4 — no value smuggling.** An action that moves value while the app never declared `VALUE` is blocked — even if
  it tries to hide the value from its own capability set.
- **R5 — no arbitrary calls.** An action whose `{to, selector}` isn't in the declared call set is blocked. A button
  can only do what it openly says it does.
- **R6 — no off-envelope bindings.** A data binding needing an undeclared capability is blocked.
- **R7 — dependency honesty.** Immutable deps grade A, attested B, unproven/mutable C — conservatively, never
  refused but always disclosed.

## Why refusal, not just warning

A warning can be ignored, suppressed, or missed. For a UI that signs transactions, "safe unless you click through a
warning" isn't safe. So the unsafe cases are *refused at registration* — they never become a live app. What remains
is a system where *every registered app is structurally incapable* of the smuggling attacks above, and its grade
honestly reflects whatever safe dependencies it does have.

## Drift-locked with the SDK

The SDK's `grade()` computes the *same* result the on-chain enforcer does — a test asserts they never diverge. So
the grade you see while building is exactly what the chain will enforce. No surprises at deploy time.

## Related
- **[The Trust Grade](./trust-grade.md)** — what passes gets graded.
- **[Actions & Signing](./actions.md)** — how declared actions satisfy R3–R5.
