fix(javascript): distinguish resolver discovery from module loading

Preserve load and resolve operations through semantic facts, worker transfer and graph Evidence. Only loads propagate executable ownership. Project ambient member writes and escapes through the shared path- and site-aware mutation owner; retain source literals, bases and uncertainty. Cover ownership and mutation boundaries through CLI and MCP.
This commit is contained in:
morluto committed 2026-10-24 02:35:59 +08:00
1 parent 635f673a8c
commit f91b7f8009
14 files changed
+351 -17

No files matched your search

@@ -1,4 +1,8 @@
import * as t from "@babel/types";
import {
createAmbientPathResolver,
retainSemanticAmbientEffect,
} from "./javascriptSemanticAmbientWrites.js";
import { isIntrinsicMapLookup } from "./javascriptSemanticMapOperations.js";
import {
isIntrinsicTypedArrayConstruction,
@@ -522,6 +526,7 @@ export function* collectSemanticMemberMutationsSteps(
iterableReferenceKeys.set(reference.node, keys);
iterableReferences.push(reference);
};
const ambientPaths = createAmbientPathResolver(state, true);
const markValue = (
node: t.Node,
path: PropertyPath,
@@ -577,6 +582,18 @@ export function* collectSemanticMemberMutationsSteps(
if (t.isIdentifier(expression)) {
const binding = resolveBinding(expression, expression.name);
if (binding === undefined) {
for (const path of ambientPaths(
expression,
current.originAt,
effect === "escape",
current.path.map((key) =>
key === null || typeof key === "object" ? null : String(key),
),
))
if (retainSemanticAmbientEffect(state, effect, path, mutation)) {
recordedEffectCount += 1;
clearSemanticValueCaches(state);
}
const processOrigin = semanticGlobalProcessOrigin(expression, state);
if (processOrigin !== undefined)
recordRequiredEffect(
@@ -1478,6 +1495,7 @@ const observableMutationPaths = (
prefix: PropertyPath,
) => boolean;
} => {
const ambientPaths = createAmbientPathResolver(state, false);
const bindingNodes = new Map<string, MutationObserverNode>();
const expressions = new WeakMap<t.Node, MutationObserverNode>();
const pendingExpressions: {
@@ -1617,6 +1635,8 @@ const observableMutationPaths = (
["globalThis", "global", "window", "self"].includes(expression.name)
)
(observer.origins ??= new Set()).add("ambient");
else if (ambientPaths(expression).length > 0)
(observer.origins ??= new Set()).add("opaque");
} else if (
t.isMemberExpression(expression) ||
t.isOptionalMemberExpression(expression)
@@ -1686,11 +1706,12 @@ const observableMutationPaths = (
add("opaque");
} else if (origin === "array-prototype" || origin === "opaque")
add(origin);
else if (
origin === "ambient" &&
semanticPropertyPathKeyMatches(key, "Array")
)
add("array");
else if (origin === "ambient")
add(
semanticPropertyPathKeyMatches(key, "Array")
? "array"
: "opaque",
);
else if (
origin === "array" &&
semanticPropertyPathKeyMatches(key, "prototype")