$ show kunobi-ninja/kache
Kache is a build cache system for Rust and C/C++ that acts as a transparent compiler wrapper (via RUSTC_WRAPPER or as a drop-in for cc/c++). It caches compilation artifacts using content-addressed storage with Blake3 hashing, enabling zero-copy restoration via reflinks/hardlinks/copies. The system features a daemon for asynchronous remote operations (S3/filesystem), a CLI/TUI for cache management and monitoring, and advanced capabilities like dependency chain analysis for cache misses, extra inputs for user-defined cache key influences, and predictive prefetching. Architecture-wise, it consists of a compiler wrapper core, a background daemon, a remote planning service (kache-service), and extensive testing/benchmarking harnesses. The code demonstrates strong craftsmanship in areas like cache key normalization, zero-copy restoration strategies, and compiler abstraction patterns.
The LLM identified 4 files worth highlighting for reuse:
Generates deterministic cache keys for Rust/C/C++ compilations by hashing normalized inputs (compiler version, source, dependencies, flags, environment). Features path normalization to sentinels (<WORKSPACE>, <HOME>), whitespace-normalized flag handling, and grouped hashing for miss diagnostics. Self-contained, depends only on blake3 and path normalization, making it highly reusable in any build system requiring reproducible caching.
Converts machine-local paths to sentinel tokens (e.g., <WORKSPACE>, <HOME>) to create cache keys portable across different machines and CI environments. Handles platform-specific path variations (Windows drive letters, case sensitivity, 8.3 names) and Unicode normalization. Demonstrates non-obvious skill in robust path manipulation while maintaining zero false positives/negatives in normalization decisions. Extractable as a standalone utility for any build reproducibility tool.
Defines a Compiler trait with RustcCompiler and CcCompiler implementations, enabling the wrapper to handle multiple compiler families through a uniform interface. Encapsulates compiler-specific quirks (argument parsing, output detection, environment handling) while providing a pluggable architecture for adding new compilers. Shows excellent separation of concerns and is a prime example of the adapter pattern applied to build tooling.
Implements a remote storage abstraction layer using OpenDAL to support S3, filesystem, and other backends through a unified interface. Handles connection management, retry logic, and credential handling while keeping the core cache logic storage-agnostic. The modular design allows swapping backends without touching cache internals, demonstrating clean separation between policy and mechanism in distributed systems.