From 50e2c59b4aba400b6219c372a58347df189e27ba Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Mon, 26 Oct 2026 19:17:22 -0700 Subject: [PATCH 1/4] chore(quest): default comparison methods and generic instances Follow-ups from #98 and #94. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn --- quest/m1/README.md | 1 + quest/m1/ffi-generic.md | 20 ++++++++++++++++++++ quest/m2/README.md | 1 + quest/m2/ts-cmp-defaults.md | 23 +++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 quest/m1/ffi-generic.md create mode 100644 quest/m2/ts-cmp-defaults.md diff --git a/quest/m1/README.md b/quest/m1/README.md index 4ea0f357f..175fc1311 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -18,5 +18,6 @@ are folded into the [exporter's](/quest/m1/ffi-export.md). The - [Waiting: publish the UniFFI fork](/quest/m1/uniffi-release.md) - the fork publishes to crates.io under `rust2-*` names, once the maintainer decides it should - [Exporter](/quest/m1/ffi-export.md) - moq's bindings exported from its crates' `pub` API, replacing the fork +- [Export instances of generic types](/quest/m1/ffi-generic.md) - a generic type exports at the instances the config names - [Land main through quest land](/quest/m1/land.md) - every queued PR lands as one tested batch through the shared gate - [Bump quest to quest land](/quest/m1/land-bump.md) - condition: kixelated/quest ships `quest land`; then bump the flake input diff --git a/quest/m1/ffi-generic.md b/quest/m1/ffi-generic.md new file mode 100644 index 000000000..16733a781 --- /dev/null +++ b/quest/m1/ffi-generic.md @@ -0,0 +1,20 @@ +# [M] Export instances of generic types + +## Goal + +The [exporter](/ffi/README.md) exports a generic type at the instances the config names, +such as `catalog::Producer`, so moq-ffi's media API that uses each at one +type exports from moq-mux and hang. + +## Plan + +Found by [#94](https://github.com/kixelated/rust2/pull/94) on 2026-10-27: refused generic +types block about 67 of moq-ffi's partly covered items, mostly in moq-mux +(`catalog::Producer`, `container::Consumer`). moq-ffi uses each at one type. + +- Name each instance in [the config](/ffi/moq/ffi.toml), with the C name it exports + under, and refuse with a span any signature that reaches a generic type at an instance + the config does not name. +- Report each export's census and the coverage of moq-ffi's API before and after. + +Public API: the exporter's config and the C names it emits. diff --git a/quest/m2/README.md b/quest/m2/README.md index 36996ca94..aba8a7cce 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -38,6 +38,7 @@ The fork's feature quests folded into the [exporter](/quest/m1/ffi-export.md); - [Share a held-back read across a call](/quest/m2/ts-shared-read.md) - `leading-ones` decode recovers what #83's copy fix cost - [Output tsc accepts for writes through Result and Poll compares](/quest/m2/ts-tsc-shapes.md) - two shapes whose output fails `tsc` type-check - [Translate derived == through references and slice index writes](/quest/m2/ts-ref-shapes.md) - two refused shapes #83's tests hit +- [Default comparison methods](/quest/m2/ts-cmp-defaults.md) - inherited `ne`, `lt`, `le`, `gt`, `ge` and `[u8]` equality translate - [Translate moq-net's model to TypeScript](/quest/m2/ts-model.md) - the driver grows from moq-net's codec to its model, for moq to compare against WASM - [Waiting: Swift 6.4 in nixpkgs-unstable](/quest/m2/uniffi-swift-arm.md) - the nightly UniFFI fixtures move back to arm - [Waiting: ubrn reads UniFFI 0.32](/quest/m2/ubrn-release.md) - the binding benchmark's browser runner pins a ubrn release, not an open PR diff --git a/quest/m2/ts-cmp-defaults.md b/quest/m2/ts-cmp-defaults.md new file mode 100644 index 000000000..6e5aef8f2 --- /dev/null +++ b/quest/m2/ts-cmp-defaults.md @@ -0,0 +1,23 @@ +# [S] Default comparison methods + +## Goal + +rust2-ts translates the default `ne`, `lt`, `le`, `gt`, and `ge` that a crate's own +`PartialEq` and `PartialOrd` impls inherit, and `<[u8] as PartialEq>::eq`, so `a != b` +and `a < b` on derived types translate, proven by differential tests against native +Rust. + +## Plan + +Found by [#98](https://github.com/kixelated/rust2/pull/98) on 2026-10-27: comparisons +through references now reach the referent's impl, which still refuses an inherited +method. moq-net's census refuses about 60 `ne` calls this way, `path::Path`'s among +them. + +- Lower `ne` as `!eq` and the ordering methods from `partial_cmp`, as std's defaults do, + so a `partial_cmp` returning `None` makes all four false. +- Cover a hand-written `partial_cmp` that returns `None`, and a type whose `eq` and + `partial_cmp` disagree, in the differential tests. +- Report moq-net's census before and after. + +Public API: the translator's output. From 3999100d62f7b5663de42cbde4e079fa2a9e29d0 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Mon, 26 Oct 2026 19:40:01 -0700 Subject: [PATCH 2/4] chore(quest): Cow and str slicing from #96 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn --- quest/m2/README.md | 2 ++ quest/m2/ts-cow-str.md | 19 +++++++++++++++++++ quest/m2/ts-str-slice.md | 20 ++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 quest/m2/ts-cow-str.md create mode 100644 quest/m2/ts-str-slice.md diff --git a/quest/m2/README.md b/quest/m2/README.md index aba8a7cce..889864268 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -39,6 +39,8 @@ The fork's feature quests folded into the [exporter](/quest/m1/ffi-export.md); - [Output tsc accepts for writes through Result and Poll compares](/quest/m2/ts-tsc-shapes.md) - two shapes whose output fails `tsc` type-check - [Translate derived == through references and slice index writes](/quest/m2/ts-ref-shapes.md) - two refused shapes #83's tests hit - [Default comparison methods](/quest/m2/ts-cmp-defaults.md) - inherited `ne`, `lt`, `le`, `gt`, `ge` and `[u8]` equality translate +- [Copy-on-write strings](/quest/m2/ts-cow-str.md) - `Cow` translates, finishing `ietf/namespace.rs` +- [str slicing and &str patterns](/quest/m2/ts-str-slice.md) - `&s[a..b]` and `&str` patterns translate, so `rfind`'s offsets are usable - [Translate moq-net's model to TypeScript](/quest/m2/ts-model.md) - the driver grows from moq-net's codec to its model, for moq to compare against WASM - [Waiting: Swift 6.4 in nixpkgs-unstable](/quest/m2/uniffi-swift-arm.md) - the nightly UniFFI fixtures move back to arm - [Waiting: ubrn reads UniFFI 0.32](/quest/m2/ubrn-release.md) - the binding benchmark's browser runner pins a ubrn release, not an open PR diff --git a/quest/m2/ts-cow-str.md b/quest/m2/ts-cow-str.md new file mode 100644 index 000000000..3332f4007 --- /dev/null +++ b/quest/m2/ts-cow-str.md @@ -0,0 +1,19 @@ +# [M] Copy-on-write strings + +## Goal + +rust2-ts translates `Cow`, so moq-net's `ietf/namespace.rs` translates with no +refusals, proven by differential tests against native Rust. + +## Plan + +Found by [#96](https://github.com/kixelated/rust2/pull/96) on 2026-10-27: after `str`'s +char methods translate, ` as From<&str>>::from` is `namespace.rs`'s last +refusal, and `Cow` accounts for 139 of moq-net's. + +- Choose the representation with the maintainer: a plain JS string, since `str` is + immutable in the output, or a tagged value that keeps `Cow::Borrowed` and + `Cow::Owned` apart for `matches!` and `is_borrowed`. +- Report moq-net's census before and after. + +Public API: the translator's output. diff --git a/quest/m2/ts-str-slice.md b/quest/m2/ts-str-slice.md new file mode 100644 index 000000000..e2f7d7a2d --- /dev/null +++ b/quest/m2/ts-str-slice.md @@ -0,0 +1,20 @@ +# [S] str slicing and &str patterns + +## Goal + +rust2-ts translates `&s[a..b]` on a `str` and the `str` methods that take a `&str` +pattern, so moq-net's `path/mod.rs`, `discovery.rs`, and `lite/compress.rs` translate, +proven by differential tests against native Rust. + +## Plan + +Found by [#96](https://github.com/kixelated/rust2/pull/96) on 2026-10-27, which +translated `char` patterns and returns UTF-8 byte offsets from `rfind` and +`match_indices`. Slicing is what lets those offsets be used. + +- Slice by UTF-8 byte offsets and panic, as std does, on a boundary inside a char. +- An empty `&str` pattern matches between every char in `split`, `trim_*`, and + `match_indices`; cover it and multi-byte patterns in the differential tests. +- Report moq-net's census before and after. + +Public API: the translator's output. From 2aa91ca1c5e840c7d548b62ec34aa2130941d751 Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Mon, 26 Oct 2026 19:48:44 -0700 Subject: [PATCH 3/4] chore(quest): share Copy types the crate never changes in place Replaces ts-shared-read's narrow fix, as #99 suggested. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn --- quest/m2/README.md | 2 +- quest/m2/ts-shared-read.md | 33 ++++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/quest/m2/README.md b/quest/m2/README.md index 81329e147..f3e257e39 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -35,7 +35,7 @@ The fork's feature quests folded into the [exporter](/quest/m1/ffi-export.md); - [Shared ownership](/quest/m2/ts-shared.md) - `Arc`/`Rc`/`Weak` keep exact counts, and locks and atomics become plain values - [Copy what a container stores](/quest/m2/ts-store-alias.md) - `push` and other stores of a `Copy` aggregate copy it instead of sharing it - [str and String methods over char](/quest/m2/ts-str-char.md) - `chars`, `char` patterns, and `String::push` translate, unblocking `ietf/namespace.rs` -- [Share a held-back read across a call](/quest/m2/ts-shared-read.md) - `leading-ones` decode recovers what #83's copy fix cost +- [Share what the crate never changes in place](/quest/m2/ts-shared-read.md) - copies of `Copy` aggregates no one writes into in place go away, recovering #83's decode cost - [Output tsc accepts for writes through Result and Poll compares](/quest/m2/ts-tsc-shapes.md) - two shapes whose output fails `tsc` type-check - [Default comparison methods](/quest/m2/ts-cmp-defaults.md) - inherited `ne`, `lt`, `le`, `gt`, `ge` and `[u8]` equality translate - [Copy-on-write strings](/quest/m2/ts-cow-str.md) - `Cow` translates, finishing `ietf/namespace.rs` diff --git a/quest/m2/ts-shared-read.md b/quest/m2/ts-shared-read.md index cefa252a8..034b5c7d5 100644 --- a/quest/m2/ts-shared-read.md +++ b/quest/m2/ts-shared-read.md @@ -1,20 +1,31 @@ -# [XS] Share a held-back read across a call +# [S] Share what the crate never changes in place ## Goal -`Decoder::varint`'s `leading-ones` decode on `just ts bench` is back to its speed before -[#83](https://github.com/kixelated/rust2/pull/83) in Chrome, with every differential -test still passing. +rust2-ts shares a `Copy` aggregate, where it copies one today, when nothing in the crate +writes into a value of that type in place. `Decoder::varint`'s `leading-ones` decode +on `just ts bench` is back to its speed before +[#83](https://github.com/kixelated/rust2/pull/83) in Chrome, and every differential +test still passes. ## Plan -Decided with the maintainer on 2026-10-26: #83 fixed a silent copy miscompile and -accepted a 2-19% `leading-ones` decode cost in Node and Chromium to do it. The -translator now copies `self.form` before calling `read`, because an earlier pass stops -holding back the read of `self.form` before that call, so the call can't share it. +Decided with the maintainer on 2026-10-27, replacing the narrower fix for +`self.form`'s copy that this quest held before: +[#83](https://github.com/kixelated/rust2/pull/83) and +[#99](https://github.com/kixelated/rust2/pull/99) copy a `Copy` aggregate before a call +can share it (`self.form` before `read`, `copy$Form` in `Decoder::new` and +`Encoder::new`, and map keys). A copy is only observable if something writes into a +shared value in place: a field or element assignment through it, or a `&mut` to its +inside. A type the crate never writes that way can be shared freely. -- Let the held-back read reach the call when nothing between them can change the - source, so `self.form` is shared again without a copy. -- Prove the read is still exact with the argument-aliasing cases #83 added. +- Find, per crate, each `Copy` aggregate type that some place writes into in place, and + let `copy_fn`'s callers skip the copy for every other type. +- Keep the analysis whole-crate and fail closed: a write the analysis can't see, such as + through a generic, counts as a write. +- Prove it with #83's argument-aliasing cases and #99's store cases, plus a new case + where the only in-place write is in another module or behind a generic. +- Report the copies removed in moq-net's output, and the Chrome codec bench before and + after. Public API: the translator's output. From a89d428c92f0c3bb3fbfb6d148615919bf70430a Mon Sep 17 00:00:00 2001 From: Luke Curley <432854+kixelated@users.noreply.github.com> Date: Mon, 26 Oct 2026 20:15:26 -0700 Subject: [PATCH 4/4] chore(quest): an A/A control that measures noise From #87's and #97's bench findings. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0115AT2ue6x9cT5e5J9SZtCn --- quest/m2/README.md | 1 + quest/m2/ts-bench-aa.md | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 quest/m2/ts-bench-aa.md diff --git a/quest/m2/README.md b/quest/m2/README.md index b011fdcbb..ef690b3b7 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -28,6 +28,7 @@ The fork's feature quests folded into the [exporter](/quest/m1/ffi-export.md); - [Cheaper byte slices](/quest/m2/ts-byte-views.md) - splitting a `&[u8]` stops making a `Uint8Array` view per split - [Smaller output from MIR](/quest/m2/ts-mir-size.md) - the bench's bundles shrink back to THIR's sizes, coroutine classes first +- [An A/A control that measures noise](/quest/m2/ts-bench-aa.md) - `just ts bench`'s A/A measures only noise, in every engine - [Time Timestamp's checked_add and Ord](/quest/m2/ts-bench-timestamp.md) - the `u128` paths #89 sped up get a Chrome timing - [Time the minified bundles](/quest/m2/ts-bench-minified.md) - `just ts bench` times what it measures for size, as consumers ship it - [Drop in the TypeScript translator](/quest/m2/ts-drop.md) - every value that drops in moq-net and kio drops where Rust drops it diff --git a/quest/m2/ts-bench-aa.md b/quest/m2/ts-bench-aa.md new file mode 100644 index 000000000..0ba45206e --- /dev/null +++ b/quest/m2/ts-bench-aa.md @@ -0,0 +1,23 @@ +# [S] An A/A control that measures noise + +## Goal + +`just ts bench`'s `A/A` route times the same code as `translated` with nothing else +different, so its spread is the run's noise on every engine, Chrome, Firefox, and Bun. + +## Plan + +Found by [#87](https://github.com/kixelated/rust2/pull/87) and +[#97](https://github.com/kixelated/rust2/pull/97) on 2026-10-27: + +- In JavaScriptCore, the `A/A` bundle and a route's bundle with identical text appear + to share type profiles, so a call site polymorphic in one is polymorphic in both. A + route that differs from `A/A` in text is then not directly comparable with it. +- In Firefox, the handoff's `A/A` runs 6-13% faster than `translated` on main, because + `translated` shares its module with `spawned` and `A/A` does not. + +Give every route the same module layout and run each in its own process or realm, so +neither shares state with another. Show the `A/A` spread before and after on each +engine. + +Public API: none.