Skip to content

feat: extend GC reclone to support ledger repos (replace temporary LFS repair) #242

@rsnodgrass

Description

@rsnodgrass

Summary

TriggerGC currently only handles team context repos. Ledger repos need the same blue-green GC reclone support to recover from corrupted state (missing LFS objects, diverged history, etc.).

Current state

  • Team context GC: TriggerGC() in sync.go does blue-green reclone — works well
  • Ledger LFS repair: RepairMissingLFSObjects() in gitutil/lfs_repair.go is a temporary mechanism that replaces orphaned LFS pointers with empty stubs + sets allowincompletepush. This is a workaround, not a proper fix.
  • The real fix: A ledger GC that does fresh clone from remote + carries over unpushed local commits (session data). This is exactly what was done manually to fix the sageox/ox ledger today.

Why ledger GC is needed

After daemon GC reclone of team contexts, locally-committed LFS objects in the ledger that were never pushed are lost. The remote's pre-receive hook then rejects all future pushes because historical commits reference missing LFS OIDs. The temporary repair (lfs_repair.go) mitigates this but:

  1. Requires lfs.allowincompletepush which only bypasses the local check
  2. Server-side GitLab pre-receive hook still rejects if old OIDs are in push range
  3. History rewriting requires force push, which is blocked on protected branches
  4. The clean approach (fresh clone + replay local data) is what GC already does for team contexts

Implementation plan

  1. Extend TriggerGC (or add TriggerLedgerGC) to support ledger repos
  2. Blue-green reclone: fresh clone → identify unpushed local commits → cherry-pick/replay session data → swap
  3. The temporary RepairMissingLFSObjects can remain as a fallback for non-GC scenarios
  4. Add ox doctor --gc-ledger or extend existing --gc flag

Related

Co-Authored-By: SageOx ox@sageox.ai

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions