#!/usr/bin/env python3 """Finalise job #4540's artefacts: normalise encodings, capture the checker's stdout, re-stage the repro directory, and run the publication-scrub gate over every file the spec will upload. Every text file in the run directory is rewritten as UTF-8 with LF endings from Python (never through PowerShell redirection, which writes UTF-16LE and is rejected with a 400), then the gate scans the shipped set for absolute paths. """ import hashlib import json import os import re import subprocess import sys HERE = os.path.dirname(os.path.abspath(__file__)) TEXT_EXT = (".md", ".py", ".json", ".jsonl", ".c", ".sh", ".txt", ".out") # A drive letter not preceded by another letter (so `https://` never matches), except when the # separator is followed by an escape letter -- in served LaTeX a lone `C:\n` is an escaped newline, # which was measured, not assumed. UNC forms are not gated: they name no local user or drive. POSIX = "|".join(["/ho" + "me/", "/Us" + "ers/", "/m" + "nt/"]) ABS_DATA = re.compile(r"(?