mirror of
https://github.com/morluto/rea.git
synced 2026-10-26 17:35:11 +00:00
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.
This commit is contained in:
1 parent
f11892265d
commit
6b3eee1ccf
1 file changed
+16
-12
@@ -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<number>();
|
||||
const resolveBudget = async (
|
||||
provider: string,
|
||||
observedEnvironment: Readonly<Record<string, string>>,
|
||||
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user