This file captures the vocabulary that emerged from the PRD #39 provider-chain collapse. New contributors and AI agents should share these terms when reading or modifying the persistence layer.
The persistence chain is now flat:
handlers / event router → service (StreamService, EventService, …) → DAO → driver
There is no longer a god-interface (DbProviderInterface) or a god-object
(common.BaseProvider) sitting between handlers and services. Each consumer
depends on the narrowest seam it actually uses.
Two independent authorization planes:
login) or the bootstrap secret / admin token (automation).stream/event scopes within a
project.A management session never grants event delivery; a delivery token never
administers the server — with one narrow carve-out: a delivery token may
read its own stream’s configuration, which (when it presents the
stream’s current server-issued bearer) doubles as self-service credential
rotation. See Rotate-on-GET below and
docs/security_model.md.
The Internet-reachable endpoints required for SSF interoperability: transmitter discovery and keys, stream configuration/status/verification/subject management, and push, poll, or SSTP event delivery. It excludes operator-only administration, bootstrap, cluster-internal, health, metrics, and Swagger surfaces unless a deployment deliberately publishes them. Avoid the narrower term “event endpoints,” which hides the required stream-control endpoints such as status.
The SSF behavior where a GET of a stream’s configuration returns a freshly-minted delivery bearer. The trigger is proof of possession: rotation fires only when the GET is authenticated by the stream’s current server-issued bearer (the credential about to be replaced). The caller is thereby obligated to persist and switch to the new value.
Any other authorized read of the same configuration — a management session, an admin token, or a valid-but-non-current delivery token — receives a masked bearer value and triggers no rotation. Admins observing config never see (or invalidate) the live credential; the live value is surfaced exactly twice in a credential’s life: the response that created it and the rotation response that retires it.
Rotation applies only to credentials goSignals itself issued (inbound-facing bearers); peer-supplied outbound credentials are never rotated by a local GET.
Rotation preserves the credential’s authorization shape — same scopes, same project — but the replacement is always bound to the stream(s) it serves: a rotated bearer never widens to a wildcard, and a presented bearer whose stream binding does not match the stream being read never rotates anything.
How a credential field reads on any surface other than the response
that minted it: the literal sentinel ***, with the field present.
The sentinel is deliberately not omission — an absent credential means
“none configured”, a *** means “configured, not shown”. Writing
*** back through an update means “leave unchanged”, so a
read-edit-write round-trip can never clobber a live credential.
Masking covers every stored credential — server-issued bearers and
peer-supplied ones alike.
The bounded window after a rotation during which the retired bearer remains valid. It exists for two client-experience reasons: requests already in flight with the old bearer are not failed mid-race, and a caller whose rotation response was lost can retry its GET with the old bearer and receive the same current bearer again (idempotent re-read — no third credential is minted). When the window expires the old bearer is dead cluster-wide. A zero-length grace means immediate revocation. Deliberate trade-off: a stolen old bearer can re-read the live credential until the window closes — inherent to possession-proves-rotation, bounded by the window.
key scopeauthSupport.ScopeKey ("key") — a narrow capability between reg and
admin. A key-scoped caller may create a new issuer signing key
(POST /key/<issuer>) and obtain a reg-only IAT (GET /iat), but is
denied key takeover (force=replace/rotate/?rotate → keyScopeOnly guard in
api_out_of_band.go) and has no stream/event capability. It seeds the machine
tier ladder for unattended bootstrap.
I2SIG_BOOTSTRAP_TOKEN — a shared secret read by authUtil.resolveBootstrapBearer.
A presented bearer that constant-time-equals the configured value is
synthesized into a key-scope AuthContext before any JWT validation. When the
variable is unset, the path is closed and no bootstrap bearer is accepted (fail
closed). It is an app-layer authorization mechanism, orthogonal to and coexisting
with transport-layer SPIFFE/TLS identity. There is no anonymous /iat
endpoint — closing it is the reason the secret exists.
The CLI’s login flow is driven by the server’s RFC 9728 Protected Resource
Metadata (/.well-known/oauth-protected-resource), which advertises the OAuth
authorization_servers and the recommended public client_id
(I2SIG_CLI_CLIENT_ID, default gosignals-cli). add server caches the PRM’s
authorization_servers; login resolves the issuer from it, discovers the
issuer’s OpenID configuration, then runs OAuth authorization-code + PKCE
(RFC 7636) via a loopback listener — or RFC 8628 device-code on headless hosts.
Sessions are stored per-issuer in credentials.json; see
docs/cli_login.md.
Two classes of SSF issuer, distinguished by whether the issuer’s root
(scheme://host[:port]) equals the server’s own base URL.
/.well-known/ssf-configuration/<path>), the discovery issuer and
the signed iss are the full URL, and jwks_uri points at a clean
…/jwks/<path> served by goSignals.iss, so the downstream receiver must verify
against that publisher’s keys — goSignals references the original
publishing entity verbatim and never serves transmitter discovery on
its behalf.The split exists because SSF §7.2.4 binds issuer == fetch-URL == SET
iss, and that binding belongs to whoever actually published the SET.
See docs/adr/0023-local-issuer-addressing.md.
Three categories of SSF transmitter, from the perspective of a Receiver registering a stream (SSF §8.1.1 / §8.1.1.1):
iss/aud/issuerJWKSUrl
are Transmitter-Supplied only. The Receiver MUST NOT send them; the
transmitter assigns and returns them. The OpenID conformance suite is the
canonical example.iss/aud when present, auto-generates them when absent. goSignals itself
is flexible, and we expect most real SSF servers to be.Server.Type == gosignals). Always flexible; the operator-asserted
iss/aud carry the cluster-federation routing intent.There is no reliable discovery signal separating strict from flexible
(goSignals advertises spec_version: 1_0 exactly as a strict server would).
The Receiver therefore declares the posture per-server via an operator
flag (add server --strict-ssf, persisted as StrictSsf); the default is
flexible. A strict transmitter that rejects an asserted iss/aud is
itself the proof of strictness. StrictSsf is carried on both the CLI
SsfServer and the shared model.Server, so the server-side TxAlias
receiver-create knows the posture of the transmitter it is registering
against.
How goSignals-as-transmitter decides whether to honor iss/aud on an
inbound stream-create: if the Receiver supplied them, honor them
(cluster-federation / flexible); if absent, auto-generate. No mode flag —
the request body picks the path, so one server serves strict external
receivers and cluster sisters simultaneously.
What goSignals auto-generates on the §8.1.1.1 path: iss = the server’s
advertised issuer (GetDefIssuer(); a per-tenant local issuer once the
create endpoint becomes issuer-aware), because §8.1.1.1 requires the
Receiver to confirm iss equals the issuer it discovered the Transmitter
Configuration from — a per-stream issuer would fail that check. jwks_uri
is that issuer’s existing JWKS endpoint (ADR 0023). aud is a
freshly-generated, immutable (§8.1.1: “cannot be updated”) per-Receiver
identifier in URI form.
What a stream does with an event on its way through the router. One value per stream:
issuerJWKSUrl — the original publisher’s keys — so the next hop in a
multi-hop chain can verify what it receives; goSignals does not check
that URL.iss and
signing_alg. The default for a push transmitter.A signing transmitter is any transmitter not in Forward mode,
whatever its delivery method; a transmitter with no route mode set
counts as Publish. An active signing key for its iss and
signing_alg must already exist: goSignals never creates a key as a
side effect of creating or updating a stream, because doing so would
mask a misconfiguration. A key is created deliberately, before the
stream that uses it. The check applies to the stream as it would be
after a create or an update (any update, not only one that changes
iss, signing_alg or route mode), and again when the stream is
re-enabled.
Avoid: calling a Forward stream “unsigned” — it may carry a signed SET untouched.
How RouteMode and the EventSource selector interact at the matcher
(EventService.MatchesStream), which today filters only on
(iss, aud, event-type) and must be extended to honor both axes:
EventSource — not RemoteStreamId, which is
the protocol pairing pointer connecting stream halves for delete-cascade.
EXPLICIT selects by event.Sid ∈ SourceStreamIds; DIRECT (which is
also where unset resolves, issue #199) keeps the full iss/aud/event-type
filter; AUDIENCE drops the aud filter, the stream’s own aud being a
routing handle. See Event source below.iss is a selection constraint only in Forward mode. A forwarded SET
is relayed as is (its original signature, if any, untouched), so its iss
must match what the downstream validates against. In Publish mode goSignals re-signs under its own
iss, so the inbound iss is irrelevant to selection — the matcher must
not require it. A strict transmitter is therefore PB + EXPLICIT,
selecting purely on source SID + event-type.jti is preserved across the PB re-sign — goSignals re-signs the
stored token, changing iss/aud/iat/kid but not jti. This keeps
ADR 0017’s jti-only dedup and SSTP crash-recovery idempotency intact across
the hop. txn (RFC 8417 §2.2) is the cross-hop audit linkage and is
likewise preserved; never act (an access-token claim, not a SET claim).
Since planning #112 the re-signed copy stored in events gets a new
jti and carries originalJti — see originalJti below.signing_alg)Which JWS algorithm a stream’s SETs are signed with, chosen per stream
rather than per server (ADR 0034, RFC 9964). A pinned value — RS256
(RSA-2048), ES256 (ECDSA P-256) or ML-DSA-65 (post-quantum) — signs
with the issuer’s newest active key of that type. "" (unset) means
any key type: the stream signs with the issuer’s newest active key,
and the JWS alg follows that key’s type (spec #114). An issuer that
only ever had its legacy RSA key therefore signs exactly as before; one
that gains a newer ES256 key moves its unset streams to ES256, while the
RSA key stays in the JWKS so SETs signed earlier still verify.
New keys minted without an explicit algorithm take the type
I2SIG_KEY_ALG names (default ES256; RS256 and ML-DSA-65 also
accepted). The auth-token key is always RSA. Every minting
POST /key/{name} response carries a Key-Id header naming the new
kid, and a key summary’s keyStates[] report each key’s alg
(RS256 for a stored ""), oldest-first.
Each opt-in trades differently, which is why the choice is per stream:
ES256 buys transmitter throughput. Signing runs once per event
per outbound stream, and RSA-2048 signing measured ~0.822 ms against
P-256’s ~0.019 ms on the same host — enough to make RSA the single
largest consumer of transmitter CPU and the dominant source of
allocation churn. Verification moves the other way (ES256 verify is
slightly dearer than RS256), so the receiver pays a little of what the
transmitter saves a lot of.ML-DSA-65 buys post-quantum resistance and costs wire size: its
signature is 3309 bytes against RS256’s 256.The vocabulary that hangs off it:
kty:"AKP"), whose parameter set lives in alg rather than in
kty. pkg/goSet/mldsa owns the codec and the jwt.SigningMethod,
because golang-jwt/keyfunc/jwkset have none.JwkKeyRec.Alg is the store’s discriminator
and its encoding contract: "" RSA/PKCS#1, ES256 SEC 1 + PKIX,
ML-DSA-65 raw seed + public bytes.GetSigner(ctx, issuer, alg) — the transmitter’s key-acquisition
seam. A pinned alg selects by algorithm, then recency: the newest
active key of that type, never a newer key of another type (which
RS256 could not use). An empty alg selects the newest active key of
any type, and services.StreamSigningMethod takes the JWS method from
that key. The router caches per (issuer, alg); invalidation stays
issuer-level and evicts every entry.goSet.AllowedAlgs() — {RS256, ES256, ML-DSA-65} on every node
whether or not it transmits ML-DSA. The allow-list gates the token
header before key lookup, and a receiver must be able to verify a
PQ-signed SET from a peer regardless of what it signs itself. It is
now exactly the set goSet.SigningMethodFor will select, because the
key store can hold a key for each.Independent of all of the above: CERT_KEY_ALG selects the key
algorithm for the internal mTLS certificates cmd/genTlsKeys
generates. Different trust root, different blast radius, its own
off-by-default switch.
How a signing key is retired, as the signing transmitters that use it see it.
signing_alg
is active before the old key is suspended or revoked. Signing
transmitters move to the replacement and keep delivering. This is the
expected way to suspend or revoke a key.A suspend or replace that would leave a signing transmitter with no active key needs the operator’s explicit confirmation; a revoke never does.
A signing key is created only by an operator, one algorithm at a time — never as a side effect of creating or updating a stream. Rotate and replace act on one algorithm and leave the issuer’s keys of other algorithms alone.
Every node stops signing with a suspended, revoked or replaced key, and picks up a rotated one, within a few seconds of the change, whichever node handled it.
The bound is the router’s key cache
(internal/eventRouter/signing_key_cache.go): each node’s in-memory
signing keys, per issuer and algorithm, which every signing transmitter
on the node shares. An entry is re-read from the key store 2 s after it
was loaded, once per issuer and algorithm however many streams use it;
the node that handles a key change clears the issuer’s entries at once.
A re-read that finds no active key drops the entry, so the transmitter
follows the missing-key rule; a re-read that fails keeps the current key,
so a key store outage does not pause every signing transmitter.
Key validity period (ADR 0042): a signing key may carry NotBefore /
NotAfter — its certificate’s dates, or creation plus a lifetime
(I2SIG_ISSUER_KEY_LIFETIME, default 180 days). Outside that period the key
is expired or not-yet-valid: it stays in the JWKS but never signs, and a
stream left without a valid key follows the missing-key rule. A key without
a period never expires. Validity is derived on read, never stored as status;
a key otherwise leaves service by suspend, revoke or replace.
Pause and disable are defined at the transmitter:
A signing transmitter that has no active signing key takes a key-unavailable pause: it keeps queuing, resumes by itself once the key is active again, and disables if the key is still unavailable after the retry limit. It resumes only its own key-unavailable pause, never an operator’s.
A receiver’s own status reports paused whenever it has stopped polling, for one of two reasons:
A transmitter disable, or an operator disable, stops the receiver until an operator re-enables it.
A receiver’s paused or disabled status is transmitter-caused when the transmitter’s status endpoint reported it, as opposed to an operator setting it. The receiver records which, so an operator can tell the two apart; any operator status change clears it.
A receiver that is only retrying (for example after connection errors) has not paused: its status stays enabled and the reason says why.
Avoid: “paused” for a receiver that is only retrying.
*dbProviders.Persistence — the composition root returned by
dbProviders.OpenPersistence(url, dbName). It bundles the per-domain
services, the cluster coordinator, and the lifecycle storage seam:
type Persistence struct {
StreamService *services.StreamService
KeyService *services.KeyService
EventService *services.EventService
ClientService *services.ClientService
ServerService *services.ServerService
TokenService *services.TokenService
Coordinator cluster.ClusterCoordinator
Storage storage.Storage
}
Callers should depend on the narrowest field they need (one service, or
Coordinator, or Storage) — not pull the whole record around.
internal/providers/cluster.ClusterCoordinator — the seam that owns
distributed-lease and node-registry state. Two implementations:
MongoCoordinator — production. Uses MongoDB
FindOneAndUpdate for atomic acquire/renew/release, with monotonic
fencing tokens and 30s leases (10s heartbeats). Backed by
cluster_leases and cluster_nodes collections.MemoryCoordinator — in-process. Real semantics, not a stub:
mutual exclusion under concurrent acquire, lease takeover after
expiry, fencing-token monotonicity, ReleaseLeaseIfOwned semantics,
active-node filtering by heartbeat freshness. Used by unit tests to
exercise lease invariants without docker.internal/providers/storage.Storage — the lifecycle surface (Name,
Check, Close, ResetDb, SetBaseUrl). Decoupled from data access
so health checks and shutdown paths don’t drag the whole god-interface
in. One implementation per adapter (MemoryStorage, MongoStorage).
internal/eventRouter/delivery.PushDelivery — the one-attempt push-side
delivery seam consumed by the router’s push loop. One method:
Deliver(ctx, PushRequest) PushOutcome “given a stream config, an event
record, a signing key, and a kid, sign-or-forward the SET, push it to
the receiver, return the goSetPush.Classification + captured peer
address + (possibly-rotated) key and kid.”
Two adapters, prior art ClusterCoordinator from PRD #39:
HTTPAdapter — production. Owns JWT signing, httptrace peer
capture, goSetPush.PushSET, goSetPush.ClassifyResult, the
stream’s RemoteAddress persistence via StreamService, and the
RFC8935 §2.4 jws_signature_failed rotate-and-retry sub-policy
(one retry, via the injected KeyReloader). For forward-mode
streams the retry is skipped (no local signing material to rotate).MemoryAdapter — tests. Returns scripted PushOutcomes
(single value or a sequence). Goroutine-safe. Used by router-level
tests that want deterministic classification outcomes without
standing up an HTTP receiver.Scope discipline: the seam covers one delivery attempt. Recovery
cadence, lease heartbeats, retry policy, backfill, and cluster
wake-ups stay in the router — the router consumes the classification
and decides what to do next. PollDelivery (the symmetric poll-side
seam) is deferred to a follow-up PRD.
The per-stream module the EventRouter owns for one target stream’s
in-memory work: the pending JTIs still to deliver, the in-memory poll
claims, and the coalesced acknowledgement batch. The acknowledgement
batch is one Mongo write — a conditional update of the stream’s
deliveries documents from pending to delivered, plus w:1 inserts of
the re-signed outbound copies into events. It replaced the old
pendingEvents DeleteMany + deliveredEvents InsertOne + retract
DeleteMany sequence.
An immutable snapshot of stream routing — stream id, status, delivery mode, event-type and subject filters — rebuilt whenever a stream is added, removed or changes status, and read without taking the router lock. Lease ownership is deliberately not part of it; that stays in the lease-owner cache (see Ingest read caches).
The seam for inter-node wake signalling. One method:
Wake(ctx, owner node, WakeMessage{StreamID, Mode, Reason, JTIs}). The
production adapter is HTTP (HMAC-signed, its own routes, node address
looked up in Mongo); the two-node test harness uses an in-process
adapter. The JTI list is advisory and capped — the receiving node falls
back to reading its pending deliveries from Mongo.
The node-level module that owns lease acquire / heartbeat / release for every stream on a node. It keeps the lease expiry each heartbeat returns and answers “do I still hold stream X” from local tenure minus a safety margin, so no Mongo read precedes an acknowledgement batch. Fencing tokens remain for operator-visible diagnostics; fence-on-write was rejected (no transactions, and delivery documents carry no owner).
Ingest stores a batch’s event bodies and every matching stream’s pending
markers in ONE store call, EventDAO.InsertWithPending (ADR 0043). On MongoDB
8.0+ it is a single ordered multi-namespace client bulkWrite, so ingest pays
one majority-acked round trip; below 8.0 it falls back to two sequential writes
(bodies, then markers for the accepted bodies only) and logs one WARN at
startup. Either way a marker is written only for a SET whose body was stored, so
there is no speculative marker to retract.
The router’s ingest path plans first and writes once: planFanoutLocked selects
the matching streams (no write), EventService.AddEventsWithPending stores
bodies and markers, and commitFanoutLocked meters the accepted SETs as egress
and only then wakes the streams. A SET is acked only when its body and its
markers are durable (ADR 0038’s contract, retained).
Worth knowing before debugging a delivery oddity: a body-less marker can
still exist — data left by an older build’s concurrent ingest — and every
delivery leg skips one without acking it. A crash between the fallback path’s
two writes leaves the opposite: a stored body with no marker, never acked.
And if a body lands but one of its markers fails, the SET is answered 503; the
retry resolves as a duplicate, and router.requeueDuplicates repairs it
through EventService.RequeueDuplicate / EventDAO.EnsurePending, an
idempotent (sid, jti) upsert that queues the SET on each target holding
neither a pending nor a delivered record for it, then meters and wakes those
targets like an accepted SET (#331). A duplicate with its markers in place
changes nothing; a failed repair is answered 503 again. The WAL drain runs the
same repair. The only residual is a retry that arrives after retention purged
the delivered record, which is re-queued (at-least-once).
The pending-marker and delivered-record collections (pendingEvents /
deliveredEvents) were replaced by the single deliveries collection under
planning #112 — see below. Legacy documents are migrated once at startup.
deliveries collectionReplaces the pendingEvents and deliveredEvents collections with one
document per (sid, jti):
{sid, jti, ackJti, state: pending|delivered, createdAt, ackDate, expireAt}
— a reference only, never the body. ackJti is the row’s
Acknowledgement JTI (see below). Indexes: unique (sid, jti);
(sid, ackJti) for the acknowledgement match; (sid, state, jti) for the
pending read; TTL on expireAt; jti for the body sweep; and a partial
(sid, createdAt) index over state: pending rows only, for the
backlog’s oldest enqueue time. state is open to a later claimed value. Because a
delivery document is a reference, a body in events is purged only when
no delivery document in either state references it. expireAt is
written at acknowledgement from the stream’s retention policy (enterprise
policy may vary it per stream).
AckJti)The JTI a receiver acknowledges a delivered SET by, stored on the
deliveries row as ackJti when the row is written. For a Forward
stream it is the inbound JTI; for a re-signing route mode it is the JTI
of the re-signed outbound copy. An acknowledgement is matched against
ackJti, never re-derived from the stream’s current route mode, so a
route-mode change does not orphan rows already written (#363).
Two related meanings, both owned by the stream’s lease owner:
I2SIG_POLL_CLAIM_TTL), so overlapping requests get disjoint
batches. An ack or release frees it; an expired claim makes its JTIs
servable again (at-least-once). A restart or lease takeover drops all
claims.PeerTransport.Claim: a node that receives a poll or
SSTP request for a stream it does not own forwards it to the lease
owner, which answers from its queue. The non-owner writes nothing and
builds no queue (#365).RouterDeps.ServesClaims: true when the process serves poll and
accepted-SSTP requests and mounts /_cluster/claim (the community
server and goSsfServer). A router with it false (business routers) never
takes a poll-transmitter or sstp-server lease; it wakes a known owner at
ingest and otherwise leaves the rows pending (#365).
The transmitter-side waiting vocabulary, per target stream:
originalJti (field on events)Set on a re-signed outbound copy stored in events: the copy carries a
new jti, and originalJti points at the inbound SET it was derived
from. Ingest dedup is on the inbound jti only (amends ADR 0017,
follow-up pending). Ordering (ADR 0040) sorts on the original jti.
Three separate caches serve the per-event reads on the ingest path, each scoped to its own staleness tolerance rather than sharing one TTL (ADR 0039). Reach for the right one by what it answers, not by name:
pkg/services/stream_request_cache.go) —
“which stream is this?”, memoised for the life of one request. No expiry, since
it cannot outlive the handler. It is a correctness surface: every
StreamService write calls invalidateRequestStreams, and any new write path
that reaches the DAO directly owes it the same. Opt-in — a context with no memo
installed is byte-for-byte the old read path.pkg/services/token_revocation_cache.go) — “is
this bearer revoked?”, 2 s TTL. Bounds exactly one case: a peer node revoking
a token this node recently validated. A local revoke drops the entry as part of
the revoke, and an entry is capped at the token’s own revoked_at, so the
rotate-on-GET grace window (ADR 0022 §2) stays exact rather than approximate. It
carries an invalidation generation so a revoke landing during an in-flight
read cannot be straddled; putIfCurrent is the only writer, and callers sample
the generation BEFORE the store read they intend to cache.internal/eventRouter/lease_owner_cache.go) — “who owns
this push-transmitter, poll-transmitter or sstp-server lease?”, 2 s TTL. A
backstop behind this node’s own acquire / renew / lose / exit transitions,
which keep it honest. It steers a wake-up or a Claim and never authorises a
delivery; a Claim answered NotOwner forgets the entry (#365). The SSTP-client lease is
deliberately not cached: it is owned by the dialer in internal/server, so a
cache here would be a bare TTL with no invalidation hook.(*EventService).MatchesStream(stream, event) bool — the SET-to-stream
routing predicate. Owns the direction/iss/aud/event-type filter that
decides whether a given AgEventRecord should be delivered to a given
StreamStateRecord. Pure predicate: touches no DAO state.
Previously a free function eventRouter.StreamEventMatch in the
router package. Lifted into EventService so the predicate sits next
to the rest of the event-routing surface and can be unit-tested
without constructing a router. Same fat-services / thin-DAOs rule
that brought the receiver-stream predicate together under
StreamService in PRD #39.
The architectural principle: business logic, predicates, caching, and
cross-DAO coordination belong in services. DAOs are storage operations
only — no predicates, no if-trees, no domain reasoning.
This rule has historical weight. Before PRD #39 the receiver-stream
predicate had drifted between adapters
(StreamDAOMongo.FindReceiverStreams filtered on route_mode == "import";
StreamDAOMemory.FindReceiverStreams used state.IsReceiver() —
different predicates that the memory adapter’s tests covered while the
Mongo path silently diverged). Lifting predicates into the service is
the structural fix that keeps the two adapters in lockstep.
Monotonically increasing per-resource counter handed back from
TryAcquireOrRenewLease. The MemoryCoordinator’s contract guarantees the
token never moves backward across the lifetime of a coordinator
instance, even after takeover.
The atomic-pointer pattern Mongo DAOs use to survive a
ResetDb(true) / reconnect without invalidating service references.
Each Mongo DAO holds its *mongo.Collection behind an
atomic.Pointer[mongo.Collection]. On reconnect the provider calls
SetCollection(newCol) on each DAO; in-flight readers see either the
old or the new collection, never a partial state. Replaces the
pre-PRD #39 swap-on-reconnect path that rebuilt the entire
*BaseProvider behind an RWMutex.
Per-DAO decorator wrappers used only by the in-memory adapter. Each
wraps an interfaces.X DAO and fires a notify() callback after
every successful mutation. Used by MemoryProvider to drive
file-backed persistence (MarkDirty → save loop). Mongo carries no
decorator and pays no overhead — the memory adapter is the only path
that needs after-mutation hooks.
Replaces the WriteHook / SetWriteHook / afterWrite /
notifyWrite plumbing previously threaded through ~25 BaseProvider
methods.
Terms used by SSF §8.1.3 subject filtering. The implementation guide is
docs/subject_processing.md.
The principal an event is about, identified per RFC9493 Subject
Identifiers — the same vocabulary SSF §8.1.3 and SCIM Events (RFC9967)
use. Formats: account, email, iss_sub, opaque, phone_number,
did, uri, aliases, plus complex subjects (user / group /
device / session / tenant / org_unit). A Subject is not necessarily a
person — it may be a device, session, or org unit.
Avoid: treating “user” or “account” as synonyms for Subject.
The SSF §8.1.3.1 predicate that decides whether two Subjects are “the
same” for filtering purposes — distinct from EventService.MatchesStream
(which is iss/aud/event-type routing). Rules:
Consequence: a receiver can subscribe broadly (few fields specified)
and still receive narrower, more-specific events. Because the two
kinds match differently, the subject filter is stored split by
kind — simple Subjects hash-indexed on their canonical key (O(1)
membership), complex Subjects held in a small field-wise-scanned
list. A filter may legitimately reach millions of entries; see
docs/adr/0003-split-subject-filter-storage.md.
A per-transmitter-stream setting (goSignals extension, not an SSF stream-config field) expressing the default delivery policy a receiver sees — not a guarantee:
ALL — Subjects are delivered by default; the receiver narrows
by removing Subjects.NONE — no Subject is delivered by default; the receiver opts
in by adding Subjects.It is only a default. Per SSF a transmitter MAY ignore Add/Remove
requests and MAY deliver a Subject out-of-band on its own policy (e.g.
a user opt-in dialog at the transmitter). So a NONE upstream can
still send Subjects goSignals never added, and an ALL upstream may
withhold some.
The stream’s subject filter table holds only the non-default set.
Changing defaultSubjects on a live stream is a deliberate reset: the
filter table is cleared, because old entries carry the opposite
meaning under the new baseline.
Because upstream delivery is never guaranteed to track what goSignals
subscribed for, goSignals must tolerate receiving events for Subjects
it never added. The downstream transmitter filter is therefore applied
to whatever arrives, judged purely on that downstream stream’s own
defaultSubjects + filter table — never on how or why the event
arrived. Inbound subscription state and outbound delivery policy are
decoupled.
A setting on a goSignals receiver stream giving the operator explicit control over how Add/Remove Subject requests arriving at the fed downstream transmitter streams are handled:
PASSTHRU — raw 1:1 relay of Add/Remove to the upstream
transmitter; no reference counting, no local filtering. Downstream
streams share one upstream subscription and share fate: one
downstream’s Remove removes the Subject for all. That bluntness is
the feature.LOCAL — filter locally, independently per downstream
transmitter stream; never touch the upstream.HYBRID — reference-counted relay and local fan-out
filtering, so each downstream sees only the Subjects it asked for.
goSignals tracks, per Subject handler + Subject, the set of
interested downstream streams; it relays an add upstream when the
set goes 0→1 and a remove only when it goes 1→0. HYBRID relays
only against a defaultSubjects=NONE upstream — against an
ALL upstream everything already arrives, so it behaves as pure
local filtering (relaying a remove could starve a not-yet-created
downstream). HYBRID is mandatory for a NONE upstream fanning
out to multiple selective downstreams — such a stream cannot be
filtered LOCAL-only because the event never arrives.PASSTHRU and HYBRID require (a) the upstream to advertise
add_subject_endpoint / remove_subject_endpoint in its SSF
discovery metadata, and (b) an unambiguous relay target — see
Event source and Subject handler.
How a transmitter stream selects the events it sends. A new axis,
distinct from RouteMode (IM/FW/PB). An unset source resolves to
Direct (issue #199), the branch that keeps the historical filter
— not to Audience-routed, which drops half of it:
LOCAL only. At the matcher this
is the branch applying the full iss/aud/event-type filter.aud is a routing handle
rather than a value the event must carry, so the matcher drops
the aud filter and keeps iss and event type. For relay, the
feeding receiver stream is found by matching the transmitter
stream’s iss to a receiver stream’s iss.The single receiver stream designated to receive relayed Add/Remove
Subject requests for a given issuer. When an Audience-routed
transmitter stream’s iss matches exactly one receiver stream, that
receiver is the subject handler automatically. When several receiver
streams share the issuer (e.g. a cluster of nodes all transmitting to
goSignals on common audiences), the ambiguity MUST be resolved at
configuration time by designating one explicitly via Explicit (SID)
source — otherwise stream configuration is rejected.
Publish-mode iss/aud rewriting is a deferred enhancement and is
out of scope; it will later interact with subject filtering because
rewriting iss changes the canonical key of iss_sub Subjects.
Receiver-initiated requests (SSF §8.1.3.2 / §8.1.3.3) telling a
transmitter stream whether to deliver events for a given Subject. Add
Subject POST returns 200; Remove Subject POST returns 204. Carry
stream_id, subject, and (Add only) an optional verified boolean.
A transmitter MAY silently ignore them. goSignals stores verified
for audit and relays it verbatim upstream, but it does not influence
filtering — goSignals is not an identity verifier.
The endpoints are gated by a server-wide I2SIG_SUBJECT_FILTERING
setting (DISABLED default / ENABLED). When DISABLED they are
omitted from SSF discovery and return 404.
Add/Remove take effect for future events only — they do not
replay a Subject’s event history. A receiver that wants history uses
the existing ResetDate / ResetJti replay mechanism instead.
goSignals applies the subject filter at delivery time, not at
routing time. MatchesStream and HandleEvent are untouched — an
event still enters the stream’s pending buffer. The filter is
consulted when the buffer is drained:
runPushLoop on the node holding the
push-transmitter:<sid> lease. A filtered-out JTI is discarded
(acked), not pushed, so the pending list still drains and stays
bounded. The filter is cached in that node’s memory; an Add/Remove
arriving on any node looks up the lease owner and notifies it (the
same point-to-point pattern as the event wake-up) to reload.This is why routing-time filtering was rejected: routing runs on an arbitrary ingest node, so it would force every node to hold every stream’s filter, with no existing channel to keep them consistent. Delivery-time filtering pins the hot path (PUSH) to the single lease owner, which the wake-up scheme already addresses.
Operational events (Operational=true — verify, stream-updated)
carry no Subject and always pass the filter, just as they already
bypass MatchesStream.
A configurable interval (SSF §9.3, “Malicious Subject Removal”) during which a Subject whose delivery was just stopped continues to be delivered, so a malicious or coerced receiver cannot instantly blind a downstream by quietly removing a victim Subject.
0 means immediate enforcement. It applies only where goSignals is
itself the filtering transmitter — LOCAL and HYBRID local
fan-out. Under PASSTHRU the upstream transmitter applies its own
§9.3, so goSignals adds no grace.defaultSubjects flip is a deliberate operator action, not
the §9.3 threat, so the flip clears the filter table immediately and
bypasses grace.Dev: The SCIM demo cluster has several i2scim nodes, each transmitting to goSignals on the same set of audiences. A downstream receiver removes a Subject — where does the Remove go? Domain expert: i2scim doesn’t speak SSF, so there’s no upstream Add/Remove endpoint to relay to. goSignals filters
LOCAL. Dev: And if i2scim later supported SSF? Domain expert: The cluster would synchronize Subjects internally, so you’d relay to just one node. You’d pick one cluster stream as the Subject handler via Explicit (SID) source — issuer matching alone is ambiguous across the cluster, so config would reject it otherwise.
DbProviderInterface (internal/providers/dbProviders/provider_interface.go)
— the 50-method god-interface. Bundled four unrelated concerns
(service-shaped data access, cluster coordination, lifecycle, auth
bridges) and forced any change to ripple through both adapters.common.BaseProvider (internal/providers/dbProviders/common/base_provider.go)
— a 323-line pass-through whose only real logic was two lines
inside CreateStream (since lifted into StreamService). Every
other method delegated to a service. Embedded by both providers
solely to satisfy the god-interface.OpenProvider — replaced by OpenPersistence. New callers
should always reach for the latter.The server handler tree (application.go, routers.go, api_*.go, and
their tests) lives in internal/server. The former pkg/goSignals/ package
(embedded Swagger UI served at /swagger/, plus codegen scaffolding) was
removed in v0.12.0-alpha.21; neither server mounts a Swagger UI any more.
pkg/goSignalsServer (product export) vs pkg/goSsfServer (spec server).
goSignals — served by cmd/goSignalsServer over internal/server.SignalsApplication —
is the primary product: a strategic gateway that is a superset of SSF (receivers,
cross-protocol SET routing, MongoDB-lease clustering, subject filtering, admin CRUD).
pkg/goSignalsServer is that product’s pkg-importable export surface for out-of-tree
consumers (the enterprise REST-coexistence binary — #215, ADR 0027); today it exports
only the admin handler set (NewAdminSurface/AdminRoutes()) with a stub event router —
the peer/event plane is served by the binary directly. pkg/goSsfServer is a separate,
minimal, SSF-spec-only server for inter-op testing and event generation that deliberately
omits the product’s extended functionality (e.g. receivers). Caution: pkg/goSignalsServer’s admin
export carries only a stub event router (adminRouterAdapter panics on every
event method) — it cannot host an event-plane seam; a live EventRouter exists
only on the in-binary gateway and the goSsfServer test server. The Slice-15
metering event-observer (#217) was therefore closed not-planned: its
AdminSurfaceConfig.EventObserver rides that stub router and observes nothing.
Where the community does meter is the live EventRouter, transport-agnostically:
IncrementCounter tags every business SET — push, poll, and SSTP alike, the
transport carried only as a tfr label — into the events_in_total /
events_out_total Prometheus counters and exposes them at /metrics
(internal/server/prometheus.go:363, routers.go:76). Event-throughput metering
is therefore a scrape of that existing surface, not a new hook; the one piece it
cannot supply is distinct-subject MAS, which is not a counter and needs per-event
subject visibility wherever subjects are seen.
Known debt: pkg/goSsfServer/ssf-application.go (a demo receiver)
imports internal/server, crossing the pkg/ → internal/ boundary.
Reabsorbing pkg/goSsfServer into internal/ (or cmd/goSsfServer/)
is deferred — recorded in PRD #50 Out of Scope.
The four slog levels (DEBUG / INFO / WARN / ERROR) are the same
labels that flow through to Loki and any dashboards built on top. Pick the
right one so operators can rely on level=ERROR as a real attention
signal, not a noise floor:
DEBUG — Verbose internal state. Off in production.INFO — Steady-state operational facts: stream registered, lease
acquired, push delivered.WARN — Recoverable and expected-as-part-of-normal-operation
conditions. Examples:
WARN until the retry budget is exhausted and it is declared a
permanent failure (then promote to ERROR).ERROR — Demands operations attention. Reserve for conditions that
will not resolve themselves without human intervention. Examples:
The discipline is asymmetric. Promoting an item from WARN to ERROR
because “it might matter” pollutes the signal that on-call uses to
decide whether to wake up. Demoting an existing ERROR to WARN
because the condition turned out to be normal-ops is welcome — leave a
note at the call site so the next reader knows it was deliberate.
If you find yourself wanting a fifth level (“this is serious but not
quite ERROR”), the answer is almost always WARN plus an error= field
on the record. Grafana / LogQL can already filter {level="WARN"} | json
| error="..." for the subset that matters; a new level cannot.
Terms for the management-plane view of issued tokens (the tokens
collection / TokenRecord). These are about administering IATs and
stream tokens, not validating them on the data plane.
The guiding insight: an issued token is a bearer credential that an administrator typically copies and pastes to wherever it will be used. The IP a token was minted from is therefore near-noise; the audit-valuable signal is where it was redeemed/used. So the model tracks redemption, not issuance.
The act of using a token, distinct from minting it.
/register call presenting the IAT.
/register is a cold path (not the hot event-delivery path), so
capturing the redemption IP there is cheap.For an IAT: the remote address of the most recent /register call
that presented it, with last_redemption_at and a redemption_count.
Last-only (not a full trail) — deep per-event forensics live in the SET
event journal. redemption_count is also the data primitive a future
max-uses / redeem-once policy would consume; a future IAT-IP-mask
restriction would consume the redemption IP. Neither policy is built
today.
For a stream token: the most recent address the peer actually
connected from — already tracked per stream as RemoteIP on
StreamStateRecord and refreshed as the peer reconnects (no extra
write on the hot path). The management-plane token table joins this
onto stream-typed tokens. This is the stream-token analogue of an IAT’s
Last-redemption IP. Undefined for IATs (they are not bound to a stream).
A setting on a goSignals receiver stream controlling whether the
semantics of SET event payloads (required claims, subject shape) are
checked after the SET itself passes signature/iss/aud verification.
Validation is per event URI: an event is recognized when a
validator for its URI is registered, unsupported otherwise.
NONE (default) — no payload checks; valid signature → forward.
Today’s content-agnostic router posture, unchanged.WARN — checks run for observability only: a recognized but
malformed payload is logged at WARN and still forwarded; unsupported
URIs forward silently. The staged-rollout mode.ENFORCE — recognized-but-malformed events are rejected on the
wire (each transport maps the rejection to its own RFC semantics);
unsupported URIs still forward. “What I recognize must be
well-formed.”STRICT — firewall posture: every event must be vouched for by
a validator. Malformed and unsupported events are both rejected.An event is also treated as unsupported when its URI is
out-of-contract — matching none of the stream’s negotiated
events_delivered patterns. Which event types flow on a stream
remains the job of events_requested ∩ events_supported;
validation mode governs payload well-formedness, not type selection.
The events_supported half of that intersection is the catalog:
the compiled-in SCIM/CAEP/RISC/WISE packs, plus any URIs an operator
adds through I2SIG_EVENT_TYPES_EXTRA (ADR 0032). It is a routing
gate, not an advertisement — a type outside it negotiates into an
empty events_delivered and its SETs are stored but never routed.
An extended URI has no built-in validator, so it is unsupported by
the definition above: forwarded under every mode but STRICT.
Rejection granularity is the whole SET (worst disposition wins): the
router forwards raw signed tokens and never strips a payload, so under
STRICT a SET carrying an unrecognized extension payload alongside a
valid event is rejected whole.
Where a rejected SET surfaces on each receive transport. The
pkg/goSet* receiver libraries never reject: they compute
dispositions and report them (goSetPush.ReceivedSET.Validation,
goSetPoll.ParsedPollResponse.Validations). Mode policy and the
mapping below live in internal/server — the libraries stay
policy-free, and “dispositions reach the server wiring” is structural
rather than a review checkpoint.
Both transports report the same error code, invalid_request: RFC8935
§2.4 defines it for a non-conformant event payload and RFC8936 §7.1.2
shares that registry. The description names the offending event URI
and, for a malformed payload, the failing claim.
EventRouter.setErrs instead of
ack. Other jtis in the same batch ack normally: the decision is
per-jti, because the jti is the ack granularity.setErrs on BOTH server
paths: the acceptor puts it in the response it is already writing,
and the dialer’s inbound half carries it in its next request
alongside the acks. A pair is one bidirectional
StreamStateRecord (ADR COM-0018), so its single
event_validation field governs the inbound leg on both paths,
and engagement comes from that leg’s events_delivered — never the
transmit leg’s. goSetSstp.VerifyConfig.Validators /
VerifiedSET.Validation are the additive hook, added without moving
VerifySET’s signature because the package has live out-of-tree
consumers.WARN is wire-invisible — normal 202 / normal ack, plus a WARN
log carrying jti, event URI and the failed check. Unsupported logs
at DEBUG, since any event type no validator pack covers yet is
unsupported and would otherwise be pure noise.Validator engagement is derived from the stream’s negotiated
events_delivered, expanded through ssfModels.MatchDeliveredEvents
so exactly one pattern→URI surface exists. NONE builds no validator
set at all, so the default posture is the pre-validation receive path
rather than “validate and discard the answer”.
Observability is one counter, goSignals_router_event_validation_total,
labeled disposition × mode × transport. It is not labeled by stream or
event URI, either of which would make the series unbounded. NONE
records nothing, because it computes nothing.
The two event types the SSF spec itself defines, both diagnostic /
operational rather than business signals: the Verification Event
(SSF §8.1.4.1, the receiver-triggered stream liveness check) and the
Stream Updated Event (§8.1.5). They are always in-contract and
always validated regardless of a stream’s events_delivered list, so
a narrowly-scoped STRICT receiver never rejects its own verification
handshake. Distinct from the enterprise product’s control-stream
events, which are not community vocabulary.
Ping event (ADR 0048, planning#142): A Verification Event, whoever sent it: a keepalive or operator-triggered verify that goSignals transmits, or one it receives from a peer SSF server. It is a diagnostic event, not a data event; it is kept only for short-term diagnosis, unlike data events, which follow their stream’s retention. Avoid: heartbeat, keepalive event (a keepalive is one source of ping events, not the whole set), verify SET
internal/dao/interfaces/). DAOs are storage-only.internal/dao/memory/ and
internal/dao/mongo/). Keep them mechanically equivalent — any
business logic that varies between adapters is a service-level
concern, not a DAO concern.StreamService, EventService, etc.). This is
where predicates, caching, and cross-DAO coordination live.Implement the three small seams:
internal/dao/interfaces/.cluster.ClusterCoordinator.storage.Storage.Then wire dbProviders.OpenPersistence to dispatch based on URL
prefix. The interfaces are free of bson.ObjectID and other
Mongo-specific types — string IDs only.
(C)2026 Independent Identity Inc.