Skip to content

Packs / leaderboards-public

run-a-score-leaderboard-with-seasons

Run a leaderboard: ingest signed scores, rank them (competition or dense ranking), reset per season and export CSV

L2 Checks passed 3 of 3 runsv1.0.0Tech-Realm/space-leaderboards-public

Install

logicpacks pack use leaderboards-public/run-a-score-leaderboard-with-seasons
get_pack leaderboards-public/run-a-score-leaderboard-with-seasons

The second line is the MCP tool call for the LogicPacks connector (Claude Code, Codex, Claude.ai and others). The first run of a pack someone else wrote asks for your yes.

Keys it needs (names only)

  • LB_HMAC_SECRET

Playbooks included

  • Spec: spec/SPEC.md (goal, steps, edge cases, don’ts)
  • Routes: stdlib-sqlitevalkey-sorted-sets
  • Checks: 2 in outcome/checks.yaml
  • Code: leaderboard.py
  • Tools: python3

Usage, last 8 weeks

New: no recorded use yet.

Purpose (from spec/SPEC.md)

Run a leaderboard: ingest signed scores, rank them (competition or dense ranking), reset per season and export CSV

Goal

Players see a correct ranked board per season, ties handled (1,2,2,4), and the board exports to CSV.

Steps

  1. Pick the board and season keys (e.g. board=game, season=2026-12).
  2. Clients submit {board, season, player, score, ts, nonce, sig} with sig = HMAC(LB_HMAC_SECRET, fields) computed server-side by the game server.
  3. leaderboard.py ingest scores.jsonl then top --board B --season S [--mode dense] --csv.
  4. New season = new season key; old seasons stay queryable.

Edge cases

  • Equal scores: competition ranking (1,2,2,4) by default; dense (1,2,2,3) on request.
  • Best score per player counts (max); change to sum for cumulative boards.

Don'ts

  • Don't sign scores in the browser (the secret would leak).
  • Don't delete old seasons.