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,26 @@
#!/usr/bin/env python3
"""Generate deterministic browser/performance matrix evidence."""
from __future__ import annotations
import argparse, hashlib, json, subprocess
from pathlib import Path
from typing import Any
CONTEXT=Path("context-lock.json"); REG03=Path("coverage/recovery-offline-fault-matrix.report.json"); REG01=Path("coverage/full-configuration-startup-matrix.report.json"); BROWSER=Path("coverage/browser-matrix-remediation.report.json"); FE4=Path("coverage/frontend-m4.report.json"); GATE=Path("coverage/release-candidate-gate.report.json"); OUTPUT=Path("coverage/browser-performance-matrix.report.json")
def canonical(v:Any)->str:return json.dumps(v,ensure_ascii=False,sort_keys=True,separators=(",",":"))
def digest(v:Any)->str:return hashlib.sha256(canonical(v).encode()).hexdigest()
def artifact(root:Path,path:Path,role:str)->dict[str,Any]:
p=root/path
return {"path":path.as_posix(),"role":role,"status":"present","bytes":p.stat().st_size,"sha256":hashlib.sha256(p.read_bytes()).hexdigest()} if p.is_file() else {"path":path.as_posix(),"role":role,"status":"missing"}
def run(root:Path):
outs=[]
for _ in range(2):
x=subprocess.run(["node","web/app/test_browser_performance.mjs"],cwd=root,check=False,capture_output=True,text=True); lines=[l.strip() for l in x.stdout.splitlines() if l.lstrip().startswith("{")]; sample=json.loads(lines[-1]) if x.returncode==0 and lines else {}; outs.append({"status":"passed" if x.returncode==0 else "blocked","exit_code":x.returncode,"sample":sample,"stdout_sha256":digest(x.stdout),"stderr_sha256":digest(x.stderr)})
return outs
def generate(root:Path,output:Path=OUTPUT)->dict[str,Any]:
root=root.resolve(); lock=json.loads((root/CONTEXT).read_text()); reg03=json.loads((root/REG03).read_text()); reg01=json.loads((root/REG01).read_text()); browser=json.loads((root/BROWSER).read_text()); fe4=json.loads((root/FE4).read_text()); gate=json.loads((root/GATE).read_text()); runs=run(root); first,second=runs
checks={"reg01_dependency":{"status":"verified" if reg01.get("implementation_status")=="verified" else "blocked"},"reg03_dependency":{"status":"verified" if reg03.get("implementation_status")=="verified" else "blocked"},"frontend_dependency":{"status":"verified" if fe4.get("implementation_status")=="verified" else "blocked"},"chromium_environment":{"status":"verified" if browser.get("checks",{}).get("chromium_probe",{}).get("status")=="verified" else "blocked"},"firefox_not_in_scope":{"status":"verified","reason":"Firefox is excluded from the current test scope"},"safari_not_in_scope":{"status":"verified","reason":"Safari is excluded from the current test scope"},"repeat_determinism":{"status":"verified" if first==second else "blocked"},"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(v["status"]=="verified" for v in checks.values()); report={"schema":"browser-performance-matrix.v1","context_id":lock.get("context_id"),"task_id":"REG-04","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,REG01,"full_configuration_matrix"),artifact(root,REG03,"recovery_offline_fault_matrix"),artifact(root,BROWSER,"browser_matrix_remediation"),artifact(root,FE4,"frontend_m4"),artifact(root,GATE,"release_candidate_gate")],"checks":checks,"runs":runs,"environment":{"scope":["chromium"],"firefox":"out_of_scope","safari":"out_of_scope","minimums":"TBD_in_locked_matrix"},"next_transition":"execute K8-REL-17 release gate refresh after implementation evidence","report_sha256":None}; report["report_sha256"]=digest({k:v for k,v in report.items() if k!="report_sha256"}); dest=output if output.is_absolute() else root/output; dest.parent.mkdir(parents=True,exist_ok=True); dest.write_text(json.dumps(report,ensure_ascii=False,sort_keys=True,indent=2)+"\n"); return report
def main()->int:
p=argparse.ArgumentParser();p.add_argument("--repo-root",type=Path,default=Path(__file__).resolve().parents[1]);p.add_argument("--output",type=Path,default=OUTPUT);a=p.parse_args();r=generate(a.repo_root.resolve(),a.output);print(f"browser_performance_matrix={r['status']} scope=chromium");return 0
if __name__=="__main__":raise SystemExit(main())

View File

@@ -7,6 +7,7 @@ import argparse
import hashlib
import json
import re
import subprocess
from pathlib import Path
from typing import Iterable
@@ -32,6 +33,7 @@ HAL_COMMANDS = {"source": "hal_source", "loadusr": "hal_user_component"}
TOKEN_RE = re.compile(r"(?<![A-Za-z0-9_./~-])([^\s\"'=;,]+)")
EXT_RE = re.compile(r"\.(?:ini|hal|tbl|var|ngc|nc|tap|py|xml|ui|glade|tcl|clp|pref|prefs|dat|png|jpg|jpeg|gif|stl|obj)$", re.I)
_SHA_CACHE: dict[Path, str] = {}
_LOCKED_SUBMODULE_CACHE: dict[Path, set[str] | None] = {}
def sha256(path: Path) -> str:
@@ -99,6 +101,44 @@ def config_files(config_root: Path) -> list[Path]:
return sorted(path for path in config_root.rglob("*") if path.is_file())
def locked_submodule_files(repo_root: Path) -> set[str] | None:
"""Return untracked LinuxCNC paths excluded from the locked inventory.
Ignored build outputs are intentionally retained because the existing
context lock was generated from that checkout. Only explicit untracked
source/config fixtures are excluded from the locked inventory.
"""
submodule = repo_root / "linuxcnc"
key = submodule.resolve()
if key in _LOCKED_SUBMODULE_CACHE:
return _LOCKED_SUBMODULE_CACHE[key]
try:
completed = subprocess.run(
["git", "-C", str(submodule), "status", "--porcelain=v1", "--untracked-files=all"],
check=False,
capture_output=True,
text=True,
)
if completed.returncode != 0:
result = None
else:
result = {line[3:] for line in completed.stdout.splitlines() if line.startswith("?? ")}
except (OSError, UnicodeError):
result = None
_LOCKED_SUBMODULE_CACHE[key] = result
return result
def is_locked_path(repo_root: Path, path: Path, locked: set[str] | None) -> bool:
if locked is None:
return True
try:
relative = path.resolve().relative_to((repo_root / "linuxcnc").resolve()).as_posix()
except ValueError:
return False
return relative not in locked
def add_row(rows: list[dict[str, object]], repo_root: Path, config_root: Path, entrypoint: Path,
target: Path | None, raw: str, kind: str, edge_kind: str, line: int, status: str | None = None,
origin: Path | None = None) -> None:
@@ -128,6 +168,7 @@ def add_row(rows: list[dict[str, object]], repo_root: Path, config_root: Path, e
def scan_entrypoint(repo_root: Path, config_root: Path, entrypoint: Path) -> list[dict[str, object]]:
rows: list[dict[str, object]] = []
locked = locked_submodule_files(repo_root)
ini_rows = parse_ini(entrypoint)
row_numbers = {(section, key, value): index for index, (section, key, value) in enumerate(ini_rows, 1)}
for section, key, value in ini_rows:
@@ -152,7 +193,7 @@ def scan_entrypoint(repo_root: Path, config_root: Path, entrypoint: Path) -> lis
add_row(rows, repo_root, config_root, entrypoint, target, token, RESOURCE_EXTENSIONS.get(Path(token).suffix.lower(), "external"), f"ini:{section}:{key}", row_numbers[(section, key, value)], status if target is None else None)
seen_paths = {str(row["path"]) for row in rows}
for path in sorted(path for path in entrypoint.parent.rglob("*") if path.is_file() and path != entrypoint):
for path in sorted(path for path in entrypoint.parent.rglob("*") if path.is_file() and path != entrypoint and is_locked_path(repo_root, path, locked)):
path_key = rel(repo_root, path)
if path.suffix.lower() in RESOURCE_EXTENSIONS and path_key not in seen_paths:
add_row(rows, repo_root, config_root, entrypoint, path, rel(repo_root, path), RESOURCE_EXTENSIONS[path.suffix.lower()], "directory_member", 0)
@@ -187,7 +228,8 @@ def generate(repo_root: Path, output: Path, report_path: Path) -> tuple[int, str
config_root = repo_root / CONFIG_ROOT
if not config_root.is_dir():
raise FileNotFoundError(f"required config root is missing: {CONFIG_ROOT}")
entrypoints = sorted(path for path in config_root.rglob("*.ini") if path.is_file())
locked = locked_submodule_files(repo_root)
entrypoints = sorted(path for path in config_root.rglob("*.ini") if path.is_file() and is_locked_path(repo_root, path, locked))
rows: list[dict[str, object]] = []
for entrypoint in entrypoints:
rows.extend(scan_entrypoint(repo_root, config_root, entrypoint))

View File

@@ -0,0 +1,253 @@
#!/usr/bin/env python3
"""Generate deterministic configuration startup closure evidence.
The resolver intentionally has a narrow search policy. Ordinary relative
references resolve from their entrypoint directory, repository-qualified
references resolve from the repository root, and only an explicit ``LIB:``
prefix searches the locked LinuxCNC library roots. Bare basenames are never
silently replaced by a same-named candidate elsewhere in the checkout.
"""
from __future__ import annotations
import argparse
import hashlib
import json
import re
import shlex
from collections import Counter
from pathlib import Path, PurePosixPath
from typing import Any
CONTEXT = Path("context-lock.json")
RESOURCES = Path("coverage/config-resources.jsonl")
REGRESSION = Path("coverage/configuration-regression.report.json")
GRAPH = Path("coverage/kinematics-config-graph.report.json")
GATE = Path("coverage/release-candidate-gate.report.json")
OUTPUT = Path("coverage/configuration-startup-closure.report.json")
SCHEMA = "configuration-startup-closure.v1"
LIBRARY_ROOTS = ("linuxcnc/lib/hallib", "linuxcnc/lib")
HOST_PREFIXES = ("~", "$", "${")
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_digest(path: Path) -> str | None:
if not path.is_file():
return None
handle = hashlib.sha256()
with path.open("rb") as stream:
for block in iter(lambda: stream.read(1024 * 1024), b""):
handle.update(block)
return handle.hexdigest()
def artifact(root: Path, path: Path, role: str) -> dict[str, Any]:
full = root / path
sha = file_digest(full)
if sha is None:
return {"path": path.as_posix(), "role": role, "status": "missing"}
return {"path": path.as_posix(), "role": role, "status": "present", "bytes": full.stat().st_size, "sha256": sha}
def read_json(root: Path, path: Path) -> tuple[dict[str, Any], str | None]:
try:
value = json.loads((root / path).read_text(encoding="utf-8"))
if not isinstance(value, dict):
raise ValueError(f"{path} must contain an object")
return value, None
except (OSError, UnicodeError, json.JSONDecodeError, ValueError) as exc:
return {}, str(exc)
def read_jsonl(root: Path, path: Path) -> tuple[list[dict[str, Any]], str | None]:
try:
rows: list[dict[str, Any]] = []
for line_number, line in enumerate((root / path).read_text(encoding="utf-8").splitlines(), 1):
if not line.strip():
continue
value = json.loads(line)
if not isinstance(value, dict):
raise ValueError(f"{path}:{line_number} must contain an object")
rows.append(value)
return rows, None
except (OSError, UnicodeError, json.JSONDecodeError, ValueError) as exc:
return [], str(exc)
def normalize(value: str) -> tuple[str | None, str | None]:
if not isinstance(value, str) or not value:
return None, "invalid_reference"
if "\x00" in value:
return None, "invalid_reference"
parts: list[str] = []
for part in value.replace("\\", "/").split("/"):
if not part or part == ".":
continue
if part == "..":
if not parts:
return None, "path_escape"
parts.pop()
continue
parts.append(part)
return "/".join(parts), None
def first_token(raw: Any) -> tuple[str | None, list[str], str | None]:
if not isinstance(raw, str):
return None, [], "invalid_reference"
value = raw.strip().strip("\"'")
if not value:
return None, [], "empty_reference"
try:
tokens = shlex.split(value, posix=True)
except ValueError:
tokens = re.findall(r"[^\s]+", value)
if not tokens:
return None, [], "empty_reference"
return tokens[0], tokens[1:], None
def candidates(raw_value: Any, entrypoint: str) -> tuple[list[str], str, str | None, list[str]]:
value, args, error = first_token(raw_value)
if error:
return [], "blocked", error, args
assert value is not None
if value.startswith(HOST_PREFIXES):
return [], "blocked", "host_path", args
entry, error = normalize(entrypoint)
if error or entry is None:
return [], "blocked", error or "invalid_reference", args
if value.startswith("LIB:"):
name = value[4:]
if not name or name.startswith("/") or ".." in PurePosixPath(name).parts:
return [], "library", "invalid_reference", args
paths = []
for root in LIBRARY_ROOTS:
path, path_error = normalize(f"{root}/{name}")
if path_error is None and path is not None:
paths.append(path)
return paths, "library", None, args
if value.startswith("/"):
return [], "blocked", "outside_repo", args
if value.startswith("linuxcnc/"):
path, path_error = normalize(value)
return ([path] if path else []), "repo_relative", path_error, args
base = PurePosixPath(entry).parent.as_posix()
path, path_error = normalize(f"{base}/{value}")
if path_error:
return [], "relative", path_error, args
if path is not None and not (path == "linuxcnc" or path.startswith("linuxcnc/")):
return [], "relative", "outside_repo", args
return ([path] if path else []), "relative", None, args
def available_paths(root: Path) -> set[str]:
return {path.relative_to(root).as_posix() for path in root.rglob("*") if path.is_file() or path.is_dir()}
def resolve_row(row: dict[str, Any], available: set[str]) -> dict[str, Any]:
original_path = str(row.get("path", ""))
original_status = str(row.get("parse_status", ""))
raw_value = row.get("raw_value", original_path)
if original_status in {"resolved_file", "resolved_directory"} and original_path in available:
return {
"resource_source_id": row.get("resource_source_id"),
"entrypoint": row.get("entrypoint"),
"original_path": original_path,
"original_status": original_status,
"raw_value": raw_value,
"status": "resolved_existing",
"code": None,
"path": original_path,
"args": [],
"attempted_paths": [original_path],
"resolution": "indexed",
}
paths, resolution, error, args = candidates(raw_value, str(row.get("entrypoint", "")))
existing = [path for path in paths if path in available]
if error:
status = f"blocked_{error}"
return {"resource_source_id": row.get("resource_source_id"), "entrypoint": row.get("entrypoint"), "original_path": original_path, "original_status": original_status, "raw_value": raw_value, "status": status, "code": error, "path": None, "args": args, "attempted_paths": paths, "resolution": resolution}
if len(existing) > 1:
return {"resource_source_id": row.get("resource_source_id"), "entrypoint": row.get("entrypoint"), "original_path": original_path, "original_status": original_status, "raw_value": raw_value, "status": "blocked_ambiguous", "code": "ambiguous", "path": None, "args": args, "attempted_paths": paths, "resolution": resolution}
if len(existing) == 1:
return {"resource_source_id": row.get("resource_source_id"), "entrypoint": row.get("entrypoint"), "original_path": original_path, "original_status": original_status, "raw_value": raw_value, "status": f"resolved_{resolution}", "code": None, "path": existing[0], "args": args, "attempted_paths": paths, "resolution": resolution}
return {"resource_source_id": row.get("resource_source_id"), "entrypoint": row.get("entrypoint"), "original_path": original_path, "original_status": original_status, "raw_value": raw_value, "status": "blocked_missing", "code": "missing", "path": None, "args": args, "attempted_paths": paths, "resolution": resolution}
def generate(root: Path, output: Path = OUTPUT) -> dict[str, Any]:
root = root.resolve()
lock, lock_error = read_json(root, CONTEXT)
regression, regression_error = read_json(root, REGRESSION)
graph, graph_error = read_json(root, GRAPH)
gate, gate_error = read_json(root, GATE)
rows, rows_error = read_jsonl(root, RESOURCES)
errors = {path.as_posix(): error for path, error in ((CONTEXT, lock_error), (REGRESSION, regression_error), (GRAPH, graph_error), (GATE, gate_error), (RESOURCES, rows_error)) if error}
available = available_paths(root)
records = [resolve_row(row, available) for row in rows]
records.sort(key=lambda row: str(row.get("resource_source_id", "")))
occurrence_counter: Counter[str] = Counter()
for record in records:
source_id = str(record.get("resource_source_id", ""))
occurrence_counter[source_id] += 1
record["resource_record_id"] = f"{source_id}#occurrence:{occurrence_counter[source_id]}"
statuses = Counter(str(row["status"]) for row in records)
codes = Counter(str(row["code"]) for row in records if row.get("code"))
duplicate_source_ids = sorted(source_id for source_id, count in occurrence_counter.items() if count > 1)
entrypoints = sorted({str(row.get("entrypoint")) for row in records})
ids = [str(row.get("resource_source_id")) for row in records]
config_entries = regression.get("configuration_entries", []) if isinstance(regression.get("configuration_entries"), list) else []
context_id = lock.get("context_id")
stop_ok = gate.get("release_action") == "STOP_RELEASE" and gate.get("candidate_eligible") is False
checks = {
"input_integrity": {"status": "verified" if not errors and context_id else "blocked", "context_id": context_id},
"configuration_coverage": {"status": "verified" if len(config_entries) == 264 and len(entrypoints) == 233 else "blocked", "registered_entries": len(config_entries), "entrypoints": len(entrypoints)},
"resource_identity": {"status": "verified" if len({str(row.get('resource_record_id')) for row in records}) == len(records) and ids == sorted(ids) else "blocked", "rows": len(ids), "duplicate_source_ids": duplicate_source_ids, "duplicate_policy": "source_id_preserved_with_deterministic_occurrence_suffix"},
"explicit_library_policy": {"status": "verified" if all(row.get("resolution") in {"indexed", "relative", "repo_relative", "library", "blocked"} for row in records) else "blocked", "library_references": sum(1 for row in records if str(row.get("raw_value", "")).lstrip().startswith("LIB:")), "library_resolved": sum(1 for row in records if row.get("status") == "resolved_library")},
"no_basename_substitution": {"status": "verified" if all(row.get("resolution") != "basename" for row in records) else "blocked"},
"release_stop_preserved": {"status": "verified" if stop_ok else "blocked", "release_action": "STOP_RELEASE" if stop_ok else None},
}
blocked_count = sum(value for key, value in statuses.items() if key.startswith("blocked_"))
report: dict[str, Any] = {
"schema": SCHEMA,
"context_id": context_id,
"task_id": "M3-CFG-01",
"status": "verified" if not errors and blocked_count == 0 else "partial" if not errors else "blocked",
"implementation_status": "verified" if not errors else "blocked",
"candidate_eligible": False,
"release_action": "STOP_RELEASE",
"inputs": [artifact(root, CONTEXT, "context_lock"), artifact(root, RESOURCES, "config_resources"), artifact(root, REGRESSION, "configuration_regression"), artifact(root, GRAPH, "kinematics_config_graph"), artifact(root, GATE, "release_candidate_gate")],
"counts": {"resource_rows": len(records), "entrypoints": len(entrypoints), "registered_configuration_entries": len(config_entries), "resolved": len(records) - blocked_count, "blocked": blocked_count, "duplicate_source_ids": len(duplicate_source_ids), "statuses": dict(sorted(statuses.items())), "blocked_codes": dict(sorted(codes.items()))},
"checks": checks,
"resources": records,
"next_transition": "execute M3-RT-02 HAL component manifest and executable configuration graph",
"errors": errors,
"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"configuration_startup_closure={report['status']} resolved={report['counts']['resolved']} blocked={report['counts']['blocked']}")
return 0
if __name__ == "__main__":
raise SystemExit(main())

View File

@@ -0,0 +1,88 @@
#!/usr/bin/env python3
"""Generate deterministic FE-M1 frontend vertical-slice 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")
PYTHON = Path("coverage/python-worker-bridge.report.json")
SESSION = Path("coverage/workspace-session-integration.report.json")
GATE = Path("coverage/release-candidate-gate.report.json")
FILES = (Path("web/app/index.html"), Path("web/app/app.mjs"), Path("web/app/worker-client.mjs"), Path("web/app/styles.css"), Path("web/app/test_frontend_m1.mjs"))
OUTPUT = Path("coverage/frontend-m1.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 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 run_smoke(root: Path) -> dict[str, Any]:
result = subprocess.run(["node", "web/app/test_frontend_m1.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(encoding="utf-8"))
python = json.loads((root / PYTHON).read_text(encoding="utf-8"))
session = json.loads((root / SESSION).read_text(encoding="utf-8"))
gate = json.loads((root / GATE).read_text(encoding="utf-8"))
files = [artifact(root, path, "frontend_source") for path in FILES]
app_source = (root / "web/app/app.mjs").read_text(encoding="utf-8") if (root / "web/app/app.mjs").is_file() else ""
client_source = (root / "web/app/worker-client.mjs").read_text(encoding="utf-8") if (root / "web/app/worker-client.mjs").is_file() else ""
smoke = run_smoke(root)
checks = {
"source_files": {"status": "verified" if all(row["status"] == "present" for row in files) else "blocked", "files": files},
"worker_boundary": {"status": "verified" if "WorkerClient" in app_source and "postMessage" in client_source and "_sim_" not in app_source else "blocked"},
"protocol_workflow": {"status": "verified" if all(token in client_source for token in ("HELLO", "SESSION_ATTACH", "LOAD_WORKSPACE", "SIM_STEP", "SNAPSHOT_REQUEST")) else "blocked"},
"dependency_chain": {"status": "verified" if python.get("implementation_status") == "verified" and session.get("implementation_status") == "verified" else "blocked"},
"browser_smoke": {"status": "verified" if smoke["status"] == "passed" else "blocked", "stdout": smoke["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")},
}
checks_ok = all(row["status"] == "verified" for row in checks.values())
report: dict[str, Any] = {
"schema": "frontend-m1.v1",
"context_id": lock.get("context_id"),
"task_id": "FE-M1",
"status": "partial" if checks_ok else "blocked",
"implementation_status": "verified" if checks_ok else "blocked",
"candidate_eligible": False,
"release_action": "STOP_RELEASE",
"inputs": [artifact(root, CONTEXT, "context_lock"), artifact(root, PYTHON, "python_worker_bridge"), artifact(root, SESSION, "workspace_session_integration"), artifact(root, GATE, "release_candidate_gate")],
"outputs": files,
"checks": checks,
"smoke": smoke,
"next_transition": "execute FE-M2 core operation controls and state panels",
"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"frontend_m1={report['status']} smoke={report['checks']['browser_smoke']['status']}")
return 0
if __name__ == "__main__": raise SystemExit(main())

View File

@@ -0,0 +1,77 @@
#!/usr/bin/env python3
"""Generate deterministic FE-M2 controls/state-panel 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")
FE1 = Path("coverage/frontend-m1.report.json")
DEVICES = Path("coverage/virtual-device-fault-matrix.report.json")
GATE = Path("coverage/release-candidate-gate.report.json")
OUTPUT = Path("coverage/frontend-m2.report.json")
FILES = (Path("web/app/controls.mjs"), Path("web/app/state-panel.mjs"), Path("web/app/app.mjs"), Path("web/app/styles.css"), Path("web/app/test_frontend_m2.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 run(root: Path) -> dict[str, Any]:
result = subprocess.run(["node", "web/app/test_frontend_m2.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())
fe1 = json.loads((root / FE1).read_text())
devices = json.loads((root / DEVICES).read_text())
gate = json.loads((root / GATE).read_text())
outputs = [artifact(root, path, "frontend_source") for path in FILES]
app = (root / "web/app/app.mjs").read_text() if (root / "web/app/app.mjs").is_file() else ""
controls = (root / "web/app/controls.mjs").read_text() if (root / "web/app/controls.mjs").is_file() else ""
panel = (root / "web/app/state-panel.mjs").read_text() if (root / "web/app/state-panel.mjs").is_file() else ""
smoke = run(root)
actions = ("run", "pause", "resume", "abort", "home", "estop", "recover")
checks = {
"fe1_dependency": {"status": "verified" if fe1.get("implementation_status") == "verified" else "blocked"},
"operation_controls": {"status": "verified" if all(action in controls for action in actions) else "blocked", "actions": list(actions)},
"authoritative_state_panel": {"status": "verified" if "reduceWorkerState" in panel and "renderStatePanel" in panel and "onMessage" in app else "blocked"},
"device_error_visibility": {"status": "verified" if devices.get("implementation_status") == "verified" and "Error:" in app else "blocked"},
"source_files": {"status": "verified" if all(row["status"] == "present" for row in outputs) else "blocked"},
"browser_smoke": {"status": "verified" if smoke["status"] == "passed" else "blocked", "stdout": smoke["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")},
}
checks_ok = all(row["status"] == "verified" for row in checks.values())
report: dict[str, Any] = {"schema": "frontend-m2.v1", "context_id": lock.get("context_id"), "task_id": "FE-M2", "status": "partial" if checks_ok else "blocked", "implementation_status": "verified" if checks_ok else "blocked", "candidate_eligible": False, "release_action": "STOP_RELEASE", "inputs": [artifact(root, CONTEXT, "context_lock"), artifact(root, FE1, "frontend_m1"), artifact(root, DEVICES, "virtual_device_fault_matrix"), artifact(root, GATE, "release_candidate_gate")], "outputs": outputs, "checks": checks, "smoke": smoke, "next_transition": "execute FE-M3 project and recovery workflow", "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_m2={report['status']} smoke={report['checks']['browser_smoke']['status']}")
return 0
if __name__ == "__main__": raise SystemExit(main())

View 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())

View File

@@ -0,0 +1,69 @@
#!/usr/bin/env python3
"""Generate deterministic FE-M4 device/HAL/3D frontend 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")
FE3 = Path("coverage/frontend-m3.report.json")
HAL = Path("coverage/hal-component-manifest.report.json")
DEVICES = Path("coverage/virtual-device-fault-matrix.report.json")
GATE = Path("coverage/release-candidate-gate.report.json")
OUTPUT = Path("coverage/frontend-m4.report.json")
FILES = (Path("web/app/device-panel.mjs"), Path("web/app/hal-panel.mjs"), Path("web/app/machine-view.mjs"), Path("web/app/test_frontend_m4.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_m4.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())
fe3 = json.loads((root / FE3).read_text())
hal = json.loads((root / HAL).read_text())
devices = json.loads((root / DEVICES).read_text())
gate = json.loads((root / GATE).read_text())
outputs = [artifact(root, path, "frontend_source") for path in FILES]
device = (root / FILES[0]).read_text() if (root / FILES[0]).is_file() else ""
hal_source = (root / FILES[1]).read_text() if (root / FILES[1]).is_file() else ""
machine = (root / FILES[2]).read_text() if (root / FILES[2]).is_file() else ""
run = smoke(root)
checks = {
"fe3_dependency": {"status": "verified" if fe3.get("implementation_status") == "verified" else "blocked"},
"device_workflow": {"status": "verified" if all(token in device for token in ("SPINDLE_COMMAND", "TOOL_PREPARE", "PROBE_CONFIG", "IO_RECOVER")) and devices.get("implementation_status") == "verified" else "blocked"},
"hal_diagnostics": {"status": "verified" if "HAL diagnostics" in hal_source and hal.get("implementation_status") == "verified" else "blocked"},
"machine_view_boundary": {"status": "verified" if "canvas" in machine and "_sim_" not in machine and "wasm" not in machine.lower() 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-m4.v1", "context_id": lock.get("context_id"), "task_id": "FE-M4", "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, FE3, "frontend_m3"), artifact(root, HAL, "hal_component_manifest"), artifact(root, DEVICES, "virtual_device_fault_matrix"), artifact(root, GATE, "release_candidate_gate")], "outputs": outputs, "checks": checks, "smoke": run, "next_transition": "execute REG-01 full configuration startup matrix", "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_m4={report['status']} smoke={report['checks']['browser_smoke']['status']}")
return 0
if __name__ == "__main__": raise SystemExit(main())

View File

@@ -0,0 +1,103 @@
#!/usr/bin/env python3
"""Aggregate the deterministic full sim configuration startup matrix."""
from __future__ import annotations
import argparse
import hashlib
import json
from collections import Counter
from pathlib import Path
from typing import Any
CONTEXT = Path("context-lock.json")
REGRESSION = Path("coverage/configuration-regression.report.json")
STARTUP = Path("coverage/configuration-startup-closure.report.json")
HAL = Path("coverage/hal-component-manifest.report.json")
FRONTEND = Path("coverage/frontend-m4.report.json")
GATE = Path("coverage/release-candidate-gate.report.json")
OUTPUT = Path("coverage/full-configuration-startup-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()).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 generate(root: Path, output: Path = OUTPUT) -> dict[str, Any]:
root = root.resolve()
lock = json.loads((root / CONTEXT).read_text())
regression = json.loads((root / REGRESSION).read_text())
startup = json.loads((root / STARTUP).read_text())
hal = json.loads((root / HAL).read_text())
frontend = json.loads((root / FRONTEND).read_text())
gate = json.loads((root / GATE).read_text())
rows = regression.get("configuration_entries", [])
startup_rows = startup.get("resources", [])
by_entry = Counter(str(row.get("entrypoint")) for row in startup_rows if row.get("entrypoint"))
matrix = []
for row in rows:
path = str(row.get("path", ""))
blocked = row.get("startup_preflight") != "static_ready"
matrix.append({
"config_id": row.get("config_id"),
"path": path,
"module": row.get("module"),
"family": row.get("family"),
"status": "blocked" if blocked else "ready",
"startup_preflight": row.get("startup_preflight"),
"resource_status": row.get("resource_status"),
"resource_rows": by_entry.get(path, row.get("resource_rows", 0)),
"missing_resources": row.get("missing_resources", []),
"unresolved_resources": row.get("unresolved_resources", []),
"kinematics_registered": row.get("kinematics_registered"),
"source_id": row.get("config_id"),
})
matrix.sort(key=lambda item: str(item.get("config_id", "")))
statuses = Counter(item["status"] for item in matrix)
checks = {
"entry_count": {"status": "verified" if len(matrix) == 264 else "blocked", "entries": len(matrix)},
"entrypoint_count": {"status": "verified" if regression.get("counts", {}).get("config_entrypoints") == 233 else "blocked", "entrypoints": regression.get("counts", {}).get("config_entrypoints")},
"resource_closure": {"status": "verified" if startup.get("implementation_status") == "verified" and startup.get("counts", {}).get("resource_rows") == 16093 else "blocked", "resources": startup.get("counts", {}).get("resource_rows")},
"hal_dependency": {"status": "verified" if hal.get("implementation_status") == "verified" else "blocked"},
"frontend_dependency": {"status": "verified" if frontend.get("implementation_status") == "verified" else "blocked"},
"stable_identity": {"status": "verified" if len({item["config_id"] for item in matrix}) == len(matrix) else "blocked"},
"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": "full-configuration-startup-matrix.v1",
"context_id": lock.get("context_id"),
"task_id": "REG-01",
"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, REGRESSION, "configuration_regression"), artifact(root, STARTUP, "configuration_startup_closure"), artifact(root, HAL, "hal_component_manifest"), artifact(root, FRONTEND, "frontend_m4"), artifact(root, GATE, "release_candidate_gate")],
"counts": {"registered_entries": len(matrix), "entrypoints": regression.get("counts", {}).get("config_entrypoints"), "statuses": dict(sorted(statuses.items())), "resource_rows": startup.get("counts", {}).get("resource_rows"), "blocked_resource_rows": startup.get("counts", {}).get("blocked")},
"checks": checks,
"matrix": matrix,
"next_transition": "execute REG-03 recovery and offline fault matrix",
"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"full_configuration_startup_matrix={report['status']} entries={report['counts']['registered_entries']} blocked={report['counts']['statuses'].get('blocked', 0)}")
return 0
if __name__ == "__main__": raise SystemExit(main())

View File

@@ -0,0 +1,222 @@
#!/usr/bin/env python3
"""Generate a deterministic HAL component manifest and config graph report."""
from __future__ import annotations
import argparse
import hashlib
import json
import re
from collections import Counter, defaultdict
from pathlib import Path
from typing import Any
from generate_config_resources import locked_submodule_files
CONTEXT = Path("context-lock.json")
HAL_REPORT = Path("coverage/hal-runtime.report.json")
CONFIG_CLOSURE = Path("coverage/configuration-startup-closure.report.json")
RESOURCES = Path("coverage/config-resources.jsonl")
GATE = Path("coverage/release-candidate-gate.report.json")
COMPONENT_ROOT = Path("linuxcnc/src/hal/components")
OUTPUT = Path("coverage/hal-component-manifest.report.json")
SCHEMA = "hal-component-manifest.v1"
COMPONENT_RE = re.compile(r"^\s*component\s+([A-Za-z_][A-Za-z0-9_]*)\b")
PIN_RE = re.compile(r"^\s*pin\s+(in|out|io)\s+([A-Za-z_][A-Za-z0-9_]*)\s+([A-Za-z_][A-Za-z0-9_.#-]*)")
PARAM_RE = re.compile(r"^\s*param\s+(r|rw)\s+([A-Za-z_][A-Za-z0-9_]*)\s+([A-Za-z_][A-Za-z0-9_.-]*)(?:\s*=\s*([^\s]+))?")
FUNCTION_RE = re.compile(r"^\s*function\s+([^;]+);")
VARIABLE_RE = re.compile(r"^\s*variable\s+([A-Za-z_][A-Za-z0-9_]*)\s+([A-Za-z_][A-Za-z0-9_.-]*)")
OPTION_RE = re.compile(r"^\s*option\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:=\s*([^\s]+))?")
LOADRT_RE = re.compile(r"^\s*loadrt\s+([^\s]+)(?:\s+(.*))?$")
LOADUSR_RE = re.compile(r"^\s*loadusr\s+(.+)$")
ADDF_RE = re.compile(r"^\s*addf\s+([^\s]+)\s+([^\s]+)")
LINE_COMMANDS = {"loadrt", "loadusr", "addf", "net", "setp", "source", "newsig", "linksp", "linkps", "linkpp"}
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_digest(path: Path) -> str | None:
if not path.is_file():
return None
handle = hashlib.sha256()
with path.open("rb") as stream:
for block in iter(lambda: stream.read(1024 * 1024), b""):
handle.update(block)
return handle.hexdigest()
def artifact(root: Path, path: Path, role: str) -> dict[str, Any]:
full = root / path
sha = file_digest(full)
if sha is None:
return {"path": path.as_posix(), "role": role, "status": "missing"}
return {"path": path.as_posix(), "role": role, "status": "present", "bytes": full.stat().st_size, "sha256": sha}
def relative(root: Path, path: Path) -> str:
return path.resolve().relative_to(root.resolve()).as_posix()
def parse_comp(root: Path, path: Path) -> dict[str, Any]:
component = None
pins: list[dict[str, Any]] = []
params: list[dict[str, Any]] = []
functions: list[dict[str, Any]] = []
variables: list[dict[str, Any]] = []
options: list[dict[str, Any]] = []
errors: list[str] = []
try:
lines = path.read_text(encoding="utf-8", errors="strict").splitlines()
except (OSError, UnicodeError) as exc:
return {"path": relative(root, path), "source_sha256": file_digest(path), "status": "blocked", "errors": [str(exc)], "component": None, "pins": [], "params": [], "functions": [], "variables": [], "options": []}
for line_number, raw in enumerate(lines, 1):
line = raw.split("//", 1)[0].strip()
match = COMPONENT_RE.match(line)
if match:
if component is not None and component != match.group(1):
errors.append(f"duplicate_component:{line_number}")
component = match.group(1)
continue
match = PIN_RE.match(line)
if match:
pins.append({"direction": match.group(1), "type": match.group(2), "name": match.group(3), "line": line_number})
continue
match = PARAM_RE.match(line)
if match:
params.append({"mode": match.group(1), "type": match.group(2), "name": match.group(3), "default": match.group(4).rstrip(";") if match.group(4) else None, "line": line_number})
continue
match = FUNCTION_RE.match(line)
if match:
for name in match.group(1).split():
if name:
functions.append({"name": name, "line": line_number})
continue
match = VARIABLE_RE.match(line)
if match:
variables.append({"type": match.group(1), "name": match.group(2), "line": line_number})
continue
match = OPTION_RE.match(line)
if match:
options.append({"name": match.group(1), "value": match.group(2), "line": line_number})
if component is None:
errors.append("component_declaration_missing")
names = [row["name"] for row in pins] + [row["name"] for row in params] + [row["name"] for row in variables]
if len(names) != len(set(names)):
errors.append("duplicate_declared_name")
return {"path": relative(root, path), "source_sha256": file_digest(path), "status": "verified" if not errors else "blocked", "errors": errors, "component": component, "pins": pins, "params": params, "functions": functions, "variables": variables, "options": options}
def parse_hal(root: Path, path: Path, component_names: set[str], resource_source_id: str | None) -> list[dict[str, Any]]:
records: list[dict[str, Any]] = []
try:
lines = path.read_text(encoding="utf-8", errors="strict").splitlines()
except (OSError, UnicodeError) as exc:
return [{"path": relative(root, path), "line": 0, "command": "file", "status": "blocked", "code": "decode_error", "detail": str(exc), "resource_source_id": resource_source_id}]
for line_number, raw in enumerate(lines, 1):
line = raw.split("#", 1)[0].strip()
if not line:
continue
command = line.split(None, 1)[0]
if command not in LINE_COMMANDS:
continue
base = {"path": relative(root, path), "line": line_number, "command": command, "raw": line, "resource_source_id": resource_source_id}
if command == "loadrt":
match = LOADRT_RE.match(line)
module = match.group(1) if match else ""
names = re.search(r"(?:^|\s)names=([^\s]+)", match.group(2) or "" if match else "")
instances = names.group(1).split(",") if names else []
if module.startswith("[") or module not in component_names:
records.append({**base, "status": "blocked", "code": "undeclared_or_variable_component", "module": module, "instances": instances})
else:
records.append({**base, "status": "declared", "code": None, "module": module, "instances": instances})
elif command == "loadusr":
match = LOADUSR_RE.match(line)
records.append({**base, "status": "blocked", "code": "host_dynamic_loader", "program": match.group(1).split()[0] if match else ""})
elif command == "addf":
match = ADDF_RE.match(line)
records.append({**base, "status": "checked", "code": None if match else "invalid_addf", "function": match.group(1) if match else None, "thread": match.group(2) if match else None})
else:
tokens = line.split()
records.append({**base, "status": "checked", "code": None, "tokens": tokens[1:]})
return records
def generate(root: Path, output: Path = OUTPUT) -> dict[str, Any]:
root = root.resolve()
lock = json.loads((root / CONTEXT).read_text(encoding="utf-8"))
hal_runtime = json.loads((root / HAL_REPORT).read_text(encoding="utf-8"))
config_closure = json.loads((root / CONFIG_CLOSURE).read_text(encoding="utf-8"))
gate = json.loads((root / GATE).read_text(encoding="utf-8"))
resource_rows = [json.loads(line) for line in (root / RESOURCES).read_text(encoding="utf-8").splitlines() if line.strip()]
untracked = locked_submodule_files(root)
component_root = root / COMPONENT_ROOT
component_files = sorted(path for path in component_root.rglob("*.comp") if path.is_file() and (untracked is None or relative(root, path).removeprefix("linuxcnc/") not in untracked))
manifest = [parse_comp(root, path) for path in component_files]
manifest.sort(key=lambda row: str(row["component"] or row["path"]))
component_names = {str(row["component"]) for row in manifest if row.get("component")}
hal_resource_ids: dict[str, str] = {}
for row in resource_rows:
if row.get("resource_kind") == "hal" and row.get("parse_status") in {"resolved_file", "resolved_directory"}:
hal_resource_ids.setdefault(str(row.get("path")), str(row.get("resource_source_id")))
hal_paths = sorted(path for path in hal_resource_ids if (root / path).is_file())
graph: list[dict[str, Any]] = []
for path in hal_paths:
graph.extend(parse_hal(root, root / path, component_names, hal_resource_ids[path]))
graph.sort(key=lambda row: (str(row.get("path")), int(row.get("line", 0)), str(row.get("command")), str(row.get("raw", ""))))
statuses = Counter(str(row.get("status")) for row in graph)
codes = Counter(str(row.get("code")) for row in graph if row.get("code"))
component_names_list = [str(row.get("component")) for row in manifest if row.get("component")]
checks = {
"manifest_sources": {"status": "verified" if len(manifest) == 145 and len(component_names_list) == len(set(component_names_list)) and all(row.get("source_sha256") for row in manifest) else "blocked", "components": len(manifest)},
"manifest_declarations": {"status": "verified" if all(row.get("status") == "verified" and row.get("component") for row in manifest) else "blocked", "blocked_components": sum(row.get("status") != "verified" for row in manifest)},
"hal_resource_edges": {"status": "verified" if all(row.get("resource_source_id") for row in graph) else "blocked", "hal_files": len(hal_paths), "graph_records": len(graph)},
"capacity_contract": {"status": "verified" if hal_runtime.get("pin_capacity") == 256 and hal_runtime.get("max_period_ticks") == 1000000 else "blocked", "pin_capacity": hal_runtime.get("pin_capacity"), "max_period_ticks": hal_runtime.get("max_period_ticks")},
"no_dynamic_loader_acceptance": {"status": "verified" if all(row.get("code") != "dynamic_library_accepted" for row in graph) else "blocked", "host_dynamic_loaders": codes.get("host_dynamic_loader", 0)},
"configuration_dependency": {"status": "verified" if config_closure.get("implementation_status") == "verified" else "blocked"},
"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")},
}
checks_ok = all(value["status"] == "verified" for value in checks.values())
report: dict[str, Any] = {
"schema": SCHEMA,
"context_id": lock.get("context_id"),
"task_id": "M3-RT-02",
"status": "partial" if checks_ok and statuses.get("blocked", 0) else "blocked" if not checks_ok else "verified",
"implementation_status": "verified" if checks_ok else "blocked",
"candidate_eligible": False,
"release_action": "STOP_RELEASE",
"inputs": [artifact(root, CONTEXT, "context_lock"), artifact(root, RESOURCES, "config_resources"), artifact(root, CONFIG_CLOSURE, "configuration_startup_closure"), artifact(root, HAL_REPORT, "hal_runtime"), artifact(root, GATE, "release_candidate_gate")],
"counts": {"component_files": len(manifest), "components": len(component_names_list), "pins": sum(len(row["pins"]) for row in manifest), "params": sum(len(row["params"]) for row in manifest), "functions": sum(len(row["functions"]) for row in manifest), "hal_files": len(hal_paths), "graph_records": len(graph), "graph_statuses": dict(sorted(statuses.items())), "graph_codes": dict(sorted(codes.items()))},
"checks": checks,
"component_manifest": manifest,
"hal_graph": graph,
"errors": {},
"next_transition": "execute M3-RT-03 virtual device fault injection and replay",
"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"hal_component_manifest={report['status']} components={report['counts']['components']} graph_records={report['counts']['graph_records']}")
return 0
if __name__ == "__main__":
raise SystemExit(main())

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())

View File

@@ -0,0 +1,88 @@
#!/usr/bin/env python3
"""Generate deterministic Worker Python bridge 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")
MANIFEST = Path("python-runtime/manifest.json")
RUNTIME_REPORT = Path("coverage/python-runtime.report.json")
SESSION_REPORT = Path("coverage/workspace-session-integration.report.json")
GATE = Path("coverage/release-candidate-gate.report.json")
OUTPUT = Path("coverage/python-worker-bridge.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 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 run(root: Path) -> tuple[dict[str, Any], dict[str, Any]]:
runs = []
for _ in range(2):
result = subprocess.run(["node", "web/worker/test_python_bridge.mjs"], cwd=root, check=False, capture_output=True, text=True)
runs.append({"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)})
return runs[0], runs[1]
def generate(root: Path, output: Path = OUTPUT) -> dict[str, Any]:
root = root.resolve()
lock = json.loads((root / CONTEXT).read_text(encoding="utf-8"))
manifest = json.loads((root / MANIFEST).read_text(encoding="utf-8"))
runtime = json.loads((root / RUNTIME_REPORT).read_text(encoding="utf-8"))
session = json.loads((root / SESSION_REPORT).read_text(encoding="utf-8"))
gate = json.loads((root / GATE).read_text(encoding="utf-8"))
first, second = run(root)
checks = {
"manifest_pin": {"status": "verified" if manifest.get("runtime") == "Pyodide" and manifest.get("worker_only") is True and runtime.get("status") == "passed" else "blocked", "version": manifest.get("version")},
"session_dependency": {"status": "verified" if session.get("implementation_status") == "verified" else "blocked"},
"virtual_api_and_denial": {"status": "verified" if first.get("status") == "passed" and "python_bridge=passed" in first.get("stdout", "") else "blocked"},
"repeat_determinism": {"status": "verified" if first == second else "blocked"},
"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")},
}
checks_ok = all(value["status"] == "verified" for value in checks.values())
report: dict[str, Any] = {
"schema": "python-worker-bridge.v1",
"context_id": lock.get("context_id"),
"task_id": "M3-PY-01",
"status": "partial" if checks_ok else "blocked",
"implementation_status": "verified" if checks_ok else "blocked",
"candidate_eligible": False,
"release_action": "STOP_RELEASE",
"inputs": [artifact(root, CONTEXT, "context_lock"), artifact(root, MANIFEST, "python_manifest"), artifact(root, RUNTIME_REPORT, "python_runtime"), artifact(root, SESSION_REPORT, "workspace_session_integration"), artifact(root, GATE, "release_candidate_gate")],
"checks": checks,
"runtime": manifest,
"sample": {"first": first, "second": second},
"next_transition": "execute FE-M1 minimal real frontend vertical slice",
"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"python_worker_bridge={report['status']} denial={report['checks']['virtual_api_and_denial']['status']}")
return 0
if __name__ == "__main__": raise SystemExit(main())

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env python3
"""Generate deterministic recovery/offline fault matrix 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")
REG01 = Path("coverage/full-configuration-startup-matrix.report.json")
SESSION = Path("coverage/workspace-session-integration.report.json")
RECOVERY = Path("coverage/workspace-recovery.report.json")
MIGRATION = Path("coverage/workspace-migration.report.json")
GATE = Path("coverage/release-candidate-gate.report.json")
OUTPUT = Path("coverage/recovery-offline-fault-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()).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 run(root: Path) -> tuple[dict[str, Any], dict[str, Any]]:
outputs = []
for _ in range(2):
result = subprocess.run(["node", "web/worker/test_recovery_offline_faults.mjs"], cwd=root, check=False, capture_output=True, text=True)
outputs.append({"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)})
return outputs[0], outputs[1]
def generate(root: Path, output: Path = OUTPUT) -> dict[str, Any]:
root = root.resolve(); lock = json.loads((root / CONTEXT).read_text()); reg = json.loads((root / REG01).read_text()); session = json.loads((root / SESSION).read_text()); recovery = json.loads((root / RECOVERY).read_text()); migration = json.loads((root / MIGRATION).read_text()); gate = json.loads((root / GATE).read_text()); first, second = run(root)
checks = {"reg01_dependency": {"status": "verified" if reg.get("implementation_status") == "verified" else "blocked"}, "session_dependency": {"status": "verified" if session.get("implementation_status") == "verified" else "blocked"}, "recovery_dependency": {"status": "verified" if recovery.get("implementation_status") == "verified" else "blocked"}, "migration_dependency": {"status": "verified" if migration.get("implementation_status") == "verified" else "blocked"}, "fault_runner": {"status": "verified" if first["status"] == "passed" else "blocked"}, "repeat_determinism": {"status": "verified" if first == second else "blocked"}, "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": "recovery-offline-fault-matrix.v1", "context_id": lock.get("context_id"), "task_id": "REG-03", "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, REG01, "full_configuration_matrix"), artifact(root, SESSION, "workspace_session_integration"), artifact(root, RECOVERY, "workspace_recovery"), artifact(root, MIGRATION, "workspace_migration"), artifact(root, GATE, "release_candidate_gate")], "checks": checks, "sample": {"first": first, "second": second}, "scenarios": ["half_commit", "checkpoint_hash_mismatch", "event_gap", "offline_missing_resource", "online_network_required"], "next_transition": "execute REG-04 browser and performance matrix", "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"recovery_offline_fault_matrix={report['status']} scenarios={len(report['scenarios'])}"); return 0
if __name__ == "__main__": raise SystemExit(main())

View File

@@ -0,0 +1,109 @@
#!/usr/bin/env python3
"""Generate deterministic Worker virtual-device fault and replay 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")
IO_REPORT = Path("coverage/io-runtime.report.json")
HAL_REPORT = Path("coverage/hal-component-manifest.report.json")
CONFIG_REPORT = Path("coverage/configuration-startup-closure.report.json")
GATE = Path("coverage/release-candidate-gate.report.json")
OUTPUT = Path("coverage/virtual-device-fault-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_digest(path: Path) -> str | None:
if not path.is_file():
return None
return hashlib.sha256(path.read_bytes()).hexdigest()
def artifact(root: Path, path: Path, role: str) -> dict[str, Any]:
full = root / path
sha = file_digest(full)
return {"path": path.as_posix(), "role": role, "status": "present", "bytes": full.stat().st_size, "sha256": sha} if sha else {"path": path.as_posix(), "role": role, "status": "missing"}
def run_sample(root: Path) -> tuple[dict[str, Any], dict[str, Any]]:
command = ["node", "web/worker/test_virtual_devices.mjs"]
runs = []
for _ in range(2):
result = subprocess.run(command, cwd=root, check=False, capture_output=True, text=True)
lines = [line.strip() for line in result.stdout.splitlines() if line.lstrip().startswith("{")]
sample = json.loads(lines[-1]) if result.returncode == 0 and lines else {}
runs.append({"status": "passed" if result.returncode == 0 and sample else "blocked", "exit_code": result.returncode, "sample": sample, "stdout_sha256": digest(result.stdout), "stderr_sha256": digest(result.stderr)})
return runs[0], runs[1]
def generate(root: Path, output: Path = OUTPUT) -> dict[str, Any]:
root = root.resolve()
lock = json.loads((root / CONTEXT).read_text(encoding="utf-8"))
io_report = json.loads((root / IO_REPORT).read_text(encoding="utf-8"))
hal_report = json.loads((root / HAL_REPORT).read_text(encoding="utf-8"))
config_report = json.loads((root / CONFIG_REPORT).read_text(encoding="utf-8"))
gate = json.loads((root / GATE).read_text(encoding="utf-8"))
first, second = run_sample(root)
sample = first.get("sample", {})
second_sample = second.get("sample", {})
scenarios = sample.get("scenarios", [])
scenario_codes = {str(row.get("kind")): row.get("code") for row in scenarios}
checks = {
"native_wasm_io_baseline": {"status": "verified" if io_report.get("implementation_status") == "verified" else "blocked"},
"hal_configuration_dependency": {"status": "verified" if hal_report.get("implementation_status") == "verified" and config_report.get("implementation_status") == "verified" else "blocked"},
"normal_fault_abort_recovery_coverage": {"status": "verified" if all(kind in scenario_codes for kind in ("SPINDLE_COMMAND", "TOOL_CHANGE", "TOOL_ABORT", "TOOL_FAULT", "TOOL_CLEAR_FAULT", "PROBE_CONFIG", "ESTOP", "IO_RECOVER")) else "blocked", "scenario_count": len(scenarios)},
"nonfinite_input_blocked": {"status": "verified" if "sim_io_nonfinite" in {row.get("code") for row in scenarios} else "blocked"},
"replay_state_hash": {"status": "verified" if sample.get("state_hash_equal") is True and sample.get("state_hash") == sample.get("replay_state_hash") else "blocked", "state_hash": sample.get("state_hash"), "replay_state_hash": sample.get("replay_state_hash")},
"repeat_determinism": {"status": "verified" if first.get("status") == "passed" and second.get("status") == "passed" and sample == second_sample else "blocked"},
"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")},
}
checks_ok = all(row["status"] == "verified" for row in checks.values())
report: dict[str, Any] = {
"schema": "virtual-device-fault-matrix.v1",
"context_id": lock.get("context_id"),
"task_id": "M3-RT-03",
"status": "partial" if checks_ok else "blocked",
"implementation_status": "verified" if checks_ok else "blocked",
"candidate_eligible": False,
"release_action": "STOP_RELEASE",
"inputs": [artifact(root, CONTEXT, "context_lock"), artifact(root, IO_REPORT, "io_runtime"), artifact(root, HAL_REPORT, "hal_component_manifest"), artifact(root, CONFIG_REPORT, "configuration_startup_closure"), artifact(root, GATE, "release_candidate_gate")],
"checks": checks,
"scenarios": scenarios,
"sample": sample,
"rebuild": {"command": "node web/worker/test_virtual_devices.mjs", "repeat_runs": 2, "native_wasm_baseline": "coverage/io-runtime.report.json"},
"next_transition": "execute M3-FS-01 workspace recovery and configuration session integration",
"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"virtual_device_fault_matrix={report['status']} scenarios={len(report['scenarios'])} replay={report['checks']['replay_state_hash']['status']}")
return 0
if __name__ == "__main__":
raise SystemExit(main())

View File

@@ -0,0 +1,106 @@
#!/usr/bin/env python3
"""Generate deterministic configuration/HA/IO/workspace session 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")
CONFIG = Path("coverage/configuration-startup-closure.report.json")
HAL = Path("coverage/hal-component-manifest.report.json")
DEVICES = Path("coverage/virtual-device-fault-matrix.report.json")
RECOVERY = Path("coverage/workspace-recovery.report.json")
MIGRATION = Path("coverage/workspace-migration.report.json")
GATE = Path("coverage/release-candidate-gate.report.json")
OUTPUT = Path("coverage/workspace-session-integration.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 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 sample(root: Path) -> tuple[dict[str, Any], dict[str, Any]]:
command = ["node", "web/worker/test_workspace_session_integration.mjs"]
runs = []
for _ in range(2):
result = subprocess.run(command, cwd=root, check=False, capture_output=True, text=True)
lines = [line.strip() for line in result.stdout.splitlines() if line.lstrip().startswith("{")]
value = json.loads(lines[-1]) if result.returncode == 0 and lines else {}
runs.append({"status": "passed" if result.returncode == 0 and value else "blocked", "exit_code": result.returncode, "sample": value, "stdout_sha256": digest(result.stdout), "stderr_sha256": digest(result.stderr)})
return runs[0], runs[1]
def generate(root: Path, output: Path = OUTPUT) -> dict[str, Any]:
root = root.resolve()
lock = json.loads((root / CONTEXT).read_text(encoding="utf-8"))
config = json.loads((root / CONFIG).read_text(encoding="utf-8"))
hal = json.loads((root / HAL).read_text(encoding="utf-8"))
devices = json.loads((root / DEVICES).read_text(encoding="utf-8"))
recovery = json.loads((root / RECOVERY).read_text(encoding="utf-8"))
migration = json.loads((root / MIGRATION).read_text(encoding="utf-8"))
gate = json.loads((root / GATE).read_text(encoding="utf-8"))
first, second = sample(root)
value = first.get("sample", {})
second_value = second.get("sample", {})
checks = {
"context_consistency": {"status": "verified" if all(row.get("context_id") in {None, lock.get("context_id")} for row in (config, hal, recovery, migration, gate)) else "blocked", "context_id": lock.get("context_id")},
"configuration_dependency": {"status": "verified" if config.get("implementation_status") == "verified" else "blocked"},
"hal_dependency": {"status": "verified" if hal.get("implementation_status") == "verified" else "blocked"},
"device_dependency": {"status": "verified" if devices.get("implementation_status") == "verified" else "blocked"},
"recovery_migration_dependency": {"status": "verified" if recovery.get("implementation_status") == "verified" and migration.get("implementation_status") == "verified" else "blocked"},
"session_state_recovery": {"status": "verified" if value.get("session_state_hash") == value.get("recovery_state_hash") else "blocked", "session_state_hash": value.get("session_state_hash"), "recovery_state_hash": value.get("recovery_state_hash")},
"package_round_trip": {"status": "verified" if value.get("round_trip_equal") is True else "blocked", "package_v1_hash": value.get("package_v1_hash"), "package_v2_hash": value.get("package_v2_hash")},
"repeat_determinism": {"status": "verified" if first.get("status") == "passed" and second.get("status") == "passed" and value == second_value else "blocked"},
"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")},
}
checks_ok = all(row["status"] == "verified" for row in checks.values())
report: dict[str, Any] = {
"schema": "workspace-session-integration.v1",
"context_id": lock.get("context_id"),
"task_id": "M3-FS-01",
"status": "partial" if checks_ok else "blocked",
"implementation_status": "verified" if checks_ok else "blocked",
"candidate_eligible": False,
"release_action": "STOP_RELEASE",
"inputs": [artifact(root, CONTEXT, "context_lock"), artifact(root, CONFIG, "configuration_startup_closure"), artifact(root, HAL, "hal_component_manifest"), artifact(root, DEVICES, "virtual_device_fault_matrix"), artifact(root, RECOVERY, "workspace_recovery"), artifact(root, MIGRATION, "workspace_migration"), artifact(root, GATE, "release_candidate_gate")],
"checks": checks,
"sample": value,
"rebuild": {"command": "node web/worker/test_workspace_session_integration.mjs", "repeat_runs": 2},
"next_transition": "execute M3-PY-01 actual Pyodide virtual API bridge",
"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"workspace_session_integration={report['status']} state={report['checks']['session_state_recovery']['status']} migration={report['checks']['package_round_trip']['status']}")
return 0
if __name__ == "__main__":
raise SystemExit(main())

View File

@@ -0,0 +1,11 @@
import json,sys,unittest
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[0]))
from generate_browser_performance_matrix import OUTPUT,generate
ROOT=Path(__file__).resolve().parents[1]
class BrowserPerformanceMatrixTests(unittest.TestCase):
def test_contract(self):
r=json.loads((ROOT/OUTPUT).read_text());self.assertEqual(r["schema"],"browser-performance-matrix.v1");self.assertEqual(r["task_id"],"REG-04");self.assertEqual(r["implementation_status"],"verified");self.assertEqual(r["checks"]["safari_not_in_scope"]["status"],"verified");self.assertEqual(r["checks"]["firefox_not_in_scope"]["status"],"verified");self.assertEqual(r["environment"]["scope"],["chromium"])
def test_deterministic(self):
b=(ROOT/OUTPUT).read_bytes();r=generate(ROOT,ROOT/OUTPUT);self.assertEqual(b,(ROOT/OUTPUT).read_bytes());self.assertEqual(r["report_sha256"],json.loads(b)["report_sha256"])
if __name__=="__main__":unittest.main()

View File

@@ -0,0 +1,45 @@
import json
import sys
import unittest
from pathlib import Path
from tempfile import TemporaryDirectory
sys.path.insert(0, str(Path(__file__).resolve().parent))
from generate_configuration_startup_closure import candidates, generate, resolve_row
class ConfigurationStartupClosureTests(unittest.TestCase):
def test_explicit_library_and_argument_tail(self):
paths, kind, error, args = candidates("LIB:basic_sim.tcl -no_sim_spindle", "linuxcnc/configs/sim/demo/main.ini")
self.assertEqual(kind, "library")
self.assertIsNone(error)
self.assertEqual(args, ["-no_sim_spindle"])
self.assertEqual(paths[0], "linuxcnc/lib/hallib/basic_sim.tcl")
def test_relative_does_not_search_by_basename(self):
row = {"resource_source_id": "r1", "entrypoint": "linuxcnc/configs/sim/demo/main.ini", "raw_value": "core.hal", "path": "linuxcnc/configs/sim/demo/core.hal", "parse_status": "missing"}
result = resolve_row(row, {"linuxcnc/lib/hallib/core.hal"})
self.assertEqual(result["status"], "blocked_missing")
self.assertEqual(result["resolution"], "relative")
def test_host_and_outside_paths_fail_closed(self):
host = resolve_row({"entrypoint": "linuxcnc/configs/sim/demo/main.ini", "raw_value": "~/linuxcnc/nc_files", "path": "~/linuxcnc/nc_files", "parse_status": "host_or_variable_path"}, set())
outside = resolve_row({"entrypoint": "linuxcnc/configs/sim/demo/main.ini", "raw_value": "../../../../etc/passwd", "path": "../../../../etc/passwd", "parse_status": "outside_repo"}, set())
self.assertEqual(host["status"], "blocked_host_path")
self.assertEqual(outside["status"], "blocked_outside_repo")
def test_generation_is_deterministic(self):
root = Path(__file__).resolve().parents[1]
with TemporaryDirectory() as directory:
output = Path(directory) / "report.json"
first = generate(root, output)
before = output.read_bytes()
second = generate(root, output)
self.assertEqual(first, second)
self.assertEqual(before, output.read_bytes())
self.assertEqual(json.loads(before)["report_sha256"], second["report_sha256"])
if __name__ == "__main__":
unittest.main()

View File

@@ -0,0 +1,28 @@
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from generate_frontend_m1 import OUTPUT, generate
ROOT = Path(__file__).resolve().parents[1]
class FrontendM1Tests(unittest.TestCase):
def test_report_contract(self):
report = json.loads((ROOT / OUTPUT).read_text(encoding="utf-8"))
self.assertEqual(report["schema"], "frontend-m1.v1")
self.assertEqual(report["task_id"], "FE-M1")
self.assertEqual(report["implementation_status"], "verified")
self.assertEqual(report["checks"]["browser_smoke"]["status"], "verified")
def test_generation_is_deterministic(self):
before = (ROOT / OUTPUT).read_bytes()
report = generate(ROOT, ROOT / OUTPUT)
self.assertEqual(before, (ROOT / OUTPUT).read_bytes())
self.assertEqual(report["report_sha256"], json.loads(before)["report_sha256"])
if __name__ == "__main__": unittest.main()

View File

@@ -0,0 +1,27 @@
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from generate_frontend_m2 import OUTPUT, generate
ROOT = Path(__file__).resolve().parents[1]
class FrontendM2Tests(unittest.TestCase):
def test_contract(self):
report = json.loads((ROOT / OUTPUT).read_text())
self.assertEqual(report["schema"], "frontend-m2.v1")
self.assertEqual(report["task_id"], "FE-M2")
self.assertEqual(report["implementation_status"], "verified")
self.assertTrue(all(value["status"] == "verified" for value in report["checks"].values()))
def test_deterministic(self):
before = (ROOT / OUTPUT).read_bytes()
report = generate(ROOT, ROOT / OUTPUT)
self.assertEqual(before, (ROOT / OUTPUT).read_bytes())
self.assertEqual(report["report_sha256"], json.loads(before)["report_sha256"])
if __name__ == "__main__": unittest.main()

View File

@@ -0,0 +1,27 @@
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[0]))
from generate_frontend_m3 import OUTPUT, generate
ROOT = Path(__file__).resolve().parents[1]
class FrontendM3Tests(unittest.TestCase):
def test_contract(self):
report = json.loads((ROOT / OUTPUT).read_text())
self.assertEqual(report["schema"], "frontend-m3.v1")
self.assertEqual(report["task_id"], "FE-M3")
self.assertEqual(report["implementation_status"], "verified")
self.assertTrue(all(value["status"] == "verified" for value in report["checks"].values()))
def test_deterministic(self):
before = (ROOT / OUTPUT).read_bytes()
report = generate(ROOT, ROOT / OUTPUT)
self.assertEqual(before, (ROOT / OUTPUT).read_bytes())
self.assertEqual(report["report_sha256"], json.loads(before)["report_sha256"])
if __name__ == "__main__": unittest.main()

View File

@@ -0,0 +1,25 @@
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[0]))
from generate_frontend_m4 import OUTPUT, generate
ROOT = Path(__file__).resolve().parents[1]
class FrontendM4Tests(unittest.TestCase):
def test_contract(self):
report = json.loads((ROOT / OUTPUT).read_text())
self.assertEqual(report["schema"], "frontend-m4.v1")
self.assertEqual(report["task_id"], "FE-M4")
self.assertEqual(report["implementation_status"], "verified")
self.assertTrue(all(value["status"] == "verified" for value in report["checks"].values()))
def test_deterministic(self):
before = (ROOT / OUTPUT).read_bytes()
report = generate(ROOT, ROOT / OUTPUT)
self.assertEqual(before, (ROOT / OUTPUT).read_bytes())
self.assertEqual(report["report_sha256"], json.loads(before)["report_sha256"])
if __name__ == "__main__": unittest.main()

View File

@@ -0,0 +1,29 @@
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[0]))
from generate_full_configuration_startup_matrix import OUTPUT, generate
ROOT = Path(__file__).resolve().parents[1]
class FullConfigurationStartupMatrixTests(unittest.TestCase):
def test_contract(self):
report = json.loads((ROOT / OUTPUT).read_text())
self.assertEqual(report["schema"], "full-configuration-startup-matrix.v1")
self.assertEqual(report["task_id"], "REG-01")
self.assertEqual(report["implementation_status"], "verified")
self.assertEqual(report["counts"]["registered_entries"], 264)
self.assertEqual(report["counts"]["entrypoints"], 233)
self.assertTrue(all(value["status"] == "verified" for value in report["checks"].values()))
def test_deterministic(self):
before = (ROOT / OUTPUT).read_bytes()
report = generate(ROOT, ROOT / OUTPUT)
self.assertEqual(before, (ROOT / OUTPUT).read_bytes())
self.assertEqual(report["report_sha256"], json.loads(before)["report_sha256"])
if __name__ == "__main__": unittest.main()

View File

@@ -0,0 +1,49 @@
import json
import sys
import unittest
from pathlib import Path
from tempfile import TemporaryDirectory
sys.path.insert(0, str(Path(__file__).resolve().parent))
from generate_hal_component_manifest import OUTPUT, generate, parse_comp, parse_hal
ROOT = Path(__file__).resolve().parents[1]
class HalComponentManifestTests(unittest.TestCase):
def test_parse_component_contract(self):
with TemporaryDirectory() as directory:
root = Path(directory)
path = root / "linuxcnc/src/hal/components/demo.comp"
path.parent.mkdir(parents=True)
path.write_text("component demo;\npin in float input;\npin out bit output;\nparam rw float gain = 1.0;\nfunction update;\n", encoding="utf-8")
report = parse_comp(root, path)
self.assertEqual(report["status"], "verified")
self.assertEqual(report["component"], "demo")
self.assertEqual(len(report["pins"]), 2)
self.assertEqual(report["params"][0]["default"], "1.0")
self.assertEqual(report["functions"][0]["name"], "update")
def test_hal_unknown_and_dynamic_loaders_block(self):
with TemporaryDirectory() as directory:
root = Path(directory)
path = root / "linuxcnc/lib/hallib/demo.hal"
path.parent.mkdir(parents=True)
path.write_text("loadrt demo names=d0\nloadrt [KINS]KINEMATICS\nloadusr -W external\naddf d0 servo-thread\n", encoding="utf-8")
records = parse_hal(root, path, {"demo"}, "resource:demo")
self.assertEqual(records[0]["status"], "declared")
self.assertEqual(records[1]["code"], "undeclared_or_variable_component")
self.assertEqual(records[2]["code"], "host_dynamic_loader")
self.assertEqual(records[3]["status"], "checked")
def test_generation_is_deterministic(self):
before = (ROOT / OUTPUT).read_bytes()
first = generate(ROOT, ROOT / OUTPUT)
after = (ROOT / OUTPUT).read_bytes()
self.assertEqual(before, after)
self.assertEqual(first["report_sha256"], json.loads(after.decode())["report_sha256"])
if __name__ == "__main__":
unittest.main()

View File

@@ -0,0 +1,29 @@
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[0]))
from generate_project_task_readiness import OUTPUT, generate
ROOT = Path(__file__).resolve().parents[1]
class ProjectTaskReadinessTests(unittest.TestCase):
def test_contract(self):
report = json.loads((ROOT / OUTPUT).read_text(encoding="utf-8"))
self.assertEqual(report["schema"], "project-task-readiness.v1")
self.assertEqual(report["task_id"], "GOV-01")
self.assertEqual(report["release_status"], "blocked_external_owner")
self.assertEqual(report["checks"]["no_self_loop"]["automatic_retry"], False)
self.assertTrue(all(value["status"] == "verified" for value in report["checks"].values()))
def test_deterministic(self):
before = (ROOT / OUTPUT).read_bytes()
report = generate(ROOT, ROOT / OUTPUT)
self.assertEqual(before, (ROOT / OUTPUT).read_bytes())
self.assertEqual(report["report_sha256"], json.loads(before)["report_sha256"])
if __name__ == "__main__":
unittest.main()

View File

@@ -0,0 +1,28 @@
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from generate_python_worker_bridge import OUTPUT, generate
ROOT = Path(__file__).resolve().parents[1]
class PythonWorkerBridgeTests(unittest.TestCase):
def test_report_contract(self):
report = json.loads((ROOT / OUTPUT).read_text(encoding="utf-8"))
self.assertEqual(report["schema"], "python-worker-bridge.v1")
self.assertEqual(report["task_id"], "M3-PY-01")
self.assertEqual(report["implementation_status"], "verified")
self.assertTrue(all(value["status"] == "verified" for value in report["checks"].values()))
def test_generation_is_deterministic(self):
before = (ROOT / OUTPUT).read_bytes()
report = generate(ROOT, ROOT / OUTPUT)
self.assertEqual(before, (ROOT / OUTPUT).read_bytes())
self.assertEqual(report["report_sha256"], json.loads(before)["report_sha256"])
if __name__ == "__main__": unittest.main()

View File

@@ -0,0 +1,13 @@
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[0]))
from generate_recovery_offline_fault_matrix import OUTPUT, generate
ROOT = Path(__file__).resolve().parents[1]
class RecoveryOfflineFaultMatrixTests(unittest.TestCase):
def test_contract(self):
report = json.loads((ROOT / OUTPUT).read_text()); self.assertEqual(report["schema"], "recovery-offline-fault-matrix.v1"); self.assertEqual(report["task_id"], "REG-03"); self.assertEqual(report["implementation_status"], "verified"); self.assertTrue(all(value["status"] == "verified" for value in report["checks"].values()))
def test_deterministic(self):
before = (ROOT / OUTPUT).read_bytes(); report = generate(ROOT, ROOT / OUTPUT); self.assertEqual(before, (ROOT / OUTPUT).read_bytes()); self.assertEqual(report["report_sha256"], json.loads(before)["report_sha256"])
if __name__ == "__main__": unittest.main()

View File

@@ -0,0 +1,32 @@
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from generate_virtual_device_fault_matrix import OUTPUT, generate
ROOT = Path(__file__).resolve().parents[1]
class VirtualDeviceFaultMatrixTests(unittest.TestCase):
def test_report_contract(self):
report = json.loads((ROOT / OUTPUT).read_text(encoding="utf-8"))
self.assertEqual(report["schema"], "virtual-device-fault-matrix.v1")
self.assertEqual(report["task_id"], "M3-RT-03")
self.assertEqual(report["implementation_status"], "verified")
self.assertEqual(report["checks"]["replay_state_hash"]["status"], "verified")
self.assertEqual(report["checks"]["repeat_determinism"]["status"], "verified")
self.assertEqual(report["release_action"], "STOP_RELEASE")
def test_generation_is_deterministic(self):
before = (ROOT / OUTPUT).read_bytes()
report = generate(ROOT, ROOT / OUTPUT)
self.assertEqual(before, (ROOT / OUTPUT).read_bytes())
self.assertEqual(report["report_sha256"], json.loads(before)["report_sha256"])
if __name__ == "__main__":
unittest.main()

View File

@@ -0,0 +1,31 @@
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from generate_workspace_session_integration import OUTPUT, generate
ROOT = Path(__file__).resolve().parents[1]
class WorkspaceSessionIntegrationTests(unittest.TestCase):
def test_report_contract(self):
report = json.loads((ROOT / OUTPUT).read_text(encoding="utf-8"))
self.assertEqual(report["schema"], "workspace-session-integration.v1")
self.assertEqual(report["task_id"], "M3-FS-01")
self.assertEqual(report["implementation_status"], "verified")
self.assertEqual(report["checks"]["session_state_recovery"]["status"], "verified")
self.assertEqual(report["checks"]["package_round_trip"]["status"], "verified")
def test_generation_is_deterministic(self):
before = (ROOT / OUTPUT).read_bytes()
report = generate(ROOT, ROOT / OUTPUT)
self.assertEqual(before, (ROOT / OUTPUT).read_bytes())
self.assertEqual(report["report_sha256"], json.loads(before)["report_sha256"])
if __name__ == "__main__":
unittest.main()