Skip to content

API: POST /me/solving-times answers with the prediction that applied before the solve, and the parsed time_seconds - #201

Merged
JanMikes merged 1 commit into
mainfrom
api/solving-time-prediction
Aug 19, 2026
Merged

API: POST /me/solving-times answers with the prediction that applied before the solve, and the parsed time_seconds#201
JanMikes merged 1 commit into
mainfrom
api/solving-time-prediction

Conversation

@JanMikes

Copy link
Copy Markdown
Member

PR 4 of docs/features/api/v1-expansion-plan.md.

POST /api/v1/me/solving-times now answers with prediction — the forecast that applied before this solve (the new time is excluded, so personal_solve_count/predicted_attempt_number are the pre-solve values), the same block the added-time recap page shows — for solo times of a member who has not opted out, with a PAT or results:read (the write scope alone does not grant reading insights). null otherwise; always null on PUT. time_seconds is now filled from the handler's own parser (was always null).

  • Trailing addition only; existing create/update tests untouched and green.
  • Cost: +1 (owner profile) +≤4 (prediction) only for eligible requests; ceilings pinned per scenario (the create's write path is data-dependent because PuzzleSolved handlers run sync).
  • 11 new tests. Full suite green.

🤖 Generated with Claude Code

https://claude.ai/code/session_015uH2n4Y6gPLiYASEJwNr3H

…before the solve, and the parsed time_seconds

PR 4 of the API V1 expansion plan (docs/features/api/v1-expansion-plan.md §7).

SolvingTimeResponse gains a trailing `prediction: null|TimePredictionResponse = null`
(PUT keeps null). CreateSolvingTimeProcessor fills it after the dispatch, for a solo
time (group_players empty) with a parsed time, when the token owner is a member who
has not opted out of time predictions and the token may read results (PAT or
results:read - plan §2's rule; the write scope alone does not read insights), from
GetPlayerPrediction::forPuzzle(playerId, puzzleId, excludeTimeId: timeId) - the
prediction that applied *before* this solve, what the added-time recap page shows:
personal_solve_count is the count before the new time, last_time_seconds the
previous solve. Everything else in the processor is untouched.

time_seconds, always null in the create response until now, is the submitted time
parsed with SolvingTime::fromUserInput - the same parser the handler stores from,
so it equals the stored seconds_to_solve (no extra query).

Query budgets (request only, PAT, CreateSolvingTimePredictionEndpointTest): the
create's own write path is data-dependent - the PuzzleSolved event runs the
statistics / intelligence recalculations, wishlist removal and notifications
synchronously - measured with the prediction switched off: 29 (member, 500_01),
28 (member, 500_04), 35 (non-member, 500_02, repeat solves + subscriber), 21 (duo).
The feature adds the owner profile (1) + the prediction query (4 personal /
2 statistical, ceiling 5) for an eligible request, the profile only (1) for a
non-member / opted-out owner, nothing for a group time; ceilings pinned per
scenario as write path + 1 + 5 / + 1 / + 0.

Plan wrinkle, documented in §12: the synchronous recalculation rewrites the posted
puzzle's puzzle_difficulty row inside the request, so a seeded difficulty does not
survive the POST - the statistical-prediction test seeds four other players' first
attempts so the puzzle is scored from real data.

Docs: README POST section (response shape, semantics, gates, cost), OpenAPI
summary/description on the operation, plan §7 corrected (results:read) and §12
ticked.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015uH2n4Y6gPLiYASEJwNr3H
@JanMikes
JanMikes merged commit 2b5b132 into main Aug 19, 2026
5 checks passed
@JanMikes
JanMikes deleted the api/solving-time-prediction branch August 19, 2026 15:24
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.

1 participant