fix(javascript): retain unresolved network targets with provenance

Resolve stable lexical and URL targets using shared effects, and preserve unresolved request expressions as partial facts. Carry their uncertainty through workers, artifact graphs, and the CLI. Scope partial endpoint identity to the source site.

Refs: #3451, #3534

Co-authored-by: Hemang Varshney <218273197+hemv-857@users.noreply.github.com>
This commit is contained in:
morlutoandHemang Varshney committed 2026-10-16 08:14:52 +08:00
1 parent 1b9b725c4c
commit 018ab2c5d9
15 files changed
+737 -27

No files matched your search

@@ -74,3 +74,54 @@ it("keeps ambiguous endpoint candidates inferred through artifact graph projecti
await rm(root, { recursive: true, force: true });
}
});
it("preserves partial and exact endpoint identity through graph projection", async () => {
const root = await createTestTempDirectory(
"rea-js-endpoint-partial-identity-",
);
await writeFile(
join(root, "app.js"),
'fetch(target); fetch("target"); function other(target) { fetch(target); }',
);
const snapshot = await scanCanonicalArtifactInventory(root, {});
const reader = createJavaScriptArtifactReader(root, "directory");
try {
const files = await readJavaScriptArtifactFiles(reader, snapshot);
const analysis = analyzeJavaScriptArtifactFiles(files);
const graph = buildJavaScriptArtifactGraph(snapshot, files, analysis);
const endpoints = graph.nodes.filter(({ kind }) => kind === "endpoint");
const partialNodes = endpoints.filter(({ observations }) =>
observations.some(
({ properties }) => properties.resolution === "partial",
),
);
const partial = partialNodes[0];
const exact = endpoints.find(({ observations }) =>
observations.some(
({ properties }) =>
properties.value === "target" && properties.resolution === undefined,
),
);
expect(partialNodes).toHaveLength(2);
expect(new Set(partialNodes.map(({ node_id }) => node_id)).size).toBe(2);
expect(exact).toBeDefined();
expect(partial?.node_id).not.toBe(exact?.node_id);
expect(partial?.observations[0]).toMatchObject({
properties: {
endpoint_kind: "network",
value: "target",
mechanism: "call:fetch",
resolution: "partial",
},
evidence: {
authority: "ast-static-analysis",
state: "observed",
limitations: [expect.stringContaining("not an exact literal")],
},
});
} finally {
await reader.close();
await rm(root, { recursive: true, force: true });
}
});