mirror of
https://github.com/morluto/rea
synced 2026-10-27 14:42:18 -04:00
9c25dc4ed2
* fix(comparisons)!: preserve unknowns across partial observations Share absence and digest semantics, keep unobserved managed bodies unknown, and match unique managed type/name/signatures before structural fallback. BREAKING CHANGE: Managed comparison metadata adds exact-signature matching and its count, and name_matching now reports exact-signature-fallback. * fix(javascript): preserve projected result binding semantics Share syntax-aware property reads and assigned-result resolution. Retain destructuring paths and downgrade downstream whole-result relationships instead of resolving nested or wrapped calls as aliases. * fix(native)!: admit complete parser values and preserve typed failures Decode Mach headers by named columns, validate complete slice keys and lipo alignment, and preserve codesign runtime flags and tagged parser errors. Rename the Ghidra test dossier fixture and connect fake-backed suites to real verification lanes. BREAKING CHANGE: Native load-command results no longer contain the unused, always-null file_offset field. * fix(process): preserve host identity and actionable boundary failures Thread selected platform and environment through process and Doctor seams, stamp observed producer identity in Evidence, and retain PTY, filesystem, lease and lazy-provider failure causes. Drain cancelled lazy loads and omit exited descendants from verified lineage. * fix(browser): preserve cleanup and document-transition evidence Make V8 and Playwright teardown cancellation-aware, expose primary failures alongside incomplete cleanup, share frame-tree and navigation rules, and clear stale WebMCP registrations without pruning unrelated child frames. * fix(adapters): align managed targets and typed CLI outcomes Inspect managed PE/CLI targets independently of native provider selection, reuse successful managed selections, and keep evidence bound to the actual inspected target. Classify canonical CLI error envelopes and exhaustive setup/update/uninstall outcomes, audit registered CLI coverage, and assert platform-specific runtime results. * docs: refresh boundary contracts and shipped roadmap behavior
170 lines
5.7 KiB
TypeScript
170 lines
5.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { functionDossierSchema } from "../domain/hopperValues.js";
|
|
import { ghidraFunctionDossier } from "../domain/ghidraValues.fixture.js";
|
|
import { nativeApiBoundarySchema } from "../domain/nativeApiBoundary.js";
|
|
import { projectNativeApiInspection } from "./NativeApiInspection.js";
|
|
|
|
describe("native API switch uncertainty", () => {
|
|
it("reports an unevidenced default path independently of known numeric cases", () => {
|
|
const dossier = functionDossierSchema.parse(ghidraFunctionDossier());
|
|
const boundary = dossier.native_api;
|
|
if (boundary?.available !== true)
|
|
throw new TypeError("Ghidra native API fixture is unavailable");
|
|
const table = boundary.jump_tables[0];
|
|
if (table === undefined)
|
|
throw new TypeError("Ghidra jump-table fixture is unavailable");
|
|
const incomplete = functionDossierSchema.parse({
|
|
...dossier,
|
|
native_api: {
|
|
...boundary,
|
|
jump_tables: [{ ...table, default_targets: [] }],
|
|
},
|
|
});
|
|
expect(projectNativeApiInspection(incomplete).residual_unknowns).toContain(
|
|
"Which default or out-of-range path, if any, belongs to the dispatch at 0x401010?",
|
|
);
|
|
});
|
|
|
|
it("does not report evidenced defaults as unknown cases and retains genuinely unresolved mappings", () => {
|
|
const dossier = functionDossierSchema.parse(ghidraFunctionDossier());
|
|
const boundary = dossier.native_api;
|
|
if (boundary?.available !== true)
|
|
throw new TypeError("Ghidra native API fixture is unavailable");
|
|
const table = boundary.jump_tables[0];
|
|
const mapping = table?.mappings[0];
|
|
if (table === undefined || mapping === undefined)
|
|
throw new TypeError("Ghidra jump-table fixture is unavailable");
|
|
const defaultTarget = {
|
|
target_address: mapping.target_address,
|
|
confidence: "high",
|
|
evidence: mapping.evidence,
|
|
};
|
|
const complete = functionDossierSchema.parse({
|
|
...dossier,
|
|
native_api: {
|
|
...boundary,
|
|
jump_tables: [{ ...table, default_targets: [defaultTarget] }],
|
|
},
|
|
});
|
|
expect(projectNativeApiInspection(complete).residual_unknowns).toEqual([]);
|
|
const unresolved = functionDossierSchema.parse({
|
|
...complete,
|
|
native_api: {
|
|
...boundary,
|
|
jump_tables: [
|
|
{
|
|
...table,
|
|
default_targets: [defaultTarget],
|
|
mappings: [
|
|
mapping,
|
|
{ ...mapping, case_value: null, target_address: "0x401030" },
|
|
],
|
|
},
|
|
],
|
|
},
|
|
});
|
|
expect(projectNativeApiInspection(unresolved).residual_unknowns).toContain(
|
|
"Which source-level case values correspond to every target dispatched at 0x401010?",
|
|
);
|
|
});
|
|
});
|
|
|
|
describe("native API inspection", () => {
|
|
it("preserves structured type and jump-table boundary evidence", () => {
|
|
const dossier = functionDossierSchema.parse(ghidraFunctionDossier());
|
|
|
|
expect(projectNativeApiInspection(dossier)).toMatchObject({
|
|
procedure: { address: "0x401000", name: "fixture_main" },
|
|
boundary: {
|
|
available: true,
|
|
return_type: { data_type: "int", confidence: "medium" },
|
|
jump_tables: [
|
|
{
|
|
dispatch_address: "0x401010",
|
|
data_sources: [{ address: "0x403000" }],
|
|
mappings: [
|
|
{
|
|
target_address: "0x401020",
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
unsupported_branches: [],
|
|
residual_unknowns: [],
|
|
});
|
|
});
|
|
|
|
it("preserves unsupported provider branches as residual unknowns", () => {
|
|
const value = ghidraFunctionDossier();
|
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
throw new TypeError("Ghidra dossier fixture is invalid");
|
|
const dossier = functionDossierSchema.parse(
|
|
Object.fromEntries(
|
|
Object.entries(value).filter(([key]) => key !== "native_api"),
|
|
),
|
|
);
|
|
|
|
expect(projectNativeApiInspection(dossier)).toMatchObject({
|
|
boundary: { available: false },
|
|
unsupported_branches: [
|
|
"structured-boundary-types",
|
|
"jump-table-data-mapping",
|
|
],
|
|
residual_unknowns: [
|
|
expect.stringContaining("boundary types"),
|
|
expect.stringContaining("jump table"),
|
|
],
|
|
});
|
|
});
|
|
|
|
it("reports missing jump-table targets as an explicit unknown", () => {
|
|
const value = ghidraFunctionDossier();
|
|
const dossier = functionDossierSchema.parse(value);
|
|
const boundary = dossier.native_api;
|
|
if (boundary?.available !== true)
|
|
throw new TypeError("Ghidra native API fixture is unavailable");
|
|
const table = boundary.jump_tables[0];
|
|
if (table === undefined)
|
|
throw new TypeError("Ghidra jump-table fixture is unavailable");
|
|
|
|
const incomplete = functionDossierSchema.parse({
|
|
...dossier,
|
|
native_api: {
|
|
...boundary,
|
|
jump_tables: [{ ...table, mappings: [] }],
|
|
},
|
|
});
|
|
expect(projectNativeApiInspection(incomplete).residual_unknowns).toContain(
|
|
"Which case values and targets belong to the dispatch at 0x401010?",
|
|
);
|
|
});
|
|
|
|
it("rejects boundary types placed in the wrong ABI role", () => {
|
|
const boundary = functionDossierSchema.parse(
|
|
ghidraFunctionDossier(),
|
|
).native_api;
|
|
if (boundary === null || boundary.available !== true)
|
|
throw new TypeError("Ghidra native API fixture is unavailable");
|
|
|
|
expect(
|
|
nativeApiBoundarySchema.safeParse({
|
|
...boundary,
|
|
return_type: { ...boundary.return_type, role: "parameter" },
|
|
}).success,
|
|
).toBe(false);
|
|
expect(
|
|
nativeApiBoundarySchema.safeParse({
|
|
...boundary,
|
|
parameters: [
|
|
{
|
|
...boundary.return_type,
|
|
role: "return",
|
|
},
|
|
],
|
|
}).success,
|
|
).toBe(false);
|
|
});
|
|
});
|