|
|
@@ -42,6 +42,25 @@ def canonical_sha256(value: Any) -> str:
|
|
|
return hashlib.sha256(data.encode("utf-8")).hexdigest()
|
|
|
|
|
|
|
|
|
+def evidence_path(path: Path) -> str:
|
|
|
+ resolved = path.resolve()
|
|
|
+ try:
|
|
|
+ return resolved.relative_to(ROOT.resolve()).as_posix()
|
|
|
+ except ValueError:
|
|
|
+ return resolved.as_posix()
|
|
|
+
|
|
|
+
|
|
|
+def formal_run_base() -> Path:
|
|
|
+ configured = os.environ.get("PRODU2_FORMAL_RUN_BASE")
|
|
|
+ base = Path(configured) if configured else (
|
|
|
+ Path(os.environ.get("XDG_STATE_HOME", "/tmp")) / "prod2u" / "formal-runs"
|
|
|
+ )
|
|
|
+ resolved = base.expanduser().resolve()
|
|
|
+ if resolved == ROOT.resolve() or ROOT.resolve() in resolved.parents:
|
|
|
+ raise RuntimeError("formal run base must be outside the Git worktree")
|
|
|
+ return resolved
|
|
|
+
|
|
|
+
|
|
|
def run_text(argv: list[str], *, check: bool = True) -> str:
|
|
|
result = subprocess.run(
|
|
|
argv,
|
|
|
@@ -244,7 +263,7 @@ def property_cell_ids(values: Iterable[str]) -> set[str]:
|
|
|
|
|
|
def relative_artifacts(workdir: Path, pattern: str) -> list[dict[str, str]]:
|
|
|
return [
|
|
|
- {"path": path.relative_to(ROOT).as_posix(), "sha256": sha256_file(path)}
|
|
|
+ {"path": evidence_path(path), "sha256": sha256_file(path)}
|
|
|
for path in sorted(workdir.rglob(pattern))
|
|
|
if path.is_file()
|
|
|
]
|
|
|
@@ -323,9 +342,9 @@ def run_job(job: dict[str, Any], run_root: Path, timeout: int) -> dict[str, Any]
|
|
|
"timed_out": timed_out,
|
|
|
"duration_seconds": round(duration, 3),
|
|
|
"command": command,
|
|
|
- "workdir": workdir.relative_to(ROOT).as_posix(),
|
|
|
+ "workdir": evidence_path(workdir),
|
|
|
"process_log": {
|
|
|
- "path": process_log.relative_to(ROOT).as_posix(),
|
|
|
+ "path": evidence_path(process_log),
|
|
|
"sha256": sha256_file(process_log),
|
|
|
},
|
|
|
"sby_log_sha256": sha256_file(logfile) if logfile.is_file() else "0" * 64,
|
|
|
@@ -373,7 +392,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
run_id = args.run_id or timestamp.strftime("6400-formal-%Y%m%dT%H%M%SZ")
|
|
|
if not re.fullmatch(r"[A-Za-z0-9._-]+", run_id):
|
|
|
parser.error("run ID may contain only letters, digits, dot, underscore, and hyphen")
|
|
|
- run_root = ROOT / "receipts" / "6400-formal" / run_id
|
|
|
+ run_root = formal_run_base() / run_id
|
|
|
if run_root.exists():
|
|
|
parser.error(f"run directory already exists: {run_root}")
|
|
|
run_root.mkdir(parents=True)
|
|
|
@@ -474,7 +493,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
print(json.dumps({
|
|
|
"status": receipt["status"],
|
|
|
"run_id": run_id,
|
|
|
- "receipt": receipt_path.relative_to(ROOT).as_posix(),
|
|
|
+ "receipt": evidence_path(receipt_path),
|
|
|
"receipt_sha256": sha256_file(receipt_path),
|
|
|
"target_count": len(target_results),
|
|
|
"task_count": len(results),
|