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:
morluto
2026-10-04 16:02:36 +08:00
committed by GitHub
parent 0356f7677f
commit 4fbc501121
205 changed files with 8136 additions and 1816 deletions
+44
View File
@@ -0,0 +1,44 @@
import { artifactInventoryResultSchema } from "../../src/domain/artifactGraph.js";
import { createEvidence, type Evidence } from "../../src/domain/evidence.js";
import { jsonValueSchema } from "../../src/domain/jsonValue.js";
/** Partition a real scan into authenticated partial observations for merge tests. */
export const fragmentInventoryEvidence = (
evidence: Evidence,
count: number,
): readonly Evidence[] => {
const inventory = artifactInventoryResultSchema.parse(
evidence.normalized_result,
);
const subject = evidence.subject;
if (subject === null)
throw new TypeError("Inventory has no artifact subject");
return Array.from({ length: count }, (_, index) =>
createEvidence(
{
path: subject.local_path,
sha256: subject.digest.sha256,
format: subject.format,
},
evidence.provider,
{
operation: "inventory_artifact",
parameters: evidence.parameters,
confidence: "derived",
authority: evidence.authority,
result: jsonValueSchema.parse({
...inventory,
nodes: inventory.nodes.filter(
(_, ordinal) => ordinal % count === index,
),
occurrences: inventory.occurrences.filter(
(_, ordinal) => ordinal % count === index,
),
edges: inventory.edges.filter(
(_, ordinal) => ordinal % count === index,
),
}),
},
),
);
};
+3
View File
@@ -193,6 +193,9 @@ const sessionInfo = ({
"resolve_containing_procedure",
"search_procedures",
"search_strings",
"inspect_native_data_type",
"inspect_native_instruction",
"resolve_native_call_targets",
"analyze_function",
"procedure_assembly",
"procedure_callees",
+68
View File
@@ -0,0 +1,68 @@
# Captured format and protocol fixtures
These are actual tool outputs, not records assembled to match the parser.
`provenance.json` records the capture host, producer versions, source digests
and immutable capture/expectation digests. Compiled binaries and catalogs are
not committed.
## Foundation archive
`keyed-archive/foundation.xml` is the XML representation of a binary archive
written by Foundation `NSKeyedArchiver`, using the source-owned Swift fixture.
`plutil` represents binary UID entries as `CF$UID` dictionaries. The captured
archive has six objects: nil, the root NSArray, one shared custom record,
its four-byte data payload and two class descriptors.
`keyed-archive/graph.json` is the reviewed complete expected graph. The source
establishes two references from the array to object 2, object 2's self-cycle,
its nil conditional reference and the payload `00 01 02 ff`. The reader reports
serialized classes as unknown and does not instantiate them. The synthetic
malformed-reference tests remain separate.
To recapture the input on an approved macOS host:
```sh
capture_root=$(mktemp -d)
xcrun swift -module-cache-path "$capture_root/modules" \
tests/conformance/native/keyed-archive.swift "$capture_root/model.plist"
plutil -convert xml1 -o tests/fixtures/golden/keyed-archive/foundation.xml \
"$capture_root/model.plist"
rm -rf "$capture_root"
```
Review expected graph changes against the source and XML before updating the
expectation or provenance. Tests never rewrite the golden.
## Asset catalog
`assetutil.json` is the unmodified output of `/usr/bin/assetutil --info` for an
actual `actool` catalog. The source colorset defines `FixtureColor` with sRGB
components `[0.125, 0.5, 0.875, 1]`. Preserve private fields and producer metadata
in this fixed input, including its original timestamp; the test checks that the
projection does not discard them.
```sh
capture_root=$(mktemp -d)
xcrun actool tests/conformance/native/Assets.xcassets \
--compile "$capture_root" --platform macosx --minimum-deployment-target 12.0
/usr/bin/assetutil --info "$capture_root/Assets.car" \
> tests/fixtures/golden/assetutil.json
rm -rf "$capture_root"
```
The real E2E lane builds fresh catalogs and compares all their metadata against
the live utility output. It does not compare volatile timestamps or producer
versions against this historical capture.
## MCP JSON-RPC request
`mcp-initialize.json` captures the `initialize` request emitted by the pinned
`@modelcontextprotocol/client` 2.0.0 SDK on 2026-10-04. The client connected to
the actual `scripts/rea.mjs mcp` subprocess and completed `listTools` (122 tools).
The recorder intercepted `transport.send`, serialized the message, and delegated
the unchanged message to the real SDK transport. The committed JSON is formatted
for review; whitespace is not a wire identity claim. No provider was launched.
The decoder expectation separately specifies every field path, JSON value and
observed-versus-inferred status. It is a captured decoder regression, not proof
of a live protocol-capture product workflow.
+34
View File
@@ -0,0 +1,34 @@
[
{
"AssetStorageVersion": "Xcode 26.5 (17F42) via AssetCatalogAgent-AssetRuntime",
"Authoring Tool": "@(#)PROGRAM:CoreThemeDefinition PROJECT:CoreThemeDefinition-653.4 [LAR] [IIO-2784.5.4][LAR] AppleJPEG[1][32] CMPhoto[1][174]]",
"CoreUIVersion": 975,
"DumpToolVersion": 973.1,
"Key Format": [
"kCRThemeAppearanceName",
"kCRThemeLocalizationName",
"kCRThemeElementName",
"kCRThemePartName",
"kCRThemeSizeName",
"kCRThemeIdentifierName",
"kCRThemeLayerName",
"kCRThemeScaleName"
],
"MainVersion": "@(#)PROGRAM:CoreUI PROJECT:CoreUI-975 [LAR]",
"Platform": "macosx",
"PlatformVersion": "12.0",
"SchemaVersion": 2,
"StorageVersion": 17,
"Timestamp": 1791093487
},
{
"AssetType": "Color",
"Color components": [0.125, 0.5, 0.875, 1],
"Colorspace": "srgb",
"Name": "FixtureColor",
"NameIdentifier": 14784,
"Scale": 1,
"SHA1Digest": "267FA6EDABB4F306584AFF0827A9A614B416CA3AC93B262160080910B446C2BA",
"SizeOnDisk": 260
}
]
+83
View File
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>$archiver</key>
<string>NSKeyedArchiver</string>
<key>$objects</key>
<array>
<string>$null</string>
<dict>
<key>$class</key>
<dict>
<key>CF$UID</key>
<integer>5</integer>
</dict>
<key>NS.objects</key>
<array>
<dict>
<key>CF$UID</key>
<integer>2</integer>
</dict>
<dict>
<key>CF$UID</key>
<integer>2</integer>
</dict>
</array>
</dict>
<dict>
<key>$class</key>
<dict>
<key>CF$UID</key>
<integer>4</integer>
</dict>
<key>conditional</key>
<dict>
<key>CF$UID</key>
<integer>0</integer>
</dict>
<key>cycle</key>
<dict>
<key>CF$UID</key>
<integer>2</integer>
</dict>
<key>payload</key>
<dict>
<key>CF$UID</key>
<integer>3</integer>
</dict>
</dict>
<data>
AAEC/w==
</data>
<dict>
<key>$classes</key>
<array>
<string>main.ReaArchiveRecord</string>
<string>NSObject</string>
</array>
<key>$classname</key>
<string>main.ReaArchiveRecord</string>
</dict>
<dict>
<key>$classes</key>
<array>
<string>NSArray</string>
<string>NSObject</string>
</array>
<key>$classname</key>
<string>NSArray</string>
</dict>
</array>
<key>$top</key>
<dict>
<key>root</key>
<dict>
<key>CF$UID</key>
<integer>1</integer>
</dict>
</dict>
<key>$version</key>
<integer>100000</integer>
</dict>
</plist>
+176
View File
@@ -0,0 +1,176 @@
{
"archive_format": "xml-plist",
"roots": {
"root": {
"CF$UID": 1
}
},
"objects": [
{
"id": 0,
"kind": "nil",
"class_id": null,
"class_name": null,
"status": "nil",
"value": "$null"
},
{
"id": 1,
"kind": "archived-object",
"class_id": 5,
"class_name": "NSArray",
"status": "unknown-class",
"value": {
"$class": {
"CF$UID": 5
},
"NS.objects": [
{
"CF$UID": 2
},
{
"CF$UID": 2
}
]
}
},
{
"id": 2,
"kind": "archived-object",
"class_id": 4,
"class_name": "main.ReaArchiveRecord",
"status": "unknown-class",
"value": {
"$class": {
"CF$UID": 4
},
"conditional": {
"CF$UID": 0
},
"cycle": {
"CF$UID": 2
},
"payload": {
"CF$UID": 3
}
}
},
{
"id": 3,
"kind": "dictionary",
"class_id": null,
"class_name": null,
"status": "observed",
"value": {
"$plist_type": "data",
"base64": "AAEC/w=="
}
},
{
"id": 4,
"kind": "class-descriptor",
"class_id": null,
"class_name": null,
"status": "observed",
"value": {
"$classes": ["main.ReaArchiveRecord", "NSObject"],
"$classname": "main.ReaArchiveRecord"
}
},
{
"id": 5,
"kind": "class-descriptor",
"class_id": null,
"class_name": null,
"status": "observed",
"value": {
"$classes": ["NSArray", "NSObject"],
"$classname": "NSArray"
}
}
],
"references": [
{
"source": null,
"path": ["root"],
"target": 1,
"raw": {
"CF$UID": 1
},
"status": "resolved"
},
{
"source": 1,
"path": ["$class"],
"target": 5,
"raw": {
"CF$UID": 5
},
"status": "resolved"
},
{
"source": 1,
"path": ["NS.objects", 0],
"target": 2,
"raw": {
"CF$UID": 2
},
"status": "resolved"
},
{
"source": 1,
"path": ["NS.objects", 1],
"target": 2,
"raw": {
"CF$UID": 2
},
"status": "resolved"
},
{
"source": 2,
"path": ["$class"],
"target": 4,
"raw": {
"CF$UID": 4
},
"status": "resolved"
},
{
"source": 2,
"path": ["conditional"],
"target": 0,
"raw": {
"CF$UID": 0
},
"status": "nil"
},
{
"source": 2,
"path": ["cycle"],
"target": 2,
"raw": {
"CF$UID": 2
},
"status": "resolved"
},
{
"source": 2,
"path": ["payload"],
"target": 3,
"raw": {
"CF$UID": 3
},
"status": "resolved"
}
],
"total_objects": 6,
"total_references": 8,
"offset": 0,
"next_offset": null,
"truncated": false,
"limitations": [
"Archive classes are never instantiated. Class names and serialized fields are observed; class-specific semantics are unknown.",
"Conditional references serialized as UID 0 cannot be distinguished from ordinary nil references. Missing fields remain absent in the raw serialized value.",
"Root selection selects the named $top entry; object pagination retains original indices and does not recursively expand references."
]
}
+10
View File
@@ -0,0 +1,10 @@
{
"method": "initialize",
"params": {
"protocolVersion": "2025-11-25",
"capabilities": {},
"clientInfo": { "name": "rea-protocol-golden", "version": "1" }
},
"jsonrpc": "2.0",
"id": 0
}
+23
View File
@@ -0,0 +1,23 @@
{
"captured_on": "2026-10-04",
"host": {
"platform": "macOS",
"version": "26.3",
"architecture": "arm64"
},
"producer": {
"xcode": "26.5 (17F42)",
"swift": "6.3.2 (swiftlang-6.3.2.1.108 clang-2100.1.1.101)",
"assetutil_dump_tool_version": 973.1,
"mcp_client": "@modelcontextprotocol/client 2.0.0"
},
"sha256": {
"tests/conformance/native/keyed-archive.swift": "21e315f01bc53c60e05f5c64c2a832afd8dbabe2369f652b96083290ca71df78",
"tests/conformance/native/Assets.xcassets/Contents.json": "67328f1f20917d61b0904d1eeadd3a9af5ebdfeb20bdd8c6f585f97f7192d873",
"tests/conformance/native/Assets.xcassets/FixtureColor.colorset/Contents.json": "26c6400ce2082ddc155175e80130daddded1a863bd68fe441bee413cc2786731",
"tests/fixtures/golden/keyed-archive/foundation.xml": "93c2bf33ad960be6fba6d45c28462c4bda73ff371fe16725d087087f044479ec",
"tests/fixtures/golden/keyed-archive/graph.json": "eaadd9fca83052e81abd0dac797d2423b0bb750bea386f790586273eb3a3172e",
"tests/fixtures/golden/assetutil.json": "ff50e24963447584e3398dddf4b0426274ffd2ea2d3ae6fac8295f449f91feb3",
"tests/fixtures/golden/mcp-initialize.json": "8f590db5143106aa43dfa96123178484d98268874eff7fabbd708c240c5975bc"
}
}
+17
View File
@@ -41,6 +41,21 @@ class FakeDocumentProvider:
return cls.current
class FakeStringSegment:
def getStringsList(self):
return [("fixture string", FakeStringAddress())]
class FakeStringAddress:
def __str__(self):
return "0x401234"
class FakeStringsDocument:
def getSegmentsList(self):
return [FakeStringSegment()]
def load_bridge(path):
namespace = {
"__file__": path,
@@ -66,6 +81,7 @@ def main():
bridge["REA_OWNS_PROCESS_LIFETIME"] = False
bridge["_configure_hopper_api"](FakeDocumentProvider)
bridge["_bind_session_document"]()
strings = bridge["_strings"](FakeStringsDocument())
current = bridge["_dispatch"]("current_document", {})
current_address = bridge["_dispatch"]("current_address", {})
selected = bridge["_session_document"]() is FakeDocumentProvider.current
@@ -115,6 +131,7 @@ def main():
"imported_without_hopper": unavailable,
"current_document": current,
"current_address": current_address,
"strings": strings,
"session_document_reused": selected,
"shared_document_shutdown": retained,
"analysis_guard": analysis_guard,