Skip to content

feat(bounties): one submission per agent per bounty#994

Merged
biwasxyz merged 5 commits into
mainfrom
fix/bounty-single-submission
Jun 10, 2026
Merged

feat(bounties): one submission per agent per bounty#994
biwasxyz merged 5 commits into
mainfrom
fix/bounty-single-submission

Conversation

@biwasxyz

Copy link
Copy Markdown
Contributor

Summary

Agents could submit to the same bounty multiple times — production has 24 bounty/agent pairs with duplicates (up to 7 resubmissions from one agent on one bounty), which spams posters during judging.

This adds a guard to POST /api/bounties/[id]/submit: if the agent already has a submission on the bounty, the request is rejected with 409 already_submitted and a message telling the agent to update the content behind their original contentUrl instead (the poster sees the latest state when judging).

Implementation is minimal — the hasSubmission(db, bountyId, submitterBtcAddress) helper already existed in lib/bounty/d1-helpers.ts (built for this, exported, never called). This PR just wires it in after the status guard, so submissions_closed (422) still takes precedence on closed bounties.

Notes / decisions

  • Existing duplicates are left in place. In both production cases where a duplicate was accepted as the winner, it was the later resubmission that won — so a dedupe migration keyed on "keep earliest" would have deleted accepted submissions referenced by bounties.accepted_submission_id, permalinks, and agents' submission history. Enforcement is forward-only.
  • No D1 unique index (yet). A unique index on (bounty_id, submitter_btc_address) can't be created while historical duplicates exist. The route guard closes the practical gap; a concurrent double-submit race is theoretically possible but harmless (two rows, poster picks one). If we later decide to clean up history, the index can follow.
  • Discovery docs updated together per repo convention: OpenAPI spec (409 response + description), /docs/bounties topic sub-doc, CLAUDE.md endpoint table.

Testing

  • New route test: first submit → 201, repeat → 409 with no insert, closed bounty → 422 takes precedence
  • Full suite: 1518 passed / 5 skipped
  • npm run lint clean (pre-existing <img> warnings only), npm run build passes

biwasxyz added 5 commits June 10, 2026 14:21
…per bounty

Wires up the existing (previously uncalled) hasSubmission helper as a
guard after the status check. Repeats get 409 already_submitted with a
pointer to update the content behind the original contentUrl instead.
Existing duplicate rows in production are left as history.
First submit 201, repeat 409 with no insert, and submissions_closed (422)
taking precedence over the duplicate check on expired bounties.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 10, 2026

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 Preview URL Updated (UTC)
✅ Deployment successful!
View logs
landing-page eb0c8de Commit Preview URL

Branch Preview URL
Jun 10 2026, 08:38 AM

@biwasxyz biwasxyz merged commit 4ae7c32 into main Jun 10, 2026
8 checks passed
@biwasxyz biwasxyz deleted the fix/bounty-single-submission branch June 10, 2026 08:42
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