Skip to content

fix(git): fail closed on ref discovery checks - #411

Merged
worstell merged 5 commits into
mainfrom
aat/fail-closed-git-refs
Sep 24, 2026
Merged

worstell merged 5 commits into
mainfrom
aat/fail-closed-git-refs

Conversation

@alecthomas

@alecthomas alecthomas commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Cachew could advertise stale refs from a local mirror when the upstream ls-remote freshness check failed. The same gap existed for protocol-v2 ls-refs, and overlapping checks could leave a stale result cached as fresh. This matches the failure class observed in squareup/blox#3879, where GitHub had a newer commit while Cachew served an older one, without assuming multi-pod skew caused it.

This change treats GET info/refs and protocol-v2 ls-refs as discovery requests. A freshness error proxies the request upstream. A stale result still proxies and schedules a background fetch. Only a completed successful check populates the 10-second cache, and a later stale result invalidates an overlapping success.

Tests:

  • Added focused error, stale, fresh, protocol-v2, overlapping-check, background-fetch, and successful-cache coverage.
  • Made Git test fixtures deterministic across installed Git versions and external GitHub availability.
  • Pre-push lint and the race-enabled test suite passed.

When upstream ref freshness cannot be verified, serving the local mirror
can advertise stale commits. Proxy info/refs upstream on check errors while
preserving stale fetches and successful-check caching.
An in-progress or failed freshness check is not evidence that local refs are current. Keep the cache invalid until both ref reads and comparison succeed so concurrent info/refs requests also fail closed.
@alecthomas

Copy link
Copy Markdown
Collaborator Author

🤖 The agent review exported a concurrency finding, but no GitHub review thread was published. I updated EnsureRefsUpToDate in 68a760e so an in-progress or failed freshness check remains invalid, and the 10-second cache is set only after both ref reads and comparison succeed. I also added focused race-enabled tests for local-ref failures and in-flight checks. The pre-push lint and full test suite passed.

@alecthomas
alecthomas marked this pull request as ready for review September 24, 2026 05:54
@alecthomas
alecthomas requested a review from a team as a code owner September 24, 2026 05:54
@alecthomas
alecthomas requested review from worstell and removed request for a team September 24, 2026 05:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T08:59:38.581099Z d4849ac New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68a760ef1b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/strategy/git/git.go Outdated
Comment thread internal/gitclone/manager.go
Protocol v2 ls-refs and overlapping checks could still advertise stale refs after a freshness failure or stale result. Treat ls-refs as discovery, invalidate stale check results, and keep clone integration coverage independent of GitHub availability.
@alecthomas alecthomas changed the title fix(git): fail closed on ref check errors fix(git): fail closed on ref discovery checks Sep 24, 2026
@alecthomas alecthomas closed this Sep 24, 2026
@alecthomas alecthomas reopened this Sep 24, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6ddfb58ae8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/gitclone/manager.go Outdated
Serve the fetch fixture from a local smart-HTTP repository so CI does not depend on external GitHub TLS trust or availability.
The assignment is self-explanatory, and removing its annotation keeps comments aligned with the repository convention.
@worstell
worstell merged commit 693941a into main Sep 24, 2026
7 checks passed
@worstell
worstell deleted the aat/fail-closed-git-refs branch September 24, 2026 17:10
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.

3 participants