feat(native): add inspection primitives, dispatch traces and approved UI observation (#500)
* fix(hopper): normalize string-backed addresses and update verification * feat(native): add inspection primitives, dispatch traces and approved UI observation * test: prioritize real artifact E2E and captured golden regressions * fix(process): queue observed output before reactive rendering actions * test: prune redundant cases and strengthen boundary assertions * fix(cli): route native value tracing through shared workflows * test: replace synthetic success with real workflows and captured data * fix(catalog): separate portable metadata from native host availability
This commit is contained in:
@@ -1,24 +1,8 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
generateLargeFixture,
|
||||
LARGE_FIXTURE_COUNT,
|
||||
sha256,
|
||||
sourceDigest,
|
||||
} from "../../../scripts/lib/conformance-fixtures.mjs";
|
||||
import { sourceDigest } from "../../../scripts/lib/conformance-fixtures.mjs";
|
||||
|
||||
describe("source-built conformance fixtures", () => {
|
||||
it("generates deterministic large-fixture source", () => {
|
||||
const first = generateLargeFixture();
|
||||
const second = generateLargeFixture();
|
||||
|
||||
expect(first).toBe(second);
|
||||
expect(first).toContain("rea_inventory_0000");
|
||||
expect(first).toContain(
|
||||
`rea_inventory_${String(LARGE_FIXTURE_COUNT - 1).padStart(4, "0")}`,
|
||||
);
|
||||
});
|
||||
|
||||
it("hashes source manifests independently of input ordering", () => {
|
||||
const left = [
|
||||
{ path: "b.c", content: "b" },
|
||||
@@ -28,6 +12,5 @@ describe("source-built conformance fixtures", () => {
|
||||
|
||||
expect(sourceDigest(left)).toBe(sourceDigest(right));
|
||||
expect(sourceDigest(left)).toMatch(/^[0-9a-f]{64}$/u);
|
||||
expect(sha256("fixture")).not.toBe(sha256("changed"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -96,6 +96,11 @@ describe("conformance CI replay", () => {
|
||||
expect(result.passed).toBe(1);
|
||||
expect(result.failed).toBe(0);
|
||||
expect(result.errored).toBe(0);
|
||||
expect(result.drift_detected).toBe(false);
|
||||
expect(
|
||||
packageReplayResultSchema.safeParse({ ...result, drift_detected: true })
|
||||
.success,
|
||||
).toBe(false);
|
||||
expect(
|
||||
packageReplayResultSchema.safeParse({ ...result, passed: 0 }).success,
|
||||
).toBe(false);
|
||||
@@ -111,21 +116,6 @@ describe("conformance CI replay", () => {
|
||||
expect(result.passed).toBe(0);
|
||||
});
|
||||
|
||||
it("does not detect drift when expected and actual match", async () => {
|
||||
const result = await replayConformancePackage(
|
||||
validPackage,
|
||||
{},
|
||||
passingRunner,
|
||||
);
|
||||
expect(
|
||||
packageReplayResultSchema.safeParse({
|
||||
...result,
|
||||
drift_detected: true,
|
||||
}).success,
|
||||
).toBe(false);
|
||||
expect(result.drift_detected).toBe(false);
|
||||
});
|
||||
|
||||
it("retains the observed Evidence ID on the first drift", async () => {
|
||||
const expected = createEvidence(
|
||||
undefined,
|
||||
@@ -167,70 +157,82 @@ describe("conformance CI replay", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("counts all result types", async () => {
|
||||
it("counts pass, fail, error and skipped results without losing runner diagnostics", async () => {
|
||||
const cases = [
|
||||
{ id: "s1", status: "pass" },
|
||||
{ id: "s2", status: "fail" },
|
||||
{ id: "s3", status: "error" },
|
||||
{ id: "s4", status: "skipped" },
|
||||
] as const;
|
||||
const multiPackage = createConformancePackage({
|
||||
...validPackageInput,
|
||||
scenarios: [
|
||||
...validPackage.scenarios,
|
||||
{
|
||||
scenario_id: "s2",
|
||||
name: "Second scenario",
|
||||
description: "Second",
|
||||
fixture_path: "tests/conformance/c/fixture2.c",
|
||||
expected_exit_code: 1,
|
||||
expected_patterns: [],
|
||||
},
|
||||
],
|
||||
replay_plans: [
|
||||
...validPackage.replay_plans,
|
||||
{
|
||||
scenario_id: "s2",
|
||||
steps: [
|
||||
{
|
||||
step_id: "step1",
|
||||
action: "run",
|
||||
arguments: [],
|
||||
timeout_ms: 1000,
|
||||
},
|
||||
],
|
||||
environment: {},
|
||||
},
|
||||
],
|
||||
expected_evidence: [
|
||||
...validPackage.expected_evidence,
|
||||
{
|
||||
scenario_id: "s2",
|
||||
envelopes: [],
|
||||
bundle: null,
|
||||
required_dimensions: [],
|
||||
},
|
||||
],
|
||||
verifier_contracts: [
|
||||
...validPackage.verifier_contracts,
|
||||
{
|
||||
scenario_id: "s2",
|
||||
dimensions: [
|
||||
{ name: "exit_code", required: true, comparison: "exact" },
|
||||
],
|
||||
timing_tolerance_ms: 0,
|
||||
},
|
||||
],
|
||||
scenarios: cases.flatMap(({ id }) =>
|
||||
validPackage.scenarios.map((scenario) => ({
|
||||
...scenario,
|
||||
scenario_id: id,
|
||||
})),
|
||||
),
|
||||
replay_plans: cases.flatMap(({ id }) =>
|
||||
validPackage.replay_plans.map((plan) => ({ ...plan, scenario_id: id })),
|
||||
),
|
||||
expected_evidence: cases.flatMap(({ id }) =>
|
||||
validPackage.expected_evidence.map((evidence) => ({
|
||||
...evidence,
|
||||
scenario_id: id,
|
||||
})),
|
||||
),
|
||||
verifier_contracts: cases.flatMap(({ id }) =>
|
||||
validPackage.verifier_contracts.map((contract) => ({
|
||||
...contract,
|
||||
scenario_id: id,
|
||||
})),
|
||||
),
|
||||
});
|
||||
const result = await replayConformancePackage(
|
||||
multiPackage,
|
||||
{},
|
||||
async (scenarioId) => ({
|
||||
scenario_id: scenarioId,
|
||||
status: scenarioId === "s1" ? "pass" : "fail",
|
||||
exit_code: scenarioId === "s1" ? 0 : 1,
|
||||
async (scenarioId) => {
|
||||
const item = cases.find(({ id }) => id === scenarioId);
|
||||
if (item === undefined)
|
||||
throw new Error(`Unexpected scenario: ${scenarioId}`);
|
||||
return {
|
||||
scenario_id: scenarioId,
|
||||
status: item.status,
|
||||
exit_code:
|
||||
item.status === "pass" ? 0 : item.status === "fail" ? 1 : null,
|
||||
duration_ms: 10,
|
||||
output: "",
|
||||
error:
|
||||
item.status === "error"
|
||||
? "fixture runner failed"
|
||||
: item.status === "skipped"
|
||||
? "fixture prerequisite unavailable"
|
||||
: null,
|
||||
};
|
||||
},
|
||||
);
|
||||
expect(result).toMatchObject({
|
||||
total_scenarios: cases.length,
|
||||
passed: 1,
|
||||
failed: 1,
|
||||
errored: 1,
|
||||
skipped: 1,
|
||||
});
|
||||
expect(result.scenario_results).toEqual(
|
||||
cases.map(({ id, status }) => ({
|
||||
scenario_id: id,
|
||||
status,
|
||||
exit_code: status === "pass" ? 0 : status === "fail" ? 1 : null,
|
||||
duration_ms: 10,
|
||||
output: "",
|
||||
error: null,
|
||||
}),
|
||||
error:
|
||||
status === "error"
|
||||
? "fixture runner failed"
|
||||
: status === "skipped"
|
||||
? "fixture prerequisite unavailable"
|
||||
: null,
|
||||
})),
|
||||
);
|
||||
expect(result.total_scenarios).toBe(2);
|
||||
expect(result.passed).toBe(1);
|
||||
expect(result.failed).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -169,8 +169,7 @@ describe("conformance trust gates", () => {
|
||||
{ exit_code: 1, stdout: "hello" },
|
||||
);
|
||||
expect(result.verdict).toBe("fail");
|
||||
expect(result.first_divergence).not.toBeNull();
|
||||
expect(result.first_divergence!.dimension).toBe("exit_code");
|
||||
expect(result.first_divergence).toMatchObject({ dimension: "exit_code" });
|
||||
});
|
||||
|
||||
it("reports unknown when both dimensions are undefined", () => {
|
||||
|
||||
@@ -24,23 +24,23 @@ describe("real Windows Ghidra workflow trust boundary", () => {
|
||||
verify: {
|
||||
if: "github.ref == 'refs/heads/main'",
|
||||
environment: "real-ghidra-windows",
|
||||
"runs-on": ["self-hosted", "Windows", "x64", "ghidra-12-1-2"],
|
||||
steps: [
|
||||
{},
|
||||
{ uses: "actions/setup-node@v4" },
|
||||
{ run: "npm ci" },
|
||||
{
|
||||
"runs-on": expect.arrayContaining(["self-hosted", "Windows", "x64"]),
|
||||
steps: expect.arrayContaining([
|
||||
expect.objectContaining({ uses: "actions/setup-node@v4" }),
|
||||
expect.objectContaining({ run: "npm ci" }),
|
||||
expect.objectContaining({
|
||||
env: { REA_ANALYSIS_PROVIDER: "ghidra" },
|
||||
run: "npm run verify:ghidra:windows | Tee-Object -FilePath windows-ghidra-proof.log",
|
||||
},
|
||||
{
|
||||
}),
|
||||
expect.objectContaining({
|
||||
uses: "actions/upload-artifact@v4",
|
||||
with: { path: "windows-ghidra-proof.log" },
|
||||
},
|
||||
],
|
||||
with: expect.objectContaining({
|
||||
path: "windows-ghidra-proof.log",
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(workflow.jobs.verify.steps).toHaveLength(5);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -21,14 +21,9 @@ describe("real Hopper complete inline search", () => {
|
||||
procedures: { count: 205, calls: 1 },
|
||||
strings: { count: 205, calls: 1 },
|
||||
});
|
||||
expect(client.calls).toEqual([
|
||||
"open_binary",
|
||||
"search_procedures",
|
||||
"search_strings",
|
||||
]);
|
||||
});
|
||||
|
||||
it.each(["duplicate", "wrong-count", "missing"] as const)(
|
||||
it.each(["duplicate", "missing"] as const)(
|
||||
"rejects %s positive evidence",
|
||||
async (fault) => {
|
||||
await expect(
|
||||
@@ -46,19 +41,13 @@ describe("real Hopper complete inline search", () => {
|
||||
);
|
||||
});
|
||||
|
||||
const fixtureClient = (
|
||||
count: number,
|
||||
fault?: "duplicate" | "wrong-count" | "missing",
|
||||
) => {
|
||||
const calls: string[] = [];
|
||||
const fixtureClient = (count: number, fault?: "duplicate" | "missing") => {
|
||||
return {
|
||||
calls,
|
||||
callTool: async (request: unknown) => {
|
||||
const parsed = request as { name: string };
|
||||
calls.push(parsed.name);
|
||||
if (parsed.name === "open_binary") return { isError: false };
|
||||
const procedures = parsed.name === "search_procedures";
|
||||
const resultCount = fault === "wrong-count" ? count - 1 : count;
|
||||
const resultCount = count;
|
||||
const items = Array.from({ length: resultCount }, (_, index) => {
|
||||
const duplicateIndex = fault === "duplicate" && index === 1 ? 0 : index;
|
||||
return {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
analyzeFixtureProcedure,
|
||||
requireCurrentDocument,
|
||||
resolveFixtureProcedure,
|
||||
} from "../../../../scripts/lib/real-hopper-semantic.mjs";
|
||||
@@ -9,29 +8,6 @@ import {
|
||||
const normalize = (value: unknown): unknown => value;
|
||||
|
||||
describe("real Hopper semantic fixture resolution", () => {
|
||||
it("requests assembly when analyzing fixture procedures", async () => {
|
||||
const requests: unknown[] = [];
|
||||
const result = await analyzeFixtureProcedure(
|
||||
{
|
||||
callTool: async (request: unknown) => {
|
||||
requests.push(request);
|
||||
return { dossier: true };
|
||||
},
|
||||
},
|
||||
{},
|
||||
{ address: "0x1000", name: "rea_entry" },
|
||||
normalize,
|
||||
);
|
||||
|
||||
expect(result).toEqual({ dossier: true });
|
||||
expect(requests).toEqual([
|
||||
{
|
||||
name: "analyze_function",
|
||||
arguments: { procedure: "0x1000" },
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("binds mutations to the active document, not the first listed one", async () => {
|
||||
await expect(
|
||||
requireCurrentDocument(
|
||||
|
||||
Reference in New Issue
Block a user