Skip to content

feat(mobile): envelope contract for the web shell bridge (OTA phase C, C0.1) - #21432

Merged
Jinwoo-H merged 20 commits into
mainfrom
ota-c0-design
Sep 18, 2026
Merged

Jinwoo-H merged 20 commits into
mainfrom
ota-c0-design

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1505 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1505
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​891 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​891

What this is

OTA phase C, step C0.1 of 7: the shared envelope contract for the page ↔ shell ↔ desktop bridge, pure TypeScript under mobile/src/mobile-web-shell/bridge/. No React, no native, no transport; nothing on main imports it yet (C0.3 the RN host and C0.4 the page client do). Released phones unchanged; no RPC operation, no recorder file.

Design: /tmp-tracked design note approved 2026-09-18 (RPC pass-through, no shell method table; page-side parsing through the existing descriptors and checked readers; the desktop's mobile-scope allowlist stays the only allowlist).

Surface

  • bridge-envelope.ts: v: 1 on every message; page→shell ready, request, subscribe, cancel, ack, notify (foreground, terminal viewport), close; shell→page init (session, build, connection snapshot, grants with native: []), state, reply (verbatim RpcResponse, optional part), error, event (json or base64 binary), end. readBridgeClientMessage / readBridgeHostMessage. Header rule: v gates incompatible shape; additive fields never bump v; unknown keys are dropped, not refused, because page and shell version independently.
  • bridge-caps.ts: one enforcement point per direction. parseBridgeMessage(raw, direction): UTF-8 byte cap (640 KiB) on the raw string before JSON.parse in both directions; depth 16 and node count 20 000 walked only for page-to-shell (the hostile direction). Shell→page is bounded by the frame cap and the reply ceiling, so a 5 000-row file listing (25 000 nodes) passes where it would have been refused. Also the in-flight (64) and subscription (32) caps the RN host enforces in C0.3, and the 8 MiB reply ceiling / 27-part budget.
  • bridge-error-capture.ts: a rejected sendRequest crosses as exactly the five fields the golden recorder captures (category, message, isRpcDeliveryUnknown, code, cause to depth 4; never a stack); reconstructBridgeError re-applies markRpcDeliveryUnknown, which is a WeakSet on identity and cannot survive serialization. A host RpcFailure is data and rides in reply verbatim, so the two error paths stay distinct.
  • bridge-reply-chunking.ts: a reply over the frame cap is split into part: { i, of } fragments and reassembled against the ceiling, which aborts the request; duplicate, out-of-range, and inconsistent parts refuse.

Review round 1 (SHIP AFTER FIXES)

The binary event could not carry a BrowserScreencastFrame (format, metadata, frame seq had nowhere to ride); it now mirrors the frame field for field with a compile-time pin. The SendRequestOptions pin was one-directional; a key-exhaustive record now fails to compile when an option is added before the schema learns it. code widened to unknown to match the recorder. The parts-ceiling branch was unreachable (worst case 26 of 27, now pinned by an all-backslash 8 MiB test) and is deleted, leaving the schema's .max as the single bound. The reply assembler refuses a new id at 64 pending (too-many-pending) and documents that the page must discard abandoned ids.

Review round 2 (SHIP AFTER FIXES) and bots

Adversarial frames in the hostile direction were all refused with the right names (prototype keys, non-finite numbers, depth 17, 20 001 nodes, oversized fields, top-level arrays, lone surrogates). Fixed: a refused reply id could be restarted and fed 67 MB through the 8 MiB ceiling (refusals are now tombstoned until discard, and the bytes held across all ids have an aggregate ceiling of four replies); no error frame was guaranteed sendable (message truncated at 16 KiB and marked, an unserializable or oversized code dropped, the worst chain measured under the frame cap); a throwing message/code/cause/toString getter escaped the capture (whole capture guarded with a minimal fallback that keeps the delivery-unknown mark); a surrogate pair split across a chunk cut was over-counted by the assembler (the sender never cuts inside a pair and the assembler measures the joined text once); the header rule now says a new enum member is a negotiated change, not an additive field. Flagged for C0.5: a rejection message over 16 KiB now crosses truncated while the recorder records it whole; no golden holds one today.

Tests

158 tests in 4 files: every message shape accept/refuse; each cap at its boundary both sides in both directions; the 25 000-node reply passing shell→page; error capture of a delivery-unknown rejection round-tripping through JSON with the mark re-applied; reassembly incl. missing, duplicate, out-of-order parts and the ceiling abort. Mutation: 36 of 36 killed on the first surface (three cap-value survivors were fixtures derived from the constants; the fifth commit pins literals), then 9 of 9 non-equivalent on the direction split, then 14 of 14 on the round-1 fixes, 6 of 7 (one equivalent) on the bot fixes, 15 of 15 on the round-2 fixes. Gates from mobile/: tsc clean; ratchet OK (126 grandfathered, none added); oxlint 0 incl. the anti-slop config; oxfmt clean; changed-code gate 0 across 8 files; nothing under mobile/rpc-foundation.

The page and the shell exchange frames over a native channel that will happily
carry whatever either side hands it. `parseBridgeMessage` is the only place the
byte, depth and node caps are checked, and the byte cap is checked against the
raw string so it protects `JSON.parse` rather than trusting it.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…known mark

A host `RpcFailure` is data and rides in the reply untouched; a rejection of
`sendRequest` is the other path and needs rebuilding page-side. The mark that
says the request may already have run is a `WeakSet` on object identity, so it
cannot survive serialization and has to be re-applied, and the recorder reads
`error.constructor.name`, so the rebuilt error is named rather than plain.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
One schema per message in both directions, with `v` gating envelope shape and
`init.grants` gating capability. Unknown keys are dropped rather than refused:
the page bundle ships from a desktop that updates independently of the installed
shell. A reply payload is read through loose objects so a field a newer host adds
reaches the page unaltered, which is what the goldens record.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The native screens have no reply byte cap, so refusing one at the frame cap would
invent a failure the phone does not have; source control's diffs would be first
to hit it. Frames are measured after serialization and only then accepted, so an
escaped control character or a surrogate pair cut across the boundary cannot push
one over. The absolute ceiling aborts the request rather than truncating a reply.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
A test that builds its fixture from the constant it is checking moves with that
constant: widening the frame cap, the depth, the node count or the reply ceiling
left every boundary case passing. These numbers are wire between a released shell
and a page served by a desktop, so they are pinned as literals; the in-flight and
subscription caps had nothing holding them at all.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The depth and node caps exist to bound the cost of walking a hostile frame,
and only one direction is hostile. A 5 000-row listing reply carries 25 000
values, so holding the shell's answers to the same 20 000 node cap would
refuse ordinary data. `parseBridgeMessage` now takes the direction and walks
`page-to-shell` only; both directions keep the frame byte cap, and a chunked
reply keeps the 8 MiB ceiling as its single bound.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 37223dab-56e6-4dfd-869a-403945289284

📥 Commits

Reviewing files that changed from the base of the PR and between ec6ee4e and 07ad057.

📒 Files selected for processing (2)
  • mobile/src/mobile-web-shell/bridge/bridge-error-capture.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-error-capture.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • mobile/src/mobile-web-shell/bridge/bridge-error-capture.ts
  • mobile/src/mobile-web-shell/bridge/bridge-error-capture.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The pull request adds bridge byte, depth, node, pending-request, subscription, and reply-size caps. It defines versioned client and host envelope schemas with typed readers. It snapshots error codes during capture and guards delivery-unknown detection. It adds byte-aware reply splitting and assembly with refusal retention and out-of-order support. Tests cover limits, schemas, error handling, chunking, and wire constants.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 07ad0

Multibyte reply chunks can use more assembly memory than the protocol limit intends. The completed reply is rejected, but the in-flight cap should be corrected before broad bridge adoption.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description gives detailed scope, design rationale, implementation areas, testing, and verification results. However, it omits the required Linked Issue, Visual Proof or explicit N/A, AI Disclosur… Add all required template sections. Include a linked issue after “Fixes #”, state “N/A” with a reason for Visual Proof if there is no UI or interaction change, complete or explicitly mark AI Disclosure, Review, Agent skill upstream boundary…
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 36 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: the mobile web shell bridge envelope contract for OTA phase C, step C0.1.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description gives detailed scope, design rationale, implementation areas, testing, and verification results. However, it omits the required Linked Issue, Visual Proof or explicit N/A, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections.

Resolution

Add all required template sections. Include a linked issue after “Fixes #”, state “N/A” with a reason for Visual Proof if there is no UI or interaction change, complete or explicitly mark AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist, and retain the existing testing details under a Testing section.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 26a94835-5bb5-4919-8e4c-8fb5e3f037d9

📥 Commits

Reviewing files that changed from the base of the PR and between ca2ae89 and 2befd94.

📒 Files selected for processing (8)
  • mobile/src/mobile-web-shell/bridge/bridge-caps.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-caps.ts
  • mobile/src/mobile-web-shell/bridge/bridge-envelope.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-envelope.ts
  • mobile/src/mobile-web-shell/bridge/bridge-error-capture.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-error-capture.ts
  • mobile/src/mobile-web-shell/bridge/bridge-reply-chunking.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-reply-chunking.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

The binary `event` carried `b64` alone, but a binary listener is handed an
already-decoded `BrowserScreencastFrame`: format, metadata and the
screencast's own frame counter would all have been lost, and the envelope's
`seq` is the backpressure counter, not that one. The frame's fields now ride
beside the base64, mirrored field for field, with a compile-time pin that
nothing but the image is missing. C6 writes the encoder.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The options pin only proved the schema accepts what the sender declares
today. A `Record<keyof SendRequestOptions, true>` makes the other direction
a compile error, so a new option cannot ship past the bridge unnoticed.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The capture narrowed `code` to a string or a number, but the recorder
records whatever code it finds. A structured code would have crossed the
bridge as an absent field and moved a golden the day C0.5 replays through
it. Absent still means absent.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The splitter's parts-ceiling branch could not fire: the largest reply the
ceiling admits, with every character re-escaping, splits into 26 parts
against a cap of 27. A branch no input reaches is a second statement of a
bound that drifts from the first. The derivation is pinned by a test now,
and `replyPartSchema` is the only place the bound is written.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Nothing expired a half-assembled reply, so a host that sent a first part
and never a last one grew the map for the life of the page. A reply exists
only for a request the page made, so the in-flight cap is the right bound,
and the new id is the one refused. C0.4 owes the assembler a discard for
every request it settles.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Only the compile-time pin stood between a metadata field and `z.unknown()`.
Every one of the nine is now exercised, so widening any of them fails a
test rather than only a typecheck.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one latent sender/receiver edge worth a look.

Reviewed changes

  • bridge-envelope.ts — declares every page↔shell message on a shared v: 1; unknown keys are dropped, additive fields never bump v, and reply.payload stays a loose RpcResponse.
  • bridge-caps.ts — one enforcement point per direction: the 640 KiB raw UTF-8 cap runs before JSON.parse both ways, while depth/node caps apply only to the hostile page-to-shell direction.
  • bridge-error-capture.ts — a rejected sendRequest crosses as the recorder's five fields; reconstructBridgeError re-applies the identity-based delivery-unknown mark and preserves constructor.name.
  • bridge-reply-chunking.ts — replies over the frame cap split into part fragments, reassembled against the reply ceiling, with duplicate/inconsistent/over-ceiling parts refused.
  • Tests — 4 files, 127 tests covering every message shape, each cap at its boundary in both directions, the direction split, error-capture round-trips through JSON, and out-of-order/surrogate-split reassembly.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Follow-up commits look clean — no new issues in the delta.

Reviewed changes (since 2befd94)

  • code widened to unknown — captureBridgeError and BridgeErrorCaptureSchema now carry any present code shape instead of narrowing to string/number, so a rejection keeps the same field the recorder reads.
  • Binary event mirrors a decoded screencast frame — binary now carries format, frameSeq, and loose metadata beside b64, with a compile-time pin against BrowserScreencastFrame; BRIDGE_BINARY_FORMATS and the metadata field set are closed against the screencast protocol.
  • too-many-pending — the assembler refuses a new id once BRIDGE_MAX_PENDING_REQUESTS replies are half-assembled, and documents that C0.4 must discard settled or abandoned ids.
  • Part-count check removed from splitBridgeReply — the schema's .max is now the single bound, pinned by an all-backslash 8 MiB test asserting 26 of 27 parts and that every emitted frame is accepted.
  • SendRequestOptions key-exhaustive pin — a new option now fails to compile until the test literal learns it.

The ceiling-accounting note from the previous review is unchanged by these commits and still open.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Reading `code` and `cause` runs whatever getter defined them, and both were
read in one parse, so a getter that throws took the capture with it: the
rejection path would have thrown where it had to produce an envelope. Each
field is read on its own now, and a throwing getter costs that field only.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
A pair cut in half encodes as two replacements, three bytes each, where the
pair whole is four. The sender cut by code unit and the assembler summed the
parts, so a reply within two bytes per boundary of the ceiling was refused
`reply-too-large` for bytes it never had, and each half-pair frame was not
well-formed UTF-8 for the native bridge to carry. The cut backs up one unit,
and the ceiling is measured once on the joined text. Code units still bound
what is held, since a reply is never fewer bytes than code units.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`message` and `constructor` can be getters, and `String(value)` runs a
`toString` the thrower wrote, so reading an error is running someone else's
code. A throw there left the rejection with no frame at all and a promise
that never settles. The whole capture is guarded now, and the fallback still
carries the delivery-unknown mark, which is a `WeakSet` lookup.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
A megabyte message or code is not a protocol error, it is a big string, and
it produced a frame the receiver refuses as oversized: a rejection the page
never hears. A cyclic code took JSON.stringify down with the whole frame.
Messages are truncated to 16 KiB and marked, a code is dropped when it will
not serialize or is past 4 KiB, and the worst chain the budgets allow now
measures 512 KiB against the 640 KiB frame cap.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Every failure dropped the id, so the next part opened a fresh accumulator:
a duplicate part then a whole set completed, and one id could feed 67 MB
through an 8 MiB ceiling one refusal at a time. A refusal is remembered now
and answers every later part, until the page discards the id. The bytes held
across all ids gain a ceiling of their own, since 64 replies at the per-reply
ceiling is half a gigabyte of parts that never complete.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The version rule read as though anything additive was safe. A value outside
a closed list is refused whole by the older side, so `end.reason`,
`binary.format`, `connection.state` and the foreground reasons are
negotiated, not appended. The byte-cap comment had its inequality the wrong
way round while I was there.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Two mutants lived: clearing the assembler could have kept its tombstones,
and the guard around a cyclic code was hidden by the outer guard added for
a throwing getter. The capture is now asserted whole, so dropping the code
has to leave the message and the cause behind, and teardown has to forget.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 3ec2fbc5-8e99-43ca-b315-faabd256c93e

📥 Commits

Reviewing files that changed from the base of the PR and between 2befd94 and ec6ee4e.

📒 Files selected for processing (7)
  • mobile/src/mobile-web-shell/bridge/bridge-caps.ts
  • mobile/src/mobile-web-shell/bridge/bridge-envelope.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-envelope.ts
  • mobile/src/mobile-web-shell/bridge/bridge-error-capture.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-error-capture.ts
  • mobile/src/mobile-web-shell/bridge/bridge-reply-chunking.test.ts
  • mobile/src/mobile-web-shell/bridge/bridge-reply-chunking.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.

if (entry.chunks.has(part.i)) {
return this.fail(id, 'duplicate-part')
}
if (this.assemblingUnits() + chunk.length > BRIDGE_MAX_ASSEMBLING_BYTES) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '1,270p' mobile/src/mobile-web-shell/bridge/bridge-reply-chunking.ts
sed -n '1,120p' mobile/src/mobile-web-shell/bridge/bridge-caps.ts
sed -n '220,460p' mobile/src/mobile-web-shell/bridge/bridge-reply-chunking.test.ts

Repository: stablyai/orca

Length of output: 23943


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- candidate files ---'
git ls-files 'mobile/src/mobile-web-shell/bridge/*' | sort
printf '%s\n' '--- assembler bindings and exports ---'
rg -n --glob '*.ts' 'BridgeReplyAssembler|splitBridgeReply|parseBridgeMessage|BridgeReplyMessage|reply.*part|part.*chunk' mobile/src/mobile-web-shell mobile/src | head -240
printf '%s\n' '--- envelope and bridge entrypoint excerpts ---'
for f in mobile/src/mobile-web-shell/bridge/bridge-envelope.ts mobile/src/mobile-web-shell/bridge/bridge-reply-chunking.ts; do
  if test -f "$f"; then
    printf '\n### %s\n' "$f"
    sed -n '1,260p' "$f"
  fi
done
printf '%s\n' '--- package/export references ---'
rg -n --glob 'package.json' --glob '*.ts' 'mobile-web-shell/bridge|bridge-reply-chunking|export \*|from .bridge' mobile mobile/src | head -240

Repository: stablyai/orca

Length of output: 48034


🤖 get_repo_knowledge executed:

get_repo_knowledge stablyai/orca /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4/learnings

Length of output: 20757


🏁 Script executed:

#!/bin/bash
set -e
printf '%s\n' '--- bridge-caps parser ---'
sed -n '130,190p' mobile/src/mobile-web-shell/bridge/bridge-caps.ts
printf '%s\n' '--- bridge-envelope host reader ---'
sed -n '250,315p' mobile/src/mobile-web-shell/bridge/bridge-envelope.ts
printf '%s\n' '--- exact production references ---'
rg -n --glob '*.ts' --glob '*.tsx' 'new BridgeReplyAssembler|BridgeReplyAssembler|splitBridgeReply' mobile/src --glob '!**/bridge-reply-chunking.test.ts' || true

Repository: stablyai/orca

Length of output: 2975


Track aggregate UTF-8 bytes before integrating the assembler.

BRIDGE_MAX_ASSEMBLING_BYTES is a byte limit, but assemblingUnits() and chunk.length count UTF-16 code units. The reply-part schema accepts arbitrary strings, so astral characters can make four incomplete replies retain up to about 64 MiB of UTF-8 data while the 32 Mi code-unit check passes.

The standalone-surrogate example overstates the wire-reachable case because JSON escapes lone surrogates and frame and part caps constrain them. This exported assembler has no production caller yet, so the defect is latent rather than a current mobile availability failure.

Track each pending reply’s exact joined UTF-8 length. Preserve the surrogate-boundary correction so a pair split across adjacent chunks counts as four joined bytes, not six bytes measured separately. Add an aggregate test with astral chunks.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

The seven commits since the last pullfrog review close out the prior round's findings. All 158 bridge tests pass and mobile tsc is clean.

  • Error frames made sendable by construction — a message past 16 Ki chars is truncated with a [truncated] mark, a code that cannot be serialized or is over its budget is dropped rather than truncated, and the whole capture is wrapped so a throwing message/code/cause/toString getter still yields a capture that keeps the delivery-unknown mark.
  • Sender and receiver now agree on the reply ceiling — chunkEnd backs a cut up one code unit when it would land inside a surrogate pair, and the assembler measures the joined text once instead of summing per-chunk bytes, so a pair costs four bytes on both sides.
  • A refused reply id stays refused, and in-flight replies are bounded together — fail tombstones the id in a bounded refused map until discard/clear, and an aggregate BRIDGE_MAX_ASSEMBLING_BYTES (four replies) caps every half-assembled reply at once.
  • Header rule clarified — a new member of a closed enum list is a negotiated compatibility change, not an additive field.
  • Tests — added budget/truncation and worst-case error-frame coverage, throwing-getter fallbacks, tombstone and aggregate refusals, and surrogate-pair integrity at every cut parity.

The one prior pullfrog thread (splitter/assembler ceiling disagreement) is addressed and resolved.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

A stateful `toJSON` answers the budget check and the frame serializer
differently, so the snapshot is what crosses.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

One commit since the prior pullfrog review (ec6ee4e), closing the CodeRabbit finding on boundCode and hardening the unreadable-error fallback. All 160 bridge tests pass.

  • Carried code is now the measured snapshot — boundCode returns JSON.parse(serialized) instead of the original value, so a stateful or throwing second toJSON cannot change or break the serialized error envelope.
  • Unreadable-error fallback guarded — the fallback reads the delivery-unknown mark through readDeliveryUnknownMark, so a revoked or throwing Proxy still yields a capture instead of throwing out of captureBridgeError.
  • Regression tests — a stateful/throwing toJSON case pins that the snapshot is read once, and a revoked/trapped-Proxy case pins the guarded fallback.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 8fc8118 into main Sep 18, 2026
23 checks passed
@Jinwoo-H
Jinwoo-H deleted the ota-c0-design branch September 18, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant