p47h_engine/
types.rs

1use serde::{Deserialize, Serialize};
2
3/// Authorization decision result
4///
5/// Returned by policy evaluation methods to indicate whether
6/// an action is allowed and why.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct AuthDecision {
9    /// Whether the action is allowed
10    pub allowed: bool,
11    /// Human-readable reasons for the decision
12    pub reasons: Vec<String>,
13    /// Evaluation time in microseconds (deterministic, no floating point)
14    pub evaluation_time_us: u64,
15}
16
17/// Authorization decision with metadata (simplified - no cryptographic proofs in open-core)
18///
19/// Note: Cryptographic Merkle proofs are a commercial feature available in p47h-pro.
20/// This open-core version only provides basic authorization decisions.
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct AuthDecisionWithProof {
23    /// Whether the action is allowed
24    pub allowed: bool,
25    /// Human-readable reasons for the decision
26    pub reasons: Vec<String>,
27    /// Evaluation time in microseconds (deterministic, no floating point)
28    pub evaluation_time_us: u64,
29}
30
31/// Policy validation diagnostic result
32///
33/// Returned by `validate_policy_detailed` to provide structured error information
34/// including line and column numbers for precise error reporting in code editors.
35///
36/// This enables IDE integrations (like VS Code) to highlight exact error locations
37/// in policy TOML files, improving developer experience.
38#[derive(Serialize)]
39pub struct PolicyDiagnostic {
40    /// Whether the policy passed validation
41    pub valid: bool,
42    /// Human-readable error message if validation failed, None if valid
43    pub message: Option<String>,
44    /// Line number where error occurred (1-indexed), None if not applicable
45    pub line: Option<u32>,
46    /// Column number where error occurred (1-indexed), None if not applicable
47    pub column: Option<u32>,
48}