Skip to content

smart previews: store proxies at JPEG quality 97 and version the encoding (#709) - #850

Merged
echelon merged 1 commit into
storytold:mainfrom
eliets2:claude/issue-709-proxy-encode-version
Oct 13, 2026
Merged

echelon merged 1 commit into
storytold:mainfrom
eliets2:claude/issue-709-proxy-encode-version

Conversation

@eliets2

@eliets2 eliets2 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Bug: Proxy previews carried a visible error against the original, as reported in #709. Its dominant term is the JPEG-quantised 8x8 DCT DC (each block's own mean, on luma and chroma), which walks block steps across the frame plus a small constant colour shift that grows with saturation.

Cause: At quality 92 the DC coefficient of each 8x8 block is quantised coarsely enough that its deviation shows as a per-block step.

Fix: Proxy JPEG quality goes from 92 to 97 (block-mean dE76 0.138 vs 0.202 on the fidelity test's smooth scene; about twice the file size). The proxy header gains enc (encode version 2) and the folder's look marker becomes <look> <enc>. A proxy or marker written before the encode version is treated as stale. Old files still decode bit-identically (decode ignores enc), and a proxy from a newer build is left alone by an older one, so there is no rebuild loop.

What this does not cover (please read): the refresh that runs when a library is opened only looks at the proxies of raw files that take the per-file camera look, the only ones the camera-look fit reaches. JPEG, PNG, TIFF and DNG proxies, and raws that do not take the per-file look, are not rebuilt by it, and a proxy whose original is offline is kept as it is. Build Smart Previews rebuilds a stale proxy once its original is readable. So an existing library ends up with a mix of quality-97 and older proxies until Build Smart Previews has run; it does not become uniform by itself, and I have not claimed that it rebuilds exactly once.

Tests: a frozen copy of the old encoder plus a block-mean dE76 metric (per-pixel dE is dominated by the shared 8-bit sRGB floor); the 0.8 bound is the geometric midpoint between the no-op ratio 1.000 and the 0.632 floor, and the metric measured 1.000 at q92 and 0.683 at q97. An encode-version staleness test covers the rebuild trigger. smart_preview_look_marker_is_read_safely was written for the one-number marker and failed on this change (the legacy 2\n marker now counts as unchecked on purpose); it now covers the legacy marker, an older encode version, a damaged second field, the current versions and newer ones.

Verified (Windows, rebased on main at 701f78ea, -j 4):

  • cargo fmt --check: pass.
  • cargo clippy -p lightcraft-engine --all-targets -D warnings: pass, with one lint allowed (clippy::chunks_exact_to_as_chunks), which fires on this toolchain in crates/pipeline/src/spots.rs, a file this PR does not touch.
  • cargo test -p lightcraft-engine --lib: 751 passed, 20 failed, 5 ignored. The 20 failures are in sidecar, rename, tests_filesystem_history and tests_folders, none of which this PR touches; the ones I read compare Archive\Trip with Archive/Trip (Windows path separators). I did not run them on a clean main, so I cannot say for certain that they fail there too. Every smart and import test passes.

Not verified: a real library rebuild by hand; the failing sidecar tests on main; Linux and macOS.

Honest note: the 8-bit ceiling means full edit-from-preview parity needs a lossless proxy format, which is out of scope here.

…ding (storytold#709)

The proxy's largest visible error against the original was the JPEG encoder's
quantised 8x8 DCT DC - each block's own mean, luma and chroma - which shows as
block steps across the frame and a small constant colour shift, and grows with
saturation. Quality 92 -> 97 shrinks those quantisers to about a third (block
-mean dE76 0.138 vs 0.202 on the fidelity test's smooth scene), at about twice
the file size; what remains is the 8-bit sRGB quantisation both encoders share,
which only a lossless proxy format can close.

The header gains an `enc` field (encode version 2) and the folder's look marker
becomes "<look> <enc>": a proxy or marker from before the encode version is
rebuilt/rescanned once, so existing libraries pick the new quality up without
any command. Old files still decode bit-identically (the scale mapping is
untouched, decode ignores `enc`), and a new proxy read by an older build is
left alone by its staleness check.

The fidelity test pins the gain with a frozen copy of the old encoder and a
block-mean dE76 metric (per-pixel dE is dominated by the shared 8-bit floor);
the 0.8 bound is the geometric midpoint between the no-op ratio 1.000 and the
0.632 floor cap the 8-bit quantisation sets on this scene.
@eliets2
eliets2 force-pushed the claude/issue-709-proxy-encode-version branch from 1f80944 to a10bc04 Compare October 13, 2026 02:01
@echelon
echelon merged commit 643bc7f into storytold:main Oct 13, 2026
@echelon

echelon commented Oct 13, 2026

Copy link
Copy Markdown
Member

Landed on main in #1438 — thank you, @eliets2, for the contribution! If you haven't already, come join us on Discord: https://discord.gg/artcraft

AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 13, 2026
… to Compact proxies only (storytold#709)

With PR storytold#850 merged, Compact proxies are stored at JPEG quality 97 and a
Compact header records its encode version (`enc: 2`); one from an older
encoding is rebuilt like one from an older camera look. The Lossless header
uses the same `enc` field for its own format version (1), which reading the
file checks, so `is_stale` applies the encode version to Compact proxies only
(resolved in the first two commits of this branch while rebasing onto it).
storytold#850's rebuild replaces a usable proxy, so it goes through the thumbnail
marker and the per-replacement clear like a look refresh.

Test: a photo with the per-file camera look; its Compact proxy from before
the encode version is rebuilt once, then its Lossless proxy is kept by Build
and by the opening scan of a folder checked before the encode version.
Docs: Compact's quality, encode version and sizes, and Lossless's own `enc`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 14, 2026
… downgrade a newer proxy (storytold#1328 review)

Review of 52f6b7e8:

P2. A pixel next to a strongly coloured clipped highlight (the blue sample
at an orange sun's rim, a neon tube's edge) had its interpolated channels
rebuilt from its weakest, measured channel, mostly with a neutral colour
where the content around was clipped: a dark checkerboard line just inside
the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The
rebuild may now darken a pixel only to 0.8 of the luminance its
reconstruction told by value gives (highlight::CONTINUITY), else it keeps
the latter; it may brighten it by as much among strongly coloured content,
and further among pale content (a white sky behind twigs, where the value
keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the
neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either
frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D
twigs stay dark. Treating only the channels with their own FROM bit as
unknown was tried: the mean colour spread around clipped areas went from
under 3 % to 8.5 % and X-Trans lifted dark lines, so the other
interpolated channel stays unknown with them.

P2. Build Smart Previews rebuilt a stale proxy from the session's source,
which is the old proxy's when it was decoded while the original was
offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded
sources and rendered previews made from the old one. On storytold#1400 both are
covered by its machinery, which this commit uses instead of its own: jobs
read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's
invalidation (a marker before the first change, the thumbnail clear at the
end of the run, decoded sources following the cache generation, late
results refused by generation). The tests below pass on it.

P2. A refresh rewrote a proxy whose other version came from a newer build
(look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and
leaves any proxy with a newer one alone; the folder markers only go up.
With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the
same way (smart::from_newer_build), staleness for the look includes an
older Compact encoding (storytold#850's is_stale), and the look marker keeps its two
versions, each never going back.

P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains
64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one
that is not finite, or whose magnitude times the largest gain (or divided
by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read
afresh, develop unbalanced. The MAX_GAIN doc no longer claims more.

P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and
X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes).

Tests: coloured suns and tubes keep their brightness at the edges (every
method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops
unbalanced and finite (1.5e28 at the extreme gains balanced and finite),
both failing on 52f6b7e8; proxies with a newer look or source version are
never rewritten and the markers stay, failing without this commit. Build
Smart Previews refreshes with the old proxy still cached, and a refreshed
proxy replaces the session's source, cached render and late results and
the reopened library's: these pass through storytold#1400's machinery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 14, 2026
…wer build (storytold#1328 review)

Review of 0accb271: a format mismatch bypassed the forward-version guard.
smart_run ORed Ages::stale with "stored format differs from the one to
build", so an ordinary Build Smart Previews (no format asked for) rebuilt
a Lossless proxy under the default Compact preference, or a Compact one
under a Lossless preference, with this build's older look or decode and
stamped its versions: (look + 1, 0), (look - 1, source + 1) and
(look + 1, source + 1) all became (5, 1) in the other format. The opening
refresh kept them already.

A usable proxy is now classified first: one from a newer build
(smart::from_newer_build: its look or source version, or a Compact
proxy's encode version from storytold#850, above this build's) is kept as
it is, in its stored format, whatever format is preferred or asked for,
and counted as newerKept in the result; only a current or older one is
considered for a format conversion. A deliberate downgrade is not offered
(Discard removes the proxy). Ages::stale uses the same check.
source_version stays a field the writer owns.

Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and
storytold#850): LOOK_VERSION is 5 there (storytold#1340), so this build writes look 5 /
source 1 (and Compact enc 2), which a build from main at look 5 takes as
current; RENDER_CACHE_VERSION goes to 65 (main is at 62).

Test: proxies at those three version pairs (and a Compact proxy from a
newer encoding) survive the opening refresh and Build Smart Previews for
both stored formats under both preferences, and are reported as newerKept
(6 of the 12 version-pair cases were rewritten before; the encoding case
is rewritten without its check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 14, 2026
… to Compact proxies only (storytold#709)

With PR storytold#850 merged, Compact proxies are stored at JPEG quality 97 and a
Compact header records its encode version (`enc: 2`); one from an older
encoding is rebuilt like one from an older camera look. The Lossless header
uses the same `enc` field for its own format version (1), which reading the
file checks, so `is_stale` applies the encode version to Compact proxies only
(resolved in the first two commits of this branch while rebasing onto it).
marker and the per-replacement clear like a look refresh.

Test: a photo with the per-file camera look; its Compact proxy from before
the encode version is rebuilt once, then its Lossless proxy is kept by Build
and by the opening scan of a folder checked before the encode version.
Docs: Compact's quality, encode version and sizes, and Lossless's own `enc`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
… to Compact proxies only (storytold#709)

With PR storytold#850 merged, Compact proxies are stored at JPEG quality 97 and a
Compact header records its encode version (`enc: 2`); one from an older
encoding is rebuilt like one from an older camera look. The Lossless header
uses the same `enc` field for its own format version (1), which reading the
file checks, so `is_stale` applies the encode version to Compact proxies only
(resolved in the first two commits of this branch while rebasing onto it).
marker and the per-replacement clear like a look refresh.

Test: a photo with the per-file camera look; its Compact proxy from before
the encode version is rebuilt once, then its Lossless proxy is kept by Build
and by the opening scan of a folder checked before the encode version.
Docs: Compact's quality, encode version and sizes, and Lossless's own `enc`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
… downgrade a newer proxy (storytold#1328 review)

Review of 52f6b7e8:

P2. A pixel next to a strongly coloured clipped highlight (the blue sample
at an orange sun's rim, a neon tube's edge) had its interpolated channels
rebuilt from its weakest, measured channel, mostly with a neutral colour
where the content around was clipped: a dark checkerboard line just inside
the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The
rebuild may now darken a pixel only to 0.8 of the luminance its
reconstruction told by value gives (highlight::CONTINUITY), else it keeps
the latter; it may brighten it by as much among strongly coloured content,
and further among pale content (a white sky behind twigs, where the value
keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the
neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either
frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D
twigs stay dark. Treating only the channels with their own FROM bit as
unknown was tried: the mean colour spread around clipped areas went from
under 3 % to 8.5 % and X-Trans lifted dark lines, so the other
interpolated channel stays unknown with them.

P2. Build Smart Previews rebuilt a stale proxy from the session's source,
which is the old proxy's when it was decoded while the original was
offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded
sources and rendered previews made from the old one. On storytold#1400 both are
covered by its machinery, which this commit uses instead of its own: jobs
read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's
invalidation (a marker before the first change, the thumbnail clear at the
end of the run, decoded sources following the cache generation, late
results refused by generation). The tests below pass on it.

P2. A refresh rewrote a proxy whose other version came from a newer build
(look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and
leaves any proxy with a newer one alone; the folder markers only go up.
With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the
same way (smart::from_newer_build), staleness for the look includes an
older Compact encoding (storytold#850's is_stale), and the look marker keeps its two
versions, each never going back.

P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains
64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one
that is not finite, or whose magnitude times the largest gain (or divided
by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read
afresh, develop unbalanced. The MAX_GAIN doc no longer claims more.

P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and
X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes).

Tests: coloured suns and tubes keep their brightness at the edges (every
method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops
unbalanced and finite (1.5e28 at the extreme gains balanced and finite),
both failing on 52f6b7e8; proxies with a newer look or source version are
never rewritten and the markers stay, failing without this commit. Build
Smart Previews refreshes with the old proxy still cached, and a refreshed
proxy replaces the session's source, cached render and late results and
the reopened library's: these pass through storytold#1400's machinery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
…wer build (storytold#1328 review)

Review of 0accb271: a format mismatch bypassed the forward-version guard.
smart_run ORed Ages::stale with "stored format differs from the one to
build", so an ordinary Build Smart Previews (no format asked for) rebuilt
a Lossless proxy under the default Compact preference, or a Compact one
under a Lossless preference, with this build's older look or decode and
stamped its versions: (look + 1, 0), (look - 1, source + 1) and
(look + 1, source + 1) all became (5, 1) in the other format. The opening
refresh kept them already.

A usable proxy is now classified first: one from a newer build
(smart::from_newer_build: its look or source version, or a Compact
proxy's encode version from storytold#850, above this build's) is kept as
it is, in its stored format, whatever format is preferred or asked for,
and counted as newerKept in the result; only a current or older one is
considered for a format conversion. A deliberate downgrade is not offered
(Discard removes the proxy). Ages::stale uses the same check.
source_version stays a field the writer owns.

Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and
storytold#850): LOOK_VERSION is 5 there (storytold#1340), so this build writes look 5 /
source 1 (and Compact enc 2), which a build from main at look 5 takes as
current; RENDER_CACHE_VERSION goes to 65 (main is at 62).

Test: proxies at those three version pairs (and a Compact proxy from a
newer encoding) survive the opening refresh and Build Smart Previews for
both stored formats under both preferences, and are reported as newerKept
(6 of the 12 version-pair cases were rewritten before; the encoding case
is rewritten without its check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
… to Compact proxies only (storytold#709)

With PR storytold#850 merged, Compact proxies are stored at JPEG quality 97 and a
Compact header records its encode version (`enc: 2`); one from an older
encoding is rebuilt like one from an older camera look. The Lossless header
uses the same `enc` field for its own format version (1), which reading the
file checks, so `is_stale` applies the encode version to Compact proxies only
(resolved in the first two commits of this branch while rebasing onto it).
marker and the per-replacement clear like a look refresh.

Test: a photo with the per-file camera look; its Compact proxy from before
the encode version is rebuilt once, then its Lossless proxy is kept by Build
and by the opening scan of a folder checked before the encode version.
Docs: Compact's quality, encode version and sizes, and Lossless's own `enc`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
… downgrade a newer proxy (storytold#1328 review)

Review of 52f6b7e8:

P2. A pixel next to a strongly coloured clipped highlight (the blue sample
at an orange sun's rim, a neon tube's edge) had its interpolated channels
rebuilt from its weakest, measured channel, mostly with a neutral colour
where the content around was clipped: a dark checkerboard line just inside
the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The
rebuild may now darken a pixel only to 0.8 of the luminance its
reconstruction told by value gives (highlight::CONTINUITY), else it keeps
the latter; it may brighten it by as much among strongly coloured content,
and further among pale content (a white sky behind twigs, where the value
keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the
neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either
frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D
twigs stay dark. Treating only the channels with their own FROM bit as
unknown was tried: the mean colour spread around clipped areas went from
under 3 % to 8.5 % and X-Trans lifted dark lines, so the other
interpolated channel stays unknown with them.

P2. Build Smart Previews rebuilt a stale proxy from the session's source,
which is the old proxy's when it was decoded while the original was
offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded
sources and rendered previews made from the old one. On storytold#1400 both are
covered by its machinery, which this commit uses instead of its own: jobs
read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's
invalidation (a marker before the first change, the thumbnail clear at the
end of the run, decoded sources following the cache generation, late
results refused by generation). The tests below pass on it.

P2. A refresh rewrote a proxy whose other version came from a newer build
(look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and
leaves any proxy with a newer one alone; the folder markers only go up.
With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the
same way (smart::from_newer_build), staleness for the look includes an
older Compact encoding (storytold#850's is_stale), and the look marker keeps its two
versions, each never going back.

P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains
64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one
that is not finite, or whose magnitude times the largest gain (or divided
by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read
afresh, develop unbalanced. The MAX_GAIN doc no longer claims more.

P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and
X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes).

Tests: coloured suns and tubes keep their brightness at the edges (every
method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops
unbalanced and finite (1.5e28 at the extreme gains balanced and finite),
both failing on 52f6b7e8; proxies with a newer look or source version are
never rewritten and the markers stay, failing without this commit. Build
Smart Previews refreshes with the old proxy still cached, and a refreshed
proxy replaces the session's source, cached render and late results and
the reopened library's: these pass through storytold#1400's machinery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 15, 2026
…wer build (storytold#1328 review)

Review of 0accb271: a format mismatch bypassed the forward-version guard.
smart_run ORed Ages::stale with "stored format differs from the one to
build", so an ordinary Build Smart Previews (no format asked for) rebuilt
a Lossless proxy under the default Compact preference, or a Compact one
under a Lossless preference, with this build's older look or decode and
stamped its versions: (look + 1, 0), (look - 1, source + 1) and
(look + 1, source + 1) all became (5, 1) in the other format. The opening
refresh kept them already.

A usable proxy is now classified first: one from a newer build
(smart::from_newer_build: its look or source version, or a Compact
proxy's encode version from storytold#850, above this build's) is kept as
it is, in its stored format, whatever format is preferred or asked for,
and counted as newerKept in the result; only a current or older one is
considered for a format conversion. A deliberate downgrade is not offered
(Discard removes the proxy). Ages::stale uses the same check.
source_version stays a field the writer owns.

Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and
storytold#850): LOOK_VERSION is 5 there (storytold#1340), so this build writes look 5 /
source 1 (and Compact enc 2), which a build from main at look 5 takes as
current; RENDER_CACHE_VERSION goes to 65 (main is at 62).

Test: proxies at those three version pairs (and a Compact proxy from a
newer encoding) survive the opening refresh and Build Smart Previews for
both stored formats under both preferences, and are reported as newerKept
(6 of the 12 version-pair cases were rewritten before; the encoding case
is rewritten without its check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eliets2
eliets2 deleted the claude/issue-709-proxy-encode-version branch October 25, 2026 18:40
mattsivak pushed a commit to mattsivak/lightcraft that referenced this pull request Oct 26, 2026
)

PR storytold#1400's eleven commits, squashed while rebasing onto main bb08a69 (main had reworked the
same smart preview code since, so a per-commit replay would have redone each conflict eleven
times):

- add opt-in lossless smart previews
- address lossless preview review
- lossless previews keep the right cache and migrate in the background
- recover thumbnail invalidation at folder commit
- interrupted builds reopen with new thumbnail keys
- a full library drive no longer blocks smart preview work
- repair cut-short Compact proxies again; every proxy change records the marker
- a folder move leaves an undecodable proxy behind; clear per proxy only for replacements
- a thumbnail clear no longer holds up drawing while it removes the files
- a thumbnail written during a clear keeps its size
- PR storytold#850's JPEG encode version applies to Compact proxies only

Store reduced scene-linear source floats in Deflate TIFF while retaining JPEG as the
per-library default. Add build overrides, original-only format conversion, unknown metadata
preservation, cancellable verified folder migration and cache invalidation.

Integration with main:
- Main's decoder-facts tail (storytold#1534, ENCODE_VERSION 3) is shared by both formats: Compact keeps
  it after the JPEG, Lossless after its end marker (format::complete and decode account for
  it); smart::encode / encode_format take the SourceInfo, decode returns it, and
  preserve_header never copies an old `tail` into a rebuilt proxy.
- is_stale_for(path, look): Compact's encode version reaches every photo (main), Lossless keeps
  its own `enc` (storytold#1400); is_valid is is_complete / is_usable.
- Main's preview_fitted_look (DNG tone fits), original_only and DecodedSource from_proxy /
  reduced are kept; Build reads the original through origin_ref as storytold#1400 did.
- The opening refresh looks at every photo now, so tests that change folders right after
  opening wait for it (cmd::previews::wait_for_opening_refresh).
- Locale catalogs merged key by key; build.rs keeps plural forms and main's English fallback
  for missing or empty translations.

Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 28, 2026
… to Compact proxies only (storytold#709)

With PR storytold#850 merged, Compact proxies are stored at JPEG quality 97 and a
Compact header records its encode version (`enc: 2`); one from an older
encoding is rebuilt like one from an older camera look. The Lossless header
uses the same `enc` field for its own format version (1), which reading the
file checks, so `is_stale` applies the encode version to Compact proxies only
(resolved in the first two commits of this branch while rebasing onto it).
marker and the per-replacement clear like a look refresh.

Test: a photo with the per-file camera look; its Compact proxy from before
the encode version is rebuilt once, then its Lossless proxy is kept by Build
and by the opening scan of a folder checked before the encode version.
Docs: Compact's quality, encode version and sizes, and Lossless's own `enc`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 28, 2026
… to Compact proxies only (storytold#709)

With PR storytold#850 merged, Compact proxies are stored at JPEG quality 97 and a
Compact header records its encode version (`enc: 2`); one from an older
encoding is rebuilt like one from an older camera look. The Lossless header
uses the same `enc` field for its own format version (1), which reading the
file checks, so `is_stale` applies the encode version to Compact proxies only
(resolved in the first two commits of this branch while rebasing onto it).
marker and the per-replacement clear like a look refresh.

Test: a photo with the per-file camera look; its Compact proxy from before
the encode version is rebuilt once, then its Lossless proxy is kept by Build
and by the opening scan of a folder checked before the encode version.
Docs: Compact's quality, encode version and sizes, and Lossless's own `enc`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 28, 2026
… downgrade a newer proxy (storytold#1328 review)

Review of 52f6b7e8:

P2. A pixel next to a strongly coloured clipped highlight (the blue sample
at an orange sun's rim, a neon tube's edge) had its interpolated channels
rebuilt from its weakest, measured channel, mostly with a neutral colour
where the content around was clipped: a dark checkerboard line just inside
the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The
rebuild may now darken a pixel only to 0.8 of the luminance its
reconstruction told by value gives (highlight::CONTINUITY), else it keeps
the latter; it may brighten it by as much among strongly coloured content,
and further among pale content (a white sky behind twigs, where the value
keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the
neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either
frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D
twigs stay dark. Treating only the channels with their own FROM bit as
unknown was tried: the mean colour spread around clipped areas went from
under 3 % to 8.5 % and X-Trans lifted dark lines, so the other
interpolated channel stays unknown with them.

P2. Build Smart Previews rebuilt a stale proxy from the session's source,
which is the old proxy's when it was decoded while the original was
offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded
sources and rendered previews made from the old one. On storytold#1400 both are
covered by its machinery, which this commit uses instead of its own: jobs
read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's
invalidation (a marker before the first change, the thumbnail clear at the
end of the run, decoded sources following the cache generation, late
results refused by generation). The tests below pass on it.

P2. A refresh rewrote a proxy whose other version came from a newer build
(look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and
leaves any proxy with a newer one alone; the folder markers only go up.
With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the
same way (smart::from_newer_build), staleness for the look includes an
older Compact encoding (storytold#850's is_stale), and the look marker keeps its two
versions, each never going back.

P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains
64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one
that is not finite, or whose magnitude times the largest gain (or divided
by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read
afresh, develop unbalanced. The MAX_GAIN doc no longer claims more.

P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and
X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes).

Tests: coloured suns and tubes keep their brightness at the edges (every
method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops
unbalanced and finite (1.5e28 at the extreme gains balanced and finite),
both failing on 52f6b7e8; proxies with a newer look or source version are
never rewritten and the markers stay, failing without this commit. Build
Smart Previews refreshes with the old proxy still cached, and a refreshed
proxy replaces the session's source, cached render and late results and
the reopened library's: these pass through storytold#1400's machinery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 28, 2026
…wer build (storytold#1328 review)

Review of 0accb271: a format mismatch bypassed the forward-version guard.
smart_run ORed Ages::stale with "stored format differs from the one to
build", so an ordinary Build Smart Previews (no format asked for) rebuilt
a Lossless proxy under the default Compact preference, or a Compact one
under a Lossless preference, with this build's older look or decode and
stamped its versions: (look + 1, 0), (look - 1, source + 1) and
(look + 1, source + 1) all became (5, 1) in the other format. The opening
refresh kept them already.

A usable proxy is now classified first: one from a newer build
(smart::from_newer_build: its look or source version, or a Compact
proxy's encode version from storytold#850, above this build's) is kept as
it is, in its stored format, whatever format is preferred or asked for,
and counted as newerKept in the result; only a current or older one is
considered for a format conversion. A deliberate downgrade is not offered
(Discard removes the proxy). Ages::stale uses the same check.
source_version stays a field the writer owns.

Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and
source 1 (and Compact enc 2), which a build from main at look 5 takes as
current; RENDER_CACHE_VERSION goes to 65 (main is at 62).

Test: proxies at those three version pairs (and a Compact proxy from a
newer encoding) survive the opening refresh and Build Smart Previews for
both stored formats under both preferences, and are reported as newerKept
(6 of the 12 version-pair cases were rewritten before; the encoding case
is rewritten without its check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 28, 2026
… downgrade a newer proxy (storytold#1328 review)

Review of 52f6b7e8:

P2. A pixel next to a strongly coloured clipped highlight (the blue sample
at an orange sun's rim, a neon tube's edge) had its interpolated channels
rebuilt from its weakest, measured channel, mostly with a neutral colour
where the content around was clipped: a dark checkerboard line just inside
the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The
rebuild may now darken a pixel only to 0.8 of the luminance its
reconstruction told by value gives (highlight::CONTINUITY), else it keeps
the latter; it may brighten it by as much among strongly coloured content,
and further among pale content (a white sky behind twigs, where the value
keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the
neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either
frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D
twigs stay dark. Treating only the channels with their own FROM bit as
unknown was tried: the mean colour spread around clipped areas went from
under 3 % to 8.5 % and X-Trans lifted dark lines, so the other
interpolated channel stays unknown with them.

P2. Build Smart Previews rebuilt a stale proxy from the session's source,
which is the old proxy's when it was decoded while the original was
offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded
sources and rendered previews made from the old one. On storytold#1400 both are
covered by its machinery, which this commit uses instead of its own: jobs
read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's
invalidation (a marker before the first change, the thumbnail clear at the
end of the run, decoded sources following the cache generation, late
results refused by generation). The tests below pass on it.

P2. A refresh rewrote a proxy whose other version came from a newer build
(look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and
leaves any proxy with a newer one alone; the folder markers only go up.
With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the
same way (smart::from_newer_build), staleness for the look includes an
older Compact encoding (storytold#850's is_stale), and the look marker keeps its two
versions, each never going back.

P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains
64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one
that is not finite, or whose magnitude times the largest gain (or divided
by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read
afresh, develop unbalanced. The MAX_GAIN doc no longer claims more.

P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and
X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes).

Tests: coloured suns and tubes keep their brightness at the edges (every
method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops
unbalanced and finite (1.5e28 at the extreme gains balanced and finite),
both failing on 52f6b7e8; proxies with a newer look or source version are
never rewritten and the markers stay, failing without this commit. Build
Smart Previews refreshes with the old proxy still cached, and a refreshed
proxy replaces the session's source, cached render and late results and
the reopened library's: these pass through storytold#1400's machinery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 28, 2026
…wer build (storytold#1328 review)

Review of 0accb271: a format mismatch bypassed the forward-version guard.
smart_run ORed Ages::stale with "stored format differs from the one to
build", so an ordinary Build Smart Previews (no format asked for) rebuilt
a Lossless proxy under the default Compact preference, or a Compact one
under a Lossless preference, with this build's older look or decode and
stamped its versions: (look + 1, 0), (look - 1, source + 1) and
(look + 1, source + 1) all became (5, 1) in the other format. The opening
refresh kept them already.

A usable proxy is now classified first: one from a newer build
(smart::from_newer_build: its look or source version, or a Compact
proxy's encode version from storytold#850, above this build's) is kept as
it is, in its stored format, whatever format is preferred or asked for,
and counted as newerKept in the result; only a current or older one is
considered for a format conversion. A deliberate downgrade is not offered
(Discard removes the proxy). Ages::stale uses the same check.
source_version stays a field the writer owns.

Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and
source 1 (and Compact enc 2), which a build from main at look 5 takes as
current; RENDER_CACHE_VERSION goes to 65 (main is at 62).

Test: proxies at those three version pairs (and a Compact proxy from a
newer encoding) survive the opening refresh and Build Smart Previews for
both stored formats under both preferences, and are reported as newerKept
(6 of the 12 version-pair cases were rewritten before; the encoding case
is rewritten without its check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 28, 2026
… downgrade a newer proxy (storytold#1328 review)

Review of 52f6b7e8:

P2. A pixel next to a strongly coloured clipped highlight (the blue sample
at an orange sun's rim, a neon tube's edge) had its interpolated channels
rebuilt from its weakest, measured channel, mostly with a neutral colour
where the content around was clipped: a dark checkerboard line just inside
the edge (public sunset ARW (2973, 1267): linear Y 0.874 -> 0.213). The
rebuild may now darken a pixel only to 0.8 of the luminance its
reconstruction told by value gives (highlight::CONTINUITY), else it keeps
the latter; it may brighten it by as much among strongly coloured content,
and further among pale content (a white sky behind twigs, where the value
keeps the demosaic's cyan and magenta). That pixel is Y 0.874 again, the
neon's (1491, 1210) 0.912 (main 0.979, 52f6b7e8 0.287); no pixel of either
frame goes from Y > 0.8 to below 0.4 (52f6b7e8: 132 and 495). The Canon 80D
twigs stay dark. Treating only the channels with their own FROM bit as
unknown was tried: the mean colour spread around clipped areas went from
under 3 % to 8.5 % and X-Trans lifted dark lines, so the other
interpolated channel stays unknown with them.

P2. Build Smart Previews rebuilt a stale proxy from the session's source,
which is the old proxy's when it was decoded while the original was
offline: it kept the proxy. P2. A rebuilt proxy left the session's decoded
sources and rendered previews made from the old one. On storytold#1400 both are
covered by its machinery, which this commit uses instead of its own: jobs
read the original afresh (origin_ref), and a replaced proxy takes storytold#1400's
invalidation (a marker before the first change, the thumbnail clear at the
end of the run, decoded sources following the cache generation, late
results refused by generation). The tests below pass on it.

P2. A refresh rewrote a proxy whose other version came from a newer build
(look 5 / source 0 -> 4 / 1). Ages::stale reads both versions together and
leaves any proxy with a newer one alone; the folder markers only go up.
With storytold#850 on storytold#1400, a Compact proxy's encode version (`enc`) counts the
same way (smart::from_newer_build), staleness for the look includes an
older Compact encoding (storytold#850's is_stale), and the look marker keeps its two
versions, each never going back.

P2. Finite samples too large for the scaling (a float DNG of 1e37 at gains
64 : 1 : 1) overflowed. The scaling pass now also checks every sample: one
that is not finite, or whose magnitude times the largest gain (or divided
by the smallest) exceeds 1e30 (MAX_BALANCED), makes the mosaic, read
afresh, develop unbalanced. The MAX_GAIN doc no longer claims more.

P3. Docs: previews bin_factor can't bin are Bayer under about 4600 px and
X-Trans under about 5760 px on the long side (the 16 MP X-E1 changes).

Tests: coloured suns and tubes keep their brightness at the edges (every
method, phase and X-Trans), and a decoded F32 DNG of 1e37 develops
unbalanced and finite (1.5e28 at the extreme gains balanced and finite),
both failing on 52f6b7e8; proxies with a newer look or source version are
never rewritten and the markers stay, failing without this commit. Build
Smart Previews refreshes with the old proxy still cached, and a refreshed
proxy replaces the session's source, cached render and late results and
the reopened library's: these pass through storytold#1400's machinery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AlexChambers added a commit to AlexChambers/lightcraft that referenced this pull request Oct 28, 2026
…wer build (storytold#1328 review)

Review of 0accb271: a format mismatch bypassed the forward-version guard.
smart_run ORed Ages::stale with "stored format differs from the one to
build", so an ordinary Build Smart Previews (no format asked for) rebuilt
a Lossless proxy under the default Compact preference, or a Compact one
under a Lossless preference, with this build's older look or decode and
stamped its versions: (look + 1, 0), (look - 1, source + 1) and
(look + 1, source + 1) all became (5, 1) in the other format. The opening
refresh kept them already.

A usable proxy is now classified first: one from a newer build
(smart::from_newer_build: its look or source version, or a Compact
proxy's encode version from storytold#850, above this build's) is kept as
it is, in its stored format, whatever format is preferred or asked for,
and counted as newerKept in the result; only a current or older one is
considered for a format conversion. A deliberate downgrade is not offered
(Discard removes the proxy). Ages::stale uses the same check.
source_version stays a field the writer owns.

Rebased onto storytold#1400 at cf1c803, which brings main b3d392b (batch 33 and
source 1 (and Compact enc 2), which a build from main at look 5 takes as
current; RENDER_CACHE_VERSION goes to 65 (main is at 62).

Test: proxies at those three version pairs (and a Compact proxy from a
newer encoding) survive the opening refresh and Build Smart Previews for
both stored formats under both preferences, and are reported as newerKept
(6 of the 12 version-pair cases were rewritten before; the encoding case
is rewritten without its check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants