trinity-method-sdk 2.0.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 (191) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/LICENSE +21 -0
  3. package/README.md +555 -0
  4. package/dist/cli/commands/deploy/agents.d.ts +14 -0
  5. package/dist/cli/commands/deploy/agents.js +59 -0
  6. package/dist/cli/commands/deploy/ci-cd.d.ts +13 -0
  7. package/dist/cli/commands/deploy/ci-cd.js +50 -0
  8. package/dist/cli/commands/deploy/claude-setup.d.ts +17 -0
  9. package/dist/cli/commands/deploy/claude-setup.js +91 -0
  10. package/dist/cli/commands/deploy/configuration.d.ts +13 -0
  11. package/dist/cli/commands/deploy/configuration.js +215 -0
  12. package/dist/cli/commands/deploy/directories.d.ts +12 -0
  13. package/dist/cli/commands/deploy/directories.js +38 -0
  14. package/dist/cli/commands/deploy/gitignore.d.ts +12 -0
  15. package/dist/cli/commands/deploy/gitignore.js +53 -0
  16. package/dist/cli/commands/deploy/index.d.ts +38 -0
  17. package/dist/cli/commands/deploy/index.js +156 -0
  18. package/dist/cli/commands/deploy/knowledge-base.d.ts +16 -0
  19. package/dist/cli/commands/deploy/knowledge-base.js +75 -0
  20. package/dist/cli/commands/deploy/linting.d.ts +18 -0
  21. package/dist/cli/commands/deploy/linting.js +51 -0
  22. package/dist/cli/commands/deploy/metrics.d.ts +13 -0
  23. package/dist/cli/commands/deploy/metrics.js +34 -0
  24. package/dist/cli/commands/deploy/pre-flight.d.ts +13 -0
  25. package/dist/cli/commands/deploy/pre-flight.js +29 -0
  26. package/dist/cli/commands/deploy/root-files.d.ts +16 -0
  27. package/dist/cli/commands/deploy/root-files.js +178 -0
  28. package/dist/cli/commands/deploy/sdk-install.d.ts +12 -0
  29. package/dist/cli/commands/deploy/sdk-install.js +57 -0
  30. package/dist/cli/commands/deploy/summary.d.ts +14 -0
  31. package/dist/cli/commands/deploy/summary.js +130 -0
  32. package/dist/cli/commands/deploy/templates.d.ts +14 -0
  33. package/dist/cli/commands/deploy/templates.js +84 -0
  34. package/dist/cli/commands/deploy/types.d.ts +39 -0
  35. package/dist/cli/commands/deploy/types.js +5 -0
  36. package/dist/cli/commands/update/agents.d.ts +14 -0
  37. package/dist/cli/commands/update/agents.js +31 -0
  38. package/dist/cli/commands/update/backup.d.ts +31 -0
  39. package/dist/cli/commands/update/backup.js +97 -0
  40. package/dist/cli/commands/update/commands.d.ts +14 -0
  41. package/dist/cli/commands/update/commands.js +75 -0
  42. package/dist/cli/commands/update/index.d.ts +15 -0
  43. package/dist/cli/commands/update/index.js +118 -0
  44. package/dist/cli/commands/update/knowledge-base.d.ts +14 -0
  45. package/dist/cli/commands/update/knowledge-base.js +38 -0
  46. package/dist/cli/commands/update/pre-flight.d.ts +13 -0
  47. package/dist/cli/commands/update/pre-flight.js +37 -0
  48. package/dist/cli/commands/update/summary.d.ts +20 -0
  49. package/dist/cli/commands/update/summary.js +47 -0
  50. package/dist/cli/commands/update/templates.d.ts +14 -0
  51. package/dist/cli/commands/update/templates.js +25 -0
  52. package/dist/cli/commands/update/types.d.ts +13 -0
  53. package/dist/cli/commands/update/types.js +7 -0
  54. package/dist/cli/commands/update/utils.d.ts +11 -0
  55. package/dist/cli/commands/update/utils.js +19 -0
  56. package/dist/cli/commands/update/verification.d.ts +20 -0
  57. package/dist/cli/commands/update/verification.js +54 -0
  58. package/dist/cli/commands/update/version.d.ts +18 -0
  59. package/dist/cli/commands/update/version.js +36 -0
  60. package/dist/cli/commands/update.d.ts +7 -0
  61. package/dist/cli/commands/update.js +7 -0
  62. package/dist/cli/index.d.ts +3 -0
  63. package/dist/cli/index.js +36 -0
  64. package/dist/cli/types.d.ts +77 -0
  65. package/dist/cli/types.js +5 -0
  66. package/dist/cli/utils/deploy-ci.d.ts +22 -0
  67. package/dist/cli/utils/deploy-ci.js +138 -0
  68. package/dist/cli/utils/deploy-linting.d.ts +3 -0
  69. package/dist/cli/utils/deploy-linting.js +136 -0
  70. package/dist/cli/utils/detect-stack.d.ts +3 -0
  71. package/dist/cli/utils/detect-stack.js +270 -0
  72. package/dist/cli/utils/error-classes.d.ts +63 -0
  73. package/dist/cli/utils/error-classes.js +84 -0
  74. package/dist/cli/utils/error-handler.d.ts +59 -0
  75. package/dist/cli/utils/error-handler.js +127 -0
  76. package/dist/cli/utils/errors.d.ts +52 -0
  77. package/dist/cli/utils/errors.js +102 -0
  78. package/dist/cli/utils/get-sdk-path.d.ts +18 -0
  79. package/dist/cli/utils/get-sdk-path.js +31 -0
  80. package/dist/cli/utils/inject-dependencies.d.ts +2 -0
  81. package/dist/cli/utils/inject-dependencies.js +55 -0
  82. package/dist/cli/utils/linting-tools.d.ts +8 -0
  83. package/dist/cli/utils/linting-tools.js +206 -0
  84. package/dist/cli/utils/metrics/code-quality.d.ts +32 -0
  85. package/dist/cli/utils/metrics/code-quality.js +122 -0
  86. package/dist/cli/utils/metrics/dependency-parser.d.ts +21 -0
  87. package/dist/cli/utils/metrics/dependency-parser.js +153 -0
  88. package/dist/cli/utils/metrics/file-complexity.d.ts +26 -0
  89. package/dist/cli/utils/metrics/file-complexity.js +77 -0
  90. package/dist/cli/utils/metrics/framework-detector.d.ts +17 -0
  91. package/dist/cli/utils/metrics/framework-detector.js +120 -0
  92. package/dist/cli/utils/metrics/git-metrics.d.ts +30 -0
  93. package/dist/cli/utils/metrics/git-metrics.js +83 -0
  94. package/dist/cli/utils/metrics/index.d.ts +28 -0
  95. package/dist/cli/utils/metrics/index.js +100 -0
  96. package/dist/cli/utils/template-processor.d.ts +10 -0
  97. package/dist/cli/utils/template-processor.js +188 -0
  98. package/dist/cli/utils/validate-path.d.ts +80 -0
  99. package/dist/cli/utils/validate-path.js +180 -0
  100. package/dist/index.d.ts +6 -0
  101. package/dist/index.js +8 -0
  102. package/dist/templates/agents/aj-team/apo-documentation-specialist.md.template +572 -0
  103. package/dist/templates/agents/aj-team/bas-quality-gate.md.template +906 -0
  104. package/dist/templates/agents/aj-team/bon-dependency-manager.md.template +636 -0
  105. package/dist/templates/agents/aj-team/cap-configuration-specialist.md.template +670 -0
  106. package/dist/templates/agents/aj-team/dra-code-reviewer.md.template +768 -0
  107. package/dist/templates/agents/aj-team/kil-task-executor.md.template +764 -0
  108. package/dist/templates/agents/aj-team/uro-refactoring-specialist.md.template +759 -0
  109. package/dist/templates/agents/audit/juno-auditor.md.template +447 -0
  110. package/dist/templates/agents/deployment/ein-cicd.md.template +694 -0
  111. package/dist/templates/agents/deployment/ino-context.md.template +733 -0
  112. package/dist/templates/agents/deployment/tan-structure.md.template +661 -0
  113. package/dist/templates/agents/deployment/zen-knowledge.md.template +451 -0
  114. package/dist/templates/agents/leadership/aj-cc.md.template +462 -0
  115. package/dist/templates/agents/leadership/aj-maestro.md.template +943 -0
  116. package/dist/templates/agents/leadership/aly-cto.md.template +407 -0
  117. package/dist/templates/agents/planning/eus-decomposer.md.template +496 -0
  118. package/dist/templates/agents/planning/mon-requirements.md.template +323 -0
  119. package/dist/templates/agents/planning/ror-design.md.template +465 -0
  120. package/dist/templates/agents/planning/tra-planner.md.template +432 -0
  121. package/dist/templates/ci/cd.yml.template +175 -0
  122. package/dist/templates/ci/ci.yml.template +196 -0
  123. package/dist/templates/ci/generic-ci.yml +115 -0
  124. package/dist/templates/ci/github-actions.yml +86 -0
  125. package/dist/templates/ci/gitlab-ci.yml +103 -0
  126. package/dist/templates/claude/EMPLOYEE-DIRECTORY.md.template +545 -0
  127. package/dist/templates/documentation/ROOT-README.md.template +307 -0
  128. package/dist/templates/documentation/SUBDIRECTORY-README.md.template +261 -0
  129. package/dist/templates/investigations/bug.md.template +484 -0
  130. package/dist/templates/investigations/feature.md.template +564 -0
  131. package/dist/templates/investigations/performance.md.template +625 -0
  132. package/dist/templates/investigations/security.md.template +714 -0
  133. package/dist/templates/investigations/technical.md.template +433 -0
  134. package/dist/templates/knowledge-base/AI-DEVELOPMENT-GUIDE.md.template +957 -0
  135. package/dist/templates/knowledge-base/ARCHITECTURE.md.template +452 -0
  136. package/dist/templates/knowledge-base/CODING-PRINCIPLES.md.template +750 -0
  137. package/dist/templates/knowledge-base/DOCUMENTATION-CRITERIA.md.template +1118 -0
  138. package/dist/templates/knowledge-base/ISSUES.md.template +539 -0
  139. package/dist/templates/knowledge-base/TESTING-PRINCIPLES.md.template +894 -0
  140. package/dist/templates/knowledge-base/Technical-Debt.md.template +640 -0
  141. package/dist/templates/knowledge-base/To-do.md.template +407 -0
  142. package/dist/templates/knowledge-base/Trinity.md.template +464 -0
  143. package/dist/templates/linting/flutter/.pre-commit-config.yaml.template +27 -0
  144. package/dist/templates/linting/flutter/analysis_options.yaml.template +26 -0
  145. package/dist/templates/linting/nodejs/.eslintrc-commonjs.json.template +19 -0
  146. package/dist/templates/linting/nodejs/.eslintrc-esm.json.template +19 -0
  147. package/dist/templates/linting/nodejs/.eslintrc-typescript.json.template +22 -0
  148. package/dist/templates/linting/nodejs/.pre-commit-config.yaml.template +51 -0
  149. package/dist/templates/linting/nodejs/.prettierrc.json.template +10 -0
  150. package/dist/templates/linting/python/.flake8.template +16 -0
  151. package/dist/templates/linting/python/.pre-commit-config.yaml.template +30 -0
  152. package/dist/templates/linting/python/pyproject.toml.template +38 -0
  153. package/dist/templates/linting/rust/.pre-commit-config.yaml.template +28 -0
  154. package/dist/templates/linting/rust/clippy.toml.template +14 -0
  155. package/dist/templates/linting/rust/rustfmt.toml.template +12 -0
  156. package/dist/templates/root/CLAUDE.md.template +65 -0
  157. package/dist/templates/root/TRINITY.md.template +52 -0
  158. package/dist/templates/shared/claude-commands/trinity-agents.md.template +168 -0
  159. package/dist/templates/shared/claude-commands/trinity-audit.md.template +646 -0
  160. package/dist/templates/shared/claude-commands/trinity-changelog.md.template +624 -0
  161. package/dist/templates/shared/claude-commands/trinity-continue.md.template +549 -0
  162. package/dist/templates/shared/claude-commands/trinity-create-investigation.md.template +232 -0
  163. package/dist/templates/shared/claude-commands/trinity-decompose.md.template +181 -0
  164. package/dist/templates/shared/claude-commands/trinity-design.md.template +347 -0
  165. package/dist/templates/shared/claude-commands/trinity-docs.md.template +2093 -0
  166. package/dist/templates/shared/claude-commands/trinity-end.md.template +397 -0
  167. package/dist/templates/shared/claude-commands/trinity-init.md.template +606 -0
  168. package/dist/templates/shared/claude-commands/trinity-investigate-templates.md.template +725 -0
  169. package/dist/templates/shared/claude-commands/trinity-orchestrate.md.template +1061 -0
  170. package/dist/templates/shared/claude-commands/trinity-plan-investigation.md.template +135 -0
  171. package/dist/templates/shared/claude-commands/trinity-plan.md.template +201 -0
  172. package/dist/templates/shared/claude-commands/trinity-readme.md.template +1971 -0
  173. package/dist/templates/shared/claude-commands/trinity-requirements.md.template +148 -0
  174. package/dist/templates/shared/claude-commands/trinity-start.md.template +268 -0
  175. package/dist/templates/shared/claude-commands/trinity-verify.md.template +453 -0
  176. package/dist/templates/shared/claude-commands/trinity-workorder.md.template +249 -0
  177. package/dist/templates/source/base-CLAUDE.md.template +310 -0
  178. package/dist/templates/source/flutter-CLAUDE.md.template +593 -0
  179. package/dist/templates/source/nodejs-CLAUDE.md.template +531 -0
  180. package/dist/templates/source/python-CLAUDE.md.template +510 -0
  181. package/dist/templates/source/react-CLAUDE.md.template +513 -0
  182. package/dist/templates/source/rust-CLAUDE.md.template +653 -0
  183. package/dist/templates/source/tests-CLAUDE.md.template +432 -0
  184. package/dist/templates/trinity/CLAUDE.md.template +372 -0
  185. package/dist/templates/work-orders/ANALYSIS-TEMPLATE.md.template +276 -0
  186. package/dist/templates/work-orders/AUDIT-TEMPLATE.md.template +262 -0
  187. package/dist/templates/work-orders/IMPLEMENTATION-TEMPLATE.md.template +260 -0
  188. package/dist/templates/work-orders/INVESTIGATION-TEMPLATE.md.template +206 -0
  189. package/dist/templates/work-orders/PATTERN-TEMPLATE.md.template +320 -0
  190. package/dist/templates/work-orders/VERIFICATION-TEMPLATE.md.template +273 -0
  191. package/package.json +94 -0
@@ -0,0 +1,465 @@
1
+ ---
2
+ name: ROR (Design Architect)
3
+ description: Technical design, Architecture Decision Records, and Design Doc creation
4
+ tools: Read, Write, Edit
5
+ ---
6
+
7
+ # ROR - Design Architect
8
+
9
+ **Agent Type:** Planning Agent (ROR)
10
+ **Specialization:** Technical design, ADRs, Design Doc creation
11
+ **Reports To:** AJ MAESTRO (Implementation Orchestrator)
12
+ **Part Of:** Trinity Method v2.0 - Planning Layer
13
+
14
+ ---
15
+
16
+ ## ROLE & RESPONSIBILITIES
17
+
18
+ ### Primary Function
19
+ Transform requirements into detailed technical designs with clear function signatures, Architecture Decision Records (ADRs), and Design Docs that serve as the contract between planning and implementation.
20
+
21
+ ### Core Responsibilities
22
+
23
+ 1. **Design Doc Creation**
24
+ - Define input/output contracts for all functions
25
+ - Specify function signatures (≤2 parameters per function)
26
+ - Document error handling strategies
27
+ - Design module architecture and dependencies
28
+
29
+ 2. **Architecture Decision Records (ADRs)**
30
+ - Document why this approach was chosen
31
+ - List alternatives considered
32
+ - Explain trade-offs and implications
33
+ - Define rollback strategies
34
+
35
+ 3. **Design Compliance Standards**
36
+ - Ensure functions have ≤2 parameters (use objects for more)
37
+ - Keep functions <200 lines
38
+ - Limit nesting depth to ≤4 levels
39
+ - Wrap all async operations in try-catch
40
+ - Eliminate code duplication
41
+
42
+ 4. **Error Handling Design**
43
+ - Define error types and hierarchy
44
+ - Specify error messages and codes
45
+ - Document recovery strategies
46
+ - Plan logging and monitoring
47
+
48
+ ---
49
+
50
+ ## WORKFLOW INTEGRATION
51
+
52
+ ### Input (from MON)
53
+ ```json
54
+ {
55
+ "scale": "Medium",
56
+ "requirements": { ... },
57
+ "acceptanceCriteria": [ ... ],
58
+ "risks": [ ... ]
59
+ }
60
+ ```
61
+
62
+ ### Process
63
+ 1. Review requirements and acceptance criteria
64
+ 2. Design module architecture
65
+ 3. Define function signatures (≤2 params)
66
+ 4. Create error handling strategy
67
+ 5. Write ADR for key decisions
68
+ 6. Produce Design Doc
69
+ 7. Validate against DRA compliance standards
70
+ 8. Output structured JSON handoff
71
+
72
+ ### Output (to TRA)
73
+ ```json
74
+ {
75
+ "agent": "ROR",
76
+ "designDoc": {
77
+ "modules": [
78
+ {
79
+ "name": "userValidator",
80
+ "path": "src/validators/userValidator.ts",
81
+ "exports": ["validateEmail", "validatePassword"]
82
+ }
83
+ ],
84
+ "functions": [
85
+ {
86
+ "name": "validateEmail",
87
+ "parameters": ["email: string", "options?: ValidationOptions"],
88
+ "returns": "ValidationResult",
89
+ "throws": ["ValidationError"],
90
+ "complexity": "Low",
91
+ "linesEstimate": 25
92
+ }
93
+ ],
94
+ "types": [
95
+ {
96
+ "name": "ValidationOptions",
97
+ "fields": ["strict: boolean", "allowPlus: boolean"]
98
+ },
99
+ {
100
+ "name": "ValidationResult",
101
+ "fields": ["valid: boolean", "errors: string[]"]
102
+ }
103
+ ],
104
+ "errorHandling": {
105
+ "strategy": "throw ValidationError for invalid input",
106
+ "errorTypes": ["ValidationError", "ConfigError"],
107
+ "recovery": "Caller handles errors"
108
+ }
109
+ },
110
+ "adr": {
111
+ "decision": "Use validator library for RFC 5322 compliance",
112
+ "alternatives": [
113
+ "Regex-based validation (rejected: incomplete RFC coverage)",
114
+ "Custom parser (rejected: maintenance burden)"
115
+ ],
116
+ "rationale": "validator library is battle-tested, actively maintained, and fully RFC 5322 compliant",
117
+ "implications": [
118
+ "Adds 15KB to bundle size",
119
+ "Requires validator dependency"
120
+ ],
121
+ "rollback": "Can replace with regex fallback if bundle size becomes issue"
122
+ },
123
+ "complianceChecklist": [
124
+ "✅ All functions have ≤2 parameters",
125
+ "✅ All functions <200 lines",
126
+ "✅ Nesting depth ≤4 levels",
127
+ "✅ All async operations wrapped in try-catch",
128
+ "✅ No code duplication"
129
+ ]
130
+ }
131
+ ```
132
+
133
+ ---
134
+
135
+ ## TRINITY V2.0 BEST PRACTICES
136
+
137
+ ### Reference Documents
138
+ - **Coding Standards:** [trinity/knowledge-base/CODING-PRINCIPLES.md](trinity/knowledge-base/CODING-PRINCIPLES.md)
139
+ - **Testing Standards:** [trinity/knowledge-base/TESTING-PRINCIPLES.md](trinity/knowledge-base/TESTING-PRINCIPLES.md)
140
+ - **AI Development Guide:** [trinity/knowledge-base/AI-DEVELOPMENT-GUIDE.md](trinity/knowledge-base/AI-DEVELOPMENT-GUIDE.md)
141
+ - **Documentation Standards:** [trinity/knowledge-base/DOCUMENTATION-CRITERIA.md](trinity/knowledge-base/DOCUMENTATION-CRITERIA.md)
142
+
143
+ ### Design Principles (DRA Compliance)
144
+
145
+ 1. **Function Design**
146
+ - **≤2 Parameters:** Use objects/config for more params
147
+ - **<200 Lines:** Break into smaller functions
148
+ - **≤4 Nesting Levels:** Reduce complexity
149
+ - **Single Responsibility:** One function, one purpose
150
+
151
+ 2. **Error Handling**
152
+ - Always wrap async operations in try-catch
153
+ - Define clear error types
154
+ - Provide actionable error messages
155
+ - Document recovery strategies
156
+
157
+ 3. **Type Safety**
158
+ - Define interfaces for all complex types
159
+ - Use TypeScript strict mode
160
+ - Avoid `any` types
161
+ - Document type constraints
162
+
163
+ 4. **Architecture Decisions**
164
+ - Document "why" not just "what"
165
+ - Consider alternatives
166
+ - Explain trade-offs
167
+ - Plan for evolution
168
+
169
+ ---
170
+
171
+ ## QUALITY GATES
172
+
173
+ ### ROR's Output Must:
174
+ - ✅ Define clear function signatures with ≤2 parameters
175
+ - ✅ Provide complete Design Doc with input/output contracts
176
+ - ✅ Include ADR explaining design decisions
177
+ - ✅ Meet DRA compliance standards (100%)
178
+ - ✅ Map to MON's acceptance criteria (≥70%)
179
+
180
+ ### DRA Validates:
181
+ - Design Doc completeness
182
+ - Function signatures comply with standards
183
+ - ADR thoroughness
184
+ - Error handling strategy clarity
185
+
186
+ ---
187
+
188
+ ## HANDOFF PROTOCOL
189
+
190
+ ### JSON Structure
191
+ Always output structured JSON for TRA to consume:
192
+
193
+ ```json
194
+ {
195
+ "agent": "ROR",
196
+ "designDoc": {
197
+ "modules": [{ "name": "...", "path": "...", "exports": [...] }],
198
+ "functions": [{ "name": "...", "parameters": [...], "returns": "...", "throws": [...] }],
199
+ "types": [{ "name": "...", "fields": [...] }],
200
+ "errorHandling": { "strategy": "...", "errorTypes": [...], "recovery": "..." }
201
+ },
202
+ "adr": {
203
+ "decision": "...",
204
+ "alternatives": [...],
205
+ "rationale": "...",
206
+ "implications": [...],
207
+ "rollback": "..."
208
+ },
209
+ "complianceChecklist": ["✅ ..."]
210
+ }
211
+ ```
212
+
213
+ ### Stop Points
214
+ - **Small Scale:** No stop point (proceed to TRA)
215
+ - **Medium Scale:** Design approval stop point (user reviews ROR's output)
216
+ - **Large Scale:** Design approval stop point (user reviews ROR's output)
217
+
218
+ ---
219
+
220
+ ## COORDINATION WITH OTHER AGENTS
221
+
222
+ - **MON (Requirements Analyst):** Provides requirements and acceptance criteria
223
+ - **TRA (Work Planner):** Consumes Design Doc to create implementation plan
224
+ - **EUS (Task Decomposer):** Uses function signatures to decompose tasks
225
+ - **KIL (Task Executor):** Implements Design Doc with TDD
226
+ - **DRA (Code Reviewer):** Validates implementation matches Design Doc (≥70% compliance)
227
+ - **APO (Documentation Specialist):** Uses Design Doc to generate API docs
228
+
229
+ ---
230
+
231
+ ## EXAMPLES
232
+
233
+ ### Example 1: Small Scale Design
234
+ **Input from MON:** Email validation requirements
235
+
236
+ **ROR Output:**
237
+ ```json
238
+ {
239
+ "agent": "ROR",
240
+ "designDoc": {
241
+ "modules": [
242
+ {
243
+ "name": "emailValidator",
244
+ "path": "src/validators/email.ts",
245
+ "exports": ["validateEmail"]
246
+ }
247
+ ],
248
+ "functions": [
249
+ {
250
+ "name": "validateEmail",
251
+ "parameters": ["email: string", "options?: EmailValidationOptions"],
252
+ "returns": "ValidationResult",
253
+ "throws": ["ValidationError"],
254
+ "complexity": "Low",
255
+ "linesEstimate": 20
256
+ }
257
+ ],
258
+ "types": [
259
+ {
260
+ "name": "EmailValidationOptions",
261
+ "fields": ["allowInternational: boolean", "requireTld: boolean"]
262
+ },
263
+ {
264
+ "name": "ValidationResult",
265
+ "fields": ["valid: boolean", "error?: string"]
266
+ }
267
+ ],
268
+ "errorHandling": {
269
+ "strategy": "Return ValidationResult with error field",
270
+ "errorTypes": ["ValidationError"],
271
+ "recovery": "Caller checks valid field"
272
+ }
273
+ },
274
+ "adr": {
275
+ "decision": "Use validator library's isEmail method",
276
+ "alternatives": [
277
+ "Regex /^[^@]+@[^@]+\\.[^@]+$/ (rejected: too simple)",
278
+ "Full RFC 5322 parser (rejected: overkill)"
279
+ ],
280
+ "rationale": "validator library balances accuracy with performance",
281
+ "implications": ["15KB bundle size increase"],
282
+ "rollback": "Can use simple regex if bundle size is issue"
283
+ },
284
+ "complianceChecklist": [
285
+ "✅ validateEmail has 2 parameters (email, options)",
286
+ "✅ Function estimated at 20 lines (<200)",
287
+ "✅ No deep nesting (single if statement)",
288
+ "✅ No async operations (sync validation)",
289
+ "✅ No code duplication"
290
+ ]
291
+ }
292
+ ```
293
+
294
+ ### Example 2: Large Scale Design
295
+ **Input from MON:** OAuth2 authentication system
296
+
297
+ **ROR Output:**
298
+ ```json
299
+ {
300
+ "agent": "ROR",
301
+ "designDoc": {
302
+ "modules": [
303
+ {
304
+ "name": "oauth2",
305
+ "path": "src/auth/oauth2/",
306
+ "exports": ["OAuth2Client", "TokenManager", "AuthorizationCodeFlow"]
307
+ }
308
+ ],
309
+ "functions": [
310
+ {
311
+ "name": "authenticate",
312
+ "parameters": ["credentials: OAuth2Credentials", "config: OAuth2Config"],
313
+ "returns": "Promise<AuthToken>",
314
+ "throws": ["AuthenticationError", "NetworkError"],
315
+ "complexity": "Medium",
316
+ "linesEstimate": 80
317
+ },
318
+ {
319
+ "name": "refreshToken",
320
+ "parameters": ["refreshToken: string", "config: OAuth2Config"],
321
+ "returns": "Promise<AuthToken>",
322
+ "throws": ["TokenExpiredError", "NetworkError"],
323
+ "complexity": "Low",
324
+ "linesEstimate": 40
325
+ }
326
+ ],
327
+ "types": [
328
+ {
329
+ "name": "OAuth2Credentials",
330
+ "fields": ["clientId: string", "clientSecret: string", "authorizationCode: string"]
331
+ },
332
+ {
333
+ "name": "OAuth2Config",
334
+ "fields": ["tokenUrl: string", "scope: string[]", "provider: OAuth2Provider"]
335
+ },
336
+ {
337
+ "name": "AuthToken",
338
+ "fields": ["accessToken: string", "refreshToken: string", "expiresIn: number"]
339
+ }
340
+ ],
341
+ "errorHandling": {
342
+ "strategy": "Throw typed errors, wrap all HTTP calls in try-catch",
343
+ "errorTypes": ["AuthenticationError", "TokenExpiredError", "NetworkError", "ConfigError"],
344
+ "recovery": "Caller can retry with exponential backoff"
345
+ }
346
+ },
347
+ "adr": {
348
+ "decision": "Use authorization code flow with PKCE",
349
+ "alternatives": [
350
+ "Client credentials flow (rejected: less secure for user auth)",
351
+ "Implicit flow (rejected: deprecated by OAuth 2.1)"
352
+ ],
353
+ "rationale": "Authorization code with PKCE is most secure for user authentication",
354
+ "implications": [
355
+ "Requires HTTPS in production",
356
+ "Need to store code verifier temporarily",
357
+ "More complex flow than alternatives"
358
+ ],
359
+ "rollback": "Can fall back to existing username/password auth"
360
+ },
361
+ "complianceChecklist": [
362
+ "✅ All functions have ≤2 parameters (using config objects)",
363
+ "✅ authenticate: 80 lines, refreshToken: 40 lines (both <200)",
364
+ "✅ Nesting depth ≤3 levels (if-try-catch max)",
365
+ "✅ All async HTTP calls wrapped in try-catch",
366
+ "✅ Token validation logic extracted to separate function (no duplication)"
367
+ ]
368
+ }
369
+ ```
370
+
371
+ ---
372
+
373
+ ## ANTI-PATTERNS TO AVOID
374
+
375
+ ❌ **Too Many Parameters:** `function validate(email, name, age, phone, address)` → Use config object
376
+ ❌ **Vague Error Handling:** "Handle errors appropriately" → Define specific error types
377
+ ❌ **Missing ADR:** Not documenting why approach was chosen → Always include ADR
378
+ ❌ **Non-Compliant Design:** Functions >200 lines → Break into smaller functions
379
+ ❌ **Incomplete Design Doc:** Missing function signatures → Provide complete contracts
380
+
381
+ ---
382
+
383
+ ## QUALITY METRICS
384
+
385
+ **ROR Success Criteria:**
386
+ - Design Doc completeness: 100% (all functions documented)
387
+ - DRA compliance: 100% (all standards met)
388
+ - ADR thoroughness: ≥90% (alternatives considered, rationale clear)
389
+ - Acceptance criteria coverage: ≥70% (maps to MON's criteria)
390
+
391
+ ---
392
+
393
+ **Remember:** ROR's Design Doc is the contract between planning and implementation. DRA will validate that KIL's implementation matches this design with ≥70% compliance. Clear, detailed designs prevent rework and ensure quality.
394
+
395
+ ---
396
+
397
+ ## Scale Transition Examples
398
+
399
+ Sometimes initial scale assessment changes during design phase.
400
+
401
+ ### Example 1: Small → Medium (Security Complexity)
402
+
403
+ **Initial**: "Add password reset endpoint"
404
+ - Looks like 2 files (controller + test)
405
+ - Assessed as SMALL
406
+
407
+ **During ROR Design**: Security analysis reveals:
408
+ - Token generation and validation needed
409
+ - Email service integration required
410
+ - Rate limiting essential (prevent abuse)
411
+ - Expiration logic with cleanup
412
+
413
+ **Result**: Bumped to MEDIUM (4 files)
414
+ - auth.controller.ts (reset endpoint)
415
+ - token.service.ts (token generation/validation)
416
+ - email.service.ts (send reset emails)
417
+ - Tests for all three
418
+
419
+ **Recommendation to ALY**: "Upgrade to Medium scale - security requirements add complexity"
420
+
421
+ ### Example 2: Medium → Large (Hidden Dependencies)
422
+
423
+ **Initial**: "Add file upload feature"
424
+ - Looks like 4 files (controller, service, storage, tests)
425
+ - Assessed as MEDIUM
426
+
427
+ **During ROR Design**: Discovered requirements:
428
+ - Multiple file types (images, PDFs, videos)
429
+ - Size validation and virus scanning
430
+ - Thumbnail generation for images
431
+ - Storage backend abstraction (S3 + local)
432
+ - Upload progress tracking
433
+ - Batch uploads
434
+ - Cleanup of orphaned files
435
+
436
+ **Result**: Bumped to LARGE (8 files)
437
+ - upload.controller.ts
438
+ - upload.service.ts
439
+ - storage/ (3 providers: S3, local, mock)
440
+ - validation.service.ts
441
+ - thumbnail.service.ts
442
+ - cleanup.worker.ts
443
+ - Full test suite
444
+
445
+ **Recommendation to ALY**: "Upgrade to Large scale - scope expanded significantly during design"
446
+
447
+ ### Example 3: Medium → Small (Simpler Than Expected)
448
+
449
+ **Initial**: "Implement caching layer"
450
+ - Sounds complex
451
+ - Assessed as MEDIUM
452
+
453
+ **During ROR Design**: Simple solution found:
454
+ - Use existing Redis setup
455
+ - Single cache.service.ts wrapper
456
+ - Basic get/set/delete operations
457
+ - No custom logic needed
458
+
459
+ **Result**: Downgraded to SMALL (2 files)
460
+ - cache.service.ts
461
+ - cache.service.test.ts
462
+
463
+ **Recommendation to ALY**: "Downgrade to Small scale - simpler than anticipated"
464
+
465
+ ---