Skip to content

feat(ci_status): a no-gh path for HEAD shas and run conclusions - #180

Merged
Jammy2211 merged 3 commits into
mainfrom
claude/heart-evidence-gaps-6svdjk
Aug 25, 2026
Merged

Jammy2211 merged 3 commits into
mainfrom
claude/heart-evidence-gaps-6svdjk

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Gives ci_status a working path on a mobile/cloud session, where gh is not installed at all.

Closes #178
Closes #179

Why

A cloud /health run cleared all three named evidence gaps — test-run verdict, install verification, release validation — and readiness still reported STALE on six reasons. Every one of them traced to the same cause: no gh in the session container, so ci_status could not run. Five CI status unavailable rows, plus release validation source unconfirmed (current HEADs unknown) blocking the release gate.

gh is only transport here. The judgment already lives in heart/checks/ci_status.py, which reads a REST-shaped {"workflow_runs": [...]} payload from stdin plus a --head-sha argument. Nothing needed reimplementing; something needed re-plumbing.

Two halves, deliberately split

They have genuinely different costs, and the cheaper one buys more.

3f57cfd — HEAD shas (#178). ci_head_sha keeps gh first (unchanged dev-box behaviour, and the only source that can read a private repo) and falls back to an anonymous git ls-remote. That needs no authentication and no session repo attachment, so it works exactly where gh cannot. On its own it clears the reason blocking the release gate.

d29fe7d — run conclusions (#179). A per-repo drop point at $HEART_STATE_DIR/cloud_ci/<Name>.json, populated by Brain via MCP, consulted only when the live fetch has already failed. Mirrors test_run.py's proven cloud_validation.json hand-off rather than inventing a second idiom — MCP's list_workflow_runs already returns the exact shape normalize_runs expects, so nothing is reshaped on the way in.

Keeping it inside the tick budget

  • The tick does no network work for the drop point — it only reads it, as it already reads cloud_validation.json. Population is a separate one-shot leg. This is the decision that matters most; per-repo network calls inside the tick loop would blow the <30s budget outright.
  • No MCP round trip for the sha. ls-remote is one cheap ref read that slots into the existing parallel fan-out.
  • The ls-remote fallback is bounded. GIT_TERMINAL_PROMPT=0 stops a private repo blocking on a credential prompt, and timeout caps a stalled connection. timeout is coreutils, so it resolves to timeout/gtimeout once at source time; where neither exists (stock macOS) the fallback is skipped rather than run unbounded — a stalled ls-remote inside the tick is worse than the empty sha that is already today's answer.
  • The drop point is age-bounded (HEART_CLOUD_CI_MAX_AGE, default 3600s). Past it, it degrades to the same unavailable a failed fetch produces, never a stale green.

Behaviour on the dev box is unchanged

Both legs are strictly fallbacks behind a successful gh. Where gh works, error is empty and neither new path executes.

Failure never fabricates: an unresolvable sha stays empty, and a rejected drop point appends its reason to the original fetch error rather than vanishing. New source field on the sidecar ("gh" | "cloud") records provenance — a reader must be able to tell a conclusion Heart fetched itself from one an agent handed it.

Verification

635 tests pass, 13 new — ci_head_sha's branches with stubbed gh/git, and cloud_runs' freshness and fail-closed paths plus main's ordering.

End-to-end in a gh-less container: 25 repos scanned in 3.3s, all five release-gate libraries resolving real shas, and readiness no longer emitting release validation source unconfirmed.

One result worth recording: the drop-point run was consumed correctly (source="cloud", error cleared) but the rollup still declined to report success, because PyAutoFit's main advanced between fetching the runs and the tick, so the existing on_head guard marked them off-HEAD. That is the guard working as intended, and it is why the age bound alone is not sufficient — a payload can be fresh by clock and stale by commit. The on-HEAD success path is covered by a unit test instead of by rewriting the sha.

Known constraint

The Actions API requires each repo attached to the session, and attachment can be refused — it was, for one library, during the session that motivated this. Such a repo degrades to unavailable, which is correct rather than an error, but it does mean the conclusions half delivers less on mobile than the sha half does.


Generated by Claude Code

claude added 3 commits August 25, 2026 12:39
On a mobile/cloud session `gh` is not installed, so the `gh api
.../commits/main` call returned an empty sha. Readiness could then not
confirm an ingested release-validation report against the live HEADs and
reported "release validation source unconfirmed (current HEADs unknown)"
even with every other evidence gap cleared.

Extract the lookup into `ci_head_sha`, which keeps `gh` first — unchanged
dev-box behaviour, and the only source that can read a private repo — and
falls back to an anonymous `git ls-remote`, which needs neither
authentication nor a session repo attachment.

The fallback is bounded because it runs inside the <30s tick:
GIT_TERMINAL_PROMPT=0 stops a private repo blocking on a credential prompt,
and `timeout` caps a stalled connection. `timeout` is coreutils, so it is
resolved to `timeout`/`gtimeout` once at source time; where neither exists
(stock macOS) the fallback is skipped rather than run unbounded, since a
stalled ls-remote is worse than the empty sha that is already today's
answer. Failure still yields an empty sha, never a fabricated one.

This works standalone because build_sidecar writes `head_sha`
unconditionally (ci_status.py:274), independent of the runs fetch error: the
CI row keeps reading "unavailable" until the conclusions half lands, but the
release gate can already confirm commit_shas.

Verified in a gh-less container: all 25 repos scanned in 3.3s, the five
release-gate libraries resolve their real shas, and readiness no longer
emits the source-unconfirmed reason.

Closes #178

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SeYsHrJsuH6wXjCCypKPzp
Second half of the no-gh mobile path (#178 covered the HEAD sha). Without
`gh` the runs fetch fails outright, so every polled repo recorded
status="unavailable" and CI was unknown per-library.

`gh` is only transport here: ci_status.py already parses a REST-shaped
{"workflow_runs": [...]} payload, and MCP's list_workflow_runs returns
exactly that shape, snake_case keys included — so nothing is reshaped on
the way in. Mirrors test_run.py's proven cloud_validation.json hand-off
rather than inventing a second idiom.

- HEART_CLOUD_CI_DIR ($HEART_STATE_DIR/cloud_ci/<Name>.json) holding
  {ts, runs}; ts optional, file mtime used when absent.
- ci_status.cloud_runs() reads and age-bounds it, returning (runs, "") or
  (None, reason), failing closed on every malformed/undated/stale path.
- main gains --cloud-runs, consulted ONLY when the live fetch already
  failed, so the dev box is byte-for-byte unchanged. A rejected payload
  appends its reason to the original error rather than vanishing.
- New `source` sidecar field ("gh" | "cloud"). Provenance is evidence: a
  reader must be able to tell a conclusion Heart fetched from one an agent
  handed it.

The tick does no network work for this — it only reads the drop point, as
it already reads cloud_validation.json. Population is a separate one-shot
leg, which is what keeps the <30s budget intact.

Verified in a gh-less container against a drop point built from a real MCP
list_workflow_runs response: consumed with source="cloud" and the error
cleared. The rollup still declined to report success, because PyAutoFit's
main advanced between the fetch and the tick and the existing on_head guard
marked the runs off-HEAD — the guard working as intended, and why the age
bound alone is not sufficient: a payload can be fresh by clock and stale by
commit.

Closes #179

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SeYsHrJsuH6wXjCCypKPzp
The tenant-firewall check (PyAutoMind repos_sync.py) failed both legs: an
unlisted organ file may carry NO instance fact, and the new test defaulted
its repo argument to a real owner/name.

Genericised rather than allowlisted. The allowlist's own comment says never
to grow it casually — each entry is a file an adopting fork must rewrite —
and this test earns no entry: `gh` and `git` are both stubbed, so the repo
string is never resolved and a real one bought nothing.

The suite itself was green on both legs (635 passed); only this check failed.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SeYsHrJsuH6wXjCCypKPzp
@Jammy2211
Jammy2211 merged commit a570d0a into main Aug 25, 2026
2 checks passed
@Jammy2211
Jammy2211 deleted the claude/heart-evidence-gaps-6svdjk branch August 25, 2026 15:52
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.

feat(ci_status): feed run conclusions from an MCP drop point feat(ci_status): resolve main HEAD sha without gh via ls-remote

2 participants