mirror of
https://github.com/Egonex-AI/Understand-Anything.git
synced 2026-06-22 10:58:03 +08:00
fix: remove unsafe tests→tested_by alias that inverts edge direction
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 <noreply@anthropic.com>
This commit is contained in:
@@ -224,13 +224,12 @@ describe("schema validation", () => {
|
|||||||
expect(result.data!.edges[0].type).toBe("depends_on");
|
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);
|
const graph = structuredClone(validGraph);
|
||||||
(graph.edges[0] as any).type = "tests";
|
(graph.edges[0] as any).type = "tests";
|
||||||
|
|
||||||
const result = validateGraph(graph);
|
const result = validateGraph(graph);
|
||||||
expect(result.success).toBe(true);
|
expect(result.success).toBe(false);
|
||||||
expect(result.data!.edges[0].type).toBe("tested_by");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("still rejects truly invalid edge types after normalization", () => {
|
it("still rejects truly invalid edge types after normalization", () => {
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ export const EDGE_TYPE_ALIASES: Record<string, string> = {
|
|||||||
relates_to: "related",
|
relates_to: "related",
|
||||||
related_to: "related",
|
related_to: "related",
|
||||||
similar: "similar_to",
|
similar: "similar_to",
|
||||||
tests: "tested_by",
|
|
||||||
import: "imports",
|
import: "imports",
|
||||||
export: "exports",
|
export: "exports",
|
||||||
contain: "contains",
|
contain: "contains",
|
||||||
|
|||||||
Reference in New Issue
Block a user