Authorize Chromium GUI visual evidence

This commit is contained in:
2026-08-23 08:03:39 +08:00
parent 06f96f85e5
commit 7b81aa9cc9
6 changed files with 110 additions and 70 deletions

View File

@@ -8,6 +8,7 @@ import json
import os
import subprocess
import tempfile
import shutil
from pathlib import Path
from typing import Any
@@ -21,11 +22,24 @@ def digest(data: bytes) -> str:
return hashlib.sha256(data).hexdigest()
def browser_version() -> str | None:
binary = shutil.which("google-chrome")
if binary is None:
return None
result = subprocess.run([binary, "--version"], cwd=ROOT, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
return result.stdout.decode("utf-8", errors="replace").strip() or None
def probe(size: str, screenshot: Path) -> dict[str, Any]:
command = ["google-chrome", "--headless=new", "--no-sandbox", "--disable-gpu", "--disable-dev-shm-usage", "--virtual-time-budget=4000", f"--window-size={size}", f"--screenshot={screenshot}", "--dump-dom", URL]
result = subprocess.run(command, cwd=ROOT, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
dom = result.stdout.decode("utf-8", errors="replace")
markers = {marker: marker in dom for marker in ("Operate", "Program", "Diagnostics", "Load case", "Run", "Pause", "Step", "Restart", "Abort", "Home", "Recover", "E-stop", "Manual jog", "Three.js / authoritative pose")}
markers = {marker: marker in dom for marker in (
"File", "Machine", "View", "Help", "Simulation case", "Load case",
"Manual Control [F3]", "MDI [F5]", "Preview", "DRO", "Run", "Pause",
"Step", "Home Axis", "Tool Touch Off", "Spindle", "Coolant",
"Active G-Codes:", "Three.js / authoritative pose",
)}
return {"command": command, "window": size, "returncode": result.returncode, "status": "verified" if result.returncode == 0 and all(markers.values()) and screenshot.is_file() and screenshot.stat().st_size > 1000 else "blocked", "dom_sha256": digest(result.stdout), "stderr_sha256": digest(result.stderr), "screenshot": {"path": str(screenshot), "bytes": screenshot.stat().st_size if screenshot.is_file() else 0, "sha256": digest(screenshot.read_bytes()) if screenshot.is_file() else None}, "markers": markers}
@@ -42,10 +56,10 @@ def generate() -> dict[str, Any]:
"status": "verified" if desktop["status"] == "verified" and mobile["status"] == "verified" else "blocked",
"implementation_status": "verified" if desktop["status"] == "verified" else "blocked",
"route": URL,
"browser": {"binary": "google-chrome", "scope": "Chromium visual smoke only", "minimum_matrix": "not established"},
"browser": {"binary": "google-chrome", "version": browser_version(), "scope": "Chromium authorized visual slice", "minimum_matrix": "not established"},
"probes": {"desktop": desktop, "mobile": mobile},
"outputs": outputs,
"checks": {"dom_controls": {"status": "verified" if desktop["status"] == "verified" else "blocked"}, "screenshot_nonempty": {"status": "verified" if all(row["bytes"] > 1000 for row in outputs) else "blocked"}, "mobile_layout": {"status": "verified" if mobile["status"] == "verified" else "blocked"}, "threejs": {"status": "verified", "evidence": "React production preview emits Three.js r185 canvas"}, "official_browser_matrix": {"status": "blocked", "reason": "locked Chromium/Firefox/Safari minimums remain TBD; this is smoke evidence only"}, "opfs_recovery": {"status": "blocked", "reason": "existing OPFS browser fault matrix remains blocked/unavailable"}},
"checks": {"dom_controls": {"status": "verified" if desktop["status"] == "verified" else "blocked"}, "screenshot_nonempty": {"status": "verified" if all(row["bytes"] > 1000 for row in outputs) else "blocked"}, "mobile_layout": {"status": "verified" if mobile["status"] == "verified" else "blocked"}, "threejs": {"status": "verified", "evidence": "React production preview emits Three.js r185 canvas"}, "chromium_authorized_slice": {"status": "verified" if desktop["status"] == "verified" and mobile["status"] == "verified" else "blocked", "authorization": "explicit_user_authorized_chromium_unblock", "browser_version": browser_version(), "scope": ["DOM", "desktop_screenshot", "mobile_screenshot", "Three.js_canvas"]}, "official_browser_matrix": {"status": "blocked", "reason": "Firefox/Safari minimums remain TBD; Chromium authorization applies only to this slice"}, "opfs_recovery": {"status": "blocked", "reason": "OPFS crash/restart matrix remains blocked/unavailable"}},
"release_action": "STOP_RELEASE",
"boundaries": ["Chromium screenshot/DOM smoke does not establish the three-browser release matrix", "visual evidence does not replace native/WASM/Worker golden parity", "OPFS/recovery blocker remains explicit"],
}