O5: safety - allowlist guard, credential separation, audit log (#13)

This commit was merged in pull request #13.
This commit is contained in:
hermes committed 2026-11-13 00:09:31 +00:00
1 parent 06662a085f
commit bea07e82bb
9 files changed
+890 -29

No files matched your search

+20
View File
@@ -34,6 +34,17 @@ pub struct Profile {
/// Extra hx attempts after a red gate (default 2). 0 = fail straight to needs-human.
#[serde(default = "default_retries")]
pub max_retries: u32,
/// Tool allowlist, see policy.rs. Absent = no policy (hx runs headless with every tool allowed).
/// Present = enforced by `orch guard` inside hx and re-checked on the event stream; a denied call ends
/// the run as needs-human.
pub allow: Option<Vec<String>>,
/// Extra directories the agent may read besides the worktree.
#[serde(default)]
pub read_roots: Vec<PathBuf>,
/// Names (trailing `*` = prefix) of orch's environment variables passed to hx. hx gets a cleared
/// environment plus PATH, HOME, USER, LOGNAME, SHELL, TERM, LANG, LC_*, TMPDIR, CARGO_*, RUST*.
#[serde(default)]
pub env: Vec<String>,
/// Parallel runs for `orch pull` (default 1).
#[serde(default = "one")]
pub workers: u32,
@@ -64,6 +75,9 @@ fn default_hx() -> String {
impl Profile {
pub fn parse(s: &str) -> Result<Self> {
let p: Profile = toml::from_str(s)?;
for e in p.allow.iter().flatten() {
crate::policy::check_entry(e)?;
}
if p.workers == 0 || p.max_concurrent == Some(0) {
bail!("workers and max_concurrent must be >= 1");
}
@@ -116,6 +130,12 @@ mod tests {
);
}
#[test]
fn allowlist_validated() {
assert!(Profile::parse("allow = [\"read\", \"bash:cargo *\"]").is_ok());
assert!(Profile::parse("allow = [\"read:x\"]").is_err());
}
#[test]
fn rejects_zero_workers() {
assert!(Profile::parse("workers = 0").is_err());