From fd0df15d1c50237bd0b6296327c91b05edb5d230 Mon Sep 17 00:00:00 2001 From: Lum1104 Date: Wed, 25 Mar 2026 09:33:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20remove=20unsafe=20tests=E2=86=92tested?= =?UTF-8?q?=5Fby=20alias=20that=20inverts=20edge=20direction?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "tests" alias silently rewrites to "tested_by" without swapping source/target, which inverts the relationship meaning and produces incorrect edges. Direction-inverting aliases should fail validation so the LLM gets explicit feedback to fix the edge. Co-Authored-By: Claude Opus 4.6 --- .../packages/core/src/__tests__/schema.test.ts | 5 ++--- understand-anything-plugin/packages/core/src/schema.ts | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts b/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts index 34df113..5e9dd4a 100644 --- a/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts +++ b/understand-anything-plugin/packages/core/src/__tests__/schema.test.ts @@ -224,13 +224,12 @@ describe("schema validation", () => { expect(result.data!.edges[0].type).toBe("depends_on"); }); - it('normalizes "tests" edge type to "tested_by"', () => { + it('rejects "tests" edge type — direction-inverting alias is unsafe', () => { const graph = structuredClone(validGraph); (graph.edges[0] as any).type = "tests"; const result = validateGraph(graph); - expect(result.success).toBe(true); - expect(result.data!.edges[0].type).toBe("tested_by"); + expect(result.success).toBe(false); }); it("still rejects truly invalid edge types after normalization", () => { diff --git a/understand-anything-plugin/packages/core/src/schema.ts b/understand-anything-plugin/packages/core/src/schema.ts index e6567b1..c42af9e 100644 --- a/understand-anything-plugin/packages/core/src/schema.ts +++ b/understand-anything-plugin/packages/core/src/schema.ts @@ -31,7 +31,6 @@ export const EDGE_TYPE_ALIASES: Record = { relates_to: "related", related_to: "related", similar: "similar_to", - tests: "tested_by", import: "imports", export: "exports", contain: "contains",