Date: 2026-08-19
Accepted (GH #264) — recorded ahead of the fix, as a constraint on it.
StreamService keeps receiverStreams, a per-process map from receive SID to
the stream record, with the resolved *keyfunc.JWKS hung off it as
ValidateJwks. GetIssuerJwksForReceiver treats entry presence as a cache
hit and returns ValidateJwks verbatim — including when it is nil. Four call
sites populate the map (the startup preload in LoadReceiverStreams,
CreateStream, and both miss paths in GetIssuerJwksForReceiver — pair-by-
inbound-SID and plain receiver); exactly one evicts from it (DeleteStream).
fetchReceiverJwks collapses three unrelated outcomes into that same nil:
On the first of those it logs "Temporary error loading JWKS, will retry", and
the function’s own doc comment says transient errors are “left for retry”. There
is nothing to retry from. The nil is cached under the SID and every later lookup
is a hit, for the life of the process.
The two error classes are asymmetric in a way that hides the live one. A
permanent error (isPermanentJwksError: 4xx other than 429, unusable URL,
undecodable body) disables the record and persists Status + ErrorMsg, so an
operator can see it. A transient error (connection refused, timeout, 5xx) —
the class that is actually expected to recover — leaves the stream enabled
with an empty reason while it verifies nothing. Nothing an operator can query
distinguishes it from a healthy stream. Verification is fail-closed at every
consumer (goSetSstp, goSetPush, goSetPoll), so inbound SETs are rejected
rather than admitted unverified: this is an availability defect, not a
verification bypass.
A second silent failure sits behind the same nil. keyService.GetPublicJWKS
swallows every per-key error with continue and returns whatever accumulated,
so a total failure yields {"keys":[]} — which keyfunc.NewJSON parses into a
non-nil, zero-key JWKS with a nil error. A presence check on the pointer
cannot tell “resolved” from “resolved to nothing”.
Fixing the caching therefore requires a distinction the codebase does not currently have: verification material is expected here and I do not have it versus nothing is expected here. Only the first may retry, and the predicate that separates them is the whole decision. Too permissive and every bearer-authenticated stream enters a permanent retry loop against an endpoint it was never given; too strict and the original bug reopens on the branch that was supposed to recover. The pull toward the permissive reading is strong, because from inside the verification path “no keys” reads as a fault — which is why the rule is recorded here rather than left implicit in the retry code.
SigningOnly — StreamConfiguration already
states it MUST NOT be inferred from “an issuer is configured”, and the
inference does not hold in the other direction either. Not “a key was found”,
which is the outcome being classified and cannot also be the classifier."NONE" is absence, not a URL. normalizeStreamTrustFields maps
IssuerJWKSUrl == "NONE" (any case) to the empty string precisely because
SCIM peers write it to mean the key is internal to this server — the
no-URL branch by intent. The predicate must be evaluated against the
normalised value, or normalise before evaluating; a record persisted before
that normalisation existed can still carry the literal, and reading it as a
URL would send the resolver to fetch https://…/NONE forever.GetPublicJWKS above
is the proof that a zero-key body is reachable in practice.isPermanentJwksError still disables the record and persists the
reason, and that path stays visible to operators and out of the retry ladder.
It no longer writes Status/ErrorMsg directly, though: the disable goes
through the shared status rule (per-direction under Q39/Q41 when this was
written; pair-level for every status since ADR 0018’s update of 2026-09-12),
so an SSTP pair whose
inbound leg cannot resolve a key carries the disable and its reason on
InboundStatus/InboundErrorMsg as well. This matters because the cache is
keyed by the inbound SID (ADR 0018) — the failing leg is the inbound one — and
inbound ingest is gated on InboundStatus alone, so a disable written only to
Status left the pair admitting events on the leg whose trust root was
missing, and left InboundStatus enabled across a restart so the preload put a
permanently-broken URL back on the retry ladder. A permanent failure latches
the cache entry out of the ladder; the latch clears when the direction is
explicitly re-enabled — the operator asserting the world changed — and the
next lookup then attempts afresh. Status changes reach the cache as well as
the DAO: the cache holds its own copy of each record and the retry machinery
reads that copy, so a re-enable that stopped at the DAO would never be seen
and the direction would stay dead until restart — the defect this ADR exists
to close, resurrected through its own remedy path.validateBusinessStreamSecurity: SigningOnly (L2 =
None) requires both Iss and IssuerJWKSUrl, so a URL-less direction is
bearer-gated by construction and has no verification material to be missing.
That dependency is load-bearing: if the create-time invariant is ever
relaxed to permit a signing stream without a JWKS URL, this branch silently
misclassifies it as not-configured and it will never retry. Relaxing 0066 §D2
requires revisiting this ADR.StreamService has no goroutine,
ticker, or shutdown hook today, and this decision declines to give it one for
a condition that only matters when someone is asking. Backoff is exponential
from ~10s, doubling, capped at 5 minutes — the cap chosen to match
RefreshRateLimit in pkg/goSet’s JWKS loader so the server has a single
story about how often it re-hits a JWKS endpoint. Bookkeeping is per cache
entry, not global.ready (resolved and non-empty), unresolved (URL configured, resolution
failing; carries last error and next-retry time), not-configured (no URL,
nothing expected). It describes this node’s current reachability of a remote
endpoint, not a property of the stream, so two cluster members may legitimately
disagree and neither is stale. Excluded from BSON; does not survive a restart.
It is per-direction, with an inbound twin mirroring the existing
InboundStatus/InboundErrorMsg convention, because the cache is keyed by the
inbound SID for a pair (ADR 0018).Status is not the carrier. An unresolvable stream keeps reporting
enabled, and the SSF-defined stream status response body gains nothing.
Readiness surfaces on the admin stream-state routes (ADR 0027) and as a
per-stream Prometheus gauge beside the existing error gauge. Those admin
routes source records from the DAO and never consult the receiver cache, so
they must overlay readiness before serializing — the least obvious part of the
change.GetPublicJWKS empty-set swallow is left in place, deliberately. It
is a real silent failure, but it lands on the no-URL branch, which by design
does not retry; the zero-key predicate above already covers the URL branch
where it would matter. Making the internal key lookup report failure instead
of returning an empty set is a separate decision, not a gap in this one.Positive
CreateStream, which poisons the entry at birth and is the case the original
report did not cover — recovers without a restart.Negative
SigningOnly trust-root invariant this ADR’s
no-URL branch depends on; validateBusinessStreamSecurity is its enforcement
point.jwks_uri goSignals publishes) and does not
bear on the verification direction (how goSignals resolves a key for an
inbound SET). Resolving locally-hosted issuers through the internal key store
to skip the HTTP hop is explicitly out of scope for #264.pkg admin route surface; where readiness is reported.docs/security_model.md — operator-facing auth and verification model.