Skip to main content

Module pathjail_scope

Module pathjail_scope 

Source
Expand description

Path-jail scope: which directories the jail treats as the user’s own code.

The jail used to admit only the session’s project root (plus allow-lists). Anyone working on several repositories at once hit “path escapes project root” on every cross-project read, and the suggested fixes — one allow entry per directory, or env vars that need an MCP restart — did not scale.

  • home (default): every path inside a project below the user’s home directory is admitted for reading (a directory between it and ~ holds .git, Cargo.toml, … — loose personal files are not), except the protected zones where credentials and other programs’ private state live (every top-level dot entry such as ~/.ssh, ~/.aws, ~/.config, ~/.zshrc or other agents’ ~/.claude, plus ~/Library on macOS, ~/AppData and the NTUSER.DAT* registry hive on Windows). Paths outside the home directory stay jailed.
  • project: the classic boundary — the project root plus allow-lists.

Explicit allow-lists (allow_paths, extra_roots, read_only_roots) and lean-ctx’s own state dir still widen either scope, so lean-ctx allow-path ~/.config/foo reopens one protected directory without dropping the zone. path_jail = false keeps disabling the jail entirely.

Resolution precedence (first hit wins): LEAN_CTX_PATH_JAIL_SCOPE env → path_jail_scope in the global config.toml → home. Like path_jail it is global-only: a project-local .lean-ctx.toml is never merged for it.

Enums§

PathJailScope

Functions§

register_session_root
Records a session’s project (or host-declared) root as writable. Called for every tool call; broad roots (/, ~, temp dirs) are never recorded.