chore(storage): bound build retention, caches and test resources
Track build ownership, qualified pins and bounded cache/log lifecycles. Move Vite fixtures to a job-owned server helper and preserve private outputs outside Git.
This commit is contained in:
@@ -31,3 +31,61 @@ def prepare_launchd_log(path: Path) -> None:
|
||||
os.fchmod(descriptor, 0o600)
|
||||
finally:
|
||||
os.close(descriptor)
|
||||
|
||||
|
||||
def bounded_launchd_output(document: dict, repository: Path, *, uv_path=None) -> dict:
|
||||
"""Preserve a declared command behind a single bounded output owner.
|
||||
|
||||
uv is the accepted Mac privacy execution boundary for this checkout. Its
|
||||
bootstrap output is discarded; child output and tracebacks go to the owned
|
||||
journal. launchd still owns the full process group and the original policy.
|
||||
"""
|
||||
result = dict(document)
|
||||
arguments = list(result["ProgramArguments"])
|
||||
if "k1link.rotating_process" in arguments:
|
||||
service_command(result) # Validate the existing owner instead of nesting wrappers.
|
||||
result["StandardOutPath"] = result["StandardErrorPath"] = "/dev/null"
|
||||
return result
|
||||
journal = result.get("StandardErrorPath") or result.get("StandardOutPath")
|
||||
if not journal or journal == "/dev/null":
|
||||
raise ValueError("An explicit service journal is required")
|
||||
path = Path(journal)
|
||||
if not path.is_absolute() or path.suffix != ".log":
|
||||
raise ValueError("Invalid service journal")
|
||||
# Legacy output is kept intact. Fresh managed generations alone rotate.
|
||||
managed = path.with_name(path.stem + ".managed.log")
|
||||
result["ProgramArguments"] = [
|
||||
str(uv_path or "/opt/homebrew/bin/uv"),
|
||||
"run",
|
||||
"--no-sync",
|
||||
"--project",
|
||||
str(repository),
|
||||
"python",
|
||||
"-m",
|
||||
"k1link.rotating_process",
|
||||
"--log",
|
||||
str(managed),
|
||||
"--",
|
||||
*arguments,
|
||||
]
|
||||
result["StandardOutPath"] = result["StandardErrorPath"] = "/dev/null"
|
||||
return result
|
||||
|
||||
|
||||
def service_command(document: dict) -> list[str]:
|
||||
arguments = list(document["ProgramArguments"])
|
||||
if "k1link.rotating_process" in arguments:
|
||||
index = arguments.index("k1link.rotating_process")
|
||||
if arguments[index + 1 : index + 2] != ["--log"] or arguments[index + 3 : index + 4] != [
|
||||
"--"
|
||||
]:
|
||||
raise ValueError("Invalid managed journal command")
|
||||
return arguments[index + 4 :]
|
||||
return arguments
|
||||
|
||||
|
||||
def service_log_path(document: dict) -> Path:
|
||||
arguments = document["ProgramArguments"]
|
||||
if "k1link.rotating_process" in arguments:
|
||||
return Path(arguments[arguments.index("k1link.rotating_process") + 2])
|
||||
return Path(document["StandardErrorPath"])
|
||||
|
||||
Reference in New Issue
Block a user