Skip to content

Retry safe GitHub observations once within their budget - #1560

Merged
mergify[bot] merged 21 commits into
mainfrom
lean178/1502-safe-observation-retry
Nov 26, 2026
Merged

mergify[bot] merged 21 commits into
mainfrom
lean178/1502-safe-observation-retry

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Context and goal

Use one backed-off retry for safe reads and idempotent thread resolution. Keep review read-back within its original deadline and preserve throttle diagnostics.

Closes #1502.

Validation

Recorded for 6ac05fda4af5

  • 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

GitHub transport, review recovery, and finding-resolution replays passed. Source +19 lines, tests −1.


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

Review

  • primary, claude, c1d8bb7, request_changes
  • delta, claude, 6ac05fd, approve

eowca and others added 18 commits November 26, 2026 04:31
Architecture-Review: unchanged; remains fail-closed while trusted evidence is unavailable, with the same status context and publisher.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; remains fail-closed while trusted evidence is unavailable, with the same status context and publisher.
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; evidence and publication failures remain distinguishable within the existing hosted trust boundary.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; transient fetch diagnostics remain inside the existing isolated checkout.
Co-Authored-By: Codex <noreply@openai.com>
…e-observation-retry

# Conflicts:
#	src/loopzero/github.py
#	src/loopzero/hosted.py
#	tests/test_hosted.py
Architecture-Review: unchanged; hosted eligibility still requires verified Git objects before accepting inherited evidence.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; remains fail-closed while trusted evidence is unavailable, with the same status context and publisher.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; evidence and publication failures remain distinguishable within the existing hosted trust boundary.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; transient fetch diagnostics remain inside the existing isolated checkout.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; hosted eligibility still requires verified Git objects before accepting inherited evidence.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the evidence outcome changes while the existing retry and wait behavior remains in force until #1502.
Co-Authored-By: Codex <noreply@openai.com>
…safe-observation-retry

# Conflicts:
#	src/loopzero/github.py
#	src/loopzero/hosted.py
#	tests/test_hosted.py
@eowca
eowca changed the base branch from lean178/1497-eligibility-outages to lean178/1497-eligibility-outages-v2 November 26, 2026 07:27
@eowca
eowca deleted the branch lean178/1497-eligibility-outages-v2 November 26, 2026 07:38
@eowca eowca closed this Nov 26, 2026
eowca and others added 2 commits November 26, 2026 08:38
…ervation-retry

# Conflicts:
#	src/loopzero/github.py
#	tests/test_hosted.py
Co-Authored-By: Codex <noreply@openai.com>
@eowca eowca reopened this Nov 26, 2026
@eowca
eowca changed the base branch from lean178/1497-eligibility-outages-v2 to main November 26, 2026 07:40

@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 c1d8bb702d1a23abad48c2ac08a81b43faea5800, 79.1s: request_changes (0 critical, 1 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 src/loopzero/github.py Resolved
Comment thread src/loopzero/github.py Outdated
tail = "\n".join(part for part in (done.stderr, body) if part)
if done.exit_code and _rate_limited(status, headers, tail):
guidance = (_redact_tokens(_rest_rate_limit(headers), selected) if rest_api
if _retry_pause(_rate_limit_delay(headers, delay), timeout):

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: Rate-limit diagnostics are lost when the retry check finds the deadline already passed

In a retry scope, a secondary-limit response with Retry-After goes to _retry_pause(_rate_limit_delay(...)), which calls _read_timeout(limit). If the response arrives at or after the deadline, _read_timeout raises ReadDeadline before the code builds the _rest_rate_limit guidance. The status, X-RateLimit-* and Retry-After evidence are then dropped, and cli.py:1333 reports a plain timeout. The transient path at line 402 has the same issue: a 5xx with a request ID becomes a bare ReadDeadline. That conflicts with "retain GitHub diagnostics". Smallest fix: in _retry_pause, treat an exhausted budget as "no retry" by catching ReadDeadline and returning False, so the usual rate-limit or transient error is raised with its detail.

Comment thread src/loopzero/github.py
message_tail=None if diagnostic_api else tail)
raise GhUnavailable(("GitHub API request",), detail, token=selected, guidance=guidance)
raise GhUnavailable(argv, tail, token=selected, guidance=guidance)
raise GhUnavailable(("gh", *args), tail, token=selected, guidance=guidance)

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: Rate-limit guidance says "No automatic retry" even when a retry was attempted, and the error argv differs from the general error path

_rest_rate_limit still ends with "No automatic retry.". After this change a secondary limit may already have been retried once after Retry-After, so the message is misleading. Also, the rate-limit raise now uses ("gh", *args) without --include, but the general error path at line 405 still reports argv, which includes --include. The same request is therefore described differently depending on the failure type. Consider rewording the guidance (for example, "retry once honored" / "not retried: delay exceeds budget") and using one command representation in both raise sites.

Architecture-Review: unchanged; scoped deadlines are still applied only to reads, and non-idempotent writes keep their original outcomes.
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 6ac05fda4af5301a0f3a7ed62fa78f4705271d83, 40.1s: 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 src/loopzero/github.py
if scope and scope[2]:
_read_timeout(timeout)
if delay is None or not retryable:
_read_timeout(timeout, scoped=bool(scope and scope[2]))

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: Post-timeout deadline check now differs from the run-timeout clamp in non-retry read scopes

The timeout passed to run is clamped with scoped=read_only (line 376), so the shared deadline still limits reads inside bounded_reads(..., retry=False). But after a ProcTimeout, the check uses scoped=bool(scope and scope[2]). When such a read times out past the deadline, it now raises a plain ProcTimeout. Before this change it raised ReadDeadline. No production code hits this today: both bounded_reads callers (cli.py:916 and cli.py:1328) pass retry=True. Still, the code now uses two different rules for 'does the deadline apply', and they could drift apart. The smallest fix is scoped=read_only on line 381, the same rule as lines 376, 382, 392 and 402. Writes would still skip the check, because scope is None for them. Alternatively, add a comment explaining why non-retry scopes should surface a raw ProcTimeout.

monkeypatch.setattr(github.time, "monotonic", lambda: 10.0 + sum(sleeps) + int(failure == "write" and bool(timeouts)))
error = github.GhError if failure == "transient" else _proc.ProcTimeout
with pytest.raises(error), github.bounded_reads(10 + budget, retry=True):
github.mark_ready("acme/widgets", 7) if failure == "write" else github.api_get("repos/acme/widgets/pulls/7/reviews")

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 new 'write' case covers only the ProcTimeout path, not the scoped=read_only changes to _retry_pause

mark_ready is a non-idempotent write, so it gets delays=(None,) and _retry_pause returns before it reads the scope. The case does catch the line-381 regression: before the fix it would have raised ReadDeadline instead of ProcTimeout. But the scoped=read_only edits at lines 382, 392 and 402 only change behaviour for retry_idempotent writes (thread resolution) inside a bounded_reads scope, and nothing tests that. No caller combines the two today, so this isn't blocking. Also, the monotonic lambda that leans on bool(timeouts) is hard to read. A named clock stub would make it clearer without adding test lines.

@eowca
eowca marked this pull request as ready for review November 26, 2026 08:33
@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 4ae0c02 at 08:38 UTC

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

So far

  • ✅ Entered the queue Thu 26 Nov, 08:34 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1716
  • ✅ Merged 08:38 · 4ae0c02 · 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

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 4ae0c02 into main Nov 26, 2026
17 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1502-safe-observation-retry branch November 26, 2026 08:39
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.

Apply the single-retry policy to safe GitHub observations

1 participant