pub struct DiffScope<S: Store> { /* private fields */ }Expand description
Confirms that a patch only touched files the step was granted.
§Which grant
The one the step was granted, passed in here. Never the work order’s
requests: that is what the model asked for, and a checker that scoped a
patch against the proposer’s own request would be asking the proposer to
mark its own homework.
Implementations§
Source§impl<S: Store> DiffScope<S>
impl<S: Store> DiffScope<S>
Sourcepub fn new(store: S, scope: GrantSet) -> Self
pub fn new(store: S, scope: GrantSet) -> Self
A scope checker over scope, reading raw patches from store.
Sourcepub fn rooted_at(self, root: impl Into<String>) -> Self
pub fn rooted_at(self, root: impl Into<String>) -> Self
Treat patch paths as relative to root before comparing them.
A patch says src/auth.rs; a grant says fs:write:/work/repo/src/**.
The two only meet if the checker knows which directory the patch is
relative to, so set this to the workspace the grant is written against.
With no root the patch path is compared as an absolute path from the
repository root — src/auth.rs becomes /src/auth.rs — which is how
every grant in this codebase is spelled.