Skip to content

chore(cleanup): 审计收口第三波——edge 输入面 / hub 死代码·P3 三修 / 孤儿脚本 / 文档预算 - #2151

Merged
DeliciousBuding merged 1 commit into
masterfrom
chore/cleanup-round-9
Aug 31, 2026
Merged

chore(cleanup): 审计收口第三波——edge 输入面 / hub 死代码·P3 三修 / 孤儿脚本 / 文档预算#2151
DeliciousBuding merged 1 commit into
masterfrom
chore/cleanup-round-9

Conversation

@DeliciousBuding

Copy link
Copy Markdown
Collaborator

来自 4 个静态审计 lane(hub/edge/frontend/docs)的批量收口,全部为低风险切片:\n\n## 做了什么\n- edge:README「Key Runtime Inputs」补齐 12 个 flag/env 行;debug 端点鉴权文档改为 deny-all fail-closed(与 server_auth.go 实现一致);删除零引用 internal/diff 整包\n- hub P3:requireMember 传播 GetActiveMember 错误(DB 抖动不再伪装成权限误判);device.Register 透传请求 ctx;seqalloc 每会话锁表改引用计数 GC(不再随 session 总数无限增长)\n- hub P1 死代码:删除 16 处零引用导出符号(UpdatePassword*/GetSecret/BackfillTeamRunTokenUsage/StopWSIPRateLimiter/6 个仓库层零调用函数/5 个 service 层死方法/3 个 errcode 死码)+ 修正 4 处过时注释(含 #2124 遗留的 seq_id 契约指针)\n- scripts:删除 14 个零引用孤儿脚本(审计发现 13 个 + 连带孤儿 verify-token-dance-id-login-readiness.py)及 .env.example 对应段落\n- docs:11-protocol-capability-mapping 精简 205→200 行并修正「#2065 待合入」过期注记;verify-doc-ssot.py 为 10/11/known-flaky/ux-benchmark/component-acceptance* 登记行数预算\n\n## 本地验证(L0)\n- hub: go vet ./... + go test ./... -short -count=1 全绿(0 FAIL)\n- edge: go test ./edge-server/... -short -count=1 全绿\n- verify-doc-ssot.py / verify-ci-gates.py / verify-doc-entrypoints.Tests.py / verify-ci-gates.Tests.py / verify-oidc-code-ssot.Tests.py 全 OK\n- git diff --check 干净\n\n## 未做 / 留后续\n- #2136 P2(truncated/hasMore 信号、搜索/agent-team 分页 P2)、#2099 locale 审计(下一轮)、#1663(上游无修复版,持续跟踪)\n- edge decision_loop / skills watcher 大块死代码、desktop settings 死键、web 无消费者 namespace:留后续轮次

@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d912033c-4627-4677-b417-71de82c7a407

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

- edge: README Key Runtime Inputs 补 12 个 flag/env 行并修正 debug 端点鉴权文档(deny-all fail-closed,与 server_auth.go 一致);删除零引用 internal/diff 整包
- hub: requireMember 传播 GetActiveMember 错误(不再零值 role 误判);device.Register 透传请求 ctx(不再 context.Background);seqalloc 锁表改引用计数 GC(不再随 session 无限增长)
- hub: 删除 16 处零引用导出符号(UpdatePassword*/GetSecret/Backfill*/StopWSIPRateLimiter/仓库层 6 个零调用函数/service 层 5 个死方法/errcode 3 个死码)+ 修正 4 处过时注释
- scripts: 删除 14 个零引用孤儿脚本(13 个审计发现 + 连带 verify-token-dance-id-login-readiness.py)及 .env.example 对应段落
- docs: 11-protocol-capability-mapping 精简至 200 行并修 #2065 已合入注记;verify-doc-ssot 为 10/11/known-flaky/ux-benchmark/component-acceptance* 登记行数预算

Co-authored-by: Cursor <cursor@vectorcontrol.tech>
@DeliciousBuding
DeliciousBuding merged commit ebc2525 into master Aug 31, 2026
44 checks passed
@DeliciousBuding
DeliciousBuding deleted the chore/cleanup-round-9 branch August 31, 2026 18:51
DeliciousBuding added a commit that referenced this pull request Sep 3, 2026
….ts 与 index.ts 不再点名 #2151 已删除的 edge-server/internal/diff(改为陈述 TS 侧实现、无 Go 对应物,并指出现存 Go 侧只有 surfacing_diff.go 生成器与 diff_apply.go 应用器);normalizeEdgeEvents.test.ts 注释改为真实发射点 parser_ndjson_parse_msg.go:29,68(事件名常量 orchestration/contracts.go:163);vitest.config.ts 删掉不存在的 src/mock.ts 覆盖排除项及其编造的理由注释;normalizeHubMessages.ts pin 溯源注释重写为实况(REST 消费方 desktop useHubPinnedMessages / web useWebWorkbenchModel,WS 帧驱动 pinMap store,结论 HubMessage.pinned 不加保留) (#2246)

Co-authored-by: Cursor <cursor@vectorcontrol.tech>
DeliciousBuding added a commit that referenced this pull request Sep 3, 2026
….ts 与 index.ts 不再点名 #2151 已删除的 edge-server/internal/diff(改为陈述 TS 侧实现、无 Go 对应物,并指出现存 Go 侧只有 surfacing_diff.go 生成器与 diff_apply.go 应用器);normalizeEdgeEvents.test.ts 注释改为真实发射点 parser_ndjson_parse_msg.go:29,68(事件名常量 orchestration/contracts.go:163);vitest.config.ts 删掉不存在的 src/mock.ts 覆盖排除项及其编造的理由注释;normalizeHubMessages.ts pin 溯源注释重写为实况(REST 消费方 desktop useHubPinnedMessages / web useWebWorkbenchModel,WS 帧驱动 pinMap store,结论 HubMessage.pinned 不加保留) (#2246)

Co-authored-by: Cursor <cursor@vectorcontrol.tech>
DeliciousBuding added a commit that referenced this pull request Sep 3, 2026
…web/desktop 4 条契约收敛到单一来源 + 21 处过期注释/路径订正(净 −119 行) (#2279)

* refactor(frontend): 删掉 34 个全仓 0 引用导出的 export 修饰符(18 文件,实现保留)——按 #2274 C-4 清单逐条复核:每个符号仅本文件内使用、全仓代码/注释/barrel 均无外部消费(自建扫描器逐一验证未照抄车道结论);公共 barrel 未收录任何一个;删后 @agenthub/shared 与 @agenthub/workbench typecheck 均绿 (#2274)

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* refactor(frontend): 删掉 7 文件 13 个全仓 0 引用的真死导出符号(含实现与其描述性注释)——C-2 同族复核:BottomSheet.motion 3 常量、theme/motion resolveMotionTiming、hubClientTeamTypes 4 个无人消费的兼容别名、hubWS 两个从未被引用的内部事件名常量(同步修正 HubWSGapPayload 的文档注释,不再点名已删常量)、surfaceMetadata getSurfaceByWebRoute、e2eDataModeContract isE2ERequestAllowed(isBoundaryAllowed 仍有他处消费,保留)、workbenchApprovalEvents ApprovalJumpDetail;shared/workbench/mobile-rn typecheck 均绿 (#2274)

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* docs(shared): 修掉 5 处过期/不实注释(D-1/D-3/D-4/D-5,均有 git log/grep 证据)——diff.ts 与 index.ts 不再点名 #2151 已删除的 edge-server/internal/diff(改为陈述 TS 侧实现、无 Go 对应物,并指出现存 Go 侧只有 surfacing_diff.go 生成器与 diff_apply.go 应用器);normalizeEdgeEvents.test.ts 注释改为真实发射点 parser_ndjson_parse_msg.go:29,68(事件名常量 orchestration/contracts.go:163);vitest.config.ts 删掉不存在的 src/mock.ts 覆盖排除项及其编造的理由注释;normalizeHubMessages.ts pin 溯源注释重写为实况(REST 消费方 desktop useHubPinnedMessages / web useWebWorkbenchModel,WS 帧驱动 pinMap store,结论 HubMessage.pinned 不加保留) (#2246)

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* docs(mobile-rn): 去掉指向仓外一次性 lane 工件的裸 BLOCKED.md 指针(D-9)——mobilePlatform.ts 复审触发条件内联为可核验判据(Mobile Hub client 暴露 approval/runtimeEvidence/sandbox 契约或接通远程执行时再重新评估);同文件 mobileFriendlyError.ts 主机已修,未动 (#2246)

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* test(workbench): 修正 14 处过期路径字面量 app/shared/src/workbench/ → app/workbench/src/(D-11)——真实文件为 app/workbench/src/{RightInspector,AgentHubWorkbench}.tsx(已 ls 证实),测试断言与夹具两侧同步改,互相钉死的关系保留;shared+workbench 全量测试通过 (#2246)

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* docs(shared): 补掉 dc7f6bb 漏改的一处——HubWSGapPayload 的头注仍点名同批删掉的 HUB_WS_GAP_EVENT 常量,改为点名真正的投递口 HubWSHandle.onGap(desktop hubEventBridge.ts:466 与 web webHubRealtime.ts:322 都只经 onGap 消费它,事件名常量从加入起就没有任何引用) (#2274)

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* refactor(frontend): 清理写集内 102 处死 export 修饰符(全仓除定义外 0 引用)

判据:全仓 grep(含 test/barrel/md)除定义外 0 引用;以 typecheck + lint 双验证。

- 79 处:仅删除 export 修饰符(符号仍在定义文件内使用,例如
  DesktopPlatform/AppLanguage/UpdateExecutionTargetRequest 等)。
- 23 处:删修饰符后变成未使用(eslint no-unused-vars 报错,typecheck 未开
  noUnusedLocals 故以 eslint 为准),连实现一并删除:
  app/desktop/src/api/agentProfileQueries.ts:useHubCreate/Update/DeleteAgentProfile
  app/desktop/src/api/edgeClient.ts:deleteThreadPin、pinThreadItem
  app/desktop/src/api/hubQueries.ts:WorkspaceProjectPage
  app/desktop/src/platform/desktopPlatform.ts:desktopAgents、desktopConversations、
    desktopTranscript、resolveDesktopPreviewTranscript + 随之无用的 import/const
    (demoWorkbenchAgents、resolveDemoWorkbenchTranscript、WorkbenchAgent、
    TranscriptBlock、WORKBENCH_DEMO_FALLBACK_CONVERSATION_ID、
    DESKTOP_FALLBACK_CONVERSATION_ID)
  app/desktop/src/stores/modelSettingsStore.ts:DEFAULT_MODEL_ALIASES、
    DEFAULT_CC_SWITCH_PROVIDER_STATUS、obscureApiKey、revealApiKey、maskApiKey、
    CREDENTIAL_SALT(原仅经 export 组导出且 0 消费者)
  app/web/src/api/agentQueries.ts:createDefaultAgentProfileRequest
  app/web/src/api/projectQueries.ts:useCreateHubWorkspaceProjectThread、
    useSendHubWorkspaceProjectThreadMessage
  app/web/src/api/runEventReplay.ts:getRecoveryState、replayGapBlock、RecoveryState import
  app/web/src/config.ts:EVENT_LOG_MAX
  app/web/src/i18n/index.ts:setLanguagePreference
  app/web/src/platform/useWebWorkbenchModel.ts:webHubEmptyContacts(re-export 行)
- 验证:pnpm -r typecheck 5 包全绿;web test 271 passed;desktop test 458 passed;
  web lint 0 problems;desktop lint 10 problems(6 errors+4 warnings)与改前基线
  完全一致(4 条 warning 未增减);git diff --check 干净。

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* docs(desktop): hubEventBridge 头注指向真实 Edge 事件入口,断链修复 (#2246 / D-2)

- 原注释点名的 edgeEventBridge.ts 全仓从未存在(grep 仅此 1 命中即注释本身),
  会把读者引向空文件;真实入口是 platform/useDesktopEdgeEvents.ts +
  api/eventClient.ts(createEventStream 建流)。改为点名真实路径。

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* fix(desktop): 登录页错误处理回灌 web 的 i18n 规则,不再直出 err.message (#2256 D-P1-4)

- app/desktop/src/components/LoginForm.tsx:32-48:catch 块对齐 web
  LoginForm——OidcError 走 t('auth.error.oidc.<code>', { defaultValue:
  t('auth.error.oidc.default') }),非 OidcError 走 t('auth.error.oidc.default'),
  删除直出 err.message 的通道与硬编码英文 defaultValue 'Login failed'。
  键在 desktop locale 双语均已存在,defaultValue 原本就是不可达的死字面量。
- app/desktop/src/__tests__/LoginForm.test.tsx:改了两条断言并点名理由——
  原 'shows TokenDance errors from the auth hook' 与 'falls back to the
  localized unavailable error...' 断言的是旧缺陷行为(alert 里出现原始
  'Hub login unavailable' / 'auth.error.tokenDanceUnavailable'),本次改为
  钉住修复后行为(auth.error.oidc.default,且不含原始串),并新增一条
  OidcError 码解析断言;未删除任何用例,未放宽。

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* refactor(web): hubClient.ts 删除 shared DTO 的本地副本,不再遮蔽 SSOT 同名别名 (#2256 D-P2-3)

- 删除 app/web/src/api/hubClient.ts 里的 AgentInstance / PendingAgentTask
  两个 interface(与 shared hubClientTeamTypes.ts:606-634 逐字全等)。
- 消费方(webPlatform.ts:17,20)经 export * from '@shared/hub/hubClient'
  解析到 shared 的 AgentInstance/PendingAgentTask 别名,值逐字相同,
  0 个消费者的 import 需要改;shared 侧给 Hub* 加字段时 web 将出现编译错误,
  不再静默漂移。
- 关于牵出的 6 对同名镜像测试(hubClient/hubAuth/hubTokenStorage/useAuth/
  AuthPage/ThemeContext .test.*):逐对 diff 复核后确认**不是副本**
  (行数/断言均不同,各自钉 web 包装器与 desktop 客户端的表面行为),
  因此无测试可合并/删除——本次未删任何测试;证据见 round-69 lane-E REPORT 第 3 节。

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* fix(frontend): 执行目标健康态白名单收敛——web 补 registered、两端去掉 | string 吸收、desktop 的 online 改计 healthy (#2256 D-P2-1/D-P3-1)

- app/web|desktop/src/api/hubClient.ts:ExecutionTargetHealthState 去掉
  '... | string'(字面量被吸收、白名单零类型安全的根因),收成服务端
  target_health.go 取值域的 8 项联合;ExecutionTargetTrustLevel 收成 4 项联合。
- app/web/src/api/executionTargetQueries.ts:healthStates 白名单补
  'registered'(已绑定但尚无存活证据的正常生命周期态),与 desktop 对齐
  (8 项);新增测试钉住 registered 透传而非落入 unknown。
- app/desktop/src/api/executionTargetQueries.ts:summarizeExecutionTargets 的
  healthy 分支补 'online'(与 web 口径一致,online 不再落入 unknown)。
- app/desktop/src/api/hubClient.ts:toSharedTarget/包装器参数改用 shared 的
  HubExecutionTargetRequest 契约(desktop 本地 shape 可赋值给它),
  收紧类型后的 contravariance 编译红以此修掉,不改任何收窄结论。
- 待产品裁决(未发明):desktop 是否补 mismatch/stale 计数、web 是否去掉,
  见 round-69 lane-E REPORT。

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* fix(web): 执行目标清单收敛到 desktop 的 50×10 cursor 翻页,取满 500 并如实报 hasMore (#2256 D-P1-3)

- fetchExecutionTargets 从单次 pageSize=50 改为与 desktop 同策略的
  cursor 循环(50×10);循环耗尽返回 hasMore:true,避免第 51 台起静默截断。
- 纯收敛,仅改 app/web 侧,shared 不动。
- 关于 executionTargetQueries.test.ts:24 的 ?pageSize=50 断言:实测收敛后
  **并未变红**——该断言断言的是第一页 URL,而 qs() 不序列化 undefined,
  第一页 URL 仍为 ?pageSize=50。因此本条**未改该断言**(它仍然钉住第一页
  URL,不是错误断言),只新增两条断言钉住多页 cursor 与 500 上限行为;
  无任何断言被放宽。

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* chore(i18n): 删掉 web 的 agents.newDefault 键(en/zh 各一行)——cd3b7a4b 删掉的 createDefaultAgentProfileRequest 是它在全仓的唯一消费者(app/web/src/api/agentQueries.ts 里那句 t?.('agents.newDefault', { index }) ?? `新 Agent ${index}`,也正是 #2278 特意保留 t 参数的那一个 mapper),函数一走这个键就成了死键,被 verify-i18n-deadkeys.py 的 fail-closed 门禁抓到;两侧同时删,不走 baseline 登记(它不是动态键,是彻底的孤儿)

明卷:
- python3 scripts/verify/verify-i18n-deadkeys.py -> 通过
- 两个 bundle json.load 校验通过
- 主机在主 checkout 的合并树上复跑 validate job 的全部 62 条命令:仅本条与 commit-message 门禁两处红,其余 60 条全绿

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

* chore(frontend): 修掉本批自己引入的 2 处 EOF 空行——e35c7387 删掉 mobile-rn theme/motion.ts 的 resolveMotionTiming、cd3b7a4b 删掉 web api/hubClient.ts 的本地 DTO 副本后各留下一个文件尾空行,被 validate 的 Check whitespace(git diff --check "origin/master...HEAD")判红;两条 lane 各自只跑了 git diff --check(工作树,无 range)所以都没看见

Co-authored-by: Cursor <cursor@vectorcontrol.tech>

---------

Co-authored-by: DeliciousBuding <DeliciousBuding@users.noreply.github.com>
Co-authored-by: Cursor <cursor@vectorcontrol.tech>
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