lean_ctx/core/intelligence_runtime/
compliance_frameworks.rs1use super::InstallError;
7use crate::core::compliance_evidence::{facts::ComplianceFactsV1, frameworks::FrameworksAnswer};
8
9pub(crate) const CAPABILITY_ID: &str = "enterprise.runtime.compliance_frameworks";
10pub(crate) const CAPABILITY_VERSION: &str = "1.0.0";
11
12const CAPABILITY: super::exchange::Capability = super::exchange::Capability {
13 id: CAPABILITY_ID,
14 version: CAPABILITY_VERSION,
15 declared: super::health::supports_compliance_frameworks,
16 deadline_ms: 10_000,
17 tag: "compliance",
18};
19
20pub(crate) const ENTERPRISE_HINT: &str = "framework coverage (EU AI Act, ISO 42001, SOC 2) is \
22 part of LeanCTX Enterprise and needs the licensed runtime; `lean-ctx compliance facts` \
23 shows what it is assessed on, `lean-ctx compliance verify` works without a license";
24
25pub fn assess(facts: &ComplianceFactsV1) -> Result<FrameworksAnswer, String> {
28 let input = serde_json::to_string(facts).map_err(|e| format!("compliance facts: {e}"))?;
29 match super::exchange::invoke(&CAPABILITY, &input) {
30 Ok(output) => serde_json::from_str(&output)
31 .map_err(|_| "compliance runtime answer refused: not a frameworks answer".to_string()),
32 Err(InstallError::Policy | InstallError::Manifest) => Err(ENTERPRISE_HINT.to_string()),
33 Err(error) => Err(format!(
34 "compliance runtime failed ({error}); an active LeanCTX Enterprise lease is required"
35 )),
36 }
37}