session_cache
session_cache
¶
The volatile unlock cache — one tier, two backings.
The cache tier of the passphrase chain holds the vault passphrase for
the login session. The cache has no timeout; vault lock clears it;
a reboot removes it. Which backing holds it follows where this host
runs the supervisor, the reader that has to find it
(supervisor_placement):
a user-unit supervisor reads the operator's kernel keyring
(kernel_keyring), so that
is the backing; a supervisor inside the container runtime's namespace
sees an empty keyring there, so the tier is a tmpfs session file
(session_file), a path
being a path in any namespace. The file also stands in where the
kernel facility itself is unusable. The status surfaces name the
backing and the reason, so a degradation is never silent.
Callers use this module, not a backing, for every cache operation.
forget clears both backings: facility availability can change
between boots, and vault lock must not leave a live cache in the
backing this boot does not prefer.
__all__ = ['backing_detail', 'forget', 'is_cached', 'load', 'store', 'unavailable_reason']
module-attribute
¶
store(passphrase, db_path)
¶
Cache passphrase for db_path in the session's preferred backing.
load(db_path)
¶
forget(db_path)
¶
Clear the cache for db_path from both backings.
Returns:
| Type | Description |
|---|---|
bool
|
True when no backing can still hold the cache, False when either |
bool
|
removal failed and a live cache may remain. |
Source code in src/terok_sandbox/vault/store/session_cache.py
is_cached(db_path)
¶
Return True when the preferred backing holds a cache for db_path.
unavailable_reason()
¶
Explain why no backing can hold the cache here, or None when one can.
A file backing that fails names why the keyring was not the choice first, so the operator reads both facts in one line.
Source code in src/terok_sandbox/vault/store/session_cache.py
backing_detail(*, cached)
¶
Human detail for the cache tier in the vault status chain.
Separates the states an operator acts on differently: which backing serves this session and why, whether it holds a passphrase, and why the tier cannot run at all.