Where sandbox grants live. The handlers only ever reach grants through this trait; a host that persists grants (its own database) implements it and installs it with [`DaemonState::with_sandbox_grants`]. Obligations of an implementation, all of which the in-memory default meets: a view has at most one live token per repository (`open` replaces it); `renew` changes only the expiry; `close` revokes;
| 266 | /// reissued token for the same view keeps its sessions and a token for |
| 267 | /// another view never gains them. |
| 268 | pub trait SandboxGrants: Send + Sync { |
| 269 | /// Mint a token for `request.view`, replacing any live one. Returns the |
| 270 | /// token (the only time it is ever available) and its grant. |
| 271 | fn open(&self, request: GrantRequest) -> Result<(Vec<u8>, SandboxGrant), GrantError>; |
| 272 | |
| 273 | /// Extend the view's live token to now + `ttl_secs`; the token itself is |
| 274 | /// unchanged. |
| 275 | fn renew( |
| 276 | &self, |
| 277 | repository_id: &[u8], |
| 278 | view: &str, |
| 279 | ttl_secs: u64, |
| 280 | ) -> Result<SandboxGrant, GrantError>; |
| 281 | |
| 282 | /// Revoke the view's token. Whether there was one. |
| 283 | fn close(&self, repository_id: &[u8], view: &str) -> Result<bool, GrantError>; |
| 284 | |
| 285 | /// What `token` grants, if it is live. |
| 286 | fn resolve(&self, token: &[u8]) -> Result<SandboxGrant, GrantError>; |
| 287 | |
| 288 | /// Whether `grant`'s sandbox may use provenance session `session_id`: |
| 289 | /// one its view started, or — when `unused` (nothing has ever been |
| 290 | /// recorded for it) — one nobody has, which becomes its own. |
| 291 | fn claim_session( |
| 292 | &self, |
| 293 | grant: &SandboxGrant, |
| 294 | session_id: &str, |
| 295 | unused: bool, |
| 296 | ) -> Result<bool, GrantError>; |
| 297 | |
| 298 | fn owns_session(&self, grant: &SandboxGrant, session_id: &str) -> Result<bool, GrantError>; |
| 299 | |
| 300 | /// Record that `grant`'s view reserved provenance turn `provenance_id`. |
| 301 | fn bind_provenance(&self, grant: &SandboxGrant, provenance_id: u64) -> Result<(), GrantError>; |
| 302 | |
| 303 | fn owns_provenance(&self, grant: &SandboxGrant, provenance_id: u64) |
| 304 | -> Result<bool, GrantError>; |
| 305 | } |
| 306 | |
| 307 | type Clock = Arc<dyn Fn() -> DateTime<Utc> + Send + Sync>; |
| 308 |
nothing calls this directly
no outgoing calls
no test coverage detected