isoloop
0.1.1GitHub

How Isoloop works

Your app’s host runs on the page’s main thread, and its parts run as isolates in workers. Isolates don’t call each other. They publish records to topics on a message bus, which runs in a worker of its own. A supervisor in the host watches every worker and restarts what fails.

Each step below covers one part, with its code and its diagram. The diagrams are drawn from the library’s code, and a test there checks their states, timings and counts against it.

Steps

The parts at a glance

Four threads: the main thread, an isolate on a worker of its own, a pool of three, and the bus worker. The main thread runs your host code and the kernel it creates: the supervisor, the compositor that applies each isolate’s DOM changes, and the bus controller.

Open full size: Isoloop runtime topology

Reading the diagram: Isoloop runtime topology

Each large box is one thread. Cards inside a box are the pieces that run on that thread. Solid lines carry messages; dashed lines are heartbeats, and the import of an isolate’s module.

What’s in it

Main thread, along the top
Your host app, which calls createKernel, and the kernel it creates. The supervisor, which starts workers and watches their heartbeats. The compositor, which applies isolates’ DOM changes to their surfaces once per animation frame. The bus controller, which hands out bus ports and supervises the bus worker. The host connection, the host’s own port for kernel.subscribe.
Own worker, middle left
One isolate, with its own JavaScript realm and document. Isolate modules, left of it, are the files the worker imports.
Pool worker, middle right
Three isolates on one thread: a headless member and two visual members, each with a root in one shared document.
Bus worker, along the bottom
The broker, which checks grants, schemas and duplicates; the log engine, which encodes and stores records; and the topics’ logs.
Below the bus worker
OPFS segments, the files persistent topics are written to. Only the tab holding the isoloop-bus Web Lock writes them.

Follow the arrows

  1. Isolate code never runs on the main thread. The main thread only runs the kernel and applies patches.
  2. The host app calls spawn. The supervisor starts a worker and sends it init, one per member in a pool, and the worker imports the isolate’s module.
  3. A visual isolate sends patches, its DOM changes, to the compositor, which applies them to the isolate’s surface.
  4. Each isolate has a port of its own to the broker, one per member in a pool. Records never pass through the main thread.
  5. The broker appends what it accepts through the log engine; persistent topics also go to OPFS.
  6. The dashed lines back to the main thread are heartbeats: one per worker to the supervisor, and the bus worker’s beat and metrics to the bus controller.

Diagrams from isoloop/isoloop at 9e030c6

The host and its isolates

The host is your page’s own code. It creates one kernel with createKernel, giving it the topics and the worker files that @isoloop/vite builds, and starts each isolate with kernel.spawn.

Importing a module with ?isolate gives its URL: @isoloop/vite builds it to run in a worker, so src is a URL, not code the host imports. The topics module goes in twice: as a URL, for the bus worker to import, and as a list the host reads.

An isolate is a module whose default export is defineIsolate(…): a start(ctx) function, or a React or Preact component through an adapter. The object passed to spawn is its manifest. It names the module, the element the isolate renders into (its surface) and its grants. An isolate with no surface is headless: it gets the same supervision and bus, and its ctx.root is undefined.

start gets a context: ctx.bus for topics, ctx.root to render into, ctx.host for host calls (measure, focus, scroll, navigate), and ctx.reportError and ctx.onShutdown.

main.ts

import { createKernel } from '@isoloop/host';
import workers from 'virtual:isoloop/workers'; // the worker files @isoloop/vite builds
import list from './topics';
import contractsUrl from './topics?isolate';
import counter from './counter?isolate';

const kernel = createKernel({ contracts: { url: contractsUrl, list }, workers });

kernel.spawn({
  id: 'counter',
  src: counter,
  surface: counterEl, // leave it out for a headless isolate
  grants: { publish: ['count.v1'], subscribe: ['count.v1'] },
});

counter.ts

import { defineIsolate } from '@isoloop/runtime';
import { count } from './topics';

export default defineIsolate<HTMLElement>({
  start(ctx) {
    let n = 0;
    const button = document.createElement('button');
    const show = () => {
      button.textContent = `Count: ${n}`;
    };
    button.addEventListener('click', () => void ctx.bus.publish(count, { value: n + 1 }));
    ctx.bus.subscribe(
      count,
      (r) => {
        n = r.value;
        show();
      },
      { from: 'earliest' },
    );
    show();
    ctx.root?.append(button);
  },
});

Diagrams from isoloop/isoloop at 9e030c6

Workers and pools

Each isolate runs in a worker: a thread of its own, with its own event loop. By default an isolate gets a worker to itself. With pool in its manifest, it shares one worker with every isolate that names the same pool.

A pool saves memory. In the plant dashboard’s matched comparison, a small headless isolate cost about 0.2 MB in a pool, against 2.8 MB on its own worker; in return its members stall and restart together, as the next paragraph says. Measured on a build before 0.1 (@isoloop/*@0.0.0-next.d028bc1) in Chromium, on 4 physical cores fixed at 2.0 GHz, medians of 5 rounds, memory after GC 16 s after load.

Members share an event loop. One that blocks stalls them all, and a worker error restarts them all; an error a member reports as its own restarts only that member (the Restarts step has the details). They also share one document, so they can read each other’s DOM and input, and they can reach each other’s bus ports, so a pool holds all its members’ grants. Pool only isolates you trust together, and keep widgets that handle secrets on their own worker.

The kernel never pools on its own. Placement is the manifest’s choice, or that of the opt-in, experimental @isoloop/balancer, which moves isolates between pools as their load changes.

// No `pool`: a worker of its own.
kernel.spawn({ id: 'a', src: counterUrl, surface: surfaces.a });

// The same `pool`: one worker, one event loop, for both.
kernel.spawn({ id: 'c', src: primesUrl, surface: surfaces.c, pool: 'shared' });
kernel.spawn({ id: 'd', src: messagesUrl, surface: surfaces.d, pool: 'shared' });
Open full size: Placement: own workers against one pool

Reading the diagram: Placement: own workers against one pool

The same three isolates, placed two ways. Each large box is one thread.

What’s in it

Left: own workers
Isolates A and B (visual) and C (headless), each in a worker of its own: three threads.
Right: one pool
The same three as members of the pool charts: one thread, one shared document with a root for each visual member.
Top and bottom
The kernel, where the manifest’s pool decides the placement, and the bus worker.

Follow the arrows

  1. On the left the kernel starts three workers and sends each one init; on the right, one worker and three inits.
  2. Either way the bus sees three ports. Grants, subscriptions and committed offsets stay per isolate, and so do the surface, the frame budget and the restart count.
  3. What the pool members share: one event loop and its timers, the globals, the document, and their fate when the worker fails.

Diagrams from isoloop/isoloop at 9e030c6

Topics, records and the bus

A topic is declared once, in a contracts module that the host, the bus and every isolate import; its default export, contracts(…), is the list the host passes to createKernel. A topic has a name (with its major version, by convention, as in count.v1), a schema (from any Standard Schema library; zod here) and a retention: { kind: 'last-n', n } keeps the last n records, { kind: 'time', ms } the records younger than ms, and { kind: 'compacted' } the latest record per key.

By default a topic lives in the bus worker’s memory. durability: 'persistent' also writes it to disk, so it survives a reload and a bus crash (the Persistence step). A topic with a reply schema also takes requests, which are experimental in 0.1: ctx.bus.request publishes one and waits for the first valid reply, 30 s at most by default.

import { contracts, topic } from '@isoloop/bus';
import { z } from 'zod';

export const count = topic('count.v1', {
  schema: z.number().int().nonnegative(),
  retention: { kind: 'last-n', n: 100 },
});

export default contracts(count);

Each isolate has a direct message channel to the bus worker, so the main thread isn’t on a record’s path.

A publish is checked in order: the publisher’s grants and the record’s size (256 KiB by default), then the topic’s schema, and on a persistent topic a duplicate check. Then it’s appended to the topic’s log and gets an offset, and publish resolves; on a persistent topic, once the record is written to disk. A rejected one rejects with a BusError.

A subscription starts where its from says: latest (the default) for new records only, earliest for everything the topic retains, or committed to read on after its last commit. It gets the topic’s records in offset order. Subscribers that name the same group share the topic: each record goes to one of them, by its key (round-robin when it has none), so each key’s records stay in order.

The bus sends each subscription up to 1,000 records ahead of what it has handled. The subscriber commits each record once its handler settles; the commits go out every 100 ms by default, or sooner once half the credit is used. Delivery is at least once: after a crash, up to one commit interval of records can come again, so a handler must be safe to run twice.

// Resolves once the bus has appended the record; rejects with a BusError.
await ctx.bus.publish(count, { value: 1 });

// Every record the topic retains, then each new one, in order.
const stop = ctx.bus.subscribe(
  count,
  (r) => console.log(`#${String(r.offset)} from ${r.producer}: ${String(r.value)}`),
  { from: 'earliest' },
);

// Shared with every subscriber in the group `totals`: each record goes to one of them.
const share = ctx.bus.subscribe(count, (r) => console.log(r.value), { group: 'totals' });
Open full size: A record through the bus: gates, log, delivery, commits

Reading the diagram: A record through the bus: gates, log, delivery, commits

One record, from left to right, through five columns: Produce, Gate, Order, Log and Consume. Red lines end in a rejection.

What’s in it

Produce
An isolate publishing on its own port, or the host with kernel.publish.
Gate
The grants and the size limit, then the schema. Topics under isoloop. belong to the kernel.
Order
On a persistent topic, the duplicate check: each publish carries its producer, instance and sequence number, so a re-sent one gets its original offset. Anything that fails a gate goes to Rejected, and nothing is appended.
Log
The log engine encodes the record, checks the storage quota and appends it. A persistent topic’s batch is written to OPFS first, then acknowledged; records evicted from memory are read back from disk.
Consume
Subscribers, a consumer group (experimental in 0.1) whose members each get some of the records (by key), and the committed offsets.

Follow the arrows

  1. The publisher sends the record; the gates check it in order.
  2. An accepted record gets an offset in the topic’s log, and the publisher gets its answer: the offset, or the error.
  3. The bus delivers it to each subscription in order, while the subscription has credit. Delivery is at least once.
  4. Each subscriber commits what its handlers finished, every 100 ms by default, which also returns credit.

Diagrams from isoloop/isoloop at 9e030c6

Rendering from a worker

A worker has no DOM. A visual isolate gets a small DOM subset as its document, enough for React, Preact and plain DOM code to run unchanged. The subset records each change (insert, move, remove, text, attribute, listener) and sends the host one batch per microtask.

On the host, the compositor applies each isolate’s batches to its surface, with a budget of 8 ms of DOM work per frame. Every tag, attribute and URL passes the host’s component registry first, so an isolate can’t create a script or an on* handler. The same registry lets isolates render the host’s own design-system elements by name: with components: { 'iso-button': { tag: 'ds-button', attributes: ['variant'] } }, an isolate’s <iso-button> becomes a <ds-button> on the page.

Each surface is a shadow root, so the page’s stylesheets don’t reach it; inherited properties, such as the font, still do. The kernel’s styles are adopted into every surface, and an isolate adds its own with ctx.styles(css). Modals, tooltips and menus that libraries render into document.body go into ctx.portalRoot, inside the isolate’s own surface.

Input on a surface goes back to the worker as data, and is dispatched there with capture and bubble. Functions never cross the boundary. What needs the real page, the isolate asks the host for through host calls: ctx.host.measure, focus and scrollIntoView for a node, requestCanvas, which hands the isolate an OffscreenCanvas to draw on from the worker, as charts do. navigate changes the URL, and needs the navigate grant.

What changes for your code

  • Layout reads are asynchronous: await ctx.host.measure(node) instead of getBoundingClientRect().
  • An isolate can’t call preventDefault in time. The host always prevents submit, and same-origin link clicks go to the router.
  • Only these events reach the worker: click, dblclick, input, change, keydown, keyup, submit, focusin, focusout, pointerdown and pointerup; pointer moves, at most one per frame; and scroll, at most one per frame for each scrolled element. There’s no wheel or drag yet.

The Host step’s counter, as a component:

React

import { defineIsolate, usePublish, useTopic } from '@isoloop/react';
import { count } from './topics';

function Counter() {
  const n = useTopic(count, { from: 'earliest' }) ?? 0;
  const publish = usePublish(count);
  return <button onClick={() => void publish(n + 1)}>Count: {n}</button>;
}

export default defineIsolate(Counter);

Preact

import { defineIsolate, usePublish, useTopic } from '@isoloop/preact';
import { count } from './topics';

function Counter() {
  const n = useTopic(count, { from: 'earliest' }) ?? 0;
  const publish = usePublish(count);
  return <button onClick={() => void publish(n + 1)}>Count: {n}</button>;
}

export default defineIsolate(Counter);
Open full size: Rendering from a worker

Reading the diagram: Rendering from a worker

One visual isolate’s frame. The top row runs left to right, from the isolate’s code to the page; the rows below carry events and host calls back to the worker.

What’s in it

Isolate’s worker
The isolate’s UI code, React, Preact or plain DOM, changes the worker’s document: the isoloop-dom subset. The recorder turns every change in one microtask into one batch. ctx.host and event dispatch live here too.
Compositor
One queue per surface. Each animation frame it applies queued batches round-robin across surfaces while 8 ms of work lasts; the first batch of a frame always applies, and a batch is never split.
Applier + registry
Writes each batch into the surface. Every tag, attribute and URL passes the registry first: unknown tags become div, and no script-capable tag or on* attribute is ever created.
Surface shadow root
The <iso-surface> on the page. The kernel’s styles and the isolate’s ctx.styles are adopted here and don’t leak out.
EventBridge and Router
Delegated listeners on the shadow root. An event goes back only if the isolate listens for it on the target or an ancestor; with routing on, same-origin link clicks go to the router.
Host calls
measure, focus, scrollIntoView and requestCanvas run in the compositor’s frame; navigate goes to the router, and needs the navigate grant.

Follow the arrows

  1. The isolate renders; the subset records the changes, and at the end of the microtask they leave as one patch, with any new stylesheets.
  2. The compositor queues the patch and applies it in the next frame that has budget for it; the applier sanitises and writes it.
  3. A click on the surface reaches the EventBridge, which sends the worker an event naming its target and the listeners on its path. The worker dispatches it with capture and bubble.
  4. ctx.host.measure(node) first sends what the recorder holds. The call runs after every batch sent before it, so it measures their layout. requestCanvas answers with an OffscreenCanvas instead.

Diagrams from isoloop/isoloop at 9e030c6

The supervisor

Every worker sends a heartbeat, by default every 100 ms. The heartbeat is a timer in the worker’s own event loop, so any long task delays it; each beat also reports how late it was (lagMs on isolate:beat), which the balancer reads. With no heartbeat for 400 ms, the worker’s isolates count as blocked: busy, not dead, and a busy overlay covers their surfaces.

With no heartbeat for 10 s, the worker is terminated and its isolates are restarted. The default is long on purpose, so a slow but working loop isn’t killed; apps shorten it with heartbeat.killAfterMs (the landing page’s demo uses 2 s).

An isolate also crashes when its code throws a fatal error, when its worker fails, or when it isn’t ready within 10 s of its spawn. Restarts back off from 250 ms, doubling up to 4 s. After 3 restarts within 60 s, the next crash leaves it failed. A visual isolate then shows its fallback, by default a message and a Retry button, or what the manifest’s fallback draws, and the host gets isolate:failed; kernel.restart brings it back. supervisor: { strategy: 'never' } turns restarts off, for tests and debugging.

A subscription handler that throws isn’t a crash. The isolate keeps running and reports isolate:error, and that subscription stops committing, so its records come back on the next start.

kernel.stop(id) sends shutdown: the isolate’s onShutdown handlers get 1 s, its last commits go out, then its worker goes.

const kernel = createKernel({
  workers,
  heartbeat: { everyMs: 100, blockedAfterMs: 400, killAfterMs: 10_000 },
  supervisor: {
    maxRestarts: 3,
    withinMs: 60_000,
    backoff: { initialMs: 250, factor: 2, maxMs: 4_000 },
  },
});

kernel.on('isolate:state', (e) => console.log(`${e.id}: ${e.prev} → ${e.state}`));
kernel.on('isolate:failed', (e) => console.warn(`${e.id} gave up: ${e.reason}`));
Open full size: Isolate lifecycle under the supervisor

Reading the diagram: Isolate lifecycle under the supervisor

The supervisor’s states for one isolate. The main path runs along the middle; failures branch off it.

What’s in it

The main path
Restarting (a spawn queued, after the backoff), Loading (the worker started and sent init; ready within 10 s), Running (a heartbeat every 100 ms), Stopped (kernel.stop).
Blocked
No heartbeat for 400 ms: the loop is busy but still alive, and a busy overlay covers its surface. A heartbeat brings it back to Running.
Crashed
Passed through on the way to a restart. It emits isolate:crash.
Failed
The restart limit was reached: the fallback shows and the host gets isolate:failed.
Suspended
Opt-in: an idle isolate’s worker is shut down and its offsets are kept. It wakes back into Loading.

Follow the arrows

  1. An isolate crashes from Running on a fatal error or a pool crash, from Blocked after 10 s without a heartbeat, and from Loading on a timeout or a version mismatch.
  2. Under 3 restarts within 60 s it goes back to Restarting, after a backoff that starts at 250 ms and doubles each time (at most 4 s). Past the limit it’s Failed.
  3. Some crashes go straight to Failed, because a restart can’t change them: a render format or version the host doesn’t speak, or a bus that couldn’t load its contracts.

Diagrams from isoloop/isoloop at 9e030c6

Restarts and catch-up

Keep what must survive a restart in a topic: anything else in the isolate’s memory is lost. A restart is a new instance, and it rebuilds its state from the bus. Meanwhile its surface is blank, and it fills again on the new instance’s first paint.

Each subscription starts where its from says, as on the first start. A subscription in a consumer group (experimental in 0.1) that has committed resumes after the group’s commit, whatever its from.

  • latest, the default: live values where only the newest matters, such as a ticker or a status.
  • earliest: state rebuilt from what the topic retains, as the counter does.
  • committed: work done once per record, such as jobs or alerts. It reads on after its last commit, so it sees again what it had read but not yet committed: the at-least-once delivery of the Bus step.
// Only what arrives from now on: live values.
ctx.bus.subscribe(count, (r) => draw(r.value), { from: 'latest' });

// Everything the topic retains, then new records: state rebuilt on every start.
ctx.bus.subscribe(count, (r) => draw(r.value), { from: 'earliest' });

// On after this subscription's last commit: work done once per record.
ctx.bus.subscribe(count, (r) => draw(r.value), { from: 'committed' });

With earliest, every restart replays everything the topic retains, and in a pool every member replays on the pool’s one thread. So the longer a topic’s retention, the longer such a restart takes to catch up, and the pools guide measured it growing over a long run. Keep retention to what a restart needs. The pools guide, with the plant’s figures

On its own worker, a crash restarts that isolate alone. In a pool, what restarts depends on who failed. An error the runtime can pin on one member restarts that member alone: start() throwing, an error the member reports with ctx.reportError, or a render error the React or Preact adapter catches (the adapters report it that way). A block, or a plain throw from an event handler, a timer or a scheduler the members share, is the worker’s error: the worker goes down, and every member restarts in a new one.

Open full size: Own worker: crash → restart → replay

Reading the diagram: Own worker: crash → restart → replay

A sequence: time runs down the page. The columns are isolate C’s old worker, the kernel, the bus worker and C’s new worker.

What’s in it

Crash
C’s old worker reports a fatal error, or fails.
Respawn
After the backoff, a new worker for C.
Replay and first paint
C reads its topics back and draws again.

Follow the arrows

  1. The kernel terminates the old worker and detaches C’s port from the bus. C’s committed offsets are kept: they belong to C, not to its worker.
  2. After the backoff, the kernel attaches a new port for C, then starts the new worker with it.
  3. The new C subscribes with from: 'committed', and the bus delivers from the record after its last commit; up to one commit interval of what C had handled comes back.
  4. C reports ready, sends its first paint and commits again. Every other isolate kept running throughout.
Open full size: Pool: a member restarts alone, or the pool restarts together

Reading the diagram: Pool: a member restarts alone, or the pool restarts together

A sequence in two parts, with time running down the page. The columns are the pool’s worker with members A, B and C, the kernel, the bus worker and a new pool worker.

What’s in it

Top part
A member’s own error: only B restarts.
Bottom part
The worker fails: every member restarts.

Follow the arrows

  1. B reports a fatal error of its own. The kernel shuts B down alone; A and C keep the worker and keep running.
  2. After B’s backoff, the kernel gives B a new bus port and starts it again in the same worker. B subscribes from its own commits.
  3. Later, the worker stops sending heartbeats for 10 s, or fails. Every member crashes with that reason, and the kernel terminates the worker.
  4. The kernel gives all three members new bus ports, starts a new worker and sends each member its init. Each one reads on from its own commits.

Diagrams from isoloop/isoloop at 9e030c6

Persistence and bus crashes

A topic with durability: 'persistent' writes its records to the origin private file system (OPFS), batched every 5 ms or 256 records, so a persistent publish resolves a few milliseconds later than a memory one. After a page reload the new bus loads them from disk, and each subscription starts where its from says: committed reads on after its last commit, earliest from what the topic retains. A memory topic, the default, starts empty after a reload.

Only one tab’s bus owns the files. In a second tab, or where the browser can’t open them (some private windows), persistent topics run in memory and the kernel emits bus:durability_degraded. When the origin’s storage is full, publishes reject with quota_exceeded; the kernel reports usage with bus:quota.

topics.ts

export const alarms = topic('alarms.v1', {
  schema: Alarm,
  retention: { kind: 'last-n', n: 10_000 },
  durability: 'persistent',
});

alarms.ts

// Persistent: after a reload or a bus restart, on after the last commit, from disk.
ctx.bus.subscribe(alarms, (r) => raise(r.value), { from: 'committed' });

// Memory: a bus restart loses it, so clear what was built from it; new records follow.
ctx.bus.subscribe(count, (r) => draw(r.value), { onReset: () => clear() });

When the bus crashes

The bus is supervised like an isolate, with the same heartbeat and restart limit. When it crashes, a new bus worker starts and every running isolate gets a new channel to it. The isolates keep running. What they publish meanwhile waits in each isolate, up to 1,000 unanswered calls, and goes out once the new bus is there.

Persistent topics come back from disk: their subscriptions resume after their last commit, whatever their from, with no gap, and re-sent publishes aren’t stored twice. Memory topics are gone: their subscribers get a reset. useTopic empties and refills, a plain ctx.bus.subscribe gets its onReset callback, and an isolate that can’t handle a reset can ask to be restarted instead, with bus: { onReset: 'restart' } in its manifest.

If the bus crashes twice while loading, a persisted record is the likely cause. The new bus sets the newest segment of each persistent topic aside (renamed, not deleted), starts from the one before, and the kernel emits bus:recovered with what it set aside. After 3 bus restarts within 60 s, the kernel emits bus:failed: isolates keep running, and every publish rejects with bus_unavailable. A contracts module that fails to load fails the bus with a code, and every isolate with it, with no retry.

Open full size: Bus worker crash → restart → reattach

Reading the diagram: Bus worker crash → restart → reattach

A sequence in three parts, with time running down the page. The columns are an isolate, the kernel’s bus controller, the old bus worker, the new one, and OPFS.

What’s in it

The bus fails
The isolates keep running.
New bus, ports moved at once
Each isolate gets a port to the new bus.
Restore and resume
Persistent topics come back from OPFS.

Follow the arrows

  1. An isolate publishes and gets no answer: it keeps the publish. The old bus stops beating or fails, and the kernel terminates it.
  2. The kernel starts a new bus worker and attaches every isolate’s port to it at once; the new bus holds what arrives until it’s ready. Each isolate subscribes again and re-sends its unanswered publishes.
  3. The new bus takes the storage lock (waiting up to 2 s) and restores the persistent topics’ segments. Their subscriptions resume after the last commit; memory topics send a reset instead.
  4. The new bus reports ready, and suspended headless isolates wake. If the bus crashes twice while loading, it sets the newest segment aside and starts from the one before.

Diagrams from isoloop/isoloop at 9e030c6

Grants and safety

Isolates run on your origin, so they share its cookies and storage: an isolate can fetch with the origin’s cookies and read its IndexedDB. Isoloop contains unreliable code (a widget that hangs, throws or leaks), not hostile code. For code you don’t trust at all, use a cross-origin iframe.

Grants
Each isolate lists the topics it may publish and subscribe to. Anything else is rejected with forbidden. Isolates in one pool share a worker and can reach each other’s ports, so treat a pool as holding all its members’ grants.
A sanitised DOM
Every tag and attribute an isolate renders passes the host’s registry first. Unknown tags become div, script-capable tags and on* attributes are never created, and URLs are limited to http(s), mailto and relative ones.
No inline scripts
The workers are same-origin module files, so a page can run Isoloop under script-src 'self'. The host writes the style an isolate renders through the element’s style object, which CSP doesn’t govern, so a page that shows a surface needs only style-src 'self' too.

Grants are checked by the bus, on every publish and subscription. A grant is a topic name or a pattern: * matches one or more characters, dots included, so machine.3.* covers machine.3.temp.v1; without * the match is exact. Topics under isoloop. belong to the kernel. An isolate also needs navigate: true to call ctx.host.navigate; plain link clicks need no grant, since the host’s router handles them.

Events reach the worker with isTrusted: false, so code that checks it must not treat forwarded input as the user’s. A pool freezes the built-ins before its first member loads, so one member can’t patch Array.prototype under the others; its members still share a document and can reach each other’s ports.

kernel.spawn({
  id: 'machine-3',
  src: machineUrl,
  surface,
  grants: {
    publish: ['machine.3.*'], // machine.3.temp.v1, machine.3.alarms.v1, …
    subscribe: ['machine.3.*', 'count.v1'],
    navigate: true, // may call ctx.host.navigate; plain link clicks need no grant
  },
});

Safety, on the features page

Diagrams from isoloop/isoloop at 9e030c6