Skip to content

Add permission-gated prediction history profiles#267

Closed
mwickett wants to merge 1 commit into
mainfrom
mwickett/prediction-history-profiles
Closed

Add permission-gated prediction history profiles#267
mwickett wants to merge 1 commit into
mainfrom
mwickett/prediction-history-profiles

Conversation

@mwickett

@mwickett mwickett commented Jun 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a server-only prediction profile query for current game players, covering registered users and recurring guests
  • Gate historical score access to authenticated viewers whose active Clerk org matches the game circle
  • Read only prior finished games in the same circle, exclude the current game, and cap each player to 120 recent score samples
  • Expose aggregate prediction inputs: mean delta, standard deviation, blitz rate, cards played, blitz pile remaining, and 40 recent deltas

Claude review

  • Claude reviewed the plan before implementation and reviewed this PR2a diff after implementation
  • Its privacy review found no blocking issues; I addressed the main design note by limiting history to finished games only
  • Added/kept tests around the empty-profile gates, same-circle scoping, per-player query cap, users vs guests, and profile math

Verification

  • npm run lint
  • npm test
  • RESEND_API_KEY=re_dummy npx next build

Notes

This is intentionally groundwork only. The forecast still needs a follow-up PR to blend these profiles into the Monte Carlo model and UI.


Integration/testing PR: #270 contains the full stack for end-to-end testing.

Copilot AI review requested due to automatic review settings June 27, 2026 18:34
@vercel

vercel Bot commented Jun 27, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
blitzer Ready Ready Preview, Comment Jun 27, 2026 6:35pm

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new server-only query that builds per-player “prediction history profiles” for a given game, with access to historical score data gated by authenticated Clerk organization membership to protect cross-circle privacy.

Changes:

  • Introduces getPredictionProfilesForGame() and buildPredictionProfiles() to fetch and summarize prior finished-game score samples (same org/circle, excludes current game, capped per player).
  • Computes aggregate profile inputs (mean/std delta, blitz rate, mean cards played, mean blitz pile remaining, and a capped list of recent deltas).
  • Adds Jest coverage for authorization gating, circle scoping, user-vs-guest handling, caps, and profile math.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/server/queries/predictionProfiles.ts Adds the new server-only profile query and aggregation logic over historical score samples.
src/server/queries/index.ts Re-exports the new prediction profile query/types from the queries barrel.
src/server/tests/predictionProfiles.test.ts Adds unit tests validating gating, scoping, caps, and computed profile statistics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +9 to +14
export {
buildPredictionProfiles,
getPredictionProfilesForGame,
type PredictionProfile,
type PredictionProfilesByPlayer,
} from "./predictionProfiles";
@mwickett

Copy link
Copy Markdown
Owner Author

Closed as superseded by merged integration PR #270.

@mwickett mwickett closed this Jun 27, 2026
@mwickett
mwickett deleted the mwickett/prediction-history-profiles branch June 27, 2026 22:39
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.

2 participants