Here's the git-sync issue, structured to mirror the entiredb one.
git-sync: batched bootstrap sends pack-less ref creates that some servers reject
Symptom
During a batched bootstrap, git-sync finalizes a "subsumed" branch by sending a ref-create command with no packfile. Against a receive-pack implementation that expects a pack for any non-delete command, this fails:
The bootstrap dies mid-run, leaving the target half-populated. First observed mirroring github.com/JUMPTOON/app → entiredb prod aws-us-east-2, 2026-06-15 07:36 (trace 433bad8f4ef654ac651f868ab3c2fa3e): ~15 batch pushes succeeded, then the subsumed-ref create EOF'd.
Root cause
In the batched bootstrap, the subsumed-branch path issues a ref-only push:
PushCommands → sendReceivePack(ctx, conn, req, nil, …) with packData=nil, so the request body is the command pkt-lines + flush and nothing else (internal/gitproto/push.go:585, body assembly at push.go:293-296).
That's valid git when the objects already exist, but it relies on the server tolerating a pack-less create. entiredb (and likely others) treats every non-delete as "a pack will follow" and errors reading the absent header. The interop contract is ambiguous and git-sync is on the fragile side of it.
Suggested fix
On the subsumed-ref / pack-less create path, send a valid empty packfile (12-byte header + trailer, 0 objects) instead of no pack, so servers that unconditionally read a pack header are satisfied. (Cheap, and strictly more compatible.) Alternatively, gate the pack-less optimization on a detected server capability.
Evidence
Trace 433bad8f4ef654ac651f868ab3c2fa3e — batched bootstrap, EOF on create subsumed branch ref for refs/heads/docs-rules.
Counterpart server-side cause (entiredb): commandsNeedPack returns true for any non-delete (server/githttp/receive_pack_connectivity.go:66), then io.ReadFull of the 12-byte header EOFs on the empty body (objstore/packfile_fanout.go:44).
Related (separate, larger git-sync issue): replicate strategy can't batch, so a half-bootstrapped repo never recovers
Why it matters
Once the bootstrap above fails partway, the target is non-empty, so runReplicate routes to executeReplicate instead of bootstrap (internal/syncer/syncer.go — replicateCanBootstrap false). The replicate strategy streams one pack for all updates with no subdivision:
go
// internal/strategy/replicate/replicate.go:62-73 — fetch one pack, push once, no retry
For JUMPTOON/app the resulting pack is >10 GiB and the target rejects it (push rejected: body exceeded size limit 10737418240), 708× over the window — a permanent wedge.
Two gaps
No body-limit fallback in replicate. The body exceeded size limit detection + checkpoint-batched relay (autoTargetMaxPackBytes, bodyLimitPattern) lives only in the bootstrap strategy (internal/strategy/bootstrap/bootstrap.go:33,1380). Replicate has none — it just returns push target refs: %w and fails.
TargetMaxPackBytes isn't reachable via the public API.Options/SyncRequest/SyncPolicy don't expose it; internalbridge/config.go:75 hardcodes it to 0. So a caller (mirror-pipeline) can't proactively cap pack size even if it wanted to.
Suggested fix
Give the replicate strategy the same body-limit detection + checkpoint-batched relay the bootstrap path has (or route replicate's create/update plans through executeBatched).
Expose TargetMaxPackBytes on the public SyncPolicy/Options and thread it through SyncConfig so callers can set it up front (~5 GiB) and avoid the wasted 10 GiB round-trips.
Consider making bootstrap resumable after a mid-batch failure rather than stranding partial state (the scaffolding exists — BootstrapResumeIndex, temp refs — but it didn't re-engage here).
I kept the pack-less-create bug as the primary issue (it's the direct counterpart to the entiredb one) and split the replicate-batching work out, since it's a bigger, separable change. Want me to file these as two GitHub issues in git-sync, or fold them into one? I can verify the exact bootstrap.go line numbers in the real git-sync repo (I've been reading the vendored copy) before filing.
Assistant· claude-opus-4-8
I'll verify these claims against the actual git-sync codebase. Let me investigate the key files referenced.
Assistant· claude-opus-4-8
I'll dispatch parallel exploration to verify each claim in the report against the real source.
Assistant· claude-opus-4-8
I dug into the actual git-sync source. Your report holds up well — line numbers are accurate and the mechanism is correctly described. Here's the verification, with the one correction worth fixing before you file.
The subsumed field (struct doc at lines 121-126) explicitly says it "skips the commit-graph fetch, the pack fetch, the temp ref, and the pack push — emitting only a single ref create command." That matches your error string exactly.
internal/gitproto/push.go — your line cites verified:
push.go:293-296 — body assembly is bytes.NewReader(header.Bytes()), and the pack is appended onlyif packData != nil. So with nil it's command pkt-lines + flush, nothing else. ✅
Empty-pack suggestion: confirmed there is no empty-pack construction anywhere in git-sync today (only packfile.NewEncoder for non-empty packs in PushObjects). So your suggested fix is genuinely new code, not a toggle of something existing — accurate framing.
Related issue: replicate can't batch — ✅ confirmed, with one correction
replicate.go:62-74 — one FetchPack, one PushPack, on failure returns fmt.Errorf("push target refs: %w", err). No fallback/retry/batching. ✅ (note it does call gitproto.LimitPackReader(packReader, p.MaxPackBytes), but that's a source-side read cap, not the target body-limit relay.)
Body-limit machinery is bootstrap-only: at , at , at , at , and the fallback wiring at . Replicate has none of it. ✅
User
I kept the pack-less-create bug as the primary issue (it's the direct counterpart to the entiredb one) and split the replicate-batching work out, since it's a bigger, separable change. Want me to file these as two GitHub issues in git-sync, or fold them into one? I can verify the exact bootstrap.go line numbers in the real git-sync repo (I've been reading the vendored copy) before filing.
User
Related (separate, larger git-sync issue): replicate strategy can't batch, so a half-bootstrapped repo never recovers
Why it matters
Once the bootstrap above fails partway, the target is non-empty, so runReplicate routes to executeReplicate instead of bootstrap (internal/syncer/syncer.go — replicateCanBootstrap false). The replicate strategy streams one pack for all updates with no subdivision:
go
// internal/strategy/replicate/replicate.go:62-73 — fetch one pack, push once, no retry
For JUMPTOON/app the resulting pack is >10 GiB and the target rejects it (push rejected: body exceeded size limit 10737418240), 708× over the window — a permanent wedge.
Two gaps
No body-limit fallback in replicate. The body exceeded size limit detection + checkpoint-batched relay (autoTargetMaxPackBytes, bodyLimitPattern) lives only in the bootstrap strategy (internal/strategy/bootstrap/bootstrap.go:33,1380). Replicate has none — it just returns push target refs: %w and fails.
TargetMaxPackBytes isn't reachable via the public API.Options/SyncRequest/SyncPolicy don't expose it; internalbridge/config.go:75 hardcodes it to 0. So a caller (mirror-pipeline) can't proactively cap pack size even if it wanted to.
Suggested fix
Give the replicate strategy the same body-limit detection + checkpoint-batched relay the bootstrap path has (or route replicate's create/update plans through executeBatched).
Expose TargetMaxPackBytes on the public SyncPolicy/Options and thread it through SyncConfig so callers can set it up front (~5 GiB) and avoid the wasted 10 GiB round-trips.
Consider making bootstrap resumable after a mid-batch failure rather than stranding partial state (the scaffolding exists — BootstrapResumeIndex, temp refs — but it didn't re-engage here).
User
git-sync: batched bootstrap sends pack-less ref creates that some servers reject
Symptom
During a batched bootstrap, git-sync finalizes a "subsumed" branch by sending a ref-create command with no packfile. Against a receive-pack implementation that expects a pack for any non-delete command, this fails:
The bootstrap dies mid-run, leaving the target half-populated. First observed mirroring github.com/JUMPTOON/app → entiredb prod aws-us-east-2, 2026-06-15 07:36 (trace 433bad8f4ef654ac651f868ab3c2fa3e): ~15 batch pushes succeeded, then the subsumed-ref create EOF'd.
Root cause
In the batched bootstrap, the subsumed-branch path issues a ref-only push:
PushCommands → sendReceivePack(ctx, conn, req, nil, …) with packData=nil, so the request body is the command pkt-lines + flush and nothing else (internal/gitproto/push.go:585, body assembly at push.go:293-296).
That's valid git when the objects already exist, but it relies on the server tolerating a pack-less create. entiredb (and likely others) treats every non-delete as "a pack will follow" and errors reading the absent header. The interop contract is ambiguous and git-sync is on the fragile side of it.
Suggested fix
On the subsumed-ref / pack-less create path, send a valid empty packfile (12-byte header + trailer, 0 objects) instead of no pack, so servers that unconditionally read a pack header are satisfied. (Cheap, and strictly more compatible.) Alternatively, gate the pack-less optimization on a detected server capability.
Evidence
Trace 433bad8f4ef654ac651f868ab3c2fa3e — batched bootstrap, EOF on create subsumed branch ref for refs/heads/docs-rules.
Counterpart server-side cause (entiredb): commandsNeedPack returns true for any non-delete (server/githttp/receive_pack_connectivity.go:66), then io.ReadFull of the 12-byte header EOFs on the empty body (objstore/packfile_fanout.go:44).
User
let's first fix the empty-pack
Assistant· claude-opus-4-8
Let me read the relevant code before making changes.
Assistant· claude-opus-4-8
Now let me check how the codebase handles pack encoding and hash format, to build a correct empty pack.
Assistant· claude-opus-4-8
git-sync supports SHA-256, so a hardcoded SHA-1 empty pack would be wrong for SHA-256 targets. Let me check how go-git's encoder determines the hash format.
Assistant· claude-opus-4-8
I now have everything I need. The fix: PushCommands should attach an empty packfile when the request contains any non-delete command (delete-only pushes must stay pack-less), and the empty pack's trailer must match the target's advertised object format (SHA-1 vs SHA-256).
Let me make the edits.
Assistant· claude-opus-4-8
Now the package-level PushCommands and the new emptyPack helper:
Assistant· claude-opus-4-8
Now let me build and check existing tests in the gitproto package.
Assistant· claude-opus-4-8
Build passes. Let me look at the existing push_test.go to match conventions for a test.
Assistant· claude-opus-4-8
Let me check the test file's imports and the connForServer helper.
Assistant· claude-opus-4-8
Now I'll add tests. Let me append them to push_test.go:
Assistant· claude-opus-4-8
All four pass, including the canonical empty-pack golden hash. Let me run the full gitproto suite plus the strategy packages to confirm nothing regressed, and vet.
Assistant· claude-opus-4-8
All green and vet is clean. Let me run the repo's lint task on the package if one exists.
Assistant· claude-opus-4-8
Project lint (mise run lint) passed clean, but the bare run flagged a perfsprint nit on my golden-hash line. Let me use hex.EncodeToString to satisfy both.
Assistant· claude-opus-4-8
The linter already auto-fixed the line to hex.EncodeToString. I added the hex import — let me verify there's no duplicate or now-unused fmt, then re-run tests and lint.
Assistant· claude-opus-4-8
Lint clean, all tests pass. Here's a summary of the empty-pack fix.
What changed
internal/gitproto/push.go — the package-level PushCommands now attaches a valid empty packfile whenever the request contains a non-delete command:
This fixes the subsumed-branch finalize path (bootstrap.go:324 and :643) and any other create/update routed through PushCommands — the request body now ends with a 12-byte header + checksum trailer instead of nothing, so a receive-pack that unconditionally reads a pack header (like entiredb) no longer EOFs.
Two correctness details I made sure of
Delete-only pushes stay pack-less.PushCommands is also used for temp-ref deletes (bootstrap.go:375/649, replicate.go:78). Gating on hasUpdates means deletes still send no pack, as git requires — I added a test asserting the body contains no PACK.
Object format is honored. git-sync supports SHA-256 (there's a convert-sha256 command), and a hardcoded SHA-1 empty pack would produce a wrong trailer for a SHA-256 target. The helper reads the advertised object-format capability and uses go-git's hash.New so the trailer is 20 or 32 bytes accordingly.
Tests added (push_test.go)
TestEmptyPackTrailerMatchesObjectFormat — SHA-1 (incl. the canonical golden hash 029d0882…) and SHA-256 trailers.
TestPushCommandsSendsEmptyPackForCreate — request body ends with a valid empty pack.
TestPushCommandsSendsNoPackForDeleteOnly — delete-only carries no pack.
go build ./..., go vet, the full internal/gitproto + internal/strategy suites, and mise run lint all pass.
This is the cheap, strictly-more-compatible option from your report. I did not add the alternative server-capability gate — sending an empty pack is unconditionally valid, so the capability detection isn't needed. Want me to commit this on a branch, and then move on to drafting the two GitHub issues?
User
simplify
/simplify
Assistant· claude-opus-4-8
I'll gather the diff first, then launch the four cleanup agents in parallel.
Assistant· claude-opus-4-8
The changes are uncommitted in the working tree. Let me capture the full diff.
Assistant· claude-opus-4-8
Now I'll launch the four cleanup review agents in parallel.
Assistant· claude-opus-4-8
All four agents reported. Let me dedup and decide:
Converging, high-value fixes:
Precompute the two empty packs (efficiency #1/#2/#3 + simplification #3): the result has exactly two possible values, so build them once at package load instead of hashing on every call. This also eliminates the subtle h.Sum(header) append-in-place idiom and the per-call allocation.
Deduplicate the 12-byte header literal (reuse #1): share one emptyPackHeader var between production and the test (same package).
Extract the test body-capture boilerplate (simplification #1): the two new tests are near-identical server+channel+select copy-paste.
Skipping (with notes):
Generalize the rule into sendReceivePack (altitude #1): the altitude agent itself graded the current placement correct. sendReceivePack doesn't have adv (no object-format), and PushObjects always encodes a real pack via the go-git encoder, so it isn't actually exposed. Moving the rule would mean reworking a shared chokepoint's signature — scope creep for no current benefit.
Extract a PreferredObjectFormat accessor (altitude #2): single caller; adding it now is speculative generality (YAGNI). Worth revisiting if a second caller appears.
var packData conditional (simplification #2): agent confirmed already minimal.
Let me apply the fixes.
Assistant· claude-opus-4-8
Now the test file: remove the duplicated emptyPackHeader var (now lives in push.go), and extract the body-capture boilerplate.
Assistant· claude-opus-4-8
Now rewrite the two tests to use the helpers:
Assistant· claude-opus-4-8
Now build, test, and lint.
Assistant· claude-opus-4-8
Build, tests, and lint all clean. Let me show the final state of the production helper for the record.
Assistant· claude-opus-4-8
Done. /simplify complete — build, full internal/gitproto suite, and mise run lint all pass.
Fixed
Precomputed the two empty packs (push.go) — the empty-pack bytes depend only on the hash algorithm, so there are exactly two possible outputs. They're now built once at package load (emptyPackSHA1, emptyPackSHA256) via a small buildEmptyPack(algo) helper, and emptyPack(adv) just selects between them after the capability check. Removes the per-call hash + allocation in bootstrap's per-branch/per-checkpoint loops, and confines the subtle Sum/append construction to one clearly-named builder that uses the unambiguous append(slices.Clone(header), h.Sum(nil)...) form.
Deduplicated the 12-byte header literal (reuse) — emptyPackHeader now lives once in push.go and is shared by both production and the test (same package), replacing the copy that was in push_test.go.
Extracted the test boilerplate (simplification) — added captureReceivePackBody(t) and awaitBody(t, bodies) helpers, collapsing the two near-identical ~30-line server/channel/select blocks in the new tests down to a few lines each.
Skipped (with reasons)
Generalizing the rule into sendReceivePack (altitude) — the altitude agent itself graded the current placement correct. sendReceivePack lacks adv/object-format, and PushObjects always encodes a real pack through the go-git encoder so it isn't exposed; moving the rule would rework a shared chokepoint's signature for no current gain.
A PreferredObjectFormat accessor (altitude) — single caller today; adding it now is speculative generality. Worth revisiting only if a second caller appears.
The var packData conditional (simplification) — already minimal and idiomatic.
Behavior is unchanged; this was quality-only. The changes remain uncommitted in the working tree.
PR #74 against main, describing the symptom, root cause, fix, tests, and noting the separate replicate-batching follow-up.
The PR body flags the larger replicate-batching issue as a follow-up. Want me to file that as a separate GitHub issue now (with the corrected TargetMaxPackBytes wording we verified earlier)?
Routing in syncer.go: replicateCanBootstrap/allAbsent check at :916, bootstrap path at :935, executeReplicate at :982. Non-empty target → executeReplicate. ✅
BootstrapResumeIndex resume scaffolding exists at bootstrap.go:348 (temp refs + re-plan on hash-in-chain). ✅
⚠️ Correction — TargetMaxPackBytesis reachable, just not on the stable API
The report says it "isn't reachable via the public API." That's only true for the stable surface. It's actually exposed in two places:
What the report correctly identified is that internalbridge/config.go:75 (SyncConfig) never threads it through — it's left at 0 in the stable bridge layer (it does hardcode MaterializedMaxObjects nearby but not this). So the precise claim is: the stable SyncPolicy/Options/SyncRequest don't expose it and the bridge hardcodes 0 — not that it's entirely unreachable. mirror-pipeline going through the stable bridge can't set it; going through unstable or the CLI can.
I'd reword that bullet to "not exposed on the stable public API; internalbridge/config.go:75 leaves it 0" so a reviewer doesn't immediately point at unstable/AdvancedOptions and dismiss it.
On filing
Two issues is the right split — the pack-less create is a tight, self-contained fix; the replicate-batching work is a real refactor. Want me to:
Draft the two GitHub issue bodies (with the corrected TargetMaxPackBytes wording and these verified line refs), and/or
Go ahead and implement the primary fix — the empty-pack path is small and I can also add the server-capability gate as the alternative?