feat: policy engine (#450)

* feat: policy engine

* fix: cargo fmt

* fix: resolve issues with miri
This commit is contained in:
stefan-gorules
2026-06-23 18:51:47 +02:00
committed by GitHub
parent 602d214b96
commit 6c0ca51354
137 changed files with 27125 additions and 290 deletions
+3 -1
View File
@@ -16,7 +16,9 @@ impl PyZenDecisionContent {
pub fn new(data: &str) -> PyResult<Self> {
let mut content: DecisionContent =
serde_json::from_str(data).context("Failed to parse JSON")?;
content.compile();
if let DecisionContent::Graph(g) = &mut content {
g.compile();
}
Ok(Self(Arc::new(content)))
}
}
+6 -2
View File
@@ -168,13 +168,17 @@ impl PyZenEngine {
}
pub fn create_decision(&self, content: PyZenDecisionContentJson) -> PyResult<PyZenDecision> {
let decision = self.engine.create_decision(content.0 .0);
let decision = self
.engine
.create_decision(content.0 .0)
.map_err(|e| anyhow!(e.to_string()))?;
Ok(PyZenDecision::from(decision))
}
pub fn get_decision<'py>(&'py self, _py: Python<'py>, key: &str) -> PyResult<PyZenDecision> {
let decision = block_on(self.engine.get_decision(key))
.context("Failed to find decision with given key")?;
.context("Failed to find decision with given key")?
.map_err(|e| anyhow!(e.to_string()))?;
Ok(PyZenDecision::from(decision))
}