Skip to content

feat(ci_status): resolve main HEAD sha without gh via ls-remote #178

Closed

Description

@Jammy2211

Mind prompt: draft/feature/pyautoheart/read_ci_status_head_shas_without_gh.md

Problem

heart/checks/ci_status.sh reads each repo's main HEAD sha with
gh api repos/<owner>/<name>/commits/main --jq .sha. On a mobile/cloud session
gh is not installed, so the sha comes back empty. Readiness then cannot confirm
an ingested release-validation report against the live HEADs and reports
release validation source unconfirmed (current HEADs unknown).

Observed 2026-08-25 in a cloud session: all three named evidence gaps were
cleared (test-run verdict, install verification, release validation), yet
readiness stayed STALE on this reason alone.

High-level plan

  1. Extract HEAD-sha resolution out of check_one_repo_ci into a named shell function.
  2. Try gh first — unchanged dev-box behaviour, and the only source that works for a private repo — then fall back to anonymous git ls-remote.
  3. Bound the fallback with a timeout and disable credential prompting, so it can never hang the <30s tick.
  4. Return empty on failure exactly as today; never a fabricated sha.
  5. Add unit coverage for the new function with stubbed gh/git.
  6. Confirm readiness stops emitting release validation source unconfirmed in a gh-less session.

Detailed plan

heart/checks/ci_status.sh — add ci_head_sha <owner/name> above
check_one_repo_ci; replace the inline gh api .../commits/main (line 47) with
a call to it. The gh path stays guarded by command -v gh; the fallback is
GIT_TERMINAL_PROMPT=0 timeout 10 git ls-remote "https://github.com/$owner_name" refs/heads/main,
taking field 1 of the first line.

tests/test_ci_status_script.py (new) — follows the existing
tests/test_verify_install_script.py precedent: source the shell file, invoke
the single function, stub gh/git via a temp dir placed first on PATH.
Cases: gh succeeds → gh's sha and no fallback; gh absent → ls-remote's sha;
both fail → empty; fallback stalls → empty within the timeout.

Key trade-offs

  • gh first, not ls-remote first. Preserves dev-box behaviour
    byte-for-byte and keeps private repos working — anonymous ls-remote would
    fail on those. Cost: the mobile path is only exercised where it is needed.
  • Hard-coded https://github.com/<owner/name>. config/repos.yaml carries
    owner/name, not URLs. Fine today since every polled repo is GitHub, but it is
    an assumption worth naming.
  • timeout 10 so that even if all ~20 parallel fallbacks stall, the tick
    stays inside its budget.

Why this works standalone

build_sidecar writes head_sha unconditionally (heart/checks/ci_status.py:274),
independent of the runs fetch error. So supplying a real sha reaches readiness
even while the runs fetch still fails: the CI row keeps reading unavailable,
but the release gate can confirm commit_shas.

The CI conclusions half needs the Actions API and is tracked separately as
draft/feature/pyautoheart/feed_ci_status_run_conclusions_from_an.md.

Acceptance

  • With gh absent, pyauto-heart tick records a real head_sha for each polled
    repo and readiness no longer emits release validation source unconfirmed (current HEADs unknown).
  • The tick stays inside its <30s budget.
  • A failed ls-remote still yields an empty sha, not a wrong one.

Activity

  1. Jammy2211 commented on Aug 25, 2026

    @Jammy2211
    ContributorAuthor

    Shipped in #180 (merged as a570d0a).

    ci_head_sha now keeps gh first and falls back to an anonymous git ls-remote, which needs neither authentication nor a session repo attachment.

    Verified in a gh-less container: 25 repos scanned in 3.3s, all five release-gate libraries resolving their real shas, and readiness no longer emitting release validation source unconfirmed (current HEADs unknown) — it advances to the next condition in the same chain.

    Two things worth recording beyond the original plan:

    • Portability. timeout is coreutils, so a macOS box without gh would have lost the fallback silently — or worse, run ls-remote unbounded inside the tick. It now resolves timeout/gtimeout once and skips the fallback when neither exists, since a stalled ls-remote is a worse failure than the empty sha that is already today's answer.
    • CI caught a real defect, not a flake: the new test defaulted its repo argument to a real owner/name, which the tenant-firewall check correctly rejected for an unlisted organ file. Genericised rather than allowlisted — gh and git are both stubbed in that test, so a real repo string bought nothing.

    Generated by Claude Code

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