Skip to content

quest(m3): delete BinaryHeap from std's MIR - #637

Draft
kixelated wants to merge 3 commits into
mainfrom
quest/m3/ts-unsafe/binary-heap-mir
Draft

kixelated wants to merge 3 commits into
mainfrom
quest/m3/ts-unsafe/binary-heap-mir

Conversation

@kixelated

@kixelated kixelated commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Deletes BinaryHeap from std's MIR and its link in the ts-unsafe epic. The runtime's port (rs.BinaryHeap, rs.PeekMut in ts/runtime/rs/collections.ts) stays.

Why

  • std structs and writing std functions. No std struct translates from MIR: an unmapped std ADT is refused as "unsupported type from another crate" (ts/src/lower/mod.rs). std's heap needs BinaryHeap<T, A>, PeekMut, Hole, RebuildOnDrop, Iter, IntoIter, and Drain to translate as the crate's own structs do. And library::from_mir refuses std functions that are unsafe or take &mut or a raw pointer, which covers nearly every heap method.
  • Elements JS keeps as objects are refused. Hole::move_to is ptr::copy_nonoverlapping(data.as_mut_ptr().add(index), data.as_mut_ptr().add(pos), 1): pointer arithmetic into an array of objects, which the epic's 2026-11-01 decision refuses. Every object heap in the orders case (Item, tuples, [u8; 2], String) would become a refusal.
  • Even for copied elements, MIR is slower. The sibling Vec::drain spike measured std's Drain from MIR at 3 to 12x the port's CPU time for u8/u32 elements (Node 24, CPU time on a loaded host), with most of it in Proxy reads of the Vec's room. No heap translation exists to measure, but Hole reads and writes through the same room.

The port follows std's sifts line for line, and the orders differential case tests it against native on every just ci.

Decisions

  • ✅ Delete this quest and Vec::drain from std's MIR, keeping the runtime's ports (maintainer, 2026-11-07).
  • Rejected: an epic with prerequisites (std structs and writing std functions from MIR; pointers into arrays of objects, which would reopen the 2026-11-01 decision).
  • Rejected: MIR only for elements JS copies, which leaves two implementations behind one type and the port still tracking std by hand.

Impact

None: quest files only. No public API or wire change.

Validation

  • quest check --fix: ok.
  • just check: passed (lint, quest).

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, high effort

Review

Skipped: a quest-only deletion needs no review round.

(Written by Claude Opus 5.5 with high effort)

🤖 Generated with Claude Code

@pullfrog

pullfrog Bot commented Nov 7, 2026

Copy link
Copy Markdown

Pullfrog  | Review this ➔

kixelated and others added 2 commits November 7, 2026 06:39
std's BinaryHeap needs std structs and writing std functions translated
from MIR, which the translator refuses, and Hole's pointer arithmetic
into arrays of objects, which the epic's 2026-11-01 decision refuses.
The port follows std's sifts line for line and is tested against native
on every `just ci`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title BinaryHeap from std's MIR quest(m3): delete BinaryHeap from std's MIR Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant