Merge branch 'feat/session-workspace-root' into feat/session-workspace-root-consumers

# Conflicts:
#	packages/experimental/client-ui-forge/README.i18n.yaml
This commit is contained in:
LegGasai committed 2026-11-10 12:00:45 +08:00
commit 4f797aaf28
192 files changed
+11445 -1133

No files matched your search

+10
View File
@@ -432,6 +432,16 @@ export const LINK_MAP: Readonly<Record<string, string>> = {
ForgeCommit: 'forge.md',
ForgeCommitList: 'forge.md',
ForgeReviewData: 'forge.md',
ForgeReviewWrite: 'forge.md',
ForgeReviewWriteResult: 'forge.md',
BranchUpdateMethod: 'forge.md',
BranchUpdateRequest: 'forge.md',
ChangeRequestReviewer: 'forge.md',
ForgeRerunRequest: 'forge.md',
ForgeReviewerCandidate: 'forge.md',
ForgeReviewersRequest: 'forge.md',
ForgeViewedFiles: 'forge.md',
ForgeViewedRequest: 'forge.md',
ForgeCommitRange: 'forge.md',
ForgeFileLayer: 'forge.md',
ForgeChangeRequestStatesFrame: 'forge.md',
+62 -1
View File
@@ -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')
+45 -1
View File
@@ -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<GateRes
return result
}
/**
* Execute one gate, repeating a failure while the gate declares `retries`.
* The wait between attempts is `retryDelayMs`, so a gate that fetches a remote
* artifact gets several connections to that host instead of failing the
* aggregate on the first one. A result the fail-fast signal terminated is not
* retried: the aggregate already decided to abort, and another attempt would be
* terminated again. The returned duration covers every attempt, and the output
* and error are the last attempt's, which is the one whose failure ends the gate.
* @param gate - command and scheduler environment to execute.
* @param signal - abort signal forwarded to every attempt.
* @param execute - executor for one attempt; the child-process boundary by default.
* @returns the last attempt's outcome with the total duration.
*/
export async function runGateWithRetry(
gate: Gate,
signal?: AbortSignal,
execute: GateExecutor = runGate,
): Promise<GateResult> {
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/<pid>/stat`
* line. The comm field may contain spaces and parentheses, so the state starts
+85
View File
@@ -2842,6 +2842,31 @@
"symbol": "ForgeThreadId",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeReviewId",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgePendingReview",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeReviewEvent",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeReviewWrite",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeReviewWriteResult",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeCommentId",
@@ -2876,6 +2901,66 @@
"doc": "docs/subsystems/session.md",
"symbol": "SessionEventInput",
"source": "packages/core/session/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeCheckId",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "BranchUpdateMethod",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ReviewVerdict",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ChangeRequestReviewer",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ChangeRequestIssue",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeRerunRequest",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeReviewersRequest",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeReviewerCandidate",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "BranchUpdateRequest",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeViewedState",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeViewedFiles",
"source": "packages/experimental/forge/src/types.ts"
},
{
"doc": "docs/subsystems/forge.md",
"symbol": "ForgeViewedRequest",
"source": "packages/experimental/forge/src/types.ts"
}
]
}