Skip to content

Compare readiness run selection and workflow replacement timestamps as instants #1462

Done

Description

@eowca

Readiness compares raw GitHub timestamp strings when two check-run rows have the same numeric ID (or both lack IDs) and when it looks for active workflow replacements. These comparisons can disagree with UTC instant order.

Offline reproduction on b02dc561 from #1453:

from unittest.mock import patch
from loopzero import github

head = "a" * 40
runs = [
    dict(id=7, name="checks", started_at="2026-09-23T12:00:00Z", conclusion="success"),
    dict(id=7, name="checks", started_at="2026-09-23T12:00:00.250Z", conclusion="failure"),
]
with patch.object(github, "_paged", side_effect=[runs, []]):
    print(github._check_signals("example/repo", head)[0])
# Actual: {"checks": "success"}. The newer row in this replay is the failure.

check = {"check_suite": {"id": 2}, "completed_at": "2026-09-23T12:00:00Z"}
rerun = dict(id=7, check_suite_id=2, head_sha=head, workflow_id=1, status="in_progress",
             run_attempt=2, run_started_at="2026-09-23T12:00:00.250Z")
print(github._has_active_replacement("example/repo", check, [rerun], head))
# Actual: False. The retry started 250 ms after the failed check completed.

The first result can let the required check pass readiness even though the newer row failed. The replay establishes the behavior if conflicting rows reach the selector. It does not establish how often GitHub delivers such rows. The second result can stop a readiness wait early even though a replacement is active. The replacement branch also orders workflow creation timestamps as strings.

Review the readiness policy in docs/ARCHITECTURE.md before changing which verdict wins. The change needs an explicit decision and tests for same-ID or missing-ID rows, equivalent offsets, malformed timestamps, and the existing numeric-ID precedence. #1453 leaves these selection rules unchanged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions