fix(javascript): preserve source facts across graph projections

This commit is contained in:
morluto
2026-10-24 02:59:20 +08:00
parent dac544be20
commit c8f8ec656c
14 changed files with 369 additions and 60 deletions
@@ -379,6 +379,13 @@ export const javascriptAnalysisCoverage = (
? completeApplicationCoverage()
: partialApplicationCoverage([], null);
/** Parsed inventory identity shared by whole-file graph representations. */
export const fileOccurrenceIdentity = (file: JavaScriptArtifactFile) => ({
container_sha256: file.container_sha256,
path: file.path,
sha256: file.sha256,
});
/** Stable identity for a fact scoped to one exact artifact. */
export const artifactLocalIdentity = (
sha256: string,
@@ -25,6 +25,7 @@ import {
dependencyManifest,
addUnavailableStaticParseScope,
artifactFileNodeKind,
fileOccurrenceIdentity,
artifactLocalIdentity,
javascriptAnalysisCoverage,
createElectronRoleNode,
@@ -603,6 +604,7 @@ const createFileTarget = (
{
label: file.path,
properties: {
file_occurrence: fileOccurrenceIdentity(file),
path: file.path,
bytes: file.bytes,
inventory_artifact_id: file.inventory_artifact_id,
@@ -23,6 +23,7 @@ import type { JavaScriptArtifactFile } from "../../domain/javascript/javascriptA
import {
addAstContainsEdge,
artifactLocalIdentity,
fileOccurrenceIdentity,
type JavaScriptArtifactGraphContext,
type JavaScriptArtifactGraphCoverage,
} from "./JavaScriptArtifactGraphContext.js";
@@ -106,6 +107,7 @@ export const addJavaScriptSourceModules = (
label: file.path,
properties: {
semantic_role: "source-module",
file_occurrence: fileOccurrenceIdentity(file),
source_sha256: file.sha256,
path: file.path,
logical_module_key: file.path,
@@ -202,6 +204,7 @@ const addExportRelationship = (
label: `${file.path}:${link.exportedName}`,
properties: {
semantic_role: "export-binding",
file_occurrence: fileOccurrenceIdentity(file),
module_path: file.path,
relationship_kind: link.kind,
exported_name: link.exportedName,