A public leaderboard: partners earning, agents spending, kept apart - #3
Merged
Conversation
Everything the board ranks is already recorded. Crawl passes land in crawl_sales because an agent paid the gateway; referral commissions land in referral_usages because a code was spent. Both are ledgers, so the board projects them (@profullstack/leaderboard projectionStore) rather than keeping a second copy that disagrees the first time a write fails. Only badges get a table, because they are awarded rather than derived. The two sides are never in one list. A partner earning $209 and an agent spending $209 are not the same fact, so each side is its own tab with its own actor column, and a commission rate is shown only where someone is earning. The board is in openPaths, both with and without the trailing slash: the gateway prefix-matches only entries ending in a slash, so '/leaderboard' alone would open the index and still charge for every board on it. An agent that hits a 402 on the page ranking its own spend cannot read the case for buying a pass. Partner names come from display_name or handle, never the email they signed up with. This page is public. Verified against a throwaway Postgres: migrations apply, both sides rank real seeded rows, GPTBot reads the board at 200 while / still answers 402. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0144uEVbZK3jdaQkwcLYTXPE
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
The repo lints with biome in CI and I had not run it here, so import ordering and formatting failed the check. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0144uEVbZK3jdaQkwcLYTXPE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
/leaderboardto NicheDB: a public board over rows we already keep, with the two sides of the marketplace shown separately.What it shows
referral_usagescrawl_salescrawl_salesA partner earning $209 and an agent spending $209 are not the same fact, so the sides never share a list. Each has its own tab and its own actor column (Partner vs Agent), and a commission rate appears only where someone is actually earning.
No second ledger
Both tables are already the record of what happened. Copying them into leaderboard tables would be a dual write, and a dual write means the board and the ledger disagree the first time one of them fails. So the board projects the source rows live (
projectionStore). Only badges get their own table (migration0005), because they are awarded at a moment rather than derived from a sum.Two things worth reviewing
/leaderboardand/leaderboard/inopenPaths. The gateway prefix-matches only entries ending in a slash, so the bare path would have opened the index and still charged for every board on it. An agent that hits a 402 on the page ranking its own spend cannot read the case for buying a pass. The data itself stays paywalled.display_nameorhandle, neveremail. This page is public.Verified
Against a throwaway Postgres, seeded with realistic sales and referrals:
GPTBotgets 200 on the board, its JSON, its RSS and the widget script, and 402 on/@example.testaddress appears anywhere in the JSONScreenshots of both sides are in the session; the tabs, the per-side board pills and the renamed actor column all render.
🤖 Generated with Claude Code
https://claude.ai/code/session_0144uEVbZK3jdaQkwcLYTXPE