Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const VOLATILE_KEYS = new Set([
"updatedAt",
"requestId",
"traceId",
"spanId",
"correlationId",
]);

function stripVolatile(v: unknown): unknown {
Expand Down
39 changes: 39 additions & 0 deletions test/match.volatile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,43 @@ describe("normalizedMatch: volatile key stripping", () => {
const b = req(2, "ping", { traceId: "t9", requestId: "r9" });
expect(normalizedMatch(a, b)).toBe(true);
});

it("strips 'spanId' so differing values still match", () => {
const a = req(1, "tools/call", { name: "search", spanId: "span-aaa" });
const b = req(2, "tools/call", { name: "search", spanId: "span-zzz" });
expect(exactMatch(a, b)).toBe(false);
expect(normalizedMatch(a, b)).toBe(true);
});

it("strips 'correlationId' so differing values still match", () => {
const a = req(1, "list_prs", { repo: "mcprec", correlationId: "corr-111" });
const b = req(2, "list_prs", { repo: "mcprec", correlationId: "corr-999" });
expect(exactMatch(a, b)).toBe(false);
expect(normalizedMatch(a, b)).toBe(true);
});

it("strips spanId and correlationId alongside other volatile keys", () => {
const a = req(1, "search", {
q: "is:open",
spanId: "s1",
correlationId: "c1",
traceId: "t1",
requestId: "r1",
});
const b = req(2, "search", {
q: "is:open",
spanId: "s9",
correlationId: "c9",
traceId: "t9",
requestId: "r9",
});
expect(exactMatch(a, b)).toBe(false);
expect(normalizedMatch(a, b)).toBe(true);
});

it("does not strip 'span' or 'correlation' (not exact key matches)", () => {
const a = req(1, "x", { span: "s1", correlation: "c1" });
const b = req(2, "x", { span: "s9", correlation: "c9" });
expect(normalizedMatch(a, b)).toBe(false);
});
});