Skip to content

feat(ts)!: name the runtime's namespace rs - #578

Merged
moq-bot[bot] merged 4 commits into
mainfrom
quest/m3/ts-rs-rename
Nov 4, 2026
Merged

moq-bot[bot] merged 4 commits into
mainfrom
quest/m3/ts-rs-rename

Conversation

@kixelated

@kixelated kixelated commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

rust2-ts's runtime was imported and named rt. The maintainer decided on 2026-11-03 to name it rs, so a translated Rust type reads as rs.Vec, rs.HashMap, rs.u64. Completes quest/m3/ts-rs-rename.md.

Approach

A purely mechanical rename, by the script below, over ts/ and the TS quests (quest/*ts-*):

  • ts/runtime/rt.ts and ts/runtime/rt/ move to ts/runtime/rs.ts and ts/runtime/rs/.
  • Every bounded rt, Rt, RT token becomes rs, Rs, RS: the emitted import * as rs from "./rs.ts", Expr::rs/Expr::Rs/Type::Rs/rs_of/uses_rs in the driver, the runtime's own imports, tests, bench, README, quest text, and the bind fixture's RS/held.ts refusal.
  • std's own rt module keeps its name: fmt::rt::Argument and rt::begin_panic (ts/src/lower/library.rs).
  • Snapshots regenerated with UPDATE_EXPECT=1.

Re-applying after merging main

Open TS PRs (#573, #574, the rs.Slice and B-tree quests) merge main, then run this from the repo root and regenerate snapshots (UPDATE_EXPECT=1 just ts test). It is idempotent, and moves any file a PR added under ts/runtime/rt/:

for f in $(git ls-files ts/runtime/rt.ts 'ts/runtime/rt/*'); do
	to="ts/runtime/rs${f#ts/runtime/rt}"
	mkdir -p "$(dirname "$to")"
	git mv "$f" "$to"
done
git grep -lzP '(?<![A-Za-z0-9])(rt|Rt|RT)(?![A-Za-z0-9])' -- ts 'quest/*ts-*' |
	xargs -0r perl -pi -e '
		s/(?<![A-Za-z0-9])(?<!fmt::)(?<!"fmt", ")rt(?![A-Za-z0-9])(?!::)(?!", "begin_panic")/rs/g;
		s/(?<![A-Za-z0-9])Rt(?![A-Za-z0-9])/Rs/g;
		s/(?<![A-Za-z0-9])RT(?![A-Za-z0-9])/RS/g'

Afterwards git grep -nwP 'rt|Rt|RT' -- ts should list only the three std paths above.

Proof: name only

  • moq bundle (just ts moq at the pin, before and after): identical once each side's namespace is replaced by a placeholder and the $hash instance suffixes are renumbered by first appearance. Those suffixes hash each instance's printed text (ts/src/program.rs name_by_text), which contains the namespace, so they change with it; renumbering consistently across both trees shows a one-to-one mapping. Source maps' sources and sourcesContent are byte-identical.
  • Snapshots: the same normalization over ts/fixtures on main against this branch differs only on lines that already said rs ("rs" in tuples, moq's rs/ source paths), which the normalizer itself rewrote.

Collisions

rs keeps every guarantee rt had: it is reserved in the module scope (ts/src/program.rs), in each function's locals (ts/src/print.rs), and in RESERVED (ts/src/lower/mod.rs); a top-level module named rs and a binding under rs/ are refused. Verified ad hoc on a scratch crate: pub fn rs prints as rs_, a local rs live across a loop as rs_, and pub mod rs fails with "a top-level module named rs would replace the runtime, rs.ts and rs/". The existing case-insensitive binding test (ts/fixtures/bind, now RS/held.ts) carries over; no test existed for the other cases, and none is added so the PR stays mechanical. Neither moq's crates nor main's output had any rs identifier before.

Impact

  • Translated output imports the runtime as rs from ./rs.ts, with its modules in rs/; every rt.X is now rs.X. Hand-written callers of translated code change import * as rt from "./rt.ts" to import * as rs from "./rs.ts".
  • A crate's top-level module or binding path may now be named rt, and may not be named rs.
  • No Rust API of the driver is public.

Alternatives

  • Hand edits per file: not reproducible for the PRs in flight.

Follow-ups

None.

Review

mechanical fix by codex / Codex: Merged base, preserved the rt-to-rs rename and base panic-site additions, and regenerated snapshots; passed in ts/ with pinned nightly: cargo build --locked -p rust2-ts; UPDATE_EXPECT=1 cargo test --locked -p rust2-ts --test fixtures lang::panics -- --exact; cargo test --locked -p rust2-ts (104 tests); cargo clippy --locked -p rust2-ts --all-targets -- -D warnings; cargo fmt --all --check; tsc -p runtime. (head ee034da)

  • Reviewer: Codex, gpt-6.1-sol, medium effort (quest review --base origin/main), round 1 on 12834f4978a27f6063aa8e1ab285963e5ecf093f: 0 findings.
  • 5f12b1794 since adds only a conflict-free merge of origin/main (perf(ffi): call the extension's Python methods with no wrapper frame #575, ffi only), on which the script is a no-op.
  • Checks: just ci passed on both heads; just ts moq passed.

🤖 Generated with Claude Code

kixelated and others added 3 commits November 4, 2026 02:02
Quest-Claim: 8a39ad44aa08ce6b
Translated code imports the runtime as `rs` from `rs.ts`, and its modules
live in `runtime/rs/`. std's own `fmt::rt` and `rt::begin_panic` keep
their names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title The runtime's namespace is rs feat(ts)!: name the runtime's namespace rs Nov 4, 2026
@kixelated
kixelated marked this pull request as ready for review November 4, 2026 10:26
@kixelated
kixelated added this pull request to the merge queue Nov 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 4, 2026
@moq-bot

moq-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

quest land watch: the merge queue removed this pull request at 5f12b17 because it conflicts with main (merge_conflict).

The land fixer works on it in the background, and the watcher re-enqueues it at the back of the queue once it is fixed or judged flaky, or hands it back here with what it needs.

(written by quest land watch)

@moq-bot
moq-bot Bot enabled auto-merge November 4, 2026 10:42
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 25206528-3b1d-4278-b622-b8ee07e21897
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@moq-bot

moq-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown

quest land watch: armed auto-merge on this pull request at ee034da, so it joins the back of the merge queue once its required checks pass, with the land fixer's fix (codex / Codex): Merged base, preserved the rt-to-rs rename and base panic-site additions, and regenerated snapshots; passed in ts/ with pinned nightly: cargo build --locked -p rust2-ts; UPDATE_EXPECT=1 cargo test --locked -p rust2-ts --test fixtures lang::panics -- --exact; cargo test --locked -p rust2-ts (104 tests); cargo clippy --locked -p rust2-ts --all-targets -- -D warnings; cargo fmt --all --check; tsc -p runtime..

(written by quest land watch)

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes: verified end-to-end that the PR's claim of a purely mechanical rt→rs rename holds, not by inspection: I re-extracted the base tree (5ad8ee2, ts/ + quest/), applied the PR's own rename script from the body into a scratch copy, normalized the $hash instance-suffixes that legitimately change (instance names hash printed text containing the namespace), and diff -red the whole ts/ tree against the head. The result: zero non-rename deltas.

  • Runtime files renamed: ts/runtime/rt.ts and ts/runtime/rt/ become rs.ts/rs/; program.rs's RUNTIME table, each module's references, and the runtime's own imports update in lockstep.
  • Driver internals renamed: Expr::Rt→Rs, Type::Rt→Rs, Expr::rt/Expr::rt_of→rs/rs_of, uses_rt→uses_rs; the emitted import is import * as rs from "./rs.ts".
  • Collisions flip: rs is reserved in module scope (ts/src/program.rs), in locals (ts/src/print.rs), and in RESERVED (ts/src/lower/mod.rs); rt is freed. The bind fixture's RS/held.ts refusal now reads "RS/held.ts would replace the runtime, rs.ts and rs/".
  • std untouched as promised: the only remaining word-token rt in ts/ is fmt::rt::Argument (ts/runtime/rs.rs doc comment) and ("rt", "begin_panic") / ["fmt", "rt", "Argument"] in ts/src/lower/library.rs:358/1033/2892.
  • Quests bookkeeping: quest/m3/ts-rs-rename.md deleted as complete, its bullet dropped from quest/m3/README.md, and the stale rt.* references in the m2/m3 TS quests updated.

Checks this run:

  • cargo test --locked --test fixtures in ts/: all 86 tests pass locally. CI (Queue) had not started at review time, so the merge queue will re-prove it.
  • The codec fixture's differential harness: 33139 cases, 0 panics, 0 aborts, 0 differences (first run failed only on bun/esbuild missing from the ephemeral shell; installing them fixed it).
  • Repo-wide grep: no stale import * as rt, ./rt.ts, or runtime/rt references anywhere outside ts/ (the ffi/ and go/ hits are those projects' own unrelated rt runtimes; remaining ts/ hits are substrings like sort.ts).

Pullfrog  | View workflow run | Using glm-5.3-flash | 𝕏

@moq-bot
moq-bot Bot added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit 1da43d5 Nov 4, 2026
7 checks passed
@moq-bot
moq-bot Bot deleted the quest/m3/ts-rs-rename branch November 4, 2026 10:50
kixelated added a commit that referenced this pull request Nov 4, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant