js: the rest of the kernel, manifest walk, isSame and BigInt property tests (slice 4B of #63) #724

Closed
opened 2026-11-12 23:00:30 +00:00 by orion · 9 comments
Collaborator

Context

Step 6 of epic #63 (JavaScript back end), slice 4, part B of docs/design/JAVASCRIPT-BACKEND.md section 6 row 4 ("The kernel, part 1B"). Slices 1 to 3 and 4A (#678, #684, #701, #708; PR #718 merged as 79b35cb9) are on main: compiler/src/backend/javascript/{emit,body,type,natives,witness,count,writer}.trb, runtime/javascript/{core,int64,list}.mjs, tools/conformance.sh --js, tests/conformance/js.allow, CI job conformance-js. 4A left the list storage and the list and text natives in place; what still stops programs is the part of the kernel of natives that has no JavaScript yet (the text show, parse and hash natives, the remaining widths, isSame) and the fact that nothing proves the table complete.

Source

  • docs/design/JAVASCRIPT-BACKEND.md section 3 (the kernel, K1 to K8), section 6 row 4B and the paragraph "What slice 4A left out, on purpose".
  • docs/design/NATIVES.md (the manifest, nativeEntries(); isSame is a planned intrinsic there).
  • compiler/src/backend/c/natives.trb and runtime/ as the reference for what each symbol means; compiler/src/backend/javascript/natives.trb for what is mapped today.

Goal

  • Manifest walk. A test walks nativeEntries() and fails for every entry that has no JavaScript mapping, except for an explicit deferred list naming the entries that belong to slice 5 (floats, libm) and slice 7 (tasks, time, files). The list is data in the repo, reviewed like js.allow.
  • Kernel, rest of part 1. K1, K2, K4, K5, K7 and K8 complete over every integer width, plus the text natives the 4A candidates needed (show, parse, hash of text and integers). Maps and sets stay out: they wait for epic #55 as the record says.
  • isSame. Mapped as it stands in NATIVES.md; if it has become an IR intrinsic by the time this is implemented, follow the IR.
  • Intrinsic sweep. Every Intrinsic of the IR over every width is emitted or named as deferred.
  • Property tests. The helpers of runtime/javascript/int64.mjs and the intrinsics are tested against BigInt in tools/ (random and boundary operands, each operator and width, 10^6 cases each) and report zero differences.

Decided by the loop

  • Maps and sets are not part of 4B (epic #55 first); a program that needs a HashMap, HashSet or Trie* stays off js.allow.
  • The programs 4A trimmed are the first candidates: bankers-queue, bound-methods, buffer-field-derived, buffer-list, collect-through-wrappers, cons-stack-persists, destructor-early-exits, entry-cell-trait, interpolation, joined, plain-bound, shared-top-level-const, source-trait-value, trait-constants, and heap-order (differs at runtime). A program that still needs floats, tasks or a map stays off and is listed in the PR with the finding that names the later slice.
  • A change of the manifest is two commits (CONTRIBUTING, "Repository Operations"); the implementer confirms with tools/check-commits.sh.

Files

  • compiler/src/backend/javascript/natives.trb, body.trb (intrinsics), emit.trb.
  • runtime/javascript/core.mjs, int64.mjs (helpers; a new file only if the "absent unless used" rule needs it).
  • tools/ (the BigInt property tests), the manifest-walk test and the deferred list.
  • tests/conformance/js.allow.
  • docs/design/JAVASCRIPT-BACKEND.md: row 4 marked done, a "What slice 4B left out" paragraph; docs regenerated as torb docs requires.

Tests

  1. The manifest walk is green with the explicit deferred list; adding an entry to nativeEntries() without a mapping or a deferred entry fails it.
  2. The BigInt property tests report zero differences for each operator and width.
  3. Existing programs that build and run under Node with the same .expected, .stderr and .exit files join js.allow (candidates above); no program of js.allow is removed.

Acceptance criteria

  • The manifest walk fails for an entry without JavaScript that is not on the deferred list, and passes on main with the list naming only slice 5 and 7 entries
  • The property tests against BigInt (10^6 cases per operator and width) report zero differences
  • js.allow grows by every candidate above that passes, at least buffer-list, interpolation and heap-order; each program left off is listed in the PR with its reason
  • A program that uses none of the new natives produces the same JavaScript as before: pinned by an unchanged output of javascript_first.trb
  • Row 4 of the design record is marked done; docs regenerated; torb format --check and torb docs check green
  • tools/check-commits.sh clean; sh tools/gates.sh a and the conformance-js job green in forge CI (CI only, no local bootstrap or gates)

Seed

No syntax change and no new std name the compiler looks up; the manifest is read, and a change of it follows the two-commit rule. Split by the implementer if a review cannot hold it: the manifest walk with the deferred list first, then the width and intrinsic sweep with the property tests, both inside this issue.

Out of scope

Maps and sets (epic #55), floats and libm (5), structured control flow (6), tasks (7), .nojs markers and torb test (8), a minifier, source maps.

Dependencies

#708 (slice 4A, landed as PR #718).

Part of #63 (epic; do not close it).

## Context Step 6 of epic #63 (JavaScript back end), slice 4, part B of `docs/design/JAVASCRIPT-BACKEND.md` section 6 row 4 ("The kernel, part 1B"). Slices 1 to 3 and 4A (#678, #684, #701, #708; PR #718 merged as 79b35cb9) are on `main`: `compiler/src/backend/javascript/{emit,body,type,natives,witness,count,writer}.trb`, `runtime/javascript/{core,int64,list}.mjs`, `tools/conformance.sh --js`, `tests/conformance/js.allow`, CI job `conformance-js`. 4A left the list storage and the list and text natives in place; what still stops programs is the part of the kernel of natives that has no JavaScript yet (the text show, parse and hash natives, the remaining widths, `isSame`) and the fact that nothing proves the table complete. ## Source - `docs/design/JAVASCRIPT-BACKEND.md` section 3 (the kernel, K1 to K8), section 6 row 4B and the paragraph "What slice 4A left out, on purpose". - `docs/design/NATIVES.md` (the manifest, `nativeEntries()`; `isSame` is a planned intrinsic there). - `compiler/src/backend/c/natives.trb` and `runtime/` as the reference for what each symbol means; `compiler/src/backend/javascript/natives.trb` for what is mapped today. ## Goal - **Manifest walk.** A test walks `nativeEntries()` and fails for every entry that has no JavaScript mapping, except for an explicit *deferred* list naming the entries that belong to slice 5 (floats, `libm`) and slice 7 (tasks, time, files). The list is data in the repo, reviewed like `js.allow`. - **Kernel, rest of part 1.** K1, K2, K4, K5, K7 and K8 complete over every integer width, plus the text natives the 4A candidates needed (show, parse, hash of text and integers). Maps and sets stay out: they wait for epic #55 as the record says. - **`isSame`.** Mapped as it stands in NATIVES.md; if it has become an IR intrinsic by the time this is implemented, follow the IR. - **`Intrinsic` sweep.** Every `Intrinsic` of the IR over every width is emitted or named as deferred. - **Property tests.** The helpers of `runtime/javascript/int64.mjs` and the intrinsics are tested against `BigInt` in `tools/` (random and boundary operands, each operator and width, 10^6 cases each) and report zero differences. ## Decided by the loop - Maps and sets are not part of 4B (epic #55 first); a program that needs a `HashMap`, `HashSet` or `Trie*` stays off `js.allow`. - The programs 4A trimmed are the first candidates: `bankers-queue`, `bound-methods`, `buffer-field-derived`, `buffer-list`, `collect-through-wrappers`, `cons-stack-persists`, `destructor-early-exits`, `entry-cell-trait`, `interpolation`, `joined`, `plain-bound`, `shared-top-level-const`, `source-trait-value`, `trait-constants`, and `heap-order` (differs at runtime). A program that still needs floats, tasks or a map stays off and is listed in the PR with the finding that names the later slice. - A change of the manifest is **two commits** (CONTRIBUTING, "Repository Operations"); the implementer confirms with `tools/check-commits.sh`. ## Files - `compiler/src/backend/javascript/natives.trb`, `body.trb` (intrinsics), `emit.trb`. - `runtime/javascript/core.mjs`, `int64.mjs` (helpers; a new file only if the "absent unless used" rule needs it). - `tools/` (the `BigInt` property tests), the manifest-walk test and the deferred list. - `tests/conformance/js.allow`. - `docs/design/JAVASCRIPT-BACKEND.md`: row 4 marked done, a "What slice 4B left out" paragraph; docs regenerated as `torb docs` requires. ## Tests 1. The manifest walk is green with the explicit deferred list; adding an entry to `nativeEntries()` without a mapping or a deferred entry fails it. 2. The `BigInt` property tests report zero differences for each operator and width. 3. Existing programs that build and run under Node with the same `.expected`, `.stderr` and `.exit` files join `js.allow` (candidates above); no program of `js.allow` is removed. ## Acceptance criteria - [ ] The manifest walk fails for an entry without JavaScript that is not on the deferred list, and passes on `main` with the list naming only slice 5 and 7 entries - [ ] The property tests against `BigInt` (10^6 cases per operator and width) report zero differences - [ ] `js.allow` grows by every candidate above that passes, at least `buffer-list`, `interpolation` and `heap-order`; each program left off is listed in the PR with its reason - [ ] A program that uses none of the new natives produces the same JavaScript as before: pinned by an unchanged output of `javascript_first.trb` - [ ] Row 4 of the design record is marked done; docs regenerated; `torb format --check` and `torb docs check` green - [ ] `tools/check-commits.sh` clean; `sh tools/gates.sh a` and the `conformance-js` job green in forge CI (CI only, no local bootstrap or gates) ## Seed No syntax change and no new std name the compiler looks up; the manifest is read, and a change of it follows the two-commit rule. Split by the implementer if a review cannot hold it: the manifest walk with the deferred list first, then the width and intrinsic sweep with the property tests, both inside this issue. ## Out of scope Maps and sets (epic #55), floats and `libm` (5), structured control flow (6), tasks (7), `.nojs` markers and `torb test` (8), a minifier, source maps. ## Dependencies #708 (slice 4A, landed as PR #718). Part of #63 (epic; do not close it).
Author
Collaborator

[loop:torbscript] claim implementation by session:loop-torbscript-20261113 until 2026-11-13T05:11:12Z

[loop:torbscript] claim implementation by session:loop-torbscript-20261113 until 2026-11-13T05:11:12Z
Author
Collaborator

[loop:torbscript] checkpoint implementation (branch loop/724-js-kernel-rest, nothing pushed yet).

  • 4A already emits the arithmetic and bit tables for I8..U64, Convert, comparisons and text intrinsics. Missing: native mapping (show, parse, hash, power, combineHashes, text and Char natives), the manifest walk with its deferred list, BigInt property tests, isSame, the design record update.
  • The manifest holds groups that are neither slice 5 nor slice 7 (Decimal, unicode/normalization/idna, tls/network/dns, console/test, OS-specific, maps and sets of epic #55). Criterion 1 says the list names only slice 5 and 7 entries. Plan: map what the kernel needs, tag the rest with its real slice or epic, and call out the deviation in the PR.
  • No C compiler or torb binary here, so compiler changes are verified in forge CI only; the BigInt property tests are plain node and run locally.
  • tasks-mcp is read-only for git.torb.dev, so write-backs go through the API with Orion's token as LOOP.md allows.
[loop:torbscript] checkpoint implementation (branch `loop/724-js-kernel-rest`, nothing pushed yet). - 4A already emits the arithmetic and bit tables for I8..U64, Convert, comparisons and text intrinsics. Missing: native mapping (show, parse, hash, power, combineHashes, text and Char natives), the manifest walk with its deferred list, BigInt property tests, `isSame`, the design record update. - The manifest holds groups that are neither slice 5 nor slice 7 (Decimal, unicode/normalization/idna, tls/network/dns, console/test, OS-specific, maps and sets of epic #55). Criterion 1 says the list names only slice 5 and 7 entries. Plan: map what the kernel needs, tag the rest with its real slice or epic, and call out the deviation in the PR. - No C compiler or torb binary here, so compiler changes are verified in forge CI only; the BigInt property tests are plain node and run locally. - tasks-mcp is read-only for git.torb.dev, so write-backs go through the API with Orion's token as LOOP.md allows.
Author
Collaborator

[loop:torbscript] checkpoint 2 (implementer, #724)

  • BigInt property script tools/js-int-properties.mjs: 113,982,535 cases (seed 724, 10^6 random per operator and width, plus boundary pairs), 0 differences against BigInt for value, canonical form and panic text. A mutation check (an overflow check removed) is caught (8 differences), so the harness is sensitive. No defect found in int64.mjs.
  • The IR already resolves Target/Intrinsic/Derived/Container/ArrayStorage/Lowered entries before the JS back end sees them, so the manifest walk is really over .Runtime(symbol) entries plus the intrinsics emitIntrinsic does not emit (floats, LazyForce).
  • Deviation (will be stated in the PR): the deferred list cannot name only slices 5 and 7 (Decimal, unicode, tls, os, vm, harness, maps/sets belong elsewhere), so entries carry honest tags.
  • Plumbing outside the literal file list: writer.trb (usesX flag), cli/build.trb (reads the new runtime file), because a new runtime part must be absent unless used (criterion 4).
  • Next: text/hash/parse/power/conversion natives in a new runtime file, natives.trb mappings, the manifest-walk test, js.allow, docs.
[loop:torbscript] checkpoint 2 (implementer, #724) - BigInt property script `tools/js-int-properties.mjs`: 113,982,535 cases (seed 724, 10^6 random per operator and width, plus boundary pairs), 0 differences against BigInt for value, canonical form and panic text. A mutation check (an overflow check removed) is caught (8 differences), so the harness is sensitive. No defect found in `int64.mjs`. - The IR already resolves Target/Intrinsic/Derived/Container/ArrayStorage/Lowered entries before the JS back end sees them, so the manifest walk is really over `.Runtime(symbol)` entries plus the intrinsics `emitIntrinsic` does not emit (floats, LazyForce). - Deviation (will be stated in the PR): the deferred list cannot name only slices 5 and 7 (Decimal, unicode, tls, os, vm, harness, maps/sets belong elsewhere), so entries carry honest tags. - Plumbing outside the literal file list: `writer.trb` (usesX flag), `cli/build.trb` (reads the new runtime file), because a new runtime part must be absent unless used (criterion 4). - Next: text/hash/parse/power/conversion natives in a new runtime file, natives.trb mappings, the manifest-walk test, js.allow, docs.
Author
Collaborator

[loop:torbscript] checkpoint 3: the kernel runtime part and its oracle property scripts are written and clean (tools/js-int-properties.mjs: 113,982,535 cases, 0 differences; tools/js-kernel-properties.mjs: 639,174 checks, 0 differences, the mutation check detects faults). Next: natives.trb mappings, the usesKernel plumbing (writer, body, emit, cli/build), the deferred list, the manifest-walk test, docs. The compiler edits cannot be built in my exec, so CI is the check.

[loop:torbscript] checkpoint 3: the kernel runtime part and its oracle property scripts are written and clean (tools/js-int-properties.mjs: 113,982,535 cases, 0 differences; tools/js-kernel-properties.mjs: 639,174 checks, 0 differences, the mutation check detects faults). Next: natives.trb mappings, the usesKernel plumbing (writer, body, emit, cli/build), the deferred list, the manifest-walk test, docs. The compiler edits cannot be built in my exec, so CI is the check.
Author
Collaborator

[loop:torbscript] checkpoint 4: natives.trb mappings, the usesKernel plumbing, the deferred list (tests/conformance/js.deferred) and the manifest-walk test (compiler/tests/js-natives.test.trb) are written. Next: js.allow candidates, the design record, commit, push, PR and CI. Note for the PR: criterion 1 holds with honest tags (5, 7, 8, 55, vm, unassigned) because many deferred natives belong to no numbered slice.

[loop:torbscript] checkpoint 4: natives.trb mappings, the usesKernel plumbing, the deferred list (tests/conformance/js.deferred) and the manifest-walk test (compiler/tests/js-natives.test.trb) are written. Next: js.allow candidates, the design record, commit, push, PR and CI. Note for the PR: criterion 1 holds with honest tags (5, 7, 8, 55, vm, unassigned) because many deferred natives belong to no numbered slice.
Author
Collaborator

[loop:torbscript] checkpoint 5: PR #725 round 2 had 4 conformance programs red (buffer-list, cons-stack-persists, heap-order, interpolation). Round 3 pushed as d4d8ec9a: interpolated Char and Void now go through torb_show_char / "void" (cause of the 223 and the empty line); a retained slot now hands a copy of its own to the new holder (suspected cause of the aliasing). Waiting for CI; any program still red will be taken off js.allow and listed in the PR.

[loop:torbscript] checkpoint 5: PR #725 round 2 had 4 conformance programs red (buffer-list, cons-stack-persists, heap-order, interpolation). Round 3 pushed as d4d8ec9a: interpolated Char and Void now go through torb_show_char / "void" (cause of the `223` and the empty line); a retained slot now hands a copy of its own to the new holder (suspected cause of the aliasing). Waiting for CI; any program still red will be taken off js.allow and listed in the PR.
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261113 until 2026-11-13T08:00:00Z

PR #725 at 40720250: tier A, tier B and tools/release-sync are red (run 2635 jobs 5, 6, 7); a fix worker reads the failures and pushes a fix round to loop/724-js-slice-4b.

[loop:torbscript] claim implement by session:loop-torbscript-20261113 until 2026-11-13T08:00:00Z PR #725 at 40720250: tier A, tier B and tools/release-sync are red (run 2635 jobs 5, 6, 7); a fix worker reads the failures and pushes a fix round to loop/724-js-slice-4b.
Author
Collaborator

[loop:torbscript] implementation: fix round for PR #725 at 40720250 found no code defect, so nothing was pushed (head unchanged).

  • What failed: run #2635 (jobs 5, 6, 7: tier A, tier B, tools/release-sync) all ended with context canceled from the runner, not with a test failure. The forge job logs (tasks 12572, 12573, 12574) show every test that ran as passing (release-sync: 66 passed, 0 failed (5 files); tier A and B had no FAIL line; tier B was in the runtime tests when the runner cancelled it). The three jobs were killed at 01:32:20 to 01:32:45Z, within seconds of each other. The same cancel hit an unrelated PR: #723 run #2633 tier A (task 12556) ended context canceled at 01:32:57Z. In the same run, bootstrap, conformance (JavaScript under Node.js), every host emits the same C and the playground are green on 40720250, so js.allow stays as it is.
  • Fix: none needed in the source. A fresh CI run for the same sha (#2644 ci, #2645 pdisc) is already queued (state waiting, not started at 01:55Z); gates is blocked on it. I did not trigger a rerun, and did not push an empty commit.
  • CI state at time of writing: old run red by runner cancel, new run waiting. If tier A/B/release-sync go red again with a real FAIL line in run #2644, that is a code failure and needs another fix round.
[loop:torbscript] implementation: fix round for PR #725 at 40720250 found no code defect, so nothing was pushed (head unchanged). - What failed: run #2635 (jobs 5, 6, 7: tier A, tier B, tools/release-sync) all ended with `context canceled` from the runner, not with a test failure. The forge job logs (tasks 12572, 12573, 12574) show every test that ran as passing (release-sync: 66 passed, 0 failed (5 files); tier A and B had no FAIL line; tier B was in the runtime tests when the runner cancelled it). The three jobs were killed at 01:32:20 to 01:32:45Z, within seconds of each other. The same cancel hit an unrelated PR: #723 run #2633 tier A (task 12556) ended `context canceled` at 01:32:57Z. In the same run, bootstrap, conformance (JavaScript under Node.js), every host emits the same C and the playground are green on 40720250, so js.allow stays as it is. - Fix: none needed in the source. A fresh CI run for the same sha (#2644 ci, #2645 pdisc) is already queued (state waiting, not started at 01:55Z); gates is blocked on it. I did not trigger a rerun, and did not push an empty commit. - CI state at time of writing: old run red by runner cancel, new run waiting. If tier A/B/release-sync go red again with a real FAIL line in run #2644, that is a code failure and needs another fix round.
Author
Collaborator

[loop:torbscript] release implement: no code fault found in the red jobs (runner context canceled at 01:32Z, also hit #723); a clean CI run on 40720250 (#2644) is queued, nothing pushed, claim ends

[loop:torbscript] release implement: no code fault found in the red jobs (runner `context canceled` at 01:32Z, also hit #723); a clean CI run on 40720250 (#2644) is queued, nothing pushed, claim ends
argus closed this issue 2026-11-13 02:43:04 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#724
No description provided.