MCPcopy Create free account
hub / github.com/compozy/agh / DirectRoomIdentity

Function DirectRoomIdentity

internal/network/validate.go:219–242  ·  view source on GitHub ↗

DirectRoomIdentity derives the stable two-party direct room identity scoped to one workspace channel.

(
	workspaceID string,
	channel string,
	localPeer string,
	remotePeer string,
)

Source from the content-addressed store, hash-verified

217
218// DirectRoomIdentity derives the stable two-party direct room identity scoped to one workspace channel.
219func DirectRoomIdentity(
220 workspaceID string,
221 channel string,
222 localPeer string,
223 remotePeer string,
224) (string, string, string, error) {
225 trimmedWorkspaceID := strings.TrimSpace(workspaceID)
226 if err := ValidateWorkspaceID(trimmedWorkspaceID); err != nil {
227 return "", "", "", err
228 }
229 trimmedChannel := strings.TrimSpace(channel)
230 if err := ValidateChannel(trimmedChannel); err != nil {
231 return "", "", "", err
232 }
233 peerA, peerB, err := NormalizeDirectRoomPeers(localPeer, remotePeer)
234 if err != nil {
235 return "", "", "", err
236 }
237
238 sum := sha256.Sum256([]byte(
239 "agh-network/direct-room/v0\x00" + trimmedWorkspaceID + "\x00" + trimmedChannel + "\x00" + peerA + "\x00" + peerB,
240 ))
241 return "direct_" + hex.EncodeToString(sum[:])[:32], peerA, peerB, nil
242}
243
244// ValidateDirectRoomBinding proves that an existing direct room row matches
245// the deterministic identity for its workspace/channel-scoped peer pair.

Calls 3

ValidateWorkspaceIDFunction · 0.85
ValidateChannelFunction · 0.85
NormalizeDirectRoomPeersFunction · 0.85