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
# Configuration File

Requiem uses a TOML configuration file named `config.toml` in the root of your requirements directory to customize behavior.

## Location

The configuration file must be named `config.toml` and placed in the root directory where your requirements are stored:

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

If no configuration file exists, Requiem uses sensible defaults and continues without error.

## File Format

The configuration file is written in TOML (Tom's Obvious Minimal Language), a simple, human-readable format.

### Minimal Example

The simplest valid configuration:

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

This accepts all defaults. The `_version` field is required for future format compatibility.

### Complete Example

A configuration using all available options:

```toml
_version = "1"

# Restrict requirement kinds
allowed_kinds = ["USR", "SYS", "SWR", "TST"]

# Number of digits in HRID numbering
digits = 3

# Allow non-requirement markdown files
allow_unrecognised = false

# Allow requirements with invalid formatting
allow_invalid = false
```

## Configuration Options

### `_version` (required)

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

**Type**: String (quoted)

**Default**: N/A (required field)

**Purpose**: Specifies the configuration format version. This enables future format changes while maintaining backward compatibility.

**Current version**: `"1"` (as a string, not a number)

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

**Invalid**:
```toml
_version = 1    # Wrong: must be a quoted string
```

### `allowed_kinds` (optional)

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

**Type**: Array of strings

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

**Purpose**: Restricts which requirement kinds (the KIND component of HRIDs) are permitted in your project.

**When to use**:
- Enforce project standards (e.g., only USR, SYS, TST requirements allowed)
- Prevent typos (USR-001 vs. UST-001)
- Document your requirement taxonomy

**Behavior**:
- **Empty array** (default): Any kind is accepted
- **Non-empty array**: Only listed kinds are valid

**Example - Aerospace project**:
```toml
allowed_kinds = ["URQT", "SRQT", "SWRQT", "HWRQT", "TEST"]
# User Requirements (URQT), System Requirements (SRQT), etc.
```

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

**Enforcement**:
When `allowed_kinds` is non-empty, attempting to create a requirement with a disallowed kind will fail:

```bash
$ req add INVALID
Error: Kind 'INVALID' is not in the allowed list
```

### `digits` (optional)

```toml
digits = 3
```

**Type**: Unsigned integer

**Default**: `3`

**Purpose**: Specifies the minimum number of digits used in HRID numbering. IDs are zero-padded to this width.

**Valid values**: Any positive integer, though 3 or 4 are most common.

**Behavior**:

With `digits = 3`:
```
USR-001
USR-002
...
USR-099
USR-100  # Exceeds 3 digits when needed
```

With `digits = 4`:
```
USR-0001
USR-0002
...
USR-9999
USR-10000  # Exceeds 4 digits when needed
```

**Choosing a value**:
- `digits = 3`: Projects with < 1000 requirements per kind
- `digits = 4`: Projects with 1000+ requirements per kind
- `digits = 5`: Very large projects

**Note**: This setting affects display format only. Parsing accepts any number of digits:
- `USR-1`, `USR-01`, `USR-001` all parse as ID 1
- Display format uses the configured padding

**Example - Large project**:
```toml
digits = 4
# Requirements display as USR-0001, USR-0002, etc.
```

### `allow_unrecognised` (optional)

```toml
allow_unrecognised = false
```

**Type**: Boolean

**Default**: `false`

**Purpose**: Controls whether markdown files that don't match the HRID pattern are allowed in the requirements directory.

**Behavior**:

**`false` (default - strict mode)**:
- Only files matching the HRID pattern (e.g., `USR-001.md`) are allowed
- Any other `.md` file causes an error during loading
- Ensures clean, requirements-only directory

**`true` (permissive mode)**:
- Files with non-HRID names are silently ignored
- Useful when requirements live alongside other documentation

**When to use `true`**:

**Integration with documentation tools**:
```
docs/
├── config.toml          ← allow_unrecognised = true
├── introduction.md      ← Ignored (not an HRID)
├── architecture.md      ← Ignored
├── USR-001.md          ← Loaded as requirement
└── USR-002.md          ← Loaded as requirement
```

**Mixed content repositories**:
```
project-docs/
├── README.md           ← Ignored
├── CHANGELOG.md        ← Ignored
├── requirements/
│   ├── USR-001.md      ← Loaded
│   └── SYS-001.md      ← Loaded
```

**When to use `false` (default)**:
- Dedicated requirements directory
- Strict separation between requirements and other docs
- Catch typos (e.g., `US-001.md` instead of `USR-001.md`)

**Error example with `allow_unrecognised = false`**:
```bash
$ req clean
Error: Unrecognised file: README.md
```

### `allow_invalid` (optional)

```toml
allow_invalid = false
```

**Type**: Boolean

**Default**: `false`

**Purpose**: Controls whether requirement files with invalid YAML frontmatter or formatting errors are allowed.

**Behavior**:

**`false` (default - strict mode)**:
- Requirements must have valid YAML frontmatter
- Missing required fields cause errors
- Ensures data integrity

**`true` (permissive mode)**:
- Invalid requirements are skipped with warnings
- Partial loading allows working with partially correct data
- Useful during migration or recovery

**Validation checks**:
- Valid YAML syntax
- Required fields present (`_version`, `uuid`, `created`)
- Valid UUID format
- Valid timestamp format
- Valid parent structure (if present)

**When to use `true`**:
- Migrating from another tool (gradual fix-up)
- Recovering from manual editing errors
- Development/debugging

**When to use `false` (default)**:
- Production use
- Ensure data quality
- Catch errors early

**Error example with `allow_invalid = false`**:
```bash
$ req clean
Error: Invalid requirement USR-001.md: missing required field 'uuid'
```

**Warning example with `allow_invalid = true`**:
```bash
$ req clean
Warning: Skipping invalid requirement USR-001.md: missing required field 'uuid'
Successfully loaded 42 requirements (1 skipped)
```

## Configuration Strategy

### Start Simple

Begin with minimal configuration:

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

Add constraints as your project matures.

### Recommended Settings

**Small project (< 100 requirements)**:
```toml
_version = "1"
digits = 3
allow_unrecognised = false
allow_invalid = false
```

**Large project (> 1000 requirements)**:
```toml
_version = "1"
allowed_kinds = ["USR", "SYS", "SWR", "HWR", "TST", "DOC"]
digits = 4
allow_unrecognised = false
allow_invalid = false
```

**Integrated documentation project**:
```toml
_version = "1"
allowed_kinds = ["USR", "SYS"]
digits = 3
allow_unrecognised = true  # Mixed with other docs
allow_invalid = false
```

**Migration project**:
```toml
_version = "1"
digits = 3
allow_unrecognised = true
allow_invalid = true  # Temporarily permissive during migration
```

## Validation

Validate your configuration by running:

```bash
req clean
```

This loads all requirements and reports configuration-related errors.

**Successful validation**:
```bash
$ req clean
# No output = success
```

**Configuration error**:
```bash
$ req clean
Error: Failed to parse config file: missing field '_version'
```

## Configuration Examples

### Regulated Industry (Aerospace)

```toml
_version = "1"

# DO-178C levels: User, System, Software, Hardware, Test
allowed_kinds = ["URQT", "SRQT", "SWRQT", "HWRQT", "TRQT"]

# Large project
digits = 4

# Strict validation
allow_unrecognised = false
allow_invalid = false
```

### Agile Software Project

```toml
_version = "1"

# User stories, system reqs, tests
allowed_kinds = ["USR", "SYS", "TST"]

# Small/medium project
digits = 3

# Allow flexibility
allow_unrecognised = false
allow_invalid = false
```

### Multi-Component System

```toml
_version = "1"

# Component-prefixed kinds
allowed_kinds = [
    "USR",           # Cross-cutting user requirements
    "AUTH-SYS",      # Authentication subsystem
    "PAY-SYS",       # Payment subsystem
    "REPORT-SYS",    # Reporting subsystem
]

digits = 3
allow_unrecognised = false
allow_invalid = false
```

## Troubleshooting

### Config file not recognized

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

**Solution**: Ensure the file is named exactly `config.toml` (lowercase, no extra extensions) and is in the requirements root directory.

### Parse errors

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

**Solution**: Validate TOML syntax:
- Strings must be quoted: `_version = "1"`, not `_version = 1`
- Arrays use square brackets: `allowed_kinds = ["USR", "SYS"]`
- Check for typos in field names

Use a TOML validator or linter if needed.

### Unexpected behavior

**Problem**: Requirements are rejected unexpectedly.

**Solution**:
1. Check `allowed_kinds` - ensure the kinds you're using are listed
2. Check `allow_unrecognised` - set to `true` if mixing requirements with other docs
3. Check `allow_invalid` - consider temporarily enabling for debugging

## Future Configuration Options

Planned configuration options (not yet implemented):

- **`namespace_separator`**: Customize the separator in namespaced HRIDs
- **`require_namespaces`**: Enforce namespace usage
- **`max_parents`**: Limit number of parent requirements
- **`tag_validation`**: Restrict allowed tag values
- **`review_policies`**: Configure review workflow behavior

## Next Steps

- Learn about [Directory Structure]./directory-structure.md for organizing requirements
- Understand [Namespaces]./namespaces.md for large projects