universal-dev-standards 5.1.0-beta.7 → 5.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 (116) hide show
  1. package/README.md +6 -0
  2. package/bin/uds.js +2 -0
  3. package/bundled/ai/standards/checkin-standards.ai.yaml +18 -0
  4. package/bundled/ai/standards/test-governance.ai.yaml +12 -0
  5. package/bundled/ai/standards/testing.ai.yaml +14 -0
  6. package/bundled/ai/standards/translation-lifecycle-standards.ai.yaml +145 -0
  7. package/bundled/core/checkin-standards.md +21 -2
  8. package/bundled/core/test-governance.md +3 -0
  9. package/bundled/core/testing-standards.md +25 -2
  10. package/bundled/core/translation-lifecycle-standards.md +162 -0
  11. package/bundled/locales/zh-CN/CHANGELOG.md +50 -3
  12. package/bundled/locales/zh-CN/README.md +1 -1
  13. package/bundled/locales/zh-CN/core/anti-hallucination.md +22 -3
  14. package/bundled/locales/zh-CN/core/anti-sycophancy-prompting.md +192 -0
  15. package/bundled/locales/zh-CN/core/capability-declaration.md +123 -0
  16. package/bundled/locales/zh-CN/core/checkin-standards.md +22 -3
  17. package/bundled/locales/zh-CN/core/circuit-breaker.md +106 -0
  18. package/bundled/locales/zh-CN/core/dual-phase-output.md +103 -0
  19. package/bundled/locales/zh-CN/core/failure-source-taxonomy.md +99 -0
  20. package/bundled/locales/zh-CN/core/frontend-design-standards.md +289 -0
  21. package/bundled/locales/zh-CN/core/health-check-standards.md +144 -0
  22. package/bundled/locales/zh-CN/core/immutability-first.md +96 -0
  23. package/bundled/locales/zh-CN/core/packaging-standards.md +224 -0
  24. package/bundled/locales/zh-CN/core/recovery-recipe-registry.md +146 -0
  25. package/bundled/locales/zh-CN/core/retry-standards.md +131 -0
  26. package/bundled/locales/zh-CN/core/security-decision.md +104 -0
  27. package/bundled/locales/zh-CN/core/skill-standard-alignment-check.md +112 -0
  28. package/bundled/locales/zh-CN/core/standard-admission-criteria.md +104 -0
  29. package/bundled/locales/zh-CN/core/standard-lifecycle-management.md +116 -0
  30. package/bundled/locales/zh-CN/core/test-governance.md +14 -3
  31. package/bundled/locales/zh-CN/core/testing-standards.md +26 -3
  32. package/bundled/locales/zh-CN/core/timeout-standards.md +117 -0
  33. package/bundled/locales/zh-CN/core/token-budget.md +108 -0
  34. package/bundled/locales/zh-CN/core/translation-lifecycle-standards.md +159 -0
  35. package/bundled/locales/zh-TW/CHANGELOG.md +50 -3
  36. package/bundled/locales/zh-TW/README.md +1 -1
  37. package/bundled/locales/zh-TW/core/anti-sycophancy-prompting.md +8 -0
  38. package/bundled/locales/zh-TW/core/capability-declaration.md +111 -0
  39. package/bundled/locales/zh-TW/core/checkin-standards.md +24 -3
  40. package/bundled/locales/zh-TW/core/circuit-breaker.md +111 -0
  41. package/bundled/locales/zh-TW/core/dual-phase-output.md +132 -0
  42. package/bundled/locales/zh-TW/core/failure-source-taxonomy.md +146 -0
  43. package/bundled/locales/zh-TW/core/frontend-design-standards.md +460 -0
  44. package/bundled/locales/zh-TW/core/health-check-standards.md +144 -0
  45. package/bundled/locales/zh-TW/core/immutability-first.md +159 -0
  46. package/bundled/locales/zh-TW/core/recovery-recipe-registry.md +146 -0
  47. package/bundled/locales/zh-TW/core/retry-standards.md +140 -0
  48. package/bundled/locales/zh-TW/core/security-decision.md +120 -0
  49. package/bundled/locales/zh-TW/core/skill-standard-alignment-check.md +112 -0
  50. package/bundled/locales/zh-TW/core/standard-admission-criteria.md +104 -0
  51. package/bundled/locales/zh-TW/core/standard-lifecycle-management.md +116 -0
  52. package/bundled/locales/zh-TW/core/test-governance.md +14 -3
  53. package/bundled/locales/zh-TW/core/testing-standards.md +31 -0
  54. package/bundled/locales/zh-TW/core/timeout-standards.md +117 -0
  55. package/bundled/locales/zh-TW/core/token-budget.md +143 -0
  56. package/bundled/locales/zh-TW/core/translation-lifecycle-standards.md +159 -0
  57. package/bundled/locales/zh-TW/skills/ac-coverage-assistant/SKILL.md +1 -0
  58. package/bundled/locales/zh-TW/skills/adr-assistant/SKILL.md +1 -0
  59. package/bundled/locales/zh-TW/skills/ai-collaboration-standards/SKILL.md +1 -0
  60. package/bundled/locales/zh-TW/skills/ai-friendly-architecture/SKILL.md +1 -0
  61. package/bundled/locales/zh-TW/skills/ai-instruction-standards/SKILL.md +1 -0
  62. package/bundled/locales/zh-TW/skills/api-design-assistant/SKILL.md +1 -0
  63. package/bundled/locales/zh-TW/skills/atdd-assistant/SKILL.md +1 -0
  64. package/bundled/locales/zh-TW/skills/audit-assistant/SKILL.md +1 -0
  65. package/bundled/locales/zh-TW/skills/bdd-assistant/SKILL.md +1 -0
  66. package/bundled/locales/zh-TW/skills/brainstorm-assistant/SKILL.md +1 -0
  67. package/bundled/locales/zh-TW/skills/changelog-guide/SKILL.md +1 -0
  68. package/bundled/locales/zh-TW/skills/checkin-assistant/SKILL.md +1 -0
  69. package/bundled/locales/zh-TW/skills/ci-cd-assistant/SKILL.md +1 -0
  70. package/bundled/locales/zh-TW/skills/code-review-assistant/SKILL.md +1 -0
  71. package/bundled/locales/zh-TW/skills/commit-standards/SKILL.md +1 -0
  72. package/bundled/locales/zh-TW/skills/contract-test-assistant/SKILL.md +1 -0
  73. package/bundled/locales/zh-TW/skills/database-assistant/SKILL.md +1 -0
  74. package/bundled/locales/zh-TW/skills/dev-workflow-guide/SKILL.md +1 -0
  75. package/bundled/locales/zh-TW/skills/docs-generator/SKILL.md +1 -0
  76. package/bundled/locales/zh-TW/skills/documentation-guide/SKILL.md +1 -0
  77. package/bundled/locales/zh-TW/skills/durable-execution-assistant/SKILL.md +1 -0
  78. package/bundled/locales/zh-TW/skills/e2e-assistant/SKILL.md +1 -0
  79. package/bundled/locales/zh-TW/skills/forward-derivation/SKILL.md +1 -0
  80. package/bundled/locales/zh-TW/skills/incident-response-assistant/SKILL.md +1 -0
  81. package/bundled/locales/zh-TW/skills/methodology-system/SKILL.md +1 -0
  82. package/bundled/locales/zh-TW/skills/metrics-dashboard-assistant/SKILL.md +1 -0
  83. package/bundled/locales/zh-TW/skills/migration-assistant/SKILL.md +1 -0
  84. package/bundled/locales/zh-TW/skills/observability-assistant/SKILL.md +1 -0
  85. package/bundled/locales/zh-TW/skills/pr-automation-assistant/SKILL.md +1 -0
  86. package/bundled/locales/zh-TW/skills/process-automation/SKILL.md +1 -0
  87. package/bundled/locales/zh-TW/skills/project-discovery/SKILL.md +1 -0
  88. package/bundled/locales/zh-TW/skills/project-structure-guide/SKILL.md +1 -0
  89. package/bundled/locales/zh-TW/skills/refactoring-assistant/SKILL.md +1 -0
  90. package/bundled/locales/zh-TW/skills/release-standards/SKILL.md +1 -0
  91. package/bundled/locales/zh-TW/skills/requirement-assistant/SKILL.md +1 -0
  92. package/bundled/locales/zh-TW/skills/retrospective-assistant/SKILL.md +1 -0
  93. package/bundled/locales/zh-TW/skills/reverse-engineer/SKILL.md +1 -0
  94. package/bundled/locales/zh-TW/skills/runbook-assistant/SKILL.md +1 -0
  95. package/bundled/locales/zh-TW/skills/security-assistant/SKILL.md +1 -0
  96. package/bundled/locales/zh-TW/skills/security-scan-assistant/SKILL.md +1 -0
  97. package/bundled/locales/zh-TW/skills/slo-assistant/SKILL.md +1 -0
  98. package/bundled/locales/zh-TW/skills/spec-driven-dev/SKILL.md +1 -0
  99. package/bundled/locales/zh-TW/skills/tdd-assistant/SKILL.md +1 -0
  100. package/bundled/locales/zh-TW/skills/test-coverage-assistant/SKILL.md +1 -0
  101. package/bundled/skills/ai-collaboration-standards/SKILL.md +1 -0
  102. package/bundled/skills/ai-friendly-architecture/SKILL.md +1 -0
  103. package/bundled/skills/ai-instruction-standards/SKILL.md +1 -0
  104. package/bundled/skills/documentation-guide/SKILL.md +1 -0
  105. package/bundled/skills/error-code-guide/SKILL.md +1 -0
  106. package/bundled/skills/git-workflow-guide/SKILL.md +1 -0
  107. package/bundled/skills/logging-guide/SKILL.md +1 -0
  108. package/bundled/skills/project-structure-guide/SKILL.md +1 -0
  109. package/bundled/skills/testing-guide/SKILL.md +1 -0
  110. package/package.json +5 -4
  111. package/src/commands/check.js +6 -0
  112. package/src/commands/init.js +6 -0
  113. package/src/commands/update.js +6 -0
  114. package/src/utils/detect-self-adoption.js +173 -0
  115. package/src/utils/directory-mapper.js +2 -2
  116. package/standards-registry.json +15 -4
@@ -0,0 +1,112 @@
1
+ ---
2
+ source: ../../../core/skill-standard-alignment-check.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-20
6
+ status: current
7
+ ---
8
+
9
+ # Skill-Standard 對齊檢查標準
10
+
11
+ > **語言**: [English](../../../core/skill-standard-alignment-check.md) | 繁體中文
12
+
13
+ **版本**: 1.0.0
14
+ **最後更新**: 2026-04-17
15
+ **狀態**: Trial(到期 2026-10-17)
16
+ **適用範圍**: universal
17
+ **來源**: XSPEC-070(DEC-043 Wave 1 治理 Meta 套件)
18
+
19
+ ---
20
+
21
+ ## 目的
22
+
23
+ Skill 必有 Standard 作為錨點,Standard 可無 Skill;定期識別孤兒 Skill。
24
+
25
+ Skill 是 UX 糖衣,Standard 是 standards-of-truth。若 Skill 無錨定 Standard,其行為就沒有明文依據,會隨作者口味飄移。本標準規範 Skill 必須指明錨定哪個 Standard,並定期識別「孤兒 Skill」(無對應 Standard),觸發補 Standard 的流程。反向允許 Standard 無 Skill(不強制每個 Standard 都造 Skill)。
26
+
27
+ ---
28
+
29
+ ## 核心規範
30
+
31
+ - 所有 Skill 必須在 frontmatter 指明 `anchor_standard`(至少一個)
32
+ - `anchor_standard` 必須指向 Trial / Active / Deprecated 狀態的標準 id
33
+ - Skill 無 `anchor_standard` 視為 orphan,必須在下一版補上或降級為 Proposed
34
+ - Standard 無對應 Skill 是合法的(Standard 可獨立存在,Skill 僅為 UX 加速)
35
+ - 定期(建議季度)執行 alignment check,產出 orphan Skill 清單
36
+
37
+ ---
38
+
39
+ ## 對齊規則
40
+
41
+ ### Skill 必須有 Standard
42
+
43
+ - **規則**:Skill 的 frontmatter 必須包含 `anchor_standard` 欄位
44
+ - **格式**:`anchor_standard: <standard-id>` 或 `[<standard-id-1>, <standard-id-2>, ...]`
45
+ - **強制執行**:CI / pre-release check,缺欄位視為 fail
46
+ - **例外**:純 utility Skill(如 docs-generator)可標記 `anchor_standard: none` + 填 `utility_reason`
47
+
48
+ ### Standard 不必有 Skill
49
+
50
+ - **規則**:Standard 是否有對應 Skill 不強制
51
+ - **理由**:Standard 是 standards-of-truth,可被 QualityGate / Agent 直接消費;強制每 Standard 都造 Skill 會導致 Skill 庫膨脹
52
+ - **範例**:`immutability-first` 標準無對應 Skill — 合法
53
+
54
+ ### 孤兒 Skill 偵測
55
+
56
+ - 沒有 `anchor_standard` 的 Skill 視為 orphan
57
+ - **偵測後行動**:
58
+ 1. 列入季度報告
59
+ 2. 建立對應 Standard 的 XSPEC(循 admission-criteria 流程)
60
+ 3. 若無法建立 Standard,降 Skill 為 Proposed 直到有錨點
61
+
62
+ ---
63
+
64
+ ## 2026-04 已知孤兒 Skill 清單
65
+
66
+ | Skill ID | 所需 Standard |
67
+ |----------|--------------|
68
+ | `slo-assistant` | slo-standards(XSPEC-063 規劃中) |
69
+ | `runbook-assistant` | runbook-standards(XSPEC-064 規劃中) |
70
+ | `incident-response-assistant` | incident-response-standards(XSPEC-063 規劃中) |
71
+ | `observability-assistant` | observability-standards(XSPEC-063 規劃中) |
72
+ | `metrics-dashboard-assistant` | metrics-dashboard-standards(XSPEC-063 規劃中) |
73
+ | `ci-cd-assistant` | ci-cd-standards(XSPEC-066 規劃中) |
74
+
75
+ 清單將隨 XSPEC-063~069 實作逐步清空。
76
+
77
+ ---
78
+
79
+ ## 對齊檢查工作流程
80
+
81
+ 1. 掃描 `skills/**/*.md` 抽取 frontmatter `anchor_standard`
82
+ 2. 掃描 `ai/standards/*.ai.yaml` 抽取所有 `standard.id`
83
+ 3. 計算差集:Skill without anchor_standard → orphan 清單
84
+ 4. 計算反向差集:Standard without Skill → informational(非錯誤)
85
+ 5. 若 `anchor_standard` 指向不存在的 id 或已 Archived 的 id → 錯誤
86
+ 6. 輸出 `alignment-report.json` / `alignment-report.md`(含 orphan 清單、broken anchor 清單)
87
+
88
+ ---
89
+
90
+ ## 遙測事件
91
+
92
+ **`alignment_check_run`**
93
+
94
+ | 欄位 | 類型 |
95
+ |------|------|
96
+ | `total_skills` | `number` |
97
+ | `total_standards` | `number` |
98
+ | `orphan_skills_count` | `number` |
99
+ | `broken_anchors_count` | `number` |
100
+ | `standalone_standards_count` | `number` |
101
+ | `timestamp` | `string` |
102
+
103
+ ---
104
+
105
+ ## 錯誤碼
106
+
107
+ | 代碼 | 說明 |
108
+ |------|------|
109
+ | `ALIGN-001` | `SKILL_MISSING_ANCHOR` — Skill frontmatter 缺 anchor_standard |
110
+ | `ALIGN-002` | `BROKEN_ANCHOR` — anchor_standard 指向不存在的 standard id |
111
+ | `ALIGN-003` | `ARCHIVED_ANCHOR` — anchor_standard 指向已 Archived 的標準 |
112
+ | `ALIGN-004` | `UTILITY_MISSING_REASON` — utility Skill 標 anchor_standard=none 但缺 utility_reason |
@@ -0,0 +1,104 @@
1
+ ---
2
+ source: ../../../core/standard-admission-criteria.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-20
6
+ status: current
7
+ ---
8
+
9
+ # 標準納入條件
10
+
11
+ > **語言**: [English](../../../core/standard-admission-criteria.md) | 繁體中文
12
+
13
+ **版本**: 1.0.0
14
+ **最後更新**: 2026-04-17
15
+ **狀態**: Trial(到期 2026-10-17)
16
+ **適用範圍**: universal
17
+ **來源**: XSPEC-070(DEC-043 Wave 1 治理 Meta 套件)
18
+
19
+ ---
20
+
21
+ ## 目的
22
+
23
+ 新標準納入 UDS 的四項條件。在 DEC-043 提出 60+ 候選新標準的背景下,需要一個明文的納入檢查清單,避免標準庫膨脹(重疊、未使用)與降低品質。本標準是 UDS 的治理層 meta 標準 — 用來「決定標準的標準」。每個候選新標準必須通過四項條件才能從 Proposed 進入 Trial。
24
+
25
+ ---
26
+
27
+ ## 核心規範
28
+
29
+ - **四項硬性條件**:所有候選新標準必須同時通過 Evidence / Scope / Non-overlapping / AI-executable
30
+ - **拒絕理由必須具體**:不得以「不合適」之類籠統用詞結案,必須指出未通過的 criterion
31
+ - **Admission ≠ Active**:通過 admission 僅代表可進 Trial,不代表直接 Active
32
+ - **Self-applicability**:本標準也必須符合四項條件
33
+ - **Backward compat**:既有 66 個 Active 標準不溯及既往
34
+
35
+ ---
36
+
37
+ ## 四項條件
38
+
39
+ ### 1. Evidence(具體場景)
40
+
41
+ 至少 2 個具體使用場景(非 hypothetical):
42
+
43
+ - 場景來自實際專案、Repo、論文或 DEC 記錄
44
+ - 描述具體(可舉出檔案 / 函式 / commit)
45
+ - 至少 1 個來自 AsiaOstrich 內部痛點或外部產業佐證
46
+
47
+ **拒絕範例**:「未來可能用到」— 無具體場景
48
+
49
+ ### 2. Scope(明確作用域)
50
+
51
+ - `meta.scope` 標示 `universal` / `partial` / `uds-specific`
52
+ - frontmatter 列出適用的活動類型(development / deployment / testing)
53
+ - 若為 partial 或 uds-specific,說明不通用的原因
54
+
55
+ **拒絕範例**:「所有場合都適用」— 過度泛化
56
+
57
+ ### 3. Non-overlapping(無重大重疊)
58
+
59
+ 與既有 UDS 標準內容重複 < 30%:
60
+
61
+ - 列出最接近的 3 個既有標準,說明差異
62
+ - 若有 ≥ 30% 重疊,應改為擴充既有標準
63
+ - 明確定義 `integration_points`
64
+
65
+ **拒絕範例**:與 `retry-standards` 80% 內容重複 — 應合併
66
+
67
+ ### 4. AI-executable(AI 可消費)
68
+
69
+ 至少一個 DevAP QualityGate / VibeOps Agent prompt / Skill 能消費:
70
+
71
+ - 定義清楚的 guidelines(每條可驗證)
72
+ - 至少 2 個 Given-When-Then scenarios
73
+ - 需型別時提供 interface / types 區塊
74
+ - 明確的 `integration_points`
75
+
76
+ **拒絕範例**:只有抽象原則,無任何 AI 可執行的規則
77
+
78
+ ---
79
+
80
+ ## 拒絕協議
81
+
82
+ 1. 拒絕理由必須指出未通過的 criterion(evidence / scope / non-overlapping / ai-executable)
83
+ 2. 拒絕記錄寫入 `cross-project/decisions/` 或 DEC 的 rejection log
84
+ 3. 候選者可依理由修正後重新申請(不永久封鎖)
85
+ 4. 若拒絕理由涉及重疊,應建議改為擴充既有標準
86
+
87
+ ---
88
+
89
+ ## 情境範例
90
+
91
+ - **情境 1 — 通過**:`retry-standards` 申請。Evidence(XSPEC-067 Scenario 1-1/1-2)、Scope(universal)、Non-overlapping(與 circuit-breaker 互補)、AI-executable(9 guidelines + 3 scenarios)全通過 → 進入 Trial
92
+ - **情境 2 — 因重疊拒絕**:`advanced-retry-with-jitter` 申請。與 `retry-standards` 重疊 > 30% → 拒絕,建議改為 Phase 2 擴充
93
+ - **情境 3 — 因證據不足拒絕**:`universal-best-practices` 申請。僅「未來可能用到」類描述 → 拒絕,要求至少 2 個已發生案例
94
+
95
+ ---
96
+
97
+ ## 錯誤碼
98
+
99
+ | 代碼 | 說明 |
100
+ |------|------|
101
+ | `ADMISSION-001` | `MISSING_EVIDENCE` — 未提供至少 2 個具體使用場景 |
102
+ | `ADMISSION-002` | `SCOPE_UNDEFINED` — 未定義 meta.scope 或適用活動類型 |
103
+ | `ADMISSION-003` | `OVERLAP_EXCEEDED` — 與既有標準重疊 > 30% |
104
+ | `ADMISSION-004` | `NOT_AI_EXECUTABLE` — 無任何 AI 可消費的規則或 scenarios |
@@ -0,0 +1,116 @@
1
+ ---
2
+ source: ../../../core/standard-lifecycle-management.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-20
6
+ status: current
7
+ ---
8
+
9
+ # 標準生命週期管理
10
+
11
+ > **語言**: [English](../../../core/standard-lifecycle-management.md) | 繁體中文
12
+
13
+ **版本**: 1.0.0
14
+ **最後更新**: 2026-04-17
15
+ **狀態**: Trial(到期 2026-10-17)
16
+ **適用範圍**: universal
17
+ **來源**: XSPEC-070(DEC-043 Wave 1 治理 Meta 套件)
18
+
19
+ ---
20
+
21
+ ## 目的
22
+
23
+ UDS 標準生命週期狀態機。既有 66 個標準無明確狀態管理:新增標準沒有試驗期、過時標準無棄用路徑、廢棄標準仍被引用。本標準建立五狀態機(Proposed / Trial / Active / Deprecated / Archived)與合法轉移規則,並規範所有 `.ai.yaml` 標準必須在 frontmatter 標示 `status` / `since` / `expires` / `supersedes`。
24
+
25
+ ---
26
+
27
+ ## 核心規範
28
+
29
+ - **所有標準必有狀態**:frontmatter 必須包含 `status` 和 `since`
30
+ - **Trial 必有期限**:`expires` 預設 since + 6 months
31
+ - **Deprecated 必有替代**:`supersedes` 指向替代標準 id 或遷移文件
32
+ - **禁止反向轉移**:Active → Proposed、Archived → Active 均無意義
33
+ - **逾期自動 Archived**:Trial 到期未決則自動歸檔
34
+
35
+ ---
36
+
37
+ ## 狀態說明
38
+
39
+ | 狀態 | 描述 | Skill 可引用? |
40
+ |------|------|--------------|
41
+ | **Proposed** | 草案階段,未通過 admission | 不可 |
42
+ | **Trial** | 批准但試驗中(預設 6 個月) | 可(標註 trial)|
43
+ | **Active** | 全面採用,standard-of-truth | 可 |
44
+ | **Deprecated** | 標記棄用,必須提供 `supersedes` | 可(Skill 應警示)|
45
+ | **Archived** | 已移除,僅保留歷史 | 不可 |
46
+
47
+ ---
48
+
49
+ ## 合法轉移路徑
50
+
51
+ ```
52
+ Proposed ──(通過 admission)──→ Trial
53
+ Trial ──(驗證通過)─────────→ Active
54
+ Trial ──(到期/拒絕)─────────→ Archived
55
+ Active ──(被取代)───────────→ Deprecated
56
+ Deprecated ──(遷移完成)────────→ Archived
57
+ ```
58
+
59
+ **禁止的轉移**:
60
+
61
+ - Active → Proposed(無意義)
62
+ - Archived → Active(應重新申請 admission)
63
+ - Deprecated → Active(應重新 Trial)
64
+ - Proposed → Active(須先 Trial)
65
+
66
+ ---
67
+
68
+ ## Frontmatter 必填欄位
69
+
70
+ ### 必填(所有狀態)
71
+
72
+ - `status`: proposed | trial | active | deprecated | archived
73
+ - `since`: ISO-8601(進入當前狀態的日期)
74
+ - `version`: semver 字串
75
+
76
+ ### 條件必填
77
+
78
+ | 欄位 | 適用時機 |
79
+ |------|---------|
80
+ | `expires` | `status = trial`(預設 since + 6 months)|
81
+ | `supersedes` | `status = deprecated`(替代標準 id 或遷移文件路徑)|
82
+ | `migration_guide` | `status = deprecated`(相對路徑,選填但強烈建議)|
83
+
84
+ ---
85
+
86
+ ## 情境範例
87
+
88
+ - **情境 1 — Trial → Active**:`retry-standards` 處於 trial。2026-08-01 審視發現 DevAP Fix Loop 和 VibeOps Builder 均採用且無重大缺陷 → 轉 Active,`since=2026-08-01`,移除 `expires`
89
+ - **情境 2 — Trial 逾期自動 Archived**:某標準 trial 期限 2026-10-17 到期未通過驗證 → 狀態轉 Archived,記錄原因
90
+ - **情境 3 — Deprecated 帶遷移**:`legacy-retry-logic` 被 `retry-standards` 取代 → `status=deprecated, supersedes=retry-standards, migration_guide=docs/migrations/retry-v1-to-v2.md`;Skill 使用時顯示警告
91
+
92
+ ---
93
+
94
+ ## 遙測事件
95
+
96
+ **`standard_state_change`**
97
+
98
+ | 欄位 | 類型 |
99
+ |------|------|
100
+ | `standard_id` | `string` |
101
+ | `from_state` | `proposed\|trial\|active\|deprecated\|archived` |
102
+ | `to_state` | `proposed\|trial\|active\|deprecated\|archived` |
103
+ | `reason` | `string` |
104
+ | `timestamp` | `ISO-8601` |
105
+
106
+ ---
107
+
108
+ ## 錯誤碼
109
+
110
+ | 代碼 | 說明 |
111
+ |------|------|
112
+ | `LIFECYCLE-001` | `MISSING_STATUS` — frontmatter 缺 status 欄位 |
113
+ | `LIFECYCLE-002` | `MISSING_EXPIRES` — trial 狀態缺 expires 欄位 |
114
+ | `LIFECYCLE-003` | `MISSING_SUPERSEDES` — deprecated 狀態缺 supersedes 欄位 |
115
+ | `LIFECYCLE-004` | `FORBIDDEN_TRANSITION` — 嘗試執行禁止的狀態轉移 |
116
+ | `LIFECYCLE-005` | `TRIAL_EXPIRED` — trial 到期未決策 |
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  source: ../../../core/test-governance.md
3
- source_version: 1.0.0
4
- translation_version: 1.0.0
5
- last_synced: 2026-03-24
3
+ source_version: 1.1.0
4
+ translation_version: 1.1.0
5
+ last_synced: 2026-04-20
6
6
  status: current
7
7
  ---
8
8
 
@@ -81,6 +81,17 @@ status: current
81
81
  | Staging | 整合和 E2E 測試 | DevOps |
82
82
  | Production | 煙霧測試和監控 | SRE |
83
83
 
84
+ ## 規則
85
+
86
+ | ID | 觸發時機 | 指令 | 優先度 |
87
+ |----|---------|------|--------|
88
+ | enforce-completion-criteria | 完成任務或功能時 | 在將任務/功能標記為完成前,驗證所有必要的完成準則已達成 | 必須 |
89
+ | pyramid-compliance | 規劃測試策略時 | 以 70/20/7/3 金字塔比例為指引。可接受偏差,但需有文件記錄的正當理由 | 必須 |
90
+ | sit-isolation | 執行系統測試時 | 系統測試應對外部相依性使用 Stub,但使用真實的內部服務。使用 SIT 環境進行系統層級的驗證 | 建議 |
91
+ | test-execution-continuity | 新增或完成測試案例時 | 測試案例必須連接到自動化執行觸發器(CI gate、build hook 或排程執行)。存在但從未執行的測試提供假信心,比沒有測試更糟。在將測試覆蓋率標記為完成前,請確認執行歷程存在。| 必須 |
92
+
93
+ ---
94
+
84
95
  ## 相關標準
85
96
 
86
97
  - [測試標準](testing-standards.md)
@@ -1,3 +1,11 @@
1
+ ---
2
+ source: ../../../core/testing-standards.md
3
+ source_version: 3.2.0
4
+ translation_version: 3.2.0
5
+ last_synced: 2026-04-20
6
+ status: current
7
+ ---
8
+
1
9
  # 測試標準
2
10
 
3
11
  > **Language**: [English](../../../core/testing-standards.md) | 繁體中文
@@ -231,6 +239,29 @@
231
239
  e2e/[feature]/[scenario].[ext]
232
240
  ```
233
241
 
242
+ #### E2E 前置條件範圍(e2e-precondition-scope)
243
+
244
+ E2E 環境前置檢查(`globalSetup`、`beforeAll`)必須驗證**所有受測頁面與端點**的健康狀態,而非僅驗證認證入口點。
245
+
246
+ **反模式** — 只驗 login:
247
+ ```ts
248
+ // ❌ 即使功能頁回傳 500 也會通過
249
+ await page.goto('/login');
250
+ expect(response.status()).toBe(200);
251
+ ```
252
+
253
+ **正確模式** — 明確的覆蓋清單:
254
+ ```ts
255
+ // ✅ 驗證套件涵蓋的所有頁面
256
+ const PAGES_UNDER_TEST = ['/login', '/dashboard', '/feature-x'];
257
+ for (const path of PAGES_UNDER_TEST) {
258
+ const res = await fetch(`${BASE_URL}${path}`);
259
+ expect(res.status).toBeLessThan(500); // 遇到 5xx 立即失敗
260
+ }
261
+ ```
262
+
263
+ > **證據**:真實事故 — E2E `globalSetup` 只驗了 `Login.aspx`;功能頁靜默回傳 HTTP 500。整個 E2E 套件通過,提供假信心,直到正式環境崩潰才被發現。
264
+
234
265
  ---
235
266
 
236
267
  ## 測試替身
@@ -0,0 +1,117 @@
1
+ ---
2
+ source: ../../../core/timeout-standards.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-20
6
+ status: current
7
+ ---
8
+
9
+ # Timeout 標準
10
+
11
+ > **語言**: [English](../../../core/timeout-standards.md) | 繁體中文
12
+
13
+ **版本**: 1.0.0
14
+ **最後更新**: 2026-04-17
15
+ **狀態**: Trial(到期 2026-10-17)
16
+ **適用範圍**: universal
17
+ **來源**: XSPEC-067(DEC-043 Wave 1 可靠性套件)
18
+
19
+ ---
20
+
21
+ ## 目的
22
+
23
+ Timeout 標準:層級預算(cascading 0.8×)、deadline propagation、與 circuit-breaker 整合。
24
+
25
+ 避免多層呼叫鏈中下層 timeout 大於上層(導致上層先 timeout 而下層仍在執行的資源浪費)。透過 cascading 預算規則(每層 ≤ 0.8× 上層)與 deadline propagation(傳 absolute timestamp)讓整條呼叫鏈都能精準 fail-fast。
26
+
27
+ ---
28
+
29
+ ## 核心規範
30
+
31
+ - 多層呼叫的 timeout 必須逐層遞減,每下一層 ≤ 0.8 × 上層(預留 20% buffer)
32
+ - 跨服務呼叫必須傳遞 deadline(absolute timestamp),不得只傳 relative duration
33
+ - 收到請求後若 `now > deadline`,必須立即 fail-fast,禁止發起下游呼叫
34
+ - Timeout 觸發必須計入對應 circuit-breaker 的 failure count
35
+ - 禁止下層 timeout 大於上層 timeout(違反 fail-fast,等同沒設 timeout)
36
+
37
+ ---
38
+
39
+ ## Cascading 預算規則
40
+
41
+ **規則**:每下一層 timeout ≤ 0.8 × 上層 timeout
42
+
43
+ **範例**(Client timeout=10s,呼叫鏈 Client → Gateway → Service A → DB):
44
+
45
+ | 層級 | timeout |
46
+ |------|---------|
47
+ | Client | 10,000ms |
48
+ | Gateway | 8,000ms(10000 × 0.8) |
49
+ | Service A | 6,400ms(8000 × 0.8) |
50
+ | DB | 5,120ms(6400 × 0.8) |
51
+
52
+ **理由**:
53
+ - 預留 20% buffer 給序列化、網路傳輸、重試等開銷
54
+ - 避免上層先 timeout 而下層仍在執行(資源浪費)
55
+ - 0.8 是業界經驗值(gRPC / Envoy 常用 0.7~0.85)
56
+
57
+ ---
58
+
59
+ ## Deadline Propagation
60
+
61
+ | 欄位 | 值 |
62
+ |------|-----|
63
+ | 格式 | absolute ISO-8601 timestamp(非 relative duration) |
64
+ | Header 名稱 | `X-Deadline` |
65
+
66
+ **規則**:
67
+ 1. 發起呼叫前計算 `deadline = now + timeout`,寫入 header
68
+ 2. 收到請求後立即檢查 `now > deadline_header` → 若是則 fail-fast(回 `DEADLINE_EXCEEDED`)
69
+ 3. 向下游呼叫時 `timeout = min(cascading_budget, deadline - now)`,取兩者較小
70
+
71
+ **理由**:Relative duration(如 timeout=5s)無法在多層呼叫中累積扣除;absolute timestamp 讓每一層都能精準計算剩餘時間。
72
+
73
+ ---
74
+
75
+ ## Timeout 類型
76
+
77
+ | 類型 | 預設值 | 說明 |
78
+ |------|--------|------|
79
+ | `connect_timeout` | 5,000ms | 建立 TCP / TLS 連線的時間上限 |
80
+ | `request_timeout` | 30,000ms | 發送請求到收到完整回應的時間上限;受 cascading 預算約束 |
81
+ | `idle_timeout` | 60,000ms | 連線閒置多久後關閉;server 端設定 |
82
+ | `total_deadline` | 60,000ms | 含所有重試在內的整體上限;retry × attempt_timeout 總和不得超過此值 |
83
+
84
+ ---
85
+
86
+ ## 與 circuit-breaker 整合
87
+
88
+ | 規則 | 說明 |
89
+ |------|------|
90
+ | Rule 1 | 每次 timeout 觸發視為一次失敗,計入 breaker 的 failure count |
91
+ | Rule 2 | 連續 timeout 達 failureThreshold 時 breaker 進入 OPEN |
92
+ | Rule 3 | OPEN 狀態下的請求應套用極短 timeout(或直接 fail-fast) |
93
+
94
+ ---
95
+
96
+ ## 情境範例
97
+
98
+ **情境 1:cascading 預算驗證**
99
+ - Client timeout=10s,各層依序 8s → 6.4s → 5.12s
100
+
101
+ **情境 2:deadline 已過期 fail-fast**
102
+ - 條件:請求抵達 Service A 時 X-Deadline 已過期
103
+ - 結果:立即回 DEADLINE_EXCEEDED,不呼叫 DB
104
+
105
+ **情境 3:timeout 觸發 circuit breaker**
106
+ - 條件:連續 3 次下游呼叫皆 timeout(failureThreshold=3)
107
+ - 結果:circuit-breaker 進入 OPEN,第 4 次立即回 CircuitOpenError
108
+
109
+ ---
110
+
111
+ ## 錯誤碼
112
+
113
+ | 代碼 | 說明 |
114
+ |------|------|
115
+ | `TIMEOUT-001` | `REQUEST_TIMEOUT` — 單次請求超時 |
116
+ | `TIMEOUT-002` | `DEADLINE_EXCEEDED` — 整體 deadline 已過,拒絕發起/處理請求 |
117
+ | `TIMEOUT-003` | `CASCADING_BUDGET_VIOLATION` — 下層 timeout > 上層 timeout(配置錯誤) |
@@ -0,0 +1,143 @@
1
+ ---
2
+ source: ../../../core/token-budget.md
3
+ source_version: 1.0.0
4
+ translation_version: 1.0.0
5
+ last_synced: 2026-04-20
6
+ status: current
7
+ ---
8
+
9
+ # Token 預算區間標準
10
+
11
+ > **語言**: [English](../../../core/token-budget.md) | 繁體中文
12
+
13
+ **版本**: 1.0.0
14
+ **最後更新**: 2026-04-15
15
+ **適用範圍**: 所有有 token 預算限制的 Agent 執行環境
16
+ **Scope**: universal
17
+ **來源**: XSPEC-036(claude-code-book Ch.7 four-zone threshold model)
18
+
19
+ ---
20
+
21
+ ## 目的
22
+
23
+ Token 閾值四區模型:以使用率百分比劃分四個運作區間,漸進觸發不同強度的保護策略。
24
+
25
+ 比「打到上限才停」更優雅,為使用者提供早期預警和自動降級機會。
26
+
27
+ ---
28
+
29
+ ## 核心規範
30
+
31
+ - 所有有 token 預算限制的執行環境必須使用四區模型監控使用率
32
+ - WARNING 區必須記錄日誌並發出可觀測事件,不得靜默
33
+ - DANGER 區必須觸發輕量保護策略(如截斷工具結果、縮減輸出預算)
34
+ - BLOCKING 區必須拒絕新請求,回傳 `TOKEN_BUDGET_EXCEEDED` 而非讓請求超時崩潰
35
+ - 壓縮操作本身需保留足夠的輸出空間(否則壓縮本身也可能失敗)
36
+
37
+ ---
38
+
39
+ ## 四區模型
40
+
41
+ | 區間 | 使用率範圍 | 行動 | 日誌等級 |
42
+ |------|----------|------|---------|
43
+ | **SAFE**(安全) | 0% – 84% | 正常執行 | — |
44
+ | **WARNING**(警告) | 85% – 89% | 發出 `TOKEN_BUDGET_WARNING` 事件,通知 Coordinator/使用者 | `info` |
45
+ | **DANGER**(危險) | 90% – 94% | 觸發輕量壓縮策略 | `warn` |
46
+ | **BLOCKING**(阻塞) | 95% – 100% | 拒絕新請求,回傳 `TOKEN_BUDGET_EXCEEDED` | `error` |
47
+
48
+ ### WARNING 區可選行動
49
+
50
+ - 降低 `model_tier`(capable → standard)
51
+ - 提示使用者考慮分割任務
52
+
53
+ ### DANGER 區必要行動
54
+
55
+ - 截斷超大工具結果(Tool Result Snip)
56
+ - 縮減後續 Agent 的 `maxToolRounds`(建議降低 20%)
57
+
58
+ ### DANGER 區可選行動
59
+
60
+ - 將重要輸出持久化到磁碟,上下文只保留摘要
61
+
62
+ ---
63
+
64
+ ## 閾值常數
65
+
66
+ | 常數 | 值 |
67
+ |------|-----|
68
+ | `WARNING_THRESHOLD` | `0.85` |
69
+ | `DANGER_THRESHOLD` | `0.90` |
70
+ | `BLOCKING_THRESHOLD` | `0.95` |
71
+
72
+ ---
73
+
74
+ ## 類型定義
75
+
76
+ ### TokenBudgetZone
77
+
78
+ ```
79
+ safe | warning | danger | blocking
80
+ ```
81
+
82
+ ### TokenBudgetStatus
83
+
84
+ | 欄位 | 類型 |
85
+ |------|------|
86
+ | `current_tokens` | `number` |
87
+ | `max_tokens` | `number` |
88
+ | `usage_ratio` | `number` |
89
+ | `zone` | `TokenBudgetZone` |
90
+
91
+ ### TokenBudgetExceededError
92
+
93
+ | 欄位 | 類型 |
94
+ |------|------|
95
+ | `code` | `"TOKEN_BUDGET_EXCEEDED"` |
96
+ | `current_tokens` | `number` |
97
+ | `max_tokens` | `number` |
98
+ | `usage_ratio` | `number` |
99
+ | `zone` | `"blocking"` |
100
+
101
+ ---
102
+
103
+ ## 壓縮後預算常數參考
104
+
105
+ | 常數 | 值 |
106
+ |------|-----|
107
+ | `MAX_FILES_TO_RESTORE` | `5` |
108
+ | `TOTAL_TOKEN_BUDGET` | `50000` |
109
+ | `MAX_TOKENS_PER_FILE` | `5000` |
110
+ | `MAX_TOKENS_PER_SKILL` | `5000` |
111
+
112
+ ---
113
+
114
+ ## 遙測事件
115
+
116
+ **`token_budget_zone_change`**
117
+
118
+ | 欄位 | 類型 |
119
+ |------|------|
120
+ | `from_zone` | `TokenBudgetZone` |
121
+ | `to_zone` | `TokenBudgetZone` |
122
+ | `usage_ratio` | `number` |
123
+ | `agent_name` | `string` |
124
+ | `timestamp` | `string` |
125
+
126
+ ---
127
+
128
+ ## 適用場景
129
+
130
+ - DevAP 任務執行(Task token 預算監控)
131
+ - VibeOps 9-Agent Pipeline(跨 Agent 累積上下文監控)
132
+ - VibeOps PipelineMemory Snip 觸發條件
133
+ - 任何有 `maxTotalTokens` 限制的 Agent 執行環境
134
+
135
+ ---
136
+
137
+ ## 錯誤碼
138
+
139
+ | 代碼 | 說明 |
140
+ |------|------|
141
+ | `TB-001` | `TOKEN_BUDGET_EXCEEDED` — 已進入 BLOCKING 區,拒絕新請求 |
142
+ | `TB-002` | `TOKEN_BUDGET_WARNING` — 已進入 WARNING 區,建議採取行動 |
143
+ | `TB-003` | `SNIP_FAILED` — 輕量壓縮失敗,仍在 DANGER 區 |