Rule 11.11
On this page

Rule 11.11

Chapter 11, Targets and the oracle Test

The program runtime, typeshade/runtime, loads a manifest (Rule 11.10) and runs its entries on WebGPU, on the host’s device or on one it requests with the features and the limits the programs need and the limits createRuntime({ limits }) names (change 0051), and reports the device’s limits as rt.limits, or on WebGL2, on the host’s context or on one it makes, in the order createRuntime({ prefer }) gives and reports as rt.tier (change 0054); on WebGL2 it runs a compute entry as the pass program the manifest carries (gl.computes) and never builds one, refuses an entry with none with a TypeError that gives the reason, and draws with the vertex and fragment programs the manifest carries (gl.vertices, gl.draws), keeping WebGPU’s conventions: a texture’s row 0 is the top row a pass draws, a fragment’s position and a stored depth are WebGPU’s, and a pass into the canvas is turned over onto the screen, and each WebGL2 pass sets its viewport, depth range and blend constant at its start and gives the host’s back at its end; it refuses with a TypeError what the tier does not support yet (a multisampled, layered or 3D texture, a storage texture in a draw (a compute entry’s storage texture runs as its pass program, Rule 10.5 and Rule 11.8), targets that blend or mask apart, a depth range other than 0 to 1 under a fragment that writes frag_depth, a depth bias on a format other than depth24plus, depth32float and depth24plus-stencil8, a non-zero depth-bias clamp when the context lacks EXT_polygon_offset_clamp, a texture bound from the depth attachment of the pass that draws), a fallback for each of these being later work (OD-11), and what only WebGPU has, with no fallback meant (a GPUCommandEncoder, a pass’s GPURenderPassEncoder); its module closure must hold no file of src/compiler/ and no package, and its bundle must stay within the size budget scripts/bundle-budget.json records. createDevice({ runtime }) (Rule 11.8, change 0071) opens an owner of the kernel calls over a program runtime: the owner’s calls run on the runtime’s device, a Buffer the owner made is a buffer of that runtime’s draws and dispatches, and the runtime’s lifetime stays the host’s, which device.dispose() leaves as it is; a WebGL2 runtime is refused, as configure({ runtime }) refuses it. The load-time emitter, repack from typeshade/emit, emits a manifest again from the portable IR it carries, under the options the manifest records (emit), with a variant the build did not write (console), and must refuse a manifest with no IR and an IR another package version wrote, naming both versions; its module closure must hold no file of src/compiler/ and no package, within its own budget; the runtime takes it as createRuntime({ emit }) and never imports it, so load(m, { console: true }) of a manifest with no recorded variant records through it, and is refused, naming the remedy, without it. load(m, { console: true }) first selects an existing console or variants.console without an emitter or IR. The default records only when console is present; console: false disables either form. Selecting a variant does not mutate the manifest. Device-limit derivation includes an available console variant, and the selected pipeline uses that variant’s bindings. Stripped or historical manifests without either variant retain the explicit emitter-and-IR path and its capability-specific refusal (change 0085). The runtime includes the synchronous fuse recorder (change 0085). device.fuse() requires no registration import; fuse from typeshade/fuse remains supported for default-owner scopes. The heavy executor loads through a cached import of one fixed package-owned path after the plan reserves its queue position. Bundlers may emit local chunks or one file. The entry and every emitted asset must contain no front end, external package, eval, Function call or new Function. A deferred import must name an included local JavaScript asset literally; remote, missing and computed imports are refused. CI measures the single-file bundle, the split entry, shared and deferred chunks, initial download and aggregate gzip bytes against scripts/bundle-budget.json. Browser and worker journeys verify strict CSP and local asset delivery, including a missing executor. The package root and typeshade/runtime still export no named fuse. It builds each pipeline’s layout from the manifest, the bindings the pipeline’s entries reach each visible to the stages that reach them and each texture laid out by the sample type the manifest gives it, and never layout: 'auto'; it makes each shader module from the text the manifest holds and binds the bindings the manifest lists, the _fp64 guard among them where it lists one, so a program packed under emit options (Rule 11.10) runs as it was packed; it binds by the names the source declares, packing a plain host value (Rule 8.21) by the binding’s layout, and refuses an unknown name, a missing binding and a value of the wrong shape with a TypeError naming the entry, its line and the binding; its load, compute, render, draw and dispatch carry the bindings a typed manifest gives each entry, so tsc refuses the same mistakes and an unknown entry name at the argument, and an untyped manifest takes any bindings (change 0030); it creates each pipeline with the override values the host gives it by name, the same to every stage, one pipeline for each set of values, and refuses with a TypeError a name the manifest does not declare, naming the program’s overrides, and a value its type cannot hold, naming the override and what its type takes; when it creates a compute pipeline, it resolves and exposes workgroupShape from the entry’s defaults and the selected override values, and checks positive dimensions against the active device’s per-axis and total-invocation limits; before it creates a compute or render pipeline it refuses one whose entries need more of a limit than rt.limits reports, with a TypeError that names the entry, its line, the limit and both numbers (change 0051, R4); its dispatch and draw refuse, with a RangeError that names the limit, a binding whose buffer the device cannot bind or make (R5) and a dispatch with more workgroups in one dimension than the device dispatches (R6), before they take the console buffer; WebGL2 accepts only the declared default shape for an override-sized workgroup and refuses a different selection with a clear TypeError; the CPU oracle can dispatch with the same override values and workgroup array length; it refuses a manifest of another schema, a feature the device lacks, and a colour target whose format cannot hold the entry’s output there; it reads a texture back as bytes (every uncompressed colour format and depth32float, rows tightly packed) or as numbers (a float, unorm or snorm format and depth32float; an integer format is refused with a TypeError that names read()), recording and submitting the copy before the read awaits anything, so that a read reads what was submitted before the call; a frame that repeats its shapes creates no GPU object; and the console.* calls of a program loaded to record reach the host’s sink or its console after the submit that ran them, and that submit resolves to what each console buffer it read back held (its entry, the lines it kept and the calls that did not fit), where a runtime given a sink prints nothing, the warning for the calls that did not fit included, since its host takes the count.

Imported compute-entry calls (Rule 8.24, change 0084) share the program runtime’s override validation and normalized cache keys. Their CPU specializations use generated closures and data, without shipping the compiler or evaluating generated source at run time. Unknown names and invalid values are checked when the call is made, before GPU work is submitted. A bare queued call retains its error on the Buffers it writes, and an invalid call in a scope throws from the body before that scope runs.

buildInfo and TypeShadeBuildInfo (change 0083), exported from the root and runtime entry points, report the package version and nullable exact source revision. The frozen object agrees with internal VERSION. A successful build records its source revision and emitted-tree fingerprint. Packaging stamps that clean revision only when the source and artifact still match the receipt; modified, unknown or unstamped sources report revision: null. Browser imports perform no Git operation and read no package metadata. Pack.compiler remains the producing compiler’s version, independent of the runtime build. Runtime.info uses the same DeviceInfo format as Device.info (Rule 11.8), from the actual device or context, and stays readable after destruction or loss. The runtime boundary and budget remain mandatory.

The rule text and the parts under it are the compiler's own English, as the design document writes them.

Rationale

a host that develops dynamically needs a runtime, and an application must not ship the compiler to have one: the front end is 1.4 MB gzipped with TypeScript, the runtime’s single-file, initial split and aggregate sizes are measured separately in CHANGELOG.md; a boundary a bundler infers from one sideEffects line is not a boundary, so the check reads the imports.

Derives from

changes 0025 (section 2), 0028, 0030, 0051 and 0054 (decision 2) in changes/; issues #335 (decision 1), #404, #407, #408 and #414; Rule 11.10.

How it is verified

Checked by a test. A test, a gate script or a CI workflow names this rule, and the traceability check fails when a file listed below stops naming it.

Where the rule says the compiler enforces it:

createRuntime and RuntimeImpl in src/runtime/runtime.ts, ProgramImpl in src/runtime/program.ts, src/runtime/resources.ts, the limits a device is requested with in src/runtime/limits.ts, and the WebGL2 tier GlRuntimeImpl in src/runtime/gl.ts and its draws in src/runtime/gl-draw.ts, over the programs buildManifest packs (src/core/manifest.ts); the binding types by src/compiler/ts/typed-bindings.test.ts, which type-checks host files against a generated view (a draw and a dispatch in each form a binding takes, a misspelled binding, a missing binding and field, a vec3 for a vec4, an unknown entry name, and an untyped manifest); the boundary of each of the three subpaths, typeshade/runtime, typeshade/emit and typeshade/fuse, by scripts/bundle-boundary.ts, in CI’s typecheck + unit job; pinned by src/runtime/runtime.test.ts against a recording device and a stand-in adapter (the limits a device is requested with, each refusal of them, and the derivation of a program’s limits in src/runtime/limits.test.ts, held to the layouts the runtime makes for the examples and for a program that records in src/runtime/limits-layout.test.ts; creation per frame, layouts, a texture’s sample type in its layout, each refusal’s text, the override values each stage is created with and the pipeline cache’s key on them, the shader module and layout a manifest packed under emit options gives and the variant a load-time emitter adds under the options the manifest records, the console’s events and the counts a submit resolves to, what a runtime given a sink prints and what one that prints does, a draw, a Buffer both layers bind uploaded once, one device for both layers, a Texture as a call’s image, the bytes a texture’s read() copies and the numbers its readFloats() decodes for every format WebGPU has, and the order the queue runs a read and a frame in; on WebGL2, the tier it takes from its device and the order prefer gives, each refusal’s text, the overrides a pipeline pins in its pass program, and each vertex and fragment entry’s program in the manifest), and on WebGPU by the compile gate’s program tier (scripts/entry-calls-page.ts), which dispatches every compute entry of the examples from its module’s manifest and holds each written value to the call’s, and draws the render case’s frames on WebGPU, on WebGL2 and into a WebGL2 canvas, each colour and depth held to its picture; and by the user journeys’ harness (journeys/_harness.mjs), which runs every journey’s compute and render run on WebGPU through typeshade/runtime as the packed tarball ships it, and each compute and render run that does not record again on its WebGL2 tier, held to the same reference, imported in the page with no bundler, its console lines and the counts submit() resolves to, the dropped count included, each held to the lines the sink was handed, and a run’s override values set by name on its pipeline (journeys/overrides/), each result held to the CPU oracle’s run of the module with the values as the overrides’ defaults; and by a program that loads an r32float level beside two textures a sampler reads (journeys/textures/), whose layouts WebGPU accepts; and by values above 1 and below 0 drawn into an rgba16float target and read back with readFloats() while a later frame is submitted (journeys/hdr-target/), whose numbers are held to the half floats the target stores; and by programs that compute in emulated doubles, packed at the defaults and under each level, parens and flavor (journeys/emit-options/), whose WGSL and bindings WebGPU accepts and whose results are held to plain JavaScript’s doubles; and by the engine journey (journeys/engine/), a host engine on the runtime’s public exports alone, two materials that share a camera and lights, a shadow pass, a render to texture and 60 frames, which the harness refuses on any other import or any WebGPU call of its own, and whose frames after the first make no GPU object, its last frame held to a reference computed in plain JavaScript.

The files that verify it at commit af54ddad5, each at the first line that names the rule:

Explained in

The sections of the surface document that explain this rule, at commit af54ddad5:

See also

Source

The rule at commit af54ddad5:

Edit this page Report a problem