dsh-flakefinder 0.4.23 → 0.5.0

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/lib/store.js CHANGED
@@ -1,16 +1,179 @@
1
1
  /**
2
- * 历史与隔离清单存储:JSON 文件、原子写入、零运行时依赖。
2
+ * 历史与隔离清单存储:按工作区隔离历史、兼容旧版全局历史与 v1 隔离清单、原子写入与文件锁。
3
3
  *
4
4
  * @module dsh-flakefinder/store
5
5
  */
6
6
  import fs from 'node:fs/promises';
7
7
  import path from 'node:path';
8
- import { randomUUID } from 'node:crypto';
8
+ import { createHash, randomUUID } from 'node:crypto';
9
9
  import lockfile from 'proper-lockfile';
10
10
  const HISTORY_FILE = 'history.json';
11
+ const WORKSPACES_DIR = 'workspaces';
11
12
  const HISTORY_LIMIT = 200;
12
- export function createStore(dataDir, quarantineFile) {
13
- const historyPath = path.join(dataDir, HISTORY_FILE);
13
+ const DAY_MS = 24 * 60 * 60 * 1000;
14
+ function normalizeWorkspacePath(workspace) {
15
+ return path.resolve(workspace);
16
+ }
17
+ function workspaceComparisonKey(normalizedWorkspace) {
18
+ return process.platform === 'win32' ? normalizedWorkspace.toLowerCase() : normalizedWorkspace;
19
+ }
20
+ /** 计算工作区稳定哈希,用于按工作区分文件存储历史。 */
21
+ export function workspaceHash(workspace) {
22
+ const normalized = normalizeWorkspacePath(workspace);
23
+ return createHash('sha256').update(workspaceComparisonKey(normalized)).digest('hex').slice(0, 16);
24
+ }
25
+ function isAbsoluteAnyPlatform(filePath) {
26
+ return path.isAbsolute(filePath) || /^[A-Za-z]:[\\/]/.test(filePath) || filePath.startsWith('\\\\');
27
+ }
28
+ function posixClean(filePath) {
29
+ const slashed = filePath.trim().replace(/\\/g, '/').replace(/\/+/g, '/');
30
+ if (slashed === '')
31
+ return '';
32
+ if (isAbsoluteAnyPlatform(slashed))
33
+ return slashed.replace(/\/+$/, '');
34
+ const normalized = path.posix.normalize(slashed);
35
+ return normalized.replace(/^(?:\.\/)+/, '').replace(/\/+$/, '');
36
+ }
37
+ /**
38
+ * 规范化隔离清单中的文件路径为 POSIX 相对路径;
39
+ * 拒绝工作区外的绝对路径与越界相对路径,避免把本机路径污染进 .flakefinder.json。
40
+ */
41
+ export function normalizeQuarantinePath(rawFile, workspace) {
42
+ const trimmed = rawFile.trim();
43
+ if (trimmed === '') {
44
+ throw new Error('测试引用缺少文件路径。');
45
+ }
46
+ if (isAbsoluteAnyPlatform(trimmed)) {
47
+ if (workspace === undefined) {
48
+ throw new Error('隔离清单只接受相对工作区的测试路径,不能写入绝对路径:' + rawFile);
49
+ }
50
+ if (!path.isAbsolute(trimmed)) {
51
+ throw new Error('测试文件路径位于当前工作区之外,不能写入隔离清单:' + rawFile);
52
+ }
53
+ const absWorkspace = normalizeWorkspacePath(workspace);
54
+ const absFile = path.resolve(trimmed);
55
+ const rel = path.relative(absWorkspace, absFile);
56
+ if (rel === ''
57
+ || rel === '.'
58
+ || rel === '..'
59
+ || rel.startsWith('..' + path.sep)
60
+ || rel.startsWith('../')
61
+ || isAbsoluteAnyPlatform(rel)) {
62
+ throw new Error('测试文件路径位于当前工作区之外,不能写入隔离清单:' + rawFile);
63
+ }
64
+ const cleanRel = posixClean(rel);
65
+ if (cleanRel === '' || cleanRel === '.') {
66
+ throw new Error('测试文件路径无效,不能指向工作区根目录:' + rawFile);
67
+ }
68
+ return cleanRel;
69
+ }
70
+ const clean = posixClean(trimmed);
71
+ if (clean === '' || clean === '.') {
72
+ throw new Error('测试文件路径无效:' + rawFile);
73
+ }
74
+ if (clean === '..' || clean.startsWith('../')) {
75
+ throw new Error('测试文件路径不能越出当前工作区:' + rawFile);
76
+ }
77
+ return clean;
78
+ }
79
+ function normalizeForMatch(rawFile, workspace) {
80
+ const trimmed = rawFile.trim();
81
+ if (trimmed === '')
82
+ return '';
83
+ if (isAbsoluteAnyPlatform(trimmed) && workspace !== undefined) {
84
+ try {
85
+ return normalizeQuarantinePath(trimmed, workspace);
86
+ }
87
+ catch {
88
+ return posixClean(trimmed);
89
+ }
90
+ }
91
+ return posixClean(trimmed);
92
+ }
93
+ function exactRef(item, ref, workspace) {
94
+ return normalizeForMatch(item.file, workspace) === normalizeForMatch(ref.file, workspace)
95
+ && item.name === ref.name;
96
+ }
97
+ function matchesRef(item, ref, workspace) {
98
+ if (normalizeForMatch(item.file, workspace) !== normalizeForMatch(ref.file, workspace))
99
+ return false;
100
+ if (ref.name === null)
101
+ return true;
102
+ return item.name === ref.name;
103
+ }
104
+ function sameWorkspace(entryWorkspace, normalizedWorkspace) {
105
+ if (entryWorkspace === undefined || entryWorkspace.trim() === '')
106
+ return false;
107
+ return workspaceComparisonKey(normalizeWorkspacePath(entryWorkspace)) === workspaceComparisonKey(normalizedWorkspace);
108
+ }
109
+ function historyDedupKey(entry) {
110
+ return [
111
+ entry.timestamp,
112
+ entry.workspace ?? '',
113
+ entry.target,
114
+ entry.framework,
115
+ String(entry.runs),
116
+ entry.verdict,
117
+ String(entry.durationMs),
118
+ String(entry.flakyCount),
119
+ ].join('\0');
120
+ }
121
+ function compareTimestampDesc(a, b) {
122
+ const ta = Date.parse(a.timestamp);
123
+ const tb = Date.parse(b.timestamp);
124
+ if (Number.isFinite(ta) && Number.isFinite(tb) && ta !== tb)
125
+ return tb - ta;
126
+ return b.timestamp.localeCompare(a.timestamp);
127
+ }
128
+ function mergeHistorySources(sources) {
129
+ const seenPrevFiles = new Set();
130
+ const merged = [];
131
+ for (const list of sources) {
132
+ const fileKeys = [];
133
+ for (const entry of list) {
134
+ const key = historyDedupKey(entry);
135
+ if (seenPrevFiles.has(key))
136
+ continue;
137
+ merged.push(entry);
138
+ fileKeys.push(key);
139
+ }
140
+ for (const key of fileKeys)
141
+ seenPrevFiles.add(key);
142
+ }
143
+ merged.sort(compareTimestampDesc);
144
+ return merged;
145
+ }
146
+ function isValidQuarantineEntry(entry) {
147
+ if (!entry || typeof entry !== 'object')
148
+ return false;
149
+ const e = entry;
150
+ if (typeof e.file !== 'string' || !e.file)
151
+ return false;
152
+ if (e.name !== null && typeof e.name !== 'string')
153
+ return false;
154
+ if (typeof e.reason !== 'string')
155
+ return false;
156
+ if (typeof e.since !== 'string')
157
+ return false;
158
+ if (e.updatedAt !== undefined && typeof e.updatedAt !== 'string')
159
+ return false;
160
+ if (e.lastVerifiedAt !== undefined && typeof e.lastVerifiedAt !== 'string')
161
+ return false;
162
+ if (e.lastFailureRate !== undefined && (typeof e.lastFailureRate !== 'number' || !Number.isFinite(e.lastFailureRate)))
163
+ return false;
164
+ if (e.issue !== undefined && typeof e.issue !== 'string')
165
+ return false;
166
+ return true;
167
+ }
168
+ export function createStore(dataDir, quarantineFile, options) {
169
+ const normalizedWorkspace = options?.workspace !== undefined && options.workspace.trim() !== ''
170
+ ? normalizeWorkspacePath(options.workspace)
171
+ : undefined;
172
+ const legacyHistoryPath = path.join(dataDir, HISTORY_FILE);
173
+ const workspacesDir = path.join(dataDir, WORKSPACES_DIR);
174
+ const historyPath = normalizedWorkspace !== undefined
175
+ ? path.join(workspacesDir, workspaceHash(normalizedWorkspace) + '.json')
176
+ : legacyHistoryPath;
14
177
  async function readJson(file) {
15
178
  try {
16
179
  const info = await fs.lstat(file);
@@ -47,29 +210,74 @@ export function createStore(dataDir, quarantineFile) {
47
210
  await fs.unlink(temp).catch(() => { });
48
211
  }
49
212
  }
50
- async function ensureDir() {
51
- await fs.mkdir(dataDir, { recursive: true });
52
- }
53
- async function readHistory() {
54
- const parsed = await readJson(historyPath);
213
+ async function readHistoryFile(file) {
214
+ const parsed = await readJson(file);
55
215
  if (parsed === undefined)
56
216
  return [];
57
- if (!Array.isArray(parsed) || parsed.some(entry => !entry || typeof entry.target !== 'string' || typeof entry.timestamp !== 'string' || !Array.isArray(entry.flakyTests)))
58
- throw new Error('历史记录格式无效,原文件已保留:' + historyPath);
217
+ if (!Array.isArray(parsed)
218
+ || parsed.some(entry => !entry || typeof entry.target !== 'string' || typeof entry.timestamp !== 'string' || !Array.isArray(entry.flakyTests))) {
219
+ throw new Error('历史记录格式无效,原文件已保留:' + file);
220
+ }
59
221
  return parsed;
60
222
  }
223
+ async function readAllWorkspaceFiles() {
224
+ let entries;
225
+ try {
226
+ entries = await fs.readdir(workspacesDir, { withFileTypes: true });
227
+ }
228
+ catch (error) {
229
+ if (error.code === 'ENOENT')
230
+ return [];
231
+ throw error;
232
+ }
233
+ const jsonFiles = entries
234
+ .filter(dirent => dirent.isFile() && dirent.name.endsWith('.json'))
235
+ .map(dirent => path.join(workspacesDir, dirent.name))
236
+ .sort();
237
+ const results = [];
238
+ for (const file of jsonFiles) {
239
+ results.push(await readHistoryFile(file));
240
+ }
241
+ return results;
242
+ }
61
243
  async function appendHistory(entry) {
62
- await ensureDir();
244
+ await fs.mkdir(path.dirname(historyPath), { recursive: true });
63
245
  return locked(historyPath, async () => {
64
- const list = await readHistory();
65
- list.unshift(entry);
246
+ const list = await readHistoryFile(historyPath);
247
+ const record = normalizedWorkspace !== undefined
248
+ ? { ...entry, workspace: normalizedWorkspace }
249
+ : entry;
250
+ list.unshift(record);
66
251
  const trimmed = list.slice(0, HISTORY_LIMIT);
67
252
  await atomicWrite(historyPath, trimmed);
68
253
  });
69
254
  }
70
- async function listHistory(target, limit) {
71
- const list = await readHistory();
72
- const filtered = target === undefined ? list : list.filter(entry => entry.target === target || entry.target.includes(target));
255
+ async function listHistory(target, limit, scope = 'workspace') {
256
+ let list;
257
+ if (scope === 'all') {
258
+ const wsSources = await readAllWorkspaceFiles();
259
+ const legacy = await readHistoryFile(legacyHistoryPath);
260
+ list = mergeHistorySources([...wsSources, legacy]);
261
+ }
262
+ else if (normalizedWorkspace !== undefined) {
263
+ const wsEntries = await readHistoryFile(historyPath);
264
+ const legacy = await readHistoryFile(legacyHistoryPath);
265
+ const matchingLegacy = legacy.filter(entry => sameWorkspace(entry.workspace, normalizedWorkspace));
266
+ list = matchingLegacy.length > 0
267
+ ? mergeHistorySources([wsEntries, matchingLegacy])
268
+ : wsEntries;
269
+ }
270
+ else {
271
+ list = await readHistoryFile(historyPath);
272
+ }
273
+ const filtered = target === undefined
274
+ ? list
275
+ : (() => {
276
+ const normTarget = target.replace(/\\/g, '/');
277
+ return list.filter(entry => entry.target === target
278
+ || entry.target.includes(target)
279
+ || entry.target.replace(/\\/g, '/').includes(normTarget));
280
+ })();
73
281
  return filtered.slice(0, limit);
74
282
  }
75
283
  async function readQuarantine() {
@@ -77,41 +285,78 @@ export function createStore(dataDir, quarantineFile) {
77
285
  if (parsed === undefined)
78
286
  return { version: 1, quarantined: [] };
79
287
  const obj = parsed;
80
- if (!obj || obj.version !== 1 || !Array.isArray(obj.quarantined) || obj.quarantined.some(entry => !entry || typeof entry.file !== 'string' || !entry.file || entry.name !== null && typeof entry.name !== 'string' || typeof entry.reason !== 'string' || typeof entry.since !== 'string'))
288
+ if (!obj || obj.version !== 1 || !Array.isArray(obj.quarantined) || obj.quarantined.some(entry => !isValidQuarantineEntry(entry))) {
81
289
  throw new Error('隔离清单格式无效,原文件已保留:' + quarantineFile);
290
+ }
82
291
  return obj;
83
292
  }
84
293
  async function writeQuarantine(doc) {
85
294
  await fs.mkdir(path.dirname(quarantineFile), { recursive: true });
86
295
  await atomicWrite(quarantineFile, doc);
87
296
  }
88
- async function addQuarantine(refs, reason) {
297
+ async function addQuarantine(refs, reason, addOptions) {
298
+ const normalizedRefs = refs.map(ref => ({
299
+ file: normalizeQuarantinePath(ref.file, normalizedWorkspace),
300
+ name: ref.name,
301
+ }));
89
302
  return locked(quarantineFile, async () => {
90
303
  const doc = await readQuarantine();
91
304
  const now = new Date().toISOString();
92
305
  const added = [];
93
- for (const ref of refs) {
94
- const existing = doc.quarantined.find(item => sameRef(item, ref));
306
+ const updated = [];
307
+ const addedSet = new Set();
308
+ const updatedSet = new Set();
309
+ for (const ref of normalizedRefs) {
310
+ const existing = doc.quarantined.find(item => exactRef(item, ref, normalizedWorkspace));
95
311
  if (existing !== undefined) {
312
+ existing.file = ref.file;
96
313
  existing.reason = reason;
97
- existing.since = now;
314
+ if (!addedSet.has(existing)) {
315
+ existing.updatedAt = now;
316
+ if (!updatedSet.has(existing)) {
317
+ updated.push(existing);
318
+ updatedSet.add(existing);
319
+ }
320
+ }
321
+ if (addOptions?.issue !== undefined)
322
+ existing.issue = addOptions.issue;
323
+ if (addOptions?.lastFailureRate !== undefined)
324
+ existing.lastFailureRate = addOptions.lastFailureRate;
325
+ if (addOptions?.lastVerifiedAt !== undefined)
326
+ existing.lastVerifiedAt = addOptions.lastVerifiedAt;
98
327
  continue;
99
328
  }
100
- const entry = { file: ref.file, name: ref.name, reason, since: now };
329
+ const entry = {
330
+ file: ref.file,
331
+ name: ref.name,
332
+ reason,
333
+ since: now,
334
+ };
335
+ if (addOptions?.issue !== undefined)
336
+ entry.issue = addOptions.issue;
337
+ if (addOptions?.lastFailureRate !== undefined)
338
+ entry.lastFailureRate = addOptions.lastFailureRate;
339
+ if (addOptions?.lastVerifiedAt !== undefined)
340
+ entry.lastVerifiedAt = addOptions.lastVerifiedAt;
101
341
  doc.quarantined.push(entry);
102
342
  added.push(entry);
343
+ addedSet.add(entry);
103
344
  }
104
345
  doc.quarantined.sort((a, b) => a.file.localeCompare(b.file) || (a.name ?? '').localeCompare(b.name ?? ''));
105
346
  await writeQuarantine(doc);
106
- return { added, file: quarantineFile };
347
+ return { added, updated, file: quarantineFile };
107
348
  });
108
349
  }
109
350
  async function removeQuarantine(refs) {
351
+ const normalizedRefs = refs.map(ref => ({
352
+ file: normalizeForMatch(ref.file, normalizedWorkspace),
353
+ name: ref.name,
354
+ }));
110
355
  return locked(quarantineFile, async () => {
111
356
  const doc = await readQuarantine();
112
357
  const removed = [];
113
358
  doc.quarantined = doc.quarantined.filter(item => {
114
- const hit = refs.some(ref => sameRef(item, ref));
359
+ const hit = normalizedRefs.some(ref => matchesRef(item, ref, normalizedWorkspace));
115
360
  if (hit)
116
361
  removed.push(item);
117
362
  return !hit;
@@ -120,21 +365,127 @@ export function createStore(dataDir, quarantineFile) {
120
365
  return { removed, file: quarantineFile };
121
366
  });
122
367
  }
123
- return {
368
+ const store = {
124
369
  appendHistory,
125
370
  listHistory,
126
371
  loadQuarantine: readQuarantine,
127
372
  addQuarantine,
128
373
  removeQuarantine,
129
374
  quarantinePath: quarantineFile,
375
+ historyPath,
130
376
  };
377
+ if (normalizedWorkspace !== undefined)
378
+ store.workspace = normalizedWorkspace;
379
+ return store;
131
380
  }
132
- function sameRef(item, ref) {
133
- if (item.file !== ref.file)
381
+ function matchesQuarantineEntry(test, entry) {
382
+ if (posixClean(test.file) !== posixClean(entry.file))
134
383
  return false;
135
- if (ref.name === null)
136
- return true;
137
- return item.name === ref.name;
384
+ return entry.name === null || entry.name === test.name;
385
+ }
386
+ /**
387
+ * 将本次检测结果中的用例与隔离清单交叉对照:
388
+ * - newFlaky: 本次新发现(尚未隔离)的 flaky 用例
389
+ * - alreadyQuarantinedFlaky: 已在隔离清单中且本次仍为 flaky 的用例
390
+ * - clearCandidates: 隔离清单中在本次运行全部稳定通过(stable-pass)的候选清理条目
391
+ */
392
+ export function annotateTestsWithQuarantine(tests, quarantineDoc) {
393
+ const newFlaky = [];
394
+ const alreadyQuarantinedFlaky = [];
395
+ const quarantined = quarantineDoc.quarantined;
396
+ for (const test of tests) {
397
+ if (test.verdict !== 'flaky')
398
+ continue;
399
+ if (quarantined.some(entry => matchesQuarantineEntry(test, entry))) {
400
+ alreadyQuarantinedFlaky.push(test);
401
+ }
402
+ else {
403
+ newFlaky.push(test);
404
+ }
405
+ }
406
+ const hasRunLevelAnomaly = tests.some(test => (test.file === '(crash)' || test.file === '(timeout)') && test.verdict !== 'stable-pass');
407
+ const clearCandidates = [];
408
+ if (!hasRunLevelAnomaly) {
409
+ for (const entry of quarantined) {
410
+ const matched = tests.filter(test => matchesQuarantineEntry(test, entry));
411
+ if (matched.length > 0 && matched.every(test => test.verdict === 'stable-pass')) {
412
+ clearCandidates.push(entry);
413
+ }
414
+ }
415
+ }
416
+ return { newFlaky, alreadyQuarantinedFlaky, clearCandidates };
417
+ }
418
+ /**
419
+ * 汇总历史与隔离清单的稳定性概览:高频 flaky 榜单 + 超期未复查的陈旧隔离条目。
420
+ */
421
+ export function summarizeStability(history, quarantineDoc, options) {
422
+ const staleDays = options?.staleDays ?? 14;
423
+ const topN = Math.max(0, options?.topN ?? 5);
424
+ const nowMs = (options?.now ?? new Date()).getTime();
425
+ const quarantined = quarantineDoc.quarantined;
426
+ const aggMap = new Map();
427
+ for (const entry of history) {
428
+ for (const test of entry.flakyTests) {
429
+ const file = posixClean(test.file) || test.file;
430
+ const key = file + '\0' + test.name;
431
+ const existing = aggMap.get(key);
432
+ if (existing === undefined) {
433
+ aggMap.set(key, {
434
+ file,
435
+ name: test.name,
436
+ occurrences: 1,
437
+ rateSum: test.failureRate,
438
+ maxFailureRate: test.failureRate,
439
+ lastSeen: entry.timestamp,
440
+ });
441
+ }
442
+ else {
443
+ existing.occurrences += 1;
444
+ existing.rateSum += test.failureRate;
445
+ if (test.failureRate > existing.maxFailureRate)
446
+ existing.maxFailureRate = test.failureRate;
447
+ const prevMs = Date.parse(existing.lastSeen);
448
+ const currMs = Date.parse(entry.timestamp);
449
+ if ((Number.isFinite(currMs) && (!Number.isFinite(prevMs) || currMs > prevMs)) || (!Number.isFinite(currMs) && entry.timestamp > existing.lastSeen)) {
450
+ existing.lastSeen = entry.timestamp;
451
+ }
452
+ }
453
+ }
454
+ }
455
+ const topFlakyTests = [...aggMap.values()]
456
+ .map(item => ({
457
+ file: item.file,
458
+ name: item.name,
459
+ occurrences: item.occurrences,
460
+ avgFailureRate: Math.round((item.rateSum / item.occurrences) * 10) / 10,
461
+ maxFailureRate: Math.round(item.maxFailureRate * 10) / 10,
462
+ lastSeen: item.lastSeen,
463
+ quarantined: quarantined.some(q => matchesQuarantineEntry({ file: item.file, name: item.name }, q)),
464
+ }))
465
+ .sort((a, b) => b.occurrences - a.occurrences
466
+ || b.avgFailureRate - a.avgFailureRate
467
+ || b.maxFailureRate - a.maxFailureRate
468
+ || a.file.localeCompare(b.file)
469
+ || a.name.localeCompare(b.name))
470
+ .slice(0, topN);
471
+ const staleQuarantined = [];
472
+ for (const entry of quarantined) {
473
+ const refIso = entry.lastVerifiedAt ?? entry.updatedAt ?? entry.since;
474
+ const refMs = Date.parse(refIso);
475
+ if (!Number.isFinite(refMs))
476
+ continue;
477
+ const exactDays = (nowMs - refMs) / DAY_MS;
478
+ if (exactDays > staleDays) {
479
+ staleQuarantined.push({
480
+ ...entry,
481
+ ageDays: Math.floor(exactDays),
482
+ });
483
+ }
484
+ }
485
+ staleQuarantined.sort((a, b) => b.ageDays - a.ageDays
486
+ || a.file.localeCompare(b.file)
487
+ || (a.name ?? '').localeCompare(b.name ?? ''));
488
+ return { topFlakyTests, staleQuarantined };
138
489
  }
139
490
  /** 解析 "file.test.mjs" 或 "file.test.mjs > 用例名" 形式的引用。 */
140
491
  export function parseRef(raw) {
@@ -142,12 +493,15 @@ export function parseRef(raw) {
142
493
  if (trimmed === '')
143
494
  throw new Error('测试引用不能为空。格式:文件路径,或 "文件路径 > 用例名"。');
144
495
  const index = trimmed.indexOf(' > ');
145
- if (index === -1)
146
- return { file: trimmed, name: null };
147
- const file = trimmed.slice(0, index).trim();
496
+ if (index === -1) {
497
+ const file = isAbsoluteAnyPlatform(trimmed) ? trimmed : (posixClean(trimmed) || trimmed);
498
+ return { file, name: null };
499
+ }
500
+ const rawFile = trimmed.slice(0, index).trim();
148
501
  const name = trimmed.slice(index + 3).trim();
149
- if (file === '')
502
+ if (rawFile === '')
150
503
  throw new Error('测试引用缺少文件路径:' + raw);
504
+ const file = isAbsoluteAnyPlatform(rawFile) ? rawFile : (posixClean(rawFile) || rawFile);
151
505
  return { file, name: name === '' ? null : name };
152
506
  }
153
507
  /** 隔离清单条目的可读格式。 */
package/lib/tools.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- * 五个面向模型的测试稳定性工具:
3
- * flaky_detect / flaky_history / flaky_quarantine / flaky_clear / flaky_report。
2
+ * 六个面向模型的测试稳定性工具:
3
+ * flaky_detect / flaky_history / flaky_quarantine / flaky_clear / flaky_report / flaky_health。
4
4
  *
5
5
  * @module dsh-flakefinder/tools
6
6
  */
@@ -24,8 +24,8 @@ export interface FlakeToolDefinition {
24
24
  render(args: unknown, value: unknown): ContentBlock[];
25
25
  };
26
26
  isConcurrencySafe?(args?: unknown): boolean;
27
- execute(args: unknown, exec: unknown): Promise<unknown>;
27
+ execute(args: unknown, exec?: unknown): Promise<unknown>;
28
28
  timeoutMs?: number;
29
29
  }
30
- /** 构建五个工具定义。 */
30
+ /** 构建六个工具定义(每次执行只解析当前调用的工作区与取消信号,不重建工具定义)。 */
31
31
  export declare function buildFlakeTools(cfg: ResolvedFlakeConfig, runner: ProcessRunner, store: Store): FlakeToolDefinition[];