feat(fabric): add NATS EventFabric + RunnerFabric seams (RIG-3107) - #877
Open
rigel-mintaka wants to merge 1 commit into
Open
feat(fabric): add NATS EventFabric + RunnerFabric seams (RIG-3107)#877rigel-mintaka wants to merge 1 commit into
rigel-mintaka wants to merge 1 commit into
Conversation
|
Compass engineering docs preview: https://compass-managed-rig-3107-nat.compass-eng-docs.pages.dev Deployed from Changed pages: |
rigel-mintaka
force-pushed
the
compass-managed/rig-3107-go-floor
branch
from
September 4, 2026 23:19
3ff1cea to
33c6519
Compare
First code slice of the T3 NATS fabric (frozen in RIG-2861): a new `go/internal/fabric` package providing the two transport seams the comms and runner planes cut over to, over a single NATS connection. Stacked on the go-1.26 floor bump (its own PR) that the nats-server test dependency requires. **EventFabric** — durable comms fan-out on JetStream. `Publish(ctx, subject, EventRef)` / `Subscribe(ctx, subject, func(EventRef))`. Carries a compact `EventRef` (tenant + kind + row id) as an at-least-once reference, never the payload, so JetStream stays a transport rather than a second store; subscribers re-read Postgres by row id. MsgID = sha256 of the length-prefixed ref for dedup within the Duplicates window; app-level DLQ via `Term()` at the delivery budget. **RunnerFabric** — best-effort runner control on core NATS. `SendCommand(ctx, runnerID, *SessionsResponse)` / `Events(ctx) (<-chan RunnerEvent, error)`; offline runners are recovered by the delivery cursor sweep, not by broker durability. One `Fabric` implements both seams over one `nats.Conn`. Lazy stream ensure (the frozen `New` carries no context, so the topology call derives its ctx from the first Publish/Subscribe). Per-subject durable consumer named `comms-`+sha256(subject) — injective, unlike a `.`→`_` substitution which would collapse two subjects onto one shared consumer. Close registers a `StatusChanged(nats.CLOSED)` listener before draining so it observes connection teardown directly rather than through a clobberable ClosedHandler. Full subject grammar + JetStream config in `SUBJECTS.md` beside the package. Subjects: `compass.<tenant>.comms.<kind>`, `compass.runner.<runner_id>.cmd`, `compass.runner.events` (queue-grouped), `client.<sessionID>`. Spec-impact: none. Refs RIG-3107 Co-authored-by: Matt Wilkinson <matt@rigel.build>
rigel-mintaka
force-pushed
the
compass-managed/rig-3107-go-floor
branch
from
September 4, 2026 23:41
33c6519 to
65ef824
Compare
rigel-mintaka
force-pushed
the
compass-managed/rig-3107-nats-fabric
branch
from
September 4, 2026 23:42
12612dd to
d9db404
Compare
rigel-mintaka
marked this pull request as ready for review
September 4, 2026 23:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First code slice of the T3 NATS fabric (frozen in RIG-2861): a new
go/internal/fabricpackage providing the two transport seams the comms and runner planes cut over to, over a single NATS connection. Stacked on the go-1.26 floor bump (its own PR) that the nats-server test dependency requires.EventFabric — durable comms fan-out on JetStream.
Publish(ctx, subject, EventRef)/Subscribe(ctx, subject, func(EventRef)). Carries a compactEventRef(tenant + kind + row id) as an at-least-once reference, never the payload, so JetStream stays a transport rather than a second store; subscribers re-read Postgres by row id. MsgID = sha256 of the length-prefixed ref for dedup within the Duplicates window; app-level DLQ viaTerm()at the delivery budget.RunnerFabric — best-effort runner control on core NATS.
SendCommand(ctx, runnerID, *SessionsResponse)/Events(ctx) (<-chan RunnerEvent, error); offline runners are recovered by the delivery cursor sweep, not by broker durability.One
Fabricimplements both seams over onenats.Conn. Lazy stream ensure (the frozenNewcarries no context, so the topology call derives its ctx from the first Publish/Subscribe). Per-subject durable consumer namedcomms-+sha256(subject) — injective, unlike a.→_substitution which would collapse two subjects onto one shared consumer. Close registers aStatusChanged(nats.CLOSED)listener before draining so it observes connection teardown directly rather than through a clobberable ClosedHandler. Full subject grammar + JetStream config inSUBJECTS.mdbeside the package.Subjects:
compass.<tenant>.comms.<kind>,compass.runner.<runner_id>.cmd,compass.runner.events(queue-grouped),client.<sessionID>.Spec-impact: none. Refs RIG-3107