pub struct ExecGuard<'a> { /* private fields */ }Expand description
What the verification layer is allowed to spawn, and where to record it.
Verification cannot prompt — there is no approver on this path — so a
command is spawned only when the policy explicitly allows it. Anything
else, including Effect::Ask, is refused.
A run builds one of these for you. Build it yourself to check a criterion outside a run — a CI step re-verifying what an agent produced, say — under the boundary the agent itself worked under:
use io_harness::{ExecGuard, Policy, Verification, TEST_BINARY};
// Compile-only: `rustc` may run, the produced test binary may not. The gate
// type-checks the criterion against the code and never executes it, which is
// what you want when the code came from a model and this host is not a sandbox
// you are willing to lose.
let policy = Policy::permissive()
.layer("verify")
.allow_exec("rustc")
.deny_exec(TEST_BINARY);
let criterion = Verification::RustTestPasses {
test_src: "#[test] fn it_answers() { assert_eq!(hello(), 42); }".into(),
};
// An allow the policy does not give is `Error::Refused`, not a silent skip —
// a verification that was refused is not one that ran and failed.
let outcome = criterion
.passes_guarded(
"src/hello.rs".as_ref(),
"pub fn hello() -> u32 { 42 }",
&ExecGuard::new(&policy),
)
.await;
assert!(matches!(outcome, Err(io_harness::Error::Refused { .. })));ExecGuard::tracing additionally writes every spawn’s full argv against a
run id, and ExecGuard::no_sandbox opts back to direct host execution —
the sandbox is the default.
Implementations§
Source§impl<'a> ExecGuard<'a>
impl<'a> ExecGuard<'a>
Sourcepub fn new(policy: &'a Policy) -> Self
pub fn new(policy: &'a Policy) -> Self
Guard spawns with policy, recording nothing. Sandboxed by default.
Sourcepub fn tracing(self, store: &'a Store, run_id: i64, step: u32) -> Self
pub fn tracing(self, store: &'a Store, run_id: i64, step: u32) -> Self
Also record every spawn’s full argv against run_id at step, so
argument-level enforcement can be added later against a real baseline.
Sourcepub fn sandboxed(self, config: SandboxConfig) -> Self
pub fn sandboxed(self, config: SandboxConfig) -> Self
Run the compile inside config’s sandbox instead of the default one.
Sourcepub fn no_sandbox(self) -> Self
pub fn no_sandbox(self) -> Self
Opt out of the sandbox: run the compile directly on the host, exactly as 0.5.0 did. Additive and reversible — the sandbox is the default, not a forced change.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ExecGuard<'a>
impl<'a> !Send for ExecGuard<'a>
impl<'a> !Sync for ExecGuard<'a>
impl<'a> !UnwindSafe for ExecGuard<'a>
impl<'a> Freeze for ExecGuard<'a>
impl<'a> Unpin for ExecGuard<'a>
impl<'a> UnsafeUnpin for ExecGuard<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.