AWESOME-OS ENGINEERING BLOG

03 — Under Adversarial Fire: Verifying Awesome-OS's Lock-Free Capability & Epoch Memory Model

03 — Under Adversarial Fire: Verifying Awesome-OS's Lock-Free Capability & Epoch Memory Model

2026-11-19 · Awesome-OS Development History

Architecture slogans are cheap. Memory models are unforgiving.

Today we took Awesome-OS's SharedArrayBuffer Capability Lattice & Epoch Revocation model (B8G_ARENA_V1, AtomicLease, CapabilityToken<TID>, and @oblivious constant-time IR lowering) through a live, multi-round adversarial stress-test on X — probing every edge case from concurrent sibling isolates to CPU happens-before fences and RCU reclamation.

Every single invariant held without a single patch or hand-wave. Here is the complete formal summary of the 6 invariants that survived scrutiny.


Invariant 1 — In-Place Evolution & O(1) Inverse Rollback

In Awesome-OS, SectionSlots live on fixed, 64-byte-aligned SharedArrayBuffer slices. Evolving an active intersection behaves like unit-quaternion conjugation (q · v · q⁻¹):


Invariant 2 — Zero Global Lock: Meet-Semilattice Cones vs. Local Slot Leases

What happens when sibling isolates concurrently attenuate capabilities and mutate shared slots?

We split the problem cleanly into two algebraic layers:

Attenuation is defined by bitwise AND over permission masks (parentMask & requestedMask) and min(TTL). Because bitwise & and min form a commutative, associative, idempotent meet-semilattice, concurrent attenuations from sibling isolates can only tighten the authority cone regardless of arrival order.

Writes to a shared 64B-aligned SectionSlot are serialized locally via a per-slot AtomicLease (0x80000000 writer bit / 0x7FFFFFFF reader refcount) and lock-free SPSC/MPMC rings — never a global lock.


Invariant 3 — Cache-Line-Isolated Epoch + Branchless @oblivious Checks

How is a revoked epoch made immediately unobservable to any peer isolate — including against timing side channels?


Invariant 4 — Instant Logical Revocation vs. RCU Physical Reclamation

A classic lock-free trap is conflating revoking access with reclaiming memory. Awesome-OS strictly decouples them:

flowchart LR
    ROT["rotateEpoch()<br/>seq-cst Atomics.add + Atomics.notify"] --> LOG["Logical Revocation (O(1), Instant)<br/>Parked & active peers collapse to sentinel<br/>(effective TID mask -> 0, zero wait)"]
    ROT --> PHYS["Physical Slot Reuse (RCU-Gated)<br/>Waits for in-flight AtomicLease refcount -> 0<br/>before zeroing or reassigning 64B slot"]

Invariant 5 — Seqlock-Bracketed e0 + Independent NO_TRANSFORM e1 Reload

Plain non-atomic TypedArray loads carry no happens-before edge from a concurrent Atomics.add. Therefore, Awesome-OS never relies on implicit visibility:

```text

valid = ct_eq_64(e1, token.epoch) & ct_eq_64(e1, e0)

result = ct_select_64(valid, value, SENTINEL)

```

This eliminates both stale acquire-time snapshots and torn multi-word reads if rotateEpoch() fires mid-lease.


Invariant 6 — Immutable token.epoch (Zero Data Race on the Token)

Finally: does token.epoch itself need a seq-cst write?

No — because token.epoch is immutable. At capability mint time, token.epoch is read once from Atomics.load(hdr, EPOCH_SLOT) and sealed inside the capability (Object.freeze / read-only handle). It is never mutated afterward. Only the shared SAB hdr[EPOCH_SLOT] is ever written, so every happens-before edge lies cleanly between rotateEpoch()'s Atomics.add and the readers' e0 / e1 Atomics.loads.


Summary Table

Attack / Edge Case Awesome-OS Mechanism Guarantee
Concurrent sibling escalation Bitwise & + min(TTL) meet-semilattice Strictly monotonic, zero global lock
Timing side-channel on revocation Branchless ct_eq_64 + ct_select_64 (NO_TRANSFORM) Zero data-dependent branches
Slow peer blocking revocation Decoupled logical revocation vs. RCU AtomicLease drain O(1) instant revocation, safe reuse
Non-atomic SAB load reordering Seqlock e0 acquire + fresh seq-cst e1 per read boundary Zero stale snapshots, zero torn reads
Race on token.epoch Immutable constant sealed at mint time Zero concurrent writes on tokens

Related specs: ct-lattice.ts · tenant-shapes.mts · authority-mapper.mts

← Back to all 27 engineering posts