@paths.design/caws-cli 7.0.2 → 7.0.3
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/dist/budget-derivation.js +5 -4
- package/dist/commands/diagnose.js +24 -19
- package/dist/commands/init.js +51 -4
- package/dist/commands/specs.js +40 -1
- package/dist/commands/status.js +2 -2
- package/dist/commands/tool.js +2 -3
- package/dist/config/index.js +17 -8
- package/dist/generators/working-spec.js +19 -6
- package/dist/scaffold/git-hooks.js +127 -29
- package/dist/scaffold/index.js +53 -7
- package/dist/templates/.caws/tools/README.md +20 -0
- package/dist/templates/.cursor/README.md +311 -0
- package/dist/templates/.cursor/hooks/audit.sh +55 -0
- package/dist/templates/.cursor/hooks/block-dangerous.sh +83 -0
- package/dist/templates/.cursor/hooks/caws-quality-check.sh +52 -0
- package/dist/templates/.cursor/hooks/caws-scope-guard.sh +130 -0
- package/dist/templates/.cursor/hooks/caws-tool-validation.sh +121 -0
- package/dist/templates/.cursor/hooks/format.sh +38 -0
- package/dist/templates/.cursor/hooks/naming-check.sh +64 -0
- package/dist/templates/.cursor/hooks/scan-secrets.sh +46 -0
- package/dist/templates/.cursor/hooks/scope-guard.sh +52 -0
- package/dist/templates/.cursor/hooks/validate-spec.sh +83 -0
- package/dist/templates/.cursor/hooks.json +59 -0
- package/dist/templates/.cursor/rules/00-claims-verification.mdc +144 -0
- package/dist/templates/.cursor/rules/01-working-style.mdc +50 -0
- package/dist/templates/.cursor/rules/02-quality-gates.mdc +370 -0
- package/dist/templates/.cursor/rules/03-naming-and-refactor.mdc +33 -0
- package/dist/templates/.cursor/rules/04-logging-language-style.mdc +23 -0
- package/dist/templates/.cursor/rules/05-safe-defaults-guards.mdc +23 -0
- package/dist/templates/.cursor/rules/06-typescript-conventions.mdc +36 -0
- package/dist/templates/.cursor/rules/07-process-ops.mdc +20 -0
- package/dist/templates/.cursor/rules/08-solid-and-architecture.mdc +16 -0
- package/dist/templates/.cursor/rules/09-docstrings.mdc +89 -0
- package/dist/templates/.cursor/rules/10-documentation-quality-standards.mdc +390 -0
- package/dist/templates/.cursor/rules/11-scope-management-waivers.mdc +385 -0
- package/dist/templates/.cursor/rules/12-implementation-completeness.mdc +516 -0
- package/dist/templates/.cursor/rules/13-language-agnostic-standards.mdc +588 -0
- package/dist/templates/.cursor/rules/README.md +148 -0
- package/dist/templates/.github/copilot/instructions.md +311 -0
- package/dist/templates/.idea/runConfigurations/CAWS_Evaluate.xml +5 -0
- package/dist/templates/.idea/runConfigurations/CAWS_Validate.xml +5 -0
- package/dist/templates/.vscode/launch.json +56 -0
- package/dist/templates/.vscode/settings.json +93 -0
- package/dist/templates/.windsurf/workflows/caws-guided-development.md +92 -0
- package/dist/templates/COMMIT_CONVENTIONS.md +86 -0
- package/dist/templates/OIDC_SETUP.md +300 -0
- package/dist/templates/agents.md +1047 -0
- package/dist/templates/codemod/README.md +1 -0
- package/dist/templates/codemod/test.js +93 -0
- package/dist/templates/docs/README.md +150 -0
- package/dist/templates/scripts/quality-gates/check-god-objects.js +146 -0
- package/dist/templates/scripts/quality-gates/run-quality-gates.js +50 -0
- package/dist/templates/scripts/v3/analysis/todo_analyzer.py +1997 -0
- package/dist/tool-loader.js +6 -1
- package/dist/tool-validator.js +8 -2
- package/dist/utils/detection.js +4 -3
- package/dist/utils/git-lock.js +118 -0
- package/dist/utils/gitignore-updater.js +148 -0
- package/dist/utils/quality-gates.js +47 -7
- package/dist/utils/spec-resolver.js +23 -3
- package/dist/utils/yaml-validation.js +155 -0
- package/dist/validation/spec-validation.js +81 -2
- package/package.json +2 -2
- package/templates/.caws/schemas/waivers.schema.json +30 -0
- package/templates/.caws/schemas/working-spec.schema.json +133 -0
- package/templates/.caws/templates/working-spec.template.yml +74 -0
- package/templates/.caws/tools/README.md +20 -0
- package/templates/.caws/tools/scope-guard.js +208 -0
- package/templates/.caws/tools-allow.json +331 -0
- package/templates/.caws/waivers.yml +19 -0
- package/templates/.cursor/hooks/scope-guard.sh +2 -2
- package/templates/.cursor/hooks/validate-spec.sh +42 -7
- package/templates/apps/tools/caws/COMPLETION_REPORT.md +0 -331
- package/templates/apps/tools/caws/MIGRATION_SUMMARY.md +0 -360
- package/templates/apps/tools/caws/README.md +0 -463
- package/templates/apps/tools/caws/TEST_STATUS.md +0 -365
- package/templates/apps/tools/caws/attest.js +0 -357
- package/templates/apps/tools/caws/ci-optimizer.js +0 -642
- package/templates/apps/tools/caws/config.ts +0 -245
- package/templates/apps/tools/caws/cross-functional.js +0 -876
- package/templates/apps/tools/caws/dashboard.js +0 -1112
- package/templates/apps/tools/caws/flake-detector.ts +0 -362
- package/templates/apps/tools/caws/gates.js +0 -198
- package/templates/apps/tools/caws/gates.ts +0 -271
- package/templates/apps/tools/caws/language-adapters.ts +0 -381
- package/templates/apps/tools/caws/language-support.d.ts +0 -367
- package/templates/apps/tools/caws/language-support.d.ts.map +0 -1
- package/templates/apps/tools/caws/language-support.js +0 -585
- package/templates/apps/tools/caws/legacy-assessment.ts +0 -408
- package/templates/apps/tools/caws/legacy-assessor.js +0 -764
- package/templates/apps/tools/caws/mutant-analyzer.js +0 -734
- package/templates/apps/tools/caws/perf-budgets.ts +0 -349
- package/templates/apps/tools/caws/prompt-lint.js.backup +0 -274
- package/templates/apps/tools/caws/property-testing.js +0 -707
- package/templates/apps/tools/caws/provenance.d.ts +0 -14
- package/templates/apps/tools/caws/provenance.d.ts.map +0 -1
- package/templates/apps/tools/caws/provenance.js +0 -132
- package/templates/apps/tools/caws/provenance.js.backup +0 -73
- package/templates/apps/tools/caws/provenance.ts +0 -211
- package/templates/apps/tools/caws/security-provenance.ts +0 -483
- package/templates/apps/tools/caws/shared/base-tool.ts +0 -281
- package/templates/apps/tools/caws/shared/config-manager.ts +0 -366
- package/templates/apps/tools/caws/shared/gate-checker.ts +0 -849
- package/templates/apps/tools/caws/shared/types.ts +0 -444
- package/templates/apps/tools/caws/shared/validator.ts +0 -305
- package/templates/apps/tools/caws/shared/waivers-manager.ts +0 -174
- package/templates/apps/tools/caws/spec-test-mapper.ts +0 -391
- package/templates/apps/tools/caws/test-quality.js +0 -578
- package/templates/apps/tools/caws/validate.js +0 -76
- package/templates/apps/tools/caws/validate.ts +0 -228
- package/templates/apps/tools/caws/waivers.js +0 -344
- /package/{templates/apps/tools/caws → dist/templates/.caws}/schemas/waivers.schema.json +0 -0
- /package/{templates/apps/tools/caws → dist/templates/.caws}/schemas/working-spec.schema.json +0 -0
- /package/{templates/apps/tools/caws → dist/templates/.caws}/templates/working-spec.template.yml +0 -0
- /package/{templates/apps/tools/caws → dist/templates/.caws/tools}/scope-guard.js +0 -0
- /package/{templates/apps/tools/caws → dist/templates/.caws}/tools-allow.json +0 -0
- /package/{templates/apps/tools/caws → dist/templates/.caws}/waivers.yml +0 -0
|
@@ -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.
|