Skip to content

feat(mobile): retire protocol-2 pairings and fail closed on unverified host compatibility - #19821

Closed
Jinwoo-H wants to merge 10 commits into
mainfrom
rpc-lane-b-gate
Closed

Jinwoo-H wants to merge 10 commits into
mainfrom
rpc-lane-b-gate

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​610 $\color{#cf222e}{\Huge{\mathbf{−}}}$​12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​598
Prod 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​177 $\color{#cf222e}{\Huge{\mathbf{−}}}$​89 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​88

Problem and decision

Mobile treated a failed or refused status.get as compatible, so a host that could not answer read as verified. Jinwoo's 2026-09-09 retirement decision raises all three minimum protocol versions from 2 to 3: runtime client, runtime server, and mobile's desktop minimum. The runtime and mobile protocol versions remain 3.

An earlier revision of this branch also added an RPC-level admission fence that withheld every ordinary request until a status.get verified the host. That has been removed. The protocol 2 to 3 bump was additive: it added browser screencast methods, a browser.screencast.v1 capability, and a binary backpressure return value in the E2EE channel. No existing field changed meaning, units or nullability. A retired desktop asked to do something it does not know about answers method-not-found; it does not misapply the request. The fence was buying a better error message on the three surfaces the block screen does not cover, at the cost of a race class that produced two blocking review findings. Version skew that does need fencing is already handled per feature by capability strings, at a finer granularity than a protocol number can express, because a capability also fences a protocol-3 host that lacks it.

Who is affected

Desktop through v1.4.4 and mobile through mobile-v0.0.7 use protocol 2 and are retired. Desktop v1.4.5 and mobile-v0.0.8 are the first releases at protocol 3. The first platform-specific tags are mobile-ios-v0.0.15 and mobile-android-v0.0.14, both at protocol 3; earlier mobile releases used the common mobile-v* namespace. Already-released protocol-3 hosts and mobile apps remain compatible. Active install counts on the retired releases are unknown.

Verified with git show v1.4.4:src/shared/protocol-version.ts, git show v1.4.5:src/shared/protocol-version.ts, the corresponding mobile protocol files at the four mobile tags, and a version-sorted enumeration of the three mobile tag namespaces. This change requires upgrades for retired pairings; it does not require identical app versions.

What changes

  • The verdict fails closed. A status.get that fails, is refused, or answers with a protocol field that is present but unreadable now produces unknown, never a fabricated version mismatch and never a pass. An unreadable answer joins the same bounded retry schedule as a network failure rather than settling straight to the recovery screen.
  • Absent is not the same as unreadable. A field that is missing or null reads as 0, matching the documented ?? 0 kill-switch semantics in src/shared/protocol-compat.ts, so a desktop old enough to omit the fields gets the actionable "Update Orca on your computer" screen with a Releases link. Only a field that is present and malformed leaves the verdict unknown.
  • The recovery screen is reachable and escapable. An unknown verdict reuses ProtocolBlockScreen with Retry and Back to hosts, without telling users to upgrade on a transient failure.
  • A transient failure does not trap navigation. The first connected route waits for verification, and already-mounted nested navigation stays mounted behind an overlay while compatibility is unknown. A probe that still has retries left counts as pending, so a hiccup shows the spinner rather than a card the user cannot dismiss; the recovery card appears only once all four attempts have failed. main achieved the same effect with a resolved-host latch in the gate, which an earlier revision of this branch replaced with a condition that had no memory. A generation that has already proved its capabilities keeps them through a failed reconnect probe.
  • The 8-second ceiling is real. Each status attempt sets budgetSpansConnect, so the connect wait comes out of the same budget. Without it the wait gets its own full timeoutMs and an attempt can run to roughly 16s. Failures retry after 1, 2 and 4 seconds, then stop until Retry or a connection change. Effect cleanup cancels timers, and host, client and logical-generation provenance prevents a stale completion from approving a replacement session.
  • The CLI consumes the shared runtime server minimum. The headless orcad entry constructs the same OrcaRuntimeService, whose status producer publishes the shared protocol and minimum values and their mobile aliases. There is no separate hardcoded protocol-2 floor in these paths.

No structural change survives from the removed revision. stable-logical-rpc-client.ts and its test are byte-identical to main; the transport is untouched by this PR.

Wire compatibility: four pairings

This changes published minimum values in status.get, not its shape. There are no new fields and no new opcodes, and no change to what either side publishes beyond those values. "Old" below means a build from before this PR, which can have protocol 2 or 3.

Host Mobile Result after this PR ships
Old Old Existing behavior is unchanged because neither binary changed; old protocol-2 pairs can still connect to each other even though support is retired.
Old New An old protocol-2 host is blocked with desktop-too-old, as is a host old enough to omit the protocol fields entirely. An already-released protocol-3 host is allowed, provided its advertised mobile minimum is met.
New Old A protocol-2 mobile app reads the published minimum 3 and shows its existing mobile-too-old update screen. An already-released protocol-3 mobile app remains compatible. The old app's existing fail-open behavior on a failed status probe cannot be changed retroactively.
New New Protocol 3 with minimum 3 is compatible. A failed, refused or unreadable status stays unknown and the retry UI is available.

Both clients evaluate the two bounds, so an advertised minCompatibleMobileVersion: 4 is blocked even when the host's own protocol is 3. This applies equally to local desktop and headless/SSH runtimes; no execution routing, provider-specific behavior, Git command, or workspace-kind assumption changes.

Tests and coverage limits

The mobile component suite exercises the real HostProtocolGate, status hook, evaluator, recovery component and stable logical client against a scripted physical sender. It verifies host protocol 2 and, separately, mobile minimum 4 at the visible gate. It covers first connection, reconnect, same-object logical cutover with the subscription replay riding the cutover, a stale old-generation success, persistent refusal, bounded retries, retry cancellation, Retry recovery, Back-to-hosts routing, host and client switching, a host that stays under the spinner through its post-cutover retries and only then reaches the card, an ok response with unreadable protocol fields rejoining the retry schedule, the status budget spanning connect, and absent versus unreadable protocol fields at both the evaluator and the gate.

Seven targeted source mutations were run against the affected test files and all seven were killed: dropping budgetSpansConnect, settling immediately instead of holding through the retries, never settling at all, treating the existence of an unknown record as proof the host answered, clobbering a proven generation's capabilities on a failed reconnect, reading an absent protocol field as unknown, and letting an unreadable ok response through without a retry. Three of those survived their first run and the tests that kill them were written in response; two of the three were live defects rather than missing coverage.

The real host status producer is covered by runtime-availability.spec.ts through src/main/runtime/orca-runtime.test.ts. Shared compatibility tests cover both directions of the retired floor. Execution-host registry and remote-pairing verification tests derive their below-floor fixtures from the constants, so no edits were needed there.

A true phone/device E2E was not run: this lane has no isolated phone/device harness, and no visible app or emulator was launched. The CI coverage above is component-to-sender integration plus the actual host producer suite, not a claim that direct E2EE framing, relay networking, or a physical phone ran end-to-end.

Gates

All commands ran with ORCA_BACKGROUND_LAUNCH=1 against the committed tree. Each exited 0:

  • pnpm --dir mobile typecheck: exit 0. Actual output: $ tsc --noEmit.
  • pnpm --dir mobile test: exit 0. Actual output: Test Files 518 passed (518); Tests 4268 passed | 3 skipped (4271).
  • pnpm exec oxlint --format github from the repo root: exit 0. Actual output: Found 0 warnings and 0 errors.; Finished in 5.5s on 23771 files using 18 threads.
  • pnpm exec oxfmt --check <changed files> (from mobile/): exit 0. Actual output: All matched files use the correct format.
  • pnpm run check:code-quality:changed: exit 0. Actual output: code quality: 0 new finding(s) across 12 changed file(s).; type-aware code quality: 0 new finding(s) across 12 changed file(s).; React Doctor: 0 new finding(s) across 12 changed file(s).; Changed-code quality gate passed since aac38d698ff7.
  • pnpm run check:react-doctor:changed: exit 0. Actual output: Bugs › 2 warnings.
  • pnpm tc: exit 0.
  • pnpm test src/shared/protocol-compat.test.ts src/shared/execution-host-registry.test.ts src/shared/remote-pairing-verification.test.ts src/main/runtime/rpc/methods/agent-session.test.ts src/main/runtime/orca-runtime.test.ts: exit 0. Actual output: Test Files 5 passed (5); Tests 1320 passed | 1 skipped (1321).

React Doctor's two warnings are one no-set-state-after-await-in-effect finding at host-status-gates.ts:58, reported once from each of the two project scans. It is pre-existing on main, where the same hook already awaits status.get and then sets state, which is why the changed-code gate reports zero new findings. The async paths check cancellation and the captured logical generation before writing state, and the host-switch, cancellation and late old-generation response tests verify that guard. No rule was disabled and no max-lines bump was added.

Lead note

Part of the mobile RPC contract foundation (step 0, lane B). Not merged by the lead; owner merges after review. Physical-phone E2E was not run; see coverage limits above.

Retire protocol 2 hosts and clients, preserve mounted navigation during unknown status, and fence requests and subscription replay by logical generation.

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

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: dd251187-1bc1-4951-b396-e50fce9cb2ef

📥 Commits

Reviewing files that changed from the base of the PR and between 03a2d4c and 62f4b10.

📒 Files selected for processing (3)
  • mobile/src/components/HostProtocolGate.test.ts
  • mobile/src/transport/host-status-gates.test.ts
  • mobile/src/transport/host-status-gates.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • mobile/src/components/HostProtocolGate.test.ts
  • mobile/src/transport/host-status-gates.ts

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


📝 Walkthrough

Walkthrough

The change retires protocol 2 and raises mobile and runtime compatibility minimums to protocol 3. Host status parsing now distinguishes absent fields from unreadable fields. Host status probes use bounded retries, timeout budgets, generation fencing, and conservative fallback gates. HostProtocolGate renders shared recovery states. ProtocolBlockScreen supports unknown verdicts and retry actions. Tests cover retries, reconnects, cutovers, malformed status responses, and stale generations.

Merge Risk: 🔵 Low · up to 62f4b

Protocol verification and recovery behavior are covered, but malformed host status data can still leave one parser case untested and may deliver invalid capabilities to mobile consumers, potentially causing recovery or UI failures for malformed responses.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.42% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 38 functions across 23 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description gives detailed problem, behavior, compatibility, testing, and validation information. However, it omits the required Linked Issue, Visual Proof, checklist, and several template section… Add the required template sections, including a valid Linked Issue, Visual Proof or an explicit N/A with a reason, Testing checklist status, Notes, and Checklist items. Resolve the inconsistency about whether the RPC admission policy remain…
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the main changes: retiring protocol-2 pairings and failing closed when host compatibility cannot be verified.
Full details: Description check

Explanation

The description gives detailed problem, behavior, compatibility, testing, and validation information. However, it omits the required Linked Issue, Visual Proof, checklist, and several template sections. It also conflicts with the PR objectives about the RPC admission policy: the description says the policy was removed, while the objectives say it blocks requests.

Resolution

Add the required template sections, including a valid Linked Issue, Visual Proof or an explicit N/A with a reason, Testing checklist status, Notes, and Checklist items. Resolve the inconsistency about whether the RPC admission policy remains in this PR.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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: cff3cb87-1af2-44df-a45f-d2663a83e467

📥 Commits

Reviewing files that changed from the base of the PR and between aac38d6 and 3995231.

📒 Files selected for processing (16)
  • mobile/src/components/HostProtocolGate.test.ts
  • mobile/src/components/HostProtocolGate.tsx
  • mobile/src/components/ProtocolBlockScreen.tsx
  • mobile/src/transport/host-logical-client.ts
  • mobile/src/transport/host-protocol-admission.test.ts
  • mobile/src/transport/host-protocol-admission.ts
  • mobile/src/transport/host-status-gates.test.ts
  • mobile/src/transport/host-status-gates.ts
  • mobile/src/transport/protocol-compat.test.ts
  • mobile/src/transport/protocol-compat.ts
  • mobile/src/transport/protocol-version.ts
  • mobile/src/transport/stable-logical-rpc-client.ts
  • src/main/runtime/orca-runtime-tests/runtime-availability.spec.ts
  • src/main/runtime/rpc/methods/agent-session.test.ts
  • src/shared/protocol-compat.test.ts
  • src/shared/protocol-version.ts

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

Comment on lines +402 to +409
it.each([
null,
{},
[],
true,
{ protocolVersion: '3', minCompatibleMobileVersion: 3 },
{ protocolVersion: 3, minCompatibleMobileVersion: null }
])('keeps malformed status %j unknown', async (result) => {

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🌐 Web query:

Vitest it.each array table entries spread as multiple arguments

💡 Result:

In Vitest, when you use test.each (or its alias it.each) with an array of arrays, each inner array is automatically spread as individual arguments to your test callback function [1][2]. For example, if you provide a table of data like this: test.each([ [1][3], [1][3][4], [3][1][4], ])('add(%i, %i) -> %i', (a, b, expected) => { expect(a + b).toBe(expected) }) Vitest will execute the test three times, spreading the inner array elements into the parameters a, b, and expected for each run [1][5]. This behavior differs from test.for, which does not automatically spread the inner arrays. If you were to use test.for with the same data, you would receive the entire inner array as a single argument, requiring you to destructure it inside the callback [1][6]: test.for([ [1][3], [1][3][4], [3][1][4], ])('add(%i, %i) -> %i', ([a, b, expected]) => { expect(a + b).toBe(expected) })

Citations:


🤖 get_repo_knowledge executed:

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

Length of output: 42075


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- relevant test file ---'
sed -n '360,430p' mobile/src/components/HostProtocolGate.test.ts
printf '%s\n' '--- bound implementation and nearby tests ---'
rg -n -C 8 'readHostProtocolVerdict|HostProtocolGate' mobile/src
printf '%s\n' '--- Vitest configuration and version ---'
rg -n -C 3 '"vitest"|vitest|test\.each|it\.each' mobile/package.json package.json mobile/vite.config.* mobile/vitest.config.* 2>/dev/null || true

Repository: stablyai/orca

Length of output: 28159


Wrap each malformed-status case in a single-element tuple.

Vitest spreads each inner array in it.each into the test arguments. The bare [] entry therefore passes no argument, so result is undefined instead of an array. This leaves the Array.isArray(status) branch in readHostProtocolVerdict untested.

   it.each([
-    null,
-    {},
-    [],
-    true,
-    { protocolVersion: '3', minCompatibleMobileVersion: 3 },
-    { protocolVersion: 3, minCompatibleMobileVersion: null }
-  ])('keeps malformed status %j unknown', async (result) => {
+    [null],
+    [{}],
+    [[]],
+    [true],
+    [{ protocolVersion: '3', minCompatibleMobileVersion: 3 }],
+    [{ protocolVersion: 3, minCompatibleMobileVersion: null }]
+  ])('keeps malformed status %j unknown', async (result: unknown) => {
📝 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.

Suggested change
it.each([
null,
{},
[],
true,
{ protocolVersion: '3', minCompatibleMobileVersion: 3 },
{ protocolVersion: 3, minCompatibleMobileVersion: null }
])('keeps malformed status %j unknown', async (result) => {
it.each([
[null],
[{}],
[[]],
[true],
[{ protocolVersion: '3', minCompatibleMobileVersion: 3 }],
[{ protocolVersion: 3, minCompatibleMobileVersion: null }]
])('keeps malformed status %j unknown', async (result: unknown) => {

@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 rough edge worth a look, plus two nits.

Reviewed changes

  • Retire protocol 2 — MIN_COMPATIBLE_RUNTIME_CLIENT_VERSION/SERVER_VERSION (shared) and MIN_COMPATIBLE_DESKTOP_VERSION (mobile) move from 2 to 3, retiring desktop ≤ v1.4.4 and mobile ≤ v0.0.7 under a documented four-pairings wire matrix.
  • Fail-closed admission gate — new HostProtocolAdmission allows only four bootstrap methods until status.get verifies protocol 3; the stable logical client rejects other RPCs locally and withholds subscriptions and viewport updates.
  • Verification + retry — useHostStatusGates adds an 8s status.get timeout, 1/2/4s bounded retries, generation fencing via useSyncExternalStore, and a retryStatus escape hatch; refused/malformed status now yields unknown rather than a fabricated mismatch.
  • Recovery UI — ProtocolBlockScreen gains an unknown mode (Retry + Back to hosts, no upgrade prompt); HostProtocolGate overlays already-mounted navigation instead of unmounting it.

ℹ️ Fail-closed admission surfaces transient errors in mounted screens

The "reject locally, don't queue or replay" decision is sound for the worktree catalog, which recovers via its existing 3s poll — but during the unverified window, worktree.ps and the metadata calls reject with a plain Error('Host compatibility has not been verified'), which use-host-worktree-catalog.ts classifies as setCatalogError('network_error') (STA-3123's "a failed request must not look like 0 worktrees"). Every host open/reconnect therefore enters a spurious network-error state until the next poll clears it — brief and largely hidden behind the overlay, but a genuine misclassification. More broadly, any screen whose fetch fires exactly once on the connected transition (no poll or focus retry) stays empty after verification, since nothing re-triggers it.

Technical details
# Fail-closed admission surfaces transient errors in mounted screens

## Affected sites
- mobile/src/transport/stable-logical-rpc-client.ts:96 — rejects unverified methods with a plain Error indistinguishable from a transport failure
- mobile/src/host-screen/use-host-worktree-catalog.ts:121 — maps any thrown rejection to setCatalogError('network_error')

## Required outcome
- mounted-route RPCs withheld during verification are not classified as network failures, and screens that fire once still load after verification completes

## Suggested approach (optional)
- reject with a distinguishable error type (e.g. an admission-pending error) that catalog/error-classification code can recognize and ignore, or publish a verification signal mounted screens can subscribe to for refetch

## Open questions for the human (optional)
- is the deliberate "no replay" stance acceptable given per-screen polling/focus already covers the main screens, or does the lane intend a verification-completion signal later?

ℹ️ Nitpicks

  • settleUnknown sets unverified false while a retry is still scheduled, so the "Unable to verify this host" Retry screen flashes between the automatic 1/2/4s backoff (spinner during each probe, Retry screen during backoff) before settling.
  • Several renderer test fixtures still advertise minCompatibleRuntimeClientVersion: 2 alongside runtimeProtocolVersion: 3 (e.g. web-runtime-session-terminal-legacy-create.test.ts, web-runtime-session-terminal-host-authority.test.ts, components/agent/AgentSettingsDialog.test.tsx). They pass — a protocol-3 client is compatible with a min-2 server — but now misrepresent a real host's floor after the retirement; only agent-session.test.ts was bumped to 3.

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

The admission gate pushed stable-logical-rpc-client.ts past the 300-line
limit. Move the subscription records, their attach/detach lifecycle, the
admission reconcile pass and the terminal viewport update into their own
module; behavior is unchanged.

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

  • Extracted the logical subscription registry — moved the subscription records, their attach/detach lifecycle, the admission reconcile pass, and the terminal viewport update out of stable-logical-rpc-client.ts into a new LogicalSubscriptionRegistry module, bringing the client back under its 300-line limit. The move is behavior-preserving: the per-record admission gate, generation-fenced callbacks, attach-before-dispose replay ordering, and the suspend/close detach-vs-dispose split all carry over unchanged, and createStableLogicalRpcClient now delegates to the registry rather than reimplementing it.

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

Admission gates every RPC the app makes, but the only thing that opened it
was a status.get issued by HostProtocolGate, which mounts under /h/ alone.
The launch screen therefore never verified: its notification and accounts
subscriptions never attached and its six card RPCs all rejected into empty
catch blocks. A relay/direct cutover reset admission and dropped the same
subscriptions for good outside that route.

openHostLogicalClient now starts a verifier that owns the probe, on connect
and on each generation bump, and useHostStatusGates reads its verdict
instead of issuing a second status.get.

A request written in the same state-listener pass that starts the probe
still lost the race by one round trip, so the logical client now holds a
denied request until that probe answers rather than refusing it. Nothing
unverified reaches the host; the refusal is only deferred. The request
dispatch and the cutover error moved into their own modules to make room.

A host that already answered once stays pending through its bounded
retries, so a single post-cutover hiccup no longer buries a live terminal
under a modal error card. The status probe budget now spans connect, so
8s is the real per-attempt ceiling rather than 16s. An absent protocol
field reads as 0 again, matching src/shared/protocol-compat.ts, so a very
old desktop gets the update screen instead of an unactionable Retry.

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

  • Moved verification from the route onto the logical client — new host-protocol-verifier.ts (startHostProtocolVerifier + attachHostProtocolVerification) drives the status.get probe on the client itself, and openHostLogicalClient wraps its client with it. This fixes the launch-screen fencing: useHostStatusGates only mounted under /h/, so a home-screen client was never probed and its admission gate stayed shut forever. useHostStatusGates now reads the client's verification snapshot via useSyncExternalStore and dropped its hostId argument and its duplicate probe.
  • Held unverified requests during the probe window — new LogicalRequestDispatcher (extracted from stable-logical-rpc-client.ts) now holds an unverified request written while a status.get is in flight, re-checking admission when the probe settles, instead of rejecting immediately. This covers the race where a screen's connect effect fires a round trip ahead of the probe; requests with no probe in flight still fail closed. HostProtocolAdmission gained beginProbe/endProbe/whenProbed to expose that distinction.
  • Read absent protocol fields as 0 — readHostProtocolVerdict now treats missing/null fields as protocol 0 (via readProtocolField), matching the shared evaluator, so an old desktop that omits the fields gets the actionable update screen rather than a Retry loop; present-but-unreadable fields stay unknown. LogicalClientCutoverError was also extracted into its own module.

The held-request, cutover, close, and retry paths are all generation-fenced and covered by exact-assertion tests (call sequences, verdict kinds, generation numbers, probe counts). openHostLogicalClient remains the sole production construction site, so every production client verifies itself.

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

The protocol 2 to 3 bump was additive: browser screencast methods, a
capability string, and a binary backpressure return value. No existing
field changed meaning, units or nullability. So a retired desktop asked
to do something it does not know about answers method-not-found rather
than misapplying the request, and the fence was buying a better error
message on three surfaces at the cost of a race class that produced two
blocking review findings.

Removed: HostProtocolAdmission and its bootstrap allow-list and probe
window, the hold path and the request dispatcher it forced, and every
admission check in the stable client and the subscription registry.

The verifier goes with it. It existed because admission was enforced
app-wide while the probe was route-scoped; with no fence, every consumer
of the verdict is a mounted component, so the probe belongs in the hook
again. That also drops the cutover-error module, which only existed to
break an import cycle the dispatcher created.

Kept, because each stands on its own: the three-minimum retirement bump,
the fail-closed verdict so a failed or unreadable status.get no longer
reads as compatible, Retry and Back-to-hosts on the recovery screen, a
host that already answered staying pending through its bounded retries
instead of being buried under a modal card, the status budget spanning
connect so 8s is the real per-attempt ceiling, and absent protocol
fields reading as 0 to match src/shared/protocol-compat.ts.

Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The split was lint collateral, not design. The base client sat at 297
effective lines against a 300 ceiling; the fence's admission calls
pushed it over and it was carved up to fit. With the admission code
gone the subscriptions fit inline again, so the transport returns to
exactly what main ships: stable-logical-rpc-client.ts and its test are
now byte-identical to aac38d6, and 297 effective lines is back under
the ceiling with no per-file bump.

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: 1

🧹 Nitpick comments (1)
mobile/src/components/HostProtocolGate.tsx (1)

77-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Update the stale reference to the admission gate.

The comment states that "the logical client's admission gate fences mounted effects." This PR removes the admission fence from mobile/src/transport/logical-subscription-registry.ts and mobile/src/transport/stable-logical-rpc-client.ts. Mounted children now issue RPCs and subscriptions freely while the verdict is unknown. The overlay blocks touches, but it does not fence effects.

The comment justifies keeping children mounted during the pending window. A reader may assume a transport-level fence that no longer exists.

♻️ Proposed comment update
-          // Preserve nested navigation; the logical client's admission gate fences mounted effects.
+          // Preserve nested navigation. The overlay blocks in-tree touches only —
+          // mounted effects still issue their own RPCs while the verdict is unknown.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 187aaa57-e230-4e98-b6ab-8f77dbcb2ea6

📥 Commits

Reviewing files that changed from the base of the PR and between 1d82f3e and 2268f1d.

📒 Files selected for processing (6)
  • mobile/src/components/HostProtocolGate.test.ts
  • mobile/src/components/HostProtocolGate.tsx
  • mobile/src/transport/host-status-gates.test.ts
  • mobile/src/transport/host-status-gates.ts
  • mobile/src/transport/logical-subscription-registry.ts
  • mobile/src/transport/stable-logical-rpc-client.ts

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

hostId,
client,
generation,
hostCapabilities: status.capabilities ?? EMPTY_HOST_CAPABILITIES,

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Description: Compare capabilities validation between the status probe and the runtime capability probe,
# and find every consumer that calls array methods on hostCapabilities.
set -eu

echo '--- runtime-capability-probe validation ---'
fd -t f 'runtime-capability-probe.ts' mobile/src --exec sed -n '1,60p' {}

echo '--- hostCapabilities consumers ---'
rg -nP --type=ts -C 3 '\bhostCapabilities\b'

echo '--- DesktopStatus definition ---'
fd -t f 'host-worktree-rpc-types.ts' mobile/src --exec sed -n '1,40p' {}

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -eu

echo '--- host-status-gates.ts ---'
sed -n '1,190p' mobile/src/transport/host-status-gates.ts

echo '--- status response/type bindings ---'
rg -n -P -C 4 'status\.capabilities|capabilities\??:|type .*Status|interface .*Status|status\.get' mobile/src mobile -g '*.ts' -g '*.tsx' | head -n 240

echo '--- repository conventions ---'
printf '%s\n' 'No repository-knowledge capability requested; inspect the directly bound source and contracts.'

Repository: stablyai/orca

Length of output: 29342


🤖 get_repo_knowledge executed:

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

Length of output: 28114


🏁 Script executed:

#!/bin/bash
set -eu

echo '--- DesktopStatus definition ---'
fd -t f 'host-worktree-rpc-types.ts' mobile/src --exec rg -n -C 8 'DesktopStatus|capabilities' {}

echo '--- protocol verdict implementation ---'
fd -t f 'protocol-compat.ts' mobile/src --exec sed -n '1,240p' {}

echo '--- direct host capability consumers ---'
sed -n '1,90p' mobile/src/agent-history/worktree-navigation-actions.ts
sed -n '35,55p' mobile/src/components/HostProtocolGate.test.ts

Repository: stablyai/orca

Length of output: 5708


Validate capabilities before storing it as string[].

If status.capabilities is not an array of strings, the type assertion does not validate it. The assignment then violates HostStatusGates.hostCapabilities: string[], and consumers that call .join() or .includes() can throw.

-          hostCapabilities: status.capabilities ?? EMPTY_HOST_CAPABILITIES,
+          hostCapabilities:
+            Array.isArray(status.capabilities) &&
+            status.capabilities.every((value) => typeof value === 'string')
+              ? status.capabilities
+              : EMPTY_HOST_CAPABILITIES,
📝 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.

Suggested change
hostCapabilities: status.capabilities ?? EMPTY_HOST_CAPABILITIES,
hostCapabilities:
Array.isArray(status.capabilities) &&
status.capabilities.every((value) => typeof value === 'string')
? status.capabilities
: EMPTY_HOST_CAPABILITIES,

A cold start whose first status.get failed flashed the full-screen
"Unable to verify this host" card for the whole backoff second, then
recovered. main never did that: its gate latched resolved hosts in
resolvedHostIdRef, so the overlay could not return once a host had
answered, and a failure fell through to a fail-open verdict. This PR
replaced that latch with a condition that has no memory.

A probe with retries left is now pending regardless of whether this
client has answered before, so the spinner covers the backoff window
and only an exhausted ladder settles and offers Retry. That restores
the effect of main's latch without restoring fail-open: four
consecutive failures still reach an actionable card rather than
silently proceeding with capabilities the host never confirmed.

Frames before, one failure then success on the first retry:
  cold start  t=0  no-content|ERROR-CARD
  cutover     t=0  CONTENT|SPINNER|OVERLAY
Both are now the spinner.

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 behavioral rough edge, plus stale references to the removed fence.

Reviewed changes

  • Removed the RPC admission fence — deleted HostProtocolAdmission, LogicalRequestDispatcher, the host-protocol-verifier, and the cutover-error module; the status probe moved back into the mounted route's useHostStatusGates hook, which now takes hostId again.
  • Inlined the generation-fenced sendRequest — createStableLogicalRpcClient fences requests and releases in-flight requests on cutover/close directly, with LogicalClientCutoverError defined in the same file.
  • Stripped admission from the subscription registry — subscriptions replay immediately on cutover with no per-record gate, and terminal viewport updates are no longer withheld.
  • Kept the retirement and fail-closed verdict — the 2→3 minimum bump, absent-fields-as-0 read, 8s budgetSpansConnect timeout, bounded 1/2/4s retries, and the Retry/Back-to-hosts recovery UI all remain.

ℹ️ PR description still describes the removed admission fence

The What changes and Tests and coverage limits sections document the HostProtocolAdmission bootstrap allow-list, the held-request path, openHostLogicalClient supplying an admission policy at its sole construction site, and per-generation admission-latch tests — all removed by this commit. A reviewer or future maintainer reading the body will expect unverified RPCs to be rejected locally, which they no longer are; worth refreshing the prose to match the fail-closed-at-the-UI-gate design.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (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.

Reviewed changes

  • Folded the logical subscription registry back into the stable client — reverted the 5993da0 extraction, so stable-logical-rpc-client.ts and its test are byte-identical to main again and drop out of the PR diff entirely. The registry module and its context type are deleted; subscription attach/detach, replay, viewport update, and generation-fenced callbacks return to inline form with no behavioral change. The commit message confirms the split was only max-lines collateral from the now-removed admission code, and 297 effective lines sits under the 300 ceiling with no per-file bump.

No new issues in this commit. The two open threads from the prior review (host-status-gates.ts retry flash, HostProtocolGate.tsx stale comment) are in files this fold-back does not touch, so they remain outstanding.

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

The previous commit's claim was wrong and mutation testing caught it.
settleUnknown writes its own unknown record, so "a record exists for
this generation" became true after the first failure and was read as
"already answered". The card therefore returned at the second attempt,
about a second in, not after the fourth.

Separate the two questions the record was answering: whether this
generation has any record at all, which decides whether a proven
verdict gets clobbered, and whether the ladder has attempts left, which
decides whether we are still pending. Only the second belongs in the
settle condition.

That left provenThisGeneration with no reader. statusPending has one
consumer, HostProtocolGate, which reads it only inside a branch that
already requires an unknown verdict, and provenThisGeneration is false
by construction there. Removed rather than kept as untestable defence.

Two tests were missing and are added: the card's position in the ladder
is now pinned by call count rather than by presence, and a proven
generation is pinned against having its capabilities wiped by a
transient reconnect failure. Both mutations survived until they existed.

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.

Reviewed changes

  • Folded the logical subscription registry back into the stable client — reverted the 5993da0 extraction, so stable-logical-rpc-client.ts and its test are byte-identical to main again and drop out of the PR diff entirely. The registry module and its context type are deleted; subscription attach/detach, replay, viewport update, and generation-fenced callbacks return to inline form with no behavioral change. The commit message confirms the split was only max-lines collateral from the now-removed admission code, and 297 effective lines sits under the 300 ceiling with no per-file bump.

No new issues in this commit. The two open threads from the prior review (host-status-gates.ts retry flash, HostProtocolGate.tsx stale comment) are in files this fold-back does not touch, so they remain outstanding.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (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.

Reviewed changes

  • Folded the logical subscription registry back into the stable client — reverted the 5993da0 extraction, so stable-logical-rpc-client.ts and its test are byte-identical to main again and drop out of the PR diff entirely. The registry module and its context type are deleted; subscription attach/detach, replay, viewport update, and generation-fenced callbacks return to inline form with no behavioral change. The commit message confirms the split was only max-lines collateral from the now-removed admission code, and 297 effective lines sits under the 300 ceiling with no per-file bump.

No new issues in this commit. The two open threads from the prior review (host-status-gates.ts retry flash, HostProtocolGate.tsx stale comment) are in files this fold-back does not touch, so they remain outstanding.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (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.

Reviewed changes

  • Folded the logical subscription registry back into the stable client — reverted the 5993da0 extraction, so stable-logical-rpc-client.ts and its test are byte-identical to main again and drop out of the PR diff. The registry module and its context type are deleted; subscription attach/detach, replay, viewport update, and generation-fenced callbacks return to inline form with no behavioral change. 297 effective lines sits under the 300 ceiling with no per-file bump.

No new issues in this commit. The two open threads from the prior review remain outstanding in files this fold-back does not touch.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Pro (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.

Reviewed changes

  • Withheld the recovery card until the retry ladder is exhausted — settleUnknown now sets unverified from delay !== undefined, so a failed probe stays under the spinner through all four attempts and only surfaces the recovery card once the 1/2/4s ladder runs out. This resolves the retry-flash regression raised in the prior review; everVerifiedRef was dropped and the provenThisGeneration check renamed to sameGeneration, which now only guards against wiping a generation's proven record.
  • Strengthened the gate tests — added a surfaces the recovery card only once all four attempts have failed assertion pinning the spinner → card progression across attempts, plus cold-start and proven-generation reconnect cases; existing card assertions now run the ladder down first via exhaustStatusRetries.

No new issues in these commits. The stale HostProtocolGate.tsx:77 comment from the prior review remains open and untouched by this change.

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

The render fence required loaded.generation === generation, and migrateTo bumps
the generation on every cutover, so a LAN<->relay switch reset the verdict to
unknown and covered the host with an opaque, touch-blocking overlay for a
status.get round trip — on a host proved compatible seconds earlier. main never
did this; its fence is host + client only. Generation is a write-side concern
and is already enforced three ways, so it comes out of the read side and stays
an effect dep, which keeps the re-probe.

The cutover test asserted the spinner was present, pinning the regression as
intent; it now requires the overlay to be absent. Re-adding the clause fails it.

Also drop three unreachable `generation !== readGeneration()` guards — each was
removed independently with 45/45 still passing, because a plain RpcClient has no
getGeneration and the logical client rejects cross-generation replies first — and
correct a comment claiming an admission gate fences mounted effects. There is no
admission gate; the overlay covers the UI, not the requests.

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

  • Stopped blanking a proven host on transport cutover — useHostStatusGates drops the generation requirement from its proven cache key, so a same-host/same-client cutover keeps the already-proved capabilities and verdict visible while status.get re-verifies in flight, instead of flashing the "Checking host compatibility" overlay on every cutover. The cutover test now asserts no overlay appears while the probe is pending.
  • Relied on effect-cancellation for stale-probe fencing — removed the generation !== readGeneration() guards from probe and settleUnknown; the cancelled cleanup flag (with generation/hostId/client still effect deps) plus the stable client's own generation-fenced sendRequest already cover the same stale-completion window, and a failing cutover probe still converges to the recovery card after the retry ladder.
  • Corrected the stale gate comment — the HostProtocolGate overlay comment now states mounted effects are not fenced by an admission gate, resolving the last open line-level finding.

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

@Jinwoo-H

Copy link
Copy Markdown
Contributor Author

Closing unmerged — superseded by the decision to drop the protocol gate.

The PR's premise was fail-closed RPC admission. The RPC fence was removed during review (an overlay is not a fence — it blocked the user, not the requests), and after that removal compatVerdict is read in exactly two places, both inside HostProtocolGate, purely to choose what to render. Nothing withholds a request, so the title no longer described the change.

What remained did not justify merging:

  • Minimums 2→3 — cleanup only. Protocol 2 shipped 2026-05-15 and was replaced on 2026-05-18 (4b7c9b7213f); last protocol-2 release v1.4.4, first protocol-3 release v1.4.5. A three-day window four months ago.
  • readProtocolField absent→0 — not a fix. main already passes status.protocolVersion into evaluateCompat, which does ?? 0, so an omitting desktop already reads as protocol 0 and already gets desktop-too-old.
  • Malformed→unknown and the non-object status guard — real hardening, but defensive against cases with no known trigger.
  • Retry ladder + recovery card — new surface with a real regression: a healthy, up-to-date host on a flaky network can show "Unable to verify this host" once the 1s/2s/4s ladder exhausts. main latched per host, so a host that resolved once never showed that card again.

Nothing depends on this PR: lane A's --allow-lane-b-deferred / --require-gate-fail-closed flags were removed in the step-0 cut, lane C has no coupling, and the step-2 migration does not need it.

The branch rpc-lane-b-gate is left in place at 5997810317 and should not be deleted. It carries two things worth keeping:

  • A fix for a real regression this PR introduced: adding loaded.generation === generation to the render fence blanked a proven host behind an opaque, touch-blocking overlay on every migrateTo (LAN↔relay switch). main does not have this bug. Anything touching host-status-gates.ts should re-check that fence; the mutation-checked test on the branch is the only record.
  • Evidence that three generation !== readGeneration() guards in that hook are dead — each removed independently with 45/45 passing.

If the malformed/non-object hardening is ever wanted, it is ~12 self-contained lines in mobile/src/transport/protocol-compat.ts and can land alone, with no floor bump and no pending-state rework.

@Jinwoo-H Jinwoo-H closed this Sep 10, 2026
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