Skip to content

Compare readiness using GitHub timestamps - #1583

Closed
eowca wants to merge 15 commits into
mainfrom
lean178/1158-readiness-fresh-review
Closed

eowca wants to merge 15 commits into
mainfrom
lean178/1158-readiness-fresh-review

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #1841 after conflicts with current main. The replacement rejects malformed HTTP Dates and preserves sub-microsecond ordering for check runs and commit statuses. It carries both fixes into a fresh primary review.

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 #1453 and preserves its reviewed commits. Main added an in-process GitHub replay fixture in #1521. The merge keeps that fixture on the expanded freshness matrix. All 66 freshness cases passed after resolving the conflict. The run-selection change in #1508 follows this PR.


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

Review

  • primary, claude, 69d7b87, approve
  • delta, codex, b072ab1, request_changes

Validation

Recorded for 69d7b878b366

  • 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

eowca and others added 13 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>
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the short wait requires trustworthy timestamps while required check verdict selection stays the same.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the conflict resolution only restores an existing test fixture.

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 69d7b878b3664cab753664316d8b2ce59def17c2, 32.6s: 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 Outdated
def api_get(endpoint: str) -> object:
def api_get(endpoint: str, *, response_headers: dict[str, str] | None = None) -> object:
"""`gh api <endpoint>` parsed as JSON (None on an empty body)."""
if response_headers is not 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: api_get has a redundant branch for response_headers

_gh_json and _gh both default response_headers to None. So return _gh_json("api", endpoint, response_headers=response_headers) behaves the same whether or not headers were requested, and the if response_headers is not None branch only duplicates the call. If the branch exists so that test fakes with a narrower _gh_json signature keep working, add a comment that says so. Otherwise, collapse it into one call.

Comment thread src/loopzero/cli.py
) -> github.Readiness:
if hold := github.merge_hold(pr.number, pr.labels):
return github.Readiness(False, (hold,))
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: The headers setup in _readiness could be simpler

headers is declared in both arms of the if/else, and _rest_rows/_pr_reviews pass an untyped **kwargs through to api_get. Two smaller options: declare headers: dict[str, str] = {} once before the if reviews is None check, and give _rest_rows/_pr_reviews an explicit response_headers: dict[str, str] | None = None parameter instead of **kwargs. That keeps the plumbing type-checked and removes the duplicated else arm. Behaviour stays the same.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Disposition of the two suggestions on 69d7b878b366: defer simplifying the api_get response-header branch and the readiness header setup. Both are readability changes, and the approval identified no behavior defect. This replacement is limited to carrying the reviewed behavior across the base conflict.

Architecture-Review: unchanged; the conflict resolution preserves the imports required by both test changes.

Co-Authored-By: Codex <noreply@openai.com>
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 b072ab156de4e0fd6ce9ab318006387766264281, 50.1s: request_changes (0 critical, 2 important, 0 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: e4ddf9215be1234cd2bf885198300d673bbf5052cb787d8b55bfd478baa33821

Comment thread src/loopzero/github.py

def response_date(value: str) -> datetime | None:
with suppress(OverflowError, ValueError):
stamp = parsedate_to_datetime(value)

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: Validate the HTTP Date before using it for review age

parsedate_to_datetime accepts malformed values such as Wed, 23 Sep 2026 12:00:05 +0060 and interprets the offset as one hour. For a review at 12:00:00Z, the computed age is −3595 seconds, so the wait exits immediately even when the local fallback would give an age of five seconds. Validate the complete HTTP Date value before trusting it and add this case to the existing invalid-Date test.

Comment thread src/loopzero/github.py
raise _not_found(number, exc) from exc


_READINESS_TIMESTAMP = re.compile(r"[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\.[0-9]+)?"

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: Preserve fractional precision when ordering verdicts

The pattern accepts arbitrary fractional precision, but datetime.fromisoformat truncates to six digits. A check failure at 12:00:00.1234561Z and a review at 12:00:00.1234569Z therefore compare equal, ending the wait even though the failure predates the review. Preserve the sub-microsecond remainder for ordering both check runs and commit statuses, and cover this pair in the freshness test.

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