Skip to content
Closed
27 changes: 25 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
name: CI

# Quality gates for every push to main and every pull request (`cargo xtask ci`), through the
# suite's shared gate workflow in craft-common-actions.
# suite's shared gate workflow in craft-common-actions, on the three desktop platforms (gap 9,
# issue #1050): code behind `cfg(target_os)`, path and line-ending assumptions and the Metal and
# DX12 code paths only show on their platform.
#
# After the gate, each leg runs the GPU tests again (CPU <-> GPU equivalence, fallback, memory,
# shutdown) with `LIGHTCRAFT_GPU_ALLOW_SOFTWARE=1`, which only tests set: the app refuses software
# adapters because the CPU pipeline is faster. The runners have no hardware GPU, so that admits
# Mesa's lavapipe on Linux and WARP (DX12) on Windows; macOS runners expose a Metal device. The
# step fails if a GPU test still skips for lack of an adapter, so "all passed" can't mean the GPU
# tests never ran.
on:
push:
branches: [main]
Expand All @@ -21,11 +30,25 @@ jobs:
# Tracks @main so suite-wide CI fixes reach every app without a PR in each repository.
uses: storytold/craft-common-actions/.github/workflows/gate.yml@main
with:
# Standard GitHub-hosted runners only: free for public repositories.
os: '["ubuntu-24.04","macos-latest","windows-latest"]'
# Same craft-fonts commit as release.yml.
craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83
timeout-minutes: 90
# a from-scratch workspace build on macOS and Windows takes about an hour
timeout-minutes: 120
# xtask ci runs cargo test: the demo scene cache is per process, so nextest is slower here.
tools: ""
command: |
cargo xtask ci
echo "=== GPU tests, software adapters allowed ==="
skips="$RUNNER_TEMP/gpu-skips.jsonl"
rm -f "$skips"
LIGHTCRAFT_GPU_ALLOW_SOFTWARE=1 LIGHTCRAFT_SKIP_LOG="$skips" cargo test --locked -p lightcraft-gpu --tests
if [ -f "$skips" ]; then echo "skipped GPU tests:"; cat "$skips"; fi
if [ -f "$skips" ] && grep -q '"reason":"no GPU adapter' "$skips"; then
echo "::error::the GPU tests skipped: no GPU adapter on this runner, software ones included"
exit 1
fi
packages: >-
pkg-config libxkbcommon-dev libwayland-dev libx11-dev libxcb1-dev libxcursor-dev
libxrandr-dev libxi-dev libfontconfig1-dev libfreetype-dev mesa-vulkan-drivers
Expand Down
9 changes: 5 additions & 4 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Stage: alpha** · next: beta, ~14 points and ~340–600 h away

> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (Print: Japanese photo and postcard paper sizes — L判, 2L判, KG判, はがき, 往復はがき, 六切, 四切, 名刺; Minolta MRW decoded, 6 bodies verified; RAW: 83% of Adobe's models decode, 38% verified after the camera-coverage sweep #1327; German catalog 91% → 97%: interface strings and What's New lines translated) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-26 · **Change:** minor (gap 9 closed: tests in CI on macOS, Windows and Linux x64, GPU tests on lavapipe, Metal and WARP; Print: Japanese photo and postcard paper sizes — L判, 2L判, KG判, はがき, 往復はがき, 六切, 四切, 名刺; Minolta MRW decoded, 6 bodies verified; RAW: 83% of Adobe's models decode, 38% verified after the camera-coverage sweep #1327; German catalog 91% → 97%: interface strings and What's New lines translated) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6

One-page summary of how close LightCraft is to Adobe Lightroom. Agents: read this, then pick work
from [docs/gaps.md](docs/gaps.md). The full assessment, method and evidence are in
Expand Down Expand Up @@ -30,8 +30,8 @@ Each audience with its own hours (Opus 5.5 agent wall-clock hours to ~95%):

The gap between breadth and readiness is quality and coverage, not missing buttons: camera colour is
estimated rather than measured, CR3 decodes on 26 verified Canon bodies (rarer CRX variants still open as previews), compressed ORF and HE NEF
open as previews, rendering is tuned by eye, AI masks are heuristics, there is no lens database, and
tests run in CI on FreeBSD only. **Why alpha:** core workflows run end to end, but readiness is below
open as previews, rendering is tuned by eye, AI masks are heuristics, there is no lens database.
Tests run in CI on macOS, Windows and Linux x64 for every pull request, and on FreeBSD nightly. **Why alpha:** core workflows run end to end, but readiness is below
the ~75% beta bar (it is above the ~40% alpha bar) and Lightroom's main inputs, raw files, still have blocking gaps (compressed ORF and HE NEF open as previews; Canon,
~30% of raw users, decodes CR3 on 26 verified bodies). It passes the alpha gate: all six core workflows
(import, cull, develop, save and reopen, batch looks, export) work end to end on macOS
Expand Down Expand Up @@ -109,7 +109,7 @@ Ranked toward beta; detail in [docs/roadmap.md](docs/roadmap.md), gaps in [docs/
5. AI masks: Subject / Sky / People (40–70 h + model decision)
6. Compressed ORF and HE NEF (28–55 h)
7. Lens profile database of our own (40–80 h)
8. Tests in CI on macOS, Windows and Linux (6–12 h)
8. ~~Tests in CI on macOS, Windows and Linux~~ (done 2026-10-26)
9. Per-model raw verification (20–35 h)

## Progress log
Expand Down Expand Up @@ -191,6 +191,7 @@ Ranked toward beta; detail in [docs/roadmap.md](docs/roadmap.md), gaps in [docs/

| Date | Change | Summary |
|---|---|---|
| 2026-10-26 | minor | Gap 9 closed (#1148): CI runs `cargo xtask ci` on macOS, Windows and Linux x64 for every pull request and push to `main`, and the GPU tests on lavapipe, Metal and WARP; ranked item 8 done; headline numbers unchanged |
| 2026-10-22 | minor | Print: Japanese photo and postcard paper sizes (L判, 2L判, KG判, はがき, 往復はがき, 六切, 四切, 名刺) in the page setup, Print dialog and PDF output; headline numbers unchanged |
| 2026-10-19 | minor | Indonesian interface (`id`): every plain and formats message, plus 69 command labels, locale, menu command and tests; What's New left in English; Localization ~55% → ~64% (mean of the 12 key languages), 8 of 12 present |
| 2026-10-12 | minor | Italian interface (`it`, #1192): 2,201 of 2,398 messages, locale, menu command and tests; headline numbers unchanged |
Expand Down
88 changes: 78 additions & 10 deletions apps/lightcraft/src/control_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn serve(stream: TcpStream, tx: &Sender<ControlRequest>, ctx: &egui::Context, id
log::warn!("control connection closed: could not set idle read timeout: {e}");
return;
}
serve_lines(&stream, &stream, |method, params| {
serve_stream(stream, |method, params| {
let (req, rrx) = ControlRequest::new(method, params);
let state = Arc::clone(&req.state);
tx.send(req).ok()?;
Expand All @@ -96,6 +96,40 @@ fn serve(stream: TcpStream, tx: &Sender<ControlRequest>, ctx: &egui::Context, id
});
}

/// The longest a closing connection is drained, however slowly its peer keeps sending.
const DRAIN_TIME: Duration = Duration::from_secs(1);

/// [`serve_lines`] on a socket, then close it so the peer reads every reply.
fn serve_stream(stream: TcpStream, handle: impl FnMut(String, Value) -> Option<Value>) {
serve_lines(&stream, &stream, handle);
close_gracefully(&stream);
}

/// Close a connection the server is done with without destroying its last reply. A socket closed
/// while the peer's later lines are unread, or arrive after it, answers them with a reset, and a
/// reset can discard the replies the peer has not read yet (on Windows it does): the client sees
/// "connection reset" instead of why. Send FIN, then read and drop what is left (at most
/// [`MAX_LINE`] bytes, 500 ms per read and [`DRAIN_TIME`] in all) before closing. From #1970
/// (LochLogic).
fn close_gracefully(stream: &TcpStream) {
let _ = stream.shutdown(std::net::Shutdown::Write);
let start = std::time::Instant::now();
let mut sink = [0u8; 8192];
let mut left = MAX_LINE;
let mut reader = stream;
while left > 0 {
// a peer that keeps trickling bytes must not hold the connection slot past DRAIN_TIME
let wait = DRAIN_TIME.saturating_sub(start.elapsed()).min(Duration::from_millis(500));
if wait.is_zero() || stream.set_read_timeout(Some(wait)).is_err() {
break;
}
match reader.read(&mut sink) {
Ok(0) | Err(_) => break,
Ok(n) => left = left.saturating_sub(n),
}
}
}

/// Wait for a request's reply. While the app has not picked the request up and `frames` (its
/// frame counter) stands still for `no_frames`, the request is abandoned (it will not run late)
/// and the reply says why; a request the app is running gets the whole `timeout`.
Expand Down Expand Up @@ -502,18 +536,52 @@ mod tests {
let addr = listener.local_addr().unwrap();
let server = std::thread::spawn(move || {
let (s, _) = listener.accept().unwrap();
let read = s.try_clone().unwrap();
serve_lines(read, s, |_, _| Some(json!({"ok": true})));
serve_stream(s, |_, _| Some(json!({"ok": true})));
});
let mut c = TcpStream::connect(addr).unwrap();
c.set_read_timeout(Some(Duration::from_secs(10))).unwrap();
c.write_all(b"{\"id\":7,\"method\":\"x\"}\nhello\n{\"method\":\"y\"}\n").unwrap();
let mut text = String::new();
c.read_to_string(&mut text).unwrap(); // returns at EOF: the server closed the connection
c.write_all(b"{\"id\":7,\"method\":\"x\"}\nhello\n").unwrap();
let mut replies = BufReader::new(c.try_clone().unwrap());
let (mut first, mut second) = (String::new(), String::new());
replies.read_line(&mut first).unwrap();
replies.read_line(&mut second).unwrap();
assert!(first.contains("\"id\":7"), "{first}");
assert!(second.contains("closing the connection"), "{second}");
// A client that keeps sending after the junk: its next line reaches the server after the
// rejection. A socket closed by then answers that line with a reset, which the client reads
// as "connection reset" (os error 10053 / 10054 on Windows) instead of the end of the
// replies. The pause lets a reset arrive before the read.
c.write_all(b"{\"method\":\"y\"}\n").unwrap();
std::thread::sleep(Duration::from_millis(100));
let mut rest = String::new();
let read = replies.read_to_string(&mut rest);
server.join().unwrap();
let lines: Vec<&str> = text.lines().collect();
assert_eq!(lines.len(), 2, "{text}");
assert!(lines[0].contains("\"id\":7"));
assert!(lines[1].contains("closing the connection"));
assert!(read.is_ok(), "the close must be clean, not a reset: {read:?}");
assert_eq!(rest, "", "nothing follows the rejection");
}

#[test]
fn a_closing_connection_is_not_held_open_by_a_trickling_peer() {
let listener = TcpListener::bind(("127.0.0.1", 0)).unwrap();
let addr = listener.local_addr().unwrap();
let done = Arc::new(std::sync::atomic::AtomicBool::new(false));
let server_done = Arc::clone(&done);
let server = std::thread::spawn(move || {
let (s, _) = listener.accept().unwrap();
let t0 = std::time::Instant::now();
close_gracefully(&s);
server_done.store(true, Ordering::SeqCst);
t0.elapsed()
});
let mut c = TcpStream::connect(addr).unwrap();
// one byte every 100 ms: each read returns well within its 500 ms timeout
for _ in 0..100 {
if done.load(Ordering::SeqCst) || c.write_all(b"x").is_err() {
break;
}
std::thread::sleep(Duration::from_millis(100));
}
let drained = server.join().unwrap();
assert!(drained < DRAIN_TIME + Duration::from_secs(1), "drained for {drained:?}");
}
}
4 changes: 1 addition & 3 deletions apps/lightcraft/src/native_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,7 @@ impl NativeMenu {
// events never reach `shortcuts::handle`, so this is the one guard for AppKit's
// accelerators and clicks: while the blocking library window or a quit/settings notice
// owns input, a queued command is dropped (Quit stays for the existing confirmation).
let (cmd, params) = if key == QUIT {
(key, serde_json::json!({}))
} else if key == "app.about" || key == SETTINGS {
let (cmd, params) = if key == QUIT || key == "app.about" || key == SETTINGS {
(key, serde_json::json!({}))
} else if let Some(it) = self.items.get(&key) {
(it.cmd.clone(), it.params.clone())
Expand Down
7 changes: 5 additions & 2 deletions crates/engine/src/doc_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ mod tests {
assert_eq!(resolve("Photos/2024:05/a.jpg", Some(&doc)), Err(NotFollowed::Refused(Refused::Invalid)));
#[cfg(not(windows))]
assert_eq!(resolve(r"C:\Photos\a.jpg", Some(&doc)), Err(NotFollowed::NotHere));
let gvfs = Path::new("/run/user/1000/gvfs/smb-share:server=tokyo,share=photos/catalog.lrcat");
// a GVfs mount point (GNOME's SMB shares) is a local folder on Unix; Windows has no such path
#[cfg(not(windows))]
assert_eq!(resolve("a.jpg", Some(gvfs)), Ok(gvfs.with_file_name("a.jpg")));
{
let gvfs = Path::new("/run/user/1000/gvfs/smb-share:server=tokyo,share=photos/catalog.lrcat");
assert_eq!(resolve("a.jpg", Some(gvfs)), Ok(gvfs.with_file_name("a.jpg")));
}
}
}
16 changes: 15 additions & 1 deletion crates/engine/src/originals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,21 @@ mod tests {
// identity of either name cannot be read while it is held.
let held = std::fs::OpenOptions::new().read(true).share_mode(0).open(&original).unwrap();
let refused = s.pin_write_target(&linked.to_string_lossy()).unwrap_err();
assert!(refused.contains("cannot tell whether"), "{refused}");
// Except with SeBackupPrivilege enabled (an admin's Git Bash, so every Windows CI gate leg):
// a backup-semantics open of both names, as the guard's identity read uses, gets past the
// held handle. The guard then sees the link and refuses it as the original instead (#3228).
const FILE_FLAG_BACKUP_SEMANTICS: u32 = 0x0200_0000;
let backup_open = |p: &std::path::Path| std::fs::OpenOptions::new().read(true).custom_flags(FILE_FLAG_BACKUP_SEMANTICS).open(p).is_ok();
if backup_open(&original) && backup_open(&linked) {
assert!(refused.contains("is the original"), "{refused}");
assert!(!refused.contains("cannot tell whether"), "{refused}");
lightcraft_testkit::skip!(
System,
"a backup-semantics open gets past share_mode(0) here (SeBackupPrivilege is enabled), so the \"cannot tell whether\" refusal can't be tested"
);
} else {
assert!(refused.contains("cannot tell whether"), "{refused}");
}
drop(held);

let refused = s.pin_write_target(&linked.to_string_lossy()).unwrap_err();
Expand Down
4 changes: 3 additions & 1 deletion crates/engine/src/tests/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ fn recursive_discovery_includes_sony_sr2_and_srf_case_insensitively() {
let src = temp_dir("sony-discovery");
std::fs::create_dir_all(src.join("trip/day2")).unwrap();
let names = ["r1.SR2", "f828.srf", "trip/r1.sr2", "trip/f828.SRF", "trip/day2/r1.Sr2", "trip/day2/f828.SrF", "control.JPG"];
let mut expected: Vec<String> = names.iter().map(|name| src.join(name).to_string_lossy().into_owned()).collect();
// one component at a time: `join("trip/r1.sr2")` keeps the `/`, discovery yields the platform's separator
let mut expected: Vec<String> =
names.iter().map(|name| name.split('/').fold(src.clone(), |p, c| p.join(c)).to_string_lossy().into_owned()).collect();
for path in &expected {
std::fs::write(path, b"discovery only, not a decoded photo").unwrap();
}
Expand Down
33 changes: 31 additions & 2 deletions crates/gpu/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ fn module_source(m: &Module, consts: &str) -> String {
}

impl Gpu {
/// Create a device on the best available adapter (no software fallback), or why there is none.
/// Create a device on the best available adapter (no software adapter unless
/// `LIGHTCRAFT_GPU_ALLOW_SOFTWARE`), or why there is none.
pub fn new(backends: wgpu::Backends) -> Result<Gpu, String> {
let mut desc = wgpu::InstanceDescriptor::new_without_display_handle();
// only these drivers are loaded (`crate::backend`: never Vulkan on Windows unless asked)
Expand All @@ -307,10 +308,13 @@ impl Gpu {
)
.map_err(|e| format!("no GPU adapter among {backends:?} ({e})"))?;
let info = adapter.get_info();
if info.device_type == wgpu::DeviceType::Cpu {
if refuse_adapter(info.device_type, software_allowed()) {
log::info!("gpu: only a software adapter ({}), using the CPU pipeline", info.name);
return Err(format!("software adapter ({}) skipped: the CPU pipeline is faster", info.name));
}
if info.device_type == wgpu::DeviceType::Cpu {
log::info!("gpu: LIGHTCRAFT_GPU_ALLOW_SOFTWARE: using the software adapter {}", info.name);
}
let mut limits = adapter.limits();
if limits.max_storage_buffers_per_shader_stage < 10 {
log::info!("gpu: {} has too few storage buffers per stage", info.name);
Expand Down Expand Up @@ -653,6 +657,20 @@ impl Gpu {
/// normally reset a hung GPU much sooner).
const READBACK_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(60);

/// Whether to turn down an adapter of `device_type`: a software rasterizer (llvmpipe / lavapipe,
/// WARP) is slower than the CPU pipeline, so it is refused unless `allow_software`.
fn refuse_adapter(device_type: wgpu::DeviceType, allow_software: bool) -> bool {
device_type == wgpu::DeviceType::Cpu && !allow_software
}

/// `LIGHTCRAFT_GPU_ALLOW_SOFTWARE=1`: accept a software adapter. For tests on machines without a
/// GPU (CI runners: Mesa lavapipe on Linux, WARP on Windows), so the CPU ↔ GPU equivalence tests
/// run there instead of skipping; the app never sets it (software rendering is slower than the CPU
/// pipeline).
fn software_allowed() -> bool {
std::env::var("LIGHTCRAFT_GPU_ALLOW_SOFTWARE").is_ok_and(|v| matches!(v.trim().to_ascii_lowercase().as_str(), "1" | "true" | "yes" | "on"))
}

/// `LIGHTCRAFT_GPU_LIMITS`: lower the device limits, e.g. to reproduce a smaller adapter.
/// `webgpu` / `downlevel` = 128 MiB storage bindings and 256 MiB buffers (the WebGPU defaults),
/// `<n>` = n MiB storage bindings and 2n MiB buffers. Returns (binding bytes, buffer bytes).
Expand Down Expand Up @@ -964,6 +982,17 @@ mod tests {
println!("CHILD: survived");
}

#[test]
fn software_adapters_need_the_opt_in() {
use wgpu::DeviceType::{Cpu, DiscreteGpu, IntegratedGpu, Other, VirtualGpu};
assert!(super::refuse_adapter(Cpu, false), "llvmpipe / WARP are refused by default");
assert!(!super::refuse_adapter(Cpu, true), "LIGHTCRAFT_GPU_ALLOW_SOFTWARE accepts them");
for t in [DiscreteGpu, IntegratedGpu, VirtualGpu, Other] {
assert!(!super::refuse_adapter(t, false), "{t:?}");
assert!(!super::refuse_adapter(t, true), "{t:?}");
}
}

#[test]
fn dispatches_stay_within_the_workgroup_limit() {
// 1-D kernels over a 100 MP image and 2-D ones over 16k × 16k stay under 65535 per axis
Expand Down
Loading
Loading