Expand description
Per-session grok leader isolation.
grok’s interactive UI may attach to a shared, long-lived “leader” backend (use_leader in
its config). The leader then runs every tool call with its own process environment, so
the node’s per-session environment (for example the m4a session identity) never reaches
the tools. A node-spawned grok session therefore gets its own --leader-socket: the backend
it starts is that session’s alone and inherits that session’s environment. The grok home
and its login are unchanged.
The leader outlives its UI by design, so the node retires it when the session ends: it stops only processes whose command line carries this session’s unique socket tag. Another leader (an operator’s shared one included) never carries that tag and is never touched.
Constants§
- SESSION_
LEADER_ ENV - Set to
0/offto let node-spawned grok sessions use grok’s own leader configuration. - SOCKET_
PREFIX - File-name prefix of every per-session socket; the tag the retire step matches on.
Functions§
- disabled
- leader_
socket_ args - retire
- Stops this session’s own leader (and only it), then removes its socket file.
- retire_
tag - The tag
retirematches on, orNonefor a path that is not a per-session socket (so a foreign path can never widen the match). - session_
tag - Short, stable tag for one session key (keeps Unix socket paths well under their limit).
- socket_
path <root>/grok-leaders/<tag>.sock; the directory is created best effort.