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⁻¹):
- Norm & layout preserved: Mutations happen in-place inside the fixed physical struct layout (
computeStructLayout), with zero object reallocation, zero JSON serialization, and zero packaging step. - Invertible O(1) rollback: Every live REPL/snapshot evolution is content-addressed (
parentSha256 -> headSnapshotSha256). If liveTelemetrySection+TraceSectionspans detect a mismatch on a target device, applying the inverse snaps the isolate back to the last proven crystal inO(1)time.
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:
- TID Capability Cone (Zero Global Order Required):
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.
- Non-Commutative Slot State (
q1·q2 != q2·q1):
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?
- The active epoch lives in a dedicated 64-byte cache-line-isolated
Int32slot in theB8G_ARENA_V1SAB header (hdr[EPOCH_SLOT]). rotateEpoch()executes a sequentially-consistentAtomics.add(hdr, EPOCH_SLOT, 1)followed byAtomics.notify.- Every peer isolate validates
Atomics.load(hdr, EPOCH_SLOT)against its sealed token via branchlessct_eq_64+ct_select_64(ct-lattice.ts). On mismatch, the read unconditionally selects the zero/sentinel mask without any data-dependent branch — closing both the stale-data window and the branch-timing side channel.
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"]
- Security is O(1) instant: A slow or stalled peer can never delay revocation for the rest of the system.
- Reclamation is race-free: Physical 64B slot zeroing/reassignment waits for active
AtomicLeaserefcounts to drain to0, guaranteeing in-flight readers never see torn or zeroed memory.
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:
- Lease Acquire (
e0): Acquiring theAtomicLeaseestablishes an acquire fence and snapshotse0 = Atomics.load(hdr, EPOCH_SLOT). - Every
NO_TRANSFORM@obliviousRead Boundary (e1): Reloads a fresh seq-cste1 = Atomics.load(hdr, EPOCH_SLOT)and computes:
```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