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:
@@ -2,6 +2,16 @@
|
||||
|
||||
volatile int rea_ghidra_inventory_global = 7;
|
||||
|
||||
enum ReaFixtureState { REA_FIXTURE_IDLE = 0, REA_FIXTURE_READY = 3 };
|
||||
union ReaFixturePayload { unsigned int word; unsigned char bytes[4]; };
|
||||
struct ReaFixtureLayout {
|
||||
enum ReaFixtureState state;
|
||||
union ReaFixturePayload payload;
|
||||
struct ReaFixtureLayout *next;
|
||||
};
|
||||
volatile struct ReaFixtureLayout rea_ghidra_inventory_layout = {
|
||||
REA_FIXTURE_READY, {.word = 5}, 0};
|
||||
|
||||
__attribute__((noinline, used)) int rea_ghidra_inventory_leaf(int value) {
|
||||
puts("REA_GHIDRA_LEAF_VALUE");
|
||||
return value + rea_ghidra_inventory_global;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#if defined(__APPLE__)
|
||||
.section __TEXT,__text,regular,pure_instructions
|
||||
.globl _rea_relative_switch
|
||||
_rea_relative_switch:
|
||||
#else
|
||||
.text
|
||||
.globl rea_relative_switch
|
||||
.type rea_relative_switch,%function
|
||||
rea_relative_switch:
|
||||
#endif
|
||||
cmp w0, #3
|
||||
b.hi Ldefault
|
||||
mov w8, w0
|
||||
#if defined(__APPLE__)
|
||||
adrp x9, Ltable@PAGE
|
||||
add x9, x9, Ltable@PAGEOFF
|
||||
#else
|
||||
adrp x9, Ltable
|
||||
add x9, x9, :lo12:Ltable
|
||||
#endif
|
||||
adr x10, Lcase0
|
||||
#if REA_ENTRY_BYTES == 2
|
||||
ldrh w11, [x9, x8, lsl #1]
|
||||
#else
|
||||
ldrb w11, [x9, x8]
|
||||
#endif
|
||||
add x10, x10, x11, lsl #2
|
||||
br x10
|
||||
Lcase0:
|
||||
mov w0, #100
|
||||
ret
|
||||
#if REA_ENTRY_BYTES == 2
|
||||
.space 1100
|
||||
#endif
|
||||
Lcase1:
|
||||
mov w0, #101
|
||||
ret
|
||||
Lcase2:
|
||||
mov w0, #102
|
||||
ret
|
||||
Lcase3:
|
||||
mov w0, #103
|
||||
ret
|
||||
Ldefault:
|
||||
mov w0, #-1
|
||||
ret
|
||||
#if defined(__APPLE__)
|
||||
.section __TEXT,__const
|
||||
#else
|
||||
.section .rodata
|
||||
#endif
|
||||
.p2align 1
|
||||
Ltable:
|
||||
#if REA_ENTRY_BYTES == 2
|
||||
.short (Lcase0-Lcase0)/4, (Lcase1-Lcase0)/4, (Lcase2-Lcase0)/4, (Lcase3-Lcase0)/4
|
||||
#else
|
||||
.byte (Lcase0-Lcase0)/4, (Lcase1-Lcase0)/4, (Lcase2-Lcase0)/4, (Lcase3-Lcase0)/4
|
||||
#endif
|
||||
@@ -0,0 +1 @@
|
||||
{ "info": { "author": "xcode", "version": 1 } }
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"colors": [
|
||||
{
|
||||
"idiom": "universal",
|
||||
"color": {
|
||||
"color-space": "srgb",
|
||||
"components": {
|
||||
"red": "0.125",
|
||||
"green": "0.500",
|
||||
"blue": "0.875",
|
||||
"alpha": "1.000"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"info": { "author": "xcode", "version": 1 }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol ReaDispatchProtocol
|
||||
- (void)performAction:(id)sender;
|
||||
@optional
|
||||
- (int)optionalFixtureValue;
|
||||
@end
|
||||
|
||||
@interface ReaDispatchFixture : NSObject <ReaDispatchProtocol> {
|
||||
int state;
|
||||
}
|
||||
- (void)performAction:(id)sender;
|
||||
+ (int)fixtureVersion;
|
||||
@end
|
||||
@implementation ReaDispatchFixture
|
||||
- (void)performAction:(id)sender { state += sender == nil ? 1 : 2; }
|
||||
+ (int)fixtureVersion { return 1; }
|
||||
@end
|
||||
int main(void) { return 0; }
|
||||
@@ -0,0 +1,12 @@
|
||||
public protocol ReaWitnessFixtureProtocol { func fixtureValue() -> Int }
|
||||
public struct ReaWitnessFixture: ReaWitnessFixtureProtocol {
|
||||
public init() {}
|
||||
public func fixtureValue() -> Int { 17 }
|
||||
}
|
||||
@_cdecl("rea_witness_fixture_entry")
|
||||
public func fixtureEntry() -> Int { ReaWitnessFixture().fixtureValue() }
|
||||
|
||||
public class ReaVtableFixture {
|
||||
public init() {}
|
||||
public func fixtureValue() -> Int { 23 }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import Foundation
|
||||
|
||||
final class ReaArchiveRecord: NSObject, NSCoding {
|
||||
var link: ReaArchiveRecord?
|
||||
override init() { super.init() }
|
||||
required init?(coder: NSCoder) { super.init() }
|
||||
func encode(with coder: NSCoder) {
|
||||
coder.encode(link, forKey: "cycle")
|
||||
coder.encode(Data([0, 1, 2, 255]), forKey: "payload")
|
||||
coder.encodeConditionalObject(nil, forKey: "conditional")
|
||||
}
|
||||
}
|
||||
let record = ReaArchiveRecord()
|
||||
record.link = record
|
||||
let data = try NSKeyedArchiver.archivedData(withRootObject: [record, record] as NSArray, requiringSecureCoding: false)
|
||||
try data.write(to: URL(fileURLWithPath: CommandLine.arguments[1]))
|
||||
@@ -0,0 +1,21 @@
|
||||
import AppKit
|
||||
|
||||
let app = NSApplication.shared
|
||||
app.setActivationPolicy(.accessory)
|
||||
let window = NSWindow(contentRect: NSRect(x: 120, y: 120, width: 360, height: 180), styleMask: [.titled, .closable], backing: .buffered, defer: false)
|
||||
window.title = "REA source-owned UI verification"
|
||||
final class FixtureController: NSObject {
|
||||
@objc func increment(_ sender: NSButton) { sender.title = "REA fixture incremented" }
|
||||
}
|
||||
let controller = FixtureController()
|
||||
let button = NSButton(frame: NSRect(x: 30, y: 60, width: 280, height: 40))
|
||||
button.title = "Increment REA fixture"
|
||||
button.target = controller
|
||||
button.action = #selector(FixtureController.increment(_:))
|
||||
window.contentView?.addSubview(button)
|
||||
window.orderFront(nil)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
let record = "{\"pid\":\(ProcessInfo.processInfo.processIdentifier),\"window_id\":\(window.windowNumber)}\n"
|
||||
FileHandle.standardOutput.write(Data(record.utf8))
|
||||
}
|
||||
app.run()
|
||||
@@ -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(
|
||||
|
||||
@@ -47,25 +47,19 @@ describe("localized README product facts", () => {
|
||||
it("keeps both English CLI onboarding paths discoverable", async () => {
|
||||
const content = await readFile(resolve("README.md"), "utf8");
|
||||
expect(content).toContain("npx -y rea-agents@latest analyze");
|
||||
expect(content).toContain("npm install rea-agents` without `--global`");
|
||||
expect(content).toContain("npm install --global rea-agents");
|
||||
expect(content).toContain("rea setup");
|
||||
expect(content).toContain("--install-hopper");
|
||||
expect(content).toContain("docs/installation.md");
|
||||
expect(content).toContain("You do not need both");
|
||||
expect(content).toContain("npx --yes rea-agents@latest setup");
|
||||
});
|
||||
|
||||
it("documents explicit setup freshness and rollback", async () => {
|
||||
const content = await readFile(resolve("docs/installation.md"), "utf8");
|
||||
const prose = normalizedProse(content);
|
||||
expect(prose).toContain("explicit `@latest` request");
|
||||
expect(prose).toContain(
|
||||
"npm exec --yes --package=rea-agents@2.4.0 -- rea setup",
|
||||
);
|
||||
expect(prose).toContain(
|
||||
"pin persistent MCP registrations to the exact version",
|
||||
);
|
||||
});
|
||||
|
||||
it("documents the published MCP Registry installation path", async () => {
|
||||
|
||||
Reference in New Issue
Block a user