Skip to main content

MemoryConfig

Struct MemoryConfig 

Source
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: PathBuf

Starting directory for the project-tier ancestor walk (typically cwd).

§project_walk_stop: WalkStop

Where 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: GlobSet

Gitignore-style patterns evaluated against paths relative to project_walk_root to skip CLAUDE.md / AGENTS.md / .caliban.md files.

§additional_directories_claude_md: bool

CALIBAN_ADDITIONAL_DIRECTORIES_CLAUDE_MD — load CLAUDE.md from --add-dir paths too.

§disable_walk: bool

CALIBAN_DISABLE_CLAUDE_MD_WALK — fall back to the legacy single-file project tier (regression escape).

§approve_imports: bool

CALIBAN_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: PathBuf

Path to the imports-allowlist JSON (~/.caliban/imports-allowlist.json).

§auto_memory_dir: PathBuf

Per-workspace auto-memory directory. Always set; may not exist yet.

§max_tokens: usize

Approximate 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: bool

CALIBAN_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

Source

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_HOME for global + auto-memory paths.
  • CALIBAN_MEMORY_DIR / CALIBAN_AUTO_MEMORY_DIRECTORY for auto-memory.
  • CALIBAN_MEMORY_BUDGET_TOKENS overrides the default 32_000 budget.
  • CALIBAN_MEMORY_CAP_TOKENS_AUTO sets the per-scope cap for the auto tier (unset = no per-scope cap).
  • CALIBAN_MEMORY_CAP_TOKENS_CLAUDE_MD sets the per-scope cap for the combined CLAUDE.md tier (global + project; unset = no per-scope cap).
  • CALIBAN_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1 enables CLAUDE.md load from --add-dir paths.
  • CALIBAN_DISABLE_CLAUDE_MD_WALK=1 reverts to the single-file project tier (regression escape).
  • CALIBAN_APPROVE_IMPORTS=1 auto-approves every external @-import.
  • CALIBAN_CLAUDE_MD_EXCLUDES is a colon-or-newline-separated list of gitignore-style patterns to skip during the ancestor walk.
Source§

impl MemoryConfig

Source

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.

Source

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.

Source

pub fn with_cap_tokens_claude_md(self, n: usize) -> Self

Builder-style setter for the per-scope CLAUDE.md-tier cap.

Source

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

Source§

fn clone(&self) -> MemoryConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more