messages send + message-to: Phase 2 auto-verify with --no-verify opt-out#52
Merged
Conversation
Mike body-verify directive 2026-05-11 — Phase 2 SDK auto-verify layer for cueapi-cli. Sibling to cueapi-python PR #39 (auto_verify default- on at the resource layer). Wire shape locked via cueapi/cueapi-core PR #86 + cueapi/cueapi PR #795 (Layer 1 substrate echo-back, merged 22:55Z). Changes: cueapi/cli.py: - _first_divergence_byte(a, b) — pure helper returning byte index of first differing position; -1 when one is a proper prefix of the other. - _emit_body_verify_mismatch_diagnostic — pretty-prints sent vs received diff (first 200 chars each side) + byte position + msg_id + actionable mitigation hint. All to stderr. - messages_send + message_to: new --no-verify flag (default verify-on). Sends X-CueAPI-Verify-Echo: true header; on 201 response, diffs m["body_received"] against sent body; on mismatch emits diagnostic + ctx.exit(7) (distinct from generic failure exit codes 1-5). - Backward-compat: when substrate omits body_received field (pre- Layer-1 deploy), no-op + return normally. tests/test_cli.py: - 5 new Phase 2 tests pin: default-on header, --no-verify omits header, byte-identical echo passes, mismatched echo exits 7 with MISMATCH in output, no-op when substrate omits echo field. - Plus 9 prior Phase 3 tests preserved. - Plus 45 prior existing tests preserved. - 205 tests in suite; 65 messaging-related; all pass. Exit code 7 distinct from generic 1-5 so callers can branch on verify-mismatch specifically (CI workflows can retry with --message-file). CHANGELOG entry under [Unreleased]. Co-Authored-By: Claude Opus 4.7 (1M context) <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
Phase 2 of body-verify defense-in-depth (Mike directive 2026-05-11). Sibling to cueapi-python's auto_verify default-on at the SDK resource layer; this PR adds CLI-layer wiring with
--no-verifyopt-out + pretty mismatch diagnostic.Wire shape from Layer 1 substrate ship (cueapi/cueapi-core#86 + cueapi/cueapi#795, merged 22:55Z):
X-CueAPI-Verify-Echo: truebody_received: "<verbatim echo>"when header setWhat
--no-verifyflag onmessages send+message-to. Default verify-on. When omitted, CLI sends the X-CueAPI-Verify-Echo header; on 201 response, diffsbody_receivedagainst sent body.body_receivedfield) → no-op + success.Test plan
Defense-in-depth status
🤖 Generated with Claude Code