Skip to content

docs: spec for per-call response verification (v0.2.0 design) - #13

Merged
Mhemd139 merged 2 commits into
mainfrom
spec/per-call-verification
Jul 25, 2026
Merged

docs: spec for per-call response verification (v0.2.0 design)#13
Mhemd139 merged 2 commits into
mainfrom
spec/per-call-verification

Conversation

@Mhemd139

@Mhemd139 Mhemd139 commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Design spec for the roadmap item from the launch post: the proxy verifies every tools/call response it forwards, not just schemas at list time.

Key decisions locked in the spec:

  • Reference hierarchy: declared outputSchema → intersection of the tool's probe fingerprints (core shape; variance across probed args can't false-positive) → unverifiable (counted, not hidden)
  • Same severity model: only output-side BREAKING classes block (field missing, structural retype, forbidden null, pinned value mismatch); scalar retypes record DEGRADED and forward; extra fields pass
  • The first lie is blocked, not waved through — deterministic evidence, and --observe is the rollout escape hatch (WAF monitor/prevention pattern)
  • Two-bucket quarantine: response-caught liars must survive the tools/list in-band sync that runs on every client connect; POST /covenant/refresh is the release valve
  • SSE frame interception for POST tools/call only — without it the feature covers ~nothing on default FastMCP; GET listen streams stay untouched
  • 1 MiB verify cap, verifier exceptions forward original bytes: the firewall never drops traffic because its own inspection broke
  • Pure verifier in covenant/verify.py, no new dependencies, one new CLI flag, targets v0.2.0

Spec-only PR — implementation follows after review.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added a design specification for per-call response verification at the proxy.
    • Documented verification outcomes, enforcement and observation behavior, quarantine handling, failure policies, and metrics.
    • Defined SSE interception rules, including matching call responses and handling oversized frames.
    • Included demonstration guidance and clarified the scope of the proposed design.

The roadmap item from the launch post: verify every tools/call response
against a per-tool reference (outputSchema, else the intersection of
baselined probe fingerprints, else unverifiable), block deterministic
BREAKING-class violations, quarantine in a new response bucket that
in-band tools/list syncs cannot release, and intercept SSE frames so
the default FastMCP transport is actually covered. Enforce by default,
--observe for rollout. Targets v0.2.0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Mhemd139, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 16 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 525d4bc4-2fb8-4e2c-82ef-dde902d0f5ff

📥 Commits

Reviewing files that changed from the base of the PR and between 5dc7bfc and ba648de.

📒 Files selected for processing (1)
  • docs/specs/2026-07-26-covenant-per-call-response-verification-design.md
📝 Walkthrough

Walkthrough

Adds a design specification for per-call Covenant response verification at the proxy, covering reference selection, verification outcomes, quarantine behavior, SSE interception, failure handling, metrics, implementation placement, and out-of-scope boundaries.

Changes

Covenant verification design

Layer / File(s) Summary
Per-call verification specification
docs/specs/2026-07-26-covenant-per-call-response-verification-design.md
Defines per-tool reference selection, response classification, enforcement and observation behavior, quarantine buckets, SSE JSON-RPC matching, 1 MiB limits, failure handling, metrics, and implementation boundaries.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main change: a design spec for per-call response verification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch spec/per-call-verification

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/specs/2026-07-26-covenant-per-call-response-verification-design.md`:
- Around line 83-86: Update the plain-JSON response design to enforce
_VERIFY_MAX_BYTES without reading the entire body via up_resp.aread(). Specify a
bounded passthrough behavior for oversized JSON responses—streaming the
remainder unverified or an equivalent bounded strategy—and define precisely when
skipped_large is incremented, while preserving verification for responses within
the cap.
- Around line 22-42: Clarify the output verification policy around the
`outputSchema` rule and the “Extra fields” violation class: explicitly state
whether additive fields are allowed to override `additionalProperties: false`,
including for nested objects, or whether the schema remains authoritative.
Ensure the chosen policy is applied consistently wherever schema validation and
extra-field classification are described.
- Around line 58-69: Define separate persistence and restoration APIs for the
schema and response quarantine buckets, including source labels in status
output; ensure response quarantines are saved and restored independently of
Quarantine.sync(). Add an explicit response-bucket clear operation and update
POST /covenant/refresh to invoke it, while preserving sync() as schema-bucket
replacement only.
- Around line 77-85: Update the per-call response verification design to
explicitly define the outcome when the SSE stream closes, is cancelled, or
contains no frame matching the request JSON-RPC id. Assign the resulting
verification counter classification and state whether this outcome contributes
to response-bucket quarantine, keeping the behavior consistent across all
no-match termination paths.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 31a958ae-1cd0-46c2-8ccb-c13a110fb284

📥 Commits

Reviewing files that changed from the base of the PR and between c10538f and 5dc7bfc.

📒 Files selected for processing (1)
  • docs/specs/2026-07-26-covenant-per-call-response-verification-design.md

Comment thread docs/specs/2026-07-26-covenant-per-call-response-verification-design.md Outdated
Comment on lines +83 to +86
- Per-frame buffer cap: **1 MiB** (`_VERIFY_MAX_BYTES`, module constant, tunable). Over
the cap, the remainder of the stream forwards unverified and `skipped_large` is
counted — a bounded verifier, never an unbounded buffer. The same cap applies to
plain-JSON bodies.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift

Make the 1 MiB cap enforceable for plain JSON.

The current plain-JSON proxy path reads the entire upstream body with up_resp.aread() before returning it. This design only explains bounded streaming for SSE, so an implementation that retains the existing JSON path can still buffer arbitrarily large responses. Specify whether oversized JSON responses are streamed unverified or handled through another bounded passthrough strategy, and when skipped_large is recorded.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/specs/2026-07-26-covenant-per-call-response-verification-design.md`
around lines 83 - 86, Update the plain-JSON response design to enforce
_VERIFY_MAX_BYTES without reading the entire body via up_resp.aread(). Specify a
bounded passthrough behavior for oversized JSON responses—streaming the
remainder unverified or an equivalent bounded strategy—and define precisely when
skipped_large is incremented, while preserving verification for responses within
the cap.

additionalProperties deliberately not enforced (classifier parity); two-bucket
lifecycle vs sync()/persistence made explicit (response bucket in-memory only);
SSE stream ending without the matching frame counts unverified; the 1 MiB cap
bounds verification cost, not proxy buffering (JSON path already buffers today).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Mhemd139
Mhemd139 merged commit caaae1e into main Jul 25, 2026
5 checks passed
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