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: parse DeepSchema hook target files as YAML, not JSON
The deepschema_write PostToolUse hook used Path.suffix to decide between
yaml.safe_load and json.loads. For files like `.deepreview` whose entire
name is treated as a hidden-file marker, Path.suffix is "" — so the hook
fell through to json.loads and reported "File is not valid JSON" on every
write/edit, even though the file was a perfectly valid YAML .deepreview.
Fix: parse the target file (and the referenced JSON Schema file) with
yaml.safe_load unconditionally. YAML is a superset of JSON, so both
formats are accepted regardless of file extension. Mirrors the approach
PR #338 already shipped for the workflow quality gate
(jobs/mcp/quality_gate.py).
Also handle the SchemaError case that becomes possible once a parser
accepts free-form text: if the schema file parses to something that
isn't a JSON Schema object or boolean, return "Cannot read JSON Schema:
not a JSON Schema object" before invoking the validator.
Updates DW-REQ-011.7.3 to match. Adds a regression test for dot-prefixed
files (the user-reported case) and revises two existing tests that were
asserting on the old "File is not valid JSON" / "schema isn't JSON"
contracts.
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
@@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
24
24
25
25
### Fixed
26
26
27
+
- DeepSchema PostToolUse hook (`deepschema_write`) no longer reports `File is not valid JSON` for YAML files whose name has no extension (e.g. `.deepreview`). The hook now parses target files and the referenced JSON Schema as YAML, which is a superset of JSON, so both formats are accepted regardless of file extension. DW-REQ-011.7.3 updated to match. (Mirrors the fix shipped in #338 for the workflow quality gate.)
Copy file name to clipboardExpand all lines: specs/deepwork/DW-REQ-011-deepschema.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ The DeepSchema system provides rich, file-level schemas with automatic validatio
50
50
51
51
1. The write hook MUST fire on PostToolUse events for Write and Edit tools.
52
52
2. For each applicable schema, the hook MUST inject a conformance note: "Note: this file must conform to the DeepSchema at `<path>`".
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.
53
+
3. If `json_schema_path` is set, the hook MUST validate the written file against the JSON Schema. The file content MUST be parsed as YAML (which is a superset of JSON), so both YAML and JSON formats are accepted regardless of file extension.
54
54
4. If `verification_bash_command` is set, the hook MUST execute each command with the file path as `$1`, with a 30-second timeout.
55
55
5. Validation failures MUST be reported via `hookSpecificOutput.additionalContext` so the agent can act on them.
56
56
6. The hook MUST NOT use `systemMessage` for validation output — that route is user-visible only.
0 commit comments