specpulse 1.4.1__py3-none-any.whl → 1.4.2__py3-none-any.whl

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 (31) hide show
  1. specpulse/__init__.py +1 -1
  2. specpulse/cli/main.py +30 -8
  3. specpulse/core/specpulse.py +328 -3
  4. specpulse/core/validator.py +115 -5
  5. specpulse/resources/commands/gemini/sp-pulse.toml +80 -23
  6. specpulse/resources/commands/gemini/sp-spec.toml +90 -45
  7. specpulse/resources/scripts/sp-pulse-decompose.ps1 +74 -0
  8. specpulse/resources/scripts/sp-pulse-execute.ps1 +177 -0
  9. specpulse/resources/scripts/sp-pulse-init.ps1 +36 -11
  10. specpulse/resources/scripts/sp-pulse-init.sh +29 -8
  11. specpulse/resources/scripts/sp-pulse-plan.sh +42 -17
  12. specpulse/resources/scripts/sp-pulse-spec.sh +49 -25
  13. specpulse/resources/scripts/sp-pulse-task.sh +49 -17
  14. specpulse/resources/templates/decomposition/api-contract.yaml +344 -12
  15. specpulse/resources/templates/decomposition/integration-plan.md +249 -97
  16. specpulse/resources/templates/decomposition/interface.ts +244 -13
  17. specpulse/resources/templates/decomposition/microservice.md +151 -0
  18. specpulse/resources/templates/decomposition/service-plan.md +187 -155
  19. specpulse/resources/templates/plan.md +134 -225
  20. specpulse/resources/templates/spec.md +94 -125
  21. specpulse/resources/templates/task.md +216 -161
  22. specpulse/utils/console.py +54 -6
  23. specpulse/utils/git_utils.py +47 -4
  24. specpulse/utils/version_check.py +15 -2
  25. {specpulse-1.4.1.dist-info → specpulse-1.4.2.dist-info}/METADATA +33 -17
  26. {specpulse-1.4.1.dist-info → specpulse-1.4.2.dist-info}/RECORD +30 -28
  27. specpulse/resources/templates/decomposition/microservices.md +0 -35
  28. {specpulse-1.4.1.dist-info → specpulse-1.4.2.dist-info}/WHEEL +0 -0
  29. {specpulse-1.4.1.dist-info → specpulse-1.4.2.dist-info}/entry_points.txt +0 -0
  30. {specpulse-1.4.1.dist-info → specpulse-1.4.2.dist-info}/licenses/LICENSE +0 -0
  31. {specpulse-1.4.1.dist-info → specpulse-1.4.2.dist-info}/top_level.txt +0 -0
@@ -1,135 +1,287 @@
1
- # Integration Plan: {{ feature_name }}
1
+ # Integration Plan: {{feature_name}}
2
2
 
3
- ## Metadata
4
- - **Spec ID**: {{ spec_id }}
5
- - **Decomposition Date**: {{ decomposition_date }}
6
- - **Services Count**: {{ service_count }}
7
- - **Generated**: {{ date }}
8
- - **Version**: {{ version }}
3
+ ## Overview
4
+ Integration strategy for microservices implementing {{feature_name}}
9
5
 
10
- ## Service Overview
11
-
12
- {{ service_list }}
13
-
14
- ## Integration Architecture
6
+ ## Service Architecture
15
7
 
16
8
  ```mermaid
17
- {{ architecture_diagram }}
18
- ```
9
+ graph TD
10
+ CLIENT[Client Application]
11
+ GATEWAY[API Gateway]
19
12
 
20
- ## Communication Strategy
13
+ AUTH[Auth Service]
14
+ USER[User Service]
15
+ NOTIFY[Notification Service]
21
16
 
22
- ### Synchronous Communication
23
- {{ sync_communication }}
17
+ DB_AUTH[(Auth DB)]
18
+ DB_USER[(User DB)]
24
19
 
25
- ### Asynchronous Communication
26
- {{ async_communication }}
20
+ CACHE[Redis Cache]
21
+ QUEUE[Message Queue]
27
22
 
28
- ## Data Consistency Strategy
23
+ CLIENT --> GATEWAY
24
+ GATEWAY --> AUTH
25
+ GATEWAY --> USER
29
26
 
30
- ### Transaction Boundaries
31
- {{ transaction_strategy }}
27
+ AUTH --> DB_AUTH
28
+ AUTH --> CACHE
29
+ AUTH --> QUEUE
32
30
 
33
- ### Event Sourcing
34
- {{ event_sourcing }}
31
+ USER --> DB_USER
32
+ USER --> CACHE
33
+ USER --> QUEUE
35
34
 
36
- ### Saga Patterns
37
- {{ saga_patterns }}
35
+ QUEUE --> NOTIFY
38
36
 
39
- ## Integration Phases
37
+ AUTH -.->|Events| USER
38
+ USER -.->|Events| NOTIFY
39
+ ```
40
40
 
41
- ### Phase 1: Service Infrastructure
42
- **Duration**: {{ phase1_duration }}
43
- **Deliverables**:
44
- - Service discovery setup
45
- - API Gateway configuration
46
- - Load balancer setup
47
- - Service mesh deployment
41
+ ## Service Communication Matrix
42
+
43
+ | Source Service | Target Service | Protocol | Pattern | Purpose |
44
+ |---------------|---------------|----------|---------|---------|
45
+ | API Gateway | Auth Service | REST | Request-Response | Authentication |
46
+ | API Gateway | User Service | REST | Request-Response | User operations |
47
+ | Auth Service | User Service | Event | Pub-Sub | User created/updated |
48
+ | User Service | Notification | Event | Pub-Sub | Send notifications |
49
+ | All Services | Cache | Redis | Cache-Aside | Performance |
50
+
51
+ ## Integration Points
52
+
53
+ ### 1. Authentication Flow
54
+ **Services**: API Gateway → Auth Service → User Service
55
+
56
+ **Flow**:
57
+ 1. Client sends credentials to API Gateway
58
+ 2. Gateway forwards to Auth Service
59
+ 3. Auth Service validates and generates token
60
+ 4. Auth Service publishes `user.authenticated` event
61
+ 5. User Service updates last login timestamp
62
+ 6. Token returned to client
63
+
64
+ **Contracts**:
65
+ - REST API: `POST /auth/login`
66
+ - Event: `user.authenticated`
67
+ - Response: JWT token
68
+
69
+ ### 2. User Registration Flow
70
+ **Services**: API Gateway → User Service → Auth Service → Notification Service
71
+
72
+ **Flow**:
73
+ 1. Client sends registration data to API Gateway
74
+ 2. Gateway forwards to User Service
75
+ 3. User Service creates user record
76
+ 4. User Service publishes `user.created` event
77
+ 5. Auth Service creates authentication record
78
+ 6. Notification Service sends welcome email
79
+ 7. Confirmation sent to client
80
+
81
+ **Contracts**:
82
+ - REST API: `POST /users/register`
83
+ - Events: `user.created`, `auth.created`, `notification.sent`
84
+
85
+ ### 3. Data Synchronization
86
+ **Services**: All services with shared data
87
+
88
+ **Strategy**:
89
+ - Event-driven synchronization
90
+ - Eventual consistency model
91
+ - Compensation for failures
92
+
93
+ **Events**:
94
+ - `user.updated` - Profile changes
95
+ - `auth.revoked` - Token invalidation
96
+ - `permission.changed` - Authorization updates
48
97
 
49
- ### Phase 2: Inter-Service Communication
50
- **Duration**: {{ phase2_duration }}
51
- **Deliverables**:
52
- - REST API endpoints
53
- - Message queue setup
54
- - Event bus configuration
55
- - Circuit breakers
98
+ ## API Gateway Configuration
56
99
 
57
- ### Phase 3: Data Synchronization
58
- **Duration**: {{ phase3_duration }}
59
- **Deliverables**:
60
- - Data replication strategy
61
- - Cache synchronization
62
- - Event replay mechanisms
63
- - Consistency validation
100
+ ### Routing Rules
101
+ ```yaml
102
+ routes:
103
+ - path: /api/v1/auth/*
104
+ service: auth-service
105
+ methods: [GET, POST, PUT, DELETE]
106
+
107
+ - path: /api/v1/users/*
108
+ service: user-service
109
+ methods: [GET, POST, PUT, DELETE]
110
+
111
+ - path: /api/v1/notifications/*
112
+ service: notification-service
113
+ methods: [GET, POST]
114
+ ```
64
115
 
65
- ### Phase 4: Integration Testing
66
- **Duration**: {{ phase4_duration }}
67
- **Deliverables**:
68
- - Contract tests
69
- - End-to-end scenarios
70
- - Performance benchmarks
71
- - Chaos engineering tests
116
+ ### Security Policies
117
+ - Rate limiting: 100 requests/minute per IP
118
+ - Authentication: JWT validation
119
+ - CORS: Configured for allowed origins
120
+ - Request/Response validation
72
121
 
73
- ## Service Dependencies
122
+ ## Message Queue Configuration
74
123
 
124
+ ### Exchanges and Queues
75
125
  ```yaml
76
- dependencies:
77
- {{ service_dependencies }}
126
+ exchanges:
127
+ - name: user-events
128
+ type: topic
129
+ durable: true
130
+
131
+ - name: auth-events
132
+ type: topic
133
+ durable: true
134
+
135
+ queues:
136
+ - name: user-service-queue
137
+ bindings:
138
+ - exchange: auth-events
139
+ routing_key: auth.*
140
+
141
+ - name: notification-queue
142
+ bindings:
143
+ - exchange: user-events
144
+ routing_key: user.*
78
145
  ```
79
146
 
80
- ## API Gateway Configuration
81
-
82
- ### Routing Rules
83
- {{ routing_rules }}
147
+ ### Event Schema
148
+ ```json
149
+ {
150
+ "eventId": "uuid",
151
+ "eventType": "user.created",
152
+ "timestamp": "ISO-8601",
153
+ "correlationId": "uuid",
154
+ "data": {
155
+ "userId": "uuid",
156
+ "email": "string"
157
+ }
158
+ }
159
+ ```
84
160
 
85
- ### Rate Limiting
86
- {{ rate_limiting }}
161
+ ## Service Discovery
87
162
 
88
- ### Authentication Flow
89
- {{ auth_flow }}
163
+ ### Registration
164
+ - Each service registers on startup
165
+ - Health checks every 30 seconds
166
+ - Deregistration on shutdown
90
167
 
91
- ## Monitoring & Observability
168
+ ### Discovery
169
+ - Service-to-service calls use discovery
170
+ - Client-side load balancing
171
+ - Circuit breaker implementation
92
172
 
93
- ### Distributed Tracing
94
- - Correlation ID propagation
95
- - Span collection strategy
96
- - Trace sampling rate
173
+ ## Error Handling Strategy
97
174
 
98
- ### Health Checks
99
- {{ health_checks }}
175
+ ### Retry Logic
176
+ - Exponential backoff: 1s, 2s, 4s, 8s
177
+ - Max retries: 3
178
+ - Dead letter queue for failures
100
179
 
101
- ### SLA Targets
102
- {{ sla_targets }}
180
+ ### Circuit Breaker
181
+ - Threshold: 50% failure rate
182
+ - Window: 60 seconds
183
+ - Half-open attempts: Every 30 seconds
103
184
 
104
- ## Rollout Strategy
185
+ ### Compensation
186
+ - Saga pattern for distributed transactions
187
+ - Compensation events for rollback
188
+ - Audit log for all operations
105
189
 
106
- ### Service Deployment Order
107
- 1. {{ deployment_order }}
190
+ ## Testing Strategy
108
191
 
109
- ### Feature Flags
110
- {{ feature_flags }}
192
+ ### Integration Tests
193
+ 1. **Service-to-Service**: Mock external dependencies
194
+ 2. **End-to-End**: Full flow testing
195
+ 3. **Contract Tests**: API and event contracts
196
+ 4. **Chaos Testing**: Failure scenarios
111
197
 
112
- ### Rollback Plan
113
- {{ rollback_plan }}
198
+ ### Test Scenarios
199
+ - [ ] Happy path: Complete user registration
200
+ - [ ] Service failure: Auth service down
201
+ - [ ] Network partition: Queue unreachable
202
+ - [ ] Data consistency: Concurrent updates
203
+ - [ ] Performance: High load conditions
114
204
 
115
- ## SDD Compliance
116
- - [ ] Specifications for each integration point (Principle 1: Specification First)
117
- - [ ] Phased integration approach (Principle 2: Incremental Planning)
118
- - [ ] Contract tests defined (Principle 6: Quality Assurance)
119
- - [ ] Architecture decisions documented (Principle 7: Architecture Documentation)
120
- - [ ] Stakeholder communication plan (Principle 9: Stakeholder Alignment)
205
+ ## Monitoring and Observability
121
206
 
122
- ## Risk Assessment
123
-
124
- ### Integration Risks
125
- {{ integration_risks }}
207
+ ### Distributed Tracing
208
+ - Correlation IDs across all services
209
+ - Request flow visualization
210
+ - Performance bottleneck identification
211
+
212
+ ### Metrics
213
+ - Request rate per service
214
+ - Error rate per integration point
215
+ - Message queue depth
216
+ - Cache hit ratio
217
+
218
+ ### Alerting
219
+ - Service unavailable > 1 minute
220
+ - Error rate > 5%
221
+ - Queue depth > 1000 messages
222
+ - Response time > 500ms (p95)
223
+
224
+ ## Security Considerations
225
+
226
+ ### Service-to-Service Authentication
227
+ - mTLS for internal communication
228
+ - Service accounts with limited scope
229
+ - Regular key rotation
230
+
231
+ ### Data Protection
232
+ - Encryption in transit (TLS)
233
+ - Encryption at rest (database)
234
+ - PII masking in logs
235
+
236
+ ## Deployment Strategy
237
+
238
+ ### Order of Deployment
239
+ 1. Infrastructure (Database, Cache, Queue)
240
+ 2. Core services (Auth, User)
241
+ 3. Support services (Notification)
242
+ 4. API Gateway
243
+ 5. Monitoring and logging
126
244
 
127
- ### Mitigation Strategies
128
- {{ mitigation_strategies }}
245
+ ### Rollback Plan
246
+ - Blue-green deployment
247
+ - Database migration rollback scripts
248
+ - Event replay capability
249
+ - Configuration rollback
250
+
251
+ ## Performance Optimization
252
+
253
+ ### Caching Strategy
254
+ - User profiles: 5 minutes TTL
255
+ - Authentication tokens: Until expiry
256
+ - Permissions: 1 minute TTL
257
+
258
+ ### Database Optimization
259
+ - Read replicas for queries
260
+ - Connection pooling
261
+ - Query optimization
262
+ - Proper indexing
263
+
264
+ ### Async Processing
265
+ - Non-critical operations queued
266
+ - Batch processing where possible
267
+ - Event debouncing
268
+
269
+ ## Timeline
270
+
271
+ | Phase | Duration | Tasks |
272
+ |-------|----------|-------|
273
+ | Setup | 2 days | Infrastructure, service discovery |
274
+ | Core Integration | 5 days | Auth + User services |
275
+ | Extended Integration | 3 days | Notification, monitoring |
276
+ | Testing | 3 days | Integration tests, load tests |
277
+ | Optimization | 2 days | Performance tuning |
129
278
 
130
279
  ## Success Criteria
280
+
131
281
  - [ ] All services communicating successfully
132
- - [ ] Data consistency maintained
282
+ - [ ] End-to-end flows working
133
283
  - [ ] Performance targets met
134
- - [ ] Zero message loss
135
- - [ ] Graceful degradation working
284
+ - [ ] Monitoring in place
285
+ - [ ] Security scans passed
286
+ - [ ] Documentation complete
287
+ - [ ] Team trained on operations
@@ -1,20 +1,251 @@
1
1
  /**
2
- * {{ interface_name }}
3
- * {{ interface_description }}
4
- *
5
- * Bounded Context: {{ bounded_context }}
6
- * Service: {{ service_name }}
2
+ * {{service_name}} Service Interfaces
3
+ * Generated from SPEC-{{spec_id}}
7
4
  */
8
5
 
9
- export interface {{ interface_name }} {
10
- {{ methods }}
6
+ // ============================================================================
7
+ // Domain Entities
8
+ // ============================================================================
9
+
10
+ export interface {{Entity}} {
11
+ id: string;
12
+ name: string;
13
+ description?: string;
14
+ status: {{Entity}}Status;
15
+ metadata?: Record<string, any>;
16
+ createdAt: Date;
17
+ updatedAt: Date;
18
+ }
19
+
20
+ export enum {{Entity}}Status {
21
+ ACTIVE = 'active',
22
+ INACTIVE = 'inactive',
23
+ PENDING = 'pending',
24
+ DELETED = 'deleted'
25
+ }
26
+
27
+ // ============================================================================
28
+ // Request/Response DTOs
29
+ // ============================================================================
30
+
31
+ export interface Create{{Entity}}Request {
32
+ name: string;
33
+ description?: string;
34
+ metadata?: Record<string, any>;
35
+ }
36
+
37
+ export interface Update{{Entity}}Request {
38
+ name?: string;
39
+ description?: string;
40
+ status?: {{Entity}}Status;
41
+ metadata?: Record<string, any>;
11
42
  }
12
43
 
13
- // Data Transfer Objects
14
- {{ dto_definitions }}
44
+ export interface {{Entity}}Response {
45
+ data: {{Entity}};
46
+ meta?: ResponseMeta;
47
+ }
48
+
49
+ export interface {{Entity}}ListResponse {
50
+ data: {{Entity}}[];
51
+ meta: PaginationMeta;
52
+ }
53
+
54
+ // ============================================================================
55
+ // Service Interface
56
+ // ============================================================================
57
+
58
+ export interface {{ServiceName}}Service {
59
+ // CRUD Operations
60
+ create(data: Create{{Entity}}Request): Promise<{{Entity}}>;
61
+ findById(id: string): Promise<{{Entity}} | null>;
62
+ findAll(params: QueryParams): Promise<{{Entity}}ListResponse>;
63
+ update(id: string, data: Update{{Entity}}Request): Promise<{{Entity}}>;
64
+ delete(id: string): Promise<boolean>;
65
+
66
+ // Business Operations
67
+ activate(id: string): Promise<{{Entity}}>;
68
+ deactivate(id: string): Promise<{{Entity}}>;
69
+ bulkUpdate(ids: string[], data: Update{{Entity}}Request): Promise<{{Entity}}[]>;
70
+
71
+ // Query Operations
72
+ findByName(name: string): Promise<{{Entity}} | null>;
73
+ findByStatus(status: {{Entity}}Status): Promise<{{Entity}}[]>;
74
+ search(query: SearchQuery): Promise<{{Entity}}[]>;
75
+ }
76
+
77
+ // ============================================================================
78
+ // Repository Interface
79
+ // ============================================================================
80
+
81
+ export interface {{Entity}}Repository {
82
+ // Basic CRUD
83
+ save(entity: {{Entity}}): Promise<{{Entity}}>;
84
+ findById(id: string): Promise<{{Entity}} | null>;
85
+ findAll(options?: FindOptions): Promise<{{Entity}}[]>;
86
+ update(id: string, data: Partial<{{Entity}}>): Promise<{{Entity}} | null>;
87
+ delete(id: string): Promise<boolean>;
88
+
89
+ // Batch Operations
90
+ saveMany(entities: {{Entity}}[]): Promise<{{Entity}}[]>;
91
+ deleteMany(ids: string[]): Promise<number>;
92
+
93
+ // Query Methods
94
+ findOne(filter: FilterQuery): Promise<{{Entity}} | null>;
95
+ find(filter: FilterQuery, options?: FindOptions): Promise<{{Entity}}[]>;
96
+ count(filter?: FilterQuery): Promise<number>;
97
+ exists(filter: FilterQuery): Promise<boolean>;
98
+ }
99
+
100
+ // ============================================================================
101
+ // Event Interfaces
102
+ // ============================================================================
103
+
104
+ export interface {{Entity}}Event {
105
+ eventId: string;
106
+ eventType: {{Entity}}EventType;
107
+ entityId: string;
108
+ timestamp: Date;
109
+ data: {{Entity}};
110
+ metadata?: EventMetadata;
111
+ }
112
+
113
+ export enum {{Entity}}EventType {
114
+ CREATED = '{{entity}}.created',
115
+ UPDATED = '{{entity}}.updated',
116
+ DELETED = '{{entity}}.deleted',
117
+ ACTIVATED = '{{entity}}.activated',
118
+ DEACTIVATED = '{{entity}}.deactivated'
119
+ }
120
+
121
+ export interface EventMetadata {
122
+ userId?: string;
123
+ correlationId?: string;
124
+ source?: string;
125
+ version?: string;
126
+ }
127
+
128
+ // ============================================================================
129
+ // Error Interfaces
130
+ // ============================================================================
131
+
132
+ export class {{Entity}}Error extends Error {
133
+ constructor(
134
+ message: string,
135
+ public code: string,
136
+ public statusCode: number,
137
+ public details?: any
138
+ ) {
139
+ super(message);
140
+ this.name = '{{Entity}}Error';
141
+ }
142
+ }
15
143
 
16
- // Event Contracts
17
- {{ event_contracts }}
144
+ export class {{Entity}}NotFoundError extends {{Entity}}Error {
145
+ constructor(id: string) {
146
+ super(
147
+ `{{Entity}} with ID ${id} not found`,
148
+ 'ENTITY_NOT_FOUND',
149
+ 404
150
+ );
151
+ }
152
+ }
153
+
154
+ export class {{Entity}}ValidationError extends {{Entity}}Error {
155
+ constructor(message: string, details: any) {
156
+ super(message, 'VALIDATION_ERROR', 400, details);
157
+ }
158
+ }
159
+
160
+ // ============================================================================
161
+ // Helper Types
162
+ // ============================================================================
163
+
164
+ export interface QueryParams {
165
+ page?: number;
166
+ limit?: number;
167
+ sort?: SortField;
168
+ order?: SortOrder;
169
+ filter?: FilterQuery;
170
+ }
171
+
172
+ export interface FilterQuery {
173
+ [field: string]: any;
174
+ }
175
+
176
+ export interface FindOptions {
177
+ skip?: number;
178
+ limit?: number;
179
+ sort?: SortOptions;
180
+ projection?: ProjectionOptions;
181
+ }
182
+
183
+ export interface SortOptions {
184
+ [field: string]: SortOrder;
185
+ }
186
+
187
+ export interface ProjectionOptions {
188
+ [field: string]: 0 | 1;
189
+ }
190
+
191
+ export type SortField = 'name' | 'status' | 'createdAt' | 'updatedAt';
192
+ export type SortOrder = 'asc' | 'desc' | 1 | -1;
193
+
194
+ export interface PaginationMeta {
195
+ page: number;
196
+ limit: number;
197
+ total: number;
198
+ totalPages: number;
199
+ hasNext: boolean;
200
+ hasPrev: boolean;
201
+ }
202
+
203
+ export interface ResponseMeta {
204
+ timestamp: Date;
205
+ version: string;
206
+ [key: string]: any;
207
+ }
208
+
209
+ export interface SearchQuery {
210
+ text?: string;
211
+ fields?: string[];
212
+ fuzzy?: boolean;
213
+ limit?: number;
214
+ }
215
+
216
+ // ============================================================================
217
+ // Configuration Interface
218
+ // ============================================================================
219
+
220
+ export interface {{ServiceName}}Config {
221
+ serviceName: string;
222
+ port: number;
223
+ database: DatabaseConfig;
224
+ cache?: CacheConfig;
225
+ messaging?: MessagingConfig;
226
+ monitoring?: MonitoringConfig;
227
+ }
228
+
229
+ export interface DatabaseConfig {
230
+ url: string;
231
+ poolSize?: number;
232
+ timeout?: number;
233
+ }
234
+
235
+ export interface CacheConfig {
236
+ url: string;
237
+ ttl?: number;
238
+ prefix?: string;
239
+ }
240
+
241
+ export interface MessagingConfig {
242
+ url: string;
243
+ exchange?: string;
244
+ queue?: string;
245
+ }
18
246
 
19
- // Domain Types
20
- {{ domain_types }}
247
+ export interface MonitoringConfig {
248
+ enabled: boolean;
249
+ endpoint?: string;
250
+ interval?: number;
251
+ }