fix(managed): share native verification input diagnostics (#2901)
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { managedNativeVerificationInputSchema } from "../domain/managed/managedNativeVerificationSchemas.js";
|
||||
import { toolContract } from "./toolContracts.js";
|
||||
import { toolInputSchemaWithMetadata } from "./toolSchemaMetadata.js";
|
||||
|
||||
import { traceJavaScriptSemanticsRequestSchema } from "./javascript/applicationWorkflowInputContracts.js";
|
||||
import { JAVASCRIPT_FEATURE_TRACE_EXAMPLE } from "./javascript/javascriptApplicationWorkflowExamples.js";
|
||||
import {
|
||||
@@ -10,7 +14,6 @@ import {
|
||||
import {
|
||||
compareManagedMembersReferenceInputSchema,
|
||||
managedApplicationGraphReferenceInputSchema,
|
||||
managedNativeVerificationReferenceInputSchema,
|
||||
} from "./managed/managedWorkflowToolContracts.js";
|
||||
|
||||
describe("workflow input contracts", () => {
|
||||
@@ -41,17 +44,6 @@ describe("workflow input contracts", () => {
|
||||
}).success,
|
||||
).toBe(false);
|
||||
|
||||
expect(
|
||||
managedNativeVerificationReferenceInputSchema.safeParse({
|
||||
managed_boundaries:
|
||||
MANAGED_NATIVE_VERIFICATION_EXAMPLE.managed_boundaries,
|
||||
native_observations: [
|
||||
MANAGED_NATIVE_VERIFICATION_EXAMPLE.native_observations[0],
|
||||
MANAGED_NATIVE_VERIFICATION_EXAMPLE.native_observations[0],
|
||||
],
|
||||
}).success,
|
||||
).toBe(false);
|
||||
|
||||
expect(
|
||||
managedApplicationGraphReferenceInputSchema.safeParse({
|
||||
managed_artifact: MANAGED_APPLICATION_GRAPH_EXAMPLE.managed_members,
|
||||
@@ -62,4 +54,80 @@ describe("workflow input contracts", () => {
|
||||
managedApplicationGraphReferenceInputSchema.safeParse({}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: "one observation reusing the boundary",
|
||||
observations: [MANAGED_NATIVE_VERIFICATION_EXAMPLE.managed_boundaries],
|
||||
issues: [
|
||||
{
|
||||
path: ["native_observations", 0],
|
||||
message:
|
||||
"Native observation Evidence must be distinct from managed boundary Evidence",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "repeated native observations",
|
||||
observations: [
|
||||
MANAGED_NATIVE_VERIFICATION_EXAMPLE.native_observations[0],
|
||||
MANAGED_NATIVE_VERIFICATION_EXAMPLE.native_observations[0],
|
||||
],
|
||||
issues: [
|
||||
{
|
||||
path: ["native_observations", 1],
|
||||
message: "Native observation Evidence IDs must be unique",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "repeated observations reusing the boundary",
|
||||
observations: [
|
||||
MANAGED_NATIVE_VERIFICATION_EXAMPLE.managed_boundaries,
|
||||
MANAGED_NATIVE_VERIFICATION_EXAMPLE.managed_boundaries,
|
||||
],
|
||||
issues: [
|
||||
{
|
||||
path: ["native_observations", 0],
|
||||
message:
|
||||
"Native observation Evidence must be distinct from managed boundary Evidence",
|
||||
},
|
||||
{
|
||||
path: ["native_observations", 1],
|
||||
message:
|
||||
"Native observation Evidence must be distinct from managed boundary Evidence",
|
||||
},
|
||||
{
|
||||
path: ["native_observations", 1],
|
||||
message: "Native observation Evidence IDs must be unique",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "distinct native observations",
|
||||
observations: MANAGED_NATIVE_VERIFICATION_EXAMPLE.native_observations,
|
||||
issues: [],
|
||||
},
|
||||
])(
|
||||
"preserves managed/native diagnostics for $name",
|
||||
async ({ observations, issues }) => {
|
||||
const input = {
|
||||
managed_boundaries:
|
||||
MANAGED_NATIVE_VERIFICATION_EXAMPLE.managed_boundaries,
|
||||
native_observations: observations,
|
||||
};
|
||||
const contract = toolContract("verify_managed_native_boundaries");
|
||||
for (const schema of [
|
||||
managedNativeVerificationInputSchema,
|
||||
contract.inputSchema,
|
||||
toolInputSchemaWithMetadata(contract),
|
||||
]) {
|
||||
const result = await schema["~standard"].validate(input);
|
||||
expect(
|
||||
result.issues?.map(({ path, message }) => ({ path, message })) ?? [],
|
||||
).toEqual(issues);
|
||||
if (issues.length === 0) expect(result).toEqual({ value: input });
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user