pub struct ValidationResponse {
pub is_valid: bool,
pub explanation: String,
pub risk_level: RiskLevel,
pub approval_token: Option<String>,
pub auto_approved: bool,
pub warnings: Vec<String>,
pub violations: Vec<PolicyViolation>,
pub metadata: ValidationMetadata,
pub action: Option<UnifiedAction>,
pub validated_code_hash: Option<String>,
}Expand description
Response from validate_code_impl containing all validation results.
Fields§
§is_valid: boolWhether the code is valid
explanation: StringHuman-readable explanation of what the code does
risk_level: RiskLevelRisk level (LOW, MEDIUM, HIGH, CRITICAL)
approval_token: Option<String>Approval token for execution (None if invalid or dry_run)
auto_approved: boolWhether this was auto-approved based on risk level
warnings: Vec<String>Warnings (non-blocking issues)
violations: Vec<PolicyViolation>Policy violations (blocking issues)
metadata: ValidationMetadataValidation metadata
action: Option<UnifiedAction>Unified action (Read, Write, Delete, Admin)
validated_code_hash: Option<String>SHA-256 hash of the canonicalized code that was validated.
Implementations§
Source§impl ValidationResponse
impl ValidationResponse
Sourcepub fn success(
explanation: String,
risk_level: RiskLevel,
approval_token: String,
metadata: ValidationMetadata,
) -> Self
pub fn success( explanation: String, risk_level: RiskLevel, approval_token: String, metadata: ValidationMetadata, ) -> Self
Create a successful validation response.
Sourcepub fn failure(
violations: Vec<PolicyViolation>,
metadata: ValidationMetadata,
) -> Self
pub fn failure( violations: Vec<PolicyViolation>, metadata: ValidationMetadata, ) -> Self
Create a failed validation response.
Sourcepub fn with_code_hash(self, hash: String) -> Self
pub fn with_code_hash(self, hash: String) -> Self
Set the validated code hash (SHA-256 of canonicalized code).
Sourcepub fn with_action(self, action: UnifiedAction) -> Self
pub fn with_action(self, action: UnifiedAction) -> Self
Set the action for this response.
Sourcepub fn with_auto_approved(self, auto_approved: bool) -> Self
pub fn with_auto_approved(self, auto_approved: bool) -> Self
Set auto_approved flag.
Sourcepub fn with_warnings(self, warnings: Vec<String>) -> Self
pub fn with_warnings(self, warnings: Vec<String>) -> Self
Add warnings to the response.
Sourcepub fn to_json_response(&self) -> (Value, bool)
pub fn to_json_response(&self) -> (Value, bool)
Convert to JSON response format.
Returns a tuple of (json_value, is_error).
Trait Implementations§
Source§impl Clone for ValidationResponse
impl Clone for ValidationResponse
Source§fn clone(&self) -> ValidationResponse
fn clone(&self) -> ValidationResponse
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more