doc-adr-validator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesedoc-adr-validator
doc-adr-validator 文档ADR验证器
Validate Architecture Decision Records (ADR) against Layer 5 schema standards.
依据Layer 5 schema标准验证架构决策记录(ADR)。
Activation
触发时机
Invoke when user requests validation of ADR documents or after creating/modifying ADR artifacts.
当用户请求验证ADR文档时,或在创建/修改ADR工件后触发。
Validation Schema Reference
验证Schema参考
Schema:
Layer: 5
Artifact Type: ADR
ai_dev_flow/ADR/ADR_SCHEMA.yamlSchema:
层级:5
工件类型:ADR
ai_dev_flow/ADR/ADR_SCHEMA.yamlValidation Checklist
验证检查清单
0. Folder Structure Validation (BLOCKING)
0. 文件夹结构验证(阻塞性检查)
Nested Folder Rule: ALL ADR documents MUST be in nested folders regardless of size.
Required Structure:
| ADR Type | Required Location |
|---|---|
| Monolithic | |
Validation:
1. Check document is inside a nested folder: docs/05_ADR/ADR-NN_{slug}/
2. Verify folder name matches ADR ID pattern: ADR-NN_{slug}
3. Verify file name matches folder: ADR-NN_{slug}.md
4. Parent path must be: docs/05_ADR/Example Valid Structure:
docs/05_ADR/
├── ADR-01_f1_iam/
│ ├── ADR-01_f1_iam.md ✓ Valid
│ ├── ADR-01.R_review_report_v001.md
│ └── .drift_cache.json
├── ADR-02_f2_session/
│ └── ADR-02_f2_session.md ✓ ValidInvalid Structure:
docs/05_ADR/
├── ADR-01_f1_iam.md ✗ NOT in nested folderError Codes:
| Code | Severity | Description |
|---|---|---|
| ADR-E020 | ERROR | ADR not in nested folder (BLOCKING) |
| ADR-E021 | ERROR | Folder name doesn't match ADR ID |
| ADR-E022 | ERROR | File name doesn't match folder name |
This check is BLOCKING - ADR must pass folder structure validation before other checks proceed.
嵌套文件夹规则:无论规模大小,所有ADR文档必须存放在嵌套文件夹中。
必填结构:
| ADR类型 | 必填存放位置 |
|---|---|
| 单体架构 | |
验证步骤:
1. 检查文档是否位于嵌套文件夹内:docs/05_ADR/ADR-NN_{slug}/
2. 验证文件夹名称是否匹配ADR ID格式:ADR-NN_{slug}
3. 验证文件名是否与文件夹名称一致:ADR-NN_{slug}.md
4. 父路径必须为:docs/05_ADR/有效结构示例:
docs/05_ADR/
├── ADR-01_f1_iam/
│ ├── ADR-01_f1_iam.md ✓ 有效
│ ├── ADR-01.R_review_report_v001.md
│ └── .drift_cache.json
├── ADR-02_f2_session/
│ └── ADR-02_f2_session.md ✓ 有效无效结构示例:
docs/05_ADR/
├── ADR-01_f1_iam.md ✗ 未存放在嵌套文件夹中错误代码:
| 代码 | 严重程度 | 描述 |
|---|---|---|
| ADR-E020 | 错误 | ADR未存放在嵌套文件夹中(阻塞性错误) |
| ADR-E021 | 错误 | 文件夹名称与ADR ID不匹配 |
| ADR-E022 | 错误 | 文件名与文件夹名称不一致 |
本检查为阻塞性检查 - ADR必须通过文件夹结构验证后,才能进行其他检查。
1. Metadata Validation
1. 元数据验证
yaml
Required custom_fields:
- document_type: ["adr", "template"]
- artifact_type: "ADR"
- layer: 5
- architecture_approaches: [array format]
- priority: ["primary", "shared", "fallback"]
- development_status: ["active", "draft", "deprecated", "reference"]
Required tags:
- adr (or adr-template)
- layer-5-artifact
Forbidden tag patterns:
- "^architecture-decision$"
- "^decision-record$"
- "^adr-\\d{3}$"yaml
必填自定义字段:
- document_type: ["adr", "template"]
- artifact_type: "ADR"
- layer: 5
- architecture_approaches: 数组格式
- priority: ["primary", "shared", "fallback"]
- development_status: ["active", "draft", "deprecated", "reference"]
必填标签:
- adr (或 adr-template)
- layer-5-artifact
禁用标签格式:
- "^architecture-decision$"
- "^decision-record$"
- "^adr-\\d{3}$"2. Structure Validation
2. 结构验证
Document Parts:
- PART 1: Decision Context and Requirements (Sections 1-6)
- PART 2: Impact Analysis and Architecture (Sections 7-10)
- PART 3: Implementation Strategy (Sections 11-13)
- PART 4: Traceability and Documentation (Sections 14-15)
Required Sections:
- Title (H1):
# ADR-NNN: Title - Section 1: Document Control
- Section 2: Position in Development Workflow
- Section 3: Status
- Section 4: Context (Problem Statement, Background, Driving Forces, Constraints)
- Section 5: Decision (Chosen Solution, Key Components, Implementation Approach)
- Section 6: Requirements Satisfied
- Section 7: Consequences (Positive, Negative Outcomes)
- Section 8: Architecture Flow (Mermaid diagram)
- Section 9: Implementation Assessment (Complexity, Dependencies)
- Section 10: Impact Analysis
Optional Sections:
- Section 11: Alternatives Considered
- Section 12: Security Considerations
- Section 13: Operational Considerations
- Section 14: Traceability
- Section 15: References
Document Control Required Fields:
- Project Name
- Document Version
- Date
- Document Owner
- Prepared By
- Status
File Naming:
Pattern:
ADR-NNN_descriptive_name.md文档组成部分:
- 第一部分:决策背景与需求(第1-6节)
- 第二部分:影响分析与架构(第7-10节)
- 第三部分:实施策略(第11-13节)
- 第四部分:可追溯性与文档(第14-15节)
必填章节:
- 标题(H1):
# ADR-NNN: 标题 - 第1节:文档管控
- 第2节:在开发流程中的定位
- 第3节:状态
- 第4节:背景(问题陈述、背景信息、驱动因素、约束条件)
- 第5节:决策(选定方案、核心组件、实施方法)
- 第6节:已满足的需求
- 第7节:影响(正面、负面结果)
- 第8节:架构流程(Mermaid图)
- 第9节:实施评估(复杂度、依赖关系)
- 第10节:影响分析
可选章节:
- 第11节:备选方案考量
- 第12节:安全考量
- 第13节:运维考量
- 第14节:可追溯性
- 第15节:参考资料
文档管控必填字段:
- 项目名称
- 文档版本
- 日期
- 文档所有者
- 编制人
- 状态
文件命名规则:
格式:
ADR-NNN_描述性名称.md3. Content Validation
3. 内容验证
Status Values:
- Proposed
- Accepted
- Deprecated
- Superseded
Context Subsections (Required):
- 4.1 Problem Statement
- 4.2 Background
- 4.3 Driving Forces
- 4.4 Constraints
Decision Subsections (Required):
- 5.1 Chosen Solution
- 5.2 Key Components
- 5.3 Implementation Approach
Consequences Subsections (Required):
- 7.1 Positive Outcomes
- 7.2 Negative Outcomes
Architecture Flow:
- Must contain Mermaid diagram
- Allowed types: flowchart, sequenceDiagram, stateDiagram-v2
ADR-Ready Score:
- Minimum threshold: 90%
- Components: Problem statement, context, decision clarity, consequences, architecture diagram, implementation assessment, traceability
状态取值:
- 提议中
- 已通过
- 已弃用
- 已取代
背景子章节(必填):
- 4.1 问题陈述
- 4.2 背景信息
- 4.3 驱动因素
- 4.4 约束条件
决策子章节(必填):
- 5.1 选定方案
- 5.2 核心组件
- 5.3 实施方法
影响子章节(必填):
- 7.1 正面结果
- 7.2 负面结果
架构流程:
- 必须包含Mermaid图
- 允许的类型:flowchart、sequenceDiagram、stateDiagram-v2
ADR就绪度评分:
- 最低阈值:90%
- 评分组成:问题陈述、背景、决策清晰度、影响、架构图、实施评估、可追溯性
4. Traceability Validation
4. 可追溯性验证
Layer 5 Cumulative Tags:
- @brd: BRD.NN.01.SS (required)
- @prd: PRD.NN.07.SS (required)
- @ears: EARS.NN.24.SS (required)
- @bdd: BDD.NN.13.SS (required)
Downstream Expected:
- SYS requirements
- REQ documents
- SPEC documents
Same-Type References:
- @related-adr: ADR-NN
- @supersedes: ADR-NN
- @depends-adr: ADR-NN
Layer5 累积标签:
- @brd: BRD.NN.01.SS(必填)
- @prd: PRD.NN.07.SS(必填)
- @ears: EARS.NN.24.SS(必填)
- @bdd: BDD.NN.13.SS(必填)
预期下游关联:
- SYS需求文档
- REQ文档
- SPEC文档
同类型引用:
- @related-adr: ADR-NN
- @supersedes: ADR-NN
- @depends-adr: ADR-NN
Error Codes
错误代码
| Code | Severity | Description |
|---|---|---|
| ADR-E001 | error | Missing required tag 'adr' |
| ADR-E002 | error | Missing required tag 'layer-5-artifact' |
| ADR-E003 | error | Invalid document_type |
| ADR-E004 | error | Invalid architecture_approaches format |
| ADR-E005 | error | Forbidden tag pattern detected |
| ADR-E006 | error | Missing required section |
| ADR-E007 | error | Multiple H1 headings detected |
| ADR-E008 | error | Missing Context section (Section 4) |
| ADR-E009 | error | Missing Decision section (Section 5) |
| ADR-E010 | error | Missing Consequences section (Section 7) |
| ADR-E011 | error | Context missing Problem Statement subsection |
| ADR-E012 | error | Decision missing Chosen Solution subsection |
| ADR-E013 | error | Consequences missing outcomes |
| ADR-E014 | warning | File name does not match format |
| ADR-W001 | warning | Missing Architecture Flow Mermaid diagram |
| ADR-W002 | warning | Context missing Constraints subsection |
| ADR-W003 | warning | Missing upstream tags (@prd, @ears, @bdd) |
| ADR-W004 | warning | Implementation Assessment missing Complexity |
| ADR-W005 | warning | SYS-Ready Score below 90% |
| ADR-W006 | warning | Requirements Satisfied table missing |
| ADR-I001 | info | Consider adding Alternatives Considered |
| ADR-I002 | info | Consider adding Security Considerations |
| ADR-I003 | info | Consider adding Rollback Plan |
| 代码 | 严重程度 | 描述 |
|---|---|---|
| ADR-E001 | 错误 | 缺失必填标签'adr' |
| ADR-E002 | 错误 | 缺失必填标签'layer-5-artifact' |
| ADR-E003 | 错误 | 无效的document_type |
| ADR-E004 | 错误 | architecture_approaches格式无效 |
| ADR-E005 | 错误 | 检测到禁用标签格式 |
| ADR-E006 | 错误 | 缺失必填章节 |
| ADR-E007 | 错误 | 检测到多个H1标题 |
| ADR-E008 | 错误 | 缺失背景章节(第4节) |
| ADR-E009 | 错误 | 缺失决策章节(第5节) |
| ADR-E010 | 错误 | 缺失影响章节(第7节) |
| ADR-E011 | 错误 | 背景章节缺失问题陈述子章节 |
| ADR-E012 | 错误 | 决策章节缺失选定方案子章节 |
| ADR-E013 | 错误 | 影响章节缺失结果子章节 |
| ADR-E014 | 警告 | 文件名不符合格式要求 |
| ADR-W001 | 警告 | 缺失架构流程Mermaid图 |
| ADR-W002 | 警告 | 背景章节缺失约束条件子章节 |
| ADR-W003 | 警告 | 缺失上游标签(@prd、@ears、@bdd) |
| ADR-W004 | 警告 | 实施评估缺失复杂度分析 |
| ADR-W005 | 警告 | SYS就绪度评分低于90% |
| ADR-W006 | 警告 | 缺失已满足需求表格 |
| ADR-I001 | 信息 | 建议添加备选方案考量章节 |
| ADR-I002 | 信息 | 建议添加安全考量章节 |
| ADR-I003 | 信息 | 建议添加回滚计划 |
Validation Commands
验证命令
bash
undefinedbash
undefinedValidate single ADR document
验证单个ADR文档
python ai_dev_flow/scripts/validate_adr.py docs/05_ADR/ADR-001_example.md
python ai_dev_flow/scripts/validate_adr.py docs/05_ADR/ADR-001_example.md
Validate all ADR documents
验证所有ADR文档
python ai_dev_flow/scripts/validate_adr.py docs/05_ADR/
python ai_dev_flow/scripts/validate_adr.py docs/05_ADR/
Check with verbose output
查看详细输出
python ai_dev_flow/scripts/validate_adr.py docs/05_ADR/ --verbose
undefinedpython ai_dev_flow/scripts/validate_adr.py docs/05_ADR/ --verbose
undefinedValidation Workflow
验证流程
- Parse YAML frontmatter
- Check required metadata fields
- Validate tag taxonomy
- Verify 4-part structure
- Validate required sections (1-10)
- Check Context subsections
- Check Decision subsections
- Check Consequences subsections
- Verify Mermaid diagram presence
- Validate upstream references
- Calculate SYS-Ready Score
- Verify file naming convention
- Generate validation report
- 解析YAML前置元数据
- 检查必填元数据字段
- 验证标签分类
- 验证四部分结构
- 验证必填章节(1-10节)
- 检查背景子章节
- 检查决策子章节
- 检查影响子章节
- 验证Mermaid图是否存在
- 验证上游引用
- 计算SYS就绪度评分
- 验证文件命名规范
- 生成验证报告
Integration
集成方式
- Invoked by: doc-flow, doc-adr (post-creation)
- Feeds into: trace-check (cross-document validation)
- Reports to: quality-advisor
- 调用方:doc-flow、doc-adr(创建后触发)
- 输出至:trace-check(跨文档验证)
- 报告至:quality-advisor
Output Format
输出格式
ADR Validation Report
=====================
Document: ADR-001_example.md
Status: PASS/FAIL
Structure:
- Context: Complete/Incomplete
- Decision: Complete/Incomplete
- Consequences: Complete/Incomplete
- Architecture Flow: Present/Missing
Errors: N
Warnings: N
Info: N
[Details listed by severity]ADR验证报告
=====================
文档: ADR-001_example.md
状态: 通过/失败
结构:
- 背景: 完整/不完整
- 决策: 完整/不完整
- 影响: 完整/不完整
- 架构流程: 存在/缺失
错误数: N
警告数: N
信息数: N
[按严重程度列出详细内容]Version History
版本历史
| Version | Date | Changes | Author |
|---|---|---|---|
| 1.1 | 2026-02-11 | Nested Folder Rule: Added Section 0 Folder Structure Validation (BLOCKING); ADR must be in | |
| 1.0 | 2026-02-08 | Initial validator skill definition with YAML frontmatter | System |
| 版本 | 日期 | 变更内容 | 作者 |
|---|---|---|---|
| 1.1 | 2026-02-11 | 嵌套文件夹规则:新增第0节文件夹结构验证(阻塞性检查);ADR必须存放在 | |
| 1.0 | 2026-02-08 | 初始验证器技能定义,包含YAML前置元数据 | 系统 |