Repository navigation
fix(application): make review-state edits of the read their save is conditional on - #1012
Merged
Merged
Conversation
…s as the write reads them rescheduleCards, resetCards and resetStudyDay read the deck's review states, made the change of them, and handed it to applyReviewChanges, whose adapter read the reviews document again and saved If-Match that second read. A grade made on another device between the two reads was in the document the save was conditional on, so a reschedule wrote the card's old interval and ease over it, due on the day set, while the grade's answer stayed in the log. editReviewStates, a new port on editDocument like writeFsrsStates, gives the change the states as read and saves it If-Match that same read, made again of a fresh read on a 412. The three use cases now make their changes in it; a day's reset still removes the day's answers from the log first. applyReviewChanges, left to an answer undone, which writes its state back whatever the document holds, is the same edit with a change made beforehand, so it is tried again on a 412 too. Refs: #1011
…ersion they were planned from A bulk edit of cards and a transfer read the review states with no version, planned their changes, then had prepareReviewChanges read the reviews document again and send If-Match that second read: the transfer's comment said each write went If-Match the read it was made from, which was true of the cards document only. writeCardEditReviews and the library upgrade each wrote their own retry, sending the same changes again on a 412. prepareReviewChanges now takes the version the changes were made from (readReviewStatesSince), as prepareCardChanges does: a document no longer at it refuses them before anything is sent, so the edit or the transfer is planned again. One that changes once a cards document was sent can't be: its changes, states added or removed by card, are made of it read afresh (editReviewStates). The use cases' own retries go. Closes: #1011
ixuz
enabled auto-merge
November 24, 2026 20:01
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 24, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 24, 2026
ixuz
added a commit
that referenced
this pull request
Nov 24, 2026
…ot under coverage The test that the shape check of a release lets the page do its work between subjects with many values validates a release of 32 cards of 1,024 values each, three times over, beside smaller ones. It was in shaclShapeValidator.test.ts, so CI's check job ran it under coverage, with every package's tests at once on two cores: 167 s of its 180 s timeout on #1012's own run, and past it in both of its merge queue runs, failing them. Without coverage it takes about 34 s in CI. Like every test that times CPU work as a ratio of two runs, it now lives in a growth test file, shaclShapeValidator.growth.test.ts, which the growth job runs without coverage and npm test leaves out. Its input and its limit are as they were, and so is the package's coverage. Closes: #1016
This was referenced Nov 25, 2026
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.
What and why
Every write of a deck's reviews document except a grade was made from one read and saved If-Match another. A use case read the review states and made its change of them. The adapter then read the document again and saved If-Match that second read. So a grade made on another device between the two reads was in the version the save was conditional on, and got written over. In the Studio, setting a card's due day wrote the card's old interval and ease over a grade made meanwhile, while the grade's answer stayed in the log. This is the defect #997 fixed for instance metadata, the catalog and the deck entry, here for review states.
Two commits:
editReviewStates, built oneditDocumentlikewriteFsrsStates. It gives the change the states as read, saves If-Match that same read, and on a 412 reads the document again and makes the change again. The day reset still removes the day's answers from the log first.applyReviewChanges, now used only to undo an answer, is the same edit with a change made beforehand, so it also retries after a 412.readReviewStatesSince) and pass it toprepareReviewChanges, as they already did for the cards document. If the reviews document is no longer at that version, nothing is sent and the edit is planned again. If it changes after the cards document was sent, the reviews' changes (states added or removed by card) are made again from a fresh read, since the edit can no longer be planned again.writeCardEditReviewsand the library upgrade's retry wrapper are gone. The transfer's comment that each write goes "If-Match the read it was made from" now holds for its reviews too.Tests
reviewStateEdits.integration.test.tshas the phone grade a card right after the Studio reads the states, then checks the card keeps that grade, due on the day set. Run againstmain's code, it fails with the Studio's stale interval. It passes oncss-7andcss-acp, and skips oncss-6,nss-6andnss-5, as thecardEditsconcurrency tests do: those servers ignore If-Match or keep an ETag across edits in the same second.data-model.md,srs.mdandstudio.mddescribe the new behavior.npm run checkpasses on each commit.Closes: #1011