Skip to content

refactor(hub): 拆分 agent_team 仓储并下沉 SafeGo,清偿 lint 欠账 - #1670

Merged
DeliciousBuding merged 1 commit into
masterfrom
refactor/hub-structure
Aug 13, 2026
Merged

refactor(hub): 拆分 agent_team 仓储并下沉 SafeGo,清偿 lint 欠账#1670
DeliciousBuding merged 1 commit into
masterfrom
refactor/hub-structure

Conversation

@DeliciousBuding

Copy link
Copy Markdown
Collaborator

Summary

hub-server 三块低风险结构拆解(探查报告中 hub Top 4/8 项),零行为变化:

  1. repository/agent_team.go 564 行 → 7 个聚合文件agent_team_teams/runs/assignments/tasks/artifacts/events/usage.go。纯文件切分,声明级脚本迁移 + 49/49 对账,无丢失无重复。
  2. middleware.SafeGo 下沉 internal/safego 叶子包:解除 service 层(agent_dispatch)对 HTTP 中间件包的依赖——internal/service/ 现已完全不再 import middleware(探查报告中的分层违规 Top 8)。补 2 个 panic 恢复冒烟测试(此前无直接覆盖)。
  3. lint 欠账清偿:ratchet 本地由 fail 转 PASS(43 findings 全部 baseline 注册):
    • 修复 5 处 QF1008(Dialector 嵌入选择器):usage/audit/agent/message×2。其中 audit/message 是拆分降低同文本 finding 数后从 max-same-issues 封顶下浮出的存量 findings(master 上被 agent_team.go 的同类 findings 遮蔽)
    • 重命名 client_auth_test.go 夹具常量 tokenHashblacklistKey,消除 3 处 G101 误报(master 上 ratchet 已红,本 PR 顺带还清)

Test plan

  • go build / go vet / staticcheck 全绿
  • go test ./... -count=1 -short -race -coverprofile 通过(CI 同款)
  • 门禁:verify-hub-layering / verify-hub-pure-packages / verify-outbound-client-hygiene / verify-dto-contract / verify-openapi-contract / verify-config-domain-ssot / verify-hub-lint-ratchet 全部 PASS
  • 声明级对账脚本:49/49 无丢失、无重复、无注释块错位

后续队列

  • service/agent_dispatch.go 8 文件散装 → dispatchsvc 包收敛(hub Top 1)
  • app/events.go pending 重放下沉(hub Top 2)
  • ws 类型上渗治理(hub Top 3)

三块低风险结构拆解,零行为变化:

1. repository/agent_team.go(564 行、49 个声明)按聚合拆为 7 个文件:
   teams / runs / assignments / tasks / artifacts / events / usage。
   纯文件切分,声明对账 49/49 无丢失无重复。

2. middleware.SafeGo 下沉到 internal/safego 叶子包:解除 service 层
   (agent_dispatch)对 HTTP 中间件包的依赖,service 目录现已不再
   import middleware。新增 safego 冒烟测试(panic 恢复路径此前无直接
   覆盖)。

3. 清偿 lint 欠账(ratchet 由 fail 转 PASS,43 findings 全部
   baseline 注册):
   - 修复 5 处 QF1008(Dialector 嵌入选择器):agent_team_usage /
     audit / agent / message 两处——其中 audit/message 是拆分后从
     max-same-issues 封顶下浮出的存量 findings
   - 重命名 client_auth_test.go 测试夹具常量 tokenHash → blacklistKey,
     消除 3 处 G101 硬编码凭据误报

验证:go build/vet/staticcheck 全绿;go test ./... -short -race 通过;
verify-hub-layering / verify-hub-pure-packages / outbound-client-hygiene /
dto-contract / openapi-contract / config-domain-ssot / hub-lint-ratchet
全部 PASS。

Co-authored-by: Cursor <cursor@vectorcontrol.tech>
Copilot AI lite review requested due to automatic review settings August 13, 2026 03:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@DeliciousBuding, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 104 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 312ff3c5-595f-493c-b670-ecdd84d40dea

📥 Commits

Reviewing files that changed from the base of the PR and between b49c40c and 24b5de3.

📒 Files selected for processing (16)
  • hub-server/internal/cache/client_auth_test.go
  • hub-server/internal/handler/ws.go
  • hub-server/internal/repository/agent.go
  • hub-server/internal/repository/agent_team.go
  • hub-server/internal/repository/agent_team_artifacts.go
  • hub-server/internal/repository/agent_team_assignments.go
  • hub-server/internal/repository/agent_team_events.go
  • hub-server/internal/repository/agent_team_runs.go
  • hub-server/internal/repository/agent_team_tasks.go
  • hub-server/internal/repository/agent_team_teams.go
  • hub-server/internal/repository/agent_team_usage.go
  • hub-server/internal/repository/audit.go
  • hub-server/internal/repository/message.go
  • hub-server/internal/safego/safego.go
  • hub-server/internal/safego/safego_test.go
  • hub-server/internal/service/agent_dispatch.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@DeliciousBuding
DeliciousBuding merged commit ca41223 into master Aug 13, 2026
21 checks passed
@DeliciousBuding
DeliciousBuding deleted the refactor/hub-structure branch August 13, 2026 03:57
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.

2 participants