refactor: remove abandoned test-only analysis scaffolding
This commit is contained in:
@@ -9,9 +9,6 @@ import { ARTIFACT_CLASSIFICATION_PREFIX_BYTES } from "../../../src/artifacts/Art
|
||||
import { scanCanonicalArtifactInventory } from "../../../src/application/ArtifactInventory/scanCanonical.js";
|
||||
import { targetFormatSchema } from "../../../src/contracts/toolOutputSchemaPrimitives.js";
|
||||
import { artifactInventoryResultSchema } from "../../../src/domain/artifactGraph.js";
|
||||
import { createEvidence } from "../../../src/domain/evidence.js";
|
||||
import { jsonValueSchema } from "../../../src/domain/jsonValue.js";
|
||||
import { identifyRuntimes } from "../../../src/domain/runtimeIdentification.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
describe("MZ artifact classification", () => {
|
||||
@@ -62,7 +59,7 @@ describe("MZ artifact classification", () => {
|
||||
expect(targetFormatSchema.parse("dos-mz")).toBe("dos-mz");
|
||||
});
|
||||
|
||||
it("keeps standalone and embedded DOS identities through inventory and runtime evidence", async () => {
|
||||
it("keeps standalone and embedded DOS identities through inventory", async () => {
|
||||
const directory = await createTestTempDirectory("rea-mz-inventory-");
|
||||
const dosPath = join(directory, "LEGACY.EXE");
|
||||
const pePath = join(directory, "NATIVE.EXE");
|
||||
@@ -88,30 +85,6 @@ describe("MZ artifact classification", () => {
|
||||
expect(inventory.nodes.map(({ format }) => format)).toEqual(
|
||||
expect.arrayContaining(["dos-mz", "pe"]),
|
||||
);
|
||||
const evidence = createEvidence(
|
||||
{
|
||||
path: tree,
|
||||
sha256: inventory.manifest.root_sha256,
|
||||
format: "directory",
|
||||
},
|
||||
{ id: "inventory-fixture", name: "Inventory fixture", version: null },
|
||||
{
|
||||
operation: "inventory_artifact",
|
||||
parameters: {},
|
||||
result: jsonValueSchema.parse(inventory),
|
||||
},
|
||||
);
|
||||
const runtimes = identifyRuntimes({ inventory_evidence: [evidence] });
|
||||
expect(runtimes.runtimes).toContainEqual(
|
||||
expect.objectContaining({
|
||||
family: "native",
|
||||
inspection: "provider-selection-required",
|
||||
observations: expect.arrayContaining([
|
||||
expect.objectContaining({ path: "LEGACY.EXE", format: "dos-mz" }),
|
||||
expect.objectContaining({ path: "NATIVE.EXE", format: "pe" }),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import { scanAuthorizedArtifactInventory } from "../../../src/application/AuthorizedArtifactInventory.js";
|
||||
|
||||
describe("authorized artifact inventory", () => {
|
||||
it("scans a local artifact without configured input roots", async () => {
|
||||
const root = await createTestTempDirectory("rea-artifact-roots-");
|
||||
const path = join(root, "artifact.js");
|
||||
await writeFile(path, "export const value = 1;\n");
|
||||
const inventory = await scanAuthorizedArtifactInventory(path);
|
||||
expect(inventory.manifest.root_format).toBe("javascript-bundle");
|
||||
});
|
||||
});
|
||||
@@ -1,191 +0,0 @@
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import {
|
||||
TextReader,
|
||||
Uint8ArrayReader,
|
||||
Uint8ArrayWriter,
|
||||
ZipWriter,
|
||||
} from "@zip.js/zip.js";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import { runProviderAnalysis } from "../../../src/composition/directAnalysis.js";
|
||||
import { parseEvidence } from "../../../src/domain/evidence.js";
|
||||
import {
|
||||
identifyRuntimes,
|
||||
runtimeIdentificationResultSchema,
|
||||
} from "../../../src/domain/runtimeIdentification.js";
|
||||
|
||||
describe("runtime identification", () => {
|
||||
it("identifies APK runtime families and exposes missing semantic providers", async () => {
|
||||
const root = await createTestTempDirectory("rea-runtime-");
|
||||
const path = join(root, "Fixture.apk");
|
||||
await writeApkRuntimeFixture(path);
|
||||
|
||||
const inventory = parseEvidence(
|
||||
await runProviderAnalysis(path, "inventory_artifact", {}),
|
||||
);
|
||||
const first = identifyRuntimes({ inventory_evidence: [inventory] });
|
||||
const second = identifyRuntimes({ inventory_evidence: [inventory] });
|
||||
expect(first).toEqual(second);
|
||||
expect(runtimeIdentificationResultSchema.parse(first)).toMatchObject({
|
||||
root_format: "apk",
|
||||
coverage: {
|
||||
status: "complete-within-inventory",
|
||||
inventory_complete: true,
|
||||
},
|
||||
});
|
||||
expect(first.runtimes.map(({ family }) => family)).toEqual([
|
||||
"android",
|
||||
"javascript",
|
||||
"jvm",
|
||||
"native",
|
||||
"webassembly",
|
||||
]);
|
||||
expect(first.runtimes).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
family: "android",
|
||||
inspection: "available",
|
||||
provider_id: "rea-android-application",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
family: "jvm",
|
||||
inspection: "provider-missing",
|
||||
provider_id: null,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
family: "webassembly",
|
||||
inspection: "provider-missing",
|
||||
provider_id: null,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
family: "javascript",
|
||||
inspection: "available",
|
||||
provider_id: "rea-javascript-application",
|
||||
}),
|
||||
expect.objectContaining({
|
||||
family: "native",
|
||||
inspection: "provider-selection-required",
|
||||
provider_id: null,
|
||||
}),
|
||||
]),
|
||||
);
|
||||
const widened = runtimeIdentificationResultSchema.parse({
|
||||
...first,
|
||||
root_format: "x".repeat(101),
|
||||
source_evidence_ids: Array.from(
|
||||
{ length: 101 },
|
||||
() => inventory.evidence_id,
|
||||
),
|
||||
limitations: Array.from({ length: 101 }, () => "x".repeat(4_097)),
|
||||
runtimes: first.runtimes.map((runtime) => ({
|
||||
...runtime,
|
||||
...(runtime.provider_id === null
|
||||
? { reason: "x".repeat(1_001) }
|
||||
: { provider_id: `provider-${"x".repeat(200)}` }),
|
||||
observations: runtime.observations.map((observation) => ({
|
||||
...observation,
|
||||
path: "x".repeat(4_097),
|
||||
format: "x".repeat(101),
|
||||
})),
|
||||
})),
|
||||
});
|
||||
expect(widened.limitations).toHaveLength(101);
|
||||
expect(widened.runtimes[0]?.observations[0]?.path).toHaveLength(4_097);
|
||||
const available = first.runtimes.find(
|
||||
({ inspection }) => inspection === "available",
|
||||
);
|
||||
if (available === undefined)
|
||||
throw new TypeError("Expected an available runtime provider");
|
||||
expect(
|
||||
runtimeIdentificationResultSchema.safeParse({
|
||||
...first,
|
||||
runtimes: [{ ...available, provider_id: null, reason: "Missing." }],
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts more than 100 supplied inventory Evidence records", async () => {
|
||||
const root = await createTestTempDirectory("rea-runtime-pages-");
|
||||
const path = join(root, "Fixture.apk");
|
||||
const writer = new ZipWriter(new Uint8ArrayWriter());
|
||||
await writer.add("one.js", new TextReader("one"));
|
||||
await writeFile(path, await writer.close());
|
||||
const inventory = parseEvidence(
|
||||
await runProviderAnalysis(path, "inventory_artifact", {}),
|
||||
);
|
||||
const result = identifyRuntimes({
|
||||
inventory_evidence: Array.from({ length: 101 }, () => inventory),
|
||||
});
|
||||
|
||||
expect(result.source_evidence_ids).toHaveLength(101);
|
||||
expect(result.coverage.status).toBe("complete-within-inventory");
|
||||
expect(result.runtimes).toContainEqual(
|
||||
expect.objectContaining({
|
||||
family: "javascript",
|
||||
observations: expect.arrayContaining([
|
||||
expect.objectContaining({ path: "one.js" }),
|
||||
]),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("does not route nested DEX content to the APK-only provider", async () => {
|
||||
const root = await createTestTempDirectory("rea-runtime-dex-");
|
||||
const path = join(root, "Fixture.zip");
|
||||
const writer = new ZipWriter(new Uint8ArrayWriter());
|
||||
await writer.add(
|
||||
"classes.dex",
|
||||
new Uint8ArrayReader(
|
||||
Uint8Array.from([...Buffer.from("dex\n035\0"), 0, 0, 0, 0]),
|
||||
),
|
||||
);
|
||||
await writeFile(path, await writer.close());
|
||||
|
||||
const inventory = parseEvidence(
|
||||
await runProviderAnalysis(path, "inventory_artifact", {}),
|
||||
);
|
||||
const result = identifyRuntimes({ inventory_evidence: [inventory] });
|
||||
|
||||
expect(result.runtimes).toContainEqual(
|
||||
expect.objectContaining({
|
||||
family: "android",
|
||||
inspection: "provider-selection-required",
|
||||
provider_id: null,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
const writeApkRuntimeFixture = async (path: string): Promise<void> => {
|
||||
const writer = new ZipWriter(new Uint8ArrayWriter());
|
||||
await writer.add(
|
||||
"AndroidManifest.xml",
|
||||
new Uint8ArrayReader(Uint8Array.from([3, 0, 8, 0, 8, 0, 0, 0])),
|
||||
);
|
||||
await writer.add(
|
||||
"classes.dex",
|
||||
new Uint8ArrayReader(
|
||||
Uint8Array.from([...Buffer.from("dex\n035\0"), 0, 0, 0, 0]),
|
||||
),
|
||||
);
|
||||
await writer.add(
|
||||
"assets/Fixture.class",
|
||||
new Uint8ArrayReader(
|
||||
Uint8Array.from([0xca, 0xfe, 0xba, 0xbe, 0, 0, 0, 61]),
|
||||
),
|
||||
);
|
||||
await writer.add(
|
||||
"assets/module.wasm",
|
||||
new Uint8ArrayReader(Uint8Array.from([0, 0x61, 0x73, 0x6d, 1, 0, 0, 0])),
|
||||
);
|
||||
await writer.add("assets/main.js", new TextReader("bridge.call();"));
|
||||
await writer.add(
|
||||
"lib/arm64-v8a/libfixture.so",
|
||||
new Uint8ArrayReader(Uint8Array.from([0x7f, 0x45, 0x4c, 0x46, 2, 1, 1, 0])),
|
||||
);
|
||||
await writeFile(path, await writer.close());
|
||||
};
|
||||
@@ -1,81 +0,0 @@
|
||||
import { execFile } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
import { lstat, readdir, rm } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
createStoreFileLock,
|
||||
removeStaleStoreFileLock,
|
||||
} from "../../../src/application/StoreFileLock.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
describe("store lock cleanup ownership", () => {
|
||||
it.each(["released", "replaced"] as const)(
|
||||
"preserves a successor lock when an old %s owner cleans up",
|
||||
async (state) => {
|
||||
const root = await createTestTempDirectory("rea-store-lock-owner-");
|
||||
const path = join(root, "transaction.lock");
|
||||
const previous = await createStoreFileLock(path);
|
||||
if (state === "released") await previous.release();
|
||||
else await rm(path, { recursive: true });
|
||||
const successor = await createStoreFileLock(path);
|
||||
try {
|
||||
await previous.release();
|
||||
await expect(lstat(path)).resolves.toBeDefined();
|
||||
await expect(createStoreFileLock(path)).rejects.toMatchObject({
|
||||
code: "EEXIST",
|
||||
});
|
||||
} finally {
|
||||
await successor.release();
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe("store lock acquisition and recovery", () => {
|
||||
it("admits one concurrent owner and removes all preparation directories", async () => {
|
||||
const root = await createTestTempDirectory("rea-store-lock-contenders-");
|
||||
const path = join(root, "transaction.lock");
|
||||
const results = await Promise.allSettled(
|
||||
Array.from({ length: 8 }, () => createStoreFileLock(path)),
|
||||
);
|
||||
try {
|
||||
expect(
|
||||
results.filter((result) => result.status === "fulfilled"),
|
||||
).toHaveLength(1);
|
||||
for (const result of results)
|
||||
if (result.status === "rejected")
|
||||
expect(result.reason).toMatchObject({ code: "EEXIST" });
|
||||
expect(await readdir(root)).toEqual(["transaction.lock"]);
|
||||
expect(await removeStaleStoreFileLock(path)).toBe(false);
|
||||
} finally {
|
||||
await Promise.all(
|
||||
results.map((result) =>
|
||||
result.status === "fulfilled" ? result.value.release() : undefined,
|
||||
),
|
||||
);
|
||||
}
|
||||
expect(await readdir(root)).toEqual([]);
|
||||
});
|
||||
|
||||
it("recovers a directory lock abandoned by an exited process", async () => {
|
||||
const root = await createTestTempDirectory("rea-store-lock-exited-");
|
||||
const path = join(root, "transaction.lock");
|
||||
await promisify(execFile)(
|
||||
process.execPath,
|
||||
["tests/fixtures/abandonStoreFileLock.mjs", path],
|
||||
{ timeout: 5_000 },
|
||||
);
|
||||
expect((await lstat(path)).isDirectory()).toBe(true);
|
||||
expect(await removeStaleStoreFileLock(path)).toBe(true);
|
||||
const successor = await createStoreFileLock(path);
|
||||
try {
|
||||
expect(await removeStaleStoreFileLock(path)).toBe(false);
|
||||
} finally {
|
||||
await successor.release();
|
||||
}
|
||||
expect(await readdir(root)).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -3,7 +3,6 @@ import { join } from "node:path";
|
||||
import { expect, it } from "vitest";
|
||||
import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js";
|
||||
import { parseBinaryTarget } from "../../../../src/application/BinaryTargetResolver.js";
|
||||
import { parseMachineType } from "../../../../src/domain/peInspection.js";
|
||||
import { buildManagedPeFixture } from "../../../../src/dotnet/ManagedPe.fixture.js";
|
||||
import { ManagedStaticProvider } from "../../../../src/dotnet/ManagedStaticProvider.js";
|
||||
|
||||
@@ -24,7 +23,6 @@ it.each([0x01c0, 0x01c2, 0x01c4])(
|
||||
architecture: "arm",
|
||||
managed: true,
|
||||
});
|
||||
expect(parseMachineType(machine)).toBe("arm");
|
||||
const client = new ManagedStaticProvider().createClient(parsed.value);
|
||||
try {
|
||||
for (const operation of [
|
||||
|
||||
@@ -4,8 +4,6 @@ import type { VerifierContract } from "../../../src/domain/conformancePackage.js
|
||||
import {
|
||||
compareDimension,
|
||||
evaluateTrustGate,
|
||||
isSemanticDimension,
|
||||
isVolatileDimension,
|
||||
trustGateResultSchema,
|
||||
} from "../../../src/domain/conformanceTrustGate.js";
|
||||
|
||||
@@ -35,52 +33,6 @@ const expectDivergenceRejected = (
|
||||
};
|
||||
|
||||
describe("conformance trust gates", () => {
|
||||
it("classifies volatile dimensions correctly", () => {
|
||||
expect(isVolatileDimension("timing")).toBe(true);
|
||||
expect(isVolatileDimension("timestamp")).toBe(true);
|
||||
expect(isVolatileDimension("pid")).toBe(true);
|
||||
expect(isVolatileDimension("exit_code")).toBe(false);
|
||||
});
|
||||
|
||||
it("classifies semantic dimensions correctly", () => {
|
||||
expect(isSemanticDimension("exit_code")).toBe(true);
|
||||
expect(isSemanticDimension("stdout")).toBe(true);
|
||||
expect(isSemanticDimension("timing")).toBe(false);
|
||||
});
|
||||
|
||||
it("matches identical values", () => {
|
||||
const result = compareDimension("exit_code", 0, 0);
|
||||
expect(result.status).toBe("match");
|
||||
});
|
||||
|
||||
it("detects mismatches", () => {
|
||||
const result = compareDimension("exit_code", 0, 1);
|
||||
expect(result.status).toBe("mismatch");
|
||||
});
|
||||
|
||||
it("ignores volatile dimensions", () => {
|
||||
const result = compareDimension("timing", 100, 200);
|
||||
expect(result.status).toBe("match");
|
||||
expect(result.message).toContain("volatile");
|
||||
});
|
||||
|
||||
it("handles truncated evidence", () => {
|
||||
const result = compareDimension("exit_code", 0, null, {
|
||||
truncated: true,
|
||||
});
|
||||
expect(result.status).toBe("truncated");
|
||||
});
|
||||
|
||||
it("handles undefined values", () => {
|
||||
const result = compareDimension("exit_code", undefined, undefined);
|
||||
expect(result.status).toBe("unknown");
|
||||
});
|
||||
|
||||
it("handles missing actual", () => {
|
||||
const result = compareDimension("exit_code", 0, undefined);
|
||||
expect(result.status).toBe("unknown");
|
||||
});
|
||||
|
||||
it("keeps semantic unknown and truncated values out of equivalence", () => {
|
||||
expect(
|
||||
compareDimension(
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
import { createStoreFileLock } from "../../dist/application/StoreFileLock.js";
|
||||
|
||||
const path = process.argv[2];
|
||||
if (path === undefined) throw new Error("A lock path is required");
|
||||
await createStoreFileLock(path);
|
||||
// Exit without invoking release so the parent can exercise dead-owner recovery.
|
||||
Reference in New Issue
Block a user