Skip to content

fix(mobile): the page bridge accepts every reply native accepts and settles what it refuses (OTA phase C, C0.8) - #21511

Merged
Jinwoo-H merged 11 commits into
mainfrom
ota-c0-8-parity
Sep 18, 2026
Merged

Jinwoo-H merged 11 commits into
mainfrom
ota-c0-8-parity

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​500 $\color{#cf222e}{\Huge{\mathbf{−}}}$​67 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​433
Prod 796 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1282 $\color{#cf222e}{\Huge{\mathbf{−}}}$​910 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​372

What this is

OTA phase C, step C0.8: the page bridge carries every golden the native transport carries, minus the classes a named predicate excludes with its reason printed. Bridged replay goes from 763 divergences to 391, all excluded; 396 of 787 goldens now replay byte for byte, up from 24. Released phones unchanged; no RPC operation changes; no golden body moved.

Fixes

  • _meta widening (372 goldens → 0). BridgeReplyPayloadSchema is now z.custom<RpcResponse>(isRpcResponse): the native acceptance predicate imported, not restated, so the bridge is the fourth call site of the one module. Killer test: "agrees with the native predicate on …" (six of eleven payloads red before), "hands a reply with no _meta back verbatim".
  • Refused-frame settlement. A reply the page cannot read now settles the request it was answering on the same turn (hung to a five-second timeout before), and an event it cannot read ends the stream it belonged to. Killer tests: "settles the request a reply it could not read was answering, on the same turn", "ends the stream an event it could not read belonged to". Forced a file split at the 300-line cap, no disable.
  • Exclusions by named predicate, ratcheted. result-absent-settlement and result-absent-observation (recorder-injected {ok:true} without result, refused by the bridge and by isRpcResponse alike), write-ordinal (the recorder stamps the logical send above the wrapper and the subscribe payload below it; wire order is proven preserved on every frame), and params-undefined (below). The pinned baseline moves only down; the excluded count is printed.
class before after
identical 24 396
reply-meta-required 372 0
result-absent-settlement 338 341
result-absent-observation 7 3
result-absent-stream-release – 6
params-undefined 33 33
write-ordinal 13 8
unclassified 0 0

Members moved between excluded classes, never out of the identical set: the refused-reply settlement makes a rejection arrive, and it now differs before the ordinal that also moved does; the refused-event cancel (round 1) makes the shell publish an unsubscribe the native run has no counterpart for, which takes the recorder's next occurrence name for that method, so six recorder-injected goldens throw before there is a recording to compare (result-absent-stream-release, same injected cause). A test holds the baseline to the corpus size on disk, so a shuffle cannot hide a regression, and the comment states which half of each pin moves which way.

params-undefined is a recorder observation, not a wire difference

The brief asked for a page-side projection. Measured: all ten scenarios that send an own property valued undefined record a wire payload with the key already absent (tw-smart-search-all-providers records {"filter":"assigned","limit":50} for linear.listIssues, workspaceId gone), and the native path drops it too. What diverges is the object ScriptedRpcTransport.complete matches a scenario step against, which is the params as the shell's client received them, one level above serialization (Request params mismatch, not a moved byte). projectMobileRpcRequestParams rewrites worktree.ps only and none of the ten call it, and the shell builds its host from the same StableLogicalRpcClient the native screens hold, so there is no separate path to keep. Excluded by predicate with that proof in the classifier and the suite header; a wire encoding for undefined would serve no product consumer.

Repin

C0.5 pinned the corpus to its own branch commit, which the squash made unreachable, so main's RPC recording pin was red at f24f38bd41. The first commit here repins baseline to main's tip and refreshes 787 headers (exactly two distinct changed lines across the corpus, zero non-baseline lines, recorderSha256 unmoved because nothing under the recorder's directory changed); it also ships alone as #21510 so main goes green first.

Review round 1 (SHIP AFTER FIXES)

The params-undefined predicate classified on any throw in the affected scenarios: a seeded wire bug (one extra own key on every request's params) left all 33 excluded while 627 others went unclassified. It now reads the refused step, the paths the scenario values undefined on that step, and every path where the arrived params (read off the request frames the page posted) differ from the scripted ones; the class requires every moved path to be a scripted-undefined one, so a key that arrived unscripted lands in unclassified. A refused event went through failExchange → subscriptions.end, deleting the page record with no cancel, so the shell's stream leaked until the overflow backstop; the reader now abandons it (cancel posted, listener told) and keeps end for error/end frames the shell already retired. The baseline is held to the number of golden files on disk. A test pins that oversized and malformed-json refusals salvage no id and settle only on close, delivery-unknown, and that neither arises from a host that chunks at the frame cap.

Verification

Mobile tsc 0; full mobile suite 666 files / 6805 tests; flagged parity 788 passed (about six minutes now that 396 goldens replay twice; C1.6 shards it when it becomes the default gate); recorder suites unflagged 979 tests; ratchet OK at 126 grandfathered; changed-code quality 0 new findings across 11 files; React Doctor changed-lines clean; oxlint 0 with the client split into bridge-client-inbound-frames.ts and bridge-client-diagnostics.ts at the 300-line cap; anti-slop 0; oxfmt clean; pin guard ancestry and reproduce OK. Two intermediate commits leave divergence-evidence.test.ts red in isolation because it pinned the narrow reader the first fix widens; the fourth commit corrects it and the head is green.

Round 2

Fresh reviewer at b6897e7043: SHIP AS-IS, with one hardening request taken: the three classes of eight or fewer goldens are now pinned by member id (BRIDGED_PARITY_MEMBERS), not only by count, and the flagged parity summary reports membership drift in both directions. A count is blind to a trade; the ids are what notice. Verified on a detached tree at 2f3ccb7648: mobile tsc clean, classifier tests green, flagged parity 788 passed, full mobile suite 6821 passed, goldens byte-identical to main.

… C0.8)

C0.5 pinned `baseline` to its own branch commit, which the squash-merge made
unreachable, so `rpc-recording-pin-guard.mts ancestry` fails on main and
`--record` refuses to run at all. Repin to main's tip and refresh every header
from it.

Header-only, and the corpus proves it: across all 787 goldens exactly two
distinct lines changed, the old `baseline` and the new one. `recorderSha256`
did not move, because nothing under the recorder's own directory did.

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

`BridgeReplyPayloadSchema` required `_meta` on both arms. The predicate the
native client applies to a reply off the wire, `transport/rpc-response-shape.ts`,
requires none, and `src/shared/runtime-rpc-envelope.ts` — the envelope clients
and runtimes share — makes `_meta` optional on a failure with a nullable
`runtimeId`. The page's reader was strictly narrower than the transport it
stands in for, so replies the phone accepts today were refused, dropped with a
diagnostic, and settled nothing.

The reader is now that predicate itself, imported rather than restated: one
module owns the shape, and a widened reader is safe in both directions. `{ ok:
true }` with no `result` key stays refused, because `isRpcResponse` drops it too.

Killer test: `the reply reader is the native acceptance predicate` compares the
page's verdict against `isRpcResponse` over eleven payloads; six of them were
red before this change.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
A host frame the page's reader refuses was reported and dropped, and the
request it answered stayed pending for the life of the document. A screen has
no recovery from that: `sendRequest` never settles, so nothing rerenders and
nothing retries.

The page now salvages the id out of the refused frame, through the same caps
the reader applies, and settles it — but only when it already holds that
exchange, so a salvaged id reaches nothing the page did not open itself. A
request rejects with `BridgeReplyRefusedError`, which carries the refusal and is
now marked delivery-unknown at construction: the shell answered, so the desktop
has already run the request and a caller told this was a definite failure would
offer to retry what already happened. A subscription ends the way a refused
`subscribe` ends today.

`bridge-rpc-client.ts` was at the 300-line ceiling, so the inbound routing moved
to `bridge-client-inbound-frames.ts` and the diagnostic vocabulary, which both
sides raise, to `bridge-client-diagnostics.ts`. No `max-lines` disable.

Killer tests: `settles the request a reply it could not read was answering, on
the same turn` (hung to a 5s timeout before) and `ends the stream an event it
could not read belonged to`.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…t the pin

The class this harness was landed to name is closed, so the pin says so:
`reply-meta-required` is 0 and has no exclusion reason, which is what
`divergence-classes.test.ts` now requires of any class the run is allowed to
count. `BRIDGED_PARITY_EXCLUSIONS` gives each remaining class the reason it is a
bound on the claim rather than a defect, the run prints the excluded total
beside those reasons, and one assertion states the whole claim: nothing diverges
that no predicate has named.

Measured, not argued, for `params-undefined`: all ten scenarios that send an own
property valued `undefined` already record the key as absent from the bytes
their request put on the wire — `tw-smart-search-all-providers` records
`{"filter":"assigned","limit":50}` with `workspaceId` already gone — so the
bridged run sends the identical frame. What differs is the object
`ScriptedRpcTransport.complete` matches a scenario step against, one level above
any serialization. The projection named as the fix is not where it lives:
`projectMobileRpcRequestParams` rewrites `worktree.ps` alone, none of the ten
calls it, and the bridge host forwards into the same `StableLogicalRpcClient`
the native screens hold, so there is no shell-side copy to move.

`divergence-evidence.test.ts` asserted the narrow reader that the `_meta`
widening removed; it now pins that the counterfactual changes no verdict, which
is what makes it a detector for that reader coming back.

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

The `params-undefined` arm named a class from two facts that never met: the run
threw, and the scenario somewhere scripts a param key valued `undefined`. Any
failure inside those ten scenarios was that class, reported by nothing. A seeded
wire bug — one extra own key on every request's params — put 627 goldens in
`unclassified` and still left `params-undefined` at exactly 33, all corrupted;
scoped to `linear.listIssues` alone it stayed green.

The evidence now carries the step the scripted transport refused, the paths the
scenario values `undefined` on it, and every path where the params that arrived
differ from the ones it scripts — read off the frames the page posted, not off
the message. The class needs every path that moved to be one of the scripted
`undefined` ones, and at least one to have moved.

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.

Important

The new refused-frame path ends a page subscription without telling the shell, which leaks the host's subscription slot. One inline comment.

Reviewed changes — full diff (799 files): the 787 golden changes are a baseline-only repin, verified below; the behavioral surface is 11 source files under mobile/src/mobile-web-shell/bridge/ and mobile/src/test-support/.

  • _meta widening. BridgeReplyPayloadSchema is now z.custom<RpcResponse>(isRpcResponse), the native acceptance predicate imported rather than restated. It is strictly wider than the old z.looseObject union on both arms, so no reply the phone accepted before is refused now; the new test pins agreement with isRpcResponse over 11 payloads.
  • Refused-frame settlement. New createBridgeInboundFrameReader reports a refused frame, salvages its id via readRefusedBridgeFrameId, and settles the exchange the frame named: a refused reply rejects the request delivery-unknown, a refused event ends the stream. BridgeReplyRefusedError now carries the delivery-unknown mark.
  • File split. BridgeRpcClientDiagnostic and the inbound reader move into bridge-client-diagnostics.ts / bridge-client-inbound-frames.ts.
  • Parity ratchet. BRIDGED_PARITY_EXCLUSIONS names each remaining class; reply-meta-required closes to 0, identical rises 24→396, and result-absent-settlement 338→341 absorbs a shuffle out of write-ordinal 13→10.

Verified independently: every changed golden line is exactly one of two distinct values (b4dfad0a… → f24f38bd…, 787 each), so no golden body moved; the repin commit touches only mobile/rpc-foundation; and the new pin is an ancestor of origin/main.

ℹ️ Nitpicks

  • divergence-evidence.ts:19-25 — withReplyMeta's doc still calls _meta "the one field the page's reader demands and the wire the page stands in for does not." After this PR the reader demands no _meta on either arm, which the PR's own envelope comment states; the helper's doc is now false.
  • divergence-classes.ts:56-57 — classifyBridgedParity's doc still says "nearly every golden here is refused some reply for the missing field," which the widening removes.
  • divergence-classes.ts:116 — BRIDGED_PARITY_BASELINE's doc says the ratchet "moves down as a class closes and never up," but result-absent-settlement rose 338→341. The inline comment explains the shuffle; the top-level sentence now contradicts the table.

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

…end it

Ending a stream deletes the page's record and posts nothing back. That is right
for `end` and `error`, where the shell has already retired it, and wrong for a
frame this reader refused: the shell is still serving that stream, so later valid
frames on the id were dropped with no diagnostic, no ack went back, and the only
release left was the host's overflow backstop, which counts unacked frames and so
never fires on a stream that has gone quiet. A newer shell adding a member to a
closed list — a new `binary.format`, say — lands exactly there.

`abandon` posts the cancel and tells the listener; `failExchange` picks it over
`end` for the one path where the shell has not let go.

Six goldens move to a new named class for what the cancel changes in the replay.
The unsubscribe it publishes is a physical payload the native run has no
counterpart for, and it takes the recorder's next occurrence name for that
method, so the scenario stops matching before there is a recording. Four came
from `result-absent-observation` and two from `write-ordinal`; the sum over the
corpus is unchanged and nothing stopped replaying byte-identically.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Each class in the pin is an upper bound and `identical` a lower one, so nothing
stopped a single class being loosened on its own: raising `params-undefined` by
one passed every assertion the flagged run makes. The comment already claimed the
total was fixed at the corpus; this counts the goldens on disk and checks it.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`oversized` is decided on the raw string and `malformed-json` on a parse that did
not finish, so neither frame ever yields an id and neither can settle the
exchange it was answering. Nothing on the page settles those: `close` or a shell
replacement releases the slot, and otherwise it is held for the life of the
document. Neither arises from a host that is behaving — it chunks at the frame
cap and answers a body over `BRIDGE_MAX_REPLY_BYTES` with an `error` frame — but
the boundary was unstated and untested, which is how it reads as covered.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The comment said the pin moves down and never up, two lines above a class that
went from 338 to 341 when a fix changed which difference a run meets first. Both
are true of different halves of it, so say which: `identical` only moves up, a
class only moves down, and two excluded classes may trade members in one edit
that leaves the sum alone. The sum is now checked, so that trade cannot hide a
golden that stopped replaying byte-identically.

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

Copy link
Copy Markdown
Contributor Author

Round 1 fixed on b6897e7043: the params-undefined predicate reads the refused step and the moved paths, so a seeded unscripted key lands in unclassified (748821432a); a refused stream frame is abandoned with a cancel posted, end/error frames keep the shell-retired path (9a109aeb10); the baseline is held to the golden files on disk (9c5c65dee5); the two id-less refusals are pinned as settling only on close (6c7c8bcf35); comment (b6897e7043). One new excluded class, result-absent-stream-release 6 (the cancel takes the recorder's next occurrence name; same injected cause; 4 from observation, 2 from write-ordinal), sum 787. Lead reproduced: headers only vs main, tsc 0, full suite 666 files / 6818 tests, flagged parity 396 identical / 391 excluded / 0 unclassified, ratchet, both changed-code gates.

@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 incremental delta since the prior pullfrog review (a1f37c39 → b6897e70, 9 files): the refused-frame path now releases the host subscription it was leaking, and the parity classifier was reworked around the throw it has to name.

  • Refused-frame settlement releases the shell slot. failExchange now distinguishes a stream the shell already retired (an error/end frame, still routed to the silent end) from one it still serves (a frame the reader refused, routed to the new BridgeClientSubscriptions.abandon, which posts the cancel that is the host's only per-stream teardown before notifying the listener). This closes the leak the prior review flagged.
  • params-undefined reads evidence, not the message. The class now requires every param that moved to be one the scenario valued undefined, read from the refused step, the scripted undefined paths, and the params on the request frames the page posted, so a seeded wire bug inside the same scenarios lands in unclassified instead of being excluded by name.
  • New result-absent-stream-release class (6). The absent-result partition delivered on a stream now throws, because the cancel renames the recorder's later occurrences before there is a recording to compare; result-absent-observation 7→3 and write-ordinal 10→8 pay for the six members.
  • Corpus-size pin. A test pins the sum of BRIDGED_PARITY_BASELINE to the golden files on disk, so one class cannot be loosened without another paying, and the unparseable refusals (oversized, malformed-json) are named as the two that can settle nothing.

Verified by running the flagged suite (RPC_FOUNDATION_BRIDGE=1): 788 passed, 787 goldens, unclassified 0, and the counts reproduce the new baseline exactly (identical 396; 341 / 3 / 6 / 33 / 8). The three changed unit suites pass (75 tests).

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

A count is blind to a trade. Every predicate reads the scenario rather
than the frame the page refused, so a golden that started refusing for
real can walk into an excluded class while another walks out, and the
counts, the sum and the `identical` floor all still hold.

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 — the incremental delta since the prior pullfrog review (b6897e70 → 2f3ccb76, 1 commit, 3 files): the three small excluded classes are now pinned golden by golden, not only by count.

  • Membership pin. New BRIDGED_PARITY_MEMBERS names the golden in each class at or below BRIDGED_PARITY_NAMEABLE (8): result-absent-observation (3), result-absent-stream-release (6), write-ordinal (8). bridgedParityMembershipDrift reports both an arrival and a departure, so one golden leaving a class as another arrives no longer moves no number.
  • List tied to the count. A unit test requires every class with a baseline of 8 or fewer to be listed with exactly BRIDGED_PARITY_BASELINE distinct ids, so the membership and the count cannot drift apart; two more tests pin the drift rule on a synthetic trade and confirm a too-large class is not named.
  • Suite consumes it. The flagged replay asserts bridgedParityMembershipDrift(members) is empty against the run's own members, and the summary prints member ids for nameable classes through the shared BRIDGED_PARITY_NAMEABLE constant.

Verified on this head: the classifier unit suite passes (15 tests), and the flagged replay (RPC_FOUNDATION_BRIDGE=1) passes 788 tests over 787 goldens, unclassified 0, with the printed membership matching BRIDGED_PARITY_MEMBERS exactly.

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

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