Skip to content

fix(core): forward to-device onward to a relay-data frame's receiver - #175

Merged
Mearman merged 1 commit into
mainfrom
fix/relay-hub-forward-to-device
Sep 17, 2026
Merged

Mearman merged 1 commit into
mainfrom
fix/relay-hub-forward-to-device

Conversation

@Mearman

@Mearman Mearman commented Sep 17, 2026

Copy link
Copy Markdown
Member

Summary

wire-mesh#170/#174 added IncomingManageRequest.toDevice, read from a relay-data frame's own to-device field, specifically so a connection fronting more than one locally-addressable device behind a single hub connection (a gateway advertising several local peers, exactly agent-comms#184's use case) can tell which of its own devices an inbound relayed request was actually addressed to.

Tracing it end to end against the installed package, relay-hub.ts's own relay-data handling reads a sender's explicit to-device to pick the right pairing among several a connection can hold at once, but then drops the field entirely before relaying the frame onward to the peer -- the receiver gets from-device only, never to-device. IncomingManageRequest.toDevice can therefore never actually populate for the gateway-fronting-multiple-devices case #170 introduced it for.

Fixes it by echoing the original to-device value through to the peer's own received frame, conditionally (omitted when the sender left it unaddressed, matching the existing single-pairing convention). Updated the four existing multi-pairing tests whose assertions implicitly relied on the old drop-it behaviour, and added a new test proving the echo-through directly.

Also splits relay-hub.unit.test.ts's multiplexed-pairing coverage into its own relay-hub-multiplexing.unit.test.ts with shared fixtures in relay-hub-test-helpers.ts, since the new assertions pushed the combined file over this repo's max-lines cap.

Test plan

  • pnpm exec vitest run test/relay-hub.unit.test.ts test/relay-hub-multiplexing.unit.test.ts -- 22 passing
  • pnpm exec vitest run (full core package) -- 535 passing (6 pre-existing, unrelated wasm-dist build-artifact failures)
  • pnpm exec tsc --noEmit -- clean (same pre-existing wasm-dist error only)
  • pnpm exec eslint on all changed files -- clean

relay-hub's own relay-data handling read a sender's explicit to-device
field to pick the right pairing among several a connection can hold at
once, then discarded it before relaying the frame onward -- the
receiving connection got only from-device, never to-device.

A connection fronting more than one locally-addressable device behind
a single hub connection (a gateway advertising several local peers,
wire-mesh#170) has no other way to tell which of its own devices a
frame was actually meant for, since every relay-data frame arrives
multiplexed over that one connection regardless of target.
IncomingManageRequest.toDevice already promised exactly this
disambiguation, read from the frame's own field, but the hub never
populated it because relay-hub.ts dropped the field on the way
through.

Splits relay-hub.unit.test.ts's multiplexed-pairing coverage into its
own file (relay-hub-multiplexing.unit.test.ts) with shared fixtures in
relay-hub-test-helpers.ts, under this repo's max-lines cap once the
new to-device assertions pushed the combined file over it.
@Mearman
Mearman marked this pull request as ready for review September 17, 2026 19:34
@Mearman
Mearman merged commit 76e5587 into main Sep 17, 2026
7 checks passed
@Mearman
Mearman deleted the fix/relay-hub-forward-to-device branch September 17, 2026 19:35
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-17T19:40:33.288611Z 7abf900 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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