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:
|
// Patterns:
|
||||||
//
|
//
|
||||||
// "chat.message.abc123" — exact match
|
// "workflow.assigned.abc123" — exact match
|
||||||
// "chat.message.*" — wildcard: matches chat.message.{anything}
|
// "workflow.assigned.*" — wildcard: matches workflow.assigned.{anything}
|
||||||
// "chat.*" — wildcard: matches chat.{anything}
|
// "workflow.*" — wildcard: matches workflow.{anything}
|
||||||
// "*" — matches all events
|
// "*" — matches all events
|
||||||
func (b *Bus) Subscribe(pattern string, handler Handler) func() {
|
func (b *Bus) Subscribe(pattern string, handler Handler) func() {
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
b.seq++
|
b.seq++
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ func TestMatch(t *testing.T) {
|
|||||||
label, pattern string
|
label, pattern string
|
||||||
want bool
|
want bool
|
||||||
}{
|
}{
|
||||||
{"chat.message.abc", "chat.message.abc", true},
|
{"workflow.assigned.abc", "workflow.assigned.abc", true},
|
||||||
{"chat.message.abc", "chat.message.*", true},
|
{"workflow.assigned.abc", "workflow.assigned.*", true},
|
||||||
{"chat.message.abc", "chat.*", true},
|
{"workflow.assigned.abc", "workflow.*", true},
|
||||||
{"chat.message.abc", "*", true},
|
{"workflow.assigned.abc", "*", true},
|
||||||
{"chat.message.abc", "chat.message.xyz", false},
|
{"workflow.assigned.abc", "workflow.assigned.xyz", false},
|
||||||
{"chat.message.abc", "channel.message.*", false},
|
{"workflow.assigned.abc", "notification.new.*", false},
|
||||||
{"chat.message.abc", "chat.message", false},
|
{"workflow.assigned.abc", "workflow.assigned", false},
|
||||||
{"ping", "ping", true},
|
{"ping", "ping", true},
|
||||||
{"ping", "pong", false},
|
{"ping", "pong", false},
|
||||||
{"plugin.hook.pre_completion", "plugin.hook.*", true},
|
{"plugin.hook.pre_completion", "plugin.hook.*", true},
|
||||||
@@ -37,12 +37,12 @@ func TestBusPublishExact(t *testing.T) {
|
|||||||
bus := NewBus()
|
bus := NewBus()
|
||||||
var count int32
|
var count int32
|
||||||
|
|
||||||
bus.Subscribe("chat.message.abc", func(e Event) {
|
bus.Subscribe("workflow.assigned.abc", func(e Event) {
|
||||||
atomic.AddInt32(&count, 1)
|
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: "chat.message.xyz", Payload: json.RawMessage(`{}`)})
|
bus.Publish(Event{Label: "workflow.assigned.xyz", Payload: json.RawMessage(`{}`)})
|
||||||
|
|
||||||
if atomic.LoadInt32(&count) != 1 {
|
if atomic.LoadInt32(&count) != 1 {
|
||||||
t.Errorf("expected 1 dispatch, got %d", count)
|
t.Errorf("expected 1 dispatch, got %d", count)
|
||||||
@@ -53,13 +53,13 @@ func TestBusPublishWildcard(t *testing.T) {
|
|||||||
bus := NewBus()
|
bus := NewBus()
|
||||||
var count int32
|
var count int32
|
||||||
|
|
||||||
bus.Subscribe("chat.message.*", func(e Event) {
|
bus.Subscribe("workflow.assigned.*", func(e Event) {
|
||||||
atomic.AddInt32(&count, 1)
|
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: "chat.message.xyz", Payload: json.RawMessage(`{}`)})
|
bus.Publish(Event{Label: "workflow.assigned.xyz", Payload: json.RawMessage(`{}`)})
|
||||||
bus.Publish(Event{Label: "chat.typing.abc", Payload: json.RawMessage(`{}`)})
|
bus.Publish(Event{Label: "workflow.claimed.abc", Payload: json.RawMessage(`{}`)})
|
||||||
|
|
||||||
if atomic.LoadInt32(&count) != 2 {
|
if atomic.LoadInt32(&count) != 2 {
|
||||||
t.Errorf("expected 2 dispatches, got %d", count)
|
t.Errorf("expected 2 dispatches, got %d", count)
|
||||||
@@ -91,7 +91,7 @@ func TestBusGlobalWildcard(t *testing.T) {
|
|||||||
atomic.AddInt32(&count, 1)
|
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: "system.notify", Payload: json.RawMessage(`{}`)})
|
||||||
bus.Publish(Event{Label: "plugin.hook.pre_completion", 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
|
label string
|
||||||
want Direction
|
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},
|
{"system.notify", DirToClient},
|
||||||
{"plugin.hook.pre_completion", DirLocal},
|
{"plugin.hook.pre_completion", DirLocal},
|
||||||
{"internal.db.write", DirLocal},
|
{"internal.db.write", DirLocal},
|
||||||
|
|||||||
@@ -35,10 +35,6 @@ const (
|
|||||||
// routeTable defines the default routing for known event prefixes.
|
// routeTable defines the default routing for known event prefixes.
|
||||||
// Events not listed default to DirLocal (server-only).
|
// Events not listed default to DirLocal (server-only).
|
||||||
var routeTable = map[string]Direction{
|
var routeTable = map[string]Direction{
|
||||||
// Chat events
|
|
||||||
|
|
||||||
// Channel events
|
|
||||||
|
|
||||||
// User/presence
|
// User/presence
|
||||||
"user.presence": DirToClient,
|
"user.presence": DirToClient,
|
||||||
"user.status": DirToClient,
|
"user.status": DirToClient,
|
||||||
|
|||||||
@@ -250,13 +250,6 @@ func (c *Conn) subscribeToBus() {
|
|||||||
return
|
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
|
// Room filtering: if event has a room, only send if conn is in that room
|
||||||
if e.Room != "" && !c.rooms[e.Room] {
|
if e.Room != "" && !c.rooms[e.Room] {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -81,19 +81,6 @@ type TeamMember struct {
|
|||||||
UserRole string `json:"user_role,omitempty"`
|
UserRole string `json:"user_role,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// =========================================
|
|
||||||
// GRANTS
|
|
||||||
// =========================================
|
|
||||||
|
|
||||||
type Grant struct {
|
|
||||||
ID string `json:"id" db:"id"`
|
|
||||||
PersonaID string `json:"persona_id" db:"persona_id"`
|
|
||||||
GrantType string `json:"grant_type" db:"grant_type"`
|
|
||||||
GrantRef string `json:"grant_ref" db:"grant_ref"`
|
|
||||||
Config JSONMap `json:"config,omitempty" db:"config"`
|
|
||||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PLATFORM POLICIES
|
// PLATFORM POLICIES
|
||||||
|
|
||||||
var PolicyDefaults = map[string]string{
|
var PolicyDefaults = map[string]string{
|
||||||
@@ -106,26 +93,6 @@ var PolicyDefaults = map[string]string{
|
|||||||
"default_model": "",
|
"default_model": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
// USER MODEL SETTINGS
|
|
||||||
|
|
||||||
// HiddenEntry identifies a model+provider pair for bulk visibility operations.
|
|
||||||
// CompositeModelKey builds the composite key used for per-provider model preferences.
|
|
||||||
func CompositeModelKey(providerConfigID, modelID string) string {
|
|
||||||
return providerConfigID + ":" + modelID
|
|
||||||
}
|
|
||||||
|
|
||||||
// CHANNELS
|
|
||||||
|
|
||||||
// SESSION PARTICIPANTS (v0.24.3)
|
|
||||||
|
|
||||||
// SessionParticipant is an ephemeral identity for anonymous workflow
|
|
||||||
// channel visitors. Scoped to a single channel, no users row required.
|
|
||||||
// MESSAGES
|
|
||||||
|
|
||||||
// CHANNEL PARTICIPANTS, MODELS, CURSORS
|
|
||||||
|
|
||||||
// PERSONA GROUPS (v0.23.0)
|
|
||||||
|
|
||||||
// HandleFromName generates a URL-safe @mention handle from a display name.
|
// HandleFromName generates a URL-safe @mention handle from a display name.
|
||||||
// "Veronica Sharpe" → "veronica-sharpe"
|
// "Veronica Sharpe" → "veronica-sharpe"
|
||||||
func HandleFromName(name string) string {
|
func HandleFromName(name string) string {
|
||||||
@@ -150,26 +117,6 @@ func HandleFromName(name string) string {
|
|||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
// ORGANIZATION
|
|
||||||
|
|
||||||
// ProjectPatch holds optional fields for updating a project.
|
|
||||||
// ProjectChannel represents a channel's membership in a project.
|
|
||||||
// ProjectKB represents a KB's association with a project.
|
|
||||||
// ProjectNote represents a note's association with a project.
|
|
||||||
// NOTES
|
|
||||||
|
|
||||||
// NoteLink represents a directed link extracted from [[wikilink]] syntax.
|
|
||||||
// ExportNoteLink is a note_link with source_note_id included (for export).
|
|
||||||
// NoteLinkResult represents a backlink — a note that links to a given note.
|
|
||||||
// NoteGraphNode is a lightweight note representation for graph display.
|
|
||||||
// NoteGraphEdge is a resolved link between two notes.
|
|
||||||
// NoteGraphDangling is an unresolved [[link]] reference.
|
|
||||||
// NoteGraph is the full graph topology for a user's notes.
|
|
||||||
// ATTACHMENTS
|
|
||||||
|
|
||||||
// FILES
|
|
||||||
|
|
||||||
// FileOrigin constants
|
|
||||||
// =========================================
|
// =========================================
|
||||||
// AUDIT LOG
|
// AUDIT LOG
|
||||||
// =========================================
|
// =========================================
|
||||||
@@ -187,14 +134,6 @@ type AuditEntry struct {
|
|||||||
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
CreatedAt time.Time `json:"created_at" db:"created_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// USAGE TRACKING
|
|
||||||
|
|
||||||
// MODEL PRICING
|
|
||||||
|
|
||||||
// VIEW MODELS (computed, not stored)
|
|
||||||
|
|
||||||
// UserModel is the view model returned by the capability resolver.
|
|
||||||
// Combines catalog entries + Personas for the frontend.
|
|
||||||
// =========================================
|
// =========================================
|
||||||
// JSON HELPERS
|
// JSON HELPERS
|
||||||
// =========================================
|
// =========================================
|
||||||
|
|||||||
Reference in New Issue
Block a user