Implement configuration, runtime, frontend, and task governance closure
This commit is contained in:
71
scripts/generate_frontend_m3.py
Normal file
71
scripts/generate_frontend_m3.py
Normal file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate deterministic FE-M3 project/recovery workflow evidence."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
||||
CONTEXT = Path("context-lock.json")
|
||||
FE2 = Path("coverage/frontend-m2.report.json")
|
||||
SESSION = Path("coverage/workspace-session-integration.report.json")
|
||||
GATE = Path("coverage/release-candidate-gate.report.json")
|
||||
OUTPUT = Path("coverage/frontend-m3.report.json")
|
||||
FILES = (Path("web/app/project-workflow.mjs"), Path("web/app/recovery-panel.mjs"), Path("web/app/app.mjs"), Path("web/app/test_frontend_m3.mjs"))
|
||||
|
||||
|
||||
def canonical(value: Any) -> str: return json.dumps(value, ensure_ascii=False, sort_keys=True, separators=(",", ":"))
|
||||
def digest(value: Any) -> str: return hashlib.sha256(canonical(value).encode()).hexdigest()
|
||||
def artifact(root: Path, path: Path, role: str) -> dict[str, Any]:
|
||||
full = root / path
|
||||
if not full.is_file(): return {"path": path.as_posix(), "role": role, "status": "missing"}
|
||||
return {"path": path.as_posix(), "role": role, "status": "present", "bytes": full.stat().st_size, "sha256": hashlib.sha256(full.read_bytes()).hexdigest()}
|
||||
def smoke(root: Path) -> dict[str, Any]:
|
||||
result = subprocess.run(["node", "web/app/test_frontend_m3.mjs"], cwd=root, check=False, capture_output=True, text=True)
|
||||
return {"status": "passed" if result.returncode == 0 else "blocked", "exit_code": result.returncode, "stdout": result.stdout.strip(), "stdout_sha256": digest(result.stdout), "stderr_sha256": digest(result.stderr)}
|
||||
|
||||
|
||||
def generate(root: Path, output: Path = OUTPUT) -> dict[str, Any]:
|
||||
root = root.resolve()
|
||||
lock = json.loads((root / CONTEXT).read_text())
|
||||
fe2 = json.loads((root / FE2).read_text())
|
||||
session = json.loads((root / SESSION).read_text())
|
||||
gate = json.loads((root / GATE).read_text())
|
||||
outputs = [artifact(root, path, "frontend_source") for path in FILES]
|
||||
workflow = (root / FILES[0]).read_text() if (root / FILES[0]).is_file() else ""
|
||||
panel = (root / FILES[1]).read_text() if (root / FILES[1]).is_file() else ""
|
||||
run = smoke(root)
|
||||
checks = {
|
||||
"fe2_dependency": {"status": "verified" if fe2.get("implementation_status") == "verified" else "blocked"},
|
||||
"session_dependency": {"status": "verified" if session.get("implementation_status") == "verified" else "blocked"},
|
||||
"journal_package_workflow": {"status": "verified" if all(token in workflow for token in ("importFiles", "exportFiles", "createWorkspacePackage", "migrateWorkspacePackage")) else "blocked"},
|
||||
"recovery_panel": {"status": "verified" if "recoveryView" in panel and "half_commits" in panel else "blocked"},
|
||||
"source_files": {"status": "verified" if all(row["status"] == "present" for row in outputs) else "blocked"},
|
||||
"browser_smoke": {"status": "verified" if run["status"] == "passed" else "blocked", "stdout": run["stdout"]},
|
||||
"release_stop_preserved": {"status": "verified" if gate.get("release_action") == "STOP_RELEASE" and gate.get("candidate_eligible") is False else "blocked", "release_action": gate.get("release_action")},
|
||||
}
|
||||
ok = all(value["status"] == "verified" for value in checks.values())
|
||||
report: dict[str, Any] = {"schema": "frontend-m3.v1", "context_id": lock.get("context_id"), "task_id": "FE-M3", "status": "partial" if ok else "blocked", "implementation_status": "verified" if ok else "blocked", "candidate_eligible": False, "release_action": "STOP_RELEASE", "inputs": [artifact(root, CONTEXT, "context_lock"), artifact(root, FE2, "frontend_m2"), artifact(root, SESSION, "workspace_session_integration"), artifact(root, GATE, "release_candidate_gate")], "outputs": outputs, "checks": checks, "smoke": run, "next_transition": "execute FE-M4 HAL/tool/IO/3D frontend workflows", "report_sha256": None}
|
||||
report["report_sha256"] = digest({key: value for key, value in report.items() if key != "report_sha256"})
|
||||
destination = output if output.is_absolute() else root / output
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
destination.write_text(json.dumps(report, ensure_ascii=False, sort_keys=True, indent=2) + "\n")
|
||||
return report
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--repo-root", type=Path, default=Path(__file__).resolve().parents[1])
|
||||
parser.add_argument("--output", type=Path, default=OUTPUT)
|
||||
args = parser.parse_args()
|
||||
report = generate(args.repo_root.resolve(), args.output)
|
||||
print(f"frontend_m3={report['status']} smoke={report['checks']['browser_smoke']['status']}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__": raise SystemExit(main())
|
||||
Reference in New Issue
Block a user