Skip to main content

appcore_security/
policy.rs

1// =============================================================================
2//        #######
3//     ###       ###     F: policy.rs
4//    ##   ## ##   ##    P: AppCore-Runtime
5//         ## ##
6//                       C: 2026/05/31 13:38:42 by dnettoRaw
7//    ##   ## ##   ##    U: 2026/07/23 23:50:45 by dnettoRaw
8//      ###########      S: 1.0.1-rc.8
9// =============================================================================
10
11//! Authorization policy contracts for runtime commands and internal actions.
12
13use appcore_core::CommandName;
14
15/// Policy decision outcome.
16#[derive(Debug, Clone, PartialEq, Eq)]
17pub enum PolicyDecision {
18    /// Policy permits execution.
19    Allow,
20    /// Policy rejects execution with a controlled reason.
21    Deny(String),
22}
23
24/// Contract for policy checks.
25pub trait PolicyCheck {
26    /// Returns the command governed by this policy.
27    fn command_name(&self) -> &CommandName;
28    /// Evaluates the policy.
29    fn evaluate(&self) -> PolicyDecision;
30}
31
32#[cfg(test)]
33#[path = "policy_tests.rs"]
34mod tests;