requirements-manager 0.1.1

Plain-text requirements management tool
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# Coverage Reports

> **Note**: Coverage reporting is **planned but not yet implemented**. This chapter describes how the feature will work when available.

Coverage reports analyze requirement traceability, identifying gaps in the requirement hierarchy and ensuring all requirements are properly traced.

## What is Coverage?

Coverage measures how completely requirements are traced across levels:

- **Downstream coverage**: Do all user requirements have system requirements?
- **Upstream coverage**: Do all test cases trace to requirements?
- **Bidirectional traceability**: Can you trace from user needs to implementation and tests?

### Example

```
USR-001 ← User requirement
  ├─ SYS-001 ← System requirement (traced)
  └─ SYS-002 ← System requirement (traced)

USR-002 ← User requirement
  └─ (no children) ← Coverage gap!

SYS-003 ← System requirement
  └─ (no parents) ← Orphan requirement!
```

**Coverage report identifies**:
- USR-002 has no system requirements (gap)
- SYS-003 has no parent (orphan)

## Planned Functionality

### Coverage Analysis Command

```bash
req coverage
```

**Output**:
```
Coverage Report

User Requirements (USR):
  Total: 25
  With children: 23 (92%)
  Without children: 2 (8%)
    - USR-002: User data export
    - USR-018: Password recovery

System Requirements (SYS):
  Total: 47
  With parents: 45 (96%)
  With children: 43 (91%)
  Orphans: 2 (4%)
    - SYS-003: Logging service
    - SYS-029: Cache invalidation

Test Cases (TST):
  Total: 156
  With parents: 150 (96%)
  Orphans: 6 (4%)

Overall Coverage: 93%
```

### Coverage by Kind

Analyze specific requirement kinds:

```bash
req coverage --kind USR
```

**Output**:
```
User Requirement Coverage

Total: 25

With children: 23 (92%)
  USR-001 → SYS-001, SYS-002
  USR-003 → SYS-005, SYS-006, SYS-007
  ...

Without children (gaps): 2 (8%)
  USR-002: User data export
  USR-018: Password recovery

Recommendation: Add system requirements for USR-002 and USR-018
```

### Detailed Reports

Generate detailed coverage information:

```bash
req coverage --detailed > coverage-report.md
```

**Output format** (Markdown):
```markdown
# Coverage Report

## Summary
- User Requirements: 92% covered
- System Requirements: 96% traced upstream, 91% traced downstream
- Tests: 96% traced

## Gaps

### User Requirements Without Children
- **USR-002**: User data export
  - Status: No system requirements
  - Action: Create SYS requirements

- **USR-018**: Password recovery
  - Status: No system requirements
  - Action: Create SYS requirements

### Orphan System Requirements
- **SYS-003**: Logging service
  - Status: No parent requirement
  - Action: Link to USR requirement or remove

...
```

### Visual Reports

Generate coverage diagrams:

```bash
req coverage --format html > coverage.html
```

**Features**:
- Interactive traceability matrix
- Heatmap showing coverage density
- Clickable requirement links
- Filterable by kind, tag, or namespace

## Use Cases

### Use Case 1: Requirement Review

**Scenario**: Preparing for a requirements review.

**Goal**: Identify incomplete traceability.

**Workflow**:

```bash
# Generate coverage report
req coverage --detailed > review-report.md

# Review gaps
# - USR-002: No system requirements
# - SYS-003: Orphan requirement

# Fix gaps
req add SYS --parent USR-002  # Add missing SYS requirement
req link SYS-003 USR-007      # Link orphan to parent

# Verify
req coverage
# Coverage improved to 100%
```

### Use Case 2: Release Readiness

**Scenario**: Ensuring all requirements are traced before release.

**Goal**: 100% coverage required for release.

**Workflow**:

```bash
# Check coverage
req coverage --minimum 100

# Output (if < 100%):
# Error: Coverage is 93%, minimum required is 100%
# Gaps:
#   - USR-002: No children
#   - USR-018: No children
#   - SYS-003: No parent

# Fix gaps...

# Verify
req coverage --minimum 100
# Success: Coverage is 100%
```

### Use Case 3: Compliance Audit

**Scenario**: Demonstrating traceability for compliance audit.

**Goal**: Prove all user requirements are traced to implementation and tests.

**Workflow**:

```bash
# Generate audit report
req coverage --audit \
  --trace-from USR \
  --trace-to TST \
  --output audit-report.pdf

# Report shows:
# - Complete traceability chain: USR → SYS → SWR → TST
# - No gaps
# - All requirements covered
```

## Configuration (Planned)

### Coverage Rules

```toml
# config.toml (planned)
[coverage]
# Minimum coverage percentage required
minimum = 95

# Require specific kinds to have children
require_children = ["USR", "SYS"]

# Require specific kinds to have parents
require_parents = ["SYS", "SWR", "TST"]

# Allowed to have no children (leaf requirements)
leaf_kinds = ["TST", "DOC"]

# Allowed to have no parents (root requirements)
root_kinds = ["USR"]
```

### Coverage Thresholds

```toml
[coverage.thresholds]
# Per-kind minimum coverage
USR = 100  # All user requirements must have children
SYS = 95   # 95% of system requirements must have children
SWR = 90   # 90% of software requirements must have children
TST = 100  # All tests must have parents
```

## Report Formats

### Plain Text

Simple text output:

```bash
req coverage
```

### Markdown

Detailed Markdown report:

```bash
req coverage --format markdown > coverage.md
```

### HTML

Interactive HTML dashboard:

```bash
req coverage --format html > coverage.html
```

### JSON

Machine-readable output:

```bash
req coverage --format json > coverage.json
```

**Example JSON**:
```json
{
  "timestamp": "2025-07-22T12:00:00Z",
  "overall_coverage": 93,
  "by_kind": {
    "USR": {
      "total": 25,
      "with_children": 23,
      "without_children": 2,
      "coverage": 92
    },
    "SYS": {
      "total": 47,
      "with_parents": 45,
      "with_children": 43,
      "coverage": 96
    }
  },
  "gaps": [
    {
      "hrid": "USR-002",
      "type": "no_children",
      "description": "User data export"
    }
  ]
}
```

### CSV

Spreadsheet-compatible output:

```bash
req coverage --format csv > coverage.csv
```

## Traceability Matrix

Generate traceability matrices showing parent-child relationships:

```bash
req coverage --matrix
```

**Output** (simplified):

```
         | USR-001 | USR-002 | USR-003
---------|---------|---------|---------
SYS-001  |    X    |         |
SYS-002  |    X    |         |    X
SYS-003  |         |         |
SYS-004  |         |         |    X
```

**Features**:
- Rows: Child requirements
- Columns: Parent requirements
- X: Link exists
- Empty: No link
- Highlights gaps and orphans

## Integration

### CI/CD

Enforce coverage in CI:

```yaml
# .github/workflows/requirements.yml (planned)
- name: Check requirement coverage
  run: |
    req coverage --minimum 95
    if [ $? -ne 0 ]; then
      echo "Coverage below minimum"
      req coverage --detailed
      exit 1
    fi
```

### Pull Request Comments

Automatically comment on PRs with coverage impact:

```yaml
- name: Coverage report
  run: |
    req coverage --format markdown > coverage.md
    gh pr comment ${{ github.event.number }} --body-file coverage.md
```

### Dashboard Integration

Export coverage to dashboards:

```bash
# Export for Grafana/Prometheus
req coverage --format prometheus > metrics.txt
```

## Metrics (Planned)

### Coverage Percentage

```
coverage = (requirements_with_links / total_requirements) * 100
```

### Downstream Coverage

```
downstream_coverage = (parents_with_children / total_parents) * 100
```

### Upstream Coverage

```
upstream_coverage = (children_with_parents / total_children) * 100
```

### Orphan Rate

```
orphan_rate = (requirements_without_parents / total_requirements) * 100
```

## Workarounds (Until Implemented)

Manual coverage analysis:

### Script to Find Gaps

```bash
#!/bin/bash
# find-gaps.sh

echo "USR requirements without SYS children:"
comm -23 \
  <(ls USR-*.md | sed 's/.md//' | sort) \
  <(grep -oh "USR-[0-9]*" SYS-*.md | sort -u)

echo ""
echo "SYS requirements without parents:"
for sys in SYS-*.md; do
    if ! grep -q "parents:" "$sys"; then
        echo "  $(basename "$sys" .md)"
    fi
done
```

### Spreadsheet Analysis

Create a spreadsheet:

| Requirement | Has Parents | Has Children | Coverage |
|-------------|-------------|--------------|----------|
| USR-001     | N/A         | Yes          | ✓        |
| USR-002     | N/A         | No           | ✗        |
| SYS-001     | Yes         | Yes          | ✓        |
| SYS-003     | No          | No           | ✗        |

Track manually until coverage reporting is implemented.

## Summary

**Planned functionality**:

- Coverage percentage by requirement kind
- Gap identification (requirements without parents/children)
- Orphan detection
- Traceability matrices
- Multiple report formats (text, Markdown, HTML, JSON, CSV)
- CI/CD integration
- Configurable coverage thresholds

**Use cases**:
- Requirement reviews
- Release readiness checks
- Compliance audits
- Quality assurance

**Timeline**: Implementation planned for future release

## Next Steps

- Use [workarounds]#workarounds-until-implemented for manual coverage analysis
- Plan your [coverage requirements]#configuration-planned for when feature is available
- See [Cycle Detection]./cycles.md for finding circular dependencies