Skip to content

PERF-CATALOG: catalog records state only what was set (catalog format 14) (stacked on #2957) - #2968

Draft
nledford wants to merge 20 commits into
storytold:mainfrom
nledford:catalog-snapshot-scale-p4b2
Draft

nledford wants to merge 20 commits into
storytold:mainfrom
nledford:catalog-snapshot-scale-p4b2

Conversation

@nledford

@nledford nledford commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Part of #800. Stacked on #2957 (a draft: the stored form of develop settings, not yet used by anything, stacked on #2951, #2948 and #2867): this PR's own commits are the last four of the branch, a57bf8826a (compact records, catalog format 14), e84fa468ce (a snapshot refers to its shared mask grids once), 0ed0782fc0 (two damaged-log tests restored, five comments corrected) and 7993cab1cb (four kept-file tests expect the refusal this PR makes of a library that can't be kept or upgraded), on top of the #2957 commit c9a46c6e15. The branch was restacked on 7 Nov onto main de096566ff together with the chain below it. Chain to main: #2867, #2948, #2951, #2957, 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 is the second half of what was one change, "compact records" (catalog format 10 then: the old head of #2957, 47cd9bc8b3). The first half is #2957; this part switches the records and the format over. They cannot ship the other way round or apart in the middle: the writer alone would write records that leave values out under format 12, where older builds read the missing values as their own defaults, and the format 14 rules alone have nothing to guard.

Problem

A photo's record in catalog.snap and catalog.log states every field, including all of its develop settings: a synthetic photo with no metadata is 3,232 bytes, almost all of it settings that equal the defaults, and the same defaults are written again in every history step, version and logged edit. A library of hundreds of thousands of photos has a snapshot of hundreds of megabytes, and every compaction and every open pays for it.

Change

  • Compact records (crates/catalog/src/stored.rs, lib.rs). A photo's record states only what was set: fields of the photo and of its metadata that are empty, zero or unset are left out (StoredPhoto, StoredMeta), and develop settings (the photo's, its history steps', versions' and import look's, and SetDevelop's) are stored as their difference from DevelopSettings::default() with PERF-CATALOG: develop settings can be stored as their difference from the defaults (stacked on #2951) #2957's functions, named by serialize_with on the ops and on the catalog's photos. The public form of a photo (catalog.query, Local fingerprints, preview-cache keys) is unchanged; reading is unchanged (a missing field reads as its default), so formats 1 to 12 load as they are.
  • Format 14 (journal::FORMATS, VERSION 12 to 14). A library in a format before 14, or one that states other defaults than this build's, and that can't be upgraded now (the files can't be kept, the snapshot can't be written) is not opened: it is left as it was and the error says why, because a record this build appended would leave out what equals this build's defaults. A library already in format 14 may go on as it is. A new library whose first snapshot can't be written is refused too (it used to open with a warning). Format 13 is held for LRC-LIB-LIBFOLDERS: a folder made with New Folder on Disk… appears in Folders at once #3166 (see Merging): its row is in FORMATS as spoken for (here: false), so nothing reads or writes it as 13 here, and main's rows 10 to 12 are as they are.
  • A library that lacks a setting this build has (it was written by a build that knew fewer settings, such as main's Remove Hot Pixels) is rewritten to state it before a compact record is appended; where that can't be written the library opens all the same and its records state develop settings whole until a snapshot is written (writing_full). The two decisions Journal::open makes about an old or incomplete library moved into Upgrade::at_open and Journal::restate_defaults (the workspace's cognitive-complexity limit, Enforce Rust coding standards via Clippy #3111, is 30 and open had reached 35); behavior is unchanged.
  • A snapshot refers to its shared mask grids once (stored.rs, journal.rs). Main's snapshots keep each AI mask's grid once, in a table the masks refer to (History steps store a full copy of every segmentation mask (98 % of catalog.snap) #2154), and the stored form keeps, per thread, the last difference it worked out for the next settings equal to them. A record that had just stated some settings (an edit's SetDevelop, appended on the thread that then compacts), or a to_snapshot(), left it holding them with their grid inline, and the snapshot write took it and wrote the grid again beside the table. Four of main's own tests_grids tests failed on it once the records were compact. write_snapshot_owned now forgets the kept difference before the write (stored::forget_last_difference). I did not show a reference into the table reaching a log record: settings that hold a mask that refers to the table don't read back from their difference, so they are written whole and nothing is kept for them.
  • Docs: docs/catalog-persistence.md ("The stored form", the masks of a snapshot, and what an upgrade that can't be written now does) and docs/whats-new.md.
  • Tests: the photo- and log-level tests of the stored form (tests_stored.rs), the format 14 fixture (v14-catalog.*: the fixture of the earlier heads, written by the build that had these records as format 10, with its snapshot header's version restamped), the refusal rules (tests_format_version.rs) and the shared grids (tests_grids.rs: a_snapshot_shares_the_grid_of_settings_a_record_just_stated). The tests the commits below have of a library in format 6 whose upgrade is put off at open and done by a later snapshot (in tests_format_version.rs, and two in the engine's tests/persist.rs with their helpers: the 75 lines this part deletes there) are not kept here: a format before 14 that can't be upgraded is refused now, so there is no such library, and two tests of that refusal replace them. The three settings-only tests that PERF-CATALOG: develop settings can be stored as their difference from the defaults (stacked on #2951) #2957 now holds (a_value_read_all_or_nothing_is_stored_whole, every_develop_setting_survives_on_its_own, a_pen_pressure_is_stored_with_the_digits_it_has) are no longer repeated here.
  • a_v6_library_loads_and_is_upgraded holds the stored form (the catalog as to_snapshot() writes it, with the defaults the file states) to under half of the old library's size, and the rewritten file to being smaller: under main's shared grids a snapshot writes the settings that hold a mask whole (see Not in this PR).

Measured before the restack of 7 Nov (not run again since), a synthetic 4032x3024 JPEG photo with no metadata: 3,232 bytes in the public form, 191 bytes stored; one with an exposure edit and a one-letter title: 3,233 and 236 (cargo test, one photo each; a photo with camera metadata is larger by what that holds, as before). The format 6 fixture library (three photos, two of them with a mask) is 39,550 bytes as it was written (snapshot 28,524, log 11,026): rewritten as a snapshot 25,291 bytes, and 16,360 as the stored form without the table of shared grids. I did not measure a library of real photos for this PR.

Not in this PR: compaction by snapshot size (#800 part 1), and storing the settings that hold an AI mask as a difference in a snapshot: a snapshot's masks refer to its table of shared grids (#2154), which a difference from the defaults can't read back, so those settings (a photo's, its history steps' and versions') are written whole in a snapshot, as on main; the log's records and the settings without a mask are compact. Also not here, a known limit: at format 14 every older library takes Upgrade::Must (14 is both the current format and the first with compact records), so Upgrade::at_open never returns May (a library whose upgrade is put off at open) and the code that keeps a library's files for a later snapshot (behind, keep_before_upgrade, take_kept, note_upgrade_kept) is unreachable and has no test here; it goes live, untested, with the next format. When format 15 lands, bring back the two later-snapshot tests on a v14 fixture.

How it was checked

  • cargo xtask ci passes on this branch, rebased on current main: not run locally for this draft (the hosted CI gate runs it once its parents have landed); at 7993cab1cb (7 Nov) clippy with -D warnings and cargo fmt --all --check pass, cargo test -p lightcraft-catalog passes (372 passed, 4 ignored, and 1 passed in path_fold_heap) and cargo test -p lightcraft-engine --lib persist passes (29 passed); cargo check --workspace --all-targets passes at 0ed0782fc0
  • A test that fails without this change. For the shared grids: on the commit before e84fa468ce (measured before the restack of 7 Nov, not run again since) with only the new test added to tests_grids.rs, five tests fail on their assertions and six pass: a_snapshot_shares_the_grid_of_settings_a_record_just_stated (the grid is written 3 times, where one is expected) and four of main's own, snapshot_deduplicates_shared_grid, versions_share_the_grid_too and v9_catalog_with_inline_grids_loads_and_is_upgraded (3 against 1) and import_look_masks_share_the_table_and_resolve_on_load (2 against 1); all pass with the last commits. For the compact records, on an earlier head (the figure this body had before the rebase of 7 Nov; not run again since): on PERF-CATALOG: develop settings can be stored as their difference from the defaults (stacked on #2951) #2957's code with this part's test files and the fixture added (and LoadReport::defaults_added given its shape, always false), 15 tests failed on their assertions: an_untouched_photo_is_stored_without_defaults (the record has every field, as_shot_wb to width, where it should have develop, file_name, format, height, id, imported, source, width), the_record_of_an_untouched_photo_is_pinned, metadata_is_stored_field_by_field, develop_settings_are_stored_as_their_difference_from_the_defaults, log_records_read_back_exactly_and_are_stored_compactly, the_rendering_process_survives, a_negative_zero_survives, a_v6_library_loads_and_is_upgraded, a_library_written_with_other_defaults_reads_as_it_was_written, a_library_that_lacks_newer_settings_is_restated_before_a_compact_record_is_appended (the open report says defaults_added: false), a_library_whose_defaults_cannot_be_restated_writes_whole_records_until_it_can, a_library_that_cannot_be_kept_is_not_opened, a_new_library_that_cannot_be_written_is_not_opened, a_format_9_library_that_states_defaults_is_refused_when_it_cannot_be_upgraded (these three panic on refused: the library opens) and a_failed_upgrade_leaves_no_copy (the test of format 9 is stamped 12 and renamed a_library_before_compact_records_that_states_defaults_is_refused_when_it_cannot_be_upgraded since)
  • User-visible change: ran the app and looked at the result: not run; nothing changes on screen (the library is smaller on disk and is upgraded on first open, with the existing note about the kept files)

Catalog compatibility both ways, with a throwaway test (not committed) on three builds, from the format-6 fixture (upgraded, two sessions on top), run at 1b75b6d037 (catalog formats 9 and 10 then; not run again at this head, where they are 12 and 14): the library this branch wrote was format 10 and origin/main (03c88c166c, catalog format 9) refused it with Newer("catalog.snap is catalog format v10; this version reads catalog format v9 and older") and changed nothing (the files were byte for byte what they were); a library origin/main wrote (format 9, no stated defaults) opened on this branch, was upgraded to 10 with its own pair kept (catalog.snap.v9-3, catalog.log.v9-3) and had the same photos, ratings, flags, labels and paths; a library #2948 wrote (format 9, stating defaults) did the same (catalog.snap.v9-11); and this branch reopened its own library with nothing upgraded and the same photos. Re-run on 26 Oct at 0634842c6e (after the rebase onto #2948's new head) with a throwaway probe built into the format 9 (origin/main bb08a697a4) and this build: a library this build wrote (format 6 fixture, two sessions) was refused by the format 9 build with every file unchanged, and a library the format 9 build wrote (same steps) was upgraded by this build, keeping catalog.snap.v9-10 byte for byte (the second session ended with a compaction, so there was no log), with the same photos. At this head newer_snapshot_is_refused_untouched holds that a library in a newer format is refused with every file unchanged, and every_format_has_a_fixture_that_opens_as_it_was that the fixtures of formats 6 to 9 and 14 open as the libraries they were.

Before the rebase of 7 Nov, three reviews with a clean context read the diff. The first found no bugs in the code and two wording gaps (a tests doc that still said nothing writes the stored form, and the refusal of a new library that can't be written was not in the docs), fixed. The second found that nothing tested the refusal of a format 9 library that already states defaults (the from < COMPACT_RECORDS rule: removing it passed every test), and the test above was added (it fails with that term removed: the library opens); and two wording nits in the docs, fixed. The third read the rebase of the whole stack and the final wording and found only text to fix, which is fixed.

The review of the rebased branch (7 Nov, a reviewer with a clean context, two rounds) read origin/main to this PR's head as it was then and found two things that mattered, both fixed (the two damaged-log tests in the engine's tests/persist.rs had been lost with the put-off-upgrade ones: back, and passing; five comments and one test name still said format 9 for "the last format before compact records": now 12). It found nothing wrong in the fix of the shared grids, the formats table or the hand-resolved hunks, and its second round found nothing more to fix. Known limits it listed: no test opens a library stamped 10, 11 or 13 (12 is tested), and the comment on SPOKEN_FOR in tests_format_version.rs says the change that lands takes its number off the list, which holds only if #3166 lands first (see Merging).

On 7 Nov the chain was restacked on #2867's two new commits (c54c05c103, 6e91bf4a77: a kept file is never replaced or removed by an upgrade that did not write it, and the two later fixes to its docs and tests), which answer CodeRabbit's review of the stack. Conflicts with this PR's code were in tests and docs: 55c2806d0b (now a57bf8826a) kept this PR's text and tests, with #2867's browser-store test and damaged-log tests in the engine's tests/persist.rs (the later-upgrade tests stay dropped, see above). Two commits are new since the review above: 0ed0782fc0 (the two damaged-log tests are back, and the format numbers in five comments say 12) and 7993cab1cb (four of #2867's kept-file tests opened an older library that, at format 14, can neither be kept nor upgraded, and expected it to open: they fail with the refusal this PR makes of it, and now expect that refusal). Checks at 7993cab1cb: clippy with -D warnings and cargo fmt --all --check clean, cargo test -p lightcraft-catalog (372 passed, 4 ignored) and cargo test -p lightcraft-engine --lib persist (29 passed); cargo check --workspace --all-targets at 0ed0782fc0.

Review: deep-reviewer at 7993cab (7 Nov, the restack of the whole chain onto #2867's two new commits and 7993cab1cb: no P1/P2; its two P3s: the later-upgrade path is unreachable at format 14 and untested, said under "Not in this PR" above, and a blank line in journal.rs removed in e84fa468ce and restored in 0ed0782fc0, left as it is)

Screenshots

None; nothing changes on screen.

Merging

Checklist

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • 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

@nledford
nledford force-pushed the catalog-snapshot-scale-p4b2 branch from e04b249 to 0634842 Compare October 26, 2026 07:56
@nledford
nledford force-pushed the catalog-snapshot-scale-p4b2 branch 2 times, most recently from 5c803aa to 7ef23c5 Compare October 27, 2026 15:08
nledford added a commit to nledford/lightcraft that referenced this pull request Oct 27, 2026
@nledford
nledford force-pushed the catalog-snapshot-scale-p4b2 branch from 7ef23c5 to c93d578 Compare October 30, 2026 11:27
nledford added a commit to nledford/lightcraft that referenced this pull request Oct 30, 2026
…compact records (storytold#2968, c93d578)

# Conflicts:
#	crates/catalog/src/lib.rs
#	crates/catalog/src/store.rs
@nledford
nledford force-pushed the catalog-snapshot-scale-p4b2 branch from c93d578 to 24ba2c5 Compare October 30, 2026 12:45
nledford added a commit to nledford/lightcraft that referenced this pull request Oct 30, 2026
…compact records (storytold#2968, 24ba2c5)

# Conflicts:
#	crates/catalog/src/lib.rs
#	crates/catalog/src/store.rs
@nledford
nledford force-pushed the catalog-snapshot-scale-p4b2 branch from 24ba2c5 to 2a51d02 Compare October 30, 2026 14:13
nledford added a commit to nledford/lightcraft that referenced this pull request Oct 30, 2026
…compact records (storytold#2968, 2a51d02)

Journal::open is split under the cognitive-complexity limit (storytold#3111): the log tail trim and the restating of the develop defaults are their own functions, as they were in the merge before this rebase.
nledford and others added 8 commits November 7, 2026 16:41
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>
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.
…n't be kept leaves nothing lying about

FsStore::write_atomic left `<name>.tmp` behind when the write, the sync or the rename failed, and write_atomic_with left it when the rename failed. The files an upgrade keeps are written through it, so a full disk or a taken name left a partial `catalog.snap.v6-8.tmp` beside the library, against the documented all-or-nothing keep and "no copy left lying about". Both now remove the staging file on any failure.

Co-Authored-By: Claude <noreply@anthropic.com>
…s: the files kept at open stay, as they were then
…when the log can't be replaced, and what a later snapshot keeps
…renames a kept catalog.log.damaged-<seq> like any kept log
… the desktop app keeps the copy

The entry said a library "saved by an earlier version" is upgraded, but an earlier
version can write the same catalog format, and opening such a library upgrades
nothing and keeps nothing. It now says a library saved in an older catalog format,
and the versions that can't open it afterward are the ones that don't know the
new format. The first paragraph of docs/catalog-persistence.md had the same
condition and now says it the same way.

The entry also said the library as it was is kept, but the browser build keeps no
copy (FilesStore::keeps_replaced_formats is false there). It now says the desktop
app keeps it and the browser build doesn't, as docs/catalog-persistence.md does.
The reworded sentence says "afterward", the American spelling.

Co-Authored-By: Claude <noreply@anthropic.com>
@nledford
nledford force-pushed the catalog-snapshot-scale-p4b2 branch from 2a51d02 to 891ddcf Compare November 7, 2026 22:12
@nledford nledford changed the title PERF-CATALOG: catalog records state only what was set (catalog format 10) (stacked on #2957) PERF-CATALOG: catalog records state only what was set (catalog format 14) (stacked on #2957) Nov 7, 2026
nledford and others added 12 commits November 7, 2026 18:04
…ere; the notice for a damaged log needs a store that keeps files; the doc says when the log is fsynced

The kept names (`catalog.snap.v<format>-<seq>`, `catalog.log.v<format>-<seq>`)
can be reached twice by a library restored from an older backup. `keep_replaced`
now reads the name first: a free name is written, the same bytes are the copy
already, other bytes make both names of the set end `-2` (then `-3`, up to 100
sets, then the upgrade is refused). Only what the call wrote is removed when
the upgrade does not happen, including a name whose write reported an error
(a rename that landed all the same).

`LoadReport::kept_files` says the store keeps what an upgrade replaces; the
notice for a damaged log needs it, so the browser's store, which keeps no
snapshot to go with the log, no longer says the library "as it was" is kept.

The persistence doc says the log is fsynced right after the command returns
natively, and the kept-file naming. A test locked `files` twice in one
assertion.
…d log keeps its own name, and the log is written by its thread; two tests for the sets that are in the way

The module docs and the persistence page named "no copy left" where a copy kept
before stays, said "never left behind under other names" without the `-2`
case, and the page said the log is appended before the command returns while
the log's thread writes and fsyncs it. They now say what the code does, and
that the damaged log's own name (`catalog.log.damaged-<seq>`) is written as it
always was.

New tests: a set whose snapshot is this very one but whose log holds other
bytes moves both files to `-2` (it fails without clearing the plan between
sets), and a hundred sets in the way refuse the upgrade without writing or
removing anything. The directory test puts the directory at the second file's
staging name, so the first copy is written and removed again.
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.
…s the changed values out, and Journal::open's docs list the refusal when the rewrite can't be written
…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>
… to 12) and the number spoken for

The module docs said every format from 6 on has a fixture while the test exempts the
formats that came with main from builds whose libraries are not kept, and a number that
is spoken for but not here yet. The rule now says so. Comments only.

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-12 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 14 is the first that leaves values out, so a library that is in a format
before 14 (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 14 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.

Main took formats 10 to 12 (masks on the photo, the lens database, shared
segmentation grids) and storytold#3166 has asked for 13 (FolderRecord.made), which is not
in this build yet: its row is in FORMATS as spoken for (`here: false`, listed in
SPOKEN_FOR), so nothing else takes it, and compact records are 14. The fixture is
v14-catalog.*: only its snapshot header says 14 (it was written by the build that
had these records as format 10). Main's three formats have no fixture here. The
stored form of the metadata states main's new fields too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rgets its last difference before the write

Main's snapshots keep each AI mask's grid once, in a table the masks refer
to (storytold#2154). The stored form of develop settings keeps the last difference
it worked out for the next settings equal to them, per thread. A record
that had just stated some settings (an edit's SetDevelop, appended on the
thread that then compacts) or a to_snapshot() left it holding them with
their grid inline, and the snapshot write took it and wrote the grid again
beside the table, for every photo and step equal to those settings. Four
of main's tests_grids tests failed on it (the grid written 3 times, or 2,
where one is expected).

write_snapshot_owned now forgets the kept difference before the write
(stored::forget_last_difference). What is worked out inside the write
can't carry a reference into the table to a record written later:
settings with a mask that refers to it don't read back from their
difference, so they are written whole and nothing is kept for them.

Test: a_snapshot_shares_the_grid_of_settings_a_record_just_stated
(failed: the grid 3 times, expected once).

For the same reason, settings that hold a mask are written whole in a
snapshot, so a_v6_library_loads_and_is_upgraded no longer expects the
rewritten file to be under half the old size (25,291 bytes against
39,550, two of the fixture's three photos hold a mask): the file has to be
smaller, and the stored form, with the defaults the file states, is still
held to half (16,360 bytes). docs/catalog-persistence.md says so.

Also, to pass what main has since the branch was started: Journal::open's
two decisions about an old or incomplete library (Upgrade::at_open,
Journal::restate_defaults) move out of it, since the workspace's
cognitive-complexity limit (storytold#3111) is 30 and it was 35, and the last blank
line of tests_stored.rs goes (rustfmt). The commit before this one fails
the four tests, the size test, clippy and rustfmt on its own.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ve comments say 12

The review of the rebase found two things.

crates/engine/src/tests/persist.rs had lost two of storytold#2867's tests along with the
two of an upgrade put off at open: an_upgraded_library_with_only_a_damaged_log_says_where_the_log_is_kept
and a_current_library_with_a_damaged_log_is_not_told_it_was_upgraded, with their
helper damaged_v6_log. Neither needs an upgrade that is put off: the first opens a
library of an earlier format that has only a damaged log, the second one in the
current format. They are back as they were.

"Format 9" meant the last format before compact records, which is 12 now. The
comments in journal.rs (the upgrade's doc, and the rule about fixtures, which now
names the formats that have none), stored.rs and tests_stored_settings.rs say so.
The test of the refusal of a library that states defaults and can't be upgraded is
stamped 12 instead of 9 and renamed
a_library_before_compact_records_that_states_defaults_is_refused_when_it_cannot_be_upgraded,
so the rule from < COMPACT_RECORDS is tried with a format a library can be in.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…be kept or upgraded expect the refusal this PR makes of it

Four tests added by the kept-file fixes on storytold#2867 (a hundred sets in the way, an upgrade
that is not written, with a set that was in the way, a kept file that landed despite an
error) opened a format-6 library and expected it to open as it was. Here a library before
the compact records is refused when its files can't be kept or it can't be upgraded, so they
expect that error, with the same assertions on the files left in the folder.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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