Repository navigation
test(cli): bind mutation contracts to output schemas (#1816) - #1986
Conversation
Problem: #1816 action contracts declared mutation and error machine envelopes, but the generated cli-output schema surface did not publish the shared MutationResultPayload/QueryErrorPayload models and the action-contract tests did not validate real mutation outputs against a schema. What changed: add generated schema entries for mutation-result and query-error, regenerate the cli-output schema index/artifacts, and extend action/schema tests so delete preview/aborted outputs validate against the published mutation schema. Verification: devtools test tests/unit/cli/test_cli_action_contracts.py tests/unit/cli/test_cli_output_schemas.py -> 36 passed; devtools render-cli-output-schemas --check -> sync OK; devtools verify --quick -> exit_code 0. Default devtools verify was attempted but this fresh worktree lacks the pytest-testmon seed. Ref #1816
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughTwo new CLI output JSON schemas ( ChangesCLI Output Schema Contracts
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b6dfa79419
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| surfaces=( | ||
| "GET /api/sessions?query=... (error path)", | ||
| "daemon query/read error responses", | ||
| "MCP query/read error responses", |
There was a problem hiding this comment.
Remove MCP from query-error schema surfaces
For MCP query/read failures, the code path I checked (server_tools.py calling hooks.error_json, implemented by _error_json) serializes MCPErrorPayload with fields like status, message, code, and is_error, not QueryErrorPayload's ok, error, detail, and field shape. Advertising this schema for MCP query/read error responses will make downstream validators reject actual MCP errors; limit this entry to the daemon HTTP shape or publish a separate MCP error schema.
Useful? React with 👍 / 👎.
Summary
Adds generated CLI output schemas for the shared mutation and query-error payloads, then binds #1816 action-contract mutation metadata to those schemas with executable tests.
Problem
#1816 introduced
CliActionContract.machine_envelope, and mutation actions (mark,delete,import) declare themutationenvelope. The generateddocs/schemas/cli-output/surface did not publishMutationResultPayload, and no action-contract test validated real destructive-action machine output against a generated schema. That left the mutation-envelope claim partially prose-only.Solution
Issue slice: contract-derived machine-output/schema drift checks for mutation/error envelopes.
Files inspected:
polylogue/cli/action_contracts.py,polylogue/surfaces/payloads.py,devtools/render_cli_output_schemas.py,tests/unit/cli/test_cli_action_contracts.py,tests/unit/cli/test_cli_output_schemas.py.Files changed:
devtools/render_cli_output_schemas.py, generateddocs/schemas/cli-output/*, and the two focused CLI schema/contract test files.Old surface removed or retained: retained the existing generated CLI-output schema surface; expanded it with
mutation-result.schema.jsonandquery-error.schema.jsonrather than adding a detached manifest.Contracts/tests added: mutation action contracts must now have a published
MutationResultPayloadschema, and delete's aborted/dry-run outputs validate against it. The schema suite also validates representativeMutationResultPayloadandQueryErrorPayloadinstances.Generated artifacts updated: regenerated
docs/schemas/cli-output/README.md,mutation-result.schema.json, andquery-error.schema.jsonwithdevtools render-cli-output-schemas.Known caveats / SPEC_MISMATCH: this does not finish all #1816 remaining work; read-view item schemas and completion/help generation remain separate coherent phases.
Follow-up intentionally not included: no command-floor expansion, no new proof/catalog layer, no release-gate closure.
Verification
devtools test tests/unit/cli/test_cli_action_contracts.py tests/unit/cli/test_cli_output_schemas.py-> 36 passed.devtools render-cli-output-schemas --check-> sync OK fordocs/schemas/cli-output.devtools verify --quick-> exit_code 0.devtools verify --quick-> exit_code 0.devtools verify; it stopped before tests because this fresh worktree has no pytest-testmon seed (.testmondata/.cache/testmon/seed.json).Ref #1816
Summary by CodeRabbit
Documentation
Tests