use async_trait::async_trait;
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct GateRequest {
pub tool_name: String,
pub args: serde_json::Value,
}
impl GateRequest {
pub fn new(tool_name: impl Into<String>, args: serde_json::Value) -> Self {
Self {
tool_name: tool_name.into(),
args,
}
}
}
pub type PolicyCode = String;
#[derive(Clone, Debug)]
#[non_exhaustive]
pub enum GateDecision {
Allow,
Deny {
code: PolicyCode,
reason: String,
},
RequireApproval {
ticket: String,
quorum: u8,
},
}
#[async_trait]
pub trait Gate: Send + Sync {
async fn evaluate(&self, req: GateRequest) -> GateDecision;
fn name(&self) -> &'static str;
}