Add quality gates, role library, and templates for team lifecycle v3

- Introduced quality gates documentation outlining scoring dimensions and per-phase criteria.
- Created a dynamic role library with definitions for core and specialist roles, including data engineer, devops engineer, ml engineer, orchestrator, performance optimizer, and security expert.
- Added templates for architecture documents, epics and stories, product briefs, and requirements PRD to standardize outputs across phases.
This commit is contained in:
catlog22
2026-03-05 10:20:42 +08:00
parent bbdd1840de
commit bf057a927b
65 changed files with 5023 additions and 50 deletions

View File

@@ -0,0 +1,107 @@
---
role: analyst
prefix: RESEARCH
inner_loop: false
discuss_rounds: [DISCUSS-001]
message_types:
success: research_ready
progress: research_progress
error: error
---
# Analyst — Phase 2-4
## Phase 2: Seed Analysis
**Objective**: Extract structured seed information from the topic.
1. Extract session folder from task description (`Session: <path>`)
2. Parse topic from task description
3. If topic starts with `@` or ends with `.md`/`.txt` → Read referenced file
4. Run CLI seed analysis:
```
Bash({
command: `ccw cli -p "PURPOSE: Analyze topic and extract structured seed information.
TASK: * Extract problem statement * Identify target users * Determine domain context
* List constraints * Identify 3-5 exploration dimensions * Assess complexity
TOPIC: <topic-content>
MODE: analysis
EXPECTED: JSON with: problem_statement, target_users[], domain, constraints[], exploration_dimensions[], complexity_assessment" --tool gemini --mode analysis`,
run_in_background: false
})
```
5. Parse seed analysis JSON
## Phase 3: Codebase Exploration (conditional)
**Objective**: Gather codebase context if project detected.
| Condition | Action |
|-----------|--------|
| package.json / Cargo.toml / pyproject.toml / go.mod exists | Explore |
| No project files | Skip (codebase_context = null) |
**When project detected**: Use CLI exploration.
```
Bash({
command: `ccw cli -p "PURPOSE: Explore codebase for context to inform spec generation
TASK: • Identify tech stack • Map architecture patterns • Document conventions • List integration points
MODE: analysis
CONTEXT: @**/*
EXPECTED: JSON with: tech_stack[], architecture_patterns[], conventions[], integration_points[]" --tool gemini --mode analysis --rule analysis-analyze-code-patterns`,
run_in_background: false
})
```
## Phase 4: Context Packaging + Discuss
### 4a: Context Packaging
**spec-config.json**`<session>/spec/spec-config.json`
**discovery-context.json**`<session>/spec/discovery-context.json`
**design-intelligence.json**`<session>/analysis/design-intelligence.json` (UI mode only)
### 4b: Inline Discuss (DISCUSS-001)
**Multi-perspective critique via parallel CLI calls**:
```bash
# Product perspective
Bash(`ccw cli -p "PURPOSE: Review discovery context from product perspective
CONTEXT: @<session>/spec/discovery-context.json
EXPECTED: Rating (1-5) + concerns + recommendations
CONSTRAINTS: Focus on market fit, user value, scope clarity" --tool gemini --mode analysis`, { run_in_background: true })
# Risk perspective
Bash(`ccw cli -p "PURPOSE: Review discovery context from risk perspective
CONTEXT: @<session>/spec/discovery-context.json
EXPECTED: Rating (1-5) + risks + mitigation strategies
CONSTRAINTS: Focus on technical risks, dependencies, unknowns" --tool codex --mode analysis`, { run_in_background: true })
# Coverage perspective
Bash(`ccw cli -p "PURPOSE: Review discovery context from coverage perspective
CONTEXT: @<session>/spec/discovery-context.json
EXPECTED: Rating (1-5) + gaps + missing dimensions
CONSTRAINTS: Focus on completeness, edge cases, requirements coverage" --tool claude --mode analysis`, { run_in_background: true })
```
Wait for all results, aggregate ratings and feedback, determine consensus verdict:
- **HIGH**: Any rating <= 2 → User pause required
- **MEDIUM**: All ratings 3-4 → Proceed with caution
- **LOW**: All ratings >= 4 → Proceed
Handle verdict per consensus protocol.
**Report**: complexity, codebase presence, problem statement, dimensions, discuss verdict, output paths.
## Error Handling
| Scenario | Resolution |
|----------|------------|
| CLI failure | Fallback to direct Claude analysis |
| Codebase detection failed | Continue as new project |
| Topic too vague | Report with clarification questions |
| CLI critique fails | Proceed without critique, log warning |

View File

@@ -3,7 +3,6 @@ role: architect
prefix: ARCH
inner_loop: false
discuss_rounds: []
subagents: [explore]
message_types:
success: arch_ready
concern: arch_concern

View File

@@ -27,8 +27,8 @@ If `<session-folder>/spec/` exists → load requirements/_index.md, architecture
| Complexity | Criteria | Strategy |
|------------|----------|----------|
| Low | < 200 chars, no refactor/architecture keywords | ACE semantic search only |
| Medium | 200-500 chars or moderate scope | 2-3 angle explore subagent |
| High | > 500 chars, refactor/architecture, multi-module | 3-5 angle explore subagent |
| Medium | 200-500 chars or moderate scope | 2-3 angle CLI exploration |
| High | > 500 chars, refactor/architecture, multi-module | 3-5 angle CLI exploration |
For each angle, use CLI exploration (cache-aware — check cache-index.json before each call):

View File

@@ -0,0 +1,122 @@
---
role: reviewer
prefix: REVIEW
additional_prefixes: [QUALITY, IMPROVE]
inner_loop: false
discuss_rounds: [DISCUSS-003]
message_types:
success_review: review_result
success_quality: quality_result
fix: fix_required
error: error
---
# Reviewer — Phase 2-4
## Phase 2: Mode Detection
| Task Prefix | Mode | Dimensions | Discuss |
|-------------|------|-----------|---------|
| REVIEW-* | Code Review | quality, security, architecture, requirements | None |
| QUALITY-* | Spec Quality | completeness, consistency, traceability, depth, coverage | DISCUSS-003 |
| IMPROVE-* | Spec Quality (recheck) | Same as QUALITY | DISCUSS-003 |
## Phase 3: Review Execution
### Code Review (REVIEW-*)
**Inputs**: Plan file, git diff, modified files, test results
**4 dimensions**:
| Dimension | Critical Issues |
|-----------|----------------|
| Quality | Empty catch, any in public APIs, @ts-ignore, console.log |
| Security | Hardcoded secrets, SQL injection, eval/exec, innerHTML |
| Architecture | Circular deps, parent imports >2 levels, files >500 lines |
| Requirements | Missing core functionality, incomplete acceptance criteria |
### Spec Quality (QUALITY-* / IMPROVE-*)
**Inputs**: All spec docs in session folder, quality gate config
**5 dimensions**:
| Dimension | Weight | Focus |
|-----------|--------|-------|
| Completeness | 25% | All sections present with substance |
| Consistency | 20% | Terminology, format, references |
| Traceability | 25% | Goals -> Reqs -> Arch -> Stories chain |
| Depth | 20% | AC testable, ADRs justified, stories estimable |
| Coverage | 10% | Original requirements mapped |
**Quality gate**:
| Gate | Criteria |
|------|----------|
| PASS | Score >= 80% AND coverage >= 70% |
| REVIEW | Score 60-79% OR coverage 50-69% |
| FAIL | Score < 60% OR coverage < 50% |
**Artifacts**: readiness-report.md + spec-summary.md
## Phase 4: Verdict + Discuss
### Code Review Verdict
| Verdict | Criteria |
|---------|----------|
| BLOCK | Critical issues present |
| CONDITIONAL | High/medium only |
| APPROVE | Low or none |
### Spec Quality Discuss (DISCUSS-003)
After generating readiness-report.md, perform multi-perspective critique via parallel CLI calls:
```bash
# Product perspective
Bash(`ccw cli -p "PURPOSE: Review spec readiness from product perspective
CONTEXT: @<session>/spec/readiness-report.md
EXPECTED: Rating (1-5) + product concerns + recommendations
CONSTRAINTS: Focus on market alignment, user value, business viability" --tool gemini --mode analysis`, { run_in_background: true })
# Technical perspective
Bash(`ccw cli -p "PURPOSE: Review spec readiness from technical perspective
CONTEXT: @<session>/spec/readiness-report.md
EXPECTED: Rating (1-5) + technical risks + feasibility assessment
CONSTRAINTS: Focus on architecture soundness, tech debt, implementation complexity" --tool codex --mode analysis`, { run_in_background: true })
# Quality perspective
Bash(`ccw cli -p "PURPOSE: Review spec readiness from quality perspective
CONTEXT: @<session>/spec/readiness-report.md
EXPECTED: Rating (1-5) + quality gaps + improvement areas
CONSTRAINTS: Focus on completeness, testability, consistency" --tool claude --mode analysis`, { run_in_background: true })
# Risk perspective
Bash(`ccw cli -p "PURPOSE: Review spec readiness from risk perspective
CONTEXT: @<session>/spec/readiness-report.md
EXPECTED: Rating (1-5) + risk factors + mitigation strategies
CONSTRAINTS: Focus on dependencies, unknowns, timeline risks" --tool gemini --mode analysis`, { run_in_background: true })
# Coverage perspective
Bash(`ccw cli -p "PURPOSE: Review spec readiness from coverage perspective
CONTEXT: @<session>/spec/readiness-report.md
EXPECTED: Rating (1-5) + coverage gaps + missing requirements
CONSTRAINTS: Focus on edge cases, non-functional requirements, traceability" --tool codex --mode analysis`, { run_in_background: true })
```
Wait for all results, aggregate ratings and feedback, determine consensus verdict per protocol.
> **Note**: DISCUSS-003 HIGH always triggers user pause (final sign-off gate).
**Report**: mode, verdict/gate, dimension scores, discuss verdict (QUALITY only), output paths.
## Error Handling
| Scenario | Resolution |
|----------|------------|
| Missing context | Request from coordinator |
| Invalid mode | Abort with error |
| Analysis failure | Retry, then fallback |
| CLI critique fails | Proceed without critique, log warning |

View File

@@ -0,0 +1,117 @@
---
role: writer
prefix: DRAFT
inner_loop: true
discuss_rounds: [DISCUSS-002]
message_types:
success: draft_ready
revision: draft_revision
error: error
---
# Writer — Phase 2-4
## Phase 2: Context Loading
**Objective**: Load all required inputs for document generation.
### Document type routing
| Task Subject Contains | Doc Type | Template | Validation |
|----------------------|----------|----------|------------|
| Product Brief | product-brief | templates/product-brief.md | self-validate |
| Requirements / PRD | requirements | templates/requirements-prd.md | DISCUSS-002 |
| Architecture | architecture | templates/architecture-doc.md | self-validate |
| Epics | epics | templates/epics-template.md | self-validate |
### Progressive dependency loading
| Doc Type | Requires |
|----------|----------|
| product-brief | discovery-context.json |
| requirements | + product-brief.md |
| architecture | + requirements/_index.md |
| epics | + architecture/_index.md |
**Prior decisions from accumulator**: Pass context_accumulator summaries as "Prior Decisions" to generation.
| Input | Source | Required |
|-------|--------|----------|
| Document standards | `../../specs/document-standards.md` | Yes |
| Template | From routing table | Yes |
| Spec config | `<session>/spec/spec-config.json` | Yes |
| Discovery context | `<session>/spec/discovery-context.json` | Yes |
| Discussion feedback | `<session>/discussions/<discuss-file>` | If exists |
| Prior decisions | context_accumulator (in-memory) | If prior tasks |
## Phase 3: Document Generation
**Objective**: Generate document using CLI tool.
```
Bash({
command: `ccw cli -p "PURPOSE: Generate <doc-type> document following template and standards
TASK: • Load template • Apply spec config and discovery context • Integrate prior feedback • Generate all sections
MODE: write
CONTEXT: @<session>/spec/*.json @<template-path> | Memory: Prior decisions: <accumulator summary>
EXPECTED: Document at <output-path> with: YAML frontmatter, all sections, cross-references
CONSTRAINTS: Follow document-standards.md" --tool gemini --mode write --rule development-implement-feature --cd <session>`,
run_in_background: false
})
```
## Phase 4: Validation
### 4a: Self-Validation (all doc types)
| Check | What to Verify |
|-------|---------------|
| has_frontmatter | Starts with YAML frontmatter |
| sections_complete | All template sections present |
| cross_references | session_id included |
| progressive_consistency | References to upstream docs are valid |
### 4b: Validation Routing
| Doc Type | Validation Method |
|----------|------------------|
| product-brief | Self-validation only → report |
| requirements (PRD) | Self-validation + **DISCUSS-002** |
| architecture | Self-validation only → report |
| epics | Self-validation only → report |
**DISCUSS-002** (PRD only) - Multi-perspective critique via parallel CLI calls:
```bash
# Quality perspective
Bash(`ccw cli -p "PURPOSE: Review requirements document from quality perspective
CONTEXT: @<session>/spec/requirements/_index.md
EXPECTED: Rating (1-5) + quality issues + improvement suggestions
CONSTRAINTS: Focus on completeness, testability, consistency" --tool gemini --mode analysis`, { run_in_background: true })
# Product perspective
Bash(`ccw cli -p "PURPOSE: Review requirements document from product perspective
CONTEXT: @<session>/spec/requirements/_index.md
EXPECTED: Rating (1-5) + product concerns + alignment feedback
CONSTRAINTS: Focus on user value, market fit, scope clarity" --tool codex --mode analysis`, { run_in_background: true })
# Coverage perspective
Bash(`ccw cli -p "PURPOSE: Review requirements document from coverage perspective
CONTEXT: @<session>/spec/requirements/_index.md
EXPECTED: Rating (1-5) + coverage gaps + missing requirements
CONSTRAINTS: Focus on edge cases, non-functional requirements, traceability" --tool claude --mode analysis`, { run_in_background: true })
```
Wait for all results, aggregate ratings and feedback, determine consensus verdict per protocol.
**Report**: doc type, validation status, discuss verdict (PRD only), output path.
## Error Handling
| Scenario | Resolution |
|----------|------------|
| CLI failure | Retry once with alternative tool. Still fails → log, continue next |
| CLI critique fails | Skip critique, log warning |
| Cumulative 3 task failures | SendMessage to coordinator, STOP |
| Prior doc not found | Notify coordinator, request prerequisite |
| Discussion contradicts prior docs | Note conflict, flag for coordinator |