Repository navigation
fix: Score only confirmed predictions at market resolution and make claims select the confirmed row - #991
Merged
greatest0fallt1me merged 1 commit intoOct 19, 2026
Conversation
|
@innocentharuna 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! 🚀 |
innocentharuna
marked this pull request as ready for review
October 18, 2026 23:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolution now scores only confirmed predictions, late confirmations are scored, and claims pick the confirmed row deterministically. I couldn't run anything here, so none of it has been run, including the unit and integration tests, lint, tsc and the openapi check. The EXPLAIN output and the repair script's dry-run output the issue asks for are not included.
atomicResolveinsrc/services/marketResolutionService.tsnow updates only rows withstatus = 'confirmed'andresult IS NULL. TheFOR UPDATEtransaction is unchanged. Pending and failed rows keepresult = NULL, and replays never flip an existingwon/lost.UPDATEinsrc/workers/predictionsConfirmer.tsnow setsresultin the same statement. It takes the value frommarkets.winning_outcomewhen the market is already resolved and keeps any existingresult.claimWinningsinsrc/services/claimService.tsselects onlystatus = 'confirmed'rows, ordered by id, and fetches up to two. Two confirmed rows return409 ambiguous_predictionand log both ids. If only unconfirmed rows exist, it returns400 prediction_not_winningbefore any RPC. If the user has no rows at all, it still returns404.src/openapi/registry.ts. I also editedopenapi.yamlby hand to match, since I couldn't regenerate it. Ifnpm run openapi:checkfails, runnpm run openapi:generate(check the script name in package.json) and commit the output.scripts/repair-unconfirmed-results.tsruns dry by default and writes only with--apply. It resetsresulton unclaimed, non-confirmed rows in resolved markets. Rows with aclaim_tx_hashare listed, not changed. It also lists users with more than one confirmed row in a market.docs/predictions-api.md.Changed files
docs/predictions-api.mdopenapi.yamlsrc/openapi/registry.tssrc/services/claimService.tssrc/services/marketResolutionService.tssrc/workers/predictionsConfirmer.tstests/marketResolver.test.tstests/predictionsConfirmer.test.tsscripts/repair-unconfirmed-results.tstests/integration/resolutionScoring.test.tsTest plan
CI should run
npm test -- tests/marketResolver.test.ts tests/predictionsConfirmer.test.tsandnpm run test:integration -- resolutionScoringagainst a migrated DB. Then runnpm run lint,npx tsc -p tsconfig.json --noEmit,npm testwith coverage, andnpm run openapi:check.tests/marketResolver.test.ts: covers a market with confirmed, pending and failed rows (only the confirmed one is scored), and a replayed resolution that changes nothing. It uses an in-memory repo, so it doesn't exercise the SQL filter.tests/predictionsConfirmer.test.ts: one test checks that the confirm update's generated SQL scores late confirmations fromwinning_outcomewithout overwriting.tests/integration/resolutionScoring.test.ts: covers plan rows 1–8 against the real DB, including the failed-row claim (400, no RPC), the confirmed row chosen over a failed duplicate, the 409 for two confirmed rows, late confirmation, and the repair script's dry run and--apply. The two regression cases (rows 1 and 2) should fail on main and pass now.Still to do for the PR: the
EXPLAINoutput on a 10,000-prediction market, the coverage summary, and the repair script's dry-run output against a seeded DB.This PR was created as a draft by the issue solver bot. It will remain a
draft until repository CI passes.
Closes #984