Skip to content

feat: per-call response verification at the proxy (v0.2.0) - #15

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

feat: per-call response verification at the proxy (v0.2.0)#15
Mhemd139 merged 2 commits into
mainfrom
spec/per-call-verification

Conversation

@Mhemd139

Copy link
Copy Markdown
Owner

The implementation commit that PR #13 was merged without - the merge landed while the branch history was being cleaned up, so main received the spec docs only. This PR carries the single squashed implementation commit; the spec file is identical on both sides, so the diff is code + tests only.

What

Every tools/call response the proxy forwards is verified against a per-tool reference: declared outputSchema, else the core fingerprint (intersection of baselined probe fingerprints), else counted unverified. Output-side BREAKING classes (missing field, structural retype, forbidden null, pinned value mismatch) block the response and response-quarantine the tool; scalar retypes record DEGRADED and forward; extra fields pass.

  • covenant/verify.py - pure verifier (Layer 0)
  • two-bucket quarantine: sync() owns schema only; POST /covenant/refresh clears the response bucket; /covenant/status shows sources
  • SSE interception: only the matching result frame is held (one frame''s latency); notifications stream through; 1 MiB cap; GET listen stream untouched
  • verifier exceptions forward original bytes - inspection failure never drops traffic
  • covenant proxy --observe for monitor-only rollout
  • snapshot embeds expect pins into the lock; lock re-snapshotted (diff is exactly the pin)
  • new metric covenant_response_verifications_total{tool, outcome}
  • COVENANT_SHEKEL_DRIFT demo lever: currency swap the pin catches per-call

Tests

37 new tests; full suite, ruff, and strict mypy green.

🤖 Generated with Claude Code

Mhemd139 and others added 2 commits July 26, 2026 01:23
….2.0)

The proxy verifies every tools/call response it forwards, not just schemas at
list time. Reference hierarchy: declared outputSchema -> core fingerprint
(intersection of baselined probe fingerprints) -> unverifiable, counted.
Only output-side BREAKING classes block; --observe is the rollout escape
hatch; two-bucket quarantine survives the in-band tools/list sync; SSE frame
interception holds only the matching result frame; 1 MiB verify cap;
verifier exceptions forward original bytes.

Includes the clarifications from CodeRabbit review: additionalProperties
deliberately not enforced, response bucket in-memory only, a stream ending
without the matching frame counts unverified, the cap bounds verification
cost not proxy buffering.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Every forwarded tools/call response is verified against a per-tool reference:
declared outputSchema, else the core fingerprint (intersection of baselined
probe fingerprints). Output-side BREAKING classes (missing field, structural
retype, forbidden null, pinned value mismatch) block the response and
response-quarantine the tool; scalar retypes record DEGRADED and forward.

- covenant/verify.py: pure verifier (Layer 0) - references, tiers, pins
- quarantine: two buckets; sync() owns schema only, refresh clears response
- proxy: JSON + SSE interception (only the matching result frame is held),
  1 MiB verify cap, verifier exceptions forward original bytes
- metrics: covenant_response_verifications_total{tool, outcome}
- cli: covenant proxy --observe; snapshot embeds expect pins into the lock
- examples: COVENANT_SHEKEL_DRIFT lever; lock re-snapshotted with the pin

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

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 5 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: 254c136f-082d-4b7a-b414-11f740c9e694

📥 Commits

Reviewing files that changed from the base of the PR and between caaae1e and 4bfd294.

📒 Files selected for processing (14)
  • covenant.lock.json
  • covenant/cli.py
  • covenant/proxy/metrics.py
  • covenant/proxy/quarantine.py
  • covenant/proxy/server.py
  • covenant/verify.py
  • docs/specs/2026-07-26-covenant-per-call-response-verification-design.md
  • examples/mcp_server.py
  • tests/test_metrics.py
  • tests/test_proxy.py
  • tests/test_proxy_store.py
  • tests/test_proxy_verify.py
  • tests/test_quarantine.py
  • tests/test_verify.py
✨ 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.

@Mhemd139
Mhemd139 merged commit b4e9969 into main Jul 25, 2026
5 checks passed
@Mhemd139
Mhemd139 deleted the spec/per-call-verification branch July 25, 2026 22:37
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