Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ loading the delivery [commands](../src/loopzero/cli.py), which implement the con
head or an eligible review covering an ancestor, blocking findings
(unresolved threads a review publisher opened with a head-bound marker line),
target branch and required CI. The receipt must record a clean passing run
at that head with the current commands and check settings digest. A settings
at that head with the current commands and check settings digest. Ready and
merge validate the PR, head and hold before checking the local receipt.
An invalid receipt stops the command before it fetches remote readiness
evidence. Writes to advance readiness or merging recheck the receipt.
Status continues to collect all readiness diagnostics. A settings
change or an older receipt without the digest requires a fresh check. The
digest covers execution and stage reuse settings without recording raw
environment values. For local sandbox receipts it omits inherited `PATH`,
Expand Down
34 changes: 9 additions & 25 deletions src/loopzero/_proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,15 @@ def run(
stdin = input.encode(raw_encoding) if preserve_newlines and input is not None else input
try:
with subprocess.Popen(
argv,
cwd=str(cwd),
env=build_env(env_allowlist, extra_env),
stdin=subprocess.PIPE if input is not None else subprocess.DEVNULL,
stdout=subprocess.PIPE,
argv, cwd=str(cwd), env=build_env(env_allowlist, extra_env),
stdin=subprocess.PIPE if input is not None else subprocess.DEVNULL, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT if merge_output else subprocess.PIPE,
encoding=None if preserve_newlines else encoding,
errors=None if preserve_newlines else "replace",
pass_fds=pass_fds,
start_new_session=os.name == "posix",
encoding=None if preserve_newlines else encoding, errors=None if preserve_newlines else "replace",
pass_fds=pass_fds, start_new_session=os.name == "posix",
) as proc:
try:
if tail_chars is None:
stdout, stderr = proc.communicate(stdin, timeout=timeout)
else:
stdout, stderr = _read_output_tail(proc, tail_chars, timeout), ""
stdout, stderr = (proc.communicate(stdin, timeout=timeout) if tail_chars is None
else (_read_output_tail(proc, tail_chars, timeout), ""))
except BaseException:
if os.name == "posix":
with suppress(ProcessLookupError):
Expand All @@ -221,19 +214,10 @@ def run(
out = exc.stdout.decode(errors="replace") if isinstance(exc.stdout, bytes) else (exc.stdout or "")
err = exc.stderr.decode(errors="replace") if isinstance(exc.stderr, bytes) else exc.stderr
elapsed = time.monotonic() - started
raise ProcTimeout(
f"{' '.join(argv)}: timed out after {timeout:g}s\n{tail(out)}",
out,
stderr=err or "",
duration_s=elapsed,
) from exc
message = f"{' '.join(argv)}: timed out after {timeout:g}s\n{tail(out)}"
raise ProcTimeout(message, out, stderr=err or "", duration_s=elapsed) from exc
if isinstance(stdout, bytes):
stdout = stdout.decode(raw_encoding, errors="surrogateescape")
if isinstance(stderr, bytes):
stderr = stderr.decode(raw_encoding, errors="replace")
return Completed(
exit_code=proc.returncode,
stdout=stdout or "",
stderr=stderr or "",
duration_s=time.monotonic() - started,
)
return Completed(proc.returncode, stdout or "", stderr or "", time.monotonic() - started)
Loading
Loading