Repository navigation
feat(mobile-web-bundle): manifest and RPC contract for the desktop-served mobile web bundle (OTA phase A, 1/5) - #21325
Conversation
…sed build id The schema every later Phase A lane parses against: the ceilings that bound host memory (256 assets, 32 MiB total, 10 MiB per asset), and a build id that is a pure function of content so a client can use it as a cache key unconditionally. The serializer sorts its input rather than trusting the caller, so a producer that emits assets in any order still lands on the same id. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Method names, capability name, the 48 KiB chunk size, params/result schemas for both methods, and the six error codes as a closed union pinned by a coverage record. Constants and data only; the host wiring and the capability push land in later lanes. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughAdds a content-addressed mobile web bundle manifest contract. It validates asset paths, hashes, sizes, content types, manifest limits, ordering, totals, entrypoints, and protocol versions. It adds deterministic asset serialization and bundle ID computation. A related RPC contract defines wire constants, error codes, manifest messages, chunk messages, size limits, a negotiated capability, and inferred types. New tests cover the manifest and RPC validation rules. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Chunk responses can pass validation despite malformed Base64 or exceeding the declared chunk size. This is a bounded contract risk before consumers are wired. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the scope, contract, rationale, testing, and reported gates. However, it omits several required template sections, including a linked issue, explicit visual proof or N/A statement, the testing checklist with platforms, AI disclosure, agent boundary, notes, and the final checklist. Resolution Add all missing template sections. Provide a valid issue reference after
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 150f0282-6247-42f9-a3dc-1f64afc3bdc6
📒 Files selected for processing (4)
src/shared/mobile-web-bundle/bundle-rpc-contract.test.tssrc/shared/mobile-web-bundle/bundle-rpc-contract.tssrc/shared/mobile-web-bundle/manifest-contract.test.tssrc/shared/mobile-web-bundle/manifest-contract.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| /** The whole asset's length and hash, not this chunk's, so a reassembler needs no second index. */ | ||
| byteLength: z.number().int().nonnegative().max(MOBILE_WEB_BUNDLE_MAX_ASSET_BYTES), | ||
| sha256: z.string().regex(SHA256_PATTERN), | ||
| dataBase64: z.string().max(MAX_DATA_BASE64_LENGTH), |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,100p' src/shared/mobile-web-bundle/bundle-rpc-contract.ts
sed -n '110,195p' src/shared/mobile-web-bundle/bundle-rpc-contract.test.ts
rg -n '"zod"|from .zod.|\.base64\(|z\.base64' package.json yarn.lock pnpm-lock.yaml package-lock.json src --glob '!**/node_modules/**'Repository: stablyai/orca
Length of output: 25503
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- root metadata ---'
find . -maxdepth 1 -type f -printf '%f\n' | sort
printf '%s\n' '--- package manager declarations ---'
sed -n '175,210p' package.json
for f in pnpm-lock.yaml package-lock.json yarn.lock bun.lockb; do
if [ -f "$f" ]; then
printf '%s\n' "--- $f zod entries ---"
rg -n -A4 -B2 '(^|[ /])zod([@:/]|$)|zod:' "$f" | head -80
fi
done
printf '%s\n' '--- chunk schema references and consumers ---'
rg -n -C3 'MobileWebBundleChunkResultSchema|dataBase64|MOBILE_WEB_BUNDLE_CHUNK_BYTES|MAX_DATA_BASE64_LENGTH' src/shared/mobile-web-bundle src/main src/renderer --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- base64-related repository contracts ---'
rg -n -C3 'Buffer\.from\([^)]*base64|atob|fromBase64|base64.*decode|decode.*base64|byteLength.*dataBase64|dataBase64.*byteLength' src --glob '*.ts' --glob '*.tsx'Repository: stablyai/orca
Length of output: 50370
🤖 get_repo_knowledge executed:
get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/architecture /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings
Length of output: 47550
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- root metadata ---'
find . -maxdepth 1 -type f -printf '%f\n' | sort
printf '%s\n' '--- package manager and zod version ---'
sed -n '175,210p' package.json
if [ -f pnpm-lock.yaml ]; then rg -n -A5 -B2 '(^|[ /])zod([@:/]|$)|zod:' pnpm-lock.yaml | head -100; fi
if [ -f package-lock.json ]; then rg -n -A5 -B2 '"zod"' package-lock.json | head -100; fi
if [ -f yarn.lock ]; then rg -n -A5 -B2 '^zod@' yarn.lock | head -100; fi
printf '%s\n' '--- chunk schema references and consumers ---'
rg -n -C4 'MobileWebBundleChunkResultSchema|dataBase64|MOBILE_WEB_BUNDLE_CHUNK_BYTES|MAX_DATA_BASE64_LENGTH' src --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- Base64 decoding and host-limit references ---'
rg -n -C4 'Buffer\.from|atob|fromBase64|base64.*decode|decode.*base64|read.*chunk|chunkBytes|readLimited|MOBILE_WEB_BUNDLE_CHUNK' src --glob '*.ts' --glob '*.tsx'Repository: stablyai/orca
Length of output: 50370
🏁 Script executed:
set -e
rg -n -C4 'MobileWebBundleChunkResultSchema|dataBase64|MOBILE_WEB_BUNDLE_CHUNK_BYTES|chunkBytes|readLimited|Buffer\.from|atob' src --glob '*.ts' --glob '*.tsx'
printf '%s\n' '--- package metadata ---'
sed -n '190,202p' package.json
find . -maxdepth 1 -type f \( -name '*lock*' -o -name 'pnpm-workspace.yaml' \) -printRepository: stablyai/orca
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- exact mobile-web-bundle files ---'
git ls-files '*mobile-web-bundle*'
printf '%s\n' '--- exact mobile bundle symbols and methods ---'
rg -n -C5 'MobileWebBundle|mobileWeb\.bundle|mobile_web_bundle|MOBILE_WEB_BUNDLE' src --glob '*.ts' --glob '*.tsx' --glob '!**/*.test.ts' --glob '!**/*.spec.ts'
printf '%s\n' '--- focused tests and nearby host-boundary code ---'
sed -n '1,230p' src/shared/mobile-web-bundle/bundle-rpc-contract.test.ts
rg -n -C6 'readFileRange|readFile|Buffer\.from\(.*dataBase64|dataBase64.*Buffer|chunk.*byte|byte.*chunk' src/main/runtime src/main/ipc src/shared/mobile-web-bundle --glob '*.ts' --glob '!**/*.test.ts'Repository: stablyai/orca
Length of output: 50370
🌐 Web query:
Zod 4.5.4 z.base64 API documentation validation padding alphabet
💡 Result:
<search_synthesis>
In Zod (including version 4.5.4), the z.base64() API is used to validate that a string is a valid base64-encoded string [1][2][3]. ### Validation Behavior * Strictness: z.base64() is designed to be strict [4]. Internally, it validates inputs using a combination of checks to ensure the string conforms to canonical base64 specifications [5][4]. * Padding: The validator expects valid base64 padding (the = characters) where required by the base64 encoding rules [6]. * Alphabet: It adheres to the standard base64 alphabet (A-Z, a-z, 0-9, +, /) [6]. * Whitespace: Recent updates have reinforced that z.base64() rejects strings containing whitespace (including spaces, tabs, and newlines), closing previous vulnerabilities where internal parsing mechanisms like atob() would silently strip whitespace and potentially allow invalid inputs [5][4]. * Empty Strings: Consistent with RFC 4648, an empty string is considered valid [7]. ### Comparison with z.base64url() While z.base64() expects standard base64 encoding with padding [3][8], z.base64url() is used for URL-safe base64 encoding, which uses a different alphabet (- and _ instead of + and /) and typically does not include padding [1][3]. ### Implementation Details For performance and reliability, Zod's internal validation for z.base64() has evolved from relying on complex regular expressions (which could cause stack overflow errors on very large strings) to using a more efficient check that includes an explicit whitespace rejection (/\s/.test(data)) followed by a standard atob()-based verification [5][4][6]. For scenarios requiring conversion between base64 strings and Uint8Array byte arrays, Zod provides z.codec utilities like base64ToBytes and base64urlToBytes [9].
</search_synthesis>
<source_evidence>
Citations:
- 1: https://zod.dev/api
- 2: https://zod.dev/api?id=zod-enums
- 3: https://github.com/colinhacks/zod/blob/c7805073/packages/docs/content/api.mdx
- 4: GitHub pull request 5888 in colinhacks/zod (link omitted to avoid creating a cross-reference)
- 5: GitHub issue 5865 in colinhacks/zod (link omitted to avoid creating a cross-reference)
- 6: GitHub issue 4283 in colinhacks/zod (link omitted to avoid creating a cross-reference)
- 7: GitHub issue 3680 in colinhacks/zod (link omitted to avoid creating a cross-reference)
- 8: https://github.com/colinhacks/zod/blob/v4.4.3/packages/docs/content/api.mdx
- 9: https://zod.dev/codecs
🏁 Script executed:
set -e
git ls-files '*mobile-web-bundle*'
rg -n -C5 'MobileWebBundle|mobileWeb\.bundle|mobile_web_bundle|MOBILE_WEB_BUNDLE' src --glob '*.ts' --glob '*.tsx' --glob '!**/*.test.ts' --glob '!**/*.spec.ts'
sed -n '145,180p' src/shared/mobile-web-bundle/bundle-rpc-contract.test.tsRepository: stablyai/orca
Length of output: 19459
Validate dataBase64 as Base64.
The schema accepts any string up to 65,544 characters, including malformed values such as !, A, and AAAA . Zod 4.5.4 provides z.base64() for this contract.
Keep the + 8 allowance. The tests define that slack for the later host boundary to enforce the negotiated chunk size. The current bound admits canonical Base64 payloads up to 49,158 bytes, while the host must enforce the 48 KiB or smaller advertised limit.
Proposed fix
- dataBase64: z.string().max(MAX_DATA_BASE64_LENGTH),
+ dataBase64: z.base64().max(MAX_DATA_BASE64_LENGTH),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| dataBase64: z.string().max(MAX_DATA_BASE64_LENGTH), | |
| dataBase64: z.base64().max(MAX_DATA_BASE64_LENGTH), |
Metro ships no Node core shims, so a value import from these modules would fail to bundle on the phone. The pure-JS sha256 keeps both contract modules runtime-neutral, which also lets a cached manifest be re-verified on device. Verified digest parity against node:crypto across the 55/56/64-byte padding boundaries before the swap. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ntent hash A stale id passed every other check and would then serve the wrong bytes under a cache key the client already trusts. Runs last of the invariants because it is the only one that hashes. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The pattern carried an `i` flag over lowercase character classes, so the same bytes described as `Text/HTML` and `text/html` produced two different build ids. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…odule A4 wires this constant into protocol-version.ts, which the phone reads on the capability path. Leaving it in the schema module would have dragged zod along with it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ength It is the whole asset's length, not the chunk's, and sitting beside dataBase64 under the old name it read as the chunk's. Both are non-negative integers, so a producer that emitted the wrong one would only surface at the final hash check. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
Important
The shared contract imports node:crypto, which the React Native/Hermes mobile bundle cannot resolve, and the repo already ships a pure-JS sha256 for exactly this boundary. One inline comment below, plus a question about buildId verification.
Reviewed changes
- Manifest contract —
manifest-contract.tsdefines the schema, the canonical serializer, the content-addressedbuildId, the permanent ceilings, and the foursuperRefineinvariants. - Bundle RPC contract —
bundle-rpc-contract.tsdefines the 48 KiB chunk size, the two method names, the capability constant, the params/result schemas, and the six closed error codes. - Tests — 32 unit tests across the two files pin the ceilings, the invariants, the asset-path rules, and the base64 bound.
ℹ️ Nitpicks
bundle-rpc-contract.ts:19-20re-declaresSHA256_PATTERNandMAX_DATA_BASE64_LENGTHthatmanifest-contract.tsalready owns; export them from one module so the two bounds cannot drift.bundle-rpc-contract.ts:9-10justifies 48 KiB against a "1 MiB frame ceiling" that no constant in the repo matches —MAX_MESSAGE_SIZEis 16 MiB,REMOTE_RUNTIME_MAX_WEBSOCKET_FRAME_BYTESis 8 MiB + 64, andMAX_E2EE_TEXT_PLAINTEXT_BYTESis 4 MiB. The chosen value is safe either way; the cited ceiling just needs reconciling.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the five commits landed since the prior pullfrog review (dc4b660 → eb4b67d). Both prior findings are fixed and the new changes are clean.
- Pure-JS build id —
computeMobileWebBundleIdnow hashes throughsrc/shared/sha256.tswithTextEncoderplus hex encoding, dropping thenode:cryptoimport so the contract can load in the mobile bundle. buildIdcontent verification —validateManifestInvariantsnow rejects a manifest whosebuildIdis notcomputeMobileWebBundleId(assets), pinned by a stale-id test.- Lowercase content types —
CONTENT_TYPE_PATTERNdrops theiflag, so case variants cannot give the same bytes two ids. - Zod-free capability module —
MOBILE_WEB_BUNDLE_CAPABILITYmoved tomobile-web-bundle-capability.tsso the phone's capability path does not pull a schema library. - Chunk field rename — the chunk reply's whole-asset length is now
assetByteLength, distinct from the chunk body.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…hat fold together Two paths differing only in case are one file on macOS and Windows, so the host would serve the same bytes under two entries and one of the two hashes could never match. Windows-reserved segment names and trailing dots cannot be written to the bundle root at all. Both follow skill-package-manifest's checks, the folded-path Set and the reserved-segment pattern. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…t type The optional space in `; ?charset=` let the same bytes carry two content types and therefore two build ids. Pinned to the single-space form the bundle builder emits. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…already rejected zod runs superRefine even after the asset-array ceiling has failed, so a 257 asset manifest was still sorted and hashed. Each invariant now returns on its own issue and the count is checked first, which is what the comment claimed. The tests read the issue paths: an oversized or otherwise invalid manifest with a deliberately wrong buildId reports no buildId issue, while the same wrong id inside the ceiling does. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`.strict()` plus a literal schemaVersion closes the shape completely, so the version bump is the only way to change it. The phone value-imports this schema, so Phase B must read an unrecognised schemaVersion as a bundle to re-fetch rather than as a parse crash. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the four commits landed since the prior pullfrog review (eb4b67d → 9099126). Both earlier threads are resolved and the new validation is clean.
- Portable asset paths —
MobileWebBundleAssetPathSchemanow rejects Windows-reserved names and trailing-dot segments throughisPortableAssetSegment, reusing the exactWINDOWS_RESERVED_SEGMENTregex fromskill-package-manifest.ts. - Case-fold collision rejection —
validateManifestInvariantsrejects two paths that fold to the same name, since they are one file on macOS and Windows. - One canonical
charsetspelling —CONTENT_TYPE_PATTERNnow requires the single-space; charset=form, so the same bytes cannot hash under two ids. - Hash short-circuit — the refinement returns after the array ceiling,
totalBytes, entrypoint, and protocol-window checks, so the content hash runs only once every cheaper invariant passed; the newrefinement short-circuittests pin each path. - Closed-manifest doc — a JSDoc note that
.strict()plus the literalschemaVersionleave no additive path, so an unknown version must be re-fetched rather than crashed on.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…rved mobile web bundle (OTA phase A, 1/5) (stablyai#21325) * feat(mobile-web-bundle): add the manifest contract and content-addressed build id The schema every later Phase A lane parses against: the ceilings that bound host memory (256 assets, 32 MiB total, 10 MiB per asset), and a build id that is a pure function of content so a client can use it as a cache key unconditionally. The serializer sorts its input rather than trusting the caller, so a producer that emits assets in any order still lands on the same id. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * feat(mobile-web-bundle): add the bundle RPC payload contract Method names, capability name, the 48 KiB chunk size, params/result schemas for both methods, and the six error codes as a closed union pinned by a coverage record. Constants and data only; the host wiring and the capability push land in later lanes. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * fix(mobile-web-bundle): hash the build id without node:crypto Metro ships no Node core shims, so a value import from these modules would fail to bundle on the phone. The pure-JS sha256 keeps both contract modules runtime-neutral, which also lets a cached manifest be re-verified on device. Verified digest parity against node:crypto across the 55/56/64-byte padding boundaries before the swap. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * fix(mobile-web-bundle): reject a manifest whose buildId is not its content hash A stale id passed every other check and would then serve the wrong bytes under a cache key the client already trusts. Runs last of the invariants because it is the only one that hashes. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * fix(mobile-web-bundle): require a lowercase content type The pattern carried an `i` flag over lowercase character classes, so the same bytes described as `Text/HTML` and `text/html` produced two different build ids. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * refactor(mobile-web-bundle): move the capability name to a zod-free module A4 wires this constant into protocol-version.ts, which the phone reads on the capability path. Leaving it in the schema module would have dragged zod along with it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * refactor(mobile-web-bundle): name the chunk reply's length assetByteLength It is the whole asset's length, not the chunk's, and sitting beside dataBase64 under the old name it read as the chunk's. Both are non-negative integers, so a producer that emitted the wrong one would only surface at the final hash check. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * fix(mobile-web-bundle): reject asset paths that are not portable or that fold together Two paths differing only in case are one file on macOS and Windows, so the host would serve the same bytes under two entries and one of the two hashes could never match. Windows-reserved segment names and trailing dots cannot be written to the bundle root at all. Both follow skill-package-manifest's checks, the folded-path Set and the reserved-segment pattern. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * fix(mobile-web-bundle): accept one spelling of a parameterised content type The optional space in `; ?charset=` let the same bytes carry two content types and therefore two build ids. Pinned to the single-space form the bundle builder emits. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * perf(mobile-web-bundle): stop hashing a manifest a cheaper invariant already rejected zod runs superRefine even after the asset-array ceiling has failed, so a 257 asset manifest was still sorted and hashed. Each invariant now returns on its own issue and the count is checked first, which is what the comment claimed. The tests read the issue paths: an oversized or otherwise invalid manifest with a deliberately wrong buildId reports no buildId issue, while the same wrong id inside the ceiling does. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * docs(mobile-web-bundle): say that the manifest has no additive path `.strict()` plus a literal schemaVersion closes the shape completely, so the version bump is the only way to change it. The phone value-imports this schema, so Phase B must read an unrecognised schemaVersion as a bundle to re-fetch rather than as a parse crash. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

What this is
First of five PRs for Phase A of the mobile OTA work: the desktop builds a content-addressed mobile web bundle with each release and serves it to a paired phone behind a new capability, so a future thin native shell can update its UI whenever the desktop does. Phase A changes nothing a released phone calls; old phones keep the native UI over unchanged RPCs.
This PR is pure vocabulary: three modules under
src/shared/mobile-web-bundle/and their tests. No host wiring, no build step, no mobile files, no wire change. Runtime-neutral: nonode:imports, so the phone can value-import the schemas and verify abuildIditself in Phase B.Contract
manifest-contract.ts: the manifest schema (schemaVersion1,buildId,desktopVersion, the protocol windowminCompatibleRuntimeProtocolVersion/runtimeProtocolVersionrecorded now so a future update wall can judge a cached bundle without re-cutting it,entrypoint,totalBytes, sortedassets[{ path, sha256, byteLength, contentType }]), the canonical serializer andcomputeMobileWebBundleId(pure-JS sha256 over the sorted asset list, sobuildIdis a pure function of content), and the permanent ceilings (256 assets, 32 MiB total, 10 MiB per asset). Invariants beyond the field list, each tested:totalBytesequals the sum of asset lengths; paths strictly ascending in code-unit order; no two paths fold to the same name (macOS/Windows collisions); no./../trailing-dot/Windows-reserved segments; the entrypoint is a listed asset; the protocol window is not inverted;buildIdequals the recomputed id (a stale id is a parse failure); the hash only runs once every cheaper invariant passed.contentTypeis lowercase with one canonical; charset=spelling so identical bytes cannot get two ids. The manifest is closed (.strict()+ literalschemaVersion): any change is a version bump, and Phase B must read an unknown version as a bundle to re-fetch, never a crash.bundle-rpc-contract.ts:MOBILE_WEB_BUNDLE_CHUNK_BYTES(48 KiB: fits the 1 MiB frame ceiling after base64 and E2EE base64 expansion with an order of magnitude of headroom), the method namesmobileWeb.bundle.manifestandmobileWeb.bundle.chunk, params and result schemas (the chunk reply echoesbuildId/path/offsetso out-of-order reassembly cannot misplace a chunk;assetByteLengthandsha256describe the whole asset so any single chunk is self-describing;dataBase64is length-bounded with the skill-upload arithmetic;chunkBytesin the manifest reply is capped at the constant, shrink-only;offsetalignment is deliberately a host-side check against the advertised chunk size), and the six stable error codes as a closed union pinned withhostUnionArms.mobile-web-bundle-capability.ts: themobileWeb.bundle.v1constant alone, import-free, soprotocol-version.tscan name it in a later PR without pulling zod onto the phone's capability path.Reuse: the serializer follows
computeSkillPackageDigest's idiom; the path rules followskill-package-manifest.ts.Review
Round 1: ship after fixes, applied:
node:cryptoreplaced by the repo's pure-JS sha256 (digest parity checked at the padding boundaries and at 18 sizes againstnode:crypto), thebuildIdrecompute refinement, lowercase content types, the capability constant split out, and theassetByteLengthrename. Round 2 (fresh): ship after fixes, applied: case-fold collisions and Windows-reserved segments rejected, one canonical charset spelling, early return before the hash (mutation-checked), the closed-manifest doc. Round 2 also confirmedTextEncoderis available on Hermes empirically (mobile-e2ee-v2-client-session.ts:98) and that a 256-asset manifest at the ceilings parses in about 1 ms.Gates
Root
tsc(config/tsconfig.node.json) 0 · vitest 2 files, 44 passed · oxfmt and oxlint clean · changed-code quality 0 findings across 5 files ·git diff -- mobileempty.Design:
/tmp/step2-parallel/phase-a-design.md; trackingdocs/reference/plans/mobile-ota-phase-a.local.md(untracked).