Files
hms/docs/archive/audits-v1/00-baseline-snapshot.md
iven 18fa6ce6d4 docs: 全局文档梳理归档 — 删除过期文件 + 归档 V1/早期设计 + wiki 数据校正 + CLAUDE.md 规则优化
**根目录清理:**
- 删除 CLAUDE-1.md(ZCLAW 旧项目配置,HMS 已完全脱离)
- 移动 DESIGN.md → docs/archive/(ERP 旧设计系统)
- 删除 plans/ 98 个临时会话计划文件

**归档重组:**
- V1 审计(12 文件)→ docs/archive/audits-v1/
- 早期 CRM/插件迭代设计(13 文件)→ docs/archive/superpowers-early/
- 已完成/已取代设计(28 文件)→ docs/archive/superpowers-completed/
- 早期讨论/测试报告 → docs/archive/discussions-early/ + test-reports-early/
- QA 重复文件清理(3 个旧版 result 文件)

**wiki 数据校正:**
- 迁移数 137→145,源文件 599→649,提交数 720→800+
- 小程序文件 124→163,Web 前端 297→332
- 后端测试 999→943(实际统计),权限码 75+→128
- 文档索引新增归档目录说明

**CLAUDE.md 规则优化:**
- §2.5 闭环工作法:提交+文档+推送三合一 + wiki 更新触发条件
- §2.6 Feature DoD:新增文档一致性检查项
- §6 反模式:新增 wiki 更新滞后/推送不及时警告
2026-05-15 09:29:04 +08:00

110 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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 个函数** |
| 通过 | **75397.5%** |
| 失败 | **91.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 个前端页面,审计工作量较大