fix(core): state integer proofs in sdk/text.ts range constructors - #394
Open
sapjax wants to merge 1 commit into
Open
fix(core): state integer proofs in sdk/text.ts range constructors#394sapjax wants to merge 1 commit into
sapjax wants to merge 1 commit into
Conversation
sdk/text.ts fails the pinned scriptc 0.0.33 integer-boundary checks (SC4022/SC4023, 19 errors) on every TextRange/TextSelection construction that is not routed through caretSelectionAt — any TS-core app importing @native-sdk/core/text (every app with a text field) cannot build. State each offset whole in place with the module's own established idiom (the range-guard + Math.trunc form caretSelectionAt already documents): an ordered comparison excludes NaN and Math.trunc states wholeness, with out-of-window values clamping to 0, the same floor every snap applies. Semantics-preserving on all reachable values: node --test packages/core/test/text.test.ts passes, and a differential fuzz of applyTextInputEvent/clampedInsertEvent against the unpatched module (4000 rounds, ~23k applied events over UTF-8, CRLF, composition and capacity-refusal paths) produces byte-identical states.
|
@sapjax is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
The shipped
packages/core/sdk/text.ts(v0.9.5, unchanged onmain) fails the pinned scriptc 0.0.33 integer-boundary checks — 19 × SC4022/SC4023 errors on everyTextRange/TextSelectionconstruction that isn't routed throughcaretSelectionAt:Any TS-core app that imports
@native-sdk/core/text— i.e. every app with a text field — failsnative build. Notenative checkstays green: this refusal comes from the external core compiler's integer-boundary proofs, not the NS subset checker, and the repo's external-compiler tests stub scriptc with a fixture, so CI never compiles this module with the real pinned compiler.Fix
State each offset whole in place, using the module's own established idiom —
caretSelectionAtalready documents exactly this pattern:This extends that form to
rangeNormalized,snapTextRange,setTextComposition, and the six delete-* edit paths. No behavior change on reachable values: every internal producer already returns whole, non-negative byte offsets ≤ text length.Verification
@native-sdk/core/textwith the unpatched module; with this patch the same app builds clean (native build, ReleaseFast).node --test packages/core/test/text.test.ts— 6/6 pass.applyTextInputEvent+clampedInsertEventcalls over random UTF-8 text (multibyte, CRLF, selections, compositions, capacity refusals) — byte-identical states.tsc --noEmit --strictclean on the patched module.Possible follow-up (out of scope here): a CI lane that compiles
sdk/text.ts/sdk/events.tswith the real pinned scriptc would catch this class of regression — the current external-compiler tests stub scriptc.