fix(javascript): preserve graph facts across omissions and versions

Omit absent inventory facts without erasing explicit unknowns. Compare canonical file occurrences by source path and digest while preserving complete container provenance in observations and Evidence.

Consolidate candidate-capacity fixtures around unresolved alternatives and update inventory coverage and source-occurrence oracles. Preserve resource, identity, relationship uncertainty, cancellation, and transfer regressions.
This commit is contained in:
morluto committed 2026-10-24 06:20:36 +08:00
1 parent 9dde3fd6a4
commit 30db499db3
9 files changed
+243 -29

No files matched your search

@@ -80,6 +80,9 @@ const contextFor = (
graph_sha256: SHA256,
},
nodes: [{ artifact_id: `art_${SHA256}`, sha256: SHA256, size: 1 }],
// These fixtures model complete directory traversal; source-analysis gaps
// remain on the individual files and do not imply missing inventory paths.
coverage: { scope: "root", status: "complete" },
} as unknown as ArtifactInventorySnapshot;
const fileSet = {
files: [file],
@@ -157,6 +160,47 @@ describe("skipped JavaScript parse reporting", () => {
});
});
it("preserves omitted inventory facts on an unavailable artifact", () => {
const file = skippedFile();
const base = contextFor(file, analysisFor([]));
const context: JavaScriptArtifactGraphContext = {
...base,
fileSet: {
...base.fileSet,
files: [],
unavailable_relevant_files: [
{
path: file.path,
container_sha256: file.container_sha256,
sha256: null,
bytes: null,
inventory_artifact_id: null,
},
],
},
};
addJavaScriptArtifactFiles(context);
const entry = context.accumulator
.nodes()
.find(
({ identity }) =>
identity.strategy === "canonical-path" && identity.path === file.path,
);
expect(entry?.observations[0]?.properties).toEqual({
path: file.path,
entry_sha256: null,
bytes: null,
inventory_artifact_id: null,
content_available: false,
});
expect(
context.accumulator
.edges()
.find(({ target_node_id }) => target_node_id === entry?.node_id)
?.properties,
).toEqual({ path: file.path, content_available: false });
});
it.each([false, true])(
"retains possible setter owners independently of proven imports (possible owner: %s)",
(possibleOwner) => {