Screenpipe 核心引擎行为覆盖率地图:读懂 Rust 层的 Coverage Flow、权重体系与验证命令
Screenpipe 是一个开源"计算机历史记录"项目:它在本地持续录制屏幕与音频,并为 Claude、Codex 等 Agent 提供上下文。要长期维护这样横跨 Windows / macOS / Linux 三平台的 Rust 采集管线,仅靠行覆盖率远远不够。本文以仓库内的 核心引擎覆盖率地图(docs/coverage/CORE.md) 为骨架,讲解 Screenpipe 如何用"行为流程覆盖率(Behavioral Flow Coverage)"回答"哪些产品风险被测试覆盖、哪些平台、被忽略的测试是否在虚增信心"这三个问题,并给出完整的度量维度、权重规则、矩阵解读与重新生成/校验的实操命令。读完你将掌握这套覆盖率体系的数据结构、评分逻辑,以及如何在本地跑出并检查这份报告。
什么是行为覆盖率地图:它不是行覆盖率
CORE.md 开头就明确了定位:这是 Screenpipe 核心 Rust crate 的行为覆盖率仪表盘(behavioral coverage dashboard),不是行或分支覆盖率。二者差异在于:
- 行/分支覆盖率回答"代码里哪些语句被执行过",由
cargo llvm-cov这类工具测量; - 行为流程覆盖率回答"哪些产品风险有测试代表",它把一个测试套件(Suite)按声明的平台(Platform)和层(Layer)映射到关键业务流(Flow),基于未被忽略的 Rust 测试块数量 × 置信度权重 × 关键度权重累加出加权分数。
从仓库的目录布局可以看到这是一套"声明式映射 + 生成器校验"的体系:
- docs/coverage/core-engine-map.json:声明式核心清单,把每个测试套件映射到 crate、平台、层、关键流;
- docs/coverage/scripts/generate-core-engine-coverage-report.ts:校验清单、统计 Rust 测试块并写出
CORE.md; - docs/coverage/README.md:使用说明与命令入口;
- COVERAGE.md:顶层汇总,把 Tauri/WebDriver E2E 覆盖率与核心引擎覆盖率合并展示。
当前快照数据
报告顶部给出了一组总量数据(以仓库当前检入版本为准):
| 指标 | 数值 |
|---|---|
| 映射套件(Mapped suites) | 32 |
| 映射 Rust 文件(Mapped Rust files) | 341 |
| 活跃测试块(Active test blocks) | 3407 |
| 忽略/手动测试块(Ignored/manual test blocks) | 139 |
| 声明的测试块(Declared test blocks) | 3546 |
| 加权覆盖率点(Weighted coverage points) | 2803.3 |
被跟踪的 6 个核心 crate 为:screenpipe-engine、screenpipe-db、screenpipe-sqlite-coordinator、screenpipe-audio、screenpipe-screen、screenpipe-a11y。
权重体系:置信度 × 关键度
报告把"测试存在"与"测试可信"区分开,通过两套权重把原始测试块数量换算成加权点:
- 置信度权重(Confidence weights):
strong=1.0、partial=0.7、conditional=0.4、smoke=0.3; - 关键度权重(Criticality weights):
high=1.0、medium=0.7、low=0.4。
某个套件的加权点计算公式为:
weightedPoints = Σ(活跃测试块数) × confidenceWeight × criticalityWeight
从生成脚本 generate-core-engine-coverage-report.ts 可以看到该公式的落地实现:activeTests * confidenceWeights[suite.confidence] * criticalityWeights[suite.criticality]。
被忽略的测试(#[ignore])会被计数,但不会贡献加权点,直到它们在某个运行时车道(runtime lane)被显式启用。这一点很关键:它防止团队用"写了但永远不跑的测试"来粉饰覆盖率。
测试块的统计方式同样可以在脚本中确认:countRustTests() 通过正则统计 #[test](含 #[tokio::test]、#[async_std::test])与 #[ignore] 属性的数量,activeTests = declared - ignored。
平台摘要:三平台的关键流覆盖率均为 100%
报告按 Windows / macOS / Linux 三个平台汇总,Critical score 指关键流覆盖得分(covered 计 1 分、weak 计 0.5 分后取均值):
| Platform | Suites | Active tests | Ignored tests | Weighted points | Layers | Flows | Critical score |
|---|---|---|---|---|---|---|---|
| windows | 29 | 3264 | 133 | 2738.2 | 21 | 11 | 100% |
| macos | 29 | 3326 | 114 | 2752.2 | 22 | 11 | 100% |
| linux | 25 | 2894 | 106 | 2397.5 | 20 | 11 | 100% |
读数要点:
- macOS 的活跃测试与加权点最高(3326 / 2752.2),Linux 最低(2894 / 2397.5),且 Linux 只有 25 个套件,说明部分 OS 专属套件(如
engine-meeting-watcher仅支持 windows/macos)在 Linux 上不参与; - 三个平台的
Critical score均为 100%,对应"关键缺口"一节的结论:当前清单中三平台均无关键缺口。
Crate 摘要:测试分布与覆盖责任
| Crate | Suites | Integration files | Source unit files | Active tests | Ignored tests | Weighted points | Flows |
|---|---|---|---|---|---|---|---|
| screenpipe-engine | 10 | 19 | 116 | 1696 | 42 | 1308.0 | 10 |
| screenpipe-db | 5 | 52 | 16 | 467 | 16 | 442.4 | 9 |
| screenpipe-sqlite-coordinator | 1 | 0 | 3 | 27 | 0 | 27.0 | 2 |
| screenpipe-audio | 6 | 25 | 51 | 606 | 44 | 532.4 | 5 |
| screenpipe-screen | 6 | 9 | 18 | 257 | 9 | 232.1 | 4 |
| screenpipe-a11y | 4 | 2 | 30 | 354 | 28 | 261.3 | 3 |
从数据可见各 crate 的测试策略差异:
screenpipe-engine是绝对主力,10 个套件贡献 1308.0 加权点,覆盖 10 条流——引擎的生命周期、API 路由、采集与时间线缓存等核心逻辑都集中在这里;screenpipe-db的集成测试文件(52 个)远多于源码单元测试文件(16 个),说明数据库层主要靠tests/下的集成测试来验证真实 SQLite 行为;screenpipe-sqlite-coordinator规模最小但关键度最高(high, strong),只用 3 个源文件、27 个活跃测试就覆盖了数据库协调与隔离这两条流。
行覆盖率补充:cargo llvm-cov 的接入方式
行为覆盖率不替代行覆盖率。CORE.md 明确说明:当前未附带 cargo llvm-cov 汇总,行/分支覆盖率应单独测量。从仓库根目录执行:
cargo llvm-cov --workspace --summary-only --output-format json > docs/coverage/core-llvm-cov-summary.json
然后带着该汇总重新生成报告(需在 Tauri 应用目录下执行):
cd apps/screenpipe-app-tauri
bun run coverage:core -- --llvm-cov-summary ../../docs/coverage/core-llvm-cov-summary.json
生成脚本支持 --llvm-cov-summary 参数解析(见 parseArgs()),并在 parseLlvmCovSummary() 中从 llvm-cov 的 JSON 中抽取 Lines / Functions / Branches / Regions 四类指标的 covered、count 与 percent,以独立表格追加到报告里,不会混入行为流评分。
如果未提供该文件,报告会保留默认提示文本,即上面这段建议命令。
层矩阵(Layer Matrix):24 个层在三个平台的覆盖明细
层(Layer)是对功能领域的横切划分。报告将每个层在三个平台上的覆盖情况汇总为 套件数 / 活跃测试 / 忽略测试 / 加权点 四元组:
| Layer | windows | macos | linux |
|---|---|---|---|
| accessibility | 4 suites / 352 active / 29 ignored / 323.5 pts | 4 suites / 410 active / 10 ignored / 332.0 pts | 4 suites / 330 active / 7 ignored / 302.5 pts |
| audio | 7 suites / 719 active / 45 ignored / 645.4 pts | 7 suites / 719 active / 45 ignored / 645.4 pts | 6 suites / 644 active / 44 ignored / 592.9 pts |
| audio-device | 2 suites / 216 active / 7 ignored / 193.5 pts | 2 suites / 216 active / 7 ignored / 193.5 pts | 1 suites / 141 active / 6 ignored / 141.0 pts |
| configuration | 2 suites / 143 active / 3 ignored / 129.2 pts | 2 suites / 143 active / 3 ignored / 129.2 pts | 2 suites / 143 active / 3 ignored / 129.2 pts |
| database | 6 suites / 414 active / 12 ignored / 389.4 pts | 6 suites / 414 active / 12 ignored / 389.4 pts | 6 suites / 414 active / 12 ignored / 389.4 pts |
| db-search | 2 suites / 113 active / 9 ignored / 113.0 pts | 2 suites / 113 active / 9 ignored / 113.0 pts | 2 suites / 113 active / 9 ignored / 113.0 pts |
| engine-lifecycle | 6 suites / 242 active / 1 ignored / 217.3 pts | 6 suites / 242 active / 1 ignored / 217.3 pts | 5 suites / 236 active / 1 ignored / 215.6 pts |
| local-api | 2 suites / 414 active / 9 ignored / 292.2 pts | 2 suites / 414 active / 9 ignored / 292.2 pts | 2 suites / 414 active / 9 ignored / 292.2 pts |
| meeting | 6 suites / 1609 active / 20 ignored / 1313.5 pts | 6 suites / 1609 active / 20 ignored / 1313.5 pts | 4 suites / 1272 active / 16 ignored / 999.0 pts |
| ocr | 4 suites / 125 active / 7 ignored / 119.0 pts | 4 suites / 129 active / 7 ignored / 124.5 pts | 3 suites / 120 active / 6 ignored / 115.5 pts |
| os-integration | 1 suites / 6 active / 0 ignored / 1.7 pts | 1 suites / 6 active / 0 ignored / 1.7 pts | - |
| performance | 13 suites / 1463 active / 67 ignored / 1286.8 pts | 14 suites / 1570 active / 71 ignored / 1329.6 pts | 13 suites / 1463 active / 67 ignored / 1286.8 pts |
| pipes | 1 suites / 504 active / 3 ignored / 352.8 pts | 1 suites / 504 active / 3 ignored / 352.8 pts | 1 suites / 504 active / 3 ignored / 352.8 pts |
| privacy | 5 suites / 935 active / 36 ignored / 758.9 pts | 5 suites / 993 active / 17 ignored / 767.4 pts | 5 suites / 913 active / 14 ignored / 737.8 pts |
| real-app | - | 1 suites / 107 active / 4 ignored / 42.8 pts | - |
| speaker | 2 suites / 362 active / 9 ignored / 362.0 pts | 2 suites / 362 active / 9 ignored / 362.0 pts | 2 suites / 362 active / 9 ignored / 362.0 pts |
| storage | 3 suites / 525 active / 29 ignored / 423.3 pts | 3 suites / 525 active / 29 ignored / 423.3 pts | 3 suites / 525 active / 29 ignored / 423.3 pts |
| sync | 1 suites / 504 active / 3 ignored / 352.8 pts | 1 suites / 504 active / 3 ignored / 352.8 pts | 1 suites / 504 active / 3 ignored / 352.8 pts |
| timeline | 4 suites / 1084 active / 33 ignored / 871.9 pts | 4 suites / 1084 active / 33 ignored / 871.9 pts | 4 suites / 1084 active / 33 ignored / 871.9 pts |
| transcription | 5 suites / 796 active / 41 ignored / 623.1 pts | 5 suites / 796 active / 41 ignored / 623.1 pts | 5 suites / 796 active / 41 ignored / 623.1 pts |
| ui-events | 4 suites / 751 active / 28 ignored / 571.3 pts | 3 suites / 702 active / 5 ignored / 537.0 pts | 3 suites / 702 active / 5 ignored / 537.0 pts |
| vision-capture | 5 suites / 549 active / 32 ignored / 433.8 pts | 5 suites / 553 active / 32 ignored / 439.3 pts | 4 suites / 544 active / 31 ignored / 430.3 pts |
几个值得注意的读点:
- meeting 层在 windows/macos 上加权点高达 1313.5,远超其他层,反映会议检测与实时转写合并是屏幕记录类产品的核心差异化能力;
- performance 层是套件数最多的层(13~14 个套件),但忽略测试也最多(67~71 个),说明大量性能/压力测试依赖真实硬件与设备,默认车道不跑;
- os-integration 层只在 windows/macos 上有覆盖(1 个套件、6 个活跃测试),Linux 为
-,对应engine-focus-os套件中focus_tracker/darwin.rs与focus_tracker/windows.rs的 cfg-gated 设计; - real-app 层仅 macOS 有覆盖(107 active / 42.8 pts),对应
a11y-macos-tree套件里针对 TextEdit/Finder/Obsidian 的真实应用探针。
关键流程矩阵(Critical Flow Matrix):11 条关键业务流的状态判定
core-engine-map.json 里声明了 11 条关键流程(Critical Flow),每条流程要求若干层(Required layers)。报告针对每个平台给出判定结果:covered (strong/partial; suite 列表) 或 weak。覆盖状态由 evaluateFlow() 计算:先找与流程匹配且活跃测试 > 0 的套件,再检查其层集合是否完整覆盖流程要求的全部层,最后看最佳置信度权重是否 ≥ partial(0.7),满足才算 covered,否则为 weak;没有任何匹配套件则为 gap,流程不适用的平台为 n/a。
| Flow | Required layers | windows | macos | linux |
|---|---|---|---|---|
| Settings to engine recording config | configuration | covered (strong; engine-config-lifecycle, db-accessibility-ui-events) | covered (strong; engine-config-lifecycle, db-accessibility-ui-events) | covered (strong; engine-config-lifecycle, db-accessibility-ui-events) |
| Engine health, sleep, and lifecycle | engine-lifecycle | covered (strong; engine-config-lifecycle, sqlite-coordinator-durable-quarantine) | covered (strong; engine-config-lifecycle, sqlite-coordinator-durable-quarantine) | covered (strong; engine-config-lifecycle, sqlite-coordinator-durable-quarantine) |
| Capture, OCR, and frame persistence | vision-capture, ocr | covered (partial; screen-capture-ocr-contract, screen-windows-ocr) | covered (strong; screen-capture-ocr-contract, screen-macos-ocr) | covered (partial; screen-capture-ocr-contract) |
| Timeline frame and stream delivery | timeline | covered (strong; engine-api-routes, engine-capture-timeline) | covered (strong; engine-api-routes, engine-capture-timeline) | covered (strong; engine-api-routes, engine-capture-timeline) |
| Local API search and indexing | local-api, db-search | covered (strong; engine-local-api-search-integration) | covered (strong; engine-local-api-search-integration) | covered (strong; engine-local-api-search-integration) |
| Audio record, transcribe, and reconcile | audio, transcription | covered (strong; audio-meetings-speakers-dedup, audio-transcription-pipeline) | covered (strong; audio-meetings-speakers-dedup, audio-transcription-pipeline) | covered (strong; audio-meetings-speakers-dedup, audio-transcription-pipeline) |
| Audio device and stream health | audio-device | covered (strong; audio-device-stream-health, audio-platform-output-capture) | covered (strong; audio-device-stream-health, audio-platform-output-capture) | covered (strong; audio-device-stream-health) |
| Meeting detection and live transcript merge | meeting | covered (strong; engine-meeting-privacy-sync, engine-api-routes) | covered (strong; engine-meeting-privacy-sync, engine-api-routes) | covered (strong; engine-meeting-privacy-sync, engine-api-routes) |
| Privacy filters, DRM guards, and redaction | privacy | covered (strong; engine-meeting-privacy-sync, screen-capture-windowing) | covered (strong; engine-meeting-privacy-sync, screen-capture-windowing) | covered (strong; engine-meeting-privacy-sync, screen-capture-windowing) |
| Accessibility tree and UI event capture | accessibility, ui-events | covered (strong; a11y-core-tree-cross-platform, a11y-windows-tree) | covered (strong; a11y-core-tree-cross-platform, db-accessibility-ui-events) | covered (strong; a11y-core-tree-cross-platform, db-accessibility-ui-events) |
| Performance, backpressure, and liveness | performance | covered (strong; engine-capture-timeline, screen-capture-windowing) | covered (strong; engine-capture-timeline, screen-capture-windowing) | covered (strong; engine-capture-timeline, screen-capture-windowing) |
这条矩阵基本勾勒出了 Screenpipe 引擎的完整业务骨架:配置下发 → 引擎生命周期 → 采集/OCR/落库 → 时间线交付 → 本地 API 搜索 → 音频录制/转写 → 音频设备健康 → 会议检测/实时转写 → 隐私过滤 → 无障碍树/UI 事件 → 性能与活性。
其中唯一的 partial 出现在 Capture, OCR, and frame persistence 的 windows 与 linux:windows 依赖 screen-capture-ocr-contract(partial)加 screen-windows-ocr,linux 只有 screen-capture-ocr-contract(partial),而 macOS 因有 screen-macos-ocr(strong)达到 strong——这正是平台 OCR 后端成熟度差异的直接体现。
关键缺口(Critical Gaps)与执行完整性(Execution Integrity)
关键缺口当前状态(以仓库检入版本为准):
- windows: no critical gaps in the current manifest.
- macos: no critical gaps in the current manifest.
- linux: no critical gaps in the current manifest.
执行完整性是这份报告防止"数据造假"的机制,共 5 条约束:
- 被跟踪 crate 中每一个发现的集成测试文件都已映射到某个套件;
- 每一个发现的源码单元测试文件也都已映射到某个套件;
- 集成测试与源码单元测试均由
--check模式强制校验(validateManifest() 中enforceMappedIntegrationTests与enforceMappedSourceTests均为 true); - 只有忽略/手动测试的套件:screen-custom-ocr(2 个忽略测试、0 个活跃测试),它在被显式运行前不贡献加权点;
- 静态计数不能证明测试真的在某个 CI runner 上执行过:平台
cfg门控、忽略测试、缺失设备与跳过的运行时路径,仍需要 job 结果或 llvm-cov 数据来确认。
套件清单(Suite Inventory):32 个套件速览
套件清单把 32 个套件的 crate、平台、层、流程、关键度、置信度、类型(unit/integration/manual/benchmark/mixed)、文件数与活跃/忽略测试逐一列出。以下按 crate 归类的速览(完整注释见原报告 docs/coverage/CORE.md):
screenpipe-engine(10 个套件)
| Suite | Platforms | Layers | Criticality / Confidence | Kind | Files | Active / Ignored |
|---|---|---|---|---|---|---|
| engine-api-routes | windows, macos, linux | local-api, timeline, meeting, transcription | high / partial | mixed | 40 | 406 / 4 |
| engine-capture-timeline | windows, macos, linux | vision-capture, timeline, storage, performance | high / partial | mixed | 25 | 301 / 26 |
| engine-config-lifecycle | windows, macos, linux | configuration, engine-lifecycle, performance | high / strong | mixed | 12 | 116 / 1 |
| engine-db-recovery-cli | windows, macos, linux | database, engine-lifecycle | high / strong | unit | 1 | 25 / 0 |
| engine-focus-os | windows, macos | engine-lifecycle, os-integration | medium / conditional | unit | 3 | 6 / 0 |
| engine-local-api-search-integration | windows, macos, linux | local-api, db-search | high / strong | integration | 1 | 8 / 5 |
| engine-meeting-privacy-sync | windows, macos, linux | meeting, privacy, ui-events, pipes, sync | medium / strong | unit | 32 | 504 / 3 |
| engine-meeting-watcher | windows, macos | meeting | high / strong | mixed | 10 | 262 / 3 |
| engine-retention-storage | windows, macos, linux | storage, engine-lifecycle, performance | medium / strong | mixed | 5 | 38 / 0 |
| engine-telemetry-observability | windows, macos, linux | engine-lifecycle, performance | medium / strong | unit | 6 | 30 / 0 |
screenpipe-db(5 个套件)
| Suite | Layers | Criticality / Confidence | Kind | Files | Active / Ignored |
|---|---|---|---|---|---|
| db-accessibility-ui-events | database, configuration, accessibility, ui-events, performance | medium / partial | integration | 7 | 27 / 2 |
| db-audio-meetings-speakers | database, audio, meeting, speaker | high / strong | integration | 15 | 113 / 1 |
| db-runtime-reliability | database, performance | high / partial | mixed | 13 | 36 / 6 |
| db-search-indexing | db-search, ocr, accessibility, performance | high / strong | mixed | 13 | 105 / 4 |
| db-timeline-frames | database, timeline, storage, performance | high / strong | mixed | 20 | 186 / 3 |
screenpipe-sqlite-coordinator(1 个套件)
| Suite | Layers | Criticality / Confidence | Kind | Files | Active / Ignored |
|---|---|---|---|---|---|
| sqlite-coordinator-durable-quarantine | database, engine-lifecycle | high / strong | unit | 3 | 27 / 0 |
screenpipe-audio(6 个套件)
| Suite | Layers | Criticality / Confidence | Kind | Files | Active / Ignored |
|---|---|---|---|---|---|
| audio-device-stream-health | audio-device, audio, performance | high / strong | mixed | 14 | 141 / 6 |
| audio-meetings-speakers-dedup | audio, meeting, speaker, transcription | high / strong | mixed | 26 | 249 / 8 |
| audio-models-filtering | audio, transcription, privacy | medium / partial | mixed | 6 | 20 / 10 |
| audio-pipeline-benchmarks | audio, transcription, performance | medium / partial | benchmark | 8 | 22 / 12 |
| audio-platform-output-capture | audio-device, audio, meeting | high / partial | unit | 7 | 75 / 1 |
| audio-transcription-pipeline | audio, transcription, performance | high / partial | mixed | 15 | 99 / 7 |
screenpipe-screen(6 个套件)
| Suite | Layers | Criticality / Confidence | Kind | Files | Active / Ignored |
|---|---|---|---|---|---|
| screen-capture-ocr-contract | vision-capture, ocr | high / partial | unit | 3 | 15 / 0 |
| screen-capture-windowing | vision-capture, timeline, performance, privacy | high / strong | mixed | 14 | 191 / 0 |
| screen-custom-ocr | ocr | medium / conditional | manual | 1 | 0 / 2 |
| screen-macos-ocr | ocr, vision-capture | high / strong | mixed | 2 | 9 / 1 |
| screen-monitor-platform | vision-capture | medium / partial | unit | 5 | 37 / 5 |
| screen-windows-ocr | ocr, vision-capture | high / partial | integration | 2 | 5 / 1 |
screenpipe-a11y(4 个套件)
| Suite | Layers | Criticality / Confidence | Kind | Files | Active / Ignored |
|---|---|---|---|---|---|
| a11y-core-tree-cross-platform | accessibility, ui-events, privacy, performance | high / strong | unit | 14 | 171 / 0 |
| a11y-linux-tree | accessibility, privacy | medium / partial | unit | 4 | 27 / 1 |
| a11y-macos-tree | accessibility, privacy, real-app, performance | high / conditional | mixed | 8 | 107 / 4 |
| a11y-windows-tree | accessibility, privacy, ui-events | high / partial | unit | 6 | 49 / 23 |
几个套件的设计细节值得一提:
- a11y-macos-tree 包含一个"100 个 case 的点击归属策略评分评估(click-attribution policy eval)"以及针对真实 TextEdit / Finder / Obsidian 的探针;点击归属与 Obsidian 真机测试因需要已登录桌面、应用安装或 AX 权限而默认忽略;
- engine-meeting-watcher 是
src/meeting_detector.rs与src/meeting_telemetry.rs的后继者,内含音频进程与 UI 扫描两条后端状态机;ui_scan/macos.rs、ui_scan/windows.rs为 cfg-gated,且 Linux 上两个后端均为 null(这是平台摘要中 Linux 套件数更少的直接原因之一); - engine-local-api-search-integration 用 1 个集成文件演示了最小闭环:构建一个禁用音频的路由器,向内存 DB 灌入"采集画面形状"的 OCR 数据,然后断言 HTTP 响应与分页;
- screen-capture-windowing 覆盖窗口过滤、空窗口回归、重试策略、URL 时机、显示器缓存、OCR 缓存、快照与图像比较,191 个活跃测试且 0 个忽略,是全清单中最"干净"的强置信套件之一;
- db-runtime-reliability 覆盖 SQLite 硬故障分类、failpoint VFS 注入、断线重连、WAL 混沌与内存压力探针,还包含对瞬时 IOERR 故障的只读隔离自愈验证(read-only quarantine self-heal)。
文件清单(File Inventory)的读法
报告末尾还有一张 341 行的文件级清单,列结构为:Suite | Crate | File | Scope | Active | Ignored | Declared,其中:
- Scope 区分
source(源码内单元测试)与integration(tests/目录集成测试); - 文件按
crate/路径字典序排列,同一套件下的所有文件会被合并统计。
例如 a11y-core-tree-cross-platform 套件映射了 src/tree/cache.rs、src/tree/macos.rs、src/url_filter.rs 等 14 个源文件;db-timeline-frames 套件映射了 src/write_queue.rs(36 active)以及 tests/db.rs(42 active)等。这张表的价值在于精确到文件的可追溯性:任何被跟踪 crate 中出现一个未被任何套件映射的测试文件,--check 会直接报错拒绝生成。
如何生成、校验与回归这份报告
docs/coverage/README.md 说明了整套命令。所有覆盖率脚本定义在 apps/screenpipe-app-tauri/package.json 中:
# 在 apps/screenpipe-app-tauri 目录下
bun run coverage:core # 仅生成核心引擎报告(docs/coverage/CORE.md)
bun run coverage:all # 先生成 E2E 覆盖率,再生成核心引擎报告,最后汇总到 COVERAGE.md
校验检入版本是否最新:
bun run coverage:core:check # 校验 CORE.md 未过期
bun run coverage:all:check # 校验 E2E + 核心 + 顶层汇总全部未过期
--check 模式(main())会读取现有报告,做 CRLF 归一化后逐字节比对;过期则抛错并提示重新生成。这保证了覆盖率地图与源码、清单永远同步,不会出现"报告和代码脱节"的漂移问题。
需要行级覆盖率时,先跑 cargo llvm-cov 生成 JSON,再传入 coverage:core(命令见前文"行覆盖率补充"一节)。
小结
Screenpipe 的核心引擎覆盖率地图是一套"防自欺"的工程度量体系:它以行为流为粒度、以平台 × 层为观察维度、以置信度 × 关键度为权重,并通过 --check 强制所有测试文件必须映射到套件。它不回答"代码覆盖了多少行",而是回答"用户关心的每一条关键链路,在每一个平台上,有多少可信的测试在守护"。对于想要深入 Screenpipe 源码、或者想为自己的多平台 Rust 项目搭建类似覆盖体系的开发者,docs/coverage/CORE.md 与其生成脚本 generate-core-engine-coverage-report.ts 本身就是一份可复用的工程模板。
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考



