Repository navigation
Conversation
There was a problem hiding this comment.
🟡 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
marked this pull request as draft
November 19, 2026 20:41
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Agents restore their source checkout from the daily full-history snapshot instead of a shallow clone, when
SOURCE_SNAPSHOT_BUCKETis set.Changes
ensure_source_repo: for a fresh checkout of a GitHub repository, streamgs://$SOURCE_SNAPSHOT_BUCKET/github/<org>/<repo>.tarintotar -x, fetch the requested ref, and check it out. The fetch only adds commits newer than the snapshot.google-auth. No new dependency.repo_url, not the origin saved in the snapshot. Git runs against the unpacked.gitonly.depthis ignored: the checkout has full history.Validation
Other
SOURCE_SNAPSHOT_BUCKET. Until then, nothing changes.