Repository navigation
feat(ts): translate the rest of std the model reaches - #168
Conversation
Quest-Claim: 898fdcce9f4d51d9
Vec's insert, remove, truncate, and clear of any element; Box's and FromUtf8Error's Clone; From into an Option; mem::size_of as wasm32 lays the type out; to_le_bytes; TryInto between integers; slice::from_ref; rposition and rfind; and max, min, max_by_key, and min_by_key by any key PartialOrd orders, testing next < best as std's Ord::max and min do. A B-tree's iterators read their ends, as std's own max and min do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e takes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…orrows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-rest # Conflicts: # ts/MIGRATE.md # ts/fixtures/lang/expected/harness.ts # ts/fixtures/lang/src/harness.rs # ts/runtime/rt.ts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-rest Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: d85402f
No actionable bugs found in the changed lowering/runtime paths and relevant surrounding code. The direction is sound: reuse the existing place replacement and comparison machinery, keep unsupported representations explicit, and leave capacity/RandomState semantics to the documented follow-up rather than approximate them here. Reversing the existing byte conversion is a suitably simple implementation.
Inspected the differential fixtures for vector edits/drop ordering, comparator operand order and ties, reverse searches, nested Option replacement, clones, integer conversions and wasm32 sizes. Verification was static GitHub inspection only; I did not run tests or independently verify the reported checks.
…-rest Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: e091c5f
Compared with my review of d85402f, accounting for the main merge.
[P2] Regenerate the fixture snapshots after merging main — ts/fixtures/lang/expected/harness.ts:18. This still imports ranked, but the merge replaced expected/iters.ts with main's version, which no longer exports that function. The Rust iters::ranked implementation and harness case are still present, so the checked-in snapshot now has a missing export and cannot match a fresh translation; just ts test compares these snapshots. Other previously added snapshot sections in expected/refs.ts and task/expected/drops.ts were also removed by the merge. Regenerate the affected fixtures with the merged translator (UPDATE_EXPECT=1 just ts test) and rerun the normal snapshot check rather than retaining main's generated files.
The underlying std-mapping direction remains sound; this is a new merge regression, not an earlier open finding. Verification: static comparison of both heads/base changes, generated imports/exports and the documented test workflow; tests were not run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Re the review of e091c5f1: agreed. The merge commit kept main's (written by Claude Opus 5.5) |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: ad4a722
The snapshot-regression P2 from my previous review is fixed: lang/expected/iters.ts again exports ranked and supplies the comparator arguments, and the generated Option-replacement and task drop scenarios are restored. Compared against e091c5f, separating the intervening main-only merge.
No new actionable bugs found in this update. Regenerating the snapshots is the right, minimal fix; no additional runtime design change is needed. Verification was static GitHub inspection of the snapshot changes and their source/import relationships. I did not run tests or independently verify the reported just ts test/just check results.
|
Landing c63a213.
(written by Claude Opus 5.5) |
Works on quest/m2/ts-model/std-rest.md, which this PR rewrites to what remains:
Vec/VecDequecapacity andRandomState.Problem
The model's census (
ts/moq/model.toml) still refused std calls that no other quest owns. Consumer: moq-net's model, where each shows up at the span below.Approach
Each one maps where std's other mappings do, with std's drops and panics:
Vecof any element (resume.rs,origin.rs,window.rs)insertandremovepanic with std's messages past the end, andinsertdrops the value it was given as it panics.truncateandclearcut first, then drop the rest in order, and keep dropping after one drop panics, asdrop_in_placeof a slice does.CloneBox<T>::cloneclones what it holds (track.rs, and throughOption<Box<_>>'s clone ingroup.rs).FromUtf8Error::clonecopies its bytes (coding/decode.rs).From<T> for Option<T>is the value, sinceSome(x)isx, also whereNoneisrt.None(track.rs'simpl Into<Option<_>>parameters).TryIntobetween integers maps asTryFromdoes (expiry.rs'su128tou64).to_le_bytesis the big-endian bytes reversed (origin.rs).mem::size_ofis the size wasm32 lays the type out in, fromlayout_of. Translation targets wasm32, and the differential tests' native side is wasm32 (datagram.rs,group.rs,object.rs).slice::from_refis an array of the one value, or a byte slice of it (origin.rs, including passed toOption::mapas a function).Option::replaceismem::replace(self, Some(value))on the place it borrows, through the same intercept (expiry.rs,track.rs).max,min,max_by_key, andmin_by_keytake any keyPartialOrdorders: tuples,Reverse,Option, references, and the crate's own types (origin.rs's route ranking,cache.rs,track.rs).max_by_keyismap(KeyAndValue).max(), andmaxisreduce(Ord::max), which testsnext < bestthroughKeyAndValue'slt, the key's. So the runtime takes the key's or item'sPartialOrd::ltas #173 builds it (the crate's own where it has one), testslt(next, best), and reads all but the first item byfold, as #172 does. An item type's ownOrd::maxormin, keys that drop, and items or keys that arert.Places are refused.Iter,Keys,Range, and the rest read their end formaxandmin, as std's own overrides do, comparing nothing.rpositionandrfindread from the back.Proof
lang(differential against wasm32, 50,000 cases plus the wide sweep), new cases:iters::ranked:min_by_key/max_by_keyof ties, by tuples ofReverseandOption, and by keys borrowing from the items.Tilt, an order whosecmpleans on its first operand, so operand order shows.max/minof tuples and ofTilt.rposition/rfindof a partly read iterator.editscase 6:Vecedits of non-Copyelements past the end,BoxandOption<Box>clones,Option::fromandimpl Into<Option<_>>,from_refdirectly and throughOption::map,FromUtf8Error's clone, andsize_ofof structs, tuples,Option<Box<_>>, arrays, andusize.ints:to_le_bytesof every width (also in the wide sweep), andTryIntofromu128andi32.refs:Option::replaceof a local, through a&mutparameter (anrt.Place), and of anOption<Option<u8>>whoseNoneisrt.None.collections: B-treekeys().max(),iter().min(),range(..).max(), andvalues().max().task'sediteddrop scenario, through the differential test and the host unwinding test:insert,remove,truncate, andclearof keys that log their drops.insertpast the end dropping its value.max_by_keyandmindropping each loser.max(the item, the best, then the rest drop).clearwith a drop that panics.bestagainstnext(std's operands swapped) failslangwith 2,191 differences andtaskwith 54, after merging feat(ts): fold std's adaptors as std's drop them #172 and feat(ts): call a crate's own lt, le, gt, and ge where std does #173.vecInsertnot dropping its value fails the unwinding test with 415 differences.Measurements
just ts census, model, at the pinned moq revision: refusals fall from 1,164 on main (95a397c, with #141's dependencies) to 1,106; moq-net from 3,804 to 3,677; kio from 397 to 387. Every std call left in the model belongs to another quest, or to what this quest keeps:Vec/VecDequecapacity,reserve, andshrink_to, andRandomState.Impact
Public API: the translator's output and runtime.
rt.iterMax,iterMin,iterMaxByKey, anditerMinByKeytake aPartialOrd::ltafter the iterator and any key function, which changes the output of everymax/minof integers (rt.iterMax(it, rt.cmpLt(rt.cmp))).MIGRATE.mdnotes it.rt.tsaddsvecInsert,vecRemove,vecTruncate, andfromUtf8ErrorClone.rt/iter.tsaddsiterRpositionanditerRfind.Choices made without asking
split_last, byte-vectorretainandsort,DebugofReverseandBound, and slicing by..=. They have no consumer in moq-net or kio; see follow-ups.Vec<u8>'sinsertandremovestay refused: moq-net calls neither.to_le_bytesistoBeBytes(x).reverse()in the output rather than 12 new runtime exports.size_ofis the wasm32 layout, inlined as a number.Decisions
Maintainer, 2026-10-28, recorded in std-rest for their own PR:
Vec/VecDequecapacity: std's exact growth everywhere, with push cost measured on the TS bench.RandomState: random per state, fromcrypto.getRandomValues.The translator is moving to abort on panic in its own quest, so this PR adds no further unwinding tests; the
editedscenario's panic cases go with the rest of the host unwinding tests there.Suggested follow-ups
split_last, byte-vectorretainandsort,DebugofReverseandBound, slicing by..=,Vec<u8>'sinsertandremove, andfrom_le_bytes.mem::takeof a&mut Veccaptured by a closure (origin.rs:3212) is refused as "replacing the value behind a reference". That is a closure capture of a place, not std.Option::get_or_insert_defaultstays refused 4 times with feat(ts): lend std's &mut to values JS copies as rt.Places #149 landed: three times under its place guard (group.rs:2397,2408,2413,&mut Option<Vec<_>>from a match on&mut self.fields) and once as an unsupported call (origin.rs:4052). No quest owns it now that std-places has landed.Checks on d85402f (main merged after #141):
just check,just ts test, andjust ts censuspass.(Written by Claude Opus 5.5)
🤖 Generated with Claude Code