From 4bb6cb521dea27b09c4c5d2ed6220653a5b74781 Mon Sep 17 00:00:00 2001 From: Geordie Moffatt Date: Tue, 1 Dec 2026 23:52:47 -0800 Subject: [PATCH 1/8] chore: rustfmt the workspace with current nightly The Lint workflow formats with the latest nightly rustfmt, and cargo +nightly fmt --all --check fails on every pull request against this branch before reaching anything the pull request changes: 117 hunks in 25 files, all in code this branch added on top of upstream 826ad5d2, which itself formats clean. This is the output of cargo +nightly fmt --all with rustfmt 1.12.0-nightly (bdf712ee87 2026-11-21), the version the failing runs used. Formatting only. Signed-off-by: Geordie Moffatt --- lore-base/src/fs/lock.rs | 6 +- lore-client/src/cli/commands/repository.rs | 5 +- lore-revision/src/branch.rs | 5 +- lore-revision/src/branch/push.rs | 12 +- lore-revision/src/file/dirty.rs | 18 +- lore-revision/src/instance.rs | 8 +- lore-revision/src/lib.rs | 4 +- lore-revision/src/projfs/serve.rs | 11 +- lore-revision/src/repository.rs | 4 +- lore-revision/src/repository/clone.rs | 11 +- lore-revision/src/vfs/fuse.rs | 37 +- lore-revision/tests/cross_vcs.rs | 17 +- lore-revision/tests/vfs_fuse.rs | 453 ++++++++++-------- lore-revision/tests/vfs_projfs.rs | 66 ++- lore-server/src/auth/jwt.rs | 8 +- .../grpc/handlers/repository_metadata_get.rs | 4 +- lore-server/src/grpc/mod.rs | 13 +- lore-server/src/grpc/server.rs | 19 +- lore-server/src/grpc/tower/build_guard.rs | 18 +- lore-server/src/protocol/storage/session.rs | 61 ++- lore-server/src/quic/storage_service.rs | 1 - lore-server/src/quic/storage_service_v4.rs | 18 +- lore-server/src/server.rs | 11 +- lore-transport/src/grpc/mod.rs | 5 +- lore/src/repository.rs | 10 +- 25 files changed, 496 insertions(+), 329 deletions(-) diff --git a/lore-base/src/fs/lock.rs b/lore-base/src/fs/lock.rs index 7d1d96da6..17f6b3e97 100644 --- a/lore-base/src/fs/lock.rs +++ b/lore-base/src/fs/lock.rs @@ -179,7 +179,11 @@ mod tests { Ok(_) => panic!("second acquisition must not succeed while held"), Err(err) => err, }; - assert_eq!(err.kind(), std::io::ErrorKind::TimedOut, "unexpected error: {err}"); + assert_eq!( + err.kind(), + std::io::ErrorKind::TimedOut, + "unexpected error: {err}" + ); assert!( elapsed >= Duration::from_secs(1) && elapsed < Duration::from_secs(8), "acquisition should time out promptly, took {elapsed:?}" diff --git a/lore-client/src/cli/commands/repository.rs b/lore-client/src/cli/commands/repository.rs index 77a52b27c..0c7f9d59f 100644 --- a/lore-client/src/cli/commands/repository.rs +++ b/lore-client/src/cli/commands/repository.rs @@ -1156,7 +1156,10 @@ pub fn handle_repository_unmount(_globals: LoreGlobalArgs, args: &RepositoryUnmo 0 } Ok(status) => { - eprintln!("fusermount3 failed to unmount {}: {status}", args.mountpoint); + eprintln!( + "fusermount3 failed to unmount {}: {status}", + args.mountpoint + ); 1 } Err(err) => { diff --git a/lore-revision/src/branch.rs b/lore-revision/src/branch.rs index 429e5a68c..53fb7ff8c 100644 --- a/lore-revision/src/branch.rs +++ b/lore-revision/src/branch.rs @@ -885,7 +885,10 @@ pub async fn load_unpinned_push( /// Drop the note of [`store_unpinned_push`]: the head is pinned on the remote, or gone from it. pub async fn clear_unpinned_push(repository: Arc, branch: BranchId) { - if load_unpinned_push(repository.clone(), branch).await.is_some() { + if load_unpinned_push(repository.clone(), branch) + .await + .is_some() + { let _ = mutable_store(repository, UNPINNED_PUSH, branch, Hash::default()).await; } } diff --git a/lore-revision/src/branch/push.rs b/lore-revision/src/branch/push.rs index b2d126900..cb94d093c 100644 --- a/lore-revision/src/branch/push.rs +++ b/lore-revision/src/branch/push.rs @@ -964,8 +964,13 @@ async fn push_revisions( if repository.is_link() { // Noted in the workspace before the remote is asked, and written out: this // push may not live to see the answer, and a note still in memory dies with it - branch::store_unpinned_push(repository.clone(), branch, link_base, current_revision) - .await; + branch::store_unpinned_push( + repository.clone(), + branch, + link_base, + current_revision, + ) + .await; let _ = repository.flush(false).await; } @@ -1215,8 +1220,7 @@ async fn withdraw_link_heads(moved: Vec) { let Ok(remote) = link.repository.remote().await else { continue; }; - let Ok(status) = - branch::load_remote(remote.clone(), link.repository.id, link.branch).await + let Ok(status) = branch::load_remote(remote.clone(), link.repository.id, link.branch).await else { continue; }; diff --git a/lore-revision/src/file/dirty.rs b/lore-revision/src/file/dirty.rs index 23b13b78a..bad51045f 100644 --- a/lore-revision/src/file/dirty.rs +++ b/lore-revision/src/file/dirty.rs @@ -241,14 +241,23 @@ pub async fn dirty_explicit( for relative_path in &paths { match action { ExplicitDirty::Add => { - dirty_add(repository.clone(), state.clone(), relative_path, stats.clone()).await?; + dirty_add( + repository.clone(), + state.clone(), + relative_path, + stats.clone(), + ) + .await?; changed = true; } ExplicitDirty::Modify => { let Some(link) = resolve_dirty_link(&repository, &state, &state_current, relative_path).await else { - lore_trace!("dirty_explicit modify: no node for {}", relative_path.as_str()); + lore_trace!( + "dirty_explicit modify: no node for {}", + relative_path.as_str() + ); continue; }; state @@ -261,7 +270,10 @@ pub async fn dirty_explicit( let Some(link) = resolve_dirty_link(&repository, &state, &state_current, relative_path).await else { - lore_trace!("dirty_explicit delete: no node for {}", relative_path.as_str()); + lore_trace!( + "dirty_explicit delete: no node for {}", + relative_path.as_str() + ); continue; }; dirty_delete( diff --git a/lore-revision/src/instance.rs b/lore-revision/src/instance.rs index f2a3d8ba5..562908537 100644 --- a/lore-revision/src/instance.rs +++ b/lore-revision/src/instance.rs @@ -411,7 +411,9 @@ pub async fn load_current_anchor( // file-based `.urc/current` (32-byte revision + 16-byte branch). Migration // into the mutable store only runs in write-mode contexts, so a read-only // command on a repository with unmigrated anchors would otherwise fail. - let dot_path = repository.require_metadata_path()?.join(repository.format.dot_dir()); + let dot_path = repository + .require_metadata_path()? + .join(repository.format.dot_dir()); let current_anchor_path = dot_path.join(crate::anchor::CURRENT); if current_anchor_path.exists() && let Ok((file_revision, file_branch)) = @@ -447,7 +449,9 @@ pub async fn load_staged_revision( // file (32-byte revision + 16-byte branch — branch is ignored here, the // staged anchor only carries a revision). Mirrors load_current_anchor's // file-based fallback for read-only commands on unmigrated repositories. - let dot_path = repository.require_metadata_path()?.join(repository.format.dot_dir()); + let dot_path = repository + .require_metadata_path()? + .join(repository.format.dot_dir()); let staged_anchor_path = dot_path.join(crate::anchor::STAGED); if staged_anchor_path.exists() && let Ok((file_revision, _branch)) = diff --git a/lore-revision/src/lib.rs b/lore-revision/src/lib.rs index 72b8b0454..17fa0041d 100644 --- a/lore-revision/src/lib.rs +++ b/lore-revision/src/lib.rs @@ -53,10 +53,10 @@ pub mod state; pub mod store; pub mod util; -#[cfg(feature = "vfs")] -pub mod vfs; #[cfg(all(target_family = "windows", feature = "vfs"))] pub mod projfs; +#[cfg(feature = "vfs")] +pub mod vfs; //#[cfg(all(target_family = "windows", feature = "vfs"))] //pub mod swfs; diff --git a/lore-revision/src/projfs/serve.rs b/lore-revision/src/projfs/serve.rs index 28fddde5e..8da7e091f 100644 --- a/lore-revision/src/projfs/serve.rs +++ b/lore-revision/src/projfs/serve.rs @@ -469,11 +469,12 @@ pub fn serve( /// Name of the per-mountpoint Win32 event `unmount` uses to signal the serving process. fn stop_event_name(mountpoint: &Path) -> Vec { - let canonical = - std::fs::canonicalize(mountpoint).unwrap_or_else(|_| mountpoint.to_path_buf()); + let canonical = std::fs::canonicalize(mountpoint).unwrap_or_else(|_| mountpoint.to_path_buf()); let key = canonical.to_string_lossy().to_lowercase(); let hash = xxhash_rust::xxh3::xxh3_64(key.as_bytes()); - let mut wide: Vec = format!("Local\\LoreVfsStop-{hash:016x}").encode_utf16().collect(); + let mut wide: Vec = format!("Local\\LoreVfsStop-{hash:016x}") + .encode_utf16() + .collect(); wide.push(0); wide } @@ -1172,7 +1173,9 @@ unsafe extern "system" fn get_placeholder_info( /// Build the ProjFS placeholder metadata for a resolved node: type, size, revision timestamps, /// and the provider/content identity ProjFS uses to detect stale placeholders. -async fn placeholder_info_for(resolved: &ResolvedNode) -> ProjectedFileSystem::PRJ_PLACEHOLDER_INFO { +async fn placeholder_info_for( + resolved: &ResolvedNode, +) -> ProjectedFileSystem::PRJ_PLACEHOLDER_INFO { let timestamp = ms_filetime(resolved.revision_timestamp_ms().await) as i64; // Safety: This type is safe to zero initialize but not marked with default in windows_sys diff --git a/lore-revision/src/repository.rs b/lore-revision/src/repository.rs index c3eaa13c2..87b846007 100644 --- a/lore-revision/src/repository.rs +++ b/lore-revision/src/repository.rs @@ -3537,7 +3537,9 @@ pub fn repository_remote(repository_path: impl AsRef) -> Result) -> Result<(), RepositoryError> { - let dot_path = repository.require_metadata_path()?.join(repository.format.dot_dir()); + let dot_path = repository + .require_metadata_path()? + .join(repository.format.dot_dir()); let config_path = dot_path.join(CONFIG); let config = load_config(config_path.as_path())?; diff --git a/lore-revision/src/repository/clone.rs b/lore-revision/src/repository/clone.rs index a88653340..791ea12eb 100644 --- a/lore-revision/src/repository/clone.rs +++ b/lore-revision/src/repository/clone.rs @@ -1324,16 +1324,14 @@ async fn clone_materialize( repository directory (CloneOptions::virtual_mountpoint)" ); return Err(NotSupported { - operation: "Virtual clone on Linux requires a separate mountpoint" - .to_string(), + operation: "Virtual clone on Linux requires a separate mountpoint".to_string(), } .into()); }; let overlay = PathBuf::from(format!("{}-overlay", mountpoint.display())); std::fs::create_dir_all(&mountpoint) .internal("Failed to create the mountpoint directory")?; - std::fs::create_dir_all(&overlay) - .internal("Failed to create the overlay directory")?; + std::fs::create_dir_all(&overlay).internal("Failed to create the overlay directory")?; crate::repository::write_mount_binding( &_path.join(repository.format.dot_dir()), &mountpoint, @@ -1361,7 +1359,10 @@ async fn clone_materialize( } .into()); } - #[cfg(all(feature = "vfs", not(any(target_family = "windows", target_os = "linux"))))] + #[cfg(all( + feature = "vfs", + not(any(target_family = "windows", target_os = "linux")) + ))] { lore_error!("Virtual repositories not yet supported on this platform"); return Err(NotSupported { diff --git a/lore-revision/src/vfs/fuse.rs b/lore-revision/src/vfs/fuse.rs index 7e99e40a6..165e45792 100644 --- a/lore-revision/src/vfs/fuse.rs +++ b/lore-revision/src/vfs/fuse.rs @@ -48,7 +48,6 @@ use fuser::INodeNo; use fuser::KernelConfig; use fuser::LockOwner; use fuser::MountOption; -use fuser::SessionACL; use fuser::OpenAccMode; use fuser::OpenFlags; use fuser::RenameFlags; @@ -61,13 +60,13 @@ use fuser::ReplyEntry; use fuser::ReplyOpen; use fuser::ReplyWrite; use fuser::Request; +use fuser::SessionACL; use fuser::TimeOrNow; use fuser::WriteFlags; -use parking_lot::Mutex; - use lore_base::lore_spawn; use lore_base::runtime::LORE_CONTEXT; use lore_base::runtime::runtime; +use parking_lot::Mutex; use crate::file::dirty::ExplicitDirty; use crate::interface::ExecutionContext; @@ -389,9 +388,11 @@ impl LoreFuse { return; }; let repository = self.base_module(); - if let Err(err) = - self.block_on(crate::file::dirty::dirty_explicit(repository, vec![path], action)) - { + if let Err(err) = self.block_on(crate::file::dirty::dirty_explicit( + repository, + vec![path], + action, + )) { lore_error!("vfs failed to mark {relative} dirty ({action:?}): {err}"); } } @@ -405,7 +406,9 @@ impl LoreFuse { fn child_relative(&self, parent: INodeNo, name: &OsStr) -> Option { let name = name.to_str()?; let table = self.inodes.lock(); - table.path(parent.0).map(|parent_path| join_path(parent_path, name)) + table + .path(parent.0) + .map(|parent_path| join_path(parent_path, name)) } /// Start a background thread that reconciles the mount to the branch anchor whenever it @@ -513,7 +516,9 @@ async fn reseed_whiteouts( }; let mut deleted = Vec::new(); for path in paths { - if let Ok(link) = staged.find_node_link(repository.clone(), path.as_str()).await + if let Ok(link) = staged + .find_node_link(repository.clone(), path.as_str()) + .await && link.is_valid() && let Ok(node) = staged.node(repository.clone(), link.node).await && node.is_dirty_delete() @@ -650,7 +655,8 @@ impl Filesystem for LoreFuse { let execution = self.execution.clone(); let repository = self.base_module(); let _ = thread::spawn(move || { - runtime().block_on(LORE_CONTEXT.scope(execution, reseed_whiteouts(&whiteouts, repository))); + runtime() + .block_on(LORE_CONTEXT.scope(execution, reseed_whiteouts(&whiteouts, repository))); }) .join(); // Reconcile the served revision if the branch anchor advances while mounted. @@ -1091,7 +1097,13 @@ impl Filesystem for LoreFuse { ); match self.current_attr(inode, &relative) { Ok(Some(attr)) => { - reply.created(&TTL, &attr, Generation(0), FileHandle(fh), FopenFlags::empty()); + reply.created( + &TTL, + &attr, + Generation(0), + FileHandle(fh), + FopenFlags::empty(), + ); } Ok(None) | Err(_) => reply.error(Errno::EIO), } @@ -1276,7 +1288,10 @@ pub fn serve( }); } - lore_info!("Serving Lore FUSE mount at {}", mountpoint.as_ref().display()); + lore_info!( + "Serving Lore FUSE mount at {}", + mountpoint.as_ref().display() + ); match fuse.run(mountpoint) { Ok(()) => lore_info!("Lore FUSE mount exited"), Err(err) => lore_error!("Lore FUSE mount failed: {err}"), diff --git a/lore-revision/tests/cross_vcs.rs b/lore-revision/tests/cross_vcs.rs index 039ad2be6..43f971fbc 100644 --- a/lore-revision/tests/cross_vcs.rs +++ b/lore-revision/tests/cross_vcs.rs @@ -117,8 +117,7 @@ mod tests { .expect("Failed to initialize repository"); // Load the ignore filter from disk exactly as a CLI open would. - let filter = - repository::load_filter(&working_path).expect("load filter"); + let filter = repository::load_filter(&working_path).expect("load filter"); let mut repository = RepositoryContext::new( Some(working_path.clone()), immutable, @@ -403,8 +402,7 @@ mod tests { #[test] fn mountpoint_binding_splits_working_tree_from_metadata() { let mountpoint = generate_tempdir(); - let workspace = - build_workspace_full(None, Some((mountpoint.to_path_buf(), true))); + let workspace = build_workspace_full(None, Some((mountpoint.to_path_buf(), true))); assert_eq!( workspace.repository.require_path().expect("working tree"), @@ -444,15 +442,10 @@ mod tests { #[test] fn scan_and_sync_refuse_dead_mountpoint_binding() { let mountpoint = generate_tempdir(); - let workspace = - build_workspace_full(None, Some((mountpoint.to_path_buf(), false))); + let workspace = build_workspace_full(None, Some((mountpoint.to_path_buf(), false))); - let error = stage_path( - &workspace, - workspace.execution.clone(), - mountpoint.path(), - ) - .expect_err("a scan against a dead mountpoint binding must be refused"); + let error = stage_path(&workspace, workspace.execution.clone(), mountpoint.path()) + .expect_err("a scan against a dead mountpoint binding must be refused"); assert!( error.contains("not") && error.contains("mounted"), "unexpected error: {error}" diff --git a/lore-revision/tests/vfs_fuse.rs b/lore-revision/tests/vfs_fuse.rs index fc9505960..bf07a27a0 100644 --- a/lore-revision/tests/vfs_fuse.rs +++ b/lore-revision/tests/vfs_fuse.rs @@ -64,89 +64,96 @@ mod tests { return; } - let (immutable_store, mutable_store, execution) = - runtime().block_on(test_store_create()).expect("Failed to create stores"); + let (immutable_store, mutable_store, execution) = runtime() + .block_on(test_store_create()) + .expect("Failed to create stores"); let repository_id = RepositoryId::from(uuid::Uuid::now_v7()); // Build a committed repository (readme.md + src/test.txt) in the in-memory store. let immutable = immutable_store.clone(); let mutable = mutable_store.clone(); - let (repository, state) = runtime().block_on(LORE_CONTEXT.scope(execution.clone(), async move { - let tempdir = generate_tempdir(); - let path = tempdir.to_path_buf(); - std::fs::create_dir_all(path.as_path()).expect("Create directory failed"); - let default_branch_id = Context::from(uuid::Uuid::now_v7()); - let write_token = repository::RepositoryWriteToken::acquire(path.as_path()).await; - let created_repo = repository::create_local( - path.as_path(), - &write_token, - repository_id, - default_branch_id, - branch::DEFAULT_DEFAULT_NAME.to_string(), - repository::RepositoryConfig::default(), - false, - ) - .await - .expect("Failed to initialize repository"); - - let repository = Arc::new( - RepositoryContext::new( - Some(path.clone()), - immutable, - mutable, + let (repository, state) = + runtime().block_on(LORE_CONTEXT.scope(execution.clone(), async move { + let tempdir = generate_tempdir(); + let path = tempdir.to_path_buf(); + std::fs::create_dir_all(path.as_path()).expect("Create directory failed"); + let default_branch_id = Context::from(uuid::Uuid::now_v7()); + let write_token = repository::RepositoryWriteToken::acquire(path.as_path()).await; + let created_repo = repository::create_local( + path.as_path(), + &write_token, repository_id, - created_repo.instance_id, - Err(ProtocolError::from(NoRemote)), - Arc::default(), - RepositoryFormat::Lore, + default_branch_id, + branch::DEFAULT_DEFAULT_NAME.to_string(), + repository::RepositoryConfig::default(), + false, ) - .with_write_token(write_token.share()), - ); + .await + .expect("Failed to initialize repository"); + + let repository = Arc::new( + RepositoryContext::new( + Some(path.clone()), + immutable, + mutable, + repository_id, + created_repo.instance_id, + Err(ProtocolError::from(NoRemote)), + Arc::default(), + RepositoryFormat::Lore, + ) + .with_write_token(write_token.share()), + ); - lore_revision::instance::store_current_anchor_branch(&repository, default_branch_id) + lore_revision::instance::store_current_anchor_branch( + &repository, + default_branch_id, + ) .await .expect("Failed to store anchor branch"); - { - let mut f = std::fs::File::create(path.join("readme.md")).expect("create readme"); - f.write_all(b"hello world").expect("write readme"); - } - std::fs::create_dir_all(path.join("src")).expect("create src"); - { - let mut f = std::fs::File::create(path.join("src/test.txt")).expect("create file"); - f.write_all(b"hello").expect("write file"); - } - - let paths = LoreArray::from_vec(vec![LoreString::from(&path)]); - file::stage::stage( - repository.clone(), - &write_token, - paths, - StageOptions { - case_change: stage::StageCaseChange::Error, - node_flags: NodeFlags::NoFlags, - file_id: None, - no_children: false, - scan: true, - }, - ) - .await - .expect("Stage failed"); + { + let mut f = + std::fs::File::create(path.join("readme.md")).expect("create readme"); + f.write_all(b"hello world").expect("write readme"); + } + std::fs::create_dir_all(path.join("src")).expect("create src"); + { + let mut f = + std::fs::File::create(path.join("src/test.txt")).expect("create file"); + f.write_all(b"hello").expect("write file"); + } - Box::pin(commit::commit( - repository.clone(), - &write_token, - CommitOptions::new("Initial commit".to_string()), - )) - .await - .expect("Commit failed"); + let paths = LoreArray::from_vec(vec![LoreString::from(&path)]); + file::stage::stage( + repository.clone(), + &write_token, + paths, + StageOptions { + case_change: stage::StageCaseChange::Error, + node_flags: NodeFlags::NoFlags, + file_id: None, + no_children: false, + scan: true, + }, + ) + .await + .expect("Stage failed"); - let (state, _, _) = State::deserialize_current_and_staged(repository.clone()) + Box::pin(commit::commit( + repository.clone(), + &write_token, + CommitOptions::new("Initial commit".to_string()), + )) .await - .expect("Deserialize failed"); + .expect("Commit failed"); - (repository, state) - })); + let (state, _, _) = State::deserialize_current_and_staged(repository.clone()) + .await + .expect("Deserialize failed"); + + (repository, state) + })); // A real backing directory holding a pass-through file (as a git working tree would). let backing = generate_tempdir(); @@ -173,9 +180,15 @@ mod tests { .into_iter() .map(|e| e.file_name().to_string_lossy().to_string()) .collect(); - assert!(names.contains("readme.md"), "projected file missing: {names:?}"); + assert!( + names.contains("readme.md"), + "projected file missing: {names:?}" + ); assert!(names.contains("src"), "projected dir missing: {names:?}"); - assert!(names.contains("code.py"), "pass-through file missing: {names:?}"); + assert!( + names.contains("code.py"), + "pass-through file missing: {names:?}" + ); // Lazy hydration of projected content. assert_eq!( @@ -228,7 +241,10 @@ mod tests { node.is_dirty_modify() } })); - assert!(dirty, "readme.md should be dirty-modify after an in-place edit"); + assert!( + dirty, + "readme.md should be dirty-modify after an in-place edit" + ); // Create a new file through the mount. { @@ -267,7 +283,10 @@ mod tests { .is_dirty_add(), _ => false, }; - let deleted = match state.find_node_link(repository.clone(), "src/test.txt").await { + let deleted = match state + .find_node_link(repository.clone(), "src/test.txt") + .await + { Ok(link) if link.is_valid() => state .node(repository.clone(), link.node) .await @@ -291,7 +310,9 @@ mod tests { Some(backing.path().to_path_buf()), execution.clone(), ); - let session = fuse.spawn(remount_point.path()).expect("Failed to remount FUSE"); + let session = fuse + .spawn(remount_point.path()) + .expect("Failed to remount FUSE"); let _ = read_dir_ready(remount_point.path()).expect("read_dir on remount"); // The delete persists: its whiteout is re-seeded from the staged dirty-delete node. @@ -301,11 +322,13 @@ mod tests { ); // The create and the in-place edit persist via the overlay. assert_eq!( - std::fs::read(remount_point.path().join("notes.txt")).expect("read notes after remount"), + std::fs::read(remount_point.path().join("notes.txt")) + .expect("read notes after remount"), b"notes" ); assert_eq!( - std::fs::read(remount_point.path().join("readme.md")).expect("read readme after remount"), + std::fs::read(remount_point.path().join("readme.md")) + .expect("read readme after remount"), b"goodbye" ); @@ -323,8 +346,9 @@ mod tests { return; } - let (immutable_store, mutable_store, execution) = - runtime().block_on(test_store_create()).expect("Failed to create stores"); + let (immutable_store, mutable_store, execution) = runtime() + .block_on(test_store_create()) + .expect("Failed to create stores"); let repository_id = RepositoryId::from(uuid::Uuid::now_v7()); let immutable = immutable_store.clone(); @@ -362,9 +386,12 @@ mod tests { .with_write_token(write_token.share()), ); - lore_revision::instance::store_current_anchor_branch(&repository, default_branch_id) - .await - .expect("Failed to store anchor branch"); + lore_revision::instance::store_current_anchor_branch( + &repository, + default_branch_id, + ) + .await + .expect("Failed to store anchor branch"); { let mut f = @@ -515,90 +542,96 @@ mod tests { return; } - let (immutable_store, mutable_store, execution) = - runtime().block_on(test_store_create()).expect("Failed to create stores"); + let (immutable_store, mutable_store, execution) = runtime() + .block_on(test_store_create()) + .expect("Failed to create stores"); let repository_id = RepositoryId::from(uuid::Uuid::now_v7()); let immutable = immutable_store.clone(); let mutable = mutable_store.clone(); - let (repository, state) = runtime().block_on(LORE_CONTEXT.scope(execution.clone(), async move { - let tempdir = generate_tempdir(); - let path = tempdir.to_path_buf(); - std::fs::create_dir_all(path.as_path()).expect("Create directory failed"); - let default_branch_id = Context::from(uuid::Uuid::now_v7()); - let write_token = repository::RepositoryWriteToken::acquire(path.as_path()).await; - let created_repo = repository::create_local( - path.as_path(), - &write_token, - repository_id, - default_branch_id, - branch::DEFAULT_DEFAULT_NAME.to_string(), - repository::RepositoryConfig::default(), - false, - ) - .await - .expect("Failed to initialize repository"); - - let repository = Arc::new( - RepositoryContext::new( - Some(path.clone()), - immutable, - mutable, + let (repository, state) = + runtime().block_on(LORE_CONTEXT.scope(execution.clone(), async move { + let tempdir = generate_tempdir(); + let path = tempdir.to_path_buf(); + std::fs::create_dir_all(path.as_path()).expect("Create directory failed"); + let default_branch_id = Context::from(uuid::Uuid::now_v7()); + let write_token = repository::RepositoryWriteToken::acquire(path.as_path()).await; + let created_repo = repository::create_local( + path.as_path(), + &write_token, repository_id, - created_repo.instance_id, - Err(ProtocolError::from(NoRemote)), - Arc::default(), - RepositoryFormat::Lore, + default_branch_id, + branch::DEFAULT_DEFAULT_NAME.to_string(), + repository::RepositoryConfig::default(), + false, ) - .with_write_token(write_token.share()), - ); + .await + .expect("Failed to initialize repository"); + + let repository = Arc::new( + RepositoryContext::new( + Some(path.clone()), + immutable, + mutable, + repository_id, + created_repo.instance_id, + Err(ProtocolError::from(NoRemote)), + Arc::default(), + RepositoryFormat::Lore, + ) + .with_write_token(write_token.share()), + ); - lore_revision::instance::store_current_anchor_branch(&repository, default_branch_id) + lore_revision::instance::store_current_anchor_branch( + &repository, + default_branch_id, + ) .await .expect("Failed to store anchor branch"); - { - let mut f = std::fs::File::create(path.join("readme.md")).expect("create readme"); - f.write_all(b"hello").expect("write readme"); - } - let paths = LoreArray::from_vec(vec![LoreString::from(&path)]); - file::stage::stage( - repository.clone(), - &write_token, - paths, - StageOptions { - case_change: stage::StageCaseChange::Error, - node_flags: NodeFlags::NoFlags, - file_id: None, - no_children: false, - scan: true, - }, - ) - .await - .expect("Stage failed"); - Box::pin(commit::commit( - repository.clone(), - &write_token, - CommitOptions::new("rev1".to_string()), - )) - .await - .expect("Commit failed"); - - let (state, _, _) = State::deserialize_current_and_staged(repository.clone()) + { + let mut f = + std::fs::File::create(path.join("readme.md")).expect("create readme"); + f.write_all(b"hello").expect("write readme"); + } + let paths = LoreArray::from_vec(vec![LoreString::from(&path)]); + file::stage::stage( + repository.clone(), + &write_token, + paths, + StageOptions { + case_change: stage::StageCaseChange::Error, + node_flags: NodeFlags::NoFlags, + file_id: None, + no_children: false, + scan: true, + }, + ) .await - .expect("Deserialize failed"); + .expect("Stage failed"); + Box::pin(commit::commit( + repository.clone(), + &write_token, + CommitOptions::new("rev1".to_string()), + )) + .await + .expect("Commit failed"); - // Simulate a workspace whose anchor was never persisted (clone --virtual before - // the anchor fix): zero out the current anchor after the commit stored it. - lore_revision::instance::store_current_anchor( - &repository, - lore_base::types::Hash::default(), - ) - .await - .expect("zero the anchor"); + let (state, _, _) = State::deserialize_current_and_staged(repository.clone()) + .await + .expect("Deserialize failed"); - (repository, state) - })); + // Simulate a workspace whose anchor was never persisted (clone --virtual before + // the anchor fix): zero out the current anchor after the commit stored it. + lore_revision::instance::store_current_anchor( + &repository, + lore_base::types::Hash::default(), + ) + .await + .expect("zero the anchor"); + + (repository, state) + })); let backing = generate_tempdir(); let mountpoint = generate_tempdir(); @@ -633,8 +666,9 @@ mod tests { return; } - let (immutable_store, mutable_store, execution) = - runtime().block_on(test_store_create()).expect("Failed to create stores"); + let (immutable_store, mutable_store, execution) = runtime() + .block_on(test_store_create()) + .expect("Failed to create stores"); let repository_id = RepositoryId::from(uuid::Uuid::now_v7()); // Keep the working directory alive so a second revision can be staged later. @@ -650,66 +684,67 @@ mod tests { }; // Revision 1: a single readme.md. - let (repository, write_token) = runtime().block_on(LORE_CONTEXT.scope(execution.clone(), { - let immutable = immutable_store.clone(); - let mutable = mutable_store.clone(); - let working_path = working_path.clone(); - async move { - std::fs::create_dir_all(&working_path).expect("create working dir"); - let default_branch_id = Context::from(uuid::Uuid::now_v7()); - let write_token = - repository::RepositoryWriteToken::acquire(&working_path).await; - let created = repository::create_local( - &working_path, - &write_token, - repository_id, - default_branch_id, - branch::DEFAULT_DEFAULT_NAME.to_string(), - repository::RepositoryConfig::default(), - false, - ) - .await - .expect("init repo"); - let repository = Arc::new( - RepositoryContext::new( - Some(working_path.clone()), - immutable, - mutable, + let (repository, write_token) = + runtime().block_on(LORE_CONTEXT.scope(execution.clone(), { + let immutable = immutable_store.clone(); + let mutable = mutable_store.clone(); + let working_path = working_path.clone(); + async move { + std::fs::create_dir_all(&working_path).expect("create working dir"); + let default_branch_id = Context::from(uuid::Uuid::now_v7()); + let write_token = + repository::RepositoryWriteToken::acquire(&working_path).await; + let created = repository::create_local( + &working_path, + &write_token, repository_id, - created.instance_id, - Err(ProtocolError::from(NoRemote)), - Arc::default(), - RepositoryFormat::Lore, + default_branch_id, + branch::DEFAULT_DEFAULT_NAME.to_string(), + repository::RepositoryConfig::default(), + false, ) - .with_write_token(write_token.share()), - ); - lore_revision::instance::store_current_anchor_branch( - &repository, - default_branch_id, - ) - .await - .expect("anchor branch"); - - { - let mut f = std::fs::File::create(working_path.join("readme.md")) - .expect("create readme"); - f.write_all(b"hello").expect("write readme"); - } - let paths = LoreArray::from_vec(vec![LoreString::from(&working_path)]); - file::stage::stage(repository.clone(), &write_token, paths, stage_options()) .await - .expect("stage rev1"); - Box::pin(commit::commit( - repository.clone(), - &write_token, - CommitOptions::new("rev1".to_string()), - )) - .await - .expect("commit rev1"); + .expect("init repo"); + let repository = Arc::new( + RepositoryContext::new( + Some(working_path.clone()), + immutable, + mutable, + repository_id, + created.instance_id, + Err(ProtocolError::from(NoRemote)), + Arc::default(), + RepositoryFormat::Lore, + ) + .with_write_token(write_token.share()), + ); + lore_revision::instance::store_current_anchor_branch( + &repository, + default_branch_id, + ) + .await + .expect("anchor branch"); + + { + let mut f = std::fs::File::create(working_path.join("readme.md")) + .expect("create readme"); + f.write_all(b"hello").expect("write readme"); + } + let paths = LoreArray::from_vec(vec![LoreString::from(&working_path)]); + file::stage::stage(repository.clone(), &write_token, paths, stage_options()) + .await + .expect("stage rev1"); + Box::pin(commit::commit( + repository.clone(), + &write_token, + CommitOptions::new("rev1".to_string()), + )) + .await + .expect("commit rev1"); - (repository, write_token) - } - })); + (repository, write_token) + } + })); let state1 = runtime().block_on(LORE_CONTEXT.scope(execution.clone(), { let repository = repository.clone(); diff --git a/lore-revision/tests/vfs_projfs.rs b/lore-revision/tests/vfs_projfs.rs index 986531c75..5364ec8c8 100644 --- a/lore-revision/tests/vfs_projfs.rs +++ b/lore-revision/tests/vfs_projfs.rs @@ -244,7 +244,10 @@ mod tests { return false; }; let state = staged.unwrap_or_else(|| current.clone()); - match state.find_node_link(repository.clone(), path.as_str()).await { + match state + .find_node_link(repository.clone(), path.as_str()) + .await + { Ok(link) if link.is_valid() => state .node(repository.clone(), link.node) .await @@ -265,7 +268,9 @@ mod tests { eprintln!("skipping ProjFS mount test: ProjectedFSLib.dll is not available"); return; } - let _guard = SERVE_LOCK.lock().unwrap_or_else(|poison| poison.into_inner()); + let _guard = SERVE_LOCK + .lock() + .unwrap_or_else(|poison| poison.into_inner()); let fixture = build_repository(&[ ("readme.md", b"hello world"), @@ -284,11 +289,9 @@ mod tests { fixture.state.clone(), fixture.execution.clone(), ); - if !wait_for(Duration::from_secs(10), || mountpoint - .path() - .join("readme.md") - .exists()) - { + if !wait_for(Duration::from_secs(10), || { + mountpoint.path().join("readme.md").exists() + }) { if serve_thread.is_finished() { panic!("serve exited early: {:?}", serve_thread.join()); } @@ -306,7 +309,10 @@ mod tests { .flatten() .map(|e| e.file_name().to_string_lossy().to_string()) .collect(); - assert!(names.contains("readme.md"), "projected file missing: {names:?}"); + assert!( + names.contains("readme.md"), + "projected file missing: {names:?}" + ); assert!(names.contains("src"), "projected dir missing: {names:?}"); // Lazy hydration of projected content. @@ -452,7 +458,9 @@ mod tests { eprintln!("skipping ProjFS reconcile test: ProjectedFSLib.dll is not available"); return; } - let _guard = SERVE_LOCK.lock().unwrap_or_else(|poison| poison.into_inner()); + let _guard = SERVE_LOCK + .lock() + .unwrap_or_else(|poison| poison.into_inner()); let fixture = build_repository(&[("readme.md", b"hello")]); @@ -555,7 +563,9 @@ mod tests { eprintln!("skipping ProjFS soak: ProjectedFSLib.dll is not available"); return; } - let _guard = SERVE_LOCK.lock().unwrap_or_else(|poison| poison.into_inner()); + let _guard = SERVE_LOCK + .lock() + .unwrap_or_else(|poison| poison.into_inner()); let iterations: usize = std::env::var("LORE_VFS_SOAK_ITERS") .ok() @@ -564,7 +574,10 @@ mod tests { let mut files: Vec<(String, Vec)> = Vec::new(); for index in 0..10 { - files.push((format!("docs/d{index:02}.md"), format!("doc-{index} base").into_bytes())); + files.push(( + format!("docs/d{index:02}.md"), + format!("doc-{index} base").into_bytes(), + )); files.push(( format!("assets/a{index:02}.txt"), format!("asset-{index} base").into_bytes(), @@ -704,7 +717,12 @@ mod tests { // Repository internals never leak into tracking. assert!( - !node_state(&fixture.repository, &fixture.execution, ".lore", is_dirty_any), + !node_state( + &fixture.repository, + &fixture.execution, + ".lore", + is_dirty_any + ), ".lore must not be tracked" ); assert!( @@ -764,14 +782,17 @@ mod tests { eprintln!("skipping ProjFS soak: ProjectedFSLib.dll is not available"); return; } - let _guard = SERVE_LOCK.lock().unwrap_or_else(|poison| poison.into_inner()); + let _guard = SERVE_LOCK + .lock() + .unwrap_or_else(|poison| poison.into_inner()); let rounds: usize = std::env::var("LORE_VFS_SOAK_ROUNDS") .ok() .and_then(|value| value.parse().ok()) .unwrap_or(4); - let fixture = build_repository(&[("baseline.txt", b"baseline r1"), ("stable.txt", b"stable")]); + let fixture = + build_repository(&[("baseline.txt", b"baseline r1"), ("stable.txt", b"stable")]); let mountpoint = generate_tempdir(); let serve_thread = spawn_serve( @@ -847,7 +868,9 @@ mod tests { eprintln!("skipping ProjFS null-anchor test: ProjectedFSLib.dll is not available"); return; } - let _guard = SERVE_LOCK.lock().unwrap_or_else(|poison| poison.into_inner()); + let _guard = SERVE_LOCK + .lock() + .unwrap_or_else(|poison| poison.into_inner()); let fixture = build_repository(&[("readme.md", b"hello")]); @@ -904,7 +927,9 @@ mod tests { eprintln!("skipping ProjFS soak: ProjectedFSLib.dll is not available"); return; } - let _guard = SERVE_LOCK.lock().unwrap_or_else(|poison| poison.into_inner()); + let _guard = SERVE_LOCK + .lock() + .unwrap_or_else(|poison| poison.into_inner()); let fixture = build_repository(&[("readme.md", b"hello"), ("data/blob.bin", b"blob")]); @@ -924,9 +949,12 @@ mod tests { mutate_from_child(&format!( "Set-Content -LiteralPath '{root}\\readme.md' -Value 'edited in place' -NoNewline" )); - node_state(&fixture.repository, &fixture.execution, "readme.md", |node| { - node.is_dirty_modify() - }) + node_state( + &fixture.repository, + &fixture.execution, + "readme.md", + |node| node.is_dirty_modify(), + ) }), "in-place edit should be tracked as dirty-modify" ); diff --git a/lore-server/src/auth/jwt.rs b/lore-server/src/auth/jwt.rs index 6c810abec..93bd1ca90 100644 --- a/lore-server/src/auth/jwt.rs +++ b/lore-server/src/auth/jwt.rs @@ -258,7 +258,8 @@ mod tests { // write. #[test] fn resources_claim_permission_is_enforced() { - let repository = RepositoryId::from(Context::from_str("0102030405060708090a0b0c0d0e0f10").unwrap()); + let repository = + RepositoryId::from(Context::from_str("0102030405060708090a0b0c0d0e0f10").unwrap()); let resource_id = format!("urc-{repository}"); let read_only = token_with_resources(vec![ResourcePermission { @@ -290,7 +291,10 @@ mod tests { resource_id: resource_id.clone(), permission: vec![elevated.to_string()], }]); - assert!(verify_authorization(&token, repository).is_ok(), "{elevated} implies read"); + assert!( + verify_authorization(&token, repository).is_ok(), + "{elevated} implies read" + ); assert!( verify_write_authorization(&token, repository).is_ok(), "{elevated} implies write" diff --git a/lore-server/src/grpc/handlers/repository_metadata_get.rs b/lore-server/src/grpc/handlers/repository_metadata_get.rs index 9c4cc4c9a..cce76c77c 100644 --- a/lore-server/src/grpc/handlers/repository_metadata_get.rs +++ b/lore-server/src/grpc/handlers/repository_metadata_get.rs @@ -42,7 +42,9 @@ pub async fn handler( if let Some(token) = authorization.as_ref() && verify_authorization(token, repository_id).is_err() { - return Err(Status::permission_denied("Not authorized to access repository")); + return Err(Status::permission_denied( + "Not authorized to access repository", + )); } let execution = setup_execution(module_path!(), correlation_id, user_id); diff --git a/lore-server/src/grpc/mod.rs b/lore-server/src/grpc/mod.rs index d420d4ad8..4cd9bddf6 100644 --- a/lore-server/src/grpc/mod.rs +++ b/lore-server/src/grpc/mod.rs @@ -232,7 +232,8 @@ pub fn verify_write(request: &tonic::Request) -> Result<(), Status> { }; } }; - crate::auth::jwt::verify_write_authorization(authorization, repository).map_err(|_| write_denied()) + crate::auth::jwt::verify_write_authorization(authorization, repository) + .map_err(|_| write_denied()) } /// Authorize the repository a request names in its body, for services whose interceptor only @@ -564,15 +565,15 @@ mod tests { use tonic::metadata::MetadataValue; let repository_hex = "0194b726b34e72b0b45550b88a967076"; - let repository: RepositoryId = - Context::from_str(repository_hex).unwrap().into(); + let repository: RepositoryId = Context::from_str(repository_hex).unwrap().into(); let resource_id = format!("urc-{repository}"); let request_with = |permission: Vec| { let mut request = tonic::Request::new(()); - request - .metadata_mut() - .insert_bin(PARTITION_ID_KEY, MetadataValue::from_bytes(repository.data())); + request.metadata_mut().insert_bin( + PARTITION_ID_KEY, + MetadataValue::from_bytes(repository.data()), + ); request.extensions_mut().insert(AuthorizationToken { resources: Some(vec![ResourcePermission { resource_id: resource_id.clone(), diff --git a/lore-server/src/grpc/server.rs b/lore-server/src/grpc/server.rs index a82fabfc5..b926de5dc 100644 --- a/lore-server/src/grpc/server.rs +++ b/lore-server/src/grpc/server.rs @@ -66,22 +66,25 @@ type GrpcRouter = tonic::transport::server::Router< Stack< BuildGuardLayer, Stack< - GrpcResponseTraceLayer, - Stack< - ServiceBuilder>, + GrpcResponseTraceLayer, Stack< - LoreTracingLayer, + ServiceBuilder>, Stack< + LoreTracingLayer, Stack< - TraceLayer, MakeCorrelationIdSpan>, - CorrelationIdLayer, + Stack< + TraceLayer< + SharedClassifier, + MakeCorrelationIdSpan, + >, + CorrelationIdLayer, + >, + tower::layer::util::Identity, >, - tower::layer::util::Identity, >, >, >, >, - >, >; #[derive(Clone, Debug, Deserialize)] diff --git a/lore-server/src/grpc/tower/build_guard.rs b/lore-server/src/grpc/tower/build_guard.rs index 24ac24ef7..9b71b0e92 100644 --- a/lore-server/src/grpc/tower/build_guard.rs +++ b/lore-server/src/grpc/tower/build_guard.rs @@ -47,8 +47,12 @@ impl Default for BuildGuardConfig { pub(crate) enum Verdict { Allow, /// Mismatched, but the client asked for it and the server permits that. - AllowOverridden { client: String }, - Deny { message: String }, + AllowOverridden { + client: String, + }, + Deny { + message: String, + }, } /// Decide whether a peer may proceed, given its user agent. @@ -230,10 +234,7 @@ mod tests { enforce: true, allow_client_override: false, }; - assert!(matches!( - evaluate(&config, Some(&ua)), - Verdict::Deny { .. } - )); + assert!(matches!(evaluate(&config, Some(&ua)), Verdict::Deny { .. })); } #[test] @@ -242,7 +243,10 @@ mod tests { enforce: false, allow_client_override: false, }; - assert_eq!(evaluate(&config, Some(&ua_for("000000000000"))), Verdict::Allow); + assert_eq!( + evaluate(&config, Some(&ua_for("000000000000"))), + Verdict::Allow + ); assert_eq!(evaluate(&config, None), Verdict::Allow); } diff --git a/lore-server/src/protocol/storage/session.rs b/lore-server/src/protocol/storage/session.rs index 245710035..79637653a 100644 --- a/lore-server/src/protocol/storage/session.rs +++ b/lore-server/src/protocol/storage/session.rs @@ -202,7 +202,9 @@ mod tests { #[test] fn start_assigns_session_id_from_one() { let map = SessionMap::default(); - let (id, _) = map.start(random(), "corr-1".into(), String::new(), true, 0).unwrap(); + let (id, _) = map + .start(random(), "corr-1".into(), String::new(), true, 0) + .unwrap(); assert_eq!(id, 1); } @@ -210,8 +212,12 @@ mod tests { fn start_increments_session_id() { let map = SessionMap::default(); let repo = random::(); - let (id1, _) = map.start(repo, "corr-1".into(), String::new(), true, 0).unwrap(); - let (id2, _) = map.start(repo, "corr-2".into(), String::new(), true, 0).unwrap(); + let (id1, _) = map + .start(repo, "corr-1".into(), String::new(), true, 0) + .unwrap(); + let (id2, _) = map + .start(repo, "corr-2".into(), String::new(), true, 0) + .unwrap(); assert_eq!(id1, 1); assert_eq!(id2, 2); } @@ -220,8 +226,12 @@ mod tests { fn start_always_allocates_new_id() { let map = SessionMap::default(); let repo = random::(); - let (id1, _) = map.start(repo, "corr-1".into(), String::new(), true, 0).unwrap(); - let (id2, _) = map.start(repo, "corr-1".into(), String::new(), true, 0).unwrap(); + let (id1, _) = map + .start(repo, "corr-1".into(), String::new(), true, 0) + .unwrap(); + let (id2, _) = map + .start(repo, "corr-1".into(), String::new(), true, 0) + .unwrap(); assert_ne!(id1, id2); } @@ -229,8 +239,12 @@ mod tests { fn start_empty_correlation_generates_uuid() { let map = SessionMap::default(); let repo = random::(); - let (id1, corr1) = map.start(repo, String::new(), String::new(), true, 0).unwrap(); - let (id2, corr2) = map.start(repo, String::new(), String::new(), true, 0).unwrap(); + let (id1, corr1) = map + .start(repo, String::new(), String::new(), true, 0) + .unwrap(); + let (id2, corr2) = map + .start(repo, String::new(), String::new(), true, 0) + .unwrap(); assert_ne!(id1, id2); assert!(!corr1.is_empty()); assert!(!corr2.is_empty()); @@ -241,7 +255,9 @@ mod tests { fn stop_removes_session() { let map = SessionMap::default(); let repo = random::(); - let (id, _) = map.start(repo, "corr-1".into(), String::new(), true, 0).unwrap(); + let (id, _) = map + .start(repo, "corr-1".into(), String::new(), true, 0) + .unwrap(); assert!(map.get(id).is_some()); map.stop(id).unwrap(); assert!(map.get(id).is_none()); @@ -256,7 +272,9 @@ mod tests { #[test] fn stop_already_stopped_returns_not_found() { let map = SessionMap::default(); - let (id, _) = map.start(random(), "corr-1".into(), String::new(), true, 0).unwrap(); + let (id, _) = map + .start(random(), "corr-1".into(), String::new(), true, 0) + .unwrap(); map.stop(id).unwrap(); assert_eq!(map.stop(id), Err(SessionError::NotFound)); } @@ -265,9 +283,13 @@ mod tests { fn start_after_stop_allocates_new_id() { let map = SessionMap::default(); let repo = random::(); - let (id1, _) = map.start(repo, "corr-1".into(), String::new(), true, 0).unwrap(); + let (id1, _) = map + .start(repo, "corr-1".into(), String::new(), true, 0) + .unwrap(); map.stop(id1).unwrap(); - let (id2, _) = map.start(repo, "corr-1".into(), String::new(), true, 0).unwrap(); + let (id2, _) = map + .start(repo, "corr-1".into(), String::new(), true, 0) + .unwrap(); assert_ne!(id1, id2); } @@ -275,7 +297,9 @@ mod tests { fn get_returns_entry_with_user_id() { let map = SessionMap::default(); let repo = random::(); - let (id, _) = map.start(repo, "corr-1".into(), "user-42".into(), true, 0).unwrap(); + let (id, _) = map + .start(repo, "corr-1".into(), "user-42".into(), true, 0) + .unwrap(); let entry = map.get(id).unwrap(); assert_eq!(entry.repository, repo); assert_eq!(entry.correlation_id, "corr-1"); @@ -293,7 +317,8 @@ mod tests { let map = SessionMap::default(); let repo_a = random::(); let repo_b = random::(); - map.start(repo_a, "corr-1".into(), String::new(), true, 0).unwrap(); + map.start(repo_a, "corr-1".into(), String::new(), true, 0) + .unwrap(); assert!(map.is_repository_authorized(repo_a, "", NOW)); assert!(!map.is_repository_authorized(repo_b, "", NOW)); @@ -362,7 +387,8 @@ mod tests { let map = SessionMap::default(); let repo = random::(); for i in 0..MAX_CONCURRENT_SESSIONS { - map.start(repo, format!("corr-{i}"), String::new(), true, 0).unwrap(); + map.start(repo, format!("corr-{i}"), String::new(), true, 0) + .unwrap(); } assert_eq!( map.start(repo, "one-more".into(), String::new(), true, 0), @@ -376,7 +402,9 @@ mod tests { let repo = random::(); let mut ids = Vec::new(); for i in 0..MAX_CONCURRENT_SESSIONS { - let (id, _) = map.start(repo, format!("corr-{i}"), String::new(), true, 0).unwrap(); + let (id, _) = map + .start(repo, format!("corr-{i}"), String::new(), true, 0) + .unwrap(); ids.push(id); } assert_eq!( @@ -384,6 +412,7 @@ mod tests { Err(SessionError::LimitReached) ); map.stop(ids[0]).unwrap(); - map.start(repo, "freed".into(), String::new(), true, 0).unwrap(); + map.start(repo, "freed".into(), String::new(), true, 0) + .unwrap(); } } diff --git a/lore-server/src/quic/storage_service.rs b/lore-server/src/quic/storage_service.rs index 4351041e7..cc453e334 100644 --- a/lore-server/src/quic/storage_service.rs +++ b/lore-server/src/quic/storage_service.rs @@ -194,7 +194,6 @@ pub enum ParsedStorageRequest { MutableCas(requests::MutableCas), } - /// Legacy opcode for the Correlate command, which was removed from the client /// Command enum in the lore-storage/0.4 protocol but must still be handled /// server-side for backward compatibility with urc/0.2 clients. diff --git a/lore-server/src/quic/storage_service_v4.rs b/lore-server/src/quic/storage_service_v4.rs index 447c272be..b0b3d33c1 100644 --- a/lore-server/src/quic/storage_service_v4.rs +++ b/lore-server/src/quic/storage_service_v4.rs @@ -186,9 +186,10 @@ impl QuicService for StorageServiceV4 { return Err(MessageHandleError::MissingToken); } - let authorization = jwt_verifier.verify_token(&token_str).await.map_err( - |err| MessageHandleError::AuthorizationFailure(err.to_string()), - )?; + let authorization = + jwt_verifier.verify_token(&token_str).await.map_err(|err| { + MessageHandleError::AuthorizationFailure(err.to_string()) + })?; crate::auth::jwt::verify_authorization(&authorization, repository) .map_err(|err| { @@ -214,7 +215,13 @@ impl QuicService for StorageServiceV4 { }; let session_map = self.session_map.clone(); - match session_map.start(repository, correlation_id, user_id, write_allowed, expires_at) { + match session_map.start( + repository, + correlation_id, + user_id, + write_allowed, + expires_at, + ) { Ok((session_id, correlation_id)) => { debug!( session_id, @@ -285,8 +292,7 @@ impl QuicService for StorageServiceV4 { ) { return Err(MessageHandleError::AuthorizationFailure( - "write access to the repository is required for this operation" - .to_string(), + "write access to the repository is required for this operation".to_string(), )); } diff --git a/lore-server/src/server.rs b/lore-server/src/server.rs index 56d92466d..e0f02c7d9 100644 --- a/lore-server/src/server.rs +++ b/lore-server/src/server.rs @@ -66,10 +66,10 @@ use crate::auth::jwk::JwkServiceImpl; use crate::auth::jwt::JwtVerifier; use crate::grpc::GrpcInternalServerBuilder; use crate::grpc::GrpcServerBuilder; -use crate::grpc::tower::build_guard::BuildGuardConfig; use crate::grpc::forwarded_requests::ForwardedRequests; use crate::grpc::forwarded_requests::GrpcForwardedRequests; use crate::grpc::notification_service::NotificationService; +use crate::grpc::tower::build_guard::BuildGuardConfig; use crate::hooks::HookDispatcher; use crate::hooks::HookRegistrationContext; use crate::hooks::HookRegistry; @@ -250,7 +250,9 @@ async fn wait_for_shutdown( // by an operator/SIGTERM is a clean stop. let finish = |failed: bool| -> Result<()> { if failed { - Err(anyhow!("a server endpoint exited before shutdown was requested; see logs")) + Err(anyhow!( + "a server endpoint exited before shutdown was requested; see logs" + )) } else { Ok(()) } @@ -1839,7 +1841,10 @@ async fn async_main(settings: (Settings, StringHash), config: ServerConfig) -> R ) })?; if auth.jwt_issuer.is_none() - || auth.jwt_audience.as_ref().is_none_or(|audience| audience.is_empty()) + || auth + .jwt_audience + .as_ref() + .is_none_or(|audience| audience.is_empty()) { return Err(anyhow!( "[server.auth] is set but jwt_issuer or jwt_audience is missing: refusing to \ diff --git a/lore-transport/src/grpc/mod.rs b/lore-transport/src/grpc/mod.rs index 1742d23d8..7909eeecd 100644 --- a/lore-transport/src/grpc/mod.rs +++ b/lore-transport/src/grpc/mod.rs @@ -1741,7 +1741,10 @@ mod build_handshake_tests { fn a_user_agent_without_a_build_token_cannot_prove_a_match() { // Pre-handshake clients, and anything using the LORE_USER_AGENT escape // hatch, advertise no build: the server must treat this as unmatchable. - assert_eq!(build_sha_from_user_agent("lore-transport/0.8.6-nightly+0"), None); + assert_eq!( + build_sha_from_user_agent("lore-transport/0.8.6-nightly+0"), + None + ); assert_eq!(build_sha_from_user_agent("grpc-go/1.2"), None); assert_eq!(build_sha_from_user_agent(""), None); // An empty build token is not a build. diff --git a/lore/src/repository.rs b/lore/src/repository.rs index 9ca9c3fc8..92708c805 100644 --- a/lore/src/repository.rs +++ b/lore/src/repository.rs @@ -1059,9 +1059,13 @@ pub struct MountArgs { /// repository write token for the lifetime of the mount so edits made through it can be /// tracked. pub async fn mount(globals: LoreGlobalArgs, args: MountArgs, callback: LoreEventCallback) -> i32 { - repository_call_write(globals, callback, args, mount, |repository, _token, args| { - mount_impl(repository, args) - }) + repository_call_write( + globals, + callback, + args, + mount, + |repository, _token, args| mount_impl(repository, args), + ) .await } From 53ce103e954c8c3982fb83ab40ab66a5443d46e9 Mon Sep 17 00:00:00 2001 From: Geordie Moffatt Date: Wed, 2 Dec 2026 00:03:45 -0800 Subject: [PATCH 2/8] chore: quote doc names, name discarded errors and fold map/unwrap_or for clippy clippy -D warnings rejects these in code this branch added on top of upstream; each change is the rewrite clippy suggests and leaves behaviour as it was: - doc_markdown: put the identifiers named in doc comments (environment variables, RPC names, ProjFS) in backticks. Comments only. - map_err_ignore: the closures that drop an error now bind it to a named `_` binding (`_elapsed`, `_refused`, `_unavailable`) instead of `_`. The value is still discarded exactly as before. - map_unwrap_or: `.map(f).unwrap_or(a)` becomes `.map_or(a, f)` and `.map(f).unwrap_or(false)` becomes `.is_ok_and(f)`. The defaults are constants, so evaluating them eagerly changes nothing. Signed-off-by: Geordie Moffatt --- build-helper.rs | 4 ++-- lore-base/src/fs/lock.rs | 3 +-- lore-base/src/version.rs | 4 ++-- lore-credential/src/token_store.rs | 2 +- lore-revision/src/repository/clone.rs | 2 +- lore-revision/tests/cross_vcs.rs | 3 +-- lore-server/src/authnz/grants.rs | 4 ++-- lore-server/src/grpc/mod.rs | 4 ++-- .../repository/contents/put_repository_content.rs | 3 +-- lore-server/src/protocol/storage/session.rs | 3 +-- lore-server/src/test_support.rs | 8 ++++---- lore-server/tests/support/mod.rs | 12 ++++++------ lore-transport/src/auth/ucs_auth.rs | 4 ++-- lore/src/repository.rs | 2 +- 14 files changed, 27 insertions(+), 31 deletions(-) diff --git a/build-helper.rs b/build-helper.rs index a399bf91f..df8ae8361 100644 --- a/build-helper.rs +++ b/build-helper.rs @@ -5,10 +5,10 @@ struct LoreVergen { } /// The source commit, stamped into the binary so a deployed artifact can be -/// identified. The version name cannot do this: it is CARGO_PKG_VERSION plus a +/// identified. The version name cannot do this: it is `CARGO_PKG_VERSION` plus a /// Lore revision number that falls back to "0" whenever the CLI probe below /// fails, so every build in a lineage reports the same string. -/// LORE_BUILD_SHA is checked first because container/CI builds copy a source +/// `LORE_BUILD_SHA` is checked first because container/CI builds copy a source /// tree without .git, leaving git no way to answer. fn get_build_sha() -> String { // Without this, a build in a tree that was built before keeps the stamp of that earlier diff --git a/lore-base/src/fs/lock.rs b/lore-base/src/fs/lock.rs index 17f6b3e97..bea16ee6d 100644 --- a/lore-base/src/fs/lock.rs +++ b/lore-base/src/fs/lock.rs @@ -100,8 +100,7 @@ impl FSLock { std::env::var("LORE_LOCK_TIMEOUT_SECS") .ok() .and_then(|value| value.parse().ok()) - .map(Duration::from_secs) - .unwrap_or(Duration::from_secs(10)) + .map_or(Duration::from_secs(10), Duration::from_secs) } /// Whether a lock error means "currently held by someone else" (retryable until the diff --git a/lore-base/src/version.rs b/lore-base/src/version.rs index 0611e7775..10845414c 100644 --- a/lore-base/src/version.rs +++ b/lore-base/src/version.rs @@ -9,8 +9,8 @@ pub static LORE_LIBRARY_VERSION_CSTR: &str = concat!(env!("VERGEN_LORE_LIBRARY_VERSION_NAME"), "\0"); /// Source commit this binary was built from, or "unknown" when the build had -/// neither LORE_BUILD_SHA nor a git tree. This — not the version name — is what -/// identifies a build: the version name is CARGO_PKG_VERSION plus a Lore revision +/// neither `LORE_BUILD_SHA` nor a git tree. This — not the version name — is what +/// identifies a build: the version name is `CARGO_PKG_VERSION` plus a Lore revision /// number that degrades to "0", so it is identical across a whole lineage. pub static LORE_BUILD_SHA: LazyLock = LazyLock::new(|| env!("VERGEN_LORE_BUILD_SHA").to_owned()); diff --git a/lore-credential/src/token_store.rs b/lore-credential/src/token_store.rs index 10ace4f58..638f0a3d5 100644 --- a/lore-credential/src/token_store.rs +++ b/lore-credential/src/token_store.rs @@ -968,7 +968,7 @@ async fn get_token_encryption_key() -> Result { /// that has ended, seen from a job that outlived it), and making a new key resets every token. async fn load_encryption() -> Result { let encryption_key_nonce = get_secret_from_store(ENCRYPTION_KEY_TARGET).await?; - get_encryption(encryption_key_nonce).map_err(|_| { + get_encryption(encryption_key_nonce).map_err(|_unavailable| { lore_warn!("{KEY_UNAVAILABLE_MSG}"); TokenStoreError::internal(KEY_UNAVAILABLE_MSG) }) diff --git a/lore-revision/src/repository/clone.rs b/lore-revision/src/repository/clone.rs index 791ea12eb..6f35e466d 100644 --- a/lore-revision/src/repository/clone.rs +++ b/lore-revision/src/repository/clone.rs @@ -309,7 +309,7 @@ pub struct CloneOptions { /// a FUSE mount fully virtualizes its mountpoint, hiding the co-located `.lore` from the /// serving process, whose next path-based store access would re-enter its own mount and /// deadlock in the kernel — so the repository is created elsewhere (the caller relocates - /// it) and the mount serves this path. Unused on Windows, where ProjFS projects into the + /// it) and the mount serves this path. Unused on Windows, where `ProjFS` projects into the /// repository directory and passes real files through. pub virtual_mountpoint: Option, /// Use direct file write diff --git a/lore-revision/tests/cross_vcs.rs b/lore-revision/tests/cross_vcs.rs index 43f971fbc..699e01461 100644 --- a/lore-revision/tests/cross_vcs.rs +++ b/lore-revision/tests/cross_vcs.rs @@ -37,8 +37,7 @@ mod tests { std::process::Command::new("git") .arg("--version") .output() - .map(|output| output.status.success()) - .unwrap_or(false) + .is_ok_and(|output| output.status.success()) } fn git(root: &Path, args: &[&str]) { diff --git a/lore-server/src/authnz/grants.rs b/lore-server/src/authnz/grants.rs index 36bc883fe..4109c634c 100644 --- a/lore-server/src/authnz/grants.rs +++ b/lore-server/src/authnz/grants.rs @@ -1,6 +1,6 @@ // SPDX-FileCopyrightText: 2026 Epic Games, Inc. // SPDX-License-Identifier: MIT -//! Validation of the ucs-auth broker's CheckUserPermission and LookupUserPermissions answers, +//! Validation of the ucs-auth broker's `CheckUserPermission` and `LookupUserPermissions` answers, //! capped by the caller's own verified token. Only `read` and `write` count in a broker answer: //! an entry with no permission, or only unknown ones, grants nothing, and a resource id that //! does not name a repository is ignored. A token without a `resources` claim grants nothing. @@ -30,7 +30,7 @@ fn permits(permission: &[String], access: Access) -> bool { }) } -/// Whether a CheckUserPermission answer grants `access` on `repository`. Only an entry for +/// Whether a `CheckUserPermission` answer grants `access` on `repository`. Only an entry for /// exactly that repository's resource id counts. pub fn check_grants( allowed: &[ResourcePermission], diff --git a/lore-server/src/grpc/mod.rs b/lore-server/src/grpc/mod.rs index 4cd9bddf6..315ee4df7 100644 --- a/lore-server/src/grpc/mod.rs +++ b/lore-server/src/grpc/mod.rs @@ -233,7 +233,7 @@ pub fn verify_write(request: &tonic::Request) -> Result<(), Status> { } }; crate::auth::jwt::verify_write_authorization(authorization, repository) - .map_err(|_| write_denied()) + .map_err(|_refused| write_denied()) } /// Authorize the repository a request names in its body, for services whose interceptor only @@ -259,7 +259,7 @@ pub fn authorize_body_repository( Access::Read => verify_authorization(token, repository), Access::Write => crate::auth::jwt::verify_write_authorization(token, repository), }; - granted.map_err(|_| denied()) + granted.map_err(|_refused| denied()) } pub use lore_transport::grpc::STREAM_TOKEN_EXPIRED as TOKEN_EXPIRED; diff --git a/lore-server/src/http/repositories/repository/contents/put_repository_content.rs b/lore-server/src/http/repositories/repository/contents/put_repository_content.rs index 5c7749af9..5d8972bfe 100644 --- a/lore-server/src/http/repositories/repository/contents/put_repository_content.rs +++ b/lore-server/src/http/repositories/repository/contents/put_repository_content.rs @@ -64,8 +64,7 @@ pub async fn handler( let write_denied = matches!(user_info.as_ref(), Some(token) if repository_id .parse::() - .map(|repository| verify_write_authorization(token, repository.into()).is_err()) - .unwrap_or(false)); + .is_ok_and(|repository| verify_write_authorization(token, repository.into()).is_err())); let user_id = get_user_id_from_token(user_info); let execution = setup_execution(module_path!(), correlation_id, user_id); diff --git a/lore-server/src/protocol/storage/session.rs b/lore-server/src/protocol/storage/session.rs index 79637653a..27afa521a 100644 --- a/lore-server/src/protocol/storage/session.rs +++ b/lore-server/src/protocol/storage/session.rs @@ -37,8 +37,7 @@ fn is_live(expires_at: u64, now: u64) -> bool { pub fn unix_now() -> u64 { SystemTime::now() .duration_since(UNIX_EPOCH) - .map(|since| since.as_secs()) - .unwrap_or(0) + .map_or(0, |since| since.as_secs()) } /// A started session's authorization to read its repository, which a Copy on another session diff --git a/lore-server/src/test_support.rs b/lore-server/src/test_support.rs index 94d61fbcf..257c6674f 100644 --- a/lore-server/src/test_support.rs +++ b/lore-server/src/test_support.rs @@ -231,9 +231,9 @@ fn verify_minted(token: &str) -> Option { pub(crate) struct BrokerState { /// Callers (`sub`) that may delete, as with `LORE_AUTH_ADMINS`. pub admins: HashSet, - /// Replaces the computed CheckUserPermission `allowed_resource_permission`. + /// Replaces the computed `CheckUserPermission` `allowed_resource_permission`. pub check_answer: Option>, - /// Replaces the computed LookupUserPermissions `resource_permission`. + /// Replaces the computed `LookupUserPermissions` `resource_permission`. pub lookup_answer: Option>, /// Lets any admin delete, as the pre-hotfix broker did, without a write grant on the target. pub admin_deletes_anything: bool, @@ -244,8 +244,8 @@ pub(crate) struct BrokerState { /// An in-process ucs-auth broker. Like GRID's (`225da2718`), it verifies the caller's bearer and /// answers from that token's own grants: Check returns each requested id the grants cover, -/// exactly or via `urc-*`, with the caller's real permissions; CreateResource needs a write -/// grant on the id; DeleteResource needs an admin caller that also holds a write grant on it. +/// exactly or via `urc-*`, with the caller's real permissions; `CreateResource` needs a write +/// grant on the id; `DeleteResource` needs an admin caller that also holds a write grant on it. pub(crate) struct FakeBroker { pub url: String, state: Arc>, diff --git a/lore-server/tests/support/mod.rs b/lore-server/tests/support/mod.rs index aa05a9a1c..278c4b556 100644 --- a/lore-server/tests/support/mod.rs +++ b/lore-server/tests/support/mod.rs @@ -220,9 +220,9 @@ pub fn verifier() -> JwtVerifier { pub struct BrokerState { /// Callers (`sub`) that may delete, as with `LORE_AUTH_ADMINS`. pub admins: HashSet, - /// Replaces the computed CheckUserPermission answer. + /// Replaces the computed `CheckUserPermission` answer. pub check_answer: Option>, - /// Replaces the computed LookupUserPermissions answer. + /// Replaces the computed `LookupUserPermissions` answer. pub lookup_answer: Option>, pub checked: Vec, pub created: Vec, @@ -230,8 +230,8 @@ pub struct BrokerState { } /// A ucs-auth broker double answering like GRID's hotfixed broker (`225da2718`): from the -/// caller's own verified grants, with read and write only; CreateResource needs write on the -/// id; DeleteResource needs an admin caller holding write on it. +/// caller's own verified grants, with read and write only; `CreateResource` needs write on the +/// id; `DeleteResource` needs an admin caller holding write on it. pub struct Broker { pub url: String, state: Arc>, @@ -504,7 +504,7 @@ pub fn set_exchange_policy(auth_url: &str, update: impl FnOnce(&mut ExchangePoli } /// The Lore client's token exchange for the test broker's URL: like the broker's -/// ExchangeUserTokenForMultiresourceToken, it verifies the identity and issues a session token +/// `ExchangeUserTokenForMultiresourceToken`, it verifies the identity and issues a session token /// for one repository with the identity's own permission on it, never outliving the identity. struct SessionExchange; @@ -899,7 +899,7 @@ impl Origin { .expect("connect to the router") } - /// Store a repository the way RepositoryCreate does, returning its metadata pointer. + /// Store a repository the way `RepositoryCreate` does, returning its metadata pointer. pub async fn seed(&self, id: RepositoryId, name: &str) -> Hash { let repository = Arc::new(RepositoryContext::new_server_context( self.immutable_store.clone(), diff --git a/lore-transport/src/auth/ucs_auth.rs b/lore-transport/src/auth/ucs_auth.rs index 55d4209b5..770dc475a 100644 --- a/lore-transport/src/auth/ucs_auth.rs +++ b/lore-transport/src/auth/ucs_auth.rs @@ -61,7 +61,7 @@ async fn connect_client( // tonic's connect timeout covers the TCP connect only, not the TLS handshake. let channel = tokio::time::timeout(CONNECT_TIMEOUT, endpoint.connect()) .await - .map_err(|_| timed_out("connecting"))? + .map_err(|_elapsed| timed_out("connecting"))? .map_err(|e| ProtocolError::internal(format!("failed to connect to auth endpoint: {e}")))?; Ok(UrcAuthApiClient::with_interceptor( channel, @@ -228,7 +228,7 @@ impl Authentication for UcsAuthentication { client.exchange_user_token_for_multiresource_token(request), ) .await - .map_err(|_| timed_out("exchanging the token"))? + .map_err(|_elapsed| timed_out("exchanging the token"))? .map_err(ProtocolError::from)?; let token = res diff --git a/lore/src/repository.rs b/lore/src/repository.rs index 92708c805..2e63fc2af 100644 --- a/lore/src/repository.rs +++ b/lore/src/repository.rs @@ -1055,7 +1055,7 @@ pub struct MountArgs { } /// Mounts the repository's current revision as a virtual workspace, blocking until it is -/// unmounted. Requires the `vfs` feature (FUSE on Linux, ProjFS on Windows). Holds the +/// unmounted. Requires the `vfs` feature (FUSE on Linux, `ProjFS` on Windows). Holds the /// repository write token for the lifetime of the mount so edits made through it can be /// tracked. pub async fn mount(globals: LoreGlobalArgs, args: MountArgs, callback: LoreEventCallback) -> i32 { From 5f0abde89584b7835021bb70ceff5b0fdee5acdc Mon Sep 17 00:00:00 2001 From: Geordie Moffatt Date: Wed, 2 Dec 2026 00:04:46 -0800 Subject: [PATCH 3/8] chore: apply clippy's suggested rewrites in fork code Each of these is the rewrite clippy proposes for code this branch added, and none changes what the code does: - items_after_test_module (lore-base fs/lock.rs): `impl Drop for FSLock` moves above the test module. Item order has no meaning in Rust. - single_match_else (lore-revision repository.rs, lore-server authnz/grants.rs): a two-arm match on an Option becomes if let/else with the same arms in the same order. - collapsible_if (lore-server auth/jwk.rs): the nested `if let ... { if ...` becomes one let chain; the read guard is still taken only when a key is wanted, and the branch still only returns. - useless_conversion (lore-server repository_metadata_set.rs): drops an `.into()` from `Partition` to `Partition`. - unused_self (lore-server stream_authorization_tests.rs): the test helper `put_request` reads nothing from `self`, so it becomes an associated function. - semicolon_if_nothing_returned (lore-server tests/client_renewal.rs), byte_char_slices (lore-storage fan_out.rs test: `*b"LVN"` is the same three bytes) and unnested_or_patterns (lore-transport grpc/mod.rs: `Ok("1" | "true" | "TRUE")` matches the same values). - unused_async (lore/src/repository.rs): the `mount_impl` built without the `vfs` feature does not await, but it has to stay `async` like the two `vfs` versions because `mount` awaits whichever one is built. It gets a scoped `#[allow(clippy::unused_async)]` saying so. Signed-off-by: Geordie Moffatt --- lore-base/src/fs/lock.rs | 32 +++++++++---------- lore-revision/src/repository.rs | 31 ++++++++---------- lore-server/src/auth/jwk.rs | 8 ++--- lore-server/src/authnz/grants.rs | 13 ++++---- .../grpc/handlers/repository_metadata_set.rs | 2 +- .../storage/v1/stream_authorization_tests.rs | 12 +++++-- lore-server/tests/client_renewal.rs | 4 +-- lore-storage/src/local/fan_out.rs | 2 +- lore-transport/src/grpc/mod.rs | 2 +- lore/src/repository.rs | 2 ++ 10 files changed, 56 insertions(+), 52 deletions(-) diff --git a/lore-base/src/fs/lock.rs b/lore-base/src/fs/lock.rs index bea16ee6d..993b13248 100644 --- a/lore-base/src/fs/lock.rs +++ b/lore-base/src/fs/lock.rs @@ -152,6 +152,22 @@ impl FSLock { } } +impl Drop for FSLock { + fn drop(&mut self) { + #[cfg(target_family = "windows")] + { + // Safety: Calling OS functions + unsafe { FileSystem::UnlockFile(self.file.as_raw_handle(), 0, 0, !0, !0) }; + } + + #[cfg(not(target_family = "windows"))] + { + // Safety: Calling OS functions + unsafe { libc::flock(self.file.as_raw_fd(), libc::LOCK_UN) }; + } + } +} + #[cfg(test)] mod tests { use super::*; @@ -197,19 +213,3 @@ mod tests { let _ = std::fs::remove_dir_all(&dir); } } - -impl Drop for FSLock { - fn drop(&mut self) { - #[cfg(target_family = "windows")] - { - // Safety: Calling OS functions - unsafe { FileSystem::UnlockFile(self.file.as_raw_handle(), 0, 0, !0, !0) }; - } - - #[cfg(not(target_family = "windows"))] - { - // Safety: Calling OS functions - unsafe { libc::flock(self.file.as_raw_fd(), libc::LOCK_UN) }; - } - } -} diff --git a/lore-revision/src/repository.rs b/lore-revision/src/repository.rs index 87b846007..e0e542d66 100644 --- a/lore-revision/src/repository.rs +++ b/lore-revision/src/repository.rs @@ -2188,23 +2188,20 @@ pub async fn load_and_connect_with_token( } else { None }; - match working_root { - Some(root) => { - lore_debug!( - "Working tree bound to {} (mount {})", - root.display(), - if live { "live" } else { "not served" } - ); - repository.with_working_root(root, live) - } - None => { - lore_warn!( - "This repository's working tree is bound to the mountpoint {}, which \ - no longer exists; operating on the repository directory instead", - binding.mountpoint.display() - ); - repository - } + if let Some(root) = working_root { + lore_debug!( + "Working tree bound to {} (mount {})", + root.display(), + if live { "live" } else { "not served" } + ); + repository.with_working_root(root, live) + } else { + lore_warn!( + "This repository's working tree is bound to the mountpoint {}, which \ + no longer exists; operating on the repository directory instead", + binding.mountpoint.display() + ); + repository } } _ => repository, diff --git a/lore-server/src/auth/jwk.rs b/lore-server/src/auth/jwk.rs index 588f0e028..ceb685337 100644 --- a/lore-server/src/auth/jwk.rs +++ b/lore-server/src/auth/jwk.rs @@ -101,10 +101,10 @@ impl JwkServiceImpl { let _refresh = self.refresh_lock.lock().await; // Check to see if the desired key was fetched while we waited for the lock. - if let Some(d) = desired { - if self.cached_set.read().await.contains_key(d) { - return Ok(()); - } + if let Some(d) = desired + && self.cached_set.read().await.contains_key(d) + { + return Ok(()); } let endpoint = reqwest::Url::parse(&self.settings.endpoint).map_err(|e| { diff --git a/lore-server/src/authnz/grants.rs b/lore-server/src/authnz/grants.rs index 4109c634c..f64d8bbdb 100644 --- a/lore-server/src/authnz/grants.rs +++ b/lore-server/src/authnz/grants.rs @@ -73,16 +73,15 @@ pub fn list_scope(grants: &[ResourcePermission]) -> ListScope { scope.every_repository = true; continue; } - match parse_resource_id(&grant.resource_id) { - Some(repository) => { - if seen.insert(repository) { - scope.repositories.push(repository); - } + if let Some(repository) = parse_resource_id(&grant.resource_id) { + if seen.insert(repository) { + scope.repositories.push(repository); } - None => warn!( + } else { + warn!( resource_id = %grant.resource_id, "Ignoring a broker grant that names no repository" - ), + ); } } scope diff --git a/lore-server/src/grpc/handlers/repository_metadata_set.rs b/lore-server/src/grpc/handlers/repository_metadata_set.rs index 8138abdd4..5eac69aa9 100644 --- a/lore-server/src/grpc/handlers/repository_metadata_set.rs +++ b/lore-server/src/grpc/handlers/repository_metadata_set.rs @@ -172,7 +172,7 @@ pub async fn handler( let previous = repository .write_mutable_store(&write_token) .compare_and_swap( - repository_id.into(), + repository_id, metadata_key, expected_hash, new_hash, diff --git a/lore-server/src/grpc/storage/v1/stream_authorization_tests.rs b/lore-server/src/grpc/storage/v1/stream_authorization_tests.rs index e0c894932..a5f5d3b64 100644 --- a/lore-server/src/grpc/storage/v1/stream_authorization_tests.rs +++ b/lore-server/src/grpc/storage/v1/stream_authorization_tests.rs @@ -108,7 +108,7 @@ impl StorageOrigin { request } - fn put_request(&self) -> storage_v1::PutRequest { + fn put_request() -> storage_v1::PutRequest { let (fragment, address, payload) = lore_revision::fragment::generate_random(); storage_v1::PutRequest { address: Some(address.into()), @@ -200,7 +200,10 @@ async fn a_put_stream_refuses_new_work_after_its_token_expires() { .expect("open a Put stream") .into_inner(); - requests.send(origin.put_request()).await.expect("send"); + requests + .send(StorageOrigin::put_request()) + .await + .expect("send"); responses .message() .await @@ -208,7 +211,10 @@ async fn a_put_stream_refuses_new_work_after_its_token_expires() { .expect("a response"); outlive_the_token().await; - requests.send(origin.put_request()).await.expect("send"); + requests + .send(StorageOrigin::put_request()) + .await + .expect("send"); let status = responses .message() .await diff --git a/lore-server/tests/client_renewal.rs b/lore-server/tests/client_renewal.rs index b13d9c561..10896cb8f 100644 --- a/lore-server/tests/client_renewal.rs +++ b/lore-server/tests/client_renewal.rs @@ -338,7 +338,7 @@ async fn concurrent_grpc_writes_across_a_token_expiry_all_succeed() { tokio::time::sleep(Duration::from_secs(SESSION_TTL + 1)).await; // A slow exchange keeps the renewal open while writes pile up behind it. set_exchange_policy(&origin.broker.url, |policy| { - policy.delay = Duration::from_millis(500) + policy.delay = Duration::from_millis(500); }); let failures = concurrent_puts(&session, 16, 3).await; assert!( @@ -470,7 +470,7 @@ async fn concurrent_quic_writes_across_a_token_expiry_all_succeed() { tokio::time::sleep(Duration::from_secs(SESSION_TTL + 1)).await; set_exchange_policy(&origin.broker.url, |policy| { - policy.delay = Duration::from_millis(500) + policy.delay = Duration::from_millis(500); }); let failures = concurrent_puts(&session, 16, 3).await; assert!( diff --git a/lore-storage/src/local/fan_out.rs b/lore-storage/src/local/fan_out.rs index e3e1b2afc..71dd2a97d 100644 --- a/lore-storage/src/local/fan_out.rs +++ b/lore-storage/src/local/fan_out.rs @@ -819,7 +819,7 @@ mod tests { // A replacement that got as far as part of its temporary file and no further let temporary = crate::fs_util::temporary_path(&dir.path().join(MARKER_FILENAME)); - std::fs::write(&temporary, [b'L', b'V', b'N']).unwrap(); + std::fs::write(&temporary, *b"LVN").unwrap(); assert_eq!(read_level_marker(dir.path()).unwrap(), Some(32)); // The next writer is not in the way of the leftover and leaves none itself diff --git a/lore-transport/src/grpc/mod.rs b/lore-transport/src/grpc/mod.rs index 7909eeecd..bfc92bd62 100644 --- a/lore-transport/src/grpc/mod.rs +++ b/lore-transport/src/grpc/mod.rs @@ -626,7 +626,7 @@ pub const BUILD_MISMATCH_OVERRIDE_TOKEN: &str = "build-override/1"; pub fn build_mismatch_override_requested() -> bool { matches!( std::env::var("LORE_ALLOW_BUILD_MISMATCH").as_deref(), - Ok("1") | Ok("true") | Ok("TRUE") + Ok("1" | "true" | "TRUE") ) } diff --git a/lore/src/repository.rs b/lore/src/repository.rs index 2e63fc2af..c1df83196 100644 --- a/lore/src/repository.rs +++ b/lore/src/repository.rs @@ -1174,6 +1174,8 @@ async fn mount_impl( all(target_os = "linux", feature = "vfs"), all(target_family = "windows", feature = "vfs") )))] +// Async to match the `vfs` builds' `mount_impl`, which the `mount` handler awaits. +#[allow(clippy::unused_async)] async fn mount_impl( _repository: Arc, _args: MountArgs, From 4596552fa38558bcf0edc3163b0961c5b7c687dc Mon Sep 17 00:00:00 2001 From: Geordie Moffatt Date: Wed, 2 Dec 2026 00:05:14 -0800 Subject: [PATCH 4/8] chore: spawn and write through the helpers clippy.toml names clippy's disallowed_methods rejects four direct spawns and two direct `std::fs::write` calls in code this branch added. - lore-storage tests (local/flush.rs, local/immutable_store.rs, local/mutable_store.rs, packstore.rs) spawn with `lore_base::lore_spawn!` instead of `tokio::spawn` / `JoinSet::spawn`, as the workspace clippy.toml asks. Inside a runtime, `lore_spawn!` spawns on `Handle::try_current()`, which is the test's own runtime. The tests set no `LORE_CONTEXT`, so nothing is scoped, and `ObservedTask` does nothing without a lifecycle callback. The tasks therefore run where and as they did before. - lore-revision `write_mount_binding` writes the mount-binding file in `.lore`. lore-revision's clippy.toml asks for a `RepositoryWriteToken`-gated helper, or an `allow` on an authorized writer. Gating it would change the signature of a pub function the `lore` crate calls, so it gets the scoped `allow` with a reason, as the repository ID writer in the same file already does. - lore-revision tests/cross_vcs.rs writes a `.loreignore` fixture before any repository exists; the statement gets a scoped `allow` with a reason. Signed-off-by: Geordie Moffatt --- lore-revision/src/repository.rs | 1 + lore-revision/tests/cross_vcs.rs | 2 ++ lore-storage/src/local/flush.rs | 2 +- lore-storage/src/local/immutable_store.rs | 2 +- lore-storage/src/local/mutable_store.rs | 2 +- lore-storage/src/packstore.rs | 2 +- 6 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lore-revision/src/repository.rs b/lore-revision/src/repository.rs index e0e542d66..41d6522f6 100644 --- a/lore-revision/src/repository.rs +++ b/lore-revision/src/repository.rs @@ -2487,6 +2487,7 @@ pub fn read_mount_binding(dot_path: &Path) -> Option { } /// Record the mount binding for a repository. +#[allow(clippy::disallowed_methods)] // Authorized writer of the `.lore` mount-binding file. pub fn write_mount_binding( dot_path: &Path, mountpoint: &Path, diff --git a/lore-revision/tests/cross_vcs.rs b/lore-revision/tests/cross_vcs.rs index 699e01461..7c765aa1b 100644 --- a/lore-revision/tests/cross_vcs.rs +++ b/lore-revision/tests/cross_vcs.rs @@ -97,6 +97,8 @@ mod tests { async move { std::fs::create_dir_all(&working_path).expect("create working dir"); if let Some(content) = loreignore.as_deref() { + #[allow(clippy::disallowed_methods)] + // Test fixture, outside any repository. std::fs::write(working_path.join(".loreignore"), content) .expect("write .loreignore"); } diff --git a/lore-storage/src/local/flush.rs b/lore-storage/src/local/flush.rs index 3c0a1fc94..2956ceb31 100644 --- a/lore-storage/src/local/flush.rs +++ b/lore-storage/src/local/flush.rs @@ -215,7 +215,7 @@ mod tests { let gate = gate.clone(); let passes = passes.clone(); let ticket = gate.ticket(); - waiting.push(tokio::spawn(async move { + waiting.push(lore_base::lore_spawn!(async move { gate.durable(ticket, || async { passes.fetch_add(1, Ordering::SeqCst); Ok::<(), ()>(()) diff --git a/lore-storage/src/local/immutable_store.rs b/lore-storage/src/local/immutable_store.rs index c346c4863..1300e4588 100644 --- a/lore-storage/src/local/immutable_store.rs +++ b/lore-storage/src/local/immutable_store.rs @@ -5149,7 +5149,7 @@ mod tests { for _ in 0..8 { let store = store.clone(); let group = group.clone(); - flushes.spawn(async move { + lore_base::lore_spawn!(flushes, async move { store.flush(true).await.unwrap(); // Whichever flush ran the pass, none returns before it is through assert!(!group.needs_flush(true)); diff --git a/lore-storage/src/local/mutable_store.rs b/lore-storage/src/local/mutable_store.rs index f8791043e..f63b0e0b3 100644 --- a/lore-storage/src/local/mutable_store.rs +++ b/lore-storage/src/local/mutable_store.rs @@ -2163,7 +2163,7 @@ mod tests { let mut flushes = JoinSet::new(); for _ in 0..8 { let store = store.clone(); - flushes.spawn(async move { + lore_base::lore_spawn!(flushes, async move { store.clone().flush(true).await.unwrap(); // Whichever flush ran the pass, none returns before it is through assert!(!needs_flush(&store, true)); diff --git a/lore-storage/src/packstore.rs b/lore-storage/src/packstore.rs index 840df3f37..66c45956f 100644 --- a/lore-storage/src/packstore.rs +++ b/lore-storage/src/packstore.rs @@ -871,7 +871,7 @@ mod tests { let mut flushes = tokio::task::JoinSet::new(); for _ in 0..8 { let store = store.clone(); - flushes.spawn(async move { + lore_base::lore_spawn!(flushes, async move { store.flush_all(true).await.unwrap(); // Whichever flush did the fsync, none returns before it is done assert!(!store.needs_sync()); From 5d47dad7ff53d1daaba0029e6ee949b83648f6d0 Mon Sep 17 00:00:00 2001 From: Geordie Moffatt Date: Wed, 2 Dec 2026 00:05:28 -0800 Subject: [PATCH 5/8] chore: box the server future in the startup-refusal tests clippy's large_futures flags the startup-refusal tests in lore-server's server.rs: `start` wraps `async_main` (about 11 KB) in a timeout, so `start` and each test that awaits it hold an 11 KB future on the stack. Pinning `async_main` in a Box at that one call site, as clippy suggests, moves it to the heap and clears all five reports. The same future runs under the same 30 s timeout; only where its state lives changes. Test code only. Signed-off-by: Geordie Moffatt --- lore-server/src/server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lore-server/src/server.rs b/lore-server/src/server.rs index e0f02c7d9..b1b4e3fbd 100644 --- a/lore-server/src/server.rs +++ b/lore-server/src/server.rs @@ -2408,7 +2408,7 @@ auth_url = "https://auth.test:9100" let settings = Settings::load(dir.to_str(), Some("startup")).expect("settings load"); let outcome = tokio::time::timeout( Duration::from_secs(30), - async_main(settings, ServerConfig::default()), + Box::pin(async_main(settings, ServerConfig::default())), ) .await; let _ = std::fs::remove_dir_all(&dir); From 3afbc79d9356e0e098d11c9e29ba7c28d387392e Mon Sep 17 00:00:00 2001 From: Geordie Moffatt Date: Wed, 2 Dec 2026 00:05:40 -0800 Subject: [PATCH 6/8] chore: keep too_many_arguments allowed where it was meant to be clippy's too_many_arguments flags two functions: - lore-revision stage.rs `stage_filesystem_path` (10 arguments). Upstream carries `#[allow(clippy::too_many_arguments)]` and its doc comment on this function. When this branch added `ensure_not_git_tracked` (fcca0ec2), it was inserted between them and the function, so they ended up on the new helper. This moves the four upstream lines back to the function they belong to, as upstream has them. No code changes. - lore-server grpc/server.rs `GrpcServerBuilder::with_http2_config` grew a seventh setting (`build_guard`) on this branch, making 8 with `self`. It is public and called positionally from lore-server, its tests and lore-integration-tests, so a parameter struct would change its signature. It gets the same scoped allow, with a comment saying why. Signed-off-by: Geordie Moffatt --- lore-revision/src/stage.rs | 8 ++++---- lore-server/src/grpc/server.rs | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lore-revision/src/stage.rs b/lore-revision/src/stage.rs index 74e476fef..405c52049 100644 --- a/lore-revision/src/stage.rs +++ b/lore-revision/src/stage.rs @@ -348,10 +348,6 @@ pub(crate) async fn process_link_updates( Ok(()) } -/// Stage changes from filesystem into the given state -/// The base directory is the point where the relative path starts -/// Only the relative path will be checked for case consistency -#[allow(clippy::too_many_arguments)] /// Enforce the cross-VCS disjointness invariant: a file tracked by a git working tree /// covering this workspace must not be staged into Lore — once staged, a backward sync would /// overwrite or delete the git-tracked source. This holds even when the ignore allowlist is @@ -376,6 +372,10 @@ fn ensure_not_git_tracked( Ok(()) } +/// Stage changes from filesystem into the given state +/// The base directory is the point where the relative path starts +/// Only the relative path will be checked for case consistency +#[allow(clippy::too_many_arguments)] pub(crate) async fn stage_filesystem_path( repository: Arc, state: Arc, diff --git a/lore-server/src/grpc/server.rs b/lore-server/src/grpc/server.rs index b926de5dc..96f07a604 100644 --- a/lore-server/src/grpc/server.rs +++ b/lore-server/src/grpc/server.rs @@ -428,6 +428,9 @@ pub struct WantsHttp2Config { } impl GrpcServerBuilder { + // Called positionally from lore-server, its tests and lore-integration-tests; grouping the + // settings into a struct would change that public signature. + #[allow(clippy::too_many_arguments)] pub fn with_http2_config( self, http2_keep_alive_interval: Option, From d5d14fbeef3ea82dd5e6e56cbe8696eca4268b64 Mon Sep 17 00:00:00 2001 From: Geordie Moffatt Date: Wed, 2 Dec 2026 00:27:53 -0800 Subject: [PATCH 7/8] chore: quote ProjFS in the VFS core's doc for clippy clippy's doc_markdown flags `ProjFS` in the doc comment of `staged_delete_paths` in lore-revision/src/vfs/core.rs. The module is only built with the `vfs` feature, which the Lint workflow's clippy run (default features) never enables, so this showed up only under `cargo clippy --features vfs`. Comment only. Signed-off-by: Geordie Moffatt --- lore-revision/src/vfs/core.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lore-revision/src/vfs/core.rs b/lore-revision/src/vfs/core.rs index 8c611b4ae..f34822849 100644 --- a/lore-revision/src/vfs/core.rs +++ b/lore-revision/src/vfs/core.rs @@ -476,7 +476,7 @@ fn refuse(address: Address, detail: std::fmt::Arguments<'_>) -> ImmutableError { /// Repository-relative paths of all staged dirty-delete nodes: files deleted since the served /// revision through any interface (the mount itself, the CLI, or a sync from elsewhere). /// Backends hide these from the projection so a delete is not undone by the projected entry -/// reappearing — the FUSE backend seeds its whiteout set from this, the ProjFS backend its +/// reappearing — the FUSE backend seeds its whiteout set from this, the `ProjFS` backend its /// hidden set (local deletes there are additionally tombstoned on disk by the OS). pub async fn staged_delete_paths(repository: Arc) -> Vec { let Ok((_current, Some(staged), _branch)) = From ee58b9190eb45a60d55ea9915983107c28c3a55f Mon Sep 17 00:00:00 2001 From: Geordie Moffatt Date: Wed, 2 Dec 2026 00:08:02 -0800 Subject: [PATCH 8/8] ci: pin the Lint workflow's clippy to 1.97.1 and rustfmt to nightly-2026-11-22 Lint installs the latest nightly for rustfmt and uses whatever stable the runner has for clippy. On 2026-11-22 that was clippy 1.100.0, which fails 157 places in upstream code this branch never changed (empty_enums on zerocopy derive output, map(..).unwrap_or_default(), result_large_err, ...). Upstream fixed these on main in cd28d446, which does not apply to this branch. With these pins, Lint checks every pull request against the same toolchains this branch is clean on: - clippy and cargo-deny run on 1.97.1, set as the default toolchain the pre-commit hooks' plain `cargo` resolves to. - cargo-fmt runs on nightly-2026-11-22 (rustfmt bdf712ee87), named in the hook entry so a local `pre-commit run` formats the same way. Drop this commit when the branch moves to an upstream that has cd28d446, or once the remaining 1.100 lints are fixed. Signed-off-by: Geordie Moffatt --- .github/workflows/lint.yml | 8 +++++--- .pre-commit-config.yaml | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 968af81a5..d61d0f3b7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -31,11 +31,13 @@ jobs: cache-dependency-path: .pre-commit-config.yaml # cargo-clippy, cargo-fmt and cargo-deny run as Rust pre-commit hooks. - # Lore formats with nightly; clippy and cargo-deny run on stable. + # Lore formats with nightly; clippy and cargo-deny run on stable. Both are pinned: a new + # release brings new lints and formatting that fail code nobody changed. - name: Install Rust toolchains run: | - rustup toolchain install nightly --profile minimal -c rustfmt - rustup component add clippy rustfmt + rustup toolchain install nightly-2026-11-22 --profile minimal -c rustfmt + rustup toolchain install 1.97.1 --profile minimal -c clippy -c rustfmt + rustup default 1.97.1 - name: Cache cargo registry and build artifacts uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c63b79894..92b89181a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: cargo-fmt name: cargo format language: rust - entry: cargo +nightly fmt --all --check + entry: cargo +nightly-2026-11-22 fmt --all --check pass_filenames: false always_run: true