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:
Lum1104
2026-03-25 09:33:47 +08:00
Unverified
parent 1a16b0fdd6
commit fd0df15d1c
2 changed files with 2 additions and 4 deletions
@@ -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", () => {
@@ -31,7 +31,6 @@ export const EDGE_TYPE_ALIASES: Record<string, string> = {
relates_to: "related",
related_to: "related",
similar: "similar_to",
tests: "tested_by",
import: "imports",
export: "exports",
contain: "contains",