feat: add Server Redirect CEP draft - #47
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Pulled the branch and went through the spec. Core design is solid, follows the same intercept-error-reissue pattern as CEP-8 which makes the SDK implementation straightforward. A few things that would be worth tightening before merge:
The spec says target is "the public key of the server" but doesn't specify the format. Hex, npub, nprofile? If nprofile is allowed it carries relay hints inline, which overlaps with the Relay fallback order when The spec covers the case where Redirect arriving during an in-flight CEP-8 payment Security considerations mention that the target becomes the payment processor on redirect. But what about the case where a redirect arrives after a Hop counter scope "At most 5 hops" but is this per original request or per session? If a client sends 10 different tool calls and each gets one redirect, that's 10 total hops but only 1 per request. I'd suggest clarifying as "at most 5 consecutive redirects for the same original request." Self-redirect A server redirecting to its own pubkey creates a trivial 1-hop loop. The hop cap catches it eventually but burns through retries. A "servers SHOULD NOT redirect to their own public key" would be a cheap guard. Unreachable target No guidance on what to do if the target is simply offline or can't be reached. Should the client surface the redirect as an error to the caller, or retry the original server? Probably the former to avoid silent fallback confusion. Minor: branch name is still |
Some additional findings+1 on all of Abhay's points. A few things not yet covered:
|
|
Thanks @abhayguptas and @1amKhush . Attached your feedback in my latest commit. Please share your thoughts |
|
All points addressed cleanly. The field table, Client behavior when server violates the CEP-41 MUST NOT Line 75 says the server MUST NOT emit a redirect for a request with an active open-ended stream. That's the right constraint. But the spec doesn't say what a client should do if a buggy server does it anyway. The client receives a Suggesting something like: "If a client receives a Everything else looks ready. |
…rationale - Client Behavior: define recovery when a server emits -32044 without first terminating an active CEP-41 stream (treat as failed, release state, follow redirect; stricter client MAY refuse). - Server Behavior: correct the MUST NOT rationale — the stream needs its terminal close/abort frame before the single final JSON-RPC response; a mid-stream redirect strands it, rather than a double-final collision.
CEP-47: Server Redirect
Summary
Adds a draft Standards Track CEP defining a request redirection mechanism for ContextVM. A server can instruct a client to re-issue a request to a different address (a public key, with optional relay hints) by returning a JSON-RPC error response (
-32044 "Redirect").Motivation
There is currently no way for a ContextVM server to hand a client a different address mid-exchange. This blocks two common patterns, both reducible to "use this address instead":
The reason for a redirect is a server-side concern; the protocol carries only the address hand-off and never represents intent on the wire. Full motivation, rationale, and security discussion live in the tracking issue.
What this PR contains
Per the CEP guidelines, this PR holds the specification-side document only:
src/content/docs/reference/ceps/cep-47.md— abstract, specification, security considerations, backward compatibility, dependencies, reference implementationastro.config.mjs— sidebar registrationThe tracking issue carries the comprehensive proposal (motivation, rationale, security implications); its Specification section should link back to this PR to keep the spec in a single place.
Design
-32044 "Redirect"in a kind-25910 response,e-tag correlated to the original request.error.data:target(required pubkey),relays(optional inline hints; absent ⇒ CEP-17 lookup),instructions(optional, agent-readable).method/params) totarget; caps redirect chains (≤5) to prevent loops; surfaces unknown codes as ordinary errors (safe degradation, not silent failure).targeton re-issue, so no state transfer is needed and redirect works at any point in an exchange.-32042payment-gating error, but is independent of it.Backward compatibility
Additive. No new event kind is introduced (redirects are normal kind-25910 responses); servers that do not redirect are unaffected; clients that do not recognize
-32044surface it as a normal error and are no worse off than with any other server refusal.Dependencies
relaysis absent)CEP-4 (channel security) and CEP-8 (error-pattern sibling) are referenced inline only, not listed as dependencies.