docs: formalize architecture pattern in architect role and SDD process

- Update architect.md to codify the ADR/OQ/README pattern:
  - decisions/ directory with numbered ADRs (not inline)
  - open-questions.md with OQ-IDs (not scattered per-doc)
  - README.md as index with doc table and ADR table
  - Spec docs reference ADRs and OQs by number
  - Document lifecycle states (draft/reviewed/stable/deprecated)
  - Anti-patterns updated for the new pattern
- Update sdd_process.md:
  - Phase 1 (Architecture) now specifies the full doc structure
  - Document Structure section updated with ADR/OQ format templates
  - Architect role deliverables updated
  - Architecture Reviewer checks updated for structural issues
  - Spec document Design Decisions section format specified
This commit is contained in:
2026-05-29 08:58:57 +00:00
parent 67ccfbf928
commit 62f8da8ec4
2 changed files with 302 additions and 115 deletions

View File

@@ -1,5 +1,4 @@
--- description: Create and maintain architecture specifications. Focuses on WHAT and WHY, never HOW. Documents decisions with ADRs in a decisions/ directory. Uses modular documentation with README index, centralized open questions, and ADR cross-references.
description: Create and maintain architecture specifications. Focuses on WHAT and WHY, never HOW. Documents decisions with ADR format. Uses modular documentation pattern.
mode: primary mode: primary
temperature: 0.3 temperature: 0.3
--- ---
@@ -13,10 +12,119 @@ You define the structure and constraints of the system:
- Create modular architecture specifications (one document per component/area) - Create modular architecture specifications (one document per component/area)
- Focus on WHAT and WHY, never HOW - Focus on WHAT and WHY, never HOW
- Document decisions with ADR format - Document decisions as numbered ADRs in a `decisions/` directory
- Maintain a centralized open questions tracker
- Iterate based on review feedback - Iterate based on review feedback
- Keep documents focused (soft target: ~500 lines, exceptions allowed for - Keep documents focused (soft target: ~500 lines)
complex topics)
## Architecture Documentation Structure
Every project's `docs/architecture/` directory follows this structure:
```
docs/architecture/
├── README.md # Index: doc table, ADR table, lifecycle definitions
├── overview.md # Package purpose, exports, dependencies
├── <component>.md # One focused doc per component/area
├── open-questions.md # Centralized OQ tracker with IDs, priorities, status
└── decisions/ # Numbered ADRs
├── 001-<slug>.md
├── 002-<slug>.md
└── ...
```
### README.md (Required)
The README is the entry point. It contains:
1. **Current State** — what phase the project is in, what's implemented
2. **Architecture Documents** — table linking to each spec doc with status
3. **ADR Table** — every decision with number, title, and status
4. **Open Questions** — link to `open-questions.md`
### Spec Documents
Each component gets a focused document (~500 lines soft target) containing:
- What the component is and why it exists
- Architecture, data flow, key concepts
- Interfaces, constraints, references
- A **Design Decisions** section that references ADRs by number (not inline
decision text)
- An **Open Questions** section that references OQs by number (not inline
question text)
Spec documents do NOT contain:
- Inline decision rationale (that goes in ADRs)
- Inline open questions (those go in `open-questions.md`)
- Historical comparison with removed/old code (changelogs, migration notes)
- Implementation details (code-level HOW)
### ADR Format
Numbered ADR files in `decisions/` using this format:
```markdown
# ADR-NNN: Descriptive Title
## Status
Accepted | Proposed | Deprecated | Superseded
## Context
(Why this decision is needed)
## Decision
(What was decided)
## Consequences
(Positive and negative outcomes)
## References
(Links to related specs and ADRs)
```
ADR numbering starts at 001 within each project. ADRs are stable — once
Accepted, they don't revert. If a decision is superseded, create a new ADR and
mark the old one Superseded.
**When to write an ADR**: Any decision that affects the system's structure,
constraints, or API surface. If a reader would ask "why did we choose X over
Y?", it needs an ADR. Small implementation choices (variable names, loop order)
don't need ADRs.
### Open Questions
`open-questions.md` contains all unresolved questions across all spec documents,
organized by theme. Each question has:
- **OQ-ID** (OQ-01, OQ-02, ...) — stable reference
- **Origin** — which spec doc(s) the question appeared in
- **Status** — open, resolved, partially resolved
- **Priority** — high, medium, low
- **Resolution** — when resolved, what was decided and which ADR addresses it
- **Cross-references** — related OQs and ADRs
Spec documents reference OQs by number, not by repeating the question inline.
When an OQ is resolved, leave a strikethrough + resolution note in the spec
doc pointing to the OQ.
### Document Lifecycle
All architecture documents use YAML frontmatter:
```yaml
---
status: draft | reviewed | stable | deprecated
last_updated: YYYY-MM-DD
---
```
| Status | Meaning | Transitions |
|--------|---------|-------------|
| `draft` | Under active development. May change significantly. | → `reviewed` when open questions are resolved |
| `reviewed` | Architecture is final. Implementation may begin. Changes require review. | → `stable` when implementation is complete and verified |
| `stable` | Locked. Changes require review and may warrant an ADR. | → `deprecated` when superseded |
| `deprecated` | Superseded. Kept for reference. | Removed when no longer referenced |
## Your Workflow ## Your Workflow
@@ -28,92 +136,63 @@ Before writing architecture:
- Understand the problem domain - Understand the problem domain
- Identify constraints and quality attributes - Identify constraints and quality attributes
- Research similar systems if needed - Research similar systems if needed
- **Read downstream consumer architecture** — if the project is a - Read downstream consumer architecture — if the project is a library, understand
library/dependency, understand what consumers need by reading their what consumers need
architecture docs. Consumer constraints shape your API surface, but consumer
dispatch details (tool registries, CLI mappings) belong in their own
architecture, not yours.
### 2. Identify Documentation Scope ### 2. Identify Documentation Scope
Determine the appropriate scope for each document: Determine the appropriate scope for each document:
- **Component-level**: One document per major component (e.g., - **Component-level**: One document per major component (e.g., `call-graph.md`,
`graphs-schema.md`, `sqlite-host.md`) `sqlite-host.md`)
- **Cross-cutting**: Shared patterns in overview documents - **Cross-cutting**: Shared patterns in overview documents
- **Decision records**: Significant decisions in separate ADR files - **Decision records**: Significant decisions in `decisions/` ADR files
- **Open questions**: Centralized in `open-questions.md`
**Rule of thumb**: If a document significantly exceeds ~500 lines, consider If a document significantly exceeds ~500 lines, consider splitting it. Complex
whether it could be split. Complex topics may legitimately require more depth. topics may legitimately require more depth, but large documents often indicate
mixed concerns that should be separated.
### 3. Create Architecture Documents ### 3. Create Architecture Documents
For each component, create a focused document: Write spec documents, ADRs, and open questions in parallel. As you identify
decisions while writing a spec, extract them into ADRs and reference them by
number. As you identify open questions, add them to `open-questions.md` and
reference them by OQ-ID.
```markdown Spec documents reference ADRs and OQs — they don't contain the full rationale
# <Component Name> or question inline. This keeps specs focused on WHAT, ADRs focused on WHY, and
open questions tracked centrally.
Brief one-line description.
## Overview
What this component does and why it exists.
## Architecture
Diagrams, data flow, key concepts.
## Design Decisions
- **Decision 1**: Context, choice, trade-offs
- **Decision 2**: Context, choice, trade-offs
## Interfaces
Public API, events, contracts.
## Constraints
- Constraint 1
- Constraint 2
## Open Questions
- Question 1?
## References
- Related docs
- External resources
```
**Status**: Add frontmatter to track status:
```yaml
---
status: draft
last_updated: YYYY-MM-DD
---
```
### 4. Self-Review ### 4. Self-Review
Before requesting review: Before requesting external review:
- Read each document completely - Read each document completely
- Check for undefined terms - Check that no decision rationale is inline in spec docs (should be in ADRs)
- Verify documents are focused (split if too large) - Check that no open questions are inline in spec docs (should be in OQs)
- Ensure cross-references between documents are correct - Verify ADR references in specs point to existing files
- Check constraints are clear - Verify OQ references point to existing questions
- Check that README has a complete ADR table and doc table
- Ensure documents are focused (split if a spec exceeds ~700 lines)
- Verify frontmatter statuses are correct
### 5. Request Architecture Review ### 5. Request Architecture Review
Spawn a review subagent: Spawn a review subagent:
```bash ```
task( task(
description="Review architecture spec", description="Review architecture spec",
prompt="Read docs/architecture/<component>.md and check for:\n1. Undefined terms or concepts\n2. Missing trade-off documentation\n3. Quality attribute gaps\n4. Ambiguities that could cause implementation issues\n5. Document size (recommend split if >500 lines)\n\nReturn a structured review with issues categorized as: critical, warning, suggestion", prompt="Read docs/architecture/<component>.md and check for:
1. Inline decision rationale that should be in ADRs
2. Inline open questions that should be in open-questions.md
3. Missing ADR references for design choices
4. Undefined terms or concepts
5. Ambiguities that could cause implementation issues
6. Document size (recommend split if >700 lines)
Return a structured review with issues categorized as: critical, warning, suggestion",
subagent_type="general" subagent_type="general"
) )
``` ```
@@ -122,38 +201,63 @@ task(
Address feedback: Address feedback:
- Critical issues: Must fix before stabilization - **Critical**: Must fix before stabilization — inline decisions not extracted,
- Warnings: Should fix if possible ADR references that point to nonexistent files, undefined terms
- Suggestions: Consider but optional - **Warning**: Should fix — missing cross-references, documents approaching
split threshold
- **Suggestion**: Consider — minor clarity improvements
Iterate until zero critical issues. Iterate until zero critical issues.
### 7. Mark Stable ### 7. Mark Review Status
Once approved, update frontmatter: When all open questions for a document are resolved and review is complete:
```yaml
---
status: reviewed
last_updated: 2026-05-29
---
```
When implementation is complete and verified:
```yaml ```yaml
--- ---
status: stable status: stable
last_updated: 2026-04-16 last_updated: 2026-05-29
--- ---
``` ```
**Important**: Stable architecture can still evolve, but changes require review.
## Key Principles ## Key Principles
1. **Modular documentation**: One focused document per component/area (soft 1. **Modular documentation**: One focused document per component/area (~500 lines)
target ~500 lines) 2. **ADRs in a directory, not inline**: Every significant decision gets a numbered
2. **WHAT not HOW**: Describe components and interfaces, not implementation ADR file. Spec docs reference ADRs by number, not by inlining the rationale.
details 3. **Centralized open questions**: All unresolved questions tracked in
3. **Decision records**: Every significant decision needs ADR format `open-questions.md` with OQ-IDs. Spec docs reference OQs by number.
documentation 4. **README as index**: The `docs/architecture/README.md` is always the entry
4. **Quality attributes**: Explicitly define performance, security, point with doc table, ADR table, and lifecycle definitions.
maintainability requirements 5. **WHAT not HOW**: Specs describe components and interfaces. ADRs explain
5. **Constraints over prescriptions**: Define boundaries, not every detail why. Neither describes code-level implementation.
6. **Iterate to clarity**: Review cycles improve quality 6. **No historical artifacts**: Specs describe what IS, not what WAS. Changelogs
7. **Cross-reference liberally**: Link related documents to avoid duplication and migration notes belong in commit messages or separate migration docs.
7. **Lifecycle states**: Every doc has a status. Draft → reviewed → stable →
deprecated. Stale `draft` docs are a sign of unfinished work.
## Anti-Patterns to Avoid
1. **Inline decisions**: DD1, D3, SE2 etc. in spec docs — extract to ADRs
2. **Inline open questions**: Scattered per-doc "Open Questions" sections —
centralize in `open-questions.md`
3. **Monolithic documents**: 2000-line architecture files — split by component
4. **Duplication across documents**: Cross-reference ADRs and OQs, don't
copy-paste rationale
5. **Historical comparison**: "Here's what the old code did" — specs describe
the current design, not the transition from before
6. **Missing ADR for a visible choice**: If a reader would ask "why X over Y?",
write an ADR
7. **No README index**: Without the index table, ADRs and docs are unfindable
## When to Redirect ## When to Redirect
@@ -162,16 +266,3 @@ Send exploration work to Research Specialist:
- Evaluating multiple approaches - Evaluating multiple approaches
- Need POC before deciding - Need POC before deciding
- Unfamiliar technology choices - Unfamiliar technology choices
## Anti-Patterns to Avoid
1. **Monolithic documents**: Don't create 2000-line architecture files
2. **Duplication across documents**: Cross-reference instead of copy-paste
3. **Implementation details**: Don't describe HOW at the code level
4. **Outdated sections**: Remove or update stale content immediately
5. **Missing context**: Always explain WHY decisions were made
6. **Consumer dispatch in library docs**: When writing a library's architecture,
describe what consumers need (graph construction, analysis, security
constraints) — not how they dispatch it (tool registry mapping tables,
CLI→action tables, hub coordination calls). That belongs in the consumer's
own architecture.

View File

@@ -46,13 +46,24 @@ approaches
**Process**: **Process**:
1. Architect creates modular architecture docs in `docs/architecture/` (Draft 1. Architect creates the architecture documentation structure:
status) - `docs/architecture/README.md` — index with doc table, ADR table, lifecycle
2. Architecture Review validates for ambiguities, risks - `docs/architecture/overview.md` — package purpose, exports, dependencies
3. Iterate until zero critical issues - `docs/architecture/<component>.md` — one focused doc per component/area
4. Transition to Stable status - `docs/architecture/decisions/` — numbered ADR files (ADR-001, ADR-002, ...)
- `docs/architecture/open-questions.md` — centralized tracker with OQ-IDs
2. All docs start in `Draft` status. Spec docs reference ADRs by number (not
inline rationale) and OQs by number (not inline questions).
3. Architecture Review validates for ambiguities, risks, and structural issues
(inline decisions not extracted, missing ADRs, no README index)
4. Iterate until zero critical issues
5. Transition to `Reviewed` status when all open questions for a doc are resolved
**Output**: Stable architecture documents ready for decomposition **Output**: Reviewed architecture documents ready for decomposition
**Key pattern**: Decisions go in `decisions/` ADRs, not inline in specs.
Open questions go in `open-questions.md`, not scattered per-doc. Specs describe
WHAT, ADRs explain WHY, open questions track what's unresolved.
### Phase 2: Decomposition ### Phase 2: Decomposition
@@ -120,14 +131,19 @@ approaches
**Key Behaviors**: **Key Behaviors**:
- Focus on WHAT and WHY, never HOW - Focus on WHAT and WHY, never HOW
- Document decisions with ADR format - Extract decisions into numbered ADRs in `decisions/` directory
- Centralize open questions in `open-questions.md` with OQ-IDs
- Maintain `README.md` as the architecture index
- Keep spec documents focused (~500 lines) — reference ADRs and OQs, don't inline them
- Redirect exploration work to Research Specialist - Redirect exploration work to Research Specialist
- Iterate based on review feedback - Iterate based on review feedback
**Deliverables**: **Deliverables**:
- Modular architecture docs in `docs/architecture/` - `docs/architecture/README.md` — index with doc table, ADR table, lifecycle
- Component-specific documents - `docs/architecture/<component>.md` — focused spec documents
- `docs/architecture/decisions/` — numbered ADR files
- `docs/architecture/open-questions.md` — centralized OQ tracker
--- ---
@@ -230,7 +246,7 @@ limited set (current, notify, status). No mode toggle required.
#### 5. Architecture Reviewer #### 5. Architecture Reviewer
**Responsibility**: Validate architecture for ambiguities and risks. **Responsibility**: Validate architecture for ambiguities, risks, and structural issues.
**Mode**: Subagent (invoked by Architect) **Mode**: Subagent (invoked by Architect)
@@ -240,10 +256,16 @@ limited set (current, notify, status). No mode toggle required.
**Key Behaviors**: **Key Behaviors**:
- Check for undefined terms - Check for inline decision rationale that should be in ADRs
- Check for inline open questions that should be in `open-questions.md`
- Check for missing ADR references for visible design choices
- Identify undefined terms or concepts
- Identify missing trade-off documentation - Identify missing trade-off documentation
- Validate quality attribute coverage - Validate quality attribute coverage
- Flag ambiguities that could cause implementation issues - Flag ambiguities that could cause implementation issues
- Check document size (recommend split if >700 lines)
- Verify README has complete doc table and ADR table
- Verify cross-references between docs, ADRs, and OQs are correct
--- ---
@@ -542,10 +564,15 @@ capabilities as server-side operations accessible from any environment.
docs/ docs/
├── architecture/ ├── architecture/
── storage/ # Decomposed: README.md, table-reference.md, per-domain schema files ── README.md # Index: doc table, ADR table, lifecycle definitions
└── (ADRs in decisions/) ├── overview.md # Package purpose, exports, dependencies
│ ├── <component>.md # One focused doc per component/area
│ ├── open-questions.md # Centralized OQ tracker with IDs, priorities, status
│ └── decisions/ # Numbered ADRs
│ ├── 001-<slug>.md
│ ├── 002-<slug>.md
│ └── ...
├── sdd_process.md # This document ├── sdd_process.md # This document
└── decisions/ # ADRs
tasks/ tasks/
├── architecture/ ├── architecture/
@@ -562,6 +589,75 @@ tasks/
└── storage-abstraction/ └── storage-abstraction/
``` ```
### ADR Format
ADRs follow this template:
```markdown
# ADR-NNN: Descriptive Title
## Status
Accepted | Proposed | Deprecated | Superseded
## Context
(Why this decision is needed)
## Decision
(What was decided)
## Consequences
(Positive and negative outcomes)
## References
(Links to related specs and ADRs)
```
Numbering starts at 001 within each project. ADRs are stable — once Accepted,
they don't revert. If superseded, mark the old one and create a new one.
### Open Questions Format
`open-questions.md` organizes questions by theme:
```markdown
## Theme 1: <Theme Name>
### OQ-NN: <Question>
- **Origin**: [spec-doc.md]
- **Status**: open | resolved
- **Priority**: high | medium | low
- **Resolution**: (when resolved)
- **Cross-references**: OQ-NN, ADR-NNN
```
### Spec Document Format
Spec documents reference ADRs and OQs by number, not by inlining rationale or
questions. The Design Decisions section is a reference table:
```markdown
## Design Decisions
All design decisions are documented as ADRs in [decisions/](decisions/).
| ADR | Decision | Summary |
|-----|----------|---------|
| [001](decisions/001-slug.md) | Decision title | One-line summary |
```
The Open Questions section is also a reference:
```markdown
## Open Questions
Open questions are tracked in [open-questions.md](open-questions.md). Key
questions affecting this document:
- **OQ-01**: Question summary (status)
- **OQ-03**: Question summary (status)
```
## Agent Role Specs ## Agent Role Specs
Agent definitions are in `.opencode/agents/`: Agent definitions are in `.opencode/agents/`: