Expand description
Protocol and storage primitives for mbx build caches.
This crate contains the types shared by cache clients, the task-scoped
cache agent, and remote cache implementations. Protocol records are
serialized with canonical_json before hashing; changing their shape is
therefore a wire-format change, not merely an implementation detail.
Most consumers start with CacheDigest and the local stores
LocalCas and LocalActionCache. Remote clients use
RemoteCacheClient, while mbx’s compiler shim communicates with a
CacheAgent using AgentRequest and AgentResponse.
use mbx_cache_core::{CacheDigest, canonical_json};
use serde::Serialize;
#[derive(Serialize)]
struct Key<'a> {
compiler: &'a str,
source: CacheDigest,
}
let source = CacheDigest::blake3(b"fn main() {}\n");
let bytes = canonical_json(&Key { compiler: "rustc", source })?;
let action = CacheDigest::blake3(&bytes);
assert_eq!(action.algorithm, "blake3");Structs§
- Action
Prediction - Adapter-owned data needed to reconstruct an action from a prior task run.
- Action
Promise Completion - Immutable completion of an invocation-wide compilation promise.
- Action
Promise Join - Request to join or claim one invocation-wide compilation promise.
- Agent
Remote Cache - Remote action-cache access owned by one task session.
- Agent
Stats - Aggregate cache activity for one task session.
- Blob
Pack Receipt - What a server did with the blobs in an uploaded pack.
- Blob
Upload - A digest paired with the data to upload under that digest.
- Blocking
Agent Client - A synchronous client over an already-connected local agent stream.
- Cache
Agent - Shared state for an agent hosted by the process that owns a build session.
- Cache
Digest - Algorithm-tagged digest and exact byte length of a cache object.
- Cache
Directory - A canonical directory object stored in the CAS.
- Cache
Directory Node - A child directory entry in a canonical cache directory.
- Cache
File Node - A file entry in a canonical cache directory.
- Cache
Symlink Node - A symbolic-link entry in a canonical cache directory.
- Capabilities
- Cache service capabilities negotiated before optional protocol features.
- Capability
Features - Optional server protocol features.
- Capability
Limits - Server-advertised request and object limits.
- Capability
Protocol - Version advertised by a cache service.
- CcMetadata
- C and C++ action metadata stored alongside compiled objects.
- Compiler
Stats - Count and cumulative wall time for one compiler-invocation outcome.
- File
Identity - The on-disk identity a recorded file digest describes.
- Local
Action Cache - A local index from action digests to their referenced cache objects.
- Local
Cas - A validated, content-addressed store on the local filesystem.
- NoFile
Digest Cache - A
FileDigestCachethat remembers nothing and finds nothing. - Path
Mapping - Mapping from a host-specific absolute root to a stable key placeholder.
- Recorded
File Digest - A file digest recorded against the identity it was read under.
- Remote
Action Manifest - Task action-manifest bytes returned with their concurrency token.
- Remote
Action Result - A canonical action-result record referencing objects in the CAS.
- Remote
Blob Pack - A verified set of remote CAS objects downloaded through blob-pack streams.
- Remote
Cache Client - A client for a remote mbx cache.
- Remote
Cache Config - Connection, authentication, and retry settings for
RemoteCacheClient. - Restore
Stats - Local output restoration work performed by one action-cache adapter hit.
- Rustc
Metadata - Rust-specific action metadata stored alongside compiled outputs.
- S3Credentials
- Long-lived or session credentials for an S3-compatible service.
- S3Remote
Cache Config - Connection, addressing, and credential settings for an S3 remote cache.
- Task
Action Manifest - Predictions associated with one stable task identity.
Enums§
- Action
Promise State - State returned when a client joins an invocation-wide promise.
- Agent
Event - One accounted cache decision, as it happens.
- Agent
Request - A request accepted by the task-scoped cache agent.
- Agent
Response - A response returned by the task-scoped cache agent.
- Blob
Source - Backing data for a blob upload.
- Digest
Algorithm - Hash algorithms supported by protocol version one.
- File
Digest Scope - What a recorded file digest may stand in for.
- Manifest
PutOutcome - Result of a conditional task-manifest write.
- Path
Normalization Error - Why a path could not be represented with the configured mappings.
- Remote
Cache Mode - Operations permitted against a configured remote cache.
- S3Conditional
Writes - Whether conditional writes are required, refused, or tried and given up on.
Constants§
- ACTION_
PROMISE_ MEDIA_ TYPE - Media type for ephemeral, invocation-keyed compilation promises.
- ACTION_
RESULT_ BATCH_ MEDIA_ TYPE - Media type for a JSON batch of
ActionResultrecords. - ACTION_
RESULT_ MEDIA_ TYPE - Media type for canonical
ActionResultJSON records. - AGENT_
PROTOCOL_ VERSION - Wire protocol version used between an in-process cache agent and its shims.
- BLOB_
MEDIA_ TYPE - Media type for opaque content-addressed blobs.
- BLOB_
PACK_ BLOBS_ HEADER - Header declaring the number of blobs in a blob pack.
- BLOB_
PACK_ BYTES_ HEADER - Header declaring the total payload bytes in a blob pack.
- BLOB_
PACK_ HEADER_ BYTES - Bytes before each blob pack payload: algorithm, hash, and length.
- BLOB_
PACK_ MAGIC - Magic prefix identifying a version-one blob pack.
- BLOB_
PACK_ MEDIA_ TYPE - Media type for framed batches of content-addressed blobs.
- BLOB_
PACK_ RECEIPT_ MEDIA_ TYPE - Media type for the receipt describing an accepted blob-pack upload.
- CLIENT_
METADATA_ MEDIA_ TYPE - Media type for adapter-specific action metadata blobs.
- DIGEST_
LIST_ MEDIA_ TYPE - Media type for a JSON list of digests.
- DIRECTORY_
MEDIA_ TYPE - Media type for canonical
DirectoryJSON records. - MAX_
ACTION_ PREDICTION_ PAYLOAD - Maximum serialized adapter payload in one action prediction.
- MAX_
ACTION_ PROMISE_ CLAIM_ BYTES - Maximum opaque lease-token length accepted for an action promise.
- NAMESPACE_
HEADER - Header carrying the caller’s isolated cache namespace.
- PROTOCOL_
HEADER - Header carrying the negotiated cache protocol version.
- PROTOCOL_
VERSION - Major version of the HTTP cache protocol.
- TASK_
ACTION_ MANIFEST_ MEDIA_ TYPE - Media type for task-to-action prediction manifests.
Traits§
- Agent
Event Observer - A sink for
AgentEvents observed during one session. - File
Digest Cache - Recorded digests a session may consult instead of rehashing a file.
Functions§
- canonical_
json - Serialize a protocol object using the JSON Canonicalization Scheme.
- is_
task_ identity - Whether
taskis a well-formed task action identity. - normalize_
mapped_ path - Map an absolute path to its cache-key placeholder form.
- normalize_
resolved_ mapped_ path - Normalize a path against mapping roots already resolved by
resolve_path_mappings. - resolve_
path_ mappings - Resolve filesystem aliases in mapping roots once for repeated lookups.
- task_
manifest_ actions - The action digests a task’s prediction manifest recorded.