Skip to content

docs(replay): say what replay re-checks for a revoked permit - #469

Open
PetrefiedThunder wants to merge 1 commit into
mainfrom
claude/replay-contract-revoked-permit
Open

PetrefiedThunder wants to merge 1 commit into
mainfrom
claude/replay-contract-revoked-permit

Conversation

@PetrefiedThunder

@PetrefiedThunder PetrefiedThunder commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Part 2 of #434. The replay contract in gateway/docs/failure-semantics.md said:

Replay access re-validates the permit↔wallet↔key binding first, so a revoked permit or a different key cannot read the stored receipt.

The revoked-permit half is false. validate_replay_access (gateway/app/services/permits.py) checks that the permit belongs to the wallet, the key binding and the signature. By design (its docstring) it does not check revocation, expiry or remaining budget. A call made before a revoke replays its stored result and receipt.

The sentence is replaced with the text proposed in #434:

Replay access first re-checks that the permit belongs to the wallet, its key binding and its signature. A key of another wallet cannot read the stored receipt, and neither can a second key on the same wallet when the permit is bound to a key. Revocation, expiry and the remaining budget are not re-checked, so a call made before the permit was revoked can still be replayed.

One test is added to pin the documented behavior, because #434 found no test that replays a completed call after revocation. test_governed_upstream_replay_after_revocation_returns_stored_receipt:

  • runs one successful governed upstream call;
  • revokes the permit;
  • sends the same request with the same key, which returns the stored result and the same receipt_id, with no new dispatch and no new charge;
  • sends a request with a new idempotency key, which is refused with permit_revoked.

The key-bound case is already covered by test_governed_upstream_replay_remains_bound_to_permit_api_key.

No product code changes.

Related issues

Refs #434. Part 1 is in #468, which is not merged, so this PR does not close the issue.

Area and license

  • I identified the repository area changed by this PR. (gateway docs and tests)
  • I understand that spec/, verifier/, sdk/python/, sdk/typescript/, integrations/, and examples/ are Apache-2.0.
  • I understand that gateway/ contributions are under FSL-1.1-ALv2 (Fair Source).
  • This PR does not include proprietary hosted-service code or secrets.

Spec changes

  • This PR does not change normative spec behavior. (gateway/docs/, not spec/)
  • If it changes normative spec behavior, I opened or linked an RFC issue.

Validation

  • Tests, run from gateway/ as CI runs them (Python 3.12, pytest 9.2.0):
    • pytest -q --ignore=tests/judge_e2e -m "not production_trust" -n auto --timeout 300: 6726 passed, 105 skipped, 1 xfailed.
    • TRUST_MODE_ENABLED=true ALLOW_LEGACY_UNPERMITTED_MCP=false ENABLE_PROOF_SURFACES=false pytest -q --ignore=tests/judge_e2e -m production_trust --timeout 300: 12 passed.
    • Every test file that reads failure-semantics.md, plus tests/test_mcp_upstream_governed.py: 215 passed.
  • Other checks: ruff 0.17.6 check and format --check clean on the touched test file.

Risk and compatibility

Documentation and one test only. Not tested: replay after expiry or after the budget is spent. The new text states those by reading validate_replay_access.

Contributor checklist

  • I added or updated tests for behavior changes, or explained why tests are not applicable.
  • I updated relevant documentation and examples.
  • Every commit in this PR is signed off under the Developer Certificate of Origin.
  • I agree to submit this contribution under the license applicable to the files I changed.

Generated by Claude Code


Note

Low Risk
Documentation-only correction plus a regression test; no runtime or auth logic changes in the diff.

Overview
Fixes the replay contract in failure-semantics.md, which previously claimed that a revoked permit could not read a stored receipt on replay. The doc now matches validate_replay_access: replay re-checks wallet ownership, key binding, and permit signature only; revocation, expiry, and remaining budget are not re-checked, so a successful call made before revoke can still replay the same result and receipt_id without a second dispatch or charge.

Adds test_governed_upstream_replay_after_revocation_returns_stored_receipt to lock that behavior: revoke after success → same idempotency key still replays; a new key after revoke gets permit_revoked and still does not redispatch.

No gateway product code changes in this PR.

Reviewed by Cursor Bugbot for commit f58d650. Bugbot is set up for automated code reviews on this repo. Configure here.

The replay contract in failure-semantics.md said replay access
re-validates the permit, wallet and key binding "so a revoked permit or a
different key cannot read the stored receipt". The revoked-permit half is
false: validate_replay_access checks the wallet, the key binding and the
signature, and by design not revocation, expiry or remaining budget. A
call made before a revoke replays its stored result and receipt.

Replace the sentence with the text proposed in issue #434 part 2, and add
a test that pins it: after a successful governed upstream call and a
revoke, the same request with the same key returns the stored result and
the same receipt_id with no new dispatch or charge, and a new idempotency
key is refused with permit_revoked.

Refs #434

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GyhDYGi5fpiBGFHez9fhbH
Signed-off-by: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agent-middleware-web Ready Ready Preview Dec 5, 2026 10:58am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ae2e721 and f58d650.

Files selected for processing: 2

  • gateway/docs/failure-semantics.md
  • gateway/tests/test_mcp_upstream_governed.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Copy link
Copy Markdown
Collaborator Author

PR Guards / Engine Review Pass is red at f58d650 because no reviewer engine other than the author has posted a review on this head yet. It needs a review, not a code change. The other checks are running.


Generated by Claude Code

@PetrefiedThunder
PetrefiedThunder marked this pull request as ready for review December 5, 2026 11:43
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-05T11:44:41.186470Z f58d650 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Collaborator Author

READY FOR QA f58d650

This is a readiness marker, not a QA verdict. I post no verdict.

Head: f58d6508c1488997e27c6a4aed4e058ed36c5252, one commit on main ae2e721: "docs(replay): say what replay re-checks for a revoked permit", by the session that opened this PR, at the maintainer's request. This head is 0 commits behind main.

What it changes: part 2 of #434. The patch has 2 files:

No product code changes. The new test pins behavior that is already on main; it is not a regression test for a code fix.

CI on this head: as read at 11:46 UTC on 2026-12-05, 34 check runs are complete: 26 success, 4 skipped, 1 neutral, 3 failure. CI result, License result and gitleaks are success. The neutral run is CodeRabbit (rate limited). The 3 failures are all runs of Engine Review Pass, which waits for a review from a non-author engine on this head.

Local check on this head, Python 3.12, SQLite:

  • Full leg (-m "not production_trust", -n auto): 6726 passed, 105 skipped, 1 xfailed, 0 failed. Production-trust leg: 12 passed.
  • Every test file that reads failure-semantics.md, plus tests/test_mcp_upstream_governed.py: 215 passed.
  • ruff 0.17.6 check and format pass on the touched test file.
  • Not run locally: PostgreSQL and the other Python versions. CI ran them on this head and they are success.

Bots and reviews: Cursor Bugbot and the copilot check are success on this head. CodeRabbit has not reviewed (rate limited). No reviews and no review threads.

Not tested: replay after expiry or after the budget is spent. The new text states those cases by reading validate_replay_access.

Related: this PR says Refs #434. Part 1 is #468, not merged, so neither PR closes the issue alone.

I merge nothing.


Generated by Claude Code

This branch was successfully deployed

1 active deployment
Preview — f58d6508 Deployed Dec 5, 2026 by vercel[bot]
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.

3 participants