Skip to main content

is_provider_ambient_home_dir

Function is_provider_ambient_home_dir 

Source
pub fn is_provider_ambient_home_dir(
    provider: &ProviderConfig,
    dir: &str,
) -> bool
Expand description

True when dir resolves to provider’s literal ambient home directory (e.g. ~/.claude for Claude Code) rather than an AgentMux-isolated dir. Used to block identity bindings/spawns from ever pointing a spawned agent at the operator’s own global CLI login — a real, currently-live instance of exactly this was found in this repo’s own data (an account’s secret_ref.dir set to the literal ambient path — see docs/status/STATUS_IDENTITY_ISOLATION_GATE_NOT_ENFORCING_2026_08_20.md §8), which nothing in the codebase previously validated against. See docs/specs/SPEC_BLOCK_AMBIENT_HOME_DIR_IDENTITY_BINDING_2026_08_25.md.

Canonicalizes both sides when possible (defeats .., symlink, and Windows \\?\-prefix tricks — same approach identity::cleanup’s containment check already uses); falls back to a normalized lexical comparison when either path doesn’t exist yet on disk (e.g. validating a not-yet-materialized dir at account-creation time), so a not-yet-created ambient path can’t slip past the guard just by not existing at check time.