Skip to content

feat(rivetkit): support gateway bypass client requests#4917

Closed
NathanFlurry wants to merge 1 commit into05-02-fix_pegboard_restore_hibernating_request_idsfrom
mock-agentic-loop/rivetkit-gateway-bypass-client
Closed

feat(rivetkit): support gateway bypass client requests#4917
NathanFlurry wants to merge 1 commit into05-02-fix_pegboard_restore_hibernating_request_idsfrom
mock-agentic-loop/rivetkit-gateway-bypass-client

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented May 4, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 4, 2026

Review: feat(rivetkit): support gateway bypass client requests

Status: Draft — feedback below before marking ready for review.

Overview

This PR adds a bypassConnectable option that lets client code route requests directly to an actor instance, bypassing the normal "connectable" routing layer. The flag propagates through three channels depending on transport:

  • HTTP: x-rivet-bypass-connectable: 1 header
  • WebSocket (subprotocol): rivet_bypass_connectable WS protocol token
  • Query-based routing: rvt-bypass_connectable=true query param

Issues

Naming inconsistency in query parameter

actor-websocket-client.ts:273

params.append("rvt-bypass_connectable", "true");

All other rvt- params use kebab-case (rvt-token, rvt-crash-policy, rvt-namespace). This one mixes a hyphen and underscore. Should be rvt-bypass-connectable.

Duplicate directActorId type definition

actor-http-client.ts exports HttpGatewayRequestOptions extends GatewayRequestOptions { directActorId?: string }, while actor-websocket-client.ts uses the inline intersection GatewayRequestOptions & { directActorId?: string }. These should share a single named interface (from driver.ts or actor-http-client.ts) to prevent silent drift.

Structural duplication between ActorGatewayOptions and GatewayRequestOptions

Both interfaces independently declare bypassConnectable?: boolean. ActorGatewayOptions in actor-common.ts should extend or re-export GatewayRequestOptions from driver.ts so they cannot diverge.

Asymmetric behavior by target type is undocumented

For directId/getForId targets with bypassConnectable: true, the URL is stripped to just the base endpoint and actor routing moves entirely into headers. For getForKey/getOrCreateForKey targets, the normal query URL is built with an added rvt-bypass_connectable param. This intentional split is invisible to callers and deserves a brief comment in #buildGatewayUrlForTarget.

directActorId is silently undefined for query targets

In sendRequest and openWebSocket in mod.ts:

directActorId: options.bypassConnectable
    ? directActorIdFromTarget(target)
    : undefined,

For getForKey/getOrCreateForKey targets, directActorIdFromTarget returns undefined, so HEADER_RIVET_TARGET and HEADER_RIVET_ACTOR are never set. If bypass is meaningless for query targets (actor not yet resolved), consider an early guard or logged warning rather than silently degrading to only the bypass header.


Minor / Style

  • WS_PROTOCOL_BYPASS_CONNECTABLE naming: All other WS_PROTOCOL_* constants are value prefixes ending with . (e.g. rivet_actor.). The new constant is a bare boolean flag with no dot. Consider naming it WS_PROTOCOL_FLAG_BYPASS_CONNECTABLE to distinguish it from the prefix family.

Test coverage

The new test covers only buildActorQueryGatewayUrl with bypassConnectable: true. Consider adding:

  1. A test for the HTTP header path: verify HEADER_RIVET_BYPASS_CONNECTABLE and HEADER_RIVET_ACTOR are set when a directId target is used.
  2. A test for buildWebSocketProtocols: verify rivet_bypass_connectable appears in the protocols list.

Summary

Core approach is sound. Main items to address before marking ready:

  1. Fix rvt-bypass_connectablervt-bypass-connectable (kebab-case consistency)
  2. Unify the directActorId type into a shared interface
  3. Have ActorGatewayOptions extend/reuse GatewayRequestOptions instead of redeclaring bypassConnectable
  4. Add an inline comment in #buildGatewayUrlForTarget explaining the directId-vs-query target asymmetry

@NathanFlurry NathanFlurry force-pushed the mock-agentic-loop/rivetkit-gateway-bypass-client branch from 78c0c4e to a0fd0c0 Compare May 4, 2026 00:54
@NathanFlurry NathanFlurry force-pushed the mock-agentic-loop/gateway-websocket-stopping-close branch from 979cd17 to 8bb1816 Compare May 4, 2026 00:54
@NathanFlurry NathanFlurry changed the base branch from mock-agentic-loop/gateway-websocket-stopping-close to graphite-base/4917 May 4, 2026 02:59
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4917 to 05-02-fix_pegboard_restore_hibernating_request_ids May 4, 2026 02:59
@NathanFlurry NathanFlurry force-pushed the mock-agentic-loop/rivetkit-gateway-bypass-client branch from a0fd0c0 to e4d176d Compare May 4, 2026 03:01
@NathanFlurry NathanFlurry force-pushed the 05-02-fix_pegboard_restore_hibernating_request_ids branch from a362f40 to b0ace70 Compare May 4, 2026 03:01
@NathanFlurry NathanFlurry marked this pull request as ready for review May 4, 2026 03:32
@NathanFlurry NathanFlurry changed the base branch from 05-02-fix_pegboard_restore_hibernating_request_ids to graphite-base/4917 May 4, 2026 03:58
@NathanFlurry NathanFlurry force-pushed the mock-agentic-loop/rivetkit-gateway-bypass-client branch from e4d176d to fc57d3c Compare May 4, 2026 04:13
@NathanFlurry
Copy link
Copy Markdown
Member Author

Landed in main via stack-merge fast-forward push. Commits are in main; closing to match.

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