From ad4cca47e4cbe58c77f4004938e0292e40bcaf93 Mon Sep 17 00:00:00 2001 From: Blake McAnally Date: Fri, 30 Oct 2026 12:57:55 -0500 Subject: [PATCH] fix(cli): pin sidebar sections head read to the writer The head read gates a full-snapshot publish, so a replica-routed read could return a lagging or empty head and erase the caller's own just-accepted edits. Send consistency: strong on the head query and bind it in the fake relay. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Blake McAnally --- crates/buzz-cli/src/commands/sidebar.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/buzz-cli/src/commands/sidebar.rs b/crates/buzz-cli/src/commands/sidebar.rs index 75ef413487..e0081e0f78 100644 --- a/crates/buzz-cli/src/commands/sidebar.rs +++ b/crates/buzz-cli/src/commands/sidebar.rs @@ -36,6 +36,9 @@ fn now() -> std::time::Duration { /// The relay's current sections event for this identity, decoded. An absent /// head is an empty tree; an unreadable one is an error, never an empty list. +/// The read is pinned to the writer (`consistency: strong`): a write derives a +/// full snapshot from it, and a lagging replica would drop the caller's own +/// just-accepted edits. async fn fetch_head(client: &BuzzClient) -> Result { let me = client.keys().public_key(); let filter = json!({ @@ -43,6 +46,7 @@ async fn fetch_head(client: &BuzzClient) -> Result { "authors": [me.to_hex()], "#d": [D_TAG], "limit": 1, + "consistency": "strong", }); let raw = client.query(&filter).await?; let events: Vec = serde_json::from_str(&raw) @@ -316,6 +320,7 @@ mod tests { assert_eq!(filter["kinds"], json!([KIND_READ_STATE])); assert_eq!(filter["#d"], json!([D_TAG])); assert_eq!(filter["limit"], json!(1)); + assert_eq!(filter["consistency"], json!("strong")); let author = &filter["authors"][0]; let relay = relay.lock().unwrap(); let matching: Vec<_> = relay