Project store¶
The persistent, size-limited, content-addressed directory every cache of a project lives in,
managed from the command line by qvr cache.
store
¶
A persistent, size-limited, content-addressed store for a project's caches.
The store keeps every cached artifact of a project (checked modules, compiled
deductions, fitted runs) under one directory, .qvr/cache at the project
root by default. Entries are addressed by a namespace and a 64-character
digest of everything that determines them, so an entry is either exactly the
artifact its key describes or absent: a key never names stale content.
The store has a byte limit. Writing past it evicts the least recently used
entries until the store fits again, and ArtifactStore.prune and the
qvr cache command evict on demand. Every payload is stored with its BLAKE3
digest and checked on every read.
CACHE_FORMAT
module-attribute
¶
The layout version of the store directory; a store of another layout is a sibling directory, never read.
DEFAULT_MAX_BYTES
module-attribute
¶
The byte limit of a store that has not been given one: 2 GiB.
CACHE_DIRECTORY_VARIABLE
module-attribute
¶
The environment variable that overrides the cache directory.
PROJECT_MARKERS
module-attribute
¶
The entries whose presence marks a directory as a project root, in the order a search checks them in each directory.
StoreError
¶
Bases: RuntimeError
The store cannot honor a request: a bad key, a corrupt entry, a limit.
StoreEntry
didactic-model
¶
StoreEntry(*, namespace: str, key: str, size: int, digest: str, created: float, accessed: float, label: str = '')
Bases: Model
One cached artifact.
| PARAMETER | DESCRIPTION |
|---|---|
namespace
|
The kind of artifact (
TYPE:
|
key
|
The digest of everything that determines the artifact.
TYPE:
|
size
|
The payload's size in bytes.
TYPE:
|
digest
|
The BLAKE3 digest of the payload, checked on every read.
TYPE:
|
created
|
When the entry was written, in seconds since the epoch.
TYPE:
|
accessed
|
When the entry was last written or read, in seconds since the epoch.
TYPE:
|
label
|
A human-readable description of what the entry holds.
TYPE:
|
NamespaceUsage
didactic-model
¶
Bases: Model
How much one namespace of a store holds.
| PARAMETER | DESCRIPTION |
|---|---|
namespace
|
The namespace.
TYPE:
|
entries
|
Its number of entries.
TYPE:
|
size
|
Their total payload size in bytes.
TYPE:
|
StoreUsage
didactic-model
¶
StoreUsage(*, root: str, entries: int, size: int, max_bytes: int, namespaces: tuple[NamespaceUsage, ...] = ())
Bases: Model
How much a store holds.
| PARAMETER | DESCRIPTION |
|---|---|
root
|
The store directory.
TYPE:
|
entries
|
The number of entries.
TYPE:
|
size
|
Their total payload size in bytes.
TYPE:
|
max_bytes
|
The store's byte limit.
TYPE:
|
namespaces
|
Each namespace's usage, sorted by name.
TYPE:
|
ArtifactStore
¶
A content-addressed artifact store rooted at one directory.
| PARAMETER | DESCRIPTION |
|---|---|
root
|
The store directory. It is created on the first write.
TYPE:
|
Source code in src/quivers/incremental/store.py
max_bytes
property
¶
The store's byte limit.
| RETURNS | DESCRIPTION |
|---|---|
int
|
The limit recorded in the store's configuration, or
|
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If the configuration file is not a valid limit record. |
for_project
classmethod
¶
for_project(start: Path | None = None) -> ArtifactStore
The store of the project a path belongs to.
| PARAMETER | DESCRIPTION |
|---|---|
start
|
A path inside the project; the working directory when None.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ArtifactStore
|
The store at |
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If no project root is found and no override is set. |
Source code in src/quivers/incremental/store.py
set_max_bytes
¶
set_max_bytes(limit: int) -> tuple[StoreEntry, ...]
Set the store's byte limit and evict down to it.
| PARAMETER | DESCRIPTION |
|---|---|
limit
|
The new limit in bytes; must be positive.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[StoreEntry, ...]
|
The entries evicted to fit the new limit. |
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If the limit is not positive. |
Source code in src/quivers/incremental/store.py
get
¶
Read an entry's payload and mark it used.
| PARAMETER | DESCRIPTION |
|---|---|
namespace
|
The namespace.
TYPE:
|
key
|
The key.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bytes or None
|
The payload, or None when the store has no such entry. |
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If the address is malformed, or the payload does not match the digest recorded with it. A corrupt entry is reported, never served and never silently replaced. |
Source code in src/quivers/incremental/store.py
payload_path
¶
The verified payload file of an entry, marked used.
| PARAMETER | DESCRIPTION |
|---|---|
namespace
|
The namespace.
TYPE:
|
key
|
The key.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path or None
|
The payload file, for a reader that needs a path rather than bytes, or None when the store has no such entry. The file must be read, not modified. |
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If the address is malformed or the payload does not match its recorded digest. |
Source code in src/quivers/incremental/store.py
staging_path
¶
A fresh file path inside the store for writing an artifact.
| PARAMETER | DESCRIPTION |
|---|---|
label
|
A short name for the file, used as its prefix.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path
|
A path in the store's staging directory that does not exist yet. Staging lives with the store, on the project's disk, so an artifact is never written to a temporary directory. |
Source code in src/quivers/incremental/store.py
put
¶
put(namespace: str, key: str, payload: bytes, *, label: str = '') -> StoreEntry
Write an entry, then evict down to the byte limit.
| PARAMETER | DESCRIPTION |
|---|---|
namespace
|
The namespace.
TYPE:
|
key
|
The key.
TYPE:
|
payload
|
The artifact.
TYPE:
|
label
|
A description shown by
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
StoreEntry
|
The written entry. |
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If the address is malformed or the payload alone exceeds the store's limit. |
Source code in src/quivers/incremental/store.py
entries
¶
entries(namespace: str | None = None) -> tuple[StoreEntry, ...]
Every entry, most recently used first.
| PARAMETER | DESCRIPTION |
|---|---|
namespace
|
Only this namespace, or every namespace when None.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[StoreEntry, ...]
|
The entries. |
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If the namespace is malformed or an entry's metadata is corrupt. |
Source code in src/quivers/incremental/store.py
remove
¶
Delete one entry.
| PARAMETER | DESCRIPTION |
|---|---|
namespace
|
The namespace.
TYPE:
|
key
|
The key.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
Whether the entry existed. |
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If the address is malformed. |
Source code in src/quivers/incremental/store.py
clear
¶
Delete every entry, or every entry of one namespace.
| PARAMETER | DESCRIPTION |
|---|---|
namespace
|
The namespace to clear, or None for the whole store.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
int
|
How many entries were deleted. |
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If the namespace is malformed. |
Source code in src/quivers/incremental/store.py
prune
¶
prune(*, max_bytes: int | None = None, older_than: float | None = None, keep: tuple[str, str] | None = None) -> tuple[StoreEntry, ...]
Evict entries by age and then by size.
| PARAMETER | DESCRIPTION |
|---|---|
max_bytes
|
Evict least recently used entries until the store holds at most this many bytes; the store's limit when None.
TYPE:
|
older_than
|
First evict every entry not used for this many seconds; nothing is evicted by age when None.
TYPE:
|
keep
|
The namespace and key of one entry never to evict, the one just written.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[StoreEntry, ...]
|
The evicted entries. |
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If an entry's metadata is corrupt. |
Source code in src/quivers/incremental/store.py
usage
¶
usage() -> StoreUsage
How much the store holds.
| RETURNS | DESCRIPTION |
|---|---|
StoreUsage
|
Entry counts and byte totals, overall and per namespace. |
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If an entry's metadata is corrupt. |
Source code in src/quivers/incremental/store.py
find_project_root
¶
The root of the project a path belongs to.
| PARAMETER | DESCRIPTION |
|---|---|
start
|
A file or directory inside the project.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path
|
The nearest directory, from |
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If no directory from |
Source code in src/quivers/incremental/store.py
default_cache_directory
¶
The cache directory of the project a path belongs to.
| PARAMETER | DESCRIPTION |
|---|---|
start
|
A path inside the project; the working directory when None.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Path
|
|
| RAISES | DESCRIPTION |
|---|---|
StoreError
|
If the variable is unset and no project root is found. |