pub struct WorkspaceAccessPolicy { /* private fields */ }Expand description
Single-source-of-truth filesystem allowlist evaluated by in-process file
tools (read_file, apply_patch), host-process sandboxes (merry-process),
and persistence guards (merry-app).
Implementations§
Source§impl WorkspaceAccessPolicy
impl WorkspaceAccessPolicy
Sourcepub fn new(workspace_root: impl Into<PathBuf>, workspace_writable: bool) -> Self
pub fn new(workspace_root: impl Into<PathBuf>, workspace_writable: bool) -> Self
Creates an access policy rooted at workspace_root.
Sourcepub fn with_static_rules(
self,
rules: impl IntoIterator<Item = PathAccessRule>,
) -> Self
pub fn with_static_rules( self, rules: impl IntoIterator<Item = PathAccessRule>, ) -> Self
Installs static baseline, trusted-config, and product path rules, canonicalizing each rule path once up front.
Sourcepub fn with_session_permissions(
self,
view: ProcessSessionPermissionView,
) -> Self
pub fn with_session_permissions( self, view: ProcessSessionPermissionView, ) -> Self
Attaches a live read-only view of session-approved capability grants.
Sourcepub fn workspace_root(&self) -> &Path
pub fn workspace_root(&self) -> &Path
Returns the workspace root path.
Sourcepub const fn workspace_writable(&self) -> bool
pub const fn workspace_writable(&self) -> bool
Returns whether writes inside the workspace are permitted.
Sourcepub fn product_private_paths(&self) -> Vec<PathBuf>
pub fn product_private_paths(&self) -> Vec<PathBuf>
Returns canonicalized ProductPrivate paths configured in static rules.
Sourcepub fn evaluate_read(
&self,
path: &Path,
once_grants: &[PathAccessRule],
) -> PathAccessDecision
pub fn evaluate_read( &self, path: &Path, once_grants: &[PathAccessRule], ) -> PathAccessDecision
Evaluates read access for path under the current policy, attached
session grants, and optional single-action once_grants.
Sourcepub fn evaluate_write(
&self,
path: &Path,
once_grants: &[PathAccessRule],
) -> PathAccessDecision
pub fn evaluate_write( &self, path: &Path, once_grants: &[PathAccessRule], ) -> PathAccessDecision
Evaluates write access for path under the current policy, attached
session grants, and optional single-action once_grants.
Sourcepub fn evaluate_path(
&self,
path: &Path,
requested: PathAccess,
session: Option<&ProcessSessionPermissionSnapshot>,
once_grants: &[PathAccessRule],
) -> PathEvaluation
pub fn evaluate_path( &self, path: &Path, requested: PathAccess, session: Option<&ProcessSessionPermissionSnapshot>, once_grants: &[PathAccessRule], ) -> PathEvaluation
Pure single-path evaluation returning structured decision, protected
target flag, .git flag, and denial reason.
Sourcepub fn evaluate_directory_grant(
&self,
path: &Path,
requested: PathAccess,
session: Option<&ProcessSessionPermissionSnapshot>,
once_grants: &[PathAccessRule],
) -> PathEvaluation
pub fn evaluate_directory_grant( &self, path: &Path, requested: PathAccess, session: Option<&ProcessSessionPermissionSnapshot>, once_grants: &[PathAccessRule], ) -> PathEvaluation
Pure directory-grant evaluation (used by process sandboxes) that also
rejects grants covering strictly nested denied or ProductReadOnly paths.
Sourcepub fn explicit_rules_cover(
&self,
path: &Path,
requested: PathAccess,
session: Option<&ProcessSessionPermissionSnapshot>,
) -> bool
pub fn explicit_rules_cover( &self, path: &Path, requested: PathAccess, session: Option<&ProcessSessionPermissionSnapshot>, ) -> bool
Returns whether path is already covered at requested access by
configured static rules or retained session grants (independent of
implicit workspace membership), and not blocked by any ceiling or
descendant constraint.
Sourcepub fn is_protected_target(&self, path: &Path, requested: PathAccess) -> bool
pub fn is_protected_target(&self, path: &Path, requested: PathAccess) -> bool
Returns whether path targets a built-in Merry protected path
(ProductPrivate or ProductReadOnly write).
Sourcepub fn blocking_rule_path(
&self,
path: &Path,
requested: PathAccess,
) -> Option<PathBuf>
pub fn blocking_rule_path( &self, path: &Path, requested: PathAccess, ) -> Option<PathBuf>
Returns the blocking rule path when a directory grant is rejected by a hard deny or descendant coverage rule, for actionable error messages.