Skip to content

Bound Git subprocesses in architecture checks and source builds - #1697

Merged
mergify[bot] merged 3 commits into
mainfrom
lean178/1664-bound-build-git
Nov 26, 2026
Merged

mergify[bot] merged 3 commits into
mainfrom
lean178/1664-bound-build-git

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Bound Git subprocesses in architecture checks and source builds

Context and goal

  • Context: The architecture script and sdist build hook call Git directly and can run outside the delivery sandbox.
  • Problem: If Git never returns, both direct entry points wait indefinitely.
  • Goal: Use the existing 60-second Git operation budget and report a timeout through each command's error path.

Closes #1664

Acceptance

  • The two direct Git invocations have an operation timeout.
  • A stalled local Git shim triggers a timeout in both call paths without live network access.
  • Validating architecture and building an sdist on a normal checkout still work.

Base

main @ bf1002c

Validation

Recorded for 14d51707c4f7

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Review

  • primary, claude, 121c081, request_changes

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Architecture-Review: unchanged; Git commands retain their existing outputs and fail through the current check when Git times out.
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero primary review by claude on 121c081cd0ed1ec6c0eaaf35c0b6308c7c096909, 22.2s: request_changes (0 critical, 1 important, 1 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread hatch_build.py Resolved
Comment thread hatch_build.py
return

tracked = subprocess.check_output(["git", "ls-files", "-z"], cwd=root)
tracked = subprocess.check_output(["git", "ls-files", "-z"], cwd=root, timeout=60)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Duplicated 60 s literal instead of a named budget

The task asks for the existing 60-second Git budget (GIT_TIMEOUT in src/loopzero/cli.py:34 and src/loopzero/sandbox.py:29). These standalone entry points can't reasonably import loopzero, so copying the value is understandable. However, hatch_build.py:16 and scripts/check_architecture_docs.py:27 each use a bare 60. A module-level GIT_TIMEOUT = 60 in each file would make the shared budget easy to find, and tests could patch it (see the testing finding).

Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero delta review by claude on 90054edc59aa2a9cdd15c8f0d9603d569c2da931, 19.3s: approve (0 critical, 0 important, 2 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.


@pytest.mark.parametrize("entry", ["architecture", "sdist"])
def test_direct_git_timeout(tmp_path, monkeypatch, capsys, entry):
def stalled_git(argv, *, timeout, **kwargs):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Test replaces subprocess.run, so it never runs a stalled Git shim

The acceptance criteria ask for "a stalled local Git shim" that triggers the timeout. This test instead monkeypatches subprocess.run to raise TimeoutExpired right away. It does check that timeout=60 reaches subprocess.run, including through check_output in hatch_build.py:16, and that main() and the hook surface the timeout on their error paths. It never runs a real process, though, so it would not catch a Git call that skips subprocess.run (for example Popen or os.system) or a timeout that fails to kill the child. Smallest fix: keep the mock-based assertions and add one case that puts a git script running sleep first on PATH, then patches the 60-second constant or wraps subprocess.run to pass a short timeout. If the mock is the intended level of coverage, reword the acceptance item to match.

assert run(git_repo, "not-a-revision").returncode == 1


@pytest.mark.parametrize("entry", ["architecture", "sdist"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: One parametrized test covers two unrelated entry points through an if/else

Each entry value runs a completely different body, and the sdist hook test sits in the architecture-docs test module. Two plain test functions, test_architecture_git_timeout and test_sdist_hook_git_timeout, would be easier to read and would make failures clearer. They could share the stalled_git fake as a fixture. This is only a structural cleanup.

@eowca
eowca marked this pull request as ready for review November 26, 2026 09:34
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 4c5e340 at 09:40 UTC

4 min in the queue, 3 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 09:35 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1768
  • ✅ Merged 09:40 · 4c5e340 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 4c5e340 into main Nov 26, 2026
13 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1664-bound-build-git branch November 26, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bound Git subprocesses in architecture checks and source builds

1 participant