feat(cli): explicit validation modes --mode basic|strict|release (#52) - #60
Merged
Merged
Conversation
loop doctor/validate/verify gain --mode: basic forces the structural fallback deterministically; strict/release require jsonschema and fail loud (ValidationModeError -> exit 2, stderr, no traceback) instead of silently downgrading; release == strict today (reserved, tripwire-tested). Reports gain requested_mode (auto|basic|strict|release) alongside the unchanged validation_mode key; VALIDATION_MODES re-exported; CI Quickstart smoke runs --mode release. 16 new tests honest in both env shapes (extras 544/14, pyyaml-only 526/32, zero regressions). Closes #52 Claude-Session: https://claude.ai/code/session_01EJ8zA8Cbi4o2amawpj8bZW
There was a problem hiding this comment.
Pull request overview
This PR makes contract validation strength explicit and deterministic for the CLI “doctor-family” commands by adding --mode basic|strict|release, while keeping the default behavior (auto) unchanged for backward compatibility. It also adds reporting that distinguishes the caller-requested mode from the internally selected validation branch.
Changes:
- Add public validation modes (
basic|strict|release) with “fail loud” behavior forstrict/releasewhenjsonschemais unavailable, plusrequested_modein validation reports. - Extend the CLI (
doctor|validate|verify) to parse--mode, return exit code 2 on mode/availability errors, and avoid tracebacks for these user-facing failures. - Update CI quickstart smoke to run
doctor --mode releaseand add tests that pin the CLI/API behavior and CI wiring.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/test_loop_contract_core.py | Adds API-level tests for VALIDATION_MODES, requested_mode, and strict/release behavior. |
| scripts/test_loop_cli.py | Adds end-to-end CLI subprocess tests for --mode behavior, exit codes, and stderr/stdout shaping. |
| scripts/test_ci_release_mode.py | Adds a CI workflow “wiring contract” test to pin release-mode usage in the smoke step. |
| README.md | Documents the new requested_mode report field and the --mode semantics. |
| loop/contract.py | Implements mode resolution, introduces ValidationModeError, threads mode through validate_contract/doctor_report, and reports requested_mode. |
| loop/main.py | Parses --mode for doctor/validate/verify, maps mode errors to exit 2, updates help text. |
| loop/init.py | Re-exports VALIDATION_MODES from the package root. |
| .github/workflows/ci.yml | Updates the Quickstart smoke test to run doctor --mode release. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Closes #52. Slice S2 of the Phase 0/1 roadmap run (SPEC criterion 3).
What
loop doctor|validate|verify --mode basic|strict|release(default = unchanged auto-detect;basic= the structural fallback made explicit and deterministic even when jsonschema is installed).strict/releaserequire real JSON-Schema validation and fail loud — newValidationModeError(RuntimeError subclass), CLI exit 2, stderr names jsonschema and the--mode basicescape hatch, no traceback — instead of silently downgrading.release≡stricttoday with reserved semantics, pinned by a tripwire test so future divergence is a conscious diff.requested_mode(auto|basic|strict|release) alongside the untouched internalvalidation_modekey;VALIDATION_MODESre-exported from the package root (ValidationModeErrordeliberately not, per the EmitError precedent).doctor --mode release; newscripts/test_ci_release_mode.pypins the wiring.Evidence (governed Claudex lane: gpt-5.6-terra worker, deterministic argv gates outside the worker, fresh claude-sonnet-5 review, Fable governance)
Test plan
https://claude.ai/code/session_01EJ8zA8Cbi4o2amawpj8bZW