@umacloud/knowledge 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/00-governance/knowledge-map.md +1 -1
- package/agentic-delivery/01-standards/context-engineering-for-delivery.md +94 -0
- package/agentic-delivery/01-standards/eval-driven-delivery.md +90 -0
- package/agentic-delivery/01-standards/generated-code-failure-modes.md +91 -0
- package/agentic-delivery/01-standards/production-readiness-scorecard.md +79 -0
- package/agentic-delivery/01-standards/self-improving-memory-and-regression-sets.md +80 -0
- package/agentic-delivery/01-standards/spec-as-contract.md +88 -0
- package/agentic-delivery/01-standards/test-discipline-for-generated-code.md +94 -0
- package/agentic-delivery/01-standards/test-integrity-and-anti-gaming.md +92 -0
- package/agentic-delivery/01-standards/verifier-critic-pattern.md +89 -0
- package/ai/agent-evaluation-benchmark.md +1 -1
- package/ai/ai-agent-memory-context-management.md +1 -1
- package/ai/ai-cost-capacity-optimization-playbook.md +1 -1
- package/ai/ai-data-security-and-compliance-playbook.md +1 -1
- package/ai/ai-domain-index-and-checklist.md +1 -1
- package/ai/ai-governance-maturity-model.md +1 -1
- package/ai/ai-model-selection-and-routing-strategy.md +1 -1
- package/ai/ai-observability-and-oncall-runbook.md +1 -1
- package/ai/ai-rag-engineering-playbook.md +1 -1
- package/ai/ai-red-team-and-safety-evaluation.md +1 -1
- package/ai/ai-release-readiness-and-rollback-gate.md +1 -1
- package/ai/llm-agent-engineering-deep-dive.md +1 -1
- package/ai/prompt-and-tool-guardrails.md +1 -1
- package/api/01-standards/api-versioning-and-deprecation-policy.md +100 -0
- package/architecture/01-standards/configuration-and-environment-management.md +104 -0
- package/architecture/01-standards/domain-driven-design-complete.md +105 -0
- package/architecture/02-playbooks/migration-playbook.md +1 -1
- package/architecture/02-playbooks/system-design-playbook.md +1 -1
- package/architecture/adr-template-and-examples.md +1 -1
- package/architecture/configuration-management.md +95 -1158
- package/architecture/resilience-and-disaster-patterns.md +87 -27
- package/architecture/system-architecture-deep-dive.md +1 -1
- package/backend/01-standards/dependency-and-supply-chain-hygiene.md +90 -0
- package/backend/01-standards/error-handling-taxonomy.md +88 -0
- package/backend/01-standards/idempotency-and-safe-retries.md +101 -0
- package/backend/01-standards/message-queue-patterns.md +96 -374
- package/backend/01-standards/queue-and-consumer-reliability.md +98 -0
- package/backend/01-standards/resilience-and-fault-tolerance.md +101 -0
- package/backend/01-standards/transactions-and-concurrency-control.md +92 -0
- package/cicd/cicd-blueprint-deep-dive.md +1 -1
- package/cicd/release-readiness-gate.md +78 -27
- package/cloud-native/01-standards/container-security.md +1 -1
- package/cloud-native/01-standards/kubernetes-complete.md +1 -1
- package/cloud-native/02-playbooks/gitops-with-argocd.md +1 -1
- package/cloud-native/02-playbooks/k8s-troubleshooting-playbook.md +1 -1
- package/cloud-native/02-playbooks/multicloud-governance.md +1 -1
- package/cloud-native/02-playbooks/serverless-patterns.md +1 -1
- package/cloud-native/02-playbooks/service-mesh-playbook.md +1 -1
- package/cloud-native/03-checklists/container-security-checklist.md +1 -1
- package/cloud-native/03-checklists/k8s-production-readiness-checklist.md +1 -1
- package/cloud-native/04-antipatterns/container-antipatterns.md +1 -1
- package/cloud-native/04-antipatterns/k8s-antipatterns.md +1 -1
- package/cloud-native/05-cases/case-k8s-migration.md +1 -1
- package/cloud-native/05-cases/case-k8s-scaling.md +1 -1
- package/cloud-native/05-cases/case-k8s-security-incident.md +1 -1
- package/cloud-native/06-glossary/cloud-native-glossary.md +1 -1
- package/compliance/01-standards/audit-logging-and-evidence.md +111 -0
- package/compliance/01-standards/privacy-and-compliance-readiness.md +119 -0
- package/data/data-governance-and-modeling-deep-dive.md +1 -1
- package/design/ux-system-deep-dive.md +1 -1
- package/development/00-governance/document-template.md +1 -1
- package/development/01-standards/code-review-and-pr-hygiene.md +85 -0
- package/development/03-checklists/production-readiness-checklist.md +6 -6
- package/development/09-maturity/quarterly-audit-template.md +1 -1
- package/development/11-ui-excellence/ui-aesthetic-system.md +1 -1
- package/development/13-implementation-assets/knowledge-gates-execution.md +1 -1
- package/development/api-contract-and-versioning-guide.md +1 -1
- package/development/api-governance-complete.md +1 -1
- package/development/backend-engineering-complete.md +1 -1
- package/development/code-review-quality-complete.md +11 -34
- package/development/concurrency-reliability-complete.md +1 -1
- package/development/database-engineering-complete.md +1 -1
- package/development/engineering-effectiveness-complete.md +1 -1
- package/development/engineering-standards-deep-dive.md +1 -1
- package/development/frontend-engineering-complete.md +1 -1
- package/development/performance-capacity-complete.md +1 -1
- package/development/refactor-migration-complete.md +1 -1
- package/development/refactoring-and-techdebt-playbook.md +1 -1
- package/development/security-in-development-complete.md +1 -1
- package/experts/architect/contract-first-api-design.md +140 -0
- package/experts/product-manager/prd-template-and-structure.md +144 -0
- package/experts/product-manager/requirements-engineering-ears.md +133 -0
- package/experts/qa-lead/test-plan-template.md +127 -0
- package/frontend/01-standards/accessibility-acceptance-gate.md +91 -0
- package/frontend/01-standards/accessibility-complete.md +3 -3
- package/frontend/01-standards/ui-states-and-resilient-data-fetching.md +97 -0
- package/high-quality-engineering-playbook.md +1 -1
- package/incident/02-playbooks/chaos-engineering-playbook.md +1 -1
- package/incident/postmortem-and-response-deep-dive.md +1 -1
- package/mobile/01-standards/flutter-complete.md +5 -5
- package/mobile/01-standards/react-native-complete.md +5 -5
- package/mobile/02-playbooks/mobile-performance.md +6 -6
- package/mobile/03-checklists/mobile-release-checklist.md +2 -2
- package/mobile/04-antipatterns/mobile-antipatterns.md +2 -2
- package/observability/01-standards/observability-and-slo-operations.md +88 -0
- package/observability/01-standards/observability-standards.md +2 -0
- package/operations/01-standards/cost-and-finops-engineering.md +84 -0
- package/operations/01-standards/production-readiness-review.md +103 -0
- package/operations/aiops-anomaly-detection.md +1 -1
- package/operations/capacity-planning.md +1 -1
- package/operations/chaos-engineering.md +1 -1
- package/operations/incident-command-system.md +1 -1
- package/operations/observability-complete.md +1 -1
- package/operations/slo-sli-playbook.md +1 -1
- package/operations/sre-operations-deep-dive.md +1 -1
- package/package.json +1 -1
- package/performance/01-standards/performance-budgets-and-load-testing.md +91 -0
- package/product/feature-prioritization-framework.md +1 -1
- package/product/kpi-and-metric-tree.md +1 -1
- package/product/product-discovery-and-prd-deep-dive.md +1 -1
- package/release-engineering/01-standards/feature-flag-lifecycle.md +92 -0
- package/release-engineering/01-standards/progressive-delivery-and-release.md +92 -0
- package/release-engineering/02-playbooks/release-rollback-and-recovery-playbook.md +99 -0
- package/release-engineering/03-checklists/release-rollback-readiness-checklist.md +61 -0
- package/release-engineering/04-antipatterns/release-antipatterns.md +63 -0
- package/security/01-standards/authorization-and-access-control.md +94 -0
- package/security/02-playbooks/incident-response-security-playbook.md +1 -1
- package/security/02-playbooks/penetration-testing-playbook.md +1 -1
- package/security/security-architecture-deep-dive.md +1 -1
- package/security/threat-modeling-stride-playbook.md +1 -1
- package/testing/01-standards/ci-test-gates-and-coverage.md +93 -0
- package/testing/01-standards/contract-testing-and-api-contracts.md +102 -0
- package/testing/01-standards/test-data-and-ephemeral-environments.md +105 -0
- package/testing/02-playbooks/e2e-testing-playbook.md +1 -1
- package/testing/risk-based-test-matrix.md +1 -1
- package/testing/testing-strategy-deep-dive.md +1 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: privacy-and-compliance-readiness
|
|
3
|
+
title: 隐私与合规就绪规范(商业级必读)
|
|
4
|
+
domain: compliance
|
|
5
|
+
category: 01-standards
|
|
6
|
+
difficulty: intermediate
|
|
7
|
+
tags: [privacy, pii, data-classification, consent, retention, audit, data-residency, dsar, 合规, 隐私, 商业级]
|
|
8
|
+
quality_score: 95
|
|
9
|
+
last_updated: 2026-06-29
|
|
10
|
+
---
|
|
11
|
+
# 隐私与合规就绪规范(商业级必读)
|
|
12
|
+
|
|
13
|
+
> 处理用户数据就要承担法律与信任责任。商业级产品在写第一行处理个人数据的代码之前,
|
|
14
|
+
> 就要把"收集什么、为什么、存多久、谁能看、用户能不能删"想清楚并落到工程里。
|
|
15
|
+
> 合规不是上线前补的文档,而是从数据模型就内建的能力(privacy by design)。
|
|
16
|
+
|
|
17
|
+
## 1. 核心原则
|
|
18
|
+
|
|
19
|
+
- **数据最小化**:只收集达成目的**必需**的数据,不"先存着以后也许有用"。字段越少,风险越小。
|
|
20
|
+
- **目的限定**:数据只能用于收集时声明的目的;换用途要重新取得依据/同意。
|
|
21
|
+
- **默认隐私(privacy by default)**:默认采集最少、默认最严权限、默认不共享;让用户主动开启而非默认开启。
|
|
22
|
+
- **可问责**:能证明你做了合规(记录、审计、控制映射),而不只是声称。
|
|
23
|
+
- **设计即合规**:在数据模型、接口、日志设计阶段就考虑分类、保留、删除、最小化,而非事后补。
|
|
24
|
+
|
|
25
|
+
## 2. 数据分类与盘点
|
|
26
|
+
|
|
27
|
+
先盘清"系统里有哪些数据、敏感度多高",否则无从保护。
|
|
28
|
+
|
|
29
|
+
| 分级 | 示例 | 处理要求 |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| 公开 | 营销文案、公开文档 | 无特殊要求 |
|
|
32
|
+
| 内部 | 业务配置、聚合统计 | 访问控制 |
|
|
33
|
+
| 个人数据(PII)| 姓名、邮箱、手机、地址、设备/账号标识 | 加密、最小化、可删除、可导出 |
|
|
34
|
+
| 敏感个人数据 | 支付卡、健康、生物特征、精确位置、身份证件、未成年人数据 | 强化加密、严格最小授权、单独同意、更短保留 |
|
|
35
|
+
| 凭据/密钥 | 密码、token、API key | 单向哈希/密管,绝不明文、绝不入日志 |
|
|
36
|
+
|
|
37
|
+
要点:维护**数据盘点(哪些字段属于哪级、存在哪、流向哪)**;新增字段时定级。**绝不**记录密码/卡号/token 明文;日志/报错里对 PII 脱敏。
|
|
38
|
+
|
|
39
|
+
## 3. 同意与合法依据
|
|
40
|
+
|
|
41
|
+
- 收集个人数据要有**合法依据**(用户同意、履行合同所必需、法定义务等),并能说明是哪一种。
|
|
42
|
+
- 同意要**明确、可知情、可撤回**:默认不勾选、分用途细分、撤回和给予一样容易。
|
|
43
|
+
- 记录同意:谁、何时、对什么版本的条款、通过什么方式同意——可审计。
|
|
44
|
+
- 对未成年人、敏感数据有更严格的同意与年龄校验要求。
|
|
45
|
+
|
|
46
|
+
## 4. 数据主体权利(必须工程化实现)
|
|
47
|
+
|
|
48
|
+
用户对自己的数据有这些权利,产品要有**真实可执行的流程**,而非客服手动翻库:
|
|
49
|
+
|
|
50
|
+
| 权利 | 工程实现 |
|
|
51
|
+
|---|---|
|
|
52
|
+
| 访问/导出 | 能按用户聚合其所有个人数据并以通用格式导出(数据可携带) |
|
|
53
|
+
| 更正 | 用户可更新其数据,且更新传播到副本/缓存 |
|
|
54
|
+
| 删除(被遗忘)| 能定位某用户的所有数据(含备份、日志、下游、缓存)并删除/匿名化;记录删除完成 |
|
|
55
|
+
| 限制/反对 | 能停止特定处理(如停止精准营销)而不删账号 |
|
|
56
|
+
| 撤回同意 | 撤回后停止相应处理 |
|
|
57
|
+
|
|
58
|
+
难点:删除要覆盖**所有副本**(备份、数据仓库、日志、第三方)。设计阶段就要让"按用户删除"可行——用户ID贯穿、可定位、可级联,而不是数据散落无法回收。
|
|
59
|
+
|
|
60
|
+
## 5. 保留与生命周期
|
|
61
|
+
|
|
62
|
+
- 每类数据定**保留期限**,到期自动删除或匿名化,**不无限留存**。
|
|
63
|
+
- 实现 TTL/定期清理任务;备份也要遵守保留策略(不能"主库删了备份留十年")。
|
|
64
|
+
- 区分"删除"与"匿名化":统计需要保留时,做**不可逆匿名化/去标识**(去掉可识别字段,确保不能反推个人)。
|
|
65
|
+
- 账号注销要触发其个人数据的删除/匿名化流程,并给用户确认。
|
|
66
|
+
|
|
67
|
+
## 6. 安全与加密
|
|
68
|
+
|
|
69
|
+
- **传输加密**:所有个人数据传输用 TLS。
|
|
70
|
+
- **静态加密**:个人/敏感数据落库加密;敏感字段做字段级加密或令牌化(tokenization),密钥与数据分离托管。
|
|
71
|
+
- **最小授权**:按角色/属性最小授权访问个人数据;访问要鉴权、要留痕。
|
|
72
|
+
- **脱敏**:日志、报错、分析、测试数据中对 PII 脱敏/掩码;测试环境绝不用真实个人数据。
|
|
73
|
+
- 与安全基线协同:见 `security/01-standards/secure-coding-baseline`、`security/01-standards/data-protection-gdpr`。
|
|
74
|
+
|
|
75
|
+
## 7. 数据驻留与跨境
|
|
76
|
+
|
|
77
|
+
- 明确数据**存储与处理的地理位置**;某些数据有"必须留在特定地区"的驻留要求。
|
|
78
|
+
- 跨境传输个人数据要有合法机制与记录;选择第三方/云区域时考虑数据驻留。
|
|
79
|
+
- 维护**数据流向图**:数据从哪进、存哪、流向哪些第三方/区域——出事和审计都要它。
|
|
80
|
+
|
|
81
|
+
## 8. 审计与可追溯
|
|
82
|
+
|
|
83
|
+
- 对敏感操作(访问/导出/修改/删除个人数据、权限变更、登录)记**审计日志**:谁、何时、对什么、从哪、结果。
|
|
84
|
+
- 审计日志要**防篡改、可追溯、有保留期**;审计日志本身也要对 PII 脱敏。
|
|
85
|
+
- 保留**合规证据**:数据盘点、同意记录、删除完成记录、访问评审记录、控制落实证据——可应对认证审计与监管问询。
|
|
86
|
+
- 定期做**访问评审**(谁有权访问敏感数据,是否仍需要)。
|
|
87
|
+
|
|
88
|
+
## 9. 第三方与供应链
|
|
89
|
+
|
|
90
|
+
- 引入处理个人数据的第三方(分析、支付、云、SaaS)前评估其安全与合规,签订数据处理约定,明确各自责任。
|
|
91
|
+
- 维护第三方数据处理清单(处理什么、为什么、在哪)。
|
|
92
|
+
- 第三方也要遵守你的保留/删除/驻留要求;用户删除要能传导到下游。
|
|
93
|
+
|
|
94
|
+
## 10. 事件响应
|
|
95
|
+
|
|
96
|
+
- 个人数据泄露要有**响应预案**:发现→遏制→评估影响范围→按法定时限通知监管/用户→复盘整改。
|
|
97
|
+
- 明确"什么算可上报的泄露"、通知时限、责任人;提前演练(见 `incident/` 与 `security/02-playbooks/incident-response-security-playbook`)。
|
|
98
|
+
|
|
99
|
+
## 11. 反模式(出现即不合格)
|
|
100
|
+
|
|
101
|
+
1. **过度采集**:能要的全要、留着以后也许有用。
|
|
102
|
+
2. **删不掉**:数据散落各处,"按用户删除"做不到。
|
|
103
|
+
3. **PII 入日志/明文存储**:密码/卡号/token 明文,日志含个人数据。
|
|
104
|
+
4. **无保留策略**:所有数据永久留存。
|
|
105
|
+
5. **同意走过场**:默认勾选、不可撤回、不记录。
|
|
106
|
+
6. **合规当文档补**:上线前补 PDF,工程里没有任何对应能力。
|
|
107
|
+
7. **忽略数据驻留/第三方**:把个人数据随手发给未评估的第三方/任意区域。
|
|
108
|
+
|
|
109
|
+
## 12. 最低交付 checklist
|
|
110
|
+
|
|
111
|
+
- [ ] 有数据分类与盘点;每个字段定级,新增字段定级。
|
|
112
|
+
- [ ] 只采集必需数据;同意明确、可撤回、可审计。
|
|
113
|
+
- [ ] 访问/导出/更正/删除/限制等数据主体权利有可执行的工程实现。
|
|
114
|
+
- [ ] 删除能覆盖所有副本(备份/日志/下游/缓存)。
|
|
115
|
+
- [ ] 每类数据有保留期与自动清理;统计数据做不可逆匿名化。
|
|
116
|
+
- [ ] 个人/敏感数据传输与静态加密,最小授权,日志脱敏。
|
|
117
|
+
- [ ] 明确数据驻留与跨境,维护数据流向图与第三方清单。
|
|
118
|
+
- [ ] 敏感操作有防篡改审计日志;保留合规证据。
|
|
119
|
+
- [ ] 有数据泄露响应预案与通知时限。
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: code-review-and-pr-hygiene
|
|
3
|
+
title: 代码评审标准与 PR 卫生规范(商业级必读)
|
|
4
|
+
domain: development
|
|
5
|
+
category: 01-standards
|
|
6
|
+
difficulty: intermediate
|
|
7
|
+
tags: [code-review, pr, pull-request, review-standards, small-pr, blocking-vs-nit, review-sla, atomic-commit, 代码评审, 评审, pr卫生, 商业级]
|
|
8
|
+
quality_score: 95
|
|
9
|
+
last_updated: 2026-06-29
|
|
10
|
+
---
|
|
11
|
+
# 代码评审标准与 PR 卫生规范(商业级必读)
|
|
12
|
+
|
|
13
|
+
> 代码评审不是挑刺仪式,也不是橡皮图章。它是**在缺陷进入主干前**拦住它、并让知识在团队里扩散的工程动作。
|
|
14
|
+
> 评审能不能起作用,一半取决于**作者把 PR 准备得多好评审**,一半取决于**评审者关注什么、用什么口吻**。
|
|
15
|
+
> 商业级团队对两端都有硬标准:小而聚焦的 PR + 有重点、可执行、对事不对人的评审。
|
|
16
|
+
|
|
17
|
+
## 1. 评审到底在查什么(优先级从高到低)
|
|
18
|
+
|
|
19
|
+
| 关注点 | 看什么 |
|
|
20
|
+
|---|---|
|
|
21
|
+
| **正确性** | 逻辑对不对、边界/错误/并发有没有处理、会不会破坏现有行为 |
|
|
22
|
+
| **安全** | 越权、注入、输入校验、敏感信息泄露、危险默认配置 |
|
|
23
|
+
| **测试** | 改动有没有对应测试,测试是否覆盖关键路径与边界,而非只测 happy path |
|
|
24
|
+
| **可维护性** | 命名、结构、复杂度、是否引入难以理解或难以删除的耦合 |
|
|
25
|
+
| **契约/兼容** | 接口/数据变更是否破坏消费方、是否需要版本化与迁移 |
|
|
26
|
+
| **可观测性** | 关键路径有没有日志/指标,错误是否可定位 |
|
|
27
|
+
| **风格** | 一致性——但**自动化能管的(格式化/lint)不靠人评审** |
|
|
28
|
+
|
|
29
|
+
把人力评审用在机器查不了的地方(正确性、设计、安全语义),格式/风格交给自动化。
|
|
30
|
+
|
|
31
|
+
## 2. 作者侧:把 PR 准备到"好评审"
|
|
32
|
+
|
|
33
|
+
- **小而聚焦**:一个 PR 只做一件事。大 PR 评审质量断崖式下降——评审者看不动就只能盖章。难以拆分的大改动要拆成一串可独立评审、可独立回滚的小 PR。
|
|
34
|
+
- **自审先行**:提交前自己先过一遍 diff,删调试代码、补测试、跑通构建+lint+测试,别把机器能发现的问题丢给评审者。
|
|
35
|
+
- **说清楚 why**:PR 描述写"为什么这么改、影响范围、如何验证、如何回滚",而不是把标题复述一遍。让评审者**不用猜**。
|
|
36
|
+
- **关联需求**:链接到对应需求/任务/缺陷,让改动可追溯(见 `experts/product-manager/prd-template-and-structure` 的可追溯矩阵)。
|
|
37
|
+
- **标注重点**:主动指出"这块我不确定""这里请重点看",引导评审注意力。
|
|
38
|
+
- **绿灯再请评**:CI 没过别请人评审;让评审者帮你跑 lint 是浪费。
|
|
39
|
+
|
|
40
|
+
## 3. 评审者侧:有效且尊重
|
|
41
|
+
|
|
42
|
+
- **及时**:评审是阻塞别人的事,设 SLA(如一个工作日内首轮响应),别让 PR 烂在队列里。评审优先级高于自己写新代码。
|
|
43
|
+
- **分清阻塞与建议**:明确标注哪些是**必须改(blocking)**、哪些是**可选建议(nit/suggestion)**。不要用一堆口味问题卡住一个正确的 PR。
|
|
44
|
+
- **具体、可执行**:指出问题要给出原因和(可能的)改法,"这里不好"不是有效评审。
|
|
45
|
+
- **问而非命令**:用"这里在 X 情况下会不会 Y?"代替"改成 Z",把判断权留给作者、把上下文逼出来。
|
|
46
|
+
- **对事不对人**:评审代码不评审人;任何人都会写 bug,评审是协作不是审判。
|
|
47
|
+
- **该夸就夸**:好的设计/测试值得肯定,评审不只是找问题。
|
|
48
|
+
- **认知边界**:看不懂的地方要问,不假装看懂盖章;批准 = 你为这段代码的正确性背了书。
|
|
49
|
+
|
|
50
|
+
## 4. PR / 提交卫生
|
|
51
|
+
|
|
52
|
+
- **原子提交**:每个提交是一个自洽的逻辑单元,信息说清"做了什么、为什么",便于排查与回滚。
|
|
53
|
+
- **干净历史**:合并前清理无意义的 "fix typo"、"wip" 提交噪音,让历史可读。
|
|
54
|
+
- **不夹带**:重构和功能改动分开 PR——把格式化大改和逻辑改动混在一个 PR 里,评审者根本看不出真正的变化。
|
|
55
|
+
- **改动可回滚**:PR 粒度要让"出事单独回滚这一个改动"成为可能。
|
|
56
|
+
|
|
57
|
+
## 5. 自动化兜底(人只做机器做不了的)
|
|
58
|
+
|
|
59
|
+
- **格式/lint/类型/测试/安全扫描**进 CI 必过门禁,**不进人工评审**(见 `testing/01-standards/ci-test-gates-and-coverage`)。
|
|
60
|
+
- **必评审 + 必过 CI** 作为合并保护:主干受保护,绕不过。
|
|
61
|
+
- **覆盖关键变更**:安全/支付/权限等高风险路径要求更强评审(如指定领域评审人)。
|
|
62
|
+
- 评审清单可参考 `development/03-checklists/pr-checklist`。
|
|
63
|
+
|
|
64
|
+
## 6. 反模式(出现即不合格)
|
|
65
|
+
|
|
66
|
+
1. **巨型 PR**:上千行混合改动,评审者看不动只能盖章,缺陷直接漏进主干。
|
|
67
|
+
2. **橡皮图章**:"LGTM" 秒批,根本没看;批准却不负责。
|
|
68
|
+
3. **风格暴政**:用一堆个人口味的 nit 卡住正确的 PR,不分阻塞与建议。
|
|
69
|
+
4. **人肉跑 lint**:把格式化/风格交给人评审,浪费人力还不一致。
|
|
70
|
+
5. **对人不对事**:评审带情绪、贬低作者,让人不敢提 PR。
|
|
71
|
+
6. **PR 无上下文**:描述空白或只复述标题,评审者全靠猜。
|
|
72
|
+
7. **重构夹带功能**:格式化与逻辑改动混一个 PR,真正的变化被淹没。
|
|
73
|
+
8. **评审烂队列**:PR 几天没人看,阻塞交付、催生"绕过评审直接合"。
|
|
74
|
+
9. **作者不自审**:把调试代码、未过 CI 的改动丢给评审者收拾。
|
|
75
|
+
|
|
76
|
+
## 7. 最低交付 checklist
|
|
77
|
+
|
|
78
|
+
- [ ] PR 小而聚焦,一个 PR 一件事;大改动拆成可独立评审/回滚的小 PR。
|
|
79
|
+
- [ ] 作者提交前自审、补测试、本地构建+lint+测试通过,CI 绿灯再请评。
|
|
80
|
+
- [ ] PR 描述写清 why/影响范围/如何验证/如何回滚,并关联需求。
|
|
81
|
+
- [ ] 评审有 SLA,及时响应,不阻塞队列。
|
|
82
|
+
- [ ] 评审区分 blocking 与建议,意见具体、可执行、对事不对人。
|
|
83
|
+
- [ ] 格式/lint/类型/测试/安全扫描走 CI 门禁,不占人工评审。
|
|
84
|
+
- [ ] 主干受"必评审 + 必过 CI"保护;高风险路径加强评审。
|
|
85
|
+
- [ ] 提交原子、历史干净,重构与功能改动分离。
|
|
@@ -5,8 +5,8 @@ domain: development
|
|
|
5
5
|
category: 03-checklists
|
|
6
6
|
difficulty: intermediate
|
|
7
7
|
tags: [checklist, development, production, readiness, 可靠性与容灾, 合规与审计, 基础设施与部署, 安全]
|
|
8
|
-
quality_score:
|
|
9
|
-
last_updated: 2026-06-
|
|
8
|
+
quality_score: 90
|
|
9
|
+
last_updated: 2026-06-29
|
|
10
10
|
---
|
|
11
11
|
# 生产就绪检查清单 (Production Readiness Checklist)
|
|
12
12
|
|
|
@@ -169,11 +169,11 @@ last_updated: 2026-06-15
|
|
|
169
169
|
|
|
170
170
|
---
|
|
171
171
|
|
|
172
|
-
##
|
|
172
|
+
## 相关规范
|
|
173
173
|
|
|
174
|
-
-
|
|
175
|
-
-
|
|
176
|
-
-
|
|
174
|
+
- 服务级一次性 go/no-go 决策门:`operations/01-standards/production-readiness-review`
|
|
175
|
+
- 每次发布的 pass/fail 门禁:`cicd/release-readiness-gate`
|
|
176
|
+
- 配置与环境治理:`architecture/01-standards/configuration-and-environment-management`
|
|
177
177
|
|
|
178
178
|
---
|
|
179
179
|
|
|
@@ -1,43 +1,20 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: code-review-quality-complete
|
|
3
|
-
title:
|
|
3
|
+
title: 代码评审与质量(已并入:代码评审标准与 PR 卫生规范)
|
|
4
4
|
domain: development
|
|
5
|
-
category:
|
|
5
|
+
category: development
|
|
6
6
|
difficulty: intermediate
|
|
7
|
-
tags: [code,
|
|
8
|
-
quality_score:
|
|
9
|
-
last_updated: 2026-06-
|
|
7
|
+
tags: [code-review, pr, quality, superseded, pointer, 代码评审, 已并入]
|
|
8
|
+
quality_score: 60
|
|
9
|
+
last_updated: 2026-06-29
|
|
10
10
|
---
|
|
11
|
-
#
|
|
11
|
+
# 代码评审与质量(本文档已并入)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
> 本文档原为占位草稿,内容已被更完整、可落地的标准取代,不再单独维护。
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- 评审意见必须具体、可执行、可验证。
|
|
18
|
-
- 对高风险变更执行严格评审等级。
|
|
15
|
+
**权威文档:[`development/01-standards/code-review-and-pr-hygiene.md`](01-standards/code-review-and-pr-hygiene.md)**
|
|
16
|
+
——代码评审标准与 PR 卫生规范(商业级必读)。
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
- PR必须聚焦单一主题。
|
|
22
|
-
- 变更必须包含测试与文档更新。
|
|
23
|
-
- 变更说明需覆盖影响范围与回滚策略。
|
|
18
|
+
它覆盖并超出了本文档原有的全部内容:评审优先级(正确性/安全/测试/可维护性/契约/可观测性/风格)、作者侧把 PR 准备到"好评审"、评审者侧有效且尊重、PR/提交卫生、自动化兜底、反模式与最低交付 checklist。
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
- 是否存在越权风险与输入校验缺失。
|
|
27
|
-
- 是否可能泄露敏感信息。
|
|
28
|
-
- 是否存在危险默认配置。
|
|
29
|
-
|
|
30
|
-
### 4. 性能评审清单
|
|
31
|
-
- 是否引入额外高复杂度计算。
|
|
32
|
-
- 是否增加高频链路IO与序列化开销。
|
|
33
|
-
- 是否影响缓存命中与数据库负载。
|
|
34
|
-
|
|
35
|
-
### 5. 可运维性评审清单
|
|
36
|
-
- 是否补充关键日志与指标。
|
|
37
|
-
- 是否可在异常时快速定位问题。
|
|
38
|
-
- 是否可安全回滚到上一个稳定版本。
|
|
39
|
-
|
|
40
|
-
### 6. 评审闭环
|
|
41
|
-
- 阻断级问题必须修复后才可合并。
|
|
42
|
-
- 复发问题应沉淀到评审清单与模板。
|
|
43
|
-
- 评审质量按缺陷逃逸率持续优化。
|
|
20
|
+
配套清单见 [`development/03-checklists/pr-checklist.md`](03-checklists/pr-checklist.md)。
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: contract-first-api-design
|
|
3
|
+
title: Architect — Contract-First / API-First Workflow
|
|
4
|
+
domain: experts
|
|
5
|
+
category: architect
|
|
6
|
+
difficulty: intermediate
|
|
7
|
+
tags: [api, architecture, contract, design, experts, integration, openapi, schema, versioning]
|
|
8
|
+
quality_score: 95
|
|
9
|
+
last_updated: 2026-06-29
|
|
10
|
+
---
|
|
11
|
+
# Architect — Contract-First / API-First Workflow
|
|
12
|
+
|
|
13
|
+
> The API contract is the **single source of truth** that frontend, backend,
|
|
14
|
+
> QA, and external integrators all build against. Write the contract **before**
|
|
15
|
+
> writing implementation code. A contract authored after the code merely
|
|
16
|
+
> documents whatever was built; a contract authored first becomes a design tool,
|
|
17
|
+
> a parallelization enabler, and an automated gate.
|
|
18
|
+
|
|
19
|
+
## 1. Why contract-first
|
|
20
|
+
|
|
21
|
+
- **Parallel work** — once the schema is agreed, frontend and backend build
|
|
22
|
+
simultaneously against the same definition instead of waiting on each other.
|
|
23
|
+
- **One source of truth** — the machine-readable schema (OpenAPI / GraphQL SDL /
|
|
24
|
+
protobuf) is generated from nothing else and nothing is generated without it.
|
|
25
|
+
- **Early design feedback** — interface mistakes (chatty endpoints, leaking the
|
|
26
|
+
data model, wrong resource granularity) surface in review of a 1-page schema,
|
|
27
|
+
not after a sprint of code.
|
|
28
|
+
- **Automated alignment** — the contract becomes a test fixture: mock servers,
|
|
29
|
+
client/server stubs, request/response validators, and a CI gate all derive
|
|
30
|
+
from it (see `testing/01-standards/contract-testing-and-api-contracts`).
|
|
31
|
+
|
|
32
|
+
## 2. The workflow
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
1. Model the resources + operations from the requirements (not the DB tables).
|
|
36
|
+
2. Write the contract: paths, methods, request/response schemas, error model, auth.
|
|
37
|
+
3. Review the contract with consumers (frontend, integrators, QA) — sign off the shape.
|
|
38
|
+
4. Generate: a mock server (consumers unblock) + server stubs + typed clients.
|
|
39
|
+
5. Implement against the contract; validate every request/response in tests.
|
|
40
|
+
6. Evolve only through additive change + explicit versioning + deprecation.
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The contract is a **reviewable artifact** that lands in the repo
|
|
44
|
+
(`openapi.yaml` / `schema.graphql` / `*.proto`) and is diffed on every change.
|
|
45
|
+
|
|
46
|
+
## 3. Designing the resource model
|
|
47
|
+
|
|
48
|
+
- Model **resources and operations**, not your storage schema. The API is a
|
|
49
|
+
product surface; the database is an implementation detail. Never expose ORM
|
|
50
|
+
entities or column names directly.
|
|
51
|
+
- Use **nouns for resources** (`/orders`), HTTP methods for verbs. Keep nesting
|
|
52
|
+
to ≤2 levels; flatten deeper relationships with query filters or links.
|
|
53
|
+
- Choose **granularity by use case**: avoid chatty designs (N calls to render
|
|
54
|
+
one screen) and avoid god-endpoints that return everything. Provide
|
|
55
|
+
field selection / expansion where payloads vary by caller.
|
|
56
|
+
- Make **read and write shapes explicit**: a create request is not the same
|
|
57
|
+
schema as the resource it returns. Define request DTOs and response DTOs separately.
|
|
58
|
+
|
|
59
|
+
## 4. Mandatory contract elements
|
|
60
|
+
|
|
61
|
+
Every contract must pin down, before code:
|
|
62
|
+
|
|
63
|
+
| Element | Requirement |
|
|
64
|
+
|---|---|
|
|
65
|
+
| Resources & paths | Every path, method, and path/query parameter typed. |
|
|
66
|
+
| Request schema | Required vs optional fields, types, formats, ranges, enums. |
|
|
67
|
+
| Response schema | Success body shape per status code, with examples. |
|
|
68
|
+
| Status codes | The full set per operation (200/201/204/400/401/403/404/409/422/429/5xx). |
|
|
69
|
+
| Error model | One consistent error envelope across all endpoints (see §5). |
|
|
70
|
+
| Auth | Which endpoints require auth and the scheme (bearer token, scopes/roles). |
|
|
71
|
+
| Pagination | The pagination contract (cursor preferred) where collections are returned. |
|
|
72
|
+
| Idempotency | Idempotency-key header on unsafe operations that may be retried. |
|
|
73
|
+
| Rate limits | Documented limits + `429` + `Retry-After` semantics. |
|
|
74
|
+
| Versioning | The version strategy and how breaking change is signalled. |
|
|
75
|
+
|
|
76
|
+
## 5. Standard error envelope (define once, use everywhere)
|
|
77
|
+
|
|
78
|
+
A single error shape lets every client handle failures uniformly:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"error": {
|
|
83
|
+
"code": "VALIDATION_ERROR",
|
|
84
|
+
"message": "Human-readable, safe to display",
|
|
85
|
+
"details": [{ "field": "email", "message": "Invalid email format" }],
|
|
86
|
+
"requestId": "req_abc123"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- `code` is a stable machine string clients branch on; `message` is for humans.
|
|
92
|
+
- Never leak stack traces, SQL, or internal identifiers in error bodies.
|
|
93
|
+
- Map every failure mode in the contract to a code, so QA can assert on them.
|
|
94
|
+
|
|
95
|
+
## 6. Versioning and evolution
|
|
96
|
+
|
|
97
|
+
- **Additive change is safe**: adding an optional field or a new endpoint does
|
|
98
|
+
not break existing clients. Make every consumer tolerant of unknown fields.
|
|
99
|
+
- **Breaking change requires a new version**: removing/renaming a field,
|
|
100
|
+
changing a type, tightening validation, or changing status-code semantics.
|
|
101
|
+
- Carry the major version in the URL prefix (`/api/v1/...`) for cache- and
|
|
102
|
+
test-friendliness; increment only on breaking change.
|
|
103
|
+
- **Deprecate, don't delete**: announce, mark deprecated in the contract, emit a
|
|
104
|
+
deprecation signal (header), set a sunset date, and keep the old version until
|
|
105
|
+
consumer traffic drains.
|
|
106
|
+
- Treat the contract diff as the **breaking-change detector** in CI — a removed
|
|
107
|
+
field or narrowed type fails the build unless the version is bumped.
|
|
108
|
+
|
|
109
|
+
## 7. Contract as a CI gate
|
|
110
|
+
|
|
111
|
+
The contract is only worth writing if it is enforced. Wire it up so drift fails the build:
|
|
112
|
+
|
|
113
|
+
- **Lint the contract**: schema validity, naming consistency, required examples.
|
|
114
|
+
- **Validate runtime traffic**: the server's real responses must satisfy the
|
|
115
|
+
schema (response validation in integration tests).
|
|
116
|
+
- **Cross-check the frontend**: extract the client's `fetch`/HTTP calls and
|
|
117
|
+
assert every called path/method/shape exists in the contract — no call to an
|
|
118
|
+
undefined endpoint, no endpoint silently changed under a live consumer.
|
|
119
|
+
- **Detect breaking diffs**: compare the new contract to the last released one;
|
|
120
|
+
block merge on a breaking change without a version bump.
|
|
121
|
+
|
|
122
|
+
## 8. Architect checklist (before implementation starts)
|
|
123
|
+
|
|
124
|
+
- [ ] Contract authored and committed before non-trivial endpoint code.
|
|
125
|
+
- [ ] Resources modeled from use cases, not from database tables.
|
|
126
|
+
- [ ] Request/response/error schemas fully typed, with examples per operation.
|
|
127
|
+
- [ ] One consistent error envelope across all endpoints.
|
|
128
|
+
- [ ] Auth, pagination, idempotency, and rate-limit semantics specified.
|
|
129
|
+
- [ ] Versioning strategy and deprecation policy stated.
|
|
130
|
+
- [ ] Mock server generated so frontend can build in parallel.
|
|
131
|
+
- [ ] CI validates server responses and frontend calls against the contract.
|
|
132
|
+
|
|
133
|
+
## 9. Anti-patterns
|
|
134
|
+
|
|
135
|
+
1. **Code-first, document-later** — generating docs from finished code, so the API shape was never reviewed.
|
|
136
|
+
2. **Exposing the data model** — returning ORM entities / DB column names as the API.
|
|
137
|
+
3. **Inconsistent errors** — every endpoint inventing its own error shape.
|
|
138
|
+
4. **Silent breaking change** — renaming a field in v1 and hoping clients cope.
|
|
139
|
+
5. **Chatty or god endpoints** — N calls to render a screen, or one endpoint returning everything.
|
|
140
|
+
6. **Unenforced contract** — a beautiful schema that nothing in CI checks, so code and contract drift apart.
|