Files
reverse-engineering-anything/src/domain/referenceSourceGraph.test.ts
T
morluto 15de1d4dce feat(evidence)!: require JavaScript, browser, managed and reference-source facts their producers always write (#10990)
* feat(javascript)!: require the runtime parse-failure count and active Electron execution paths

The V8 Inspector projection always writes scripts.parse_failed_total and the
active Electron service always commits parameters.resolved_paths, so both are
now required. Runtime reconciliation reads the admitted execution paths only
and no longer falls back to request-spelled paths in parameters, and checks
the observed executable path against them on every capture.

JavaScriptStaticAnalysis.routes and module_runtime keep their omission, which
current producers still make (a checkpoint that cannot retain route facts; no
recovered factory runtime); their comments now say so instead of naming
historical analyses.

BREAKING CHANGE: JavaScript runtime observations without
scripts.parse_failed_total, and active Electron Evidence without
parameters.resolved_paths, are refused as malformed; recreate the observation.

* test(javascript): give the shared Node reconciliation fixture the required parse-failure count

* feat(browser)!: require browser observation facts their producers always write (#10991)

* feat(browser)!: require browser observation facts their producers always write

The source-map fetcher always writes effective_url (string or null), the web
bundle analyzer always writes schema_property_names_coverage, and the CDP
storage fingerprinter always marks IndexedDB schema fingerprints with
projection_version 2. Each is now required. The IndexedDB marker is tied to
its scope by a discriminated union and derived from the scope in the
producer, so compare_web_captures no longer carries the store-only
projection branch.

response_identity and the WebMCP consequential hint keep their omission,
which current producers still make (a body not fully read; an invalid
annotation); the guide no longer attributes it to historical captures.

BREAKING CHANGE: source-map items without effective_url, WebMCP declarations
without schema_property_names_coverage, and IndexedDB schema fingerprints
without projection_version are refused as malformed; recreate the capture.

* feat(managed)!: refuse members beside a null signature resolution (#10992)

* feat(managed)!: refuse members beside a null signature resolution

signature_resolution is null only when member decoding exceeded capacity,
and the capacity-recovery producer then examines no members. The managed
member inspection schema now enforces that: a null resolution with any
field, method, member reference, call edge or field access is malformed.

With that rule, every admitted inspection with members attests type-name
resolution, so the raw-digest fallback is unreachable and is deleted:
comparableSides, hasSignatureResolution, the comparison's
signatureResolutionExamined flag and the "does not attest" limitation. The
shared workflow example that carried resolved digests beside a null
attestation now attests resolution.

BREAKING CHANGE: managed member Evidence with a null signature_resolution
and any examined member is refused as malformed; recreate the observation.

* docs: describe historical Evidence by what the format revision now refuses (#10993)

SQLite worker_timeout_ms is required, so the SQLite guide no longer reads a
missing value as unknown settings. The IL2CPP, ESP image and process capture
guides now say that bundles exported without evidence_format are refused,
while a standalone record from an earlier release is still read with the
stated omission semantics (records carry no format marker yet). The route
inventory guide describes a parent without route_inventory by its meaning
rather than by its age.

* refactor(javascript): require static analysis coverage from the JavaScript worker (#11001)

* refactor(javascript): require static analysis coverage from the JavaScript worker

Both JavaScript static producers always write analysis_coverage: the
analyzer measures it on every parsed source and the failed-parse result
carries an unexamined coverage. The worker schema and the static analysis
type therefore require it, the preload-discovery checkpoint copies it
unconditionally, and ElectronBoundaryAnalysis reads Electron applicability
and examination limits from it alone. The fallback that re-derived Electron
use from semantic module links and retained references for analyses
without coverage is deleted, as are the graph and builder branches for a
missing coverage.

Retained Evidence graph observations are unchanged: the analysis view still
counts a stored JavaScript observation without analysis_coverage as
unmeasured, since standalone records carry no format marker yet.

The worker runs from the same build as its parent, so no external caller
sees the stricter reply schema.

* feat(browser)!: require storage fingerprint, Link context, mapping index and invalid-map identity facts (#11002)

* feat(browser)!: require storage fingerprint, Link context, mapping index and invalid-map identity facts

Each field is written by its only producer on every capture:

- The CDP storage capture always writes content_fingerprints,
  fingerprint_algorithm and fingerprints_complete, so their schema defaults
  are removed.
- The CDP Link header projection always writes context_url and
  context_scope, so they are required.
- The source-map fetcher writes source_index and declaration_index on every
  mapping row, so they are required.
- The fetcher judges a map invalid only after reading its complete body. A
  separate invalidSourceMapItem builder now takes the response identity as a
  required argument, and the schema's invalid member requires
  response_identity; fetch_failed keeps it optional because those rows can
  come from a body that was not fully read.

The browser and source-location guides no longer describe these fields as
optional for older saved captures.

BREAKING CHANGE: page inspections without the storage fingerprint fields or
Link context fields, source-map mapping rows without their indexes, and
invalid source-map items without response_identity are refused as malformed;
recreate the capture.

* test(browser): keep source-omission coverage on a still-defaulted field and refuse a missing fingerprint algorithm

* feat(browser)!: require web-bundle target origin, inspection producer facts, scenario redirect state and exclusion kind (#11014)

feat(browser)!: require web-bundle target origin, page inspection producer facts, scenario redirect state and exclusion kind

Each field is written by its only producer on every record:

- buildCaptureObservation always writes capture.target_origin (the validated
  origin or null), so analyze_web_bundle Evidence and both web-bundle view
  results require it; the view's conditional spread is gone.
- The CDP page capture always writes accessibility node states, script
  frame_id (null when unattributed) and worker opener_target_id and
  parent_frame_id, so their schema defaults are removed.
- PlaywrightScenarioNetwork writes redirected_from_transaction_state exactly
  when the predecessor ID is null, so request events now require it there and
  still refuse it on linked events.
- The reference-source importer writes entry_kind on every exclusion
  (unknown when the kind was not observed), so it is required.

The browser scenario contract and CLI guide no longer describe older
captures or exclusions without these fields.

BREAKING CHANGE: web-bundle analyses without capture.target_origin, page
inspections without these script, accessibility or worker fields, scenario
network events with a null predecessor and no redirect state, and reference
source graphs whose exclusions lack entry_kind are refused as malformed;
recreate the capture or re-import the source.
2026-11-15 19:37:10 +08:00

678 lines
21 KiB
TypeScript

import { createHash } from "node:crypto";
import canonicalize from "canonicalize";
import { describe, expect, it } from "vitest";
import {
createHistoricalSourceGraph,
createHistoricalSourceManifest,
historicalSourceGraphSchema,
historicalSourceParseFailureKey,
type HistoricalSourceGraphInput,
} from "./referenceSourceGraph.js";
const HASH_A = "a".repeat(64);
const HASH_B = "b".repeat(64);
type Entry = HistoricalSourceGraphInput["entries"][number];
type DirectoryEntry = Extract<Entry, { kind: "directory" }>;
type FileEntry = Extract<Entry, { kind: "file" }>;
type HashedFileEntry = Extract<FileEntry, { content_state: "hashed" }>;
type UnavailableFileEntry = Exclude<FileEntry, HashedFileEntry>;
type SymlinkEntry = Extract<Entry, { kind: "symlink" }>;
const directoryEntry = (
treeState: DirectoryEntry["tree_state"] = "enumerated",
): DirectoryEntry => ({
path: "src",
kind: "directory",
classifications: ["source"],
tree_state: treeState,
limitations: [],
});
const fileEntry = (
overrides: Partial<HashedFileEntry> = {},
): HashedFileEntry => ({
path: "src/main.ts",
kind: "file",
sha256: HASH_B,
size: 20,
language: "TypeScript",
classifications: ["source"],
content_state: "hashed",
limitations: [],
...overrides,
});
const unavailableFileEntry = (
overrides: Partial<UnavailableFileEntry> = {},
): UnavailableFileEntry => ({
path: "src/main.ts",
kind: "file",
sha256: null,
size: null,
language: "TypeScript",
classifications: ["source"],
content_state: "unreadable",
limitations: ["Permission denied"],
...overrides,
});
type KnownTargetSymlinkEntry = Extract<SymlinkEntry, { target: string }>;
const symlinkEntry = (
overrides: Partial<KnownTargetSymlinkEntry> = {},
): KnownTargetSymlinkEntry => ({
path: "src/package.json",
kind: "symlink",
target: "main.ts",
target_state: "internal",
classifications: ["manifest"],
limitations: [],
...overrides,
});
const graphInput = (): HistoricalSourceGraphInput => ({
schema: "HistoricalSourceGraph",
authority: "historical-reference",
root_alias: "$REFERENCE_ROOT",
inventory_state: "complete",
entries: [directoryEntry(), fileEntry(), symlinkEntry()],
relationships: [
{
from_path: "src/main.ts",
to: "node:fs",
kind: "imports",
resolution: "external",
parse_state: "parsed",
},
{
from_path: "src/main.ts",
to: "src",
kind: "references",
resolution: "internal",
parse_state: "parsed",
},
],
parse_failures: [],
exclusions: [],
languages: ["TypeScript"],
manifests: [],
vcs: { kind: "git", head: HASH_A, dirty: false },
provenance: { importer: "rea", importer_version: "1", caller: "test" },
limitations: [],
});
const registerSourceCommitmentTests = (): void => {
it("builds and verifies internal root and manifest commitments", () => {
const graph = createHistoricalSourceGraph(graphInput());
const first = createHistoricalSourceManifest(graph);
const second = createHistoricalSourceManifest(structuredClone(graph));
const graphJson = canonicalize(graph);
if (graphJson === undefined) throw new TypeError("Unserializable graph");
const expectedSemantic = {
schema: "HistoricalSourceManifest",
authority: "historical-reference",
graph_sha256: createHash("sha256").update(graphJson).digest("hex"),
root_sha256: graph.root_sha256,
inventory_state: "complete",
entry_count: 3,
relationship_count: 2,
};
const semanticJson = canonicalize(expectedSemantic);
if (semanticJson === undefined)
throw new TypeError("Unserializable manifest semantics");
expect(first).toEqual({
...expectedSemantic,
manifest_id: `hsm_${createHash("sha256").update(semanticJson).digest("hex")}`,
});
expect(first).toEqual(second);
expect(historicalSourceGraphSchema.parse(graph)).toEqual(graph);
expect(() =>
createHistoricalSourceGraph({
...graphInput(),
entries: [
directoryEntry(),
{ ...fileEntry(), content_state: "unreadable" },
symlinkEntry(),
],
}),
).toThrow();
});
it("rejects stale roots and commits file, directory, and symlink semantics", () => {
const original = createHistoricalSourceGraph(graphInput());
expect(() =>
historicalSourceGraphSchema.parse({ ...original, root_sha256: HASH_A }),
).toThrow(/root commitment/u);
for (const mutate of [
(input: HistoricalSourceGraphInput) => {
input.entries[0] = directoryEntry("partial");
input.inventory_state = "partial";
},
(input: HistoricalSourceGraphInput) => {
input.entries[1] = fileEntry({ sha256: "c".repeat(64) });
},
(input: HistoricalSourceGraphInput) => {
input.entries[2] = symlinkEntry({
target: "other.json",
target_state: "missing",
});
input.inventory_state = "partial";
},
(input: HistoricalSourceGraphInput) => {
input.exclusions = [
{
path: "private.env",
entry_kind: "file",
reason: "configured-secret",
pattern: ".env",
},
];
input.inventory_state = "partial";
},
]) {
const changed = graphInput();
mutate(changed);
expect(createHistoricalSourceGraph(changed).root_sha256).not.toBe(
original.root_sha256,
);
}
});
it("commits the matched pattern for each exclusion", () => {
const graphWith = (pattern: string) =>
createHistoricalSourceGraph({
...graphInput(),
inventory_state: "partial",
exclusions: [
{
path: "private.env",
entry_kind: "file",
reason: "configured-secret",
pattern,
},
],
});
expect(graphWith(".env").root_sha256).not.toBe(
graphWith("*.env").root_sha256,
);
});
};
describe("historical source graph", () => {
it("validates supplementary paths and derived indexes by code point", () => {
const paths = ["a", "aa", "\uE000", "\u{10000}"];
const input: HistoricalSourceGraphInput = {
...graphInput(),
entries: paths.map((path) =>
fileEntry({
path,
language: path,
classifications: ["manifest"],
}),
),
relationships: [],
languages: paths,
manifests: paths,
};
const graph = createHistoricalSourceGraph(input);
expect(historicalSourceGraphSchema.parse(graph)).toEqual(graph);
expect(() =>
createHistoricalSourceGraph({
...input,
entries: [...input.entries].sort((left, right) =>
left.path < right.path ? -1 : left.path > right.path ? 1 : 0,
),
}),
).toThrow(/Unicode code point/u);
});
it("omits absent local diagnostics and rejects explicitly undefined non-JSON metadata", () => {
const input = graphInput();
const graph = createHistoricalSourceGraph(input);
expect(graph.entries.map((entry) => entry.path)).toEqual(
input.entries.map((entry) => entry.path),
);
expect(
graph.entries.every(
(entry) => !Object.hasOwn(entry, "local_diagnostics"),
),
).toBe(true);
expect(() =>
createHistoricalSourceGraph({
...input,
entries: input.entries.map((entry) => ({
...entry,
local_diagnostics: undefined,
})),
}),
).toThrow();
});
registerSourceCommitmentTests();
it("retains actual external targets and rejects placeholder targets", () => {
const input = { ...graphInput(), inventory_state: "partial" as const };
input.entries[2] = symlinkEntry({
target: "/private/shared/target.js",
target_state: "external",
});
const graph = createHistoricalSourceGraph(input);
expect(graph.entries[2]).toMatchObject({
kind: "symlink",
target: "/private/shared/target.js",
target_state: "external",
});
expect(() =>
createHistoricalSourceGraph({
...input,
entries: input.entries.map((entry) =>
entry.kind === "symlink"
? { ...entry, target: "<outside-root>" }
: entry,
),
}),
).toThrow(/target path does not match/u);
});
it("derives language and manifest indexes and enforces code-point order", () => {
const input = graphInput();
input.entries[1] = fileEntry({ classifications: ["source", "test"] });
expect(() =>
createHistoricalSourceGraph({ ...input, languages: [] }),
).toThrow(/derived/u);
expect(() =>
createHistoricalSourceGraph({ ...input, manifests: ["src/main.ts"] }),
).toThrow(/derived/u);
expect(() =>
createHistoricalSourceGraph({
...input,
entries: input.entries.toReversed(),
}),
).toThrow(/Unicode code point/u);
expect(() =>
createHistoricalSourceGraph({
...input,
entries: input.entries.map((entry) =>
entry.path === "src/main.ts"
? { ...entry, classifications: ["test", "source"] }
: entry,
),
}),
).toThrow(/Unicode code point/u);
});
});
const registerLocalDiagnosticCommitmentTests = (): void => {
it("keeps unknown-entry diagnostics outside the root commitment", () => {
const base = graphInput();
base.inventory_state = "partial";
base.entries[2] = {
path: "src/package.json",
kind: "unknown",
classifications: ["unknown"],
limitations: ["Permission denied at /private/first"],
};
const graph = createHistoricalSourceGraph(base);
const changedMessage = structuredClone(base);
changedMessage.entries[2] = {
path: "src/package.json",
kind: "unknown",
classifications: ["unknown"],
limitations: ["Permission denied at /private/second"],
};
const revised = createHistoricalSourceGraph(changedMessage);
expect(revised.root_sha256).toBe(graph.root_sha256);
expect(createHistoricalSourceManifest(revised).graph_sha256).not.toBe(
createHistoricalSourceManifest(graph).graph_sha256,
);
});
it("retains local diagnostics outside semantic commitments while committing operation failures", () => {
const base = graphInput();
base.inventory_state = "partial";
base.entries[1] = unavailableFileEntry({
limitations: [
"File could not be read safely: EACCES. Check permissions.",
],
local_diagnostics: [
"EACCES: permission denied, open '/first/src/main.ts'",
],
});
const graph = createHistoricalSourceGraph(base);
const moved = structuredClone(base);
moved.entries[1]!.local_diagnostics = [
"EACCES: permission denied, open '/second/src/main.ts'",
];
const relocated = createHistoricalSourceGraph(moved);
expect(createHistoricalSourceManifest(relocated)).toEqual(
createHistoricalSourceManifest(graph),
);
expect(relocated.entries[1]!.local_diagnostics).toEqual(
moved.entries[1]!.local_diagnostics,
);
moved.entries[1]!.limitations = [
"File could not be read safely: EIO. Check permissions.",
];
expect(
createHistoricalSourceManifest(createHistoricalSourceGraph(moved))
.graph_sha256,
).not.toBe(createHistoricalSourceManifest(graph).graph_sha256);
});
};
describe("partial historical source graphs", () => {
registerLocalDiagnosticCommitmentTests();
it("keeps an unreadable symlink target unknown and out of root identity", () => {
const base = graphInput();
base.inventory_state = "partial";
base.entries[2] = {
path: "src/package.json",
kind: "symlink",
target: null,
target_state: "unreadable",
classifications: ["manifest"],
limitations: ["Target could not be read."],
};
const graph = createHistoricalSourceGraph(base);
expect(graph.entries[2]).toMatchObject({
kind: "symlink",
target: null,
target_state: "unreadable",
});
const changedMessage = structuredClone(base);
changedMessage.entries[2] = {
path: "src/package.json",
kind: "symlink",
target: null,
target_state: "unreadable",
classifications: ["manifest"],
limitations: ["A different diagnostic."],
};
const revised = createHistoricalSourceGraph(changedMessage);
expect(revised.root_sha256).toBe(graph.root_sha256);
expect(createHistoricalSourceManifest(revised).graph_sha256).not.toBe(
createHistoricalSourceManifest(graph).graph_sha256,
);
expect(() =>
createHistoricalSourceGraph({
...base,
entries: base.entries.map((entry) =>
entry.kind === "symlink"
? { ...entry, target: "<unreadable>" }
: entry,
),
}),
).toThrow();
});
it("preserves partial observations but rejects every partial complete graph", () => {
const partial = graphInput();
partial.inventory_state = "partial";
partial.entries[1] = unavailableFileEntry();
partial.parse_failures = [
{ path: "src/main.ts", parser: "typescript", reason: "Malformed input" },
];
expect(createHistoricalSourceGraph(partial).inventory_state).toBe(
"partial",
);
expect(
createHistoricalSourceGraph({ ...partial, inventory_state: "unknown" })
.inventory_state,
).toBe("unknown");
for (const change of [
{ entries: partial.entries },
{ parse_failures: partial.parse_failures },
{
exclusions: [
{
path: "secret",
entry_kind: "file" as const,
reason: "configured-secret" as const,
pattern: "secret",
},
],
},
{ limitations: ["Incomplete"] },
{
relationships: [
{
...graphInput().relationships[0]!,
parse_state: "partial" as const,
},
],
},
])
expect(() =>
createHistoricalSourceGraph({ ...graphInput(), ...change }),
).toThrow(/Complete inventory/u);
});
it("keeps distinct parse failure reasons for the same path and parser", () => {
const input = graphInput();
const malformed = {
path: "src/main.ts",
parser: "typescript",
reason: "Malformed input",
};
const unexpected = {
path: "src/main.ts",
parser: "typescript",
reason: "Unexpected token",
};
input.inventory_state = "partial";
input.parse_failures = [malformed, unexpected];
expect(createHistoricalSourceGraph(input).parse_failures).toEqual(
input.parse_failures,
);
expect(historicalSourceParseFailureKey(malformed)).not.toBe(
historicalSourceParseFailureKey(unexpected),
);
});
});
describe("historical source graph validation", () => {
it("rejects strict unknown fields, invalid VCS, and dangling internal edges", () => {
expect(() =>
createHistoricalSourceGraph({ ...graphInput(), surprise: true }),
).toThrow();
expect(() =>
createHistoricalSourceGraph({
...graphInput(),
vcs: { kind: "git", head: "main", dirty: false },
}),
).toThrow();
expect(() =>
createHistoricalSourceGraph({
...graphInput(),
relationships: [
{ ...graphInput().relationships[1]!, to: "missing.ts" },
],
}),
).toThrow(/normalized and inventoried/u);
expect(() =>
createHistoricalSourceGraph({
...graphInput(),
relationships: [
{ ...graphInput().relationships[1]!, to: "../escape.ts" },
],
}),
).toThrow(/normalized and inventoried/u);
expect(() =>
historicalSourceGraphSchema.parse({
...createHistoricalSourceGraph(graphInput()),
extra: true,
}),
).toThrow();
});
});
describe("historical source graph excluded symlink targets", () => {
it("retains internal symlinks into excluded trees without accepting sibling prefixes", () => {
const input = { ...graphInput(), inventory_state: "partial" as const };
input.exclusions = [
{
path: "dist",
entry_kind: "directory",
reason: "caller-excluded",
pattern: "dist/",
},
];
input.entries[2] = symlinkEntry({ target: "../dist/generated.js" });
const graph = createHistoricalSourceGraph(input);
expect(graph.entries[2]).toMatchObject({
target: "../dist/generated.js",
target_state: "internal",
});
input.entries[2] = symlinkEntry({ target: "../dist-old/generated.js" });
expect(() => createHistoricalSourceGraph(input)).toThrow(
/recorded exclusion/u,
);
});
it("does not treat an excluded file or unknown-kind ancestor as a directory", () => {
const input = { ...graphInput(), inventory_state: "partial" as const };
input.exclusions = [
{
path: "secret.txt",
entry_kind: "file",
reason: "configured-secret",
pattern: "secret.txt",
},
];
input.entries[2] = symlinkEntry({ target: "../secret.txt/child" });
expect(() => createHistoricalSourceGraph(input)).toThrow(
/recorded exclusion/u,
);
input.exclusions[0] = {
path: "secret.txt",
entry_kind: "unknown",
reason: "configured-secret",
pattern: "secret.txt",
};
expect(() => createHistoricalSourceGraph(input)).toThrow(
/recorded exclusion/u,
);
input.exclusions[0] = {
path: "secret.txt",
reason: "configured-secret",
pattern: "secret.txt",
} as (typeof input.exclusions)[number];
expect(() => createHistoricalSourceGraph(input)).toThrow(/entry_kind/u);
});
});
describe("historical source graph symlink path identity", () => {
it("joins internal symlink targets with the inventory NFC normalizer", () => {
// "café" spelled NFC, as the inventory produces it, and the same
// name spelled NFD, as a macOS readlink can report it.
const nfcPath = "src/café.ts";
const nfdTarget = "cafe\u0301.ts";
expect(nfcPath).not.toBe(nfdTarget);
const input = { ...graphInput(), inventory_state: "partial" as const };
input.entries[1] = fileEntry({ path: nfcPath });
input.entries[2] = symlinkEntry({
path: "src/link.js",
target: nfdTarget,
target_state: "internal",
});
input.relationships = [];
const graph = createHistoricalSourceGraph(input);
expect(graph.entries[2]).toMatchObject({
kind: "symlink",
target: nfdTarget,
target_state: "internal",
});
});
it("preserves an exact NFD inventory spelling when resolving its symlink", () => {
const input = { ...graphInput(), inventory_state: "partial" as const };
input.entries[1] = fileEntry({ path: "src/cafe\u0301.ts" });
input.entries[2] = symlinkEntry({
path: "src/link.js",
target: "cafe\u0301.ts",
target_state: "internal",
});
input.relationships = [];
expect(createHistoricalSourceGraph(input).entries[1]?.path).toBe(
"src/cafe\u0301.ts",
);
});
it("still rejects an internal symlink target that no inventory holds", () => {
const input = { ...graphInput(), inventory_state: "partial" as const };
input.entries[2] = symlinkEntry({
path: "src/link.js",
// The NFD spelling normalizes to "src/café.ts", which the
// inventory does not contain, so the join must still miss.
target: "cafe\u0301.ts",
target_state: "internal",
});
expect(() => createHistoricalSourceGraph(input)).toThrow(
/must resolve to an inventoried entry/u,
);
});
});
it.each([
"\0",
"/absolute.js",
"../outside.js",
"a/../b.js",
"a//b.js",
"./a.js",
"a/",
])("rejects unsafe historical logical entry spelling %j", (path) => {
const input = graphInput();
input.entries = [fileEntry({ path })];
input.relationships = [];
expect(() => createHistoricalSourceGraph(input)).toThrow();
});
it("rejects NUL in observed symlink targets before graph identity", () => {
const input = graphInput();
input.entries[2] = symlinkEntry({ target: "literal\0name.js" });
expect(() => createHistoricalSourceGraph(input)).toThrow(
/normalized POSIX symlink target/u,
);
});
it.each(["C:\\outside\\file.js", "\\\\server\\share.js"])(
"preserves unowned recorded Windows absolute target policy %j",
(target) => {
const external = graphInput();
external.inventory_state = "partial";
external.entries[2] = symlinkEntry({ target, target_state: "external" });
expect(createHistoricalSourceGraph(external).entries).toContainEqual(
expect.objectContaining({ target, target_state: "external" }),
);
const internal = graphInput();
internal.entries[2] = symlinkEntry({ target, target_state: "internal" });
expect(() => createHistoricalSourceGraph(internal)).toThrow(
/target path does not match its target state/u,
);
},
);
it("refuses an absolute POSIX internal target even when lexical joining would name an inventoried file", () => {
const input = graphInput();
input.entries[2] = symlinkEntry({
target: "/main.ts",
target_state: "internal",
});
expect(() => createHistoricalSourceGraph(input)).toThrow(
/target path does not match its target state/u,
);
});