specky-sdd 2.0.0 → 2.2.2
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/CHANGELOG.md +93 -0
- package/README.md +803 -88
- package/SECURITY.md +110 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +66 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +100 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +112 -1
- package/dist/constants.js.map +1 -1
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/dist/schemas/environment.d.ts +12 -37
- package/dist/schemas/environment.d.ts.map +1 -1
- package/dist/schemas/infrastructure.d.ts +22 -42
- package/dist/schemas/infrastructure.d.ts.map +1 -1
- package/dist/schemas/input.d.ts +13 -34
- package/dist/schemas/input.d.ts.map +1 -1
- package/dist/schemas/integration.d.ts +12 -80
- package/dist/schemas/integration.d.ts.map +1 -1
- package/dist/schemas/pipeline.d.ts +24 -230
- package/dist/schemas/pipeline.d.ts.map +1 -1
- package/dist/schemas/quality.d.ts +27 -39
- package/dist/schemas/quality.d.ts.map +1 -1
- package/dist/schemas/quality.js +13 -0
- package/dist/schemas/quality.js.map +1 -1
- package/dist/schemas/testing.d.ts +23 -0
- package/dist/schemas/testing.d.ts.map +1 -0
- package/dist/schemas/testing.js +26 -0
- package/dist/schemas/testing.js.map +1 -0
- package/dist/schemas/transcript.d.ts +18 -40
- package/dist/schemas/transcript.d.ts.map +1 -1
- package/dist/schemas/utility.d.ts +33 -65
- package/dist/schemas/utility.d.ts.map +1 -1
- package/dist/schemas/visualization.d.ts +28 -39
- package/dist/schemas/visualization.d.ts.map +1 -1
- package/dist/services/test-generator.d.ts +61 -0
- package/dist/services/test-generator.d.ts.map +1 -0
- package/dist/services/test-generator.js +217 -0
- package/dist/services/test-generator.js.map +1 -0
- package/dist/tools/input.d.ts.map +1 -1
- package/dist/tools/input.js +12 -0
- package/dist/tools/input.js.map +1 -1
- package/dist/tools/integration.d.ts.map +1 -1
- package/dist/tools/integration.js +24 -0
- package/dist/tools/integration.js.map +1 -1
- package/dist/tools/quality.d.ts +3 -2
- package/dist/tools/quality.d.ts.map +1 -1
- package/dist/tools/quality.js +84 -3
- package/dist/tools/quality.js.map +1 -1
- package/dist/tools/testing.d.ts +9 -0
- package/dist/tools/testing.d.ts.map +1 -0
- package/dist/tools/testing.js +130 -0
- package/dist/tools/testing.js.map +1 -0
- package/dist/tools/utility.d.ts.map +1 -1
- package/dist/tools/utility.js +36 -1
- package/dist/tools/utility.js.map +1 -1
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -1
- package/hooks/auto-docs.md +53 -0
- package/hooks/auto-test.md +61 -0
- package/hooks/changelog.md +74 -0
- package/hooks/security-scan.md +72 -0
- package/hooks/spec-sync.md +80 -0
- package/hooks/srp-validator.md +86 -0
- package/package.json +14 -5
- package/references/design-patterns.md +434 -0
- package/references/ears-notation.md +605 -0
- package/references/spec-templates.md +936 -0
- package/templates/analysis.md +1 -0
- package/templates/api-docs.md +1 -0
- package/templates/bugfix.md +1 -0
- package/templates/checklist.md +1 -0
- package/templates/compliance.md +1 -0
- package/templates/constitution.md +1 -0
- package/templates/cross-analysis.md +1 -0
- package/templates/data-model.md +1 -0
- package/templates/design.md +1 -0
- package/templates/devcontainer.md +1 -0
- package/templates/dockerfile.md +1 -0
- package/templates/onboarding.md +1 -0
- package/templates/research.md +1 -0
- package/templates/runbook.md +1 -0
- package/templates/specification.md +1 -0
- package/templates/sync-report.md +1 -0
- package/templates/tasks.md +3 -2
- package/templates/terraform.md +1 -0
- package/templates/test-stub.md +34 -0
- package/templates/user-stories.md +1 -0
- package/templates/verification.md +1 -0
- package/templates/work-items.md +1 -0
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: EARS Notation Guide for Specification Writing
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
date: 2026-03-20
|
|
5
|
+
author: Claude
|
|
6
|
+
description: Complete reference for Easy Approach to Requirements Syntax (EARS)
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# EARS Notation Guide
|
|
10
|
+
|
|
11
|
+
## Introduction
|
|
12
|
+
|
|
13
|
+
**EARS** (Easy Approach to Requirements Syntax) is a standardized template-based notation for writing clear, unambiguous, testable requirements. This guide provides complete patterns with examples, keywords, and anti-patterns.
|
|
14
|
+
|
|
15
|
+
## Core Principle
|
|
16
|
+
|
|
17
|
+
Every requirement answers three questions:
|
|
18
|
+
1. **When/Where** does this apply? (Context)
|
|
19
|
+
2. **What** shall the system do? (Action)
|
|
20
|
+
3. **Why** matters? (Acceptance criteria)
|
|
21
|
+
|
|
22
|
+
Structure: `[Context] The [system] shall [action] [constraints]`
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Six EARS Requirement Patterns
|
|
27
|
+
|
|
28
|
+
### Pattern 1: Ubiquitous Requirements
|
|
29
|
+
|
|
30
|
+
**Usage:** Requirements that apply at all times, everywhere, with no special conditions
|
|
31
|
+
|
|
32
|
+
**Template:**
|
|
33
|
+
```
|
|
34
|
+
The [system] shall [action].
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Examples:**
|
|
38
|
+
|
|
39
|
+
**Example 1.1: Basic Authentication**
|
|
40
|
+
```
|
|
41
|
+
The system shall authenticate users via email and password.
|
|
42
|
+
```
|
|
43
|
+
✅ **Good:** Clear action, no ambiguity
|
|
44
|
+
- Acceptance Criteria: User can successfully log in with valid email + password
|
|
45
|
+
- Test: curl -X POST /auth/login with valid credentials → 200 OK + token
|
|
46
|
+
|
|
47
|
+
**Example 1.2: API Response Format**
|
|
48
|
+
```
|
|
49
|
+
The system shall return all API responses in JSON format.
|
|
50
|
+
```
|
|
51
|
+
✅ **Good:** Defines standard for all endpoints
|
|
52
|
+
- Acceptance Criteria: Every API endpoint response is valid JSON
|
|
53
|
+
- Test: Validate response headers include "Content-Type: application/json"
|
|
54
|
+
|
|
55
|
+
**Example 1.3: Data Encryption**
|
|
56
|
+
```
|
|
57
|
+
The system shall encrypt all personally identifiable information (PII) at rest.
|
|
58
|
+
```
|
|
59
|
+
✅ **Good:** Clear scope (PII), clear requirement (encryption)
|
|
60
|
+
- Acceptance Criteria: All PII in database is encrypted with AES-256
|
|
61
|
+
- Test: Dump database; verify PII fields are unreadable
|
|
62
|
+
|
|
63
|
+
**Example 1.4: Anti-Example (Vague)**
|
|
64
|
+
```
|
|
65
|
+
❌ The system shall be easy to use.
|
|
66
|
+
Problem: "Easy" is subjective, not testable
|
|
67
|
+
Better: The system shall enable user account creation in <3 clicks
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
### Pattern 2: Event-Driven Requirements
|
|
73
|
+
|
|
74
|
+
**Usage:** Requirements triggered by a specific event or condition
|
|
75
|
+
|
|
76
|
+
**Template:**
|
|
77
|
+
```
|
|
78
|
+
When [event], the [system] shall [action].
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Examples:**
|
|
82
|
+
|
|
83
|
+
**Example 2.1: Login with Incorrect Password**
|
|
84
|
+
```
|
|
85
|
+
When a user submits an incorrect password, the system shall return
|
|
86
|
+
a 401 Unauthorized error and NOT increment the login attempt counter
|
|
87
|
+
until the email is correct.
|
|
88
|
+
```
|
|
89
|
+
✅ **Good:** Specifies trigger (incorrect password), action (401), and constraint
|
|
90
|
+
- Acceptance Criteria: Error returned immediately; counter only increments for valid email
|
|
91
|
+
- Test: Submit wrong password 3x → 401 each time; 4th attempt not rate-limited
|
|
92
|
+
|
|
93
|
+
**Example 2.2: Token Expiration**
|
|
94
|
+
```
|
|
95
|
+
When a user's JWT token expires, the system shall invalidate the token
|
|
96
|
+
and require re-authentication on the next request.
|
|
97
|
+
```
|
|
98
|
+
✅ **Good:** Trigger (expiry), action (invalidate), requirement (re-auth)
|
|
99
|
+
- Acceptance Criteria: Expired token returns 401 Unauthorized
|
|
100
|
+
- Test: Wait 15+ minutes; attempt authenticated request → 401 Unauthorized
|
|
101
|
+
|
|
102
|
+
**Example 2.3: Payment Failure**
|
|
103
|
+
```
|
|
104
|
+
When a Stripe payment charge fails, the system shall:
|
|
105
|
+
1. Log the failure with error code and timestamp
|
|
106
|
+
2. Notify the user via email within 5 minutes
|
|
107
|
+
3. Mark the order as PAYMENT_FAILED
|
|
108
|
+
4. Queue retry attempt for 24 hours later
|
|
109
|
+
```
|
|
110
|
+
✅ **Good:** Multiple outcomes for single event, all testable
|
|
111
|
+
- Acceptance Criteria: All 4 actions occur in sequence
|
|
112
|
+
- Test: Simulate Stripe payment failure; verify logs, email, order status, queue entry
|
|
113
|
+
|
|
114
|
+
**Example 2.4: Anti-Example (Missing Context)**
|
|
115
|
+
```
|
|
116
|
+
❌ When a user logs in, the system shall authenticate them.
|
|
117
|
+
Problem: "Authenticate them" is vague (method? algorithm? response?)
|
|
118
|
+
Better: When a user submits email and password, the system shall
|
|
119
|
+
verify credentials against the user database and return a JWT token.
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
### Pattern 3: State-Driven Requirements
|
|
125
|
+
|
|
126
|
+
**Usage:** Requirements that apply while the system is in a particular state
|
|
127
|
+
|
|
128
|
+
**Template:**
|
|
129
|
+
```
|
|
130
|
+
While [state], the [system] shall [action].
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Examples:**
|
|
134
|
+
|
|
135
|
+
**Example 3.1: System Maintenance**
|
|
136
|
+
```
|
|
137
|
+
While the system is in MAINTENANCE mode, the system shall:
|
|
138
|
+
1. Return HTTP 503 Service Unavailable to all requests
|
|
139
|
+
2. Display maintenance page to users
|
|
140
|
+
3. Queue API requests for processing after maintenance ends
|
|
141
|
+
4. NOT process payments or critical transactions
|
|
142
|
+
```
|
|
143
|
+
✅ **Good:** Defines behavior for entire state, multiple outcomes
|
|
144
|
+
- Acceptance Criteria: All 4 behaviors occur when status = MAINTENANCE
|
|
145
|
+
- Test: Set system to MAINTENANCE mode; verify 503, queue, no payments
|
|
146
|
+
|
|
147
|
+
**Example 3.2: Network Failure**
|
|
148
|
+
```
|
|
149
|
+
While the database connection is unavailable, the system shall:
|
|
150
|
+
1. Return cached responses for recently accessed data (max 1 hour old)
|
|
151
|
+
2. Queue write operations in Redis for replay after connection restores
|
|
152
|
+
3. Log warnings every 30 seconds
|
|
153
|
+
```
|
|
154
|
+
✅ **Good:** Graceful degradation pattern with fallback behavior
|
|
155
|
+
- Acceptance Criteria: Cache serves reads; writes queue; logs appear
|
|
156
|
+
- Test: Disconnect database; verify cache hits, queue depth, log frequency
|
|
157
|
+
|
|
158
|
+
**Example 3.3: Peak Load Condition**
|
|
159
|
+
```
|
|
160
|
+
While system load exceeds 80% CPU utilization, the system shall
|
|
161
|
+
implement aggressive rate limiting (10 requests/minute per user)
|
|
162
|
+
and auto-scale to additional server instances.
|
|
163
|
+
```
|
|
164
|
+
✅ **Good:** Adaptive behavior based on measurable state
|
|
165
|
+
- Acceptance Criteria: Rate limiting triggers at 80%+ CPU; new instances start
|
|
166
|
+
- Test: Generate load to 80%+ CPU; verify rate limiting, scale-up events
|
|
167
|
+
|
|
168
|
+
**Example 3.4: Anti-Example (Unclear State)**
|
|
169
|
+
```
|
|
170
|
+
❌ While the user is active, the system shall keep their session alive.
|
|
171
|
+
Problem: "Active" is undefined (last keystroke? API call? page view?)
|
|
172
|
+
Better: While a user has made an API request in the last 15 minutes,
|
|
173
|
+
the system shall extend their session timeout another 15 minutes.
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### Pattern 4: Optional Requirements
|
|
179
|
+
|
|
180
|
+
**Usage:** Requirements that apply only under specific conditions
|
|
181
|
+
|
|
182
|
+
**Template:**
|
|
183
|
+
```
|
|
184
|
+
Where [condition], the [system] shall [action].
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Examples:**
|
|
188
|
+
|
|
189
|
+
**Example 4.1: Enterprise Accounts**
|
|
190
|
+
```
|
|
191
|
+
Where the user account type is ENTERPRISE, the system shall:
|
|
192
|
+
1. Enforce single sign-on (SSO) via SAML 2.0
|
|
193
|
+
2. Disable password-based login
|
|
194
|
+
3. Restrict access to IP address whitelist
|
|
195
|
+
4. Provide audit logging of all user actions
|
|
196
|
+
```
|
|
197
|
+
✅ **Good:** Feature toggle for specific user segment
|
|
198
|
+
- Acceptance Criteria: Conditional logic applied only to ENTERPRISE accounts
|
|
199
|
+
- Test: Compare ENTERPRISE user vs standard user; verify SSO, no passwords, audit logs
|
|
200
|
+
|
|
201
|
+
**Example 4.2: High-Value Transactions**
|
|
202
|
+
```
|
|
203
|
+
Where a payment amount exceeds $10,000, the system shall:
|
|
204
|
+
1. Require manual approval from a merchant
|
|
205
|
+
2. Send email notification to merchant
|
|
206
|
+
3. Hold payment in PENDING_APPROVAL status
|
|
207
|
+
4. Expire hold after 48 hours if not approved
|
|
208
|
+
```
|
|
209
|
+
✅ **Good:** Conditional workflow based on numeric threshold
|
|
210
|
+
- Acceptance Criteria: Workflow only triggers for >$10K; all steps occur
|
|
211
|
+
- Test: Create $5K payment (normal flow); create $15K payment (approval flow)
|
|
212
|
+
|
|
213
|
+
**Example 4.3: Mobile Clients**
|
|
214
|
+
```
|
|
215
|
+
Where the API client is a mobile application (User-Agent contains "mobile"),
|
|
216
|
+
the system shall return paginated results (max 50 items per page)
|
|
217
|
+
to reduce bandwidth consumption.
|
|
218
|
+
```
|
|
219
|
+
✅ **Good:** Conditional optimization based on client type
|
|
220
|
+
- Acceptance Criteria: Desktop clients get unpaginated results; mobile gets 50-item pages
|
|
221
|
+
- Test: Call API with desktop User-Agent vs mobile User-Agent; verify pagination
|
|
222
|
+
|
|
223
|
+
**Example 4.4: Anti-Example (Too Many Conditions)**
|
|
224
|
+
```
|
|
225
|
+
❌ Where the user is in the US and the time is between 9 AM and 5 PM
|
|
226
|
+
and it's a weekday and the user has made >10 purchases and...
|
|
227
|
+
the system shall apply a discount.
|
|
228
|
+
Problem: Too complex; hard to test; maintenance nightmare
|
|
229
|
+
Better: Where the user is a Premium member, the system shall apply
|
|
230
|
+
a 10% discount to all purchases.
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
### Pattern 5: Unwanted Behavior Requirements
|
|
236
|
+
|
|
237
|
+
**Usage:** Requirements that specify what the system shall NOT do (negative requirements)
|
|
238
|
+
|
|
239
|
+
**Template:**
|
|
240
|
+
```
|
|
241
|
+
If [unwanted condition], the [system] shall [prevention action].
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Examples:**
|
|
245
|
+
|
|
246
|
+
**Example 5.1: Duplicate Payments**
|
|
247
|
+
```
|
|
248
|
+
If a payment request is submitted twice with identical amount and user
|
|
249
|
+
within 60 seconds, the system shall reject the second request with
|
|
250
|
+
error code DUPLICATE_PAYMENT and NOT charge the customer twice.
|
|
251
|
+
```
|
|
252
|
+
✅ **Good:** Specifies unwanted condition, prevention, error code
|
|
253
|
+
- Acceptance Criteria: Duplicate detection works; second charge prevented
|
|
254
|
+
- Test: Submit same payment 2x rapidly; verify second is rejected, only 1 charge
|
|
255
|
+
|
|
256
|
+
**Example 5.2: SQL Injection**
|
|
257
|
+
```
|
|
258
|
+
If user input contains SQL metacharacters (', ", --, ;), the system
|
|
259
|
+
shall escape or parameterize the input before executing database queries
|
|
260
|
+
to prevent SQL injection attacks.
|
|
261
|
+
```
|
|
262
|
+
✅ **Good:** Specifies security threat, mitigation technique
|
|
263
|
+
- Acceptance Criteria: All user inputs sanitized before database access
|
|
264
|
+
- Test: Submit ' or 1=1 -- as input; verify no SQL injection
|
|
265
|
+
|
|
266
|
+
**Example 5.3: Expired Tokens**
|
|
267
|
+
```
|
|
268
|
+
If a user attempts to use an expired access token, the system shall
|
|
269
|
+
reject the request with 401 Unauthorized and NOT process the requested action.
|
|
270
|
+
```
|
|
271
|
+
✅ **Good:** Clear unwanted scenario, clear prevention
|
|
272
|
+
- Acceptance Criteria: Expired tokens always rejected; no transaction processing
|
|
273
|
+
- Test: Create token, wait 15+ minutes, attempt API call; verify 401
|
|
274
|
+
|
|
275
|
+
**Example 5.4: Concurrent Modifications**
|
|
276
|
+
```
|
|
277
|
+
If two users attempt to modify the same record simultaneously, the
|
|
278
|
+
system shall implement optimistic locking and return 409 Conflict
|
|
279
|
+
to the second user rather than allowing data corruption.
|
|
280
|
+
```
|
|
281
|
+
✅ **Good:** Specifies concurrency scenario, conflict resolution
|
|
282
|
+
- Acceptance Criteria: Concurrent edits detected; second edit fails gracefully
|
|
283
|
+
- Test: Open 2 sessions, edit same record simultaneously; second gets 409
|
|
284
|
+
|
|
285
|
+
**Example 5.5: Anti-Example (Too Vague)**
|
|
286
|
+
```
|
|
287
|
+
❌ If something bad happens, the system shall not crash.
|
|
288
|
+
Problem: "Something bad" undefined; "crash" is vague (error log? downtime?)
|
|
289
|
+
Better: If a required external API is unreachable, the system shall
|
|
290
|
+
log an error and continue processing from cached data, but shall NOT
|
|
291
|
+
stop responding to user requests.
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
### Pattern 6: Complex Requirements (Combinations)
|
|
297
|
+
|
|
298
|
+
**Usage:** Requirements combining multiple patterns for nuanced scenarios
|
|
299
|
+
|
|
300
|
+
**Template:**
|
|
301
|
+
```
|
|
302
|
+
[Pattern 1] ... [Pattern 2] ... [Pattern 3]
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Examples:**
|
|
306
|
+
|
|
307
|
+
**Example 6.1: Multi-Part Authorization**
|
|
308
|
+
```
|
|
309
|
+
When a user with ADMIN role attempts to delete a production database backup,
|
|
310
|
+
where that backup contains customer PII, the system shall:
|
|
311
|
+
1. Require secondary approval from another ADMIN (not the initiator)
|
|
312
|
+
2. Log the deletion request with both admin names, timestamp, and reason
|
|
313
|
+
3. If no secondary approval is received within 24 hours, automatically
|
|
314
|
+
deny the deletion and notify both admins
|
|
315
|
+
4. If deletion is approved, execute the deletion and email both admins
|
|
316
|
+
with deletion confirmation within 5 minutes
|
|
317
|
+
```
|
|
318
|
+
✅ **Good:** Combines event (deletion attempt), state (ADMIN role), condition (PII backup), with multiple outcomes
|
|
319
|
+
- Acceptance Criteria: Secondary approval required; logging; timeout; notification
|
|
320
|
+
- Test: Delete backup as ADMIN1; verify approval prompt; approve as ADMIN2; verify logs and email
|
|
321
|
+
|
|
322
|
+
**Example 6.2: Failover Behavior**
|
|
323
|
+
```
|
|
324
|
+
When the primary database becomes unavailable while the system is handling
|
|
325
|
+
active user requests, the system shall:
|
|
326
|
+
1. Detect unavailability within 30 seconds (via health check)
|
|
327
|
+
2. Failover to standby database
|
|
328
|
+
3. Replay queued writes from the last 5 minutes
|
|
329
|
+
4. Notify ops team via Slack
|
|
330
|
+
5. If failover fails, return 503 Service Unavailable to clients (rather than 500 Internal Server Error)
|
|
331
|
+
6. Continue retrying failover every 10 seconds until successful
|
|
332
|
+
```
|
|
333
|
+
✅ **Good:** Multi-step recovery procedure with timeout, fallback, notification
|
|
334
|
+
- Acceptance Criteria: Failover detection, standby activation, queue replay, notification, graceful degradation
|
|
335
|
+
- Test: Kill primary DB; verify failover <30s, replay succeeds, clients get 503
|
|
336
|
+
|
|
337
|
+
**Example 6.3: Feature Rollout**
|
|
338
|
+
```
|
|
339
|
+
Where a feature flag "new_checkout_flow" is enabled for a user,
|
|
340
|
+
when that user navigates to the checkout page, the system shall:
|
|
341
|
+
1. Display the NEW checkout interface (v2)
|
|
342
|
+
2. Route payment requests to the NEW payment processor (Stripe)
|
|
343
|
+
3. If the new processor fails, fall back to the OLD processor silently
|
|
344
|
+
and log the fallback event (no error to user)
|
|
345
|
+
4. After successful payment via new processor, display a survey asking
|
|
346
|
+
for feedback on the new experience
|
|
347
|
+
5. Collect feature metrics (conversion rate, error rate) separately
|
|
348
|
+
from old interface metrics
|
|
349
|
+
```
|
|
350
|
+
✅ **Good:** Feature flag logic + fallback + analytics
|
|
351
|
+
- Acceptance Criteria: Feature flag logic works; fallback silent; metrics tracked
|
|
352
|
+
- Test: Enable feature flag for test user; complete checkout; verify metrics
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## RFC 2119 Keywords
|
|
357
|
+
|
|
358
|
+
All EARS requirements use standardized keywords from RFC 2119 to express requirement strength:
|
|
359
|
+
|
|
360
|
+
### SHALL (MUST)
|
|
361
|
+
**Definition:** Absolute requirement; implementation is mandatory
|
|
362
|
+
|
|
363
|
+
**Usage:** All critical functionality must use "shall"
|
|
364
|
+
|
|
365
|
+
**Examples:**
|
|
366
|
+
- "The system **shall** authenticate users via email and password."
|
|
367
|
+
- "All API responses **shall** be valid JSON."
|
|
368
|
+
- "The system **shall** encrypt PII at rest."
|
|
369
|
+
|
|
370
|
+
**Testing:** Test MUST pass; failure is a bug
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
### SHOULD (RECOMMENDED)
|
|
375
|
+
**Definition:** Strongly recommended but not mandatory; implementation is expected unless there's good reason not to
|
|
376
|
+
|
|
377
|
+
**Usage:** Best practices, preferred patterns
|
|
378
|
+
|
|
379
|
+
**Examples:**
|
|
380
|
+
- "The system **should** log all authentication attempts."
|
|
381
|
+
- "The system **should** return responses in <100ms (median latency)."
|
|
382
|
+
- "The system **should** include request IDs in all responses for traceability."
|
|
383
|
+
|
|
384
|
+
**Testing:** Test SHOULD pass; failure is a concern but acceptable with documented rationale
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
### MAY (OPTIONAL)
|
|
389
|
+
**Definition:** Truly optional; implementation is discretionary; provides flexibility
|
|
390
|
+
|
|
391
|
+
**Usage:** Nice-to-have features, optimization strategies
|
|
392
|
+
|
|
393
|
+
**Examples:**
|
|
394
|
+
- "The system **may** cache recently accessed user profiles."
|
|
395
|
+
- "The system **may** support multiple languages in future versions."
|
|
396
|
+
- "The system **may** offer dark mode UI theme."
|
|
397
|
+
|
|
398
|
+
**Testing:** Test MAY pass or fail; feature is optional
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
### SHALL NOT (MUST NOT)
|
|
403
|
+
**Definition:** Absolute prohibition; implementation of this action is forbidden
|
|
404
|
+
|
|
405
|
+
**Usage:** Security constraints, safety requirements
|
|
406
|
+
|
|
407
|
+
**Examples:**
|
|
408
|
+
- "The system **shall not** store passwords in plaintext."
|
|
409
|
+
- "The system **shall not** process expired tokens."
|
|
410
|
+
- "The system **shall not** allow SQL injection attacks."
|
|
411
|
+
|
|
412
|
+
**Testing:** Test MUST verify violation is prevented
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
### Keyword Decision Table
|
|
417
|
+
|
|
418
|
+
| Strength | RFC 2119 | Use When | Example |
|
|
419
|
+
|----------|----------|----------|---------|
|
|
420
|
+
| Mandatory | SHALL | Critical functionality, legal requirement, core feature | "System shall authenticate users" |
|
|
421
|
+
| Mandatory | SHALL NOT | Security, safety, compliance | "System shall not store passwords plaintext" |
|
|
422
|
+
| Strong | SHOULD | Best practice, preferred pattern, almost always implemented | "System should log auth attempts" |
|
|
423
|
+
| Weak | MAY | Optional, nice-to-have, flexibility needed | "System may cache user profiles" |
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Complete Example: User Authentication Feature
|
|
428
|
+
|
|
429
|
+
**Feature:** Email-based login for consumer accounts
|
|
430
|
+
|
|
431
|
+
**EARS Requirements:**
|
|
432
|
+
|
|
433
|
+
```markdown
|
|
434
|
+
### REQ-AUTH-001: Basic Email/Password Authentication
|
|
435
|
+
The system shall authenticate users via email address and password.
|
|
436
|
+
|
|
437
|
+
### REQ-AUTH-002: Password Hashing
|
|
438
|
+
The system shall hash passwords using bcryptjs (10+ salt rounds)
|
|
439
|
+
and shall NOT store plaintext passwords in any form (database, logs, backups).
|
|
440
|
+
|
|
441
|
+
### REQ-AUTH-003: Invalid Credentials Response
|
|
442
|
+
When a user submits invalid credentials, the system shall return
|
|
443
|
+
HTTP 401 Unauthorized with generic error message "Invalid email or password"
|
|
444
|
+
(to prevent email enumeration attacks).
|
|
445
|
+
|
|
446
|
+
### REQ-AUTH-004: Rate Limiting
|
|
447
|
+
When a user exceeds 5 failed login attempts within 60 seconds,
|
|
448
|
+
the system shall enforce rate limiting and return HTTP 429 Too Many Requests
|
|
449
|
+
for subsequent attempts from that email address.
|
|
450
|
+
|
|
451
|
+
### REQ-AUTH-005: JWT Token Issuance
|
|
452
|
+
When a user successfully authenticates, the system shall issue a JWT token
|
|
453
|
+
signed with HS256, with 15-minute expiry, containing user_id and email claims.
|
|
454
|
+
|
|
455
|
+
### REQ-AUTH-006: Token Validation
|
|
456
|
+
When a user sends an API request with a valid JWT token in the Authorization header,
|
|
457
|
+
the system shall validate the signature and expiry, and proceed with the request.
|
|
458
|
+
|
|
459
|
+
### REQ-AUTH-007: Expired Token Handling
|
|
460
|
+
If a user attempts to use an expired token, the system shall reject the request
|
|
461
|
+
with HTTP 401 Unauthorized and require re-authentication.
|
|
462
|
+
|
|
463
|
+
### REQ-AUTH-008: Login Latency
|
|
464
|
+
When a user authenticates with valid credentials, the system shall respond
|
|
465
|
+
with token within 500ms (p99 latency), even during peak load (1000 concurrent users).
|
|
466
|
+
|
|
467
|
+
### REQ-AUTH-009: HTTPS Enforcement
|
|
468
|
+
Where the client connects via plain HTTP, the system shall redirect to HTTPS
|
|
469
|
+
to prevent token interception over unencrypted connections.
|
|
470
|
+
|
|
471
|
+
### REQ-AUTH-010: Logging
|
|
472
|
+
The system shall log all authentication attempts (both successful and failed)
|
|
473
|
+
with timestamp, email, and IP address, should support audit trail for security investigation.
|
|
474
|
+
|
|
475
|
+
### REQ-AUTH-011: Concurrent Login
|
|
476
|
+
When a user logs in from multiple devices simultaneously, the system
|
|
477
|
+
shall allow concurrent sessions (no forced logout on subsequent login).
|
|
478
|
+
|
|
479
|
+
### REQ-AUTH-012: Mobile Client Support
|
|
480
|
+
Where the API client is a mobile application, the system may implement
|
|
481
|
+
refresh token rotation strategy (optional enhancement for long-lived sessions).
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
---
|
|
485
|
+
|
|
486
|
+
## Anti-Patterns: What NOT To Do
|
|
487
|
+
|
|
488
|
+
### Anti-Pattern 1: Vague Action Verbs
|
|
489
|
+
|
|
490
|
+
**❌ Bad:**
|
|
491
|
+
```
|
|
492
|
+
The system shall handle user input.
|
|
493
|
+
```
|
|
494
|
+
**Problem:** "Handle" is ambiguous (validate? store? display? sanitize?)
|
|
495
|
+
|
|
496
|
+
**✅ Better:**
|
|
497
|
+
```
|
|
498
|
+
The system shall validate user email address against RFC 5322 format
|
|
499
|
+
and display error message if invalid.
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
504
|
+
### Anti-Pattern 2: Missing Acceptance Criteria
|
|
505
|
+
|
|
506
|
+
**❌ Bad:**
|
|
507
|
+
```
|
|
508
|
+
When a user logs in, the system shall authenticate them.
|
|
509
|
+
```
|
|
510
|
+
**Problem:** "Authenticate" not testable (what counts as success?)
|
|
511
|
+
|
|
512
|
+
**✅ Better:**
|
|
513
|
+
```
|
|
514
|
+
When a user submits email and password, the system shall verify credentials
|
|
515
|
+
against the database and return HTTP 200 with JWT token if valid,
|
|
516
|
+
HTTP 401 if invalid.
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
### Anti-Pattern 3: Unclear Scope
|
|
522
|
+
|
|
523
|
+
**❌ Bad:**
|
|
524
|
+
```
|
|
525
|
+
The system shall be secure.
|
|
526
|
+
```
|
|
527
|
+
**Problem:** Too broad; what security aspect?
|
|
528
|
+
|
|
529
|
+
**✅ Better:**
|
|
530
|
+
```
|
|
531
|
+
The system shall encrypt all personally identifiable information at rest
|
|
532
|
+
using AES-256 encryption.
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
---
|
|
536
|
+
|
|
537
|
+
### Anti-Pattern 4: Combining Multiple Unrelated Actions
|
|
538
|
+
|
|
539
|
+
**❌ Bad:**
|
|
540
|
+
```
|
|
541
|
+
The system shall handle authentication, authorization, and logging.
|
|
542
|
+
```
|
|
543
|
+
**Problem:** Three different concerns lumped into one requirement
|
|
544
|
+
|
|
545
|
+
**✅ Better:** Separate into three requirements:
|
|
546
|
+
```
|
|
547
|
+
REQ-001: The system shall authenticate users via email and password.
|
|
548
|
+
REQ-002: The system shall authorize users based on role (ADMIN, USER, GUEST).
|
|
549
|
+
REQ-003: The system shall log all authentication attempts with timestamp and email.
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
---
|
|
553
|
+
|
|
554
|
+
### Anti-Pattern 5: Untestable Performance Claims
|
|
555
|
+
|
|
556
|
+
**❌ Bad:**
|
|
557
|
+
```
|
|
558
|
+
The system shall be fast.
|
|
559
|
+
```
|
|
560
|
+
**Problem:** "Fast" is subjective; no measurable target
|
|
561
|
+
|
|
562
|
+
**✅ Better:**
|
|
563
|
+
```
|
|
564
|
+
When a user submits an authentication request, the system shall respond
|
|
565
|
+
within 500ms (p99 latency) during normal load (100 concurrent users).
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
---
|
|
569
|
+
|
|
570
|
+
### Anti-Pattern 6: Missing Context
|
|
571
|
+
|
|
572
|
+
**❌ Bad:**
|
|
573
|
+
```
|
|
574
|
+
The system shall return an error.
|
|
575
|
+
```
|
|
576
|
+
**Problem:** What error? When? What's the context?
|
|
577
|
+
|
|
578
|
+
**✅ Better:**
|
|
579
|
+
```
|
|
580
|
+
If a required field is missing from the request, the system shall return
|
|
581
|
+
HTTP 400 Bad Request with a descriptive error message listing the missing fields.
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
---
|
|
585
|
+
|
|
586
|
+
## Writing Checklist
|
|
587
|
+
|
|
588
|
+
For each requirement, verify:
|
|
589
|
+
|
|
590
|
+
- [ ] **Specific:** Does it specify exactly what the system does? (not "be easy" but "enable signup in 3 clicks")
|
|
591
|
+
- [ ] **Measurable:** Can you test it? (not "fast" but "<500ms latency")
|
|
592
|
+
- [ ] **Context:** Does it include When/Where/While/If? (or is ubiquitous?)
|
|
593
|
+
- [ ] **Single Concern:** Does it address one thing? (not "auth, authz, and logging")
|
|
594
|
+
- [ ] **RFC 2119 Keyword:** Does it use SHALL/SHOULD/MAY correctly? (not "must" or "will")
|
|
595
|
+
- [ ] **Complete:** Does a developer understand what to implement?
|
|
596
|
+
- [ ] **Testable:** Can QA write a test to verify it?
|
|
597
|
+
- [ ] **Traceable:** Can you link this to a design component and task?
|
|
598
|
+
|
|
599
|
+
---
|
|
600
|
+
|
|
601
|
+
## Additional Resources
|
|
602
|
+
|
|
603
|
+
- **RFC 2119:** https://www.ietf.org/rfc/rfc2119.txt (Keyword definitions)
|
|
604
|
+
- **EARS Original Paper:** "Easy Approach to Requirements Syntax" by Alistair Mavin et al.
|
|
605
|
+
- **INCOSE:** International Council on Systems Engineering (INCOSE) standards on requirements
|