Skip to main content

Module grok_leader

Module grok_leader 

Source
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 / off to 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 retire matches on, or None for 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.