Skip to content
Invariant
[ ≡ ] THE TECHNICAL JOURNAL

INVARIANT.

The code changes. The frameworks change. The invariants don’t.
Systems, Rust, and the properties that make software worth trusting.

Systems / Operating-Systems

The Scheduler: Fairness on a Finite Machine

Sixty processes want the CPU. Four cores exist. The scheduler decides who runs, for how long, and what happens when everyone wants more. This post names the invariant it must keep.

13 min read
Systems / Database-Internals

The Buffer Pool: Why Databases Don't Trust the OS

The OS has a page cache. The database ignores it and builds its own. This post explains why — and how the buffer pool decides what stays in RAM.

13 min read
Systems / Database-Internals

Pages: The Fixed-Size Bet Every Database Makes

Databases don't read bytes. They read pages — fixed-size blocks that turn random I/O into something the disk can handle. This post explains why.

14 min read
Rust / Fundamentals

Macro Hygiene and Design: Writing Macros that Compose

Identifiers inside a macro expansion live in a separate namespace from the caller's code. A macro cannot accidentally shadow, capture, or conflict with variables at its call site. Naming collisions are struc...

10 min read
Rust / Fundamentals

Procedural Macros: Compile-Time Code from Code

A procedural macro is a function from TokenStream to TokenStream — arbitrary Rust code that runs at compile time. But its output is still bound by every invariant the compiler enforces. Full power, zero priv...

10 min read
Rust / Fundamentals

Declarative Macros: Code that Writes Code Under Contract

Rust macros generate code at compile time — but every expansion must pass the same type checking, borrow checking, and lifetime analysis as hand-written code. The macro writes; the compiler judges.

9 min read
Rust / Fundamentals

Modules and Crates: The Visibility Invariant

Everything in Rust is private by default. Modules enforce encapsulation at the language level — internal implementation stays internal unless you explicitly expose it. This is how Rust makes invalid states u...

10 min read
Rust / Fundamentals

Closures and Iterators: Zero-Cost Functional Invariants

Closures capture their environment under the same ownership rules as everything else in Rust. Iterators are lazy, composable, and compile down to the same code as hand-written loops. Functional style, system...

9 min read
Rust / Fundamentals

Collections: Owned Data with Built-in Guarantees

Vec, String, and HashMap are the workhorses of Rust. Each one owns its data on the heap and enforces invariants the compiler alone can't — contiguous memory, valid UTF-8, unique keys.

8 min read
Rust / Fundamentals

Lifetimes: The Reference Validity Invariant

Lifetimes are the compiler's proof that every reference points to valid data. You don't control how long things live — you help the compiler verify that references never outlive what they point to.

7 min read
Rust / Fundamentals

Generics: Write Once, Check Every Type

Generics let you write code that works for many types without sacrificing type safety or performance. The compiler generates specialized code for each concrete type — zero cost, full safety.

8 min read
Rust / Fundamentals

Traits: Behavioral Contracts the Compiler Enforces

Traits define shared behavior across types — and the compiler guarantees every type that claims to implement a trait actually does. This is polymorphism with compile-time proof, not runtime hope.

7 min read
Rust / Fundamentals

Error Handling: No Silent Failures

Rust splits errors into two categories: unrecoverable (panic) and recoverable (Result). The compiler forces you to handle the recoverable ones. You cannot ignore a Result — the type system won't let you.

9 min read
Rust / Fundamentals

Enums and Pattern Matching: The Exhaustiveness Invariant

Enums let you define a type by listing its possible variants. match forces you to handle every single one. The compiler guarantees you never forget a case — and Option guarantees you never forget about absence.

8 min read
Blockchain / CosmWasm

CosmWasm 101: Messages and State

Instantiate, Execute, Query — three message types, three classes of invariants. How CosmWasm contracts enforce valid state transitions through typed messages and ownership checks.

8 min read
Blockchain / CosmWasm

CosmWasm 101: The Entry Points

Smart contracts don't have main(). They have entry points — and each one enforces a different invariant about how the outside world can interact with on-chain state.

5 min read
Rust / Fundamentals

Structs: Building Custom Types with Custom Invariants

Structs let you define your own types — and your own invariants. By controlling construction, field access, and method behavior, you decide what 'valid' means for your data.

6 min read
Rust / Fundamentals

Borrowing and References: The Aliasing Invariant

Rust's borrowing rules encode a fundamental invariant: you can have many readers or one writer, but never both. This single rule eliminates data races at compile time.

6 min read
Rust / Fundamentals

Ownership Simplified: Rust's Central Invariant

Ownership is not a feature of Rust. It IS Rust. Three rules, enforced at compile time, that eliminate use-after-free, double-free, and data races — without a garbage collector.

5 min read
Rust / Fundamentals

Rust Functions: Invariants at Every Boundary

Every function in Rust is a boundary — and every boundary is a place where invariants are declared. Parameter types, return types, and the expression system all enforce contracts the compiler checks.

4 min read
Rust / Fundamentals

Intro to Rust: A Language Built on Invariants

Rust isn't just another systems language. It's a language that encodes invariants — memory safety, thread safety, type correctness — directly into the compiler. Here's where it starts.

2 min read
Cryptography / Security

Modes of Operation: Same Cipher, Different Invariants

A block cipher encrypts fixed-size blocks. Modes of operation define how to encrypt messages longer than one block — and each mode upholds (or fails to uphold) different invariants.

7 min read
Cryptography / Security

AES Internals: Four Operations, Four Invariants

AES is built from four operations, each preserving a specific invariant. Remove any one of them and the cipher breaks in a distinct, predictable way.

6 min read
Cryptography / Security

Cryptography: Invariants Over Untrusted Channels

Cryptography is the discipline of preserving invariants over untrusted channels. Confidentiality, integrity, authenticity — these are guarantees that must hold no matter what.

3 min read
Systems / Engineering

Why Invariants Matter

On the one principle that separates resilient systems from fragile ones.

2 min read