Skip to content

Commit 6bbcac1

Browse files
atlas-formclaude
andcommitted
refactor: simplify PKI module naming and struct names
- Rename modules: identity_auth → identity, approval_workflow → approval - Simplify struct names in identity module: * IdentityContext → Context * VerificationCredential → Credential * VerificationCredentials → Credentials * AuthResult → AuthOutcome (avoid Rust Result conflict) * TrustPolicy → Policy * TrustEvaluator → Evaluator - Simplify struct names in approval module: * WorkflowState → State * ApprovalWorkflow → Workflow - Simplify struct names in validation module: * ValidationIssue → Issue * ValidationResult → ValidationOutcome * ValidationPolicy → Policy - Add backward compatibility type aliases for all renamed structs - All 44 tests passing after refactoring 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6e77836 commit 6bbcac1

File tree

6 files changed

+1828
-727
lines changed

6 files changed

+1828
-727
lines changed

crates/capsula-pki/src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ pub enum PkiError {
8787
#[error("Key error: {0}")]
8888
KeyError(String),
8989

90+
/// 身份认证错误
91+
#[error("Authentication error: {0}")]
92+
AuthError(String),
93+
9094
/// IO错误
9195
#[error("IO error: {0}")]
9296
IoError(#[from] std::io::Error),

crates/capsula-pki/src/ra/approval_workflow.rs renamed to crates/capsula-pki/src/ra/approval.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
//!
33
//! 提供手动/自动审批流程控制
44
5-
use crate::error::Result;
6-
use crate::ra::identity_auth::AuthResult;
5+
use crate::ra::identity::AuthOutcome;
76

87
/// 工作流状态
98
#[derive(Debug, Clone, PartialEq)]
10-
pub enum WorkflowState {
9+
pub enum State {
1110
/// 待审批
1211
Pending,
1312
/// 审批通过
@@ -17,12 +16,12 @@ pub enum WorkflowState {
1716
}
1817

1918
/// 审批工作流
20-
pub struct ApprovalWorkflow {
19+
pub struct Workflow {
2120
/// 自动审批阈值
2221
auto_approval_threshold: u8,
2322
}
2423

25-
impl ApprovalWorkflow {
24+
impl Workflow {
2625
/// 创建新的审批工作流
2726
pub fn new(auto_approval_threshold: u8) -> Self {
2827
Self {
@@ -31,13 +30,17 @@ impl ApprovalWorkflow {
3130
}
3231

3332
/// 评估是否可以自动审批
34-
pub fn evaluate(&self, auth_result: &AuthResult) -> WorkflowState {
33+
pub fn evaluate(&self, auth_result: &AuthOutcome) -> State {
3534
if auth_result.trust_level >= self.auto_approval_threshold {
36-
WorkflowState::Approved
35+
State::Approved
3736
} else if auth_result.trust_level < 30 {
38-
WorkflowState::Rejected
37+
State::Rejected
3938
} else {
40-
WorkflowState::Pending
39+
State::Pending
4140
}
4241
}
43-
}
42+
}
43+
44+
// 重新导出为旧名称以保持向后兼容
45+
pub type WorkflowState = State;
46+
pub type ApprovalWorkflow = Workflow;

0 commit comments

Comments
 (0)