Fix #205: bare-hex pack checksums #207

Merged
crueber merged 1 commit from fix/issue-205 into main 2026-09-08 18:11:03 +00:00
Owner

Fixes #205: push/import/CLI producers derived PackRef.checksum with TrimSuffix-only on git's on-disk pack-.idx names, keeping the pack- infix in the manifest + bucket keys (wal/pack-.pack) against the 02 §2.2 bare-hex contract, and stacking a new pack- layer per re-ingest. newLocalPack additionally returned hollow claims for pack-less idx files (silent pack-upload skip).

What changed:

  • internal/git: new PackChecksumFromIdx helper (single source of truth, 04_git.md).
  • internal/server bind_wal.go newLocalPack: strip infix; paths from the real on-disk basename; complete (.pack+.idx) pairs only — a pack-less idx now yields nil instead of a hollow claim; known-set also matches the bare form of stored checksums so materialized legacy packs are never re-published.
  • internal/repoimport task.go + cmd/walhub ops.go FullRepack tails: bare checksums, paths as pack-.pack.
  • internal/wal installPackFile: same-file no-op — the tails AddPack packs already in the serving copy (read-only repack output); self-copy truncated with EACCES. Found because the fixed tail exposed it (old code survived by writing a doubled pack-pack-.pack copy).
  • Readers verified shape-agnostic (all derive from the stored checksum); no reader changes.

Tests (all go test -race green; make cover gate passes, every internal/... package >=95%):

  • internal/server: TestReceivePackPushBareChecksums (HTTP receive-pack, real engine+git: 2 pushes, bare manifest, bare keys, no prefixed keys); TestWalEngineNewLocalPackShapes (7-case matrix incl. legacy/doubled); TestWalEngineNewLocalPackFindsIngestedPack extended (bare manifest + key existence = upload not skipped); stray-idx tests updated to the nil contract.
  • internal/repoimport: TestImportPackChecksumsBareHex (full file:// import incl. tier-2 base).
  • internal/wal: TestPublish_LegacyPrefixedChecksumReads (legacy entry materializes; mixed old/new live set syncs); TestPublish_AddPackSameFileSkipsInstall (read-only preserved).
  • internal/git: TestPackChecksumFromIdx table.
  • Full suites: git, wal, server, repoimport, maintain, cmd/walhub, store-adjacent e2e (internal/e2e smart-HTTP, 45s) all pass. Note: web/dist in scratch needed a fresh make web for UI-asset tests (main worktree build was stale, missing dist/concepts/) — environmental only.

Docs (law 12): Decisions entries in 02 (+wire-contract note), 04, 05, 06 §14, 11 §8, features/10.

Repair/fsck scope: OUT of scope by decision (documented in 02). Old prefixed/duplicated entries stay readable (shape-agnostic readers); compaction folds legacy tier-0 packs into bare tier-1 (supersedes by stored checksum; gcSuperseded deletes old keys post-retention), so live sets converge without a dedicated migration pass.

Deviations: none (stdlib only; pre-1.0 no-alias law respected — no shims, old shape deleted in the same change).

Fixes #205: push/import/CLI producers derived PackRef.checksum with TrimSuffix-only on git's on-disk pack-<hex>.idx names, keeping the pack- infix in the manifest + bucket keys (wal/pack-<hex>.pack) against the 02 §2.2 bare-hex contract, and stacking a new pack- layer per re-ingest. newLocalPack additionally returned hollow claims for pack-less idx files (silent pack-upload skip). What changed: - internal/git: new PackChecksumFromIdx helper (single source of truth, 04_git.md). - internal/server bind_wal.go newLocalPack: strip infix; paths from the real on-disk basename; complete (.pack+.idx) pairs only — a pack-less idx now yields nil instead of a hollow claim; known-set also matches the bare form of stored checksums so materialized legacy packs are never re-published. - internal/repoimport task.go + cmd/walhub ops.go FullRepack tails: bare checksums, paths as pack-<bare>.pack. - internal/wal installPackFile: same-file no-op — the tails AddPack packs already in the serving copy (read-only repack output); self-copy truncated with EACCES. Found because the fixed tail exposed it (old code survived by writing a doubled pack-pack-<hex>.pack copy). - Readers verified shape-agnostic (all derive from the stored checksum); no reader changes. Tests (all go test -race green; make cover gate passes, every internal/... package >=95%): - internal/server: TestReceivePackPushBareChecksums (HTTP receive-pack, real engine+git: 2 pushes, bare manifest, bare keys, no prefixed keys); TestWalEngineNewLocalPackShapes (7-case matrix incl. legacy/doubled); TestWalEngineNewLocalPackFindsIngestedPack extended (bare manifest + key existence = upload not skipped); stray-idx tests updated to the nil contract. - internal/repoimport: TestImportPackChecksumsBareHex (full file:// import incl. tier-2 base). - internal/wal: TestPublish_LegacyPrefixedChecksumReads (legacy entry materializes; mixed old/new live set syncs); TestPublish_AddPackSameFileSkipsInstall (read-only preserved). - internal/git: TestPackChecksumFromIdx table. - Full suites: git, wal, server, repoimport, maintain, cmd/walhub, store-adjacent e2e (internal/e2e smart-HTTP, 45s) all pass. Note: web/dist in scratch needed a fresh make web for UI-asset tests (main worktree build was stale, missing dist/concepts/) — environmental only. Docs (law 12): Decisions entries in 02 (+wire-contract note), 04, 05, 06 §14, 11 §8, features/10. Repair/fsck scope: OUT of scope by decision (documented in 02). Old prefixed/duplicated entries stay readable (shape-agnostic readers); compaction folds legacy tier-0 packs into bare tier-1 (supersedes by stored checksum; gcSuperseded deletes old keys post-retention), so live sets converge without a dedicated migration pass. Deviations: none (stdlib only; pre-1.0 no-alias law respected — no shims, old shape deleted in the same change).
Push/import/CLI repack tails derived PackRef.checksum with
TrimSuffix-only on git's on-disk pack-<hex>.idx names, keeping the
pack- infix in the manifest and bucket keys (wal/pack-<hex>.pack)
against the 02 §2.2 bare-hex contract, and stacking a new pack- layer
per re-ingest. newLocalPack additionally returned hollow claims for
pack-less idx files (silent pack-upload skip).

- internal/git: new PackChecksumFromIdx helper (single source of truth)
- internal/server bind_wal.go: strip infix, sibling-derived paths,
  complete-pair claims only, legacy-known matching (no re-publish)
- internal/repoimport task.go, cmd/walhub ops.go: bare checksums +
  pack-<bare>.pack paths in the FullRepack tails
- internal/wal installPackFile: same-file no-op (repack outputs are
  read-only; self-copy truncated with EACCES)
- tests: HTTP push + engine shape matrix + import e2e + mixed-manifest
  reads + helper unit table; x_gaps{,7,8} updated to the new contract
- docs: Decisions entries in 02 (+wire-contract note), 04, 05, 06, 11,
  features/10; repair/fsck pass out of scope (readers shape-agnostic,
  compaction converges live sets to bare)
Sign in to join this conversation.
No description provided.