mirror of
https://github.com/morluto/rea.git
synced 2026-10-29 10:55:57 +00:00
refactor(javascript): reuse parsed semantic query contracts
This commit is contained in:
1 parent
db2a3174f6
commit
0b17cb621d
5 files changed
+112
-34
No files matched your search
@@ -4,6 +4,7 @@ import {
|
||||
unknownSemanticGraphTestEvidence,
|
||||
} from "../../../tests/support/javascriptSemanticGraphFixture.js";
|
||||
import { expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
|
||||
import {
|
||||
JAVASCRIPT_SEMANTIC_NODE_KINDS,
|
||||
@@ -24,7 +25,11 @@ import type {
|
||||
JavaScriptSemanticGraphNode,
|
||||
JavaScriptSemanticGraphRelation,
|
||||
} from "./javascriptSemanticGraphSchemas.js";
|
||||
import { queryJavaScriptSemanticGraph } from "./javascriptSemanticQuery.js";
|
||||
import {
|
||||
queryJavaScriptSemanticGraph,
|
||||
queryJavaScriptSemanticGraphValidated,
|
||||
} from "./javascriptSemanticQuery.js";
|
||||
import { javaScriptSemanticQueryInputSchema } from "./javascriptSemanticQuerySchemas.js";
|
||||
import type { JsonValue } from "../jsonValue.js";
|
||||
|
||||
const SHA = "a".repeat(64);
|
||||
@@ -266,7 +271,10 @@ it("excludes candidate edges unless the caller explicitly opts in", () => {
|
||||
direction: "forward-influence" as const,
|
||||
allowed_relations: ["supplies-request-field" as const],
|
||||
};
|
||||
const conservative = queryJavaScriptSemanticGraph(graph, input);
|
||||
const conservative = queryJavaScriptSemanticGraphValidated(
|
||||
graph,
|
||||
javaScriptSemanticQueryInputSchema.parse(input),
|
||||
);
|
||||
const optedIn = queryJavaScriptSemanticGraph(graph, {
|
||||
...input,
|
||||
include_ambiguous_dynamic_edges: true,
|
||||
@@ -281,6 +289,16 @@ it("excludes candidate edges unless the caller explicitly opts in", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects an empty relation selection at the raw query boundary", () => {
|
||||
expect(() =>
|
||||
queryJavaScriptSemanticGraph(graphWithCandidateEdge(), {
|
||||
seed: { kind: "literal", value: "TOKEN" },
|
||||
direction: "forward-influence",
|
||||
allowed_relations: [],
|
||||
}),
|
||||
).toThrow(z.ZodError);
|
||||
});
|
||||
|
||||
it("retains every structural application node linked to one semantic node", () => {
|
||||
const evidenceContexts = new JavaScriptSemanticEvidenceContextRegistry();
|
||||
const original = node("module", "module", evidenceContexts);
|
||||
|
||||
Reference in new issue
Block a user