Skip to content

Bound standalone urllib response reads by wall clock - #1776

Closed
eowca wants to merge 3 commits into
mainfrom
lean178/1666-bounded-waits
Closed

eowca wants to merge 3 commits into
mainfrom
lean178/1666-bounded-waits

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Bound standalone urllib response reads by wall clock

Context and goal

  • Context: Standalone Mergify and optional account requests use urllib, whose socket timeout limits inactivity.
  • Problem: A server can keep a request open indefinitely by dribbling response headers or body bytes.
  • Goal: Enforce the existing per-request wall-clock budget on the CLI main thread and keep the current transport failure mapping.

Closes #1666

Acceptance

  • The deadline spans headers, error bodies, and success bodies that callers read.
  • A timed-out request fails closed and restores the main thread's previous alarm handler.
  • Test headers and bodies offline. Keep retries, endpoints, and request identity unchanged.

Validation

(no loopzero check run recorded)

Review

  • primary, codex, 04a8622, request_changes

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

Superseded by #1837, merged as 9f42663a. #1666 is closed.

eowca and others added 2 commits November 26, 2026 10:04
Architecture-Review: unchanged; the existing HTTP requests retain their endpoints, credentials, and failure paths while using an attempt-wide deadline.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; restore main Mergify test setup and retain the separate deadline regression.
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 codex on 04a8622008c199bd00c17c7f7c2fe06e9a265160, 87.7s: request_changes (0 critical, 2 important, 1 suggestion)

Same-family fallback: independent reviewers failed: claude: not authenticated. Cross-family review is preferred.

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

  • Call 1: requested model gpt-6.2-astra (effort medium); CLI-reported model gpt-6.2-astra (effort medium); configured model gpt-6.2-astra (effort medium)
Raw reviewer output
Native Codex transcript retained in the restricted local review receipt; public evidence is publisher-derived, not backend attestation. Exact raw SHA256: 7c95919f78d13ac4e35f68b9f80d0389a07e7e683abdd84cf9aa539dd48e8411

Comment thread src/loopzero/mergify.py Resolved
Comment thread src/loopzero/mergify.py Resolved
Comment thread tests/test_mergify.py
pytest.raises(TimeoutError, match="Mergify HTTP request timed out"),
mergify._open(urllib.request.Request("https://example.invalid")),
):
expire()

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: Exercise the success-body read through api_get

The body case raises the signal directly inside _open without reading the response. It would still pass if api_get moved json.load outside the deadline. Have the fake response raise the signal from read() and call api_get with retry sleeps stubbed out. That also checks the transport error seen by the caller.

Architecture-Review: unchanged; retain the existing wait and failure interfaces while covering their boundary cases.
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 codex on 7147cfa9e8fe37a52d6da53308090287482e2a89, 74.7s: approve (0 critical, 0 important, 1 suggestion)

Same-family fallback: independent reviewers failed: claude: not authenticated. Cross-family review is preferred.

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

  • Call 1: requested model gpt-6.2-astra (effort medium); CLI-reported model gpt-6.2-astra (effort medium); configured model gpt-6.2-astra (effort medium)
Raw reviewer output
Native Codex transcript retained in the restricted local review receipt; public evidence is publisher-derived, not backend attestation. Exact raw SHA256: e771d9d43c39d319b712033cd8ba08f4af37a8f17a3dfcf426a0da4598fd6418

Comment thread tests/test_mergify.py



def test_request_deadline_stops_address_fallback(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: Exercise both deadline regressions through the account helper

The address-fallback and interrupted-disarm tests both exercise mergify._open. The standalone account _http implements the same logic independently. Its existing error-body test would still pass if address fallback swallowed its timeout or an interruption during disarming left its handler installed. Reuse the two offline scenarios against _http, checking the attempted addresses and restored handler.

@eowca

eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor Author

The 60-line reserve was released after #1731 merged. At main a31a2b0f, #1795 makes #1776 fit the test cap, but the approved head conflicts with its changes in tests/test_mergify.py.

Local resolution b8b9fab2a439bc963a6a7e96b79783bd6f17f6db preserves both sets of tests. Focused Mergify and account tests pass. The resolution measures 13,833 test lines of 13,850 and 8,277 source lines of 8,250. It would need review coverage for the conflicted merge and 27 more source lines of headroom.

The approved remote head remains 7147cfa9e8fe37a52d6da53308090287482e2a89. #1666 remains open.

After #1790 landed, a second test-placement conflict appeared in tests/test_ai_accounts.py. Local resolution 76924f5ab4c0e686ccfe1e1d275ff18e0478aa0c preserves both changes at main 40fab657. It passes 197 focused tests and measures 13,898 test lines and 8,269 source lines, 48 and 19 above their caps respectively. The approved remote head is unchanged.

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