Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
session_scoped.h File Reference

Server state that belongs to a SESSION, not to the server (gh#158). More...

#include <cstddef>
#include <mutex>
#include <string>
#include <unordered_map>
Include dependency graph for session_scoped.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  entropic::SessionScoped< T >
 One T per session key, under one leaf mutex (gh#158). More...
 
class  entropic::SessionStateOwner
 A server that keeps state per session and can release it (gh#158). More...
 

Namespaces

namespace  entropic
 Activate model on GPU (WARM → ACTIVE).
 

Detailed Description

Server state that belongs to a SESSION, not to the server (gh#158).

Why
concurrent_sessions defaults true, so every unbound session on a handle runs against ONE default server set. A built-in server that keeps conversation-describing state on itself — the filesystem server's read-before-write tracker, the entropic server's todo list — therefore pooled it across sessions: session B could overwrite a file only session A had read, and B's todo result listed A's items. That is the shape decision #66 fixed for the ConstitutionalValidator's per-turn fields — per-handle storage of a per-conversation thing — and locking it (46d3474, 095a2f2) made it safe without making it right.
The key
current_run_session(): the session the dispatching ToolExecutor routed the call on, which it publishes to its own thread around every dispatch (a run is a blocking call on its thread, so the value is unambiguous — the same argument as RunCancelScope, decision #66). A delegated child inherits its parent's key, so a child's read legitimately satisfies its parent's write. Outside a run the key is "", the default session.
Lifetime
An entry lives until the conversation it describes ends: the facade releases it on entropic_session_drop, entropic_session_context_clear, entropic_session_context_set and entropic_context_clear, through ServerManager::release_session and the SessionStateOwner interface below. Without that the map would grow by one entry per session a long-running host ever served.
Why not a virtual on MCPServerBase
Its vtable is part of the plugin ABI (i_mcp_server.h); a server that owns per-session state opts in by also deriving SessionStateOwner, and the manager finds it with a cross-cast — the base class does not change.
Version
2.13.0

Definition in file session_scoped.h.