Skip to content

Commit fc2f5fd

Browse files
nhortonclaude
andcommitted
feat: add requirements_file standard schema, specs, and review improvements
- Add built-in requirements_file deepschema for RFC 2119 spec files - Add JOBS-REQ-012 spec for learn workflow prevention automation - Add DW-REQ-011.10 requirement quality constraints for deepschemas - Add anonymous deepschemas validating JOBS-REQ-012 and DW-REQ-011.10 - Improve requirements_traceability review to prefer anonymous deepschemas for single-file requirements over tests - Fix multi-keyword requirements in DW-REQ-011 (011.6.3, 011.7.3, 011.8.7) - Fix REVIEW-REQ-005.7 sequential ordering - Fix job_schema_instruction_compatibility description accuracy Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9ebe600 commit fc2f5fd

8 files changed

Lines changed: 189 additions & 35 deletions

File tree

.deepreview

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,33 @@ requirements_traceability:
131131
false confidence (a passing test that doesn't actually verify anything)
132132
or wastes reviewer judgment on something a machine can check exactly.
133133

134+
**Use anonymous DeepSchemas** (`.deepschema.<filename>.yml`) when
135+
requirements target a specific file — whether structural or semantic:
136+
- "This config file MUST include a timeout field" — structural check
137+
for one file (use `json_schema_path` or `verification_bash_command`
138+
for exact verification)
139+
- "The learn workflow MUST accept X and Y step arguments" — the
140+
requirement governs a specific YAML file's content
141+
- "Skill MUST instruct the agent to do X" — judgment-based check
142+
of prose in one specific file
143+
- "The error message MUST include a suggestion for how to fix the
144+
problem" — governs a specific source file's behavior
145+
146+
Anonymous DeepSchemas provide both write-time validation and review-time
147+
checks, and they keep the requirement co-located with the file it governs.
148+
**Prefer them over both tests and `.deepreview` rules whenever the
149+
requirement targets a specific file** rather than a class of files.
150+
DeepSchemas can enforce structural requirements via `json_schema_path`
151+
or `verification_bash_command` just as precisely as a test, while also
152+
supporting judgment-based requirements in the same schema.
153+
134154
**Use automated tests** (`tests/`) when the requirement specifies a
135-
concrete, machine-verifiable fact:
136-
- File exists at a specific path
137-
- JSON/YAML field has a specific value
138-
- Config contains a specific identifier (e.g., `mcp__deepwork__get_review_instructions`)
155+
concrete, machine-verifiable fact that spans multiple files or is not
156+
tied to a single file's content:
139157
- File A is byte-identical to file B
140-
- A data structure has a required shape
158+
- A Python function returns the correct value for given inputs
159+
- A CLI command produces expected output
160+
- A data structure assembled from multiple sources has a required shape
141161

142162
Tests reference requirement IDs via docstrings and traceability comments.
143163

@@ -150,21 +170,6 @@ requirements_traceability:
150170
- "Documentation MUST stay in sync with code" — are the descriptions
151171
still accurate after changes?
152172

153-
**Use anonymous DeepSchemas** (`.deepschema.<filename>.yml`) when the
154-
requirement is specific to a single file's behavior or content:
155-
- "The error message in situation X MUST include a suggestion for how
156-
to fix the problem" — place the requirement in a `.deepschema` for
157-
the file that implements that functionality
158-
- "This config file MUST include a timeout field" — a structural
159-
requirement for one specific file
160-
- "Skill MUST instruct the agent to do X" — does the prose in this
161-
specific skill file convey X clearly enough?
162-
163-
Anonymous DeepSchemas provide both write-time validation and review-time
164-
checks, and they keep the requirement co-located with the file it governs.
165-
Prefer them over `.deepreview` rules whenever the requirement targets a
166-
specific file rather than a class of files.
167-
168173
Both `.deepreview` rules and DeepSchemas reference requirement IDs in
169174
their `description`, `instructions`, or `requirements` fields.
170175

@@ -456,7 +461,7 @@ deepreview_config_quality:
456461
and a specific recommendation.
457462

458463
job_schema_instruction_compatibility:
459-
description: "Verify deepwork_jobs job.yml inline instructions are compatible with the job schema."
464+
description: "Verify all standard and library job.yml definitions and templates are compatible with the job schema."
460465
match:
461466
include:
462467
- "src/deepwork/jobs/job.schema.json"

.deepwork/schemas/claude_settings/claude_settings.schema.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"examples": [
1111
"Bash",
1212
"Bash(npm run build)",
13-
"Bash(git commit *)",
14-
"Bash(npm run *)",
13+
"Bash(git commit:*)",
14+
"Bash(npm run:*)",
1515
"Bash(ls*)",
1616
"Bash(git * main)",
1717
"Edit",
@@ -24,7 +24,8 @@
2424
"WebFetch",
2525
"WebFetch(domain:example.com)",
2626
"mcp__puppeteer",
27-
"mcp__github__search_repositories"
27+
"mcp__github__search_repositories",
28+
"mcp__github__*"
2829
]
2930
},
3031
"hookCommand": {
@@ -1798,4 +1799,4 @@
17981799
}
17991800
},
18001801
"title": "Claude Code Settings"
1801-
}
1802+
}

specs/deepwork/DW-REQ-011-deepschema.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# DW-REQ-011: DeepSchema System
22

3+
## Overview
4+
35
The DeepSchema system provides rich, file-level schemas with automatic validation on writes and synthetic review rule generation.
46

57
## DW-REQ-011.1: Schema Types
@@ -42,13 +44,13 @@ The DeepSchema system provides rich, file-level schemas with automatic validatio
4244

4345
1. A file MUST match a named schema if any of the schema's `matchers` glob patterns match the file's project-relative path.
4446
2. A file MUST match an anonymous schema if a `.deepschema.<filename>.yml` file exists alongside it.
45-
3. The `get_schemas_for_file_fast()` function MUST avoid full tree walks — it MUST only scan named schema folders and check for the anonymous schema file at O(1).
47+
3. The `get_schemas_for_file_fast()` function MUST avoid full tree walks by only scanning named schema folders and checking for the anonymous schema file at O(1).
4648

4749
## DW-REQ-011.7: Write Hook (PostToolUse)
4850

4951
1. The write hook MUST fire on PostToolUse events for Write and Edit tools.
5052
2. For each applicable schema, the hook MUST inject a conformance note: "Note: this file must conform to the DeepSchema at `<path>`".
51-
3. If `json_schema_path` is set, the hook MUST validate the written file against the JSON Schema. YAML files (`.yml`/`.yaml`) MUST be parsed as YAML before validation.
53+
3. If `json_schema_path` is set, the hook MUST validate the written file against the JSON Schema, parsing YAML files (`.yml`/`.yaml`) as YAML before validation.
5254
4. If `verification_bash_command` is set, the hook MUST execute each command with the file path as `$1`, with a 30-second timeout.
5355
5. Validation failures MUST be reported via `hookSpecificOutput.additionalContext` so the agent can act on them.
5456
6. The hook MUST NOT use `systemMessage` for validation output — that route is user-visible only.
@@ -61,10 +63,17 @@ The DeepSchema system provides rich, file-level schemas with automatic validatio
6163
4. Anonymous schema reviews MUST include only the requirements.
6264
5. All generated reviews MUST use the `"individual"` strategy (one file at a time).
6365
6. Generated reviews MUST be included in both `/review` runs and workflow quality gate checks.
64-
7. Review instructions MUST specify RFC 2119 severity logic: reviewers MUST fail any violation of a MUST requirement, MUST fail any SHOULD requirement that could easily be followed but is not, SHOULD give feedback without failing on other applicable items, and MUST ignore requirements that are not applicable.
66+
7. Review instructions MUST specify RFC 2119 severity logic: fail any violation of a MUST requirement, fail any SHOULD requirement that could easily be followed but is not, give feedback without failing on other applicable items, and ignore requirements that are not applicable.
6567

6668
## DW-REQ-011.9: MCP Tool — get_named_schemas
6769

6870
1. The `get_named_schemas` MCP tool MUST return all discovered named schemas.
6971
2. Each entry MUST include `name`, `summary`, and `matchers` fields.
7072
3. Schemas that fail to parse MUST still appear in the results with an error summary instead of a real summary.
73+
74+
## DW-REQ-011.10: Requirement Quality Constraints
75+
76+
1. Each requirement in the `requirements` field MUST be verifiable by examining files on the filesystem.
77+
2. Requirements about processes, user behavior, or context not present in files SHOULD be placed in the `instructions` section instead.
78+
3. Requirements MUST NOT restate constraints that are already enforced by the schema's `json_schema_path` or `verification_bash_command`, including syntactic validity (e.g., "must be valid JSON"), field types, allowed enum values, required fields, and structural shape.
79+
4. Requirements SHOULD focus on semantic rules, behavioral gotchas, and cross-field concerns that JSON Schema cannot express.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# JOBS-REQ-012: Learn Workflow
2+
3+
## Overview
4+
5+
The `learn` workflow in the `deepwork_jobs` standard job analyzes conversation history to extract learnings from DeepWork job executions. It improves job instructions with generalizable insights, captures run-specific learnings in AGENTS.md files, and creates preventive automation (DeepSchemas and DeepReview rules) to prevent recurring issues.
6+
7+
## Requirements
8+
9+
### JOBS-REQ-012.1: Learning Classification
10+
11+
1. The learn workflow MUST classify each identified learning as either **generalizable** (applicable to future runs of the same job) or **bespoke** (specific to the current run/context).
12+
2. Generalizable learnings MUST be applied to job instruction files.
13+
3. Bespoke learnings MUST be captured in an AGENTS.md file in the deepest common folder that would contain all future work on the topic.
14+
15+
### JOBS-REQ-012.2: Prevention Opportunity Evaluation
16+
17+
1. The learn workflow MUST evaluate whether DeepSchemas or DeepReview rules could prevent issues encountered during the session.
18+
2. If prevention opportunities exist, the workflow SHOULD create the corresponding DeepSchemas or DeepReview rules.
19+
3. If no prevention opportunities are found, the workflow MUST state why none were identified.
20+
21+
### JOBS-REQ-012.3: Step Arguments
22+
23+
1. The learn workflow MUST accept a `deepschemas` step argument for outputting created DeepSchema files.
24+
2. The learn workflow MUST accept a `deepreviews` step argument for outputting created DeepReview rule files.
25+
26+
### JOBS-REQ-012.4: Process Requirements
27+
28+
1. The workflow MUST enforce that generalizable learnings are applied to job instructions ("Generalizable Learnings Applied").
29+
2. The workflow MUST enforce that bespoke learnings are captured in AGENTS.md ("Bespoke Learnings Captured").
30+
3. The workflow MUST enforce that prevention opportunities are evaluated ("Prevention Opportunities Evaluated").

specs/deepwork/review/REVIEW-REQ-005-instruction-generation.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ For each `ReviewTask`, the system generates a self-contained markdown instructio
1616
6. When the task has `additional_files` (unchanged matching files), the file MUST contain an "Unchanged Matching Files" section listing those file paths.
1717
7. When the task has `all_changed_filenames`, the file MUST contain an "All Changed Files" section listing every changed filename for context.
1818

19-
### REVIEW-REQ-005.7: Git Diff Section
20-
21-
1. When a `ReviewTask` has a non-null `git_diff_output`, the instruction file MUST contain a section headed `## Output from \`git diff main..HEAD\` for you to review (sorted by filepath)`.
22-
2. The diff output MUST be rendered inside a fenced code block with the `diff` language tag.
23-
3. This section MUST appear after the "Files to Review" section and before the "All Changed Files" section.
24-
4. When `git_diff_output` is `None`, this section MUST be omitted.
25-
2619
### REVIEW-REQ-005.2: File Path Formatting
2720

2821
1. File paths in the "Files to Review" section MUST be prefixed with `@` to trigger Claude Code's file-reading behavior (e.g., `@src/app.py`).
@@ -54,3 +47,10 @@ For each `ReviewTask`, the system generates a self-contained markdown instructio
5447
2. The traceability line MUST be formatted as: `This review was requested by the policy at \`{source_location}\`.` where `source_location` is the relative file path and line number (e.g., `src/.deepreview:5`).
5548
3. The traceability line MUST be preceded by a markdown horizontal rule (`---`).
5649
4. When `source_location` is empty, the traceability section MUST be omitted.
50+
51+
### REVIEW-REQ-005.7: Git Diff Section
52+
53+
1. When a `ReviewTask` has a non-null `git_diff_output`, the instruction file MUST contain a section headed `## Output from \`git diff main..HEAD\` for you to review (sorted by filepath)`.
54+
2. The diff output MUST be rendered inside a fenced code block with the `diff` language tag.
55+
3. This section MUST appear after the "Files to Review" section and before the "All Changed Files" section.
56+
4. When `git_diff_output` is `None`, this section MUST be omitted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
requirements:
2+
learn-workflow-step-arguments: >
3+
The learn workflow MUST accept `deepschemas` and `deepreviews` step
4+
arguments for outputting created DeepSchema and DeepReview rule files.
5+
(JOBS-REQ-012.3)
6+
7+
learn-workflow-classification: >
8+
The learn workflow's step instructions MUST describe how to classify
9+
each learning as either generalizable (applied to job instructions) or
10+
bespoke (captured in AGENTS.md). (JOBS-REQ-012.1)
11+
12+
learn-workflow-prevention-evaluation: >
13+
The learn workflow MUST include instructions for evaluating whether
14+
DeepSchemas or DeepReview rules could prevent issues encountered during
15+
the session, and MUST require the agent to state why if none are found.
16+
(JOBS-REQ-012.2)
17+
18+
learn-workflow-process-requirements: >
19+
The learn workflow's quality review MUST enforce "Generalizable Learnings
20+
Applied", "Bespoke Learnings Captured", and "Prevention Opportunities
21+
Evaluated" as process requirements. (JOBS-REQ-012.4)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
requirements:
2+
requirements-filesystem-verifiable-present: >
3+
The deepschema standard schema MUST include a requirement enforcing that
4+
DeepSchema requirements are verifiable by examining files on the
5+
filesystem. (DW-REQ-011.10.1)
6+
7+
no-structural-requirements-present: >
8+
The deepschema standard schema MUST include a requirement enforcing that
9+
DeepSchema requirements do not restate constraints already enforced by
10+
json_schema_path or verification_bash_command. (DW-REQ-011.10.3)
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
summary: "RFC 2119 requirements specification files."
2+
3+
instructions: |
4+
Requirements files define formal specifications using RFC 2119 keywords.
5+
They follow the naming convention `REQ-NNN-<topic>.md` where NNN is a
6+
zero-padded number.
7+
8+
Each file has:
9+
- A `# REQ-NNN: Title` top-level heading matching the filename prefix.
10+
- An `## Overview` section describing the subsystem.
11+
- A `## Requirements` section containing one or more `### REQ-NNN.M: Title`
12+
subsections, each with a numbered list of requirements.
13+
14+
Every requirement statement must be specific enough to be verifiable by either
15+
an automated test or a DeepReview rule. Vague requirements like "SHOULD be fast"
16+
or "MUST be user-friendly" are not acceptable — they must include a concrete,
17+
evaluable criterion.
18+
19+
When adding new requirements:
20+
- Assign the next sequential section number (REQ-NNN.M where M is next unused).
21+
- Number requirements sequentially within each section (1, 2, 3...).
22+
- Each requirement gets exactly one RFC 2119 keyword (MUST, SHOULD, MAY, etc.).
23+
24+
Requirement ID stability:
25+
- Never change or reassign an existing requirement's number.
26+
- New requirements always go at the end of their section.
27+
- If a requirement is removed, keep its number and replace the body with
28+
"REQUIREMENT REMOVED" so external references (tests, review rules) remain valid.
29+
30+
matchers:
31+
- "**/*REQ-*.md"
32+
33+
requirements:
34+
rfc-2119-keyword: >
35+
Every numbered requirement statement MUST contain exactly one RFC 2119
36+
keyword (MUST, MUST NOT, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED,
37+
MAY, OPTIONAL, REQUIRED). A requirement without a keyword is ambiguous and
38+
MUST be flagged.
39+
40+
unique-section-ids: >
41+
Each `### REQ-NNN.M:` section heading MUST have a unique ID within the
42+
file. The NNN portion MUST match the filename's prefix (e.g., sections in
43+
`REQ-001-application-shell.md` MUST all use `REQ-001.X`).
44+
45+
sequential-numbering: >
46+
Requirements within each section MUST be sequentially numbered starting
47+
from 1, with no gaps or duplicates. Section sub-IDs (the .M part) MUST
48+
also be sequential within the file.
49+
50+
testability: >
51+
Each requirement MUST be specific enough to be verifiable — either by an
52+
automated test (for concrete, machine-checkable facts) or by a DeepReview
53+
rule (for judgment-based, cross-file concerns). Requirements that cannot
54+
be objectively evaluated MUST be rewritten with concrete criteria.
55+
56+
overview-section: >
57+
Requirements files MUST begin with a top-level heading matching the
58+
filename prefix, followed by an `## Overview` section that describes the
59+
subsystem's purpose and scope.
60+
61+
no-orphan-requirements: >
62+
Every MUST or SHALL requirement MUST have a corresponding test, DeepSchema
63+
requirement, or DeepReview rule that validates it. Requirements without any
64+
validation mechanism SHOULD be flagged during review.
65+
66+
requirement-id-stability: >
67+
Existing requirement numbers MUST NOT be changed or reassigned. New
68+
requirements MUST be appended to the end of their section with the next
69+
sequential number. If a requirement is fully removed, its number MUST
70+
remain in place with the body replaced by "REQUIREMENT REMOVED" so that
71+
all other IDs remain stable and external references do not break.
72+
73+
verification_bash_command:
74+
- "grep -nE '^[0-9]+\\.' \"$1\" | grep -vE 'MUST|SHALL|SHOULD|MAY|REQUIRED|RECOMMENDED|OPTIONAL' | { if read -r line; then echo \"FAIL: Requirement without RFC 2119 keyword: $line\"; exit 1; fi; }"
75+
76+
references:
77+
- path: "https://www.ietf.org/rfc/rfc2119.txt"
78+
description: "RFC 2119 — Key words for use in RFCs to Indicate Requirement Levels."

0 commit comments

Comments
 (0)