Skip to main content

Module relay

Module relay 

Source
Expand description

Outbound cloud relay — jekt delivery tier 4.

Tiers 1–3 (local handler, same-host registry including this machine’s other AgentMux channels, LAN peer) all live in server/reactive.rs, and so does the hold: a known agent of this AgentMux that no tier found running is held there before this tier is tried, unless the relay says another install runs it. Tier 4 was, until this module existed, a comment there — // 4. Return original error (muxbus-client will fall back to cloud relay) — delegating to a “muxbus-client” that the callers agents actually use are not. The MCP Message tool’s send POSTs to /agentmux/reactive/inject and bails on success != true, so the tier chain silently stopped at three while the tool’s own description promised “local → LAN → cloud”. See docs/reports/REPORT_NETWORK_ARCHITECTURE_DRYNESS_AND_ROBUST_LAN_2026_09_06.md §5.

This module makes tier 4 real and owned by the same handler as the other three, so every caller inherits it instead of re-implementing it.

§What “success” means here

Tier 4 is store-and-forward, not delivery. The cloud persists the injection and broadcasts a wake signal; the recipient’s srv picks it up on its next sync, which may be seconds away or never (that instance may be offline). A 2xx here therefore means queued, and RelayOutcome::Queued is deliberately not named anything that reads as delivered — the tier-3 forward path had exactly that confusion and it produced a real bug (see forward_inject_to_peer’s “one behaviour unified” note).

Structs§

RelayCredential
What relay_token resolved: the bearer to send with, and the account (sub) of the shared token it was resolved under — empty if that token names none, which leaves the carry gate without a directory (unsigned).
WanCarried
The W3-S carried tuple (SPEC_WAN_JEKT_VERIFICATION_2026_09_24.md §2.1): the sender’s WAN signature and the exact values it signed, so a receiver can re-check it. Field names are the cloud’s; an old cloud silently drops them.

Enums§

RelayOutcome
Outcome of a tier-4 relay attempt.

Functions§

relay_inject
POST one injection to the cloud relay.
relay_token
Resolve the credential to relay as, preferring one bound to this specific sender over the shared account token — the same precedence the inbound path (cloud_subscriber::sync_agent_reactive) already uses, so a binding-enforced account behaves consistently in both directions.
rest_base_url
Base URL of the muxbus REST API.
wan_sign_at_origin
Sign a WAN jekt at the instance that relays it, for the agent its token names (docs/specs/SPEC_WAN_JEKT_SIGNED_BY_SRV_2026_10_14.md §3). The tuple rides the relay only if every condition holds; otherwise the message is relayed exactly as before, with nothing carried, so every gap degrades to “unsigned”, never to a false forgery alarm at the receiver. Err names the first condition that failed, for the “queued” log line.