feat(inspection): stage 2 response schema validation - #131
Merged
Conversation
Implements output_schema validation in the inspection pipeline. Supports three per-entry modes — redact (default), strict, and log — driven by schema_validation_mode on CatalogEntry. Redact mode strips surplus fields and propagates modified_response to the caller; strict denies; log passes through with audit metadata. Non-JSON responses and entries without output_schema skip the stage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
_stage2_schema_validation()ininspection/pipeline.py— validates JSON responses againstoutput_schemain the catalog entryschema_validation_mode: Literal["redact", "strict", "log"](default"redact") toCatalogEntryincatalog/loader.pyInspectionPipeline.run(): redact mode modifiesresponse_bytesfor downstream stages and setsInspectionResult.modified_responsejsonschema(already a dependency vialoader.py); surplus check is top-level only per specCloses #74
Test plan
test_skip_when_no_output_schema— no schema → stage skipstest_non_json_response_allows— non-JSON bytes pass throughtest_valid_response_allows— conforming payload → allow, no modificationtest_redact_mode_strips_surplus_fields— surplus fields removed,stripped_fieldspopulatedtest_pipeline_redact_mode_sets_modified_response—InspectionResult.modified_responseis non-Nonetest_strict_mode_denies_on_surplus— deny withRESPONSE_SCHEMA_VIOLATION_STRICTtest_log_mode_allows_with_surplus_logged— allow, bytes unchanged,stripped_fieldsset🤖 Generated with Claude Code