Repository navigation
Description
Summary
The TypeScript port of the shell contract checker (pkgs/id/web/src/shell-contract.ts) caps every u64 field at Number.MAX_SAFE_INTEGER (2^53−1), while the Rust original (pkgs/id/src/shell_contract.rs) caps u64 at u64::MAX and the contract document (pkgs/id/contract/shell-contract.v1.json) puts no max on most u64 fields. The TS checker therefore reports false violations for contract-valid frames — e.g. an install_begin whose seed is 2^53 or larger, a value class the system itself produces (rand::rng().random::<u64>(), src/world_session/mod.rs:1162).
Evidence (verified on main 95cd41f0, 2026-10-27)
Verbatim shell-contract.ts (sha256 02baac39…, identical both sides) plus the real shell-contract.v1.json, driven under Bun on the laptop (log: goal hidden_files/probe-2026-10-27-laneB-u64/out.log):
client install_begin seed=42: {"ok":true}
client install_begin seed=9007199254740991 (2^53−1): {"ok":true}
client install_begin seed=9007199254740992 (2^53): {"ok":false,"error":"`install_begin.seed` must be in 0..=9007199254740991, got 9007199254740992"}
client install_begin seed=u64::MAX (from wire JSON): {"ok":false,"error":"`install_begin.seed` must be in 0..=9007199254740991, got 18446744073709552000"}
server view sequence=u64::MAX (from wire JSON): {"ok":false,"error":"`view.sequence` must be in 0..=9007199254740991, got 18446744073709552000"}
server view sequence=7: {"ok":true}
Code facts:
- TS:
INTEGER_MAXinshell-contract.tsmapsu64toNumber.MAX_SAFE_INTEGER, andcheckValueclamps every integer field tomin(field.max ?? typeMax, typeMax). - Rust:
check_valueinshell_contract.rsmapsFieldType::U64tou64::MAX; only an explicit contractmaxnarrows it. - Contract fields with
u64and no explicit max includeinstall_begin.seed(required),install_chunk.offset,view.sequence,program_changed.sequence,records.sequence,module_info.current_sequence,participant_id, and the optionalexpires_at/expires_in_secsfields. - The one
u64field with an explicit max (install_begin.total_bytes, ≤ 16777216) is unaffected — the cap only bites where the contract leaves the range open, which is exactly where the Rust checker allows the full range.
Why it matters
The contract's stated purpose (module docs, both ports) is that "a new shell proves conformance by running a check instead of reading host code." A shell (or a transcript checker — the Rust side ships check_transcript, the TS side Conformance) built on the TS port will fail frames the Rust host accepts, and its error message asserts a range (0..=9007199254740991) that appears nowhere in the contract — a conformance proof that disagrees with the contract is worse than none, because the failure looks like the frame's fault.
Scope honesty: no production web code imports the TS checker today (only world-contract.test.ts); this is a correctness/parity defect in the conformance library before it gains consumers, not a live user-facing outage — hence priority/low.
Note on precision: a JS consumer parsing wire JSON already loses integer precision above 2^53 (the probe shows u64::MAX arriving as 18446744073709552000). The fix is therefore not "validate the exact value" — it is "do not reject values the contract allows": for u64, a non-negative integer number at or above the safe range cannot be proven out of range in JS and must be accepted (explicit field min/max bounds that lie within the safe range can still be enforced exactly).
Acceptance criteria
-
checkClientFrameacceptsinstall_beginwithseed= 2^53 and with the JSON-parsed form ofu64::MAX;checkServerFramelikewise accepts aview/recordsframe whosesequenceis at/above 2^53. (Parity with the Rust checker's verdicts on the same frames.) - Bounds that are exactly enforceable in JS still are: negative and non-integer values are still rejected for all integer kinds;
u16/u32caps unchanged; explicit contractmaxvalues within the safe range (e.g.total_bytes≤ 16777216) still reject above-max values, including foru64fields. - Error messages for
u64fields no longer cite9007199254740991as a contract bound. - Regression tests in
world-contract.test.tspin the parity cases above, and a comment at the cap explains the JS precision constraint (mirroring how the Rust side documents its bound). - Rust checker and the contract JSON are unchanged.
Activity
developing-today commentedon Oct 27, 2026
CODE-524
dezren39 commentedon Oct 27, 2026
🤖 Agent note · state: filed
49 remaining items
id(web): reject u64 values provably above u64::MAX in the TS shell-co…
Merge pull request #2874 from developing-today/queue/1748-1441-u64-pa…
dezren39 commentedon Oct 31, 2026
🤖 Agent note · done
Number.MAX_SAFE_INTEGER; non-negative integers at/above 2^53 accepted (parity with Rustu64::MAX), values provably above range (> 2^64:2**65,1e100) still rejected, exact bounds (total_bytes <= 16777216, negatives, non-integers) still enforced, u64 errors cite the true18446744073709551615bound. Regression tests inworld-contract.test.ts.