Repository navigation
Conversation
Opening a library in an older format rewrites it in this build's, and older builds then refuse it: a one-way step. Journal::open now first keeps the files the library was, byte for byte, as catalog.snap.v<format>-<seq> and catalog.log.v<format>-<seq>, and reports their names (LoadReport::kept). Put back under their own names they are the library as the older build left it (docs/catalog-persistence.md, Going back to an older version). A library whose files can't be kept is not upgraded (it opens as it is; the next open tries again), and an upgrade that fails leaves no copy; kept files stay whenever the upgrade may have been written. A library whose log was damaged is an upgrade like any other: its snapshot is kept beside the damaged log, and it is refused if that log can't be replaced. The person is told once where the library as it was is kept. A library left in its old format at open is upgraded by a later snapshot (compaction, or closing), which keeps its files first and is not written when it can't. The browser build keeps none (Store::keeps_replaced_formats). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration:
Comment |
11 of 12 tasks
nledford
force-pushed
the
catalog-snapshot-scale-p4c
branch
from
October 25, 2026 19:05
e9663de to
e258a98
Compare
Contributor
Author
This was referenced Oct 25, 2026
Draft
Draft
Draft
A library left in an older format at open keeps its files when a later snapshot upgrades it. Those files are the library as it was at open (the snapshot, and the log up to its length then), under the names the open would have given them, so what is appended meanwhile in this build's ops is never in them. The snapshot hands the names on (Journal::take_kept) and the engine tells the person once, as the open does. Appends are not refused meanwhile (a library whose files can't be copied would save nothing): the module doc and the persistence doc say so.
…he later upgrade's tests and docs are exact A library left in its old format whose snapshot is in this build's format already (a write that landed and reported a failure) no longer fails every snapshot until it is reopened: it is the upgrade done, with nothing to keep. Tests now cover the files kept at open's length and seq when changes were made before the first attempt, the snapshot that landed after its files were kept, no second copy on a retry, the background worker's result and telling once. The docs say what the kept files hold when a session already added changes in the old format, what going back loses, and that a snapshot at close or a library switch has no one to tell.
A develop setting a record leaves out reads as its default, so a default
that changed in the code would change every photo relying on it. catalog.snap
now states the defaults it was written with ("defaults"), and they cover the
log beside it. A build whose own defaults differ reads the library's settings
over the library's (stored::reading_over) and rewrites it with its own before
anything is appended (LoadReport::other_defaults); a library that only lacks
newer settings, or knows more, is read as it is. What a missing value reads as
in this build is pinned by a test (develop_defaults.json).
Every record is still written in full, and the format stays 9: older builds
ignore the extra header field. This is the reading half of the compact records
of the next change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lts fails The sentence said the library's files still state its own defaults. That holds when catalog.snap could not be written; when it was written and only the log could not be emptied, they state this build's, and the log's records are skipped as stale.
…fixture The catalog formats were a table in journal.rs's module docs that nothing read. They are now one list in code, journal::FORMATS: each row has the format's number, the build that wrote it first, what it adds, and whether it adds an op (NEW_OP) or only fields (FIELDS). VERSION is the newest row this build has. A test holds that the numbers run 1.. without a gap, that a row that adds an op names it, and that the newest op's format is the newest row that adds one (what NEWEST_FIELDS held by hand). Every format from 6 on has a fixture, a small library written by the build of that format, which every later build must open as it was: fixtures v7 to v9 are new (v6 was there), written by their builds from the fixture library of tests_stored.rs. Nothing is written or read differently: VERSION stays 9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…defaults
The writing half of compact records, for develop settings only and with no
caller yet: the settings of a photo, and those of its history steps, versions
and import look, stored as their difference from the defaults ({} for an
unedited photo). A value is left out only where that reads back the same
(worked out from the types on first use: not the rendering process, not single
fields of the crop rectangle), every difference is read back before it is
written, and a negative zero is kept. writing_full() stores settings whole while
a library's header lacks a setting this build has, and states_every_setting()
says when that is so.
Nothing writes this form yet: records stay as they are, and the format stays 9.
The next change names these functions from the ops, stores the photos with them and brings
catalog format 10.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A photo's record in catalog.snap / catalog.log states only what was set: unset fields of the photo and its metadata are left out, and develop settings (the photo's, its history steps', versions' and import look's) are stored as their difference from the defaults, with the stored form of the previous change. A record of a photo with no metadata goes from 3.2 kB to 0.2 kB. Reading is unchanged, so formats 1-9 load as they are and are rewritten on open; the public JSON of a photo (catalog.query, Local fingerprints, preview-cache keys) is unchanged. Format 10 is the first that leaves values out, so a library that is in a format before 10 (also one that states defaults), or states other ones than this build's, and can't be upgraded, is not opened (it is left as it was, and the error says why). A library in format 10 that lacks a setting this build has is rewritten to state it before a compact record is appended; where that can't be written, its records state develop settings whole until a snapshot is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s at open, and the tests make the state by hand A library whose upgrade is put off at open (it stays in its old format, and a later snapshot upgrades it, keeping its files first) keeps one pair of copies however many attempts fail, writes them once, tells them once the snapshot that works is written, and takes a snapshot that landed all the same as the upgrade done: that is what the base of this branch does. No format this build reads and upgrades from puts a library in that state yet (a format before 10 is refused when it can't be upgraded), so the tests that had it from an old format's library make the state by hand, for the next format that can be put off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nledford
force-pushed
the
catalog-snapshot-scale-p4c
branch
from
October 26, 2026 07:56
e258a98 to
ae75897
Compare
nledford
added a commit
to nledford/lightcraft
that referenced
this pull request
Oct 26, 2026
…mat 11's one-file store Moved from storytold#2958 (ae75897, catalog-snapshot-scale-p4c), whose own change had become only these tests after storytold#2867. `tests_upgrade_attempts.rs` is the file as it was there, with the same `mod` line in `journal.rs`, and its opening comment no longer says that no format can be put off (a format 10 library can be on this build). Ten tests that set up a put-off upgrade's state by hand (the library as it was at open, behind) and check that it keeps one pair of files however many attempts fail, writes them once, tells them once the snapshot that works is written, and takes a snapshot that landed all the same as the upgrade done. The store they use is one file, as the browser's is: they don't cover the segments of format 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nledford
added a commit
to nledford/lightcraft
that referenced
this pull request
Oct 26, 2026
…mat 11's one-file store Moved from storytold#2958 (ae75897, catalog-snapshot-scale-p4c), whose own change had become only these tests after storytold#2867. `tests_upgrade_attempts.rs` is the file as it was there, with the same `mod` line in `journal.rs`, and its opening comment no longer says that no format can be put off (a format 10 library can be on this build). Ten tests that set up a put-off upgrade's state by hand (the library as it was at open, behind) and check that it keeps one pair of files however many attempts fail, writes them once, tells them once the snapshot that works is written, and takes a snapshot that landed all the same as the upgrade done. The store they use is one file, as the browser's is: they don't cover the segments of format 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nledford
added a commit
to nledford/lightcraft
that referenced
this pull request
Oct 27, 2026
…mat 11's one-file store Moved from storytold#2958 (ae75897, catalog-snapshot-scale-p4c), whose own change had become only these tests after storytold#2867. `tests_upgrade_attempts.rs` is the file as it was there, with the same `mod` line in `journal.rs`, and its opening comment no longer says that no format can be put off (a format 10 library can be on this build). Ten tests that set up a put-off upgrade's state by hand (the library as it was at open, behind) and check that it keeps one pair of files however many attempts fail, writes them once, tells them once the snapshot that works is written, and takes a snapshot that landed all the same as the upgrade done. The store they use is one file, as the browser's is: they don't cover the segments of format 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nledford
added a commit
to nledford/lightcraft
that referenced
this pull request
Oct 30, 2026
…mat 11's one-file store Moved from storytold#2958 (ae75897, catalog-snapshot-scale-p4c), whose own change had become only these tests after storytold#2867. `tests_upgrade_attempts.rs` is the file as it was there, with the same `mod` line in `journal.rs`, and its opening comment no longer says that no format can be put off (a format 10 library can be on this build). Ten tests that set up a put-off upgrade's state by hand (the library as it was at open, behind) and check that it keeps one pair of files however many attempts fail, writes them once, tells them once the snapshot that works is written, and takes a snapshot that landed all the same as the upgrade done. The store they use is one file, as the browser's is: they don't cover the segments of format 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nledford
added a commit
to nledford/lightcraft
that referenced
this pull request
Oct 30, 2026
…mat 11's one-file store Moved from storytold#2958 (ae75897, catalog-snapshot-scale-p4c), whose own change had become only these tests after storytold#2867. `tests_upgrade_attempts.rs` is the file as it was there, with the same `mod` line in `journal.rs`, and its opening comment no longer says that no format can be put off (a format 10 library can be on this build). Ten tests that set up a put-off upgrade's state by hand (the library as it was at open, behind) and check that it keeps one pair of files however many attempts fail, writes them once, tells them once the snapshot that works is written, and takes a snapshot that landed all the same as the upgrade done. The store they use is one file, as the browser's is: they don't cover the segments of format 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nledford
added a commit
to nledford/lightcraft
that referenced
this pull request
Oct 30, 2026
…mat 11's one-file store Moved from storytold#2958 (ae75897, catalog-snapshot-scale-p4c), whose own change had become only these tests after storytold#2867. `tests_upgrade_attempts.rs` is the file as it was there, with the same `mod` line in `journal.rs`, and its opening comment no longer says that no format can be put off (a format 10 library can be on this build). Ten tests that set up a put-off upgrade's state by hand (the library as it was at open, behind) and check that it keeps one pair of files however many attempts fail, writes them once, tells them once the snapshot that works is written, and takes a snapshot that landed all the same as the upgrade done. The store they use is one file, as the browser's is: they don't cover the segments of format 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Part of #800. Stacked on #2968 (a draft: compact records, format 10, stacked on #2957, #2951, #2948 and #2867 which is approved): this PR's own commit is
ae75897435, the one on top of #2968's head0634842c6e. Chain tomain: #2867, #2948, #2951, #2957, #2968, then this. It waits for them to land and is a draft until then: GitHub shows their commits in the diff until they do.This part used to change the code that keeps the files of a library whose upgrade is put off at open. #2867's later commits (in #2948's base) now do that, in their own way (the files are kept once, as the library was at open, and told once the snapshot that upgrades it is written), so this part is now only the tests that make that state by hand. The title still names the old change.
Problem
A library whose upgrade is put off at open (it stays in its old format, and a later snapshot upgrades it, keeping its files first) is the state #2867's upgrade code has to get right: attempts that fail must not pile copies up beside the library, a snapshot request on a store with no background writer must not keep the files twice, and a snapshot that took effect and then failed (the folder sync after the rename, or a worker that died after its commit) must leave the upgrade done, with the files it kept as its way back.
#2867 tested that through a library in format 6. With #2968 a library in a format before 10 that can't be upgraded is refused at open, so no library in a format this build reads is put off yet, and those tests have no state to start from (they are not repeated in #2968). The next catalog format (format 11, the segments) is the first that can be put off, and its tests start from a format 10 library. Until then the state has to be made by hand.
Change
crates/catalog/src/tests_upgrade_attempts.rs, a child ofjournal(it setsbehindandbehind_at, which only an open does), and the line injournal.rsthat names it. No other code changes. Ten tests, each from a library made to look as an open that put its upgrade off leaves it:Not in this PR: anything that puts a library in that state (the next catalog format), and any change to the code that keeps the files.
How it was checked
cargo xtask cipasses on this branch, rebased on currentmain: not run locally for this draft (the hostedCIgate runs it once its parents have landed); atae75897435cargo fmt --all --check,cargo check --workspace --all-targetsand clippy with-D warningspass,cargo test -p lightcraft-catalog --libpasses (308 passed, 3 ignored) andcargo test -p lightcraft-engine --libfor the library and persistence tests passes (109 passed, 1 ignored)journal.rsand the ten tests run. Keeping the files again on every try (kept_pendingignored) failsfailed_attempts_keep_one_pair,a_worker_that_dies_keeps_the_files_for_the_next_attemptanda_background_request_without_a_writer_keeps_the_files_once; clearingbehindwithout telling the files (upgraded_laterreplaced bybehind = Noneafter a written snapshot) fails six tests, among theman_upgrade_whose_log_cannot_be_emptied_is_done_and_tellsanda_later_attempt_upgrades_and_tells_what_it_kept; treating an unreadable disk as an empty one failsa_disk_that_cannot_be_read_keeps_nothing_and_is_tried_againNo catalog compatibility check is needed: no file is written or read differently (the format stays 10, and the state these tests make can't be reached by any format this build reads).
A reviewer with a clean context read the rebase of this part and the ones above and below it (two rounds): no data-loss finding; its findings on the tests (three test knobs with nothing using them, so three paths untested) were fixed with the three tests above.
Screenshots
None; nothing changes on screen.
Merging
journal.rs,tests_persist.rsanddocs/catalog-persistence.md; PERF-CATALOG: equal develop settings are held once in memory #2812 conflicts inlib.rsandmodel.rs; Catalog: the store can write files that a later write names, list its files and sync folders it can #2871 conflicts inlib.rsandstore.rs; Catalog: the snapshot in segments of about 2 MB and at most 4096 photos (format 11, stacked on #800) #814 (segments, older draft) conflicts in several catalog files. Whichever lands second takes a rebase. Next in the chain: PERF-CATALOG: the segments of a snapshot, with no caller yet (stacked on #2968 and #2871) #2978 (a draft, stacked on this PR) is the next part.unsafe, build scripts, network access, spawned processes, deleted files, CI orxtaskgate changes: none. Test code only.Checklist
tr()and has its key incrates/ui-egui/locales/*.json: no new text on screendocs/parity-checklist.mdand its entry indocs/gaps.mdare updated: no feature row; no doc changeskeep_before_upgrade), though only a library that is behind, which no format this build reads puts there yet, reaches the branches it tests; the segments change (format 11) is the first that doesassets/ATTRIBUTION.md; no font or media files added