Skip to content

Compare readiness using GitHub timestamps - #1265

Closed
eowca wants to merge 6 commits into
mainfrom
lean178/1158-readiness-replacement
Closed

eowca wants to merge 6 commits into
mainfrom
lean178/1158-readiness-replacement

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Compare readiness using GitHub timestamps

Context and goal

  • Goal: Readiness waits compare UTC instants and use GitHub server time for review age.
  • Problem: Fractional and offset review timestamps could crash parsing, a same-second newer failure could look stale, and a slow host clock could end a wait early.
  • Context: Required checks must pass before readiness succeeds. Freshness determines how long the command waits for a replacement verdict.

Closes #1158
Closes #1159

Acceptance

  • UTC, fractional UTC and explicit-offset timestamps are accepted. Failures at or after the review do not qualify as stale, including equal instants with different offsets.
  • Missing, malformed and naive timestamps do not grant stale-verdict grace.
  • The same server timeline waits for a replacement of a pre-review failure across local clock offsets, including a host 40 seconds behind.
  • Old reviews remain outside grace. A missing or unusable Date uses the existing bounded local fallback. Readiness still requires passing checks.

Notes

  • Supersedes Compare readiness using GitHub timestamps #1198. Carries the approved diff from da40f81f2042 plus the merge resolution in the CLI tests.
    GitHub server time affects the wait decision only. The existing review criteria, check requirements, grace durations and monotonic wait budget remain in place.

  • Pre-fix replay: fractional review timestamps and the host clock behind by 40 seconds both returned exit 1. The focused post-fix matrix passed 28 cases.

Base

main @ 5137bf0

Validation

Recorded for 34889c3445ff

  • 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

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

Review

  • primary, claude, 2479b47, approve
  • delta, claude, 861dda1, request_changes

eowca and others added 5 commits November 26, 2026 01:02
Architecture-Review: unchanged; freshness still governs waiting while the existing checks and eligible review govern readiness.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the conflict resolution combines imports for review reservation and timestamp parsing.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the same response headers are captured during waits.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the resolution preserves both branches’ CLI tests.
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 2479b47922e224f580ef4e2f4820d91dec9d5800, 28.5s: approve (0 critical, 0 important, 3 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


def api_get(endpoint: str) -> object:
def api_get(endpoint: str, *, response_headers: dict[str, str] | None = None) -> object:

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: api_get branches on response_headers when it could just pass it through

api_get only passes response_headers to _gh_json when it is not None. _gh already treats None as "don't capture", via _capture_headers. That makes the branch redundant, and it adds a second call path to keep in sync. Smallest fix: replace both lines with a single return _gh_json("api", endpoint, response_headers=response_headers).

Comment thread src/loopzero/cli.py


def _rest_rows(endpoint: str, what: str) -> list[dict]:
def _rest_rows(endpoint: str, what: str, **kwargs) -> list[dict]:

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: Untyped kwargs passthrough in _rest_rows/_pr_reviews

_rest_rows and _pr_reviews forward bare **kwargs to github.api_get. The only option they actually forward is response_headers, and the bare **kwargs hides that from type checkers and readers. Smallest fix: declare the parameter explicitly as *, response_headers: dict[str, str] | None = None in both functions. That is the same signature api_get and _gh_json use.

Comment thread src/loopzero/cli.py
@@ -294,25 +305,26 @@ def _readiness(
reason = f"PR #{pr.number} {github.MERGE_HOLD_MESSAGE}"
return github.Readiness(ready=False, reasons=(reason,))
if reviews is None:

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: Header dict setup split across if/else

headers is assigned in both branches, and the first branch then passes headers if workflow_wait else None. It is simpler to write headers: dict[str, str] = {} once before the if reviews is None: check and keep the conditional pass-through. Behaviour stays the same and the block loses three lines.

eowca added a commit that referenced this pull request Nov 26, 2026
@eowca
eowca marked this pull request as ready for review November 26, 2026 02:54
@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

⏳ Waiting for queue conditions

Queue rule main · nothing left

Queue rule main: 10 met
  • -closed
  • -conflict
  • -draft
  • any of:
    • -mergify-configuration-changed
    • check-success = @mergify/Configuration changed
    • check-success = @mergify/Configuration has been deleted
  • -label = hold
  • base = main
  • check-success = Loop-zero Eligibility
  • 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
@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

❌ Left the queue · checks fails with this pull request

5 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 02:56 · rule main · triggered by a @mergifyio queue command
  • ❌ Checks failed · draft #1445
  • 🚫 Left the queue 03:01 · 34889c3

The failure is in this pull request. It failed tested alone on top of main.

Reason

The merge conditions cannot be satisfied due to failing checks

  • checks

Failing checks:

To get back in the queue

  • Push a fix: the pull request is queued again once its queue conditions match.
  • If the failure is a flake, comment @mergifyio queue to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-neutral = checks
    • check-skipped = checks
    • check-success = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility
    • check-success = Loop-zero Eligibility
1 merge condition met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required

Times in UTC · dashboard · how the merge queue works

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

Co-Authored-By: Codex <noreply@openai.com>
@eowca
eowca force-pushed the lean178/1158-readiness-replacement branch from 34889c3 to 861dda1 Compare November 26, 2026 03:05

@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 861dda106e6ed9f6b1275e284678454a029f8ebf, 19.8s: request_changes (0 critical, 1 important, 0 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_cli.py
failed_at = {
"tie": "2026-09-23T12:00:00Z",
"missing": None,
"fractional-newer": "2026-09-23T12:00:00.250Z",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

important: Refactor drops the only sub-second staleness check

This delta removes "fractional-review": "2026-09-23T12:00:00.000Z" from failed_at. The parametrize row (False, 5, "fractional-review", True, 0, True) at line 2723 is still there, so its failure time now falls back to 2026-09-23T11:59:59Z. That is a full second before the review at 12:00:00.125Z.

Before this change, the case checked that a failure 125 ms before the review counts as stale. An implementation that drops the fractional part would see 12:00:00 vs 12:00:00, treat it as a tie, return exit 1, and fail the test. With the fallback value, that implementation now passes.

fractional-newer (review 12:00:00Z, failure 12:00:00.250Z) does not cover this either: truncation also gives the expected not-stale result there. After this change, no case in the matrix detects lost sub-second precision, even though the task's acceptance and problem statement cover fractional and same-second instants.

The commit is described as a fixture reuse, so the lost coverage is easy to miss. Smallest fix: restore the "fractional-review": "2026-09-23T12:00:00.000Z" entry in failed_at. The other changes in this delta keep behavior the same: the runs/statuses rewrite matches the old conditional expressions, and formatdate(server_now, usegmt=True) gives the same output as the old format_datetime call.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1453. That head restores the 125 ms stale-verdict assertion identified in review and keeps the test delta at zero lines.

@eowca eowca closed this Nov 26, 2026
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.

Use GitHub server time for review freshness during readiness waits Parse and compare GitHub readiness timestamps as UTC instants

1 participant