refactor(test): colocate pure-domain tests and reduce test debt (#471)
* refactor(test): colocate pure-domain tests and reduce test debt Move focused immutable domain/contracts/adapter tests from tests/composition/** beside their production owners under src/** as colocated *.test.ts/*.fixture.ts, and relocate persistence-shaped composition tests under tests/boundary/filesystem/**. Update import paths, the Vitest project topology (shared worker context for pure domain/contracts and recording-port service projects), the test migration ledger, testing docs, and AGENTS.md to match. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: remove test migration ledger The cutover is complete and the ledger is no longer referenced anywhere in source, scripts, or the docs gate. Drop the standalone artifact. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: clean up stale migration artifacts Remove empty directories left by the test migration and replace the "final cutover" language in docs/testing.md with standing PR guidance that no longer references the completed migration. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: repair CI failures from schema, knip, and stale generated artifacts Three root causes fixed: 1. catalog-schemas.mjs: valuesAt only traversed anyOf from Zod's toJSONSchema, not oneOf. The webScreenshotDiffSchema change to a discriminated union produces oneOf, so the product catalog generator could not derive the web_screenshot_diff schema version. Add oneOf traversal. 2. conformancePackage.ts: the test rewrite removed the only imports of ScenarioManifest, ReplayPlan, ShimPlan, and ExpectedEvidence, making them unused exports that knip flags. Remove the dead type aliases. 3. Regenerate stale artifacts (product catalog, MCP tool catalog, skill metadata, conformance manifest) that drifted from the source changes. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
344b9b6dff
commit
e91c8c39c2
@@ -28,12 +28,11 @@ export const resolveGhidraAnalysisProfile = (
|
||||
return Promise.resolve(err(new AnalysisCancelledError("open_binary")));
|
||||
if (target.kind !== "executable")
|
||||
return Promise.resolve(ok({ profile: null, compatibility: {} }));
|
||||
const version = installation.providerVersion;
|
||||
if (!installation.available || version === null)
|
||||
if (installation.status === "unavailable")
|
||||
return Promise.resolve(
|
||||
err(new ProviderAdapterError(identity.id, "resolve_analysis_profile")),
|
||||
);
|
||||
const provider = { ...identity, version };
|
||||
const provider = { ...identity, version: installation.providerVersion };
|
||||
return Promise.resolve(
|
||||
ok({
|
||||
profile: createAnalysisProfile(provider, 1, {
|
||||
|
||||
+11
-11
@@ -14,15 +14,13 @@ export const projectGhidraDoctorInspection = (
|
||||
): DoctorProviderInspection => ({
|
||||
id: "ghidra",
|
||||
configured: inspection.installDir !== null,
|
||||
available: inspection.available,
|
||||
available: inspection.status === "available",
|
||||
providerVersion: inspection.providerVersion,
|
||||
registrationEnvironment:
|
||||
inspection.available && inspection.installDir !== null
|
||||
inspection.status === "available"
|
||||
? {
|
||||
GHIDRA_INSTALL_DIR: inspection.installDir,
|
||||
...(inspection.javaHome === null
|
||||
? {}
|
||||
: { JAVA_HOME: inspection.javaHome }),
|
||||
JAVA_HOME: inspection.javaHome,
|
||||
}
|
||||
: {},
|
||||
checks: selectedChecks(inspection).map((check) =>
|
||||
@@ -54,14 +52,14 @@ const selectedChecks = (
|
||||
);
|
||||
const configuration = byName.get("configuration");
|
||||
if (configuration === undefined) return [];
|
||||
if (!configuration.ok) return [configuration];
|
||||
if (configuration.status === "failed") return [configuration];
|
||||
const installation = byName.get("installation");
|
||||
return [
|
||||
configuration,
|
||||
byName.get("platform"),
|
||||
byName.get("architecture"),
|
||||
installation,
|
||||
...(installation?.ok === true
|
||||
...(installation?.status === "passed"
|
||||
? [byName.get("version"), byName.get("headless")]
|
||||
: []),
|
||||
byName.get("java"),
|
||||
@@ -75,14 +73,16 @@ const projectCheck = (
|
||||
configured: boolean,
|
||||
): DoctorProviderCheck => ({
|
||||
name: check.name,
|
||||
ok: check.ok,
|
||||
code: check.code,
|
||||
ok: check.status === "passed",
|
||||
code: check.status === "failed" ? check.code : null,
|
||||
detail: check.detail,
|
||||
remediation: check.remediation,
|
||||
remediation: check.status === "failed" ? check.remediation : null,
|
||||
classification:
|
||||
check.name === "platform" || check.name === "architecture"
|
||||
? "unsupported_host"
|
||||
: check.name === "java" && check.code === "runtime_missing"
|
||||
: check.name === "java" &&
|
||||
check.status === "failed" &&
|
||||
check.code === "runtime_missing"
|
||||
? "missing_dependency"
|
||||
: configured
|
||||
? "config_drift"
|
||||
|
||||
@@ -20,45 +20,77 @@ export interface GhidraInstallationOptions {
|
||||
}
|
||||
|
||||
/** One independently actionable part of the supported-installation contract. */
|
||||
export interface GhidraInstallationCheck {
|
||||
readonly name:
|
||||
| "configuration"
|
||||
| "platform"
|
||||
| "architecture"
|
||||
| "installation"
|
||||
| "version"
|
||||
| "headless"
|
||||
| "java";
|
||||
readonly ok: boolean;
|
||||
readonly code: ProviderRejectionCode | null;
|
||||
readonly detail: string;
|
||||
readonly remediation: string | null;
|
||||
}
|
||||
export type GhidraInstallationCheck =
|
||||
| {
|
||||
readonly status: "passed";
|
||||
readonly name: GhidraInstallationCheckName;
|
||||
readonly detail: string;
|
||||
}
|
||||
| {
|
||||
readonly status: "failed";
|
||||
readonly name: GhidraInstallationCheckName;
|
||||
readonly code: ProviderRejectionCode;
|
||||
readonly detail: string;
|
||||
readonly remediation: string;
|
||||
};
|
||||
|
||||
/** Bounded observation of a BYO Ghidra installation and JDK. */
|
||||
export interface GhidraInstallationInspection {
|
||||
readonly available: boolean;
|
||||
/** Stable identity for one Ghidra installation check. */
|
||||
export type GhidraInstallationCheckName =
|
||||
| "configuration"
|
||||
| "platform"
|
||||
| "architecture"
|
||||
| "installation"
|
||||
| "version"
|
||||
| "headless"
|
||||
| "java";
|
||||
|
||||
interface GhidraInstallationObservation {
|
||||
readonly platform: NodeJS.Platform;
|
||||
readonly architecture: NodeJS.Architecture;
|
||||
readonly applicationPropertiesPath: string | null;
|
||||
readonly javaCommand: string;
|
||||
readonly checks: readonly GhidraInstallationCheck[];
|
||||
}
|
||||
|
||||
/** Bounded observation of a supported BYO Ghidra installation and JDK. */
|
||||
export interface AvailableGhidraInstallation
|
||||
extends GhidraInstallationObservation {
|
||||
readonly status: "available";
|
||||
readonly installDir: string;
|
||||
readonly analyzeHeadlessPath: string;
|
||||
readonly applicationPropertiesPath: string;
|
||||
readonly providerVersion: string;
|
||||
readonly javaHome: string;
|
||||
readonly javaVersion: string;
|
||||
}
|
||||
|
||||
/** Bounded observation explaining why a BYO Ghidra installation is unusable. */
|
||||
export interface UnavailableGhidraInstallation
|
||||
extends GhidraInstallationObservation {
|
||||
readonly status: "unavailable";
|
||||
readonly installDir: string | null;
|
||||
readonly analyzeHeadlessPath: string | null;
|
||||
readonly applicationPropertiesPath: string | null;
|
||||
readonly providerVersion: string | null;
|
||||
readonly javaCommand: string;
|
||||
readonly javaHome: string | null;
|
||||
readonly javaVersion: string | null;
|
||||
readonly checks: readonly GhidraInstallationCheck[];
|
||||
readonly rejectionCode: ProviderRejectionCode | null;
|
||||
readonly reason: string | null;
|
||||
readonly rejection: Readonly<{
|
||||
code: ProviderRejectionCode;
|
||||
reason: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
/** Parsed available or unavailable state of one BYO Ghidra installation. */
|
||||
export type GhidraInstallationInspection =
|
||||
| AvailableGhidraInstallation
|
||||
| UnavailableGhidraInstallation;
|
||||
|
||||
/** Parsed identity of the JDK selected for Ghidra. */
|
||||
export interface GhidraJavaObservation {
|
||||
readonly version: string;
|
||||
readonly major: number;
|
||||
readonly home: string;
|
||||
readonly bits: number;
|
||||
readonly jdk: boolean;
|
||||
readonly runtime: "jdk" | "jre";
|
||||
}
|
||||
|
||||
/** Narrow synchronous seam used by provider discovery without launching Ghidra. */
|
||||
@@ -77,8 +109,7 @@ interface GhidraInstallationCoordinates {
|
||||
readonly installDir: string | null;
|
||||
readonly applicationPropertiesPath: string | null;
|
||||
readonly analyzeHeadlessPath: string | null;
|
||||
readonly propertiesAvailable: boolean;
|
||||
readonly providerVersion: string | null;
|
||||
readonly properties: Readonly<{ providerVersion: string | null }> | undefined;
|
||||
readonly javaCommand: string;
|
||||
readonly java: GhidraJavaObservation | undefined;
|
||||
}
|
||||
@@ -106,21 +137,56 @@ export const inspectGhidraInstallation = (
|
||||
javaHome: options.javaHome,
|
||||
host,
|
||||
});
|
||||
const failed = checks.find(({ ok }) => !ok);
|
||||
return {
|
||||
available: failed === undefined,
|
||||
const failed = checks.find(
|
||||
(check): check is Extract<GhidraInstallationCheck, { status: "failed" }> =>
|
||||
check.status === "failed",
|
||||
);
|
||||
const observation = {
|
||||
platform,
|
||||
architecture,
|
||||
applicationPropertiesPath: coordinates.applicationPropertiesPath,
|
||||
javaCommand: coordinates.javaCommand,
|
||||
checks,
|
||||
};
|
||||
if (failed !== undefined)
|
||||
return {
|
||||
status: "unavailable",
|
||||
...observation,
|
||||
installDir: coordinates.installDir,
|
||||
analyzeHeadlessPath: coordinates.analyzeHeadlessPath,
|
||||
providerVersion: coordinates.properties?.providerVersion ?? null,
|
||||
javaHome: coordinates.java?.home ?? options.javaHome ?? null,
|
||||
javaVersion: coordinates.java?.version ?? null,
|
||||
rejection: { code: failed.code, reason: failed.remediation },
|
||||
};
|
||||
return availableInstallation(coordinates, observation);
|
||||
};
|
||||
|
||||
const availableInstallation = (
|
||||
coordinates: GhidraInstallationCoordinates,
|
||||
observation: GhidraInstallationObservation,
|
||||
): AvailableGhidraInstallation => {
|
||||
const providerVersion = coordinates.properties?.providerVersion;
|
||||
if (
|
||||
coordinates.installDir === null ||
|
||||
coordinates.applicationPropertiesPath === null ||
|
||||
coordinates.analyzeHeadlessPath === null ||
|
||||
providerVersion === null ||
|
||||
providerVersion === undefined ||
|
||||
coordinates.java === undefined
|
||||
)
|
||||
throw new TypeError(
|
||||
"Passing Ghidra installation checks produced incomplete coordinates",
|
||||
);
|
||||
return {
|
||||
status: "available",
|
||||
...observation,
|
||||
installDir: coordinates.installDir,
|
||||
analyzeHeadlessPath: coordinates.analyzeHeadlessPath,
|
||||
applicationPropertiesPath: coordinates.applicationPropertiesPath,
|
||||
providerVersion: coordinates.providerVersion,
|
||||
javaCommand: coordinates.javaCommand,
|
||||
javaHome: coordinates.java?.home ?? options.javaHome ?? null,
|
||||
javaVersion: coordinates.java?.version ?? null,
|
||||
checks,
|
||||
rejectionCode: failed?.code ?? null,
|
||||
reason: failed?.remediation ?? null,
|
||||
providerVersion,
|
||||
javaHome: coordinates.java.home,
|
||||
javaVersion: coordinates.java.version,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -161,11 +227,10 @@ const installationCoordinates = (
|
||||
installDir,
|
||||
applicationPropertiesPath,
|
||||
analyzeHeadlessPath,
|
||||
propertiesAvailable: properties !== undefined,
|
||||
providerVersion:
|
||||
properties:
|
||||
properties === undefined
|
||||
? null
|
||||
: propertyValue(properties, "application.version"),
|
||||
? undefined
|
||||
: { providerVersion: propertyValue(properties, "application.version") },
|
||||
javaCommand,
|
||||
java: host.probeJava(
|
||||
javaCommand,
|
||||
@@ -183,7 +248,7 @@ const installationChecks = ({
|
||||
}: GhidraInstallationCheckContext): readonly GhidraInstallationCheck[] => [
|
||||
installationCheck({
|
||||
name: "configuration",
|
||||
ok: coordinates.installDir !== null,
|
||||
passed: coordinates.installDir !== null,
|
||||
code: "not_configured",
|
||||
detail: coordinates.installDir ?? "GHIDRA_INSTALL_DIR is not set",
|
||||
remediation:
|
||||
@@ -191,7 +256,7 @@ const installationChecks = ({
|
||||
}),
|
||||
installationCheck({
|
||||
name: "platform",
|
||||
ok: platform === "linux" || platform === "win32",
|
||||
passed: platform === "linux" || platform === "win32",
|
||||
code: "unsupported_host",
|
||||
detail: platform,
|
||||
remediation:
|
||||
@@ -199,7 +264,7 @@ const installationChecks = ({
|
||||
}),
|
||||
installationCheck({
|
||||
name: "architecture",
|
||||
ok: architecture === "x64",
|
||||
passed: architecture === "x64",
|
||||
code: "unsupported_host",
|
||||
detail: architecture,
|
||||
remediation:
|
||||
@@ -207,7 +272,7 @@ const installationChecks = ({
|
||||
}),
|
||||
installationCheck({
|
||||
name: "installation",
|
||||
ok: coordinates.propertiesAvailable,
|
||||
passed: coordinates.properties !== undefined,
|
||||
code: "executable_missing",
|
||||
detail:
|
||||
coordinates.applicationPropertiesPath ??
|
||||
@@ -217,17 +282,19 @@ const installationChecks = ({
|
||||
}),
|
||||
installationCheck({
|
||||
name: "version",
|
||||
ok: coordinates.providerVersion === SUPPORTED_GHIDRA_VERSION,
|
||||
passed:
|
||||
coordinates.properties?.providerVersion === SUPPORTED_GHIDRA_VERSION,
|
||||
code:
|
||||
coordinates.providerVersion === null
|
||||
coordinates.properties?.providerVersion === null ||
|
||||
coordinates.properties?.providerVersion === undefined
|
||||
? "version_unresolved"
|
||||
: "unsupported_version",
|
||||
detail: coordinates.providerVersion ?? "unknown",
|
||||
detail: coordinates.properties?.providerVersion ?? "unknown",
|
||||
remediation: `Install Ghidra ${SUPPORTED_GHIDRA_VERSION}, or update REA for a different Ghidra build.`,
|
||||
}),
|
||||
installationCheck({
|
||||
name: "headless",
|
||||
ok:
|
||||
passed:
|
||||
coordinates.analyzeHeadlessPath !== null &&
|
||||
host.executable(coordinates.analyzeHeadlessPath),
|
||||
code: "executable_missing",
|
||||
@@ -253,8 +320,8 @@ export const ghidraInstallationDiagnostics = (
|
||||
architecture: inspection.architecture,
|
||||
checks: inspection.checks.map((check) => ({
|
||||
name: check.name,
|
||||
ok: check.ok,
|
||||
code: check.code,
|
||||
ok: check.status === "passed",
|
||||
code: check.status === "failed" ? check.code : null,
|
||||
detail: check.detail,
|
||||
})),
|
||||
});
|
||||
@@ -284,18 +351,26 @@ export const ghidraJavaEnvironment = (
|
||||
};
|
||||
};
|
||||
|
||||
const installationCheck = (
|
||||
options: Omit<GhidraInstallationCheck, "code" | "remediation"> & {
|
||||
readonly code: ProviderRejectionCode;
|
||||
readonly remediation: string;
|
||||
},
|
||||
): GhidraInstallationCheck => ({
|
||||
name: options.name,
|
||||
ok: options.ok,
|
||||
code: options.ok ? null : options.code,
|
||||
detail: options.detail,
|
||||
remediation: options.ok ? null : options.remediation,
|
||||
});
|
||||
const installationCheck = (options: {
|
||||
readonly name: GhidraInstallationCheckName;
|
||||
readonly passed: boolean;
|
||||
readonly detail: string;
|
||||
readonly code: ProviderRejectionCode;
|
||||
readonly remediation: string;
|
||||
}): GhidraInstallationCheck =>
|
||||
options.passed
|
||||
? {
|
||||
status: "passed",
|
||||
name: options.name,
|
||||
detail: options.detail,
|
||||
}
|
||||
: {
|
||||
status: "failed",
|
||||
name: options.name,
|
||||
code: options.code,
|
||||
detail: options.detail,
|
||||
remediation: options.remediation,
|
||||
};
|
||||
|
||||
const javaCheck = (
|
||||
observation: GhidraJavaObservation | undefined,
|
||||
@@ -306,14 +381,14 @@ const javaCheck = (
|
||||
observation !== undefined &&
|
||||
observation.major === SUPPORTED_GHIDRA_JAVA_MAJOR &&
|
||||
observation.bits === 64 &&
|
||||
observation.jdk;
|
||||
observation.runtime === "jdk";
|
||||
const detail =
|
||||
observation === undefined
|
||||
? command
|
||||
: `${observation.version}; ${String(observation.bits)}-bit; ${observation.jdk ? "JDK" : "runtime only"}; ${observation.home}`;
|
||||
: `${observation.version}; ${String(observation.bits)}-bit; ${observation.runtime === "jdk" ? "JDK" : "runtime only"}; ${observation.home}`;
|
||||
return installationCheck({
|
||||
name: "java",
|
||||
ok: supported,
|
||||
passed: supported,
|
||||
code: observation === undefined ? "runtime_missing" : "unsupported_version",
|
||||
detail,
|
||||
remediation:
|
||||
@@ -375,13 +450,15 @@ const systemGhidraInstallationHost = (): GhidraInstallationHost => ({
|
||||
major: javaMajor(version),
|
||||
home,
|
||||
bits,
|
||||
jdk: executablePath(
|
||||
runtime: executablePath(
|
||||
(process.platform === "win32" ? win32 : posix).join(
|
||||
home,
|
||||
"bin",
|
||||
process.platform === "win32" ? "javac.exe" : "javac",
|
||||
),
|
||||
),
|
||||
)
|
||||
? "jdk"
|
||||
: "jre",
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { parseConfig } from "../config.js";
|
||||
import { silentLogger } from "../logger.js";
|
||||
import { GHIDRA_FUNCTION_OPERATIONS } from "./GhidraFunctionValues.js";
|
||||
import { GHIDRA_INVENTORY_OPERATIONS } from "./GhidraInventoryValues.js";
|
||||
import { GhidraProvider } from "./GhidraProvider.js";
|
||||
|
||||
describe("Ghidra provider capabilities", () => {
|
||||
it("publishes only admitted immutable read-only operations", () => {
|
||||
const config = parseConfig({});
|
||||
expect(config.ok).toBe(true);
|
||||
if (!config.ok) return;
|
||||
const provider = new GhidraProvider(config.value, silentLogger, {
|
||||
readText: () => undefined,
|
||||
executable: () => false,
|
||||
probeJava: () => undefined,
|
||||
});
|
||||
const capabilities = provider.capabilities();
|
||||
expect(capabilities.map(({ operation }) => operation).sort()).toEqual(
|
||||
[...GHIDRA_INVENTORY_OPERATIONS, ...GHIDRA_FUNCTION_OPERATIONS].sort(),
|
||||
);
|
||||
expect(Object.isFrozen(capabilities)).toBe(true);
|
||||
for (const descriptor of capabilities) {
|
||||
expect(descriptor).toMatchObject({
|
||||
available: true,
|
||||
reason: null,
|
||||
effects: {
|
||||
mutatesArtifact: false,
|
||||
mayShowUi: false,
|
||||
mayAccessNetwork: false,
|
||||
changesPermissions: false,
|
||||
requiresRoot: false,
|
||||
},
|
||||
});
|
||||
expect(Object.isFrozen(descriptor)).toBe(true);
|
||||
expect(Object.isFrozen(descriptor.effects)).toBe(true);
|
||||
expect(Object.isFrozen(descriptor.limits)).toBe(true);
|
||||
expect(Object.isFrozen(descriptor.limitations)).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -104,7 +104,7 @@ export class GhidraProvider implements AnalysisProviderCandidate {
|
||||
const installation = this.#inspectInstallation();
|
||||
const diagnostics = ghidraInstallationDiagnostics(installation);
|
||||
if (
|
||||
installation.available &&
|
||||
installation.status === "available" &&
|
||||
installation.platform === "win32" &&
|
||||
!hasWindowsNativeAuthority(installation.platform)
|
||||
)
|
||||
@@ -119,7 +119,7 @@ export class GhidraProvider implements AnalysisProviderCandidate {
|
||||
),
|
||||
},
|
||||
};
|
||||
return installation.available
|
||||
return installation.status === "available"
|
||||
? {
|
||||
status: "available",
|
||||
code: null,
|
||||
@@ -128,9 +128,8 @@ export class GhidraProvider implements AnalysisProviderCandidate {
|
||||
}
|
||||
: {
|
||||
status: "unavailable",
|
||||
code: installation.rejectionCode ?? "not_configured",
|
||||
reason:
|
||||
installation.reason ?? "Ghidra installation is not available.",
|
||||
code: installation.rejection.code,
|
||||
reason: installation.rejection.reason,
|
||||
diagnostics,
|
||||
};
|
||||
}
|
||||
@@ -363,11 +362,7 @@ const ghidraClientPrerequisites = (
|
||||
`Ghidra cannot import ${target.kind} targets through this adapter.`,
|
||||
),
|
||||
);
|
||||
if (
|
||||
!installation.available ||
|
||||
installation.analyzeHeadlessPath === null ||
|
||||
installation.providerVersion === null
|
||||
)
|
||||
if (installation.status === "unavailable")
|
||||
return err(
|
||||
new ProviderAdapterError("ghidra", "health", {
|
||||
diagnostics: ghidraInstallationDiagnostics(installation),
|
||||
|
||||
Reference in New Issue
Block a user