|
Entropic 2.14.3
Local-first agentic inference engine
|
Per-session llama sequence slots and their resident tokens. More...
#include </home/runner/work/entropic/entropic/src/inference/session_residency.h>
Public Member Functions | |
| SessionResidency (int slots=1) | |
| Size the pool. | |
| int | slot_for (const std::string &key) const |
| Slot currently holding this session, if any. | |
| int | acquire (const std::string &key, std::string *evicted) |
| Assign a slot to this session, evicting the least-recently used one when the pool is full. | |
| const std::vector< Tok > & | resident (int slot) const |
| Tokens recorded as resident in a slot. | |
| void | set_resident (int slot, std::vector< Tok > tokens) |
| Record what a slot now holds after a decode. | |
| void | invalidate (int slot) |
| Forget a slot's residency (its KV was cleared or invalidated). | |
| void | invalidate_all () |
| Forget every slot's residency. | |
| int | forget_session (const std::string &key) |
| Drop one SESSION's residency and release its slot (gh#165). | |
| int | slots () const |
| Number of sequence slots in the pool. | |
| std::size_t | assigned_count () const |
| How many sessions currently hold a slot. | |
Per-session llama sequence slots and their resident tokens.
| Tok | Token type (llama_token in production; int in tests). |
Definition at line 54 of file session_residency.h.
|
inlineexplicit |
Size the pool.
| slots | Number of llama sequences available (>= 1). |
Definition at line 61 of file session_residency.h.
|
inline |
Assign a slot to this session, evicting the least-recently used one when the pool is full.
| key | Session key. | |
| [out] | evicted | Receives the key evicted to make room, empty when nothing was evicted. The caller must clear that slot's KV. |
key. @req REQ-INFER-019 Definition at line 88 of file session_residency.h.
|
inline |
How many sessions currently hold a slot.
Definition at line 203 of file session_residency.h.
|
inline |
Drop one SESSION's residency and release its slot (gh#165).
invalidate(slot) needs a slot; a restore only knows a key, and after a restore the session should not hold a slot at all — it has no resident prefix worth keeping and another session may want the sequence.
Warm-keep is prefix-correct on its own (it reuses only the common token prefix and seq_rm's the divergent tail), so this is belt AND braces — deliberately. The reuse gate is token equality, not conversation identity, so a future change that coarsened it would silently decode a restored session against the prefix of the one it replaced. Dropping the residency makes the restore correct by construction rather than by an argument about the gate.
| key | Session key. |
Definition at line 180 of file session_residency.h.
Forget a slot's residency (its KV was cleared or invalidated).
| slot | Slot index. @req REQ-INFER-019 |
Definition at line 139 of file session_residency.h.
|
inline |
Forget every slot's residency.
For the unconditional whole-context clears that still exist on some paths — after one of those, no slot holds what we think it does. @req REQ-INFER-019
Definition at line 153 of file session_residency.h.
|
inline |
Tokens recorded as resident in a slot.
| slot | Slot index. |
Definition at line 114 of file session_residency.h.
|
inline |
Record what a slot now holds after a decode.
| slot | Slot index. |
| tokens | Tokens now resident. @req REQ-INFER-019 |
Definition at line 127 of file session_residency.h.
|
inline |
Slot currently holding this session, if any.
| key | Session key ("" is the default session). |
Definition at line 72 of file session_residency.h.
|
inline |
Number of sequence slots in the pool.
Definition at line 195 of file session_residency.h.