Expand description
Re-entrancy markers that stop nested lean-ctx invocations from
double-compressing — decoupled from the user-facing activation flag.
Two distinct signals were historically conflated in LEAN_CTX_ACTIVE
(GH #533), which silently disabled compression for any agent that
inherited it:
LEAN_CTX_ACTIVE: shell-hook re-entry guard. Stops the shell hook from re-firing inside a command lean-ctx already spawned. It is a plain env var an agent’s top-level process can legitimately inherit.WRAP_MARKER(LEAN_CTX_WRAPPED): process-level ownership. Set ONLY by lean-ctx on the children it spawns, so its presence reliably means “a parent lean-ctx already owns compression of this command tree” and a nestedlean-ctx -cmust pass through. Because lean-ctx is the only writer, an agent cannot trigger it by leaking an env var.
Functions§
- is_
wrapped - True when a parent lean-ctx already owns this command tree. Nested explicit
lean-ctx -cshould defer to the ambient shell defaults, not force raw command bytes, so shell-hook compression can still apply when configured. - mark_
child - Stamp a child command so nested lean-ctx invocations pass through and the
shell hook does not re-fire: sets both the ownership marker
(
WRAP_MARKER) and the legacy hook guard (LEAN_CTX_ACTIVE). - should_
pass_ through - True when
lean-ctx -c/-tmust avoid owning compression itself: either a parent lean-ctx already owns this command tree (WRAP_MARKER) or compression is globally disabled (LEAN_CTX_DISABLED).