From 1a3d59a0ff4d1b68a01514d3a9e6c5fe2e13e5eb Mon Sep 17 00:00:00 2001 From: dsh-ci-bot Date: Fri, 6 Nov 2026 16:06:14 +0800 Subject: [PATCH 1/5] test(ui-theme): skip dot directories in the package scan The hover-styles contract walks packages/ for package.json files. Typert generator specs create temporary roots inside that tree with mkdtempSync(join(import.meta.dirname, '....')) and remove them in afterEach, so a concurrent scan can readdir one and then hit ENOENT when its owner deletes it. Dot directories hold VCS metadata and those transient roots, never shipped source, so skip them and let the helper walk an explicit root for the regression test. --- .../ui-theme/tests/stylesheet-scan.spec.ts | 23 +++++++++++++++++++ .../client/ui-theme/tests/stylesheet-scan.ts | 12 ++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 packages/client/ui-theme/tests/stylesheet-scan.spec.ts diff --git a/packages/client/ui-theme/tests/stylesheet-scan.spec.ts b/packages/client/ui-theme/tests/stylesheet-scan.spec.ts new file mode 100644 index 0000000000..1614ee55a7 --- /dev/null +++ b/packages/client/ui-theme/tests/stylesheet-scan.spec.ts @@ -0,0 +1,23 @@ +/** Tests for the package-tree scan helpers that the stylesheet contracts range over. */ +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { afterEach, expect, it } from 'vitest' +import { packageFiles } from './stylesheet-scan.ts' + +const roots: string[] = [] + +afterEach(() => { + for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }) +}) + +it('walks shipped package files and skips dot directories holding transient roots', () => { + const root = mkdtempSync(join(tmpdir(), 'dsh-stylesheet-scan-')) + roots.push(root) + mkdirSync(join(root, 'pkg')) + writeFileSync(join(root, 'pkg', 'package.json'), '{}') + mkdirSync(join(root, '.typert-worker-failure-probe')) + writeFileSync(join(root, '.typert-worker-failure-probe', 'package.json'), '{}') + + expect(packageFiles(name => name === 'package.json', root)).toEqual([`${root}/pkg/package.json`]) +}) diff --git a/packages/client/ui-theme/tests/stylesheet-scan.ts b/packages/client/ui-theme/tests/stylesheet-scan.ts index 91311945bf..0ddb93e0f8 100644 --- a/packages/client/ui-theme/tests/stylesheet-scan.ts +++ b/packages/client/ui-theme/tests/stylesheet-scan.ts @@ -75,20 +75,24 @@ export function varReferences(value: string): string[] { * Every file shipped as package source whose name the predicate accepts, * excluding build output and installed dependencies. * @param accepts - filename predicate. - * @returns absolute paths under packages/, `/`-separated on every platform so + * @param root - tree to walk, the packages directory by default. + * @returns absolute paths under `root`, `/`-separated on every platform so * specs can match repo-relative suffixes verbatim. */ -export function packageFiles(accepts: (name: string) => boolean): string[] { +export function packageFiles(accepts: (name: string) => boolean, root: string = PACKAGES_DIR): string[] { const found: string[] = [] const walk = (dir: string): void => { for (const entry of readdirSync(dir, { withFileTypes: true })) { const path = join(dir, entry.name) if (entry.isDirectory()) { - if (entry.name !== 'node_modules' && entry.name !== 'lib' && entry.name !== 'dist') walk(path) + // Dot directories hold VCS metadata and per-test temporary roots (for + // example `.typert-worker-failure-*`), never shipped package source; a + // concurrent owner can remove one while a scan reads it. + if (!entry.name.startsWith('.') && entry.name !== 'node_modules' && entry.name !== 'lib' && entry.name !== 'dist') walk(path) } else if (accepts(entry.name)) found.push(path.replaceAll('\\', '/')) } } - walk(PACKAGES_DIR) + walk(root) return found } From 646e46e0afeb47bce742a1eae4e473b8d6f51a99 Mon Sep 17 00:00:00 2001 From: dsh-ci-bot Date: Fri, 6 Nov 2026 16:24:29 +0800 Subject: [PATCH 2/5] test(ui-theme): scope the package-scan spec to the client face packageFiles() reports '/'-separated paths on every platform, so the fixture's temporary root must be normalized before it forms the expectation; otherwise the Windows coverage lane fails. The spec also belongs to the client aggregate, because an unsuffixed spec file under packages/client is compiled by both aggregates. --- ...stylesheet-scan.spec.ts => stylesheet-scan.client.spec.ts} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename packages/client/ui-theme/tests/{stylesheet-scan.spec.ts => stylesheet-scan.client.spec.ts} (82%) diff --git a/packages/client/ui-theme/tests/stylesheet-scan.spec.ts b/packages/client/ui-theme/tests/stylesheet-scan.client.spec.ts similarity index 82% rename from packages/client/ui-theme/tests/stylesheet-scan.spec.ts rename to packages/client/ui-theme/tests/stylesheet-scan.client.spec.ts index 1614ee55a7..312ee01382 100644 --- a/packages/client/ui-theme/tests/stylesheet-scan.spec.ts +++ b/packages/client/ui-theme/tests/stylesheet-scan.client.spec.ts @@ -19,5 +19,7 @@ it('walks shipped package files and skips dot directories holding transient root mkdirSync(join(root, '.typert-worker-failure-probe')) writeFileSync(join(root, '.typert-worker-failure-probe', 'package.json'), '{}') - expect(packageFiles(name => name === 'package.json', root)).toEqual([`${root}/pkg/package.json`]) + // The helper reports `/`-separated paths on every platform, so the Windows + // temporary root's separators must not reach the expectation. + expect(packageFiles(name => name === 'package.json', root)).toEqual([`${root.replaceAll('\\', '/')}/pkg/package.json`]) }) From dbf13cd572a8128e2c4bc5c07f73c7cfe6fb38bb Mon Sep 17 00:00:00 2001 From: dsh-ci-bot Date: Mon, 9 Nov 2026 13:42:26 +0800 Subject: [PATCH 3/5] test(ui-theme): name the dot-directory exclusion and cover a nested manifest packageFiles() now states the dot-directory exclusion in its JSDoc, and the inline comment no longer names one concrete temporary-root prefix. The spec title describes what the case checks, and the case also asserts a manifest one level below the root so an implementation that only scans the root fails. --- .../ui-theme/tests/stylesheet-scan.client.spec.ts | 15 +++++++++++---- packages/client/ui-theme/tests/stylesheet-scan.ts | 8 +++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/client/ui-theme/tests/stylesheet-scan.client.spec.ts b/packages/client/ui-theme/tests/stylesheet-scan.client.spec.ts index 312ee01382..e65cb1a16a 100644 --- a/packages/client/ui-theme/tests/stylesheet-scan.client.spec.ts +++ b/packages/client/ui-theme/tests/stylesheet-scan.client.spec.ts @@ -11,15 +11,22 @@ afterEach(() => { for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }) }) -it('walks shipped package files and skips dot directories holding transient roots', () => { +it('skips dot directories holding transient roots', () => { const root = mkdtempSync(join(tmpdir(), 'dsh-stylesheet-scan-')) roots.push(root) - mkdirSync(join(root, 'pkg')) + mkdirSync(join(root, 'pkg', 'nested'), { recursive: true }) writeFileSync(join(root, 'pkg', 'package.json'), '{}') + writeFileSync(join(root, 'pkg', 'nested', 'package.json'), '{}') mkdirSync(join(root, '.typert-worker-failure-probe')) writeFileSync(join(root, '.typert-worker-failure-probe', 'package.json'), '{}') // The helper reports `/`-separated paths on every platform, so the Windows - // temporary root's separators must not reach the expectation. - expect(packageFiles(name => name === 'package.json', root)).toEqual([`${root.replaceAll('\\', '/')}/pkg/package.json`]) + // temporary root's separators must not reach the expectation. Traversal + // reports the nested manifest before its parent, and directory order is not + // guaranteed, so both sides are compared sorted. + const normalized = root.replaceAll('\\', '/') + expect(packageFiles(name => name === 'package.json', root).sort()).toEqual([ + `${normalized}/pkg/nested/package.json`, + `${normalized}/pkg/package.json`, + ]) }) diff --git a/packages/client/ui-theme/tests/stylesheet-scan.ts b/packages/client/ui-theme/tests/stylesheet-scan.ts index 0ddb93e0f8..ce796bc62c 100644 --- a/packages/client/ui-theme/tests/stylesheet-scan.ts +++ b/packages/client/ui-theme/tests/stylesheet-scan.ts @@ -73,7 +73,9 @@ export function varReferences(value: string): string[] { /** * Every file shipped as package source whose name the predicate accepts, - * excluding build output and installed dependencies. + * excluding build output, installed dependencies, and dot directories. + * Dot directories hold VCS metadata and per-test temporary roots rather than + * shipped source, and their owner can remove one while a scan reads it. * @param accepts - filename predicate. * @param root - tree to walk, the packages directory by default. * @returns absolute paths under `root`, `/`-separated on every platform so @@ -85,8 +87,8 @@ export function packageFiles(accepts: (name: string) => boolean, root: string = for (const entry of readdirSync(dir, { withFileTypes: true })) { const path = join(dir, entry.name) if (entry.isDirectory()) { - // Dot directories hold VCS metadata and per-test temporary roots (for - // example `.typert-worker-failure-*`), never shipped package source; a + // Dot directories hold VCS metadata and the temporary roots each spec + // creates inside the package tree, never shipped package source; a // concurrent owner can remove one while a scan reads it. if (!entry.name.startsWith('.') && entry.name !== 'node_modules' && entry.name !== 'lib' && entry.name !== 'dist') walk(path) } else if (accepts(entry.name)) found.push(path.replaceAll('\\', '/')) From 37ee8d34ad158992cb7c072d17c06c1204548e82 Mon Sep 17 00:00:00 2001 From: dsh-ci-bot Date: Mon, 9 Nov 2026 14:18:13 +0800 Subject: [PATCH 4/5] fix(ci): retry the Electron provisioning fetch The Windows coverage lane provisions the locked Electron binary through the runner proxy. A gateway timeout on that one fetch failed the required lane before any test ran: on 2026-11-09 four jobs on three branches stopped at `504 (Gateway Time-out)` for the release archive, while other jobs fetched the same archive minutes later (2.5 s from a warm cache, 14.7 s cold). `electron-install` now declares two retries with a 15 s wait, and the aggregate executor repeats a failed gate only when it declares `retries`. A gate the fail-fast signal terminated is not repeated, and the returned duration covers every attempt. --- scripts/run-gates.spec.ts | 63 ++++++++++++++++++++++++++++++++++++++- scripts/run-gates.ts | 46 +++++++++++++++++++++++++++- 2 files changed, 107 insertions(+), 2 deletions(-) diff --git a/scripts/run-gates.spec.ts b/scripts/run-gates.spec.ts index dd6d7cf536..1c00ad9264 100644 --- a/scripts/run-gates.spec.ts +++ b/scripts/run-gates.spec.ts @@ -1,4 +1,6 @@ -import { readFileSync } from 'node:fs' +import { mkdtempSync, readFileSync, rmSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { join } from 'node:path' import { afterEach, beforeEach, describe, expect, it, onTestFinished, vi, type MockInstance } from 'vitest' import { cliGateOptions, @@ -9,6 +11,7 @@ import { gatesForMode, parsePidPpidLines, runGate, + runGateWithRetry, runGates, taskkillArgs, type Gate, @@ -617,6 +620,8 @@ describe('gate graph validation', () => { command: process.execPath, args: ['/private/pnpm.cjs', '--filter', '@deepseek-ai/dsh-desktop', 'exec', 'install-electron'], env: { ELECTRON_GET_USE_PROXY: '1' }, + retries: 2, + retryDelayMs: 15000, }) expect(gates.find(gate => gate.id === 'built-bin-smoke')?.needs).toContain('electron-install') expect(gates.filter(gate => gate.id !== 'electron-install').every(gate => gate.env?.ELECTRON_GET_USE_PROXY === undefined)).toBe(true) @@ -1068,6 +1073,62 @@ describe('gate process outcomes', () => { }) }) +describe('gate retries', () => { + it('runs a gate that declares no retries exactly once', async () => { + const subject = gate('single') + const execute = vi.fn(async () => resultFor(subject, 'passed')) + + const result = await runGateWithRetry(subject, undefined, execute) + + expect(execute).toHaveBeenCalledTimes(1) + expect(result).toMatchObject({ status: 'passed', exitCode: 0 }) + }) + + it('repeats a failed gate until a later attempt passes', async () => { + const directory = mkdtempSync(join(tmpdir(), 'run-gates-retry-')) + onTestFinished(() => rmSync(directory, { recursive: true, force: true })) + const marker = join(directory, 'attempts') + const result = await runGateWithRetry(gate('fetch', { + args: ['-e', [ + "const fs = require('node:fs')", + `const marker = ${JSON.stringify(marker)}`, + "const attempts = fs.existsSync(marker) ? Number(fs.readFileSync(marker, 'utf8')) + 1 : 1", + 'fs.writeFileSync(marker, String(attempts))', + 'if (attempts === 1) process.exit(1)', + ].join(';')], + // One attempt remains unused after the second attempt passes, so the + // loop also exercises its status check rather than only its attempt cap. + retries: 2, + retryDelayMs: 0, + })) + + expect(result).toMatchObject({ status: 'passed', exitCode: 0 }) + expect(readFileSync(marker, 'utf8')).toBe('2') + }) + + it('stops at the declared attempt count and keeps the last failure', async () => { + const subject = gate('fetch', { retries: 2 }) + const execute = vi.fn(async () => resultFor(subject, 'failed')) + + const result = await runGateWithRetry(subject, undefined, execute) + + expect(execute).toHaveBeenCalledTimes(3) + expect(result).toMatchObject({ status: 'failed', exitCode: 1 }) + }) + + it('does not repeat a gate that the fail-fast signal terminated', async () => { + const controller = new AbortController() + controller.abort() + const subject = gate('fetch', { retries: 2, retryDelayMs: 0 }) + const execute = vi.fn(async () => ({ ...resultFor(subject, 'failed'), aborted: true })) + + const result = await runGateWithRetry(subject, controller.signal, execute) + + expect(execute).toHaveBeenCalledTimes(1) + expect(result).toMatchObject({ status: 'failed', aborted: true }) + }) +}) + describe('fail-fast scheduling', () => { it('aborts the aggregate at the first blocking failure', async () => { const slow = gate('slow') diff --git a/scripts/run-gates.ts b/scripts/run-gates.ts index 6caa503c79..782ed05639 100644 --- a/scripts/run-gates.ts +++ b/scripts/run-gates.ts @@ -55,6 +55,10 @@ export interface Gate { quick?: boolean /** Keep a failure visible without failing the aggregate. */ allowFailure?: boolean + /** Extra attempts after a failed run, for a gate whose failure can come from one remote fetch. */ + retries?: number + /** Wait before each retry, in milliseconds; default 0. */ + retryDelayMs?: number /** Write child output as it arrives instead of buffering it until completion. */ streamOutput?: boolean } @@ -133,7 +137,7 @@ export async function runAggregate(name: string, gates: Gate[], concurrencyDefau const startedAt = performance.now() console.log(`run-gates: ${name} running ${gates.length} gate(s) with ${maxConcurrency} worker(s) from ${concurrencySource}${failFast ? ', fail-fast after first blocking failure' : ''}.`) - const results = await runGates(gates, maxConcurrency, runGate, printResult, cliGateOptions(failFast)) + const results = await runGates(gates, maxConcurrency, runGateWithRetry, printResult, cliGateOptions(failFast)) printSummary(results, performance.now() - startedAt) return results.some(result => result.gate.allowFailure !== true && (result.status === 'failed' || result.status === 'skipped')) ? 1 @@ -628,6 +632,14 @@ function ciWindowsCompleteGates(): Gate[] { } // Native Electron fixtures need the locked binary before Vitest removes ambient proxies. +// +// The installer fetches the 100 MB Electron release archive through the runner +// proxy, and one gateway timeout there fails the required Windows coverage lane +// before any test runs. On 2026-11-09 four jobs on three branches stopped at +// `504 (Gateway Time-out)` for that URL after ~12 s, while other jobs fetched +// the same archive minutes later (2.5 s from a warm cache, 14.7 s cold), so the +// fetch gets three attempts instead of one. The wait outlasts the observed +// gateway timeout, after which a fresh connection can reach the archive. function electronInstallGate(): Gate { return { id: 'electron-install', @@ -635,6 +647,8 @@ function electronInstallGate(): Gate { displayCommand: 'pnpm --filter @deepseek-ai/dsh-desktop exec install-electron', ...pnpmInvocation(['--filter', '@deepseek-ai/dsh-desktop', 'exec', 'install-electron']), env: { ELECTRON_GET_USE_PROXY: '1' }, + retries: 2, + retryDelayMs: 15000, } } @@ -1409,6 +1423,36 @@ export async function runGate(gate: Gate, signal?: AbortSignal): Promise { + const started = performance.now() + const attempts = 1 + Math.max(0, gate.retries ?? 0) + let result = await execute(gate, signal) + for (let attempt = 2; attempt <= attempts && result.status === 'failed' && signal?.aborted !== true; attempt++) { + const delayMs = Math.max(0, gate.retryDelayMs ?? 0) + console.log(`run-gates: retrying ${gate.label} (attempt ${String(attempt)} of ${String(attempts)}) in ${String(delayMs)} ms`) + await new Promise(resolve => setTimeout(resolve, delayMs)) + result = await execute(gate, signal) + } + return { ...result, durationMs: performance.now() - started } +} + /** * Parse the state, parent, and process-group fields from a `/proc//stat` * line. The comm field may contain spaces and parentheses, so the state starts From b840ff5b9f60b26c8502643e9e609b7a521b148d Mon Sep 17 00:00:00 2001 From: dsh-ci-bot Date: Mon, 9 Nov 2026 14:34:35 +0800 Subject: [PATCH 5/5] fix(ci): brace the retry cleanup hook `typescript/no-confusing-void-expression` rejects the shorthand arrow that returns `rmSync`'s void expression; the staged lint configuration does not enable type-aware rules, so only the full lint gate caught it. --- scripts/run-gates.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run-gates.spec.ts b/scripts/run-gates.spec.ts index 1c00ad9264..89458b4d2b 100644 --- a/scripts/run-gates.spec.ts +++ b/scripts/run-gates.spec.ts @@ -1086,7 +1086,7 @@ describe('gate retries', () => { it('repeats a failed gate until a later attempt passes', async () => { const directory = mkdtempSync(join(tmpdir(), 'run-gates-retry-')) - onTestFinished(() => rmSync(directory, { recursive: true, force: true })) + onTestFinished(() => { rmSync(directory, { recursive: true, force: true }) }) const marker = join(directory, 'attempts') const result = await runGateWithRetry(gate('fetch', { args: ['-e', [