Files
aigc-home/docs/hel-892/batch175-closure-evidence/collect.py
T

106 lines
2.6 KiB
Python

"""Collect explicitly named commands, including failed checks; no cross-batch glob."""
import hashlib
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[3]
HERE = Path(__file__).resolve().parent
LOCAL = ROOT / ".local-evidence/batch175-closure"
KEYS = [
"preflight",
"fresh-import",
"history",
"audit-initial",
"audit-second",
"audit-third",
"audit-fourth",
"audit-fifth",
"audit-final",
"format-write",
"lint-initial",
"lint-auto-fix",
"wrap-literals",
"format-repair",
"lint-final-in-progress",
"wrap-literals-width",
"format-width",
"lint-width",
"format-parsed",
"lint-parsed",
"audit-expanded",
"render",
"render-final",
"finalize",
"format-delivery",
"lint-delivery",
"format-check",
"parse",
"diff-check",
"csv-repair",
"lint-post",
"format-post",
"parse-post",
"diff-check-final",
"lint-last",
"format-last",
"parse-last",
"diff-check-clean",
]
def main():
records = []
logs = HERE / "logs"
logs.mkdir(exist_ok=True)
for key in KEYS:
r = json.loads((LOCAL / "records" / (key + ".json")).read_bytes())
assert r["key"] == key
for log in r["logs"]:
raw = (ROOT / log["path"]).read_bytes()
assert hashlib.sha256(raw).hexdigest() == log["sha256"]
assert len(raw) == log["bytes"]
target = logs / Path(log["path"]).name
if target.exists():
assert target.read_bytes() == raw
else:
with target.open("xb") as f:
f.write(raw)
records.append(r)
required_pass = [
"preflight",
"fresh-import",
"history",
"audit-fifth",
"audit-final",
"audit-expanded",
"render-final",
"finalize",
"lint-delivery",
"format-check",
"parse",
"diff-check-clean",
]
assert all(r["returncode"] == 0 for r in records if r["key"] in required_pass)
with (HERE / "completed-log-records.json").open("x") as f:
json.dump(
dict(
explicit_keys=KEYS,
records=records,
failed_keys=[r["key"] for r in records if r["returncode"]],
no_glob=True,
product_tests_or_builds_rerun=False,
),
f,
ensure_ascii=False,
indent=2,
)
f.write("\n")
print(
"PASS", len(records), "explicit records;", len(records) * 2, "raw logs; failures retained"
)
if __name__ == "__main__":
main()