@dzhechkov/keysarium 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/package.json +10 -2
  2. package/templates/.claude/commands/dream.md +101 -0
  3. package/templates/.claude/commands/feature-adr.md +92 -0
  4. package/templates/.claude/commands/init-platform.md +161 -0
  5. package/templates/.claude/commands/learning-stats.md +130 -0
  6. package/templates/.claude/commands/workers.md +140 -0
  7. package/templates/.claude/rules/background-workers.md +72 -0
  8. package/templates/.claude/rules/dream-cycles.md +90 -0
  9. package/templates/.claude/rules/feature-adr-conventions.md +82 -0
  10. package/templates/.claude/rules/reward-learning.md +124 -0
  11. package/templates/.claude/shards/feature-adr.shard.md +98 -0
  12. package/templates/.claude/skills/feature-adr/SKILL.md +252 -0
  13. package/templates/.claude/skills/feature-adr/examples/sample-feature-output.md +257 -0
  14. package/templates/.claude/skills/feature-adr/modules/00-complexity-router.md +114 -0
  15. package/templates/.claude/skills/feature-adr/modules/01-requirements.md +113 -0
  16. package/templates/.claude/skills/feature-adr/modules/02-research.md +92 -0
  17. package/templates/.claude/skills/feature-adr/modules/03-adr.md +135 -0
  18. package/templates/.claude/skills/feature-adr/modules/04-ddd.md +114 -0
  19. package/templates/.claude/skills/feature-adr/modules/05-architecture.md +149 -0
  20. package/templates/.claude/skills/feature-adr/modules/06-implementation-plan.md +129 -0
  21. package/templates/.claude/skills/feature-adr/modules/07-code.md +126 -0
  22. package/templates/.claude/skills/feature-adr/modules/08-qe.md +167 -0
  23. package/templates/.claude/skills/feature-adr/references/adr-template.md +102 -0
  24. package/templates/.claude/skills/feature-adr/references/c4-template.md +120 -0
  25. package/templates/.claude/skills/feature-adr/references/complexity-matrix.md +139 -0
  26. package/templates/.claude/skills/feature-adr/references/qe-checklist.md +86 -0
  27. package/templates/CLAUDE.md +124 -3
  28. package/templates/docs/improvement-directions.md +16 -16
  29. package/templates/docs/keysarium/01-deployment-guide.md +21 -12
  30. package/templates/docs/keysarium/02-admin-guide.md +204 -3
  31. package/templates/docs/keysarium/03-user-guide.md +224 -0
  32. package/templates/docs/keysarium/05-architecture.md +181 -0
  33. package/templates/docs/keysarium/06-user-flows.md +235 -0
  34. package/templates/lib/background-workers.md +278 -0
  35. package/templates/lib/dream-engine.md +460 -0
  36. package/templates/lib/judge-attestation.md +322 -0
  37. package/templates/lib/memory-protocol.md +239 -0
  38. package/templates/lib/platform-adapters.md +100 -0
  39. package/templates/lib/platform-templates/copilot.md +134 -0
  40. package/templates/lib/platform-templates/cursor.md +95 -0
  41. package/templates/lib/platform-templates/opencode.md +155 -0
  42. package/templates/lib/reward-tracker.md +256 -0
  43. package/templates/lib/witness-chain.md +372 -0
  44. package/templates/lib/worker-templates/brain-export.md +187 -0
  45. package/templates/lib/worker-templates/consolidate.md +180 -0
  46. package/templates/lib/worker-templates/dream-cycle.md +154 -0
  47. package/templates/lib/worker-templates/health-check.md +255 -0
@@ -0,0 +1,252 @@
1
+ ---
2
+ name: feature-adr
3
+ description: >
4
+ 9-step feature development pipeline with Complexity Router (S/M/L/XL),
5
+ ADR-driven architecture decisions, DDD modeling, and multi-agent QE.
6
+ Triggers on "реализуй фичу", "feature implementation", "добавь функциональность",
7
+ "implement feature", "/feature-adr".
8
+ trust_tier: 0
9
+ trust_tier_label: "Advisory"
10
+ trust_tier_path: "Run /bto-test to promote to Tier 1"
11
+ ---
12
+
13
+ # Feature ADR — Adaptive Feature Development Pipeline
14
+
15
+ > 9-шаговый pipeline для разработки фич любой сложности.
16
+ > Complexity Router автоматически определяет масштаб (S/M/L/XL) и пропускает ненужные шаги.
17
+
18
+ ## When To Activate
19
+
20
+ Trigger on:
21
+ - "реализуй фичу [описание]"
22
+ - "implement feature [description]"
23
+ - "добавь функциональность [описание]"
24
+ - "feature [описание]"
25
+ - `/feature-adr [описание или путь к issue]`
26
+
27
+ ## Architecture
28
+
29
+ ```
30
+ .claude/skills/feature-adr/
31
+ ├── SKILL.md ← This file (orchestrator)
32
+ ├── modules/
33
+ │ ├── 00-complexity-router.md ← Step 0: S/M/L/XL classification
34
+ │ ├── 01-requirements.md ← Step 1: Requirements gathering
35
+ │ ├── 02-research.md ← Step 2: Analogues & patterns research
36
+ │ ├── 03-adr.md ← Step 3: Architecture Decision Records
37
+ │ ├── 04-ddd.md ← Step 4: Domain-Driven Design
38
+ │ ├── 05-architecture.md ← Step 5: Technical architecture
39
+ │ ├── 06-implementation-plan.md ← Step 6: Task decomposition & ordering
40
+ │ ├── 07-code.md ← Step 7: Code generation
41
+ │ └── 08-qe.md ← Step 8: Quality Engineering
42
+ ├── references/
43
+ │ ├── complexity-matrix.md ← S/M/L/XL criteria & step activation
44
+ │ ├── adr-template.md ← ADR document template
45
+ │ ├── c4-template.md ← C4 diagram templates
46
+ │ └── qe-checklist.md ← Quality engineering checklist
47
+ └── examples/
48
+ └── sample-feature-output.md ← Example output for M-tier feature
49
+ ```
50
+
51
+ ## Pipeline Overview
52
+
53
+ ```
54
+ Step 0 Step 1 Step 2 Step 3 Step 4
55
+ ROUTER → REQUIREMENTS → RESEARCH → ADR → DDD
56
+ (all) (all) (L/XL) (M+) (L/XL)
57
+ │ │
58
+ └──→ Step 5 ←┘
59
+ ARCHITECTURE
60
+ (M+)
61
+ │
62
+ ↓
63
+ Step 6
64
+ IMPL PLAN
65
+ (all)
66
+ │
67
+ ↓
68
+ Step 7
69
+ CODE
70
+ (all)
71
+ │
72
+ ↓
73
+ Step 8
74
+ QE
75
+ (all)
76
+ ```
77
+
78
+ ## Complexity Tiers
79
+
80
+ | Tier | Scope | Steps | Example |
81
+ |------|-------|-------|---------|
82
+ | **S** | 1-3 files, single domain | 0→1→6→7→8 | Bug fix, config change, small util |
83
+ | **M** | 4-10 files, 1-2 domains | 0→1→3→5(light)→6→7→8 | New API endpoint, UI component |
84
+ | **L** | 11-30 files, 2-4 domains | 0→1→2→3→4→5→6→7→8 | New module, integration |
85
+ | **XL** | 30+ files, cross-cutting | Full DAG with parallelism | New subsystem, major refactor |
86
+
87
+ See `references/complexity-matrix.md` for detailed classification criteria.
88
+
89
+ ## Step Activation Matrix
90
+
91
+ ```
92
+ Step | S | M | L | XL | Model |
93
+ ───────────────────────────────────────────────────────
94
+ 0 Complexity Router | ✓ | ✓ | ✓ | ✓ | haiku |
95
+ 1 Requirements | ✓ | ✓ | ✓ | ✓ | sonnet |
96
+ 2 Research | - | - | ✓ | ✓ | sonnet |
97
+ 3 ADR | - | ✓ | ✓ | ✓ | opus |
98
+ 4 DDD | - | - | ✓ | ✓ | opus |
99
+ 5 Architecture | - | ✓ | ✓ | ✓ | opus |
100
+ 6 Implementation Plan | ✓ | ✓ | ✓ | ✓ | sonnet |
101
+ 7 Code | ✓ | ✓ | ✓ | ✓ | opus |
102
+ 8 QE | ✓ | ✓ | ✓ | ✓ | sonnet |
103
+ ```
104
+
105
+ ## DAG Dependencies
106
+
107
+ Steps are NOT purely linear. The DAG defines what can run in parallel:
108
+
109
+ ```
110
+ Group 1 (sequential): Step 0 → Step 1
111
+ Group 2 (parallel): Step 2 ‖ Step 3 (after Step 1)
112
+ Group 3 (parallel): Step 4 ‖ Step 5 (after Steps 2+3)
113
+ Group 4 (sequential): Step 6 (after Step 5)
114
+ Group 5 (sequential): Step 7 (after Step 6)
115
+ Group 6 (sequential): Step 8 (after Step 7)
116
+ ```
117
+
118
+ For tiers S/M, the DAG collapses to a linear sequence (no parallelism needed).
119
+
120
+ ## Agent Swarm Strategy
121
+
122
+ ### Per-Step Parallelism (L/XL tiers only)
123
+
124
+ | Step | Agents | Tasks |
125
+ |------|--------|-------|
126
+ | Step 2 | 2 parallel (sonnet) | Codebase patterns ‖ External analogues |
127
+ | Step 3+4 | 2 parallel (opus) | ADR drafting ‖ DDD modeling |
128
+ | Step 7 | N parallel (opus) | One agent per independent module/file |
129
+ | Step 8 | 3 parallel (sonnet) | Unit tests ‖ Integration tests ‖ Code review |
130
+
131
+ ### Cross-Step Parallelism
132
+
133
+ For L/XL: Steps 2 and 3 run in parallel after Step 1 completes.
134
+ For L/XL: Steps 4 and 5 can overlap if Step 3 finishes before Step 2.
135
+
136
+ ## Execution Protocol
137
+
138
+ ### 1. Load Governance
139
+ ```
140
+ Read: .claude/shards/feature-adr.shard.md
141
+ ```
142
+
143
+ ### 2. Run Step 0 (Complexity Router)
144
+ ```
145
+ Read: modules/00-complexity-router.md
146
+ Read: references/complexity-matrix.md
147
+ → Output: {COMPLEXITY_TIER}, {ACTIVE_STEPS}, {TIME_BUDGET}
148
+ → Checkpoint 0
149
+ ```
150
+
151
+ ### 3. Execute Active Steps per DAG
152
+ For each active step:
153
+ ```
154
+ Read: modules/<step>.md
155
+ Execute protocol
156
+ → Create artifacts in features/<feature-slug>/
157
+ → Checkpoint N
158
+ ```
159
+
160
+ ### 4. Final Verification
161
+ After Step 8 completes, verify:
162
+ - All mandatory artifacts exist per tier
163
+ - QE checks passed
164
+ - ADR decisions are traceable to code (L/XL)
165
+
166
+ ## Cross-Phase Variables
167
+
168
+ | Variable | Set In | Used In | Type |
169
+ |----------|--------|---------|------|
170
+ | `{COMPLEXITY_TIER}` | Step 0 | All steps | S/M/L/XL |
171
+ | `{ACTIVE_STEPS}` | Step 0 | Orchestrator | list[int] |
172
+ | `{TIME_BUDGET}` | Step 0 | All steps | dict |
173
+ | `{REQUIREMENTS}` | Step 1 | Steps 2-8 | structured |
174
+ | `{RESEARCH_FINDINGS}` | Step 2 | Steps 3-5 | structured |
175
+ | `{ADR_DECISIONS}` | Step 3 | Steps 4-7 | list[ADR] |
176
+ | `{DOMAIN_MODEL}` | Step 4 | Steps 5-7 | structured |
177
+ | `{ARCHITECTURE}` | Step 5 | Steps 6-7 | structured |
178
+ | `{IMPL_PLAN}` | Step 6 | Step 7 | list[task] |
179
+ | `{QE_RESULTS}` | Step 8 | Final report | structured |
180
+
181
+ ## Output Directory Structure
182
+
183
+ All artifacts are created in `features/<feature-slug>/`:
184
+
185
+ ```
186
+ features/<feature-slug>/
187
+ ├── 00_complexity_assessment.md ← Always
188
+ ├── 01_requirements.md ← Always
189
+ ├── 02_research.md ← L/XL only
190
+ ├── 03_adr/ ← M+ only
191
+ │ ├── 001-<decision>.md
192
+ │ └── ...
193
+ ├── 04_domain_model.md ← L/XL only
194
+ ├── 05_architecture.md ← M+ only
195
+ ├── 06_implementation_plan.md ← Always
196
+ ├── 07_code_changes/ ← Always (actual code in repo)
197
+ │ └── change_manifest.md ← List of modified files
198
+ ├── 08_qe_report.md ← Always
199
+ ├── diagrams/ ← M+ only
200
+ │ ├── architecture-c4.mermaid
201
+ │ ├── sequence-*.mermaid
202
+ │ └── domain-model.mermaid
203
+ └── README.md ← Always (auto-generated summary)
204
+ ```
205
+
206
+ ## Promise Tags
207
+
208
+ | Step | Promise Tag |
209
+ |------|-------------|
210
+ | Step 0 | `<promise>FEATURE_ADR_ROUTED</promise>` |
211
+ | Step 1 | `<promise>FEATURE_ADR_REQUIREMENTS_GATHERED</promise>` |
212
+ | Steps 2-5 | `<promise>FEATURE_ADR_DESIGNED</promise>` |
213
+ | Step 6 | `<promise>FEATURE_ADR_PLANNED</promise>` |
214
+ | Step 7 | `<promise>FEATURE_ADR_IMPLEMENTED</promise>` |
215
+ | Step 8 | `<promise>FEATURE_ADR_VERIFIED</promise>` |
216
+
217
+ ## External Skills (loaded as needed)
218
+
219
+ | Skill | Used In | Purpose |
220
+ |-------|---------|---------|
221
+ | explore | Step 1 | Requirements clarification |
222
+ | problem-solver-enhanced | Step 3 | Trade-off analysis for ADR decisions |
223
+ | frontend-design | Step 7 | UI implementation (if feature has UI) |
224
+
225
+ ## Anti-Patterns
226
+
227
+ | Anti-Pattern | Detection | Fix |
228
+ |-------------|-----------|-----|
229
+ | Skip complexity assessment | Jump straight to coding | BLOCK — always run Step 0 |
230
+ | Over-engineer S-tier | Run full pipeline for a config change | Router should classify as S |
231
+ | Under-engineer XL-tier | Skip ADR/DDD for major refactor | Router should classify as XL |
232
+ | ADR without alternatives | Only one option considered | Require ≥2 alternatives per ADR |
233
+ | Architecture without ADR | Diagram before decisions | Step 5 requires Step 3 output |
234
+ | Code without plan | Start coding without Step 6 | BLOCK — plan is mandatory |
235
+ | No QE | Ship without testing | BLOCK — Step 8 is mandatory |
236
+
237
+ ## Checkpoint Format
238
+
239
+ ```
240
+ ═══════════════════════════════════════════════════════
241
+ ⏸️ STEP N/8: [Step Name] Complete
242
+ <promise>[PROMISE_TAG]</promise>
243
+ Tier: {COMPLEXITY_TIER} | Active Steps: {ACTIVE_STEPS}
244
+
245
+ [2-3 line summary]
246
+ Artifacts: [list] ✅
247
+
248
+ • "ок" — next step
249
+ • "углуби [section]" — elaborate
250
+ • "[feedback]" — adjust
251
+ ═══════════════════════════════════════════════════════
252
+ ```
@@ -0,0 +1,257 @@
1
+ # Sample Output: M-tier Feature — "Add User Notifications"
2
+
3
+ > This example shows the expected output structure for a medium-complexity feature.
4
+
5
+ ---
6
+
7
+ ## Step 0: Complexity Assessment
8
+
9
+ ```
10
+ Feature: Add email and in-app notifications for order status changes
11
+ ```
12
+
13
+ | Dimension | Score | Reasoning |
14
+ |-----------|-------|-----------|
15
+ | Files affected | 2 (M) | ~8 files: model, service, controller, templates, tests |
16
+ | Domains touched | 2 (M) | Orders domain + Notifications domain |
17
+ | New integrations | 2 (M) | Email service (SendGrid) |
18
+ | Breaking changes | 1 (S) | No breaking changes |
19
+ | New data models | 2 (M) | Notification entity + preferences |
20
+ | Cross-cutting concerns | 1 (S) | None |
21
+
22
+ **Total: 10 → Tier M**
23
+
24
+ Active steps: 0, 1, 3, 5(light), 6, 7, 8
25
+
26
+ ---
27
+
28
+ ## Step 1: Requirements
29
+
30
+ ```markdown
31
+ # Requirements: User Notifications
32
+
33
+ ## Stakeholders
34
+ - End user: receives notifications
35
+ - Product owner: defines notification triggers
36
+ - Ops team: monitors delivery rates
37
+
38
+ ## Functional Requirements
39
+
40
+ FR-1: Order status notification
41
+ Priority: MUST
42
+ Acceptance: Given a user with email notifications enabled,
43
+ When their order status changes,
44
+ Then they receive an email within 5 minutes.
45
+
46
+ FR-2: In-app notification
47
+ Priority: MUST
48
+ Acceptance: Given a user is logged in,
49
+ When a notification is created,
50
+ Then it appears in the notification bell within 10 seconds.
51
+
52
+ FR-3: Notification preferences
53
+ Priority: SHOULD
54
+ Acceptance: Given a user in settings,
55
+ When they toggle notification types,
56
+ Then only enabled types are delivered.
57
+
58
+ FR-4: Notification history
59
+ Priority: COULD
60
+ Acceptance: Given a user in notification center,
61
+ When they scroll,
62
+ Then they see paginated notification history.
63
+
64
+ ## Constraints
65
+ - Must use existing SendGrid account
66
+ - Must not exceed 10K emails/day (current plan limit)
67
+ - Must follow existing event-driven architecture
68
+
69
+ ## Scope
70
+ - IN: Order status emails, in-app notifications, preferences
71
+ - OUT: Push notifications (mobile), SMS, marketing emails
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Step 3: ADR
77
+
78
+ ```markdown
79
+ # ADR-001: Notification Delivery Strategy
80
+
81
+ ## Status
82
+ Accepted
83
+
84
+ ## Context
85
+ We need to deliver notifications both via email and in-app.
86
+ The question is whether to send synchronously or asynchronously.
87
+
88
+ ## Decision Drivers
89
+ - Order status changes happen in bursts (batch processing)
90
+ - Email delivery latency is acceptable within 5 minutes
91
+ - System should not slow down order processing
92
+
93
+ ## Considered Options
94
+
95
+ ### Option 1: Synchronous delivery
96
+ Send notification during order status update request.
97
+ - ✅ Simple implementation
98
+ - ❌ Slows down order status updates
99
+ - ❌ Email failures block the request
100
+
101
+ ### Option 2: Async via existing job queue
102
+ Publish notification event, worker processes it.
103
+ - ✅ Non-blocking for order processing
104
+ - ✅ Retry on failure
105
+ - ✅ Uses existing Bull queue infrastructure
106
+ - ❌ Slight delay (acceptable per requirements)
107
+
108
+ ## Decision
109
+ We chose **Option 2: Async via job queue** because it matches our existing
110
+ event-driven architecture and meets the 5-minute SLA with room to spare.
111
+
112
+ ## Consequences
113
+ ### Positive
114
+ - Order processing unaffected by notification delivery
115
+ - Built-in retry and dead-letter handling
116
+ ### Negative
117
+ - Need to monitor queue depth for capacity planning
118
+ ```
119
+
120
+ ---
121
+
122
+ ## Step 5: Architecture (Light)
123
+
124
+ ```markdown
125
+ # Architecture: User Notifications
126
+
127
+ ## Component Diagram
128
+
129
+ ​```mermaid
130
+ graph TB
131
+ subgraph "API Server"
132
+ OrderService[OrderService]
133
+ NotifService[NotificationService]
134
+ NotifController[NotificationController]
135
+ PrefsController[PreferencesController]
136
+ end
137
+
138
+ subgraph "Workers"
139
+ EmailWorker[EmailNotificationWorker]
140
+ InAppWorker[InAppNotificationWorker]
141
+ end
142
+
143
+ OrderService -->|"publish event"| Queue[(Bull Queue)]
144
+ Queue -->|"consume"| EmailWorker
145
+ Queue -->|"consume"| InAppWorker
146
+ EmailWorker -->|"send"| SendGrid[SendGrid API]
147
+ InAppWorker -->|"write"| DB[(Database)]
148
+ NotifController -->|"read"| DB
149
+ PrefsController -->|"read/write"| DB
150
+ ​```
151
+
152
+ ## API Endpoints
153
+ - GET /api/notifications — list user notifications (paginated)
154
+ - PATCH /api/notifications/:id/read — mark as read
155
+ - GET /api/preferences/notifications — get preferences
156
+ - PUT /api/preferences/notifications — update preferences
157
+ ```
158
+
159
+ ---
160
+
161
+ ## Step 6: Implementation Plan
162
+
163
+ ```markdown
164
+ # Implementation Plan
165
+
166
+ ## Tasks
167
+
168
+ TASK-1: Create Notification model + migration
169
+ Files: models/notification.ts, migrations/add-notifications.ts
170
+ Depends: none
171
+ Test: Migration runs, model validates
172
+
173
+ TASK-2: Create NotificationPreference model + migration
174
+ Files: models/notification-preference.ts, migrations/add-notification-prefs.ts
175
+ Depends: none
176
+ Test: Migration runs, defaults created for existing users
177
+
178
+ TASK-3: Create NotificationService
179
+ Files: services/notification.service.ts
180
+ Depends: TASK-1, TASK-2
181
+ Test: Unit tests for create/read/mark-read/filter-by-prefs
182
+
183
+ TASK-4: Create notification workers
184
+ Files: workers/email-notification.worker.ts, workers/in-app-notification.worker.ts
185
+ Depends: TASK-3
186
+ Test: Worker processes event, creates notification, sends email mock
187
+
188
+ TASK-5: Add event publishing to OrderService
189
+ Files: services/order.service.ts (modify)
190
+ Depends: TASK-4
191
+ Test: Order status change publishes notification event
192
+
193
+ TASK-6: Create API endpoints
194
+ Files: controllers/notification.controller.ts, controllers/preferences.controller.ts
195
+ Depends: TASK-3
196
+ Test: API returns notifications, updates preferences
197
+
198
+ TASK-7: Write integration tests
199
+ Files: tests/notifications.integration.test.ts
200
+ Depends: TASK-4, TASK-5, TASK-6
201
+ Test: Full flow: order change → event → worker → notification visible via API
202
+
203
+ ## Parallel Groups
204
+ Group 1: TASK-1, TASK-2 (parallel)
205
+ Group 2: TASK-3 (after Group 1)
206
+ Group 3: TASK-4, TASK-5, TASK-6 (parallel, after Group 2)
207
+ Group 4: TASK-7 (after Group 3)
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Step 8: QE Report
213
+
214
+ ```markdown
215
+ # QE Report: User Notifications
216
+
217
+ ## Summary
218
+ - Tests: 14/14 (100%)
219
+ - Review findings: 0 🔴, 2 🟡, 1 🔵
220
+ - Requirements: 3/3 MUST passed, 1/1 SHOULD passed
221
+
222
+ ## Review Findings
223
+ 🟡 WARNING: NotificationService.create() doesn't validate notification type enum
224
+ 🟡 WARNING: Email template uses inline styles instead of project's template engine
225
+ 🔵 SUGGESTION: Consider adding index on notifications.user_id + created_at
226
+
227
+ ## Acceptance Criteria
228
+ | Req | Status | Evidence |
229
+ |-----|--------|----------|
230
+ | FR-1 | ✅ PASS | Integration test: order_status_email_notification |
231
+ | FR-2 | ✅ PASS | Integration test: in_app_notification_created |
232
+ | FR-3 | ✅ PASS | Unit test: filters_by_user_preferences |
233
+ | FR-4 | ✅ PASS | API test: paginated_notification_history |
234
+
235
+ ## Verdict
236
+ ⚠️ CONDITIONAL APPROVAL — fix 2 warnings before merge
237
+ ```
238
+
239
+ ---
240
+
241
+ ## Final Directory Structure
242
+
243
+ ```
244
+ features/add-user-notifications/
245
+ ├── 00_complexity_assessment.md
246
+ ├── 01_requirements.md
247
+ ├── 03_adr/
248
+ │ └── 001-notification-delivery-strategy.md
249
+ ├── 05_architecture.md
250
+ ├── 06_implementation_plan.md
251
+ ├── 07_code_changes/
252
+ │ └── change_manifest.md
253
+ ├── 08_qe_report.md
254
+ ├── diagrams/
255
+ │ └── architecture-c4.mermaid
256
+ └── README.md
257
+ ```
@@ -0,0 +1,114 @@
1
+ # Step 0: Complexity Router
2
+
3
+ > Classify the feature into S/M/L/XL tier and determine which pipeline steps to activate.
4
+
5
+ ## When
6
+
7
+ Always runs first. Takes ~30 seconds. Uses haiku model.
8
+
9
+ ## Input
10
+
11
+ - Feature description (from user or issue)
12
+ - Current codebase context (project structure, tech stack)
13
+
14
+ ## Protocol
15
+
16
+ ### 1. Analyze Feature Scope
17
+
18
+ Evaluate the feature against 6 dimensions:
19
+
20
+ | Dimension | S (1pt) | M (2pt) | L (3pt) | XL (4pt) |
21
+ |-----------|---------|---------|---------|----------|
22
+ | **Files affected** | 1-3 | 4-10 | 11-30 | 30+ |
23
+ | **Domains touched** | 1 | 1-2 | 2-4 | 4+ |
24
+ | **New integrations** | 0 | 0-1 | 1-3 | 3+ |
25
+ | **Breaking changes** | 0 | 0 | 0-2 | 2+ |
26
+ | **New data models** | 0 | 0-1 | 1-3 | 3+ |
27
+ | **Cross-cutting concerns** | 0 | 0-1 | 1-2 | 3+ |
28
+
29
+ Cross-cutting concerns: auth, logging, caching, i18n, error handling, etc.
30
+
31
+ ### 2. Score and Classify
32
+
33
+ Sum all dimension scores:
34
+
35
+ | Total Score | Tier | Label |
36
+ |-------------|------|-------|
37
+ | 6-8 | **S** | Small — localized change |
38
+ | 9-13 | **M** | Medium — bounded feature |
39
+ | 14-19 | **L** | Large — multi-domain feature |
40
+ | 20-24 | **XL** | Extra Large — cross-cutting system change |
41
+
42
+ ### 3. Override Rules
43
+
44
+ The router may override the score-based classification:
45
+
46
+ - If **any single dimension = XL (4pt)** → minimum tier is L
47
+ - If **breaking changes > 0** → minimum tier is M
48
+ - If user explicitly requests a tier → use that tier
49
+ - If feature description mentions "refactor", "migration", "redesign" → bias toward L/XL
50
+
51
+ ### 4. Determine Active Steps
52
+
53
+ Load `references/complexity-matrix.md` for the full matrix. Summary:
54
+
55
+ | Step | S | M | L | XL |
56
+ |------|---|---|---|-----|
57
+ | 0 Complexity Router | ✓ | ✓ | ✓ | ✓ |
58
+ | 1 Requirements | ✓ light | ✓ | ✓ | ✓ |
59
+ | 2 Research | - | - | ✓ | ✓ |
60
+ | 3 ADR | - | ✓ (1 ADR) | ✓ (N ADRs) | ✓ (N ADRs) |
61
+ | 4 DDD | - | - | ✓ | ✓ |
62
+ | 5 Architecture | - | ✓ light | ✓ | ✓ |
63
+ | 6 Implementation Plan | ✓ inline | ✓ | ✓ | ✓ |
64
+ | 7 Code | ✓ | ✓ | ✓ | ✓ |
65
+ | 8 QE | ✓ smoke | ✓ | ✓ | ✓ full |
66
+
67
+ ### 5. Calculate Time Budget
68
+
69
+ | Tier | Total Budget | Distribution |
70
+ |------|-------------|--------------|
71
+ | S | 15 min | R:2 P:0 I:10 Q:3 |
72
+ | M | 45 min | R:5 P:10 I:20 Q:10 |
73
+ | L | 2 hours | R:15 P:30 I:45 Q:30 |
74
+ | XL | 4+ hours | R:30 P:60 I:90 Q:60 |
75
+
76
+ R = Requirements, P = Planning (ADR+DDD+Arch), I = Implementation, Q = QE
77
+
78
+ ## Output
79
+
80
+ Set the following variables:
81
+
82
+ ```
83
+ {COMPLEXITY_TIER} = S | M | L | XL
84
+ {ACTIVE_STEPS} = [0, 1, 6, 7, 8] # example for S
85
+ {TIME_BUDGET} = { requirements: 2, planning: 0, implementation: 10, qe: 3 }
86
+ {DIMENSION_SCORES} = { files: 1, domains: 1, integrations: 1, breaking: 1, models: 1, crosscutting: 1 }
87
+ ```
88
+
89
+ Create artifact: `features/<slug>/00_complexity_assessment.md`
90
+
91
+ ## Checkpoint 0 Format
92
+
93
+ ```
94
+ ═══════════════════════════════════════════════════════
95
+ ⏸️ STEP 0/8: Complexity Router Complete
96
+ <promise>FEATURE_ADR_ROUTED</promise>
97
+ Tier: {COMPLEXITY_TIER} | Active Steps: {ACTIVE_STEPS}
98
+
99
+ Feature classified as {TIER} based on: {top 2-3 scoring dimensions}
100
+ Pipeline: {ACTIVE_STEPS count} steps, estimated {TIME_BUDGET total}
101
+
102
+ • "ок" — proceed with this tier
103
+ • "повысь" — bump to next tier
104
+ • "понизь" — drop to lower tier
105
+ ═══════════════════════════════════════════════════════
106
+ ```
107
+
108
+ ## Quality Gates
109
+
110
+ - [ ] All 6 dimensions evaluated with explicit reasoning
111
+ - [ ] Override rules checked
112
+ - [ ] Active steps list matches tier definition
113
+ - [ ] Time budget calculated
114
+ - [ ] User confirmed tier before proceeding