Skip to content

feat(hackbot-runtime): start checkouts from the full-history source snapshot - #7595

Draft
jwmossmoz wants to merge 3 commits into
mozilla:masterfrom
jwmossmoz:relops/hackbot-source-snapshot
Draft

jwmossmoz wants to merge 3 commits into
mozilla:masterfrom
jwmossmoz:relops/hackbot-source-snapshot

Conversation

@jwmossmoz

@jwmossmoz jwmossmoz commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Agents restore their source checkout from the daily full-history snapshot instead of a shallow clone, when SOURCE_SNAPSHOT_BUCKET is set.

Changes

  • ensure_source_repo: for a fresh checkout of a GitHub repository, stream gs://$SOURCE_SNAPSHOT_BUCKET/github/<org>/<repo>.tar into tar -x, fetch the requested ref, and check it out. The fetch only adds commits newer than the snapshot.
  • The download uses the agent's own identity through google-auth. No new dependency.
  • The restore only runs into an empty directory. It fetches from repo_url, not the origin saved in the snapshot. Git runs against the unpacked .git only.
  • If the bucket is not set, the repository is not on GitHub, or any step fails (download, unpack, fetch, checkout), the directory is removed and the shallow clone runs as before.
  • With a snapshot, depth is ignored: the checkout has full history.

Validation

  • hackbot-runtime: 371 passed. Tests restore a real snapshot tar with a stale origin, fetch a commit newer than it, fall back after a failed download and after a failed fetch, and leave an enclosing repository unchanged.
  • Ruff check and format pass.
  • Autoreview (P0–P2) with GPT-6.2 Astra and Claude Fable. Astra's finding about an enclosing repository is fixed. A symlinked checkout path is not handled; no deployment uses one.
  • Not yet tested on Cloud Run.

Other

  • Needs mozilla/webservices-infra#13771, which sets SOURCE_SNAPSHOT_BUCKET. Until then, nothing changes.
  • Full history adds about 4–5 GB to the checkout. Agents without a workspace disk hold it in memory (24 GiB).
  • #13771 also turns on read-only CI sccache for all agents through environment variables. That needs no bugbug change.

@jwmossmoz
jwmossmoz requested a review from a team as a code owner November 19, 2026 20:27
Copilot AI balanced review requested due to automatic review settings November 19, 2026 20:27

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

Snapshot restoration can truncate history on reuse, fetch from an archived origin instead of the requested URL, and leave incomplete repository state that blocks fallback or retries.

4 open issues
What changed in this PR

Adds snapshot-backed source preparation to Hackbot’s shared runtime, allowing agents to start fresh GitHub checkouts with full history when SOURCE_SNAPSHOT_BUCKET is configured.

Changes:

  • Streams repository snapshots from Cloud Storage using the agent’s existing Google credentials.
  • Fetches and checks out the requested ref without a depth limit after restoration.
  • Retains shallow cloning when snapshots are unavailable or download/extraction fails, with tests for restoration and cleanup.
File Description
libs/​hackbot-runtime/​tests/​test_source.py Tests snapshot restoration, newer commits, failure cleanup, and skipped restores.
libs/​hackbot-runtime/​hackbot_runtime/​source.py Adds authenticated snapshot download, extraction, and fresh-checkout integration.

Review effort: Balanced

try:
source_repo.mkdir(parents=True, exist_ok=True)
tar = subprocess.Popen(
["tar", "-x", "-C", str(source_repo)], stdin=subprocess.PIPE
Comment on lines +144 to +145
if _restore_snapshot(source_repo, repo_url):
# The snapshot has full history, so fetching only adds newer commits.
if _restore_snapshot(source_repo, repo_url):
# The snapshot has full history, so fetching only adds newer commits.
for args in (
["fetch", "origin", fetch_target],
Comment on lines +150 to +152
subprocess.run(
["git", "-C", str(source_repo), *args],
check=True,
@jwmossmoz
jwmossmoz marked this pull request as draft November 19, 2026 20:41

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