feat(immutable-arraybuffer,pass-style): passable byte arrays (freezable TypedArray emulation + byteArray brand check) - #3311
Open
kriskowal wants to merge 4 commits into
Open
feat(immutable-arraybuffer,pass-style): passable byte arrays (freezable TypedArray emulation + byteArray brand check)#3311kriskowal wants to merge 4 commits into
kriskowal wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: acf062a The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
added 4 commits
June 25, 2026 15:34
Constructing a TypedArray over an emulated immutable ArrayBuffer now yields a freezable wrapper whose mutators throw, whose buffer getter returns the immutable wrapper, and which Object.freeze accepts. The genuine-buffer path is unchanged. The changeset bumps immutable-arraybuffer and pass-style minor and ses patch.
…byteArray A plain frozen Uint8Array backed by an immutable ArrayBuffer is now a passable byteArray, alongside an immutable ArrayBuffer itself. passStyleOf reports a clear "Cannot pass mutable typed arrays" diagnostic for a mutable TypedArray instead of the generic non-remotable error.
bytesToText, bytesEqual, and concatBytes now copy an emulated immutable ArrayBuffer-backed Uint8Array to a genuine Uint8Array before any platform call or indexing. The copy uses the wrapper's native slice memcopy rather than result.set(wrapper), which would read zeros because the wrapper exposes no integer-indexed own properties. Genuine views pass through uncopied.
The permits walk accepts the shim-installed %TypedArrayPrototype% slots without complaint; no new permit rows are required. Adds the regression test covering this.
kriskowal
force-pushed
the
feat/passable-byte-arrays
branch
from
June 25, 2026 22:35
c166199 to
acf062a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces passable byte arrays. Ferried from bot fork endojs/endo-but-for-bots#503, rebased onto current
master.The feature now spans four commits:
1. Freezable TypedArray emulation (
@endo/immutable-arraybuffer)After loading
@endo/immutable-arraybuffer/shim.js, constructing a TypedArray from an emulated immutableArrayBufferyields an emulated freezable wrapper instead of the previous 0-byte fallback:copyWithin,fill,reverse,set,sort) throwTypeError; thebuffergetter returns the immutable wrapper;Object.freezeworks on the view.T.prototypewith no intermediate prototype; emulation covers all eleven concrete TypedArray constructors via a single install on%TypedArrayPrototype%.ArrayBufferis unchanged.Symbol.iteratorinstalled (for...of/spread);subarray()returns a wrapped sub-view;BYTES_PER_ELEMENTforwarded so post-lockdown reads are correct.2.
byteArraybrand check for plain frozenUint8Array(@endo/pass-style)A plain frozen
Uint8Arraybacked by a plain frozen immutableArrayBufferis now recognized as a passablebyteArray, alongside the raw immutableArrayBuffershape. The plain-wrapper definition distinguishes the emulated path (zero own indexed properties) from a future native TC39 integer-indexed-exotic path (exactlylength-many own enumerable data properties each agreeing with the backing byte), rejecting any other shape.passStyleOfalso reports a clearCannot pass mutable typed arraysdiagnostic rather than the generic non-remotable error underLOCKDOWN_HARDEN_TAMING=unsafe.3.
@endo/bytesponyfills tolerate the emulated wrapper (new)A
Uint8Arrayover an emulated immutableArrayBufferis a plain object thatArrayBuffer.isViewrejects — integer indexing readsundefined, andTextDecoder.decode/TypedArray.prototype.setthrow or silently read zeros.bytesToText,bytesEqual, andconcatBytesnow copy such an emulated wrapper to a genuineUint8Array(via the wrapper's nativeslice, which memcopies from the hidden genuine TypedArray it amplifies to) before any platform call or indexing. Genuine views pass through uncopied, so the common path is unaffected.4. ses permits (test)
The
sespermits walk accepts the shim-installed%TypedArrayPrototype%slots with no new permit rows; covered by a regression test.Changesets
@endo/immutable-arraybufferminor,@endo/pass-styleminor,sespatch (infreezable-typedarray-emulation.md);@endo/bytespatch (inbytes-tolerate-emulated-frozen-uint8array.md).Testing
On top of current
master:@endo/immutable-arraybuffer217,@endo/pass-style41,@endo/bytes38,ses513 — all passing; lint clean.