> For the complete documentation index, see [llms.txt](https://surf-2.gitbook.io/surfliquid-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://surf-2.gitbook.io/surfliquid-docs/security-control-layer/deterministic-rules-and-invariants.md).

# Deterministic Rules and Invariants

<figure><img src="/files/dJkF0hjw1Y0LKoKH37ol" alt=""><figcaption></figcaption></figure>

**The hard boundaries that make autonomous finance safe**

Surf does not rely on “good behaviour” from AI. It relies on rules that cannot be bypassed.

At the core of the system is a set of deterministic rules and invariants that define what is always allowed and what is never allowed, regardless of market conditions, vault logic or AI confidence.

These rules are not heuristics. They are enforced conditions at the execution layer.

**If a rule is violated, the action simply does not happen.**

***

#### What Are Deterministic Rules?

Deterministic rules are binary checks:

* Either the condition is satisfied
* Or execution is blocked

There is no discretion, no override, and no probabilistic interpretation.

Examples:

* Is the protocol on the allowlist?
* Is exposure below the maximum cap?
* Is exit liquidity sufficient at the current depth?
* Is slippage within bounds after fees?
* Does the action preserve vault isolation?
* Does the route respect chain and bridge constraints?

If the answer to any of these is “no”, the transaction is rejected.

***

#### What Are Invariants?

Invariants are properties of the system that must always remain true, before and after every action.

They define the safety shape of the vault and the execution layer.

Examples of Surf invariants:

**Custody Invariants**

* Funds never leave the user-owned vault except through:
  * approved vault execution
  * user-initiated withdrawal
* Surf cannot transfer assets to arbitrary addresses
* Surf cannot seize, rehypothecate, or redirect funds

**Exposure Invariants**

* Maximum exposure per protocol
* Maximum exposure per asset class
* Maximum correlated risk per vault cluster

**Liquidity Invariants**

* Minimum exit depth must exist at the current utilisation
* Rebalance must be fully reversible under stress assumptions
* No execution that strands liquidity in illiquid states

**Execution Invariants**

* Atomic execution only (no partial states)
* No multi-step sequences that leave funds between venues
* No bridge or swap path without validated settlement guarantees

**Risk Invariants**

* Health factor must remain above minimum thresholds
* Oracle deviation must be within tolerance
* Abnormal utilisation spikes trigger freeze conditions

***

#### Why Determinism Matters for AI Systems

AI works with probabilities. Money requires guarantees.

Surf separates these domains:

* AI operates in the proposal space
* Deterministic rules operate in the permission space

AI can suggest:

* reallocations
* optimisations
* migrations
* yield improvements

Rules decide:

* whether the suggestion is allowed to become reality

This ensures that:

* Intelligence can evolve
* Safety remains fixed

***

#### How Rules Are Enforced

Rules are enforced at multiple layers:

1. **Vault-level controls**

   Define what the vault can and cannot do.
2. **Guardian Layer constraints**

   Enforce exposure, slippage, venue, and path limits.
3. **Execution pre-checks**

   Simulate outcomes and reject if invariants would be violated.
4. **On-chain assertions**

   Validate the state before and after execution.

This makes the system resistant to:

* model errors
* oracle anomalies
* black swan liquidity events
* vault logic bugs
* operator mistakes

***

#### Why This Is a Core Moat

Most DeFi automation relies on:

* vault logic
* off-chain monitoring
* social trust in operators

Surf relies on:

* mathematical boundaries
* on-chain enforcement
* non-bypassable constraints

That is why Surf can scale autonomy without scaling risk.

***

#### The Principle

AI can be creative. Capital must be conservative.

Deterministic rules and invariants are what make that coexistence possible.

They ensure that no matter how advanced the optimisation becomes, the system never violates the core promises:

* Non-custodial
* Rule-bound
* Auditable
* Reversible
* Withdraw-anytime

This is what allows Surf to move from “automation” to autonomous finance with guarantees.
