Skip to content

perf(cargo): centralize default feature ownership - #2259

Merged
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/default-feature-policy
Aug 13, 2026
Merged

limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/default-feature-policy

Conversation

@limityan

Copy link
Copy Markdown
Collaborator

概要

本 PR 将 Cargo default feature 的责任集中到正确 owner,避免在大量 workspace member 上重复声明 default-features = false,同时继续保持 capability feature 由真实 consumer 显式选择。

  • 对 9 个长期保持 default = [] 的仓内 crate 建立统一 guarded registry:target 必须显式保持空默认,consumer 不再重复关闭。
  • ACP 保留 client + server 兼容默认;Desktop/CLI 继续显式关闭并分别选择真实角色。
  • 第三方默认策略尽可能集中到 [workspace.dependencies];成员仅增加实际使用的 slice。
  • Relay Server/Relay Service/Page Function Runtime 会被 Docker 单独复制,无法继承 workspace 根,因此继续保留显式版本与默认策略。
  • 不修改运行时代码、公开 API、wire shape 或错误语义;不新增 CI job、matrix 或 package script。

依赖与编译图

指标 变更前 变更后
member default-features = false 70 6
Cargo.lock packages 1169 1158
lock 新增 packages - 0
lock 删除 packages - 11

三平台 normal,build 版本化 package 去重:

闭包 Windows macOS Linux
Core feature-free 63 → 63 51 → 51 50 → 50
Core product-full 569 → 569 556 → 556 600 → 600
CLI 642 → 640 641 → 639 664 → 662
Desktop 790 → 790 805 → 793 887 → 887
Relay Service 190 → 190 193 → 193 192 → 192
Services Integrations feature-free 26 → 26 28 → 28 27 → 27

macOS 数字表示 resolved package closure。BitFun 的 Objective-C direct edges 按实际 imports 选择 feature,但 Tauri/wry/notification/updater 仍会按 Cargo additive union 合并自身需求。

验证

通过:

  • node --test scripts/check-core-boundaries.test.mjs(118/118)
  • node scripts/check-core-boundaries.mjs
  • cargo metadata --locked --offline --format-version 1
  • AI Adapters / Agent Stream / Terminal Core all-target check
  • Page Function Runtime tests(5/5)
  • Remote Connect QR focused test(1/1)
  • CLI all-target check
  • focused service package check
  • git diff --check
  • 两轮独立架构、依赖、checker/CI 对抗复审,最终无 P0-P3 finding

未改 .github/**:现有 workspace/platform CI 会覆盖产品组合和真实平台构建,本 PR 不追加重复检查。

本机限制:Windows workspace check 到 Desktop build script 后因缺少 src/mobile-web/dist 停止;macOS cross-check 因 Windows 主机没有 Apple C compiler 在 objc2-exception-helper build script 停止。两者均未出现 Rust feature 错误,真实 macOS/产品构建以现有 CI 为最终证据。

@limityan
limityan merged commit 9b05dd0 into GCWing:main Aug 13, 2026
7 checks passed
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