Repository navigation
test(gateway): pin that a pull over /nats keeps the stream subject - #93
Merged
Merged
Conversation
A message that a pull delivers comes on the pull's inbox subscription, but with the event's own subject and the ack subject as its reply; only a status reply carries the inbox as its subject. A client whose request mux finds the request by the subject's last token (nats.js request() without noMux) drops every event. nats.go's mux hides this, because it gives a message of an unknown subject to its single request, so the broker's tests could not see it. TestNatsPullKeepsTheStreamSubject drives the protocol's own lines over /nats with the real broker: the expired pull's 408 on the inbox subject, the event on the mux's subscription with the stream subject, and the ack that moves the ack floor. The spec's broker section tells clients to read a pull on a subscription of their own.
bketelsen
approved these changes
Nov 16, 2026
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.
Summary
A guard test and a spec rule for clients of the broker's
/natsdoor: a message that a pull delivers keeps its stream subject.internal/gateway/broker_pull_test.go:TestNatsPullKeepsTheStreamSubjectruns the real broker behind the gateway's/natshandler. It speaks the NATS protocol's own lines over the WebSocket, so no client library hides what arrives. A client subscribes a request mux (_INBOX.chani.mux.*, as nats.js does) and asserts 3 things:marks.bookmark.created.folder.pilot), not the inbox, and with a$JS.ACK.app_marks.<consumer>.…reply.+ACKon that reply moves the consumer's ack floor.docs/specs/lodge-http.md, The broker: "A pulled message keeps its stream subject". A client reads a pull on a subscription of its own and never finds its request by the subject. A request mux that does (nats.jsrequest()withoutnoMux) drops every event and sees only the status replies..memory/corrections/2026-11-16-pr-93-pull-keeps-stream-subject.json: the broker's client tests used only nats.go. nats.go's request mux gives a message with an unknown subject to its single open request, so no test showed the subject.Why
The pilot run of docs/runbook-pilot.md failed at line L2: a saved bookmark did not reach the agent's events bridge.
request()pull timed out. The protocol trace showedMSG marks.a 1 $JS.ACK…: the message came on the mux's subscription, with the stream subject, and the mux dropped it.noMux: truereturned the message in 2 ms.The fix is in the bridge, not in lodge: lodge behaves as JetStream does. This PR records the contract and guards lodge's side of it.
Verification
make cipassed before the first push. It includesmake race,make crossand the nsl checks.internal/broker/broker.go(addImports). Thengo test ./internal/gateway -run TestNatsPullKeepsTheStreamSubjectfailed:the ack floor is 0 after the ack, want 1. The test checks lodge's own pull and ack path, so it can fail. The stream subject is JetStream's behavior, which lodge cannot change. The test pins that behavior for clients.Risk tier
Risk tier: 1 — tests and docs only (level L3). The PR changes only a test, the spec and a correction record. It matches no path in
.github/risk-paths.json(internal/gateway/broker.gois listed;broker_pull_test.gois not).Docs housekeeping
Cross-review
Coder: anthropic/claude-opus-5-5. Reviewer: openai/gpt-6.1-sol.
22962d19a0ff3f5047dd0bfc033ecabd5d2c5422(base49b1616ab67b8d91bb7586d06e531abc6fbddd78): Ready, Blocking: none. It had 1 low finding: the event pull reused the 300 ms expiry, so a slow delivery could give a 408.23ecc044bd2ddc57c5f6b4cbf04e32aeda1728d7: the event pull now has a 5 s expiry. Re-review 1 at that head: Ready, Blocking: none, no findings.