pub struct MemoryConfig {Show 16 fields
pub global_path: Option<PathBuf>,
pub project_path: Option<PathBuf>,
pub project_walk_root: PathBuf,
pub project_walk_stop: WalkStop,
pub additional_dirs: Vec<PathBuf>,
pub claude_md_excludes: GlobSet,
pub additional_directories_claude_md: bool,
pub disable_walk: bool,
pub approve_imports: bool,
pub non_interactive: bool,
pub imports_allowlist_path: PathBuf,
pub auto_memory_dir: PathBuf,
pub max_tokens: usize,
pub cap_tokens_auto: Option<usize>,
pub cap_tokens_claude_md: Option<usize>,
pub disable_auto: bool,
}Expand description
Resolved configuration for one memory-load invocation.
Holds a handful of boolean knobs (regression escape + non-interactive +
additional-dirs + approve-imports). Clippy’s struct_excessive_bools
would otherwise nudge us to bucket them, but their semantics are distinct
enough that operators benefit from the flat list — keep them inline.
Fields§
§global_path: Option<PathBuf>Path to the operator-global CLAUDE.md. None if none was discoverable.
project_path: Option<PathBuf>Legacy single-file project tier path. Still honored when
MemoryConfig::disable_walk is true (regression escape).
project_walk_root: PathBufStarting directory for the project-tier ancestor walk (typically cwd).
project_walk_stop: WalkStopWhere the walk stops (defaults to Both).
additional_dirs: Vec<PathBuf>Additional --add-dir paths. Each contributes its own ancestor walk
when MemoryConfig::additional_directories_claude_md is true.
claude_md_excludes: GlobSetGitignore-style patterns evaluated against paths relative to
project_walk_root to skip CLAUDE.md / AGENTS.md / .caliban.md files.
additional_directories_claude_md: boolCALIBAN_ADDITIONAL_DIRECTORIES_CLAUDE_MD — load CLAUDE.md from
--add-dir paths too.
disable_walk: boolCALIBAN_DISABLE_CLAUDE_MD_WALK — fall back to the legacy single-file
project tier (regression escape).
approve_imports: boolCALIBAN_APPROVE_IMPORTS — auto-approve every external @-import.
non_interactive: bool--print / --bare / similar — short-circuit the import dialog to
auto-deny. Defaults to false (interactive). Set by the binary based
on its run mode.
imports_allowlist_path: PathBufPath to the imports-allowlist JSON (~/.caliban/imports-allowlist.json).
auto_memory_dir: PathBufPer-workspace auto-memory directory. Always set; may not exist yet.
max_tokens: usizeApproximate token budget for the combined memory prefix.
cap_tokens_auto: Option<usize>Optional per-scope cap for the auto-memory tier. When set, the auto
tier is truncated to fit this cap before the combined max_tokens
ceiling is applied. None means “no per-scope cap; only the combined
ceiling applies”.
cap_tokens_claude_md: Option<usize>Optional per-scope cap for the combined CLAUDE.md tier (global +
project). When set, truncates project first, then global, to fit. None
means “no per-scope cap”.
disable_auto: boolCALIBAN_DISABLE_AUTO_MEMORY — kill-switch: drop the auto-memory tier
from the prefix entirely. Resolved from the environment once in
MemoryConfig::from_env and defaulted to false in
MemoryConfig::for_test, so crate::loader::load never reads the
process environment directly (which previously raced with env-mutating
tests under parallel execution).
Implementations§
Source§impl MemoryConfig
impl MemoryConfig
Sourcepub fn from_env(workspace_root: &Path) -> Self
pub fn from_env(workspace_root: &Path) -> Self
Resolve a MemoryConfig from the environment + the given workspace root.
Env vars honored:
XDG_CONFIG_HOME/XDG_DATA_HOMEfor global + auto-memory paths.CALIBAN_MEMORY_DIR/CALIBAN_AUTO_MEMORY_DIRECTORYfor auto-memory.CALIBAN_MEMORY_BUDGET_TOKENSoverrides the default32_000budget.CALIBAN_MEMORY_CAP_TOKENS_AUTOsets the per-scope cap for the auto tier (unset = no per-scope cap).CALIBAN_MEMORY_CAP_TOKENS_CLAUDE_MDsets the per-scope cap for the combined CLAUDE.md tier (global + project; unset = no per-scope cap).CALIBAN_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1enables CLAUDE.md load from--add-dirpaths.CALIBAN_DISABLE_CLAUDE_MD_WALK=1reverts to the single-file project tier (regression escape).CALIBAN_APPROVE_IMPORTS=1auto-approves every external@-import.CALIBAN_CLAUDE_MD_EXCLUDESis a colon-or-newline-separated list of gitignore-style patterns to skip during the ancestor walk.
Source§impl MemoryConfig
impl MemoryConfig
Sourcepub fn for_test(auto_memory_dir: PathBuf) -> Self
pub fn for_test(auto_memory_dir: PathBuf) -> Self
Construct a minimal config for unit tests / library callers that don’t want to read from the process environment. All env-driven fields take their defaults; only the auto-memory directory and the token budget are caller-controlled.
Sourcepub fn with_cap_tokens_auto(self, n: usize) -> Self
pub fn with_cap_tokens_auto(self, n: usize) -> Self
Builder-style setter for the per-scope auto-tier cap. Allows callers
(typically the binary at startup, reading from [memory] settings) to
override the env-driven value.
Sourcepub fn with_cap_tokens_claude_md(self, n: usize) -> Self
pub fn with_cap_tokens_claude_md(self, n: usize) -> Self
Builder-style setter for the per-scope CLAUDE.md-tier cap.
Sourcepub fn effective_cap(&self, this_cap: usize, other_cap: Option<usize>) -> usize
pub fn effective_cap(&self, this_cap: usize, other_cap: Option<usize>) -> usize
Compute the effective per-scope cap accounting for the combined
ceiling. When the sum of both per-scope caps would exceed max_tokens,
each is scaled down proportionally so the sum equals max_tokens.
this_cap is the per-scope cap being computed; other_cap is the
other per-scope cap (used to compute the per-scope sum). When the
other cap is unset, the combined ceiling is treated as its value.
Trait Implementations§
Source§impl Clone for MemoryConfig
impl Clone for MemoryConfig
Source§fn clone(&self) -> MemoryConfig
fn clone(&self) -> MemoryConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more