Asupersync Browser Edition · 21 live exhibits
The lifecycle contract, made visible.
Explore the ownership, cancellation, outcome, and capability model behind Asupersync. Every lifecycle mutation in this lab crosses the shipped WebAssembly boundary; the browser supplies the promises, timers, and event loop.
Browse all 21 experiments
ABI Handshake & Version Negotiation
Before lifecycle work begins, Asupersync's WASM module and JavaScript host perform a version handshake with a 64-bit fingerprint. Incompatible consumers are rejected at the first API call, before any state is mutated. That makes ABI drift an explicit contract failure instead of a late runtime surprise.
Structured Concurrency: The Region Tree
Asupersync makes task ownership explicit: every task belongs to a region, and regions form a tree rooted at the runtime. Closing a region drives its recorded children toward quiescence and resolves their lifecycle obligations. Choose any region to watch the host-timed phases while the corresponding scope handles close in WASM.
Four-Valued Outcome Algebra
Asupersync uses a four-valued Outcome
with a severity lattice: Ok < Err < Cancelled < Panicked.
Combinators can aggregate by severity, keeping application errors, attributed cancellation, and panics distinct
without flattening them into a single failure channel.
Cancellation Is a Protocol, Not a Silent Drop
Cancellation flows through a multi-phase protocol: Running → Requested → Draining → Finalizing → Completed. Budget is consumed during drain, so cleanup policy is visible and bounded instead of being implicit. The comparison below contrasts a detached-drop pattern with Asupersync's explicit close protocol.
All tasks executing normally.
Illustrative resource labels; the Asupersync side records and joins three WASM task obligations.
Tasks running...
Tasks running...
Budget Algebra with Semiring Composition
Asupersync makes cleanup constraints first-class. Its budgets compose as a
semiring: combine(b1, b2)
takes componentwise min for quotas/deadlines and max for priority.
That turns nested constraints into an operation the runtime can validate and inspect.
Generation Counters Reject Stale Handles
Integer IDs are easy to recycle incorrectly: an old reference can accidentally address new state in the same slot. Asupersync's handles carry a generation counter that increments on every slot recycle. Stale handles are rejected with a precise error message.
Deep Cascade Close
Asupersync regions form a tree with cascade close: close a node and its recorded descendants close children-first. This exhibit builds a four-level scope tree in WASM, closes a middle node, and probes each handle after the cascade.
Cancel Is Not Enough. You Must Join.
In Asupersync, task_cancel() requests cancellation.
The task stays pinned.
You must call task_join()
to record the outcome and release the handle. The ledger makes this two-step protocol directly observable.
Live WASM Lifecycle REPL
Type JavaScript below to call the shipped WASM lifecycle API directly. Handle allocation, scope transitions, task outcomes, and cancellation records cross the compiled Rust boundary; the browser remains responsible for scheduling JavaScript work. Open DevTools to inspect each ABI call.
Lifecycle Stress Run
Rapid create, cancel, join, and close sequences exercise the places where stale generations and unresolved obligations tend to surface. This browser run performs 200 randomized operations against WASM handles, closes the root, then probes the handles it created to report what the ledger accepted or rejected.
Scope-Bounded HTTP
In vanilla JavaScript, cancelling an in-flight fetch() requires
manually creating an AbortController, threading its signal through the call, and remembering
to call abort() on teardown. Browser Edition binds each host request to a
region-owned fetch handle. Closing the region invalidates the
associated lifecycle handles while the WASM host bridge aborts the browser requests.
Outcome Severity as Algebra
Asupersync's four-valued Outcome forms a
severity lattice: Ok < Err < Cancelled < Panicked.
This exhibit records five mixed task outcomes in WASM and applies the same ordering used by the API.
Cancellation Forensics with Attribution
Asupersync's cancellation outcome carries a structured attribution record: the cancel kind (user/timeout/fail_fast/race_lost/shutdown), the phase (requested/draining/finalizing/completed), the originating region, task, timestamp, message, and whether the chain was truncated. The result keeps operational context attached to the terminal outcome.
Handle Slot Recycling Under Pressure
Asupersync exposes deterministic slot allocation with LIFO free-list recycling. This exhibit performs 40 create/close cycles in one runtime instance and displays the observed slots, generation increments, and reuse order.
Sibling Scope Isolation
Sibling scopes have distinct handles and obligations. This exhibit creates four siblings with tasks, closes them one at a time, and probes each remaining sibling after every close. A successful probe is direct evidence that the living handle remains valid.
Checking LIFO Slot Reuse
Asupersync's handle allocator uses a deterministic LIFO free-list. This exhibit creates four scopes, frees them in order, then creates four more and compares the observed slots with the exact reverse sequence. The verdict comes from the returned handles, not a prewritten animation.
Unjoined Task Handles at Scope Close
Spawned task handles are recorded as scope obligations. This exhibit intentionally leaves five handles unjoined, closes their parent scope, and probes the old handles afterward. The returned outcomes show whether the scope close invalidated each outstanding lifecycle record.
A Browser Deadline Closing One Scope
In vanilla JavaScript, implementing a timeout for a group of concurrent operations requires
creating an AbortController, a setTimeout,
wiring the signal to every fetch(), handling the
AbortError in every .catch(),
and clearing the timer on success. Here a host setTimeout closes one
Asupersync scope. The deadline still comes from the browser; the scope supplies one ownership boundary
for the three lifecycle handles beneath it.
Scoped Channel Lifecycle
Browser resources need an explicit ownership policy. This exhibit creates a browser
MessageChannel, records each end as a task handle in a WASM scope,
sends messages, then closes both the native ports and their lifecycle scope through one UI action.
Explicit Signals vs Scope-Owned Handles
Here is one three-request deadline written two ways. The left example wires a shared abort signal and timer directly. The right records request handles under one scope and closes that ownership boundary. This is an illustrative comparison of coordination surfaces, not a universal JavaScript benchmark.
Rapid Scope Churn in This Browser
This local sample measures synchronous WASM ABI bookkeeping: one child-scope create plus close per cycle, including handle allocation, generation tracking, and parent registration. It does not measure native task scheduling, I/O throughput, or end-to-end application latency.