Skip to content

Fetch agents' internal repositories at build time - #7706

Open
suhaibmujahid wants to merge 3 commits into
perf-plugin/build-tablefrom
perf-plugin/build-tokens
Open

suhaibmujahid wants to merge 3 commits into
perf-plugin/build-tablefrom
perf-plugin/build-tokens

Conversation

@suhaibmujahid

Copy link
Copy Markdown
Member

Part of #7610

The shared scripts/fetch_repos.py fetches each repository in an agent's
[build] table at its pinned commit, for a Dockerfile build stage to copy
from, using one BuildKit secret, github_token. In Cloud Build, a new
Tokens step runs hackbot-deploy build-tokens, which asks the build's
GitHub connection for a short-lived read token for each planned agent
with a [build] table, so no GitHub credential of ours is ever in the
build. The Build step passes it as the secret and removes it afterwards.
A failed token costs only that agent; no agent uses this yet.


Stack created with GitHub Stacks CLI • Give Feedback 💬

@suhaibmujahid
suhaibmujahid requested a review from a team as a code owner November 29, 2026 18:17
Copilot AI balanced review requested due to automatic review settings November 29, 2026 19:00

Copilot AI 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.

🟡 Changes recommended

The token request uses an invalid REST action that prevents private dependency access, and token files remain exposed in the Docker build context to package build scripts.

2 open issues
What changed in this PR

This PR adds build-time private repository fetching for Hackbot agents, laying groundwork for #7610. No agent adopts the feature yet.

Changes:

  • Adds a shared script to fetch repositories at pinned commits using a BuildKit secret.
  • Adds per-agent token retrieval from Cloud Build’s GitHub connection and token cleanup after builds.
  • Documents the workflow and tests fetching, token handling, and failure isolation.
File Description
tools/​hackbot-deploy/​tests/​test_fetch_repos.py Tests pinned fetches and token-safe error handling.
tools/​hackbot-deploy/​tests/​test_build_tokens.py Tests token retrieval, file permissions, and per-agent failures.
tools/​hackbot-deploy/​scripts/​fetch_repos.py Fetches configured repositories using a supplied token.
tools/​hackbot-deploy/​README.md Documents private repository build integration.
tools/​hackbot-deploy/​hackbot_deploy/​cli.py Adds the plan-driven build-tokens command.
tools/​hackbot-deploy/​hackbot_deploy/​build_tokens.py Retrieves read tokens and writes per-agent secret files.
agents/​cloudbuild.yaml Adds token retrieval, BuildKit secret passing, and cleanup.

Review effort: Balanced

Comment thread agents/cloudbuild.yaml Resolved
The shared scripts/fetch_repos.py fetches each repository in an agent's
[build] table at its pinned commit, for a Dockerfile build stage to copy
from, using one BuildKit secret, github_token. In Cloud Build, a new
Tokens step runs hackbot-deploy build-tokens, which asks the build's
GitHub connection for a short-lived read token for each planned agent
with a [build] table, so no GitHub credential of ours is ever in the
build. The Build step passes it as the secret and removes it afterwards.
A failed token costs only that agent; no agent uses this yet.
build-deps undersold it: the stage fetches whole repositories, into
/repos/<name>.
The Tokens step wrote them under /workspace, the build context, which
every agent's Dockerfile bind-mounts to install dependencies, so any
package build script in any agent built afterwards could read them. They
now go to a github-tokens volume that only the Tokens and Build steps
mount.
@suhaibmujahid
suhaibmujahid force-pushed the perf-plugin/build-tokens branch from 3e09d20 to 7508fce Compare December 3, 2026 00:25
@suhaibmujahid
suhaibmujahid enabled stacked auto-merge (squash) December 3, 2026 00:40

This branch has not been deployed

No deployments
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.

2 participants