Review the staged git changes (git diff --staged main) in this Go repository. This is a rewrite of a git-sync tool. Focus on: 1) any remaining correctness bugs 2) regressions from the old code 3) conc

Codex·GPT-5.4·Soph·5mo ago·34min·1 Checkpoint·39 file changes·+7196/-3981·1.4M tokens

Review the staged git changes (git diff --staged main) in this Go repository. This is a rewrite of a git-sync tool. Focus on: 1) any remaining correctness bugs 2) regressions from the old code 3) concurrency issues 4) error handling gaps. Be concise — under 500 words.

5mo ago·5.5s

Reviewing the staged diff against main first, then I’ll trace the changed code paths for correctness, concurrency, regressions, and error handling.

The rewrite split concerns as intended; I’m checking whether behavior stayed equivalent in the new package boundaries and whether the old known failure modes were actually closed.

I’ve confirmed the obvious race fix in stats.go; now I’m looking for less visible regressions in protocol negotiation, bootstrap batching, and token-store behavior.

I’ve narrowed it to a few likely regressions. Running the test suite now to see which of those are already caught versus silently slipping through.

I found two concrete behavioral regressions and one remaining correctness issue that the green test run doesn’t cover. Pulling exact line references now.

Findings:

  1. High: auth resolution now hard-fails instead of falling back when Entire DB state is half-configured. In internal/auth/entiredb.go ReadStoredToken errors are returned directly, and internal/auth/auth.go propagates them out of Resolve. On main, missing/broken Entire tokens were treated as “no credential” and git credential helper could still succeed. With this rewrite, a stale hosts.json entry or missing keyring item now aborts the whole sync before trying helper auth.

  2. High: fast-forward detection is now lossy and can misclassify valid updates as non-FF. internal/planner/planner.go caps ancestry traversal at 100_000, and line 265 returns false, nil when the limit is hit. That is a behavior regression from main, which walked the graph exhaustively. Result: a legitimate fast-forward on a deep history can become ActionBlock, or require --force unnecessarily.

  3. Medium: the new “materialized safety limit” does not actually prevent the OOM path it claims to address. Run still fetches all desired objects into an in-memory repo before strategy selection in internal/syncer/syncer.go, while the limit check only happens later in internal/strategy/materialized/materialized.go. So large non-relay syncs can still exhaust memory before hitting the guard.

Open question:

  • The new auth behavior intentionally surfaces refresh failures, which is good, but it should probably distinguish “refresh failed for a credential we actually selected” from “Entire lookup unavailable, try next provider”.

Verification:

  • go test ./...
  • go test -race ./internal/syncer ./internal/auth ./internal/gitproto ./internal/planner
0520b7cRewrite git-sync into focused packages Break the monolithic syncer.go (3143 lines) into 7 focused packages: - internal/gitproto: pkt-line, smart HTTP, capability negotiation, v1/v2 fetch/push - internal/planner: mapping validation, planning, relay eligibility, checkpoints - internal/auth: credential resolution, Entire DB tokens, git credential helper - internal/strategy/bootstrap: one-shot + batched bootstrap, GitHub preflight - internal/strategy/incremental: incremental relay execution - internal/strategy/materialized: materialized fallback push with size guard - internal/syncer: slim orchestrator (734 lines), stats, measurement Addresses all 22 issues from docs/rewrite-issue-list.md: Correctness: tag ref creation independent of pack (#1), duplicate target mapping rejection (#2), cross-kind mapping rejection (#3), sideband-64k preference (#4), pack reader close discipline (#5), include-tag capability gating (#6), OAuth refresh error propagation (#7). Concurrency: mutex-protected stats (#8), bounded response reads (#9), flock-based file token store locking (#10). Architecture: package decomposition (#11), shared session setup (#12), explicit Params structs (#13). Performance: commit-count batch sizing heuristic (#14), materialized object count guard (#15), bounded ancestry checks with ErrAncestryDepthExceeded (#16), reusable pkt-line buffer (#17). Testing: 73 test functions, 7 benchmarks, coverage 41-58% on core packages. Protocol malformed-input tests (#18-20), behavioral edge cases (#21), benchmarks for planning/protocol hot paths (#22). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 27633b8ca595+7196/-3981