Implement configuration, runtime, frontend, and task governance closure

This commit is contained in:
2026-08-21 16:51:42 +08:00
parent b1b5a3cc8a
commit 63c0408ce7
92 changed files with 343619 additions and 172 deletions

View File

@@ -0,0 +1,108 @@
#!/usr/bin/env python3
"""Generate a deterministic project task graph and external-blocker readiness report."""
from __future__ import annotations
import argparse
import hashlib
import json
from pathlib import Path
from typing import Any
CONTEXT = Path("context-lock.json")
GATE = Path("coverage/release-candidate-gate.report.json")
AUDIT = Path("coverage/post-release-audit.report.json")
OWNER = Path("coverage/owner-review-gate-refresh.report.json")
TASK_MAP = Path("docs/linuxcnc-web-wasm-task-map.md")
OUTPUT = Path("coverage/project-task-readiness.report.json")
TASK_REPORTS = (
("M3-CFG-01", "coverage/configuration-startup-closure.report.json"),
("M3-RT-02", "coverage/hal-component-manifest.report.json"),
("M3-RT-03", "coverage/virtual-device-fault-matrix.report.json"),
("M3-FS-01", "coverage/workspace-session-integration.report.json"),
("M3-PY-01", "coverage/python-worker-bridge.report.json"),
("FE-M1", "coverage/frontend-m1.report.json"),
("FE-M2", "coverage/frontend-m2.report.json"),
("FE-M3", "coverage/frontend-m3.report.json"),
("FE-M4", "coverage/frontend-m4.report.json"),
("REG-01", "coverage/full-configuration-startup-matrix.report.json"),
("REG-03", "coverage/recovery-offline-fault-matrix.report.json"),
("REG-04", "coverage/browser-performance-matrix.report.json"),
)
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("utf-8")).hexdigest()
def file_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 generate(root: Path, output: Path = OUTPUT) -> dict[str, Any]:
root = root.resolve()
lock = json.loads((root / CONTEXT).read_text(encoding="utf-8"))
gate = json.loads((root / GATE).read_text(encoding="utf-8"))
audit = json.loads((root / AUDIT).read_text(encoding="utf-8"))
owner = json.loads((root / OWNER).read_text(encoding="utf-8"))
tasks = []
for task_id, report_path in TASK_REPORTS:
report = json.loads((root / report_path).read_text(encoding="utf-8"))
tasks.append({"id": task_id, "report": report_path, "implementation_status": report.get("implementation_status"), "report_status": report.get("status"), "context_id": report.get("context_id"), "release_action": report.get("release_action"), "task_hash": report.get("report_sha256")})
task_ids = [task["id"] for task in tasks]
blocker_ids = sorted(row.get("id") for row in gate.get("blockers", []) if isinstance(row, dict))
checks = {
"task_map_present": {"status": "verified" if (root / TASK_MAP).is_file() else "blocked"},
"implementation_tasks_unique": {"status": "verified" if len(task_ids) == len(set(task_ids)) else "blocked", "tasks": len(task_ids)},
"implementation_evidence_verified": {"status": "verified" if all(task["implementation_status"] == "verified" for task in tasks) else "blocked"},
"context_consistency": {"status": "verified" if all(task["context_id"] in {None, lock.get("context_id")} for task in tasks) and owner.get("context_id") == lock.get("context_id") else "blocked", "context_id": lock.get("context_id")},
"six_release_blockers": {"status": "verified" if len(blocker_ids) == 6 and len(audit.get("blockers", [])) == 6 else "blocked", "ids": blocker_ids},
"owner_wait_is_external": {"status": "verified" if owner.get("checks", {}).get("owner_inputs_present", {}).get("present") == 0 and owner.get("checks", {}).get("gate_refresh_allowed", {}).get("status") == "blocked" else "blocked"},
"stop_release_preserved": {"status": "verified" if gate.get("release_action") == "STOP_RELEASE" and audit.get("release_action") == "STOP_RELEASE" else "blocked", "release_action": gate.get("release_action")},
"no_self_loop": {"status": "verified", "current": "GOV-01", "next": "WAIT-OWNER-01", "automatic_retry": False},
}
ok = all(value["status"] == "verified" for value in checks.values())
report: dict[str, Any] = {
"schema": "project-task-readiness.v1",
"context_id": lock.get("context_id"),
"task_id": "GOV-01",
"status": "partial" if ok else "blocked",
"implementation_status": "verified" if ok else "blocked",
"release_status": "blocked_external_owner",
"candidate_eligible": False,
"release_action": "STOP_RELEASE",
"tasks": tasks,
"blockers": blocker_ids,
"checks": checks,
"inputs": [file_artifact(root, CONTEXT, "context_lock"), file_artifact(root, GATE, "release_candidate_gate"), file_artifact(root, AUDIT, "post_release_audit"), file_artifact(root, OWNER, "owner_review"), file_artifact(root, TASK_MAP, "task_map")],
"next_transition": "WAIT-OWNER-01: pause until six owner decisions or a new locked context input arrives; no automatic retry",
"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", encoding="utf-8")
return report
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
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"project_task_readiness={report['status']} release={report['release_status']} auto_retry={report['checks']['no_self_loop']['automatic_retry']}")
return 0
if __name__ == "__main__":
raise SystemExit(main())