Commit graph

131 commits

Author SHA1 Message Date
Sebastian Herrlinger
c01c31121e feat(codemode): keep unpaired surrogates in namespace paths, error names, RegExp sources, bindings, metadata and durable data 2026-11-19 03:11:19 +01:00
Sebastian Herrlinger
7bddc79372 feat(codemode): keep unpaired surrogates in diagnostics and host failures 2026-11-19 03:02:33 +01:00
Sebastian Herrlinger
9257f8889f feat(codemode): keep unpaired surrogates in the result and the logs (Data, HostString) 2026-11-19 02:53:56 +01:00
Sebastian Herrlinger
6cfcfcf628 feat(codemode): cross strings to the host losslessly, unpaired surrogates included (HostString) 2026-11-19 02:41:41 +01:00
Sebastian Herrlinger
4c7e4da0d7 fix(codemode): give each read of a namespace path a new reference, as the reference does 2026-11-19 02:41:40 +01:00
Sebastian Herrlinger
d7829cc4d9 chore(codemode): format the streaming generator and its array frames 2026-11-19 02:24:27 +01:00
Sebastian Herrlinger
7df0f9074e test(codemode): keep another platform's cases in the current format, and fail when they need a run there 2026-11-19 02:24:27 +01:00
kommander
0a8fd7250b test(codemode): regenerate the Linux-only libm cases through the language runtime 2026-11-19 01:22:22 +00:00
Sebastian Herrlinger
8943a0a540 test(codemode): bound the streaming busy loops by wall-clock time, so a resumed run leaves them at once 2026-11-19 02:17:01 +01:00
Sebastian Herrlinger
52b73e3e03 test(codemode): say what a resume the state can't make records in the streaming recording 2026-11-19 01:55:19 +01:00
Sebastian Herrlinger
6d7e96a399 refactor(codemode): make the Rust crate the language layer only
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.
2026-11-19 01:54:11 +01:00
Sebastian Herrlinger
88ff918816 test(codemode): record namespace paths without comparing their identity 2026-11-19 01:53:46 +01:00
Sebastian Herrlinger
0c91fc1516 chore(codemode): format the language-layer generators 2026-11-19 01:53:46 +01:00
Sebastian Herrlinger
5c11644089 test(codemode): record the boundary and configuration from the language runtime, drop the catalog and OpenAPI recordings 2026-11-19 01:53:46 +01:00
Sebastian Herrlinger
5d0ac6c8b2 test(codemode): record host-function behaviour from the language layer instead of tool calls 2026-11-19 01:53:46 +01:00
Sebastian Herrlinger
5208cfd308 test(codemode): record streaming and crossings through the reference's language runtime 2026-11-19 01:53:45 +01:00
Sebastian Herrlinger
1d250bc759 test(codemode): record the conformance cases through the reference's language runtime 2026-11-19 01:53:45 +01:00
Sebastian Herrlinger
e072d3c69c test(codemode): regenerate the streaming recording with unsupported syntax at run time 2026-11-19 00:29:56 +01:00
Sebastian Herrlinger
3cf39e761d test(codemode): record unsupported syntax at run time and acorn's parse errors from the reference
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.
2026-11-19 00:28:20 +01:00
Sebastian Herrlinger
fcc9ebcd46 test(codemode): record unknown-tool suggestions and regenerate the streaming recording 2026-11-18 23:55:55 +01:00
Sebastian Herrlinger
790c34e5f6 test(codemode): record destructured promises, error locations and checked member writes from the reference
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.
2026-11-18 23:50:22 +01:00
Sebastian Herrlinger
93abe8d1e5 fix(codemode): let then name a namespace path, and never take a namespace as a thenable
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.
2026-11-18 23:50:22 +01:00
Sebastian Herrlinger
a0ab788627 fix(codemode): refuse calling the namespace itself and hide an uncaught value that isn't data
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.
2026-11-18 23:11:59 +01:00
Sebastian Herrlinger
505a33d1e6 test(codemode): regenerate the streaming recording with the boundary fuel programs 2026-11-18 23:05:18 +01:00
Sebastian Herrlinger
9e87d3b91a fix(codemode): check prototype method receivers and arguments in the reference's order
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.
2026-11-18 23:05:06 +01:00
Sebastian Herrlinger
9a6b18d046 test(codemode): record the fuel of namespace and promise conversions in busy loops
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.
2026-11-18 23:05:06 +01:00
Sebastian Herrlinger
9f4fca2982 fix(codemode): refuse built-in inputs as the reference does
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.
2026-11-18 23:05:06 +01:00
Sebastian Herrlinger
f2eb1ac29f fix(codemode): word the two symbols as the reference's host does
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.
2026-11-18 23:05:06 +01:00
Sebastian Herrlinger
1bfc8f666d fix(codemode): read namespace paths and nullish bases as the reference does
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.
2026-11-18 23:05:06 +01:00
Sebastian Herrlinger
84d9ab3f47 fix(codemode): take enumeration sources and property bases 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.
2026-11-18 23:00:42 +01:00
Sebastian Herrlinger
a56513f977 fix(codemode): reject String method arguments that are still not data
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.
2026-11-18 23:00:42 +01:00
Sebastian Herrlinger
a31e7f534d fix(codemode): convert a namespace or a promise without calling its methods
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).
2026-11-18 23:00:42 +01:00
Sebastian Herrlinger
eea63a8980 test(codemode): regenerate the recordings with dev's extension and host-call cases 2026-11-18 21:55:08 +01:00
Sebastian Herrlinger
b97c413f60 fix(codemode): match the reference's callback rules and messages in built-ins
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.
2026-11-18 21:55:08 +01:00
Sebastian Herrlinger
e941709ea3 test(codemode): mirror the reference's host-call argument tests
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.
2026-11-18 21:29:00 +01:00
Sebastian Herrlinger
71a99f6d7e test(codemode): record host-call argument cases from the reference
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.
2026-11-18 21:29:00 +01:00
Sebastian Herrlinger
beda44806f test(codemode): record extension configuration from the reference
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.
2026-11-18 21:10:49 +01:00
Sebastian Herrlinger
462f1b82c8 test(codemode): regenerate the recordings from the rebased reference
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.
2026-11-18 20:50:32 +01:00
Sebastian Herrlinger
ff703af7d0 test(codemode): keep one busy-loop fuel case per cost rule 2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
1361c6f9a1 chore(codemode): write conformance recordings one entry per line 2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
d507a5971a test(codemode): record the call depth limit and its RangeError
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.
2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
7c7c332639 test(codemode): record conversions with no primitive to give 2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
b9037a236c feat(codemode): convert Object.fromEntries keys and URLSearchParams and Headers pair parts from their frames 2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
77e31369f5 feat(codemode): convert Object.groupBy keys from its frame, each after its callback 2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
e73f2595a0 feat(codemode): resume a sync generator's throw and return from the async adapter's frame
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*.
2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
161cc82bb4 test(codemode): record fuel of abrupt requests through yield* and for await closes 2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
64be1f3c2d feat(codemode): park a search inside the program result's toJSON
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.
2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
4faf34382c feat(codemode): call a crossing's toJSON from a native frame
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.
2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
e077d7a261 feat(codemode): park a search inside an async generator's frame
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.
2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
31a124de02 test(codemode): record yield* and for await over the program's iterators 2026-11-18 18:56:13 +01:00