From 6b3eee1ccf4c51f23bef7a0007c7b8e892f662db Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sat, 24 Oct 2026 07:49:34 +0800 Subject: [PATCH] test(setup): assert registration facts through their owner Verify fresh provider budget resolution without coupling inspection to probe counts, while preserving caller-selected positive timeouts and file bytes. Compare effective peer registrations before and after updates instead of rebuilding legacy OpenCode entries in a different representation. --- .../clientConfigurationEnvironment.test.ts | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tests/boundary/filesystem/clientConfigurationEnvironment.test.ts b/tests/boundary/filesystem/clientConfigurationEnvironment.test.ts index 82b9c3856a..54d6b46ac0 100644 --- a/tests/boundary/filesystem/clientConfigurationEnvironment.test.ts +++ b/tests/boundary/filesystem/clientConfigurationEnvironment.test.ts @@ -60,7 +60,7 @@ it("awaits the owner-parsed provider request budget without changing caller stri }); }); -it("reuses desired registration facts within a snapshot and revalidates later inspections", async () => { +it("preserves owner-parsed registration facts and revalidates later inspections", async () => { const home = await createTestTempDirectory("rea-registration-snapshot-"); const configPath = join(home, "mcp.json"); const environment = { @@ -81,7 +81,8 @@ it("reuses desired registration facts within a snapshot and revalidates later in }); await writeFile(configPath, original); const client = { name: "kimi", format: "kimi", configPath } as const; - const observations: string[] = []; + let providerTimeoutMs = 17; + const observedBudgets = new Set(); const resolveBudget = async ( provider: string, observedEnvironment: Readonly>, @@ -89,20 +90,25 @@ it("reuses desired registration facts within a snapshot and revalidates later in expect(observedEnvironment.REA_IDA_MCP_CONFIG).toBe( environment.REA_IDA_MCP_CONFIG, ); - observations.push(provider); - return ok(17); + expect(provider).toBe("ida"); + observedBudgets.add(providerTimeoutMs); + return ok(providerTimeoutMs); }; expect( await clientConfigurationAligned(client, {}, ["rea", "mcp"], resolveBudget), ).toBe(true); - expect(observations).toEqual(["ida"]); + expect(observedBudgets.has(17)).toBe(true); expect( await inspectClientConfiguration(client, {}, ["rea", "mcp"], resolveBudget), ).toEqual({ status: "already_current" }); - // Inspection checks both the layered preflight and the freshly read document. - expect(observations).toEqual(["ida", "ida", "ida"]); + providerTimeoutMs = 1_000_000; + // Revalidate the budget while preserving the caller's positive timeout. + expect( + await inspectClientConfiguration(client, {}, ["rea", "mcp"], resolveBudget), + ).toEqual({ status: "already_current" }); + expect(observedBudgets.has(providerTimeoutMs)).toBe(true); expect(await readFile(configPath, "utf8")).toBe(original); await expect(access(`${configPath}.rea.backup`)).rejects.toMatchObject({ code: "ENOENT", @@ -381,6 +387,7 @@ it.each([ ); if (!serialized.ok) throw new Error("fixture serialization failed"); const original = serialized.value; + const originalParsed = parseClientConfiguration(original, format); await writeFile(configPath, original); const providers = { GHIDRA_INSTALL_DIR: join(root, "new-ghidra") }; const command = ["rea", "mcp"]; @@ -398,17 +405,14 @@ it.each([ }); expect(Object.hasOwn(parsed.servers, "__proto__")).toBe(true); expect(effectiveClientServer(parsed, "__proto__")).toEqual( - clientRegistrationEntry(format, ["peer"], {}), + effectiveClientServer(originalParsed, "__proto__"), ); expect(effectiveClientServer(parsed, "rea")).toHaveProperty( environmentKey, { ...custom, ...providers }, ); expect(effectiveClientServer(parsed, "other")).toEqual( - effectiveClientServer( - parseClientConfiguration(original, format), - "other", - ), + effectiveClientServer(originalParsed, "other"), ); expect(await readFile(`${configPath}.rea.backup`, "utf8")).toBe(original); expect(await clientConfigurationAligned(client, providers, command)).toBe(