The crate becomes the Rust implementation of the reference's language layer (`src/language/`): its public API is
the Rust form of `Language` (`Runtime::make` with `globals(run)`, modules, limits and translation; `HostFunction`
for `Host.fn` with sync, async and sync-thenable types, idempotent, constructible and takes-functions;
`DurableFunction`; `Namespace`; `Failure` for `Host.fail` and `Host.missing`; `Run` with its metadata; programs,
suspend and resume; snapshots). Code Mode (tools, schemas, the catalog, `search`, OpenAPI, hooks, max tool calls,
extensions) is removed, and the language files move from `src/language/` to `src/`.
Host calls follow the reference's language runtime: arguments cross under the runtime's translation (functions and
promises fail the call unless dropped or awaited), a function from a result crosses back only to a function that
takes functions, async and durable calls start at the next handover, sync work can block (`Returned::Block`) or
stay pending (`Returned::Pending`), and a suspend is refused while a call that can't be detached runs. Namespace
paths carry their root label, and their `keys` may fail. Snapshots save the run's metadata and its calls by global
path, and restart them by resolving that path again.
The replays define the generators' host globals (`conformance/reference.rs` shares `tools` with
`conformance/reference.ts`): the cases, `host.json`, `boundary.json` and `streaming.json`. `tests/host.rs` mirrors
the reference's `test/language.test.ts`; the API tests are ported, and the Code Mode tests are removed.
Programs in frames/core.ts record, with message and location, unsupported syntax that
runs or is never reached (classes, with, debugger, new.target, import.meta, super,
nested exports), the bindings it hides, using declarations, nested imports, names
located inside parentheses, and parse errors in acorn's words; a suspension reaches
unsupported syntax after resuming. New cases record values around it, and the api
test checks the suggestion, which the recordings do not capture. streaming.json is
to be regenerated at integration.
Uncaught failures in conformance/frames/core.ts programs record their message with its location, for each site the
Rust compiler now places where the reference does, and the destructuring and member-write behaviour fixed with them.
Reading then from a namespace gave undefined, so awaiting one could not
mistake it for a thenable and call a tool. The reference reads it as a
path like any other (typeof tools.then is "function") and never takes a
namespace as a thenable. Rust now does both: the read gives the path, and
resolving a promise with a namespace, or crossing one, doesn't look for
then.
Recorded: boundary-namespace-then.
Left over from the boundary sweep, outside its files: tools() fails with
tools is not a function, delete with a number or symbol key on a
namespace fails as reading one does, and a thrown value that holds a
function, a promise, a namespace or a built-in object, at any depth,
fails as Uncaught: a non-data value, as the reference's
containsRuntimeReference has it.
Recorded: boundary-namespace-calls and six uncaught values.
Headers and URLSearchParams methods count their arguments before they check their receiver; Uint8Array.set reads
its offset as a number before its source; Number.prototype methods name themselves ("Number.prototype.toFixed
requires that 'this' be a Number."); Array.with words an index out of range as the reference does. A namespace is
no callable receiver for Function.prototype.call, apply and bind (Rust called the tool), no argument list for apply
(which words any other non-object the reference's way), and no Set-like object for the Set methods.
Object.prototype.toLocaleString refuses a symbol as it refuses null, since neither has a prototype to look in.
Two programs run built-ins that convert a namespace (for nothing, with no conversion of its own) and a promise (its
$vmToPrimitive call, then kept), and String methods and enumeration sources that refuse them, before the loop whose
first locked read shows the fuel they left. streaming.json is left for the integration to regenerate.
Built-ins given a namespace, a promise or a primitive where they need something else now fail with the reference's
words: new Map, Set, WeakMap and WeakSet, Object.groupBy and the other prelude loops over a value with no iterator
fail InvalidData "for...of requires an iterable value, received <a Date>.", naming the value as describeValue does
(also in the for...of statement, which said "an object" for a Date, a RegExp or a URL). Array.from, Iterator.from,
String.raw and new Promise take no namespace, which is no object; Object.isFrozen, isSealed and isExtensible answer
for it as for a primitive; Object(...) and new Number, String and Boolean word their refusals as the reference does,
and String.fromCodePoint words an invalid code point as the reference's host. A combinator's rejection for an input
it cannot iterate points at its call, as the reference's does.
Records cases for these and for the member writes, deletes, in and instanceof of the earlier commit.
The reference's symbols are its host's, described "codemode.iterator" and "codemode.async-iterator". Where its
host's String makes a symbol text (String(s), a template literal, join, the String methods' arguments, an Error
message), it reads "Symbol(codemode.iterator)"; Rust threw "Cannot convert a Symbol value to a string" or wrote
"Symbol(Symbol.iterator)". The host's + still refuses ("Cannot convert a symbol to a string"), ToNumber words its
refusal "Cannot convert a symbol to a number", Object.prototype.toString gives "[object Object]", JSON.stringify
writes a symbol as an object with no fields, as the reference's walk with a replacer already did, and an uncaught
symbol names itself the same way.
A namespace path takes string names only: a number or a symbol key fails "tools paths must use string property
names.", where Rust read undefined or a path named by the number. Object.keys and for...in of a path that names
neither a tool nor a namespace fail with the reference's UnknownTool "Unknown tool namespace '<path>'." instead of
listing nothing.
A computed member write on null or undefined fails as the read the reference resolves it with, and an object key in
that message is made without calling the program ("[object Object]"), as the reference's coerceToString makes it.
Promise.prototype.then, catch and finally name themselves and the receiver they refuse, and new URLSearchParams
words a symbol as the reference does.
Object.keys, values, entries, assign and hasOwn, for...in, object spread and object rest read their source through
the reference's enumerableSource: null and undefined fail "<label> cannot convert null to an object.", a promise
fails InvalidData "<label> received an un-awaited Promise; ..." and a namespace InvalidData "<label> cannot read
tools: it is a namespace of host functions, not plain data. ...", except that Object.keys and for...in list a
namespace's names. Rust gave V8's message, and enumerated a promise or a namespace as empty. Object.assign names the
target it refuses, sets fields on a promise as they are, and a string source reads as its characters (so it owns
length); Object.getPrototypeOf and Object.create word their failures as the reference does.
Destructuring null or undefined no longer quotes the value. A member assignment on null or undefined fails as the
read the reference resolves it with, on a primitive names the value, and a symbol has no properties to read, write or
delete. `in` checks its right side before it converts its key, and fails for a namespace or another opaque operand as
the binary operators do; instanceof is false for a namespace and words its failures as the reference does.
The spread and rest checks run inside one out-of-line call each, as the copy before them did: a second call in those
arms of the run loop cost numeric-loop 1% of its instructions.
The reference's String methods read each argument through requireDataArgument once the receiver and the arguments
converted: one that is still a promise or a namespace fails with InvalidData "String.<name> expects argument <n> to
be a data value.", in the order the method reads its arguments (padStart checks its length before its fill, split
its limit before its separator, replace its pattern before its replacement). Rust read a promise as
"[object Promise]" and threw for a namespace.
A receiver of null or undefined now names the method ("String.prototype.trim called on null or undefined."), and
split tells a missing separator from one that converts to undefined by the argument, as the reference does.
The reference keeps its namespace references outside its objects, so a built-in that converts one reads the text
"[object Object]" (NaN as a number) without a call and without a conversion request of its own; Rust threw
"Cannot convert object to primitive value." for String(tools), [1, 2].join(tools), Math.max(tools) and the like.
Its $vmToPrimitive also keeps a promise as it is, spending only its own unit, so that what reads it can reject it as
an un-awaited value; Rust called the promise's toString and valueOf.
primitive_of now returns both unchanged, number_of and string_of give their text and NaN, and a list of conversions
counts neither as an object to convert. A property key made from either is its text: key_of looped forever on one
before (const { [tools]: a } = {} overflowed the stack).
Found while reading the rebase's recordings; none of these were recorded
before, and the pre-rebase reference behaves the same except where noted.
- Callback sites (array methods, sort, then/catch/finally, replace and
replaceAll, JSON.parse's reviver and JSON.stringify's replacer) admit
what the reference's isSupportedCallback does: not the Promise statics
or Symbol (marked NOT_CALLBACK), nor a namespace reference, each refused
with the site's wording. The hint now says (value) => fn(value), as on
dev.
- Symbol says it isn't callable, and new Symbol() asks for a call.
- Array.prototype methods on a receiver that isn't an array name themselves
and what they got.
- JSON.parse fails with its host runtime's message after the reference's
prefix, from the parser Response.json already used.
- Assigning to a namespace says only data fields may be assigned; a
namespace is described as a namespace reference, and the un-awaited
promise hint names load(...), as on dev.
Recorded: std-callback-admission, std-json-parse-errors and
std-array-receivers.
tools.rs mirrors codemode.test.ts: a tool's arguments leave a function (a
toJSON included) out and await a promise, pending ones too, and a rejection
fails the call before the tool runs. extensions.rs mirrors extensions.test.ts
and language.test.ts: a host function from a result arrives back as itself
wherever it sits, a program function or a global's function is left out, a
promise that never settles waits until the timeout, and a result holding
functions is handed to a tool as its data. The host-args-promise case mirrors
promise.test.ts: a tool's promise inside another call's arguments is awaited.
conformance/frames/hostargs.ts adds streaming programs for what tools, search
and extension functions receive: functions left out at every position,
promises fulfilled, pending and rejected at every position, nested promises, a
promise fulfilling with a function, cycles through promises, built-in objects
and errors in tool arguments with toJSON never called, Uint8Array failures,
when a waiting call starts and the jobs its waits take, search and extension
calls that wait, a function from a host result handed back to an extension
function, and an unknown tool's call rejecting its promise (caught with .catch,
try/await, Promise.allSettled, unawaited), plus suspensions while a call waits.
catalog.ts gains a separate block of boundary programs at the end of its list
for the host values an extension function receives under the same rules.
streaming.json and catalog.json are regenerated at integration.
catalog.ts now records an extensions section: runtimes made from a fixed
library of extensions, runs that pick some of them, constructible globals
called with and without new, an extension's module names loaded through
import, require and import(), and imports that can't be resolved with
their reasons, each with its outcome and what the host functions
received. It mirrors the reference's new tests for per-run extensions,
constructible globals, module names and import errors. tests/extensions.rs
replays it with the same library built in Rust.
The reference now carries dev's changes: tool and search arguments cross
through the host-call path (functions dropped, promises awaited, toJSON
not called), imports that can't resolve say why, namespace references are
no longer called tool references, extension arguments are passed to the
host, and an un-awaited promise's hint names load(...). The suspension
that started tools.wait inside a toJSON in tool arguments is removed: the
reference no longer calls that toJSON, so the wait never starts.
The Rust side follows in the commits after this one.
The deepest level and the error there, with one frame per level (plain,
method, call, apply, generator, async, and built-ins calling the
recursing function back: map, forEach, toString, replace, toJSON,
Array.from, reduce, sort), two frames and three, probed from the
program's top level; exactly the limit succeeding while one more level
fails; and the uncaught RangeError with its location.
for await and an async generator's yield* over a sync generator called
its own throw and return from Rust, through call_counted: the adapter's
frame now calls them, counted as before, and closes a generator without a
throw through its return for nothing, so a search in the generator's
catch or finally parks.
Recorded: search parking in a sync generator's finally and catch under for
await and an async generator's yield*.
The program result's crossing runs in a native frame at the base of the
run, which a search(...) inside a toJSON there now parks with a fresh
coroutine, as a promise job's frame does.
Recorded: search parking inside a toJSON in tool arguments, in search
input and in the program's result.
The walk that crosses tool arguments, search input and the program's result to the host now calls each toJSON from a native frame it pushes, as bytecode calls it, so a toJSON can park for search(...), suspend and be saved in a snapshot. A search's walk runs in its frame and parks it with the search's frames when it awaits. The fast path makes a Date's or URL's JSON itself instead of calling the prototype's toJSON, as the reference does.
An async generator runs from native code, so its frame is a run's base: a
search(...) inside it, or in what its yield* or for await calls, now parks
the generator's frame and those above it with a fresh coroutine, the VM
going back to the resumer's stack as the generator's await does, and the
generator taking the resumer's stack again when they are restored.
Recorded: search parking under yield* over the program's iterator, in a
delegated generator's return() and throw(), in for await over a
generator, and in async generators.