Skip to content

feat(review): inline reference files into review instructions + wire DeepSchema refs through#353

Merged
nhorton merged 3 commits intomainfrom
feat/inline-reference-files
Apr 9, 2026
Merged

feat(review): inline reference files into review instructions + wire DeepSchema refs through#353
nhorton merged 3 commits intomainfrom
feat/inline-reference-files

Conversation

@nhorton
Copy link
Copy Markdown
Contributor

@nhorton nhorton commented Apr 9, 2026

Problem

DeepSchema-generated reviews only pointed reviewers at their examples, references, and json_schema_path by path. Running just the job_yml DeepSchema Compliance review for a single job.yml forced the reviewer to Read job.schema.json, several templates, and doc/job_yml_guidance.md at runtime — the main source of tool-call overhead.

Approach

Make reference-file inlining a generic feature of the review pipeline rather than a DeepSchema-only fix.

  • ReviewRule and ReviewTask now carry reference_files: list[ReferenceFile].
  • .deepreview rules get an optional review.reference_files field (schema + parser).
  • build_instruction_file emits a new ## Reference Materials section with fenced contents, honoring MAX_INLINE_FILES = 20 and MAX_INLINE_TOTAL_BYTES = 256 * 1024, with graceful markers for missing files.
  • The matcher propagates reference_files from rules to tasks across all strategies.
  • The DeepSchema bridge populates reference_files from examples, references, and json_schema_path, resolved relative to the schema file's directory. URL-style entries are skipped. Missing files surface via the existing errors channel from generate_review_rules.

Also fixes a pre-existing broken relative path in src/deepwork/standard_schemas/job_yml/deepschema.yml that the new error-surfacing flagged.

Before / After

Generated instruction file for job_yml DeepSchema Compliance on src/deepwork/standard_jobs/deepwork_jobs/job.yml:

  • Before: ## Review Instructions (summary + requirements) + ## Files to Review. Reviewer had to Read job.schema.json, templates/job.yml.example, templates/job.yml.template, templates/step_instruction.md.template, research_report_job_best_practices.md, and doc/job_yml_guidance.md.
  • After: Same plus a new ## Reference Materials section containing all of those files inlined. Reviewer makes zero extra Read calls for the schema's referenced material.

Verification

  • uv run pytest — 1263 passed, 1 skipped, 1 xfailed.
  • uv run ruff check src tests — clean.
  • uv run mypy src/deepwork/review/instructions.py src/deepwork/review/config.py src/deepwork/deepschema/review_bridge.py — clean.
  • End-to-end: re-generated the job_yml DeepSchema Compliance instruction file and confirmed the new section contains the six reference files.

New tests cover: inlining with description + fenced blocks, count cap, byte cap, missing file, empty list, .deepreview parsing, and DeepSchema bridge population + error surfacing.

Files

  • src/deepwork/review/config.py — new ReferenceFile; field on ReviewRule/ReviewTask; .deepreview parser.
  • src/deepwork/review/instructions.py — caps, _build_reference_files_section, wired into build_instruction_file.
  • src/deepwork/review/matcher.py — propagate reference_files to ReviewTask.
  • src/deepwork/schemas/deepreview_schema.json — optional reference_files field.
  • src/deepwork/deepschema/review_bridge.py_collect_reference_files helper.
  • src/deepwork/standard_schemas/job_yml/deepschema.yml — fix broken ../../../doc/... path.
  • tests/unit/review/test_instructions.py, tests/unit/review/test_config.py, tests/unit/deepschema/test_review_bridge.py — new tests.

🤖 Generated with Claude Code

nhorton and others added 3 commits April 8, 2026 19:37
…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>
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>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nhorton nhorton added this pull request to the merge queue Apr 9, 2026
Merged via the queue into main with commit 994fb70 Apr 9, 2026
5 checks passed
@nhorton nhorton deleted the feat/inline-reference-files branch April 9, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant