refactor(core): retire superseded report and scanner APIs - #181
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (18)
💤 Files with no reviewable changes (2)
Walkthrough本次变更统一图生成的定价诊断输出,清理扫描、聚合和旧诊断加载公共 API,并扩展性能测量脚本以支持 graph 报告模式及新的处理时间字段路径。 Changes图生成与定价诊断
公共接口与聚合边界清理
扫描器错误与发现测试调整
性能报告模式扩展
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant generate_graph
participant PricingLoader
participant GraphMeta
CLI->>generate_graph: generate graph
generate_graph->>PricingLoader: load pricing with diagnostics
PricingLoader-->>generate_graph: pricing data and diagnostics
generate_graph->>GraphMeta: populate pricingStatus and pricingDiagnostics
GraphMeta-->>CLI: export graph metadata
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
背景
关联 #176 的 B 部分。
这一部分不是编译器可以直接证明的私有死代码,而是已经偏离当前架构的公开表面:部分 API 因为是
pub而不会触发 dead-code 警告,部分字段仍被写入却没有活跃读取者,还有两个 Graph 入口对同一聚合算法承诺了不同的定价失败语义。本 PR 以当前 adapter + bounded fold 管线为唯一架构事实,删除旧中心 scanner 和中间投影包装器,并把 Graph 统一成一个 usage-first 公共入口。相关 breaking 决策记录在
docs/adr/0027-current-source-discovery-and-graph-semantics.md。主要变化
1. Graph 只保留一个公开语义
generate_local_graph_report,统一使用generate_graph。PricingService;0.0。data.meta.pricingStatus,可能值为:availableavailableWithWarningscachedFallbackunavailabledata.meta.pricingDiagnostics,CLI 同时写入 stderr;失败不会被伪装成静默成功。PricingStatus分类,删除 CLI 内重复枚举和判断逻辑。2. 移除整个 legacy
ScanResultAPI旧路径由中央 scanner 发现所有文件和数据库,再写入
ScanResult。当前生产路径已经是:选择 adapters → 每个 adapter 发现自己的 source unit → parse/fold。Kilo、Goose、Kiro 等旧 DB 字段仍会被旧 scanner 写入,但活跃 adapter 从不读取。本 PR 删除:
ScanResult;scan_all_clients_with_scanner_settings;scan_all_clients_with_env_strategy;ScannerError;仍保留并继续测试生产代码实际使用的扫描能力:
ScannerSettings、scan_directory、extra-dir 解析、OpenCode DB 发现/合并和 source inspection 所需的路径解析函数。Kilo、Goose、Kiro、Hermes、Zed 等路径现在只有各自 adapter 一个发现权威。3. 删除其余过时公开包装器
UsageDataWithDiagnostics及load_*usage_data*_with_diagnosticsload_prepared_tui_bundle_with_diagnostics;普通调用使用具体 report API。UsageAccumulatorWithDiagnostics及对应 loaderTuiBundleWithDiagnostics是当前 usage + sessions + source-space 边界。load_usage_dataWeekdayBucket、aggregate_by_weekdayparse_claude_file_with_cache*parse_claude_file/parse_claude_file_with_home;父级 cache 继续留在 resolver-aware 内部路径。显式返回全部
UnifiedMessage的 raw-message API 保留不变,因为 materialize messages 本身就是它们的公开契约,而不是旧架构泄漏。4. 更新性能测量接口
scripts/measure-scan-performance.sh改为读取当前 report envelope 的metadata.processingTimeMs,不再读取已经不存在的顶层字段。time-metrics|graphreport 参数,让 Graph 复用同一套 warm-up、处理时间、wall/user/sys 和 max RSS 口径。同机性能对比
基线是本机从当前
personal/local-clientsHEAD5c009d75eda7c70905b26c77805835b0e9a4699f编译并安装的/home/travis/.local/bin/tokscale;候选使用本 PR 的 release build。两者在同一 WSL2 主机、同一份实时本地语料上连续测量,每组先 warm-up 一次,再取 3 次中位数。Graph 使用TOKSCALE_PRICING_CACHE_ONLY=1排除网络波动。所有候选中位数均低于预设回归上限。此次删除的大部分代码不在生产热路径,因此不宣称运行时性能优化;Graph RSS 的 +32 KiB 属于噪声级变化。
release 二进制从 19,823,032 增至 19,825,016 bytes(+1,984 bytes,+0.01%)。旧公开函数原本已可被 LTO 从 CLI 二进制剔除,新加入的 Graph pricing 状态和诊断抵消了源码删除带来的体积变化。
完整原始样本、测量契约和门槛见
docs/performance/2026-07-21-public-surface-cleanup.md。验证
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningsTOKSCALE_CONFIG_DIR=/tmp/tokscale-b-cleanup-tests cargo test --workspace --no-fail-fastbash scripts/test-measure-scan-performance.shgit diff --check以上检查全部通过;workspace 测试无失败,两个需要真实外部 catalog 的用例保持 ignored。
Summary by CodeRabbit
新功能
graph输出新增定价状态与诊断信息。改进
graph报告模式,并统一读取处理耗时。文档
清理