eval_magic/sandbox/mod.rs
1//! Execution sandbox: shared write-guard machinery and write-boundary policy.
2//!
3//! The hook entry points are hidden subcommands on this binary (see `cli`), so
4//! the installed PreToolUse hook invokes `eval-magic guard <marker>`,
5//! `eval-magic guard-codex <marker>`, or the generic
6//! `eval-magic guard-hook --harness <name> <marker>` — no separate hook script
7//! to ship or locate. Each harness's hook path, matcher, and verdict shape are
8//! descriptor data rendered by the generic engine (`crate::adapters::guard`);
9//! this module holds the shared marker/manifest/teardown machinery and the
10//! boundary policy.
11
12pub mod decide;
13pub mod guard;
14pub mod install;
15pub mod policy;
16
17pub(crate) use decide::marker_is_armed;
18pub use decide::{GuardDecision, GuardMarker, decide};
19pub(crate) use guard::parse_tool_call;
20pub use guard::read_marker;
21pub(crate) use install::guard_is_armed;
22pub use install::{GUARD_MANIFEST, GUARD_MARKER, teardown_guard};
23pub use policy::{classify_bash, is_shell_tool, is_under, is_under_any, is_write_tool, path_arg};
24
25use std::time::{SystemTime, UNIX_EPOCH};
26
27/// Current wall clock in epoch milliseconds. chrono ships without its `clock`
28/// feature (it parses timestamps but never reads the clock), so the time comes
29/// from `std::time`. Shared by the guard's expiry check and marker stamping.
30pub(crate) fn now_ms() -> i64 {
31 SystemTime::now()
32 .duration_since(UNIX_EPOCH)
33 .unwrap_or_default()
34 .as_millis() as i64
35}