Uh oh!
There was an error while loading. Please reload this page.
feat(cli): first-class fbuild cache save/restore/list/verify (#527) - #1014
Conversation
Consumers keeping `~/.fbuild/prod/cache/` warm across CI runs currently hand-pick six paths for `actions/cache@v4` — fragile, and it leaks fbuild's internal layout into every workflow. Add a first-class cache archiver that owns the layout and ships one portable `.tar.zst`. - `fbuild-packages::cache_archive` — the engine: hand-written prost manifest (no protoc), zstd(9) tar, content-hash (not mtime) per-slice fingerprints. Slices: toolchains, platforms, packages, libraries, archives, installed, index.sqlite (default); zccache engine store opt-in. save() / restore() / read_manifest() / verify() - `fbuild cache save|restore|list|verify` — thin in-process CLI (like `port scan`/`lnk`, no daemon round-trip): `--include/--exclude/--zstd-level /--cache-dir`, manifest dump for list, full re-hash for verify. v1 = full snapshot. Delta archives, mtime replay, and a zccache `gha-cache` sidecar are deferred to v2 (per the issue); zccache is available as a normal opt-in slice meanwhile. Verified end-to-end on real dirs: save → list → verify (VERIFIED OK) → restore reproduces the tree byte-for-byte (`diff -r` clean). 8 tests (engine round-trip/verify/select/corruption + CLI layer) green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughAdds a new "fbuild cache" CLI subcommand (save/restore/list/verify) backed by a new fbuild-packages cache_archive module that produces a manifest-based .tar.zst archive of cache slices (toolchains, platforms, packages, libraries, archives, installed, index.sqlite, optional zccache), with hash-based verification and safe restore. ChangesCache archive feature
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as fbuild CLI
participant Dispatch as dispatch::async_main
participant Cache as cache::run_cache
participant Archive as cache_archive
CLI->>Dispatch: fbuild cache save --archive out.tar.zst
Dispatch->>Cache: run_cache(CacheAction::Save)
Cache->>Archive: save(cache_dir, out_archive, selection, exclude, zstd_level)
Archive->>Archive: enumerate slices, hash content, build manifest
Archive->>Archive: write manifest + slices as tar.zst
Archive-->>Cache: CacheManifest
Cache-->>CLI: render_saved(manifest, archive size)
CLI->>Dispatch: fbuild cache verify --archive out.tar.zst
Dispatch->>Cache: run_cache(CacheAction::Verify)
Cache->>Archive: verify(archive)
Archive->>Archive: read_manifest + re-hash payload entries
Archive-->>Cache: CacheManifest (verified)
Cache-->>CLI: render_manifest(manifest, verified=true)
CLI->>Dispatch: fbuild cache restore --archive out.tar.zst
Dispatch->>Cache: run_cache(CacheAction::Restore)
Cache->>Archive: restore(archive, cache_dir)
Archive->>Archive: replay entries, skip unknown slices, reject ".." paths
Archive-->>Cache: CacheManifest
Cache-->>CLI: print restore summary
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes#527.
What
A first-class
fbuild cachesubcommand that packs the fbuild cache into one portable.tar.zst, replacing the fragile six-pathactions/cache@v4workaround every consumer grows.fbuild-packages::cache_archive— engine: hand-written prost manifest (no protoc), zstd(9) tar, content-hash (not mtime) per-slice fingerprints. Slices:toolchains, platforms, packages, libraries, archives, installed, index.sqlite(default) +zccache(opt-in).save/restore/read_manifest/verify.fbuild cache save|restore|list|verify— thin in-process CLI (likeport scan/lnk):--include/--exclude/--zstd-level/--cache-dir;listdumps the manifest,verifyre-hashes every slice.Scope
v1 is a full snapshot. Delta archives, mtime replay, and a zccache
gha-cachesidecar are deferred to v2 (per the issue); the zccache store is available as a normal opt-in slice meanwhile.Verified locally (end-to-end, real dirs)
8 tests green (engine round-trip / verify / include−exclude / corruption-detect / CLI layer); clippy + fmt clean.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
fbuild cachecommand with options to save, restore, list, and verify cache archives..tar.zstfile and restored later.Bug Fixes