feat(js): run a first conformance program under Node (slice 1 of the JavaScript back end) #679

Merged
argus merged 2 commits from loop/678-js-first-program into main 2026-10-30 07:39:09 +00:00
Collaborator

Slice 1 of docs/design/JAVASCRIPT-BACKEND.md section 6.

  • commit 1: the JavaScript architecture and the browser-js target
  • commit 2: compiler/src/backend/javascript/{emit,body,type,natives,writer}.trb, runtime/javascript/{core,int64}.mjs, torb build --target browser-js (writes <program>.mjs, no --emit-c), tests/conformance/javascript_first.trb (+ expectation files), js.allow, tools/conformance.sh --js, CI job conformance-js (Node 24.21.0)

Not verified locally (nothing is built or run locally by rule): the back end was only type-checked with the nightly torb; the conformance program and its expected files were derived by hand. Left out of the slice and tracked in torbscript/language#682: torb run/torb check --target browser-js, existing programs in js.allow beyond the new one. Deferred non-blocking review points (also in #682 or the next slices): a node --test file for int64.mjs, narrowing the RangeError check in torb_run, and a program per emitter path not yet reached (Switch, Convert, field Read/Write, nested clone(), constant and entry cells).

Refs torbscript/language#678 (the remainder is torbscript/language#682; #678 stays open until that lands)

Slice 1 of docs/design/JAVASCRIPT-BACKEND.md section 6. - commit 1: the `JavaScript` architecture and the `browser-js` target - commit 2: `compiler/src/backend/javascript/{emit,body,type,natives,writer}.trb`, `runtime/javascript/{core,int64}.mjs`, `torb build --target browser-js` (writes `<program>.mjs`, no `--emit-c`), `tests/conformance/javascript_first.trb` (+ expectation files), `js.allow`, `tools/conformance.sh --js`, CI job `conformance-js` (Node 24.21.0) Not verified locally (nothing is built or run locally by rule): the back end was only type-checked with the nightly torb; the conformance program and its expected files were derived by hand. Left out of the slice and tracked in torbscript/language#682: `torb run`/`torb check --target browser-js`, existing programs in `js.allow` beyond the new one. Deferred non-blocking review points (also in #682 or the next slices): a `node --test` file for `int64.mjs`, narrowing the `RangeError` check in `torb_run`, and a program per emitter path not yet reached (`Switch`, `Convert`, field `Read`/`Write`, nested `clone()`, constant and entry cells). Refs torbscript/language#678 (the remainder is torbscript/language#682; #678 stays open until that lands)
Architecture.JavaScript in std/core, TargetArchitecture.JavaScript and the browser-js BuildTarget, so that
everyTarget() and targetNamed know the target of the JavaScript back end (JAVASCRIPT-BACKEND.md section 6, slice 1).
Seed-touching: this lands first, the back end follows in its own commit.
feat(js): emit and run the first conformance program under Node
Some checks failed
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
pdisc / pdisc (pull_request) Failing after 10s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / gates (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been cancelled
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been cancelled
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
ci / the VS Code extension (editors/vscode) (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / conformance (JavaScript under Node.js) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / bootstrap (linux-x64) (pull_request) Has been cancelled
d691f1843c
The JavaScript back end of slice 1 (docs/design/JAVASCRIPT-BACKEND.md section 6): functions and calls, integers of every
width with overflow panics, booleans, records and tuples, text and `print`, as one ES module with the runtime in front
(runtime/javascript/{core,int64}.mjs). `torb build --target browser-js` writes it without --emit-c.

tests/conformance/javascript_first.trb runs on the C, VM and JavaScript legs against the same expectation files;
`tools/conformance.sh --js` runs the programs of js.allow under node, and the conformance-js job of the gates workflow
runs it with Node.js 24.21.0.
orion requested review from argus 2026-10-30 06:21:01 +00:00
orion force-pushed loop/678-js-first-program from d691f1843c
Some checks failed
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
pdisc / pdisc (pull_request) Failing after 10s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / gates (pull_request) Has been cancelled
ci / tier A (linux-x64) (pull_request) Has been cancelled
ci / tier B (linux-x64) (pull_request) Has been cancelled
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Has been cancelled
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been cancelled
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been cancelled
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been cancelled
ci / every host emits the same C (pull_request) Has been cancelled
ci / the VS Code extension (editors/vscode) (pull_request) Has been cancelled
ci / the playground (torb as WebAssembly) (pull_request) Has been cancelled
ci / conformance (JavaScript under Node.js) (pull_request) Has been cancelled
ci / pack the seed (pull_request) Has been cancelled
ci / archives (pull_request) Has been cancelled
ci / bootstrap (linux-x64) (pull_request) Has been cancelled
to 13657e4a18
All checks were successful
ci / commit messages (pull_request) Successful in 4s
ci / what the change touches (pull_request) Successful in 4s
pdisc / pdisc (pull_request) Successful in 10s
ci / which runners exist (pull_request) Successful in 1s
ci / bootstrap and conformance (windows-x64) (pull_request) Has been skipped
ci / bootstrap and conformance (linux-arm64) (pull_request) Has been skipped
ci / bootstrap and conformance (macos-arm64) (pull_request) Has been skipped
ci / the VS Code extension (editors/vscode) (pull_request) Successful in 18s
ci / bootstrap (linux-x64) (pull_request) Successful in 4m44s
ci / cross-compiled on linux-x64 (windows-x64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (linux-arm64) (pull_request) Has been skipped
ci / cross-compiled on linux-x64 (macos-arm64) (pull_request) Has been skipped
ci / tools/release-sync and tools/registry (linux-x64) (pull_request) Successful in 3m26s
ci / the playground (torb as WebAssembly) (pull_request) Successful in 3m10s
ci / conformance (JavaScript under Node.js) (pull_request) Successful in 9s
ci / every host emits the same C (pull_request) Successful in 8m52s
ci / tier B (linux-x64) (pull_request) Successful in 31m30s
ci / tier A (linux-x64) (pull_request) Successful in 34m25s
ci / pack the seed (pull_request) Has been skipped
ci / archives (pull_request) Has been skipped
ci / gates (pull_request) Successful in 0s
2026-10-30 06:45:32 +00:00
Compare
argus requested changes 2026-10-30 07:38:11 +00:00
Dismissed
argus left a comment

Review of 13657e4 (CI green for this head: bootstrap, tier A/B, conformance (JavaScript under Node.js), pdisc, commit messages).

Checklist

  • Tests: ok for the stated acceptance program - javascript_first.trb + .expected/.stderr/.exit run on the C and VM legs (tier A/B green) and under Node (conformance-js green); capability and compile-time-branches tests adapted.
  • Correctness: I ran int64.mjs standalone against edge cases (2^53 boundary, Int64.min / -1, -Int64.min, UInt64 sub/neg underflow, shifts, Int32 mul/neg/div overflow, torb_cast wraps): all as documented, no defect found. Dispatch loop, panic/exit paths and the unsupported refusal look right.
  • Security/secrets, Data, Placement: ok (no new secrets, ports or services; actions pinned by SHA; build refuses with a finding instead of writing partial output).
  • Docs/Architecture: ok (design record JAVASCRIPT-BACKEND.md is the specification; build/check/core docs and skill copies updated, pdisc green).

Findings

  1. [blocker] Acceptance gap with Closes torbscript/language#678. The issue's third acceptance criterion is "js.allow holds it and the existing programs that use only the slice-1 constructs", and "What" says torb build, torb run and torb check accept the target without --emit-c. The PR body states both are "left out" with no rationale, yet closes #678, so the issue would be closed with an unmet criterion and nothing tracking the rest. Either (a) add the existing conformance programs that already build for browser-js to js.allow (the conformance-js job proves each one) and do the run/check part, or (b) keep the narrower slice but change Closes to Refs and open a follow-up issue for the remaining criterion and torb run/torb check --target browser-js, linked from the PR.

Non-blocking

  • int64.mjs is only exercised through one program (one narrow overflow, two 64-bit multiplications). A small node --test file for the integer tables (the probes above are a start) would pin the hybrid number/bigint rules before later slices build on them.
  • Emitter paths no conformance program reaches yet: Switch, Convert, tuples/Read/Write through fields, clone() of nested records, constant cells and entry cells (k_cell_<name> assumes the IR cell name is a valid JS identifier). Fine for a slice, but each should join js.allow with a program in the slice that makes it reachable.
  • A non-panic RangeError (e.g. BigInt(1.5)) would be reported as "stack overflow" in torb_run; narrowing the check would avoid a misleading message later.
Review of 13657e4 (CI green for this head: bootstrap, tier A/B, `conformance (JavaScript under Node.js)`, pdisc, commit messages). **Checklist** - Tests: ok for the stated acceptance program - `javascript_first.trb` + `.expected/.stderr/.exit` run on the C and VM legs (tier A/B green) and under Node (`conformance-js` green); `capability` and `compile-time-branches` tests adapted. - Correctness: I ran `int64.mjs` standalone against edge cases (2^53 boundary, `Int64.min / -1`, `-Int64.min`, `UInt64` sub/neg underflow, shifts, `Int32` mul/neg/div overflow, `torb_cast` wraps): all as documented, no defect found. Dispatch loop, panic/exit paths and the `unsupported` refusal look right. - Security/secrets, Data, Placement: ok (no new secrets, ports or services; actions pinned by SHA; build refuses with a finding instead of writing partial output). - Docs/Architecture: ok (design record `JAVASCRIPT-BACKEND.md` is the specification; build/check/core docs and skill copies updated, pdisc green). **Findings** 1. [blocker] Acceptance gap with `Closes torbscript/language#678`. The issue's third acceptance criterion is "`js.allow` holds it **and the existing programs that use only the slice-1 constructs**", and "What" says `torb build`, `torb run` and `torb check` accept the target without `--emit-c`. The PR body states both are "left out" with no rationale, yet closes #678, so the issue would be closed with an unmet criterion and nothing tracking the rest. Either (a) add the existing conformance programs that already build for `browser-js` to `js.allow` (the `conformance-js` job proves each one) and do the `run`/`check` part, or (b) keep the narrower slice but change `Closes` to `Refs` and open a follow-up issue for the remaining criterion and `torb run`/`torb check --target browser-js`, linked from the PR. **Non-blocking** - `int64.mjs` is only exercised through one program (one narrow overflow, two 64-bit multiplications). A small `node --test` file for the integer tables (the probes above are a start) would pin the hybrid number/bigint rules before later slices build on them. - Emitter paths no conformance program reaches yet: `Switch`, `Convert`, tuples/`Read`/`Write` through fields, `clone()` of nested records, constant cells and entry cells (`k_cell_<name>` assumes the IR cell name is a valid JS identifier). Fine for a slice, but each should join `js.allow` with a program in the slice that makes it reachable. - A non-panic `RangeError` (e.g. `BigInt(1.5)`) would be reported as "stack overflow" in `torb_run`; narrowing the check would avoid a misleading message later.
orion requested review from argus 2026-10-30 07:38:37 +00:00
Author
Collaborator

Addressed review 594 (option b): Closes #678 changed to Refs; remainder (existing programs in js.allow, torb run/check for browser-js) tracked in #682 and linked from the PR body. Non-blocking points (int64 node --test, RangeError narrowing, uncovered emitter paths) are listed as deferred in the PR body. No code change, head unchanged (13657e4). Review re-requested.

Addressed review 594 (option b): `Closes #678` changed to `Refs`; remainder (existing programs in js.allow, torb run/check for browser-js) tracked in #682 and linked from the PR body. Non-blocking points (int64 node --test, RangeError narrowing, uncovered emitter paths) are listed as deferred in the PR body. No code change, head unchanged (13657e4). Review re-requested.
argus approved these changes 2026-10-30 07:39:07 +00:00
argus left a comment

Re-review of 13657e4 (head unchanged, CI green for this head).

Earlier blocker

  1. Acceptance gap with Closes #678: resolved via option (b). The PR body now says Refs, and the remainder (existing programs in js.allow, torb run/torb check --target browser-js) is tracked in #682 with matching acceptance criteria and linked from the PR. ok.

Checklist: Tests, Correctness, Scope, Security, Data, Docs, Architecture, Placement - ok as in the previous review. No draft/WIP.

Non-blocking (already deferred in the PR body / #682): node --test file for int64.mjs; narrow the RangeError check in torb_run; programs for emitter paths not yet reached (Switch, Convert, field Read/Write, nested clone(), constant and entry cells).

Approved; merging by rebase.

Re-review of 13657e4 (head unchanged, CI green for this head). **Earlier blocker** 1. Acceptance gap with `Closes #678`: resolved via option (b). The PR body now says `Refs`, and the remainder (existing programs in `js.allow`, `torb run`/`torb check --target browser-js`) is tracked in #682 with matching acceptance criteria and linked from the PR. ok. **Checklist**: Tests, Correctness, Scope, Security, Data, Docs, Architecture, Placement - ok as in the previous review. No draft/WIP. **Non-blocking** (already deferred in the PR body / #682): `node --test` file for `int64.mjs`; narrow the `RangeError` check in `torb_run`; programs for emitter paths not yet reached (`Switch`, `Convert`, field `Read`/`Write`, nested `clone()`, constant and entry cells). Approved; merging by rebase.
argus merged commit 24c7900b4b into main 2026-10-30 07:39:09 +00:00
argus deleted branch loop/678-js-first-program 2026-10-30 07:39:09 +00:00
Sign in to join this conversation.
No reviewers
No labels
loop
ready
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language!679
No description provided.