Skip to content

Keep checkout credentials available for later Git commands - #692

Open
sj26 wants to merge 5 commits into
mainfrom
checkout-ephemeral-credentials
Open

sj26 wants to merge 5 commits into
mainfrom
checkout-ephemeral-credentials

Conversation

@sj26

@sj26 sj26 commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

🤖

Why

Checkout rejects persist-credentials: true. Omitting it gets past validation, but later Git commands cannot use checkout's managed read credentials:

permissions:
  contents: read
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: true
      - run: git fetch --unshallow origin

What

Keep a temporary, repository-local credential helper available for later Git reads, linked worktrees, and post actions. Modern checkout defaults to persistence; false keeps managed authentication checkout-only. Legacy v1 and Origin retain their non-persistent behavior.

Reuse the existing Agent Git credential helper and read-only checkout issuer. No workflow-token request, pipeline workflow-token opt-in, backend change, plugin change, managed write access, or second token cache is needed.

The new code is a narrow bridge, because directly exposing the Agent helper to workflow processes would require giving them Agent job credentials:

  1. Git invokes a copy of buildkite-gha in runner temp, using its credential-helper command.
  2. That client sends the HTTPS host and repository to the running runtime over a per-job Unix socket, authenticated by a local key.
  3. The runtime accepts only the event repository. It invokes the pinned buildkite-agent git-credentials-helper get with its retained Agent job credentials.
  4. The existing helper requests a read-only GitHub credential from the existing checkout issuer. The provider's username and token return through the bridge to Git.

Git config contains the client command and local key, not the GitHub token. Workflow processes receive neither Agent nor job access credentials. The bridge doesn't cache tokens; it delegates each lookup to the existing helper. Cleanup removes its entries and closes the service after post actions. Workflow code can retrieve its read bearer through Git's credential protocol; cleanup stops new lookups but doesn't revoke issued tokens.

Separately configured HTTPS authentication keeps precedence and its own permissions. The managed helper chain is isolated so Git cannot save a managed token through an inherited store helper. Private credentials for sibling repositories remain usable. Native checkout retains the Agent issuer's existing authorized submodule reads; the persistent bridge itself serves only the event repository.

Two intentional compatibility changes remain: later code gains managed read access by default, and effective job permissions without contents access no longer grant managed private checkout. Anonymous public reads and private credentials remain possible. Declaring contents: write still obtains only a managed read credential. Pushes need independent write credentials; API clients still need explicit API authentication. Existing Agent eligibility and repository authorization remain unchanged.

Use permission-aware workflow tokens through a temporary Git helper, without exposing Agent credentials or storing GitHub bearers in Git config. Preserve separate self-hosted authentication and remove managed helpers after post actions.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ed50-5a1d-728f-b171-397528702a44
Co-authored-by: Amp <amp@ampcode.com>

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Managed checkout loses proxy settings on the new credential path. The inline comments also cover two persistence and cleanup edge cases. This changes access to write-capable credentials and requires human approval.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 56311, then answer my questions about the findings.
About buildsworth

Model: gpt-6.1-sol with xhigh thinking.

How to request a review: Comment @buildsworth-bk review on the PR, or request buildsworth-bk as a reviewer.

Risk labels — buildsworth classifies risk itself from the diff. The same approval policy applies in every repository:

  • L1 — Low risk (dep bumps, docs/copy, lockfiles, small presentational fixes). buildsworth may approve by default.
  • L2 — Standard risk (new UI, additive API fields, refactors). buildsworth may approve without per-PR permission.
  • L3 — High risk (auth, migrations, payments, secrets, perf-critical pipeline paths). Human approval required; buildsworth never approves.

Comment thread internal/runtime/checkout.go Resolved
Comment thread internal/runtime/checkout.go Resolved
Comment thread internal/runtime/git_credentials.go Resolved
Keep captured proxy settings on the workflow credential path, use release contracts for legacy persistence, and allow workflows to remove checkout metadata before cleanup.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-01a1ed50-5a1d-728f-b171-397528702a44

sj26 commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

🤖 @buildsworth-bk review

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proxy forwarding, legacy-v1 persistence, and deleted-checkout cleanup findings are addressed. No new findings; human approval is still required for the change to write-capable credential access.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 56328, then answer my questions about the findings.

@buildsworth-bk-app
buildsworth-bk-app Bot dismissed their stale review November 20, 2026 04:25

Superseded by a newer Buildsworth review.

Keep checkout on the existing Agent credential helper and issuer. Isolate managed helper storage, preserve private authentication and native submodule reads, and remove checkout-only workflow-token authority and caching.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ed50-5a1d-728f-b171-397528702a44
Co-authored-by: Amp <amp@ampcode.com>

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One new non-blocking finding: parallel checkouts can lose a cleanup registration.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 57466, then answer my questions about the findings.

Comment thread internal/runtime/checkout.go Resolved
Synchronize shared checkout registration and use the existing synchronized writer for persistence messages. Exercise two background checkouts through authenticated fetches, post actions, and cleanup under the race detector.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ed50-5a1d-728f-b171-397528702a44
Co-authored-by: Amp <amp@ampcode.com>

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parallel-checkout cleanup issue is fixed. I found a separate regression in checkout permission handling for reusable workflows.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 57468, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

Comment thread internal/compiler/plan_builder.go Resolved
Keep effective checkout access separate from root workflow-token policy, including nested permission ceilings.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1ed50-5a1d-728f-b171-397528702a44
Co-authored-by: Amp <amp@ampcode.com>

@buildsworth-bk-app buildsworth-bk-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reusable-workflow checkout permission regression is fixed; I found no new issues. Human approval is still required for extending managed read-credential access to later workflow code by default.

Want to dig deeper?

Paste this into your agent to explore the findings from this review's Buildkite build:

Download the buildsworth logs from build 57473, then answer my questions about the findings.

Install the reading-buildsworth-logs skill to run this.

@buildsworth-bk-app
buildsworth-bk-app Bot dismissed their stale review November 24, 2026 05:15

Superseded by a newer Buildsworth review.

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.

1 participant