fix: add --all to cargo fmt in script/test and autoformat codebase

cargo fmt without --all fails with "Failed to find targets" in
workspace repos. This was blocking every story's gates. Also ran
cargo fmt --all to fix all existing formatting issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dave
2026-04-13 14:07:08 +00:00
parent ed2526ce41
commit 845b85e7a7
128 changed files with 3566 additions and 2395 deletions
+68 -53
View File
@@ -408,7 +408,9 @@ mod tests {
// Serialise op1 into a SyncMessage::Op.
let op1_json = serde_json::to_string(&op1).unwrap();
let wire_msg = SyncMessage::Op { op: op1_json.clone() };
let wire_msg = SyncMessage::Op {
op: op1_json.clone(),
};
let wire_json = serde_json::to_string(&wire_msg).unwrap();
// ── Node B: receive the op through protocol ──
@@ -517,10 +519,7 @@ mod tests {
.sign(&kp);
crdt_a.apply(op2.clone());
let op3 = crdt_a.doc.items[0]
.stage
.set("3_qa".to_string())
.sign(&kp);
let op3 = crdt_a.doc.items[0].stage.set("3_qa".to_string()).sign(&kp);
crdt_a.apply(op3.clone());
// Serialise all ops as a bulk message (simulates partition heal).
@@ -623,7 +622,10 @@ name = "test"
// Simulate a clean reconnect.
consecutive_failures = 0;
assert_eq!(consecutive_failures, 0, "counter must reset to 0 on success");
assert_eq!(
consecutive_failures, 0,
"counter must reset to 0 on success"
);
// Next error is attempt 1 — well below the ERROR threshold.
consecutive_failures += 1;
@@ -685,7 +687,10 @@ name = "test"
assert_eq!(crdt.doc.items.view().len(), 1);
// Stage update also deduplicated correctly.
let stage_op = crdt.doc.items[0].stage.set("2_current".to_string()).sign(&kp);
let stage_op = crdt.doc.items[0]
.stage
.set("2_current".to_string())
.sign(&kp);
assert_eq!(crdt.apply(stage_op.clone()), OpState::Ok);
assert_eq!(
crdt.doc.items[0].stage.view(),
@@ -806,10 +811,7 @@ name = "test"
.set("2_current".to_string())
.sign(&kp);
crdt_a.apply(op2.clone());
let op3 = crdt_a.doc.items[0]
.stage
.set("3_qa".to_string())
.sign(&kp);
let op3 = crdt_a.doc.items[0].stage.set("3_qa".to_string()).sign(&kp);
crdt_a.apply(op3.clone());
// Receiver applies all ops in the correct order.
@@ -830,7 +832,7 @@ name = "test"
/// pending op is evicted (queue never grows beyond the cap).
#[test]
fn causal_queue_overflow_drops_oldest() {
use bft_json_crdt::json_crdt::{BaseCrdt, OpState, CAUSAL_QUEUE_MAX};
use bft_json_crdt::json_crdt::{BaseCrdt, CAUSAL_QUEUE_MAX, OpState};
use bft_json_crdt::keypair::make_keypair;
use bft_json_crdt::op::ROOT_ID;
use serde_json::json;
@@ -854,11 +856,7 @@ name = "test"
"claimed_at": 0.0,
})
.into();
let phantom_op = source
.doc
.items
.insert(ROOT_ID, phantom_item)
.sign(&kp);
let phantom_op = source.doc.items.insert(ROOT_ID, phantom_item).sign(&kp);
// Receiver never sees phantom_op, so any op declaring it as a dep will
// sit in the causal queue forever (until evicted by overflow).
@@ -871,9 +869,7 @@ name = "test"
for i in 0..CAUSAL_QUEUE_MAX + 5 {
let stage_name = format!("stage_{i}");
// Generate from source so seq numbers are valid.
let op = source
.doc
.items[0]
let op = source.doc.items[0]
.stage
.set(stage_name)
.sign_with_dependencies(&kp, vec![&phantom_op]);
@@ -1006,8 +1002,13 @@ name = "test"
.iter()
.filter_map(|item| {
if let JV::Object(m) = CrdtNode::view(item) {
m.get("story_id")
.and_then(|s| if let JV::String(s) = s { Some(s.clone()) } else { None })
m.get("story_id").and_then(|s| {
if let JV::String(s) = s {
Some(s.clone())
} else {
None
}
})
} else {
None
}
@@ -1194,15 +1195,9 @@ name = "test"
.set("2_current".to_string())
.sign(&kp);
crdt.apply(op2.clone());
let op3 = crdt.doc.items[0]
.stage
.set("3_qa".to_string())
.sign(&kp);
let op3 = crdt.doc.items[0].stage.set("3_qa".to_string()).sign(&kp);
crdt.apply(op3.clone());
let op4 = crdt.doc.items[0]
.stage
.set("4_merge".to_string())
.sign(&kp);
let op4 = crdt.doc.items[0].stage.set("4_merge".to_string()).sign(&kp);
crdt.apply(op4.clone());
// Send more ops than the channel capacity without consuming.
@@ -1245,8 +1240,8 @@ name = "test"
use serde_json::json;
use std::sync::{Arc, Mutex};
use tokio::net::TcpListener;
use tokio_tungstenite::{accept_async, connect_async};
use tokio_tungstenite::tungstenite::Message as TMsg;
use tokio_tungstenite::{accept_async, connect_async};
use crate::crdt_state::PipelineDoc;
@@ -1271,7 +1266,9 @@ name = "test"
// Serialise A's full state as a bulk message.
let op1_json = serde_json::to_string(&op1).unwrap();
let bulk_msg = SyncMessage::Bulk { ops: vec![op1_json] };
let bulk_msg = SyncMessage::Bulk {
ops: vec![op1_json],
};
let bulk_wire = serde_json::to_string(&bulk_msg).unwrap();
// ── Start Node A's WebSocket server on a random port ───────────────
@@ -1349,11 +1346,17 @@ name = "test"
// ── Assert convergence ─────────────────────────────────────────────
// Node B received Node A's item.
assert_eq!(crdt_b.doc.items.view().len(), 2,
"Node B must see both items after sync");
let has_a_item = crdt_b.doc.items.view().iter().any(|item| {
item.story_id.view() == JV::String("508_e2e_convergence".to_string())
});
assert_eq!(
crdt_b.doc.items.view().len(),
2,
"Node B must see both items after sync"
);
let has_a_item = crdt_b
.doc
.items
.view()
.iter()
.any(|item| item.story_id.view() == JV::String("508_e2e_convergence".to_string()));
assert!(has_a_item, "Node B must have Node A's item");
// Node A received Node B's op via the WebSocket.
@@ -1378,8 +1381,8 @@ name = "test"
use futures::{SinkExt, StreamExt};
use serde_json::json;
use tokio::net::TcpListener;
use tokio_tungstenite::{accept_async, connect_async};
use tokio_tungstenite::tungstenite::Message as TMsg;
use tokio_tungstenite::{accept_async, connect_async};
use crate::crdt_state::PipelineDoc;
@@ -1482,10 +1485,7 @@ name = "test"
}
// B sends its bulk state to A.
sink_b
.send(TMsg::Text(b_bulk_wire.into()))
.await
.unwrap();
sink_b.send(TMsg::Text(b_bulk_wire.into())).await.unwrap();
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
@@ -1504,26 +1504,41 @@ name = "test"
// ── Assert convergence ─────────────────────────────────────────────
// Both nodes must have 2 items.
assert_eq!(crdt_a.doc.items.view().len(), 2,
"A must have 2 items after healing");
assert_eq!(crdt_b.doc.items.view().len(), 2,
"B must have 2 items after healing");
assert_eq!(
crdt_a.doc.items.view().len(),
2,
"A must have 2 items after healing"
);
assert_eq!(
crdt_b.doc.items.view().len(),
2,
"B must have 2 items after healing"
);
// A must see B's story.
let b_story_on_a = crdt_a.doc.items.view().iter().any(|item| {
item.story_id.view() == JV::String("508_heal_b".to_string())
});
let b_story_on_a = crdt_a
.doc
.items
.view()
.iter()
.any(|item| item.story_id.view() == JV::String("508_heal_b".to_string()));
assert!(b_story_on_a, "A must have B's story after healing");
// B must see A's stage advance.
let a_story_on_b = crdt_b.doc.items.view().iter().any(|item| {
item.story_id.view() == JV::String("508_heal_a".to_string())
});
let a_story_on_b = crdt_b
.doc
.items
.view()
.iter()
.any(|item| item.story_id.view() == JV::String("508_heal_a".to_string()));
assert!(a_story_on_b, "B must have A's story after healing");
// CRDT views must be byte-identical (convergence).
let view_a = serde_json::to_string(&CrdtNode::view(&crdt_a.doc.items)).unwrap();
let view_b = serde_json::to_string(&CrdtNode::view(&crdt_b.doc.items)).unwrap();
assert_eq!(view_a, view_b, "Both nodes must converge to identical state");
assert_eq!(
view_a, view_b,
"Both nodes must converge to identical state"
);
}
}