修复 AGC 配置向导持久化用例在 Windows 上稳定超时:读路径补上 ACL 桩

- agentSwarmTestEntry.test.ts:readGameCreatorWizardConfigState 的三处调用补传 persistenceOptions,读路径不再拉起真实 powershell.exe 去加固私有 DACL。
- agentSwarmTestEntry.test.ts:在 persistenceOptions 定义处补注释,说明读路径同样会加固、读写都要带桩,避免后续再漏。
- 失败形态:单跑该文件稳定 1 failed | 124 passed,报错为 Test timed out in 5000ms,不是 expected / actual 断言不符。
- 根因:该用例只校验配置分层优先级(local 覆盖 primary → 向导写入后剥离 local 的 llm → GUI 后写 primary 获胜),但三处读路径都没传桩;每次 readGameCreatorWizardConfigState 会加固目录、主配置、本地配置各一次,三处读累计 9 次 powershell.exe 子进程。逐段实测 5474.9ms / 5494.9ms,正好压过 vitest 默认 5000ms。
- 基线定性:8f96b05f6 上同一用例同样失败(连续两次 1 failed | 124 passed,同样报 5000ms 超时),且该用例与 game-creator-config-wizard.mjs、agent-swarm-test-chat.mjs 在本批前后逐字节一致(blob 相同),故不是本批引入的回归。
- 未放宽任何断言:补桩后该用例 5500ms → 39ms,本文件 13.6s → 8.7s,断言与断言语义均未改动。
This commit is contained in:
2026-09-10 19:33:58 +08:00
parent cb76aadb48
commit 2570831779
@@ -584,6 +584,9 @@ describe('terminal configuration wizard persistence', () => {
it('moves the default LLM to primary config and lets later GUI saves win', async () => {
await withTemporaryRoot(async (root) => {
// 读写都要带上这个桩:读路径同样会加固私有目录与配置文件,
// 在 Windows 上每次加固都要拉起一个 powershell.exe(约 0.6 秒),
// 本用例只校验配置分层优先级,不该为无关的 DACL 子进程耗掉超时预算。
const persistenceOptions =
process.platform === 'win32'
? { secureWindowsPath: async () => {} }
@@ -601,7 +604,10 @@ describe('terminal configuration wizard persistence', () => {
'{"llm":{"model":"stale-local","stream":true},"agentLlm":{"planner":{"model":"planner"}}}\n',
);
const state = await readGameCreatorWizardConfigState(configDir);
const state = await readGameCreatorWizardConfigState(
configDir,
persistenceOptions,
);
expect(state.configPath).toBe(primaryPath);
expect(state.effectiveConfig.llm.model).toBe('stale-local');
const wizardConfig = buildGameCreatorWizardConfig(state.writeConfig, {
@@ -619,7 +625,10 @@ describe('terminal configuration wizard persistence', () => {
const sanitizedLocal = JSON.parse(await readFile(localPath, 'utf8'));
expect(sanitizedLocal.llm).toBeUndefined();
expect(sanitizedLocal.agentLlm.planner.model).toBe('planner');
const afterWizard = await readGameCreatorWizardConfigState(configDir);
const afterWizard = await readGameCreatorWizardConfigState(
configDir,
persistenceOptions,
);
expect(afterWizard.effectiveConfig.llm).toMatchObject({
apiKey: 'wizard-key',
model: 'wizard-model',
@@ -638,7 +647,10 @@ describe('terminal configuration wizard persistence', () => {
guiConfig,
persistenceOptions,
);
const afterGui = await readGameCreatorWizardConfigState(configDir);
const afterGui = await readGameCreatorWizardConfigState(
configDir,
persistenceOptions,
);
expect(afterGui.effectiveConfig.llm.apiKey).toBe('gui-key');
expect(afterGui.effectiveConfig.llm.model).toBe('gui-model');
});