pub struct EvalContext {
pub home: String,
pub project: Option<String>,
pub real_home: Option<String>,
pub real_project: Option<String>,
pub moved_dirs: Vec<(String, String)>,
pub cwd: String,
pub case_insensitive_paths: bool,
}Expand description
Everything the engine needs from the environment. Supplied by the caller.
Fields§
§home: StringThe user’s home directory, for ~ and $HOME.
project: Option<String>The trusted project root, for ${project}. None when the session has
no project the caller is willing to trust (it would be the home directory,
one of its ancestors or a filesystem root): every pattern naming
${project} then matches nothing, so project-scoped allows do not apply.
real_home: Option<String>home with its symlinks resolved, when that differs (a home on a linked
volume, a Windows 8.3 short name). Patterns naming ~ match under both
spellings, since the caller’s PathResolver reports paths in this one.
real_project: Option<String>project with its symlinks resolved, when that differs (macOS /tmp →
/private/tmp, ~/code → /Volumes/dev/code). Patterns naming
${project} match under both spellings, exclusions included, so a file
in the project is the project’s however its path is written. A link
inside the project changes nothing here: its target is checked as is.
moved_dirs: Vec<(String, String)>Directories an environment variable moved out of the home directory
(MOAT_HOME, CLAUDE_CONFIG_DIR, CODEX_HOME, CURSOR_CONFIG_DIR), as
(default, moved) pairs such as ("~/.claude", "/srv/claude"). A
pattern naming default or a path below it also matches the same path
under moved, so rules about a host’s directory follow it when it moves.
cwd: StringThe directory relative paths are taken from.
case_insensitive_paths: boolWhether file paths compare case-insensitively, as on the default macOS and Windows file systems. Host names always do; names never do.
Implementations§
Source§impl EvalContext
impl EvalContext
Sourcepub fn spellings(&self, raw: &str) -> Vec<String>
pub fn spellings(&self, raw: &str) -> Vec<String>
raw expanded once per spelling of the home directory and project root
it names (paths::expand_pattern), and once more per directory in
Self::moved_dirs it falls under; empty when it names no location.
The policy compiler (ir) lowers patterns through the same expansion,
and openmoat run finds where a policy pattern points with it.