refactor(protocol): delete dead route origin, target validation, and catalogue helpers
RouteOrigin/valid/Validate and RemoteInventorySourceKey belonged to the old route model with zero remaining callers or tests. validateRemoteTarget and catalogue.CatalogTabs likewise have no caller anywhere in the tree.
- commit
- 5a12f4fd2661de6d03d318fbaff3337dcb289d48
- author
- brice · · 2026-09-23 01:54 UTC
- parent
- a54aa39
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +1 -44
M internal/protocol/catalogue/catalogue.go +1 -3
| @@ -6,7 +6,6 @@ import ( | |||
| 6 | 6 | "errors" | |
| 7 | 7 | "fmt" | |
| 8 | 8 | "math" | |
| 9 | - | "slices" | |
| 10 | 9 | "time" | |
| 11 | 10 | "unicode" | |
| 12 | 11 | "unicode/utf8" | |
| @@ -78,8 +77,7 @@ type RemoteCatalogSession struct { | |||
| 78 | 77 | Reason string `json:"reason,omitempty"` | |
| 79 | 78 | } | |
| 80 | 79 | ||
| 81 | - | func CatalogTabs(session RemoteCatalogSession) []RemoteCatalogTab { return slices.Clone(session.Tabs) } | |
| 82 | - | func CatalogTabCount(session RemoteCatalogSession) int { return len(session.Tabs) } | |
| 80 | + | func CatalogTabCount(session RemoteCatalogSession) int { return len(session.Tabs) } | |
| 83 | 81 | ||
| 84 | 82 | func SaturateUint16(n int) uint16 { | |
| 85 | 83 | if n <= 0 { | |
| @@ -6,7 +6,6 @@ import ( | |||||
| 6 | "errors" | 6 | "errors" | ||
| 7 | "fmt" | 7 | "fmt" | ||
| 8 | "math" | 8 | "math" | ||
| 9 | - | "slices" | |||
| 10 | "time" | 9 | "time" | ||
| 11 | "unicode" | 10 | "unicode" | ||
| 12 | "unicode/utf8" | 11 | "unicode/utf8" | ||
| @@ -78,8 +77,7 @@ type RemoteCatalogSession struct { | |||||
| 78 | Reason string `json:"reason,omitempty"` | 77 | Reason string `json:"reason,omitempty"` | ||
| 79 | } | 78 | } | ||
| 80 | 79 | ||||
| 81 | - | func CatalogTabs(session RemoteCatalogSession) []RemoteCatalogTab { return slices.Clone(session.Tabs) } | 80 | + | func CatalogTabCount(session RemoteCatalogSession) int { return len(session.Tabs) } |
| 82 | - | func CatalogTabCount(session RemoteCatalogSession) int { return len(session.Tabs) } | |||
| 83 | 81 | ||||
| 84 | func SaturateUint16(n int) uint16 { | 82 | func SaturateUint16(n int) uint16 { | ||
| 85 | if n <= 0 { | 83 | if n <= 0 { | ||
M internal/protocol/routes.go +0 -34
| @@ -1,8 +1,6 @@ | |||
| 1 | 1 | package protocol | |
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | - | "crypto/sha256" | |
| 5 | - | "encoding/hex" | |
| 6 | 4 | "errors" | |
| 7 | 5 | "fmt" | |
| 8 | 6 | "unicode" | |
| @@ -15,32 +13,6 @@ import ( | |||
| 15 | 13 | // strict route codecs while route values live in the semantic protocol. | |
| 16 | 14 | var ErrInvalidRouteWire = errors.New("invalid route wire message") | |
| 17 | 15 | ||
| 18 | - | // RouteOrigin identifies how a client reached a daemon. The origin is client | |
| 19 | - | // composition metadata, not an authority granted to the daemon. | |
| 20 | - | type RouteOrigin uint8 | |
| 21 | - | ||
| 22 | - | const ( | |
| 23 | - | RouteOriginLocal RouteOrigin = iota + 1 | |
| 24 | - | RouteOriginRemote | |
| 25 | - | RouteOriginDiscovery | |
| 26 | - | ) | |
| 27 | - | ||
| 28 | - | func (o RouteOrigin) valid() bool { | |
| 29 | - | switch o { | |
| 30 | - | case RouteOriginLocal, RouteOriginRemote, RouteOriginDiscovery: | |
| 31 | - | return true | |
| 32 | - | default: | |
| 33 | - | return false | |
| 34 | - | } | |
| 35 | - | } | |
| 36 | - | ||
| 37 | - | func (o RouteOrigin) Validate() error { | |
| 38 | - | if !o.valid() { | |
| 39 | - | return errors.New("invalid route origin") | |
| 40 | - | } | |
| 41 | - | return nil | |
| 42 | - | } | |
| 43 | - | ||
| 44 | 16 | // RouteKind identifies the kind of target represented by one display entry. | |
| 45 | 17 | type RouteKind uint8 | |
| 46 | 18 | ||
| @@ -287,12 +259,6 @@ func (r RouteRetired) Validate() error { | |||
| 287 | 259 | return nil | |
| 288 | 260 | } | |
| 289 | 261 | ||
| 290 | - | // RemoteInventorySourceKey identifies a configured endpoint without disclosing it. | |
| 291 | - | func RemoteInventorySourceKey(endpoint string) string { | |
| 292 | - | sum := sha256.Sum256([]byte("vev-inventory-remote\x00" + endpoint)) | |
| 293 | - | return NavigationInventoryRemoteSourcePrefix + hex.EncodeToString(sum[:12]) | |
| 294 | - | } | |
| 295 | - | ||
| 296 | 262 | // RouteAttentionSubscription is the bounded, client-owned mapping a daemon | |
| 297 | 263 | // uses to resolve live attention and retire authoritatively absent lifecycles. | |
| 298 | 264 | type RouteAttentionSubscription struct { | |
| @@ -1,8 +1,6 @@ | |||||
| 1 | package protocol | 1 | package protocol | ||
| 2 | 2 | ||||
| 3 | import ( | 3 | import ( | ||
| 4 | - | "crypto/sha256" | |||
| 5 | - | "encoding/hex" | |||
| 6 | "errors" | 4 | "errors" | ||
| 7 | "fmt" | 5 | "fmt" | ||
| 8 | "unicode" | 6 | "unicode" | ||
| @@ -15,32 +13,6 @@ import ( | |||||
| 15 | // strict route codecs while route values live in the semantic protocol. | 13 | // strict route codecs while route values live in the semantic protocol. | ||
| 16 | var ErrInvalidRouteWire = errors.New("invalid route wire message") | 14 | var ErrInvalidRouteWire = errors.New("invalid route wire message") | ||
| 17 | 15 | ||||
| 18 | - | // RouteOrigin identifies how a client reached a daemon. The origin is client | |||
| 19 | - | // composition metadata, not an authority granted to the daemon. | |||
| 20 | - | type RouteOrigin uint8 | |||
| 21 | - | ||||
| 22 | - | const ( | |||
| 23 | - | RouteOriginLocal RouteOrigin = iota + 1 | |||
| 24 | - | RouteOriginRemote | |||
| 25 | - | RouteOriginDiscovery | |||
| 26 | - | ) | |||
| 27 | - | ||||
| 28 | - | func (o RouteOrigin) valid() bool { | |||
| 29 | - | switch o { | |||
| 30 | - | case RouteOriginLocal, RouteOriginRemote, RouteOriginDiscovery: | |||
| 31 | - | return true | |||
| 32 | - | default: | |||
| 33 | - | return false | |||
| 34 | - | } | |||
| 35 | - | } | |||
| 36 | - | ||||
| 37 | - | func (o RouteOrigin) Validate() error { | |||
| 38 | - | if !o.valid() { | |||
| 39 | - | return errors.New("invalid route origin") | |||
| 40 | - | } | |||
| 41 | - | return nil | |||
| 42 | - | } | |||
| 43 | - | ||||
| 44 | // RouteKind identifies the kind of target represented by one display entry. | 16 | // RouteKind identifies the kind of target represented by one display entry. | ||
| 45 | type RouteKind uint8 | 17 | type RouteKind uint8 | ||
| 46 | 18 | ||||
| @@ -287,12 +259,6 @@ func (r RouteRetired) Validate() error { | |||||
| 287 | return nil | 259 | return nil | ||
| 288 | } | 260 | } | ||
| 289 | 261 | ||||
| 290 | - | // RemoteInventorySourceKey identifies a configured endpoint without disclosing it. | |||
| 291 | - | func RemoteInventorySourceKey(endpoint string) string { | |||
| 292 | - | sum := sha256.Sum256([]byte("vev-inventory-remote\x00" + endpoint)) | |||
| 293 | - | return NavigationInventoryRemoteSourcePrefix + hex.EncodeToString(sum[:12]) | |||
| 294 | - | } | |||
| 295 | - | ||||
| 296 | // RouteAttentionSubscription is the bounded, client-owned mapping a daemon | 262 | // RouteAttentionSubscription is the bounded, client-owned mapping a daemon | ||
| 297 | // uses to resolve live attention and retire authoritatively absent lifecycles. | 263 | // uses to resolve live attention and retire authoritatively absent lifecycles. | ||
| 298 | type RouteAttentionSubscription struct { | 264 | type RouteAttentionSubscription struct { | ||
M internal/protocol/session.go +0 -7
| @@ -529,10 +529,3 @@ func ValidateAttachTarget(m AttachTarget) error { | |||
| 529 | 529 | } | |
| 530 | 530 | return nil | |
| 531 | 531 | } | |
| 532 | - | ||
| 533 | - | func validateRemoteTarget(target domain.RemoteSessionTarget) error { | |
| 534 | - | if len(target.Endpoint) > math.MaxUint16 || len(target.DisplayOrigin) > math.MaxUint16 || len(target.SessionName) > math.MaxUint16 || len(target.LiveTabID) > math.MaxUint16 || len(target.StoppedTab.RawName) > math.MaxUint16 { | |
| 535 | - | return errors.New("remote target string too long") | |
| 536 | - | } | |
| 537 | - | return target.Validate() | |
| 538 | - | } | |
| @@ -529,10 +529,3 @@ func ValidateAttachTarget(m AttachTarget) error { | |||||
| 529 | } | 529 | } | ||
| 530 | return nil | 530 | return nil | ||
| 531 | } | 531 | } | ||
| 532 | - | ||||
| 533 | - | func validateRemoteTarget(target domain.RemoteSessionTarget) error { | |||
| 534 | - | if len(target.Endpoint) > math.MaxUint16 || len(target.DisplayOrigin) > math.MaxUint16 || len(target.SessionName) > math.MaxUint16 || len(target.LiveTabID) > math.MaxUint16 || len(target.StoppedTab.RawName) > math.MaxUint16 { | |||
| 535 | - | return errors.New("remote target string too long") | |||
| 536 | - | } | |||
| 537 | - | return target.Validate() | |||
| 538 | - | } | |||