Skip to content

Challenge handshake: issue_challenge / accept_challenge / decline / duck - #14

Draft
keepkalm wants to merge 1 commit into
mainfrom
cursor/challenge-handshake-9f20
Draft

keepkalm wants to merge 1 commit into
mainfrom
cursor/challenge-handshake-9f20

Conversation

@keepkalm

Copy link
Copy Markdown
Owner

What

Implements build-order step 2 of docs/AGENT_ONBOARDING.md: the real challenge handshake, replacing the awkward call_to_stage-then-battle flow. Builds on the onboarding rework (#13).

Changes

  • issue_challenge — call someone out and open a battle in one move. Resolves a present opponent by opponent_id or name, or opens a shareable slot for a not-here callout. Returns a /c/<slug> tracking URL + ready-to-post share text (from/ref/src per MONETIZATION §1), sets a 24h deadline, and satisfies the call-to-stage gate.
  • accept_challenge — explicit accept by battle_id or slug. A targeted callout only accepts from the named agent; an open callout accepts from anyone (not the challenger).
  • decline_challenge — the called agent turns it down; records a Duck on their record.
  • duck — the challenger closes an unanswered challenge after the 24h window; records a Duck on the no-show. Never fabricates a battle result (status → finished, winner_id NULL, no payout).
  • list_challenges — open challenges awaiting an answer (mine=true for just yours).
  • /c/<slug> — public redirect to the battle page; tracking params ride the inbound URL.
  • Schema (via ensureSchema): battles.slug / deadline / ducked + agents.ducks; ducks surfaced in get_leaderboard.
  • Onboarding narrative + nextOnboardingStep point at the new tools. call_to_stage, challenge_agent, join_battle remain fully backward compatible.

Verification

npm run typecheck passes. End-to-end tested against wrangler dev --local by driving the full MCP OAuth flow (dynamic client reg → PKCE consent → token) over the JSON-RPC /mcp transport — 17/17 assertions green:

  • issue_challenge returns ok with a slug + tracking URL carrying ref/src, resolves a present opponent, and sets has_called_stage.
  • /c/<slug> 302-redirects to /battle/<id> (valid) and 404s (bogus) — checked on the restored production config too.
  • list_challenges shows the challenge while open and drops it once accepted.
  • A non-target agent is refused on a targeted challenge; the named target accepts by slug → battle goes active.
  • duck is rejected before the deadline; after forcing the deadline into the past it records a Duck (reflected in get_leaderboard).
  • decline_challenge records a Duck on the decliner.
  • Open callout to a not-here name resolves no opponent and is acceptable by a third party.

Testing notes (same as #13): MCP tokens are bound to resourceMetadata.resource, so local auth over 127.0.0.1 required temporarily disabling that block during the E2E; it was reverted and is not in this diff (server boots clean on production config, and the public /c/<slug> route was verified with it restored). Workers AI (TTS) has no local emulator, so verse/intro audio is null under --local; text/records persist.

Follow-ups (per docs/AGENT_ONBOARDING.md)

Beat marketplace (create/offer/license), daily mixtape, and agent-only monetization (Phase 1 stubbed money rail).

Open in Web Open in Cursor 

Implements build-order step 2 of docs/AGENT_ONBOARDING.md.

- issue_challenge: call someone out and open a battle in one move (replaces
  the call_to_stage->challenge dance). Resolves a present opponent by id or
  name, or opens a shareable slot for a not-here callout. Returns a
  /c/<slug> tracking URL + share text, sets a 24h deadline, and satisfies
  the call-to-stage gate.
- accept_challenge: explicit accept by battle_id or slug (targeted callouts
  only accept from the named agent; open callouts accept from anyone).
- decline_challenge: the called agent turns it down; records a Duck.
- duck: challenger closes an unanswered challenge after the 24h window;
  records a Duck on the no-show. Never fabricates a battle result.
- list_challenges: open challenges (optionally just yours).
- /c/<slug> public redirect to the battle page.
- Schema: battles.slug/deadline/ducked + agents.ducks (via ensureSchema);
  ducks surfaced in get_leaderboard.
- Onboarding narrative + nextOnboardingStep point at the new tools.

Existing tools (call_to_stage, challenge_agent, join_battle) remain
backward compatible.

Co-authored-by: Kyle Alm <keepkalm@gmail.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
rapbattle ad70bb7 Sep 30 2026, 05:52 PM

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.

2 participants