refactor(server): pull HubRouter back into server, delete dead wshub pkg [#2195 G1]#2218
Merged
Merged
Conversation
…pkg [#2195] G1 of the god-struct extraction RFC (docs/rfc/godstruct-extraction.md). internal/wshub was a Phase-4a interface-only shell: the 49-field Hub mirror skeleton was deleted in #1741, leaving 6 interfaces of which only HubRouter (14 methods) had a live consumer — internal/server/consumer.go aliased it via `type HubRouter = wshub.HubRouter`. The other five (MessageEnqueuer / CronView / ScratchOps / UploadOps / Auth) had ZERO live references, and wshub.MessageEnqueuer had already rotted out of sync with the real server-package MessageEnqueuer (missing the evictedID return value). Changes: - consumer.go: replace the type-alias with a direct HubRouter interface declaration (14 methods, verbatim). *session.Router still satisfies it structurally; consumer_contract_test.go (var _ HubRouter = (*session.Router)(nil)) guards it unchanged. - delete internal/wshub/types.go (the whole package) — the five dead interfaces go with it. - drop the server→internal/wshub import edge. - clean up stale comment references to the deleted package in cronview.go (×2), dashboard/cronview/cronview.go, backendid.go, and the lint tool's Phase-4 scan assumption. No behavior change, no Hub struct / lock / nodes touched. Both hard gates (TestHubSharesServerNodesState, TestHubShutdown_LockOrderInvariant) and the full internal/server -race suite pass; go build ./... green; no residual production reference to internal/wshub. Adversarial RFC review corrected three stale premises baked into the issues (no compiled field-count test exists; a SECOND hard gate hub_shared_state_test.go exists; handler-grouping conflicts with the existing server-split-phase4 plan) — see RFC §5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
god-struct 抽取 RFC 的 G1(
docs/rfc/godstruct-extraction.md,本 PR 一并加入)。这是经对抗性 review 验证为最隔离、零行为变更、与既有 server-split-phase4 计划无冲突的第一步。问题(#2195 选项②)
internal/wshub是 Phase-4a 遗留的接口空壳:49 字段的 Hub mirror 骨架已于 #1741 删除,只剩 6 个 interface。其中:HubRouter(14 方法),被consumer.go:44以type HubRouter = wshub.HubRouter别名引用。MessageEnqueuer/CronView/ScratchOps/UploadOps/Auth)零 live 引用;且wshub.MessageEnqueuer已与 server 包同名 interface 漂移(缺evictedID返回值),是明确腐化证据。改动
consumer.go:把 type-alias 替换为直接的HubRouterinterface 声明(14 方法逐字一致)。*session.Router仍结构化满足;consumer_contract_test.go(var _ HubRouter = (*session.Router)(nil))守护不变。internal/wshub/types.go(整个包)——5 个死接口随之移除。internal/wshub的 import 边。cronview.go(×2)、dashboard/cronview/cronview.go、backendid.go、lint 工具的 Phase-4 扫描假设。验证
go build ./...、go vet、gofmt全过TestHubSharesServerNodesState、TestHubShutdown_LockOrderInvariantinternal/server-race(211s)+session/cronview/backendid/dashboard/cron全过grep internal/wshub全仓库无残留生产引用(仅说明性注释)对抗性 review 留痕
RFC v1 经 3 视角对抗 review,订正了 issue 流传的三个错误前提:① 不存在编译期字段计数测试(实测 51 字段,文档 47/49 全 stale);② 存在第二个硬 gate
hub_shared_state_test.go(recon 初次漏掉);③ handler-grouping(原 Phase 1)与既有server-split-phase4-design.md否决方向冲突,已降级。详见 RFC §5。范围
本 PR 是 #2195 的 G1(选项②)。#2195 的选项①(Hub 子结构抽取 = RFC G3,高风险、需扩锁序 gate)留作后续 PR,故 Part of #2195,不 close。
Part of #2195
🤖 Generated with Claude Code