# run-a-score-leaderboard-with-seasons

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

- **Space:** leaderboards-public (https://github.com/Tech-Realm/space-leaderboards-public/tree/main/run-a-score-leaderboard-with-seasons)
- **Level:** L2 (as the registry reports it)
- **Keys it needs (names only):** LB_HMAC_SECRET
- **Tools:** python3
- **Routes:** stdlib-sqlite, valkey-sorted-sets; checks: 2
- **Uses:** new (no recorded use yet)
- **Install:** `logicpacks pack use leaderboards-public/run-a-score-leaderboard-with-seasons` or MCP `get_pack leaderboards-public/run-a-score-leaderboard-with-seasons`
- **Files:** CHANGELOG.md, code/leaderboard.py, outcome/EVIDENCE.md, outcome/checks.yaml, outcome/results.json, pack.yaml, refs/refs.yaml, spec/SPEC.md, spec/source.md

## Purpose (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.



---

Canonical URL: https://logicpacks.io/packs/leaderboards-public/run-a-score-leaderboard-with-seasons

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
