* codecs,raw,preview,meta,engine: cut over TIFF/JPEG/focus to craft-libs and fix CI
* docs: update parity-checklist paths after craft-raw/craft-metadata cutover
* Remove unused codec workspace deps and cut examples over to craft-image-codecs
* chore: update Cargo.lock after removing unused codec deps
* security: importers and preset application index instead of rescanning
* address review: keep first match when indexing names, skip used mask ids, move presets instead of cloning
* address review: a dry-run import keeps its rows, not the parsed presets
* merge main into fix/sec-importers-indexed
* address review: key duplicate presets by the settings value, so 0.0 and -0.0 are one preset
* preset import index: key numbers as f64 so 0 and 0.0 cannot collide
* security(pipeline): one dab budget per brush mask; linear-time defringe min/max
* address review: drop min_filter transpose buffers once consumed
* address review: an over-budget brush mask fails the render instead of dropping later strokes
* merge main into fix/sec-pipeline-render-work; the web worker rejects an over-budget brush mask
* address review: validate brush budgets on the mask's own frame; an exactly filled budget is not over it
* security(meta): bound namespace declarations in scope while parsing XMP
* address review: a readable sidecar that fails the merge read-back is kept and the save fails
* address review: a sidecar over the XMP complexity limit is kept and the save fails
* merge main into fix/sec-xmp-namespace-bound
* address review: text with no rdf:RDF element is backed up and replaced, not kept as readable
* xmp merge: open a self-closing rdf:RDF element instead of replacing the sidecar
Use craft-gainmap from craft-libs for gain map metadata and arithmetic
* Use craft-heif from craft-libs; remove crates/heif
lightcraft-heif moved to craft-libs unchanged as craft-heif
(storytold/craft-libs#784), so PhotoCraft can share it. The layer table,
the heif CI step and the change triggers drop the local crate; a workspace
file change (which a craft-heif rev bump is) still runs the heif step.
* Pin craft-heif to the merge of storytold/craft-libs#794
* docs: the HEIF rows point at craft-heif, not the removed crates/heif
* Use craft-gainmap from craft-libs for gain map metadata and arithmetic
crates/codecs/src/gainmap.rs keeps the JPEG layout (encode_jpeg, read_jpeg,
is_gain_map_jpeg) and re-exports GainMapMeta, GainImage, GainMapOptions,
ISO_URN, compute and apply from craft-gainmap, which is this file's metadata
and arithmetic moved to craft-libs (storytold/craft-libs#904). The tests of
the moved code went with it.
* craft-heif's Options has a chroma field at this rev: keep the libheif upsampling LightCraft had
* raw: count the chunks a TIFF declares from its offsets table
craft-tiff builds at most one chunk descriptor per byte of file
(craft-libs#827), so a grid of tiles sharing one payload lists fewer
chunks than the image declares. Compare the offsets table, which is the
source of truth, so such a file reaches the byte-accounting check and is
refused for the data it actually holds.
* Use craft-tiff from craft-libs; remove crates/tiff
lightcraft-tiff moved to craft-libs unchanged as craft-tiff
(storytold/craft-libs#783), the first step of sharing RAW support with
PhotoCraft (storytold/craft-libs#587). The layer table drops tiff and its
intra-layer ordering before raster.
* Pin craft-tiff to the merge of storytold/craft-libs#795
* mask.exportEffects refuses originals and sidecars and writes atomically
* check_write_target refuses unresolvable .. components in a missing destination folder
* test: accept either refusal for a missing/.. destination (Windows resolves .. lexically)
* security(engine): read user-named files through the opened regular file under a byte cap
* address review: compare the probe error with the std::fs::read error
* address review: open files for reading without waiting for a FIFO writer
* security(meta): linear entity decoding, indexed keyword de-duplication, bounded XMP path building
* address review: decode zero-padded numeric references in the three entity decoders
Part of the Lens Blur row (`LR-EDIT-LENSBLUR`, ⬜ → 🟡: no depth map yet). Related: #377 (SAM 3 subject selection, used here for the Lens Blur focus).
## Problem
Lens Blur settings existed but nothing rendered them: there was no way to add a shallow depth of field, keep the subject sharp while the rest falls out of focus, or blur only part of a photo through a mask.
## Change
**Edit → Lens Blur** (`section.lensBlur`, ⌘6)
- **Apply**, **Amount**, **Boost** (brighter bokeh highlights) and **Transition** (how gradually the blur grows away from what is in focus, so the subject doesn't look cut out).
- **In Focus**: *Subject* (a mask) or a fixed shape: **Auto / Round / Horizontal / Vertical**, buttons drawn in code that work on the light themes.
- **Move & Resize** (tool `lensBlurShape`) drags the ellipse on the photo and stretches it by its handles. Each drag is one undo step; a shape button puts the ellipse back in the middle.
- **Find Subject** (`lensBlur.findSubject`) runs only when clicked, never automatically on Apply.
- It starts from the focus point the camera recorded, when the file has one (Sony ILCE-1 and ILCE-7SM3, the models `lightcraft_meta` reads today). Otherwise it starts from the subject estimate.
- SAM 3 keeps the prominent people and animals: those at the focus point and those of a similar size. When the focus point falls on neither, it falls back to an object click at that point.
- The result is a normal Object mask ("Lens Blur Subject") that can be refined in Masking.
- It runs on the background segment worker, and on remote SAM 3 too (`Operation::Subject`). While the mask is pending, the UI shows a spinner and the render keeps the subject estimate in focus, so the photo is never blurred whole.
- Without the model, it returns the model-missing error, changes nothing, and the UI offers the SAM 3 download.
- **Brush Refinement**: Focus and Blur brushes painted on the photo (`lensBlur.brushStroke`, `lensBlur.brushReset`), with Size, Feather, Flow, Amount and Auto Mask.
- While Apply is off, In Focus, the shapes, Move & Resize and Find Subject are disabled.
**Masking: a Lens Blur block in every mask** (`section:maskLensBlur`, under Refine Edges)
- **Blur: Selection / Outside**. Outside blurs what the mask leaves out, without inverting the mask's other adjustments.
- **Amount**, **Boost** and **Transition**, per mask. The header's eye switches the block off and keeps its values; the header folds the block.
- Stored as `lens_blur`, `lens_blur_outside`, `lens_blur_boost`, `lens_blur_transition` and `lens_blur_off` on `LocalAdjustments`, set through `mask.adjust`.
**Rendering** (`crates/pipeline/src/lens_blur.rs`)
- Runs in the scene-linear stage after denoise; its settings are part of `pre_nr_key`.
- Disc (bokeh) kernel at four levels on coarse grids, with a normalized convolution weighted by the circle of confusion, so sharp areas don't bleed halos into the blur. Transition uses a chamfer distance to the in-focus area.
- The radius is relative to the long edge, so the blur doesn't depend on resolution. The work stays bounded on large exports: the disc kernel has a fixed size, and each level's coarse grid stays within a cell budget.
- Zoomed windows, both 8-bit and deep (16-bit/float), read around them and are cut back to the request. The grids follow the whole output's origin, and the automatic subject estimate is made once from the whole photo. A window therefore matches the whole render.
- GPU path: read back, apply on the CPU, upload (`crates/gpu/src/render.rs`).
- Hostile values (NaN or infinite sizes, out-of-range areas and focus points, oversized stroke lists) are sanitized or rejected, never a panic.
All new strings are in the 17 locales.
**Not in this PR:**
- Real depth. The falloff is the image distance from the focus, not scene depth; a depth model (e.g. Depth Anything V2 Small on candle) would be a separate PR.
- Rotating the ellipse.
- Aperture shapes.
- Focus points for more camera makes and models.
- Find Subject doesn't resume by itself after the SAM 3 download (the Masking tools do). Like the existing Object / Describe jobs, it shows no row in the activity stack.
## How it was checked
- [x] Full `cargo xtask ci` on Windows 11 x86_64 after the latest merge of `main` (465c8722):
- fmt, clippy, heif, parity, layers, assets and wasm pass;
- every Lens Blur test passes;
- the only failures are five tests outside this change that fail on Windows on `main` too: `export::tests::sixteen_bit_zip_tiff_is_never_larger_than_uncompressed`, the two GPU out-of-memory tests in `gpu::ctx`, `dialog_role::settings_is_a_dialog_too` (needs craft-fonts) and `folder_drop::dont_ask_again_moves_the_next_drop_at_once`.
- [x] Tests that fail without the change:
- **pipeline**:
- the `lens_blur` tests: shapes and moved or hostile areas, blur growth away from the focus, the fallback while an AI mask is pending, brushes, masks blurring their selection or outside with Transition, hostile input;
- `large_image_blur_work_is_bounded`: on a 60 MP export with the strongest global and per-mask settings, the disc kernel stays a fixed size and every level's coarse grid stays within its cell budget, including an offset render window;
- window/full-render parity at U8 and U16, including the automatic subject.
- **engine**: brushes with undo; Find Subject without the model changes nothing; deleting the focus mask clears the focus; a partial effect preset sets `lens_blur`; with the `sam` feature, Find Subject fills the waiting mask.
- **segment**: `prominent_subjects`, and remote `Subject` validation.
- **catalog**: `op_variants_are_versioned` with the new format version.
- **ui-egui**: the brushes painting on the photo, the shape buttons, the controls disabled while Apply is off, Move & Resize with undo and redo, the mask block (side, sliders, eye, folding).
- [x] User-visible change: ran the app and looked at the result (dark and light themes).
## Screenshots
**Before / after**
<img width="1402" height="952" alt="before" src="https://github.com/user-attachments/assets/8baceb99-7708-4c25-990c-8da29b6bc1b4" />
<img width="1320" height="937" alt="after" src="https://github.com/user-attachments/assets/a1476510-558a-4460-8766-b25bda0dfd3d" />
**Edit → Lens Blur** and **the mask's Lens Blur block**
<img width="457" height="626" alt="main painel" src="https://github.com/user-attachments/assets/47a19637-29a8-4446-a003-2eef416975b7" />
<img width="463" height="333" alt="mask painel" src="https://github.com/user-attachments/assets/345ffc14-66d2-4adc-af3c-b756727201de" />
## Merging
- **Overlap:** #1713 (Clearfall; a draft since 2026-10-14 that conflicts with main) implements the same row on the CPU. It has aperture shapes and XMP roundtrip, which this PR lacks. This PR adds the per-mask block, SAM 3 Find Subject from the camera's focus point, the GPU path and window parity. Only one should land; happy to port what #1713 has that this lacks.
- **Existing edits and libraries:** unchanged. Lens Blur is off by default and every new field is omitted from the JSON at its default, so existing settings keep their JSON and hashes.
- **Shared numbers taken:** catalog format `VERSION` 12 (`crates/catalog/src/journal.rs`). main already uses 10 (`Mask.on_photo`) and 11 (`EmbeddedLens.source`), so Lens Blur takes one past them. If another pull request lands with 12 first, I'll take the next one when I merge main. No render-cache, look or process version change.
- **Where it came from:** own implementation; nothing derived from GPL code or Adobe data. The camera focus point comes from the existing `lightcraft_meta` reader; subject selection uses SAM 3 through the existing segment crate.
- **New dependencies, `unsafe`, build scripts, network access, spawned processes, deleted files, CI or `xtask` gate changes:** none. The remote SAM 3 protocol gains one request (`Operation::Subject`). An older worker rejects it with an error, as `docs/ai-masks.md` notes.
## Checklist
- [x] No new panic path in non-test code
- [x] New text on screen goes through `tr()` with keys in all `locales/*.json`; ⌘6 opens the new section (KEY-SECTIONS)
- [x] `docs/parity-checklist.md` rows updated (LR-EDIT-LENSBLUR 🟡, LR-MASK-SLIDERS, KEY-SECTIONS); `docs/gaps.md` has no Lens Blur entry
- [x] New code has a caller
- [x] No new assets (the shape icons are drawn in code)
- [x] Ready to merge
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **New Features**
* Added Lens Blur with adjustable strength, highlight boost, and transition controls, plus Round, Wide, and Tall focus shapes.
* Keep a subject or selected mask in focus, find people or animals automatically, and refine focus or blur with brushes. Move and resize the focus area directly on the photo.
* Apply Lens Blur to individual masks, including selections or areas outside them.
* **Bug Fixes**
* Improved Lens Blur rendering for cropped views and preserved focus-mask assignments correctly when masks are edited.
* **Documentation**
* Updated feature and control guides, with Lens Blur interface translations added across multiple languages.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
lightcraft-heif moved to craft-libs unchanged as craft-heif
(storytold/craft-libs#784), so PhotoCraft can share it. The layer table,
the heif CI step and the change triggers drop the local crate; a workspace
file change (which a craft-heif rev bump is) still runs the heif step.
lightcraft-tiff moved to craft-libs unchanged as craft-tiff
(storytold/craft-libs#783), the first step of sharing RAW support with
PhotoCraft (storytold/craft-libs#587). The layer table drops tiff and its
intra-layer ordering before raster.
* security(segment): Object selections take at most 64 clicks at the engine API and the model
* address review: refuse over-cap Object clicks before queueing in background mode
* security(engine): one unpack budget across a preset zip's packs; linear comment skipping; small zip errors
* address review: charge a failed pack's unpacked bytes to the shared zip budget
* address review: charge a corrupt deflate entry's partial output to the shared budget
* address review: an entry past its stated size spends only what it unpacked
somewhere else (a share mounted over the folder, the folder moved away
and another put in its place) made the session write into that other
folder: its catalog.snap and catalog.log were replaced, and dropping the
lock removed the owner note of the program that had the library open.
OpenedFolder records the folder's device and inode number (and when it
was made, where the file system keeps that) when a library opens, and
check() asks, with one stat, whether the path still leads to it. A drive
or share mounted again gets another device number, and some file systems
number their folders anew at every mount, so a folder also counts when
it holds exactly the owner note this session's lock wrote (the lock
vouches for it, and the note holds a value no other lock's note has), or
when it has the same inode number and both creation times are known and
equal; on the same device two different creation times are two folders,
since an inode number is given again to a folder made later. FsStore
(both stores of a library, the snapshot worker), the catalog log's
thread and the lock's owner note ask before they write; a refusal is an
ordinary write error that names the path, so the changes stay queued,
the app says why they are unsaved, and saving goes on once the folder is
back. The thumbnail cache gets a gate that the library closes the same
way, and its takeover, prune and clear passes look at it every 256
files.
The catalog log is opened by its path for each batch and appended to
only while it is as long as what the thread wrote. A copy of the folder
put at the path holds the note and counts as the library, but its log
lacks what was written after the copy was made: it is refused like a
failed write (reported, with later changes taken meanwhile), and the
snapshot the app takes for held records replaces it, instead of going on
writing into the folder that was moved away. A longer log is cut back
only after a write of the thread's own failed.
The lock removes the owner note only when it is the one it wrote, in the
folder it locked. Reopening a path whose folder was replaced takes that
folder's own lock instead of handing the old one over, so does the
check_library preflight, and a lock taken in another folder than the
stores recorded is refused. A Move import removes its originals only
after the catalog log is on disk, not when it was handed to the log's
thread.
Windows reports no folder identity through std (nightly only): there the
check only asks that a folder is still at the path.
* LR-IMP-FORMATS: withdraw compressed ORF decoding
Remove the decoder introduced in #3775 pending provenance review while preserving uncompressed ORF layouts and embedded previews. Add unsupported probe/decode regressions, remove the prior provenance narrative, and restore camera coverage records to preview-only.
* LR-IMP-FORMATS: refresh ORF support status and render caches
* LR-IMP-FORMATS: document ORF withdrawal regressions
Libraries created on another OS may have no recorded file size for some photos. After moving OS and renaming the file, Find Missing should still relink it by its content hash instead of leaving it missing.
Allow plan_find_missing to match renamed files by content hash when size is unknown by hashing unused candidate files, and add a regression test with a Windows-style path, unknown size, known hash and a renamed file in the searched folder.
Test: find_missing_matches_renamed_file_by_content_without_size failed before the change and passes after.
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Users importing a Lightroom catalog see masks that darken or lighten the wrong part of the photo, even though the mask exposure value itself looks correct.
Carry the inverted flag through catalog mask orientation handling for develop and XMP masks, and add a regression test with an inverted radial mask.
Test: inverted_radial_mask_keeps_its_inversion_on_import failed before the change and passes after.
* Picture Package and Custom Package pages can print cut guides at each cell's corners
Picture Package and Custom Package pages can print cut guides at each cell's corners
Picture Package and Custom Package pages can print cut guides at each cell's corners
Test: picture_package_and_custom_package_pages_can_print_cut_guide failed before the change and passes after.
* Print: Cut Guides in the package preview, page panel in its own function, tests follow the guides
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Print: Cut Guides sit at each cell's corners, outside any border
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Print: shorten the scroll position comment to what the code does
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Print: back to one scroll position for the settings column
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Write camera make and lens make to EXIF on export
PTGui and similar stitching tools read EXIF Make/LensMake to identify camera and lens; without them, exported JPEGs from CR2 files are not recognized the same way as Adobe's export.
Add make and lens_make fields to catalog Meta, populate them from the raw's EXIF on import in meta_of, and write them as EXIF Make and LensMake tags in export_metadata.
Test: export_writes_camera_make_and_lens_make_to_exif failed before the change and passes after.
* Export: read Make and LensMake on import and write them, with Model on its own
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Export: strip the maker from Model only as a separate word
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Add flash, exposure bias and serial rules to smart albums
Smart albums cannot filter by flash fired, exposure bias or camera serial even though the file metadata is already parsed.
Add flash, exposure_bias and camera_serial to Meta, copy them in meta_of and on reload, and add flash, exposureBias and cameraSerial rule fields evaluated in Rule::matches.
Test: flash_exposure_bias_and_serial_rules failed before the change and passes after.
* Rules editor: Exposure Bias takes negative values
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Import: an optional batch-edit recipe for newly imported photos
library.import takes a recipe, a list of develop control ids and values.
Each control is set, clamped to its range like a slider's, on every photo
the import actually adds, after the XMP sidecar, the camera default and
the chosen preset, as one more History step named Import adjustments.
Photos that are skipped as duplicates, restored from Recently Deleted or
joined from a browsed folder are not touched, as the preset and keywords
never touch them.
A recipe names plain adjustments only. White balance is refused, because
a temperature means Kelvin on a raw with colour matrices and a shift from
the as-shot white on a rendered photo, so one number cannot name the same
look for a whole batch, and the as-shot white balance of a raw is never
touched. Geometry and crop controls are refused, because the slider
refits the crop around a new angle and a batch write cannot. Per-photo
controls such as pointColor.0.hueShift are refused, because a write to a
photo without that instance is dropped. The rule is on the control's
spec (a control of the shared list, outside the Geometry section, not
white balance, and one that set accepts), so new controls follow it. An
id named twice counts once, the last value winning, and a list longer
than the control list is refused. ImportJob::new checks a recipe built in
code the same way, before any file is read or placed.
preset.saveRecipe saves a recipe as a user preset that stores only the
settings the recipe names, including a control the recipe sets to its
default, and refuses a recipe that stores nothing. The preset gets its id
the way imported presets do (user.<group>-<name>, then -2, -3 ...), so no
two presets share one: an id from the list length repeats once a preset
is deleted, and the first preset with an id is the one that gets applied.
A name or group over 100 characters is refused, and saving the same
recipe under the same name and group again returns the preset that
exists.
* Import recipe: tests
Cover a recipe on import (the values, the Import adjustments step, a
render, one undo step), the refusals (unknown ids, malformed items,
per-photo controls, geometry and crop, white balance, too many entries,
by the command and by ImportJob::new), clamping and a repeated id, a
raw's as-shot white balance staying as imported, a saved recipe preset
giving the same settings as the recipe (including a reset to a default),
the photos the recipe leaves alone (duplicates by path and by content, a
restored photo, a browsed photo that joins; a photo imported afresh gets
it), preset ids staying distinct after a delete and surviving a reopened
library, and both commands being listed with their parameters.
* Import review: a Batch edits section
The import review gets a collapsible Batch edits section: sliders for
the everyday adjustments (exposure, contrast, highlights, shadows,
whites, blacks, vibrance, saturation, clarity, texture, dehaze,
sharpening, grain, vignette). The controls moved off their default go to
library.import as its recipe, only when there are any, and a summary
beside the section counts them. The recipe stays in the dialog until the
import runs, so cancelling changes neither the catalog nor the presets.
Save as Preset, which needs a name and a recipe, saves the recipe with
preset.saveRecipe. It leaves the review's own preset choice as it is, so
a preset picked for the import is never replaced by the saved one. The
name goes in a TextField, as new text boxes do.
The summary line is a new tr_format message, added with a translation to
every formats catalog; the other new messages are plain and show in
English until a catalog translates them.
* Import review recipe: tests
Unit tests hold the dialog to the engine: every control it offers is one
a recipe may name, a slider moved back to its default leaves the recipe,
and start passes a recipe to library.import only when the dialog has one.
Driving the real review, Save as Preset saves nothing without a name or
without a recipe and with both saves exactly the recipe (leaving the
review's preset choice and the catalog alone), cancelling the review
discards the recipe, and confirming imports the photos with it as one
undo step, or without an Import adjustments step when there is none.
* Import recipe: tests for the disabled Save button and MCP reachability
The disabled state of Save as Preset was not pinned: the engine refuses
a nameless or empty recipe anyway, so the preset count stayed the same
even with the button always on. The test now also expects no error
toast, which only an enabled button that asked the engine would raise.
A new MCP end-to-end test drives both commands through the public
tools: list_commands documents them, run_command takes library.import
with a recipe (a recipe naming white balance is a tool error that
imports nothing), get_develop shows the values on the imported photo,
and the generated cmd_preset_saveRecipe tool saves a recipe.
* Import recipe: follow main's register(ui) and Id::unique after the rebase
Upstream main changed widgets::register to take &egui::Ui (every other
call site passes ui) and deprecated egui::Id::new in favour of Id::unique
(same hash, so the stored open/closed state is unchanged). Adapt the
batch-edit recipe section so lightcraft-ui-egui compiles again.
* docs: parity row LR-IMP-RECIPE for batch edits during import
* Keep HDR resets when a recipe is saved as a preset
A recipe that resets an HDR control to its default was dropped when it was saved as a preset, because the HDR subtree is left out of the settings JSON while it is the default. The recipe's settings are now compared with the HDR subtree always present, so the reset is stored alone and next to other adjustments. Round-trip tests apply the saved preset to settings with a non-default headroom.
* Address review findings
* Address review findings
* Import review: the imports the merge left in body.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* never-crash: deny the panic lints in every crate root; GPU asserts become fail paths (#2137)
The never-crash policy was documented but not machine-checked for the two largest crates:
engine and meta carried only #![forbid(unsafe_code)], so a future unwrap/expect/panic would
pass cargo xtask ci. Both crate roots now also carry
as does xtask (previously un-annotated); the guarded expects in meta/src/xmp.rs and xtask's
parity.rs / root() now use the documented #[allow(clippy::expect_used)] + invariant form.
crates/gpu: the three production asserts become fail(FailKind::Fatal, ..) + return, so a
binding-count mismatch, an over-long readback, or a wrong-length curve fails the render over
to the CPU instead of crashing (finish_and_read also early-returns on len == 0, which would
have issued a zero-size copy_buffer_to_buffer that wgpu rejects).
xtask: new roots check (in ci) verifies every workspace lib root and every binary main.rs
carries both attributes; crates/sysmem is the documented exception for forbid(unsafe_code)
only. A panic in placement or readback is a fail, not a crash.
* audit fixes: roots covers binary and cdylib/rlib roots; render gates on failed() after finish_block (#2137)
Two reviewers audited the first commit; both highs it found are fixed here:
- roots scanner: the by_ref().any()/any() pair consumed the kind iterator hunting for
"lib", so every bin-only root (both app mains, the sam3-worker bin, xtask itself) and the
cdylib/rlib web root was silently unchecked — the check covered 29 of the 33 real roots.
Kind detection now collects the kinds once and matches lib/rlib/dylib/cdylib/staticlib,
with a root_paths regression test over bin, lib and cdylib/rlib targets; unreadable root
files now fail with the I/O error instead of a fake policy violation.
- render.rs: the caller gates on failed() right after finish_block, so the malformed-curve
fail path can no longer reach the band loop's p[y0_at] index on the empty block.
- finish_and_read: the len == 0 path now submits the encoder before returning zeros, so a
failure staged in the same render stays detectable (the old zero-size copy failed loudly
via the error scopes; a bare return would have hidden it).
- docs: finish_block and finish_and_read state their failure contracts; USAGE and AGENTS.md
name the new roots step in the ci enumeration.
* xtask: check a library root at the source path that cargo metadata reports
The roots check read src/lib.rs for every library target, so a package that sets its library path was checked on the wrong file. Libraries now use the reported source path, with the same default as binaries when none is given.
* xtask: match the crate-root deny lints by whole name, ignoring a trailing comment
A lint named only in a trailing comment, or a lint whose name contains another (clippy::panic inside clippy::panic_in_result_fn), satisfied the deny check. Lint names are now compared whole and a trailing comment is ignored.
* xtask: read the crate-root attributes from the header, not a fixed 30 lines
The roots check read only the first 30 lines of each crate root, so a root whose attributes came after a longer doc header was reported as missing them. The check now reads the inner attributes at the top of the file: it skips blank lines and comments, reads each attribute whole, and stops at the first item. A multi-line list is read in full and a commented-out attribute does not count.
* xtask: reword two comments in the roots check
Comments only: the lint-name match and the source-path default are described without naming a lint or a build tool. No code changes.
* xtask: report a root attribute that overrides the required denies
* xtask: accept a runtime manifest dir only when it has a parent
* xtask: render the overridden deny attribute without literal braces
The write! escaped the braces around the substituted attribute and lint,
so the violation printed `#![{allow}({clippy::panic})]`; assert the
rendered message in the allow-override test.
* Tests: new test helpers meet the crate-root panic lints
Main added test helpers after this branch; the deny at the crate root now
applies to them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* roots: crates/wincolor is the second crate allowed unsafe
Main added it for the Windows colour APIs after this branch; its module docs
already say so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Extend CR3 white level to actual sensor saturation
The white level comes from Canon's stated value, not from the sensor data, so highlights between the stated level and true saturation are misclassified as clipped. Extending the white level to the real pile-up and folding the delta into baseline_exposure leaves everything below the old white unchanged while recovering the lost highlight range.
Add RawImage::extend_white_to_saturation() to saturation.rs that scans for a saturation pile-up above the stated white (coarse 1/128 bins, requires >= 1 sample in 100,000 and >= 64 samples above), sets white to the lowest colour's pile-up edge or the bit-depth top, and returns the EV delta. Call it from cr3.rs decode() on Mode::Full and add the delta to ColorData::baseline_exposure. Bump RENDER_CACHE_VERSION in media.rs.
Test: extend_white_to_saturation_above_stated_white failed before the change and passes after.
* Preserve CR3 highlight headroom and exposure
Assisted-by: OpenAI Codex
* Tests: a probe does not know the white headroom a CR3 decode finds
The header probe stays a header probe, so the comparison leaves out
baseline_exposure, which a full decode adjusts from the samples.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <FredApps@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Apply Auto settings to every selected photo
Users expect Auto and preset application to affect the whole selection, as Quick Develop already does. `develop.auto` is the only edit command in that file that hard-codes the active photo instead of the selection.
Make `develop.auto` accept the same target rule as the other selection commands (`ids` when given, else the selection), analyse each target photo's own source with `auto_tone`, and commit the results as one batched undo step labelled "Auto".
Test: auto_applies_to_every_selected_photo failed before the change and passes after.
* Run multi-photo Auto settings off the UI thread
Assisted-by: OpenAI Codex
* Auto Settings: skip unreadable photos and refuse stale results
One offline photo stopped Auto for the whole selection. The background
result is checked against each photo's settings, because an undo changes
them without a commit, and it commits through the command wrapper so sidecars
and the durable save follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Auto Settings: a wrong photo id is refused, not skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <FredApps@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* Presets compose on the photo's original state, not the visible edits (fixes#2159)
Applying a preset deep-merged it into the photo's current settings, so a
second preset inherited whatever an earlier one (or a manual edit) had put
in the groups it styles, and its amount interpolated against the visible
values: a B&W preset followed by a color one stayed black and white. Each
group a preset covers is now computed on the photo's original state (its
import settings) and replaces the photo's own, at any amount; groups the
preset doesn't name, and the photo's pixel repairs (masks, spots, red eye),
are kept. An unresolved profile reference still means "the photo keeps its
own profile", and the built-in color presets now name their treatment, so
applying one after a B&W preset brings the colors back. The UI's hover previews and thumbnails show the same composed
result.
* Presets change only the settings they name (#2159)
The commit before this one computed each group a preset names on the
photo's import state and replaced the whole group. A preset therefore
also reset the settings it leaves out: Blacks under Bright & Airy, the
mixer colours it does not name, and imported exposure, whites and
blacks under Crisp Landscape.
Now each setting a preset names is computed alone, from the photo's
import look when a default preset recorded one, and otherwise from its
current value, because sidecar and catalog imports record no import
look and the camera defaults are then not their import state. Every
other setting keeps the photo's value. Pixel repairs (masks, spots,
red eye) compose on the photo's own values as before, and masks are
still added by the preset.
A color preset applied after a black and white one still restores the
treatment and the settings it names. Amount 0 applies nothing to a
photo without an import look. An unresolved profile reference leaves
the photo's profile as it is. Each case has a test.
* Document that presets change only the settings they name
The presets row and the preset amount row of the parity checklist now
describe the composition: each named setting is measured from the import
look when one is recorded, otherwise from the photo's current value, and
the settings a preset does not name keep their values. The revision
history records the change; statuses are unchanged.
* Test amount 0 on a setting the preset names
The amount-0 test used a preset that does not name exposure, so it
passed even when the original was the camera defaults. Bright & Airy
names exposure, and the test now checks that the photo keeps its value
at amount 0 for that setting.
* Keep a preset's null in an option field, and never take one from the original
A preset that writes null into an option setting (a crop aspect, where
null means free) was dropped below full amount: the scaled patch
removed every null, including the ones the preset wrote. At 100 % the
same preset cleared the aspect, at 50 to 99 % the photo kept it.
Now a null the preset writes applies from half amount up, as its other
values do. A null in the original never changes the photo: below half
amount such a setting is left out, so the photo keeps its own value.
Numbers and other values behave as before. The null-removal step is
gone, since the scaled patch no longer writes nulls for settings the
amount does not reach.
Tests: a preset null clears an option field from half amount up and
leaves it below; an option that is unset in the original does not
overwrite the photo's value.
* Build a preset's scaling base only below full amount
The presets panel asks for every visible row at 100 % on every frame,
and on hover. Each of those calls serialized the photo's current
settings and its original although, at 100 %, the preset's own values
apply as they are and the original is not read.
Compose now builds the scaling base only below 100 %. The engine also
builds the import state, or copies the photo's settings, only below
100 %. Results are unchanged; the existing preset tests cover both paths.
* Preserve preset baselines and allocate safe mask IDs
Assisted-by: OpenAI Codex
---------
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <FredApps@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
* Give the pipeline one exact output size instead of re-fitting
Export and the pipeline each compute the output size independently from two descriptions of the photo's shape, so an already-chosen export size can come back a pixel short when the pipeline re-fits against a reduced source whose aspect rounds differently.
Add an exact output size to RenderRequest, make plan take it unchanged via an exact Frame::sized mode, drop the aspect-tolerance guard, and have export resolve one canonical size before calling the pipeline; add a unit test asserting plan returns the requested size unchanged when it matches the frame aspect.
Test: plan_preserves_matching_box_size failed before the change and passes after.
* Honor exact output dimensions for exports
Assisted-by: OpenAI Codex
* Export: an exact size does not stretch a source of another shape
A raw whose decode failed can fall back to an embedded preview with a
different aspect. The exact box now stands only against a proxy that differs
by rounding.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <FredApps@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* catalog: history steps and versions share segmentation grids (#2154)
Every history step stored its own copy of each segmentation grid, so a
photo with AI masks rewrote every unchanged grid (about 220 KB each) with
every slider change: on a real library, 183.6 MB of a 187.8 MB
catalog.snap was duplicated grids (830 copies of 126 distinct ones).
Snapshots now keep each distinct grid once, in Catalog.grids (a new
serialization detail, format v10), and the masks of the photo's settings,
versions and history steps refer to it by index (SegMask.grid, with the
data omitted). The table is built while the snapshot is written and is
never held in the live catalog: Journal::open resolves the references
back to inline data (Catalog::repair), so rendering, hash64, presets,
XMP and log records are unchanged, and catalogs written before v10 load
and are upgraded as before. A reference past the table (a damaged
snapshot) is cleared and reported, rendering nothing.
Measured on 90 history steps over one 1024x1024 grid: the snapshot drops
every step's copy of the grid (1.29 MB -> 0.30 MB in the fixture; on the
reporter's library, the grids shrink from 181.8 MB to the 25.9 MB of
distinct grids).
* catalog: the snapshot's shared grids cover the import look too (#2154)
A photo's import look (Photo.import_look, the settings a user default
preset gave the photo on import) can hold segmentation masks, and its
grids can be the same grids that the develop settings, versions or
history steps hold. The snapshot writer referred to such a grid by its
table index, but the table was built from the other settings holders
only and the load resolved only those, so the look's mask came back
empty with a dangling reference.
Photo::settings_holders lists every settings holder (develop settings,
versions, history steps, import look). The writer builds the table from
it and the load resolves references through the same list, so a holder
added there is covered on both sides.
New test import_look_masks_share_the_table_and_resolve_on_load: a look
whose mask shares a grid with the develop settings and a history step,
plus a grid only the look holds. It reloads exactly, and the table holds
both grids once each. Before this change the look's mask came back as
data "" with grid Some(0).
* catalog: state what a snapshot copy shares (#2154)
The snapshot writer copies the catalog to serialize it. Its photos are shared (Catalog.photos holds Arc<Photo>), so the copy is a pointer per photo, not a deep copy; the comment said so without saying which tables are copied. It now lists them, and notes that the derived indexes start empty on the copy.
* develop: a segmentation grid reference is written only by a snapshot (#2154)
The inline serialization of a mask wrote its `grid` whenever one was
set. A `grid` can be set in memory from a document: a mask given to a
command (mask.update, develop.merge) or read from a preset goes through
the derived Deserialize, and such a value stayed in the live catalog.
The next snapshot wrote it inline, and on load the index resolved to
whatever grid sat at that position in the new table, so a mask could
take another mask's grid without a repair being reported. The same
stray value also changed hash64 for identical settings.
The inline form no longer writes `grid`, so it is the pre-v10 form
again. Only the snapshot interner writes a reference, into the table it
builds, so a snapshot cannot hold an index that points elsewhere.
New tests: stray_grid_is_never_written_outside_the_interner (develop)
and stray_grid_from_a_document_is_not_written_as_a_reference (catalog: a
stray reference is not resolved to another photo's grid after a reload).
Both failed before this change: the first wrote "grid":3, the second
loaded photo one's grid into photo two.
* Address review for pull request 2203
* Format the files this pull request changes
* catalog: don't clone a grid that is already in the snapshot's table
The snapshot's grid interning indexed with `entry(m.data.clone())`:
the whole grid was copied before the map said whether it was already
there, so every history step that repeats a mask's grid paid a needless
allocation and copy on the snapshot path. The lookup is borrowed now
(`contains_key`), and a grid is cloned (into the pool and the table)
only when it is new, in the same first-appearance order.
The background snapshot also held two catalogs: `snapshot_in_background`
clones the catalog for the worker, and `write_snapshot` cloned it again
to attach the grid pool. The writer now takes the catalog by value and
the background path hands over its copy, so a snapshot in flight holds
one catalog; the synchronous path keeps its own single clone.
Not observable in behaviour: the grid tests and the catalog suite pass
unchanged.
* Tests: the hostile-mask test names the new grid field
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: eliets2 <287273517+eliets2@users.noreply.github.com>
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>