Fork Horse repository, listed by its owner. Publisher snapshot.

packages/forkhorse-mcp/__tests__/judge.test.ts

Snapshot at 34e3175

Containing directory

2,055 bytes · typescriptView raw
1import { writeFileSync } from "node:fs";
2import { describe, expect, it } from "vitest";
3import { fixtureDiffPath, judgeDetail, judgeDiff, judgeFixture } from "./judge-fixture";
4import expectedCapture from "./judge-capture.fixture.json";
5
6describe("FH-063b labeled offline MCP capture", () => {
7  it("captures judge tools through the real MCP facade with fixture data and no credentials", async () => {
8    const { state, controls, call } = judgeFixture();
9    const advice = {
10      project: "demo",
11      packet: "FH-judge",
12      ranking: ["second", "builder"],
13      rationale:
14        "Receipts pass; compare diff size and elapsed time. Tokens are reported, not independently measured. This ranking is advice; the owner promotes.",
15    };
16    const captures = [];
17    for (const [tool, args] of [
18      ["list_judge_races", { project: "demo" }],
19      ["get_review", { project: "demo", review: "review-builder" }],
20      ["get_review_diff", { project: "demo", review: "review-builder", path: fixtureDiffPath }],
21      ["submit_verdict", advice],
22      ["list_judge_races", { project: "demo" }],
23    ] as const) {
24      const reply = await call(tool, args);
25      expect(reply.status).toBe(200);
26      expect(reply.body!.result.isError).toBeUndefined();
27      captures.push({ tool, args, response: JSON.parse(reply.body!.result.content[0]!.text) });
28    }
29    expect(captures[1]!.response).toEqual(judgeDetail);
30    expect(captures[2]!.response).toEqual(judgeDiff);
31    expect(captures[3]!.response).toEqual({
32      verdict: { ranking: advice.ranking, rationale: advice.rationale, at: controls.adviceAt },
33    });
34    expect(captures[4]!.response).toEqual({ races: [state.races[0]] });
35    const captured = {
36      fixture:
37        "FH-063b offline fixed-contract MCP capture, not live authorization or deployment evidence",
38      captures,
39    };
40    expect(captured).toEqual(expectedCapture);
41    const destination = process.env.FH063_CAPTURE_PATH;
42    if (destination) writeFileSync(destination, JSON.stringify(captured, null, 2) + "\n");
43  });
44});
45