Skip to content

Compare readiness using GitHub timestamps - #1198

Closed
eowca wants to merge 4 commits into
mainfrom
lean178/1158-readiness-timestamps
Closed

eowca wants to merge 4 commits into
mainfrom
lean178/1158-readiness-timestamps

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

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 3a241dc2c18e (not current head)

  • 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

eowca and others added 2 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>

@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 3ca6df47b2adfacf0cc7969f380aeacbab10c195, 42.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:
"""`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 duplicates the _gh_json call just to avoid passing response_headers=None

api_get has two branches that differ only in whether response_headers is forwarded. _gh already ignores None through _capture_headers. The branch seems to exist only so test doubles of _gh_json that don't accept keyword arguments (e.g. tests/test_cli.py:3681) keep working. That ties production code to test mocks. Smallest fix: always call _gh_json("api", endpoint, response_headers=response_headers) and update the mock's signature to accept **kwargs.

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 on _rest_rows, _pr_reviews and _gh_json hides the only option they forward

_rest_rows, _pr_reviews (cli.py:234) and _gh_json (github.py:442) now take **kwargs just to pass response_headers through. This drops type checking, so a typo such as response_header= reaches _gh and only fails at runtime there. Smallest fix: declare an explicit keyword-only parameter response_headers: dict[str, str] | None = None on each of these functions.

Comment thread src/loopzero/cli.py
headers: dict[str, str] = {}
if reviews is None:
reviews = _pr_reviews(config.repo, pr.number)
reviews = _pr_reviews(config.repo, pr.number, response_headers=headers if workflow_wait else 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: Server Date comes from the last reviews page, and only on the wait path

Headers are captured only when workflow_wait is true, and each page overwrites the previous one, so the Date used is from the last page fetched. That is the right instant for computing age. However, review_grace on the non-wait path (ready without --wait, and cli.py:1681 where reviews are passed in) still uses local time.time(). A host clock that is behind can still make review_age negative there and withhold review_grace. If this is intended (the task scopes server time to the wait decision), a short comment at _readiness would make it explicit. Otherwise, always capture headers when reviews is None.

Architecture-Review: unchanged; the same response headers are captured during waits.
Co-Authored-By: Codex <noreply@openai.com>
@eowca
eowca force-pushed the lean178/1158-readiness-timestamps branch from f863f84 to 159b375 Compare November 26, 2026 00:22

@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 159b375905b48dcac5bdc4c632c63ee6191d45ef, 9.7s: approve (0 critical, 0 important, 1 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/cli.py
wt: Path, config: Config, pr: github.PR, head: str, reviews: list[dict] | None = None,
*, workflow_wait: bool = False, announce_receipt: bool = False,
) -> github.Readiness:
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: Refactor duplicates the headers initialisation without changing behaviour

Behaviour is the same before and after this change. In both versions headers starts as an empty dict and is filled only when _pr_reviews runs with workflow_wait. When the caller passes reviews, _review_age(review_at, headers) still receives an empty dict, so it falls back to local time as before. The only change is that headers = {} is now written in two branches, one in the if and one in the new else. That adds a line and an extra branch without making anything clearer. Smallest fix: go back to a single headers: dict[str, str] = {} before the if, or drop the commit. If the aim is to show that caller-supplied reviews have no server Date, a short comment would say that without the extra branch.

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1265, which carries the approved changes and the resolution of the conflicts with main.

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