(payload: serde_json::Value)
| 26 | } |
| 27 | |
| 28 | fn map_generic_decision(payload: serde_json::Value) -> HookResult { |
| 29 | match serde_json::from_value::<Decision>(payload) { |
| 30 | Ok(Decision::Allow { |
| 31 | modified_payload, .. |
| 32 | }) => { |
| 33 | if let Some(modified) = modified_payload { |
| 34 | HookResult::Continue(Some(modified)) |
| 35 | } else { |
| 36 | HookResult::Continue(None) |
| 37 | } |
| 38 | } |
| 39 | Ok(Decision::Block { reason, .. }) => HookResult::Block(reason), |
| 40 | Ok(Decision::Defer { |
| 41 | retry_after_ms, |
| 42 | reason, |
| 43 | }) => { |
| 44 | if let Some(r) = reason { |
| 45 | debug!("AHP defer: {}", r); |
| 46 | } |
| 47 | HookResult::Retry(retry_after_ms) |
| 48 | } |
| 49 | Ok(Decision::Modify { |
| 50 | modified_payload, .. |
| 51 | }) => HookResult::Continue(Some(modified_payload)), |
| 52 | Ok(Decision::Escalate { |
| 53 | reason, |
| 54 | escalation_target, |
| 55 | }) => HookResult::Escalate { |
| 56 | reason, |
| 57 | target: escalation_target, |
| 58 | }, |
| 59 | Err(_) => HookResult::Block("Invalid decision payload".into()), |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | fn map_context_perception_decision(payload: &serde_json::Value) -> HookResult { |
| 64 | match serde_json::from_value::<ContextPerceptionDecision>(payload.clone()) { |
no outgoing calls
no test coverage detected