Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
503 changes: 319 additions & 184 deletions go/gen/compass/v1/comms.pb.go

Large diffs are not rendered by default.

48 changes: 46 additions & 2 deletions go/gen/compass/v1/compassv1connect/comms.connect.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go/internal/auth/admin_gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func classifyProcedure(procedure string) (privilege, bool) {
compassv1connect.CommsServiceSetChannelPolicyProcedure,
compassv1connect.CommsServiceGetRosterProcedure,
compassv1connect.CommsServiceUpdatePinnedBoardProcedure,
compassv1connect.CommsServiceOpenDMProcedure,
compassv1connect.CommsServiceSubscribeCommsProcedure:
return authenticatedOpen{}, true

Expand Down
65 changes: 65 additions & 0 deletions go/internal/comms/channel_mapping_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// The channel-kind discriminant at the store <-> proto edge (mapping.go
// channelKindToWire / channelKindFromWire). Both are pure functions of their
// argument, so the contract is fully observable with NO database — this file is
// untagged and runs on the default `go test` lane.
//
// GROUP_DM retirement (RIG-2962 T1): the kind is deprecated in place — never
// PRODUCED on either side. A DM widens by converting to a named CHANNEL, so no
// mapping arm may mint a GROUP_DM. The number stays reserved (tombstone), but a
// legacy or hostile GROUP_DM input collapses to a plain channel rather than
// round-tripping the retired kind.

package comms

import (
"testing"

compassv1 "github.com/RigelBuild/compass/go/gen/compass/v1"
"github.com/RigelBuild/compass/go/internal/store"
)

func TestChannelKindToWireNeverProducesGroupDM(t *testing.T) {
tests := []struct {
name string
kind store.ChannelKind
want compassv1.ChannelKind
}{
{"channel", store.ChannelKindChannel, compassv1.ChannelKind_CHANNEL_KIND_CHANNEL},
{"dm", store.ChannelKindDM, compassv1.ChannelKind_CHANNEL_KIND_DM},
{"retired group_dm collapses to channel", store.ChannelKindGroupDM, compassv1.ChannelKind_CHANNEL_KIND_CHANNEL},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := channelKindToWire(tt.kind)
if got != tt.want {
t.Fatalf("channelKindToWire(%v) = %v, want %v", tt.kind, got, tt.want)
}
if got == compassv1.ChannelKind_CHANNEL_KIND_GROUP_DM { //nolint:staticcheck // SA1019: deliberately references the retired GROUP_DM to assert it is never produced.
t.Fatalf("channelKindToWire produced retired GROUP_DM for %v", tt.kind)
}
})
}
}

func TestChannelKindFromWireNeverProducesGroupDM(t *testing.T) {
tests := []struct {
name string
kind compassv1.ChannelKind
want store.ChannelKind
}{
{"channel", compassv1.ChannelKind_CHANNEL_KIND_CHANNEL, store.ChannelKindChannel},
{"dm", compassv1.ChannelKind_CHANNEL_KIND_DM, store.ChannelKindDM},
{"retired group_dm collapses to channel", compassv1.ChannelKind_CHANNEL_KIND_GROUP_DM, store.ChannelKindChannel}, //nolint:staticcheck // SA1019: deliberately exercises the retired GROUP_DM input path.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := channelKindFromWire(tt.kind)
if got != tt.want {
t.Fatalf("channelKindFromWire(%v) = %v, want %v", tt.kind, got, tt.want)
}
if got == store.ChannelKindGroupDM {
t.Fatalf("channelKindFromWire produced retired GROUP_DM for %v", tt.kind)
}
})
}
}
15 changes: 15 additions & 0 deletions go/internal/comms/comms.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,21 @@ func (c *Comms) UpdatePinnedBoard(
return connect.NewResponse(&compassv1.UpdatePinnedBoardResponse{Channel: wire}), nil
}

// OpenDM resolves-or-creates the two-party DM channel between the caller and a
// peer, addressed by handle (RIG-2962). T1 lands the contract (proto + regen)
// proto-first; the real handler — caller/peer resolve, same-owner authz, the
// reserved-DM-group upsert, and the post-commit ChannelChanged emit — is the
// T3 leg (compass-agent-peer-dm design.md T3), which replaces this stub. Until
// then it returns CodeUnimplemented so *Comms satisfies the generated
// CommsServiceHandler (asserted with no Unimplemented embed) without pretending
// to serve a surface whose store legs (T2 dm.go) do not exist yet.
func (c *Comms) OpenDM(
_ context.Context,
_ *connect.Request[compassv1.OpenDMRequest],
) (*connect.Response[compassv1.OpenDMResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("comms: OpenDM not implemented until RIG-2962 T3"))
}

// applyBoardOp maps the request's op oneof to its store call: a plain pin
// (PinMessage, replace ""), a compare-and-swap repoint (PinMessage, replace set),
// or an unpin (UnpinMessage). An unset oneof is a malformed request
Expand Down
10 changes: 6 additions & 4 deletions go/internal/comms/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func channelKindToWire(k store.ChannelKind) compassv1.ChannelKind {
switch k {
case store.ChannelKindDM:
return compassv1.ChannelKind_CHANNEL_KIND_DM
case store.ChannelKindGroupDM:
return compassv1.ChannelKind_CHANNEL_KIND_GROUP_DM
default:
// GROUP_DM is retired (never produced; a DM converts to a named
// CHANNEL). A legacy kind=2 row renders as a plain channel.
return compassv1.ChannelKind_CHANNEL_KIND_CHANNEL
}
}
Expand Down Expand Up @@ -256,9 +256,11 @@ func channelKindFromWire(k compassv1.ChannelKind) store.ChannelKind {
switch k {
case compassv1.ChannelKind_CHANNEL_KIND_DM:
return store.ChannelKindDM
case compassv1.ChannelKind_CHANNEL_KIND_GROUP_DM:
return store.ChannelKindGroupDM
default:
// GROUP_DM is retired: a wire GROUP_DM (only a legacy/hostile input,
// never freshly produced) maps to a plain channel. The collapse itself
// is the sole retirement mechanism at this edge — the retired kind can
// never round-trip into the store.
return store.ChannelKindChannel
}
}
Expand Down
Loading
Loading