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
fix: handle YAML files in quality gate json_schema validation (#338)
* fix: handle YAML files in quality gate json_schema validation
validate_json_schemas() used json.loads() unconditionally, failing on
.yml/.yaml files. Now checks file extension and uses yaml.safe_load()
for YAML files, matching the approach already used in deepschema_write.py.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: handle YAML files in quality gate json_schema validation
- Update JOBS-REQ-004.2.2 spec to cover YAML parsing based on file extension
- Update JOBS-REQ-004.2.3 spec wording (JSON parsing -> file parsing)
- Add traceability comments to new YAML tests
- Fix incorrect traceability ref: JOBS-REQ-001.4.8 -> JOBS-REQ-004.2.6
- Update doc/job_yml_guidance.md to reflect YAML support
- Add changelog entry
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: use yaml.safe_load unconditionally since YAML is a JSON superset
Simplifies the implementation — no need to branch on file extension.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: update changelog entry to reflect unconditional yaml.safe_load approach
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: move yaml import to top-level and narrow exception handling
- Move `import yaml` from loop body to module-level (PyYAML is a runtime dep)
- Narrow `except Exception` to `(yaml.YAMLError, UnicodeDecodeError)`
- Fix doc wording: remove stale "based on file extension" references
- Fix extra blank line flagged by ruff
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: restore required blank line before top-level comment block
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: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
26
26
27
27
### Fixed
28
28
29
+
- Quality gate `validate_json_schemas()` now uses `yaml.safe_load` (a JSON superset) instead of `json.loads`, so YAML output files are validated correctly
Copy file name to clipboardExpand all lines: doc/job_yml_guidance.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -64,7 +64,7 @@ You define quality criteria once, and they apply everywhere. If three workflows
64
64
65
65
### `json_schema`
66
66
67
-
Only applies to `file_path` arguments. When set, the framework parses each output file as JSON and validates it against the schema **before any reviews run**. If validation fails, `finished_step` returns the error immediately -- reviews are skipped entirely. This is a hard gate, not a soft review. Use for structured outputs where format correctness is non-negotiable.
67
+
Only applies to `file_path` arguments. When set, the framework parses each output file (JSON or YAML -- both are supported since YAML is a JSON superset) and validates it against the schema **before any reviews run**. If validation fails, `finished_step` returns the error immediately -- reviews are skipped entirely. This is a hard gate, not a soft review. Use for structured outputs where format correctness is non-negotiable.
68
68
69
69
---
70
70
@@ -152,7 +152,7 @@ A map of step_argument names to output configuration. When the agent calls `fini
152
152
153
153
1. **Completeness**: All required outputs must be present. No unknown output names allowed.
154
154
2. **Type validation**: `file_path`values must point to existing files. `string` values must be strings.
155
-
3. **JSON schema**: If the step_argument has `json_schema`, file contents are parsed and validated. Failures are returned immediately; reviews are skipped.
155
+
3. **JSON schema**: If the step_argument has `json_schema`, file contents are parsed (JSON or YAML) and validated. Failures are returned immediately; reviews are skipped.
156
156
4. **Quality reviews**: Dynamic reviews from the output ref and step_argument, plus .deepreview rules.
157
157
158
158
**Important**: The agent must provide ALL required outputs on every `finished_step` call, even outputs whose files have not changed since a previous attempt. The framework re-validates everything each time.
Copy file name to clipboardExpand all lines: specs/deepwork/jobs/JOBS-REQ-004-quality-review-system.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,8 +15,8 @@ The quality review system evaluates step outputs against defined quality criteri
15
15
### JOBS-REQ-004.2: JSON Schema Validation
16
16
17
17
1.`validate_json_schemas()` MUST check all `file_path` type outputs that have a `json_schema` defined on their `StepArgument`.
18
-
2. For each such output, the file content MUST be parsed as JSON and validated against the schema.
19
-
3. If JSON parsing fails, the error MUST be included in the returned error list.
18
+
2. For each such output, the file content MUST be parsed as YAML (which is a superset of JSON) and validated against the schema.
19
+
3. If file parsing fails, the error MUST be included in the returned error list.
20
20
4. If schema validation fails, the error MUST be included in the returned error list.
21
21
5. Files that do not exist MUST be skipped (not treated as errors by this function).
22
22
6.`run_quality_gate()` MUST run JSON schema validation before building review rules. If schema errors exist, it MUST return an error message listing them without proceeding to reviews.
0 commit comments