Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions quest/m5/rs2ts-model-subset.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,31 @@ rust2-ts stays general, translating safe dependencies from source and refusing `
and trait objects, so the moq-specific changes are made here. Waits until rust2's epic
reaches the model; none of these changes behavior.

- Safe twins, under `cfg(rust2_ts)`, which rust2-ts's driver passes, for the internal
`unsafe`:
`model/group.rs`'s `MaybeUninit` frame ring, `NonNull` in `track.rs` and
`track/demand/ranges.rs`, `cache.rs`'s pointer identity, `frame.rs`'s `Segment`, and
kio's lock-free `log`. Differential tests cover the twins, and native builds keep the
`unsafe` versions.
- `Track` and `FrameContent` take a unique id at construction, a `u64` from a counter, and
key `cache.rs`'s deadlines and `frame.rs`'s per-group frames by it in place of their
addresses (`Arc::as_ptr(..) as usize`, and `ptr::from_ref(self) as usize` in `Drop`).
rust2-ts refuses every address read, while `ptr::eq` and `Arc::ptr_eq` translate.
Comment on lines +18 to +21

@pullfrog pullfrog Bot Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The parenthetical names Arc::as_ptr and ptr::from_ref, but frame.rs's Drop uses self as *const Self and SharedWeak::address uses as_ptr, so those two frame.rs reads are not explicit. Naming the four reads makes the plan's checklist complete.

Suggested change
- `Track` and `FrameContent` take a unique id at construction, a `u64` from a counter, and
key `cache.rs`'s deadlines and `frame.rs`'s per-group frames by it in place of their
addresses (`Arc::as_ptr(..) as usize`, and `ptr::from_ref(self) as usize` in `Drop`).
rust2-ts refuses every address read, while `ptr::eq` and `Arc::ptr_eq` translate.
- `Track` and `FrameContent` take a unique id at construction, a `u64` from a counter, and
key `cache.rs`'s deadlines (`Arc::as_ptr(..) as usize` and `ptr::from_ref(self) as usize`)
and `frame.rs`'s per-group frames (`self as *const Self` and `SharedWeak::address`) by it
in place of their addresses. rust2-ts refuses every address read, while `ptr::eq` and
`Arc::ptr_eq` translate.
Technical details
# The address-key parenthetical omits two of the four reads

## Affected sites
- `rs/moq-net/src/model/cache.rs:485` — `Arc::as_ptr(track) as usize` in `schedule`.
- `rs/moq-net/src/model/cache.rs:1040` — `std::ptr::from_ref::<Self>(self) as usize` in `Drop`.
- `rs/moq-net/src/model/frame.rs:517` — `self as *const Self as usize` in `Drop`.
- `rs/moq-net/src/model/frame.rs:535` — `self.0.as_ptr() as usize` in `SharedWeak::address`.

## Required outcome
- Name the four sites (or the four forms) so the implementation does not miss the `frame.rs` `Drop` and `SharedWeak::address` reads.

- The internal `unsafe`: `model/group.rs`'s `MaybeUninit` frame ring, `NonNull` in
`track.rs` and `track/demand/ranges.rs`, `frame.rs`'s `Segment`, and kio's lock-free
Comment on lines +22 to +23

@pullfrog pullfrog Bot Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The model's unsafe census is wrong here: track.rs and track/demand/ranges.rs contain no unsafe and no NonNull at this head; the only NonNull in the model's path is kio/src/log.rs, which the same bullet already lists. The model's other unsafe is model/frame.rs's Segment, so this clause should be dropped.

Suggested change
- The internal `unsafe`: `model/group.rs`'s `MaybeUninit` frame ring, `NonNull` in
`track.rs` and `track/demand/ranges.rs`, `frame.rs`'s `Segment`, and kio's lock-free
- The internal `unsafe`: `model/group.rs`'s `MaybeUninit` frame ring, `frame.rs`'s
`Segment`, and kio's lock-free
Technical details
# The `NonNull` census entry points at no code

## Affected sites
- `quest/m5/rs2ts-model-subset.md:22-23` — lists `NonNull` in `track.rs` and `track/demand/ranges.rs`.
- `rs/moq-net/src/model/track.rs` and `rs/moq-net/src/model/track/demand/ranges.rs` — no `unsafe` and no `NonNull` at this head.
- `rs/moq-net/src/model/frame.rs:859` — `Segment` is the only `unsafe` in the model besides `group.rs`'s `MaybeUninit` ring.
- `rs/kio/src/log.rs:27` — the only `NonNull` in the model's path, already covered by the separate kio `log` item.

## Required outcome
- Drop the `NonNull` clause or re-point it at the real `unsafe` sites.

`log`. Each is either rewritten in safe Rust for both builds, at measured native cost, or
left for rust2-ts's [unsafe epic](https://github.com/moq-dev/rust2/blob/main/quest/m3/ts-unsafe/README.md)
Comment on lines +24 to +25

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The plan offers "left for rust2-ts's unsafe epic to translate as is" for every item, but rust2's model epic says kio's log.rs retires through crossbeam-epoch, whose tagged pointers and inline closures translation refuses "for good"; the log must be rewritten or dropped, not deferred. This is the one item the option cannot cover, so it should be called out separately.

Suggested change
`log`. Each is either rewritten in safe Rust for both builds, at measured native cost, or
left for rust2-ts's [unsafe epic](https://github.com/moq-dev/rust2/blob/main/quest/m3/ts-unsafe/README.md)
`log`. Each is either rewritten in safe Rust for both builds, at measured native cost, or
left for rust2-ts's [unsafe epic](https://github.com/moq-dev/rust2/blob/main/quest/m3/ts-unsafe/README.md)
to translate as is, except kio's `log`, which that epic refuses for good.
Technical details
# `kio`'s log cannot be left to the unsafe epic

## Affected sites
- `quest/m5/rs2ts-model-subset.md:24-25` — the plan allows leaving each item to rust2-ts's unsafe epic.
- `rs/kio/src/log.rs:34` — imports `crossbeam_epoch`.
- `rs/kio/Cargo.toml:46` — `crossbeam-epoch = "0.9.21"`.
- rust2's model epic (`quest/m2/ts-model/README.md`) says `kio`'s `log.rs` retires through crossbeam-epoch, whose tagged pointers and inline closures translation refuses "for good".

## Required outcome
- Scope the "left for the unsafe epic" option to the items the epic can model, or state that `kio`'s log must be rewritten or dropped.

to translate as is.
- `group.rs`'s `dyn Expiry` becomes an enum of its two implementations.
- Drop `hashlink`, `slab`, and `smallvec` from the model's path where a std type does the
job at measured cost, or bind them to hand-written TS through rust2-ts's config.

Decided with the rust2 maintainer on 2026-11-07, in
[rust2's model epic](https://github.com/moq-dev/rust2/blob/main/quest/m2/ts-model/README.md),
after rust2-ts's designs for addresses as identity
([moq-dev/rust2#596](https://github.com/moq-dev/rust2/pull/596)) kept leaking:

- ✅ Explicit ids for the two address keys, the same in both builds (rejected: a
`cfg(rust2_ts)` twin; rust2-ts translating `Arc` addresses).
- ✅ No `cfg(rust2_ts)` twins anywhere: every change here is the same in native and
translated builds (rejected: twins until rust2-ts translates the `unsafe`).
- ✅ Whether each `unsafe` item is rewritten or waits on rust2-ts is decided per item when
this quest starts (rejected: deciding now).

Public API: none.

## Required
Expand Down