fix: authenticate the GitHub repo-size preflight and log its outcome #124
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.75) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #124"
general
weight: 0.35
pjbgf
Problem
When bootstrapping from a
github.comsource without--target-max-pack-bytes, git-sync asks the GitHub REST API (GET /repos/{owner}/{repo}) for the repository size. It switches to 512 MiB batches when the size is 1.5 GiB or more. That lookup sent no credentials. For a private repository GitHub answers 404 to an anonymous caller, so every private repository bootstrapped as a single pack, whatever its size.Nothing reported this:
Public repositories were exposed too: anonymous calls share GitHub's 60 requests/hour limit per egress IP.
Changes
Authenticated lookup
user:token@in the source URL, or credentials the git credential helper supplied when the git server asked for them. A public repository never asks, so with only a helper its lookup stays anonymous. A URL username without a password is not sent: it may be an account name.HTTPConn.CredentialsFor(dest)decides which credentials may go to the API, checking the real destination. Each credential is measured from the URL it is bound to (the endpoint for explicit and URL credentials, the looked-up host for helper ones), the destination must be same-site with it, and with TLS verification off nothing crosses to another host. So helper credentials looked up for a redirect host stay with that host, and an API base on another site gets nothing.GitHubOwnerReponow treatsgithub.comas GitHub only on its scheme's default port. The connection's redirect guard still strips credentials from any hop that leaves the API's site, and the loggedauthenticatedreflects the request that actually produced the answer.Visible outcome
Options.BootstrapLogger. This does not need verbose mode.repository,authenticated,http_status,refused_auth_status,refused_auth_error,size_kborerror,threshold_kb,mode,target_max_pack_bytes.-v(it can still switch to batches if the target rejects the pack). The notice names the token refusal when there was one. Under-vthe failure is printed once, and the verbose log andBootstrapLoggeruse the same record name.Hardening
owner/repo.wiki) get no lookup: the API has nothing to size.Docs
docs/usage.mddocuments the lookup and its credential scope.BootstrapLoggerdoc comments andCHANGELOG.md.Tests
New file
internal/strategy/bootstrap/github_preflight_test.go, written test-first. It covers:Execute);user:token@URL credentials, and a bare URL username not being sent;CredentialsForininternal/gitproto/smarthttp_test.go: explicit, helper and URL credentials, helper credentials bound to a redirect host, and TLS verification off.The preflight tests reach a local TLS server as
https://api.github.com, so the destination check runs as in production.The new tests fail against the previous implementation.
go test ./...,go test -raceon the affected packages andgolangci-lint run(v2.11.4) all pass.---
_Generated by Claude Code_
<!-- CURSOR_SUMMARY -->
---
<!-- /CURSOR_SUMMARY -->