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
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
# Configuration Reference

Complete reference for Requiem's `config.toml` configuration file.

## Overview

The `config.toml` file configures Requiem's behavior. It must be located in the root of your requirements directory.

### File Location

```
requirements/
├── config.toml    ← Configuration file
├── USR-001.md
├── USR-002.md
└── SYS-001.md
```

### File Format

TOML (Tom's Obvious Minimal Language)

### Optional

Configuration file is optional. If absent, Requiem uses defaults.

## Schema Version 1

Current schema version: `1`

### Complete Example

```toml
_version = "1"
allowed_kinds = ["USR", "SYS", "SWR", "TST"]
digits = 3
allow_unrecognised = false
allow_invalid = false
subfolders_are_namespaces = false
```

## Configuration Fields

### `_version` (required)

Schema version for forward/backward compatibility.

**Type**: String (quoted)

**Required**: Yes

**Default**: N/A (must be explicitly specified)

**Valid Values**: `"1"`

**Example**:
```toml
_version = "1"
```

**Purpose**:
- Enables future schema changes
- Allows old Requiem versions to detect incompatible configs
- Allows new Requiem versions to handle old configs

**Validation**:
- Must be present
- Must be quoted string
- Must be `"1"` in current version

**Errors**:

Missing:
```toml
# config.toml
allowed_kinds = ["USR"]
```
```
Error: Failed to parse config file: missing field '_version'
```

Wrong type:
```toml
_version = 1  # Wrong: integer instead of string
```
```
Error: Failed to parse config file: invalid type: integer, expected a string
```

### `allowed_kinds`

Restrict which requirement kinds are permitted.

**Type**: Array of strings

**Required**: No

**Default**: `[]` (empty array = all kinds allowed)

**Valid Values**: Array of non-empty strings

**Example**:
```toml
allowed_kinds = ["USR", "SYS", "SWR", "TST"]
```

**Purpose**:
- Enforce project conventions
- Prevent typos (USR vs UST)
- Document allowed requirement types

**Behavior**:

**Empty array (default)**:
```toml
allowed_kinds = []
# OR omit field entirely
```
All kinds accepted: `USR-001`, `SYS-001`, `CUSTOM-001`, etc.

**Non-empty array**:
```toml
allowed_kinds = ["USR", "SYS"]
```
Only listed kinds accepted:
- `req add USR` ✓ Succeeds
- `req add SYS` ✓ Succeeds
- `req add TST` ✗ Fails (TST not in allowed list)

**With namespaces**:
```toml
allowed_kinds = ["AUTH-USR", "AUTH-SYS", "PAYMENT-USR"]
```
Exact match required:
- `req add AUTH-USR` ✓ Succeeds
- `req add USR` ✗ Fails (USR not in allowed list)

**Examples**:

Aerospace project (DO-178C):
```toml
allowed_kinds = ["URQT", "SRQT", "SWRQT", "HWRQT", "TRQT"]
```

Software project:
```toml
allowed_kinds = ["USR", "SYS", "SWR", "TST", "DOC"]
```

Multi-component with namespaces:
```toml
allowed_kinds = [
    "AUTH-USR", "AUTH-SYS",
    "PAYMENT-USR", "PAYMENT-SYS",
    "REPORTING-USR", "REPORTING-SYS"
]
```

**Validation**:
- Each element must be non-empty string
- Duplicates allowed (but pointless)
- Case-sensitive matching

**Errors**:

Empty string in array:
```toml
allowed_kinds = ["USR", ""]
```
```
Error: Failed to parse config file: empty strings not allowed in allowed_kinds
```

### `digits`

Number of digits in HRID numbering (with zero-padding).

**Type**: Unsigned integer

**Required**: No

**Default**: `3`

**Valid Values**: Any positive integer (typically 3-5)

**Example**:
```toml
digits = 3
```

**Purpose**:
- Control HRID formatting
- Accommodate projects with many requirements per kind

**Behavior**:

**digits = 3** (default):
```
USR-001
USR-002
USR-010
USR-099
USR-100  # Expands beyond 3 digits when needed
USR-1000
```

**digits = 4**:
```
USR-0001
USR-0002
USR-0010
USR-0999
USR-1000
USR-10000  # Expands beyond 4 digits when needed
```

**digits = 2**:
```
USR-01
USR-02
USR-99
USR-100  # Expands beyond 2 digits when needed
```

**Parsing**:
- Requirements can have any number of digits when parsing
- `USR-1`, `USR-01`, `USR-001` all parse as ID 1
- Display/creation uses configured padding

**Recommendations**:
- `digits = 3`: < 1000 requirements per kind (most projects)
- `digits = 4`: 1000-9999 requirements per kind
- `digits = 5`: Very large projects

**Examples**:

Small project:
```toml
digits = 2
```

Medium project (default):
```toml
digits = 3
```

Large project:
```toml
digits = 4
```

**Validation**:
- Must be positive integer
- Zero or negative not allowed

**Errors**:

Zero:
```toml
digits = 0
```
```
Error: Failed to parse config file: digits must be positive
```

### `allow_unrecognised`

Allow markdown files that don't match HRID pattern.

**Type**: Boolean

**Required**: No

**Default**: `false`

**Valid Values**: `true`, `false`

**Example**:
```toml
allow_unrecognised = true
```

**Purpose**:
- Enable mixing requirements with other documentation
- Control strictness of file validation

**Behavior**:

**allow_unrecognised = false** (default, strict):
```
docs/
├── config.toml
├── USR-001.md     ← Loaded (valid HRID)
├── USR-002.md     ← Loaded (valid HRID)
└── README.md      ← ERROR: Not a valid HRID
```

Error during `req clean`:
```
Error: Unrecognised file: README.md
```

**allow_unrecognised = true** (permissive):
```
docs/
├── config.toml
├── USR-001.md     ← Loaded (valid HRID)
├── USR-002.md     ← Loaded (valid HRID)
└── README.md      ← Ignored (not a valid HRID)
```

No error; `README.md` is silently skipped.

**Use Cases**:

**Use `false` (default)**:
- Dedicated requirements directory
- Strict validation desired
- Catch typos in filenames

**Use `true`**:
- Requirements mixed with MdBook/Sphinx content
- Documentation and requirements in same directory
- Legacy projects with existing non-requirement files

**Examples**:

Strict requirements-only:
```toml
_version = "1"
allow_unrecognised = false
```

Mixed documentation:
```toml
_version = "1"
allow_unrecognised = true  # Allow chapter1.md, README.md, etc.
```

**Validation**:
- Must be boolean
- Case-sensitive: `true` or `false` (lowercase)

**Errors**:

Wrong case:
```toml
allow_unrecognised = True  # Wrong: uppercase
```
```
Error: Failed to parse config file: invalid value
```

### `subfolders_are_namespaces`

Control whether subfolder paths contribute to requirement namespaces.

**Type**: Boolean

**Required**: No

**Default**: `false`

**Valid Values**: `true`, `false`

**Example**:
```toml
subfolders_are_namespaces = true
```

**Purpose**:
- Choose between filename-based and path-based directory organization
- Enable cleaner filenames in hierarchical structures
- Align folder structure with namespace hierarchy

**Behavior**:

**subfolders_are_namespaces = false** (default, filename-based):
```
requirements/
├── custom/folder/
│   └── system-auth-REQ-001.md   → HRID: system-auth-REQ-001
└── any/path/
    └── payment-USR-002.md       → HRID: payment-USR-002
```

- **HRID**: Fully encoded in filename
- **Folders**: Purely organizational, don't affect HRID
- **Flexibility**: Move files freely without changing HRIDs

**subfolders_are_namespaces = true** (path-based):
```
requirements/
├── system/
│   └── auth/
│       ├── REQ-001.md           → HRID: system-auth-REQ-001
│       └── USR/
│           └── 002.md           → HRID: system-auth-USR-002
└── payment/
    └── USR-003.md               → HRID: payment-USR-003
```

- **HRID**: Namespace from folder path + KIND-ID from filename
- **Folders**: Encode namespace segments
- **Format inference**:
  - Numeric filename (`002.md`) → KIND from parent folder
  - KIND-ID filename (`USR-003.md`) → KIND from filename
- **Constraint**: Moving files changes their HRID

**Use Cases**:

**Use `false` (default)**:
- Maximum folder flexibility
- Arbitrary organizational schemes
- Frequent folder reorganization
- Explicit namespaces in every filename

**Use `true`**:
- Hierarchical component structures
- Folder structure mirrors system architecture
- Cleaner, shorter filenames
- Enforced namespace-folder alignment

**Examples**:

Filename-based (flexible organization):
```toml
_version = "1"
subfolders_are_namespaces = false
```

Path-based (structured hierarchy):
```toml
_version = "1"
subfolders_are_namespaces = true
```

**Migration**:

To convert from filename-based to path-based:
1. Set `subfolders_are_namespaces = true`
2. Reorganize files to match namespace structure
3. Rename files to remove namespace prefix

To convert from path-based to filename-based:
1. Move files and encode full HRID in filename
2. Set `subfolders_are_namespaces = false`
3. Optionally flatten directory structure

See [Directory Structure](../configuration/directory-structure.md) for detailed migration guide.

**Validation**:
- Must be boolean
- Case-sensitive: `true` or `false` (lowercase)

**Errors**:

Wrong type:
```toml
subfolders_are_namespaces = "yes"  # Wrong: string instead of boolean
```
```
Error: Failed to parse config file: invalid type: string, expected a bool
```

### `allow_invalid`

Allow requirements with invalid YAML frontmatter or formatting.

**Type**: Boolean

**Required**: No

**Default**: `false`

**Valid Values**: `true`, `false`

**Example**:
```toml
allow_invalid = true
```

**Purpose**:
- Control strictness of requirement validation
- Enable partial loading during migration or recovery

**Behavior**:

**allow_invalid = false** (default, strict):
```
requirements/
├── USR-001.md    ← Valid frontmatter, loaded
├── USR-002.md    ← Invalid frontmatter (missing uuid)
└── USR-003.md    ← Valid frontmatter
```

Error during `req clean`:
```
Error: Invalid requirement USR-002.md: missing required field 'uuid'
```

Loading fails; no requirements processed.

**allow_invalid = true** (permissive):
```
requirements/
├── USR-001.md    ← Valid, loaded
├── USR-002.md    ← Invalid, skipped with warning
└── USR-003.md    ← Valid, loaded
```

Warning during `req clean`:
```
Warning: Skipping invalid requirement USR-002.md: missing required field 'uuid'
Successfully loaded 2 requirements (1 skipped)
```

Loading continues; valid requirements processed.

**Use Cases**:

**Use `false` (default)**:
- Production use
- Ensure data quality
- Catch errors immediately

**Use `true`**:
- Migrating from another tool (gradual fix-up)
- Recovering from manual editing errors
- Development/debugging
- Partial validation during cleanup

**Examples**:

Production (strict):
```toml
_version = "1"
allow_invalid = false
```

Migration (permissive):
```toml
_version = "1"
allow_invalid = true  # Temporarily allow invalid requirements
```

**Validation**:
- Must be boolean
- Case-sensitive: `true` or `false` (lowercase)

**Errors**:

Wrong type:
```toml
allow_invalid = "yes"  # Wrong: string instead of boolean
```
```
Error: Failed to parse config file: invalid type: string, expected a bool
```

## Minimal Configuration

Smallest valid configuration:

```toml
_version = "1"
```

All other fields use defaults:
- `allowed_kinds = []` (all kinds allowed)
- `digits = 3`
- `allow_unrecognised = false`
- `allow_invalid = false`
- `subfolders_are_namespaces = false`

## Default Configuration

If `config.toml` is absent, equivalent to:

```toml
_version = "1"
allowed_kinds = []
digits = 3
allow_unrecognised = false
allow_invalid = false
subfolders_are_namespaces = false
```

## Configuration Examples

### Small Project

```toml
_version = "1"
digits = 3
allow_unrecognised = false
allow_invalid = false
```

### Large Project

```toml
_version = "1"
allowed_kinds = ["USR", "SYS", "SWR", "HWR", "TST", "DOC"]
digits = 4  # Expect 1000+ requirements per kind
allow_unrecognised = false
allow_invalid = false
```

### Integrated Documentation

```toml
_version = "1"
allowed_kinds = ["USR", "SYS"]
digits = 3
allow_unrecognised = true  # Allow MdBook/Sphinx files
allow_invalid = false
```

### Migration Project

```toml
_version = "1"
digits = 3
allow_unrecognised = true   # Mixed content during migration
allow_invalid = true         # Some requirements may be incomplete
```

### Aerospace (DO-178C)

```toml
_version = "1"
allowed_kinds = ["URQT", "SRQT", "SWRQT", "HWRQT", "TRQT"]
digits = 4
allow_unrecognised = false
allow_invalid = false
```

### Multi-Component System

```toml
_version = "1"
allowed_kinds = [
    "CORE-USR", "CORE-SYS",
    "AUTH-USR", "AUTH-SYS",
    "PAYMENT-USR", "PAYMENT-SYS",
    "REPORTING-USR", "REPORTING-SYS"
]
digits = 3
allow_unrecognised = false
allow_invalid = false
```

## Validation

### Parsing Errors

**Missing _version**:
```toml
allowed_kinds = ["USR"]
```
```
Error: Failed to parse config file: missing field '_version'
```

**Invalid TOML syntax**:
```toml
_version = "1
allowed_kinds = ["USR"]
```
```
Error: Failed to parse config file: expected '"', got newline
```

**Wrong type**:
```toml
_version = 1  # Should be string
```
```
Error: Failed to parse config file: invalid type: integer, expected a string
```

**Unknown field** (future-proofing):
```toml
_version = "1"
unknown_field = "value"
```
Currently allowed (forward compatibility), but may be rejected in strict mode.

### Runtime Validation

Configuration is loaded at:
- `req add`
- `req link`
- `req clean`

Errors reported immediately:
```bash
req clean
# Error: Failed to load config: missing field '_version'
```

## Schema Evolution

### Version 1 (Current)

Fields:
- `_version` (required)
- `allowed_kinds` (optional)
- `digits` (optional)
- `allow_unrecognised` (optional)
- `allow_invalid` (optional)
- `subfolders_are_namespaces` (optional)

### Future Versions

Planned fields (not yet implemented):

**Version 2** (hypothetical):
```toml
_version = "2"

# Existing fields
allowed_kinds = ["USR", "SYS"]
digits = 3
allow_unrecognised = false
allow_invalid = false

# New fields
[namespaces]
required = true
allowed = ["AUTH", "PAYMENT"]

[review]
auto_flag = true
notify = "team@example.com"

[coverage]
minimum = 95
```

**Compatibility**:
- Old Requiem: Rejects `_version = "2"` (unknown version)
- New Requiem: Reads `_version = "1"` (backward compatible)

## Troubleshooting

### Config Not Recognized

**Problem**: Changes to `config.toml` don't take effect.

**Solution**:
- Ensure file is named exactly `config.toml` (lowercase, no extension)
- Ensure file is in requirements root directory
- Verify TOML syntax with validator

### Parse Errors

**Problem**: `Error: Failed to parse config file`

**Diagnosis**:
1. Check TOML syntax
2. Ensure strings are quoted
3. Ensure arrays use square brackets
4. Check for typos in field names

**Solution**: Validate TOML:
```bash
# Python
python -c "import sys, toml; toml.load(open('config.toml'))"

# Online validator
# Copy config to https://www.toml-lint.com/
```

### Requirements Rejected

**Problem**: `req add` fails with "Kind not in allowed list"

**Diagnosis**: Check `allowed_kinds` in config.

**Solution**: Add kind to `allowed_kinds` or use empty array:
```toml
allowed_kinds = []  # Allow all kinds
```

### Files Ignored Unexpectedly

**Problem**: Valid requirement files not loaded.

**Diagnosis**: Check filename matches HRID pattern.

**Solution**:
- Ensure filename is `{KIND}-{ID}.md`
- Set `allow_unrecognised = false` to get error messages

## Summary

**Configuration file**:
- Location: `config.toml` in requirements root
- Format: TOML
- Optional: Uses defaults if absent

**Required fields**:
- `_version`: Schema version (currently `"1"`)

**Optional fields**:
- `allowed_kinds`: Restrict requirement kinds (default: `[]`, allow all)
- `digits`: HRID digit padding (default: `3`)
- `allow_unrecognised`: Allow non-HRID files (default: `false`)
- `allow_invalid`: Allow invalid requirements (default: `false`)
- `subfolders_are_namespaces`: Use path-based structure (default: `false`)

**Defaults**:
- All kinds allowed
- 3-digit HRID padding
- Strict file validation
- Strict requirement validation
- Filename-based directory structure

## Next Steps

- See [CLI Command Reference]./cli.md for commands affected by configuration
- See [File Format Specification]./file-format.md for requirement format
- Review [Configuration File]../configuration/config-file.md for detailed explanations