Skip to content

Commit d615a22

Browse files
nhortonclaude
andauthored
Make compares_to field required in rules (#78)
* Make compare_to field required in rules format Previously compare_to was optional with a default of "base". Now it must be explicitly specified in all rule definitions, making the change detection baseline configuration explicit rather than implicit. Changes: - Update schema to require compare_to field - Remove default value from rules parser - Update documentation to reflect required status - Add test for missing compare_to validation - Update all test rule definitions to include compare_to * Add compare_to field to all existing rule files All rule files now require the compare_to field. Updated: - .deepwork/rules/architecture-documentation-accuracy.md - .deepwork/rules/readme-accuracy.md - .deepwork/rules/standard-jobs-source-of-truth.md - .deepwork/rules/version-and-changelog-update.md - src/deepwork/standard_jobs/deepwork_rules/rules/skill-md-validation.md Also ran deepwork install to sync changes. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3afaeba commit d615a22

11 files changed

Lines changed: 105 additions & 11 deletions

File tree

.deepwork/jobs/deepwork_rules/rules/skill-md-validation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
name: SKILL.md Validation
33
trigger: "**/SKILL.md"
4+
compare_to: base
45
---
56
A SKILL.md file has been created or modified. Please validate that it follows the required format:
67

.deepwork/rules/architecture-documentation-accuracy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name: Architecture Documentation Accuracy
33
trigger: src/**/*
44
safety: doc/architecture.md
5+
compare_to: base
56
---
67
Source code in src/ has been modified. Please review doc/architecture.md for accuracy:
78
1. Verify the documented architecture matches the current implementation

.deepwork/rules/readme-accuracy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name: README Accuracy
33
trigger: src/**/*
44
safety: README.md
5+
compare_to: base
56
---
67
Source code in src/ has been modified. Please review README.md for accuracy:
78
1. Verify project overview still reflects current functionality

.deepwork/rules/standard-jobs-source-of-truth.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ trigger:
66
safety:
77
- src/deepwork/standard_jobs/deepwork_jobs/**/*
88
- src/deepwork/standard_jobs/deepwork_rules/**/*
9+
compare_to: base
910
---
1011
You modified files in `.deepwork/jobs/deepwork_jobs/` or `.deepwork/jobs/deepwork_rules/`.
1112

.deepwork/rules/version-and-changelog-update.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ trigger: src/**/*
44
safety:
55
- pyproject.toml
66
- CHANGELOG.md
7+
compare_to: base
78
---
89
Source code in src/ has been modified. **You MUST evaluate whether version and changelog updates are needed.**
910

doc/rules_syntax.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class AuthService:
3636
name: README Accuracy
3737
trigger: src/**/*
3838
safety: README.md
39+
compare_to: base
3940
---
4041
Source code changed. Please verify README.md is accurate.
4142

@@ -54,6 +55,7 @@ name: Source/Test Pairing
5455
set:
5556
- src/{path}.py
5657
- tests/{path}_test.py
58+
compare_to: base
5759
---
5860
Source and test files should change together.
5961

@@ -70,6 +72,7 @@ name: API Documentation
7072
pair:
7173
trigger: api/{path}.py
7274
expects: docs/api/{path}.md
75+
compare_to: base
7376
---
7477
API changes require documentation updates.
7578

@@ -88,6 +91,7 @@ name: Python Formatting
8891
trigger: "**/*.py"
8992
action:
9093
command: ruff format {file}
94+
compare_to: prompt
9195
---
9296
Automatically formats Python files using ruff.
9397

@@ -145,6 +149,7 @@ name: Source/Test Pairing
145149
set:
146150
- src/{path}.py
147151
- tests/{path}_test.py
152+
compare_to: base
148153
---
149154
```
150155

@@ -176,18 +181,21 @@ name: API Documentation
176181
pair:
177182
trigger: api/{module}/{name}.py
178183
expects: docs/api/{module}/{name}.md
184+
compare_to: base
179185
---
180186
```
181187

182188
Can specify multiple expected patterns:
183189

184190
```yaml
185191
---
192+
name: API Documentation
186193
pair:
187194
trigger: api/{path}.py
188195
expects:
189196
- docs/api/{path}.md
190197
- schemas/{path}.json
198+
compare_to: base
191199
---
192200
```
193201

@@ -224,6 +232,7 @@ safety: "*.pyi"
224232
action:
225233
command: ruff format {file}
226234
run_for: each_match
235+
compare_to: prompt
227236
---
228237
```
229238

@@ -385,19 +394,19 @@ action:
385394
---
386395
```
387396

388-
### compare_to (optional)
397+
### compare_to (required)
389398

390399
Determines the baseline for detecting file changes.
391400

392401
| Value | Description |
393402
|-------|-------------|
394-
| `base` (default) | Compare to merge-base with default branch |
403+
| `base` | Compare to merge-base with default branch |
395404
| `default_tip` | Compare to current tip of default branch |
396405
| `prompt` | Compare to state at last prompt submission |
397406

398407
```yaml
399408
---
400-
compare_to: prompt
409+
compare_to: base
401410
---
402411
```
403412

@@ -412,6 +421,7 @@ name: Test Coverage
412421
set:
413422
- src/{path}.py
414423
- tests/{path}_test.py
424+
compare_to: base
415425
---
416426
Source code was modified without corresponding test updates.
417427
@@ -434,6 +444,7 @@ pair:
434444
expects:
435445
- docs/api/{module}/{endpoint}.md
436446
- openapi/{module}.yaml
447+
compare_to: base
437448
---
438449
API endpoint changed. Please update:
439450
- Documentation: {expected_files}
@@ -453,6 +464,7 @@ safety:
453464
action:
454465
command: black {file}
455466
run_for: each_match
467+
compare_to: prompt
456468
---
457469
Formats Python files using Black.
458470
@@ -472,6 +484,7 @@ set:
472484
- backend/api/{feature}/models.py
473485
- frontend/src/api/{feature}.ts
474486
- frontend/src/components/{feature}/**/*
487+
compare_to: base
475488
---
476489
Feature files should be updated together across the stack.
477490
@@ -494,6 +507,7 @@ trigger:
494507
safety:
495508
- pyproject.toml
496509
- CHANGELOG.md
510+
compare_to: base
497511
---
498512
Code changes detected. Before merging, ensure:
499513
- Version is bumped in pyproject.toml (if needed)

src/deepwork/core/rules_parser.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class ActionType(Enum):
4040

4141
# Valid compare_to values
4242
COMPARE_TO_VALUES = frozenset({"base", "default_tip", "prompt"})
43-
DEFAULT_COMPARE_TO = "base"
4443

4544

4645
@dataclass
@@ -69,6 +68,11 @@ class Rule:
6968

7069
# Detection mode (exactly one must be set)
7170
detection_mode: DetectionMode
71+
72+
# Common options (required)
73+
compare_to: str # Required: "base", "default_tip", or "prompt"
74+
75+
# Detection mode details (optional, depends on mode)
7276
triggers: list[str] = field(default_factory=list) # For TRIGGER_SAFETY mode
7377
safety: list[str] = field(default_factory=list) # For TRIGGER_SAFETY mode
7478
set_patterns: list[str] = field(default_factory=list) # For SET mode
@@ -79,9 +83,6 @@ class Rule:
7983
instructions: str = "" # For PROMPT action (markdown body)
8084
command_action: CommandAction | None = None # For COMMAND action
8185

82-
# Common options
83-
compare_to: str = DEFAULT_COMPARE_TO
84-
8586
@classmethod
8687
def from_frontmatter(
8788
cls,
@@ -166,8 +167,8 @@ def from_frontmatter(
166167
if not markdown_body.strip():
167168
raise RulesParseError(f"Rule '{name}' with prompt action requires markdown body")
168169

169-
# Get compare_to
170-
compare_to = frontmatter.get("compare_to", DEFAULT_COMPARE_TO)
170+
# Get compare_to (required field)
171+
compare_to = frontmatter["compare_to"]
171172

172173
return cls(
173174
name=name,

src/deepwork/schemas/rules_schema.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
RULES_FRONTMATTER_SCHEMA: dict[str, Any] = {
1616
"$schema": "http://json-schema.org/draft-07/schema#",
1717
"type": "object",
18-
"required": ["name"],
18+
"required": ["name", "compare_to"],
1919
"properties": {
2020
"name": {
2121
"type": "string",
@@ -80,7 +80,6 @@
8080
"compare_to": {
8181
"type": "string",
8282
"enum": ["base", "default_tip", "prompt"],
83-
"default": "base",
8483
"description": "Baseline for detecting file changes",
8584
},
8685
},

src/deepwork/standard_jobs/deepwork_rules/rules/skill-md-validation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
name: SKILL.md Validation
33
trigger: "**/SKILL.md"
4+
compare_to: base
45
---
56
A SKILL.md file has been created or modified. Please validate that it follows the required format:
67

0 commit comments

Comments
 (0)