110 lines
3.8 KiB
Markdown
110 lines
3.8 KiB
Markdown
# HMS 功能审计 — Phase 0: 基线快照
|
||
|
||
> 日期: 2026-04-30 | 审计范围: 全系统
|
||
|
||
## 环境信息
|
||
|
||
| 项目 | 值 |
|
||
|------|-----|
|
||
| Git HEAD | `84fafb0bc5bf3d742f4136c78288a3d06678fc4d` |
|
||
| 最新提交 | `fix(web+health): 修复咨询轮询 temp ID 400 + 健康数据统计 500` |
|
||
| 总提交数 | 409 |
|
||
|
||
## 编译状态
|
||
|
||
| 指标 | 值 |
|
||
|------|-----|
|
||
| `cargo check --workspace` | **通过**(有警告) |
|
||
| 编译警告总数 | 40 个 |
|
||
| 受影响 crate | erp-core(1), erp-plugin(11), erp-health(11), erp-ai(6), erp-dialysis(1), erp-workflow(2), erp-server(1) |
|
||
|
||
### 警告分类
|
||
|
||
**未使用字段(9 处)**:
|
||
| 文件 | 字段 | 状态 |
|
||
|------|------|------|
|
||
| erp-plugin `host.rs` | `chk`(×2), `tenant_id`, `user_id` | #[allow(dead_code)] 已抑制 |
|
||
| erp-health 多处 | `message`, `usage`, `input_tokens`, `output_tokens`, `check_result`, `total` | 编译器警告 |
|
||
| erp-server `analytics.rs` | `timestamp` | 编译器警告 |
|
||
| erp-health | `RefRow` struct 从未构造 | 编译器警告 |
|
||
|
||
**未使用导入(18 处)**:分布在 erp-health(7)、erp-plugin(3)、erp-ai(2)、erp-workflow(2)、erp-dialysis(1)、erp-core(1)。
|
||
|
||
**未使用变量(7 处)**:`user_id`, `total`, `tenant_id`, `plugin_resp`, `plugin_id`, `final_nodes`, `entity`。
|
||
|
||
## 测试状态
|
||
|
||
### 总览
|
||
|
||
| 指标 | 值 |
|
||
|------|-----|
|
||
| 测试总数 | **772 个函数** |
|
||
| 通过 | **753(97.5%)** |
|
||
| 失败 | **9(1.2%)** |
|
||
| 跳过 | 0 |
|
||
|
||
### 失败测试(全部因 `blind_indexes` 表缺失)
|
||
|
||
| 测试 | 文件 |
|
||
|------|------|
|
||
| `test_create_patient` | `health_patient_tests.rs` |
|
||
| `test_patient_pii_encrypted` | `health_patient_tests.rs` |
|
||
| `test_dialysis_create_without_patient_returns_error` | `health_dialysis_tests.rs` |
|
||
| `test_cross_tenant_data_integrity` | `health_pii_encryption_tests.rs` |
|
||
| `test_patient_detail_returns_decrypted_fields` | `health_pii_encryption_tests.rs` |
|
||
| `test_patient_hmac_search_by_phone` | `health_pii_encryption_tests.rs` |
|
||
| `test_patient_list_hides_tier1_fields` | `health_pii_encryption_tests.rs` |
|
||
| `test_patient_tier1_fields_encrypted_in_db` | `health_pii_encryption_tests.rs` |
|
||
| `test_tenant_isolation_encrypted_patient` | `health_pii_encryption_tests.rs` |
|
||
|
||
**根因**:测试数据库缺少 `blind_indexes` 表(迁移未执行),非代码逻辑错误。
|
||
|
||
### 模块测试分布
|
||
|
||
| Crate | 单元测试 | 集成测试 | 总计 | 通过率 |
|
||
|-------|---------|---------|------|--------|
|
||
| erp-core | 74 | — | 74 | 100% |
|
||
| erp-auth | 41 | 3 | 44 | 100% |
|
||
| erp-config | 78 | — | 78 | 100% |
|
||
| erp-workflow | 63 | 4 | 67 | 100% |
|
||
| erp-message | 72 | — | 72 | 100% |
|
||
| erp-health | 159 | 144 | 303 | 97% |
|
||
| erp-ai | 36 | — | 36 | 100% |
|
||
| erp-dialysis | 10 | 15 | 25 | 93% |
|
||
| erp-plugin | 78 | 2 | 80 | 100% |
|
||
| erp-server | — | 153 | 153 | 94% |
|
||
| **合计** | **611** | **153** | **772** | **97.5%** |
|
||
|
||
## 路由统计
|
||
|
||
| 模块 | 路由数 |
|
||
|------|--------|
|
||
| erp-health | 169 |
|
||
| erp-plugin | 38 |
|
||
| erp-config | 26 |
|
||
| erp-auth | 33(含 4 个公开路由) |
|
||
| erp-workflow | 17 |
|
||
| erp-ai | 12 |
|
||
| erp-dialysis | 12 |
|
||
| erp-message | 13 |
|
||
| erp-server | 8(含 4 个公开路由) |
|
||
| **合计** | **328**(8 个公开 + 320 个受保护) |
|
||
|
||
## 代码规模
|
||
|
||
| 维度 | 值 |
|
||
|------|-----|
|
||
| Rust 源文件 | 462 个 |
|
||
| Rust 代码行数 | ~77,000 行 |
|
||
| Web 前端文件 | 163 个 |
|
||
| 小程序文件 | 125 个 |
|
||
| 数据库迁移 | 96 个 |
|
||
| Rust crate | 18 个 |
|
||
|
||
## 基线结论
|
||
|
||
1. **系统整体健康**:编译通过,97.5% 测试通过
|
||
2. **单一阻塞问题**:9 个测试因 `blind_indexes` 表缺失失败,需执行迁移
|
||
3. **技术债务低**:仅 40 个编译警告(多为未使用导入/变量),无 `unimplemented!` 或 `todo!` 宏
|
||
4. **规模庞大**:233 个后端路由、40 个前端页面,审计工作量较大
|