mirror of
https://github.com/morluto/rea.git
synced 2026-11-11 01:13:39 +00:00
* fix(javascript)!: preserve operator influence in semantic traces * test(javascript): align semantic influence regressions * style(javascript): format semantic IR * test(javascript): follow literal argument seed influence * fix(javascript): keep one literal node per operator operand Reuse an existing literal for operator influence, and treat TypeScript assertion wrappers as transparent when deciding whether a call result is used. * test(mcp): assert bundle path issues by field compare_bundles reports each relative path as an invalid_format issue instead of one joined diagnostic sentence. * fix(javascript): index operator literals by range and initializer Repeated string operands rescanned every retained literal and every initializer flow. Lookup now uses those indexes, and a 1200-declaration file still projects one literal per operand. * fix(javascript): keep literal and call facts on their own occurrences Operator literals match their own source range, so a nested function does not inherit the enclosing declaration's literal. A direct argument still reaches the call, while the assigned result follows modeled returns. for-loop initializers and updates are discarded call results. * test(javascript): expect conditional operand literals beside binding values A conditional binding keeps one candidate literal per union value and one operator literal per operand token. Those are different facts, so the aggregate payload check counts four nodes and compares literal seeds in query order. * perf(javascript): index call return flows by call site projectCalls filtered every call return for each assigned result. Group those flows once while projecting returns-to-call edges. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
82 lines
2.9 KiB
TypeScript
82 lines
2.9 KiB
TypeScript
import { uniqueSorted } from "../canonicalOrdering.js";
|
|
import type { JavaScriptSemanticGraph } from "./javascriptSemanticGraph.js";
|
|
import type { JavaScriptSemanticGraphUnknown } from "./javascriptSemanticGraphSchemas.js";
|
|
import type { JavaScriptSemanticQueryResult } from "./javascriptSemanticQuerySchemas.js";
|
|
|
|
/** Inputs needed to classify one completed semantic traversal. */
|
|
export interface JavaScriptSemanticQueryAssessmentInput {
|
|
readonly graph: JavaScriptSemanticGraph;
|
|
readonly totalSeeds: number;
|
|
readonly expectedMatches: number;
|
|
readonly hasExpectation: boolean;
|
|
readonly unknowns: readonly JavaScriptSemanticGraphUnknown[];
|
|
readonly candidateRelations: number;
|
|
}
|
|
|
|
/** Status, coverage, and limitations derived from one traversal. */
|
|
export interface JavaScriptSemanticQueryAssessment {
|
|
readonly status: JavaScriptSemanticQueryResult["status"];
|
|
readonly coverage: JavaScriptSemanticQueryResult["coverage"];
|
|
readonly limitations: string[];
|
|
}
|
|
|
|
/** Classify a complete semantic traversal without promoting unknowns to absence. */
|
|
export const assessJavaScriptSemanticQuery = (
|
|
input: JavaScriptSemanticQueryAssessmentInput,
|
|
): JavaScriptSemanticQueryAssessment => ({
|
|
status: queryStatus(input),
|
|
coverage: queryCoverage(input),
|
|
limitations: queryLimitations(input),
|
|
});
|
|
|
|
const queryCoverage = (
|
|
input: JavaScriptSemanticQueryAssessmentInput,
|
|
): JavaScriptSemanticQueryResult["coverage"] => ({
|
|
status:
|
|
input.graph.coverage.status === "unavailable"
|
|
? "unavailable"
|
|
: input.unknowns.length > 0 ||
|
|
input.candidateRelations > 0 ||
|
|
input.graph.coverage.status !== "complete" ||
|
|
input.graph.coverage.truncated
|
|
? "partial"
|
|
: "complete",
|
|
});
|
|
|
|
const queryStatus = (
|
|
input: JavaScriptSemanticQueryAssessmentInput,
|
|
): JavaScriptSemanticQueryResult["status"] => {
|
|
if (input.graph.coverage.status === "unavailable") return "unsupported";
|
|
if (input.candidateRelations > 0) return "ambiguous";
|
|
if (input.unknowns.length > 0 || input.graph.coverage.truncated)
|
|
return "partial";
|
|
if (
|
|
input.totalSeeds === 0 ||
|
|
(input.hasExpectation && input.expectedMatches === 0)
|
|
)
|
|
return input.unknowns.length > 0 ||
|
|
input.graph.coverage.status !== "complete" ||
|
|
input.graph.coverage.truncated
|
|
? "partial"
|
|
: "no-match";
|
|
return input.totalSeeds > 1 ? "ambiguous" : "found";
|
|
};
|
|
|
|
const queryLimitations = (
|
|
input: JavaScriptSemanticQueryAssessmentInput,
|
|
): string[] =>
|
|
uniqueSorted([
|
|
"Semantic graph reachability is a static inference and does not prove runtime execution.",
|
|
...input.graph.limitations,
|
|
...(input.unknowns.length === 0
|
|
? []
|
|
: [
|
|
"Relevant dynamic, unsupported, incomplete, or ambiguous semantics remain unknown.",
|
|
]),
|
|
...(input.candidateRelations === 0
|
|
? []
|
|
: [
|
|
"Candidate relations remain ambiguous and do not establish a resolved semantic path.",
|
|
]),
|
|
]);
|