Skip to content

Bound standalone urllib responses by wall clock - #1837

Merged
mergify[bot] merged 1 commit into
mainfrom
lean178/1666-standalone-http-deadlines
Nov 26, 2026
Merged

mergify[bot] merged 1 commit into
mainfrom
lean178/1666-standalone-http-deadlines

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Bound standalone urllib responses by wall clock

Context and goal

  • Context: Mergify and account commands use urllib, whose socket timeout bounds inactivity.
  • Problem: An upstream can dribble bytes and keep the response open past the timeout.
  • Goal: Bound each request across headers and body, fail through the existing transport handling, and restore alarm state.

Supersedes #1776. Closes #1666.

Acceptance

  • Bound header, body and error-body reads without changing retry policy.
  • Address fallback cannot swallow the deadline, and interrupted cleanup restores the caller's handler.
  • Cover all cases without external network access.

Validation

Recorded for f10d43ca92ac

  • 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, f10d43c, approve

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

Architecture-Review: unchanged; existing main-thread urllib consumers keep their transport and failure mapping, with a per-attempt deadline.
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 f10d43ca92ac1d0b14145f3f403e41b8c5c517d3, 62.9s: 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.

Comment thread tests/test_ai_accounts.py
assert home_lock_entries == [".codex-sync.lock"] * 2


def test_provider_deadline_covers_http_error_body(helper, monkeypatch):

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: ai-accounts deadline test covers only the error body and never checks that alarm state is restored

The new ai-accounts test only covers an HTTPError body read that times out. It never checks that the SIGALRM handler and ITIMER_REAL are restored afterwards. It also doesn't cover the headers phase, the success-body phase, or an alarm that fires during the cleanup finally (setitimer(0) raising before the handler is restored). Those are exactly the paths the acceptance criteria name ('interrupted cleanup restores the caller's handler'). The Mergify test covers them for _open, but _http has its own separate implementation. Smallest fix: parametrize the test like test_request_deadline (headers/body/cleanup), and after each case assert signal.getsignal(SIGALRM) is original and getitimer(ITIMER_REAL) == (0, 0).

Comment thread src/loopzero/mergify.py
def expire(_signum, _frame):
raise _RequestDeadline()

if signal.getitimer(signal.ITIMER_REAL) != (0, 0):

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: The two copies of the deadline guard check different preconditions

ai-accounts _http refuses to start when timeout <= 0 or a timer is already armed. Mergify _open only checks for an armed timer. With timeout=0, setitimer(ITIMER_REAL, 0) disarms the timer, so the request runs without a wall-clock bound. Today the only caller uses the default of 30, so this isn't a live bug. Keeping two copies is justified because the ai-accounts script runs standalone, but they should check the same things. Add the timeout <= 0 guard to _open, or drop the parameter.

@eowca
eowca marked this pull request as ready for review November 26, 2026 11:28
@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 9f42663 at 11:34 UTC

6 min in the queue, 5 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 11:28 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1843
  • ✅ Merged 11:34 · 9f42663 · 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 9f42663 into main Nov 26, 2026
20 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1666-standalone-http-deadlines branch November 26, 2026 11:36
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 standalone urllib response reads by wall clock

1 participant