dhurandhar 1.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.
- package/.dhurandhar-session-start.md +242 -0
- package/LICENSE +21 -0
- package/README.md +416 -0
- package/docs/ARCHITECTURE_V2.md +249 -0
- package/docs/DECISION_REGISTRY.md +357 -0
- package/docs/IMPLEMENTATION_PERSONAS.md +406 -0
- package/docs/PLUGGABLE_STRATEGIES.md +439 -0
- package/docs/SYSTEM_OBSERVER.md +433 -0
- package/docs/TEST_FIRST_AGILE.md +359 -0
- package/docs/architecture.md +279 -0
- package/docs/engineering-first-philosophy.md +263 -0
- package/docs/getting-started.md +218 -0
- package/docs/module-development.md +323 -0
- package/docs/strategy-example.md +299 -0
- package/docs/test-first-example.md +392 -0
- package/package.json +79 -0
- package/src/core/README.md +92 -0
- package/src/core/agent-instructions/backend-developer.md +412 -0
- package/src/core/agent-instructions/devops-engineer.md +372 -0
- package/src/core/agent-instructions/dhurandhar-council.md +547 -0
- package/src/core/agent-instructions/edge-case-hunter.md +322 -0
- package/src/core/agent-instructions/frontend-developer.md +494 -0
- package/src/core/agent-instructions/lead-system-architect.md +631 -0
- package/src/core/agent-instructions/system-observer.md +319 -0
- package/src/core/agent-instructions/test-architect.md +284 -0
- package/src/core/module.yaml +54 -0
- package/src/core/schemas/design-module-schema.yaml +995 -0
- package/src/core/schemas/system-design-map-schema.yaml +324 -0
- package/src/modules/example/README.md +130 -0
- package/src/modules/example/module.yaml +252 -0
- package/tools/cli/commands/audit.js +267 -0
- package/tools/cli/commands/config.js +113 -0
- package/tools/cli/commands/context.js +170 -0
- package/tools/cli/commands/decisions.js +398 -0
- package/tools/cli/commands/entity.js +218 -0
- package/tools/cli/commands/epic.js +125 -0
- package/tools/cli/commands/install.js +172 -0
- package/tools/cli/commands/module.js +109 -0
- package/tools/cli/commands/service.js +167 -0
- package/tools/cli/commands/story.js +225 -0
- package/tools/cli/commands/strategy.js +294 -0
- package/tools/cli/commands/test.js +277 -0
- package/tools/cli/commands/validate.js +107 -0
- package/tools/cli/dhurandhar.js +212 -0
- package/tools/lib/config-manager.js +170 -0
- package/tools/lib/filesystem.js +126 -0
- package/tools/lib/module-installer.js +61 -0
- package/tools/lib/module-manager.js +149 -0
- package/tools/lib/sdm-manager.js +982 -0
- package/tools/lib/test-engine.js +255 -0
- package/tools/lib/test-templates/api-client.template.js +100 -0
- package/tools/lib/test-templates/vitest.config.template.js +37 -0
- package/tools/lib/validators/config-validator.js +113 -0
- package/tools/lib/validators/module-validator.js +137 -0
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
# Pluggable Architectural Strategies
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Dhurandhar v2.2 introduces **Pluggable Architectural Strategies** - a system for injecting complex architectural patterns as modular constraints that automatically propagate to all services.
|
|
6
|
+
|
|
7
|
+
## Philosophy
|
|
8
|
+
|
|
9
|
+
### Traditional Approach (Anti-Pattern)
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Developer: "Add payment service"
|
|
13
|
+
System: "What database?"
|
|
14
|
+
Developer: "PostgreSQL"
|
|
15
|
+
System: "Should it have its own database?"
|
|
16
|
+
Developer: "Yes, we're doing database-per-service"
|
|
17
|
+
|
|
18
|
+
[Next service]
|
|
19
|
+
|
|
20
|
+
Developer: "Add user service"
|
|
21
|
+
System: "What database?"
|
|
22
|
+
Developer: "PostgreSQL"
|
|
23
|
+
System: "Should it have its own database?"
|
|
24
|
+
Developer: "YES! I told you we're doing database-per-service!"
|
|
25
|
+
|
|
26
|
+
[Cognitive fatigue from repeated decisions]
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Dhurandhar Approach
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
Developer: "Set persistence strategy to database-per-service"
|
|
33
|
+
System: "✓ Strategy set. All new services will have dedicated databases."
|
|
34
|
+
|
|
35
|
+
Developer: "Add payment service"
|
|
36
|
+
System: "✓ payment-service added with dedicated payment_db"
|
|
37
|
+
|
|
38
|
+
Developer: "Add user service"
|
|
39
|
+
System: "✓ user-service added with dedicated user_db"
|
|
40
|
+
|
|
41
|
+
[Zero repeated questions. Strategy enforced automatically.]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Strategy Categories
|
|
45
|
+
|
|
46
|
+
### 1. Persistence Strategy
|
|
47
|
+
|
|
48
|
+
**Controls**: Data isolation model
|
|
49
|
+
|
|
50
|
+
**Options**:
|
|
51
|
+
- `database_per_service` - Full isolation, eventual consistency
|
|
52
|
+
- `shared_database` - Monolith pattern, ACID transactions
|
|
53
|
+
- `hybrid` - Mix of both approaches
|
|
54
|
+
- `event_sourcing` - Event log as source of truth
|
|
55
|
+
|
|
56
|
+
**Auto-Applied Constraints**:
|
|
57
|
+
- `database_per_service`:
|
|
58
|
+
- Each service gets dedicated database
|
|
59
|
+
- Constraint: `no_cross_service_queries`
|
|
60
|
+
- Constraint: `eventual_consistency`
|
|
61
|
+
- `shared_database`:
|
|
62
|
+
- All services share one database
|
|
63
|
+
- ACID transactions allowed
|
|
64
|
+
- Tighter coupling
|
|
65
|
+
|
|
66
|
+
### 2. Communication Pattern
|
|
67
|
+
|
|
68
|
+
**Controls**: Service-to-service interaction model
|
|
69
|
+
|
|
70
|
+
**Options**:
|
|
71
|
+
- `synchronous_rest` - Request/response, immediate
|
|
72
|
+
- `asynchronous_events` - Event-driven, decoupled
|
|
73
|
+
- `hybrid` - Both REST and events
|
|
74
|
+
- `grpc_streaming` - High performance, bidirectional
|
|
75
|
+
- `graphql_federation` - Federated GraphQL gateway
|
|
76
|
+
|
|
77
|
+
**Auto-Applied Constraints**:
|
|
78
|
+
- `asynchronous_events`:
|
|
79
|
+
- Services MUST define `event_boundaries` (produces/consumes)
|
|
80
|
+
- Event bus technology injected (Kafka, RabbitMQ, etc.)
|
|
81
|
+
- Message format specified (JSON, Avro, Protobuf)
|
|
82
|
+
- `synchronous_rest`:
|
|
83
|
+
- Services define REST API contracts
|
|
84
|
+
- No event boundaries required
|
|
85
|
+
|
|
86
|
+
### 3. State Management
|
|
87
|
+
|
|
88
|
+
**Controls**: Caching and session distribution
|
|
89
|
+
|
|
90
|
+
**Options**:
|
|
91
|
+
- `distributed_redis` - Shared cache across services
|
|
92
|
+
- `local_in_memory` - Per-service cache
|
|
93
|
+
- `sidecar_cache` - Service mesh pattern
|
|
94
|
+
- `cdn_edge` - Edge caching for static content
|
|
95
|
+
- `none` - No caching
|
|
96
|
+
|
|
97
|
+
**Auto-Applied Constraints**:
|
|
98
|
+
- `distributed_redis`:
|
|
99
|
+
- Redis dependency added to services
|
|
100
|
+
- Cache config injected
|
|
101
|
+
- Invalidation strategy set (TTL, event-driven, etc.)
|
|
102
|
+
|
|
103
|
+
### 4. Security Strategy
|
|
104
|
+
|
|
105
|
+
**Controls**: Authentication and authorization patterns
|
|
106
|
+
|
|
107
|
+
**Options**:
|
|
108
|
+
- `jwt_centralized` - Auth service validates all tokens
|
|
109
|
+
- `oauth2_delegated` - External OAuth provider
|
|
110
|
+
- `mtls` - Certificate-based, service-to-service
|
|
111
|
+
- `api_keys` - Simple key-based auth
|
|
112
|
+
- `hybrid` - Multiple mechanisms
|
|
113
|
+
|
|
114
|
+
**Auto-Applied Constraints**:
|
|
115
|
+
- `jwt_centralized`:
|
|
116
|
+
- Services depend on `auth-service`
|
|
117
|
+
- JWT validation endpoint configured
|
|
118
|
+
- Token refresh flow defined
|
|
119
|
+
|
|
120
|
+
### 5. Resilience Strategy
|
|
121
|
+
|
|
122
|
+
**Controls**: Fault tolerance patterns
|
|
123
|
+
|
|
124
|
+
**Options**:
|
|
125
|
+
- `circuit_breaker: true/false`
|
|
126
|
+
- `retry_strategy: exponential_backoff | fixed_delay | none`
|
|
127
|
+
- `timeout_policy: aggressive_5s | moderate_30s | lenient_60s`
|
|
128
|
+
- `bulkhead_isolation: true/false`
|
|
129
|
+
|
|
130
|
+
**Auto-Applied Constraints**:
|
|
131
|
+
- `circuit_breaker: true`:
|
|
132
|
+
- Circuit breaker config added to all services
|
|
133
|
+
- Failure threshold: 5
|
|
134
|
+
- Timeout: 30s
|
|
135
|
+
|
|
136
|
+
### 6. Deployment Strategy
|
|
137
|
+
|
|
138
|
+
**Controls**: Orchestration and scaling
|
|
139
|
+
|
|
140
|
+
**Options**:
|
|
141
|
+
- `orchestration: kubernetes | docker_swarm | ecs | serverless`
|
|
142
|
+
- `scaling_strategy: horizontal_pod_autoscaling | vertical_scaling | manual`
|
|
143
|
+
- `service_mesh: istio | linkerd | consul | none`
|
|
144
|
+
|
|
145
|
+
### 7. Observability Strategy
|
|
146
|
+
|
|
147
|
+
**Controls**: Monitoring, logging, tracing
|
|
148
|
+
|
|
149
|
+
**Options**:
|
|
150
|
+
- `logging: centralized_elk | cloudwatch | datadog | loki`
|
|
151
|
+
- `metrics: prometheus | datadog | cloudwatch`
|
|
152
|
+
- `tracing: jaeger | zipkin | aws_xray | datadog_apm`
|
|
153
|
+
- `distributed_tracing: true/false`
|
|
154
|
+
|
|
155
|
+
## CLI Commands
|
|
156
|
+
|
|
157
|
+
### Show Active Strategies
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
dhurandhar strategy --show
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Output**:
|
|
164
|
+
```
|
|
165
|
+
📐 Active Architectural Strategies
|
|
166
|
+
|
|
167
|
+
Persistence Strategy:
|
|
168
|
+
Model: database_per_service
|
|
169
|
+
Constraints: no_cross_service_queries, eventual_consistency
|
|
170
|
+
|
|
171
|
+
Communication Pattern:
|
|
172
|
+
Primary: asynchronous_events
|
|
173
|
+
Event Bus: kafka
|
|
174
|
+
|
|
175
|
+
State Management:
|
|
176
|
+
Caching: distributed_redis
|
|
177
|
+
Sessions: redis_distributed
|
|
178
|
+
|
|
179
|
+
Security:
|
|
180
|
+
Authentication: jwt_centralized
|
|
181
|
+
Authorization: rbac
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Set Strategy
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
dhurandhar strategy --set persistence
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Interactive**:
|
|
191
|
+
```
|
|
192
|
+
? Persistence model:
|
|
193
|
+
❯ Database-per-Service (Full isolation, eventual consistency)
|
|
194
|
+
Shared Database (Monolith pattern, ACID transactions)
|
|
195
|
+
Hybrid (Mix of both)
|
|
196
|
+
Event Sourcing (Event log as source of truth)
|
|
197
|
+
|
|
198
|
+
✓ persistence strategy set
|
|
199
|
+
|
|
200
|
+
⚠ 3 services need alignment:
|
|
201
|
+
auth-service: Missing dedicated database
|
|
202
|
+
user-service: Missing dedicated database
|
|
203
|
+
payment-service: Missing dedicated database
|
|
204
|
+
|
|
205
|
+
Run to auto-align:
|
|
206
|
+
dhurandhar strategy --align
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Pivot Strategy
|
|
210
|
+
|
|
211
|
+
Change an existing strategy:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
dhurandhar strategy --pivot communication
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Direct action**:
|
|
218
|
+
```
|
|
219
|
+
⚡ Pivot communication Strategy
|
|
220
|
+
|
|
221
|
+
Current strategy:
|
|
222
|
+
{
|
|
223
|
+
"primary_pattern": "synchronous_rest"
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
? This will update all services. Continue? Yes
|
|
227
|
+
|
|
228
|
+
? Primary communication pattern:
|
|
229
|
+
Synchronous REST
|
|
230
|
+
❯ Asynchronous Events
|
|
231
|
+
Hybrid
|
|
232
|
+
gRPC Streaming
|
|
233
|
+
|
|
234
|
+
? Event bus technology:
|
|
235
|
+
❯ Apache Kafka
|
|
236
|
+
RabbitMQ
|
|
237
|
+
AWS SNS/SQS
|
|
238
|
+
Redis Streams
|
|
239
|
+
|
|
240
|
+
✓ communication strategy set
|
|
241
|
+
✓ 3 services flagged for alignment
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Align Services
|
|
245
|
+
|
|
246
|
+
Apply strategies to all existing services:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
dhurandhar strategy --align
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Output**:
|
|
253
|
+
```
|
|
254
|
+
🔄 Align Services to Strategies
|
|
255
|
+
|
|
256
|
+
✓ All services now match active strategies
|
|
257
|
+
|
|
258
|
+
Check results:
|
|
259
|
+
dhurandhar service --list
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Global Strategy Injection
|
|
263
|
+
|
|
264
|
+
### How It Works
|
|
265
|
+
|
|
266
|
+
When you add a new service, strategies are automatically applied:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# Set strategies first
|
|
270
|
+
dhurandhar strategy --set persistence
|
|
271
|
+
→ database_per_service
|
|
272
|
+
|
|
273
|
+
dhurandhar strategy --set communication
|
|
274
|
+
→ asynchronous_events (Kafka)
|
|
275
|
+
|
|
276
|
+
dhurandhar strategy --set security
|
|
277
|
+
→ jwt_centralized
|
|
278
|
+
|
|
279
|
+
# Add service
|
|
280
|
+
dhurandhar service add "order-service: Process orders"
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Auto-Generated Service Definition**:
|
|
284
|
+
```yaml
|
|
285
|
+
services:
|
|
286
|
+
- name: order-service
|
|
287
|
+
scope: "Process orders"
|
|
288
|
+
tech_stack:
|
|
289
|
+
language: Go
|
|
290
|
+
framework: Echo
|
|
291
|
+
database: PostgreSQL
|
|
292
|
+
|
|
293
|
+
# AUTO-INJECTED by persistence strategy
|
|
294
|
+
dedicated_database:
|
|
295
|
+
name: order_db
|
|
296
|
+
type: PostgreSQL
|
|
297
|
+
isolation: full
|
|
298
|
+
constraints:
|
|
299
|
+
- no_cross_service_queries
|
|
300
|
+
- eventual_consistency
|
|
301
|
+
|
|
302
|
+
# AUTO-INJECTED by communication strategy
|
|
303
|
+
event_boundaries:
|
|
304
|
+
produces:
|
|
305
|
+
- order.created
|
|
306
|
+
- order.completed
|
|
307
|
+
consumes:
|
|
308
|
+
- payment.completed
|
|
309
|
+
- inventory.reserved
|
|
310
|
+
event_bus: kafka
|
|
311
|
+
|
|
312
|
+
# AUTO-INJECTED by security strategy
|
|
313
|
+
dependencies:
|
|
314
|
+
- auth-service
|
|
315
|
+
authentication:
|
|
316
|
+
type: jwt
|
|
317
|
+
validation: centralized
|
|
318
|
+
token_endpoint: /api/v1/auth/validate
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**Result**: Developer only specified service name and scope. Framework applied all architectural constraints automatically.
|
|
322
|
+
|
|
323
|
+
## Extensibility Over Redesign
|
|
324
|
+
|
|
325
|
+
### Pattern: Extend Existing Architecture
|
|
326
|
+
|
|
327
|
+
When introducing new technical concepts (JWT rotation, Circuit Breakers, Event Sourcing):
|
|
328
|
+
|
|
329
|
+
**❌ Old Way** (Redesign):
|
|
330
|
+
```
|
|
331
|
+
User: "Add JWT rotation"
|
|
332
|
+
System: "Let's redesign the authentication system..."
|
|
333
|
+
[Hours of discussion]
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**✅ New Way** (Extension):
|
|
337
|
+
```
|
|
338
|
+
User: "Add JWT rotation"
|
|
339
|
+
Agent: [Checks SDM: security.authentication = jwt_centralized ✓]
|
|
340
|
+
Agent: "Extension of existing auth strategy"
|
|
341
|
+
Agent: "Adding rotation endpoint to auth-service"
|
|
342
|
+
✓ Story STORY-004: JWT Token Rotation
|
|
343
|
+
✓ Added to auth-service (no redesign)
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### Pattern: Strategy Pivot
|
|
347
|
+
|
|
348
|
+
When fundamentally changing architecture:
|
|
349
|
+
|
|
350
|
+
```bash
|
|
351
|
+
# Current: Monolith with shared database
|
|
352
|
+
dhurandhar strategy --pivot persistence
|
|
353
|
+
|
|
354
|
+
? Persistence model:
|
|
355
|
+
❯ Database-per-Service
|
|
356
|
+
|
|
357
|
+
? This will update all services. Continue? Yes
|
|
358
|
+
|
|
359
|
+
✓ Strategy pivoted
|
|
360
|
+
✓ 5 services realigned
|
|
361
|
+
✓ Each service now has dedicated database
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
**No justification loop. Direct pivot with impact analysis.**
|
|
365
|
+
|
|
366
|
+
## Strategy Rehydration
|
|
367
|
+
|
|
368
|
+
### Context Loading
|
|
369
|
+
|
|
370
|
+
When starting a new session:
|
|
371
|
+
|
|
372
|
+
```
|
|
373
|
+
Agent loads SYSTEM_DESIGN_MAP.yaml:
|
|
374
|
+
|
|
375
|
+
1. Metadata (project, architecture type)
|
|
376
|
+
2. Tech Stack (languages, frameworks)
|
|
377
|
+
3. **Technical Strategies** ← NEW
|
|
378
|
+
4. Services, Entities
|
|
379
|
+
5. Agile Blueprint
|
|
380
|
+
6. Test Coverage
|
|
381
|
+
|
|
382
|
+
Agent recognizes:
|
|
383
|
+
"We are in a Database-per-Service + Event-Driven + JWT-Centralized context"
|
|
384
|
+
|
|
385
|
+
All subsequent operations respect these constraints.
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### Strategy-Aware Code Generation
|
|
389
|
+
|
|
390
|
+
Test generation, code generation, and task creation all respect active strategies:
|
|
391
|
+
|
|
392
|
+
```
|
|
393
|
+
# With communication.primary_pattern: asynchronous_events
|
|
394
|
+
|
|
395
|
+
dhurandhar test --generate
|
|
396
|
+
|
|
397
|
+
Generated tests include:
|
|
398
|
+
- Event producer tests (Kafka publish)
|
|
399
|
+
- Event consumer tests (Kafka consume)
|
|
400
|
+
- Message schema validation
|
|
401
|
+
- Idempotency tests
|
|
402
|
+
|
|
403
|
+
# With resilience.circuit_breaker: true
|
|
404
|
+
|
|
405
|
+
Tests include:
|
|
406
|
+
- Circuit breaker trigger tests
|
|
407
|
+
- Fallback logic tests
|
|
408
|
+
- Circuit recovery tests
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
## Benefits
|
|
412
|
+
|
|
413
|
+
### 1. Zero Repeated Decisions
|
|
414
|
+
|
|
415
|
+
Set once, apply everywhere:
|
|
416
|
+
```
|
|
417
|
+
Before: 5 services × 10 questions = 50 questions
|
|
418
|
+
After: 1 strategy setup × 7 categories = 7 questions total
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
### 2. Architectural Consistency
|
|
422
|
+
|
|
423
|
+
All services follow the same patterns automatically.
|
|
424
|
+
|
|
425
|
+
### 3. Easy Pivots
|
|
426
|
+
|
|
427
|
+
Change your mind? Pivot the strategy. All services update.
|
|
428
|
+
|
|
429
|
+
### 4. Extensibility-First
|
|
430
|
+
|
|
431
|
+
New features plug into existing strategies without redesign.
|
|
432
|
+
|
|
433
|
+
### 5. Strategy Rehydration
|
|
434
|
+
|
|
435
|
+
New sessions immediately understand architectural constraints.
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
**Dhurandhar v2.2: Engineering-First + Test-First + Strategy-Driven**
|