Repository navigation
refactor(cleanup): 删除只被测试调用的死代码及其测试 - #2059
Merged
Merged
Conversation
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 20, 2026 13:16
deepcoldy
force-pushed
the
refactor/remove-test-only-dead-code
branch
2 times, most recently
from
October 20, 2026 18:10
fabb72c to
5adb923
Compare
静态分析列出 153 个「只被测试引用、生产路径无调用方」的 src 导出符号。逐个核实 (git grep 生产引用、再导出链、git log -S 来历、读符号体)后,本提交删除其中确认 不可达的生产代码,以及以它们为被测对象的测试用例;principal-lane 脚手架单独放在 下一个提交里。 判定为死代码的依据分三类: - 曾有调用方、后来被删的遗留:Codex App runner 的 normalizeAppRunnerFinalMarker / projectAppRunnerFinalIds(#597 后 worker 不再调用)、CliFilterGroup(Calm Console 改造后被内联实现替代)、BotPolicyCard 与随之孤立的 SkillMultiPicker、 buildConnectorInstructionUpdateBody、pickBotEntryByName、formatNumber、 pm2ManagedExitConfig、managedTargetsForCliChange、getGitRepoInfo(dashboard 不再 注入,连同整套 git 探测缓存)、findDispatchRegistryEntry / resolveReportTarget / resolveReportRecipient(report 改走 daemon IPC 后无调用方)、listTeamsForMember、 extractEventContext(v2 workflow 已下线)、parseDumpLayoutLeafPanes、 resolveTerminalWriteForRequest(生产用 resolveTerminalAccessForRequest)。 - 落地起就没接线:readFirstEventTimestamp、extractAssistantThinking、 shouldBeginCodexAppReattachObservation、codexAppControlStatePathForPlatform、 sessionHasNoFeishuTransport(cli.ts 里是另一份内联实现)、safeWorkbenchReturnTo (生产用 safeDashboardH5ReturnTo)、formatDaemonVersionRestartHint、 parseDispatchLaunchOverrideSnapshot 及其 schema/类型/版本常量、asDocWatchOutcome、 resolveFeedbackPolicy、isBuiltinSkillDisabled、agentHasSections、 emptyWorkbenchSeenLedger、hasMarkdown、wrapResolvedCardText、mayRetryClose、 inheritContainmentHandles、sessionContainmentQuiescence、mojoWorkspaceHash、 removeGatewayEntry、networkPolicyAllows(生产只走 compileNetworkNft)、 filterAndPaginateSchedules / kindCounts、schedulePreconditionTrustedFileExamplePath、 scratchMergedRootFor、filterByCli / filterBySearch / filterByStatus、 normalizeCreateMode、listSessionGroups、cliSelectionKeys、removeTeamBot、 clearBotOwner、listBotProfiles、resolveStableBotmuxWrapperPath、deleteResults、 findBindingByClaimId / listDanglingClaimIntents / removeBinding、matchesClaimMarker、 clearLarkCliAuth / larkCliHomeForTurn、traexRolloutHasUserInputSince、 unauthorizedOutcomeFor、mayOfferTurnRetry、archiveSavedWorkflow / resolveSavedWorkflowRef(library-service 有自己的实现)、pruneVcMeetingDeliveryState、 listVcMeetingFeedMetadataAfter / removeVcMeetingFeedMetadata、 listWebhookLifecycleRecords / resolveWebhookLifecycleGroup。 - 初版消息队列读侧:readUnread / rewindOffset / getOffset(生产只 append,从不读)。 级联:tsc noUnusedLocals 暴露出的内部 helper、import 一并删除;因删除而只剩测试 引用或零引用的导出类型/常量(AppRunnerFinalIds、DispatchRegistryEntry、LeafPane、 StatusChip、SessionStatus、SavedWorkflowResolution、UnauthorizedOutcome、 TRIGGER_USER_AUTH_TOOL_CAPABILITIES、KindCounts、ScheduleListPage 等)同样删除; SkillMultiPicker 删除后只剩 i18n 表引用的 8 个 skills.picker* / skills.priority 文案 一并移除(中英两份)。 测试侧:以上述符号为被测对象的用例删除;只把它们当工具用的地方换成等价的生产入口 (例如 normalizeFinalUsage、effectiveBuiltinSkillContent、containmentHandles、 claimMarker、getVcMeetingFeedMetadataState,或直接读落盘文件),以保留对生产逻辑的 覆盖。薄包装(SEAM)、测试钩子、给正当测试提供取值域的常量表均保留不动。 不改任何生产行为:被删代码在生产路径上均不可达。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
3025187(feat(xpi): 支持群内多主体独立会话并行与安全回收)一次性落地了群内多主体 lane 的整套「入口规划 → 派发 capability → 每 lane 队列/不可变记录 → workspace 工单」 脚手架,但此后只有路由判定(decidePrincipalLaneRoute 等)、turn 绑定、出站 provenance、 source/shadow lane 存储等部分接进了 daemon / worker-pool;下面这些自落地起就没有任何 生产调用方(git log -S 只有那一个提交),只靠测试续命: - src/core/principal-lane-ingress.ts:planPrincipalLaneIngress、 materializePrincipalLaneIngress、decidePrincipalLaneIngress、 validPrincipalLaneIngressFence 及配套类型——整个文件删除。 - src/core/principal-lane-dispatch.ts:createPrincipalLaneDispatchContext、 executePrincipalLaneOutput、revalidatePrincipalLaneDispatchCapability 及 capability/上下文类型——create 是唯一的 capability 签发点,没有它其余部分全部不可达, 整个文件删除。 - src/services/principal-lane-ticket-record-resolver.ts:checkpoint A 的占位实现 (永远 fail-closed),唯一调用方是下面被删的 rehydrate,整个文件删除。 - src/services/message-queue.ts:openPrincipalLaneQueue、appendPrincipalLaneMessage、 readPrincipalLaneUnread、getPrincipalLaneQueueOffset、rewindPrincipalLaneQueue、 ensurePrincipalLaneQueue、appendPrincipalLaneQueueRecord、 readExactPrincipalLaneQueueRecord、inventoryPrincipalLaneQueueRecords、 principalLaneAppendReceiptLocator、rehydratePrincipalLaneClaimedRecordFromTicket 及其 manifest/记录编解码 helper;文件回到只有 ensureQueue / appendMessage。 - src/services/session-store.ts:readPrincipalWorkspaceMembershipV2、 ensurePrincipalWorkspaceMembershipV2、enqueuePrincipalWorkspaceTicket、 inventoryPrincipalWorkspaceTickets,以及只为它们服务的内部 helper、结果类型和 4 个 __testOnly_set*PrincipalWorkspace* 钩子。 - src/core/principal-lane-routing.ts:resolveCallerLaneId、principalLaneDisplayTarget、 SOURCE_PRINCIPAL_LANE_ID。 - src/core/principal-workspace-admission.ts:工单相关的 parse/ID/版本常量与类型。 保留:仍在生产路径上的 principal-lane 代码(路由判定、turn 绑定、出站 provenance、 source/shadow lane 存储与 worktree 物化等)以及 SQLite schema(PRINCIPAL_LANE_SCHEMA_SQL 里的 workspace/ticket 表定义不动,避免改变已有库的结构)。validPrincipalLaneBinding 是生产在用的 parsePrincipalLaneBinding 的薄包装,按约定保留。 级联由 tsc noUnusedLocals 逐轮暴露并清理;之后对相关模块重新扫描「只剩声明处」的导出, 直到不再有新的孤儿。删除前已确认没有 open PR 在接线这些文件。 测试侧:删除以上述符号为被测对象的测试文件(principal-lane-dispatch / ingress / immutable-record / ticket-record-resolver、principal-workspace-ticket 及 helpers/principal-lane-record-fixture)与 session-store / message-queue / principal-lane-routing / principal-workspace-admission 中对应的用例。 这组改动集中在一个提交里,如需恢复脚手架可直接 revert 本提交。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
force-pushed
the
refactor/remove-test-only-dead-code
branch
from
October 20, 2026 19:13
5adb923 to
734fb31
Compare
This was referenced Oct 21, 2026
deepcoldy
added a commit
to Hyperzsb/botmux
that referenced
this pull request
Oct 21, 2026
合并含 deepcoldy#1823(按任务合并补授权/保留未失效请求/60s 自动轮询冷却/ denied-invalid-expired 三类失败分类)与 deepcoldy#2059 的最新 master。 身份模型留本 PR:个人 app 两步、不复制宿主 appsecret; deepcoldy#1823 机制与本 PR 三态融合: - dashboard 授权路由采用 deepcoldy#1823 daemon 侧后台 poll 框架(trackSessionAuthorization/ isAuthorizationValid/pending 请求复用/dispose),签发按三态:bound 与跨应用委派走 (目标)Bot 应用 requestUserAuthorization,普通按人会话走发送人个人 app beginLarkCliLogin 两步;统一 poll 返回 app-token|user-home。 - lark-cli-auth 保留个人 app 两步,带 deepcoldy#1823 completeLarkCliLogin 失败三类分类 (临时失败复用链接+60s autoPollAfter 冷却)与 resolveLarkCliHomeForTurn 冷却门。 - 测试:deepcoldy#1823 的 cooldown/分类/链接保留/daemon-polling 用例改用本 PR 个人 app 夹具 (provisionPersonalApp 替代 seedMachine)或委派场景;lark-user-scope 加购走个人 app; 随 deepcoldy#2059 删除死代码 TRIGGER_USER_AUTH_TOOL_CAPABILITIES 及其测试。
|
🚀 Released in v3.49.0 |
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.
改了什么
静态分析找出 153 个
src/导出符号:它们被测试 import,但在src/、scripts/、packages/里没有任何生产调用方,在自己的模块里也只出现在声明处。也就是说,只有测试在给这些代码「续命」。本 PR 逐个核实(git grep生产引用、export *再导出链、git log -S查来历、读符号体),只删确认不可达的代码及以它们为被测对象的测试。clear*Cache、内部状态探针、注入点之类的测试隔离钩子SESSION_PHASES)分两个 commit,方便单独回退:
refactor(cleanup):71 个死符号。分三类:normalizeAppRunnerFinalMarker、CliFilterGroup、getGitRepoInfo;readFirstEventTimestamp、networkPolicyAllows;refactor(xpi):principal-lane-*脚手架共 17 个符号。它们在3025187ee0 feat(xpi)中一次性落地,此后从未接进生产路径。级联删除后,principal-lane-ingress.ts、principal-lane-dispatch.ts、principal-lane-ticket-record-resolver.ts三个文件整体删除。SQLite schema 一行未动;仍在生产路径上的 principal-lane 代码(路由判定、turn 绑定、出站 provenance、source/shadow lane)都保留。动手前确认过没有 open PR 在接线这些代码。影响范围评估
src/core/、src/services/、src/dashboard/、src/im/lark/等公共层里的死导出,以及只被它们引用的内部代码。noUnusedLocals,bun run build通过,说明没有生产代码再引用它们;export *再导出链核对过,没有被删符号经由对外入口暴露(包括packages/workflow-core);也没有通过字符串名、IPC 方法名做动态访问的。测试验证
d06d38563后bun run build通过(tsc + 构建期审计)。plugin-mcp-sandbox的 2 个 bwrap 用例失败。把 src 切回基线重新构建后同样失败,属于本机环境问题。留给 reviewer 的判断
discoverSlashCommands、previewMessageListenerMatches、discoverExternalRuntimeCandidate、setBotSpecialties、persistTurnTerminal、mintWorkbenchTicket。它们是生产在用的内部逻辑的唯一测试入口。要删的话,得先把这些用例迁到生产入口上。invalidateAll:生产关停时从不调用它。clearScratchView:生产 teardown 不调用。getClaimIntent:claim 意图的读侧在生产里全未接线。resolveTerminalAccessForRequest的「数组形式x-botmux-role」与「每次请求都重新求值」,原来只测在被删的旧孪生函数上。ensureShadowPrincipalLane返回member:indexed_value_mismatch的那条路径。drainTraexRollout的probe选项已经没有生产调用方,但删它要改活函数,本 PR 不做。合并顺序
本 PR 和 #2057 有 3 个测试文件冲突:
report-daemon-ipc-auth-wiring.test.ts:PR1 已整文件删除。worker-pipe-initial-screen-order.test.ts:本 PR 只删了一行,而那条用例 PR1 已经整条删除。dashboard-skills-ui.test.ts:引用死组件BotPolicyCard的用例,按本 PR 删掉。请在 #2057 合入后再 rebase 本 PR。
🤖 Generated with Claude Code