i2goSignals

goSignals

31. SSTP inbound honours its direction’s RouteMode

Date: 2026-08-18

Status

Accepted (GH #261)

Context

An SSTP pair carries a mode per direction. SstpModeToRouteMode maps the inbound one onto SstpInbound.RouteMode, and docs/SSTP.md stated that “a pair can FORWARD outbound while PUBLISH-ing inbound”.

The router never read it. HandleEvent resolved an SSTP-ingested SET via GetStreamStateBySID, flagged sstpInbound = true, and then returned unconditionally:

if sstpInbound {
    return nil
}

That guard sat before the RouteModeImport check and before the aud / explicit-route fan-out, so every SET entering goSignals over SSTP was treated as IMPORT regardless of the mode configured on the pair. Both ingest paths reach it: the responder side (runner_sstp_server.go) and the initiator’s response-SET side (sstp_outbound.go).

The comment cited PRD #154 Q5.1 (“consumed locally … not fanned out”), which predates per-direction mode. The visible cost is that a two-hop topology — A --sstp--> goSignals --sstp--> B, aud-routed — silently drops hop 2. The workaround was RFC 8935 push for the inbound leg, which forfeits SSTP’s single-request bidirectional exchange and multi-SET batching.

Decision

D1 — Inbound routing is governed by the inbound direction’s RouteMode. The guard now consults it: IMPORT returns as before; FORWARD and PUBLISH fall through to the same fan-out an RFC 8935 push receiver uses. streamState at that point is the rx-side view built by sstpInboundCounterRecord, whose StreamConfiguration is the pair’s SstpInbound, so GetRouteMode() already returns the inbound mode — no new lookup is needed.

D2 — The forward-vs-re-sign choice is NOT made on the inbound path. It is made per outbound stream at delivery time, from that stream’s own route mode (delivery/http.go forward(), and buildSstpOutboundSets in runner_sstp_server.go), which is how the push path already works. The inbound mode decides only whether the SET is routed. This keeps one signing decision point rather than two that could disagree.

This deviates from the issue’s acceptance criteria, deliberately. GH #261 asks for a test proving the SET arrives “re-signed / verbatim respectively” for inbound PUBLISH / FORWARD. That is not implementable as written: on the inbound leg the two modes are indistinguishable, because nothing about signing has happened yet. An outbound stream in FORWARD mode forwards verbatim even when the inbound direction is PUBLISH. The AC is therefore read as satisfied by proving the SET is routed under both modes, with signing left to the existing outbound-side tests. Recorded here rather than silently dropped.

D3 — The check cannot reuse IsReceiver(). That helper matches ReceivePush / ReceivePoll only, and an SSTP inbound’s delivery method is ReceiveSstp, so the pre-existing IsReceiver() && RouteModeImport line does not fire for SSTP. The SSTP branch is therefore explicit rather than folded into that condition. Widening IsReceiver() was rejected: it is used elsewhere to mean “RFC8935/8936 receive-side”, and changing it would move behaviour outside this issue.

D4 — “No inbound mode” normalises to IMPORT, not to SstpModeToRouteMode’s PUBLISH default. sstpInboundRouteMode folds two cases into IMPORT:

Both behaved as import-only under the old guard, and honouring the PUBLISH default would silently start fanning out their events on upgrade — a data-flow change no operator asked for. New pairs are unaffected.

The normalisation lives in the helper rather than in the caller so the caller can make exactly the same == RouteModeImport test the push path makes.

D5 — A SET is never routed back out the pair it arrived on. routeEventToSstpPairsLocked takes an excludeTxSid. The originating pair’s outbound direction frequently matches the event on aud, so without this the fan-out would return the SET to the peer that just sent it.

The tx SID is the exclusion key, not PairId. It identifies the pair in both fan-out maps — initiator pairs are keyed by PairId, which the aliasing invariant makes equal to the tx SID, and responder pairs are keyed by the tx SID directly — so one key covers both loops with an identical test, and it stays correct on a record whose PairId was never populated (where a PairId-keyed exclusion would silently no-op and echo).

This is a pair-level exclusion, not a general loop suppressor. A longer cycle across distinct pairs (A→B→A) is still possible and is out of scope here; SSTP has no hop count or path record to detect it with.

Consequences

Positive

Negative

Amendment — 2026-09-13 (GH #306)

route_mode — together with iss, aud and the issuer JWKS URL — is now updatable after creation rather than create-only, on every delivery method and on each SSTP side addressed by its own SID (PairId / tx SID → the primary transmit direction; SstpInbound.Id → the inbound direction). route_mode is validated by the targeted direction’s role: a transmit direction accepts PB | FW, a receive direction accepts IM | FW; any other value is rejected with a 400 naming route_mode, and an empty value means unchanged. The vocabulary split follows the two read sites this ADR describes — a transmitter tests only == FW, a receiver only == IM — so a value from the wrong vocabulary would be mis-read rather than refused. An SSTP update is local to the patched side; the peer is not notified. D1–D5 above are unchanged: the inbound mode still decides only whether an SSTP-ingested SET is routed, and the sign-vs-forward choice stays on the outbound stream.