diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml new file mode 100644 index 00000000..3eab1b3b --- /dev/null +++ b/.github/workflows/bench.yml @@ -0,0 +1,42 @@ +# The representative-task benchmark (bench/README.md): each task is a job a Solid user does with a library of the +# ecosystem — its good program accepted by both checkers, typed by the library's own types and run in Chromium, its +# one-line mistakes refused. The run is compared with bench/scorecard.json: a check that is green there may not turn +# red, and a check that is red is one its task's `known` gives the reason for. +name: bench + +on: + push: + branches: [main] + paths: ["compiler/**", "ref/**", "runtime/**", "tooling/rx-language-server/**", "bench/**", ".github/workflows/bench.yml"] + pull_request: + paths: ["compiler/**", "ref/**", "runtime/**", "tooling/rx-language-server/**", "bench/**", ".github/workflows/bench.yml"] + workflow_dispatch: + +jobs: + bench: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: compiler + - uses: actions/setup-node@v5 + with: + node-version: 24 + - name: The crate (rxc, and the Node-API build Solid's Vite plugin loads) + working-directory: compiler + run: | + npm ci + cargo build --release + npx napi build --platform --release --features node --manifest-path ./Cargo.toml -- --lib + - name: The runtime + run: npm --prefix runtime ci && npm --prefix runtime run build + - name: The language server's packages (rx-tsc) + run: npm --prefix tooling/rx-language-server ci + - name: The libraries, and Chromium + run: | + mkdir -p bench/.out/ws && cp bench/package.json bench/.out/ws/package.json + (cd bench/.out/ws && npm install --no-audit --no-fund --legacy-peer-deps && npx playwright install --with-deps chromium) + - name: The benchmark, against bench/scorecard.json + run: node bench/run.mjs --check --strict diff --git a/.github/workflows/editor.yml b/.github/workflows/editor.yml index 10042da9..2caa5db2 100644 --- a/.github/workflows/editor.yml +++ b/.github/workflows/editor.yml @@ -13,9 +13,9 @@ name: editor on: push: branches: [main] - paths: ["compiler/**", "tooling/**", ".github/workflows/editor.yml"] + paths: ["compiler/**", "tooling/**", "runtime/**", "ref/compile/rt-*.ts", ".github/workflows/editor.yml"] pull_request: - paths: ["compiler/**", "tooling/**", ".github/workflows/editor.yml"] + paths: ["compiler/**", "tooling/**", "runtime/**", "ref/compile/rt-*.ts", ".github/workflows/editor.yml"] workflow_dispatch: jobs: @@ -41,6 +41,8 @@ jobs: cargo build --lib --release --target wasm32-unknown-unknown --manifest-path compiler/Cargo.toml - name: Solid next (the types the tests check against) run: sh ref/scripts/solid-next.sh && npm --prefix ref install + - name: The runtime (test/tsc.js checks an entry against its types) + run: npm --prefix runtime ci && npm --prefix runtime run build - name: Language server tests working-directory: tooling/rx-language-server run: | diff --git a/.github/workflows/suites.yml b/.github/workflows/suites.yml new file mode 100644 index 00000000..22b15e75 --- /dev/null +++ b/.github/workflows/suites.yml @@ -0,0 +1,109 @@ +# The suites CONTRIBUTING.md lists ("Running the suite"), on every change to what they read: the crate's own tests, the +# reference implementation's (ref/: the interpreter over every scenario, the same scenarios lowered onto Solid, the +# compiled modules, streamed SSR and hydration in Chromium, the TSX projection), the crate against ref/ in each of its +# modes (CP-5: checked, client-only, whole-program, lowered, projected), and the three suites that run a guarantee +# rather than a list of cases (compiler/test/confined.mjs, drafts.mjs, ssr-held.mjs). +# +# ref/ runs on Solid built from source at ref/SOLID_NEXT (ref/scripts/solid-next.sh: pnpm, and a Rust build of Solid's +# native compiler). That build is kept in a cache keyed by the pin, so it is made once per pin and restored after. +name: suites + +on: + push: + branches: [main] + paths: ["compiler/**", "ref/**", "runtime/**", "scenarios/**", "examples/**", "bench/**", ".github/workflows/suites.yml"] + pull_request: + paths: ["compiler/**", "ref/**", "runtime/**", "scenarios/**", "examples/**", "bench/**", ".github/workflows/suites.yml"] + workflow_dispatch: + +jobs: + # the crate's own tests (compiler/src's units, compiler/tests/) + cargo: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: compiler + key: test + - name: cargo test + working-directory: compiler + run: cargo test --release + + # ref/'s runners, and the crate against ref/ + ref: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: compiler + - uses: pnpm/action-setup@v4 + with: + version: 11.1.1 # solid-next's packageManager + - uses: actions/setup-node@v5 + with: + node-version: 24 + - name: Solid next, from the cache + id: solid + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/../solid-next + key: solid-next-${{ runner.os }}-${{ hashFiles('ref/SOLID_NEXT', 'ref/scripts/solid-next.sh') }} + - name: Solid next, built at the pin + if: steps.solid.outputs.cache-hit != 'true' + run: sh ref/scripts/solid-next.sh + - name: ref/ (links ../solid-next), and Chromium + run: | + npm --prefix ref install + (cd ref && npx playwright install --with-deps chromium) + - name: The crate (rxc, and the Node-API build) + working-directory: compiler + run: | + npm ci + cargo build --release + npx napi build --platform --release --features node --manifest-path ./Cargo.toml -- --lib + - name: The runtime + run: npm --prefix runtime ci && npm --prefix runtime run build + - name: "ref: the interpreter over every scenario" + working-directory: ref + run: npm test + - name: "ref: the scenarios lowered onto Solid (the oracle)" + working-directory: ref + run: npm run oracle + - name: "ref: compiled modules" + working-directory: ref + run: npm run compiled + - name: "ref: streamed SSR and hydration in Chromium" + working-directory: ref + run: npm run ssr + - name: "ref: the TSX projection, checked by TypeScript" + working-directory: ref + run: npm run types + - name: "crate against ref/: checked" + working-directory: ref + run: npm run crate + - name: "crate against ref/: client-only (--spa)" + working-directory: ref + run: npm run crate -- --spa + - name: "crate against ref/: the whole program (--whole-program)" + working-directory: ref + run: npm run crate -- --whole-program + - name: "crate against ref/: lowered (--lower)" + working-directory: ref + run: npm run crate -- --lower + - name: "crate against ref/: projected (--project)" + working-directory: ref + run: npm run crate -- --project + - name: "the guarantees, run: drafts (MO-10i) and held results (MO-10f) on the server" + run: | + node compiler/test/drafts.mjs + node compiler/test/ssr-held.mjs + - name: The libraries confined.mjs runs against (bench/package.json) + run: | + mkdir -p bench/.out/ws && cp bench/package.json bench/.out/ws/package.json + (cd bench/.out/ws && npm install --no-audit --no-fund --legacy-peer-deps) + - name: "the guarantees, run: the counterexamples and their controls, in Chromium (CN-7)" + run: node compiler/test/confined.mjs diff --git a/.github/workflows/tree-sitter.yml b/.github/workflows/tree-sitter.yml new file mode 100644 index 00000000..373fc5a2 --- /dev/null +++ b/.github/workflows/tree-sitter.yml @@ -0,0 +1,38 @@ +# The tree-sitter grammar (tooling/tree-sitter-rx): src/ is generated but committed, since Zed compiles src/parser.c +# as it is, so check it is what grammar.js generates; then the corpus, and every tracked .rx file with no ERROR or +# MISSING node. +name: tree-sitter + +on: + push: + branches: [main] + paths: ["tooling/tree-sitter-rx/**", "**/*.rx", ".github/workflows/tree-sitter.yml"] + pull_request: + paths: ["tooling/tree-sitter-rx/**", "**/*.rx", ".github/workflows/tree-sitter.yml"] + workflow_dispatch: + +jobs: + grammar: + runs-on: ubuntu-latest + defaults: + run: + working-directory: tooling/tree-sitter-rx + steps: + - uses: actions/checkout@v5 + - uses: pnpm/action-setup@v4 + with: + version: 11.1.1 # as editor.yml + - uses: actions/setup-node@v5 + with: + node-version: 22 + - run: pnpm install --frozen-lockfile + - name: src/ is what grammar.js generates + run: | + pnpm run generate + git diff --exit-code -- src/ + - name: Corpus + run: pnpm test + - name: Every tracked .rx file + run: pnpm run parse:repo + - name: Queries + run: pnpm run query -- ../../examples/*.rx > /dev/null diff --git a/CHANGELOG.md b/CHANGELOG.md index 72ea93c6..1103d1b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ ## Unreleased +**Changed** + +- Values the checker confines have a closed set of operations (spec/09 MO-10k, spec/08 CN-7d). A JS result whose + fields wait or fail is read by the fields its declaration names: `q.valueOf()`, `q.toJSON()`, an undeclared field and + `q[k]()` are `RESULT_AS_VALUE`. What is called on a library's draft is a method of plain data; a callback given to one + (`d.items.forEach((row) => { … })`) has parameters that are places of the draft, an iterator read out of one is kept + as an iterator over copies, and any other method is `DRAFT_ESCAPES`. A method keeps nothing of a `renders` value only + when `methods(…)` names it and it is called on the value's own name. A call through a record, an array or a call + (`box.read()`, `fs[0]()`, `mk()()`) reads what the closures it may call read (`SNAPSHOT_KEPT`, `SNAPSHOT_ARGUMENT`). +- The loop `for (const x of xs) { … }` visits what `xs` held when it started, as the spec said; it compiled to a loop + over `xs` itself, which a turn could lengthen. +- A record result with no accessor part is the library's own object, not a copy with a getter per declared field. +- A declared fn whose result hands out drafts (`createStore`) is a primitive: its setter is io. +- `catch` follows only an `await`: `await f(x) catch (e) => alt` makes a matching rejection the answer. A `catch` after + anything else is the new compile error `CATCH_NOT_ON_AWAIT` (R-f-4). Show a failed value with an `errored` region + where it is read; in a handler or action, read it inside `try { … } catch (e) { … }`; write validation as a value + (`""` or a message), not a thrown class. + **Fixed** - `affects` on a keyed or structured source that takes a guess threw `INVALID_AFFECTS_TARGET` in a dev build, so the @@ -11,6 +29,38 @@ row, so a row's readers re-run only when its own leaves change (#51). - The guide's action example (`guide/async.md` §3) lost an error thrown before the first `await`: the `onFlush` clear ran after the catch. The catch now writes the error through `onFlush` as well (#52). +- A `catch` expression read with no observer (a component `fn` called from a handler or an action) built a fresh error + boundary, which had no value while a `refresh` was out, so the click threw `NotReadyError` and was lost. It is now a + snapshot: the committed value, or the alternative on a matching failure (R-8, S-catch-snapshot). + +**New** + +- `bench/`: a representative-task benchmark over the Solid ecosystem's libraries (Formisch, TanStack Query, Router, + Start and Table, Kobalte, Solid's store). Each task is a good program (accepted by both checkers, typed by the + library's types, run in Chromium) and one-line mistakes that must be refused. `node bench/run.mjs`; CI holds the + scorecard. +- A whole query result can be passed to a component whose prop's type keeps the fields' rows: + `props: { query: { data: pending fails(Error) T; status: string } }` (MO-10f). +- A component that gives a prop on to a provider that renders it (``) renders + it in turn: a router can be wrapped in the app's own frame, in any module (MO-11o). +- A store updater can have a name: `bump = (d) => { d.done := d.done + 1 }`, then `setTodos(bump)` (MO-10i). +- A part of a `renders` value that its declaration types as a primitive (`getPageCount: () => number`, a row's `id`) + is passed to a child or a callback as it is, with its type (MO-11l). +- `MUTATION_IN_PLACE` (W-1a): `rows.push(x)`, `props.items.sort()` and the like on the value of a source, an equation, + a prop or a row. +- `DISPOSER_DROPPED` (EF-5a): a declared JS call whose result is `() => void`, dropped. +- `DUPLICATE_KEY` (ST-4d): two rows of a keyed list written with one key. +- A handler attribute given a call of something io (`onClick={save()}`) is refused (SC-4); a method declared to answer + nothing is io where the view computes (MO-10b). +- A component a JS host renders (`?rx-lib`) is checked under a root of its own in a whole-program build (CP-4d). +- Advice: `rxc check` lists `advice` beside its diagnostics, never an error. `ASYNC_WATERFALL`: a question awaited + after another whose answer it does not read. + +- `ARGUMENT_COUNT` (AC-1f): a call of an action declared in the module with another number of arguments than its + parameters is refused. +- `props` in a component declared without props (`component C()`) is `UNBOUND` (RG-4b); it read `undefined`. +- `guide/async.md`: "One store over the server"; the `GUESS_WHILE_LOADING` advice says what holds when a selection + changes while a guess is out (05 DV-22). ## 0.3.1 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cb9ab9f1..cac8b3fe 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -23,17 +23,34 @@ spec diverges from Solid, the divergence is recorded as a `DV-n` in ## Running the suite -Solid is built from its `next` branch at the pinned commit (needs pnpm and a -Rust toolchain): +Solid is built from its `main` branch at the pinned commit (needs Node 22+, +pnpm, a Rust toolchain and the network). `scripts/setup.sh` does every step +from a fresh clone: Solid beside this repository (`../solid-next`), `ref/`'s +links to it, the crate (its Node-API binding, `rxc` and the WebAssembly build the language server reads), the runtime, the +language server, and Playwright's Chromium for the browser suites. ```sh -sh ref/scripts/solid-next.sh # checks out and builds ../solid-next -cd ref && npm install +sh scripts/setup.sh # or, for ref/ alone: sh ref/scripts/solid-next.sh && (cd ref && npm install) +cd ref npm test # interpreter over every scenario npm run oracle # the same scenarios lowered onto Solid npm run compiled # compiled modules npm run ssr # streamed SSR + hydration in Chromium npm run types # TSX projection checked by TypeScript +npm run crate # the Rust crate against ref/ (also --spa, --whole-program, --lower, --project) +``` + +The crate, the plugin, the runtime and the tooling, from the repository's root: + +```sh +(cd compiler && cargo test --release) +for t in vite kobalte formisch ssr-router start vite-types vite-gate ssr-held drafts confined; do node compiler/test/$t.mjs; done +# with a Solid plugin that has context.resolve and Frontend.buildStart (compiler/README.md): +for t in vite-hosts vite-watch; do SOLID_VITE_PLUGIN= node compiler/test/$t.mjs; done +(cd tooling/tree-sitter-rx && pnpm install && pnpm run generate && pnpm test && pnpm run parse:repo) # a new form in .rx or .d.rx needs its grammar +(cd runtime && node test.mjs) +(cd tooling/rx-language-server && npm test) +node bench/run.mjs --check # the representative tasks (bench/README.md): real libraries, good programs and one-line mistakes ``` `ref/README.md` describes each runner. Please run the suite before opening a diff --git a/README.md b/README.md index f593c7b8..1621ffa0 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,15 @@ them things the compiler refuses, the way Rust refuses a borrow, so the program that runs is one where those mistakes cannot happen ([spec/08](spec/08-constraints.md), [spec/99](spec/99-diagnostics.md)). -The checks are static only. A `.rx` program compiles to ordinary Solid 2.0 -code and adds nothing at run time beyond what Solid does -([spec/11](spec/11-compiler.md)). +The checks are static: none of them becomes a run-time check. A `.rx` +program compiles to ordinary Solid 2.0 code over a small runtime of Solid's +own primitives ([spec/11](spec/11-compiler.md)). In three places a rule is +kept by construction instead of by refusal, and there the compiled code does +a little more than hand-written Solid would: a value read out of a library's +draft is a copy, a JS result with an accessor among its parts is read +through a getter per part, and a loop runs over the values its list held +when it started ([spec/09](spec/09-modules.md) MO-10i, MO-10b; +[spec/07](spec/07-surface.md) §5). It is also meant to be easy for an AI to write correctly. The rules are small and explicit, and each checker error names the rule it enforces and usually the fix. We @@ -82,7 +88,7 @@ export default component Profile() { Leave out the `errored` boundary and it does not compile: ``` -profile.rx:10: error UNHANDLED_FAILURE [R-f-5] a reader of user.name (in ) can fail with Error and no catch or errored boundary above it discharges Error — wrap it in `errored fallback(e) { … } { … }`, or catch it: `… catch (e) => …` +profile.rx:10: error UNHANDLED_FAILURE [R-f-5] a reader of user.name (in ) can fail with Error and no catch or errored boundary above it discharges Error — show it where it is read: `errored fallback(e) { … } { … }` around the reader (or `await … catch (e) => …` at the await, to make the rejection an answer) ``` Beyond this the language has structured stores with per-path writes @@ -177,7 +183,7 @@ node --experimental-strip-types ref/check.ts examples/todo.rx # check a progra node --experimental-strip-types ref/run.ts # run every scenario ``` -Running the scenarios on Solid itself needs Solid's `next` branch built from +Running the scenarios on Solid itself needs Solid's `main` branch built from source (pnpm and a Rust toolchain); see [CONTRIBUTING.md](CONTRIBUTING.md) and [`ref/README.md`](ref/README.md). The compiler builds with Cargo ([`compiler/README.md`](compiler/README.md)). To try an unreleased editor build, install a `.vsix` from a run of the diff --git a/bench/.gitignore b/bench/.gitignore new file mode 100644 index 00000000..4efeb1bf --- /dev/null +++ b/bench/.gitignore @@ -0,0 +1 @@ +.out/ diff --git a/bench/README.md b/bench/README.md new file mode 100644 index 00000000..55ec9cd0 --- /dev/null +++ b/bench/README.md @@ -0,0 +1,116 @@ +# bench — the representative-task benchmark + +ReactiveScript's goal is to be the best way to use the whole Solid ecosystem +while making wrong Solid code difficult to write. The scenarios and the unit +tests check rules one at a time; this suite checks the goal: a list of jobs a +Solid user does with the ecosystem's libraries, each written the way that +user would write it, and for each job the mistakes they would make. + +```sh +node bench/run.mjs # the scorecard +node bench/run.mjs table query # some tasks +node bench/run.mjs --check # compared with bench/scorecard.json: a green check may not turn red (CI) +node bench/run.mjs --check --strict # and every failure is one its task's `known` gives a reason for +node bench/run.mjs --write # write bench/scorecard.json and bench/scorecard.txt from this run +``` + +It needs the crate (`cargo build --release` and `npm run build` in +`compiler/`), the runtime (`npm run build` in `runtime/`), the language +server's packages (`npm ci` in `tooling/rx-language-server`), Node 22.6 or +later, and the network once: `bench/package.json` is installed into +`bench/.out/ws`, with this repository's compiler, runtime and language server +linked in as an app would install them (a task with a `package.json` of its +own beside its `task.mjs` has an install of its own, for a library that pins +another version: TanStack Start pins its router). `scripts/setup.sh` builds all but the +last. + +## What a task is + +A folder under `tasks/`: `src/` is the app, `task.mjs` says how it is judged. + +- **The good program** (`src/`) is a realistic job: the libraries are the + ones npm has (Solid 2.0, Formisch, TanStack Query, Router, Start and Table, + Kobalte), imported by their own names, declared in `rx-types/` as a project + declares a package that ships no `.d.rx` (09 MO-8k), and typed by the + library's own TypeScript types. +- **The bad variants** are that program with one line changed into a mistake + a Solid user makes: a read with no boundary, a value frozen where it should + follow, a write while the view computes, a value that escapes where the + library checked it. + +and five columns score it, with two numbers beside them: + +| column | green when | +| --- | --- | +| **good accepted** | the crate and `ref/` both accept the program, and agree | +| **types kept** | `rx-tsc` is clean with the library's own types; the `.rx` writes no `any`; and each *type probe* — a mistake only the library's real type can refuse (a field path the schema has not, a link to no route) — is refused by TypeScript **on the line the probe wrote** (an error elsewhere is not the type refusing the edit). A probe that passes means the type was lost on the way | +| **runtime ok** | the compiled program does the job: rendered on the server and/or driven in Chromium on Solid's development build, with no console error or warning | +| **unrepresentable** | the variants the language has no way to write: refused by the parser, by name resolution or by TypeScript alone (`PARSE`, `ASSIGNMENT`, `UNBOUND`, `UNKNOWN_COMPONENT`, a JS habit's code, a `ts` variant). They show that a mistake cannot be spelled, not that a check of the program's meaning caught it, so they are counted apart from the next column | +| **bad caught** | each variant is refused by both checkers, with the diagnostic named, by a diagnostic the good program does not have. Where only the run can know (a duplicate key computed at run time, a `pure` JS function that answers differently on the server), the variant must compile and then fail loudly in development (`dev`); where the language makes the mistake harmless instead of refusing it (a draft's row kept by a callback is a copy), the variant may compile and must then behave (`orSafe`); advice that never fails a build is `advise` | + +| number | what it counts (lower is better) | +| --- | --- | +| **hand-written `.d.rx` words** | for every `.d.rx` of the task, the words a person wrote on top of what `rx-declare` drafts for the same module (run by the suite, with the flags the task's `declare` names: `--run --dom` where the draft was made by running the package). A row the draft has word for word costs nothing, a row it has otherwise costs the words that differ, a row it has not costs every word; rows left out cost nothing. It is what an app pays to use the library | +| **`any` in `.d.rx`** | the `any`s those files hold: what the checker is told nothing about | + +`--check` holds both numbers too: a task's declarations may not need more hand-written words, nor hold more `any`s, +than `scorecard.json` records. + +What is not in the suite: probes written to find the edge of a rule rather than a mistake a user makes (an +inherited `valueOf()`, a draft's iterator kept, a callback kept in a record, `[f][0]()`). They were here once and +are now `compiler/test/confined.mjs`'s, which runs each with its controls. + +Nothing in a task names a rule of the checker: the programs come from the +libraries' documentation and from what goes wrong in Solid apps, and the +expected diagnostics are the ones the language already has for the mistake +(or the one its spec says it should have). A fix to the compiler follows from +a rule in `spec/`, never from a task. + +## The tasks + +| task | the job | the mistakes | +| --- | --- | --- | +| `formisch-field-path` | a Formisch form whose fields are named by typed paths into a valibot schema | a schema that reads state, a form made in the view; *(unrepresentable)* a write while the view computes, state assigned with `=` | +| `formisch-field-array` | a Formisch array field: rows inserted, removed and moved by the library's methods | a method called while the view computes or given to a button called, the form made in the view, the row ids changed in place | +| `query-forward` | a TanStack Query result passed down: its data to a list, a flag to a badge, the whole result to a panel; a refetch; a failing query | `data` read under no boundary, the result in a record, to a child that takes it for plain data | +| `query-mutation` | a TanStack Query mutation that invalidates its query; the cache sent from the server and taken up in the browser (dehydrate / hydrate) | a query key that lacks what the query's function reads, the mutation run or the cache invalidated while the view computes, a hook outside the provider | +| `router-provider` | TanStack Router's provider inside the app's own `Shell` component, in a module of its own | a page that fails with no boundary at the outlet, a hook outside the provider, a router never rendered | +| `router-data` | `@solidjs/router` 2.0's data layer: a `query()` a page reads, a form action, `useSubmissions`, `revalidate` (2.0 has no `createAsync` nor `useSubmission`: a query is read by an equation that awaits it) | an async read with no boundary, `revalidate` called while the view computes, a submission's input or a query's answer kept in state | +| `start-route` | a TanStack Start file route rendering `.rx` components, served and hydrated at `/people/2?tab=role` | the page's data with no boundary, a param copied into state; *(unrepresentable)* state written while a page renders | +| `store-updater` | a Solid store updater written once and used by two handlers; a snapshot read out of the draft | the store written outside its setter, the updater called by hand, an `await` in the updater, a closure that writes the draft later | +| `store-helper` | a Solid store's draft changed in place by a helper written in JS (`moveItem(d.columns, from, to)`) | the helper given the store itself, called while the view computes, the draft kept by a closure | +| `table-pagination` | a TanStack Table: cell components, pagination buttons, a pager given page numbers and handlers, and — shadcn/ui's `DataTablePagination` — a component given the table itself | a row handed up through a callback, the table kept in state, a cell's context missing, a page turned while the view computes | +| `kobalte-dialog` | a controlled Kobalte dialog | a part outside its root, a write while the view computes, a stale read of an own write; *(unrepresentable)* a part the kit has not, a write to derived state | +| `kobalte-select` | a Kobalte Select whose options are objects, each rendered by an `.rx` component | an item outside the select, the options sorted in place, a write while the view computes | +| `primitives-virtual` | solid-primitives' listeners and resize observer and a TanStack Virtual list, on an element ref | a listener's disposer dropped (its type an alias), a primitive made in a handler; *(unrepresentable)* the ref read before there is an element | +| `frozen-read` | formatters kept in a record, read by the view, by a primitive and by a seed | a formatter read under a kept `peek`, given to a value parameter, used as a seed | +| `source-mutation` | a list in a source, added to by a write and sorted for display | `rows.push(…)`, a prop sorted in place, a row written through a local alias, the value a functional write is given reversed in place | +| `keyed-edits` | a keyed list edited every way: insert, remove, move, rename in place, reset | rows written out with one key in a handler, rows keyed by their index, a row written through the loop's name | +| `listener-cleanup` | a JS listener whose disposer the mount effect returns | the disposer dropped: in the effect, in a handler, in a local never used | +| `duplicate-keys` | a keyed list whose rows keep their state across a reorder | two literal rows with one key; a row added at run time with a key the list has | +| `effect-derived` | a total that is an equation, a history the clicks write, an effect for what leaves the program | the total kept in a source by an effect (with and without inputs), a history appended by an effect, a mount effect that reads what it never hears of again | +| `projection-selection` | a selection as a projection (`draft(…)`, Solid's `createProjection`): picking a row tells two rows | the selection kept in a store by an effect, the projection written from a handler | +| `optimistic-todo` | an optimistic add: a guess, the server asked, the list asked again, a refusal taken back | a guess where nothing is awaited, an `await` before the guess, the answer written to, a failure let out | +| `context-provider` | a context of the app's own, a provider component holding the state, readers under it | a reader beside or above the provider, the provided state written or changed in place, the provided action called while the view computes | +| `sequential-awaits` | an action whose second load needs the first's answer, the independent one asked beside them (asserted: two calls in flight at once) | two independent loads awaited one after the other (advice) | +| `ssr-divergence` | a value only the browser knows, asked as a client question | the question read with nothing to hold it, client JS called for its value, a `pure` JS call that answers differently on each side | + +Two libraries have no Solid 2 build yet, and each has a small adapter in its task, as `@tanstack/solid-table` and +`@tanstack/solid-virtual` are for Solid 1: `table-pagination/src/table.js` over `@tanstack/table-core`, and +`primitives-virtual/src/virtual.js` over `@tanstack/virtual-core`. + +## What the suite decided + +`scorecard.txt` lists every check that is not green, each with the reason its task's `known` gives: the rule of +`spec/` that makes it one. `spec/rfc-revisions-2026-11-22.md` lists what each task changed in the language. + +## The scorecard + +`scorecard.txt` is the last run committed, and `scorecard.json` the same as data (what `--check` compares with). +Three earlier runs are kept beside it: + +- `baseline-d6e640e.txt`: the run at the commit this suite was first written against, before any of the work it drove; +- `scorecard-2f9baf7.txt`: thirteen tasks, as the suite stood when it was reviewed (four columns; its bad variants + held probes and unwritable programs); +- `baseline-rebased.txt`: the suite as it is now — the probes moved out, the unwritable variants counted apart, the + declarations measured, eleven tasks added — run on the checker of `2f9baf7`, before any change to it. diff --git a/bench/baseline-d6e640e.txt b/bench/baseline-d6e640e.txt new file mode 100644 index 00000000..2c13e564 --- /dev/null +++ b/bench/baseline-d6e640e.txt @@ -0,0 +1,66 @@ +task good accepted types kept runtime ok bad caught +--------------------------------------------------------------------------------- +duplicate-keys 3/3 ✓ 3/3 ✓ 3/3 ✓ 0/2 ✗ +formisch-field-path 3/3 ✓ 6/6 ✓ 4/4 ✓ 4/4 ✓ +frozen-read 3/3 ✓ 3/3 ✓ 3/3 ✓ 1/5 ✗ +kobalte-dialog 3/3 ✓ 4/4 ✓ 5/5 ✓ 5/5 ✓ +listener-cleanup 3/3 ✓ 3/3 ✓ 4/4 ✓ 1/4 ✗ +query-forward 1/3 ✗ 1/5 ✗ 0/1 ✗ 3/6 ✗ +router-provider 1/3 ✗ 4/5 ✗ 0/1 ✗ 3/6 ✗ +sequential-awaits 3/3 ✓ 3/3 ✓ 2/2 ✓ 2/3 ✗ +source-mutation 3/3 ✓ 3/3 ✓ 3/3 ✓ 1/4 ✗ +ssr-divergence 3/3 ✓ 3/3 ✓ 3/3 ✓ 2/3 ✗ +start-route 3/3 ✓ 5/5 ✓ 8/8 ✓ 2/3 ✗ +store-updater 1/3 ✗ 4/5 ✗ 0/1 ✗ 3/7 ✗ +table-pagination 1/3 ✗ 6/7 ✗ 0/1 ✗ 4/7 ✗ +--------------------------------------------------------------------------------- +total 31/39 48/55 35/39 31/59 + +Not green (47): + ✗ duplicate-keys · bad caught · two rows written with one key (DUPLICATE_KEY) — crate: accepted / ref: accepted + ✗ duplicate-keys · bad caught · rows added with a key the list already has (known only when it runs) (dev: duplicate key|DUPLICATE_KEY) — ran silently + ✗ frozen-read · bad caught · the formatter read under a kept peek: the view shows the first value for ever (SNAPSHOT_KEPT) — crate: accepted / ref: accepted + ✗ frozen-read · bad caught · a kept peek of it in an equation (SNAPSHOT_KEPT) — crate: accepted / ref: accepted + ✗ frozen-read · bad caught · the formatter's value given to a value parameter: the primitive is made from the first value (SNAPSHOT_ARGUMENT) — crate: accepted / ref: accepted + ✗ frozen-read · bad caught · the same through an array of formatters (SNAPSHOT_ARGUMENT) — crate: accepted / ref: accepted + ✗ listener-cleanup · bad caught · the disposer dropped in the mount effect (DISPOSER_DROPPED) — crate: accepted / ref: accepted + ✗ listener-cleanup · bad caught · the disposer dropped in a click handler: a listener added per click (DISPOSER_DROPPED) — crate: accepted / ref: accepted + ✗ listener-cleanup · bad caught · the disposer kept in a local, and never called nor returned (DISPOSER_DROPPED) — crate: accepted / ref: accepted + ✗ query-forward · good accepted · main.rx: accepted by the crate — RESULT_AS_VALUE@21: todos is a JS result whose fields hold or fail where each is read (todos.data), so it is read a field at a time: it is not passed, stored, returned, spread or s + ✗ query-forward · good accepted · main.rx: accepted by ref/ — RESULT_AS_VALUE@21: todos is a JS result whose fields hold or fail where each is read (todos.data), so it is read a field at a time: it is not passed, stored, returned, spread or s + ✗ query-forward · types kept · rx-tsc: clean with the library's types — main.rx(13,49): error TS1005: ';' expected. main.rx(13,62): error TS1005: ';' expected. main.rx(13,66): error TS1005: ',' expected. main.rx(13,68): error TS1005: ',' expected. main.rx(13,85): error TS1005: ',' expected. main.rx(13,87): error TS1138: Parameter declaration expected. main.rx:21:3 - error RESULT_AS_VALUE: todos is a JS result whose fields hold or fail where each is read (todos.data), so it is read a fiel + ✗ query-forward · types kept · a row of the query's data is the fetcher's Todo: a field it has not is refused (TS2551|TS2339) — main.rx(13,49): error TS1005: ';' expected. main.rx(13,62): error TS1005: ';' expected. main.rx(13,66): error TS1005: ',' expected. main.rx(13,68): error TS1005: ',' expected. main.rx(13,85): error TS1005: ',' expected. main.rx(13,87): error TS1138: Parameter declaration expected. main.rx:21:3 - error RESULT_AS_VALUE: todos is a JS result whose fields hold or fail where each is read (todos.data), so it is read a fiel + ✗ query-forward · types kept · the result's own fields are the library's: `isFetching` is a boolean (TS2339) — main.rx(13,49): error TS1005: ';' expected. main.rx(13,62): error TS1005: ';' expected. main.rx(13,66): error TS1005: ',' expected. main.rx(13,68): error TS1005: ',' expected. main.rx(13,85): error TS1005: ',' expected. main.rx(13,87): error TS1138: Parameter declaration expected. main.rx:21:3 - error RESULT_AS_VALUE: todos is a JS result whose fields hold or fail where each is read (todos.data), so it is read a fiel + ✗ query-forward · types kept · the options are the library's: a queryKey must be an array (TS2322|TS2769|TS2345) — main.rx(13,49): error TS1005: ';' expected. main.rx(13,62): error TS1005: ';' expected. main.rx(13,66): error TS1005: ',' expected. main.rx(13,68): error TS1005: ',' expected. main.rx(13,85): error TS1005: ',' expected. main.rx(13,87): error TS1138: Parameter declaration expected. main.rx:21:3 - error RESULT_AS_VALUE: todos is a JS result whose fields hold or fail where each is read (todos.data), so it is read a fiel + ✗ query-forward · runtime ok · the good program runs — not compiled: the checker refused it + ✗ query-forward · bad caught · the result handed on by an inherited method: `todos.valueOf()` is the result itself (RESULT_AS_VALUE) — crate: accepted / ref: accepted + ✗ query-forward · bad caught · the result stored in a record (RESULT_AS_VALUE) — crate: RESULT_AS_VALUE@21: todos is a JS result whose fields hold or fail where each is read (todos.data), so it is read a field at a time: it is not passed, stored, returned, spread or s / ref: RESULT_AS_VALUE@21: todos is a JS result whose fields hold or fail where each is read (todos.data), so it is read a field at a time: it is not passed, stored, returned, spread or s + ✗ query-forward · bad caught · the whole result given to a child whose interface does not say `data` waits and fails (RESULT_AS_VALUE) — crate: RESULT_AS_VALUE@21: todos is a JS result whose fields hold or fail where each is read (todos.data), so it is read a field at a time: it is not passed, stored, returned, spread or s / ref: RESULT_AS_VALUE@21: todos is a JS result whose fields hold or fail where each is read (todos.data), so it is read a field at a time: it is not passed, stored, returned, spread or s + ✗ router-provider · good accepted · main.rx: accepted by the crate — RENDERS_ESCAPES@6: renders what its router carries, and props is a prop, which whatever applies the component may give: the components it carries cannot be named | COMPONENT_AS_VALUE@22: component Root is carried by createRootRoute(…), but nothing renders it: pass what carries it to a JS component's prop declared `renders` (MO-11o) | COMPONENT_AS_VALUE@23: component Home is carried by createRoute(…), + ✗ router-provider · good accepted · main.rx: accepted by ref/ — RENDERS_ESCAPES@6: renders what its router carries, and props is a prop, which whatever applies the component may give: the components it carries cannot be named | COMPONENT_AS_VALUE@22: component Root is carried by createRootRoute(…), but nothing renders it: pass what carries it to a JS component's prop declared `renders` (MO-11o) | COMPONENT_AS_VALUE@23: component Home is carried by createRoute(…), + ✗ router-provider · types kept · rx-tsc: clean with the library's types — main.rx:22:1 - error COMPONENT_AS_VALUE: component Root is carried by createRootRoute(…), but nothing renders it: pass what carries it to a JS component's prop declared `renders` (MO-11o) (RG-4a) main.rx:23:1 - error COMPONENT_AS_VALUE: component Home is carried by createRoute(…), but nothing renders it: pass what carries it to a JS component's prop declared `renders` (MO-11o) (RG-4a) main.rx:24:1 - error COMPONENT_A + ✗ router-provider · runtime ok · the good program runs — not compiled: the checker refused it + ✗ router-provider · bad caught · a page that can fail, with no errored boundary around the outlet (UNHANDLED_FAILURE) — crate: RENDERS_ESCAPES@6: renders what its router carries, and props is a prop, which whatever applies the component may give: the components it carries cannot be named | COMPONENT_AS_VALUE@20: component Root is carried by createRootRoute(…), but nothing renders it: pass what carries it to a JS component's prop declared `renders` (MO-11o) | COMPONENT_AS_VALUE@21: component Home is carried by createRo + ✗ router-provider · bad caught · the router built, and never rendered (COMPONENT_AS_VALUE) — crate: RENDERS_ESCAPES@6: renders what its router carries, and props is a prop, which whatever applies the component may give: the components it carries cannot be named | COMPONENT_AS_VALUE@22: component Root is carried by createRootRoute(…), but nothing renders it: pass what carries it to a JS component's prop declared `renders` (MO-11o) | COMPONENT_AS_VALUE@23: component Home is carried by createRo + ✗ router-provider · bad caught · a client-only build with no loading above a page that waits (ASYNC_OUTSIDE_LOADING_BOUNDARY) — crate: RENDERS_ESCAPES@6: renders what its router carries, and props is a prop, which whatever applies the component may give: the components it carries cannot be named | COMPONENT_AS_VALUE@22: component Root is carried by createRootRoute(…), but nothing renders it: pass what carries it to a JS component's prop declared `renders` (MO-11o) | COMPONENT_AS_VALUE@23: component Home is carried by createRo + ✗ sequential-awaits · bad caught · two independent loads awaited one after the other (advice: ASYNC_WATERFALL) — crate: accepted, advice none / ref: accepted, advice none + ✗ source-mutation · bad caught · the source's array pushed to in a handler: the view never hears of it (MUTATION_IN_PLACE) — crate: accepted / ref: accepted + ✗ source-mutation · bad caught · a prop's array sorted in place while the view computes: the parent's source is reordered under it (MUTATION_IN_PLACE) — crate: accepted / ref: accepted + ✗ source-mutation · bad caught · the list spliced inside a functional write's own argument (MUTATION_IN_PLACE) — crate: accepted / ref: accepted + ✗ ssr-divergence · bad caught · a `pure` JS call that answers differently on each side, read by the view (the declaration's assertion: reported when it runs) (dev: HYDRATION_MISMATCH|mismatch) — ran silently + ✗ start-route · bad caught · the page's data read with no errored boundary around it (UNHANDLED_FAILURE) — crate: accepted / ref: accepted + ✗ store-updater · good accepted · main.rx: accepted by the crate — REACTIVE_WRITE_IN_OWNED_SCOPE@12: a statement-bodied closure in reactive scope (SC-3: a closure created here is a pure function) | DRAFT_ESCAPES@15: setCart(…) hands this callback a library's draft: write the callback here, as a closure (`(d) => { … }`) — a function made elsewhere would be given the draft wh | DRAFT_ESCAPES@16: setCart(…) hands this callback a library's draft: write the callback here, as a closure (` + ✗ store-updater · good accepted · main.rx: accepted by ref/ — REACTIVE_WRITE_IN_OWNED_SCOPE@12: a statement-bodied closure in reactive scope (SC-3: a closure created here is a pure function) | DRAFT_ESCAPES@15: setCart(…) hands this callback a library's draft: write the callback here, as a closure (`(d) => { … }`) — a function made elsewhere would be given the draft wh | DRAFT_ESCAPES@16: setCart(…) hands this callback a library's draft: write the callback here, as a closure (` + ✗ store-updater · types kept · rx-tsc: clean with the library's types — main.rx:12:3 - error REACTIVE_WRITE_IN_OWNED_SCOPE: a statement-bodied closure in reactive scope (SC-3: a closure created here is a pure function) (W-2) main.rx:15:3 - error DRAFT_ESCAPES: setCart(…) hands this callback a library's draft: write the callback here, as a closure (`(d) => { … }`) — a function made elsewhere would be given the draft where the checker cannot see what it does with it (MO-10i) main.rx:16:3 - + ✗ store-updater · runtime ok · the good program runs — not compiled: the checker refused it + ✗ store-updater · bad caught · the setter called while the view computes (IO_IN_REACTIVE) — crate: REACTIVE_WRITE_IN_OWNED_SCOPE@12: a statement-bodied closure in reactive scope (SC-3: a closure created here is a pure function) | DRAFT_ESCAPES@14: setCart(…) hands this callback a library's draft: write the callback here, as a closure (`(d) => { … }`) — a function made elsewhere would be given the draft wh | DRAFT_ESCAPES@15: setCart(…) hands this callback a library's draft: write the callback here, as a clo + ✗ store-updater · bad caught · the shared updater also called by hand, with something that is no draft (DRAFT_ESCAPES) — crate: REACTIVE_WRITE_IN_OWNED_SCOPE@12: a statement-bodied closure in reactive scope (SC-3: a closure created here is a pure function) | DRAFT_ESCAPES@15: setCart(…) hands this callback a library's draft: write the callback here, as a closure (`(d) => { … }`) — a function made elsewhere would be given the draft wh / ref: REACTIVE_WRITE_IN_OWNED_SCOPE@12: a statement-bodied closure in reactive scope (SC-3: a closure + ✗ store-updater · bad caught · live rows of the draft kept by a forEach callback (DRAFT_ESCAPES, or harmless) — crate: REACTIVE_WRITE_IN_OWNED_SCOPE@12: a statement-bodied closure in reactive scope (SC-3: a closure created here is a pure function) | DRAFT_ESCAPES@15: setCart(…) hands this callback a library's draft: write the callback here, as a closure (`(d) => { … }`) — a function made elsewhere would be given the draft wh | DRAFT_ESCAPES@16: setCart(…) hands this callback a library's draft: write the callback here, as a clo + ✗ store-updater · bad caught · the draft's iterator kept (DRAFT_ESCAPES, or harmless) — crate: REACTIVE_WRITE_IN_OWNED_SCOPE@12: a statement-bodied closure in reactive scope (SC-3: a closure created here is a pure function) | DRAFT_ESCAPES@15: setCart(…) hands this callback a library's draft: write the callback here, as a closure (`(d) => { … }`) — a function made elsewhere would be given the draft wh | DRAFT_ESCAPES@16: setCart(…) hands this callback a library's draft: write the callback here, as a clo + ✗ table-pagination · good accepted · main.rx: accepted by the crate — RENDERS_ESCAPES@35: row may hold a part of table, whose components `renders` checked where table is bound, and here it is passed to props.onPick(…): render it in the view where tab | RENDERS_ESCAPES@38: table holds components `renders` checked where table is bound, and here it is passed to as pages: render it in the view where table is bound — what leav | RENDERS_ESCAPES@38: table holds components `renders` c + ✗ table-pagination · good accepted · main.rx: accepted by ref/ — RENDERS_ESCAPES@35: row may hold a part of table, whose components `renders` checked where table is bound, and here it is passed to props.onPick(…): render it in the view where tab | RENDERS_ESCAPES@38: table holds components `renders` checked where table is bound, and here it is passed to as pages: render it in the view where table is bound — what leav | RENDERS_ESCAPES@38: table holds components `renders` c + ✗ table-pagination · types kept · rx-tsc: clean with the library's types — main.rx:35:7 - error RENDERS_ESCAPES: row may hold a part of table, whose components `renders` checked where table is bound, and here it is passed to props.onPick(…): render it in the view where table is bound — what leaves that view is a primitive made of it (`str(…)`, a template, arithmetic, a comparison, `len(…)`) — or declare the library `renders(later)` with a prop that `renders` it (MO-11o), or `renders(root, … + ✗ table-pagination · runtime ok · the good program runs — not compiled: the checker refused it + ✗ table-pagination · bad caught · a row of the table handed up through a prop's callback (RENDERS_ESCAPES) — crate: RENDERS_ESCAPES@35: row may hold a part of table, whose components `renders` checked where table is bound, and here it is passed to props.onPick(…): render it in the view where tab | RENDERS_ESCAPES@38: table holds components `renders` checked where table is bound, and here it is passed to as pages: render it in the view where table is bound — what leav | RENDERS_ESCAPES@38: table holds components `ren + ✗ table-pagination · bad caught · the table sent up through a callback kept in a record (RENDERS_ESCAPES) — crate: RENDERS_ESCAPES@35: row may hold a part of table, whose components `renders` checked where table is bound, and here it is passed to props.onPick(…): render it in the view where tab | RENDERS_ESCAPES@38: table holds components `renders` checked where table is bound, and here it is passed to as pages: render it in the view where table is bound — what leav | RENDERS_ESCAPES@38: table holds components `ren + ✗ table-pagination · bad caught · a page turned while the view computes (the handler called, not passed) (IO_IN_REACTIVE) — crate: RENDERS_ESCAPES@35: row may hold a part of table, whose components `renders` checked where table is bound, and here it is passed to props.onPick(…): render it in the view where tab | RENDERS_ESCAPES@38: table holds components `renders` checked where table is bound, and here it is passed to as pages: render it in the view where table is bound — what leav | RENDERS_ESCAPES@38: table holds components `ren diff --git a/bench/baseline-rebased.txt b/bench/baseline-rebased.txt new file mode 100644 index 00000000..76def156 --- /dev/null +++ b/bench/baseline-rebased.txt @@ -0,0 +1,101 @@ +task good accepted types kept runtime ok bad caught unrepresentable hand-written .d.rx words `any` in .d.rx +------------------------------------------------------------------------------------------------------------------------------------------- +context-provider 3/3 ✓ 5/5 ✓ 4/4 ✓ 5/7 ✗ — — — +duplicate-keys 3/3 ✓ 3/3 ✓ 3/3 ✓ 1/2 ✗ — — — +effect-derived 3/3 ✓ 3/3 ✓ 4/4 ✓ 1/5 ✗ — 0 0 +formisch-field-array 3/3 ✓ 6/6 ✓ 7/7 ✓ 4/5 ✗ — 35 26 +formisch-field-path 3/3 ✓ 6/6 ✓ 4/4 ✓ 2/2 ✓ 2/2 ✓ 37 16 +frozen-read 3/3 ✓ 3/3 ✓ 3/3 ✓ 4/4 ✓ — 2 0 +keyed-edits 3/3 ✓ 4/4 ✓ 3/7 ✗ 4/6 ✗ — — — +kobalte-dialog 3/3 ✓ 4/4 ✓ 5/5 ✓ 3/3 ✓ 2/2 ✓ 18 28 +kobalte-select 1/3 ✗ 4/5 ✗ 0/1 ✗ 2/3 ✗ 1/1 ✓ 11 60 +listener-cleanup 3/3 ✓ 3/3 ✓ 4/4 ✓ 4/4 ✓ — 3 0 +optimistic-todo 3/3 ✓ 4/4 ✓ 6/6 ✓ 4/6 ✗ — — — +primitives-virtual 3/3 ✓ 5/5 ✓ 6/6 ✓ 3/5 ✗ 1/1 ✓ 24 17 +projection-selection 3/3 ✓ 3/4 ✗ 4/4 ✓ 2/4 ✗ — — — +query-forward 3/3 ✓ 6/6 ✓ 6/6 ✓ 5/5 ✓ — 30 5 +query-mutation 3/3 ✓ 5/5 ✓ 5/5 ✓ 4/7 ✗ — 39 11 +router-data 3/3 ✓ 5/5 ✓ 5/5 ✓ 7/7 ✓ — 61 7 +router-provider 3/3 ✓ 5/5 ✓ 4/4 ✓ 5/5 ✓ 1/1 ✓ 51 8 +sequential-awaits 3/3 ✓ 3/3 ✓ 4/4 ✓ 2/3 ✗ — 0 2 +source-mutation 3/3 ✓ 3/3 ✓ 3/3 ✓ 4/4 ✓ — — — +ssr-divergence 3/3 ✓ 3/3 ✓ 3/3 ✓ 2/3 ✗ — 3 0 +start-route 3/3 ✓ 5/5 ✓ 8/8 ✓ 2/2 ✓ 1/1 ✓ 20 0 +store-helper 3/3 ✓ 3/4 ✗ 1/4 ✗ 4/4 ✓ — 12 3 +store-updater 3/3 ✓ 5/5 ✓ 5/5 ✓ 5/5 ✓ — 12 0 +table-pagination 1/3 ✗ 7/8 ✗ 0/1 ✗ 5/5 ✓ — 79 12 +------------------------------------------------------------------------------------------------------------------------------------------- +total 68/72 103/107 97/106 84/106 8/8 437 195 + +Not green (39): + ✗ context-provider · bad caught · the provided action called while the view computes (ACTION_CALLED_IN_OWNED_SCOPE) — crate: accepted / ref: accepted + ✗ context-provider · bad caught · the same through a prop: a row's handler called, not passed on (ACTION_CALLED_IN_OWNED_SCOPE) — crate: accepted / ref: accepted + ✗ duplicate-keys · bad caught · rows added with a key the list already has (known only when it runs) (dev: duplicate key|DUPLICATE_KEY) — ran silently + known: 06 ST-4d, 08 CN-2: a key computed at run time is the data's (bin R). The checker refuses rows written out with one key; it cannot see a key that a click computes, a static check does not become a run-time one, and Solid's development build reports no duplicate either. The variant stays as the measure of that limit. + ✗ effect-derived · bad caught · the total kept in a source, written by a mount effect that reads the others: computed once, stale after (EFFECT_RELAY_TEAR) — crate: accepted / ref: accepted + ✗ effect-derived · bad caught · the same with the inputs named: a frame late, an equation written the long way (EFFECT_RELAY_TEAR) — crate: accepted / ref: accepted + ✗ effect-derived · bad caught · the history appended by an effect on the quantity, not by the click that changed it (EFFECT_RELAY_TEAR) — crate: accepted / ref: accepted + ✗ effect-derived · bad caught · the title set by a mount effect that reads the total by name: sent once, never again (advice: SNAPSHOT_IN_EFFECT) — crate: accepted, advice none / ref: accepted, advice none + ✗ formisch-field-array · bad caught · the list of row ids changed in place (MUTATION_IN_PLACE) — crate: accepted / ref: accepted + ✗ keyed-edits · runtime ok · rename in place: the row keeps its state — new,cook,wash,read / open cook + ✗ keyed-edits · runtime ok · remove: the others stay as they are — cook,wash,read / open cook + ✗ keyed-edits · runtime ok · reset to rows written out: the kept keys keep their rows' state — wash,cook / open + ✗ keyed-edits · runtime ok · no console errors or warnings — ["[UNRECOGNIZED_INSERT_VALUE] Unrecognized value. Skipped inserting (function).\n[UNRECOGNIZED_INSERT_VALUE] what it means and how to fix it: https://docs.solidjs.com/reference/solid-js/diagnostics/unrecognized-insert-value\n[UNRECOGNIZED_INSERT_VALUE] agent repair guide: node_modules/solid-js/skills/re"] + ✗ keyed-edits · bad caught · the list reset from a handler with two rows of one key (DUPLICATE_KEY) — crate: accepted / ref: accepted + ✗ keyed-edits · bad caught · rows added in a handler's functional write, two written with one key (DUPLICATE_KEY) — crate: accepted / ref: accepted + ✗ kobalte-select · good accepted · main.rx: accepted by the crate — VIEW_FN_EXPECTED@22: 's children are a function of what it renders: write them as `{view (item) { … }}` + ✗ kobalte-select · good accepted · main.rx: accepted by ref/ — VIEW_FN_EXPECTED@22: 's children are a function of what it renders: write them as `{view (item) { … }}` + ✗ kobalte-select · types kept · rx-tsc: clean with the library's types — main.rx:22:7 - error VIEW_FN_EXPECTED: 's children are a function of what it renders: write them as `{view (item) { … }}` (MO-11k) Found 1 ReactiveScript error. VIEW_FN_EXPECTED: why, and the fix — https://github.com/solidjs/reactivescript/blob/main/guide/diagnostics.md#view_fn_expected + ✗ kobalte-select · runtime ok · the good program runs — not compiled: the checker refused it + ✗ kobalte-select · bad caught · an item rendered outside the select (its context is the listbox's, which only running it shows) (dev: context|Context|within|undefined|null) — not compiled: VIEW_FN_EXPECTED@22: 's children are a function of what it renders: write them as `{view (item) { … }}` + ✗ optimistic-todo · bad caught · an optimistic write outside an action: a guess in a handler that awaits nothing (GUESS_OUTSIDE_ACTION) — crate: accepted / ref: accepted + ✗ optimistic-todo · bad caught · an await before the optimistic write: the row shows only once the server has answered (advice: GUESS_AFTER_AWAIT) — crate: accepted, advice none / ref: accepted, advice none + ✗ primitives-virtual · bad caught · a listener's disposer dropped (its type is the library's alias for `() => void`) (DISPOSER_DROPPED) — crate: accepted / ref: accepted + ✗ primitives-virtual · bad caught · a listener added by hand in a click handler, its disposer dropped: one more on every click (DISPOSER_DROPPED) — crate: accepted / ref: accepted + ✗ projection-selection · types kept · rx-tsc: clean with the library's types — main.rx(14,76): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'. main.rx(14,110): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on ty + ✗ projection-selection · bad caught · the selection kept in a store, written by an effect on the picked id (EFFECT_RELAY_TEAR) — crate: accepted / ref: accepted + ✗ projection-selection · bad caught · …by a mount effect that reads the picked id: the first row stays selected for ever (EFFECT_RELAY_TEAR) — crate: accepted / ref: accepted + ✗ query-mutation · bad caught · the query's function reads the id, its key does not: the cache answers the first todo for every id (KEY_MISSES_INPUT, or harmless) — accepted, and not harmless when run: the other todo is shown: milk + ✗ query-mutation · bad caught · the mutation run while the view computes (IO_IN_REACTIVE) — crate: accepted / ref: accepted + ✗ query-mutation · bad caught · the cache invalidated while the view computes (IO_IN_REACTIVE) — crate: accepted / ref: accepted + ✗ sequential-awaits · bad caught · two independent loads awaited one after the other (advice: ASYNC_WATERFALL) — crate: accepted, advice none / ref: accepted, advice none + ✗ ssr-divergence · bad caught · a `pure` JS call that answers differently on each side, read by the view (the declaration's assertion: reported when it runs) (dev: HYDRATION_MISMATCH|mismatch) — ran silently + known: 10 SV-7c (ruled 2026-10-24), 08 CN-5: `pure` is the author's assertion at the JS boundary, the one unchecked word, and that the function answers alike on both machines is part of it. What only the browser knows is `client` JS, which is checked (SV-7b: the good program). Solid's development build adopts the server's text without comparing it, so nothing reports this mismatch, and the language adds no run-time comparison of its own. + ✗ store-helper · types kept · rx-tsc: clean with the library's types — array.d.rx:3:1 - error DECLARATION_MISMATCH: sortBy: Type '(list: T[], key: keyof T) => void' is not assignable to type '__decl_sortBy'. Types of parameters 'key' and 'key' are incompatible. Type 'any' is not assignable to type 'never'. (TY-6) Found 1 ReactiveScript error. DECLARATION_MISMATCH: why, and the fix — https://github.com/solidjs/reactivescript/blob/main/guide/diagnostics.md#declaration_mismatch + ✗ store-helper · runtime ok · the helper moved the draft's own list: the store follows — todo,doing,done / 1 moves + ✗ store-helper · runtime ok · a helper that sorts in place — todo,doing,done + ✗ store-helper · runtime ok · and again, composed — todo,doing,done / 2 moves + ✗ table-pagination · good accepted · main.rx: accepted by the crate — RENDERS_ESCAPES@47: table holds components `renders` checked where table is bound, and here it is passed to as table: render it in the view where table is bou + ✗ table-pagination · good accepted · main.rx: accepted by ref/ — RENDERS_ESCAPES@47: table holds components `renders` checked where table is bound, and here it is passed to as table: render it in the view where table is bou + ✗ table-pagination · types kept · rx-tsc: clean with the library's types — main.rx:47:3 - error RENDERS_ESCAPES: table holds components `renders` checked where table is bound, and here it is passed to as table: render it in the view where table is bound — what leaves that view is a primitive made of it (`str(…)`, a template, arithmetic, a comparison, `len(…)`) — or declare the library `renders(later)` with a prop that `renders` it (MO-11o), or `renders(root, …)` if it + ✗ table-pagination · runtime ok · the good program runs — not compiled: the checker refused it + +Declarations (words written by hand over rx-declare's draft; `any`s held): + effect-derived/page.d.rx: 0 words by hand, 0 `any` + formisch-field-array/rx-types/@formisch/solid/v2.d.rx: 6 words by hand, 18 `any` + formisch-field-array/rx-types/valibot.d.rx: 29 words by hand, 8 `any` + formisch-field-path/rx-types/@formisch/solid/v2.d.rx: 6 words by hand, 9 `any` + formisch-field-path/rx-types/valibot.d.rx: 31 words by hand, 7 `any` + frozen-read/label.d.rx: 2 words by hand, 0 `any` + kobalte-dialog/rx-types/@kobalte/core/dialog.d.rx: 18 words by hand, 28 `any` + kobalte-select/rx-types/@kobalte/core/select.d.rx: 11 words by hand, 60 `any` + listener-cleanup/keys.d.rx: 3 words by hand, 0 `any` + primitives-virtual/rx-types/@solid-primitives/event-listener.d.rx: 4 words by hand, 11 `any` + primitives-virtual/rx-types/@solid-primitives/resize-observer.d.rx: 3 words by hand, 4 `any` + primitives-virtual/virtual.d.rx: 17 words by hand, 2 `any` + query-forward/api.d.rx: 8 words by hand, 1 `any` + query-forward/rx-types/@tanstack/solid-query.d.rx: 22 words by hand, 4 `any` + query-mutation/api.d.rx: 6 words by hand, 2 `any` + query-mutation/rx-types/@tanstack/solid-query.d.rx: 33 words by hand, 9 `any` + router-data/people.d.rx: 6 words by hand, 1 `any` + router-data/rx-types/@solidjs/router.d.rx: 55 words by hand, 6 `any` + router-provider/people.d.rx: 9 words by hand, 0 `any` + router-provider/rx-types/@tanstack/solid-router.d.rx: 42 words by hand, 8 `any` + sequential-awaits/api.d.rx: 0 words by hand, 2 `any` + ssr-divergence/env.d.rx: 3 words by hand, 0 `any` + start-route/src/people.d.rx: 20 words by hand (rx-declare drafts nothing for it: the module has no types), 0 `any` + store-helper/array.d.rx: 0 words by hand, 3 `any` + store-helper/rx-types/solid-js.d.rx: 12 words by hand, 0 `any` + store-updater/audit.d.rx: 0 words by hand, 0 `any` + store-updater/rx-types/solid-js.d.rx: 12 words by hand, 0 `any` + table-pagination/table.d.rx: 79 words by hand, 12 `any` diff --git a/bench/harness.mjs b/bench/harness.mjs new file mode 100644 index 00000000..82f5509c --- /dev/null +++ b/bench/harness.mjs @@ -0,0 +1,259 @@ +// What bench/run.mjs runs a task with: the workspace (the libraries from npm, once), both checkers, rx-tsc, the compiled +// program on the server and in Chromium. See bench/README.md. +import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs"; +import { execFileSync, spawnSync } from "node:child_process"; +import { createServer } from "node:http"; +import { createRequire } from "node:module"; +import { fileURLToPath, pathToFileURL } from "node:url"; +import path from "node:path"; + +export const here = path.dirname(fileURLToPath(import.meta.url)); +export const repo = path.resolve(here, ".."); +export const ws = path.join(here, ".out/ws"); +export const rxc = process.env.RXC || path.join(repo, "compiler/target/release/rxc"); + +/** The workspace: bench/package.json installed from npm (once; again when it changes), with this repository's compiler, + * runtime and language server linked as installed. Every task is a folder under it, so each resolves the same Solid. */ +export function workspace() { + const pkg = readFileSync(path.join(here, "package.json"), "utf8"); + mkdirSync(ws, { recursive: true }); + const at = path.join(ws, "package.json"); + if (!existsSync(path.join(ws, "node_modules/solid-js")) || !existsSync(at) || readFileSync(at, "utf8") !== pkg) { + writeFileSync(at, pkg); + execFileSync("npm", ["install", "--no-audit", "--no-fund", "--silent", "--legacy-peer-deps"], { cwd: ws, stdio: "inherit" }); + } + linkOwn(path.join(ws, "node_modules")); +} +/** This repository's packages in a node_modules, as an app installs them: the compiler and the language server linked, + * the runtime copied (its peers are then that install's Solid, one copy). */ +function linkOwn(nm) { + const rx = path.join(nm, "@reactivescript"); rmSync(rx, { recursive: true, force: true }); mkdirSync(path.join(rx, "runtime"), { recursive: true }); + symlinkSync(path.join(repo, "compiler"), path.join(rx, "compiler")); + symlinkSync(path.join(repo, "tooling/rx-language-server"), path.join(rx, "language-server")); + for (const f of ["package.json", "dist", "rx-lib.d.ts"]) cpSync(path.join(repo, "runtime", f), path.join(rx, "runtime", f), { recursive: true }); +} +/** A task with a package.json of its own (beside its task.mjs) has an install of its own, for a library that pins + * another version of what the workspace holds: installed once into bench/.out/ws/deps/ (again when it changes). */ +function ownInstall(id) { + const from = path.join(here, "tasks", id, "package.json"); if (!existsSync(from)) return null; + const pkg = readFileSync(from, "utf8"); const at = path.join(ws, "deps", id); mkdirSync(at, { recursive: true }); + const had = path.join(at, "package.json"); + if (!existsSync(path.join(at, "node_modules/solid-js")) || !existsSync(had) || readFileSync(had, "utf8") !== pkg) { + writeFileSync(had, pkg); + execFileSync("npm", ["install", "--no-audit", "--no-fund", "--silent", "--legacy-peer-deps"], { cwd: at, stdio: "inherit" }); + } + linkOwn(path.join(at, "node_modules")); + return path.join(at, "node_modules"); +} + +/** A task's folder in the workspace: its `src/`, copied fresh. */ +export function stage(id) { + const dir = path.join(ws, "tasks", id); + rmSync(dir, { recursive: true, force: true }); mkdirSync(dir, { recursive: true }); + cpSync(path.join(here, "tasks", id, "src"), dir, { recursive: true }); + const own = ownInstall(id); if (own) symlinkSync(own, path.join(dir, "node_modules"), "dir"); + if (!existsSync(path.join(dir, "tsconfig.json"))) writeFileSync(path.join(dir, "tsconfig.json"), JSON.stringify({ compilerOptions: { jsx: "preserve", jsxImportSource: "@solidjs/web", strict: true, noImplicitAny: true, target: "ES2022", module: "ESNext", moduleResolution: "Bundler", allowImportingTsExtensions: true, noEmit: true, skipLibCheck: true, lib: ["ES2023", "DOM", "DOM.Iterable"], types: [] }, include: ["**/*.rx", "**/*.d.ts"], exclude: ["node_modules", "dist", ".build"] }, null, 2)); + return dir; +} + +const codes = ds => ds.map(d => `${d.code}@${path.basename(d.file ?? "")}:${d.line}`); +/** The crate's diagnostics for a program (`rxc check --json`). */ +export function crate(entry, spa, host) { + const r = spawnSync(rxc, ["check", "--json", ...(spa ? ["--spa"] : []), ...(host ? ["--whole-program", "--host", entry] : []), entry], { encoding: "utf8", maxBuffer: 1 << 26 }); + try { const out = JSON.parse(r.stdout); return { diagnostics: out.diagnostics ?? [], advice: out.advice ?? [] }; } catch { return { diagnostics: [{ code: "CRASH", line: 0, file: entry, message: (r.stderr || r.stdout || "").slice(0, 400) }], advice: [] }; } +} +/** The reference checker's (`ref/src/check.ts`). */ +export function ref(entry, spa, host) { + const r = spawnSync(process.execPath, ["--experimental-strip-types", "--no-warnings", path.join(here, "ref-check.ts"), ...(spa ? ["--spa"] : []), ...(host ? ["--host"] : []), entry], { encoding: "utf8", maxBuffer: 1 << 26 }); + try { const out = JSON.parse(r.stdout); return out.error ? { diagnostics: [{ code: out.code ?? "PARSE", line: 0, file: entry, message: out.error }], advice: [] } : out; } catch { return { diagnostics: [{ code: "CRASH", line: 0, file: entry, message: (r.stderr || r.stdout || "").slice(0, 400) }], advice: [] }; } +} +/** Both checkers on one program: what each says, and whether they say the same (code and line, in order). */ +export function both(entry, spa, host) { + const c = crate(entry, spa, host), r = ref(entry, spa, host); + // a parse error is one diagnostic on either side, placed differently: compared by code + const loose = [...c.diagnostics, ...r.diagnostics].some(d => d.line === 0); + const key = x => loose ? x.diagnostics.map(d => d.code) : codes(x.diagnostics); + return { crate: c, ref: r, agree: JSON.stringify(key(c)) === JSON.stringify(key(r)) && JSON.stringify(codes(c.advice)) === JSON.stringify(codes(r.advice)) }; +} + +/** rx-tsc over the task's tsconfig: TypeScript's errors and the crate's, as text ("" when clean). */ +export function rxTsc(dir) { + const r = spawnSync(process.execPath, [path.join(repo, "tooling/rx-language-server/bin/tsc.js"), "--noEmit", "-p", "tsconfig.json"], { cwd: dir, encoding: "utf8", env: { ...process.env, RXC: rxc } }); + return r.status === 0 ? "" : String(r.stdout ?? "") + String(r.stderr ?? "") || `exit ${r.status}`; +} + +/** One edit of one file, undone by the function it returns. A variant is one line changed: `[from, to]`, each once. */ +export function edit(dir, file, [from, to]) { + const f = path.join(dir, file); const good = readFileSync(f, "utf8"); + if (!good.includes(from)) throw new Error(`the edit does not apply: ${JSON.stringify(from)} is not in ${file}`); + writeFileSync(f, good.replace(from, to)); + return () => writeFileSync(f, good); +} + +let seq = 0; +/** The program compiled by the crate for one target (`rxc app`), each module written beside its `.rx` (`x.rx...mjs`), + * importing the others by those names. Returns the entry's file, or `{ diagnostics }`. */ +export function compile(entry, target, spa) { + const r = spawnSync(rxc, ["app", entry, "--target", target, ...(spa ? ["--spa"] : [])], { encoding: "utf8", maxBuffer: 1 << 27 }); + let out; try { out = JSON.parse(r.stdout); } catch { return { error: (r.stderr || r.stdout || "").slice(0, 600) }; } + if (!out.modules) return out; + const n = ++seq; const name = p => `${p}.${n}.${target}.mjs`; + for (const [p, m] of Object.entries(out.modules)) writeFileSync(name(p), m.code.replace(/from "(\.{1,2}\/[^"]+\.rx)"/g, (_, s) => `from "${s}.${n}.${target}.mjs"`)); + return { file: name(out.entry ?? entry), css: out.css }; +} + +const esbuild = () => createRequire(path.join(ws, "package.json"))("esbuild"); +const pw = () => createRequire(path.join(ws, "package.json"))("playwright"); + +/** What a task's `run` drives the compiled program with. */ +export class Runner { + constructor(dir, entry, spa) { this.dir = dir; this.entry = path.join(dir, entry); this.spa = spa; this.checks = []; this.servers = []; this.problems = []; } + check(name, ok, got) { this.checks.push({ name, ok: !!ok, got: ok ? undefined : typeof got === "string" ? got.slice(0, 600) : JSON.stringify(got)?.slice(0, 600) }); return !!ok; } + /** The server's render of one URL: `{ html, text, error }` (the stream, to its end; hydration comments dropped from `text`). */ + async ssr(url = "/", { wait = 4000 } = {}) { + const built = this.server ??= compile(this.entry, "ssr", this.spa); + if (!built.file) return { html: "", text: "", error: new Error(JSON.stringify(built).slice(0, 600)) }; + const { createApp } = await import(pathToFileURL(path.join(ws, "node_modules/@reactivescript/runtime/dist/server.js")).href); + let html = "", error = null; + const caught = e => { error ??= e; }; + process.on("uncaughtException", caught); process.on("unhandledRejection", caught); + try { + const main = (await import(pathToFileURL(built.file).href)).default; + const app = createApp({ request: new Request("http://localhost" + url) }); + await new Promise((res, rej) => { try { app.stream(main(app), { write: c => { html += c; }, end: res }); } catch (e) { rej(e); } setTimeout(res, wait); }); + await new Promise(r => setTimeout(r, 20)); + } catch (e) { error ??= e; } + process.off("uncaughtException", caught); process.off("unhandledRejection", caught); + return { html, text: html.replace(//g, "").replace(//g, "").replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim(), error }; + } + /** The client's bundle (the dom build, with Solid's development build, so its dev errors are loud). */ + client(hydrate) { + const built = compile(this.entry, "dom", this.spa); + if (!built.file) throw new Error(JSON.stringify(built).slice(0, 600)); + const entry = built.file + ".entry.mjs"; + writeFileSync(entry, `import main from ${JSON.stringify("./" + path.basename(built.file))};\nimport { createApp } from "@reactivescript/runtime";\nconst app = createApp({ root: document.getElementById("app") });\ntry { app.mount(main(app)${hydrate ? ", true" : ""}); } catch (e) { console.error("mount threw: " + (e && e.message)); }\nwindow.__mounted = true;\n`); + const r = esbuild().buildSync({ entryPoints: [entry], bundle: true, write: false, format: "esm", platform: "browser", conditions: ["browser", "development"], logLevel: "silent", tsconfigRaw: "{}", absWorkingDir: this.dir, loader: { ".css": "empty" } }); + return r.outputFiles[0].text; + } + /** Serves the program: `ssr` renders each URL on the server and hydrates it; otherwise an empty page the client mounts in. */ + async serve({ ssr = false } = {}) { + const client = this.client(ssr); + let render = null; + if (ssr) { + const built = this.server ??= compile(this.entry, "ssr", this.spa); + if (!built.file) throw new Error(JSON.stringify(built).slice(0, 600)); + const rt = await import(pathToFileURL(path.join(ws, "node_modules/@reactivescript/runtime/dist/server.js")).href); + const main = (await import(pathToFileURL(built.file).href)).default; + render = (url, res) => { + res.write(`${rt.generateHydrationScript()}
`); + const app = rt.createApp({ request: new Request("http://localhost" + url) }); + let first = true; + app.stream(main(app), { write: s => { res.write(s); if (first) { first = false; res.write(`
`); } }, end: () => res.end("") }); + }; + } + const server = createServer((rq, res) => { + if (rq.url === "/client.js") { res.writeHead(200, { "content-type": "text/javascript" }); return res.end(client); } + if (rq.url === "/favicon.ico") { res.writeHead(404); return res.end(); } + res.writeHead(200, { "content-type": "text/html" }); + if (render) { try { render(rq.url, res); } catch (e) { this.problems.push("server: " + e.message); res.end(); } return; } + res.end(`
`); + }); + await new Promise(r => server.listen(0, "127.0.0.1", r)); + this.servers.push(server); + return `http://127.0.0.1:${server.address().port}`; + } + /** A page in Chromium; console errors and warnings and page errors are collected in `problems`. */ + async page() { + this.browser ??= await pw().chromium.launch(); + const page = await this.browser.newPage(); + page.on("console", m => { if (["error", "warning"].includes(m.type())) this.problems.push(m.text().slice(0, 300)); }); + page.on("pageerror", e => this.problems.push(String(e).slice(0, 300))); + return page; + } + /** Opens `url` of a served program and waits for the client to mount. */ + async open(base, url = "/") { + const page = await this.page(); + await page.goto(base + url); + await page.waitForFunction(() => window.__mounted, null, { timeout: 10000 }).catch(() => this.problems.push("the client never mounted")); + return page; + } + async text(page, sel = "#app") { return ((await page.textContent(sel)) ?? "").replace(/\s+/g, " ").trim(); } + async until(ok, tries = 80) { for (let i = 0; i < tries; i++) { try { if (await ok()) return true; } catch { /* not yet */ } await new Promise(r => setTimeout(r, 50)); } return false; } + async close() { await this.browser?.close(); for (const s of this.servers) s.close(); } +} + +/** Every file under a task's folder (its own: no node_modules, no dot folders, nothing the build wrote), by a test of its name. */ +function own(dir, keep) { + const out = []; + const walk = d => { for (const e of readdirSync(d, { withFileTypes: true })) { if (e.name === "node_modules" || e.name === "dist" || e.name.startsWith(".")) continue; const p = path.join(d, e.name); if (e.isDirectory()) walk(p); else if (keep(e.name)) out.push(p); } }; + walk(dir); + return out.sort(); +} +const code = text => text.split("\n").map(l => l.replace(/\/\/.*$/, "")); +/** `any` written in a task's `.rx` (an annotation or a cast): what the program gave up of the library's types. */ +export function anysWritten(dir) { + const out = []; + for (const p of own(dir, n => n.endsWith(".rx") && !n.endsWith(".d.rx"))) code(readFileSync(p, "utf8")).forEach((l, i) => { if (/(:|\bas)\s*any\b|/.test(l)) out.push(`${path.basename(p)}:${i + 1}`); }); + return out; +} + +// ---- the declarations a task's checker reasons with (its `.d.rx` files) ---- +const tokens = line => line.match(/[A-Za-z_$][\w$]*|\d+|[^\s\w]/g) ?? []; +const isWord = t => /^[\w$]/.test(t); +const exported = line => /^export\s+(?:(?:pure|server|client|trusted)\s+)*(?:fn|component|const|type|context|error)\s+([\w$.]+)/.exec(line.trim())?.[1]; +/** The words of `hand` that are not `draft`'s: the tokens of `hand` outside a longest common subsequence of the two. */ +function written(hand, draft) { + const a = tokens(hand), b = tokens(draft); + const m = Array.from({ length: a.length + 1 }, () => new Uint16Array(b.length + 1)); + for (let i = a.length - 1; i >= 0; i--) for (let j = b.length - 1; j >= 0; j--) m[i][j] = a[i] === b[j] ? m[i + 1][j + 1] + 1 : Math.max(m[i + 1][j], m[i][j + 1]); + let n = 0; + for (let i = 0, j = 0; i < a.length;) { if (j < b.length && a[i] === b[j]) { i++; j++; } else if (j < b.length && m[i][j + 1] >= m[i + 1][j]) j++; else { if (isWord(a[i])) n++; i++; } } + return n; +} +/** The module a `.d.rx` declares, as `rx-declare` is asked for it, and the folder it is asked from: a package under + * `rx-types/` by its import name (09 MO-8k), a file beside a JS module by that module. */ +function declares(dir, file) { + const rel = path.relative(dir, file).split(path.sep); + const at = rel.lastIndexOf("rx-types"); + if (at >= 0) return { spec: rel.slice(at + 1).join("/").replace(/\.d\.rx$/, ""), from: path.join(dir, ...rel.slice(0, at)) }; + const stem = file.replace(/\.d\.rx$/, ""); + const js = [".js", ".mjs", ".jsx", ".ts", ".tsx"].find(x => existsSync(stem + x)); + return { spec: `./${path.basename(stem)}${js ?? ".js"}`, from: path.dirname(file) }; +} +/** What `rx-declare` drafts for a module (its lines, comments dropped), with the flags the task says its draft was made + * with (`--run`, `--dom`: 09 MO-12, what running the package shows); [] when the module has no types to draft from. */ +export function draftOf(spec, from, flags = []) { + const r = spawnSync(process.execPath, ["--conditions=browser", path.join(repo, "tooling/rx-language-server/bin/declare.js"), spec, ...flags], { cwd: from, encoding: "utf8", maxBuffer: 1 << 26 }); + return r.status === 0 ? code(r.stdout).map(l => l.trim()).filter(Boolean) : []; +} +/** A task's declarations, measured against the tool that drafts them: for each `.d.rx` of the task, the words a person + * wrote on top of `rx-declare`'s draft of the same module (a row the draft has, word for word, costs nothing; a row it + * has otherwise costs the words that differ; a row it has not costs every word; a row left out costs nothing), and the + * `any`s the file holds — what the checker is told nothing about. `{ words, any, files: [{ file, words, any, drafted }] }`. */ +export function declarations(dir, flagsFor = {}) { + const files = []; + for (const p of own(dir, n => n.endsWith(".d.rx"))) { + const { spec, from } = declares(dir, p); + const draft = draftOf(spec, from, flagsFor[spec] ?? []); + const whole = new Set(draft), byName = new Map(draft.map(l => [exported(l), l]).filter(([n]) => n)); + let words = 0, any = 0; + for (const line of code(readFileSync(p, "utf8")).map(l => l.trim()).filter(Boolean)) { + any += tokens(line).filter(t => t === "any").length; + if (whole.has(line)) continue; + const was = byName.get(exported(line)); + words += was ? written(line, was) : tokens(line).filter(isWord).length; + } + files.push({ file: path.relative(dir, p), words, any, drafted: draft.length > 0 }); + } + return { words: files.reduce((n, f) => n + f.words, 0), any: files.reduce((n, f) => n + f.any, 0), files }; +} + +/** rx-tsc's errors that are on the lines an edit wrote: `file(line,col): error …` rows whose file is the edited one and + * whose line is one of the edit's. What a type probe is judged by: an error elsewhere is not the type refusing the edit. */ +export function onEdit(out, dir, file, [from, to]) { + const good = readFileSync(path.join(dir, file), "utf8"); // read after the undo: the program as it was + const first = good.slice(0, good.indexOf(from)).split("\n").length, last = first + to.split("\n").length - 1; + const name = file.split("/").pop().replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + return out.split("\n").filter(l => { const m = new RegExp(`(?:^|[\\\\/])${name}[(:](\\d+)[,:]`).exec(l); return m && Number(m[1]) >= first && Number(m[1]) <= last; }).join("\n"); +} +export { statSync }; diff --git a/bench/package.json b/bench/package.json new file mode 100644 index 00000000..22d39b40 --- /dev/null +++ b/bench/package.json @@ -0,0 +1,28 @@ +{ + "name": "rx-bench-workspace", + "private": true, + "type": "module", + "description": "The libraries bench/run.mjs runs its tasks against, installed once into bench/.out/ws: Solid 2.0 and the ecosystem's Solid 2 releases. (@tanstack/virtual-core has no Solid 2 adapter yet: tasks/primitives-virtual/src/virtual.js is a small one, as tasks/table-pagination/src/table.js is for table-core. @happy-dom/global-registrator is what `rx-declare --run --dom` runs a package's hooks in.)", + "dependencies": { + "solid-js": "2.0.2", + "@solidjs/web": "2.0.2", + "@solidjs/signals": "2.0.2", + "@formisch/solid": "1.3.0", + "valibot": "1.5.0", + "@tanstack/solid-query": "6.0.0-rc.6", + "@tanstack/solid-router": "2.0.0-rc.11", + "@tanstack/solid-start": "2.0.0-rc.11", + "@tanstack/table-core": "8.21.3", + "@kobalte/core": "2.0.0-alpha.4", + "vite": "8.1.5", + "@solidjs/vite-plugin": "3.0.1", + "esbuild": "^0.28.2", + "playwright": "1.63.0", + "typescript": "^6.0.3", + "@solidjs/router": "2.0.1", + "@solid-primitives/event-listener": "3.0.0", + "@solid-primitives/resize-observer": "4.0.0", + "@tanstack/virtual-core": "3.19.11", + "@happy-dom/global-registrator": "21.0.4" + } +} diff --git a/bench/ref-check.ts b/bench/ref-check.ts new file mode 100644 index 00000000..ce41dfc1 --- /dev/null +++ b/bench/ref-check.ts @@ -0,0 +1,19 @@ +// The reference checker's answer for one program, as JSON: `{ diagnostics: [{ file, line, code, rule, message }], advice }` +// or `{ error }`. What bench/run.mjs compares with `rxc check --json`. +// Usage: node --experimental-strip-types bench/ref-check.ts [--spa] [--host] entry.rx (--host: the entry is a module a +// JS host imports with ?rx-lib, checked as the whole program, CP-4d) +import { resolve } from "node:path"; +import { readDisk } from "../ref/disk.ts"; +import { loadModules } from "../ref/src/modules.ts"; +import { checkModules } from "../ref/src/check.ts"; + +const args = process.argv.slice(2); +const entry = resolve(args.find(a => !a.startsWith("--"))!); +try { + const set = loadModules(entry, readDisk); + const checked = checkModules(set, args.includes("--spa"), args.includes("--host"), args.includes("--host") ? [entry] : []) as { diags: { file?: string; line: number; code: string; rule: string; msg: string }[]; advice?: { file?: string; line: number; code: string; rule: string; msg: string }[] }; + const row = (d: { file?: string; line: number; code: string; rule: string; msg: string }) => ({ file: d.file ?? entry, line: d.line, code: d.code, rule: d.rule, message: d.msg }); + console.log(JSON.stringify({ diagnostics: checked.diags.map(row), advice: (checked.advice ?? []).map(row) })); +} catch (e) { + console.log(JSON.stringify({ error: (e as Error).message, code: (e as { code?: string }).code ?? "PARSE" })); +} diff --git a/bench/run.mjs b/bench/run.mjs new file mode 100644 index 00000000..eee9d7bd --- /dev/null +++ b/bench/run.mjs @@ -0,0 +1,213 @@ +// The representative-task benchmark (bench/README.md): each task under bench/tasks/ is a job a Solid user does with a +// library of the ecosystem, written as they would write it. Its GOOD program must be accepted by both checkers, keep the +// library's types, and run; each BAD variant is one realistic mistake, one line changed, that must be refused with the +// diagnostic named (or, where only the runtime can know, fail loudly in a development build). +// +// A variant the language has no way to write — refused by the parser, by name resolution or by TypeScript alone (PARSE, +// ASSIGNMENT, UNBOUND, UNKNOWN_COMPONENT, a JS habit's code, a `ts` variant) — is counted apart, as UNREPRESENTABLE: it +// shows that the mistake cannot be spelled, not that a check of the program's meaning caught it. And each task's +// declarations are measured against the tool that drafts them: the words written by hand on top of `rx-declare`'s draft, +// and the `any`s the `.d.rx` files hold. +// +// Usage: node bench/run.mjs [filter…] the scorecard for every task (or those whose id contains a filter) +// node bench/run.mjs --check also compares with bench/scorecard.json: exits 1 when a check that was +// green there is not now (the ratchet CI runs) +// node bench/run.mjs --check --strict and when a failure is not one the task's `known` gives a reason for +// node bench/run.mjs --write writes bench/scorecard.json and bench/scorecard.txt from this run +// VERBOSE=1 prints every check, not only the failures +// Needs: the crate (`cargo build --release` in compiler/), the runtime (`npm run build` in runtime/), the language +// server's packages (`npm ci` in tooling/rx-language-server), Node 22.6+, and the network once (bench/package.json). +import { existsSync, readFileSync, readdirSync, writeFileSync } from "node:fs"; +import { spawnSync } from "node:child_process"; +import { pathToFileURL } from "node:url"; +import path from "node:path"; +import { here, ws, workspace, stage, both, rxTsc, edit, Runner, anysWritten, declarations, onEdit } from "./harness.mjs"; + +/** The codes of a program that cannot be written: the grammar has no position for it (99, bin U as the parser reports + * it, and the habits it names), or a name resolves to nothing. */ +const UNWRITABLE = new Set(["PARSE", "ASSIGNMENT", "UNBOUND", "UNKNOWN_COMPONENT", "JS_LOCAL", "JS_FUNCTION", "JS_RETURN", "JS_API"]); + +const args = process.argv.slice(2); +const flag = f => args.includes(f); +const one = args.includes("--task") ? args[args.indexOf("--task") + 1] : null; + +/** One task, in this process: `{ id, title, good, types, runtime, bad, unrep }`, each `{ pass, total, fails: [text] }`, + * and `decl`: `{ words, any, files }` (harness.mjs, declarations). */ +async function runTask(id) { + const task = (await import(pathToFileURL(path.join(here, "tasks", id, "task.mjs")).href)).default; + const dir = stage(id); + if (task.prepare) await task.prepare(dir); + const cell = () => ({ pass: 0, total: 0, fails: [], notes: [] }); + const res = { id, title: task.title, good: cell(), types: cell(), runtime: cell(), bad: cell(), unrep: cell(), decl: { words: 0, any: 0, files: [] }, known: task.known ?? {} }; + const mark = (c, name, ok, why) => { c.total++; if (ok) c.pass++; else c.fails.push(`${name}${why ? ` — ${String(why).replace(/\s+/g, " ").slice(0, 420)}` : ""}`); }; + const show = x => x.diagnostics.map(d => `${d.code}@${d.line}: ${String(d.message ?? "").slice(0, 160)}`).join(" | ") || "accepted"; + const entries = task.entries ?? [task.entry ?? "main.rx"]; + + // (a) GOOD: accepted by both checkers, which agree + let accepted = true; + for (const e of entries) { + const r = both(path.join(dir, e), task.spa, task.host); + const ok = !r.crate.diagnostics.length && !r.ref.diagnostics.length; + accepted &&= ok; + mark(res.good, `${e}: accepted by the crate`, !r.crate.diagnostics.length, show(r.crate)); + mark(res.good, `${e}: accepted by ref/`, !r.ref.diagnostics.length, show(r.ref)); + mark(res.good, `${e}: the two agree`, r.agree, `crate: ${show(r.crate)} / ref: ${show(r.ref)}`); + for (const a of task.advice ?? []) mark(res.good, `${e}: advice ${a}`, r.crate.advice.some(d => d.code === a) && r.ref.advice.some(d => d.code === a), `crate: ${r.crate.advice.map(d => d.code)} / ref: ${r.ref.advice.map(d => d.code)}`); + } + + // the declarations, against rx-declare's draft of the same modules (before anything is edited) + try { res.decl = declarations(dir, task.declare ?? {}); } catch (e) { res.decl = { words: 0, any: 0, files: [], error: String(e.message ?? e) }; } + + // (b) TYPES: rx-tsc is clean with the library's own types, the program wrote no `any`, and each probe — a mistake + // only the library's real type refuses — is refused by TypeScript, on the line the probe wrote + if (task.types !== false) { + const clean = rxTsc(dir); + mark(res.types, "rx-tsc: clean with the library's types", clean === "", clean); + const anys = anysWritten(dir); + mark(res.types, "no `any` written in the .rx", anys.length === 0, anys.join(", ")); + for (const p of task.types ?? []) { + let undo; try { undo = edit(dir, p.file ?? entries[0], p.edit); } catch (e) { mark(res.types, p.name, false, e.message); continue; } + const out = rxTsc(dir); undo(); + const there = onEdit(out, dir, p.file ?? entries[0], p.edit); + mark(res.types, `${p.name} (${p.expect.source})`, p.expect.test(there), !out ? "rx-tsc accepted it: the type was lost" : there ? there : `nothing on the edited line; elsewhere: ${out}`); + } + } + + // (c) RUNTIME: the task drives its compiled program (server render, Chromium) + if (task.run) { + if (!accepted) mark(res.runtime, "the good program runs", false, "not compiled: the checker refused it"); + else { + const h = new Runner(dir, entries[0], task.spa); + try { await task.run(h); } catch (e) { h.check("the run completed", false, e.stack ?? String(e)); } + await h.close(); + for (const c of h.checks) mark(res.runtime, c.name, c.ok, c.got); + } + } + + // (d) BAD: each variant is refused by both checkers with the code named, by a diagnostic the good program does not + // have — or (`orSafe`) compiles to a program in which the mistake does no harm, or (`dev`) compiles and fails loudly + // when it is run, or (`ts`) is refused by TypeScript + const sig = d => `${d.code}|${String(d.message ?? "").replace(/\d+/g, "#")}`; + const goodDiags = {}; + for (const e of entries) { const r = both(path.join(dir, e), task.spa, task.host); goodDiags[e] = { crate: new Set(r.crate.diagnostics.map(sig)), ref: new Set(r.ref.diagnostics.map(sig)) }; } + const drive = async (b, how) => { + const h = new Runner(dir, b.entry ?? entries[0], b.spa ?? task.spa); + let threw = ""; try { await how(h); } catch (e) { threw = String(e.message ?? e); } + await h.close(); + return { h, threw }; + }; + for (const b of task.bad ?? []) { + const col = b.ts || UNWRITABLE.has(b.expect) ? res.unrep : res.bad; // a mistake that cannot be written is counted apart + let undo; try { const u1 = edit(dir, b.file ?? entries[0], b.edit); const u2 = b.edit2 ? edit(dir, b.file ?? entries[0], b.edit2) : null; undo = () => { u2?.(); u1(); }; } catch (e) { mark(col, b.name, false, e.message); continue; } + const e0 = b.entry ?? entries[0]; const entry = path.join(dir, e0); + try { + if (b.expect) { + const spa = b.spa ?? task.spa; + const r = both(entry, spa, task.host); + const was = spa === task.spa ? goodDiags[e0] : (() => { undo(); const g = both(entry, spa, task.host); undo = edit(dir, b.file ?? entries[0], b.edit); return { crate: new Set(g.crate.diagnostics.map(sig)), ref: new Set(g.ref.diagnostics.map(sig)) }; })(); + const hit = (x, old) => x.diagnostics.some(d => d.code === b.expect && !old.has(sig(d))); + let ok = hit(r.crate, was.crate) && hit(r.ref, was.ref) && r.agree, why = `crate: ${show(r.crate)} / ref: ${show(r.ref)}`; + if (!ok && b.orSafe && !r.crate.diagnostics.length && !r.ref.diagnostics.length) { + const { h, threw } = await drive(b, b.orSafe); + const bad = [threw, ...h.checks.filter(c => !c.ok).map(c => `${c.name}: ${c.got ?? ""}`)].filter(Boolean); + ok = !bad.length && h.checks.length > 0; why = `accepted, and not harmless when run: ${bad.join(" | ")}`; + } + mark(col, `${b.name} (${b.expect}${b.orSafe ? ", or harmless" : ""})`, ok, why); + } else if (b.advise) { + // advice, never an error (99, the advisory rows): the program is accepted, and both checkers say the same advice + const r = both(entry, b.spa ?? task.spa, task.host); + const ok = !r.crate.diagnostics.length && !r.ref.diagnostics.length && r.crate.advice.some(d => d.code === b.advise) && r.ref.advice.some(d => d.code === b.advise) && r.agree; + mark(res.bad, `${b.name} (advice: ${b.advise})`, ok, `crate: ${show(r.crate)}, advice ${r.crate.advice.map(d => d.code).join(",") || "none"} / ref: ${show(r.ref)}, advice ${r.ref.advice.map(d => d.code).join(",") || "none"}`); + } else if (b.ts) { + const out = rxTsc(dir); + mark(col, `${b.name} (${b.ts.source})`, b.ts.test(out), out || "rx-tsc accepted it"); + } else if (b.dev) { + // only the runtime can know: the program compiles, and running it reports the mistake where a developer sees it + const r = both(entry, b.spa ?? task.spa, task.host); + if (r.crate.diagnostics.length) mark(res.bad, `${b.name} (dev: ${b.dev.source})`, false, `not compiled: ${show(r.crate)}`); + else { + const { h, threw } = await drive(b, b.drive); + const said = [threw, ...h.problems, ...h.checks.filter(c => !c.ok).map(c => c.got ?? "")].join(" | "); + mark(res.bad, `${b.name} (dev: ${b.dev.source})`, b.dev.test(said), said || "ran silently"); + } + } + } finally { undo(); } + } + return res; +} + +if (one) { + const r = await runTask(one).catch(e => ({ id: one, crash: e.stack ?? String(e) })); + writeFileSync(path.join(ws, "tasks", `${one}.result.json`), JSON.stringify(r)); + process.exit(0); +} + +workspace(); +const filters = args.filter(a => !a.startsWith("--")); +const ids = readdirSync(path.join(here, "tasks"), { withFileTypes: true }).filter(e => e.isDirectory() && existsSync(path.join(here, "tasks", e.name, "task.mjs"))).map(e => e.name).sort().filter(id => !filters.length || filters.some(f => id.includes(f))); +const results = []; +for (const id of ids) { + const out = path.join(ws, "tasks", `${id}.result.json`); + const r = spawnSync(process.execPath, [path.join(here, "run.mjs"), "--task", id], { stdio: ["ignore", "inherit", "inherit"], timeout: 600000 }); + let res; try { res = JSON.parse(readFileSync(out, "utf8")); } catch { res = { id, crash: `no result (exit ${r.status}${r.signal ? `, ${r.signal}` : ""})` }; } + results.push(res); +} + +// ---- the scorecard ---- +const cols = [["good", "good accepted"], ["types", "types kept"], ["runtime", "runtime ok"], ["bad", "bad caught"], ["unrep", "unrepresentable"]]; +// the declarations' two numbers (lower is better; no pass or fail): words written by hand over rx-declare's draft, and `any`s +const nums = [["words", "hand-written .d.rx words"], ["any", "`any` in .d.rx"]]; +const cellText = c => !c || !c.total ? "—" : `${c.pass}/${c.total}`; +const lines = []; +const w = Math.max(...results.map(r => r.id.length), 4); +const cw = t => Math.max(13, t.length); +const rule = "-".repeat(w + [...cols, ...nums].reduce((n, [, t]) => n + cw(t) + 2, 0)); +lines.push(`${"task".padEnd(w)} ${[...cols, ...nums].map(([, t]) => t.padEnd(cw(t))).join(" ")}`); +lines.push(rule); +const total = Object.fromEntries(cols.map(([k]) => [k, { pass: 0, total: 0 }])); +const sum = Object.fromEntries(nums.map(([k]) => [k, 0])); +for (const r of results) { + if (r.crash) { lines.push(`${r.id.padEnd(w)} CRASHED: ${r.crash.split("\n")[0]}`); continue; } + lines.push(`${r.id.padEnd(w)} ${[...cols.map(([k, t]) => { total[k].pass += r[k].pass; total[k].total += r[k].total; return `${cellText(r[k])}${r[k].total && r[k].pass === r[k].total ? " ✓" : r[k].total ? " ✗" : ""}`.padEnd(cw(t)); }), ...nums.map(([k, t]) => { sum[k] += r.decl[k]; return (r.decl.files.length ? String(r.decl[k]) : "—").padEnd(cw(t)); })].join(" ")}`); +} +lines.push(rule); +lines.push(`${"total".padEnd(w)} ${[...cols.map(([k, t]) => `${total[k].pass}/${total[k].total}`.padEnd(cw(t))), ...nums.map(([k, t]) => String(sum[k]).padEnd(cw(t)))].join(" ")}`); +const failing = []; +for (const r of results) { + if (r.crash) { failing.push(`${r.id}: crashed\n ${r.crash}`); continue; } + for (const [k, t] of cols) for (const f of r[k].fails) { + const name = f.split(" — ")[0]; + const reason = Object.entries(r.known).find(([n]) => name.includes(n))?.[1]; + failing.push(`${r.id} · ${t} · ${f}${reason ? `\n known: ${reason}` : ""}`); + } +} +// the declarations, file by file: where the hand-written words are +const declLines = results.filter(r => !r.crash && r.decl.files.length).flatMap(r => r.decl.files.map(f => ` ${r.id}/${f.file}: ${f.words} word${f.words === 1 ? "" : "s"} by hand${f.drafted ? "" : " (rx-declare drafts nothing for it: the module has no types)"}, ${f.any} \`any\``)); +const card = lines.join("\n") + (failing.length ? `\n\nNot green (${failing.length}):\n${failing.map(f => ` ✗ ${f}`).join("\n")}` : "\n\nAll green.") + (declLines.length ? `\n\nDeclarations (words written by hand over rx-declare's draft; \`any\`s held):\n${declLines.join("\n")}` : ""); +console.log("\n" + card); + +const snapshot = Object.fromEntries(results.map(r => [r.id, r.crash ? { crash: true } : { ...Object.fromEntries(cols.map(([k]) => [k, { pass: r[k].pass, total: r[k].total, fails: r[k].fails.map(f => f.split(" — ")[0]) }])), decl: { words: r.decl.words, any: r.decl.any } }])); +if (flag("--write")) { + writeFileSync(path.join(here, "scorecard.json"), JSON.stringify(snapshot, null, 2) + "\n"); + writeFileSync(path.join(here, "scorecard.txt"), card.replaceAll(ws, "bench/.out/ws") + "\n"); +} +let exit = 0; +if (flag("--check")) { + // the ratchet: nothing that the committed scorecard has green may be red, and every red is a documented one + const was = JSON.parse(readFileSync(path.join(here, "scorecard.json"), "utf8")); + const problems = []; + for (const r of results) { + const old = was[r.id]; + if (r.crash) { problems.push(`${r.id}: crashed`); continue; } + for (const [k, t] of cols) for (const f of r[k].fails) { + const name = f.split(" — ")[0]; + if (old && !old[k]?.fails.includes(name)) problems.push(`${r.id} · ${t} · ${name}: was green in bench/scorecard.json`); + else if (flag("--strict") && !Object.keys(r.known).some(n => name.includes(n))) problems.push(`${r.id} · ${t} · ${name}: fails, and the task's \`known\` gives no reason for it`); + } + // the declarations may not need more hand-written words, nor hold more `any`s, than the committed scorecard's + for (const [k, t] of nums) if (old?.decl && r.decl[k] > old.decl[k]) problems.push(`${r.id} · ${t}: ${r.decl[k]}, was ${old.decl[k]} in bench/scorecard.json`); + if (flag("--strict")) for (const n of Object.keys(r.known)) if (!cols.some(([k]) => r[k].fails.some(f => f.split(" — ")[0].includes(n)))) problems.push(`${r.id}: \`known\` names "${n}", which does not fail (remove it)`); + } + if (problems.length) { console.log(`\n--check: ${problems.length} problem(s)\n${problems.map(p => ` ${p}`).join("\n")}`); exit = 1; } else console.log("\n--check: as bench/scorecard.json, or better; every failure is a documented one"); +} +process.exit(exit); diff --git a/bench/scorecard-2f9baf7.txt b/bench/scorecard-2f9baf7.txt new file mode 100644 index 00000000..a70af790 --- /dev/null +++ b/bench/scorecard-2f9baf7.txt @@ -0,0 +1,23 @@ +task good accepted types kept runtime ok bad caught +--------------------------------------------------------------------------------- +duplicate-keys 3/3 ✓ 3/3 ✓ 3/3 ✓ 1/2 ✗ +formisch-field-path 3/3 ✓ 6/6 ✓ 4/4 ✓ 4/4 ✓ +frozen-read 3/3 ✓ 3/3 ✓ 3/3 ✓ 5/5 ✓ +kobalte-dialog 3/3 ✓ 4/4 ✓ 5/5 ✓ 5/5 ✓ +listener-cleanup 3/3 ✓ 3/3 ✓ 4/4 ✓ 4/4 ✓ +query-forward 3/3 ✓ 5/5 ✓ 3/3 ✓ 6/6 ✓ +router-provider 3/3 ✓ 5/5 ✓ 4/4 ✓ 6/6 ✓ +sequential-awaits 3/3 ✓ 3/3 ✓ 2/2 ✓ 3/3 ✓ +source-mutation 3/3 ✓ 3/3 ✓ 3/3 ✓ 4/4 ✓ +ssr-divergence 3/3 ✓ 3/3 ✓ 3/3 ✓ 2/3 ✗ +start-route 3/3 ✓ 5/5 ✓ 8/8 ✓ 3/3 ✓ +store-updater 3/3 ✓ 5/5 ✓ 5/5 ✓ 7/7 ✓ +table-pagination 3/3 ✓ 7/7 ✓ 8/8 ✓ 7/7 ✓ +--------------------------------------------------------------------------------- +total 39/39 55/55 55/55 57/59 + +Not green (2): + ✗ duplicate-keys · bad caught · rows added with a key the list already has (known only when it runs) (dev: duplicate key|DUPLICATE_KEY) — ran silently + known: 06 ST-4d, 08 CN-2: a key computed at run time is the data's (bin R). The checker refuses rows written out with one key; it cannot see a key that a click computes, a static check does not become a run-time one, and Solid's development build reports no duplicate either. The variant stays as the measure of that limit. + ✗ ssr-divergence · bad caught · a `pure` JS call that answers differently on each side, read by the view (the declaration's assertion: reported when it runs) (dev: HYDRATION_MISMATCH|mismatch) — ran silently + known: 10 SV-7c (ruled 2026-10-24), 08 CN-5: `pure` is the author's assertion at the JS boundary, the one unchecked word, and that the function answers alike on both machines is part of it. What only the browser knows is `client` JS, which is checked (SV-7b: the good program). Solid's development build adopts the server's text without comparing it, so nothing reports this mismatch, and the language adds no run-time comparison of its own. diff --git a/bench/scorecard.json b/bench/scorecard.json new file mode 100644 index 00000000..b7f665a0 --- /dev/null +++ b/bench/scorecard.json @@ -0,0 +1,807 @@ +{ + "context-provider": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 5, + "total": 5, + "fails": [] + }, + "runtime": { + "pass": 4, + "total": 4, + "fails": [] + }, + "bad": { + "pass": 5, + "total": 7, + "fails": [ + "the provided action called while the view computes (ACTION_CALLED_IN_OWNED_SCOPE)", + "the same through a prop: a row's handler called, not passed on (ACTION_CALLED_IN_OWNED_SCOPE)" + ] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 0, + "any": 0 + } + }, + "duplicate-keys": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 3, + "total": 3, + "fails": [] + }, + "runtime": { + "pass": 3, + "total": 3, + "fails": [] + }, + "bad": { + "pass": 1, + "total": 2, + "fails": [ + "rows added with a key the list already has (known only when it runs) (dev: duplicate key|DUPLICATE_KEY)" + ] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 0, + "any": 0 + } + }, + "effect-derived": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 3, + "total": 3, + "fails": [] + }, + "runtime": { + "pass": 4, + "total": 4, + "fails": [] + }, + "bad": { + "pass": 1, + "total": 5, + "fails": [ + "the total kept in a source, written by a mount effect that reads the others: computed once, stale after (EFFECT_RELAY_TEAR)", + "the same with the inputs named: a frame late, an equation written the long way (EFFECT_RELAY_TEAR)", + "the history appended by an effect on the quantity, not by the click that changed it (EFFECT_RELAY_TEAR)", + "the title set by a mount effect that reads the total by name: sent once, never again (advice: SNAPSHOT_IN_EFFECT)" + ] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 0, + "any": 0 + } + }, + "formisch-field-array": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 6, + "total": 6, + "fails": [] + }, + "runtime": { + "pass": 7, + "total": 7, + "fails": [] + }, + "bad": { + "pass": 4, + "total": 5, + "fails": [ + "the list of row ids changed in place (MUTATION_IN_PLACE)" + ] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 35, + "any": 26 + } + }, + "formisch-field-path": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 6, + "total": 6, + "fails": [] + }, + "runtime": { + "pass": 4, + "total": 4, + "fails": [] + }, + "bad": { + "pass": 2, + "total": 2, + "fails": [] + }, + "unrep": { + "pass": 2, + "total": 2, + "fails": [] + }, + "decl": { + "words": 37, + "any": 16 + } + }, + "frozen-read": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 3, + "total": 3, + "fails": [] + }, + "runtime": { + "pass": 3, + "total": 3, + "fails": [] + }, + "bad": { + "pass": 4, + "total": 4, + "fails": [] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 2, + "any": 0 + } + }, + "keyed-edits": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 4, + "total": 4, + "fails": [] + }, + "runtime": { + "pass": 3, + "total": 7, + "fails": [ + "rename in place: the row keeps its state", + "remove: the others stay as they are", + "reset to rows written out: the kept keys keep their rows' state", + "no console errors or warnings" + ] + }, + "bad": { + "pass": 4, + "total": 6, + "fails": [ + "the list reset from a handler with two rows of one key (DUPLICATE_KEY)", + "rows added in a handler's functional write, two written with one key (DUPLICATE_KEY)" + ] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 0, + "any": 0 + } + }, + "kobalte-dialog": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 4, + "total": 4, + "fails": [] + }, + "runtime": { + "pass": 5, + "total": 5, + "fails": [] + }, + "bad": { + "pass": 3, + "total": 3, + "fails": [] + }, + "unrep": { + "pass": 2, + "total": 2, + "fails": [] + }, + "decl": { + "words": 18, + "any": 28 + } + }, + "kobalte-select": { + "good": { + "pass": 1, + "total": 3, + "fails": [ + "main.rx: accepted by the crate", + "main.rx: accepted by ref/" + ] + }, + "types": { + "pass": 4, + "total": 5, + "fails": [ + "rx-tsc: clean with the library's types" + ] + }, + "runtime": { + "pass": 0, + "total": 1, + "fails": [ + "the good program runs" + ] + }, + "bad": { + "pass": 2, + "total": 3, + "fails": [ + "an item rendered outside the select (its context is the listbox's, which only running it shows) (dev: context|Context|within|undefined|null)" + ] + }, + "unrep": { + "pass": 1, + "total": 1, + "fails": [] + }, + "decl": { + "words": 11, + "any": 60 + } + }, + "listener-cleanup": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 3, + "total": 3, + "fails": [] + }, + "runtime": { + "pass": 4, + "total": 4, + "fails": [] + }, + "bad": { + "pass": 4, + "total": 4, + "fails": [] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 3, + "any": 0 + } + }, + "optimistic-todo": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 4, + "total": 4, + "fails": [] + }, + "runtime": { + "pass": 6, + "total": 6, + "fails": [] + }, + "bad": { + "pass": 4, + "total": 6, + "fails": [ + "an optimistic write outside an action: a guess in a handler that awaits nothing (GUESS_OUTSIDE_ACTION)", + "an await before the optimistic write: the row shows only once the server has answered (advice: GUESS_AFTER_AWAIT)" + ] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 0, + "any": 0 + } + }, + "primitives-virtual": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 5, + "total": 5, + "fails": [] + }, + "runtime": { + "pass": 6, + "total": 6, + "fails": [] + }, + "bad": { + "pass": 3, + "total": 5, + "fails": [ + "a listener's disposer dropped (its type is the library's alias for `() => void`) (DISPOSER_DROPPED)", + "a listener added by hand in a click handler, its disposer dropped: one more on every click (DISPOSER_DROPPED)" + ] + }, + "unrep": { + "pass": 1, + "total": 1, + "fails": [] + }, + "decl": { + "words": 24, + "any": 17 + } + }, + "projection-selection": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 3, + "total": 4, + "fails": [ + "rx-tsc: clean with the library's types" + ] + }, + "runtime": { + "pass": 4, + "total": 4, + "fails": [] + }, + "bad": { + "pass": 2, + "total": 4, + "fails": [ + "the selection kept in a store, written by an effect on the picked id (EFFECT_RELAY_TEAR)", + "…by a mount effect that reads the picked id: the first row stays selected for ever (EFFECT_RELAY_TEAR)" + ] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 0, + "any": 0 + } + }, + "query-forward": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 6, + "total": 6, + "fails": [] + }, + "runtime": { + "pass": 6, + "total": 6, + "fails": [] + }, + "bad": { + "pass": 5, + "total": 5, + "fails": [] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 30, + "any": 5 + } + }, + "query-mutation": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 5, + "total": 5, + "fails": [] + }, + "runtime": { + "pass": 5, + "total": 5, + "fails": [] + }, + "bad": { + "pass": 4, + "total": 7, + "fails": [ + "the query's function reads the id, its key does not: the cache answers the first todo for every id (KEY_MISSES_INPUT, or harmless)", + "the mutation run while the view computes (IO_IN_REACTIVE)", + "the cache invalidated while the view computes (IO_IN_REACTIVE)" + ] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 39, + "any": 11 + } + }, + "router-data": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 5, + "total": 5, + "fails": [] + }, + "runtime": { + "pass": 5, + "total": 5, + "fails": [] + }, + "bad": { + "pass": 7, + "total": 7, + "fails": [] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 61, + "any": 7 + } + }, + "router-provider": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 5, + "total": 5, + "fails": [] + }, + "runtime": { + "pass": 4, + "total": 4, + "fails": [] + }, + "bad": { + "pass": 5, + "total": 5, + "fails": [] + }, + "unrep": { + "pass": 1, + "total": 1, + "fails": [] + }, + "decl": { + "words": 51, + "any": 8 + } + }, + "sequential-awaits": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 3, + "total": 3, + "fails": [] + }, + "runtime": { + "pass": 4, + "total": 4, + "fails": [] + }, + "bad": { + "pass": 2, + "total": 3, + "fails": [ + "two independent loads awaited one after the other (advice: ASYNC_WATERFALL)" + ] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 0, + "any": 2 + } + }, + "source-mutation": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 3, + "total": 3, + "fails": [] + }, + "runtime": { + "pass": 3, + "total": 3, + "fails": [] + }, + "bad": { + "pass": 4, + "total": 4, + "fails": [] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 0, + "any": 0 + } + }, + "ssr-divergence": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 3, + "total": 3, + "fails": [] + }, + "runtime": { + "pass": 3, + "total": 3, + "fails": [] + }, + "bad": { + "pass": 2, + "total": 3, + "fails": [ + "a `pure` JS call that answers differently on each side, read by the view (the declaration's assertion: reported when it runs) (dev: HYDRATION_MISMATCH|mismatch)" + ] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 3, + "any": 0 + } + }, + "start-route": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 5, + "total": 5, + "fails": [] + }, + "runtime": { + "pass": 8, + "total": 8, + "fails": [] + }, + "bad": { + "pass": 2, + "total": 2, + "fails": [] + }, + "unrep": { + "pass": 1, + "total": 1, + "fails": [] + }, + "decl": { + "words": 20, + "any": 0 + } + }, + "store-helper": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 3, + "total": 4, + "fails": [ + "rx-tsc: clean with the library's types" + ] + }, + "runtime": { + "pass": 1, + "total": 4, + "fails": [ + "the helper moved the draft's own list: the store follows", + "a helper that sorts in place", + "and again, composed" + ] + }, + "bad": { + "pass": 4, + "total": 4, + "fails": [] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 12, + "any": 3 + } + }, + "store-updater": { + "good": { + "pass": 3, + "total": 3, + "fails": [] + }, + "types": { + "pass": 5, + "total": 5, + "fails": [] + }, + "runtime": { + "pass": 5, + "total": 5, + "fails": [] + }, + "bad": { + "pass": 5, + "total": 5, + "fails": [] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 12, + "any": 0 + } + }, + "table-pagination": { + "good": { + "pass": 1, + "total": 3, + "fails": [ + "main.rx: accepted by the crate", + "main.rx: accepted by ref/" + ] + }, + "types": { + "pass": 7, + "total": 8, + "fails": [ + "rx-tsc: clean with the library's types" + ] + }, + "runtime": { + "pass": 0, + "total": 1, + "fails": [ + "the good program runs" + ] + }, + "bad": { + "pass": 5, + "total": 5, + "fails": [] + }, + "unrep": { + "pass": 0, + "total": 0, + "fails": [] + }, + "decl": { + "words": 79, + "any": 12 + } + } +} diff --git a/bench/scorecard.txt b/bench/scorecard.txt new file mode 100644 index 00000000..76def156 --- /dev/null +++ b/bench/scorecard.txt @@ -0,0 +1,101 @@ +task good accepted types kept runtime ok bad caught unrepresentable hand-written .d.rx words `any` in .d.rx +------------------------------------------------------------------------------------------------------------------------------------------- +context-provider 3/3 ✓ 5/5 ✓ 4/4 ✓ 5/7 ✗ — — — +duplicate-keys 3/3 ✓ 3/3 ✓ 3/3 ✓ 1/2 ✗ — — — +effect-derived 3/3 ✓ 3/3 ✓ 4/4 ✓ 1/5 ✗ — 0 0 +formisch-field-array 3/3 ✓ 6/6 ✓ 7/7 ✓ 4/5 ✗ — 35 26 +formisch-field-path 3/3 ✓ 6/6 ✓ 4/4 ✓ 2/2 ✓ 2/2 ✓ 37 16 +frozen-read 3/3 ✓ 3/3 ✓ 3/3 ✓ 4/4 ✓ — 2 0 +keyed-edits 3/3 ✓ 4/4 ✓ 3/7 ✗ 4/6 ✗ — — — +kobalte-dialog 3/3 ✓ 4/4 ✓ 5/5 ✓ 3/3 ✓ 2/2 ✓ 18 28 +kobalte-select 1/3 ✗ 4/5 ✗ 0/1 ✗ 2/3 ✗ 1/1 ✓ 11 60 +listener-cleanup 3/3 ✓ 3/3 ✓ 4/4 ✓ 4/4 ✓ — 3 0 +optimistic-todo 3/3 ✓ 4/4 ✓ 6/6 ✓ 4/6 ✗ — — — +primitives-virtual 3/3 ✓ 5/5 ✓ 6/6 ✓ 3/5 ✗ 1/1 ✓ 24 17 +projection-selection 3/3 ✓ 3/4 ✗ 4/4 ✓ 2/4 ✗ — — — +query-forward 3/3 ✓ 6/6 ✓ 6/6 ✓ 5/5 ✓ — 30 5 +query-mutation 3/3 ✓ 5/5 ✓ 5/5 ✓ 4/7 ✗ — 39 11 +router-data 3/3 ✓ 5/5 ✓ 5/5 ✓ 7/7 ✓ — 61 7 +router-provider 3/3 ✓ 5/5 ✓ 4/4 ✓ 5/5 ✓ 1/1 ✓ 51 8 +sequential-awaits 3/3 ✓ 3/3 ✓ 4/4 ✓ 2/3 ✗ — 0 2 +source-mutation 3/3 ✓ 3/3 ✓ 3/3 ✓ 4/4 ✓ — — — +ssr-divergence 3/3 ✓ 3/3 ✓ 3/3 ✓ 2/3 ✗ — 3 0 +start-route 3/3 ✓ 5/5 ✓ 8/8 ✓ 2/2 ✓ 1/1 ✓ 20 0 +store-helper 3/3 ✓ 3/4 ✗ 1/4 ✗ 4/4 ✓ — 12 3 +store-updater 3/3 ✓ 5/5 ✓ 5/5 ✓ 5/5 ✓ — 12 0 +table-pagination 1/3 ✗ 7/8 ✗ 0/1 ✗ 5/5 ✓ — 79 12 +------------------------------------------------------------------------------------------------------------------------------------------- +total 68/72 103/107 97/106 84/106 8/8 437 195 + +Not green (39): + ✗ context-provider · bad caught · the provided action called while the view computes (ACTION_CALLED_IN_OWNED_SCOPE) — crate: accepted / ref: accepted + ✗ context-provider · bad caught · the same through a prop: a row's handler called, not passed on (ACTION_CALLED_IN_OWNED_SCOPE) — crate: accepted / ref: accepted + ✗ duplicate-keys · bad caught · rows added with a key the list already has (known only when it runs) (dev: duplicate key|DUPLICATE_KEY) — ran silently + known: 06 ST-4d, 08 CN-2: a key computed at run time is the data's (bin R). The checker refuses rows written out with one key; it cannot see a key that a click computes, a static check does not become a run-time one, and Solid's development build reports no duplicate either. The variant stays as the measure of that limit. + ✗ effect-derived · bad caught · the total kept in a source, written by a mount effect that reads the others: computed once, stale after (EFFECT_RELAY_TEAR) — crate: accepted / ref: accepted + ✗ effect-derived · bad caught · the same with the inputs named: a frame late, an equation written the long way (EFFECT_RELAY_TEAR) — crate: accepted / ref: accepted + ✗ effect-derived · bad caught · the history appended by an effect on the quantity, not by the click that changed it (EFFECT_RELAY_TEAR) — crate: accepted / ref: accepted + ✗ effect-derived · bad caught · the title set by a mount effect that reads the total by name: sent once, never again (advice: SNAPSHOT_IN_EFFECT) — crate: accepted, advice none / ref: accepted, advice none + ✗ formisch-field-array · bad caught · the list of row ids changed in place (MUTATION_IN_PLACE) — crate: accepted / ref: accepted + ✗ keyed-edits · runtime ok · rename in place: the row keeps its state — new,cook,wash,read / open cook + ✗ keyed-edits · runtime ok · remove: the others stay as they are — cook,wash,read / open cook + ✗ keyed-edits · runtime ok · reset to rows written out: the kept keys keep their rows' state — wash,cook / open + ✗ keyed-edits · runtime ok · no console errors or warnings — ["[UNRECOGNIZED_INSERT_VALUE] Unrecognized value. Skipped inserting (function).\n[UNRECOGNIZED_INSERT_VALUE] what it means and how to fix it: https://docs.solidjs.com/reference/solid-js/diagnostics/unrecognized-insert-value\n[UNRECOGNIZED_INSERT_VALUE] agent repair guide: node_modules/solid-js/skills/re"] + ✗ keyed-edits · bad caught · the list reset from a handler with two rows of one key (DUPLICATE_KEY) — crate: accepted / ref: accepted + ✗ keyed-edits · bad caught · rows added in a handler's functional write, two written with one key (DUPLICATE_KEY) — crate: accepted / ref: accepted + ✗ kobalte-select · good accepted · main.rx: accepted by the crate — VIEW_FN_EXPECTED@22: 's children are a function of what it renders: write them as `{view (item) { … }}` + ✗ kobalte-select · good accepted · main.rx: accepted by ref/ — VIEW_FN_EXPECTED@22: 's children are a function of what it renders: write them as `{view (item) { … }}` + ✗ kobalte-select · types kept · rx-tsc: clean with the library's types — main.rx:22:7 - error VIEW_FN_EXPECTED: 's children are a function of what it renders: write them as `{view (item) { … }}` (MO-11k) Found 1 ReactiveScript error. VIEW_FN_EXPECTED: why, and the fix — https://github.com/solidjs/reactivescript/blob/main/guide/diagnostics.md#view_fn_expected + ✗ kobalte-select · runtime ok · the good program runs — not compiled: the checker refused it + ✗ kobalte-select · bad caught · an item rendered outside the select (its context is the listbox's, which only running it shows) (dev: context|Context|within|undefined|null) — not compiled: VIEW_FN_EXPECTED@22: 's children are a function of what it renders: write them as `{view (item) { … }}` + ✗ optimistic-todo · bad caught · an optimistic write outside an action: a guess in a handler that awaits nothing (GUESS_OUTSIDE_ACTION) — crate: accepted / ref: accepted + ✗ optimistic-todo · bad caught · an await before the optimistic write: the row shows only once the server has answered (advice: GUESS_AFTER_AWAIT) — crate: accepted, advice none / ref: accepted, advice none + ✗ primitives-virtual · bad caught · a listener's disposer dropped (its type is the library's alias for `() => void`) (DISPOSER_DROPPED) — crate: accepted / ref: accepted + ✗ primitives-virtual · bad caught · a listener added by hand in a click handler, its disposer dropped: one more on every click (DISPOSER_DROPPED) — crate: accepted / ref: accepted + ✗ projection-selection · types kept · rx-tsc: clean with the library's types — main.rx(14,76): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on type '{}'. main.rx(14,110): error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{}'. No index signature with a parameter of type 'string' was found on ty + ✗ projection-selection · bad caught · the selection kept in a store, written by an effect on the picked id (EFFECT_RELAY_TEAR) — crate: accepted / ref: accepted + ✗ projection-selection · bad caught · …by a mount effect that reads the picked id: the first row stays selected for ever (EFFECT_RELAY_TEAR) — crate: accepted / ref: accepted + ✗ query-mutation · bad caught · the query's function reads the id, its key does not: the cache answers the first todo for every id (KEY_MISSES_INPUT, or harmless) — accepted, and not harmless when run: the other todo is shown: milk + ✗ query-mutation · bad caught · the mutation run while the view computes (IO_IN_REACTIVE) — crate: accepted / ref: accepted + ✗ query-mutation · bad caught · the cache invalidated while the view computes (IO_IN_REACTIVE) — crate: accepted / ref: accepted + ✗ sequential-awaits · bad caught · two independent loads awaited one after the other (advice: ASYNC_WATERFALL) — crate: accepted, advice none / ref: accepted, advice none + ✗ ssr-divergence · bad caught · a `pure` JS call that answers differently on each side, read by the view (the declaration's assertion: reported when it runs) (dev: HYDRATION_MISMATCH|mismatch) — ran silently + known: 10 SV-7c (ruled 2026-10-24), 08 CN-5: `pure` is the author's assertion at the JS boundary, the one unchecked word, and that the function answers alike on both machines is part of it. What only the browser knows is `client` JS, which is checked (SV-7b: the good program). Solid's development build adopts the server's text without comparing it, so nothing reports this mismatch, and the language adds no run-time comparison of its own. + ✗ store-helper · types kept · rx-tsc: clean with the library's types — array.d.rx:3:1 - error DECLARATION_MISMATCH: sortBy: Type '(list: T[], key: keyof T) => void' is not assignable to type '__decl_sortBy'. Types of parameters 'key' and 'key' are incompatible. Type 'any' is not assignable to type 'never'. (TY-6) Found 1 ReactiveScript error. DECLARATION_MISMATCH: why, and the fix — https://github.com/solidjs/reactivescript/blob/main/guide/diagnostics.md#declaration_mismatch + ✗ store-helper · runtime ok · the helper moved the draft's own list: the store follows — todo,doing,done / 1 moves + ✗ store-helper · runtime ok · a helper that sorts in place — todo,doing,done + ✗ store-helper · runtime ok · and again, composed — todo,doing,done / 2 moves + ✗ table-pagination · good accepted · main.rx: accepted by the crate — RENDERS_ESCAPES@47: table holds components `renders` checked where table is bound, and here it is passed to as table: render it in the view where table is bou + ✗ table-pagination · good accepted · main.rx: accepted by ref/ — RENDERS_ESCAPES@47: table holds components `renders` checked where table is bound, and here it is passed to as table: render it in the view where table is bou + ✗ table-pagination · types kept · rx-tsc: clean with the library's types — main.rx:47:3 - error RENDERS_ESCAPES: table holds components `renders` checked where table is bound, and here it is passed to as table: render it in the view where table is bound — what leaves that view is a primitive made of it (`str(…)`, a template, arithmetic, a comparison, `len(…)`) — or declare the library `renders(later)` with a prop that `renders` it (MO-11o), or `renders(root, …)` if it + ✗ table-pagination · runtime ok · the good program runs — not compiled: the checker refused it + +Declarations (words written by hand over rx-declare's draft; `any`s held): + effect-derived/page.d.rx: 0 words by hand, 0 `any` + formisch-field-array/rx-types/@formisch/solid/v2.d.rx: 6 words by hand, 18 `any` + formisch-field-array/rx-types/valibot.d.rx: 29 words by hand, 8 `any` + formisch-field-path/rx-types/@formisch/solid/v2.d.rx: 6 words by hand, 9 `any` + formisch-field-path/rx-types/valibot.d.rx: 31 words by hand, 7 `any` + frozen-read/label.d.rx: 2 words by hand, 0 `any` + kobalte-dialog/rx-types/@kobalte/core/dialog.d.rx: 18 words by hand, 28 `any` + kobalte-select/rx-types/@kobalte/core/select.d.rx: 11 words by hand, 60 `any` + listener-cleanup/keys.d.rx: 3 words by hand, 0 `any` + primitives-virtual/rx-types/@solid-primitives/event-listener.d.rx: 4 words by hand, 11 `any` + primitives-virtual/rx-types/@solid-primitives/resize-observer.d.rx: 3 words by hand, 4 `any` + primitives-virtual/virtual.d.rx: 17 words by hand, 2 `any` + query-forward/api.d.rx: 8 words by hand, 1 `any` + query-forward/rx-types/@tanstack/solid-query.d.rx: 22 words by hand, 4 `any` + query-mutation/api.d.rx: 6 words by hand, 2 `any` + query-mutation/rx-types/@tanstack/solid-query.d.rx: 33 words by hand, 9 `any` + router-data/people.d.rx: 6 words by hand, 1 `any` + router-data/rx-types/@solidjs/router.d.rx: 55 words by hand, 6 `any` + router-provider/people.d.rx: 9 words by hand, 0 `any` + router-provider/rx-types/@tanstack/solid-router.d.rx: 42 words by hand, 8 `any` + sequential-awaits/api.d.rx: 0 words by hand, 2 `any` + ssr-divergence/env.d.rx: 3 words by hand, 0 `any` + start-route/src/people.d.rx: 20 words by hand (rx-declare drafts nothing for it: the module has no types), 0 `any` + store-helper/array.d.rx: 0 words by hand, 3 `any` + store-helper/rx-types/solid-js.d.rx: 12 words by hand, 0 `any` + store-updater/audit.d.rx: 0 words by hand, 0 `any` + store-updater/rx-types/solid-js.d.rx: 12 words by hand, 0 `any` + table-pagination/table.d.rx: 79 words by hand, 12 `any` diff --git a/bench/tasks/context-provider/src/main.rx b/bench/tasks/context-provider/src/main.rx new file mode 100644 index 00000000..d9b552f5 --- /dev/null +++ b/bench/tasks/context-provider/src/main.rx @@ -0,0 +1,32 @@ +// A cart the whole page shares, the way a Solid app makes a `CartProvider`: a context of the app's own, a provider +// component that holds the state and provides it with the action that changes it, and readers anywhere under it. +type Line = { name: string; qty: number } +context cart: { lines: Line[]; add: (name: string) => void } + +component CartProvider(props: { children: View }) { + source held: Line[] := [] + action add(name: string) { held := ls => [...ls, { name: name, qty: 1 }] } + provide cart = { lines: held, add: add } + {props.children} +} + +component Badge() { + c = use cart + {len(c.lines)} in the cart +} +component Shelf(props: { items: string[] }) { + c = use cart +
    {for name in props.items {
  • }}
+} +component Summary() { + c = use cart +
    {for line in c.lines {
  1. {line.name} × {line.qty}
  2. }}
+} + +export default component App() { + +
+ + + +} diff --git a/bench/tasks/context-provider/task.mjs b/bench/tasks/context-provider/task.mjs new file mode 100644 index 00000000..33838140 --- /dev/null +++ b/bench/tasks/context-provider/task.mjs @@ -0,0 +1,29 @@ +// An app's own context and its provider component (03 RG-7, 09 MO-7). Solid: `createContext`, a `CartProvider` that +// holds the store, `useContext` in the readers — and "useCart must be used within a CartProvider" at run time when a +// reader is rendered outside it. +export default { + title: "A context of the app's own: a provider component, readers under it", + types: [ + { name: "what a reader gets is the context's type: a line has no `title`", edit: ["{line.name} × {line.qty}", "{line.title} × {line.qty}"], expect: /TS2339|TS2551/ }, + { name: "the provided action keeps its parameter's type", edit: ["c.add(name) }}>{name}", "c.add(len(name)) }}>{name}"], expect: /TS2345/ }, + { name: "a provision is checked against the context's type", edit: ["provide cart = { lines: held, add: add }", "provide cart = { lines: len(held), add: add }"], expect: /TS2322|TS2345|TS2739|TS2740|TS2741/ }, + ], + bad: [ + { name: "a reader rendered beside the provider, not under it (a sibling)", edit: [" \n ", " \n "], expect: "CONTEXT_NOT_FOUND" }, + { name: "the context read above its provider: in the component that renders it", edit: ["export default component App() {\n", "export default component App() {\n c = use cart\n"], expect: "CONTEXT_NOT_FOUND" }, + { name: "provided in one branch of the page, read in the other", edit: ["
", "
"], edit2: ["export default component App() {\n", "export default component App() {\n \n"], expect: "CONTEXT_NOT_FOUND" }, + { name: "a reader writing the provided state itself, not through the action", edit: ["onClick={() => { c.add(name) }}", "onClick={() => { c.lines := [] }}"], expect: "WRITE_TO_NON_SOURCE" }, + { name: "the provided list changed in place by a reader", edit: ["onClick={() => { c.add(name) }}", "onClick={() => { c.lines.push({ name: name, qty: 1 }) }}"], expect: "MUTATION_IN_PLACE" }, + { name: "the provided action called while the view computes", edit: ["{len(c.lines)} in the cart", "{c.add(\"tea\")} in the cart"], expect: "ACTION_CALLED_IN_OWNED_SCOPE" }, + { name: "the same through a prop: a row's handler called, not passed on", edit: ["
  • ", "
  • "], expect: "ACTION_CALLED_IN_OWNED_SCOPE" }, + ], + async run(h) { + const base = await h.serve(); const page = await h.open(base); + h.check("mounted: every reader sees the provider's empty cart", await h.until(async () => /0 in the cart/.test(await h.text(page))), await h.text(page)); + await page.click("text=tea"); await page.click("text=milk"); await page.click("text=tea"); + h.check("the provided action writes the provider's state; the badge and the summary follow", await h.until(async () => /3 in the cart/.test(await h.text(page)) && (await h.text(page, ".summary")) === "tea × 1milk × 1tea × 1"), await h.text(page)); + h.check("no console errors or warnings", h.problems.length === 0, h.problems); + const r = await h.ssr("/"); + h.check("the server renders the readers under the provider", !r.error && /0 in the cart/.test(r.text), r.error?.message ?? r.text); + }, +}; diff --git a/bench/tasks/duplicate-keys/src/main.rx b/bench/tasks/duplicate-keys/src/main.rx new file mode 100644 index 00000000..5b9687d6 --- /dev/null +++ b/bench/tasks/duplicate-keys/src/main.rx @@ -0,0 +1,14 @@ +// A keyed list: rows keep their identity by `id`, so a row's own state survives a reorder. +type Row = { id: number; text: string } + +component Line(props: { text: string }) { + source picked := false +
  • { picked := !picked }}>{props.text}
  • +} + +export default component App() { + source next := 3 + source rows: Row[] key id := [{ id: 1, text: "a" }, { id: 2, text: "b" }] +
      {for row in rows { }}
    + +} diff --git a/bench/tasks/duplicate-keys/task.mjs b/bench/tasks/duplicate-keys/task.mjs new file mode 100644 index 00000000..c232ad69 --- /dev/null +++ b/bench/tasks/duplicate-keys/task.mjs @@ -0,0 +1,29 @@ +// Two rows of a keyed list with one key (06 ST-4): Solid keeps one row's state for both, or drops one. +const dup = async h => { + const base = await h.serve(); const page = await h.open(base); + await page.click(".add"); await page.click(".add"); + await new Promise(r => setTimeout(r, 300)); + h.check("the list after two adds", (await page.locator("li").count()) === 4, `${await page.locator("li").count()} rows: ${await h.text(page)}`); +}; +export default { + title: "A keyed list: every row has its own key", + known: { + "rows added with a key the list already has": "06 ST-4d, 08 CN-2: a key computed at run time is the data's (bin R). The checker refuses rows written out with one key; it cannot see a key that a click computes, a static check does not become a run-time one, and Solid's development build reports no duplicate either. The variant stays as the measure of that limit.", + }, + types: [ + { name: "a row's key field is its type's", edit: ["{ id: next, text: \"new\" }", "{ id: \"x\", text: \"new\" }"], expect: /TS2322|TS2345/ }, + ], + bad: [ + { name: "two rows written with one key", edit: ['[{ id: 1, text: "a" }, { id: 2, text: "b" }]', '[{ id: 1, text: "a" }, { id: 1, text: "b" }]'], expect: "DUPLICATE_KEY" }, + { name: "rows added with a key the list already has (known only when it runs)", edit: ["rows := rs => [{ id: next, text: \"new\" }, ...rs]; next := n => n + 1", "rows := rs => [{ id: 1, text: \"new\" }, ...rs]"], dev: /duplicate key|DUPLICATE_KEY/i, drive: dup }, + ], + async run(h) { + const base = await h.serve(); const page = await h.open(base); + await h.until(async () => (await page.locator("li").count()) === 2); + await page.click("li >> nth=1"); + h.check("a row's own state", await h.until(async () => (await page.locator("li.on").count()) === 1 && (await page.textContent("li.on")) === "b"), await h.text(page)); + await page.click(".add"); + h.check("a row added in front: the picked row is still `b` (identity by key)", await h.until(async () => (await page.locator("li").count()) === 3 && (await page.textContent("li.on")) === "b"), await h.text(page)); + h.check("no console errors or warnings", h.problems.length === 0, h.problems); + }, +}; diff --git a/bench/tasks/effect-derived/src/main.rx b/bench/tasks/effect-derived/src/main.rx new file mode 100644 index 00000000..040ba13f --- /dev/null +++ b/bench/tasks/effect-derived/src/main.rx @@ -0,0 +1,15 @@ +// A cart line: the total is computed from the quantity and the price, the history is what the clicks did, and an +// effect is kept for what leaves the program (the page's title). +import { setTitle } from "./page.js" + +export default component App() { + source qty := 1 + source price := 5 + source history: number[] := [] + total = qty * price + effect (total) { setTitle(`cart: ${$0}`) } +

    {qty} × {price} = {total}

    +

    {history.join(", ")}

    + + +} diff --git a/bench/tasks/effect-derived/src/page.d.rx b/bench/tasks/effect-derived/src/page.d.rx new file mode 100644 index 00000000..0994e0ee --- /dev/null +++ b/bench/tasks/effect-derived/src/page.d.rx @@ -0,0 +1,2 @@ +// Drafted by rx-declare from ./page.js's TypeScript types. Check every TODO, then delete it; rx-tsc checks the rest (TY-6). +export fn setTitle(text: string): void diff --git a/bench/tasks/effect-derived/src/page.d.ts b/bench/tasks/effect-derived/src/page.d.ts new file mode 100644 index 00000000..8efbb7b9 --- /dev/null +++ b/bench/tasks/effect-derived/src/page.d.ts @@ -0,0 +1 @@ +export declare function setTitle(text: string): void; diff --git a/bench/tasks/effect-derived/src/page.js b/bench/tasks/effect-derived/src/page.js new file mode 100644 index 00000000..688d1535 --- /dev/null +++ b/bench/tasks/effect-derived/src/page.js @@ -0,0 +1,2 @@ +// What leaves the program: the document's title. +export const setTitle = text => { document.title = text; }; diff --git a/bench/tasks/effect-derived/task.mjs b/bench/tasks/effect-derived/task.mjs new file mode 100644 index 00000000..2500cb71 --- /dev/null +++ b/bench/tasks/effect-derived/task.mjs @@ -0,0 +1,26 @@ +// State derived through an effect (02 C-3): Solid's `createEffect(() => setTotal(qty() * price()))` — a value that is +// an equation of others, kept in a signal of its own by an effect. It is a frame late at best (the view shows the new +// quantity beside the old total; the server, which runs no effect, never computes it), and stale for ever when the +// effect does not name what it reads. +export default { + title: "Derived state: an equation, not a source an effect keeps in step", + types: [ + { name: "the equation keeps its type: a number", edit: ["{qty} × {price} = {total}", "{qty} × {price} = {total.length}"], expect: /TS2339/ }, + ], + bad: [ + { name: "the total kept in a source, written by a mount effect that reads the others: computed once, stale after", edit: ["total = qty * price", "source total := 0\n effect () { total := qty * price }"], expect: "EFFECT_RELAY_TEAR" }, + { name: "the same with the inputs named: a frame late, an equation written the long way", edit: ["total = qty * price", "source total := 0\n effect (qty, price) { total := $0 * $1 }"], expect: "EFFECT_RELAY_TEAR" }, + { name: "the history appended by an effect on the quantity, not by the click that changed it", edit: ["let n = qty + 1; qty := n; history := h => [...h, n]", "qty := qty + 1"], edit2: ["effect (total) {", "effect (qty) { history := [...history, $0] }\n effect (total) {"], expect: "EFFECT_RELAY_TEAR" }, + { name: "the title set by a mount effect that reads the total by name: sent once, never again", edit: ["effect (total) { setTitle(`cart: ${$0}`) }", "effect () { setTitle(`cart: ${total}`) }"], advise: "SNAPSHOT_IN_EFFECT" }, + { name: "the effect's own input written by it", edit: ["effect (total) { setTitle(`cart: ${$0}`) }", "effect (qty) { qty := $0 + 1 }"], expect: "EFFECT_WRITES_OWN_SOURCE" }, + ], + async run(h) { + const base = await h.serve(); const page = await h.open(base); + h.check("mounted: the total, and the title the effect set", await h.until(async () => /1 × 5 = 5/.test(await h.text(page)) && await page.title() === "cart: 5"), `${await h.text(page)} / ${await page.title()}`); + await page.click(".more"); await page.click(".more"); + h.check("the total follows the quantity in the same frame; the history is what the clicks did", await h.until(async () => /3 × 5 = 15\s*2, 3/.test(await h.text(page))), await h.text(page)); + await page.click(".raise"); + h.check("…and the price; the effect sends the new total out", await h.until(async () => /3 × 6 = 18/.test(await h.text(page)) && await page.title() === "cart: 18"), `${await h.text(page)} / ${await page.title()}`); + h.check("no console errors or warnings", h.problems.length === 0, h.problems); + }, +}; diff --git a/bench/tasks/formisch-field-array/src/main.rx b/bench/tasks/formisch-field-array/src/main.rx new file mode 100644 index 00000000..6b81ef30 --- /dev/null +++ b/bench/tasks/formisch-field-array/src/main.rx @@ -0,0 +1,31 @@ +// A packing list on Formisch: an array field whose rows are added, removed and moved by the library's own methods, +// each row's input named by its typed path. +import { createForm, Form, Field, FieldArray, insert, remove, move } from "@formisch/solid/v2" +import { object, array, string, pipe, minLength } from "valibot" + +schema = object({ + items: pipe(array(object({ label: pipe(string(), minLength(1, "Name it")) })), minLength(1, "Pack something")), +}) +source packed := "" + +export default component App() { + form = createForm({ schema: schema, initialInput: { items: [{ label: "tent" }, { label: "stove" }] } }) +
    { packed := output.items.map(item => item.label).join(", ") }}> + {view (list) { +
      {for id in list.items { +
    1. + {view (field) { + + if (field.errors) { {field.errors[0]} } + }} + + +
    2. + }}
    + if (list.errors) {

    {list.errors[0]}

    } + }}
    + + +
    +

    packed: {packed}

    +} diff --git a/bench/tasks/formisch-field-array/src/rx-types/@formisch/solid/v2.d.rx b/bench/tasks/formisch-field-array/src/rx-types/@formisch/solid/v2.d.rx new file mode 100644 index 00000000..1bc367a3 --- /dev/null +++ b/bench/tasks/formisch-field-array/src/rx-types/@formisch/solid/v2.d.rx @@ -0,0 +1,10 @@ +//@ for @formisch/solid ^1.3.0 +// Formisch's Solid 2 build in rows, as rx-declare drafts it, kept to what the form uses: the form is made once +// (`pure`), and a submit is called later (`handler`). The types are the package's own. +export component Field(props: { of: any; path: any; children: (store: any) => View }) +export component FieldArray(props: { of: any; path: any; children: (store: any) => View }) +export component Form(props: { of: any; children: View; onSubmit: handler (output: any, event: any) => any }) +export pure fn createForm(config: any): any instantiates +export fn insert(form: any, config: any): void +export fn move(form: any, config: any): void +export fn remove(form: any, config: any): void diff --git a/bench/tasks/formisch-field-array/src/rx-types/valibot.d.rx b/bench/tasks/formisch-field-array/src/rx-types/valibot.d.rx new file mode 100644 index 00000000..5ee6bb9f --- /dev/null +++ b/bench/tasks/formisch-field-array/src/rx-types/valibot.d.rx @@ -0,0 +1,7 @@ +//@ for valibot ^1.5.0 +// valibot's schema builders: each makes a value from what it is given +export pure fn object(entries: any): any +export pure fn array(item: any): any +export pure fn string(): any +export pure fn pipe(...items: any[]): any +export pure fn minLength(n: number, message?: string): any diff --git a/bench/tasks/formisch-field-array/task.mjs b/bench/tasks/formisch-field-array/task.mjs new file mode 100644 index 00000000..d0869e56 --- /dev/null +++ b/bench/tasks/formisch-field-array/task.mjs @@ -0,0 +1,35 @@ +// Formisch field arrays (RFC 23, 13 TY-1; 09 MO-11k): ``, and the methods that change one — insert, +// remove, move — called from handlers. +const labels = async page => (await page.locator("input.label").evaluateAll(xs => xs.map(x => x.value))).join(","); +export default { + title: "Formisch: an array field — insert, remove, move", + types: [ + { name: "a row's path is typed through the array: a field the row has not is refused", edit: ['path={["items", list.items.indexOf(id), "label"]}', 'path={["items", list.items.indexOf(id), "lable"]}'], expect: /TS2322|TS2820/ }, + { name: "the methods take the paths of array fields only", edit: ['insert(form, { path: ["items"], initialInput: { label: "" } })', 'insert(form, { path: ["itmes"], initialInput: { label: "" } })'], expect: /TS2322|TS2820|TS2345/ }, + { name: "a new row's input is the schema's row", edit: ['initialInput: { label: "" } })', 'initialInput: { label: 5 } })'], expect: /TS2322|TS2345/ }, + { name: "the submit's output is the schema's output", edit: ["output.items.map(item => item.label)", "output.items.map(item => item.name)"], expect: /TS2339|TS2551/ }, + ], + bad: [ + { name: "a row inserted while the view computes, not from a handler", edit: ['

    packed: {packed}

    ', '

    packed: {insert(form, { path: ["items"] })}{packed}

    '], expect: "IO_IN_REACTIVE" }, + { name: "a method given to a button, called, not passed", edit: ['onClick={() => { insert(form, { path: ["items"], initialInput: { label: "" } }) }}', 'onClick={insert(form, { path: ["items"], initialInput: { label: "" } })}'], expect: "IO_IN_REACTIVE" }, + { name: "the form made in the view, again on every change", edit: ["
    (await labels(page)) === "tent,stove"), await labels(page)); + await page.click(".more"); + h.check("insert: a third row, empty", await h.until(async () => (await labels(page)) === "tent,stove,"), await labels(page)); + await page.locator("input.label").nth(2).fill("map"); + await page.locator(".up").nth(2).click(); + h.check("move: the row goes up with what was typed in it", await h.until(async () => (await labels(page)) === "tent,map,stove"), await labels(page)); + await page.locator(".drop").nth(0).click(); + h.check("remove: the others keep their input", await h.until(async () => (await labels(page)) === "map,stove"), await labels(page)); + await page.click(".submit"); + h.check("the submit's typed output is the rows as they stand", await h.until(async () => /packed: map, stove/.test(await h.text(page, ".packed"))), await h.text(page, ".packed")); + await page.locator(".drop").nth(0).click(); await page.locator(".drop").nth(0).click(); await page.click(".submit"); + h.check("the array's own rule: an empty list is refused with the schema's message", await h.until(async () => /Pack something/.test(await h.text(page))), await h.text(page)); + h.check("no console errors or warnings", h.problems.length === 0, h.problems); + }, +}; diff --git a/bench/tasks/formisch-field-path/src/main.rx b/bench/tasks/formisch-field-path/src/main.rx new file mode 100644 index 00000000..e5ad79e8 --- /dev/null +++ b/bench/tasks/formisch-field-path/src/main.rx @@ -0,0 +1,25 @@ +// A sign-in form on Formisch: a valibot schema, each field named by its typed path, the submit writing .rx state. +import { createForm, Form, Field } from "@formisch/solid/v2" +import { object, string, pipe, email, minLength } from "valibot" + +schema = object({ + email: pipe(string(), email("Enter a valid email")), + profile: object({ name: pipe(string(), minLength(2, "At least 2 characters")) }), +}) +source signedIn := "" + +export default component App() { + form = createForm({ schema: schema }) + { signedIn := `${output.profile.name} <${output.email}>` }}> + {view (field) { + + if (field.errors) {

    {field.errors[0]}

    } + }}
    + {view (field) { + + if (field.errors) {

    {field.errors[0]}

    } + }}
    + +
    +

    signed in: {signedIn}

    +} diff --git a/bench/tasks/formisch-field-path/src/rx-types/@formisch/solid/v2.d.rx b/bench/tasks/formisch-field-path/src/rx-types/@formisch/solid/v2.d.rx new file mode 100644 index 00000000..8ebf71b5 --- /dev/null +++ b/bench/tasks/formisch-field-path/src/rx-types/@formisch/solid/v2.d.rx @@ -0,0 +1,5 @@ +//@ for @formisch/solid ^1.3.0 +// Formisch's Solid 2 build in rows (as rx-declare drafts it, kept to what the form uses). The types are the package's own. +export component Field(props: { of: any; path: any; children: (store: any) => View }) +export component Form(props: { of: any; children: View; onSubmit: handler (output: any, event: any) => any }) +export pure fn createForm(config: any): any instantiates diff --git a/bench/tasks/formisch-field-path/src/rx-types/valibot.d.rx b/bench/tasks/formisch-field-path/src/rx-types/valibot.d.rx new file mode 100644 index 00000000..e549bfc5 --- /dev/null +++ b/bench/tasks/formisch-field-path/src/rx-types/valibot.d.rx @@ -0,0 +1,6 @@ +// valibot's schema builders: each makes a value from what it is given +export pure fn object(entries: any): any +export pure fn string(): any +export pure fn pipe(...items: any[]): any +export pure fn email(message?: string): any +export pure fn minLength(n: number, message?: string): any diff --git a/bench/tasks/formisch-field-path/task.mjs b/bench/tasks/formisch-field-path/task.mjs new file mode 100644 index 00000000..b791c5ff --- /dev/null +++ b/bench/tasks/formisch-field-path/task.mjs @@ -0,0 +1,26 @@ +// A typed Formisch field path (RFC 23, 13 TY-1; 09 MO-11k for the render prop). +export default { + title: "Formisch: a form whose fields are named by typed paths", + types: [ + { name: "a path the schema does not have is refused", edit: ['path={["email"]}', 'path={["emial"]}'], expect: /TS2322|TS2820/ }, + { name: "a nested path is typed through the schema", edit: ['path={["profile", "name"]}', 'path={["profile", "nmae"]}'], expect: /TS2322/ }, + { name: "the field's input is the schema's type at that path: a string", edit: ['', ''], expect: /TS2339|TS2551/ }, + { name: "the submit's output is the schema's output", edit: ["${output.profile.name} <${output.email}>", "${output.profile.nmae} <${output.email}>"], expect: /TS2339|TS2551/ }, + ], + bad: [ + { name: "the form made from a schema that reads a source: read once, then stale", edit: ["form = createForm({ schema: schema })", "form = createForm({ schema: object({ email: pipe(string(), minLength(len(signedIn))) }) })"], expect: "SNAPSHOT_ARGUMENT" }, + { name: "the form made where the view reads it, again on every change", edit: ["
    signed in: {signedIn}

    ', '

    signed in: {signedIn := "x"}

    '], expect: "PARSE" }, + { name: "the submit's state assigned with `=`", edit: ["signedIn := `${output.profile.name} <${output.email}>`", "signedIn = output.email"], expect: "ASSIGNMENT" }, + ], + async run(h) { + const base = await h.serve(); + const page = await h.open(base); + h.check("mounted", await h.until(async () => (await h.text(page)).includes("Sign in")), await h.text(page)); + await page.click(".submit"); + h.check("an empty submit shows the schema's messages at each path", await h.until(async () => /Enter a valid email/.test(await h.text(page)) && /At least 2 characters/.test(await h.text(page))), await h.text(page)); + await page.fill(".email", "ann@example.com"); await page.fill(".name", "Ann"); await page.click(".submit"); + h.check("a valid submit writes the .rx source with the typed output", await h.until(async () => (await h.text(page)).includes("signed in: Ann ")), await h.text(page)); + h.check("no console errors or warnings", h.problems.length === 0, h.problems); + }, +}; diff --git a/bench/tasks/frozen-read/src/label.d.rx b/bench/tasks/frozen-read/src/label.d.rx new file mode 100644 index 00000000..5d287074 --- /dev/null +++ b/bench/tasks/frozen-read/src/label.d.rx @@ -0,0 +1,2 @@ +export pure fn createLabel(ref text: string): ref string +export pure fn createStamp(text: string): ref string diff --git a/bench/tasks/frozen-read/src/label.d.ts b/bench/tasks/frozen-read/src/label.d.ts new file mode 100644 index 00000000..8253a08a --- /dev/null +++ b/bench/tasks/frozen-read/src/label.d.ts @@ -0,0 +1,3 @@ +import type { Accessor } from "solid-js"; +export declare function createLabel(text: Accessor): Accessor; +export declare function createStamp(text: string): Accessor; diff --git a/bench/tasks/frozen-read/src/label.js b/bench/tasks/frozen-read/src/label.js new file mode 100644 index 00000000..558e9482 --- /dev/null +++ b/bench/tasks/frozen-read/src/label.js @@ -0,0 +1,5 @@ +// Two small primitives, as a design system ships them: a label that follows what it is given (an accessor), and a +// stamp made once from a value. +import { createMemo } from "solid-js"; +export const createLabel = text => createMemo(() => `[${text()}]`); +export const createStamp = text => { const made = `#${text}`; return () => made; }; diff --git a/bench/tasks/frozen-read/src/main.rx b/bench/tasks/frozen-read/src/main.rx new file mode 100644 index 00000000..3450a7fc --- /dev/null +++ b/bench/tasks/frozen-read/src/main.rx @@ -0,0 +1,13 @@ +// Formatters kept together in a record, as apps keep them, and read by the view, by a primitive and by a seed. +import { createLabel, createStamp } from "./label.js" + +export default component App() { + source count := 0 + fmt = { total: () => `${count} items`, unit: () => "items" } + label = createLabel(fmt.total()) + stamp = createStamp(fmt.unit()) +

    {fmt.total()}

    +

    {label}

    +

    {stamp}

    + +} diff --git a/bench/tasks/frozen-read/task.mjs b/bench/tasks/frozen-read/task.mjs new file mode 100644 index 00000000..4874bb36 --- /dev/null +++ b/bench/tasks/frozen-read/task.mjs @@ -0,0 +1,21 @@ +// A function kept in a record, read under `peek`, by a value parameter or by a seed: the read is frozen (E-5a, E-10; +// RFC 14, RFC 34). Solid: `untrack(() => fmt.total())`, `createSignal(fmt.total())`. +export default { + title: "A formatter kept in a record: live where it is read, never frozen without saying so", + types: [ + { name: "a formatter's result keeps its type through the record", edit: ['

    {fmt.total()}

    ', '

    {fmt.total().toFixed(1)}

    '], expect: /TS2339|TS2551/ }, + ], + bad: [ + { name: "the formatter read under a kept peek: the view shows the first value for ever", edit: ['

    {fmt.total()}

    ', '

    {peek fmt.total()}

    '], expect: "SNAPSHOT_KEPT" }, + { name: "a kept peek of it in an equation", edit: ["label = createLabel(fmt.total())", "label = createLabel(fmt.total())\n first = peek fmt.total()"], expect: "SNAPSHOT_KEPT" }, + { name: "the formatter's value given to a value parameter: the primitive is made from the first value", edit: ["stamp = createStamp(fmt.unit())", "stamp = createStamp(fmt.total())"], expect: "SNAPSHOT_ARGUMENT" }, + { name: "the formatter's value as a source's seed, with no peek", edit: ["stamp = createStamp(fmt.unit())", "stamp = createStamp(fmt.unit())\n source seeded := fmt.total()"], expect: "SNAPSHOT_INITIALIZER" }, + ], + async run(h) { + const base = await h.serve(); const page = await h.open(base); + h.check("mounted", await h.until(async () => /0 items\s*\[0 items\]\s*#items/.test(await h.text(page))), await h.text(page)); + await page.click("button"); await page.click("button"); + h.check("the view and the label follow the source through the record's formatter; the stamp is made once from a constant", await h.until(async () => /2 items\s*\[2 items\]\s*#items/.test(await h.text(page))), await h.text(page)); + h.check("no console errors or warnings", h.problems.length === 0, h.problems); + }, +}; diff --git a/bench/tasks/keyed-edits/src/main.rx b/bench/tasks/keyed-edits/src/main.rx new file mode 100644 index 00000000..01553c41 --- /dev/null +++ b/bench/tasks/keyed-edits/src/main.rx @@ -0,0 +1,27 @@ +// A list edited every way a list is: a row added in front, removed, moved up, renamed in place, and the whole list +// reset. Each row has state of its own (opened or not), which stays with its row through every edit. +type Task = { id: number; title: string } + +component Line(props: { title: string; onUp: () => void; onRemove: () => void; onRename: () => void }) { + source open := false +
  • + { open := !open }}>{props.title} + + + +
  • +} + +export default component App() { + source next := 4 + source tasks: Task[] key id := [{ id: 1, title: "wash" }, { id: 2, title: "cook" }, { id: 3, title: "read" }] + fn swapped(ts: Task[], i: number): Task[] => i < 1 ? ts : [...ts.slice(0, i - 1), ts[i], ts[i - 1], ...ts.slice(i + 1)] +
      {for task in tasks { + { let i = tasks.findIndex(t => t.id == task.id); tasks := ts => swapped(ts, i) }} + onRename={() => { let i = tasks.findIndex(t => t.id == task.id); tasks[i].title := t => `${t}!` }} + onRemove={() => { let id = task.id; tasks := ts => ts.filter(t => t.id != id) }} /> + }}
    + + +} diff --git a/bench/tasks/keyed-edits/task.mjs b/bench/tasks/keyed-edits/task.mjs new file mode 100644 index 00000000..1f29efa7 --- /dev/null +++ b/bench/tasks/keyed-edits/task.mjs @@ -0,0 +1,42 @@ +// A keyed list edited in place (06 ST-4, W-6): rows keep their identity, and so their own state, by their key through +// an insert, a removal, a move and a rename. Solid: `` over a store, rows keyed by `id`. +const order = async (h, page) => (await page.locator("li .title").allTextContents()).join(","); +const open = async (h, page) => (await page.locator("li.open .title").allTextContents()).join(","); +// rows by position: open the second row, put a row in front — the open row should still be `cook` +const byIndex = async h => { + const base = await h.serve(); const page = await h.open(base); + await page.click("li >> nth=1 >> .title"); await page.click(".add"); await new Promise(r => setTimeout(r, 300)); + h.check("the opened row is still the row that was opened", (await open(h, page)) === "cook", `open: ${await open(h, page)} of ${await order(h, page)}`); +}; +export default { + title: "A keyed list, edited: insert, remove, move, rename, reset", + types: [ + { name: "a row keeps its type where the list is edited", edit: ["tasks := ts => [{ id: id, title: \"new\" }, ...ts]", "tasks := ts => [{ id: id, name: \"new\" }, ...ts]"], expect: /TS2322|TS2353|TS2345/ }, + { name: "a path write is typed by the row's field", edit: ["tasks[i].title := t => `${t}!`", "tasks[i].title := t => len(t)"], expect: /TS2322|TS2345/ }, + ], + bad: [ + { name: "the list reset from a handler with two rows of one key", edit: ['tasks := [{ id: 1, title: "wash" }, { id: 2, title: "cook" }] }}>reset', 'tasks := [{ id: 1, title: "wash" }, { id: 1, title: "cook" }] }}>reset'], expect: "DUPLICATE_KEY" }, + { name: "rows added in a handler's functional write, two written with one key", edit: ['tasks := ts => [{ id: id, title: "new" }, ...ts]', 'tasks := ts => [{ id: 9, title: "new" }, { id: 9, title: "newer" }, ...ts]'], expect: "DUPLICATE_KEY" }, + { name: "the rows keyed by their index: a row's state stays at its position, not with its row", edit: ["source tasks: Task[] key id := [", "source tasks: Task[] := ["], expect: "UNSTABLE_LIST_IDENTITY", orSafe: byIndex }, + { name: "the rows shown from a copy rebuilt with the index as its key", edit: ["