mirror of
https://github.com/morluto/rea
synced 2026-10-27 06:33:32 -04:00
fix(javascript): preserve semantic query identity and source coverage
This commit is contained in:
@@ -48,8 +48,17 @@ export const resolveJavaScriptSemanticQuerySeeds = (
|
||||
.map(({ function_node_id }) => function_node_id)
|
||||
: [],
|
||||
);
|
||||
const unresolvedAccesses = new Set(
|
||||
input.seed.kind === "property"
|
||||
? graph.unknowns.flatMap(({ family, node_id }) =>
|
||||
family === "object-flow" && node_id !== null ? [node_id] : [],
|
||||
)
|
||||
: [],
|
||||
);
|
||||
return graph.nodes
|
||||
.filter((node) => seedMatches(node, input, fingerprintFunctions))
|
||||
.filter((node) =>
|
||||
seedMatches(node, input, fingerprintFunctions, unresolvedAccesses),
|
||||
)
|
||||
.map(({ node_id }) => node_id)
|
||||
.sort(compareUnicodeCodePoints);
|
||||
};
|
||||
@@ -58,6 +67,7 @@ const seedMatches = (
|
||||
node: JavaScriptSemanticGraphNode,
|
||||
input: JavaScriptSemanticQueryInput,
|
||||
fingerprintFunctions: ReadonlySet<string>,
|
||||
unresolvedAccesses: ReadonlySet<string>,
|
||||
): boolean => {
|
||||
const seed = input.seed;
|
||||
if (seed.kind === "semantic-node") return node.node_id === seed.node_id;
|
||||
@@ -66,8 +76,20 @@ const seedMatches = (
|
||||
if (seed.kind === "function") return fingerprintFunctions.has(node.node_id);
|
||||
if (seed.kind === "literal")
|
||||
return node.kind === "literal" && node.properties.value === seed.value;
|
||||
if (seed.kind === "property")
|
||||
return node.kind === "property-slot" && node.properties.name === seed.name;
|
||||
if (seed.kind === "property") {
|
||||
if (node.kind === "property-slot")
|
||||
return node.properties.name === seed.name;
|
||||
if (node.kind !== "expression") return false;
|
||||
const path = node.properties.property_path;
|
||||
// Older retained graphs did not record slot resolution. Their existing
|
||||
// source-bound unknown establishes an unresolved access without guessing
|
||||
// from an absent or resource-omitted relation.
|
||||
const slotless =
|
||||
node.properties.property_slot_resolution === "unresolved" ||
|
||||
(node.properties.property_slot_resolution === undefined &&
|
||||
unresolvedAccesses.has(node.node_id));
|
||||
return slotless && Array.isArray(path) && path.at(-1) === seed.name;
|
||||
}
|
||||
if (seed.kind === "endpoint")
|
||||
return (
|
||||
(node.kind === "request" || node.kind === "response") &&
|
||||
|
||||
Reference in New Issue
Block a user