You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(review): inline reference files into review instructions + wire DeepSchema refs through (#353)
* feat(review): inline reference files into review instructions + wire DeepSchema refs through
DeepSchema-generated reviews previously only referenced their examples,
references, and json_schema_path by path, forcing reviewer agents to make
a Read tool call for each external file at review time.
Make reference-file inlining a generic feature of the review pipeline:
- Add `reference_files: list[ReferenceFile]` to both ReviewRule and ReviewTask
(src/deepwork/review/config.py).
- `.deepreview` rules gain an optional `review.reference_files` field
(src/deepwork/schemas/deepreview_schema.json), parsed with paths resolved
against the rule's source dir.
- `build_instruction_file` emits a new `## Reference Materials` section with
fenced contents of each referenced file, honoring MAX_INLINE_FILES (20) and
MAX_INLINE_TOTAL_BYTES (256KB) caps, with graceful markers for
missing/unreadable files (src/deepwork/review/instructions.py).
- Matcher propagates `reference_files` from ReviewRule to ReviewTask for all
strategies (src/deepwork/review/matcher.py).
- DeepSchema bridge now populates reference_files from examples, references,
and json_schema_path, resolved relative to the schema file's directory.
URL-style entries (http/https) are skipped. Missing-file errors are surfaced
via the existing errors channel of generate_review_rules
(src/deepwork/deepschema/review_bridge.py).
- Fix a pre-existing broken relative path in the job_yml standard schema
(`../../../doc/...` → `../../../../doc/...`) that the new error-surfacing
flagged (src/deepwork/standard_schemas/job_yml/deepschema.yml).
Tests cover inlining, count/byte caps, missing files, .deepreview parsing,
and DeepSchema bridge population + error surfacing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat(review): examples listed not inlined; add requirements + docs
Follow-up to the review pipeline reference_files work:
- DeepSchema bridge now lists `examples` (path + description) inside the
generated review instructions instead of inlining their contents, keeping
the prompt lean. `references` and `json_schema_path` are still inlined.
- Add REVIEW-REQ-001.10 (Reference Files config), REVIEW-REQ-005.8
(Reference Materials section + caps), and DW-REQ-011.11 (Review Bridge
Reference Files) covering the new end-user-observable behavior.
- Add traceability comments on the new tests referencing the new REQ IDs.
- Add test coverage for the new listing behavior and URL-reference skipping.
- Document reference_files in README_REVIEWS.md and the deepreviews skill,
including the 20-file / 256 KB caps and the examples-listed-vs-references-
inlined split for DeepSchema-generated reviews.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* chore: ruff format
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README_REVIEWS.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -106,8 +106,19 @@ rule_name:
106
106
additional_context: # Optional. Extra context for the reviewer.
107
107
all_changed_filenames: true
108
108
unchanged_matching_files: true
109
+
reference_files: # Optional. Files whose contents are inlined
110
+
- path: "docs/style_guide.md"# into a "## Reference Materials" section of
111
+
description: "Style guide"# every generated review instruction file.
109
112
```
110
113
114
+
### Reference Files
115
+
116
+
`reference_files` inline small support documents (style guides, JSON schemas, templates) directly into the reviewer's prompt so the agent does not need to fetch them at review time. Paths are resolved relative to the `.deepreview` file's directory.
117
+
118
+
Inlining is capped: at most 20 files and 256 KB of total content per review. Files beyond either cap are listed in an omitted summary line; oversized files are truncated with a marker. Missing or unreadable files produce a graceful marker but do not abort the review.
119
+
120
+
DeepSchema-generated reviews automatically populate `reference_files` from the schema's `references` entries and `json_schema_path`. A schema's `examples` are listed (by path and description) in the review instructions but are **not** inlined — reviewers can fetch them on demand.
121
+
111
122
## Review Strategies
112
123
113
124
The `strategy` field controls how matched files are grouped into review tasks.
Copy file name to clipboardExpand all lines: plugins/claude/skills/deepreviews/SKILL.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,8 +52,15 @@ rule_name:
52
52
additional_context: # Optional
53
53
all_changed_filenames: true # Include all changed files list
54
54
unchanged_matching_files: true # Include unchanged files matching the pattern
55
+
reference_files: # Optional: inlined into review prompt
56
+
- path: "docs/style_guide.md"
57
+
description: "Coding style guide"
55
58
```
56
59
60
+
### Reference Files
61
+
62
+
`reference_files` inline small support files (style guides, schemas, templates) into a `## Reference Materials` section of every generated review instruction file. Paths are resolved relative to the `.deepreview` file's directory. Inlining is capped at 20 files and 256 KB of total content per review — entries beyond the caps are listed in an omitted-summary line; oversized files are truncated. Missing files produce a graceful marker rather than aborting the review. Use this instead of asking the reviewer to Read each file at runtime.
63
+
57
64
## Review Strategies
58
65
59
66
| Strategy | Behavior | Best for |
@@ -91,6 +98,8 @@ Deleted files are excluded — there's nothing to review.
91
98
92
99
DeepSchemas automatically generate synthetic review rules. When a file matches a DeepSchema with requirements, the review pipeline creates a rule that checks those requirements during `/review` and workflow quality gates. No `.deepreview` file is needed — the DeepSchema's `requirements` field drives the review.
93
100
101
+
Generated reviews automatically populate `reference_files` from the schema's `references` entries and `json_schema_path`, so reviewers receive that supporting context inlined. A schema's `examples` are listed (by path + description) in the review instructions but are **not** inlined; reviewers can open them on demand if needed. URL-valued references are skipped.
102
+
94
103
This means requirements defined in a DeepSchema are enforced in two places:
95
104
- **Write-time**: validation runs when the file is written or edited
96
105
- **Review-time**: a generated review rule checks compliance during `/review`
Copy file name to clipboardExpand all lines: specs/deepwork/DW-REQ-011-deepschema.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,3 +77,12 @@ The DeepSchema system provides rich, file-level schemas with automatic validatio
77
77
2. Requirements about processes, user behavior, or context not present in files SHOULD be placed in the `instructions` section instead.
78
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
79
4. Requirements SHOULD focus on semantic rules, behavioral gotchas, and cross-field concerns that JSON Schema cannot express.
80
+
81
+
## DW-REQ-011.11: Review Bridge Reference Files
82
+
83
+
1. The DeepSchema review bridge MUST populate the generated `ReviewRule.reference_files` with the schema's `references` entries and the `json_schema_path` file (when set), so reviewers receive their contents inlined in the review instructions.
84
+
2. Each referenced path MUST be resolved relative to the schema file's directory.
85
+
3. The schema's `examples` entries MUST NOT be inlined as reference files. Instead, the bridge MUST list them in the rule's review instruction text with their `path` and `description` so reviewers know the example material exists and can fetch it on demand.
86
+
4. The order of inlined reference files MUST be deterministic across runs for a given schema.
87
+
5. When a referenced file cannot be located on disk, the bridge MUST skip it and surface an error through the `errors` return of `generate_review_rules`. A missing reference file MUST NOT prevent the rule from being generated.
88
+
6. Reference entries whose `path` begins with `http://` or `https://` MUST be skipped without producing an error, since they are informational pointers rather than local files.
5. If the command fails (non-zero exit or timeout), the system MUST inject an error message into the instruction file rather than failing the pipeline.
86
86
6. The command MUST be executed at most once per unique command string across all tasks in a review run.
87
87
7. When multiple rules declare precompute commands, all unique commands MUST be executed in parallel.
88
+
89
+
### REVIEW-REQ-001.10: Reference Files
90
+
91
+
1. A rule's `review` block MAY declare an optional `reference_files` array. Each entry MUST be an object with a required `path` field and an optional `description` field.
92
+
2. Each `reference_files.path` MUST be resolved relative to the `.deepreview` file's directory and surfaced on the parsed rule as an absolute path with its original relative string preserved as a display label.
93
+
3. When `reference_files` is not specified, the parsed rule's `reference_files` MUST default to an empty list.
Copy file name to clipboardExpand all lines: specs/deepwork/review/REVIEW-REQ-005-instruction-generation.md
+9Lines changed: 9 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,3 +55,12 @@ For each `ReviewTask`, the system generates a self-contained markdown instructio
55
55
2. The "Precomputed Context" section MUST be the last content section in the instruction file, appearing after all file listing sections and before the "After Review" section.
56
56
3. The section MUST contain the verbatim stdout of the precomputed command.
57
57
4. When the command failed, the section MUST contain an error message with stderr and exit code.
58
+
59
+
### REVIEW-REQ-005.8: Reference Materials Section
60
+
61
+
1. When a task's `reference_files` is empty, the instruction file MUST NOT contain a "Reference Materials" section.
62
+
2. When a task has `reference_files`, the instruction file MUST contain a "## Reference Materials" section placed between "Review Instructions" and "Files to Review".
63
+
3. Each inlined file MUST be rendered with a `### {relative_label}` subheading, the optional description, and the file contents inside a fenced code block whose language is inferred from the file extension.
64
+
4. The number of inlined reference files MUST NOT exceed `MAX_INLINE_FILES` (20). Entries beyond that cap MUST be listed in an "omitted due to size/count caps" summary line rather than inlined.
65
+
5. The total inlined byte size of reference file contents MUST NOT exceed `MAX_INLINE_TOTAL_BYTES` (256 * 1024). Files whose contents would exceed the remaining byte budget MUST be truncated with a visible truncation marker, and any subsequent entries MUST be reported in the omitted summary line.
66
+
6. When a referenced file cannot be read (missing, permission denied, or invalid UTF-8), the system MUST emit a graceful marker line referencing the file and the error, MUST NOT abort the section, and MUST NOT count the file's would-be bytes against the budget.
0 commit comments