Skip to content

fix(mobile): stop unrenewed-grace rotation churn and close gate cadence gaps - #12426

Merged
Jinwoo-H merged 1 commit into
mainfrom
fix/mobile-relay-followups
Aug 4, 2026
Merged

fix(mobile): stop unrenewed-grace rotation churn and close gate cadence gaps#12426
Jinwoo-H merged 1 commit into
mainfrom
fix/mobile-relay-followups

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Follow-ups documented on #12374 (all three were review-round residuals deliberately left out of the incident PR so the phone-verified binary matched the merge commit):

  1. Unrenewed-grace rotation churn. When the cell answers a resume with renewed: false (return-unchanged-grace), the returned deadline never advances, so the phone force-rotated once per clamp floor — ~60 session replacements/hour, each killing any in-flight RPC — until a fresh credential arrived. A re-resume with the same grace credential provably returns the same decision, so rotation is now skipped entirely when confirmation?.renewed === false. Fresh credentials still arrive via direct rotation or durable bundle reads, exactly as before.

  2. Gate cadence doubling under external-signal gates. An E2EE (external-signal) gate never records rejected credential versions, so armCredentialReprobe with no dialable bundle took the plain-cooldown branch and its tick carried no gate pass token — every second wakeup bounced off shouldDefer, settling the effective attempt interval at ~30min instead of the intended 15min ceiling. Under a held gate the reprobe now mints the token.

  3. Gate timers armed against scheduleRetry=false. registerFailure's gate branches armed a reprobe tick even when the supervisor was backgrounded/stopped. Measured-benign but wrong lifecycle; the gate branches now honor scheduleRetry, and a test proves foreground resume restores the cadence (no permanent stall).

Also extracts RelayRetryDelays (all jittered retry delay policy) and the supervisor test fakes into their own modules to satisfy max-lines without weakening the cap.

Tests

Three new red-before/green-after tests (verified failing on pre-fix sources):

  • supervisor: skips forced rotation for a session resumed without renewal (red: 2nd dial at the 60s clamp floor)
  • controller: mints the gate pass when arming a no-bundle reprobe under a held gate (red: shouldDefer true after the 120s tick)
  • controller: does not arm a gate reprobe timer when the supervisor declined retries (red: timer armed after each gated failure)

Full mobile suite: 2969 passed (1 pre-existing unrelated local failure: missing mermaid-webview-engine.generated codegen artifact).

- skip proactive rotation when the resume confirmation reports renewed=false
  (a re-resume provably returns the same unchanged deadline; rotating churned
  one session replacement per clamp floor, ~60/hour, until a fresh credential)
- armCredentialReprobe under a held gate mints the tick's pass token so the
  effective reprobe cadence stays 60s..15min instead of doubling to ~30min
- registerFailure honors scheduleRetry=false in gate branches: no reprobe
  timer is armed while backgrounded/stopped; foreground resume re-arms
- extract RelayRetryDelays and supervisor test fakes into their own modules
  (max-lines)
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 010dea30-ebcb-4a72-ab72-0d6537f499d4

📥 Commits

Reviewing files that changed from the base of the PR and between 5bd2f59 and 889c739.

📒 Files selected for processing (6)
  • mobile/src/transport/mobile-endpoint-supervisor-test-fakes.ts
  • mobile/src/transport/mobile-endpoint-supervisor.test.ts
  • mobile/src/transport/mobile-endpoint-supervisor.ts
  • mobile/src/transport/mobile-relay-reconnect-controller.test.ts
  • mobile/src/transport/mobile-relay-reconnect-controller.ts
  • mobile/src/transport/mobile-relay-retry-delays.ts

📝 Walkthrough

Walkthrough

The change centralizes relay retry-delay calculations in RelayRetryDelays with injected randomness and capped backoff rules. RelayReconnectController uses the shared delays and conditionally schedules credential reprobes. Endpoint supervisor tests now use shared fake sessions, fixtures, dependencies, and credential-rotation helpers. Relay lease rotation is disabled when resume confirmation reports renewed === false. Tests cover reprobe scheduling and resumed relay sessions.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the fixes and tests, but it omits the required Screenshots, AI Review Report, Security Audit, and Notes sections. Add all required template sections, including visual-change status, completed test checklist, AI review findings with cross-platform confirmation, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the three main mobile relay fixes: rotation churn prevention and gate cadence corrections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 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.

@Jinwoo-H

Jinwoo-H commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Merging on green CI + red-before/green-after tests + a line-by-line self-review of the final diff. Note for the record: an external adversarial review pass was spawned but did not return; the three behavior changes here implement remedies that were themselves specified during PR #12374's review rounds (grace-path rotation skip, gate-token minting, scheduleRetry honoring), so the design has had adversarial eyes even though this diff has not.

@Jinwoo-H
Jinwoo-H merged commit e8d3043 into main Aug 4, 2026
44 checks passed
@Jinwoo-H
Jinwoo-H deleted the fix/mobile-relay-followups branch August 4, 2026 06:23
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.

2 participants