dsh-flakefinder 0.4.23 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # 更新记录
2
2
 
3
+ ## 0.5.1 (2026-11-23)
4
+
5
+ - 将 `tools/pre-execute` 审批监听器纳入插件卸载清理(`disposers`),确保 `dispose` 与 `ctx.effect` 卸载释放,并补充单元测试。
6
+ - 在 `README.en.md` 补齐缺失的第 6 类根因模式 `intermittent`,在 `cordis.patch.yml` 补充 `graceMs` 注释,并修正 `docs/REFERENCE.{zh,en}.md` 语言切换链接与更新说明。
7
+ - Track the `tools/pre-execute` listener disposer in `disposers` for clean `dispose`/`ctx.effect` teardown (with unit tests); list the missing `intermittent` root-cause pattern in `README.en.md`, document `graceMs` in `cordis.patch.yml`, and align `docs/REFERENCE.{zh,en}.md` links and update policy wording.
8
+
9
+ ## 0.5.0 (2026-11-22)
10
+
11
+ - 核心正确性修复:修复混合 `stable-fail` + `flaky`(`passRuns=0`)误判稳定失败及合成 `(crash)`/`(timeout)` 失败率;单轮超时不再中断整批检测并区分宿主取消信号;新增 `lossy` 输出截断检测;升级层级 TAP 13 解析器(叶子用例去重、去除顺序号防并发串位、提取 YAML 耗时与堆栈)与 JUnit XML 严格校验;支持 Monorepo 向上查找 `node_modules`、工作区 `.venv`/`venv` 自动探测与 Windows 路径规范化。
12
+ - 诊断与执行力升级:新增报错指纹聚类与脱敏精简堆栈、每用例单轮时间线(`✓/✗/⏱/S/-`)、通过/失败耗时对比、6 类根因模式画像与 95% 置信度提示;`flaky_detect` 新增 `testName` 过滤、`mode`(`full` / `until-flaky` / `verify-fix`)早停、`concurrency`(1–4)、`shuffle`/`seed` 随机顺序复现与 `noCoverage` 默认跳过覆盖率;抽离 `FrameworkAdapter` 注册表架构。
13
+ - 工作区隔离与闭环联动:检测历史按工作区独立存储(保留 `scope=all` 兼容旧记录);修复 `.flakefinder.json` 隔离写入匹配缺陷并保留首次 `since`、新增可选 `updatedAt`/`issue`/`lastFailureRate` 与相对 POSIX 路径归一化;`flaky_detect` 自动标注 `[新增未隔离]`/`[已隔离]`/可消单候选,`flaky_report` 新增高频不稳定 Top N 榜单与超期未复查提醒;丰富审批弹窗内容,升级 `flaky_health` 为工作区感知自检。
14
+ - Core correctness & reliability fixes: ensure test-level `flakyCount > 0` always yields top-level `flaky` verdict; record per-run timeouts gracefully without aborting remaining runs (preserving host abort cancellation); detect `lossy` output truncation; upgrade to a hierarchical TAP 13 + YAML diagnostics parser with deterministic order-independent leaf IDs and strict JUnit XML validation; add upward monorepo `node_modules` and workspace `.venv`/`venv` discovery plus Windows path normalization.
15
+ - Diagnostics & execution controls: add secret-redacted error fingerprinting with compact representative stacks, per-test timelines, pass-vs-fail duration stats, 6 root-cause pattern heuristics, and 95% confidence upper bounds; extend `flaky_detect` with `testName`, `mode` (`full` / `until-flaky` / `verify-fix`), `concurrency` (1–4), `shuffle`/`seed`, and `noCoverage` (default `true`); extract the `FrameworkAdapter` registry.
16
+ - Workspace isolation & quarantine feedback loop: isolate history per workspace (with `scope=all` legacy compatibility); fix quarantine add/update matching while preserving original `since` and enforcing relative POSIX paths; cross-annotate `flaky_detect` with new/quarantined/clear-candidate items; add Top-N hotspots and stale-quarantine warnings in `flaky_report`; enrich approval prompts and make `flaky_health` workspace-aware.
17
+
3
18
  ## 0.4.23 (2026-11-20)
4
19
 
5
20
  - 升级共享更新组件至 0.2.10,移除跨插件右下角浮动提醒,保留工作台及插件详情页更新控制。
package/README.en.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  # FlakeFinder
4
4
 
5
- **Turn intermittent test failures into traceable evidence.**
5
+ > **Turn intermittent test failures into quantified, diagnosable, traceable evidence.**
6
6
 
7
- Flaky test investigation plugin for DeepSeek Harness (`>=0.2.2-rc.3`): runs Vitest, Jest, pytest, and `node:test` repeatedly, tracks failure rates across runs, and manages approval-gated workspace quarantine lists.
7
+ Flaky test investigation plugin for DeepSeek Harness (`>=0.2.2-rc.3`) supporting Vitest, Jest, pytest, and `node:test` with root-cause heuristics and approval-gated quarantine tracking.
8
8
 
9
9
  [![npm](https://img.shields.io/npm/v/dsh-flakefinder)](https://www.npmjs.com/package/dsh-flakefinder) [![downloads](https://raw.githubusercontent.com/STARDUSTLC666/dsh-suite/npm-downloads/assets/dsh-flakefinder-downloads.svg)](https://www.npmjs.com/package/dsh-flakefinder) [![total downloads](https://raw.githubusercontent.com/STARDUSTLC666/dsh-suite/npm-downloads/assets/dsh-flakefinder-total-downloads.svg)](https://www.npmjs.com/package/dsh-flakefinder)
10
10
 
11
- **[Install](#install) · [Workflow](#start-using-it) · [Full guide](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.en.md)**
11
+ **[Features](#features) · [Install](#install) · [Workflow](#start-using-it) · [Full guide](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.en.md)**
12
12
 
13
13
  <picture>
14
14
  <source media="(prefers-color-scheme: dark) and (max-width: 640px)" srcset="https://raw.githubusercontent.com/STARDUSTLC666/dsh-flakefinder/master/docs/assets/intro/workflow-en-mobile-dark.svg">
@@ -19,54 +19,49 @@ Flaky test investigation plugin for DeepSeek Harness (`>=0.2.2-rc.3`): runs Vite
19
19
 
20
20
  ## Features
21
21
 
22
- - Investigate Vitest, Jest, pytest and node:test runs.
23
- - Keep each run’s outcome and failure history.
24
- - Narrow the cause using differences and maintain quarantine lists.
22
+ | Pillar | Capabilities |
23
+ | :--- | :--- |
24
+ | **Multi-Runner Support** | Supports Vitest, Jest, pytest, and `node:test` with upward monorepo resolution and automatic workspace `.venv` detection |
25
+ | **Resilient Run Controls** | Targeted `testName` filters, early-stop modes (`until-flaky` / `verify-fix`), 1–4 worker concurrency & reproducible order shuffling (`shuffle`/`seed`) |
26
+ | **Root-Cause Diagnostics** | Deduplicates redacted stack traces, renders pass/fail timelines, infers 6 root-cause patterns (cold-start, state-leak, timeout-race, order-dependent, teardown-crash, intermittent) & reports 95% confidence bounds |
27
+ | **Workspace Quarantine** | Keeps per-workspace history, cross-checks `.flakefinder.json` quarantine lists, surfaces Top-N hotspots & stale reminders, and gates writes behind explicit approval prompts |
25
28
 
26
29
  ## Install
27
30
 
28
- Open **Plugins** in the DSH desktop app and install `dsh-flakefinder`. If the CLI is available:
31
+ Open **Plugins** in the DSH desktop app and install `dsh-flakefinder`, or use the CLI:
29
32
 
30
33
  ```bash
31
34
  dsh plugin --profile desktop add dsh-flakefinder
32
35
  ```
33
36
 
34
- For the web profile, replace `desktop` with `web`. Restart that DSH profile after installation. The package’s DSH requirement is `>=0.2.2-rc.3`.
37
+ For the web profile, replace `desktop` with `web` and restart DSH. Requires DSH `>=0.2.2-rc.3`.
35
38
 
36
39
  ## Start using it
37
40
 
38
- When a test passes locally but fails intermittently in CI, turn guesswork into repeatable evidence in four steps:
41
+ 1. **Target the suspect test**: Name the intermittent test file or case inside your repository session.
42
+ 2. **Repeat & capture evidence**: Run 10–20 iterations to quantify failure rates, stack clusters, and timing deltas.
43
+ 3. **Fix or quarantine**: Patch timing/state issues from root-cause hints, or approve adding the case to `.flakefinder.json` while fixing.
44
+ 4. **Verify & clear**: Re-run the exact loop after fixing and remove the test from quarantine once green.
39
45
 
40
- 1. **Point at the suspect test**: Open a session in the repo and name the flaky test file or suite (supports Vitest, Jest, pytest, and `node:test`).
41
- 2. **Repeat & capture failure rate**: Ask the assistant to repeat the target test 10–20 times, recording pass/fail ratios and preserving failure stack traces.
42
- 3. **Isolate root cause or quarantine**: Compare passing vs. failing runs to spot timing races or shared state; if needed, approve adding the test to `.flakefinder.json` while working on a fix.
43
- 4. **Verify the fix with the same loop**: Re-run the exact repeat count after patching and clear the test from the quarantine list once confirmed stable.
46
+ ### Ready-to-copy prompts
44
47
 
45
- Ready-to-copy prompts:
46
-
47
- - **Reproduce an intermittent failure**: `test/checkout.spec.ts fails sporadically in CI — repeat just that file 15 times, report the failure rate, and summarize what differs on failed runs.`
48
- - **Check existing flaky inventory**: `Show the recorded flaky test history and current quarantine list for this repo.`
49
- - **Verify fix & unquarantine**: `Re-run that test 20 times after my timer cleanup fix, and remove it from quarantine once all runs pass.`
48
+ - **Reproduce flakiness**: `test/checkout.spec.ts fails sporadically in CI — repeat just that file 15 times, report the failure rate, and summarize what differs on failed runs.`
49
+ - **Check flaky hotspots**: `Show the recorded flaky test history and current quarantine list for this repo.`
50
+ - **Verify & clear**: `Re-run that test 20 times after my timer cleanup fix, and remove it from quarantine once all runs pass.`
50
51
 
51
52
  ## Before you start
52
53
 
53
- Repeated tests execute real project commands. Failure to reproduce is not proof that a flaky issue is absent.
54
-
55
- Configuration, detailed tools and troubleshooting: [full reference](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.en.md).
54
+ - Repeated runs execute real project test commands; non-reproduction does not guarantee zero flakiness.
55
+ - Full configuration, tools, and troubleshooting: [full reference](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.en.md).
56
56
 
57
57
  ## Plugin updates
58
58
 
59
- Check updates at the bottom of the workbench or native plugin details. Automatic checks are on by default; **automatic installation is off**. You choose whether to install and when to restart. Suite-managed components update with their bundle. [Update behavior](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.en.md).
60
-
61
- ## Documentation
62
-
63
- - [Full usage, configuration and limits](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.en.md)
64
- - [Release notes](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/CHANGELOG.md)
65
- - [Validation scope and history](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/VALIDATION.md)
59
+ Check updates at the bottom of native plugin details. Automatic checks are on by default; **automatic installation is off**. Suite-managed components update with their bundle.
66
60
 
67
- ## Feedback and contributions
61
+ ## Documentation & feedback
68
62
 
69
- If the plugin helps, a Star makes it easier for others to discover. Report problems or suggest improvements in [Issues](https://github.com/STARDUSTLC666/dsh-flakefinder/issues); code and documentation [PRs](https://github.com/STARDUSTLC666/dsh-flakefinder/pulls) are welcome. Include versions and reproduction steps, and remove credentials from reports.
63
+ - [Full usage, configuration and limits](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.en.md) · [Release notes](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/CHANGELOG.md) · [Validation history](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/VALIDATION.md)
64
+ - Stars, [Issues](https://github.com/STARDUSTLC666/dsh-flakefinder/issues), and [PRs](https://github.com/STARDUSTLC666/dsh-flakefinder/pulls) are welcome (strip credentials first).
70
65
 
71
66
  ## License
72
67
 
package/README.md CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  # FlakeFinder
4
4
 
5
- **把偶发失败变成有记录、能继续排查的线索。**
5
+ > **把“本地能过、CI 偶发飘红”的测试,变成可量化、可追踪、可根治的证据。**
6
6
 
7
- DeepSeek Harness(`>=0.2.2-rc.3`)偶发测试排查插件:面向 Vitest、Jest、pytest 与 `node:test` 提供多轮复跑、失败率统计、历史追踪及受宿主审批保护的工作区隔离清单管理。
7
+ DeepSeek Harness(`>=0.2.2-rc.3`)偶发测试诊断插件:支持 Vitest、Jest、pytest 与 `node:test` 多轮复跑、根因模式画像与受宿主审批保护的隔离清单管理。
8
8
 
9
9
  [![npm](https://img.shields.io/npm/v/dsh-flakefinder)](https://www.npmjs.com/package/dsh-flakefinder) [![downloads](https://raw.githubusercontent.com/STARDUSTLC666/dsh-suite/npm-downloads/assets/dsh-flakefinder-downloads.svg)](https://www.npmjs.com/package/dsh-flakefinder) [![total downloads](https://raw.githubusercontent.com/STARDUSTLC666/dsh-suite/npm-downloads/assets/dsh-flakefinder-total-downloads.svg)](https://www.npmjs.com/package/dsh-flakefinder)
10
10
 
11
- **[安装使用](#安装) · [使用流程](#开始使用) · [完整说明](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.zh.md)**
11
+ **[核心能力](#核心能力) · [安装](#安装) · [快速上手](#开始使用) · [完整说明](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.zh.md)**
12
12
 
13
13
  <picture>
14
14
  <source media="(prefers-color-scheme: dark) and (max-width: 640px)" srcset="https://raw.githubusercontent.com/STARDUSTLC666/dsh-flakefinder/master/docs/assets/intro/workflow-zh-mobile-dark.svg">
@@ -17,56 +17,51 @@ DeepSeek Harness(`>=0.2.2-rc.3`)偶发测试排查插件:面向 Vitest、J
17
17
  <img src="https://raw.githubusercontent.com/STARDUSTLC666/dsh-flakefinder/master/docs/assets/intro/workflow-zh-light.svg" alt="把偶发失败变成有记录、能继续排查的线索。 · 流程示意" width="100%">
18
18
  </picture>
19
19
 
20
- ## 功能
20
+ ## 核心能力
21
21
 
22
- - 支持 Vitest、Jest、pytest 与 node:test 调查。
23
- - 保留每轮结果与失败历史。
24
- - 依据差异继续定位,并管理隔离清单。
22
+ | 模块 | 核心特性 |
23
+ | :--- | :--- |
24
+ | **多框架自动适配** | 原生支持 Vitest、Jest、pytest 与 `node:test`,自动向上解析 Monorepo 框架并探测工作区 `.venv` |
25
+ | **弹性复跑控制** | 支持用例名过滤(`testName`)、早停模式(`until-flaky` / `verify-fix`)、1–4 路并发与可复现随机乱序(`shuffle`/`seed`) |
26
+ | **根因诊断画像** | 自动聚类报错并脱敏堆栈,输出通过/失败时间线、6 类根因模式(冷启动/状态泄漏/超时竞态/顺序依赖/清理崩溃等)与 95% 置信度 |
27
+ | **工作区隔离与清单** | 按工作区独立留存历史,交叉对照 `.flakefinder.json` 隔离清单,输出高频 Top 榜与超期未复查提醒,写入经宿主审批弹窗确认 |
25
28
 
26
29
  ## 安装
27
30
 
28
- 在 DSH 桌面版「插件」面板安装 `dsh-flakefinder`。已配置命令行时也可使用:
31
+ 在 DSH 桌面版「插件」面板安装 `dsh-flakefinder`,或使用命令行:
29
32
 
30
33
  ```bash
31
34
  dsh plugin --profile desktop add dsh-flakefinder
32
35
  ```
33
36
 
34
- 网页版把 `desktop` 改为 `web`;安装后重启对应的 DSH。宿主要求以包声明 `>=0.2.2-rc.3` 为准。
37
+ 网页版将 `desktop` 改为 `web`,安装后重启 DSH。宿主要求:`>=0.2.2-rc.3`。
35
38
 
36
39
  ## 开始使用
37
40
 
38
- 遇到「本地跑通、CI 偶发飘红」的测试时,按四步抓出现场证据:
41
+ 1. **锁定怀疑对象**:在项目会话中指定偶发失败的测试文件或用例名。
42
+ 2. **多轮复跑抓现场**:让助手连续跑 10–20 轮,自动统计失败率并留存报错聚类与时序差异。
43
+ 3. **定位根因或临时隔离**:依据根因画像修复竞态/状态污染;需临时止血时经审批写入 `.flakefinder.json` 跟踪。
44
+ 4. **同口径复测消单**:修完后按相同轮次复跑验证全绿,并移出隔离清单。
39
45
 
40
- 1. **锁定怀疑对象**:在项目仓库打开会话,告诉助手是哪个测试文件或测试名称偶发失败(支持 Vitest、Jest、pytest 与 `node:test`)。
41
- 2. **多轮复跑抓现场**:让助手对目标用例连续跑 10–20 轮,自动统计失败率并留存失败轮次的完整堆栈与差异日志。
42
- 3. **定位竞态 / 临时隔离**:根据成功轮与失败轮的时序或状态污染差异定位根因;若短期需要止血,可在你审批后写入 `.flakefinder.json` 隔离清单集中跟踪。
43
- 4. **修复后同口径复测**:改完代码再用相同轮次复跑验证全绿,并清理已修复的隔离记录。
44
-
45
- 常用场景怎么对助手说(可直接复制):
46
+ ### 常用对话示例
46
47
 
47
48
  - **复现偶发红单**:`test/checkout.spec.ts 在 CI 偶尔超时失败,帮我单独连续跑 15 轮统计失败率,并对比失败轮的报错差异。`
48
- - **全仓稳定性摸底**:`查看当前仓库的历史偶发失败记录和隔离清单,汇总最不稳定的前三个用例。`
49
- - **修完回归消单**:`我已经修了异步定时器未清理的问题,再用同样参数连跑 20 轮确认稳定通过,通过后把它移出隔离清单。`
49
+ - **稳定性摸底**:`查看当前仓库的历史偶发失败记录和隔离清单,汇总最不稳定的前三个用例。`
50
+ - **修完回归消单**:`我已修复异步定时器未清理问题,用同样参数连跑 20 轮确认稳定通过,通过后移出隔离清单。`
50
51
 
51
52
  ## 开始前要知道
52
53
 
53
- 重复测试会实际执行项目命令。未复现不等于不存在偶发问题。
54
-
55
- 配置、完整工具与排错见[详细使用说明](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.zh.md)。
54
+ - 复跑会真实执行项目测试命令;多轮未复现并不绝对证明偶发缺陷不存在。
55
+ - 详细配置、工具与排错见 [完整说明](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.zh.md)。
56
56
 
57
57
  ## 插件更新
58
58
 
59
- 在工作台或原生插件详情页底部检查更新。默认自动检查,**默认不自动安装**;是否安装、何时重启由你决定。Suite 管理的组件随整包更新。[查看更新规则](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.zh.md)。
60
-
61
- ## 文档
62
-
63
- - [详细使用、配置与边界](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.zh.md)
64
- - [更新记录](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/CHANGELOG.md)
65
- - [验证范围与历史](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/VALIDATION.md)
59
+ 在原生插件详情页底部检查更新。默认自动检查,**默认不自动安装**;Suite 管理的组件随整包更新。
66
60
 
67
- ## 反馈与贡献
61
+ ## 文档与反馈
68
62
 
69
- 如果插件帮到了你,欢迎 Star,让更多人发现它。问题和建议请提交 [Issues](https://github.com/STARDUSTLC666/dsh-flakefinder/issues),也欢迎代码与文档 [PR](https://github.com/STARDUSTLC666/dsh-flakefinder/pulls)。反馈时附上版本与复现步骤,并移除凭据。
63
+ - [完整使用、配置与边界](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/REFERENCE.zh.md) · [更新记录](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/CHANGELOG.md) · [验证历史](https://github.com/STARDUSTLC666/dsh-flakefinder/blob/master/docs/VALIDATION.md)
64
+ - 欢迎 Star、提交 [Issues](https://github.com/STARDUSTLC666/dsh-flakefinder/issues) 与 [PR](https://github.com/STARDUSTLC666/dsh-flakefinder/pulls)(反馈请附版本与复现步骤,并移除凭据)。
70
65
 
71
66
  ## License
72
67
 
package/cordis.patch.yml CHANGED
@@ -5,12 +5,17 @@
5
5
  # - id: flakefinder
6
6
  # name: 'dsh-flakefinder'
7
7
  # config:
8
- # defaultRuns: 5 # flaky_detect 默认重复次数(3-20)
9
- # timeoutMs: 120000 # 单次测试运行超时(毫秒)
10
- # writeApproval: true # quarantine/clear 是否走审批门(默认 true)
11
- # dataDir: '' # 历史存储目录(默认 DSH_HOME/.dsh-flakefinder)
12
- # quarantineFile: '' # 隔离清单(默认项目根 .flakefinder.json)
13
- # pythonPath: '' # pytest 使用的 Python 解释器(默认 python/python3)
8
+ # defaultRuns: 5 # flaky_detect 默认重复次数(3-20)
9
+ # maxRuns: 20 # 单次运行允许的最大重复次数(3-50)
10
+ # defaultConcurrency: 1 # flaky_detect 默认并发 worker 数(1-4)
11
+ # noCoverage: true # 默认关闭覆盖率采集以加速复跑(Vitest/Jest 生效)
12
+ # staleQuarantineDays: 14 # 隔离清单条目超期未复查提醒天数(1-365)
13
+ # timeoutMs: 120000 # 单次测试运行超时(毫秒)
14
+ # graceMs: 10000 # 超时或取消后等待测试进程优雅退出的宽限时间(毫秒,1 秒 - 2 分钟)
15
+ # writeApproval: true # quarantine/clear 是否走审批门(默认 true)
16
+ # dataDir: '' # 历史存储目录(默认 DSH_HOME/.dsh-flakefinder)
17
+ # quarantineFile: '' # 隔离清单(默认工作区根 .flakefinder.json)
18
+ # pythonPath: '' # pytest 使用的 Python 解释器(默认自动探测 .venv / python/python3)
14
19
  #
15
20
  - insert:
16
21
  - id: flakefinder
@@ -2,7 +2,7 @@
2
2
 
3
3
  # dsh-flakefinder
4
4
 
5
- [中文](../README.md)
5
+ [中文](./REFERENCE.zh.md)
6
6
 
7
7
  ![dsh-flakefinder whale girl plugin cover](https://raw.githubusercontent.com/STARDUSTLC666/dsh-flakefinder/master/assets/cover-whale-girl.png)
8
8
 
@@ -16,9 +16,10 @@ Feedback and contributions are welcome: report [issues](https://github.com/STARD
16
16
 
17
17
  ## What it does
18
18
 
19
- - Support Vitest, Jest, pytest and node:test.
20
- - Track repeated run results and failure history.
21
- - Generate and maintain a quarantine list.
19
+ - Support Vitest, Jest, pytest, and `node:test` (including monorepo upward module lookup, hierarchical TAP 13 diagnostics, and automatic workspace `.venv` discovery).
20
+ - Support targeted filtering (`testName`), `until-flaky` / `verify-fix` early stopping, bounded concurrency (1–4), coverage disabled by default, and `shuffle` / `seed` order randomization.
21
+ - Provide deduplicated error clusters with secret-redacted stacks, per-run timelines, duration stats, root-cause pattern hints, 95% confidence bounds, and quarantine cross-annotation.
22
+ - Isolate detection history per workspace, summarize top flaky hotspots and stale quarantine items, and run workspace-aware `flaky_health` diagnostics.
22
23
 
23
24
  ## Install
24
25
 
@@ -52,7 +53,7 @@ Detailed configuration, tool arguments and troubleshooting are in the [usage gui
52
53
 
53
54
  ## Plugin updates
54
55
 
55
- Requires DSH 0.2.2-rc.3 or newer. Update controls sit at the bottom of the existing workbench, or native plugin details for plugins without a workbench. Checks, release notes and preferences expand in place, with no separate update page or settings menu. Automatic checks are on by default; **automatic installation is off by default**. Only explicit opt-in permits compatible stable patches while idle with no unsaved changes. Preferences are independent, with per-plugin disable, deferral and ignore controls. No forced DSH restart or upgrade, and local-source installations stay unchanged. Suite components explain and operate on the whole Suite in the same footer.
56
+ Requires DSH 0.2.2-rc.3 or newer. Update controls sit at the bottom of the existing workbench, or native plugin details for plugins without a workbench. Checks, release notes and preferences expand in place, with no separate update page or settings menu. Automatic checks are on by default; **automatic installation is off by default**. Only explicit opt-in permits compatible stable updates (compatible minor and patch releases by default, or patch-only) while idle with no unsaved changes. Preferences are independent, with per-plugin disable, deferral and ignore controls. No forced DSH restart or upgrade, and local-source installations stay unchanged. Suite components explain and operate on the whole Suite in the same footer.
56
57
 
57
58
  Older releases need one manual update in native plugin management to acquire these controls. Publishing to npm does not replace an existing user installation.
58
59
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # dsh-flakefinder
4
4
 
5
- [English](../README.en.md)
5
+ [English](./REFERENCE.en.md)
6
6
 
7
7
  ![dsh-flakefinder 鲸鱼娘插件封面](https://raw.githubusercontent.com/STARDUSTLC666/dsh-flakefinder/master/assets/cover-whale-girl.png)
8
8
 
@@ -16,9 +16,10 @@
16
16
 
17
17
  ## 功能
18
18
 
19
- - 支持 Vitest、Jest、pytest 和 node:test。
20
- - 记录重复运行结果与失败历史。
21
- - 生成和维护用例隔离清单。
19
+ - 支持 Vitest、Jest、pytest 与 `node:test`(含 monorepo 向上查找依赖、`node:test` 层级 TAP 13 诊断解析与工作区 `.venv` 自动探测)。
20
+ - 支持精准用例过滤(`testName`)、`until-flaky` / `verify-fix` 早停、受控并发(1–4 路)、默认跳过覆盖率与 `shuffle` / `seed` 顺序打乱。
21
+ - 输出去重错误聚类(带密钥脱敏堆栈)、时间线、耗时分布、根因模式标签、95% 置信度提示与隔离清单交叉对照。
22
+ - 按工作区隔离历史记录,汇总高频不稳定 Top 榜单与超期未复查隔离项,并提供工作区感知的 `flaky_health` 自检。
22
23
 
23
24
  ## 安装
24
25
 
@@ -52,7 +53,7 @@ dsh plugin --profile desktop add dsh-flakefinder
52
53
 
53
54
  ## 插件更新
54
55
 
55
- 需要 DSH 0.2.2-rc.3 或更新版本。更新控件直接位于原有工作台内容末尾;没有工作台的插件,位于原生插件详情页底部。检查、更新记录和偏好在原地展开,不增加独立更新页面或设置菜单。自动检查默认开启;**自动安装默认关闭**,明确授权后才会在空闲且没有未保存修改时安装兼容的稳定补丁。开关按插件独立保存,可关闭、推迟或忽略提醒;不会强制重启 DSH、升级 DSH 本体或替换本地源码安装。Suite 组件在当前页面底部明确说明并操作 Suite 整包更新。
56
+ 需要 DSH 0.2.2-rc.3 或更新版本。更新控件直接位于原有工作台内容末尾;没有工作台的插件,位于原生插件详情页底部。检查、更新记录和偏好在原地展开,不增加独立更新页面或设置菜单。自动检查默认开启;**自动安装默认关闭**,明确授权后才会在空闲且没有未保存修改时安装兼容的稳定版本(默认涵盖兼容的小版本与补丁更新,也可限定为仅补丁)。开关按插件独立保存,可关闭、推迟或忽略提醒;不会强制重启 DSH、升级 DSH 本体或替换本地源码安装。Suite 组件在当前页面底部明确说明并操作 Suite 整包更新。
56
57
 
57
58
  旧版用户先在官方插件管理中手动更新一次,之后才会获得此入口。发布到 npm 不会直接替换用户已经安装的版本。
58
59
 
package/docs/USAGE.en.md CHANGED
@@ -2,25 +2,50 @@
2
2
 
3
3
  ## Confirmation in Full Access
4
4
 
5
- The plugin keeps its confirmation requirement. With approval policy `never`, it reports that confirmation is unavailable and performs no write. Switch to a mode that can ask, or explicitly set `writeApproval: false` yourself. Host denials still apply.
5
+ The plugin keeps its confirmation requirement and displays the full list of tests to be quarantined or cleared (plus reason/issue for `flaky_quarantine`) inside the approval prompt. With approval policy `never`, it reports that confirmation is unavailable and performs no write. Switch to a mode that can ask, or explicitly set `writeApproval: false` yourself. Host denials still apply.
6
6
 
7
7
  [Overview](../README.en.md) · [Changelog](../CHANGELOG.md) · [Validation](VALIDATION.md)
8
8
 
9
- ## Current improvements
9
+ ## Highlights
10
10
 
11
- Relative quarantineFile defaults to .flakefinder.json in the current workspace. Cancellation stops the current process. Concurrent writers preserve history and quarantine entries; damaged files are preserved with explicit errors for inspection.
11
+ - **Workspace-aware & isolated**: Detection history is stored per workspace under `dataDir/workspaces/<hash>.json` (while remaining compatible with legacy `history.json`). Relative `quarantineFile` defaults to `.flakefinder.json` in the active session workspace, normalizing paths to workspace-relative POSIX paths and rejecting out-of-workspace absolute paths.
12
+ - **Fast targeted reruns**: Supports test-name filtering (`testName`), early-stop modes (`until-flaky` / `verify-fix`), bounded concurrency (`1`–`4` workers), coverage disabled by default (`noCoverage`), and order shuffling with reproducible seeds (`shuffle` / `seed`).
13
+ - **Root-cause diagnostics & confidence**: Deduplicates failures into error clusters (normalizing timestamps/UUIDs/ports and redacting secrets in stacks), renders per-run timelines (`✓`/`✗`/`⏱`/`S`/`-`), compares passing vs. failing durations, infers 6 flake patterns (`cold-start`, `state-leak`, `timeout-race`, `order-dependent`, `teardown-crash`, `intermittent`), and prints 95% confidence upper bounds on all-pass runs.
14
+ - **Quarantine loop & reporting**: `flaky_detect` cross-checks `.flakefinder.json` to tag `[新增未隔离]` / `[已隔离]` flaky tests and surface `clearCandidates`; `flaky_report` adds top flaky hotspots and stale quarantine reminders.
15
+ - **Safety & resilience**: Cancellation aborts active test processes without writing partial history; concurrent writes use `proper-lockfile`; corrupt JSON files fail loudly while preserving the original file; payloads with >60 tests automatically cap `stable-pass` entries to protect context size.
12
16
 
13
17
  ## Tools
14
18
 
15
19
  | Tool | Purpose | Write |
16
20
  | :-- | :-- | :-- |
17
- | `flaky_detect` | Repeat tests N times and classify stable-pass / stable-fail / flaky | history only |
18
- | `flaky_history` | Query detection history, filter by target | no |
19
- | `flaky_report` | Combine quarantine manifest and history into a report | no |
20
- | `flaky_quarantine` | Write flaky cases to `.flakefinder.json` | yes (approval) |
21
- | `flaky_clear` | Remove recovered cases from the manifest | yes (approval) |
22
-
23
- Frameworks: vitest / jest / pytest (setup.cfg / pyproject / pytest.ini / tox.ini) / node:test, auto-detected in that order. JUnit XML entities and TAP SKIP directives are parsed.
21
+ | `flaky_detect` | Repeat tests N times with timeline, error clusters, root-cause patterns, and quarantine sync | history only |
22
+ | `flaky_history` | Query detection history, filter by `target`, switch `scope` (`workspace` / `all`) | no |
23
+ | `flaky_report` | Combine quarantine manifest, top flaky hotspots, stale quarantine alerts, and history | no |
24
+ | `flaky_quarantine` | Add or update flaky entries in `.flakefinder.json` (with optional `issue` / `lastFailureRate`) | yes (approval) |
25
+ | `flaky_clear` | Remove recovered cases from the quarantine manifest | yes (approval) |
26
+ | `flaky_health` | Workspace-aware health check: Node version, detected frameworks, Python/pytest, store readability, defaults | no |
27
+
28
+ ### `flaky_detect` parameters
29
+
30
+ | Parameter | Type | Default | Description |
31
+ | :-- | :-- | :-- | :-- |
32
+ | `target` | `string` (required) | — | Test file, directory, or glob relative to workspace (cannot start with `-`) |
33
+ | `framework` | `enum` | `auto` | `auto` / `vitest` / `jest` / `pytest` / `node` (aliases `node:test`, `py` also accepted) |
34
+ | `runs` | `integer` | `defaultRuns` | Repeat count (`3`–`maxRuns`) |
35
+ | `testName` | `string` | — | Filter tests by name/pattern (Vitest/Jest `-t`, pytest `-k`, `node:test` `--test-name-pattern`) |
36
+ | `mode` | `enum` | `full` | `full` (run all) / `until-flaky` (stop once flake confirmed) / `verify-fix` (stop on first failure) |
37
+ | `concurrency` | `integer` | `defaultConcurrency` | Worker concurrency (`1`–`4`) |
38
+ | `shuffle` | `boolean` | `false` | Randomize test order (Vitest/Jest; generates a distinct seed per run if `seed` is omitted) |
39
+ | `seed` | `integer` | — | Explicit RNG seed (`0`–`2147483647`) for reproducible shuffled runs |
40
+ | `noCoverage` | `boolean` | `noCoverage` config | Disable coverage collection during reruns (Vitest/Jest, default `true`) |
41
+
42
+ ### Supported frameworks
43
+
44
+ - **vitest**: Walks up from workspace to locate hoisted `node_modules/vitest/vitest.mjs`; JSON reporter; supports `-t`, `--coverage.enabled=false`, `--sequence.shuffle --sequence.seed=...`.
45
+ - **jest**: Walks up to locate `node_modules/jest/bin/jest.js`; `--json --outputFile`; uses `--runInBand` when serial and unshuffled; supports `-t`, `--coverage=false`, `--randomize --seed=...`.
46
+ - **pytest**: Resolves Python in priority order `explicit pythonPath > DSH_FLAKEFINDER_PYTHON > VIRTUAL_ENV > workspace .venv/venv > platform default`, runs `python -m pytest -q --junitxml=...` with `-k`, CDATA/XML entity decoding, and `<system-err>` fallback.
47
+ - **node:test**: Runs `node --test --test-reporter=tap` with `--test-name-pattern=...`, hierarchical TAP 13 + YAML diagnostic block parsing, `SKIP`/`TODO` handling, and `Bail out!` detection.
48
+ - `framework: auto` detects in order: `vitest → jest → pytest → node:test`.
24
49
 
25
50
  ## Install
26
51
 
@@ -39,30 +64,56 @@ Then restart the web service. To clean up fully, also remove the plugin entry fr
39
64
  ## Example
40
65
 
41
66
  ```text
42
- User: src/checkout.test.ts keeps failing recently, is it real?
67
+ User: The timer test in src/checkout.test.ts keeps flaking in CI, can you investigate?
68
+ Agent:
69
+ flaky_detect(target="src/checkout.test.ts", testName="timer restore", runs=10, concurrency=2, mode="until-flaky")
70
+ -> verdict: flaky (ran 4/10; timeline ✓✓✗✓; pattern: timeout-race; clustered TimeoutError)
71
+ -> flaky_quarantine(tests=["src/checkout.test.ts > timer restore"], reason="timer race", issue="#12", lastFailureRate=25)
72
+
73
+ User: Fixed the timer cleanup — please verify it stays green.
43
74
  Agent:
44
- flaky_detect(target="src/checkout.test.ts", runs=5)
45
- -> verdict: flaky (3/5 passed; failures cluster on fake timers)
46
- -> flaky_quarantine(tests=["src/checkout.test.ts > timer restore"], reason="timer race")
75
+ flaky_detect(target="src/checkout.test.ts", testName="timer restore", runs=15, mode="verify-fix")
76
+ -> verdict: stable-pass (95% confidence residual flake rate <= 18.1%; clear candidate detected)
77
+ -> flaky_clear(tests=["src/checkout.test.ts > timer restore"])
47
78
  ```
48
79
 
49
80
  ## Config
50
81
 
51
- See `cordis.patch.yml`; defaults: `defaultRuns=5`, `maxRuns=20`, `timeoutMs=120000`, `writeApproval=true`, `pythonPath=python` (`python3` on Linux/macOS; used for pytest runs).
82
+ See `cordis.patch.yml`. Key options:
83
+
84
+ | Field | Default | Description |
85
+ | :-- | :-- | :-- |
86
+ | `defaultRuns` | `5` | Default rerun count for `flaky_detect` (`3`–`20`) |
87
+ | `maxRuns` | `20` | Maximum allowed rerun count (`3`–`50`) |
88
+ | `defaultConcurrency` | `1` | Default worker concurrency (`1`–`4`) |
89
+ | `noCoverage` | `true` | Disable coverage collection during Vitest/Jest reruns |
90
+ | `staleQuarantineDays` | `14` | Days before a quarantine entry is flagged as stale in `flaky_report` (`1`–`365`) |
91
+ | `timeoutMs` | `120000` | Per-run timeout in milliseconds (`10000`–`600000`) |
92
+ | `graceMs` | `10000` | Grace period after timeout (`1000`–`120000`) |
93
+ | `writeApproval` | `true` | Gate `flaky_quarantine` and `flaky_clear` behind host approval |
94
+ | `dataDir` | `DSH_HOME/.dsh-flakefinder` | Root directory for workspace-isolated history |
95
+ | `quarantineFile` | `<cwd>/.flakefinder.json` | Quarantine manifest path (relative paths resolve against the session workspace) |
96
+ | `pythonPath` | auto `.venv` or `python`/`python3` | Python interpreter for pytest runs (`DSH_FLAKEFINDER_PYTHON` supported) |
97
+
98
+ ## Requirements & runtime
99
+
100
+ - Requires **Node `>= 22.19`** (`^22.19.0 || >=24.0.0`) and **DSH `>= 0.2.2-rc.3`**.
101
+ - Runtime dependencies: `proper-lockfile` and `@stardustlc/dsh-updates`.
102
+ - Test subprocesses always execute via DSH's `subprocess` service using `argv` arrays (no shell).
52
103
 
53
104
  ## Troubleshooting
54
105
 
55
- Run `flaky_health` first: it checks the Python interpreter and pytest availability and summarizes the defaults.
106
+ Run `flaky_health` first: it inspects the active workspace's Node version, auto-detected test framework paths, Python/pytest (missing pytest is treated as informational/optional in JS-only workspaces and only fails health when pytest config is present or `pythonPath` is explicitly configured), `.flakefinder.json` and history readability, and default config.
56
107
 
57
108
  | Symptom | Usual cause | What to do |
58
109
  | :-- | :-- | :-- |
59
- | Verdict says no tests were parsed | `target` matched nothing, or only skipped tests | Point `target` at real test files/directories (globs work), or pass `framework` explicitly |
60
- | "N runs produced no report" | Framework CLI missing, unsupported reporter flag, pytest lacking junitxml | Run the same command once by hand to see the real error; make sure the temp directory is writable |
61
- | `framework=vitest` cannot find `node_modules/vitest` | Not installed, or invoked outside the project | Call it from the project that installed the framework, or set `framework` |
62
- | pytest-related failure | Interpreter or pytest missing | `pip install pytest`, or point `pythonPath` at the right interpreter |
63
- | Quarantine/clear removed 0 entries | Reference format or path does not match the list | Use `"file path > test name"`; check existing entries with `flaky_report` |
110
+ | Verdict says no tests were parsed | `target` or `testName` matched nothing, or only skipped tests | Point `target` at real test files/directories (globs work), verify `testName`, or pass `framework` explicitly |
111
+ | Run anomaly / timeout / truncated output | Missing CLI, per-run timeout exceeded, TAP output > 4MB, or post-assertion teardown crash | Inspect error clusters and stderr tail; raise `timeoutMs` or narrow scope with `testName` |
112
+ | `framework=vitest` cannot find `node_modules/vitest` | Not installed, or invoked outside the project/monorepo | Run inside the repository that installed Vitest, or set `framework` |
113
+ | Python workspace `flaky_health` fails on pytest | Virtualenv or pytest missing | Run `pip install pytest`, or point `pythonPath` at the right interpreter |
114
+ | Quarantine/clear matched 0 entries | Reference format or path does not match the manifest | Use `"relative/path > test name"`; inspect current entries with `flaky_report` |
64
115
 
65
- The `flaky_detect` summary always ends with the next step: quarantine flaky tests, reproduce stable failures, or clear recovered ones.
116
+ The `flaky_detect` summary always ends with the next step: quarantine new flaky tests, reproduce stable failures, or clear recovered quarantine entries.
66
117
 
67
118
  ## Development
68
119