@paths.design/caws-cli 4.0.0 → 5.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 (119) hide show
  1. package/dist/commands/archive.js +353 -0
  2. package/dist/commands/iterate.js +12 -13
  3. package/dist/commands/mode.js +259 -0
  4. package/dist/commands/plan.js +448 -0
  5. package/dist/commands/quality-gates.js +490 -0
  6. package/dist/commands/specs.js +735 -0
  7. package/dist/commands/status.js +552 -22
  8. package/dist/commands/tutorial.js +481 -0
  9. package/dist/commands/validate.js +137 -54
  10. package/dist/commands/waivers.js +101 -26
  11. package/dist/config/modes.js +321 -0
  12. package/dist/constants/spec-types.js +42 -0
  13. package/dist/index.js +225 -10
  14. package/dist/scaffold/git-hooks.js +32 -44
  15. package/dist/scaffold/index.js +19 -0
  16. package/dist/utils/quality-gates-errors.js +520 -0
  17. package/dist/utils/quality-gates.js +361 -0
  18. package/dist/utils/spec-resolver.js +602 -0
  19. package/dist/waivers-manager.js +49 -4
  20. package/package.json +6 -5
  21. package/templates/.cursor/hooks/caws-scope-guard.sh +64 -8
  22. package/templates/.cursor/hooks/validate-spec.sh +22 -12
  23. package/templates/.cursor/rules/{01-claims-verification.mdc → 00-claims-verification.mdc} +1 -1
  24. package/templates/.cursor/rules/01-working-style.mdc +50 -0
  25. package/templates/.cursor/rules/{02-testing-standards.mdc → 02-quality-gates.mdc} +84 -29
  26. package/templates/.cursor/rules/03-naming-and-refactor.mdc +33 -0
  27. package/templates/.cursor/rules/04-logging-language-style.mdc +23 -0
  28. package/templates/.cursor/rules/05-safe-defaults-guards.mdc +23 -0
  29. package/templates/.cursor/rules/06-typescript-conventions.mdc +36 -0
  30. package/templates/.cursor/rules/07-process-ops.mdc +20 -0
  31. package/templates/.cursor/rules/08-solid-and-architecture.mdc +16 -0
  32. package/templates/.cursor/rules/09-docstrings.mdc +89 -0
  33. package/templates/.cursor/rules/10-authorship-and-attribution.mdc +15 -0
  34. package/templates/.cursor/rules/11-documentation-quality-standards.mdc +390 -0
  35. package/templates/.cursor/rules/12-scope-management-waivers.mdc +385 -0
  36. package/templates/.cursor/rules/13-implementation-completeness.mdc +516 -0
  37. package/templates/.cursor/rules/14-language-agnostic-standards.mdc +588 -0
  38. package/templates/.cursor/rules/15-sophisticated-todo-detection.mdc +425 -0
  39. package/templates/.cursor/rules/README.md +93 -7
  40. package/templates/scripts/quality-gates/check-god-objects.js +146 -0
  41. package/templates/scripts/quality-gates/run-quality-gates.js +50 -0
  42. package/templates/scripts/v3/analysis/todo_analyzer.py +1950 -0
  43. package/dist/budget-derivation.d.ts +0 -74
  44. package/dist/budget-derivation.d.ts.map +0 -1
  45. package/dist/cicd-optimizer.d.ts +0 -142
  46. package/dist/cicd-optimizer.d.ts.map +0 -1
  47. package/dist/commands/burnup.d.ts +0 -6
  48. package/dist/commands/burnup.d.ts.map +0 -1
  49. package/dist/commands/diagnose.d.ts +0 -52
  50. package/dist/commands/diagnose.d.ts.map +0 -1
  51. package/dist/commands/evaluate.d.ts +0 -8
  52. package/dist/commands/evaluate.d.ts.map +0 -1
  53. package/dist/commands/init.d.ts +0 -5
  54. package/dist/commands/init.d.ts.map +0 -1
  55. package/dist/commands/iterate.d.ts +0 -8
  56. package/dist/commands/iterate.d.ts.map +0 -1
  57. package/dist/commands/provenance.d.ts +0 -32
  58. package/dist/commands/provenance.d.ts.map +0 -1
  59. package/dist/commands/quality-monitor.d.ts +0 -17
  60. package/dist/commands/quality-monitor.d.ts.map +0 -1
  61. package/dist/commands/status.d.ts +0 -43
  62. package/dist/commands/status.d.ts.map +0 -1
  63. package/dist/commands/templates.d.ts +0 -74
  64. package/dist/commands/templates.d.ts.map +0 -1
  65. package/dist/commands/tool.d.ts +0 -13
  66. package/dist/commands/tool.d.ts.map +0 -1
  67. package/dist/commands/troubleshoot.d.ts +0 -8
  68. package/dist/commands/troubleshoot.d.ts.map +0 -1
  69. package/dist/commands/validate.d.ts +0 -8
  70. package/dist/commands/validate.d.ts.map +0 -1
  71. package/dist/commands/waivers.d.ts +0 -8
  72. package/dist/commands/waivers.d.ts.map +0 -1
  73. package/dist/commands/workflow.d.ts +0 -85
  74. package/dist/commands/workflow.d.ts.map +0 -1
  75. package/dist/config/index.d.ts +0 -29
  76. package/dist/config/index.d.ts.map +0 -1
  77. package/dist/error-handler.d.ts +0 -164
  78. package/dist/error-handler.d.ts.map +0 -1
  79. package/dist/generators/jest-config.d.ts +0 -32
  80. package/dist/generators/jest-config.d.ts.map +0 -1
  81. package/dist/generators/working-spec.d.ts +0 -13
  82. package/dist/generators/working-spec.d.ts.map +0 -1
  83. package/dist/index.d.ts +0 -5
  84. package/dist/index.d.ts.map +0 -1
  85. package/dist/minimal-cli.d.ts +0 -3
  86. package/dist/minimal-cli.d.ts.map +0 -1
  87. package/dist/policy/PolicyManager.d.ts +0 -104
  88. package/dist/policy/PolicyManager.d.ts.map +0 -1
  89. package/dist/scaffold/cursor-hooks.d.ts +0 -7
  90. package/dist/scaffold/cursor-hooks.d.ts.map +0 -1
  91. package/dist/scaffold/git-hooks.d.ts +0 -20
  92. package/dist/scaffold/git-hooks.d.ts.map +0 -1
  93. package/dist/scaffold/index.d.ts +0 -20
  94. package/dist/scaffold/index.d.ts.map +0 -1
  95. package/dist/spec/SpecFileManager.d.ts +0 -146
  96. package/dist/spec/SpecFileManager.d.ts.map +0 -1
  97. package/dist/test-analysis.d.ts +0 -182
  98. package/dist/test-analysis.d.ts.map +0 -1
  99. package/dist/tool-interface.d.ts +0 -236
  100. package/dist/tool-interface.d.ts.map +0 -1
  101. package/dist/tool-loader.d.ts +0 -77
  102. package/dist/tool-loader.d.ts.map +0 -1
  103. package/dist/tool-validator.d.ts +0 -72
  104. package/dist/tool-validator.d.ts.map +0 -1
  105. package/dist/utils/detection.d.ts +0 -7
  106. package/dist/utils/detection.d.ts.map +0 -1
  107. package/dist/utils/finalization.d.ts +0 -17
  108. package/dist/utils/finalization.d.ts.map +0 -1
  109. package/dist/utils/project-analysis.d.ts +0 -14
  110. package/dist/utils/project-analysis.d.ts.map +0 -1
  111. package/dist/utils/typescript-detector.d.ts +0 -63
  112. package/dist/utils/typescript-detector.d.ts.map +0 -1
  113. package/dist/validation/spec-validation.d.ts +0 -43
  114. package/dist/validation/spec-validation.d.ts.map +0 -1
  115. package/dist/waivers-manager.d.ts +0 -167
  116. package/dist/waivers-manager.d.ts.map +0 -1
  117. package/templates/.cursor/rules/03-infrastructure-standards.mdc +0 -251
  118. package/templates/.cursor/rules/04-documentation-integrity.mdc +0 -291
  119. package/templates/.cursor/rules/05-production-readiness-checklist.mdc +0 -214
@@ -0,0 +1,516 @@
1
+ ---
2
+ description: Anti-fake implementation guardrails to prevent incomplete, stubbed, or fake implementations
3
+ globs:
4
+ alwaysApply: true
5
+ ---
6
+
7
+ # Implementation Completeness Guardrails
8
+
9
+ ## Core Principle
10
+
11
+ **No incomplete, stubbed, or fake implementations in production code.** All business logic must be fully implemented with proper error handling and real integrations.
12
+
13
+ ## Implementation Quality Detection
14
+
15
+ ### PLACEHOLDER Detection
16
+
17
+ **Automated Detection Patterns:**
18
+
19
+ ```bash
20
+ # Find all placeholder implementations
21
+ rg -n "PLACEHOLDER|TODO|MOCK_DATA|FIXME|HACK" src/
22
+ rg -n "throw new Error.*not implemented" src/
23
+ rg -n "return.*mock|fake|dummy" src/
24
+ rg -n "console\.log.*placeholder" src/
25
+ ```
26
+
27
+ **Required Tagging:**
28
+
29
+ ```typescript
30
+ // PLACEHOLDER: Real payment processing not implemented
31
+ function processPayment(amount: number): Promise<PaymentResult> {
32
+ throw new Error('PLACEHOLDER: Payment processing not implemented');
33
+ }
34
+
35
+ // TODO: Implement actual tax calculation
36
+ function calculateTax(amount: number): number {
37
+ if (process.env.NODE_ENV === 'production') {
38
+ throw new Error('TODO: Tax calculation must be implemented before production');
39
+ }
40
+ return amount * 0.1; // Mock calculation
41
+ }
42
+
43
+ // MOCK DATA: Remove before production
44
+ const mockUsers = [{ id: 1, name: 'John Doe', email: 'john@example.com' }];
45
+ ```
46
+
47
+ ### Stub Implementation Prevention
48
+
49
+ **Forbidden Patterns:**
50
+
51
+ ```typescript
52
+ // ❌ BAD: Silent stub implementation
53
+ function getUserData(id: string) {
54
+ return { id, name: 'Mock User' }; // No indication this is fake
55
+ }
56
+
57
+ // ❌ BAD: Console.log stub
58
+ function processOrder(order: Order) {
59
+ console.log('Processing order:', order); // Not real implementation
60
+ return { success: true };
61
+ }
62
+
63
+ // ❌ BAD: Empty implementation
64
+ function calculateTotal(items: Item[]) {
65
+ // Implementation coming soon
66
+ return 0;
67
+ }
68
+ ```
69
+
70
+ **Required Patterns:**
71
+
72
+ ```typescript
73
+ // ✅ GOOD: Explicit placeholder with error
74
+ function getUserData(id: string) {
75
+ // PLACEHOLDER: Real user data fetching not implemented
76
+ throw new Error('PLACEHOLDER: getUserData not implemented');
77
+ }
78
+
79
+ // ✅ GOOD: Proper implementation
80
+ function processOrder(order: Order) {
81
+ const total = calculateTotal(order.items);
82
+ const tax = calculateTax(total);
83
+ return { success: true, total, tax };
84
+ }
85
+ ```
86
+
87
+ ## Fake Persistence Detection
88
+
89
+ ### Database Mock Detection
90
+
91
+ **Forbidden Patterns:**
92
+
93
+ ```typescript
94
+ // ❌ BAD: In-memory "database"
95
+ class UserRepository {
96
+ private users: User[] = []; // Not real persistence
97
+
98
+ async save(user: User) {
99
+ this.users.push(user); // Fake persistence
100
+ }
101
+ }
102
+
103
+ // ❌ BAD: Mock database operations
104
+ async function createUser(userData: CreateUserRequest) {
105
+ // Mock database call
106
+ return { id: Math.random(), ...userData };
107
+ }
108
+ ```
109
+
110
+ **Required Patterns:**
111
+
112
+ ```typescript
113
+ // ✅ GOOD: Real database implementation
114
+ class UserRepository {
115
+ constructor(private db: Database) {}
116
+
117
+ async save(user: User) {
118
+ const result = await this.db.query(
119
+ 'INSERT INTO users (name, email) VALUES ($1, $2) RETURNING *',
120
+ [user.name, user.email]
121
+ );
122
+ return result.rows[0];
123
+ }
124
+ }
125
+ ```
126
+
127
+ ### API Mock Detection
128
+
129
+ **Forbidden Patterns:**
130
+
131
+ ```typescript
132
+ // ❌ BAD: Fake API responses
133
+ async function fetchUserData(id: string) {
134
+ // Mock API response
135
+ return { id, name: 'Mock User', email: 'mock@example.com' };
136
+ }
137
+
138
+ // ❌ BAD: Hardcoded responses
139
+ async function getWeatherData(city: string) {
140
+ return { city, temperature: 72, condition: 'sunny' }; // Fake data
141
+ }
142
+ ```
143
+
144
+ **Required Patterns:**
145
+
146
+ ```typescript
147
+ // ✅ GOOD: Real API implementation
148
+ async function fetchUserData(id: string) {
149
+ const response = await fetch(`/api/users/${id}`, {
150
+ headers: { Authorization: `Bearer ${token}` },
151
+ });
152
+
153
+ if (!response.ok) {
154
+ throw new Error(`Failed to fetch user: ${response.statusText}`);
155
+ }
156
+
157
+ return await response.json();
158
+ }
159
+ ```
160
+
161
+ ## Business Logic Completeness
162
+
163
+ ### Core Business Functions
164
+
165
+ **Must be fully implemented:**
166
+
167
+ - Authentication and authorization
168
+ - Data validation and sanitization
169
+ - Business rule enforcement
170
+ - Error handling and recovery
171
+ - Audit logging and monitoring
172
+
173
+ **Implementation Requirements:**
174
+
175
+ ```typescript
176
+ // ✅ GOOD: Complete business logic
177
+ class OrderService {
178
+ async processOrder(order: Order): Promise<OrderResult> {
179
+ // Validate input
180
+ if (!order.items || order.items.length === 0) {
181
+ throw new ValidationError('Order must contain items');
182
+ }
183
+
184
+ // Check inventory
185
+ const inventoryCheck = await this.inventoryService.checkAvailability(order.items);
186
+ if (!inventoryCheck.available) {
187
+ throw new InsufficientInventoryError(inventoryCheck.unavailableItems);
188
+ }
189
+
190
+ // Calculate pricing
191
+ const pricing = await this.pricingService.calculateOrder(order);
192
+
193
+ // Process payment
194
+ const payment = await this.paymentService.processPayment({
195
+ amount: pricing.total,
196
+ method: order.paymentMethod,
197
+ });
198
+
199
+ // Create order record
200
+ const orderRecord = await this.orderRepository.create({
201
+ ...order,
202
+ total: pricing.total,
203
+ paymentId: payment.id,
204
+ status: 'confirmed',
205
+ });
206
+
207
+ // Send confirmation
208
+ await this.notificationService.sendOrderConfirmation(orderRecord);
209
+
210
+ return {
211
+ orderId: orderRecord.id,
212
+ total: pricing.total,
213
+ estimatedDelivery: pricing.estimatedDelivery,
214
+ };
215
+ }
216
+ }
217
+ ```
218
+
219
+ ## Quality Gates for Implementation
220
+
221
+ ### Pre-Production Checks
222
+
223
+ **Automated Verification:**
224
+
225
+ ```bash
226
+ # Check for incomplete implementations
227
+ npm run check:completeness
228
+ # - Scan for PLACEHOLDER/TODO/MOCK_DATA
229
+ # - Verify all business logic is implemented
230
+ # - Check for real database connections
231
+ # - Validate API integrations
232
+
233
+ # Check for fake persistence
234
+ npm run check:persistence
235
+ # - Verify database connections are real
236
+ # - Check for in-memory storage patterns
237
+ # - Validate migration scripts exist
238
+ ```
239
+
240
+ ### Implementation Completeness Matrix
241
+
242
+ | Component | Real DB | Real APIs | Error Handling | Validation | Logging |
243
+ | ------------------- | ----------- | ----------- | -------------- | ----------- | ----------- |
244
+ | **Auth** | ✅ Required | ✅ Required | ✅ Required | ✅ Required | ✅ Required |
245
+ | **Billing** | ✅ Required | ✅ Required | ✅ Required | ✅ Required | ✅ Required |
246
+ | **Data Processing** | ✅ Required | ✅ Required | ✅ Required | ✅ Required | ✅ Required |
247
+ | **UI Components** | N/A | ✅ Required | ✅ Required | ✅ Required | Optional |
248
+ | **Utilities** | N/A | ✅ Required | ✅ Required | ✅ Required | Optional |
249
+
250
+ ## Advanced Detection Patterns
251
+
252
+ ### Hidden TODO Detection
253
+
254
+ **High-Confidence Hidden TODO Patterns:**
255
+
256
+ ```python
257
+ # Sophisticated patterns for detecting incomplete implementations
258
+ high_confidence_patterns = {
259
+ 'incomplete_implementation': [
260
+ r'\bnot\s+yet\s+implemented\b',
261
+ r'\bmissing\s+implementation\b',
262
+ r'\bincomplete\s+implementation\b',
263
+ r'\bpartial\s+implementation\b',
264
+ r'\bunimplemented\b',
265
+ r'\bnot\s+done\b',
266
+ r'\bpending\s+implementation\b',
267
+ r'\bto\s+be\s+implemented\b',
268
+ r'\bwill\s+be\s+implemented\b',
269
+ ],
270
+
271
+ 'placeholder_code': [
272
+ r'\bplaceholder\s+code\b',
273
+ r'\bplaceholder\s+implementation\b',
274
+ r'\bstub\s+implementation\b',
275
+ r'\bdummy\s+implementation\b',
276
+ r'\bfake\s+implementation\b',
277
+ r'\bsimplified\s+.*?\s+implementation\b',
278
+ r'\bfor\s+now\b.*?(just|simply|only)\s+(concatenate|return|use)',
279
+ ],
280
+
281
+ 'temporary_solutions': [
282
+ r'\btemporary\s+solution\b',
283
+ r'\btemporary\s+fix\b',
284
+ r'\bquick\s+fix\b',
285
+ r'\bworkaround\b',
286
+ r'\bhack\b.*?(fix|solution)',
287
+ ],
288
+
289
+ 'hardcoded_values': [
290
+ r'\bhardcoded\s+value\b',
291
+ r'\bmagic\s+number\b',
292
+ r'\bmagic\s+string\b',
293
+ r'\bconstant\s+value\b.*?(replace|change|make\s+configurable)',
294
+ ],
295
+
296
+ 'future_improvements': [
297
+ r'\bin\s+production\b.*?(implement|add|fix)',
298
+ r'\bin\s+a\s+real\s+implementation\b',
299
+ r'\beventually\b.*?(implement|add|fix)',
300
+ r'\bshould\s+be\b.*?(implemented|added|fixed)',
301
+ r'\bwould\s+be\b.*?(implemented|added|fixed)',
302
+ ],
303
+ }
304
+ ```
305
+
306
+ **Code Stub Detection:**
307
+
308
+ ```python
309
+ # Language-specific stub patterns
310
+ code_stub_patterns = {
311
+ 'javascript': {
312
+ 'function_stub': re.compile(r'^\s*(async\s+)?function\s+\w+\(.*\)\s*{'),
313
+ 'throw_not_impl': re.compile(r"^\s*throw\s+new\s+Error\((\"|')(TODO|Not\s+Implemented)"),
314
+ 'return_todo': re.compile(r"^\s*return\s+(null|undefined);\s*//\s*TODO"),
315
+ },
316
+ 'typescript': {
317
+ 'function_stub': re.compile(r'^\s*(async\s+)?function\s+\w+\(.*\)\s*{'),
318
+ 'throw_not_impl': re.compile(r"^\s*throw\s+new\s+Error\((\"|')(TODO|Not\s+Implemented)"),
319
+ 'return_todo': re.compile(r"^\s*return\s+(null|undefined);\s*//\s*TODO"),
320
+ },
321
+ 'python': {
322
+ 'function_stub': re.compile(r'^\s*def\s+\w+\(.*\):'),
323
+ 'pass_stmt': re.compile(r'^\s*pass\s*$'),
324
+ 'ellipsis_stmt': re.compile(r'^\s*\.\.\.\s*$'),
325
+ 'raise_not_impl': re.compile(r'^\s*raise\s+NotImplementedError'),
326
+ },
327
+ }
328
+ ```
329
+
330
+ ## Enforcement Mechanisms
331
+
332
+ ### Pre-Commit Hooks
333
+
334
+ ```bash
335
+ # Check for incomplete implementations
336
+ check-implementation-completeness() {
337
+ echo "🔍 Running implementation completeness check..."
338
+
339
+ # Check for placeholder implementations
340
+ local placeholders=$(git diff --cached | grep -E "PLACEHOLDER|TODO|MOCK_DATA" | wc -l)
341
+ if [ "$placeholders" -gt 0 ]; then
342
+ echo "❌ Found $placeholders placeholder implementations"
343
+ echo "All business logic must be fully implemented"
344
+ exit 1
345
+ fi
346
+
347
+ # Check for fake persistence patterns
348
+ local fake_persistence=$(git diff --cached | grep -E "private.*\[\]|mock.*database|fake.*persistence" | wc -l)
349
+ if [ "$fake_persistence" -gt 0 ]; then
350
+ echo "❌ Found $fake_persistence fake persistence patterns"
351
+ echo "Real database connections required"
352
+ exit 1
353
+ fi
354
+
355
+ echo "✅ No incomplete implementations found"
356
+ }
357
+ ```
358
+
359
+ ### CI/CD Integration
360
+
361
+ ```yaml
362
+ # Implementation completeness checks
363
+ - name: Check Implementation Completeness
364
+ run: |
365
+ echo "🔍 Running implementation completeness analysis..."
366
+
367
+ # Check for placeholder implementations
368
+ placeholder_count=$(grep -r "PLACEHOLDER\|TODO\|MOCK_DATA" src/ | wc -l)
369
+ if [ "$placeholder_count" -gt 0 ]; then
370
+ echo "❌ Found $placeholder_count placeholder implementations"
371
+ echo "All business logic must be fully implemented"
372
+ exit 1
373
+ fi
374
+
375
+ # Check for fake persistence
376
+ fake_persistence_count=$(grep -r "private.*\[\]\|mock.*database\|fake.*persistence" src/ | wc -l)
377
+ if [ "$fake_persistence_count" -gt 0 ]; then
378
+ echo "❌ Found $fake_persistence_count fake persistence patterns"
379
+ echo "Real database connections required"
380
+ exit 1
381
+ fi
382
+
383
+ echo "✅ No incomplete implementations found"
384
+
385
+ - name: Check for Hidden TODOs
386
+ run: |
387
+ # Use sophisticated pattern detection
388
+ hidden_todos=$(grep -r -E "(not yet implemented|missing implementation|incomplete implementation|partial implementation|unimplemented|not done|pending implementation|to be implemented|will be implemented)" src/ | wc -l)
389
+ if [ "$hidden_todos" -gt 0 ]; then
390
+ echo "❌ Found $hidden_todos hidden incomplete implementations"
391
+ echo "All implementations must be complete"
392
+ exit 1
393
+ fi
394
+
395
+ echo "✅ No hidden incomplete implementations found"
396
+ ```
397
+
398
+ ## Testing Requirements
399
+
400
+ ### Implementation Testing
401
+
402
+ **Must test real implementations:**
403
+
404
+ ```typescript
405
+ // ✅ GOOD: Test real database operations
406
+ describe('UserRepository', () => {
407
+ let db: Database;
408
+
409
+ beforeEach(async () => {
410
+ db = await createTestDatabase();
411
+ await seedTestData(db);
412
+ });
413
+
414
+ afterEach(async () => {
415
+ await cleanupTestData(db);
416
+ await db.end();
417
+ });
418
+
419
+ it('should save user to database', async () => {
420
+ const user = { name: 'John Doe', email: 'john@example.com' };
421
+ const savedUser = await userRepository.save(user);
422
+
423
+ expect(savedUser.id).toBeDefined();
424
+ expect(savedUser.name).toBe(user.name);
425
+
426
+ // Verify in database
427
+ const dbUser = await db.query('SELECT * FROM users WHERE id = $1', [savedUser.id]);
428
+ expect(dbUser.rows[0]).toEqual(savedUser);
429
+ });
430
+ });
431
+ ```
432
+
433
+ **Forbidden test patterns:**
434
+
435
+ ```typescript
436
+ // ❌ BAD: Mock the system under test
437
+ jest.mock('./userRepository', () => ({
438
+ save: jest.fn(() => ({ id: 1, name: 'Mock User' })),
439
+ }));
440
+
441
+ // ❌ BAD: Test fake implementations
442
+ test('save user', () => {
443
+ const result = userRepository.save({ name: 'John' });
444
+ expect(result.name).toBe('John'); // Tests mock, not real implementation
445
+ });
446
+ ```
447
+
448
+ ## Quality Metrics
449
+
450
+ ### Implementation Completeness Score
451
+
452
+ **Calculation Formula:**
453
+
454
+ ```python
455
+ def calculate_completeness_score(analysis_results):
456
+ total_files = analysis_results['total_files']
457
+ files_with_todos = analysis_results['files_with_todos']
458
+ high_conf_todos = analysis_results['high_confidence_todos']
459
+
460
+ # Completeness score (higher is better)
461
+ completeness_score = 1.0 - (files_with_todos / total_files) if total_files > 0 else 1.0
462
+
463
+ # Quality score based on confidence levels
464
+ quality_score = 1.0 - (high_conf_todos / total_files) if total_files > 0 else 1.0
465
+
466
+ return {
467
+ 'completeness_score': completeness_score,
468
+ 'quality_score': quality_score,
469
+ 'files_with_todos': files_with_todos,
470
+ 'high_confidence_todos': high_conf_todos,
471
+ 'total_files_analyzed': total_files
472
+ }
473
+ ```
474
+
475
+ **Anti-Pattern Detection Metrics:**
476
+
477
+ - **Placeholder Density**: Number of high-confidence TODOs per 1000 lines
478
+ - **Stub Implementation Rate**: % of functions with stub patterns detected
479
+ - **Temporary Solution Rate**: % of code marked as temporary/workaround
480
+ - **Hardcoded Value Rate**: % of magic numbers/strings detected
481
+
482
+ ## Integration with CAWS
483
+
484
+ ### CAWS Quality Monitoring
485
+
486
+ ```bash
487
+ # Use CAWS quality monitoring
488
+ caws quality-monitor --action=code_edited --files="$(git diff --name-only)"
489
+
490
+ # Track TODO resolution progress
491
+ caws progress-update --criterion-id="TODO-001" --status="completed" --tests-passing=1
492
+ ```
493
+
494
+ ### Continuous Improvement
495
+
496
+ **Monthly Audits:**
497
+
498
+ ```bash
499
+ # Generate monthly completeness report
500
+ grep -r "PLACEHOLDER\|TODO\|MOCK_DATA" src/ > monthly-todo-report.txt
501
+ grep -r -E "(not yet implemented|missing implementation|incomplete implementation)" src/ > monthly-hidden-todos.txt
502
+
503
+ # Track trends over time
504
+ echo "Implementation completeness trends:" >> monthly-report.md
505
+ echo "- Placeholder implementations: $(wc -l < monthly-todo-report.txt)" >> monthly-report.md
506
+ echo "- Hidden incomplete implementations: $(wc -l < monthly-hidden-todos.txt)" >> monthly-report.md
507
+ ```
508
+
509
+ **Quarterly Reviews:**
510
+
511
+ - Full implementation audit across entire codebase
512
+ - Review integration reality and persistence patterns
513
+ - Update quality gates based on project evolution
514
+ - Refine detection patterns based on new anti-patterns
515
+
516
+ This rule ensures all implementations are complete, real, and production-ready, preventing the accumulation of incomplete or fake code that could cause production issues.