Skip to content

messages send + message-to: Phase 2 auto-verify with --no-verify opt-out#52

Merged
mikemolinet merged 1 commit into
mainfrom
feat/messages-no-verify-flag
May 11, 2026
Merged

messages send + message-to: Phase 2 auto-verify with --no-verify opt-out#52
mikemolinet merged 1 commit into
mainfrom
feat/messages-no-verify-flag

Conversation

@mikemolinet
Copy link
Copy Markdown
Collaborator

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-verify opt-out + pretty mismatch diagnostic.

Wire shape from Layer 1 substrate ship (cueapi/cueapi-core#86 + cueapi/cueapi#795, merged 22:55Z):

  • Request header: X-CueAPI-Verify-Echo: true
  • 201 response includes body_received: "<verbatim echo>" when header set

What

  • --no-verify flag on messages send + message-to. Default verify-on. When omitted, CLI sends the X-CueAPI-Verify-Echo header; on 201 response, diffs body_received against sent body.
  • Exit code 7 distinct from generic failure (1-5) so CI workflows can branch on body-verify-mismatch specifically.
  • Pretty diagnostic to stderr on mismatch: first 200 chars of sent vs received, byte position of first divergence, msg_id (mutated content stored server-side; recoverable), actionable mitigation hint.
  • Backward-compat: pre-Layer-1 substrate (no body_received field) → no-op + success.

Test plan

  • 5 new Phase 2 tests pin all invariants
  • 9 prior Phase 3 tests preserved
  • 45 prior existing messages tests preserved
  • 65 of 205 messaging-related tests pass

Defense-in-depth status

🤖 Generated with Claude Code

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>
@mikemolinet mikemolinet merged commit b45f822 into main May 11, 2026
3 of 4 checks passed
@mikemolinet mikemolinet deleted the feat/messages-no-verify-flag branch May 11, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant