Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions crates/repo/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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) = (
Expand Down
2 changes: 1 addition & 1 deletion crates/repo/src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>, FileMode)> = Vec::new();
let mut to_encrypt: Vec<(String, Vec<u8>, FileMode, Vec<[u8; 32]>)> = Vec::new();
let mut to_encrypt: Vec<crate::protect::SealInput> = Vec::new();
let mut published: BTreeMap<String, (ObjectId, FileMode, u8)> = BTreeMap::new();
let mut wrapped: BTreeMap<ObjectId, Vec<WrappedKey>> = BTreeMap::new();
for (path, (id, mode, perms)) in &files {
Expand Down
15 changes: 9 additions & 6 deletions crates/repo/src/protect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>, FileMode, Vec<[u8; 32]>);
/// A sealed (or carried) protected file: `(path, ciphertext, mode, perms)`.
pub(crate) type SealedFile = (String, Vec<u8>, FileMode, u8);
/// Wrapped DEKs keyed by the ciphertext blob they unlock.
pub(crate) type WrapMap = BTreeMap<ObjectId, Vec<WrappedKey>>;

/// 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
Expand All @@ -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<u8>, FileMode, Vec<[u8; 32]>)>,
) -> Result<(
Vec<(String, Vec<u8>, FileMode, u8)>,
BTreeMap<ObjectId, Vec<WrappedKey>>,
)> {
pub(crate) fn encrypt_protected(plaintexts: Vec<SealInput>) -> Result<(Vec<SealedFile>, WrapMap)> {
// Encrypt protected files; accumulate fresh wrapped DEKs keyed by blob id.
let mut all: Vec<(String, Vec<u8>, FileMode, u8)> = Vec::new();
let mut fresh_wrapped: BTreeMap<ObjectId, Vec<WrappedKey>> = BTreeMap::new();
Expand Down
2 changes: 1 addition & 1 deletion crates/repo/src/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions crates/repo/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>, scl_core::FileMode, Vec<[u8; 32]>);
type ProtectedFile = crate::protect::SealInput;

/// Working-tree status against HEAD.
pub type Status = Diff;
Expand Down Expand Up @@ -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<u8>, scl_core::FileMode, u8)> = Vec::new();
let mut to_encrypt: Vec<(String, Vec<u8>, scl_core::FileMode, Vec<[u8; 32]>)> = Vec::new();
let mut carried: Vec<crate::protect::SealedFile> = Vec::new();
let mut to_encrypt: Vec<crate::protect::SealInput> = Vec::new();
for f in &merge_result.files {
if f.needs_encrypt {
let recipients = crate::protect::matching_prefix(&union_prot, &f.path)
Expand Down Expand Up @@ -1791,9 +1791,9 @@ impl Repo {
pub(crate) fn materialize_conflict_state(
&self,
op: &str,
carried: &[(String, Vec<u8>, scl_core::FileMode, u8)],
carried: &[crate::protect::SealedFile],
carried_subtrees: &[(String, scl_core::TreeEntry)],
to_encrypt: &[(String, Vec<u8>, scl_core::FileMode, Vec<[u8; 32]>)],
to_encrypt: &[crate::protect::SealInput],
sidecars: &[(String, Vec<u8>)],
conflict_prot: &scl_core::Protection,
old_root: ObjectId,
Expand Down Expand Up @@ -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| {
Expand Down
Loading