The host passes the template's lines to the run (programLines), reports a fetch rejection the program let escape in
phase fetch (by the run's error's kind), and reports a GPU batch's errors at its post's line and column (the frame
request that carried it). scripts/report-check.ts checks the six cases' reports in headless Chromium.
LiveOptions::program_lines (startLive's programLines) declares the template's lines (Runtime::program_lines), so an
error raised in the preludes is at the template's nearest line. A fetch rejection is a located error with its kind,
and uncaught it is the run's error of that kind (CapabilityDenied, ...), raw or rethrown by widget.fetch. A GPU batch's
post carries its line and column (`at`) for the client's errors in it, and an invalid draw fails at its post
(Error::Draw has a line and column). Tests: the five cases natively, on the real preludes.
The prelude rethrows a fetch rejection that has a kind (the same { kind, message }) instead of a copy, so a host's
location and kind for it stay. widgets-rs takes psychoscript 0.1.2 and psychoscript-mobile 0.2.0 (program_lines,
fetch kinds, GPU errors at their post).
No git dependency on PsychoScript; wgpu-hal stays patched to its vendored Metal fix, now at PsychoScript dev 2ef493f (a
published crate can't carry it).
psychoscript now comes from PsychoScript's git rev (patched, as the other crates use it): without the remap the
module carried this machine's checkout paths in its panic messages.
The batch format, canvas size, limits, host checks and the generic errors and device loss rules moved to
anomalyco/psychoscript rust/crates/psychoscript-gpu/README.md; widgets-gpu.md keeps the program side, the widget
messages, the wgsl shorthand and conformance. The mobile clients are widget-mobile (packages/widgets-rs) on
psychoscript-mobile and psychoscript-gpu.
packages/widgets-rs/README.md: the crates, how PsychoScript's crates are pinned and bumped, the toolchain and the
commands. widget-mobile/README.md replaces the copied psychoscript-mobile README: what the crate adds (the widget
encoder's behaviour, ShaderCanvas, OpenCode widgets on this API with widgetEncoder()), its build outputs and its tests;
psychoscript-mobile's README covers the rest.
uniffi-bindgen-swift names a crate's Swift file after its module_name: with psychoscript-mobile's name it overwrote
PsychoScript.swift. WidgetMobile.swift is compiled into the same `PsychoScript` target (its helpers are fileprivate).
A Rust workspace for the widget hosts' native code, on PsychoScript's crates by git rev (psychoscript-gpu and
psychoscript-mobile aren't on crates.io yet; psychoscript patched to the same rev, and wgpu-hal to its vendored Metal
fix).
- widget-wire: the binary wire format, from psychoscript's mobile branch; GPU batches are psychoscript-gpu's `Arg`
and `Batch`, and the `wgsl` shorthand moved here with it. Its tests read packages/widget/test/fixtures in place:
all 58 wire fixtures and draw.json.
- widget-mobile: the one native library each app ships, psychoscript-mobile's UniFFI API plus the widget encoder
(`widgetEncoder()`, on psychoscript-mobile's LiveGpu) and `ShaderCanvas`; built by psychoscript-mobile's
build-ios.sh and build-android.sh. Its widget and GPU tests moved here, on packages/widget's preludes and fixtures
in place (the 58 wire and 53 GPU fixtures).
packages/widgets-rs/web: PsychoScript's web/ (web branch e16ce7e), the TypeScript host that runs widgets in Web
Workers on widget-web's WebAssembly, as package widget-web.
The module is widget_web_bg.wasm (was psychoscript_web_bg.wasm): scripts/build-wasm.sh builds crate widget-web in the
workspace one level up, with the opencode checkout's root remapped to /opencode, and the worker, the host's default
module URL, build.ts and the package's exports follow. dist/ is no longer committed (it holds the ~10 MB module):
bash scripts/build-wasm.sh && bun run build makes it. The scripts read the fixtures and preludes in place from
packages/widget, and fixtures.ts takes it by default. The bundle is otherwise byte for byte the web branch's.
A new Rust workspace, packages/widgets-rs, with crates/widget-web: psychoscript-web from PsychoScript's web branch
(e16ce7e), renamed (lib widget_web), on psychoscript 0.1 from crates.io instead of a path to a patched copy.
psychoscript 0.1 always has typed arrays, so the two Runtime::typed_arrays(true) calls go, and the test that a plain
run has none now says every run has them. Otherwise the code is as it was.
The tests read the fixtures (packages/widget/test/fixtures) and the preludes (packages/widget/src) in place instead of
copies. The views they compare byte for byte, the copies' <name>.wire files (JSON.stringify(view)), are now written
from each fixture's view in the test, the same bytes for all 46.
Without capture the wheel scrolls the page or transcript and is never delivered; under capture it
is { kind: "wheel", dx, dy }, where captured moves go, summed per frame. The Wheel type and the
wheel wire fixture lose x and y; the prelude is unchanged.
widgets-input.md specifies { kind: "wheel", x, y, dx, dy } in logical pixels (lines 40 px, pages
the canvas's size), summed per frame, delivered as move is, and { kind, dx, dy } under capture.
The prelude passes it to onPointer and leaves widget.pointer alone. Two wire fixtures (wheel,
wheel-captured) take the TypeScript host's outcome, as protocol 1's prelude doesn't know the event;
four fixtures' prelude line numbers move by 5.
Outside dev mode client errors are neither logged nor shown, as before. The reason is captured when
a canvas becomes unavailable or stops, never per frame, batch or call, so nothing on a hot path pays
for it with dev mode off.
Every client error and GPU-unavailable state has a reason; clients log it, and in dev mode show
it under the canvas placeholder or as a dev line on the widget. Outside dev mode nothing more
shows.
The step timeout, the live slice and the draw budget count CPU time, so a loaded machine no
longer stops an idle widget as a program error; a 10x wall-clock backstop remains for a program
stuck in a synchronous host call. The web worker and the TypeScript host stay on wall clock, and
say why.
A loss is a strike only if the run's GPU work finished on a device since its previous strike (or
its start): a recovery that discards each new device's first work lost Rune's device four times
and stopped an innocent widget. LiveWidget.loseDevice takes { inFlight, finished }; fixture loss
inputs carry finished; hang-one-reset-several-losses shows three losses in one reset stop nothing.
Item (b) quotes both (checked 2026-11-23): sharing needs accepted terms of use, and agent-made
widgets, as AI-generated content, need in-app reporting too.
widgets-store-policy.md quotes the Apple App Review Guidelines, Google Play's Device and Network
Abuse and REQUEST_INSTALL_PACKAGES policies and Android developer verification (checked
2026-11-23): what already complies, the to-do list of cross-host features (network consent,
report and block, an index with universal links, an age gate, the 4.7.2 statement, what never to
add, no generated per-widget apps) and the open questions for Apple. widgets.md links it.
widgets-gpu.md drops the 30 ms aborted-work and 250 ms-at-loss rules, keeps the 250 ms unfinished
rule, and adds strikes: a device loss while a run has GPU work in flight is a strike, and two 30 s
apart or less stop every GPU canvas of the run ('the GPU work hung; the canvas is stopped').
LiveWidget.loseDevice takes inFlight and applies it; fixture loss inputs carry inFlight, and two
new fixtures show a stop and a loss with no work in flight being no strike.
Its 20,000 generated ops aren't recorded: "batches": "from-source" tells drivers to run the
source for them, as they run raw programs. The GPU fixtures go from 668,839 to 147,200 bytes.
As separate WebGPU calls would: resources made, writes and submits before it take effect; an
encoder or pass still open at op i is dropped. The host checks' handle state already does this;
error-keeps-the-ops-before-it shows a later batch using a handle the failed batch made.
macOS aborts heavy work about 50 ms in, before any time threshold, and blames other queues; hosts
that can tell (Metal, through a host hook) count an aborted submit that ran 30 ms as a hang. Every
hang stop says 'the GPU work hung; the canvas is stopped'.
The watchdog (~0.5 s) blames the app's queue and the killed work looks finished, so the at-loss
rule never fired. A submit unfinished 250 ms after it stops its canvases: 'the GPU work took over
250 ms; the canvas is stopped'. The at-loss rule stays, as a safety net.
The macOS watchdog kills hung work at about 0.5 s, before the 1 s rule, so each loss restarted the
heavy widget. At a loss, the oldest unfinished submit that had run at least 250 ms counts as a GPU
hang; no loss reason needed.
GPU work (a live batch or a wgsl shader frame) still unfinished 1 s after its submit stops every
canvas it draws into: a client error 'the GPU work took over 1 s; the canvas is stopped', ahead of
the 50 ms shader rule. A device loss after it doesn't restart those canvases.
Tests that don't prove the 250 ms step timeout or the 50 ms live slice run with limits no test
comes near (test/limits.ts); those that prove them set them. The post-rate test waits until all
30 renders are posted (a send marks it) instead of assuming the loop ends within a few turns.
20 full runs under load, all green.
widgets.md: a host never submits a shader frame while the previous one draws; one still
unfinished 50 ms after its submit three frames in a row stops on its last frame, a client error
'the shader took over 50 ms a frame, three frames in a row'.
Drag to look and hold still to walk, beside WASD and mouse-look; it starts facing the open
corridor. widgets-input.md says touch never grants pointer capture: touches stay absolute drags.
error-nan-rows-per-image (writeTexture rowsPerImage NaN) and error-infinite-depth-clear-value
(depthClearValue Infinity) fail where null would pass. Recorded batches write a number JSON can't
hold as { "$num": "NaN" | "Infinity" | "-Infinity" }, only there.
gpu.ts reads a batch's ops as native and web hosts do: an undefined list item is null, an undefined
member absent (copying only what changes). widgets-gpu.md says so in Transport and Host checks, and
defines a run restored from a snapshot as a device loss that keeps the greatest handle and the
stopped canvases. Two new raw GPU fixtures.
raw-bytes-not-an-array-buffer posts valid ops into scene with a Uint8Array for bytes (stops
["scene"]); raw-ops-not-a-list posts a string for ops (stops all). Raw fixtures of the wrong shape
keep their batches, with bytes null when they aren't an ArrayBuffer and ops as posted.
A copy from or into a canvas's texture, a write into it or a binding of a view of it fails
'<path> uses canvas "<key>"'s texture, which can only be rendered into' on every host, so the
web (RENDER_ATTACHMENT alone) and native hosts agree. configure's usage is ignored: the program's
canvas texture has usage RENDER_ATTACHMENT. Four new GPU fixtures.
batches now has each bare frame request in its place as { frame: true, ops: [], bytes: "" }, so a
driver replaying them ends each frame, and resets the per-frame counts, where the program did.
Only frame-counts-reset-at-a-bare-frame gains an entry.
widgets-gpu.md: a pass renders into a canvas through its resolveTarget too; a batch from before
the program learned of a device loss is dropped quietly; canvases are clamped to 4096 with their
aspect ratio kept; per-frame counts reset at every frame request; a canvas is cleared once per
frame; batch-shape checks may come from the host's conversion; a canvas an error stopped stays
stopped for the run and a new device doesn't restart it; validation messages are the GPU
implementation's own.
gpu.ts and LiveWidget follow, with five new GPU fixtures and a test for stopped canvases.
located() throws psychoscript's Host.error of the thrown error's class and message: the same
located, real-class errors as before, without psychoscript/effect.
The widget packages pin psychoscript to rust b30b1c2, where typed arrays are opt-in; steps, draws,
live runs and compiles turn them on, and widgets.md lists the globals. The GPU and wire fixtures
regenerate unchanged; without the opt-in the GPU ones fail.
prelude-live.js holds widget (with widget.gpu) and __widget_live; a step widget template's program
is prelude + "\n" + source, a live one's prelude + "\n" + livePrelude + "\n" + source, and
versions hash the program as served. Lint reserves both preludes' names; positions stay
source-relative per mode. Steps compile and run faster than before widget.gpu.
Also lands the widgets-gpu.md changes 0786c7331 described but didn't carry: the live input's gpu,
the flag globals, the normalised op shapes, error ops, which canvases an error stops, Host checks
and Conformance; and widgets-live.md's rule that GPU batches never overtake waiting posts.
The prelude records WebGPU's API (devices, contexts by canvas key, resources, pipelines, bind
groups, command encoders and passes) into batches of ops and bytes with prelude-assigned handles
and every default filled in; batches ride frame requests, or go before other waits and at the
end. device.lost, unavailable GPUs and encoder misuse (error ops) are handled.
The TypeScript host (LiveWidget) passes { available, format } in the live input and checks
batches without a GPU: op shapes, handles and limits, with exact messages; an error stops the
canvases its batch renders into, else all. GPU batches never overtake waiting renders or draws.
widgets-gpu.md gains the normalised op shapes, the host checks and the conformance driver;
test/fixtures/gpu holds 34 fixtures, among them four example widget templates (a lit cube, a
textured quad, post-processing, a first-person maze).
widgets.md (Canvas, Draw command checks) states the rules: lengths before arguments, finite
numbers, alpha and stop offsets clamped to 0..1, text size to 1..512, a negative stroke width 0,
only the spec's weights, aligns and caps, a string text, an optional text style, null object
fields failing, extra elements failing, and the exact messages (draw command <i>: <reason>).
The TypeScript host checks with src/draw.ts instead of its schema and gives normalised commands;
test/fixtures/draw.json holds 89 cases, checked alone, through a draw step and a live draw.
One rule for every host: render and draw posts take tokens from a bucket of 8 refilled at 240 a
second; over it they wait, the latest render and the latest draw per canvas key replacing earlier
ones, and go out as tokens come, or all at once when the run ends (not on a client stop). Frame
requests are idempotent and never counted or dropped, so a 120 Hz game doesn't freeze; submit,
dismiss, capture and GPU batches aren't counted, and the post rate is no longer a program error.
A draw post without a string key is an invalid post; the TypeScript host's by-id draw path is gone.
Widget packages pin psychoscript to rust 7b09bac (limits.maxValueDepth); the TypeScript host runs
steps and live programs at 202, the depth of a 100-level view. Fixtures add 100-level views (one
with the deepest prop) and a 150-level one, and 101 now fails in the host's walk.
__widget_native_step hands a draw's commands to __widget_emit and returns nothing, so hosts skip
the result conversion; they read the commands as JSON would and check them as a draw output, with
the same failures. Tests hold draws of every built-in and edge cases to the last prelude's results.
The prelude keeps only protocol 2: __widget_native_step and the native live path, with handlers
found by path. The tree building, handler table and __widget_step go; tests hold the hosts to the
last prelude that had them (test/fixtures/scripted-prelude.js) and to the closure reference walk.
The spec keeps protocol 1 as history only, and says clients show protocol errors without a retry.