|
| 1 | +//! Permission requests bound to module-derived pre-execution audit evidence. |
| 2 | +use serde::{Deserialize, Serialize}; |
| 3 | + |
| 4 | +/// Stable retry metadata; the module supplies scope, stream, payload and verdict. |
| 5 | +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] |
| 6 | +#[serde(deny_unknown_fields)] |
| 7 | +pub struct AuditCorrelation2 { |
| 8 | + /// Opaque 32-hex event identity allocated once by the trusted host. |
| 9 | + pub event_id: String, |
| 10 | + /// Exact previously committed stream tail; adding one must not overflow. |
| 11 | + pub expected_tail: u64, |
| 12 | + /// Expected policy generation, retained unchanged for an indeterminate retry. |
| 13 | + pub generation: u64, |
| 14 | +} |
| 15 | +/// Original permission request and stable audit correlation, without caller verdicts. |
| 16 | +#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)] |
| 17 | +#[serde(deny_unknown_fields)] |
| 18 | +pub struct AuditedRequest2<T> { |
| 19 | + /// Actual original request evaluated by the module. |
| 20 | + pub request: T, |
| 21 | + /// Stable event correlation for exact reconciliation. |
| 22 | + pub audit: AuditCorrelation2, |
| 23 | +} |
| 24 | +impl<T> std::fmt::Debug for AuditedRequest2<T> { |
| 25 | + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 26 | + f.write_str("AuditedRequest2([REDACTED])") |
| 27 | + } |
| 28 | +} |
| 29 | +/// Computed permission and its independent audit durability evidence. |
| 30 | +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] |
| 31 | +#[serde(deny_unknown_fields)] |
| 32 | +pub struct AuditedResponse2<T> { |
| 33 | + /// Computed permission, denied on required loss or stale generation. |
| 34 | + pub decision: T, |
| 35 | + /// Exact audit evidence; a stale policy does not erase a committed receipt. |
| 36 | + pub audit: crate::AuditResponse2, |
| 37 | +} |
| 38 | +/// Module-evaluated operation with pre-execution audit. |
| 39 | +pub type EvaluateAuditedRequest2 = AuditedRequest2<crate::EvaluateRequest>; |
| 40 | +/// Computed operation permission with audit evidence. |
| 41 | +pub type EvaluateAuditedResponse2 = AuditedResponse2<crate::Decision>; |
| 42 | +/// Module-evaluated ordered checks with one pre-execution audit event. |
| 43 | +pub type CheckAuditedRequest2 = AuditedRequest2<crate::CheckRequest>; |
| 44 | +/// Computed ordered permissions with audit evidence. |
| 45 | +pub type CheckAuditedResponse2 = AuditedResponse2<crate::CheckResponse>; |
| 46 | +#[cfg(test)] |
| 47 | +#[path = "audited_tests.rs"] |
| 48 | +mod tests; |
0 commit comments