refactor(managed): reuse the member comparison input contract

This commit is contained in:
morluto committed 2026-10-22 11:11:42 +08:00
1 parent 51e0df97e9
commit 27dc9735e4
2 files changed
+4 -24

No files matched your search

@@ -1,5 +1,6 @@
import { z } from "zod";
import { evidenceSchema } from "../../domain/evidence.js";
import { compareManagedMembersInputSchema } from "../../domain/managed/managedMemberComparison.js";
import { managedNativeVerificationInputSchema } from "../../domain/managed/managedNativeVerificationSchemas.js";
import { managedReconstructionImportInputSchema } from "../../domain/managed/managedReconstruction.js";
@@ -14,31 +15,13 @@ import {
import { toolContractMetadata } from "../toolEffects.js";
import { requireOutputSchema } from "../toolOutputSchemaPrimitives.js";
/** Inputs for comparing two managed observations carried inline. */
export const compareManagedMembersReferenceInputSchema = z
.strictObject({
left: evidenceSchema,
right: evidenceSchema,
})
.superRefine((input, context) => {
if (input.left.evidence_id === input.right.evidence_id)
context.addIssue({
code: "custom",
path: ["right"],
message: "Managed member Evidence must be distinct",
});
});
/** Inline Evidence input for importing reconstruction. */
export const managedReconstructionReferenceInputSchema =
managedReconstructionImportInputSchema.extend({
static_members: evidenceSchema,
});
const managedApplicationGraphReferenceFacts = {} as const;
const managedApplicationGraphReferenceShape = z.strictObject({
...managedApplicationGraphReferenceFacts,
managed_artifact: evidenceSchema.optional(),
managed_members: evidenceSchema.optional(),
managed_native_boundaries: evidenceSchema.optional(),
@@ -100,7 +83,7 @@ export const MANAGED_WORKFLOW_TOOL_CONTRACTS = [
description:
"Compare two authenticated inspect_managed_members Evidence records using unique-only tiers: exact declared type, name, and CIL/signature; exact declared type, name, and signature (decoded or not); exact declared type, name, and decoded structural method shape; then exact CIL/signature or decoded structural method shape alone, which never takes a member whose own declared type and name remain unpaired on the other side or whose declaring type is unresolved. Signatures compare type operands by name, not by build-local metadata row. Names alone are never a matching basis; a member whose signature was not decoded, or whose same-named counterpart's was not, stays unknown rather than added or removed. Metadata tokens remain build-local coordinates bound to each artifact SHA-256 and MVID, and the tuple digest does not itself remap them.",
kind: "application",
inputSchema: compareManagedMembersReferenceInputSchema,
inputSchema: compareManagedMembersInputSchema,
outputSchema: comparisonOutputSchema,
examples: [
{
+2 -5
View File
@@ -11,10 +11,7 @@ import {
MANAGED_MEMBER_COMPARISON_EXAMPLE,
MANAGED_NATIVE_VERIFICATION_EXAMPLE,
} from "./managed/managedWorkflowExamples.js";
import {
compareManagedMembersReferenceInputSchema,
managedApplicationGraphReferenceInputSchema,
} from "./managed/managedWorkflowToolContracts.js";
import { managedApplicationGraphReferenceInputSchema } from "./managed/managedWorkflowToolContracts.js";
describe("workflow input contracts", () => {
it("rejects application Evidence ID references and duplicate inline records", () => {
@@ -38,7 +35,7 @@ describe("workflow input contracts", () => {
it("rejects duplicate inline managed Evidence records", () => {
expect(
compareManagedMembersReferenceInputSchema.safeParse({
toolContract("compare_managed_members").inputSchema.safeParse({
left: MANAGED_MEMBER_COMPARISON_EXAMPLE.left,
right: MANAGED_MEMBER_COMPARISON_EXAMPLE.left,
}).success,