test: cross-validate scenario.schema.json with the Python validator#128
Merged
Conversation
Add tests/test_scenario_schema_sync.py with 45 tests that enforce three contracts between the JSON Schema and the Python validator: 1. Every bundled scenario (20 files) validates against both. 2. Generic structural errors (missing required fields, bad enum values, empty assertions, etc.) are rejected by both — 16 cases. 3. Documented asymmetries are pinned, not silent: 7 assertion-specific conditional cases (memory_isolation markers, goal_integrity expected_goal, allowed_tools/denied_tools shapes) where Python is stricter than the schema, and 2 structural cases (extra top-level fields, target without adapter) where the schema is stricter than Python. Per the issue's "decide and document" requirement: schema stays intentionally permissive about assertion-specific conditional rules because JSON Schema can't express them cheaply. Python is the source of truth at runtime. The schema does as much structural enforcement as JSON Schema does well: required fields, enums, top-level additionalProperties: false, required target.adapter. Document the decision in docs/scenario-spec.md under a new "Validation: schema vs Python validator" section that names every documented asymmetry, so future contributors changing either side know what they're allowed to break. Closes #88
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds `tests/test_scenario_schema_sync.py` with 45 tests that enforce three contracts between `schemas/scenario.schema.json` and `src/agent_harness/scenario.py::validate_scenario_data`:
Decision (per issue #88's "decide and document" requirement)
The schema stays intentionally permissive about assertion-specific conditional rules. JSON Schema can express "if/then" conditional shapes, but only verbosely, and every new assertion type would require a schema edit. Python is the source of truth for those rules at runtime. The schema does what JSON Schema does well: required fields, enums, top-level `additionalProperties: false`, required `target.adapter`.
Documented in `docs/scenario-spec.md` under a new "Validation: schema vs Python validator" section that names every asymmetry, so future contributors know what they're allowed to break on each side.
Test plan
Closes #88