Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
macro_sha_count_client
What it is
Part of document/file storage. A Redis-backed reference counter for content-addressed file blobs (SHA keys), used to know when a blob's last reference is gone and it's safe to delete.
Start here
src/lib.rs:Redis::increment_counts/release_shas(decrement) /sha_exists/find_non_existing_shas(_string).src/increment_count.rs,src/decrement_count.rs,src/exists.rs: the underlying Redis operations.
Scope
- Owns: reference counting for file content SHAs and the
bucket:sha-deletetracking used to find SHAs ready for cleanup. Counters are a cache, not the source of truth:"BomPart"rows are, andsha_cleanup_workerrecounts them before deleting anything. - Not here: actually deleting the underlying blob storage — this crate only tracks the reference count.
Boundaries
- Depends on:
model(forSaveBomPart). - Used by:
documents,projects,document_storage_service,docx_unzip_handler.
Checks
cargo test -p macro_sha_count_client(needs Redis atREDIS_URI, defaultredis://127.0.0.1:6379).
Gotchas
Every
sha:counter expiresSHA_REFERENCE_TTL(30 days) after the last increment. Set the expiry in the same MULTI/EXEC as any write that can create a counter, or the key lives forever in the shared cache, where volatile-lru cannot evict it (the 2026-10-28 OOM). A missing counter only makes the next upload re-send that part.release_shascollapses a list with duplicate SHAs into per-SHA counts before decrementing (reference_counts) — releasing the same SHA twice in one call removes two references, not one, so callers must pass every BOM reference, not a deduplicated set.
Related
- Skill:
dump-schema(if cross-checking againstdocument.save_bom_part)