Skip to content

Leaderboard snapshot swap, edit deadline, compose, k6 gates - #2270

Merged
Olowodarey merged 1 commit into
Arena1X:mainfrom
Diyaq:handsoff/issues-1932-2204-2211-2212-ac6809
Nov 23, 2026
Merged

Olowodarey merged 1 commit into
Arena1X:mainfrom
Diyaq:handsoff/issues-1932-2204-2211-2212-ac6809

Conversation

@Diyaq

@Diyaq Diyaq commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Closes #1932, closes #2204, closes #2211, closes #2212

#1932 — Leaderboard snapshot consistency during recompute

backend/src/leaderboard/leaderboard.service.ts

  • recalculateRanks() now builds the whole next board in memory first, writes it in a single DB transaction, and only then publishes it. Publishing is one reference assignment (publishedBoard = Object.freeze({...})), so readers see either the old board or the new one, never a partial one.
  • New getPublishedBoard() returns the latest complete, frozen snapshot (version, computed_at, entries). While a recompute is running it keeps returning the previous snapshot. If the recompute fails, the previous snapshot is kept.
  • Overlapping recalculateRanks() calls share one in-flight run, so two recomputes can't interleave their writes. isRecomputing() reports whether one is running.
  • Tests in leaderboard.service.spec.ts:
    • a read during a recompute (paused mid-write) gets the complete prior snapshot
    • after the recompute, reads get the new snapshot
    • the board sampled at every intermediate write is only ever the full old or full new board
    • a failed recompute keeps the prior snapshot
    • overlapping calls share a single run

#2204 — Enforce the prediction edit deadline on-chain

contracts/creator-event-manager/src/{match.rs,prediction.rs,lib.rs}

  • match::prediction_edit_deadline(&Match) / get_prediction_edit_deadline(match_id): the deadline comes from the match start (match_time minus the configured prediction lock lead-time, stored as prediction_lock_time).
  • New prediction::edit_prediction: only the owner can edit. Edits are rejected for cancelled events and once a result is in. An edit at or after the deadline is rejected with EditDeadlinePassed and emits ("prediction", "edit_rejected") with (prediction_id, match_id, predictor, deadline, attempted_at). An edit before the deadline updates the scoreline and derived outcome, keeps predicted_at, and emits ("prediction", "edited").
  • Contract entry points edit_prediction and get_prediction_edit_deadline. edit_prediction returns false on a deadline rejection instead of panicking. A panic would roll back the rejection event, and this way it is persisted. Every other error still panics, as elsewhere in the contract.
  • Tests in tests/prediction_edit_deadline_tests.rs:
    • the deadline equals match_time - lock_lead
    • an edit one second before the deadline succeeds
    • an edit after the deadline is rejected, leaves the prediction unchanged and emits the event
    • edits exactly at the deadline and after kickoff are rejected
    • edits by a non-owner are rejected

#2211 — docker-compose for local development

  • New root docker-compose.yml: Postgres 16 with a healthcheck and a persistent volume. There is also an optional Adminer UI under the tools profile. Values can be overridden through POSTGRES_* env vars.
  • backend/.env.example: DATABASE_URL and JWT_SECRET now default to working local values that match the compose file.
  • backend/src/config/env.validation.ts: exports LOCAL_DEV_DATABASE_URL and documents it on DATABASE_URL. A failed validation now tells the developer to run docker compose up -d and copy .env.example. Validation is not loosened.
  • README.md: new "Local services (Docker Compose)" step with commands, a defaults table and the override/cleanup workflow. The later steps are renumbered.
  • Tests in env.validation.spec.ts:
    • the .env.example DATABASE_URL matches the compose default
    • the documented .env.example passes validation as-is
    • the failure message points to the compose workflow

#2212 — Enforce k6 performance thresholds in CI

  • performance/k6-config.js: shared buildThresholds() sets p(95)/p(99) latency and error-rate limits (http_req_failed, errors). They can be overridden with K6_P95_MS, K6_P99_MS and K6_ERROR_RATE.
  • Fixed a gap: the API, oracle, database and cache scripts imported helpers from k6-config.js but never exported options. k6 only applies options exported by the entry script, so their thresholds were never enforced. Each script now re-exports options.
  • New performance/smoke-test.js: 5 VUs for 30s against /api/v1/health/live and /api/v1/health/ping, with thresholds enforced.
  • New performance/threshold-breach-check.sh: runs the smoke test with an impossible p(95)<0ms budget and fails unless k6 exits non-zero. This proves a breach fails the run.
  • backend/package.json: new perf:smoke and perf:smoke:breach-check scripts.
  • .github/workflows/backend-ci.yml: new optional Performance smoke (k6) job. It runs on workflow_dispatch or on PRs labelled perf, with timeout-minutes: 10. It builds and migrates against a Postgres service, starts the API, then runs the smoke check and the breach check.
  • performance/README.md: documents the thresholds, overrides, smoke run and CI job.

Note: per the task rules, none of this was built or run locally. The Rust and Jest tests, the compose file and the k6 job still need to be checked in CI or by a reviewer.

Closes #1932
Closes #2204
Closes #2211
Closes #2212

@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@Diyaq Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@vercel

vercel Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
insight-arena-4rll Error Error Nov 23, 2026 1:18pm UTC

@Olowodarey
Olowodarey merged commit 16d9f26 into Arena1X:main Nov 23, 2026
2 of 9 checks passed

This branch had an error being deployed

1 failed deployment
Preview — 67856085 Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants