Skip to content

feat(parity): BodyVerify Layer 1 — X-CueAPI-Verify-Echo echo-back substrate primitive#86

Merged
mikemolinet merged 1 commit into
mainfrom
feat/bodyverify-echo-back
May 11, 2026
Merged

feat(parity): BodyVerify Layer 1 — X-CueAPI-Verify-Echo echo-back substrate primitive#86
mikemolinet merged 1 commit into
mainfrom
feat/bodyverify-echo-back

Conversation

@mikemolinet
Copy link
Copy Markdown
Collaborator

Summary

Parity port of cueapi/cueapi#795 — substrate echo-back primitive (BodyVerify Layer 1). Opt-in via X-CueAPI-Verify-Echo: true request header on POST /v1/messages and POST /v1/cues/{cue_id}/fire. Server returns `body_received` + `body_received_sha256` so callers can diff sent vs received bytes and detect caller-side shell expansion (backticks, $-paren, ${VAR}) that silently mutates body content at variable-assignment time.

Design doc: https://trydock.ai/workspaces/cue-message-silent-corruption-substrate-design-2026-05-11

Direction of parity

Private-leads → OSS-lags. cueapi/cueapi#795 merged first; this port follows within ~30min.

OSS-specific adaptations

  • `app/utils/verify_echo.py` ported verbatim from private.
  • `app/routers/messages.py` — `send_message` handler extended; 3-element `create_message` tuple unpack preserved (private has 4-element with `bcc_emitted`).
  • `app/routers/cues.py` — `fire_cue` handler extended; `Request` param added.
  • `tests/test_verify_echo.py` — adapted: fire-path metachar-class parametrization removed because OSS `FireRequest` carries only `send_at` (datetime). Hosted's `payload_override` (dict with user-supplied strings) is the corruption vector and lives in cueapi/cueapi exclusively. The substrate-helper behavior is fully exercised via messages-endpoint tests (6 metachar classes).

Net test count: 27 in OSS (vs 33 in private).

Parity-manifest updates

  • New entry: `app/utils/verify_echo.py` (private-counterpart same path)
  • Updated deviation note: `app/routers/messages.py` (BodyVerify port; tuple-arity divergence noted)
  • Updated deviation note: `app/routers/cues.py` (BodyVerify port; FireRequest field divergence noted; metachar parametrization private-only)

Test plan

  • Local: 27/27 OSS tests pass
  • CI: green on cueapi-core
  • parity-check action: no warnings (manifest updated)

🤖 Generated with Claude Code

Parity port of cueapi/cueapi PR #795. Adds the X-CueAPI-Verify-Echo
opt-in echo-back primitive on POST /v1/messages and
POST /v1/cues/{cue_id}/fire so callers can diff sent vs received body
bytes and catch caller-side shell expansion that silently mutates body
content at variable-assignment time.

Design doc:
https://trydock.ai/workspaces/cue-message-silent-corruption-substrate-design-2026-05-11

Files added:
- app/utils/verify_echo.py (verbatim port from private)
- tests/test_verify_echo.py (adapted: fire metachar parametrization is
  private-only since OSS FireRequest carries only send_at; hosted's
  payload_override is the corruption vector and lives in private)

Files modified:
- app/routers/messages.py — send_message integrates apply_verify_echo
- app/routers/cues.py — fire_cue takes Request param + integrates helper

Parity-manifest updates:
- New entry: app/utils/verify_echo.py
- Updated: app/routers/messages.py + app/routers/cues.py deviation notes
- Documents the OSS / private fire-test divergence in a single place

27/27 OSS tests pass locally (private had 33; 6 fire-metachar tests
deferred per FireRequest shape divergence).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Parity check

This PR modifies files tracked in parity-manifest.json:

  • app/routers/cues.py
  • app/routers/messages.py
  • app/utils/verify_echo.py

Please confirm one of the following in a reply or PR description update:

  1. The equivalent change has been applied to the private cueapi monorepo. Link the PR.
  2. This change is OSS-only and does not need porting. Briefly explain why (e.g. "fixes a bug that only exists in the OSS build").
  3. A follow-up issue has been filed to port the reverse direction. Link the issue.

This is a soft check — it does not block merge. The goal is visibility, not friction. See HOSTED_ONLY.md for the open-core policy.

@govindkavaturi-art govindkavaturi-art enabled auto-merge (squash) May 11, 2026 22:53
@mikemolinet mikemolinet merged commit f60c25a into main May 11, 2026
6 checks passed
@mikemolinet mikemolinet deleted the feat/bodyverify-echo-back branch May 11, 2026 22:55
mikemolinet added a commit that referenced this pull request May 12, 2026
Private cueapi #801 added docs/guides/body-verify.mdx (Mintlify, 247
lines) documenting the X-CueAPI-Verify-Echo primitive for hosted users.
cueapi-core ships the SAME substrate (Layer 1 from #86 + Layer 1.5
universal middleware from #87 + STRING-shape spec-lock from #88) but
had no user-facing guide. Self-hosters running cueapi-core need this.

## Scope

cueapi-core-flavored adaptation — plain MD (not MDX), substrate-focused
(narrower than the hosted MDX guide which covers SDK install + hosted-
specific patterns). Sections:

1. The bug class — caller-side shell expansion ($(...), `...`, ${VAR})
2. How it works — X-CueAPI-Verify-Echo header + response shape
3. Substrate architecture — Layer 1 (endpoint-specific STRING shape on
   /v1/messages + /v1/cues/{id}/fire) vs Layer 1.5 (universal middleware
   on all other POST/PATCH/PUT endpoints, OBJECT shape)
4. SDK auto-verify summary table (python / cli / mcp / action), with
   the messages-default-on vs fire-opt-in distinction explicit
5. Defense-in-depth layers — substrate + SDK + force-file + docs
6. When to disable + opt-out semantics
7. Implementation file references (app/utils/verify_echo.py,
   app/middleware/verify_echo.py, app/routers/{messages,cues}.py)
8. Background — Mike directive 2026-05-11; cross-stack ship history

## Out of scope

- Per-language SDK install / API-key bootstrap content — already in
  each SDK's own README. This guide links rather than duplicates.
- The hosted-specific Mintlify mint.json registration — cueapi-core
  uses plain MD; doc discovery via the docs/ dir, not Mintlify.

## Build / lint

- Plain Markdown; no build step required. (Other docs in this dir
  follow the same convention — see quickstart.md, configuration.md.)
mikemolinet added a commit that referenced this pull request May 12, 2026
…90)

Private cueapi #801 added docs/guides/body-verify.mdx (Mintlify, 247
lines) documenting the X-CueAPI-Verify-Echo primitive for hosted users.
cueapi-core ships the SAME substrate (Layer 1 from #86 + Layer 1.5
universal middleware from #87 + STRING-shape spec-lock from #88) but
had no user-facing guide. Self-hosters running cueapi-core need this.

## Scope

cueapi-core-flavored adaptation — plain MD (not MDX), substrate-focused
(narrower than the hosted MDX guide which covers SDK install + hosted-
specific patterns). Sections:

1. The bug class — caller-side shell expansion ($(...), `...`, ${VAR})
2. How it works — X-CueAPI-Verify-Echo header + response shape
3. Substrate architecture — Layer 1 (endpoint-specific STRING shape on
   /v1/messages + /v1/cues/{id}/fire) vs Layer 1.5 (universal middleware
   on all other POST/PATCH/PUT endpoints, OBJECT shape)
4. SDK auto-verify summary table (python / cli / mcp / action), with
   the messages-default-on vs fire-opt-in distinction explicit
5. Defense-in-depth layers — substrate + SDK + force-file + docs
6. When to disable + opt-out semantics
7. Implementation file references (app/utils/verify_echo.py,
   app/middleware/verify_echo.py, app/routers/{messages,cues}.py)
8. Background — Mike directive 2026-05-11; cross-stack ship history

## Out of scope

- Per-language SDK install / API-key bootstrap content — already in
  each SDK's own README. This guide links rather than duplicates.
- The hosted-specific Mintlify mint.json registration — cueapi-core
  uses plain MD; doc discovery via the docs/ dir, not Mintlify.

## Build / lint

- Plain Markdown; no build step required. (Other docs in this dir
  follow the same convention — see quickstart.md, configuration.md.)
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