universal-dev-standards 6.0.0 → 6.1.1

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.
Files changed (91) hide show
  1. package/bundled/ai/options/commit-message/bilingual.ai.yaml +19 -1
  2. package/bundled/ai/standards/checkin-standards.ai.yaml +3 -3
  3. package/bundled/ai/standards/documentation-writing-standards.ai.yaml +1 -1
  4. package/bundled/ai/standards/frontend-design-standards.ai.yaml +33 -3
  5. package/bundled/ai/standards/push-standards.ai.yaml +14 -3
  6. package/bundled/ai/standards/requirement-engineering.ai.yaml +42 -3
  7. package/bundled/ai/standards/self-review-protocol.ai.yaml +15 -10
  8. package/bundled/ai/standards/verification-evidence.ai.yaml +88 -5
  9. package/bundled/core/checkin-standards.md +3 -3
  10. package/bundled/core/documentation-writing-standards.md +1 -1
  11. package/bundled/core/feature-discovery-standards.md +191 -0
  12. package/bundled/core/frontend-design-standards.md +93 -4
  13. package/bundled/core/multi-environment-e2e-testing.md +195 -0
  14. package/bundled/core/push-standards.md +82 -0
  15. package/bundled/core/requirement-engineering.md +2 -2
  16. package/bundled/core/self-review-protocol.md +13 -8
  17. package/bundled/core/verification-evidence.md +170 -10
  18. package/bundled/locales/COVERAGE.md +27 -21
  19. package/bundled/locales/zh-CN/CHANGELOG.md +38 -3
  20. package/bundled/locales/zh-CN/CLAUDE.md +1 -1
  21. package/bundled/locales/zh-CN/MAINTENANCE.md +42 -661
  22. package/bundled/locales/zh-CN/README.md +10 -10
  23. package/bundled/locales/zh-CN/SECURITY.md +2 -2
  24. package/bundled/locales/zh-CN/ai/options/commit-message/bilingual.ai.yaml +6 -1
  25. package/bundled/locales/zh-CN/core/browser-compatibility-standards.md +17 -7
  26. package/bundled/locales/zh-CN/core/cost-budget-test.md +1 -1
  27. package/bundled/locales/zh-CN/core/cross-flow-regression.md +8 -7
  28. package/bundled/locales/zh-CN/core/flaky-test-management.md +1 -1
  29. package/bundled/locales/zh-CN/core/flow-based-testing.md +8 -8
  30. package/bundled/locales/zh-CN/core/frontend-design-standards.md +1 -1
  31. package/bundled/locales/zh-CN/core/full-coverage-testing.md +74 -2
  32. package/bundled/locales/zh-CN/core/license-compliance.md +3 -1
  33. package/bundled/locales/zh-CN/core/logging-standards.md +83 -7
  34. package/bundled/locales/zh-CN/core/mock-boundary.md +58 -6
  35. package/bundled/locales/zh-CN/core/packaging-standards.md +2 -1
  36. package/bundled/locales/zh-CN/core/pipeline-security-gates.md +24 -4
  37. package/bundled/locales/zh-CN/core/prompt-regression.md +1 -1
  38. package/bundled/locales/zh-CN/core/replay-test.md +1 -1
  39. package/bundled/locales/zh-CN/core/requirement-engineering.md +1 -1
  40. package/bundled/locales/zh-CN/core/security-testing.md +24 -7
  41. package/bundled/locales/zh-CN/core/self-review-protocol.md +17 -12
  42. package/bundled/locales/zh-CN/core/smoke-test.md +1 -1
  43. package/bundled/locales/zh-CN/core/verification-evidence.md +252 -41
  44. package/bundled/locales/zh-CN/docs/CHEATSHEET.md +6 -2
  45. package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +16 -25
  46. package/bundled/locales/zh-CN/docs/user/GLOSSARY.md +1 -1
  47. package/bundled/locales/zh-CN/options/commit-message/bilingual.md +10 -3
  48. package/bundled/locales/zh-CN/skills/brainstorm-assistant/SKILL.md +21 -19
  49. package/bundled/locales/zh-CN/skills/brainstorm-assistant/guide.md +14 -11
  50. package/bundled/locales/zh-CN/skills/dev-methodology/guide.md +1 -1
  51. package/bundled/locales/zh-CN/skills/logging-guide/SKILL.md +29 -6
  52. package/bundled/locales/zh-CN/skills/spec-derivation/guide.md +1 -1
  53. package/bundled/locales/zh-TW/CHANGELOG.md +38 -3
  54. package/bundled/locales/zh-TW/CLAUDE.md +1 -1
  55. package/bundled/locales/zh-TW/MAINTENANCE.md +32 -8
  56. package/bundled/locales/zh-TW/README.md +10 -10
  57. package/bundled/locales/zh-TW/SECURITY.md +2 -2
  58. package/bundled/locales/zh-TW/ai/options/commit-message/bilingual.ai.yaml +6 -1
  59. package/bundled/locales/zh-TW/core/cost-budget-test.md +1 -1
  60. package/bundled/locales/zh-TW/core/flaky-test-management.md +1 -1
  61. package/bundled/locales/zh-TW/core/flow-based-testing.md +8 -8
  62. package/bundled/locales/zh-TW/core/frontend-design-standards.md +1 -1
  63. package/bundled/locales/zh-TW/core/license-compliance.md +3 -1
  64. package/bundled/locales/zh-TW/core/logging-standards.md +2 -2
  65. package/bundled/locales/zh-TW/core/mock-boundary.md +1 -1
  66. package/bundled/locales/zh-TW/core/packaging-standards.md +2 -1
  67. package/bundled/locales/zh-TW/core/pipeline-security-gates.md +24 -4
  68. package/bundled/locales/zh-TW/core/prompt-regression.md +1 -1
  69. package/bundled/locales/zh-TW/core/replay-test.md +1 -1
  70. package/bundled/locales/zh-TW/core/requirement-engineering.md +1 -1
  71. package/bundled/locales/zh-TW/core/security-testing.md +24 -7
  72. package/bundled/locales/zh-TW/core/self-review-protocol.md +16 -11
  73. package/bundled/locales/zh-TW/core/smoke-test.md +1 -1
  74. package/bundled/locales/zh-TW/core/verification-evidence.md +260 -31
  75. package/bundled/locales/zh-TW/docs/CHEATSHEET.md +6 -2
  76. package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +16 -25
  77. package/bundled/locales/zh-TW/docs/user/GLOSSARY.md +1 -1
  78. package/bundled/locales/zh-TW/options/commit-message/bilingual.md +10 -3
  79. package/bundled/locales/zh-TW/skills/brainstorm-assistant/SKILL.md +21 -19
  80. package/bundled/locales/zh-TW/skills/brainstorm-assistant/guide.md +14 -11
  81. package/bundled/locales/zh-TW/skills/dev-methodology/guide.md +1 -1
  82. package/bundled/locales/zh-TW/skills/logging-guide/SKILL.md +29 -6
  83. package/bundled/locales/zh-TW/skills/spec-derivation/guide.md +1 -1
  84. package/bundled/skills/brainstorm-assistant/SKILL.md +22 -20
  85. package/bundled/skills/brainstorm-assistant/guide.md +10 -7
  86. package/bundled/skills/spec-driven-dev/SKILL.md +11 -0
  87. package/package.json +3 -3
  88. package/src/commands/check.js +23 -13
  89. package/src/commands/init.js +58 -17
  90. package/src/i18n/messages.js +6 -6
  91. package/standards-registry.json +10 -10
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  source: ../../README.md
3
- source_version: 5.17.0
4
- translation_version: 5.17.0
5
- last_synced: 2026-06-10
6
- source_hash: 651c07df0abe
3
+ source_version: 6.0.0
4
+ translation_version: 6.0.0
5
+ last_synced: 2026-07-08
6
+ source_hash: add024721b5a
7
7
  status: current
8
8
  ---
9
9
 
@@ -15,7 +15,7 @@ status: current
15
15
 
16
16
  > **语言**: [English](../../README.md) | [繁體中文](../zh-TW/README.md) | 简体中文
17
17
 
18
- **版本**: 6.0.0 | **发布日期**: 2026-07-06 | **授权**: [双重授权](../../LICENSE) (CC BY 4.0 + MIT)
18
+ **版本**: 6.1.1 | **发布日期**: 2026-07-18 | **授权**: [双重授权](../../LICENSE) (CC BY 4.0 + MIT)
19
19
 
20
20
  语言无关、框架无关的软件项目文档标准。通过 AI 原生工作流,确保不同技术栈之间的一致性、质量和可维护性。
21
21
 
@@ -62,7 +62,7 @@ npx universal-dev-standards init
62
62
  | 我想要... | 文档 |
63
63
  |---|---|
64
64
  | **UDS 新手?** 5 分钟快速上手 | [docs/user/GETTING-STARTED.md](docs/user/GETTING-STARTED.md) |
65
- | 按 Tier & Category 浏览全部 54 个技能 | [docs/user/SKILLS-INDEX.md](../../docs/user/SKILLS-INDEX.md) |
65
+ | 按 Tier & Category 浏览全部 55 个技能 | [docs/user/SKILLS-INDEX.md](../../docs/user/SKILLS-INDEX.md) |
66
66
  | 查看所有斜线命令 | [docs/user/COMMANDS-INDEX.md](../../docs/user/COMMANDS-INDEX.md) |
67
67
  | 快速参考卡片 | [docs/user/CHEATSHEET.md](docs/CHEATSHEET.md) |
68
68
  | 常见问题 | [docs/user/FAQ.md](docs/user/FAQ.md) |
@@ -76,10 +76,10 @@ npx universal-dev-standards init
76
76
  <!-- UDS_STATS_TABLE_START -->
77
77
  | 类别 | 数量 | 说明 |
78
78
  |----------|-------|-------------|
79
- | **核心标准** | 146 | 通用开发准则 |
79
+ | **核心标准** | 149 | 通用开发准则 |
80
80
  | **AI Skills** | 55 | 互动式技能 |
81
81
  | **斜线命令** | 51 | 快速操作 |
82
- | **CLI 命令** | 6 | list, init, configure, check, update, skills |
82
+ | **CLI 命令** | 21 | 项目设置与维护 |
83
83
  <!-- UDS_STATS_TABLE_END -->
84
84
 
85
85
  > **5.0 新功能?** 请参阅[预发布说明](../../docs/PRE-RELEASE.md)了解新功能详情。
@@ -117,8 +117,8 @@ graph TD
117
117
 
118
118
  | AI 工具 | 状态 | Skills | 斜线命令 | 配置文件 |
119
119
  | :--- | :--- | :---: | :---: | :--- |
120
- | **Claude Code** | ✅ 完整支持 | **29** | **33** | `CLAUDE.md` |
121
- | **OpenCode** | ✅ 完整支持 | **29** | **33** | `AGENTS.md` |
120
+ | **Claude Code** | ✅ 完整支持 | **55** | **51** | `CLAUDE.md` |
121
+ | **OpenCode** | ✅ 完整支持 | **55** | **51** | `AGENTS.md` |
122
122
  | **Cursor** | ✅ 完整支持 | **核心** | **模拟支持** | `.cursorrules` |
123
123
  | **Roo Code** | ✅ 完整支持 | **核心** | **工作流** | `.roo/rules/` |
124
124
  | **Gemini CLI** | 🧪 预览版 | **18+** | **20+** | `GEMINI.md` |
@@ -13,8 +13,8 @@ status: current
13
13
  <!-- UDS_SUPPORTED_VERSIONS_START -->
14
14
  | 版本 | 支持状态 |
15
15
  |------|--------|
16
- | 5.17.0 | ✅ 最新正式版 |
17
- | < 5.0.0 | ❌ 已终止支持 |
16
+ | 6.0.0 | ✅ 最新正式版 |
17
+ | < 6.0.0 | ❌ 已终止支持 |
18
18
  <!-- UDS_SUPPORTED_VERSIONS_END -->
19
19
 
20
20
  > **说明**:仅最新正式版与当前预发布分支会收到安全更新。
@@ -4,7 +4,7 @@
4
4
  id: bilingual
5
5
  meta:
6
6
  parent: commit-message
7
- version: "1.0.0"
7
+ version: "1.1.0"
8
8
  description: 混合团队的雙語格式
9
9
  language: zh-CN
10
10
 
@@ -85,6 +85,11 @@ rules:
85
85
  instruction: 以雙語撰写內文,英文優先
86
86
  priority: recommended
87
87
 
88
+ - id: mid-conversation-language-drift-check
89
+ trigger: AI 助手在长对话中处理大量非目标语言内容(代码、log、英文文档)后切回用户对话文字时
90
+ instruction: 下一段用户对话文字发出前先自我核对是否使用目标语言,不需等用户指出;用户已指出语言跑偏时,下一则回复立即修正,不重复道歉拖延
91
+ priority: recommended
92
+
88
93
  examples:
89
94
  simple: "feat(auth): Add login form. 新增登入表单."
90
95
  with_body: |
@@ -1,20 +1,21 @@
1
1
  ---
2
2
  source: ../../../core/browser-compatibility-standards.md
3
- source_version: 1.0.0
4
- translation_version: 1.0.0
5
- last_synced: 2026-06-10
6
- source_hash: 56b7d0fbf522
7
- status: stale
3
+ source_version: 1.0.2
4
+ translation_version: 1.0.2
5
+ last_synced: 2026-07-08
6
+ source_hash: d4a9c4e89256
7
+ status: current
8
8
  ---
9
9
 
10
10
  # 浏览器兼容性标准
11
11
 
12
12
  > **语言**: [English](../../../core/browser-compatibility-standards.md) | [繁體中文](../../zh-TW/core/browser-compatibility-standards.md) | 简体中文
13
13
 
14
- **版本**:1.0.0
15
- **最后更新**:2026-05-05
14
+ **版本**:1.0.2
15
+ **最后更新**:2026-06-18
16
16
  **适用范围**:前端项目(Web 应用、渐进式 Web 应用 PWA、Web Components)
17
17
  **范围**:universal
18
+ **负责规格**:XSPEC-293(与 XSPEC-209 路由覆盖率正交)
18
19
  **行业标准**:Browserslist、W3C WebDriver、WebDriver BiDi
19
20
  **参考资料**:[caniuse.com](https://caniuse.com/)、[Playwright 浏览器支持矩阵](https://playwright.dev/docs/browsers)
20
21
 
@@ -36,6 +37,13 @@ status: stale
36
37
  | **Tier-2**(部分支持) | 尽力支持;主要流程必须可运行 | ≥ 95% 通过 —— 低于则 WARN,< 90% 则 FAIL |
37
38
  | **Tier-3**(尽力而为) | 非正式支持;缺陷会记录但不阻断发布 | 仅作为建议参考 |
38
39
 
40
+ > **Tier-2 `≥95%` / `<90%` 阈值 —— 依据与可配置性**:这些是 UDS 默认值,可依项目配置。
41
+ > Tier-2 是「尽力支持,主要流程必须可运行」,因此门禁容许少量非关键失败的尾量:
42
+ > `≥95%` = 健康(低于则 WARN,用于提示排查);`<90%` = 实质性回归(FAIL)。
43
+ > 请依你的目标市场浏览器覆盖率调整——例如依 Browserslist 市场占比配置(`> 0.5%` 等)
44
+ > 推导 Tier-2 浏览器集合与通过门槛。**例外**:当失败的 Tier-2 案例皆为非关键流程
45
+ > (以 Tier-3 类型缺陷记录)时,发布负责人可在记录理由后覆盖 WARN/FAIL 判定。
46
+
39
47
  ---
40
48
 
41
49
  ## 默认浏览器矩阵
@@ -218,6 +226,8 @@ last 2 ChromeAndroid versions
218
226
 
219
227
  | 版本 | 日期 | 变更内容 |
220
228
  |---------|------|---------|
229
+ | 1.0.2 | 2026-06-18 | 新增:Tier-2 95%/90% 阈值的依据、可配置性与例外说明(XSPEC-292 T8 / XSPEC-293 AC-293-2) |
230
+ | 1.0.1 | 2026-06-18 | 新增:负责规格指标 → XSPEC-293(XSPEC-291 §11) |
221
231
  | 1.0.0 | 2026-05-05 | 首次发布:Tier-1/2/3 矩阵、Playwright 配置、云端测试、发布门禁条件 |
222
232
 
223
233
  ---
@@ -3,7 +3,7 @@ source: ../../../core/cost-budget-test.md
3
3
  source_version: 1.0.0
4
4
  translation_version: 1.0.0
5
5
  last_synced: 2026-06-10
6
- source_hash: 19cf2a8cd706
6
+ source_hash: 88b78e9c7e7c
7
7
  status: current
8
8
  ---
9
9
 
@@ -1,20 +1,21 @@
1
1
  ---
2
2
  source: ../../../core/cross-flow-regression.md
3
- source_version: 1.0.0
4
- translation_version: 1.0.0
5
- last_synced: 2026-06-10
6
- source_hash: ac618caf6d7f
7
- status: stale
3
+ source_version: 1.0.1
4
+ translation_version: 1.0.1
5
+ last_synced: 2026-07-08
6
+ source_hash: 33da58d89648
7
+ status: current
8
8
  ---
9
9
 
10
10
  # 跨流程回归(Cross-Flow Regression)
11
11
 
12
12
  > **语言**:[English](../../../core/cross-flow-regression.md) | [繁體中文](../../zh-TW/core/cross-flow-regression.md) | 简体中文
13
13
 
14
- **版本**:1.0.0
15
- **最后更新**:2026-05-05
14
+ **版本**:1.0.1
15
+ **最后更新**:2026-06-18
16
16
  **适用范围**:所有具有多个 user flow 或业务流程的软件项目
17
17
  **Scope**:universal
18
+ **所属规格**:XSPEC-294(与 flow-based-testing 互补,无重叠)
18
19
  **业界标准**:ISTQB Advanced Test Analyst(Regression Test Strategy)
19
20
  **参考资料**:`core/flow-based-testing.md`、`core/testing-standards.md`
20
21
 
@@ -3,7 +3,7 @@ source: ../../../core/flaky-test-management.md
3
3
  source_version: 1.0.0
4
4
  translation_version: 1.0.0
5
5
  last_synced: 2026-06-10
6
- source_hash: ed870e072b63
6
+ source_hash: 04c9ce181011
7
7
  status: current
8
8
  ---
9
9
 
@@ -1,18 +1,18 @@
1
1
  ---
2
2
  source: ../../../core/flow-based-testing.md
3
- source_version: 1.3.0
4
- translation_version: 1.3.0
5
- last_synced: 2026-06-10
6
- source_hash: a8838e95f84e
7
- status: stale
3
+ source_version: 1.3.1
4
+ translation_version: 1.3.1
5
+ last_synced: 2026-07-08
6
+ source_hash: afadaebc0f49
7
+ status: current
8
8
  ---
9
9
 
10
10
  # 流程式测试(Flow-Based Testing)
11
11
 
12
12
  > **语言**: [English](../../../core/flow-based-testing.md) | [繁體中文](../../zh-TW/core/flow-based-testing.md) | 简体中文
13
13
 
14
- **版本**: 1.3.0
15
- **最后更新**: 2026-05-05
14
+ **版本**: 1.3.1
15
+ **最后更新**: 2026-06-18
16
16
  **适用性**: 所有具备多步骤工作流程的软件项目
17
17
  **范围**: universal
18
18
  **行业标准**: ISO/IEC/IEEE 29119-4(测试技术)、ISTQB Foundation Syllabus
@@ -120,7 +120,7 @@ describe("Flow Branch: Quota exceeded path", () => {
120
120
 
121
121
  ## 与其他标准的关系
122
122
 
123
- - **test-completeness-dimensions**:维度 9(Flow Completeness)与维度 10(Branch Coverage)在此定义
123
+ - **test-completeness-dimensions**:定义了 **8** 个维度。Flow Completeness Branch Coverage(决策表)的细节在本标准中说明——它们并非该标准中编号的维度 9/10(该标准仅有 8 个维度)
124
124
  - **behavior-driven-development**:BDD Scenario Outline 表格对应到决策表展开
125
125
  - **mock-boundary**:流程测试必须遵守 mock boundary 规则(不 mock 自身模块逻辑)
126
126
  - **e2e-testing**:旅程测试在 ST 或 E2E 级别运行;流程测试可在 IT 级别搭配真实 DB 运行
@@ -3,7 +3,7 @@ source: ../../../core/frontend-design-standards.md
3
3
  source_version: 1.0.0
4
4
  translation_version: 1.0.0
5
5
  last_synced: 2026-04-20
6
- status: current
6
+ status: stale
7
7
  ---
8
8
 
9
9
  # 前端设计标准
@@ -2,8 +2,8 @@
2
2
  source: ../../../core/full-coverage-testing.md
3
3
  source_version: 1.0.0
4
4
  translation_version: 1.0.0
5
- last_synced: 2026-06-10
6
- source_hash: e05fa172a6ee
5
+ last_synced: 2026-07-08
6
+ source_hash: 8ca921c68533
7
7
  status: current
8
8
  ---
9
9
 
@@ -171,6 +171,74 @@ CI 会回报 AC 覆盖率。若超过 20% 的 AC 没有 `@ac` 标签的测试,
171
171
 
172
172
  ---
173
173
 
174
+ ## 迁移错误路径完整性(XSPEC-288)
175
+
176
+ > 属于 [XSPEC-284](https://github.com/AsiaOstrich/universal-dev-standards) 9 轴迁移完整性矩阵的**轴⑨(错误路径)**。上述三路径模型要求**每个函数**都有错误路径;本节新增**迁移专属**保证——legacy 的错误/降级/fallback 分支被**系统性**移植,而非仅抽样。
177
+
178
+ ### 为何三路径模型对迁移还不够
179
+
180
+ 每函数错误路径要求与 XSPEC-201 的错误路径快照,只验证你**想到要枚举**的错误案例。重写时 happy path 因有明确需求而被迁移,而错误分支——散落于 `try/catch` 层级、自定义异常层级、特定错误码、降级 fallback——**被整批静默遗漏**。通过的错误路径抽样**不能证明没有分支被遗漏**(与 #134 同源盲区,只是发生在错误路径层)。本节是快照机制之上的**系统性枚举 + gap 分析**层。
181
+
182
+ ### 步骤 1 — 机械化 legacy 异常/错误码清单(derive,R1)
183
+
184
+ **机械化**枚举 legacy 错误面,而非依赖人脑回忆:
185
+
186
+ | 来源 | 推导出 |
187
+ |--------|--------|
188
+ | `catch` / `except` / `rescue` 区块(grep) | 每个捕获的异常类型 + handler |
189
+ | 自定义异常/错误类层级 | 声明的错误分类法 |
190
+ | 错误/状态码(HTTP status、app 错误码、错误 enum) | 响应码面 |
191
+ | 错误响应形状(serializer、错误 DTO) | on-the-wire 错误契约 |
192
+
193
+ 捕获到的清单即**错误路径待验清单**——来自 artifact 而非人脑回忆。
194
+
195
+ ### 步骤 2 — 系统性遗漏分支 gap 分析(oracle,R2)
196
+
197
+ 对步骤 1 的**每条** legacy 错误分支,验证新系统有对应 handler。无对应者标记为 `not_implemented`(XSPEC-199)并**阻止**。产出覆盖完整推导清单的**「遗漏错误分支」gap 报告**——而非仅抽样通过。
198
+
199
+ ```markdown
200
+ ## Error-Path Gap Report — <module>
201
+
202
+ | Legacy branch (error type / code) | New-system handler | Status |
203
+ |-----------------------------------|--------------------|--------|
204
+ | PaymentDeclinedException → 402 | PaymentService.handleDecline | MAPPED |
205
+ | GatewayTimeout → retry+fallback | (none found) | not_implemented — BLOCK |
206
+ | ValidationError → 422 + field list | InputValidator | MAPPED |
207
+
208
+ **Branches: N total · M mapped · K not_implemented (block if K>0)**
209
+ ```
210
+
211
+ ### 步骤 3 — 降级/Fallback 对等(R3)
212
+
213
+ legacy 降级模式(外部服务失败时的 fallback、重试、部分结果)因仅在失败时才执行而容易被遗漏。验证新系统保留对应降级行为,避免「正常路径一致、失败时行为迥异」:
214
+
215
+ - [ ] 外部服务失败的 **fallback** 行为与 legacy 一致
216
+ - [ ] **重试**策略(次数、backoff、放弃条件)与 legacy 一致
217
+ - [ ] **部分结果**处理与 legacy 一致(尽量返回 vs all-or-nothing)
218
+ - [ ] **熔断器/超时**降级与 legacy 一致
219
+
220
+ ### 步骤 4 — 错误响应差分(oracle,R4)
221
+
222
+ 把 [behavior-snapshot](behavior-snapshot.md) 对等与 XSPEC-284 R5 replay 延伸至涵盖**错误响应**,而不只是 happy-path 响应。比对新旧系统:
223
+
224
+ - **错误码**(HTTP status、app 错误码)
225
+ - **消息结构**(错误 DTO 形状、字段级错误)
226
+ - 各错误类的 **HTTP status** 映射
227
+
228
+ 这让隐性错误路径分歧在 cutover 时自我暴露,如同 happy-path 快照一样。
229
+
230
+ **Gate 时机**:pre-UAT(gap 分析 + 降级对等)+ cutover 前后(错误响应差分)。
231
+
232
+ ### 重要性分级(范围指引)
233
+
234
+ 并非每条 legacy 错误分支都同等优先。按**生产实际触发频率**排序(呼应 #134「以生产为准」):生产日志中实际触发过的分支优先对应;从未触发的潜在分支优先级较低但仍列入。高频生产错误分支若无新系统对应即为硬阻止。
235
+
236
+ ### 完整性声明(矩阵对齐)
237
+
238
+ 当本节声明以下三者——**derive**(步骤 1 机械化异常/错误码清单)、**oracle**(步骤 2 系统性 gap 分析 + 步骤 4 错误响应差分)、**gate 时机**(pre-UAT + cutover 前后)——即满足轴⑨。复用 XSPEC-201 错误路径快照 + 上述三路径模型——本节只新增系统性遗漏分支分析与错误响应差分,不重建测试框架。
239
+
240
+ ---
241
+
174
242
  ## 从金字塔模型迁移
175
243
 
176
244
  若你的项目先前使用金字塔门槛:
@@ -191,7 +259,11 @@ CI 会回报 AC 覆盖率。若超过 20% 的 AC 没有 `@ac` 标签的测试,
191
259
  - `unit-testing.ai.yaml` — 单元测试范围与组织
192
260
  - `integration-testing.ai.yaml` — 集成测试模式
193
261
  - `deployment-standards.ai.yaml` — 部署闸门需求
262
+ - `flaky-test-management.md` — 间歇性失败处理:会 flaky 的测试**不算**通过的测试。覆盖率数字计入闸门前,间歇性失败必须(MUST)依该标准隔离/设定重试预算/根因排查——否则「全覆盖」会掩盖非确定性缺口。
263
+ - `behavior-snapshot.md` — 错误响应差分 oracle(迁移错误路径完整性,轴⑨)
264
+ - `migration-assistant` skill — legacy 异常/错误码 derive + 降级对等(XSPEC-288)
194
265
  - XSPEC-178 — 完整规格与实现阶段
266
+ - XSPEC-288 — 迁移错误路径完整性(XSPEC-284 矩阵轴⑨)
195
267
 
196
268
 
197
269
  **Scope**: universal
@@ -3,7 +3,7 @@ source: ../../../core/license-compliance.md
3
3
  source_version: 2.1.0
4
4
  translation_version: 2.1.0
5
5
  last_synced: 2026-06-10
6
- source_hash: 8a754039a2b5
6
+ source_hash: 8ac1763bd1a1
7
7
  status: current
8
8
  ---
9
9
 
@@ -15,6 +15,8 @@ status: current
15
15
  > **AI 优化版本**: `ai/standards/license-compliance.ai.yaml`
16
16
  > **Agent Spec**: ASPEC-001 (cross-project/aspec/ASPEC-001-license-compliance-agent.md)
17
17
 
18
+ **Scope**: universal
19
+
18
20
  ## 概述
19
21
 
20
22
  面向 AI 增强开发的完整许可证合规标准,涵盖通用 OSS 实践(Tier 1)以及针对 AI 生成代码的 AI 专属规则(Tier 2)。
@@ -1,18 +1,18 @@
1
1
  ---
2
2
  source: ../../../core/logging-standards.md
3
- source_version: 1.3.0
4
- translation_version: 1.3.0
5
- last_synced: 2026-06-10
6
- source_hash: 7853d510d681
7
- status: stale
3
+ source_version: 1.4.0
4
+ translation_version: 1.4.0
5
+ last_synced: 2026-07-08
6
+ source_hash: 732277ef939f
7
+ status: current
8
8
  ---
9
9
 
10
10
  > **语言**: [English](../../../core/logging-standards.md) | 简体中文
11
11
 
12
12
  # 日志标准
13
13
 
14
- **版本**: 1.3.0
15
- **最后更新**: 2026-05-26
14
+ **版本**: 1.4.0
15
+ **最后更新**: 2026-06-17
16
16
  **适用范围**: 所有软件项目
17
17
  **范围**: universal
18
18
  **行业标准**: RFC 5424, OpenTelemetry, W3C Trace Context
@@ -24,6 +24,81 @@ status: stale
24
24
 
25
25
  本标准定义日志记录的最佳实践,确保日志的一致性、结构化和可操作性。
26
26
 
27
+ ## 强制事件(Mandatory Events)
28
+
29
+ > **关闭** UDS issue [#108](https://github.com/AsiaOstrich/universal-dev-standards/issues/108)(XSPEC-234)。本标准其余部分定义**如何**写一条日志(级别/字段/PII 脱敏/轮转);本节定义**何时必须写**——把「格式合规但实质沉默」的日志排除在外。
30
+
31
+ 遵守所有格式规则、却**在关键时刻从不触发**的日志比没有日志还糟:它在事故发生时给人一种虚假的安全感。以下事件是**必须**写日志的 canonical 时机,每项声明 `when`/`must_log`/`must_NOT_log`/`level`/`rationale`。
32
+
33
+ ### 为何需要(真实事故)
34
+
35
+ 某次 PHP→.NET 迁移耗费 2 天诊断「发送失败、没有日志」,原因是**四层全部沉默**:
36
+
37
+ 1. **负载均衡器将后端标记为 DOWN**(503)——health probe 超时;后端只记录了 probe 噪音,零业务事件。
38
+ 2. **框架验证 reject**(如 ModelState/DTO 501)——校验框架在任何 handler 执行前就返回,**payload 从未被记录**。
39
+ 3. **认证失败**只记录了「Account or password error」——**无 uid、无 source IP** → 无法排查。
40
+ 4. **后台 worker 仍存活,但日志文件 0 字节**——没有机制检测到这种沉默。
41
+
42
+ 以上都无法仅靠格式规则捕捉,强制事件补上这一缺口。
43
+
44
+ ### 类目(9 个 canonical 事件)
45
+
46
+ | id | when(时机) | level | 核心必填字段(`must_log`) | `must_NOT_log` |
47
+ |----|------|-------|-----------------------------------|----------------|
48
+ | `application_startup` | 进程启动后、**接受请求前** | INFO | app_name, version, git_sha, environment, hostname, pid, listening_endpoints | secrets、完整连接字符串 |
49
+ | `request_received` | HTTP 中间件首次看到请求 | INFO / DEBUG | method, path, source_ip, request_id | request body、auth headers |
50
+ | `validation_failure` | schema / ModelState / DTO 验证被拒绝 | WARN | request_id, path, missing_fields[], payload_shape(仅字段名) | 字段**值**、PII |
51
+ | `authentication_failure` | 登录 / token 校验失败 | WARN | uid(尝试值), source_ip, failure_reason | password、token 值 |
52
+ | `outbound_call_start` | 发起对外 HTTP/RPC 调用 | INFO | target_url(host+path), request_id propagated, timeout_ms | credentials、bearer token |
53
+ | `outbound_call_complete` | 外部调用返回或失败 | INFO / WARN / ERROR | status_code **或** failure_phase(dns/tcp/tls/http), elapsed_ms, retries | 含 PII 的 response body |
54
+ | `business_event` | 状态变更类业务操作完成 | INFO | operation_name, actor, target ids, outcome | 完整 record payload、PII |
55
+ | `heartbeat` | 长时间运行的后台服务,≥ 1 次 / 60 秒 | INFO | service_name, queue_depth, items_processed_since_last_heartbeat | — |
56
+ | `shutdown` | 进程退出(正常或致命) | INFO / ERROR | app_name, signal/reason, uptime_seconds, pending_work_count | — |
57
+
58
+ 每个事件的 `rationale` 都对应一个真实失效模式:`validation_failure` ⇒ 事故 #2(payload 未记录);`authentication_failure` 字段要求 ⇒ 事故 #3(无 uid/IP);`heartbeat` + 沉默检测 ⇒ 事故 #4(0 字节日志);`application_startup`/`shutdown` ⇒ 生命周期盲区;`outbound_call_*` ⇒「发送失败」却查不到调用痕迹。
59
+
60
+ ### 场景
61
+
62
+ #### 场景:验证失败必须产生日志
63
+
64
+ - **GIVEN** API 端点收到缺少 `[Required]` 字段的 payload
65
+ - **WHEN** 框架在 handler 执行前自动 reject(如 400/501)
66
+ - **THEN** 必须写一条 WARN 日志,包含 `request_id`、`path`、`missing_fields[]`、`payload_shape`(仅字段名)
67
+ - **AND** 事后复盘可直接从日志重建失败原因
68
+
69
+ #### 场景:后台服务必须心跳(heartbeat)
70
+
71
+ - **GIVEN** worker 进程正在运行
72
+ - **WHEN** 60 秒内没有写入任何 INFO/WARN/ERROR
73
+ - **THEN** 必须写一条 `heartbeat` 日志,包含当前 queue depth 与自上次心跳以来的处理量
74
+ - **AND** 若连续 ≥ 2 倍心跳间隔(≥ 120 秒)未出现心跳,沉默检测器必须告警
75
+
76
+ ### Compliant startup log 示例
77
+
78
+ ```json
79
+ {
80
+ "timestamp": "2026-06-17T08:00:00.000Z",
81
+ "level": "INFO",
82
+ "message": "application_startup",
83
+ "event": "application_startup",
84
+ "app_name": "payment-service",
85
+ "version": "2.3.1",
86
+ "git_sha": "a1b2c3d",
87
+ "environment": "production",
88
+ "hostname": "pod-abc123",
89
+ "pid": 4711,
90
+ "listening_endpoints": ["0.0.0.0:8080", "0.0.0.0:9090/metrics"]
91
+ }
92
+ ```
93
+
94
+ ### 后续规则
95
+
96
+ 1. **访问日志分离**——health probe/liveness 流量不得污染业务事件日志。将 probe 路由至独立 sink/文件,避免其淹没或轮转掉业务事件(见事故 #1)。
97
+ 2. **日志沉默检测 SLA**——服务应在连续 N 分钟无事件时告警,N ≤ 2 × `heartbeat` 间隔。缺少预期日志本身就是一种可告警条件(参见下方「Absence of Expected Logs」告警模式)。
98
+ 3. **面向运维的日志可发现性**——返回给客户端的错误响应应携带 `request_id`,以便支持人员将用户报告的故障对应到后端日志,无需为查日志来回沟通。
99
+
100
+ > **交叉引用**:`heartbeat`/沉默检测与[日志文件轮转策略](#日志文件轮转策略)互补(0 字节/静默丢弃的日志是同一盲区的两个方向),并与 migration-assistant 的后台任务/副作用完整性互补(这些事件即是可观测的「已触发」证据)。
101
+
27
102
  ---
28
103
 
29
104
  ## 日志级别
@@ -445,6 +520,7 @@ new DailyRotateFile({
445
520
 
446
521
  | 版本 | 日期 | 变更 |
447
522
  |-----|------|------|
523
+ | 1.4.0 | 2026-06-17 | 新增:强制事件类目——9 个 canonical「何时必须写日志」事件(when/must_log/must_NOT_log/level/rationale)、验证失败 + heartbeat 场景、compliant startup 示例、后续规则(访问日志分离、沉默检测 SLA、request_id 可发现性)(XSPEC-234 / 关闭 issue #108) |
448
524
  | 1.3.0 | 2026-05-26 | 新增:日志文件轮转策略——强制双触发器(时间 + 大小)轮转,含默认上限危害警告、各语言(.NET/Python/Java/Node)配置示例、运营 SOP(XSPEC-232 / 关闭 issue #111) |
449
525
  | 1.2.0 | 2026-01-24 | 新增:OpenTelemetry 语义规范、可观测性三支柱整合、基于日志的告警、进阶关联模式 |
450
526
  | 1.1.0 | 2026-01-05 | 新增:参考标准章节,包含 OWASP、RFC 5424、OpenTelemetry 和 12 Factor App |
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  source: ../../../core/mock-boundary.md
3
- source_version: 1.0.0
4
- translation_version: 1.0.0
5
- last_synced: 2026-06-10
6
- source_hash: d2648ad3d869
3
+ source_version: 1.1.0
4
+ translation_version: 1.1.0
5
+ last_synced: 2026-07-08
6
+ source_hash: fe4715991a4c
7
7
  status: current
8
8
  ---
9
9
 
@@ -11,8 +11,8 @@ status: current
11
11
 
12
12
  > **语言**: [English](../../../core/mock-boundary.md) | [繁體中文](../../zh-TW/core/mock-boundary.md) | 简体中文
13
13
 
14
- **版本**: 1.0.0
15
- **最后更新**: 2026-05-04
14
+ **版本**: 1.1.0
15
+ **最后更新**: 2026-07-01
16
16
  **适用性**: 所有具备单元测试与集成测试的软件项目
17
17
  **范围**: universal
18
18
  **行业标准**: ISTQB Foundation(Test Doubles), xUnit Patterns(Gerard Meszaros)
@@ -55,6 +55,7 @@ vi.mock('node:fs/promises', ...) // I/O replaced
55
55
  | 环境变量 | `process.env.NODE_ENV`、`process.env.LICENSE_KEY` | 支持配置变化 |
56
56
  | 文件系统(仅限单元测试) | `fs.readFile`、`fs.writeFile` | 让快速单元测试避免 I/O |
57
57
  | 跨模块边界(须有对应 IT) | 其他模块的 public API | 隔离被测单元 |
58
+ | 进程内后台执行(通过可注入 runner) | `Task.Run`、unawaited promise、`setTimeout`、goroutine、thread-pool dispatch | 注入 runner seam 让测试能 await 到确定完成,消除 race |
58
59
 
59
60
  ---
60
61
 
@@ -69,6 +70,46 @@ vi.mock('node:fs/promises', ...) // I/O replaced
69
70
 
70
71
  ---
71
72
 
73
+ ## 可注入的后台执行(Injectable Background Execution)
74
+
75
+ fire-and-forget 的后台工作(`Task.Run`、unawaited promise、`setTimeout`、goroutine、`java.util.concurrent` executor 提交,或 `asyncio.create_task`)是一个 **seam**,就跟系统时钟一样。正如你注入 clock 而非直接读取 wall-clock 时间,你也应该注入后台 dispatcher,而非直接生成后台工作。这样测试就能把工作驱动到**确定、可被 await 的完成**,并对其结果(成功、异常或 retry)进行断言——不用 poll、不用 sleep、没有 race。
76
+
77
+ 将 dispatch 抽象成一个小接口(例如 `IBackgroundTaskRunner` / `BackgroundDispatcher`),再提供两种实现:
78
+
79
+ - **Production**:保留真正的 fire-and-forget 语义——dispatch 立即返回,工作以 detached 方式运行。
80
+ - **Test**:以 **inline** 方式执行工作并**追踪底层 Task/promise**,对外暴露一个 handle 供测试 `await`,使完成(及任何失败)可被观察。
81
+
82
+ 语言中立示意(TypeScript 伪代码):
83
+
84
+ ```typescript
85
+ // Seam — 在任何 dispatch 后台工作处注入
86
+ interface BackgroundDispatcher {
87
+ dispatch(work: () => Promise<void>): void
88
+ }
89
+
90
+ // Production:真正的 fire-and-forget——立即返回,工作以 detached 方式运行
91
+ class FireAndForgetDispatcher implements BackgroundDispatcher {
92
+ dispatch(work: () => Promise<void>): void {
93
+ void work() // 刻意不 await
94
+ }
95
+ }
96
+
97
+ // Test:inline 执行 + 追踪 task,让测试能 await 到完成
98
+ class DeterministicDispatcher implements BackgroundDispatcher {
99
+ private readonly tasks: Promise<void>[] = []
100
+ dispatch(work: () => Promise<void>): void {
101
+ this.tasks.push(work()) // inline 启动并保留 handle
102
+ }
103
+ async settle(): Promise<void> {
104
+ await Promise.all(this.tasks) // 测试 await 到确定完成
105
+ }
106
+ }
107
+ ```
108
+
109
+ 测试注入 `DeterministicDispatcher`,执行被测代码,再在断言结果前 `await dispatcher.settle()`——后台副作用此时已完全可观察且具确定性。
110
+
111
+ ---
112
+
72
113
  ## 空心测试检测
73
114
 
74
115
  提交测试文件之前,请检查:
@@ -87,6 +128,7 @@ vi.mock('node:fs/promises', ...) // I/O replaced
87
128
  - **Orphan Mock**:跨模块 mock 却没有对应的集成测试
88
129
  - **Security Bypass Mock**:auth/权限逻辑被换成直接放行的 stub
89
130
  - **Database Mock Cascade**:DB 返回硬编码的数据,隐藏真实查询错误
131
+ - **Poll/Sleep for Background Result**:用 sleep 或 poll 等待 fire-and-forget 后台工作完成。race 依然存在——timeout 只是多数时候把它掩盖住,同时拖慢整个测试套件;在共享 runner 上还会把 flakiness 泄漏到其他 MR 的 CI 中。应改为注入 deterministic runner 并 await 被追踪的 task。
90
132
 
91
133
  ---
92
134
 
@@ -99,6 +141,7 @@ vi.mock('node:fs/promises', ...) // I/O replaced
99
141
  | IT 对应测试 | mock 跨模块边界 | 确保有对应的 IT 存在 |
100
142
  | 禁止 mock 安全机制 | 测试涉及 auth/权限 | 使用真实测试用户 + 真实 token |
101
143
  | 空心评审 | Mock 数量 ≥ import 数量 | 加入输出值断言 |
144
+ | 后台工作禁止 poll/sleep | 测试断言某个 fire-and-forget 副作用 | 注入 deterministic runner;await 被追踪的 task |
102
145
 
103
146
  ---
104
147
 
@@ -107,3 +150,12 @@ vi.mock('node:fs/promises', ...) // I/O replaced
107
150
  - **testing**:Mock 边界规则适用于测试金字塔的所有测试级别
108
151
  - **test-completeness-dimensions**:维度 8(AI 测试质量)引用了这些规则
109
152
  - **flow-based-testing**:Flow 测试必须遵循 mock 边界规则
153
+
154
+ ---
155
+
156
+ ## 版本历史
157
+
158
+ | 版本 | 日期 | 变更 |
159
+ |------|------|------|
160
+ | 1.0.0 | 2026-05-04 | 初始标准:空心测试问题、可/不可 Mock 表格、检测、反模式、规则摘要 |
161
+ | 1.1.0 | 2026-07-01 | 新增可注入的后台执行作为 seam(平行于 clock injection):可 Mock 表格新增行、`可注入的后台执行` 章节、`Poll/Sleep for Background Result` 反模式,以及后台工作禁止 poll/sleep 规则(issue #143) |
@@ -3,7 +3,7 @@ source: ../../../core/packaging-standards.md
3
3
  source_version: 1.1.0
4
4
  translation_version: 1.1.0
5
5
  last_synced: 2026-06-10
6
- source_hash: aa338edba3b1
6
+ source_hash: 69ff3afd3c1e
7
7
  status: current
8
8
  ---
9
9
 
@@ -278,6 +278,7 @@ python -c "import zipfile; zipfile.ZipFile('dist/patch.zip').namelist()"
278
278
  - [Pipeline 整合标准](pipeline-integration-standards.md) — CI/CD pipeline 配置
279
279
  - [Check-in 标准](checkin-standards.md) — 打包前的质量关卡
280
280
  - [版本控制标准](versioning.md) — 包产出物使用的版本号
281
+ - [供应链证明标准](supply-chain-attestation.md) — 打包产出物的 SBOM / SLSA 溯源 / 签名(此处的格式完整性属于归档层级;证明则补充了从源码到产出物的溯源)
281
282
 
282
283
  ---
283
284