pub struct ImportState<'a> {
pub workspace_root: PathBuf,
pub allowlist: ImportAllowlist,
pub allowlist_path: Option<PathBuf>,
pub approval: ApprovalMode<'a>,
pub loaded: BTreeSet<PathBuf>,
pub depth: u8,
pub import_stack: Vec<PathBuf>,
pub bytes_emitted: usize,
pub bytes_shed: usize,
pub session_allow_once: BTreeSet<PathBuf>,
}Expand description
Mutable state shared across all @-imports during a single tier load.
Holds the depth counter, the import stack (cycle detection), the already-loaded set (dedupe), the running byte budget, and the approval mode.
Fields§
§workspace_root: PathBufWorkspace root — any resolved path not under this directory
requires approval (also tolerated under ~/.config/caliban).
allowlist: ImportAllowlistAllowlist of pre-approved external paths.
allowlist_path: Option<PathBuf>Path to the allowlist file on disk (used when persisting “always”).
approval: ApprovalMode<'a>Approval mode (interactive / auto-allow / auto-deny).
loaded: BTreeSet<PathBuf>Files already loaded — second @-import of the same path skips.
depth: u8Current recursion depth (top-level body is depth 0).
import_stack: Vec<PathBuf>Cycle-detection stack of canonical paths currently being resolved.
bytes_emitted: usizeBytes of imported content emitted so far.
bytes_shed: usizeBytes shed by the per-tier budget cap.
session_allow_once: BTreeSet<PathBuf>Allow-once tracking (in-memory, session-scoped).
Implementations§
Source§impl<'a> ImportState<'a>
impl<'a> ImportState<'a>
Sourcepub fn new(workspace_root: PathBuf, approval: ApprovalMode<'a>) -> Self
pub fn new(workspace_root: PathBuf, approval: ApprovalMode<'a>) -> Self
Build a fresh state with the given approval mode and workspace root.
Sourcepub fn with_allowlist(
self,
allowlist: ImportAllowlist,
path: Option<PathBuf>,
) -> Self
pub fn with_allowlist( self, allowlist: ImportAllowlist, path: Option<PathBuf>, ) -> Self
Attach an allowlist (loaded from disk) and remember the persistence path.