pub struct SandboxEvent {
pub run_id: i64,
pub step: u32,
pub kind: String,
pub backend: Option<String>,
pub detail: Option<String>,
}Expand description
One event in the life of a sandboxed execution: the sandbox created for a run, a command run in it (with the backend that isolated it), a resource cap that killed it, a denied network attempt, or the sandbox torn down.
Together these let an operator audit not just what code ran but where and how it was isolated, reconstructable from the store alone after the run.
use io_harness::{SandboxEvent, Store};
let events = store.sandbox_events(run_id)?;
// Which backend actually isolated the run. The crate picks a native one per
// platform and falls back to a portable floor, so "was this really contained"
// is a question about this field and not about the configuration.
let backend = events.iter().find_map(|e| e.backend.as_deref());
assert_eq!(backend, Some("macos-sandbox-exec"));
// And the phase to look for when a run that used to pass stops passing:
// `criterion-compile` means the criterion no longer compiles *against* the
// subject, which before 0.8.1 could be reported as a pass.
let phases: Vec<&str> = events
.iter()
.filter(|e| e.kind == "gate_phase_failed")
.filter_map(|e| e.detail.as_deref())
.collect();
assert_eq!(phases, ["criterion-compile"]);Fields§
§run_id: i64The run this execution belongs to.
step: u32The step it occurred on.
kind: String"create", "exec", "cap_hit", "destroy", "gate_phase_failed"
(whose detail names the phase), or "gate_output" (whose detail is
what a failing gate command printed).
A "net_deny" kind was documented here from 0.6.0 to 0.11.0 and never
existed: nothing constructed it and nothing emitted it. It was removed in
0.12.0 rather than implemented, because a sandbox denies egress
structurally — the backend gives the child no route out, so there is no
attempt to observe and nothing to count. Network decisions the harness
actually makes are in policy_events with act = "net".
backend: Option<String>The backend that isolated the run (e.g. "macos-sandbox-exec").
detail: Option<String>The argv for an "exec", the breached cap for a "cap_hit", or the
bounded output of a failing gate command for a "gate_output". Never the
agent’s file contents and never credentials — the command line, or what
the caller’s own criterion printed.
Implementations§
Source§impl SandboxEvent
impl SandboxEvent
Sourcepub fn create(run_id: i64, step: u32, backend: &str) -> Self
pub fn create(run_id: i64, step: u32, backend: &str) -> Self
A sandbox was created for a run, isolated by backend.
Sourcepub fn exec(run_id: i64, step: u32, backend: &str, argv: &str) -> Self
pub fn exec(run_id: i64, step: u32, backend: &str, argv: &str) -> Self
A command ran in the sandbox under backend.
Sourcepub fn destroy(run_id: i64, step: u32) -> Self
pub fn destroy(run_id: i64, step: u32) -> Self
The sandbox was torn down (workdir removed, processes reaped).
Sourcepub fn gate_phase_failed(run_id: i64, step: u32, phase: &str) -> Self
pub fn gate_phase_failed(run_id: i64, step: u32, phase: &str) -> Self
Which phase of an execution gate failed: "subject-compile" (the file
under verification does not compile), "criterion-compile" (the
criterion does not compile against it), "test-run" (it compiled and
the test failed), or "subject-emptied" (the file compiled but a
crate-level attribute stripped its items, so nothing was type-checked —
the compile-only gates).
0.8.1 added this because the release deliberately makes some previously
passing runs fail. criterion-compile is the one to look for: before
0.8.1 the subject and the criterion were one crate, so a subject could
shadow the names the criterion used — or delete it outright — and be
reported as passing. An operator whose run stopped passing on upgrade can
tell that case from an ordinary failed criterion without reading the
harness’s source.
A new kind value, not a new table or column: a 0.8.0 store takes it
with no migration.
Sourcepub fn gate_output(run_id: i64, step: u32, output: &str) -> Self
pub fn gate_output(run_id: i64, step: u32, output: &str) -> Self
What a failing gate command printed, already bounded by the caller (0.17.0).
Verification::Command can run any
command in any language, so “the criterion did not pass” stops being a
self-explaining outcome: cargo test failing because the agent’s change
is wrong and npm test failing because the machine has no node_modules
are the same discriminant and need opposite responses. The command’s own
output is the only thing that tells them apart.
This is the one detail that is not a command line. It is a gate
command’s output — a caller-supplied criterion, never the agent’s file
contents — and it is what makes a language-agnostic gate diagnosable at
all. Bounded by the caller before it arrives here.
use io_harness::{SandboxEvent, Store};
let store = Store::memory()?;
let run_id = store.start_run("make the suite pass", "/repo")?;
store.record_sandbox_event(&SandboxEvent::gate_output(
run_id, 3, "FAIL test/parse.test.js\n expected 2 received 1",
))?;
let why = store.sandbox_events(run_id)?;
assert!(why.iter().any(|e| e.kind == "gate_output"
&& e.detail.as_deref().is_some_and(|d| d.contains("expected 2"))));A new kind value, not a new table or column: a 0.6.0 store takes it with
no migration.
Trait Implementations§
Source§impl Clone for SandboxEvent
impl Clone for SandboxEvent
Source§fn clone(&self) -> SandboxEvent
fn clone(&self) -> SandboxEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SandboxEvent
impl Debug for SandboxEvent
impl Eq for SandboxEvent
Source§impl PartialEq for SandboxEvent
impl PartialEq for SandboxEvent
impl StructuralPartialEq for SandboxEvent
Auto Trait Implementations§
impl Freeze for SandboxEvent
impl RefUnwindSafe for SandboxEvent
impl Send for SandboxEvent
impl Sync for SandboxEvent
impl Unpin for SandboxEvent
impl UnsafeUnpin for SandboxEvent
impl UnwindSafe for SandboxEvent
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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,
impl<T> Scalar for T
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.