Merge origin/main for artifact admission and evidence fixes

This commit is contained in:
64579525
2026-10-13 14:32:52 +08:00
188 changed files with 8882 additions and 937 deletions
+6 -2
View File
@@ -1,5 +1,6 @@
import { createHash } from "node:crypto";
import { createAnalysisExecution } from "../../../src/application/AnalysisProvider.js";
import type { EvmInterfaceExecution } from "../../../src/application/evm/EvmInterfacePort.js";
import type { EvmInterface } from "../../../src/domain/evm/evmInterface.js";
/** Source-owned transport seam, independent of real engine verification. */
@@ -27,8 +28,10 @@ export const evmInterfaceFixture = (
});
/** Bind a fixture to its explicit producing seam and carrier identity. */
export const evmInterfaceExecution = (value = evmInterfaceFixture()) =>
createAnalysisExecution(
export const evmInterfaceExecution = (
value = evmInterfaceFixture(),
): EvmInterfaceExecution => {
return createAnalysisExecution(
value,
{ id: "fixture-evm", name: "Source-owned EVM seam", version: "1" },
{
@@ -42,3 +45,4 @@ export const evmInterfaceExecution = (value = evmInterfaceFixture()) =>
locations: [{ kind: "artifact-path", path: value.artifact.path }],
},
);
};
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env python3
"""Inspect the real Node launcher stdio with the production lifetime parser."""
import importlib.util
import json
from pathlib import Path
import sys
spec = importlib.util.spec_from_file_location(
"hopper_demo_x11", Path(__file__).resolve().parents[2] / "scripts/hopper-demo-x11.py"
)
assert spec is not None and spec.loader is not None
helper = importlib.util.module_from_spec(spec)
spec.loader.exec_module(helper)
assert "--owner-stdin" in sys.argv
print(json.dumps({"owner_alive": helper.OwnerLifetime(True).alive()}))
+110
View File
@@ -0,0 +1,110 @@
#!/usr/bin/env python3
"""Exercise the production runner with real children and a simulated X11 surface."""
import argparse
import importlib.util
import json
from pathlib import Path
import signal
import subprocess
import sys
import tempfile
import time
spec = importlib.util.spec_from_file_location("hopper_demo_x11", sys.argv[1])
assert spec is not None and spec.loader is not None
helper = importlib.util.module_from_spec(spec)
spec.loader.exec_module(helper)
def child_command(receipt):
return [
sys.executable,
"-c",
"import os,pathlib,time;"
f"receipt=pathlib.Path({str(receipt)!r});"
"pending=receipt.with_suffix('.pending');"
"pending.write_text(str(os.getpid()));pending.replace(receipt);"
"time.sleep(100)",
]
if len(sys.argv) > 3:
phase, directory = sys.argv[2], Path(sys.argv[3])
def terminate_worker(*_):
raise SystemExit(143)
# Failed assertions in the parent must still unwind run_launch's finally.
signal.signal(signal.SIGTERM, terminate_worker)
class X11:
def XOpenDisplay(self, *_):
return 1
def XDefaultRootWindow(self, *_):
return 1
def XDisplayWidth(self, *_):
return 1280
def XDisplayHeight(self, *_):
return 1024
def XCloseDisplay(self, *_):
return 1
def start_xvfb(*_):
child = subprocess.Popen(
child_command(directory / "xvfb.pid"),
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
)
return child, ":123", directory / "Xauthority", helper.CapturedStderr(child.stderr)
helper.digest = lambda _: next(iter(helper.SUPPORTED_HOPPER_SHA256))
helper.start_xvfb = start_xvfb
helper.ctypes.CDLL = lambda _: X11()
helper.configure_x11 = lambda *_: None
helper.windows = lambda *_: []
socket = directory / "bridge.sock"
if phase == "ready":
socket.touch()
raise SystemExit(helper.run_launch(argparse.Namespace(
owner_stdin=True,
hopper=sys.executable,
socket=str(socket),
command=child_command(directory / "hopper.pid"),
)))
with tempfile.TemporaryDirectory(prefix="rea-owner-lifetime-") as root:
directory = Path(root)
sentinel = subprocess.Popen([sys.executable, "-c", "import time;time.sleep(100)"])
worker = subprocess.Popen(
[sys.executable, __file__, sys.argv[1], sys.argv[2], root],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
try:
deadline = time.monotonic() + 5
receipts = [directory / "hopper.pid", directory / "xvfb.pid"]
while not all(receipt.exists() for receipt in receipts):
assert worker.poll() is None, worker.communicate()
assert time.monotonic() < deadline, "owned children did not start"
time.sleep(0.01)
pids = [int(receipt.read_text()) for receipt in receipts]
assert worker.poll() is None, "live owner did not retain the helper"
assert worker.stdin is not None
worker.stdin.close()
assert worker.wait(timeout=5) == 0, worker.stderr.read()
for pid in pids:
assert not Path(f"/proc/{pid}").exists(), f"owned child {pid} survived EOF"
assert sentinel.poll() is None, "unrelated process was stopped"
print(json.dumps({"phase": sys.argv[2], "children_cleaned": True, "sentinel_alive": True}))
finally:
helper.stop_process(worker)
helper.stop_process(sentinel)
+4 -1
View File
@@ -34,7 +34,9 @@ const compileValidator = (schema: unknown): ValidateFunction<unknown> => {
};
/** Start the built production server without configuring deep binary providers. */
export async function connectLocalToolsMcp() {
export async function connectLocalToolsMcp(
environment: Readonly<Record<string, string>> = {},
) {
const transport = new StdioClientTransport({
command: process.execPath,
args: [
@@ -45,6 +47,7 @@ export async function connectLocalToolsMcp() {
PATH: process.env.PATH ?? "/usr/bin:/bin",
REA_LOG_LEVEL: "silent",
HOPPER_LAUNCHER_PATH: "/rea-unconfigured-deep-provider/hopper",
...environment,
},
stderr: "pipe",
});
+19
View File
@@ -0,0 +1,19 @@
@echo off
rem capinfos stub for Windows: emulates capinfos --version and metadata output.
if "%~1"=="--version" (
echo Capinfos ^(Wireshark^) 4.6.6-windows-stub
exit /b 0
)
if not "%~1"=="-M" exit /b 2
if not "%~2"=="--" exit /b 2
if "%~3"=="" exit /b 2
echo File name: capture.pcap
echo File type: Wireshark/tcpdump/... - pcap
echo File encapsulation: Ethernet
echo Packet size limit: file hdr: 262144 bytes
echo Number of packets: 3
echo Capture duration: 0.123 seconds
exit /b 0
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
# POSIX capinfos stub (mirrors capinfos-stub.cmd for Windows parity).
if [ "$1" = "--version" ]; then printf 'Capinfos (Wireshark) 4.6.6-posix-stub\n'; exit 0; fi
[ "$1" = "-M" ] && [ "$2" = "--" ] && [ "$#" = "3" ] || exit 2
printf '%s\n' 'File name: capture.pcap'
printf '%s\n' 'File type: Wireshark/tcpdump/... - pcap'
printf '%s\n' 'File encapsulation: Ethernet'
printf '%s\n' 'Packet size limit: file hdr: 262144 bytes'
printf '%s\n' 'Number of packets: 3'
printf '%s\n' 'Capture duration: 0.123 seconds'
exit 0
+17
View File
@@ -0,0 +1,17 @@
@echo off
rem Pcap tool stub for Windows: emulates tshark --version and field output.
rem %1 is the first argument; the capture path arrives as %2 for -r/-c.
if "%~1"=="--version" (
echo TShark ^(Wireshark^) 4.6.6-windows-stub
exit /b 0
)
if not "%~1"=="-n" exit /b 2
if not "%~2"=="-r" exit /b 2
if not "%~4"=="-T" exit /b 2
if not "%~5"=="json" exit /b 2
rem Emit the same JSON as the POSIX stub
echo [{"_source":{"layers":{"frame.number":["1"],"frame.protocols":["eth:ethertype:ip:udp:dns"],"ip.src":["192.168.1.100"],"ip.dst":["8.8.8.8"],"dns.qry.name":["api.example.com"],"dns.flags.response":["1"],"dns.a":["93.184.216.34"]}}},{"_source":{"layers":{"frame.number":["2"],"frame.protocols":["eth:ethertype:ip:tcp:tls"],"ip.src":["192.168.1.100"],"ip.dst":["93.184.216.34"],"tls.handshake.extensions_server_name":["api.example.com"]}}},{"_source":{"layers":{"frame.number":["3"],"frame.protocols":["eth:ethertype:ip:tcp:http"],"ip.src":["192.168.1.100"],"ip.dst":["93.184.216.34"],"http.request.full_uri":["http://api.example.com/v1/data"]}}}]
exit /b 0
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
# POSIX pcap tool stub (mirrors tshark-stub.cmd for Windows parity).
if [ "$1" = "--version" ]; then printf 'TShark (Wireshark) 4.6.6-posix-stub\n'; exit 0; fi
[ "$1" = "-n" ] && [ "$2" = "-r" ] && [ "$4" = "-T" ] && [ "$5" = "json" ] || exit 2
printf '%s' '[{"_source":{"layers":{"frame.number":["1"],"frame.protocols":["eth:ethertype:ip:udp:dns"],"ip.src":["192.168.1.100"],"ip.dst":["8.8.8.8"],"dns.qry.name":["api.example.com"],"dns.flags.response":["1"],"dns.a":["93.184.216.34"]}}},{"_source":{"layers":{"frame.number":["2"],"frame.protocols":["eth:ethertype:ip:tcp:tls"],"ip.src":["192.168.1.100"],"ip.dst":["93.184.216.34"],"tls.handshake.extensions_server_name":["api.example.com"]}}},{"_source":{"layers":{"frame.number":["3"],"frame.protocols":["eth:ethertype:ip:tcp:http"],"ip.src":["192.168.1.100"],"ip.dst":["93.184.216.34"],"http.request.full_uri":["http://api.example.com/v1/data"]}}}]'
exit 0
+6 -2
View File
@@ -1,5 +1,6 @@
import { createHash } from "node:crypto";
import { createAnalysisExecution } from "../../../src/application/AnalysisProvider.js";
import type { WasmArtifactExecution } from "../../../src/application/wasm/WasmArtifactPort.js";
import type { WasmArtifact } from "../../../src/domain/wasm/wasmArtifact.js";
/** Source-owned transport seam; upstream binaries are verified in a separate lane. */
export const wasmArtifactFixture = (
@@ -42,8 +43,10 @@ export const wasmArtifactFixture = (
network_fetch: "not-performed" as const,
limitations: ["Source-owned transport seam."],
});
export const wasmArtifactExecution = (value = wasmArtifactFixture()) =>
createAnalysisExecution(
export const wasmArtifactExecution = (
value = wasmArtifactFixture(),
): WasmArtifactExecution => {
return createAnalysisExecution(
value,
{ id: "fixture-wabt", name: "Source-owned WABT seam", version: "1" },
{
@@ -55,3 +58,4 @@ export const wasmArtifactExecution = (value = wasmArtifactFixture()) =>
limitations: value.limitations,
},
);
};