Skip to content

refactor(server): pull HubRouter back into server, delete dead wshub pkg [#2195 G1]#2218

Merged
KevinZhao merged 1 commit into
masterfrom
refactor/2195-wshub-deadiface
Jun 21, 2026
Merged

refactor(server): pull HubRouter back into server, delete dead wshub pkg [#2195 G1]#2218
KevinZhao merged 1 commit into
masterfrom
refactor/2195-wshub-deadiface

Conversation

@KevinZhao

Copy link
Copy Markdown
Owner

背景

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。其中:

  • 唯一 live 的是 HubRouter(14 方法),被 consumer.go:44type HubRouter = wshub.HubRouter 别名引用。
  • 另 5 个(MessageEnqueuer/CronView/ScratchOps/UploadOps/Auth)零 live 引用;且 wshub.MessageEnqueuer 已与 server 包同名 interface 漂移(缺 evictedID 返回值),是明确腐化证据。

改动

  • consumer.go:把 type-alias 替换为直接的 HubRouter interface 声明(14 方法逐字一致)。*session.Router 仍结构化满足;consumer_contract_test.go(var _ HubRouter = (*session.Router)(nil))守护不变。
  • 删除 internal/wshub/types.go(整个包)——5 个死接口随之移除。
  • 移除 server→internal/wshub 的 import 边。
  • 清理对已删包的 stale 注释:cronview.go(×2)、dashboard/cronview/cronview.gobackendid.go、lint 工具的 Phase-4 扫描假设。

验证

  • go build ./...go vetgofmt 全过
  • ✅ 两个硬 gate 通过:TestHubSharesServerNodesStateTestHubShutdown_LockOrderInvariant
  • ✅ 完整 internal/server -race(211s)+ session/cronview/backendid/dashboard/cron 全过
  • grep internal/wshub 全仓库无残留生产引用(仅说明性注释)
  • 不碰 Hub struct / 锁 / nodes

对抗性 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

…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.
@KevinZhao KevinZhao merged commit 28a9cf5 into master Jun 21, 2026
7 checks passed
@KevinZhao KevinZhao deleted the refactor/2195-wshub-deadiface branch June 21, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant