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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
# Namespaces

Namespaces extend HRIDs with prefixes to organize requirements in large, multi-component projects. This chapter explains when and how to use them.

## What Are Namespaces?

A namespace is an optional prefix in an HRID that provides additional context:

```
USR-001              # No namespace
AUTH-USR-001         # One namespace level: AUTH
AUTH-LOGIN-USR-001   # Two namespace levels: AUTH, LOGIN
A-B-C-USR-001        # Three namespace levels: A, B, C
```

### HRID Format with Namespaces

Complete format:
```
{NAMESPACE-}*{KIND}-{ID}
```

Where:
- `NAMESPACE`: Zero or more namespace segments
- `KIND`: Requirement kind (e.g., USR, SYS)
- `ID`: Numeric identifier

Examples:
```
USR-001                    # KIND=USR, ID=001, namespace=[]
COMPONENT-USR-001          # KIND=USR, ID=001, namespace=[COMPONENT]
AUTH-LOGIN-SYS-042         # KIND=SYS, ID=042, namespace=[AUTH, LOGIN]
```

## When to Use Namespaces

### Large Projects

Projects with many requirements benefit from namespacing:

```
# Without namespaces (confusion)
USR-001  # Which component?
USR-002  # Auth or payment?
USR-003  # Mobile or web?

# With namespaces (clarity)
AUTH-USR-001    # Authentication user requirement
PAY-USR-002     # Payment user requirement
MOBILE-USR-003  # Mobile app user requirement
```

### Multi-Component Systems

Systems with distinct components or subsystems:

```
FRONTEND-USR-001
FRONTEND-SYS-001

BACKEND-USR-001
BACKEND-SYS-001

DATABASE-SYS-001
CACHE-SYS-001
```

### Product Families

Related products sharing requirements:

```
CORE-USR-001      # Shared across all products
CORE-SYS-001

MOBILE-USR-001    # Mobile-specific
MOBILE-SYS-001

WEB-USR-001       # Web-specific
WEB-SYS-001
```

### Team Boundaries

Map namespaces to team ownership:

```
TEAM-ALPHA-USR-001    # Team Alpha's requirements
TEAM-BETA-USR-001     # Team Beta's requirements
SHARED-USR-001        # Cross-team requirements
```

### Acquisitions and Mergers

Integrate acquired codebases without renumbering:

```
LEGACY-USR-001    # From acquired company (existing numbering)
NEW-USR-001       # Newly created requirements
```

## When NOT to Use Namespaces

### Small Projects

Projects with < 100 requirements rarely need namespaces:

```
# Simple project (no namespace needed)
USR-001
USR-002
SYS-001
SYS-002
```

Namespaces add complexity without benefit for small projects.

### Single Component

If your project is a single cohesive unit:

```
# Single-component app
USR-001
SYS-001
TST-001
```

No need for namespaces unless planning for future growth.

### Shallow Hierarchy

If requirements naturally form a flat or shallow structure, namespaces may be overkill.

## Namespace Strategies

### Strategy 1: By Component

Organize by system architecture:

```
AUTH-USR-001       # Authentication component
AUTH-SYS-001

API-USR-001        # API gateway
API-SYS-001

DB-SYS-001         # Database layer

CACHE-SYS-001      # Cache layer
```

**Advantages**:
- Mirrors system architecture
- Clear component ownership
- Natural for microservices

**When to use**: Systems with well-defined component boundaries.

### Strategy 2: By Layer

Organize by architectural layer:

```
UI-USR-001         # User interface layer
UI-SYS-001

BL-SYS-001         # Business logic layer

DATA-SYS-001       # Data layer
```

**Advantages**:
- Aligns with layered architectures
- Clear layer separation

**When to use**: Traditional n-tier applications.

### Strategy 3: By Feature

Organize by product feature:

```
LOGIN-USR-001      # Login feature
LOGIN-SYS-001
LOGIN-TST-001

PAYMENT-USR-001    # Payment feature
PAYMENT-SYS-001
PAYMENT-TST-001

REPORTING-USR-001  # Reporting feature
REPORTING-SYS-001
```

**Advantages**:
- Groups related requirements
- Feature-based development
- Easy feature scoping

**When to use**: Feature-driven development, agile teams.

### Strategy 4: Hybrid

Combine multiple levels:

```
MOBILE-AUTH-USR-001    # Mobile app, auth feature, user requirement
MOBILE-PAY-SYS-001     # Mobile app, payment feature, system requirement

WEB-AUTH-USR-001       # Web app, auth feature, user requirement
WEB-PAY-SYS-001        # Web app, payment feature, system requirement
```

**Advantages**:
- Maximum organization
- Clear context at a glance

**When to use**: Very large, multi-product systems.

**Caution**: Deep hierarchies can make HRIDs verbose. Balance clarity with brevity.

## Namespace Depth

### Single Level

```
COMPONENT-USR-001
```

**Typical**: 5-10 namespaces per project

**Best for**: Medium projects with distinct components

### Two Levels

```
PRODUCT-COMPONENT-USR-001
```

**Typical**: 3-5 top-level namespaces, 3-7 sub-namespaces each

**Best for**: Large projects, product families

### Three+ Levels

```
ORG-PRODUCT-COMPONENT-USR-001
```

**Typical**: Very large enterprises

**Best for**: Massive systems, multi-organization projects

**Caution**: HRIDs become long and unwieldy. Consider if truly necessary.

## Namespace Naming Conventions

### Use Descriptive Names

```
# Good
AUTH-USR-001      # Clear: authentication
PAYMENT-SYS-001   # Clear: payment processing

# Less clear
A-USR-001         # What is "A"?
MOD1-SYS-001      # What is "MOD1"?
```

### Keep Short

```
# Good
AUTH-USR-001      # 4 characters
PAY-USR-001       # 3 characters

# Too long
AUTHENTICATION-USR-001    # 14 characters
PAYMENT-PROCESSING-USR-001  # 18 characters
```

Aim for 3-8 characters per namespace segment.

### Use Consistent Casing

```
# Good (all uppercase)
AUTH-USR-001
PAYMENT-SYS-001

# Inconsistent (avoid)
auth-USR-001
Payment-SYS-001
```

Convention: Use uppercase to match KIND and ID conventions.

### Avoid Special Characters

```
# Good
AUTH-USR-001
PAYMENT-SYS-001

# Bad (don't use)
AUTH_USR-001      # Underscore confuses parsing
AUTH.USR.001      # Periods not supported
AUTH/USR/001      # Slashes not supported
```

Only use hyphens as separators.

## Implementation

### Creating Namespaced Requirements

Use the namespace in the KIND argument:

```bash
# Single namespace
req add AUTH-USR

# Output: Added requirement AUTH-USR-001
```

```bash
# Two namespace levels
req add MOBILE-AUTH-SYS

# Output: Added requirement MOBILE-AUTH-SYS-001
```

### Linking Namespaced Requirements

Linking works identically:

```bash
req link MOBILE-AUTH-SYS-001 AUTH-USR-001
```

Namespaces don't affect link functionality.

### File Naming

Filenames match HRIDs exactly:

```
requirements/
├── AUTH-USR-001.md
├── AUTH-SYS-001.md
├── PAYMENT-USR-001.md
└── MOBILE-AUTH-USR-001.md
```

## Namespace Organization with Directories

Combine namespaces with directory structure:

### Option 1: Match Namespace to Directory

```
requirements/
├── auth/
│   ├── AUTH-USR-001.md
│   └── AUTH-SYS-001.md
└── payment/
    ├── PAYMENT-USR-001.md
    └── PAYMENT-SYS-001.md
```

**Advantages**:
- Reinforces namespace structure
- Easy to navigate

**Disadvantage**:
- Redundancy (namespace in filename and path)

### Option 2: Namespace Without Matching Directory

```
requirements/
├── AUTH-USR-001.md
├── AUTH-SYS-001.md
├── PAYMENT-USR-001.md
└── PAYMENT-SYS-001.md
```

**Advantages**:
- Simpler structure
- No redundancy

**Disadvantage**:
- Large directories if many components

### Option 3: Hybrid

```
requirements/
├── mobile/
│   ├── MOBILE-AUTH-USR-001.md
│   └── MOBILE-PAY-USR-001.md
└── web/
    ├── WEB-AUTH-USR-001.md
    └── WEB-PAY-USR-001.md
```

**Advantages**:
- Top level organized by directory
- Sub-level by namespace

## Configuration

### Restricting Namespaces

Currently, Requiem doesn't restrict namespaces via configuration. Any valid namespace is accepted.

**Workaround**: Use `allowed_kinds` to restrict full namespaced kinds:

```toml
_version = "1"
allowed_kinds = [
    "AUTH-USR",
    "AUTH-SYS",
    "PAYMENT-USR",
    "PAYMENT-SYS",
]
```

This allows:
- `AUTH-USR-001` ✓
- `PAYMENT-SYS-001` ✓

This blocks:
- `INVALID-USR-001` ✗
- `USR-001` ✗ (no namespace)

**Limitation**: Doesn't enforce namespace structure for multi-level namespaces.

### Future Configuration

Planned configuration options (not yet implemented):

```toml
# Planned (not implemented)
[namespaces]
required = true          # Require all HRIDs to have namespaces
allowed = ["AUTH", "PAYMENT", "REPORTING"]
separator = "-"          # Customize separator (default: "-")
max_depth = 2            # Limit namespace depth
```

## Migration to Namespaces

### Adding Namespaces to Existing Project

**Challenge**: Existing requirements lack namespaces:
```
USR-001.md
USR-002.md
SYS-001.md
```

**Goal**: Add namespaces:
```
AUTH-USR-001.md
PAYMENT-USR-002.md
AUTH-SYS-001.md
```

**Steps**:

1. **Plan namespace scheme**: Decide which requirements belong to which namespace

2. **Rename files**:
```bash
mv USR-001.md AUTH-USR-001.md
mv USR-002.md PAYMENT-USR-002.md
mv SYS-001.md AUTH-SYS-001.md
```

3. **Update HRIDs in frontmatter**: Edit each file to update the HRID references

4. **Fix parent links**: Run `req clean` to correct parent HRIDs
```bash
req clean
```

5. **Verify**:
```bash
req clean  # Should succeed with no errors
```

6. **Commit**:
```bash
git add -A
git commit -m "Add namespaces to requirements"
```

**Note**: UUIDs remain unchanged, so relationships are preserved.

## Examples

### Example 1: E-commerce Platform

```
# Customer-facing requirements
CUSTOMER-USR-001.md  # Customer account management
CUSTOMER-USR-002.md  # Product browsing

# Cart and checkout
CART-USR-001.md      # Shopping cart
CHECKOUT-USR-001.md  # Checkout process

# Payment processing
PAYMENT-SYS-001.md   # Payment gateway integration
PAYMENT-SYS-002.md   # PCI compliance

# Order management
ORDER-SYS-001.md     # Order processing
ORDER-SYS-002.md     # Order fulfillment

# Inventory
INVENTORY-SYS-001.md # Stock management
```

### Example 2: Aerospace System

```
# Aircraft levels (DO-178C)
AIRCRAFT-URQT-001.md   # Aircraft-level user requirement

# System level
AVIONICS-SRQT-001.md   # Avionics system requirement
ENGINES-SRQT-001.md    # Engine system requirement

# Software level
AVIONICS-FCS-SWRQT-001.md   # Flight control software
AVIONICS-NAV-SWRQT-001.md   # Navigation software

# Hardware level
AVIONICS-FCS-HWRQT-001.md   # Flight control hardware
```

### Example 3: Mobile and Web Apps

```
# Shared requirements
CORE-USR-001.md         # Cross-platform user requirement
CORE-SYS-001.md         # Backend API

# Mobile-specific
MOBILE-IOS-USR-001.md   # iOS-specific requirement
MOBILE-ANDROID-USR-001.md  # Android-specific

# Web-specific
WEB-USR-001.md          # Web app requirement
WEB-ADMIN-USR-001.md    # Admin panel requirement
```

## Best Practices

### 1. Design Namespace Scheme Early

Define your namespace strategy before creating many requirements:

```toml
# Document in config.toml comments
_version = "1"

# Namespace scheme:
# - AUTH: Authentication and authorization
# - PAYMENT: Payment processing
# - REPORTING: Report generation
# - ADMIN: Administration features

allowed_kinds = ["AUTH-USR", "AUTH-SYS", "PAYMENT-USR", "PAYMENT-SYS"]
```

### 2. Keep Namespaces Shallow

Prefer 1-2 levels over 3+:

```
# Good
AUTH-USR-001

# Still good
MOBILE-AUTH-USR-001

# Getting long
COMPANY-PRODUCT-MOBILE-AUTH-USR-001
```

### 3. Document Namespace Meanings

Create a README or documentation page:

```markdown
# Namespace Guide

- **AUTH**: Authentication and authorization
- **PAYMENT**: Payment processing
- **REPORT**: Report generation
- **ADMIN**: Administration and configuration
```

### 4. Consistent Abbreviations

Use consistent abbreviations across namespaces:

```
# Good (consistent)
AUTH-USR-001
AUTH-SYS-001
PAYMENT-USR-001
PAYMENT-SYS-001

# Inconsistent (avoid)
AUTH-USR-001
AUTHENTICATION-SYS-001
PAY-USR-001
PAYMENT_PROCESSING-SYS-001
```

### 5. Consider Future Growth

Choose namespaces that won't become obsolete:

```
# Flexible
MOBILE-USR-001       # Can add MOBILE-IOS, MOBILE-ANDROID later

# Inflexible
IPHONE-USR-001       # What about iPads? Android?
```

## Summary

**Key Takeaways**:

1. **Optional**: Namespaces are optional; use when beneficial
2. **Hierarchical**: Support multiple levels (1-3 typical)
3. **Flexible**: Choose strategy that fits your project
4. **Scalable**: Essential for large, multi-component systems
5. **Format**: `{NAMESPACE-}*{KIND}-{ID}`

**When to use**:
- Large projects (> 100 requirements)
- Multi-component systems
- Product families
- Team boundaries
- Acquisitions

**When NOT to use**:
- Small projects (< 100 requirements)
- Single-component systems
- When simplicity is priority

**Best practices**:
- Design namespace scheme early
- Keep shallow (1-2 levels)
- Use descriptive, short names
- Document namespace meanings
- Consider future growth

## Next Steps

- Review [Directory Structure]./directory-structure.md for organizing namespaced requirements
- Learn about [Creating Requirements]../working-with-requirements/creating.md with namespaces