Skip to content

Commit 571cfcd

Browse files
corvid-agentclaude
andcommitted
docs: add spec for specsync rules command
Adds cmd_rules spec with companion files (tasks.md, context.md) covering the new declarative rules listing command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6e1ac3e commit 571cfcd

3 files changed

Lines changed: 97 additions & 0 deletions

File tree

specs/cmd_rules/cmd_rules.spec.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
module: cmd_rules
3+
version: 1
4+
status: stable
5+
files:
6+
- src/commands/rules.rs
7+
db_tables: []
8+
tracks: []
9+
depends_on:
10+
- specs/commands/commands.spec.md
11+
- specs/config/config.spec.md
12+
- specs/types/types.spec.md
13+
---
14+
15+
# Cmd Rules
16+
17+
## Purpose
18+
19+
Implements the `specsync rules` command. Lists all active validation rules — both built-in (from `specsync.json` `rules` section) and custom declarative rules (from `customRules` array). Shows configuration status, severity, rule type, and filter criteria.
20+
21+
## Public API
22+
23+
### Exported Functions
24+
25+
| Function | Parameters | Returns | Description |
26+
|----------|-----------|---------|-------------|
27+
| `cmd_rules` | `root: &Path` | `()` | Load config and display all built-in and custom validation rules |
28+
29+
### Internal Functions
30+
31+
| Function | Parameters | Returns | Description |
32+
|----------|-----------|---------|-------------|
33+
| `print_builtin` | `name: &str, description: &str, value: Option<String>` | `()` | Print a built-in rule with its active/off status |
34+
35+
## Invariants
36+
37+
1. Built-in rules always display, showing "active" with value when configured or "off" when unset
38+
2. Five built-in rules listed: `max_changelog_entries`, `require_behavioral_examples`, `min_invariants`, `max_spec_size_kb`, `require_depends_on`
39+
3. Custom rules section only displays when `customRules` is non-empty; otherwise shows guidance to add them
40+
4. Each custom rule displays name, severity (color-coded), type, and optional section/pattern/min_words/applies_to/message fields
41+
5. Severity colors: error → red, warning → yellow, info → blue
42+
43+
## Behavioral Examples
44+
45+
### Scenario: No custom rules defined
46+
47+
- **Given** `specsync.json` has no `customRules` array
48+
- **When** `specsync rules` runs
49+
- **Then** built-in rules are listed, followed by "No custom rules defined." with guidance text
50+
51+
### Scenario: Custom rules with filters
52+
53+
- **Given** a custom rule with `appliesTo: { status: "stable", module: "^auth" }`
54+
- **When** `specsync rules` runs
55+
- **Then** the rule shows `applies_to: status=stable, module=/^auth/`
56+
57+
## Error Cases
58+
59+
| Condition | Behavior |
60+
|-----------|----------|
61+
| Missing `specsync.json` | Config loader handles this (not this module's concern) |
62+
63+
## Dependencies
64+
65+
### Consumes
66+
67+
| Module | What is used |
68+
|--------|-------------|
69+
| config | `load_config` |
70+
| types | `CustomRuleType`, `RuleSeverity` |
71+
72+
### Consumed By
73+
74+
| Module | What is used |
75+
|--------|-------------|
76+
| cli (main.rs) | Entry point for `specsync rules` |
77+
78+
## Change Log
79+
80+
| Date | Change |
81+
|------|--------|
82+
| 2026-04-10 | Initial spec |

specs/cmd_rules/context.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# cmd_rules — Context
2+
3+
## Design Decisions
4+
5+
- **Read-only command**: `rules` is purely informational — it reads config and displays, never modifies state.
6+
- **Built-in rules always shown**: Even when all are "off", they're listed so users know what's available to configure.
7+
- **Color-coded severity**: Matches the color scheme used in `specsync check` output for consistency.
8+
9+
## Related
10+
11+
- Custom rules are defined in `specsync.json` under the `customRules` key.
12+
- Custom rule validation logic lives in `src/validator.rs`, not in this command module.

specs/cmd_rules/tasks.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# cmd_rules — Tasks
2+
3+
No open tasks.

0 commit comments

Comments
 (0)