doc-spec-autopilot
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesedoc-spec-autopilot
doc-spec-autopilot
Purpose
用途
Automated Technical Specifications (SPEC) generation pipeline that processes REQ documents (and optional CTR) to generate implementation-ready YAML specifications with TASKS-Ready scoring.
Layer: 9
Upstream: REQ (Layer 7), CTR (Layer 8 - optional)
Downstream: TSPEC (Layer 10), TASKS (Layer 11)
自动化的**技术规格说明(SPEC)**生成流水线,处理REQ文档(及可选的CTR文档)以生成可直接用于实现的YAML规格说明,并提供TASKS就绪评分。
层级: 9
上游: REQ(层级7),CTR(层级8 - 可选)
下游: TSPEC(层级10),TASKS(层级11)
Skill Dependencies
技能依赖
| Skill | Purpose | Phase |
|---|---|---|
| Element ID format (SPEC.NN.TT.SS, codes 15, 16, 17, 21, 28) | All Phases |
| Validate REQ SPEC-Ready score | Phase 2 |
| SPEC creation rules, YAML format | Phase 3 |
| Real-time quality feedback | Phase 3 |
| Validation with TASKS-Ready scoring | Phase 4 |
| Content review, link validation, quality scoring | Phase 5: Review |
| Apply fixes from review report, create missing files | Phase 5: Fix |
| 技能 | 用途 | 阶段 |
|---|---|---|
| 元素ID格式(SPEC.NN.TT.SS,编码15、16、17、21、28) | 所有阶段 |
| 验证REQ的SPEC就绪评分 | 阶段2 |
| SPEC创建规则、YAML格式 | 阶段3 |
| 实时质量反馈 | 阶段3 |
| 带TASKS就绪评分的验证 | 阶段4 |
| 内容审查、链接验证、质量评分 | 阶段5:审查 |
| 应用审查报告中的修复建议,创建缺失文件 | 阶段5:修复 |
Smart Document Detection
智能文档检测
The autopilot automatically determines the action based on the input document type.
该自动化工具会根据输入文档类型自动确定操作。
Input Type Recognition (Multiple Upstreams)
输入类型识别(多上游来源)
SPEC can be derived from REQ and/or CTR:
| Input | Detected As | Action |
|---|---|---|
| Self type | Review existing SPEC document |
| Primary upstream | Generate if missing, review if exists |
| Alternative upstream | Generate if missing, review if exists |
SPEC可从REQ和/或CTR推导而来:
| 输入 | 识别类型 | 操作 |
|---|---|---|
| 自身类型 | 审查现有SPEC文档 |
| 主要上游来源 | 若缺失则生成,若存在则审查 |
| 备选上游来源 | 若缺失则生成,若存在则审查 |
Detection Algorithm
检测算法
1. Parse input: Extract TYPE and NN from "{TYPE}-{NN}"
2. Determine action:
- IF TYPE == "SPEC": Review Mode
- ELSE IF TYPE in ["REQ", "CTR"]: Generate/Find Mode
- ELSE: Error (invalid type for this autopilot)
3. For Generate/Find Mode:
- Check: Does SPEC-{NN} exist in docs/09_SPEC/?
- IF exists: Switch to Review Mode for SPEC-{NN}
- ELSE: Proceed with Generation from {TYPE}-{NN}1. 解析输入:从"{TYPE}-{NN}"中提取TYPE和NN
2. 确定操作:
- 若TYPE == "SPEC":审查模式
- 若TYPE属于["REQ", "CTR"]:生成/查找模式
- 否则:错误(该自动化工具不支持此类型)
3. 对于生成/查找模式:
- 检查:docs/09_SPEC/中是否存在SPEC-{NN}?
- 若存在:切换为SPEC-{NN}的审查模式
- 否则:从{TYPE}-{NN}开始生成File Existence Check
文件存在性检查
bash
undefinedbash
undefinedCheck for nested folder structure (mandatory)
检查嵌套文件夹结构(必填)
ls docs/09_SPEC/SPEC-{NN}_*/
undefinedls docs/09_SPEC/SPEC-{NN}_*/
undefinedExamples
示例
bash
undefinedbash
undefinedReview mode (same type - SPEC input)
审查模式(同一类型 - SPEC输入)
/doc-spec-autopilot SPEC-01 # Reviews existing SPEC-01
/doc-spec-autopilot SPEC-01 # 审查现有SPEC-01
Generate/Find mode (upstream types)
生成/查找模式(上游类型)
/doc-spec-autopilot REQ-01 # Generates SPEC-01 if missing, or reviews existing SPEC-01
/doc-spec-autopilot CTR-01 # Generates SPEC-01 if missing, or reviews existing SPEC-01
/doc-spec-autopilot REQ-01 # 若缺失则生成SPEC-01,否则审查现有SPEC-01
/doc-spec-autopilot CTR-01 # 若缺失则生成SPEC-01,否则审查现有SPEC-01
Multiple inputs
多输入
/doc-spec-autopilot REQ-01,REQ-02 # Generates/reviews SPEC-01 and SPEC-02
/doc-spec-autopilot SPEC-01,SPEC-02 # Reviews SPEC-01 and SPEC-02
undefined/doc-spec-autopilot REQ-01,REQ-02 # 生成/审查SPEC-01和SPEC-02
/doc-spec-autopilot SPEC-01,SPEC-02 # 审查SPEC-01和SPEC-02
undefinedAction Determination Output
操作确定输出
Input: REQ-01
├── Detected Type: REQ (primary upstream)
├── Expected SPEC: SPEC-01
├── SPEC Exists: Yes → docs/09_SPEC/SPEC-01_f1_iam/
└── Action: REVIEW MODE - Running doc-spec-reviewer on SPEC-01
Input: CTR-05
├── Detected Type: CTR (alternative upstream)
├── Expected SPEC: SPEC-05
├── SPEC Exists: No
└── Action: GENERATE MODE - Creating SPEC-05 from CTR-05
Input: SPEC-03
├── Detected Type: SPEC (self)
└── Action: REVIEW MODE - Running doc-spec-reviewer on SPEC-03输入: REQ-01
├── 检测类型: REQ(主要上游来源)
├── 预期SPEC: SPEC-01
├── SPEC是否存在: 是 → docs/09_SPEC/SPEC-01_f1_iam/
└── 操作: 审查模式 - 对SPEC-01运行doc-spec-reviewer
输入: CTR-05
├── 检测类型: CTR(备选上游来源)
├── 预期SPEC: SPEC-05
├── SPEC是否存在: 否
└── 操作: 生成模式 - 从CTR-05创建SPEC-05
输入: SPEC-03
├── 检测类型: SPEC(自身)
└── 操作: 审查模式 - 对SPEC-03运行doc-spec-reviewerWorkflow Overview
工作流概述
mermaid
flowchart TD
subgraph Phase1["Phase 1: REQ/CTR Analysis"]
A[Start] --> B[Read REQ Documents]
B --> C[Read CTR Documents if exists]
C --> D[Extract Implementation Details]
D --> E[Map to SPEC Structure]
end
subgraph Phase2["Phase 2: SPEC Readiness Check"]
E --> F[Check REQ SPEC-Ready Score]
F --> G{Score >= 90%?}
G -->|No| H[Flag REQ Issues]
H --> I{Auto-Fixable?}
I -->|Yes| J[Fix REQ Issues]
J --> F
I -->|No| K[Abort - Manual Fix Required]
G -->|Yes| L[Mark REQ Ready]
end
subgraph Phase3["Phase 3: SPEC Generation"]
L --> M[Generate YAML Structure]
M --> N[Add Methods/Interfaces]
N --> O[Add Data Models]
O --> P[quality-advisor: Real-time Feedback]
P --> Q[Add Traceability]
Q --> R[Write SPEC File]
end
subgraph Phase4["Phase 4: SPEC Validation"]
R --> S[Run doc-spec-validator]
S --> T{TASKS-Ready >= 90%?}
T -->|No| U[Auto-Fix SPEC Issues]
U --> V[Re-validate SPEC]
V --> T
T -->|Yes| W[Mark SPEC Validated]
end
subgraph Phase5["Phase 5: Review & Fix Cycle"]
W --> X[Run doc-spec-reviewer]
X --> X2{Score >= 90?}
X2 -->|No| X3[Run doc-spec-fixer]
X3 --> X4{Iteration < Max?}
X4 -->|Yes| X
X4 -->|No| X5[Flag Manual Review]
X2 -->|Yes| Y[Verify Quality Checks]
X5 --> Y
Y --> Z[Update Traceability Matrix]
Z --> AA[Generate Summary Report]
end
AA --> AB[Complete]
K --> AC[Exit with Error]mermaid
flowchart TD
subgraph Phase1["Phase 1: REQ/CTR Analysis"]
A[Start] --> B[Read REQ Documents]
B --> C[Read CTR Documents if exists]
C --> D[Extract Implementation Details]
D --> E[Map to SPEC Structure]
end
subgraph Phase2["Phase 2: SPEC Readiness Check"]
E --> F[Check REQ SPEC-Ready Score]
F --> G{Score >= 90%?}
G -->|No| H[Flag REQ Issues]
H --> I{Auto-Fixable?}
I -->|Yes| J[Fix REQ Issues]
J --> F
I -->|No| K[Abort - Manual Fix Required]
G -->|Yes| L[Mark REQ Ready]
end
subgraph Phase3["Phase 3: SPEC Generation"]
L --> M[Generate YAML Structure]
M --> N[Add Methods/Interfaces]
N --> O[Add Data Models]
O --> P[quality-advisor: Real-time Feedback]
P --> Q[Add Traceability]
Q --> R[Write SPEC File]
end
subgraph Phase4["Phase 4: SPEC Validation"]
R --> S[Run doc-spec-validator]
S --> T{TASKS-Ready >= 90%?}
T -->|No| U[Auto-Fix SPEC Issues]
U --> V[Re-validate SPEC]
V --> T
T -->|Yes| W[Mark SPEC Validated]
end
subgraph Phase5["Phase 5: Review & Fix Cycle"]
W --> X[Run doc-spec-reviewer]
X --> X2{Score >= 90?}
X2 -->|No| X3[Run doc-spec-fixer]
X3 --> X4{Iteration < Max?}
X4 -->|Yes| X
X4 -->|No| X5[Flag Manual Review]
X2 -->|Yes| Y[Verify Quality Checks]
X5 --> Y
Y --> Z[Update Traceability Matrix]
Z --> AA[Generate Summary Report]
end
AA --> AB[Complete]
K --> AC[Exit with Error]SPEC YAML Format (13 Required Sections)
SPEC YAML格式(13个必填章节)
Trading Nexus patterns require comprehensive 13-section YAML structure:
yaml
undefinedTrading Nexus模式要求包含13个章节的完整YAML结构:
yaml
undefinedSPEC-NN: Specification Title
SPEC-NN: Specification Title
Required sections (all 13 mandatory)
Required sections (all 13 mandatory)
metadata:
spec_id: SPEC-01
title: "Component Specification"
version: "1.0.0"
status: "approved"
created_date: "2026-02-09T00:00:00"
last_updated: "2026-02-09T00:00:00"
task_ready_score: "✅ 95% (Target: ≥90%)"
authors: [{name: "...", email: "...", role: "..."}]
reviewers: [{name: "...", email: "...", role: "..."}]
traceability:
upstream_sources:
business_requirements:
- id: "BRD.01.01.03"
link: "../01_BRD/BRD-01.md#BRD.01.01.03"
relationship: "Business driver"
product_requirements:
- id: "PRD.01.07.02"
link: "../02_PRD/PRD-01.md#PRD.01.07.02"
atomic_requirements:
- id: "REQ-01.01.01"
# CRITICAL: Use nested REQ path format
link: "../07_REQ/SYS-01_iam/REQ-01.01_jwt_authentication.md"
cumulative_tags:
brd: ["BRD.01.01.03"]
prd: ["PRD.01.07.02"]
ears: ["EARS.01.25.01"]
bdd: ["BDD.01.14.01"]
adr: ["ADR-01"]
sys: ["SYS.01.26.01"]
req: ["REQ.01.27.01"]
ctr: ["CTR.01.16.01"]
threshold: ["perf.auth.p95_latency", "sla.uptime.target"] # 9th layer
interfaces:
Level 1: External APIs (REST)
external_apis:
- endpoint: "POST /api/v1/auth/login"
method: "POST"
auth: "None"
rate_limit: "5 req/5 min per IP"
request_schema:
type: "object"
required: ["email", "password"]
properties:
email: { type: "string", format: "email" }
password: { type: "string", minLength: 12 }
response_schema:
type: "object"
properties:
access_token: { type: "string" }
token_type: { type: "string", enum: ["Bearer"] }
latency_target_ms: "@threshold:perf.auth.p95_latency"
Level 2: Internal APIs (Service signatures)
internal_apis:
- interface: "AuthService.authenticate()"
signature: "async def authenticate(email: str, password: str) -> TokenPair"
purpose: |
1. Fetch user by email from Identity Platform.
2. Verify password via Argon2id.
3. Issue JWT token pair.
Level 3: Classes (OOP structure)
classes:
- name: "IAMService"
description: "Facade combining auth, token, and authz services"
constructor:
params:
config: { type: object, required: true }
methods:
- name: "initialize"
input: { }
output: { success: boolean }
data_models:
- id: SPEC.01.17.01 name: "RequestModel" json_schema: type: object properties: id: { type: string } pydantic_code: | from pydantic import BaseModel class RequestModel(BaseModel): id: str
validation_rules:
- id: SPEC.01.21.01 rule: "Email format validation" implementation: "Use EmailStr from pydantic"
error_handling:
catalog:
INVALID_CREDENTIALS:
http_status: 401
message: "Invalid email or password"
RATE_LIMIT_EXCEEDED:
http_status: 429
message: "Too many attempts"
configuration:
environment_variables:
- name: JWT_SECRET
required: true
description: "JWT signing secret"
feature_flags:
- name: MFA_REQUIRED
default: false
performance:
latency_targets:
login_p95_ms: "@threshold:perf.auth.p95_latency"
throughput_targets:
auth_rps: "@threshold:perf.auth.throughput"
behavior:
login_flow:
pseudocode: |
def login(email, password):
enforce_rate_limit(ip, "login")
user = idp.get_user(email)
if not user or not verify_password(password, user.hash):
raise AuthenticationError("INVALID_CREDENTIALS")
return token_service.issue_tokens(user)
behavioral_examples:
api_example_login:
request:
endpoint: "/api/v1/auth/login"
payload: { email: "user@example.com", password: "SecureP@ss!" }
response:
status: 200
body: { access_token: "<jwt>", token_type: "Bearer" }
architecture:
component_structure:
- name: "AuthService"
responsibility: "User authentication"
dependencies: ["GCP Identity Platform", "Redis"]
resilience:
circuit_breaker_enabled: true
retry_policy:
max_attempts: 3
backoff_strategy: "exponential"
operations:
slo:
uptime: "@threshold:sla.uptime.target"
error_rate: "<1%"
monitoring_metrics: ["auth_login_latency_p95_ms", "auth_errors_total"]
req_implementations:
- req_id: "REQ-01.01" req_link: "../07_REQ/SYS-01_iam/REQ-01.01.md" implementation: interfaces: - class: "AuthService" method: "login" signature: "async def login(...) -> LoginResult" data_models: - name: "LoginRequest" fields: ["email", "password"] validation_rules: - rule: "Rate limit login attempts" implementation: "5 attempts/5 minutes per IP" error_handling: - error_code: "INVALID_CREDENTIALS" http_status: 401 test_approach: unit_tests: ["hash verification rejects wrong password"] integration_tests: ["login flow returns token pair"]
threshold_references:
registry_document: "PRD-01_thresholds"
keys_used:
performance:
- key: "perf.auth.p95_latency"
usage: "performance.latency_targets.login"
sla:
- key: "sla.uptime.target"
usage: "operations.slo.uptime"
---metadata:
spec_id: SPEC-01
title: "Component Specification"
version: "1.0.0"
status: "approved"
created_date: "2026-02-09T00:00:00"
last_updated: "2026-02-09T00:00:00"
task_ready_score: "✅ 95% (Target: ≥90%)"
authors: [{name: "...", email: "...", role: "..."}]
reviewers: [{name: "...", email: "...", role: "..."}]
traceability:
upstream_sources:
business_requirements:
- id: "BRD.01.01.03"
link: "../01_BRD/BRD-01.md#BRD.01.01.03"
relationship: "Business driver"
product_requirements:
- id: "PRD.01.07.02"
link: "../02_PRD/PRD-01.md#PRD.01.07.02"
atomic_requirements:
- id: "REQ-01.01.01"
# CRITICAL: Use nested REQ path format
link: "../07_REQ/SYS-01_iam/REQ-01.01_jwt_authentication.md"
cumulative_tags:
brd: ["BRD.01.01.03"]
prd: ["PRD.01.07.02"]
ears: ["EARS.01.25.01"]
bdd: ["BDD.01.14.01"]
adr: ["ADR-01"]
sys: ["SYS.01.26.01"]
req: ["REQ.01.27.01"]
ctr: ["CTR.01.16.01"]
threshold: ["perf.auth.p95_latency", "sla.uptime.target"] # 9th layer
interfaces:
Level 1: External APIs (REST)
external_apis:
- endpoint: "POST /api/v1/auth/login"
method: "POST"
auth: "None"
rate_limit: "5 req/5 min per IP"
request_schema:
type: "object"
required: ["email", "password"]
properties:
email: { type: "string", format: "email" }
password: { type: "string", minLength: 12 }
response_schema:
type: "object"
properties:
access_token: { type: "string" }
token_type: { type: "string", enum: ["Bearer"] }
latency_target_ms: "@threshold:perf.auth.p95_latency"
Level 2: Internal APIs (Service signatures)
internal_apis:
- interface: "AuthService.authenticate()"
signature: "async def authenticate(email: str, password: str) -> TokenPair"
purpose: |
1. Fetch user by email from Identity Platform.
2. Verify password via Argon2id.
3. Issue JWT token pair.
Level 3: Classes (OOP structure)
classes:
- name: "IAMService"
description: "Facade combining auth, token, and authz services"
constructor:
params:
config: { type: object, required: true }
methods:
- name: "initialize"
input: { }
output: { success: boolean }
data_models:
- id: SPEC.01.17.01 name: "RequestModel" json_schema: type: object properties: id: { type: string } pydantic_code: | from pydantic import BaseModel class RequestModel(BaseModel): id: str
validation_rules:
- id: SPEC.01.21.01 rule: "Email format validation" implementation: "Use EmailStr from pydantic"
error_handling:
catalog:
INVALID_CREDENTIALS:
http_status: 401
message: "Invalid email or password"
RATE_LIMIT_EXCEEDED:
http_status: 429
message: "Too many attempts"
configuration:
environment_variables:
- name: JWT_SECRET
required: true
description: "JWT signing secret"
feature_flags:
- name: MFA_REQUIRED
default: false
performance:
latency_targets:
login_p95_ms: "@threshold:perf.auth.p95_latency"
throughput_targets:
auth_rps: "@threshold:perf.auth.throughput"
behavior:
login_flow:
pseudocode: |
def login(email, password):
enforce_rate_limit(ip, "login")
user = idp.get_user(email)
if not user or not verify_password(password, user.hash):
raise AuthenticationError("INVALID_CREDENTIALS")
return token_service.issue_tokens(user)
behavioral_examples:
api_example_login:
request:
endpoint: "/api/v1/auth/login"
payload: { email: "user@example.com", password: "SecureP@ss!" }
response:
status: 200
body: { access_token: "<jwt>", token_type: "Bearer" }
architecture:
component_structure:
- name: "AuthService"
responsibility: "User authentication"
dependencies: ["GCP Identity Platform", "Redis"]
resilience:
circuit_breaker_enabled: true
retry_policy:
max_attempts: 3
backoff_strategy: "exponential"
operations:
slo:
uptime: "@threshold:sla.uptime.target"
error_rate: "<1%"
monitoring_metrics: ["auth_login_latency_p95_ms", "auth_errors_total"]
req_implementations:
- req_id: "REQ-01.01" req_link: "../07_REQ/SYS-01_iam/REQ-01.01.md" implementation: interfaces: - class: "AuthService" method: "login" signature: "async def login(...) -> LoginResult" data_models: - name: "LoginRequest" fields: ["email", "password"] validation_rules: - rule: "Rate limit login attempts" implementation: "5 attempts/5 minutes per IP" error_handling: - error_code: "INVALID_CREDENTIALS" http_status: 401 test_approach: unit_tests: ["hash verification rejects wrong password"] integration_tests: ["login flow returns token pair"]
threshold_references:
registry_document: "PRD-01_thresholds"
keys_used:
performance:
- key: "perf.auth.p95_latency"
usage: "performance.latency_targets.login"
sla:
- key: "sla.uptime.target"
usage: "operations.slo.uptime"
---Phase 5: Review & Fix Cycle (v2.2)
阶段5:审查与修复周期(v2.2)
Iterative review and fix cycle to ensure SPEC quality before completion.
mermaid
flowchart TD
A[Phase 5 Start] --> B[Run doc-spec-reviewer]
B --> C[Generate Review Report]
C --> D{Review Score >= 90?}
D -->|Yes| E[PASS - Proceed to Phase 6]
D -->|No| F{Iteration < Max?}
F -->|Yes| G[Run doc-spec-fixer]
G --> H[Apply Fixes]
H --> I[Generate Fix Report]
I --> J[Increment Iteration]
J --> B
F -->|No| K[Flag for Manual Review]
K --> L[Generate Final Report with Remaining Issues]
L --> E迭代式审查与修复周期,确保完成前的SPEC质量。
mermaid
flowchart TD
A[Phase 5 Start] --> B[Run doc-spec-reviewer]
B --> C[Generate Review Report]
C --> D{Review Score >= 90?}
D -->|Yes| E[PASS - Proceed to Phase 6]
D -->|No| F{Iteration < Max?}
F -->|Yes| G[Run doc-spec-fixer]
G --> H[Apply Fixes]
H --> I[Generate Fix Report]
I --> J[Increment Iteration]
J --> B
F -->|No| K[Flag for Manual Review]
K --> L[Generate Final Report with Remaining Issues]
L --> E5.1 Initial Review
5.1 初始审查
Run to identify issues.
doc-spec-reviewerbash
/doc-spec-reviewer SPEC-NNOutput:
SPEC-NN.R_review_report_v001.md运行以识别问题。
doc-spec-reviewerbash
/doc-spec-reviewer SPEC-NN输出:
SPEC-NN.R_review_report_v001.md5.2 Fix Cycle
5.2 修复周期
If review score < 90%, invoke .
doc-spec-fixerbash
/doc-spec-fixer SPEC-NN --revalidateFix Categories:
| Category | Fixes Applied |
|---|---|
| Missing Sections | Add missing 13 required sections |
| Broken Links | Update paths, fix REQ references |
| Element IDs | Convert legacy patterns, fix invalid type codes |
| Threshold References | Replace hardcoded values with @threshold syntax |
| Interface Levels | Add missing external/internal/classes stubs |
| Traceability | Update cumulative tags (9 layers) |
Output:
SPEC-NN.F_fix_report_v001.md若审查评分<90%,调用。
doc-spec-fixerbash
/doc-spec-fixer SPEC-NN --revalidate修复类别:
| 类别 | 应用的修复 |
|---|---|
| 缺失章节 | 添加缺失的13个必填章节 |
| 失效链接 | 更新路径,修复REQ引用 |
| 元素ID | 转换旧有模式,修复无效类型编码 |
| 阈值引用 | 替换硬编码值为@threshold语法 |
| 接口层级 | 添加缺失的外部/内部/类存根 |
| 可追溯性 | 更新累积标签(9个层级) |
输出:
SPEC-NN.F_fix_report_v001.md5.3 Re-Review
5.3 重新审查
After fixes, automatically re-run reviewer.
bash
/doc-spec-reviewer SPEC-NNOutput:
SPEC-NN.R_review_report_v002.md修复后,自动重新运行审查工具。
bash
/doc-spec-reviewer SPEC-NN输出:
SPEC-NN.R_review_report_v002.md5.4 Iteration Control
5.4 迭代控制
| Parameter | Default | Description |
|---|---|---|
| 3 | Maximum fix-review cycles |
| 90 | Minimum passing score |
| false | Stop if only manual issues remain |
Iteration Example:
Iteration 1:
Review v001: Score 82 (3 errors, 5 warnings)
Fix v001: Fixed 6 issues, added 2 sections
Iteration 2:
Review v002: Score 93 (0 errors, 3 warnings)
Status: PASS (score >= 90)| 参数 | 默认值 | 描述 |
|---|---|---|
| 3 | 最大修复-审查周期数 |
| 90 | 最低合格分数 |
| false | 若仅剩余手动问题则停止 |
迭代示例:
迭代1:
审查v001: 分数82(3个错误,5个警告)
修复v001: 修复6个问题,添加2个章节
迭代2:
审查v002: 分数93(0个错误,3个警告)
状态: 通过(分数≥90)5.5 Quality Checks (Post-Fix)
5.5 质量检查(修复后)
After passing the fix cycle:
-
Section Completeness:
- All 13 required sections present
- No placeholder text remaining ([TBD], TODO, XXX)
- Minimum content length per section
-
Three-Level Interface Coverage:
- external_apis defined with OpenAPI format
- internal_apis defined with method signatures
- classes defined with constructors and methods
-
Element ID Compliance (perskill):
doc-naming- All IDs use SPEC.NN.TT.SS format
- Element type codes valid for SPEC (15, 16, 17, 21, 28)
- No legacy patterns
-
TASKS-Ready Report:
TASKS-Ready Score Breakdown =========================== Interface Completeness: 23/25 (3 levels defined) Data Models: 20/20 (Pydantic + JSON Schema) Validation Rules: 15/15 (input/output validated) Error Handling: 15/15 (catalog with HTTP status) Test Approach: 10/10 (unit + integration tests) Traceability: 10/10 (all 9 cumulative tags) Performance Specs: 5/5 (@threshold references) ---------------------------- Total TASKS-Ready Score: 98/100 (Target: >= 90) Status: READY FOR TASKS GENERATION -
Traceability Matrix Update:bash
# Update SPEC traceability python ai_dev_flow/scripts/update_traceability_matrix.py \ --spec docs/09_SPEC/SPEC-NN.yaml \ --matrix docs/09_SPEC/SPEC-00_TRACEABILITY_MATRIX.md
通过修复周期后:
-
章节完整性:
- 所有13个必填章节均存在
- 无占位文本残留([TBD]、TODO、XXX)
- 每个章节达到最小内容长度
-
三级接口覆盖:
- 按OpenAPI格式定义external_apis
- 按方法签名定义internal_apis
- 按构造函数和方法定义classes
-
元素ID合规性(遵循技能):
doc-naming- 所有ID使用SPEC.NN.TT.SS格式
- 元素类型编码对SPEC有效(15、16、17、21、28)
- 无旧有模式
-
TASKS就绪报告:
TASKS就绪评分明细 =========================== 接口完整性: 23/25(定义了3个层级) 数据模型: 20/20(Pydantic + JSON Schema) 验证规则: 15/15(输入/输出已验证) 错误处理: 15/15(含HTTP状态码的目录) 测试方法: 10/10(单元 + 集成测试) 可追溯性: 10/10(所有9个累积标签) 性能规格: 5/5(@threshold引用) ---------------------------- TAS就绪总评分: 98/100(目标: ≥90) 状态: 可用于生成TASKS -
可追溯性矩阵更新:bash
# 更新SPEC可追溯性 python ai_dev_flow/scripts/update_traceability_matrix.py \ --spec docs/09_SPEC/SPEC-NN.yaml \ --matrix docs/09_SPEC/SPEC-00_TRACEABILITY_MATRIX.md
Element Type Codes
元素类型编码
| Code | Element Type | Example |
|---|---|---|
| 15 | Step | SPEC.01.15.01 |
| 16 | Interface | SPEC.01.16.01 |
| 17 | Data Model | SPEC.01.17.01 |
| 21 | Validation Rule | SPEC.01.21.01 |
| 28 | Specification Element | SPEC.01.28.01 |
| 编码 | 元素类型 | 示例 |
|---|---|---|
| 15 | 步骤 | SPEC.01.15.01 |
| 16 | 接口 | SPEC.01.16.01 |
| 17 | 数据模型 | SPEC.01.17.01 |
| 21 | 验证规则 | SPEC.01.21.01 |
| 28 | 规格说明元素 | SPEC.01.28.01 |
Cumulative Tags (7-8 Required)
累积标签(7-8个必填)
markdown
@brd: BRD.NN.TT.SS
@prd: PRD.NN.TT.SS
@ears: EARS.NN.TT.SS
@bdd: BDD.NN.TT.SS
@adr: ADR-NN
@sys: SYS.NN.TT.SS
@req: REQ.NN.TT.SS
@ctr: CTR.NN.TT.SS # Optionalmarkdown
@brd: BRD.NN.TT.SS
@prd: PRD.NN.TT.SS
@ears: EARS.NN.TT.SS
@bdd: BDD.NN.TT.SS
@adr: ADR-NN
@sys: SYS.NN.TT.SS
@req: REQ.NN.TT.SS
@ctr: CTR.NN.TT.SS # 可选Configuration
配置
Default Configuration
默认配置
yaml
spec_autopilot:
version: "2.0"
scoring:
spec_ready_min: 90
tasks_ready_min: 90
strict_mode: false
# NEW: 7-component scoring weights
scoring_weights:
interface_completeness: 25 # All 3 levels defined
data_models: 20 # Pydantic + JSON Schema
validation_rules: 15 # Input/output validation
error_handling: 15 # Error catalog with HTTP status
test_approach: 10 # Unit + integration tests
traceability: 10 # All 9 cumulative tags
performance_specs: 5 # Latency targets with thresholds
execution:
max_parallel: 3 # HARD LIMIT - do not exceed
chunk_size: 3 # Documents per chunk
pause_between_chunks: true
auto_fix: true
continue_on_error: false
timeout_per_req: 180 # seconds
output:
format: yaml
report_format: markdown
# NEW: File splitting strategy
max_file_size_kb: 66
split_strategy: auto # auto, single, nested
validation:
skip_validation: false
fix_iterations_max: 3
# NEW: Enhanced validation
require_all_13_sections: true
require_three_interface_levels: true
require_threshold_registry: true
require_req_implementations: true
require_nested_req_paths: true
traceability:
# NEW: 9-layer cumulative tags
required_layers: 9
include_threshold_references: trueyaml
spec_autopilot:
version: "2.0"
scoring:
spec_ready_min: 90
tasks_ready_min: 90
strict_mode: false
# 新增:7个组件的评分权重
scoring_weights:
interface_completeness: 25 # 定义了所有3个层级
data_models: 20 # Pydantic + JSON Schema
validation_rules: 15 # 输入/输出验证
error_handling: 15 # 含HTTP状态码的错误目录
test_approach: 10 # 单元 + 集成测试
traceability: 10 # 所有9个累积标签
performance_specs: 5 # 带阈值的延迟目标
execution:
max_parallel: 3 # 硬限制 - 请勿超出
chunk_size: 3 # 每个批次的文档数
pause_between_chunks: true
auto_fix: true
continue_on_error: false
timeout_per_req: 180 # 秒
output:
format: yaml
report_format: markdown
# 新增:文件拆分策略
max_file_size_kb: 66
split_strategy: auto # auto, single, nested
validation:
skip_validation: false
fix_iterations_max: 3
# 新增:增强验证
require_all_13_sections: true
require_three_interface_levels: true
require_threshold_registry: true
require_req_implementations: true
require_nested_req_paths: true
traceability:
# 新增:9个层级的累积标签
required_layers: 9
include_threshold_references: true7-Component TASKS-Ready Scoring
7组件TASKS就绪评分
| Component | Weight | Criteria |
|---|---|---|
| Interface Completeness | 25% | external_apis, internal_apis, classes defined |
| Data Models | 20% | Pydantic code + JSON Schema present |
| Validation Rules | 15% | Input/output validation specified |
| Error Handling | 15% | Error catalog with HTTP status codes |
| Test Approach | 10% | Unit + integration tests in req_implementations |
| Traceability | 10% | All 9 cumulative tags populated |
| Performance Specs | 5% | Latency targets with @threshold references |
Score Display Format:
✅ 95% (Target: ≥90%) # Passing
🟡 87% (Target: ≥90%) # Near threshold
❌ 75% (Target: ≥90%) # Failing| 组件 | 权重 | 标准 |
|---|---|---|
| 接口完整性 | 25% | 定义了external_apis、internal_apis、classes |
| 数据模型 | 20% | 存在Pydantic代码 + JSON Schema |
| 验证规则 | 15% | 指定了输入/输出验证 |
| 错误处理 | 15% | 含HTTP状态码的错误目录 |
| 测试方法 | 10% | req_implementations中有单元 + 集成测试 |
| 可追溯性 | 10% | 所有9个累积标签已填充 |
| 性能规格 | 5% | 带@threshold引用的延迟目标 |
分数显示格式:
✅ 95% (目标: ≥90%) # 通过
🟡 87% (目标: ≥90%) # 接近阈值
❌ 75% (目标: ≥90%) # 未通过Context Management
上下文管理
Chunked Parallel Execution (MANDATORY)
分块并行执行(必填)
CRITICAL: To prevent conversation context overflow errors ("Prompt is too long", "Conversation too long"), all autopilot operations MUST follow chunked execution rules:
Chunk Size Limit: Maximum 3 documents per chunk
Chunking Rules:
- Chunk Formation: Group REQ-derived SPEC documents into chunks of maximum 3 at a time
- Sequential Chunk Processing: Process one chunk at a time, completing all documents in a chunk before starting the next
- Context Pause: After completing each chunk, provide a summary and pause for user acknowledgment
- Progress Tracking: Display chunk progress (e.g., "Chunk 2/4: Processing SPEC-04, SPEC-05, SPEC-06...")
Why Chunking is Required:
- Prevents "Conversation too long" errors during batch processing
- Allows context compaction between chunks
- Enables recovery from failures without losing all progress
- Provides natural checkpoints for user review
Chunk Completion Template:
markdown
undefined关键: 为防止对话上下文溢出错误("提示过长"、"对话过长"),所有自动化工具操作必须遵循分块执行规则:
分块大小限制: 每个批次最多3个文档
分块规则:
- 批次形成: 将REQ派生的SPEC文档分组为最多3个文档的批次
- 批次顺序处理: 一次处理一个批次,完成一个批次的所有文档后再开始下一个
- 上下文暂停: 完成每个批次后,提供摘要并暂停以等待用户确认
- 进度跟踪: 显示批次进度(例如:"批次2/4:正在处理SPEC-04、SPEC-05、SPEC-06...")
分块的必要性:
- 批量处理时防止"对话过长"错误
- 允许批次间的上下文压缩
- 故障恢复时不会丢失所有进度
- 为用户提供自然的检查点
批次完成模板:
markdown
undefinedChunk N/M Complete
批次N/M完成
Generated:
- SPEC-XX: TASKS-Ready Score 94%
- SPEC-YY: TASKS-Ready Score 92%
- SPEC-ZZ: TASKS-Ready Score 95%
Proceeding to next chunk...
---已生成:
- SPEC-XX: TASKS就绪评分94%
- SPEC-YY: TASKS就绪评分92%
- SPEC-ZZ: TASKS就绪评分95%
正在进入下一批次...
---Execution Modes
执行模式
Single SPEC Mode
单SPEC模式
Generate SPEC from one REQ document.
bash
python ai_dev_flow/scripts/spec_autopilot.py \
--req docs/REQ/REQ-01_authentication.md \
--output docs/SPEC/ \
--id 01从一个REQ文档生成SPEC。
bash
python ai_dev_flow/scripts/spec_autopilot.py \
--req docs/REQ/REQ-01_authentication.md \
--output docs/SPEC/ \
--id 01Batch Mode
批量模式
Generate SPEC from multiple REQ documents.
bash
python ai_dev_flow/scripts/spec_autopilot.py \
--batch config/spec_batch.yaml \
--output docs/SPEC/从多个REQ文档生成SPEC。
bash
python ai_dev_flow/scripts/spec_autopilot.py \
--batch config/spec_batch.yaml \
--output docs/SPEC/Dry Run Mode
试运行模式
Preview execution plan without generating files.
bash
python ai_dev_flow/scripts/spec_autopilot.py \
--req docs/REQ/ \
--dry-run预览执行计划但不生成文件。
bash
python ai_dev_flow/scripts/spec_autopilot.py \
--req docs/REQ/ \
--dry-runReview Mode (v2.1)
审查模式(v2.1)
Validate existing SPEC documents and generate a quality report without modification.
Purpose: Audit existing SPEC documents for compliance, quality scores, and identify issues.
Command:
bash
undefined验证现有SPEC文档并生成质量报告,不修改文档。
用途: 审计现有SPEC文档的合规性、质量评分并识别问题。
命令:
bash
undefinedReview single SPEC
审查单个SPEC
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode review
--spec docs/SPEC/SPEC-01.yaml
--mode review
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode review
--spec docs/SPEC/SPEC-01.yaml
--mode review
Review all SPECs
审查所有SPEC
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/
--mode review
--output-report tmp/spec_review_report.md
--spec docs/SPEC/
--mode review
--output-report tmp/spec_review_report.md
**Review Process**:
```mermaid
flowchart TD
A[Input: Existing SPEC] --> B[Load YAML Files]
B --> C[Validate YAML Syntax]
C --> D[Check 13 Required Sections]
D --> E[Validate 3-Level Interfaces]
E --> F[Check Threshold References]
F --> G[Calculate TASKS-Ready Score]
G --> H{Generate Report}
H --> I[Fixable Issues List]
H --> J[Manual Review Items]
H --> K[7-Component Breakdown]
I --> L[Output: Review Report]
J --> L
K --> LReview Report Structure:
markdown
undefinedpython ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/
--mode review
--output-report tmp/spec_review_report.md
--spec docs/SPEC/
--mode review
--output-report tmp/spec_review_report.md
**审查流程**:
```mermaid
flowchart TD
A[Input: Existing SPEC] --> B[Load YAML Files]
B --> C[Validate YAML Syntax]
C --> D[Check 13 Required Sections]
D --> E[Validate 3-Level Interfaces]
E --> F[Check Threshold References]
F --> G[Calculate TASKS-Ready Score]
G --> H{Generate Report}
H --> I[Fixable Issues List]
H --> J[Manual Review Items]
H --> K[7-Component Breakdown]
I --> L[Output: Review Report]
J --> L
K --> L审查报告结构:
markdown
undefinedSPEC Review Report: SPEC-01.yaml
SPEC审查报告: SPEC-01.yaml
Summary
摘要
- TASKS-Ready Score: 87% 🟡
- Total Issues: 9
- Auto-Fixable: 6
- Manual Review: 3
- TAS就绪评分: 87% 🟡
- 总问题数: 9
- 可自动修复: 6
- 需手动审查: 3
7-Component Score Breakdown
7组件评分明细
| Component | Score | Status |
|---|---|---|
| Interface Completeness | 23/25 | 🟡 |
| Data Models | 18/20 | 🟡 |
| Validation Rules | 14/15 | ✅ |
| Error Handling | 13/15 | 🟡 |
| Test Approach | 9/10 | ✅ |
| Traceability | 8/10 | 🟡 |
| Performance Specs | 4/5 | 🟡 |
| 组件 | 分数 | 状态 |
|---|---|---|
| 接口完整性 | 23/25 | 🟡 |
| 数据模型 | 18/20 | 🟡 |
| 验证规则 | 14/15 | ✅ |
| 错误处理 | 13/15 | 🟡 |
| 测试方法 | 9/10 | ✅ |
| 可追溯性 | 8/10 | 🟡 |
| 性能规格 | 4/5 | 🟡 |
Section Completeness
章节完整性
| Section | Present | Status |
|---|---|---|
| metadata | ✅ | Complete |
| traceability | ✅ | Missing @ctr tag |
| interfaces | 🟡 | Missing internal_apis |
| data_models | ✅ | Complete |
| validation_rules | ✅ | Complete |
| error_handling | ✅ | Complete |
| configuration | ✅ | Complete |
| performance | 🟡 | Hardcoded values |
| behavior | ✅ | Complete |
| behavioral_examples | ✅ | Complete |
| architecture | ✅ | Complete |
| operations | ✅ | Complete |
| req_implementations | ❌ | Missing |
| 章节 | 是否存在 | 状态 |
|---|---|---|
| metadata | ✅ | 完整 |
| traceability | ✅ | 缺失@ctr标签 |
| interfaces | 🟡 | 缺失internal_apis |
| data_models | ✅ | 完整 |
| validation_rules | ✅ | 完整 |
| error_handling | ✅ | 完整 |
| configuration | ✅ | 完整 |
| performance | 🟡 | 硬编码值 |
| behavior | ✅ | 完整 |
| behavioral_examples | ✅ | 完整 |
| architecture | ✅ | 完整 |
| operations | ✅ | 完整 |
| req_implementations | ❌ | 缺失 |
v2.0 Compliance
v2.0合规性
| Check | Status | Details |
|---|---|---|
| 13 Sections Present | ❌ | Missing req_implementations |
| Three Interface Levels | 🟡 | Missing internal_apis |
| Threshold Registry | ✅ | Present |
| Nested REQ Paths | ✅ | Correct format |
| 9-Layer Traceability | 🟡 | Missing @ctr |
| @threshold Format | ❌ | 2 hardcoded values |
| 检查项 | 状态 | 详情 |
|---|---|---|
| 13个章节均存在 | ❌ | 缺失req_implementations |
| 三级接口 | 🟡 | 缺失internal_apis |
| 阈值注册表 | ✅ | 存在 |
| 嵌套REQ路径 | ✅ | 格式正确 |
| 9层级可追溯性 | 🟡 | 缺失@ctr |
| @threshold格式 | ❌ | 2个硬编码值 |
Auto-Fixable Issues
可自动修复的问题
| # | Issue | Location | Fix Action |
|---|---|---|---|
| 1 | Missing @ctr tag | traceability | Add placeholder @ctr reference |
| 2 | Hardcoded latency | performance.latency_targets | Replace with @threshold:perf.api.p95 |
| 3 | Missing req_implementations | root | Add template section |
| ... | ... | ... | ... |
| # | 问题 | 位置 | 修复操作 |
|---|---|---|---|
| 1 | 缺失@ctr标签 | traceability | 添加占位符@ctr引用 |
| 2 | 硬编码延迟值 | performance.latency_targets | 替换为@threshold:perf.api.p95 |
| 3 | 缺失req_implementations | 根节点 | 添加模板章节 |
| ... | ... | ... | ... |
Manual Review Required
需手动审查
| # | Issue | Location | Reason |
|---|---|---|---|
| 1 | Missing internal_apis | interfaces | Architecture decision needed |
| 2 | Incomplete behavior | behavior.login_flow | Domain knowledge required |
| ... | ... | ... | ... |
**Review Configuration**:
```yaml
review_mode:
enabled: true
checks:
- yaml_syntax # Valid YAML structure
- section_completeness # All 13 sections present
- interface_levels # 3-level interface hierarchy
- threshold_references # @threshold format
- cumulative_tags # 9-layer traceability
- score_calculation # TASKS-Ready score
- file_size # <66KB check
output:
format: markdown
include_fix_suggestions: true
thresholds:
pass: 90
warning: 85
fail: 0| # | 问题 | 位置 | 原因 |
|---|---|---|---|
| 1 | 缺失internal_apis | interfaces | 需架构决策 |
| 2 | 行为不完整 | behavior.login_flow | 需领域知识 |
| ... | ... | ... | ... |
**审查配置**:
```yaml
review_mode:
enabled: true
checks:
- yaml_syntax # 有效的YAML结构
- section_completeness # 所有13个章节均存在
- interface_levels # 三级接口层级
- threshold_references # @threshold格式
- cumulative_tags # 9层级可追溯性
- score_calculation # TASKS就绪评分
- file_size # <66KB检查
output:
format: markdown
include_fix_suggestions: true
thresholds:
pass: 90
warning: 85
fail: 0Fix Mode (v2.1)
修复模式(v2.1)
Auto-repair existing SPEC documents while preserving manual content.
Purpose: Apply automated fixes to SPEC documents to improve quality scores and compliance.
Command:
bash
undefined自动修复现有SPEC文档,同时保留手动内容。
用途: 对SPEC文档应用自动修复以提高质量评分和合规性。
命令:
bash
undefinedFix single SPEC
修复单个SPEC
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--spec docs/SPEC/SPEC-01.yaml
--mode fix
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--spec docs/SPEC/SPEC-01.yaml
--mode fix
Fix with backup
修复并备份
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--backup
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--backup
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--backup
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--backup
Fix specific issue types only
仅修复特定类型的问题
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--fix-types "sections,thresholds,traceability"
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--fix-types "sections,thresholds,traceability"
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--fix-types "sections,thresholds,traceability"
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--fix-types "sections,thresholds,traceability"
Dry-run fix (preview changes)
试运行修复(预览更改)
python ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--dry-run
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--dry-run
**Fix Categories and Actions**:
| Category | Issue | Auto-Fix Action | Preserves Content |
|----------|-------|-----------------|-------------------|
| **Sections** | Missing req_implementations | Add template section | ✅ |
| **Sections** | Missing threshold_references | Add template section | ✅ |
| **Sections** | Missing metadata fields | Add required fields | ✅ |
| **Thresholds** | Hardcoded numeric values | Replace with @threshold:xxx | ✅ |
| **Thresholds** | Invalid @threshold format | Convert to category.field format | ✅ |
| **Traceability** | Missing cumulative tags | Add with placeholder references | ✅ |
| **Traceability** | Wrong REQ path format | Convert to nested format | ✅ |
| **Interfaces** | Missing level placeholder | Add template structure | ✅ |
| **Interfaces** | Missing method signatures | Flag for manual (content needed) | N/A |
| **YAML** | Formatting issues | Auto-format with ruamel.yaml | ✅ |
| **Score** | Missing TASKS-Ready score | Calculate and insert | ✅ |
**Content Preservation Rules**:
1. **Never delete** existing interface definitions
2. **Never modify** method signatures or logic
3. **Never change** data model schemas
4. **Only add** missing sections and metadata
5. **Only replace** hardcoded values with threshold references
6. **Backup first** if `--backup` flag is set
**Fix Report Structure**:
```markdownpython ai_dev_flow/scripts/spec_autopilot.py
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--dry-run
--spec docs/SPEC/SPEC-01.yaml
--mode fix
--dry-run
**修复类别与操作**:
| 类别 | 问题 | 自动修复操作 | 保留内容 |
|----------|-------|-----------------|-------------------|
| **章节** | 缺失req_implementations | 添加模板章节 | ✅ |
| **章节** | 缺失threshold_references | 添加模板章节 | ✅ |
| **章节** | 缺失metadata字段 | 添加必填字段 | ✅ |
| **阈值** | 硬编码数值 | 替换为@threshold:xxx | ✅ |
| **阈值** | 无效@threshold格式 | 转换为category.field格式 | ✅ |
| **可追溯性** | 缺失累积标签 | 添加占位符引用 | ✅ |
| **可追溯性** | 错误的REQ路径格式 | 转换为嵌套格式 | ✅ |
| **接口** | 缺失层级占位符 | 添加模板结构 | ✅ |
| **接口** | 缺失方法签名 | 标记为需手动处理(需内容) | N/A |
| **YAML** | 格式问题 | 用ruamel.yaml自动格式化 | ✅ |
| **评分** | 缺失TASKS就绪评分 | 计算并插入 | ✅ |
**内容保留规则**:
1. **绝不删除**现有接口定义
2. **绝不修改**方法签名或逻辑
3. **绝不更改**数据模型 schema
4. **仅添加**缺失的章节和元数据
5. **仅替换**硬编码值为阈值引用
6. 若设置`--backup`标志则**先备份**
**修复报告结构**:
```markdownSPEC Fix Report: SPEC-01.yaml
SPEC修复报告: SPEC-01.yaml
Summary
摘要
- Before TASKS-Ready Score: 87% 🟡
- After TASKS-Ready Score: 94% ✅
- Issues Fixed: 6
- Issues Remaining: 3 (manual review required)
- 修复前TAS就绪评分: 87% 🟡
- 修复后TAS就绪评分: 94% ✅
- 已修复问题数: 6
- 剩余问题数: 3(需手动审查)
Fixes Applied
已应用的修复
| # | Issue | Location | Fix Applied |
|---|---|---|---|
| 1 | Missing req_implementations | root | Added template section |
| 2 | Hardcoded latency | performance.latency_targets | Replaced with @threshold:perf.api.p95 |
| 3 | Missing @ctr tag | traceability | Added @ctr: CTR.01.16.01 |
| ... | ... | ... | ... |
| # | 问题 | 位置 | 应用的修复 |
|---|---|---|---|
| 1 | 缺失req_implementations | 根节点 | 添加模板章节 |
| 2 | 硬编码延迟值 | performance.latency_targets | 替换为@threshold:perf.api.p95 |
| 3 | 缺失@ctr标签 | traceability | 添加@ctr: CTR.01.16.01 |
| ... | ... | ... | ... |
Files Modified
修改的文件
- docs/SPEC/SPEC-01.yaml
- docs/SPEC/SPEC-01.yaml
Backup Location
备份位置
- tmp/backup/SPEC-01_20260209_143022.yaml
- tmp/backup/SPEC-01_20260209_143022.yaml
7-Component Score Impact
7组件评分影响
| Component | Before | After | Delta |
|---|---|---|---|
| Interface Completeness | 23/25 | 24/25 | +1 |
| Data Models | 18/20 | 18/20 | 0 |
| Validation Rules | 14/15 | 14/15 | 0 |
| Error Handling | 13/15 | 13/15 | 0 |
| Test Approach | 9/10 | 10/10 | +1 |
| Traceability | 8/10 | 10/10 | +2 |
| Performance Specs | 4/5 | 5/5 | +1 |
| 组件 | 修复前 | 修复后 | 变化值 |
|---|---|---|---|
| 接口完整性 | 23/25 | 24/25 | +1 |
| 数据模型 | 18/20 | 18/20 | 0 |
| 验证规则 | 14/15 | 14/15 | 0 |
| 错误处理 | 13/15 | 13/15 | 0 |
| 测试方法 | 9/10 | 10/10 | +1 |
| 可追溯性 | 8/10 | 10/10 | +2 |
| 性能规格 | 4/5 | 5/5 | +1 |
Next Steps
下一步
- Add internal_apis level to interfaces section
- Complete behavior.login_flow pseudocode
- Re-run validation to confirm score
**Fix Configuration**:
```yaml
fix_mode:
enabled: true
backup:
enabled: true
location: "tmp/backup/"
retention_days: 7
fix_categories:
sections: true # Missing required sections
thresholds: true # @threshold references
traceability: true # Cumulative tags
interfaces: false # Interface placeholders (risky)
yaml: true # YAML formatting
preservation:
interfaces: true # Never modify existing interfaces
data_models: true # Never modify schemas
behavior: true # Never modify logic
comments: true # Preserve YAML comments
validation:
re_validate_after_fix: true
require_score_improvement: false
max_fix_iterations: 3Command Line Options (Review/Fix):
| Option | Mode | Default | Description |
|---|---|---|---|
| Review | - | Run review mode only |
| Fix | - | Run fix mode |
| Both | auto | Report output path |
| Fix | true | Create backup before fixing |
| Fix | all | Comma-separated fix categories |
| Fix | false | Preview fixes without applying |
| Fix | false | Extra cautious preservation |
- 为interfaces章节添加internal_apis层级
- 完善behavior.login_flow伪代码
- 重新运行验证以确认评分
**修复配置**:
```yaml
fix_mode:
enabled: true
backup:
enabled: true
location: "tmp/backup/"
retention_days: 7
fix_categories:
sections: true # 缺失的必填章节
thresholds: true # @threshold引用
traceability: true # 累积标签
interfaces: false # 接口占位符(有风险)
yaml: true # YAML格式化
preservation:
interfaces: true # 绝不修改现有接口
data_models: true # 绝不修改schema
behavior: true # 绝不修改逻辑
comments: true # 保留YAML注释
validation:
re_validate_after_fix: true
require_score_improvement: false
max_fix_iterations: 3命令行选项(审查/修复):
| 选项 | 模式 | 默认值 | 描述 |
|---|---|---|---|
| 审查 | - | 仅运行审查模式 |
| 修复 | - | 运行修复模式 |
| 两者 | auto | 报告输出路径 |
| 修复 | true | 修复前创建备份 |
| 修复 | all | 逗号分隔的修复类别 |
| 修复 | false | 预览修复但不应用 |
| 修复 | false | 额外谨慎的内容保留 |
Related Resources
相关资源
- SPEC Skill:
.claude/skills/doc-spec/SKILL.md - SPEC Validator:
.claude/skills/doc-spec-validator/SKILL.md - Naming Standards:
.claude/skills/doc-naming/SKILL.md - Quality Advisor:
.claude/skills/quality-advisor/SKILL.md - SPEC Template:
ai_dev_flow/09_SPEC/SPEC-TEMPLATE.yaml
- SPEC技能:
.claude/skills/doc-spec/SKILL.md - SPEC验证器:
.claude/skills/doc-spec-validator/SKILL.md - 命名标准:
.claude/skills/doc-naming/SKILL.md - 质量顾问:
.claude/skills/quality-advisor/SKILL.md - SPEC模板:
ai_dev_flow/09_SPEC/SPEC-TEMPLATE.yaml
Validation Rules (v2.0)
验证规则(v2.0)
| Check | Requirement | Error Code |
|---|---|---|
| 13 Sections | All required sections present | SPEC-E030 |
| Three Interface Levels | external_apis, internal_apis, classes | SPEC-E031 |
| Threshold Registry | threshold_references section present | SPEC-E032 |
| REQ Implementation | req_implementations section present | SPEC-E033 |
| Nested REQ Paths | | SPEC-E034 |
| 7-Component Score | All components calculated | SPEC-E035 |
| File Size | <66KB or split into micro-SPECs | SPEC-E036 |
| 9-Layer Traceability | All 9 cumulative_tags populated | SPEC-E037 |
| Threshold Format | | SPEC-E038 |
| 检查项 | 要求 | 错误编码 |
|---|---|---|
| 13个章节 | 所有必填章节均存在 | SPEC-E030 |
| 三级接口 | external_apis、internal_apis、classes | SPEC-E031 |
| 阈值注册表 | 存在threshold_references章节 | SPEC-E032 |
| REQ实现 | 存在req_implementations章节 | SPEC-E033 |
| 嵌套REQ路径 | | SPEC-E034 |
| 7组件评分 | 所有组件均已计算 | SPEC-E035 |
| 文件大小 | <66KB或拆分为微SPEC | SPEC-E036 |
| 9层级可追溯性 | 所有9个累积标签均已填充 | SPEC-E037 |
| 阈值格式 | | SPEC-E038 |
File Splitting Strategy
文件拆分策略
| Condition | Strategy | Result |
|---|---|---|
| <66KB | Single file | |
| >66KB | Split | |
| >3 splits | Nested folder | |
| 条件 | 策略 | 结果 |
|---|---|---|
| <66KB | 单个文件 | |
| >66KB | 拆分 | |
| >3个拆分文件 | 嵌套文件夹 | |
Review Document Standards (v2.2)
审查文档标准(v2.2)
Review reports generated by this skill are formal project documents and MUST comply with shared standards.
Reference: See in the skills directory for complete requirements.
REVIEW_DOCUMENT_STANDARDS.mdKey Requirements:
- Storage Location: Same folder as the reviewed SPEC document
- File Naming:
SPEC-NN.R_review_report.md - YAML Frontmatter: Required with ,
artifact_type: SPEC-REVIEWlayer: 9 - Score Field: /
tasks_ready_score_claimedtasks_ready_score_validated - Parent Reference: Must link to parent SPEC document
Example Location (ALWAYS use nested folders):
undefined该技能生成的审查报告属于正式项目文档,必须符合共享标准。
参考: 技能目录中的包含完整要求。
REVIEW_DOCUMENT_STANDARDS.md关键要求:
- 存储位置: 与被审查的SPEC文档同一文件夹
- 文件命名:
SPEC-NN.R_review_report.md - YAML前置元数据: 必填,包含,
artifact_type: SPEC-REVIEWlayer: 9 - 分数字段: /
tasks_ready_score_claimedtasks_ready_score_validated - 父引用: 必须链接到父SPEC文档
示例位置(始终使用嵌套文件夹):
undefinedMonolithic SPEC (<20k tokens):
单体SPEC(<20k tokens):
docs/09_SPEC/SPEC-03_f3_observability/
├── SPEC-03_f3_observability.yaml # ← Single YAML file
├── SPEC-03.R_review_report_v001.md # ← Review report
├── SPEC-03.F_fix_report_v001.md # ← Fix report
└── .drift_cache.json # ← Drift cache
docs/09_SPEC/SPEC-03_f3_observability/
├── SPEC-03_f3_observability.yaml # ← 单个YAML文件
├── SPEC-03.R_review_report_v001.md # ← 审查报告
├── SPEC-03.F_fix_report_v001.md # ← 修复报告
└── .drift_cache.json # ← 漂移缓存
Split SPEC (≥20k tokens or multiple components):
拆分后的SPEC(≥20k tokens或多组件):
docs/09_SPEC/SPEC-01_f1_iam/
├── SPEC-01.01_authentication.yaml # ← Component 1
├── SPEC-01.02_authorization.yaml # ← Component 2
├── SPEC-01.03_user_profile.yaml # ← Component 3
├── SPEC-01.R_review_report_v001.md # ← Review report
├── SPEC-01.F_fix_report_v001.md # ← Fix report
└── .drift_cache.json # ← Drift cache
**Nested Folder Rule**: ALL SPECs use nested folders (`SPEC-NN_{slug}/`) regardless of size. This keeps YAML files and companion files (review reports, fix reports, drift cache) organized together.
---docs/09_SPEC/SPEC-01_f1_iam/
├── SPEC-01.01_authentication.yaml # ← 组件1
├── SPEC-01.02_authorization.yaml # ← 组件2
├── SPEC-01.03_user_profile.yaml # ← 组件3
├── SPEC-01.R_review_report_v001.md # ← 审查报告
├── SPEC-01.F_fix_report_v001.md # ← 修复报告
└── .drift_cache.json # ← 漂移缓存
**嵌套文件夹规则**: 所有SPEC无论大小均使用嵌套文件夹(`SPEC-NN_{slug}/`)。这可将YAML文件和配套文件(审查报告、修复报告、漂移缓存)组织在一起。
---Version History
版本历史
| Version | Date | Changes |
|---|---|---|
| 2.3 | 2026-02-11 | Smart Document Detection: Added automatic document type recognition; Self-type input (SPEC-NN) triggers review mode; Multiple upstream-type inputs (REQ/CTR-NN) trigger generate-if-missing or find-and-review; Updated input patterns table with type-based actions |
| 2.2 | 2026-02-10 | Review & Fix Cycle: Replaced Phase 5 with iterative Review -> Fix cycle using |
| 2.1 | 2026-02-10 | Added Review Document Standards section; Review reports now stored alongside reviewed documents with proper YAML frontmatter and parent references |
| 2.0 | 2026-02-09 | Added Review Mode for validating existing SPEC documents without modification; Added Fix Mode for auto-repairing SPEC documents while preserving manual content; Added fix categories (sections, thresholds, traceability, interfaces, yaml); Added content preservation rules; Added backup functionality for fix operations; Added review/fix report generation with 7-component score impact; Added execution modes section (single, batch, dry-run, review, fix) |
| 1.1 | 2026-02-09 | Added 13-section YAML structure; Added 9-layer cumulative traceability; Added three-level interface specification (external, internal, classes); Added threshold registry pattern; Added req_implementations section for REQ-to-implementation bridges; Added 7-component TASKS-Ready scoring; Added file splitting strategy (<66KB); Added validation rules SPEC-E030 to SPEC-E038 |
| 1.0 | 2026-02-08 | Initial skill creation with 5-phase workflow; Integrated doc-naming, doc-spec, quality-advisor, doc-spec-validator |
| 版本 | 日期 | 变更 |
|---|---|---|
| 2.3 | 2026-02-11 | 智能文档检测: 添加自动文档类型识别;自身类型输入(SPEC-NN)触发审查模式;多上游类型输入(REQ/CTR-NN)触发缺失则生成或查找并审查;更新输入模式表格以包含基于类型的操作 |
| 2.2 | 2026-02-10 | 审查与修复周期: 用 |
| 2.1 | 2026-02-10 | 添加审查文档标准章节;审查报告现在与被审查文档存储在一起,包含正确的YAML前置元数据和父引用 |
| 2.0 | 2026-02-09 | 添加用于验证现有SPEC文档且不修改的审查模式;添加用于自动修复SPEC文档同时保留手动内容的修复模式;添加修复类别(章节、阈值、可追溯性、接口、yaml);添加内容保留规则;添加修复操作的备份功能;添加包含7组件评分影响的审查/修复报告生成;添加执行模式章节(单文件、批量、试运行、审查、修复) |
| 1.1 | 2026-02-09 | 添加13章节YAML结构;添加9层级累积可追溯性;添加三级接口规格(外部、内部、类);添加阈值注册表模式;添加用于REQ到实现桥梁的req_implementations章节;添加7组件TASKS就绪评分;添加文件拆分策略(<66KB);添加验证规则SPEC-E030至SPEC-E038 |
| 1.0 | 2026-02-08 | 初始技能创建,包含5阶段工作流;集成doc-naming、doc-spec、quality-advisor、doc-spec-validator |