Remove dead Go types and event code
- Delete unused Grant struct (persona-era, zero references) - Delete CompositeModelKey (never called) - Remove dead comment-only type stubs (NoteGraph, ProjectChannel, etc.) - Remove empty Chat/Channel event sections from route table - Remove dead chat.typing/channel.typing condition in WS subscriber - Update bus doc examples and test labels to use real event names Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,10 +43,10 @@ func (b *Bus) SetBroadcastHook(fn func(Event)) {
|
||||
//
|
||||
// Patterns:
|
||||
//
|
||||
// "chat.message.abc123" — exact match
|
||||
// "chat.message.*" — wildcard: matches chat.message.{anything}
|
||||
// "chat.*" — wildcard: matches chat.{anything}
|
||||
// "*" — matches all events
|
||||
// "workflow.assigned.abc123" — exact match
|
||||
// "workflow.assigned.*" — wildcard: matches workflow.assigned.{anything}
|
||||
// "workflow.*" — wildcard: matches workflow.{anything}
|
||||
// "*" — matches all events
|
||||
func (b *Bus) Subscribe(pattern string, handler Handler) func() {
|
||||
b.mu.Lock()
|
||||
b.seq++
|
||||
|
||||
@@ -12,13 +12,13 @@ func TestMatch(t *testing.T) {
|
||||
label, pattern string
|
||||
want bool
|
||||
}{
|
||||
{"chat.message.abc", "chat.message.abc", true},
|
||||
{"chat.message.abc", "chat.message.*", true},
|
||||
{"chat.message.abc", "chat.*", true},
|
||||
{"chat.message.abc", "*", true},
|
||||
{"chat.message.abc", "chat.message.xyz", false},
|
||||
{"chat.message.abc", "channel.message.*", false},
|
||||
{"chat.message.abc", "chat.message", false},
|
||||
{"workflow.assigned.abc", "workflow.assigned.abc", true},
|
||||
{"workflow.assigned.abc", "workflow.assigned.*", true},
|
||||
{"workflow.assigned.abc", "workflow.*", true},
|
||||
{"workflow.assigned.abc", "*", true},
|
||||
{"workflow.assigned.abc", "workflow.assigned.xyz", false},
|
||||
{"workflow.assigned.abc", "notification.new.*", false},
|
||||
{"workflow.assigned.abc", "workflow.assigned", false},
|
||||
{"ping", "ping", true},
|
||||
{"ping", "pong", false},
|
||||
{"plugin.hook.pre_completion", "plugin.hook.*", true},
|
||||
@@ -37,12 +37,12 @@ func TestBusPublishExact(t *testing.T) {
|
||||
bus := NewBus()
|
||||
var count int32
|
||||
|
||||
bus.Subscribe("chat.message.abc", func(e Event) {
|
||||
bus.Subscribe("workflow.assigned.abc", func(e Event) {
|
||||
atomic.AddInt32(&count, 1)
|
||||
})
|
||||
|
||||
bus.Publish(Event{Label: "chat.message.abc", Payload: json.RawMessage(`{}`)})
|
||||
bus.Publish(Event{Label: "chat.message.xyz", Payload: json.RawMessage(`{}`)})
|
||||
bus.Publish(Event{Label: "workflow.assigned.abc", Payload: json.RawMessage(`{}`)})
|
||||
bus.Publish(Event{Label: "workflow.assigned.xyz", Payload: json.RawMessage(`{}`)})
|
||||
|
||||
if atomic.LoadInt32(&count) != 1 {
|
||||
t.Errorf("expected 1 dispatch, got %d", count)
|
||||
@@ -53,13 +53,13 @@ func TestBusPublishWildcard(t *testing.T) {
|
||||
bus := NewBus()
|
||||
var count int32
|
||||
|
||||
bus.Subscribe("chat.message.*", func(e Event) {
|
||||
bus.Subscribe("workflow.assigned.*", func(e Event) {
|
||||
atomic.AddInt32(&count, 1)
|
||||
})
|
||||
|
||||
bus.Publish(Event{Label: "chat.message.abc", Payload: json.RawMessage(`{}`)})
|
||||
bus.Publish(Event{Label: "chat.message.xyz", Payload: json.RawMessage(`{}`)})
|
||||
bus.Publish(Event{Label: "chat.typing.abc", Payload: json.RawMessage(`{}`)})
|
||||
bus.Publish(Event{Label: "workflow.assigned.abc", Payload: json.RawMessage(`{}`)})
|
||||
bus.Publish(Event{Label: "workflow.assigned.xyz", Payload: json.RawMessage(`{}`)})
|
||||
bus.Publish(Event{Label: "workflow.claimed.abc", Payload: json.RawMessage(`{}`)})
|
||||
|
||||
if atomic.LoadInt32(&count) != 2 {
|
||||
t.Errorf("expected 2 dispatches, got %d", count)
|
||||
@@ -91,7 +91,7 @@ func TestBusGlobalWildcard(t *testing.T) {
|
||||
atomic.AddInt32(&count, 1)
|
||||
})
|
||||
|
||||
bus.Publish(Event{Label: "chat.message.abc", Payload: json.RawMessage(`{}`)})
|
||||
bus.Publish(Event{Label: "workflow.assigned.abc", Payload: json.RawMessage(`{}`)})
|
||||
bus.Publish(Event{Label: "system.notify", Payload: json.RawMessage(`{}`)})
|
||||
bus.Publish(Event{Label: "plugin.hook.pre_completion", Payload: json.RawMessage(`{}`)})
|
||||
|
||||
@@ -105,8 +105,6 @@ func TestRouteFor(t *testing.T) {
|
||||
label string
|
||||
want Direction
|
||||
}{
|
||||
{"chat.message.abc", DirLocal}, // chat routes removed in v0.1.0
|
||||
{"chat.typing.abc", DirLocal}, // chat routes removed in v0.1.0
|
||||
{"system.notify", DirToClient},
|
||||
{"plugin.hook.pre_completion", DirLocal},
|
||||
{"internal.db.write", DirLocal},
|
||||
|
||||
@@ -35,10 +35,6 @@ const (
|
||||
// routeTable defines the default routing for known event prefixes.
|
||||
// Events not listed default to DirLocal (server-only).
|
||||
var routeTable = map[string]Direction{
|
||||
// Chat events
|
||||
|
||||
// Channel events
|
||||
|
||||
// User/presence
|
||||
"user.presence": DirToClient,
|
||||
"user.status": DirToClient,
|
||||
|
||||
@@ -250,13 +250,6 @@ func (c *Conn) subscribeToBus() {
|
||||
return
|
||||
}
|
||||
|
||||
// Don't echo typing events back to the sender
|
||||
if strings.HasPrefix(e.Label, "chat.typing.") || strings.HasPrefix(e.Label, "channel.typing.") {
|
||||
if e.SenderID == c.userID && e.ConnID == c.id {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Room filtering: if event has a room, only send if conn is in that room
|
||||
if e.Room != "" && !c.rooms[e.Room] {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user