Repository navigation
feat(mobile): add typed RPC operations and fence raw requests - #20018
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 4dde824 and 3ff035cc96015bcb414af39472173c0bc80123b3. 📒 Files selected for processing (7)
💤 Files with no reviewable changes (3)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughAdds a typed mobile RPC operation framework. Operation contracts define acceptance policies, readers, and barriers. Result readers decode modern and legacy variants, report salvage data, and bound diagnostics. Operation execution classifies replies, preserves transport errors, applies policy-specific verdicts, and supports after-all-requests barriers. New request-port contracts, parameter types, fixtures, boundary inventories, and compile-time tests enforce the framework. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The typed RPC framework adds contracts and validation fences without migrating production call sites or changing wire behavior. No concrete merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the scope, motivation, implementation details, validation, and lack of UI changes. However, it omits required template sections, including the mandatory Linked Issue entry, Testing checkboxes, Agent skill upstream boundary checkbox, Notes, and Checklist. Resolution Add the missing template sections. Include a required ✨ 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: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 49821ab9-970d-4ba8-a8e6-c757210789c4
📒 Files selected for processing (9)
mobile/src/transport/rpc-incompatible-reply-error.tsmobile/src/transport/rpc-operation-barrier.test.tsmobile/src/transport/rpc-operation-compile-fence.tsmobile/src/transport/rpc-operation-contract.tsmobile/src/transport/rpc-operation-result-reader.test.tsmobile/src/transport/rpc-operation-result-reader.tsmobile/src/transport/rpc-operation-test-families.tsmobile/src/transport/rpc-operation.test.tsmobile/src/transport/rpc-operation.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the full 9-file additive diff introducing the mobile RpcOperation descriptor, send, and barrier interpretation machinery, plus the surrounding contracts it reuses.
defineRpcOperation+runRpcOperation/startRpcOperation+interpretAtRpcBarrier— four frozen-descriptor overloads binding method, acceptance policy, and barrier at definition time; interpretation deferred to the declared barrier in declared order.RpcRequestOutcomeclassification — fulfilled envelopes classify into exactlyouter-refused | decoded | incompatible; transport rejection stays on the promise channel as the original error object.- Reader + salvage machinery —
rpcResultVariant/rpcResultVariantsovercollectSalvageDrops, with bounded issue reporting. RpcIncompatibleReplyError— deliberately neither delivery-unknown nor cutover-shaped, so retry loops never replay on it.- Compile fence + test families — 11
@ts-expect-errordirectives in a non-.test.tsfile sopnpm --dir mobile typecheckactually gates them; pinned by a test.
The descriptor/verdict typing is coherent (contravariance of RpcCompatibleReader, RpcVerdict per-policy mapping, the frozen descriptor preventing runtime policy/barrier swaps), the reuse of rpc-acceptance-policies.ts and the stable logical client's projection is faithful, and the tests are exact rather than loose (identity-preserving transport rejection, byte-level projection assertion). The two deferred design questions (absent-result classification; cutover dropping the delivery-unknown mark) are correctly scoped out of this change.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
The new empty-reader fence leaves the fence-pinning test asserting a stale count — the mobile test suite is red.
Reviewed changes
Reviewed the incremental commit 588e4af, which pins CodeRabbit's "require at least one variant reader" suggestion.
- Restricted
rpcResultVariantsto a non-empty reader tuple — a zero-reader combinator (which could only ever returnincompatiblewith no issues) is now rejected at compile time. - Added the
_fenceEmptyVariantReaderscompile-fence directive — pins the new constraint behind@ts-expect-errorsopnpm --dir mobile typecheckenforces it.
The tuple change itself is correct and type-only (runtime behavior unchanged); the only problem is the stale count pin.
Note: 1 inline comment(s) dropped because they did not anchor to lines inside the PR diff:
mobile/src/transport/rpc-operation.test.ts:1229(RIGHT) — line 1229 (RIGHT) is not inside a diff hunk
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Important
Two count-pinning tests are now out of sync with their targets, leaving the mobile test suite red (rpc-operation.test.ts and unvalidated-rpc-request-port-boundary.test.ts both fail).
Reviewed changes
Reviewed the three new commits since the last review (32f4f99, 8182f43, 6920fcd), which fold a send-side params type and a raw-port boundary into the operation machinery.
- Introduced
UnvalidatedRpcRequestPort+ inventory + boundary ratchet — the rawsendRequestport moved to its own module; every remaining direct caller is inventoried (owners + ~144 pending), and an AST-scanning test fails if the list gains an unlisted file, loses a listed file, or a count drifts. - Added the cast fence — a test that bans
as/any/@ts-escapes inside the computed operation region, so a reply type can't be asserted instead of decoded. - Introduced
RpcSendParams— a send-side params type derived from the catalog (z.input key optionality + z.output value types), swappingRpcParamsforRpcSendParamson the send helpers and adding five new compile-fence assertions. - Moved
SendRequestOptionsinto the port module and madeRpcClientextendUnvalidatedRpcRequestPortstructurally.
The RpcSendInput derivation is sound (typecheck passes, and the send-params-* fences pin optionality/requiredness/tightness catalog-wide), and the two AST-ratchet mechanisms are well-reasoned. The only problems are the two stale count pins below.
One housekeeping note: the PR body still claims "9 new files, zero existing files modified, zero call sites migrated", but this is now 18 files including modifications to rpc-client.ts, rpc-params-contract.ts, the generated catalog, and its generator script. Worth updating the prose so it doesn't mislead the next reviewer.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 489a0786-c67f-43ca-a639-2f45f8ae91a7
⛔ Files ignored due to path filters (1)
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing (13)
config/scripts/generate-rpc-params-catalog.mjsmobile/src/transport/rpc-client.tsmobile/src/transport/rpc-operation-cast-fence.test.tsmobile/src/transport/rpc-operation-compile-fence.tsmobile/src/transport/rpc-operation-contract.tsmobile/src/transport/rpc-operation-result-reader.tsmobile/src/transport/rpc-operation.test.tsmobile/src/transport/rpc-operation.tsmobile/src/transport/rpc-params-contract.tsmobile/src/transport/unvalidated-rpc-request-port-boundary.test.tsmobile/src/transport/unvalidated-rpc-request-port-inventory.tsmobile/src/transport/unvalidated-rpc-request-port.tssrc/shared/rpc-contract/rpc-send-params.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the two commits landed since the prior review (9c14b4f, ae6e2ae), which fix both stale count pins and harden the descriptor's policy/reader correlation.
- Correlated
RpcOperation.readwith the acceptance policy —readis now a mapped type keyed onacceptance: the decoding policies (require-result-or-throw,object-result-or-null) require a reader while the probe and streaming-opener policies pinread: undefined.AnyRpcOperationbecame an erasedPickview scoped to the interpreter, so the correlation no longer has to survive erased passing. - Added three compile-fence directives —
manual-decoding-descriptor-needs-a-reader,broad-policy-still-requires-a-reader, andobject-descriptor-needs-a-readerpin that manual descriptors and widened policies cannot drop the reader; the directive pin and marker list were bumped accordingly (13 → 17). - Send helpers now take
UnvalidatedRpcRequestPort—request,runRpcOperation,captureRpcOperationSettlement, andstartRpcOperationaccept the raw port rather thanRpcClient, which is both a more honest signature and what makes the inventory'srpc-operation.tscount of 2 (import +sendRequest) accurate. - Reconciled the raw-port inventory with main —
mobile-notifications.tsdropped to 1,push-dismissal-reconciliation.ts(2) andpush-registration.ts(3) were added, andruntime-capability-probe.tsrose to 2, reflecting the notification refactors landed on main.
Both prior findings are resolved, and the full mobile suite (4475 tests) plus pnpm --dir mobile typecheck pass.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
9c14b4f to
4dde824
Compare
…rpretation An operation family declares its method, compatible reader, acceptance policy and interpretation barrier once. The send classifies only a fulfilled envelope; transport rejection stays on the promise channel as the original error object, so the cutover and delivery-unknown predicates keep working and a Promise.all group still fails fast. Multi-request families go through a post-barrier combinator that awaits every raw request and then interprets in declared order. No production call site is migrated: this lands as self-contained machinery so runtime behaviour is provably untouched. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…d boundary The raw sender takes an unchecked method string and returns an envelope whose result is `unknown`; 153 non-test files still reach it and each re-decides acceptance and decoding for itself. The type system cannot close that today — `RpcClient` structurally carries `sendRequest` and ~190 files hold a client — so move the port's declaration into its own module, name it unvalidated, and hold the boundary as a ratcheted inventory instead. `SendRequestOptions` is re-exported from rpc-client.ts so the move touches no call site, and rpc-operation.ts now asks for the port rather than the whole client: it is the one module allowed to cross it. Two ratchets, both AST-based: - the port inventory fails on an unlisted file, a stale entry, and a listed file whose reference count went up, so the list only shrinks; - the cast fence bans `as`, `any` and `@ts-` suppressions in the operation region, which is computed from the imports rather than listed, so step 4's operation modules land inside it automatically. Zero runtime change: no wire change, no call site touched. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
3ff035c to
f0965e9
Compare
There was a problem hiding this comment.
Important
Mobile Checks / verify is red on this head: the branch predates main's push refactor (#20068), so the repo-wide raw-request-port inventory no longer matches the merge tree.
Reviewed changes
Reviewed the incremental commit since the prior pullfrog review (3ff035c, "simplify RPC descriptors and fence the contract module").
- Dropped unused
consumes/schedulesdescriptor metadata — removed fromRpcOperation/AnyRpcOperation, the four definition types, the frozen runtime descriptor, the test families, and the compile fence. - Fenced the operation contract module itself —
REGION_SEEDSmembers are now seeded into the cast fence's region directly, andrpc-operation-contract.tsjoined the fenced-module assertion. - Removed the compile-fence marker/count meta-test — the textual test in
rpc-operation.test.tsthat pinned the marker names and@ts-expect-errorcount, along with itsnode:fsimports.
⚠️ Mobile verify is red because the inventory predates main's push refactor
Mobile Checks / verify fails on 3ff035c. That job tests the PR merge ref, and the base has since advanced to 341b13cf67 (#20068, "Restore mobile push and fix cold-start dismissals"), so the merged tree carries main's notification files while this branch's unvalidated-rpc-request-port-inventory.ts still describes the pre-refactor layout — the repo-wide ratchet then fails. Nothing in 3ff035c caused it, but the check stays red until the branch is rebased and the inventory reconciled.
Technical details
# Raw-port inventory is stale against current main
## Affected sites
- `mobile/src/transport/unvalidated-rpc-request-port-inventory.ts:93` — `src/notifications/mobile-notifications.ts` listed `references: 2`, main now reaches the port once
- `mobile/src/transport/unvalidated-rpc-request-port-inventory.ts:218` — `src/transport/runtime-capability-probe.ts` listed `1`, observed `2`
- `mobile/src/transport/unvalidated-rpc-request-port-inventory.ts` — missing `src/notifications/push-dismissal-reconciliation.ts`, `src/notifications/push-registration.ts`, `src/settings/notification-display-test.tsx`
## Required outcome
- `Mobile Checks / verify` passes on the merged tree: rebase (or merge main) onto `341b13cf67` or later and set the inventory entries to the references observed there.
## Evidence
- Check run `103502326470` (`verify`, head `3ff035c`) failed with the three boundary assertions above.
- Reproduced locally: `git merge origin/main` then `pnpm --dir mobile exec vitest run src/transport/unvalidated-rpc-request-port-boundary.test.ts` → 3 failed, 5 passed.ℹ️ Nitpicks
3ff035cremoved therpc-operation.test.tstest that pinned the compile fence's marker names and@ts-expect-errorcount. The cast-fence "no stale exception" test still requiresrpc-operation-compile-fence.tsto contain at least one@ts-suppression, so the fence cannot be fully gutted, but an individual directive plus the code it guards can now be deleted without any test noticing. If that guard was load-bearing, pinning the markers would be better than dropping the test wholesale.
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the new commit since the prior pullfrog review (d2d7995, "baseline landed notification RPC callers"), which reconciles the raw-port inventory with main's push refactor.
- Baseline-landed main's notification RPC callers into the inventory —
mobile-notifications.tsdropped to 1 reference;push-dismissal-reconciliation.ts(2),push-registration.ts(3), andsettings/notification-display-test.tsx(1) were added;runtime-capability-probe.tsrose to 2.
The blocker from the previous review is resolved: the branch is now based on 341b13cf67, and the boundary ratchet passes both on the branch and on a fresh merge with current origin/main (pnpm --dir mobile exec vitest run src/transport/unvalidated-rpc-request-port-boundary.test.ts → 8 passed after git merge origin/main).
ℹ️ Stale backlog size in the inventory header
unvalidated-rpc-request-port-inventory.ts:12 still says the pending list states one reason "instead of 144 times"; with the three new entries it is now 147. Mergeable as-is — just noting the number will keep drifting as the backlog shrinks and there is no test keeping it honest.
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
…nuation
Two ratchets conflicted, both recomputed rather than resolved to either side, as
D-007 prescribes:
- terminal-webview-payload-hash: rebuilt the engine and recomputed. 734707 bytes,
4235 more than upstream's new 730472 — the same minifySyntax-off cost measured
before, so the fix composed with upstream's bundle change. Verified the build
script still carries minifyWhitespace/minifyIdentifiers and that the generated
engine has no `(void 0||(i={}))`, i.e. the DECRQM defect stayed fixed.
- mobile-session-route-parity: re-pinned from actual values; only the
nested-function and runtime-string digests moved.
Upstream stablyai#20018 then fenced raw RPC sends: a new boundary test fails any file
reaching sendRequest that is not in the legacy inventory, and says in as many
words that nothing may be added to that inventory. So the continuation delivery
now goes through typed operations — continuation-rpc-operations.ts declares
terminal.wait and terminal.send with zod readers under `object-result-or-null`,
and the delivery calls runRpcOperation. Outcomes are unchanged: a null verdict is
the old `!response.ok`, and an ambiguous throw still reports `unknown`. This is
the first product consumer of that API; only the compile fence used it before.
The client type comes from rpc-client rather than unvalidated-rpc-request-port,
which the boundary test counts as reaching the raw port.
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ddyy32VYir3LAeFDHv71UT

Summary
Mobile RPC callers repeat response acceptance and decoding rules, and moving calls into concurrent groups can change when errors surface. This adds operation descriptors that bind the method, reader, acceptance policy, and interpretation barrier in one definition.
The combined PR also includes the raw-request boundary from #20026 and send-side parameter types from #20028. No production call sites are migrated and no wire behavior changes.
Contract and boundary
UnvalidatedRpcRequestPort, preserving the stable logical client's existing request projection and transport error identity.RpcSendParamsderives optional keys from the schema's input metadata and values from output types, allowing omission of defaulted keys without accepting arbitrary coercion inputs.Validation
Scope
Transport cutover delivery-unknown marking remains a separate behavior issue. This PR preserves existing rejection identity and does not add retries, change serialization, or perform client-side parameter parsing.
Visual proof: N/A; no rendered UI changes.
Simplification review
Removed unused
consumes/schedulesmetadata and the textual test that counted compiler assertions. The compiler-checked negative assertions remain. The cast-fence region now includes the seed contract module itself. A fresh GPT-6-astra medium review found no actionable issues in this cleanup. Mobile typechecking, 53 focused tests, native code-quality lint and commit hooks passed locally; CI runs against the latest head.