Skip to content

fix(remote): fit the hosted path inside relay transport limits - #429

Merged
Lokesh7025 merged 1 commit into
RCfrom
remote/transport-limits
Sep 25, 2026
Merged

Lokesh7025 merged 1 commit into
RCfrom
remote/transport-limits

Conversation

@Lokesh7025

Copy link
Copy Markdown
Contributor

Summary

Step 2 of the remote control roadmap. It fixes the transport limits that failed in the real-stack remote scenarios (real OpenMLS endpoints, real Elixir relay, real control plane, real daemon, real SDK). All 9 scenarios now pass.

Scenario Before After
E2E-3: 200 streamed deltas relay closed the daemon with rate_limited 200/200 delivered, no close
E2E-5: request sealed under a superseded grant stayed in the device outbox forever fails with stale_grant_generation, leaves the outbox
E2E-8: idle connection past 60 s force-closed at ticket expiry stays connected
E2E-9: 100 KB assistant reply could not be sealed delivered whole

Changes

  • Connection lease. Consuming a ticket now starts a 30-minute connection lease. The ticket itself stays single-use and valid for 60 seconds. The control plane refuses a lease shorter than the ticket or longer than 24 hours.
  • Frame budget. maxFramesPerWindow and rateWindowMs are now part of the admission limits, validated by the protocol, the control plane, and the relay. Defaults are 100 frames per 10 s for a device and 1,000 for the daemon. RemoteRelayConnection paces its sends to 90% of the budget using a bounded queue.
  • Delivery batching. The bridge coalesces live deliveries into daemon_deliveries. A batch waits up to 50 ms and keeps growing while earlier batches are in flight. A reply flushes pending deliveries first, so results never overtake the events before them.
  • Fragmentation. Messages above 60,000 bytes are split into daemon_fragment messages, each sealed under its own derived operation. The cap is 4 MiB. RemoteDaemonMessageAssembler reassembles them with bounded state: 4 pending sets, a 60 s lifetime, conflict detection, and no nested fragments.
  • Stale grant rejection. An envelope sealed under an older hosted generation is answered once with daemon_rejected and never decrypted. The rejection goes to the frame's source route without moving the reply route. The SDK completes the matching outbox record and publishes a failed state with daemonRejection.
  • Route following. bridge.observeRelayRoutes() follows the relay's route for the paired device, so a reconnected device gets deliveries before it sends anything.
  • Outbox release. Each sent daemon envelope is acknowledged out of the native outbox. The bridge never resends from it, since replies replay from memory and deliveries resume from cursors.

Docs: e2ee-transport-preflight.md gets a new "Connection lease and frame budget" section. remote-hosted-path.md gets a new "Daemon delivery shape" section. decisions.md records the lease and budget decision.

Validation

  • pnpm typecheck, pnpm lint, pnpm format:check, check:boundaries, check:generated: clean.
  • Remote suites: protocol, SDK, control plane, and daemon remote-* tests pass (141/141 run, 1 skipped). The daemon hosted-path integration (AXL_RUN_HOSTED_PATH_INTEGRATION=1) passes.
  • Relay: mix test 17 tests, 0 failures, --warnings-as-errors clean. New test: "enforces the frame budget carried in the admission limits".
  • Real-stack E2E: 9/9 pass. After 5 turns of 200 deltas, the daemon native store stops growing at 2.3 MB and no outbox records are retained.
  • pnpm test: 1025/1026 pass. The failure is packages/tui "pending steering and follow-ups display their actual injection order", which this branch does not touch and which fails about 1 in 3 isolated runs.

Notes for review

  • Releasing the outbox adds one witness barrier per sent envelope. Adaptive batching absorbs this in the streaming scenario, where the relay shows no failures or closes.
  • A paired device can trigger at most one daemon_rejected per distinct stale operation (the last 256 are remembered). Its own relay frame budget still bounds this.

The real-stack remote scenarios hit four transport limits: the relay
closed busy connections with rate_limited, every connection was dropped
at the 60 s ticket expiry, daemon messages above one E2EE frame could not
be sent, and requests sealed under a superseded grant generation sat in
the device outbox forever.

- Separate the connection lease (30 min) from the single-use 60 s ticket.
- Carry the frame budget in the admission limits, sized per role
  (100 frames per 10 s for devices, 1,000 for the daemon), and pace SDK
  sends below it.
- Batch live deliveries into daemon_deliveries envelopes and fragment
  messages above 60,000 bytes, reassembled by the SDK with bounded state.
- Answer stale-generation envelopes once with daemon_rejected so the
  device fails the request instead of retrying it.
- Follow the relay's route view for the paired device, and release each
  sent envelope from the native outbox so daemon state stays bounded.

Signed-off-by: Lokesh <lokeshselvam7025@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 14bd8ea5-1536-4da2-a4fa-d39fbe5c6c78

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@github-actions

Copy link
Copy Markdown

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@Lokesh7025
Lokesh7025 merged commit 6be9476 into RC Sep 25, 2026
34 checks passed
@Lokesh7025
Lokesh7025 deleted the remote/transport-limits branch September 25, 2026 05:50
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