Add some docs for debugging policies

This commit is contained in:
Letro Bot
2026-04-09 16:19:17 -05:00
parent 367b161336
commit 2f42e545d6
2 changed files with 34 additions and 0 deletions

View File

@@ -89,6 +89,7 @@ impl Entrypoints {
}
}
/// Global static data that stays the same for the life of the [`PolicyFactory`]
#[derive(Debug)]
pub struct Data {
base: BaseData,
@@ -198,6 +199,10 @@ fn merge_data_rec(
Ok(())
}
/// Global dynamic data
///
/// Hint: there is an admin API to manage this, see
/// `crates/handlers/src/admin/v1/policy_data/set.rs`
struct DynamicData {
version: Option<Ulid>,
merged: serde_json::Value,
@@ -319,6 +324,7 @@ impl PolicyFactory {
&self,
data: &serde_json::Value,
) -> Result<Policy, InstantiateError> {
tracing::debug!("Instantiating policy with data={}", data);
let mut store = Store::new(&self.engine, ());
let runtime = Runtime::new(&mut store, &self.module)
.await