Implement AXIS parity UI and execution baseline

This commit is contained in:
2026-08-23 07:28:37 +08:00
parent 1325504544
commit 06f96f85e5
463 changed files with 84893 additions and 692 deletions

View File

@@ -0,0 +1,71 @@
#!/usr/bin/env python3
"""Generate deterministic S3-04 browser simulation compatibility evidence."""
from __future__ import annotations
import hashlib
import json
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
OUTPUT = ROOT / "coverage/browser-simulation-s3.report.json"
INPUTS = (
"context-lock.json",
"web/app/worker-client.mjs",
"web/app/browser-compatibility.mjs",
"web/app/test_browser_compatibility_s3.mjs",
"web/app/machine-view.mjs",
"web/worker/sim-session.mjs",
"web/worker/capabilities.mjs",
)
def digest(data: bytes) -> str:
return hashlib.sha256(data).hexdigest()
def canonical(value: object) -> bytes:
return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode("utf-8")
def run(command: list[str]) -> dict[str, object]:
result = subprocess.run(command, cwd=ROOT, text=True, capture_output=True, check=False)
sample = None
for line in reversed(result.stdout.splitlines()):
if line.lstrip().startswith("{"):
try:
sample = json.loads(line)
break
except json.JSONDecodeError:
continue
return {"command": command, "returncode": result.returncode, "status": "verified" if result.returncode == 0 else "blocked", "stdout_sha256": digest(result.stdout.encode()), "stderr_sha256": digest(result.stderr.encode()), "sample": sample}
def generate(output: Path = OUTPUT) -> dict[str, object]:
context = json.loads((ROOT / "context-lock.json").read_text(encoding="utf-8"))
compatibility = run(["node", "web/app/test_browser_compatibility_s3.mjs"])
worker_client = run(["node", "web/app/test_worker_client_runtime.mjs"])
machine = run(["node", "web/app/test_machine_view.mjs"])
report: dict[str, object] = {
"schema": "browser-simulation-s3-report.v1",
"task_id": "S3-04",
"context_id": context["context_id"],
"status": "verified" if all(item["status"] == "verified" for item in (compatibility, worker_client, machine)) else "blocked",
"compatibility": {"real_worker_client": True, "logical_tick_only": True, "default_session_id": "deterministic_instance_sequence", "snapshot_handshake": True, "cancel_and_backpressure": True},
"performance": {"sample_cycles": 8, "sample_chunks": 4, "wall_clock_simulation": False, "max_cycles": 1000000, "max_chunks": 1000000},
"visual": {"canvas": "640x320", "nonblank_test": True, "narrow_viewport_test": True},
"boundaries": ["browser engine versions remain governed by locked matrix", "Safari/Firefox scope follows existing browser matrix", "real hardware and host paths remain excluded"],
"inputs": [{"path": path, "sha256": digest((ROOT / path).read_bytes())} for path in INPUTS],
"tests": {"compatibility": compatibility, "worker_client": worker_client, "machine_view": machine},
"report_sha256": None,
}
report["report_sha256"] = digest(canonical({key: value for key, value in report.items() if key != "report_sha256"}))
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text(json.dumps(report, ensure_ascii=False, sort_keys=True, indent=2) + "\n", encoding="utf-8")
return report
if __name__ == "__main__":
report = generate()
print(f"browser_simulation_s3={report['status']}")