gabriel / muse public
gc.md markdown
72 lines 2.3 KB
Raw
sha256:660fcac1df3ab28f61862e961890bd2ca8b754fa0242079d93ca1e25037ec8a6 chore(tests): add docstring to tests/__init__.py so rc14 tr… Human 26 days ago

muse gc — garbage-collect unreachable objects

Muse stores every tracked file as a content-addressed blob under .muse/objects/. Over time — after branch deletions, abandoned experiments, or squash merges — blobs that are no longer reachable from any live commit accumulate and waste disk space. muse gc identifies and removes them.

How it works

  1. Reachability walk: Starting from every live branch head and tag, Muse walks the commit graph:
    branch HEAD → CommitRecord → SnapshotRecord → manifest → object SHA-256
    
  2. Unreachable detection: Any object not reachable from step 1 is garbage.
  3. Deletion (if not --dry-run): Unreachable objects are deleted. Empty prefix directories are also cleaned up.

Usage

muse gc                  # remove unreachable objects (safe default)
muse gc --dry-run        # show what would be removed without touching anything
muse gc --verbose        # print each removed object ID

Options

Flag Default Description
--dry-run, -n false Preview only — no files are deleted
--verbose, -v false Print each collected object ID

Output

Removed 12 object(s) (48.3 KiB) in 0.031s  [247 reachable]

In --dry-run mode:

[dry-run] Would remove 12 object(s) (48.3 KiB) in 0.028s  [247 reachable]

Safety guarantees

  • The reachability walk always completes before any deletion begins.
  • --dry-run is always safe to run — even in production, even by agents.
  • GC never touches commit or snapshot records — only content blobs.
  • Running GC is idempotent: running it twice produces the same result.

When to run

Trigger Recommendation
After deleting branches muse gc
Weekly CI maintenance muse gc --dry-run to audit, then muse gc
Before muse archive muse gc to shrink the repo
After a large squash merge muse gc to free replaced blobs

Agent workflows

# Audit unreachable bloat before a deployment:
muse gc --dry-run

# Automated nightly cleanup:
muse gc 2>&1 | logger -t muse-gc

Exit codes

Code Meaning
0 Success (even if nothing was collected)
1 Internal error (corrupt store, permission issue)
File History 3 commits
sha256:660fcac1df3ab28f61862e961890bd2ca8b754fa0242079d93ca1e25037ec8a6 chore(tests): add docstring to tests/__init__.py so rc14 tr… Human 26 days ago
sha256:d8316ffae901be06347e16ab55be11868eb519dd16ade3e8aa16a99e662f7e62 baseline: rc14 re-baseline after rc3 store corruption recovery Human patch 26 days ago
sha256:1c4b3e3a9a1f300774c3ee662b572a698d5fd405bf765a71e6011a2e9c3eaaaa feat: Muse — version control for the agent era Human 100 days ago