test(evidence): avoid recursive matching at the recorded array depth limit (#12819)

This commit is contained in:
morluto authored and GitHub committed 2026-11-20 12:59:28 +00:00
1 parent 7f5a39c0c1
commit edf33a448b
1 file changed
+13 -11
@@ -56,7 +56,7 @@ it("omits parent parameters that would exceed Evidence depth by one level", () =
rawResult: { values: ["row"] },
},
);
expect(admitted.parameters).toStrictEqual(parameters);
expect(JSON.stringify(admitted.parameters)).toBe(JSON.stringify(parameters));
const projected = project(parent(parameters));
if (!projected.ok) throw projected.error;
expect(projected.value).toMatchObject({
@@ -85,20 +85,19 @@ it("keeps parameters that still fit one level below the Evidence root", () => {
if (!projected.ok) throw projected.error;
if (projected.value.kind !== "recorded-array")
throw new Error("expected a recorded-array page");
expect(projected.value.source_parameters).toEqual(parameters);
expect(JSON.stringify(projected.value.source_parameters)).toBe(
JSON.stringify(parameters),
);
});
it("returns a typed depth refusal instead of throwing when a row cannot be nested", () => {
const projected = project(parent({}, nested(MAX_JSON_DEPTH - 1)));
expect(projected.ok).toBe(false);
if (projected.ok) return;
if (projected.ok) throw new Error("expected a depth refusal");
expect(projectAnalysisError(projected.error)).toMatchObject({
code: "resource_constraint",
details: { reported_limits: { maximum_json_depth: MAX_JSON_DEPTH } },
remediation: { action: expect.stringContaining("JSON depth") },
});
expect(projectAnalysisError(projected.error).remediation.action).toContain(
"JSON depth",
);
});
it("stops before a later row exceeds the output Evidence depth", () => {
@@ -115,9 +114,12 @@ it("stops before a later row exceeds the output Evidence depth", () => {
}),
);
if (!projected.ok) throw projected.error;
expect(projected.value).toMatchObject({
kind: "recorded-array",
rows: [first],
coverage: { examined: 1, total: 3, next_offset: 1 },
if (projected.value.kind !== "recorded-array")
throw new Error("expected a recorded-array page");
expect(projected.value.coverage).toMatchObject({
examined: 1,
total: 3,
next_offset: 1,
});
expect(JSON.stringify(projected.value.rows)).toBe(JSON.stringify([first]));
});