Skip to content

A restore records the trashed page row it was made against - #1026

Merged
SunkenInTime merged 8 commits into
mainfrom
t3/store-restore-recorded-row
Nov 30, 2026
Merged

SunkenInTime merged 8 commits into
mainfrom
t3/store-restore-recorded-row

Conversation

@SunkenInTime

@SunkenInTime SunkenInTime commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Part of the one-store cutover (#615). It fixes sweep seed 72992 from #847: my restore of a page was queued, then a page result came back saying the page was gone. The store dropped the page row, and the restore was drawn as nothing. The drawn strategy revision fell by one, so my next page add was made one revision low and the player was asked a false question when it went out.

The design

  • When a restore is committed, its queue row records the trashed page row it was made against (AuthoredRow.restoredRow). These are the same rows RestoreNotTaken checks. Its landed work keeps a copy, the same way movedRow does for a move.
  • restoringFrom is the only reader. If the drawn rows hold any form of the page, it draws from them. If not, it draws from the later of the recorded row and the page list's trash row, by Version order (life, then revision; on a tie, the listed row). A row stored without the record falls back to the page list's trash, as on main. Each draw uses one source.
  • Settling, _leftWithItsRow, _knownRow, the judge, contentKnown and trashOffered don't change, and none of them reads the record. Nothing is added to Shown or the cached rows, so no queue rule can take the record for server state (73570's cause). The record goes away with its queue row or landed work, so no exit rule is needed. A reopen draws the same as memory.

Stored format

One new optional key, restoredRow, on pending/ rows (inside authored) and on landed/ rows. It holds the trashed page row. There is no version bump, and the key isn't movedRow: that key's decoder rejects anything that isn't an item row, so an older build would hold the whole queue. A row without the key draws exactly as main does. Both directions are tested:

  • This build reads rows written without the key. A queued restore whose page a result took isn't drawn. One the page list's trash holds is drawn from that trash. A landed restore under an older page-gone result isn't drawn.
  • Main's decoder reads a queued and a landed restore written with the key and keeps the queue: the restore is sent and lands, and later work is sent. I ran cloud_restored_row_older_build_test.dart against 863ea63 in a separate worktree, and it passes there.

Rollback: a build without the key ignores it on read. If that build rewrites the row, the key is dropped and main's behaviour comes back for that restore: it's drawn from the page list's trash, or not at all. Nothing is lost.

Two model changes

These bring the queue model in line with the store.

  • It kept a page the store drops. On a page result that takes a page away, the model now drops that page from its base when leaving is the last decision about the page in that step (pagesLeftBy, the part of the 73242 fix that does this, nothing else from it). Seed 72992 shows it: without this change the branch still fails 72992 on op60 with main's text. 75620 fails the same way without it, on op31.
  • It made edits without the rows the store makes them over. Client now makes edits over restoringFrom(visible), as _commitCloud does, so a restore made from the page list's trash records its row in the model as it does in the store. No seed shows this change alone. With only this change reverted, queue seeds 1–200 and 72000–74000 fail exactly as the branch does (72928, 73483, 73591, 73913). In the default run it affects the 29 restores made from the page list's trash.

Counters

Queue model, default run (200 seeds, 150 steps, both folding modes):

counter main branch floor
restore drawn from its recorded row after its page left 0 (main records no row) 52 36
page edit authored behind such a restore, answered applied (page adds only) 0 (main records no row) 0 in the default run, 2 in seed 72992 1, in a new test that runs seed 72992
own restores refused not_found, then neither drawn nor offered 6 (before this condition was added) 4 3

A restore counts as drawn from its record only when the same queue without records wouldn't draw it. The default 200 seeds never make a page edit while such a restore is drawn, so that counter's floor sits on seed 72992, which fails on main.

Store tests

Eight paths in cloud_store_restore_recorded_row_test.dart (plus cloud_restored_row_older_build_test.dart for path 7):

  1. Queued restore, page-gone, reopen: a page add lands without asking. On main it fails at the harm: the add is NeedsUser: changed by someone else since the user saw it.
  2. Landed restore, then an older page-gone: the page stays drawn. On main it fails at the harm: ['page-a'], page-b not drawn.
  3. Reopen, refusal as not_found, discard: the page is neither drawn nor offered. Passes on main.
  4. A page in the server's trash whose restore is refused for another reason and then discarded is still offered, online and offline, and a second restore lands. Passes on main.
  5. A restore set aside under a replaced strategy isn't drawn. Passes on main.
  6. Rows stored without the key draw as main does. Passes on main.
  7. Main's decoder reads rows with the key and keeps the queue. Passes on 863ea63.
  8. 73570's shape: a list taken before my restore's answer arrives without the page while a drag of one of its items waits. Nothing is asked, and the drag lands once the page is read. Passes on main.

Also: the queued restore draws from its record before and after a reopen, with its content not read (fails on main: ['page-a']), and this build writes exactly the row the older-build test reads.

Sweep

Branch at fa18004 (same package code as this head; later commits change only counters, floors and the README). Queue 72000–74000 and 74201–76200 at 150 steps in both folding modes, and store 1–740 at 120. Main (863ea63, the same package code as ab5637d) was asked only about seeds that failed.

Known limits

  • Only the page row is recorded. An edit of one of the page's items queued behind the restore (a drag, say) is drawn once the page is read. Until then the page shows that it's loading. Nothing is lost; it's drawn late. If it's ever done, it reuses this key.

ci: analyze test web library

Confidence Score: 5/5 · The PR appears safe to merge once the selected CI checks pass.RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge once the selected CI checks pass.

Summary

Restores now keep the trashed page row they were made against, so an arriving result cannot make a waiting restore disappear.

  • Page restores keep the trashed row they were made against.
  • The queue model now tracks the same page rows the store uses.

No actionable issues were found. The previous-review guard failed because the merge bases differ, so the supplied full PR changes were reviewed. Checks were limited to source and test inspection; tests were not run. Run the selected CI lanes before merging.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Restore committed] --> B[Save trashed page row with queued work]
  B --> C[Draw restore]
  C --> D{Drawn rows hold the page?}
  D -- Yes --> E[Use drawn rows]
  D -- No --> F[Use newer recorded or listed trash row]
  B --> G[Server accepts restore]
  G --> H[Carry recorded row into landed work]
  H --> C
  H --> I[Later result settles landed work]
Loading

Reviews (6) · Last reviewed commit: "The README states the restore's draw as ..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2e8b87d5-6af9-47da-91f9-3a0499e6ae83
Commits

Reviewing files that changed from the base of the PR and between 6a8a92b and e12ade9.

Files selected for processing: 10

  • packages/icarus_library/README.md
  • packages/icarus_library/lib/src/cloud/codec.dart
  • packages/icarus_library/lib/src/cloud/op_facts.dart
  • packages/icarus_library/lib/src/cloud/pending.dart
  • packages/icarus_library/lib/src/cloud/queue.dart
  • packages/icarus_library/lib/src/cloud/visible.dart
  • packages/icarus_library/test/cloud_model_test.dart
  • packages/icarus_library/test/cloud_restored_row_older_build_test.dart
  • packages/icarus_library/test/cloud_store_restore_recorded_row_test.dart
  • packages/icarus_library/test/cloud_support.dart
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

…dits made behind them, and not-found refusals that leave nothing offered
…at leave nothing offered; seed 72992 shows a page edit made behind such a restore answered applied
…age away at once, before and after a reopen, and the recorded row does not draw it back
…of its recorded row and the page list's trash row; the model samples restores drawn from their record after a read is mirrored, counts only page adds behind them, counts a not-found refusal only when the page is not drawn; the set-aside test checks the restore stays set aside
…ot-found refusals that leave nothing drawn or offered, 1 page add behind such a restore in seed 72992
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