Make stream correlation a first-class seam (CorrelationID)#3
Draft
sigma wants to merge 1 commit into
Draft
Conversation
…seam auth.Wrap keyed its identity map on transport.Stream.RemoteID() — a field documented "not for authentication" — so every backend quietly overloaded RemoteID with a correlation value (websocket's per-process token, unix's SO_PEERCRED string). vterm did the same to tie a peer's /mosey/control resize to its later /mosey/pty attach. The interface contradicted its use. Add Stream.CorrelationID(): an unauthenticated, per-dialer-instance handle that *links* streams to an Identity the handshake already established — it never grants identity. RemoteID reverts to a pure log tag. auth.Wrap and vterm both key on CorrelationID, and auth.Wrap fails closed on an empty handle. No wire change: the websocket subprotocol token and unix peercreds derivation are byte-identical; only where the value surfaces in Go moves. See docs/adr/0004-stream-correlation-seam.md and the CONTEXT.md Transport glossary. Backend correlation tests migrate from RemoteID to CorrelationID. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Implements candidate #4 from the architecture review: name the stream-correlation requirement that
auth.Wrap(and, it turns out,vterm) was smuggling throughRemoteID.Problem
auth.Wrapkeyed its identity map ontransport.Stream.RemoteID()— a field documented "used for log tagging; not for authentication." To satisfy this unnamed requirement, every backend overloadedRemoteIDwith a correlation value (websocket's per-process token, unix'sSO_PEERCREDstring). The interface contradicted its own contract, and each new backend had to reverse-engineer what auth needed.Change
Stream.CorrelationID(): an unauthenticated, per-dialer-instance handle that links streams to anIdentitythe handshake already established — it never itself grants identity.RemoteID()reverts to a pure, possibly-empty log tag.auth.Wrapkeys onCorrelationIDand fails closed on an empty handle (no aliasing under the""key), both when storing post-handshake and when admitting app streams.CorrelationID) from the remote address (RemoteID); unix/libp2p/http2 expose one honest value for both roles.RemoteIDtoCorrelationID; addsauth/wrap_test.gofor the empty-handle guard.Second consumer found during implementation
vtermcorrelated a peer's/mosey/controlresize with its later/mosey/ptyattach also viaRemoteID. DemotingRemoteIDto a per-connection tag would have silently broken that over websocket.vtermnow readsCorrelationIDtoo (internalremote→correlationrename). The review only flaggedauth.Wrap; this was under-scoped.Safety
No wire/protocol change — the websocket
mosey-peer-<token>subprotocol and unix peercreds derivation are byte-identical; only where the value surfaces in Go moves. Fullgo build/go test ./...green.Design record
docs/adr/0004-stream-correlation-seam.md— granularity decision (per-dialer, not per-connection or per-identity), the link-not-grant contract, the fail-closed rule, per-backend unforgeability bar, and deferred known-limits (identity-map eviction, unix pid-reuse).CONTEXT.md— new Transport glossary section (Stream,CorrelationID,RemoteID).Produced via a
/grill-with-docssession.Notes for the reviewer
origin/main(83876a5).CONTEXT.mdanddocs/adr/do not yet exist upstream — they are being introduced by the parallel/grill-with-docssessions. This PR'sCONTEXT.mdtherefore also carries candidate refactor(walletsolana): keyless Source construction; export RPC caller seam #1's Capabilities/Auth sections (uncommitted elsewhere); only the Transport section and ADR 0004 are this PR's subject. ADR numbering was bumped 0002→0004 to avoid collision with the concurrent signing-session (0002) and moseynet (0003) sessions.