From 44e9bfca750a77576e5a9fe7553ecf10d1bcd778 Mon Sep 17 00:00:00 2001 From: Yichen Jiang Date: Fri, 7 Aug 2026 15:11:39 +0800 Subject: [PATCH] test(agent-presets): keep one write regression after the merge The lower layer now carries the same test, and the merge kept both copies. --- .../preset/agent-presets/tests/mount.spec.ts | 52 ------------------- 1 file changed, 52 deletions(-) diff --git a/packages/preset/agent-presets/tests/mount.spec.ts b/packages/preset/agent-presets/tests/mount.spec.ts index a2f54ebe99..244d8cadb0 100644 --- a/packages/preset/agent-presets/tests/mount.spec.ts +++ b/packages/preset/agent-presets/tests/mount.spec.ts @@ -288,55 +288,3 @@ describe('attributing a service to a subtree', () => { }) }) -describe('the preset file is an input, never a persistence target', () => { - it('survives a row that disposes itself, which makes the Loader persist a tree', async () => { - // The preset lives in a temp root, not under `fixtures/`: without the - // `write()` override the Loader REWRITES the composition it read, so a - // committed fixture would be mutated by the very run that proves the bug - // and every later run would compare against the damaged file and pass. - const root = await mkdtemp(join(tmpdir(), 'dsh-preset-write-')) - const dir = join(root, 'self-disposing') - await mkdir(dir) - const path = join(dir, COMPOSITION_FILE) - const composition = [ - '- id: tool-kept', - ` name: ${join(FIXTURES, 'plugins', 'contribute.js')}`, - ' config:', - ' tool: kept', - '- id: goes-away', - ` name: ${join(FIXTURES, 'plugins', 'self-dispose.js')}`, - '', - ].join('\n') - await writeFile(path, composition) - - const scoped = new Context() - scoped.baseUrl = pathToFileURL(FIXTURES).href + '/' - await scoped.plugin(Loader) - scoped.loader.builtins.include = Include - await scoped.plugin(LlmService) - await scoped.plugin(SessionStore) - await scoped.plugin(SystemPrompt, { persona: '' }) - await scoped.plugin(ToolRegistry) - await scoped.plugin(AgentRegistry) - await scoped.plugin(AgentLoop, { agents: [] }) - await scoped.plugin(AgentPresets, { default: 'self-disposing', roots: [{ path: root, trust: 'user' as const }] }) - - await scoped.agents.create({ - sessionId: SessionId('sess-self-dispose'), - setup: async (agentCtx: Context) => void await scoped.agentPresets.mount(agentCtx), - }) - await (globalThis as { __SELF_DISPOSED__?: Promise }).__SELF_DISPOSED__ - // Slack past the deterministic signal above, not a race the number has to - // win. The write rides the Loader's fiber-unload listener, which stamps - // `disabled: true` and calls `write()` in the same synchronous step; once - // the self-dispose has settled, a regression has already written. Polling - // would not help — the assertion is an ABSENCE, and no amount of waiting - // proves one — so the wait only has to clear settlement. - await new Promise(resolve => setTimeout(resolve, 50)) - - // Inherited, `EntryTree.write()` persists the dying tree — stamping - // `disabled: true` onto the row and, in the shipped case, truncating the - // composition every session shares. - expect(await readFile(path, 'utf8')).toBe(composition) - }) -})