From 2b177d948220fc7e4f90532ba2b76cd7fe33b820 Mon Sep 17 00:00:00 2001 From: Toni Bergholm Date: Mon, 19 Oct 2026 17:58:18 +0300 Subject: [PATCH] chore: drop two workspace clippy allows, fix them at the source type_complexity gets named aliases (SealInput, SealedFile, WrapMap, plus two local ones) and doc_lazy_continuation was one reflowed doc comment. too_many_arguments stays: eight commit/snapshot-assembly and replay functions take their inputs one by one by design. Co-Authored-By: Claude Sonnet 5.5 --- Cargo.toml | 11 +++++------ ROADMAP.md | 12 ++++++------ crates/repo/src/merge.rs | 9 ++++++--- crates/repo/src/private.rs | 2 +- crates/repo/src/protect.rs | 15 +++++++++------ crates/repo/src/replay.rs | 2 +- crates/repo/src/repo.rs | 13 +++++++------ 7 files changed, 35 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 907cbe3f..312077a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,14 +26,13 @@ categories = ["development-tools", "command-line-utilities"] publish = false # Clippy lints intentionally allowed workspace-wide (each crate opts in with -# `[lints] workspace = true`). Kept deliberately small: two structural lints that -# are design choices, and one pedantic markdown lint that misfires on prose doc -# comments. Everything else clippy flags is fixed at the source. CI runs -# `clippy --all-targets -D warnings`, so this list is the single source of truth. +# `[lints] workspace = true`). Kept deliberately to one structural lint: the +# commit/snapshot-assembly and replay functions take many inputs by design, and +# bundling them into parameter structs would only move the list. Everything else +# clippy flags is fixed at the source. CI runs `clippy --all-targets -D +# warnings`, so this list is the single source of truth. [workspace.lints.clippy] -type_complexity = "allow" # deliberate: crypto wrap/protection map types too_many_arguments = "allow" # deliberate: commit/snapshot-assembly fns -doc_lazy_continuation = "allow" # pedantic markdown lint on prose doc comments [profile.release] lto = true diff --git a/ROADMAP.md b/ROADMAP.md index b26ac1f3..36b2bd80 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -848,12 +848,12 @@ scale-&-reach horizon): a lone `stream.read()` for the `HTTP/1.1 400` assertion returned as soon as the first TCP segment arrived, so under load it split off just `HTTP/1.1 ` before `400 Bad Request` — now read to EOF. -- **Tighten the workspace clippy allow-list (launch prep).** CI runs - `clippy --all-targets -D warnings`; `[workspace.lints.clippy]` in the root - `Cargo.toml` allows a curated set (`type_complexity`, `too_many_arguments`, - `doc_lazy_continuation`, and three cosmetic style lints) that are deliberate - design or cosmetic in reviewed code. Revisit whether any should be fixed at - the source and removed from the allow-list. +- **Workspace clippy allow-list — tightened.** `type_complexity` (named aliases in + `protect.rs` for the seal inputs, sealed files and wrap map) and + `doc_lazy_continuation` are fixed at the source and no longer allowed; + `too_many_arguments` stays, for the eight commit/snapshot-assembly and replay + functions that take their inputs one by one (a parameter struct would only + move the list). - **CodeQL / SAST workflow (launch prep).** A CodeQL security-scanning workflow (as the sibling `git.agentic` has) was left out of the initial launch because CodeQL's Rust support is newer; add it once verified not to diff --git a/crates/repo/src/merge.rs b/crates/repo/src/merge.rs index ba3bad4e..2c2ae402 100644 --- a/crates/repo/src/merge.rs +++ b/crates/repo/src/merge.rs @@ -975,6 +975,9 @@ mod tests { ); } + /// A tree root with the protection that governs it. + type RootAndProtection = (ObjectId, Protection); + /// Fixture for the content-divergent cases: secret/a.txt protected on all /// three sides with distinct contents. Returns (repo, roots, protections). fn divergent_protected_fixture( @@ -984,9 +987,9 @@ mod tests { theirs_c: &[u8], ) -> ( VfsRepo, - (ObjectId, Protection), - (ObjectId, Protection), - (ObjectId, Protection), + RootAndProtection, + RootAndProtection, + RootAndProtection, ) { let repo = VfsRepo::new(Store::with_budget(1 << 20)); let (mut bp, mut op, mut tp) = ( diff --git a/crates/repo/src/private.rs b/crates/repo/src/private.rs index 6483b52f..8a4c8d77 100644 --- a/crates/repo/src/private.rs +++ b/crates/repo/src/private.rs @@ -1525,7 +1525,7 @@ impl Repo { let snap = self.get_inner_snapshot(&mut store, &ctx, inner_id)?; let files = self.inner_tree_files(&mut store, &ctx, snap.root)?; let mut plain: Vec<(String, Vec, FileMode)> = Vec::new(); - let mut to_encrypt: Vec<(String, Vec, FileMode, Vec<[u8; 32]>)> = Vec::new(); + let mut to_encrypt: Vec = Vec::new(); let mut published: BTreeMap = BTreeMap::new(); let mut wrapped: BTreeMap> = BTreeMap::new(); for (path, (id, mode, perms)) in &files { diff --git a/crates/repo/src/protect.rs b/crates/repo/src/protect.rs index c8158145..2afc1fc5 100644 --- a/crates/repo/src/protect.rs +++ b/crates/repo/src/protect.rs @@ -123,6 +123,14 @@ pub(crate) fn decrypt_with( Err(Error::NotAuthorized(path.to_string())) } +/// A working-tree file headed for sealing: `(path, plaintext, mode, recipient +/// pubkeys)`. +pub(crate) type SealInput = (String, Vec, FileMode, Vec<[u8; 32]>); +/// A sealed (or carried) protected file: `(path, ciphertext, mode, perms)`. +pub(crate) type SealedFile = (String, Vec, FileMode, u8); +/// Wrapped DEKs keyed by the ciphertext blob they unlock. +pub(crate) type WrapMap = BTreeMap>; + /// Randomized encryption (P33, ADR-0043): each file seals under a fresh /// random DEK+nonce, wrapping that DEK to its rule's recipients. Returns the /// ciphertext write-set entries (PROTECTED | RANDOMIZED perms) and fresh @@ -133,12 +141,7 @@ pub(crate) fn decrypt_with( /// file's recipient list is empty: a rule whose every recipient is /// tombstoned (e.g. crossed revokes merged together) must fail the seal /// loudly — sealing to nobody mints permanently unreadable ciphertext. -pub(crate) fn encrypt_protected( - plaintexts: Vec<(String, Vec, FileMode, Vec<[u8; 32]>)>, -) -> Result<( - Vec<(String, Vec, FileMode, u8)>, - BTreeMap>, -)> { +pub(crate) fn encrypt_protected(plaintexts: Vec) -> Result<(Vec, WrapMap)> { // Encrypt protected files; accumulate fresh wrapped DEKs keyed by blob id. let mut all: Vec<(String, Vec, FileMode, u8)> = Vec::new(); let mut fresh_wrapped: BTreeMap> = BTreeMap::new(); diff --git a/crates/repo/src/replay.rs b/crates/repo/src/replay.rs index 9a00cdee..7833f80d 100644 --- a/crates/repo/src/replay.rs +++ b/crates/repo/src/replay.rs @@ -325,7 +325,7 @@ impl Repo { /// update is the atomic commit point — a crash before it leaves tip and /// tree consistently pre-pick), with the oplog record written last, after /// the ref write it describes. A conflicting replay writes conflict markers - /// + sidecars over the working tree and records pick state + /// and sidecars over the working tree and records pick state /// (`PICK_HEAD`/`PICK_CONFLICTS`/`PICK_DECIDED_ROOT`) — no ref moves, no /// oplog entry, so the current branch tip is unchanged until the conflicts /// are resolved and committed. An empty replay is `AlreadyApplied` only diff --git a/crates/repo/src/repo.rs b/crates/repo/src/repo.rs index 8e316868..5e960e96 100644 --- a/crates/repo/src/repo.rs +++ b/crates/repo/src/repo.rs @@ -17,7 +17,7 @@ pub(crate) const DEFAULT_BUDGET: usize = 512 * 1024 * 1024; /// A working-tree file headed for encryption at commit time: /// `(path, plaintext bytes, file mode, recipient pubkeys)`. -type ProtectedFile = (String, Vec, scl_core::FileMode, Vec<[u8; 32]>); +type ProtectedFile = crate::protect::SealInput; /// Working-tree status against HEAD. pub type Status = Diff; @@ -1564,8 +1564,8 @@ impl Repo { // through encryption — one side unprotecting a path the other side // still rules must not let plaintext land in the merged snapshot // (bit<->rule invariant, Task 4 review I2). - let mut carried: Vec<(String, Vec, scl_core::FileMode, u8)> = Vec::new(); - let mut to_encrypt: Vec<(String, Vec, scl_core::FileMode, Vec<[u8; 32]>)> = Vec::new(); + let mut carried: Vec = Vec::new(); + let mut to_encrypt: Vec = Vec::new(); for f in &merge_result.files { if f.needs_encrypt { let recipients = crate::protect::matching_prefix(&union_prot, &f.path) @@ -1791,9 +1791,9 @@ impl Repo { pub(crate) fn materialize_conflict_state( &self, op: &str, - carried: &[(String, Vec, scl_core::FileMode, u8)], + carried: &[crate::protect::SealedFile], carried_subtrees: &[(String, scl_core::TreeEntry)], - to_encrypt: &[(String, Vec, scl_core::FileMode, Vec<[u8; 32]>)], + to_encrypt: &[crate::protect::SealInput], sidecars: &[(String, Vec)], conflict_prot: &scl_core::Protection, old_root: ObjectId, @@ -5877,7 +5877,8 @@ mod tests { // (state name, setup fn, teardown fn) — each policy op is exercised // against all three, asserting the exact typed error per state. - let states: [(&str, fn(&Layout), fn(&Layout)); 3] = [ + type StateFns = (&'static str, fn(&Layout), fn(&Layout)); + let states: [StateFns; 3] = [ ( "merge", |layout| {