From 76da8fd8baa9ffe61be1d772a3cc1d0ac65dbf8b Mon Sep 17 00:00:00 2001 From: Kaoru0822 Date: Sat, 21 Nov 2026 00:23:02 -0800 Subject: [PATCH] fix(uninstall): keep emptied DSH inserts from applying overrides (#13036) * test(uninstall): reproduce DSH inserts becoming active overrides * fix(uninstall): preserve the mode of emptied DSH insert operations --- src/application/DshCordisPatch.ts | 8 +-- .../filesystem/dshClientConfiguration.test.ts | 50 +++++++++++++------ 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/application/DshCordisPatch.ts b/src/application/DshCordisPatch.ts index fbb1f96ef0..8a27ef4e22 100644 --- a/src/application/DshCordisPatch.ts +++ b/src/application/DshCordisPatch.ts @@ -11,7 +11,7 @@ import { isRecord } from "../kernel/isRecord.js"; export const DSH_ENTRY_ID = "rea-mcp"; export const DSH_CLIENT_PACKAGE = "@deepseek-ai/dsh-mcp-client"; const LAUNCHER_KEYS = new Set(["serverName", "transport", "command", "args"]); -const SELECTOR_KEYS = new Set(["id", "name"]); +const PATCH_ROUTING_KEYS = new Set(["id", "name", "insert"]); const isPatchRecord = (value: unknown): value is Record => isRecord(value) && !(value instanceof CordisExpression); @@ -329,13 +329,13 @@ export class DshCordisDocument { this.#entry(edit.desired, edit.platform, invalidated), ] as typeof inserted.items; }); - if (inserted.items.length === 0) copy.delete("insert"); - // An emptied operation keeps caller fields unless it would patch REA's row. + // Cordis still treats an empty insert list as an insert operation. + // Dropping the list would activate the other fields as direct overrides. const kept = inserted.items.length > 0 || (this.#id(op.map) !== DSH_ENTRY_ID && copy.items.some( - (pair) => !SELECTOR_KEYS.has(this.#yaml.value(pair.key) as string), + (pair) => !PATCH_ROUTING_KEYS.has(this.#yaml.key(pair.key)), )); replacements.set(op.source, kept ? copy : undefined); } diff --git a/tests/boundary/filesystem/dshClientConfiguration.test.ts b/tests/boundary/filesystem/dshClientConfiguration.test.ts index af570c7267..17ccc49119 100644 --- a/tests/boundary/filesystem/dshClientConfiguration.test.ts +++ b/tests/boundary/filesystem/dshClientConfiguration.test.ts @@ -2748,14 +2748,19 @@ describe("DeepSeek Harness caller node metadata", () => { }); describe("DeepSeek Harness uninstall of a shared operation", () => { - it("keeps a group patch's own fields and comment when its only row was REA's", async () => { + it("keeps a group insert from activating its ignored overrides on uninstall", async () => { const { home, client } = await harnessClient(); const entry = canonicalEntry(); - await writeFile( - client.configPath, - `- insert: - - id: user-a - name: plugin-a + const initial = `- insert: + - id: tools + name: "@deepseek-ai/cordis-plugin-group" + group: true + config: + - id: user-a + name: plugin-a +- id: user-a + config: + sandbox: permissive # caller group patch - id: tools config: @@ -2768,18 +2773,32 @@ describe("DeepSeek Harness uninstall of a shared operation", () => { transport: stdio command: ${entry.config.command} args: ${JSON.stringify(entry.config.args)} -`, - ); +`; + await writeFile(client.configPath, initial); - expect((await systemUninstallHost(home).removeClient(client)).status).toBe( - "removed", - ); + const host = systemUninstallHost(home); + expect((await host.removeClient(client)).status).toBe("removed"); const text = await readFile(client.configPath, "utf8"); expect(parseYaml(text)).toEqual([ - { insert: [{ id: "user-a", name: "plugin-a" }] }, - { id: "tools", config: { sandbox: "strict" } }, + { + insert: [ + { + id: "tools", + name: "@deepseek-ai/cordis-plugin-group", + group: true, + config: [{ id: "user-a", name: "plugin-a" }], + }, + ], + }, + { id: "user-a", config: { sandbox: "permissive" } }, + { id: "tools", config: { sandbox: "strict" }, insert: [] }, ]); expect(text).toContain("# caller group patch"); + expect((await host.removeClient(client)).status).toBe("skipped"); + expect(await readFile(client.configPath, "utf8")).toBe(text); + expect(await readFile(`${client.configPath}.rea.backup`, "utf8")).toBe( + initial, + ); }); it("keeps an operation's own fields when setup removes a second REA row from it", async () => { @@ -2810,7 +2829,10 @@ ${row("second-launcher")}`, const text = await readFile(client.configPath, "utf8"); expect(text).toContain("# caller operation"); expect(loadedInserts(text)).toHaveLength(1); - expect((parseYaml(text) as unknown[]).at(-1)).toEqual({ disabled: false }); + expect((parseYaml(text) as unknown[]).at(-1)).toEqual({ + disabled: false, + insert: [], + }); expect(await dshStatus(home)).toMatchObject({ state: "aligned" }); });