{"messages":[{"content":"You are a constitutional council ranking individual git commits for ownership allocation.\n\nCompare these two commits. Decide which contributed more lasting value to the project.\n\nJudge substance, not spectacle:\n- Prefer correct, lasting design and real bugfixes over churn, formatting, renames, or generated noise.\n- Prefer clarity and necessity over sheer line count. A small precise change can beat a large diffuse one.\n- Do not favor a side merely because its patch is longer or noisier.\n- Weight what the change does for the project, not the contributor's name.\n\nReturn ONLY a JSON object: {\"winner\": \"A\" or \"B\", \"ratio\": \"N:M\", \"explanation\": \"...\"}\nThe explanation must cite concrete differences in the patches (1-3 sentences).\n\nSide A — contributor: tommy-mor\nSide A — commit message:\n[5db58b98] Improve vote pair selection for spanning trees and rank refinement.\n\nPrefer attaching unranked items to established components before comparing\nisolates, then zip down adjacent rank-centrality pairs once the pool is fully\nconnected, skipping pairs that already have votes.\n\nCo-authored-by: Cursor \n\nSide A — unified diff (full patch):\ndiff --git a/server/src/pair.rs b/server/src/pair.rs\nindex 54b5d2417e9dba04ed8df422156e274c2b2f76b2..c14de4b0502c8b5a17cddf3746077739d56e03e0 100644\n--- a/server/src/pair.rs\n+++ b/server/src/pair.rs\n@@ -3,13 +3,21 @@\n //! Pair selection prefers **bridge** votes — comparisons between items in\n //! different connected components of the voted-pairs graph — so the pool\n //! merges into one ranking group before refining within it.\n+//!\n+//! Among unvoted bridges, prefer merging established voted components, then\n+//! attaching a never-voted child to an established component, and only then\n+//! comparing two never-voted children (so the voted graph grows as one tree).\n+//!\n+//! Once every pool child sits in one voted component, refinement **zips** down\n+//! the rank-centrality order: prefer 1 vs 2, then 2 vs 3, and so on, skipping\n+//! pairs that already have a vote.\n \n use rand::seq::SliceRandom;\n use std::collections::{HashMap, HashSet};\n \n use crate::{\n path_types::ItemId,\n- ranking::connected_components_from_voted_pairs,\n+ ranking::{connected_components_from_voted_pairs, ranked_items},\n reducer::{GlobalTree, GroupState},\n };\n \n@@ -28,36 +36,77 @@ fn pair_is_voted(group: &GroupState, a: &ItemId, b: &ItemId) -> bool {\n group.voted_pairs.contains(&(i, j))\n }\n \n-/// Component id per pool item: voted-pairs graph components plus one id per\n-/// never-voted child.\n-fn component_ids(group: &GroupState, pool: &[ItemId]) -> HashMap {\n+/// Voted-pairs layout for pool items: component id per item plus which ids are\n+/// multi-node voted components (ranked groups in the UI).\n+struct ComponentLayout {\n+ ids: HashMap,\n+ established: HashSet,\n+}\n+\n+fn component_layout(group: &GroupState, pool: &[ItemId]) -> ComponentLayout {\n let n = group.idx_to_item.len();\n let (comps, isolates) =\n connected_components_from_voted_pairs(n, group.voted_pairs.iter().copied());\n \n- let mut out: HashMap = HashMap::new();\n+ let mut established = HashSet::new();\n+ let mut ids: HashMap = HashMap::new();\n for (comp_idx, comp) in comps.iter().enumerate() {\n+ if comp.len() >= 2 {\n+ established.insert(comp_idx);\n+ }\n for &idx in comp {\n if idx < n {\n- out.insert(group.idx_to_item[idx].clone(), comp_idx);\n+ ids.insert(group.idx_to_item[idx].clone(), comp_idx);\n }\n }\n }\n let mut next = comps.len();\n for &idx in &isolates {\n if idx < n {\n- out.insert(group.idx_to_item[idx].clone(), next);\n+ ids.insert(group.idx_to_item[idx].clone(), next);\n next += 1;\n }\n }\n for item in pool {\n- out.entry(item.clone()).or_insert_with(|| {\n+ ids.entry(item.clone()).or_insert_with(|| {\n let id = next;\n next += 1;\n id\n });\n }\n- out\n+ ComponentLayout { ids, established }\n+}\n+\n+/// Every pool child shares one multi-node voted component (spanning tree phase done).\n+fn pool_fully_connected(layout: &ComponentLayout, pool: &[ItemId]) -> bool {\n+ if pool.len() < 2 {\n+ return false;\n+ }\n+ let mut comp_id = None;\n+ for item in pool {\n+ let Some(id) = layout.ids.get(item) else {\n+ return false;\n+ };\n+ if !layout.established.contains(id) {\n+ return false;\n+ }\n+ match comp_id {\n+ None => comp_id = Some(*id),\n+ Some(expected) if expected == *id => {}\n+ _ => return false,\n+ }\n+ }\n+ comp_id.is_some()\n+}\n+\n+/// Pool children that appear in `group`, sorted best rank first.\n+fn ranked_pool_order(group: &GroupState, pool: &[ItemId]) -> Vec {\n+ let pool_set: HashSet<_> = pool.iter().collect();\n+ ranked_items(group)\n+ .into_iter()\n+ .map(|r| r.item)\n+ .filter(|id| pool_set.contains(id))\n+ .collect()\n }\n \n #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]\n@@ -72,19 +121,108 @@ enum PairPriority {\n WithinVoted = 3,\n }\n \n-fn pair_priority(\n+/// Tie-break among unvoted bridge pairs.\n+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]\n+enum BridgeSubPriority {\n+ /// Both endpoints lie in established (multi-node) voted components.\n+ MergeEstablished = 0,\n+ /// One established component member and one never-voted child.\n+ AttachIsolate = 1,\n+ /// Two never-voted children (separate singleton components).\n+ IsolatePair = 2,\n+}\n+\n+/// Tie-break among within-component pairs once the pool is one connected group.\n+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]\n+struct WithinSubPriority {\n+ /// 1 = adjacent ranks (i vs i+1); larger = farther apart in the order.\n+ rank_gap: usize,\n+ /// min rank index of the two — zip from the top (1 vs 2 before 2 vs 3).\n+ zip_index: usize,\n+}\n+\n+const WITHIN_SUB_WORST: WithinSubPriority = WithinSubPriority {\n+ rank_gap: usize::MAX,\n+ zip_index: usize::MAX,\n+};\n+\n+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]\n+struct PairSortKey {\n+ priority: PairPriority,\n+ bridge_sub: BridgeSubPriority,\n+ within_sub: WithinSubPriority,\n+}\n+\n+fn item_in_established(layout: &ComponentLayout, item: &ItemId) -> bool {\n+ layout\n+ .ids\n+ .get(item)\n+ .is_some_and(|id| layout.established.contains(id))\n+}\n+\n+fn bridge_sub_priority(layout: &ComponentLayout, a: &ItemId, b: &ItemId) -> BridgeSubPriority {\n+ let a_est = item_in_established(layout, a);\n+ let b_est = item_in_established(layout, b);\n+ match (a_est, b_est) {\n+ (true, true) => BridgeSubPriority::MergeEstablished,\n+ (true, false) | (false, true) => BridgeSubPriority::AttachIsolate,\n+ (false, false) => BridgeSubPriority::IsolatePair,\n+ }\n+}\n+\n+fn within_sub_priority(\n+ group: &GroupState,\n+ pool: &[ItemId],\n+ layout: &ComponentLayout,\n+ a: &ItemId,\n+ b: &ItemId,\n+) -> WithinSubPriority {\n+ if !pool_fully_connected(layout, pool) {\n+ return WITHIN_SUB_WORST;\n+ }\n+ let order = ranked_pool_order(group, pool);\n+ let (Some(i), Some(j)) = (order.iter().position(|x| x == a), order.iter().position(|x| x == b))\n+ else {\n+ return WITHIN_SUB_WORST;\n+ };\n+ WithinSubPriority {\n+ rank_gap: i.abs_diff(j),\n+ zip_index: i.min(j),\n+ }\n+}\n+\n+fn pair_sort_key(\n group: &GroupState,\n- components: &HashMap,\n+ pool: &[ItemId],\n+ layout: &ComponentLayout,\n a: &ItemId,\n b: &ItemId,\n-) -> PairPriority {\n+) -> PairSortKey {\n let voted = pair_is_voted(group, a, b);\n- let bridge = components.get(a) != components.get(b);\n- match (bridge, voted) {\n+ let bridge = layout.ids.get(a) != layout.ids.get(b);\n+ let priority = match (bridge, voted) {\n (true, false) => PairPriority::BridgeUnvoted,\n (false, false) => PairPriority::WithinUnvoted,\n (true, true) => PairPriority::BridgeVoted,\n (false, true) => PairPriority::WithinVoted,\n+ };\n+ let bridge_sub = if priority == PairPriority::BridgeUnvoted {\n+ bridge_sub_priority(layout, a, b)\n+ } else {\n+ BridgeSubPriority::MergeEstablished\n+ };\n+ let within_sub = if matches!(\n+ priority,\n+ PairPriority::WithinUnvoted | PairPriority::WithinVoted\n+ ) {\n+ within_sub_priority(group, pool, layout, a, b)\n+ } else {\n+ WITHIN_SUB_WORST\n+ };\n+ PairSortKey {\n+ priority,\n+ bridge_sub,\n+ within_sub,\n }\n }\n \n@@ -109,9 +247,12 @@ fn candidate_pairs(pool: &[ItemId], exclude: Option<(&ItemId, &ItemId)>) -> Vec<\n \n /// Pick the next pair to vote on within `pool`.\n ///\n-/// 1. Prefer unvoted **bridge** pairs (connect separate ranking components).\n-/// 2. Then unvoted within-component pairs (refinement).\n-/// 3. Then already-voted pairs (re-compare).\n+/// 1. Prefer unvoted **bridge** pairs (connect separate ranking components),\n+/// with sub-priority: merge established components, attach an isolate to\n+/// established, then compare two isolates.\n+/// 2. Then unvoted within-component pairs; when the pool is one connected group,\n+/// prefer adjacent ranks (1 vs 2, 2 vs 3, …) in order, skipping voted pairs.\n+/// 3. Then already-voted pairs (re-compare), with the same zip ordering.\n pub fn suggest_next_pair_in_pool(\n group: &GroupState,\n pool: &[ItemId],\n@@ -121,15 +262,15 @@ pub fn suggest_next_pair_in_pool(\n if candidates.is_empty() {\n return None;\n }\n- let components = component_ids(group, pool);\n+ let layout = component_layout(group, pool);\n let best = candidates\n .iter()\n- .map(|(a, b)| (pair_priority(group, &components, a, b), (a, b)))\n- .min_by_key(|(p, _)| *p)?\n+ .map(|(a, b)| (pair_sort_key(group, pool, &layout, a, b), (a, b)))\n+ .min_by_key(|(k, _)| *k)?\n .0;\n let best_pairs: Vec<(ItemId, ItemId)> = candidates\n .into_iter()\n- .filter(|(a, b)| pair_priority(group, &components, a, b) == best)\n+ .filter(|(a, b)| pair_sort_key(group, pool, &layout, a, b) == best)\n .collect();\n best_pairs.choose(&mut rand::thread_rng()).cloned()\n }\n@@ -303,6 +444,38 @@ mod tests {\n assert!(from_ab && from_cd, \"expected bridge pair, got {:?}\", chosen);\n }\n \n+ #[test]\n+ fn suggest_prefers_attach_over_isolate_pair_among_many_unranked() {\n+ let parent = ItemId::parse(\"reddit.com/r/rust\").unwrap();\n+ let mut tree = seed_children(\n+ &parent,\n+ &[\n+ \"reddit.com/r/rust/a\",\n+ \"reddit.com/r/rust/b\",\n+ \"reddit.com/r/rust/c\",\n+ \"reddit.com/r/rust/d\",\n+ \"reddit.com/r/rust/e\",\n+ ],\n+ );\n+ let ab =\n+ VoteData::from_recorded(1, \"reddit.com/r/rust/a\", \"reddit.com/r/rust/b\", 2, 1).unwrap();\n+ tree.apply_vote(&parent, ab);\n+ let group = tree.get(&parent).unwrap().local_ranking.clone();\n+ let pool = children_of(&tree, &parent);\n+ let pair = suggest_next_pair_in_pool(&group, &pool, None).unwrap();\n+ let chosen = pair_set(&pair);\n+ let from_ab =\n+ chosen.contains(\"reddit.com/r/rust/a\") || chosen.contains(\"reddit.com/r/rust/b\");\n+ let from_cde = chosen.contains(\"reddit.com/r/rust/c\")\n+ || chosen.contains(\"reddit.com/r/rust/d\")\n+ || chosen.contains(\"reddit.com/r/rust/e\");\n+ assert!(\n+ from_ab && from_cde,\n+ \"expected ranked+unranked attach, got {:?}\",\n+ chosen\n+ );\n+ }\n+\n #[test]\n fn suggest_connects_isolate_to_existing_component() {\n let parent = ItemId::parse(\"reddit.com/r/rust\").unwrap();\n@@ -325,6 +498,65 @@ mod tests {\n assert!(chosen.contains(\"reddit.com/r/rust/a\") || chosen.contains(\"reddit.com/r/rust/b\"));\n }\n \n+ #[test]\n+ fn suggest_zips_adjacent_ranks_when_tree_complete() {\n+ let parent = ItemId::parse(\"reddit.com/r/rust\").unwrap();\n+ let mut tree = seed_children(\n+ &parent,\n+ &[\n+ \"reddit.com/r/rust/a\",\n+ \"reddit.com/r/rust/b\",\n+ \"reddit.com/r/rust/c\",\n+ ],\n+ );\n+ // Star at a connects all three; b-c is the only unvoted adjacent pair left.\n+ for (a, b, l, r) in [\n+ (\"reddit.com/r/rust/a\", \"reddit.com/r/rust/b\", 3, 1),\n+ (\"reddit.com/r/rust/a\", \"reddit.com/r/rust/c\", 2, 1),\n+ ] {\n+ let v = VoteData::from_recorded(1, a, b, l, r).unwrap();\n+ tree.apply_vote(&parent, v);\n+ }\n+ let group = tree.get(&parent).unwrap().local_ranking.clone();\n+ let pool = children_of(&tree, &parent);\n+ let pair = suggest_next_pair_in_pool(&group, &pool, None).unwrap();\n+ let chosen = pair_set(&pair);\n+ // a-b and a-c voted; b-c is the only unvoted adjacent pair in rank order.\n+ assert!(chosen.contains(\"reddit.com/r/rust/b\"));\n+ assert!(chosen.contains(\"reddit.com/r/rust/c\"));\n+ }\n+\n+ #[test]\n+ fn suggest_zip_prefers_1v2_before_2v3_when_both_unvoted() {\n+ let parent = ItemId::parse(\"reddit.com/r/rust\").unwrap();\n+ let mut tree = seed_children(\n+ &parent,\n+ &[\n+ \"reddit.com/r/rust/a\",\n+ \"reddit.com/r/rust/b\",\n+ \"reddit.com/r/rust/c\",\n+ \"reddit.com/r/rust/d\",\n+ ],\n+ );\n+ // Hub at c connects all four; leave rank-adjacent a-b and b-c unvoted.\n+ for (a, b, l, r) in [\n+ (\"reddit.com/r/rust/c\", \"reddit.com/r/rust/d\", 3, 1),\n+ (\"reddit.com/r/rust/b\", \"reddit.com/r/rust/c\", 2, 1),\n+ (\"reddit.com/r/rust/a\", \"reddit.com/r/rust/c\", 2, 1),\n+ ] {\n+ let v = VoteData::from_recorded(1, a, b, l, r).unwrap();\n+ tree.apply_vote(&parent, v);\n+ }\n+ let group = tree.get(&parent).unwrap().local_ranking.clone();\n+ let pool = children_of(&tree, &parent);\n+ assert!(pool_fully_connected(&component_layout(&group, &pool), &pool));\n+ let pair = suggest_next_pair_in_pool(&group, &pool, None).unwrap();\n+ let chosen = pair_set(&pair);\n+ // Top adjacent unvoted edge should be a-b (zip index 0), not b-c (index 1).\n+ assert!(chosen.contains(\"reddit.com/r/rust/a\"));\n+ assert!(chosen.contains(\"reddit.com/r/rust/b\"));\n+ }\n+\n #[test]\n fn resolve_pair_picks_from_pool() {\n let parent = ItemId::parse(\"reddit.com/r/rust\").unwrap();\n\n\nSide B — contributor: tommy-mor\nSide B — commit message:\n[601d3a05] fix(html): drop home toolbar + and ExpandNewThreadForm (single + flow)\n\nPublic home now SSRs #new-thread-ui-slot like room pages: collapsed compose\nfor signed-in users, login hint when logged out. Removes the extra toolbar\nthat morphed the same collapsed state and the expand_new_thread_form action.\n\nMade-with: Cursor\n\nSide B — unified diff (full patch):\ndiff --git a/server/src/api/ui_html.rs b/server/src/api/ui_html.rs\nindex e979053ff1ba8c0e2bf55add0a32b7de11cf1e56..f3ce5cb2ab2f923440a8479d0f1fb4acbba166ca 100644\n--- a/server/src/api/ui_html.rs\n+++ b/server/src/api/ui_html.rs\n@@ -139,51 +139,6 @@ async fn dispatch_ui_action(\n }\n }\n }\n- HtmlUiAction::ExpandNewThreadForm { room_wire } => {\n- let room_wire = room_wire.trim().to_string();\n- if room_wire.is_empty() {\n- return ui_js_warn(\"missing room\").into_response();\n- }\n- if room_wire == \"public\" {\n- let reduced = state.reduced.read().await;\n- let user = session.map(|s| s.username.as_str());\n- drop(reduced);\n- let markup = if user.is_some() {\n- fragment_new_thread_slot(&ThreadNav::public(), true, false)\n- } else {\n- login_to_post_hint_markup()\n- };\n- return JsBuilder::new()\n- .morph_inner_selector(\"#new-thread-ui-slot\", markup)\n- .into_response();\n- }\n- let reduced = state.reduced.read().await;\n- let user = session.map(|s| s.username.as_str());\n- if !reduced.rooms.contains(&room_wire) {\n- drop(reduced);\n- return ui_js_warn(\"room not found\").into_response();\n- }\n- if !user_can_view_room(&reduced, &room_wire, user) {\n- drop(reduced);\n- return ui_js_warn(\"forbidden\").into_response();\n- }\n- let can_post = session\n- .as_ref()\n- .map(|s| user_can_post_room(&reduced, &room_wire, &s.username))\n- .unwrap_or(false);\n- drop(reduced);\n- let Some(nav) = ThreadNav::from_room_id(&room_wire) else {\n- return ui_js_warn(\"bad room\").into_response();\n- };\n- let markup = if can_post {\n- fragment_new_thread_slot(&nav, true, false)\n- } else {\n- login_to_post_hint_markup()\n- };\n- JsBuilder::new()\n- .morph_inner_selector(\"#new-thread-ui-slot\", markup)\n- .into_response()\n- }\n HtmlUiAction::SetRoomMembersExpanded { room_wire, expanded } => {\n let room_wire = room_wire.trim().to_string();\n if room_wire.is_empty() {\ndiff --git a/server/src/html/forum/feed.rs b/server/src/html/forum/feed.rs\nindex 1b4ae7baa3ad4757b74172d7b67f3f2b33d1075d..945bdd6c48bc164e2cf91fd0996c4321b75f5abf 100644\n--- a/server/src/html/forum/feed.rs\n+++ b/server/src/html/forum/feed.rs\n@@ -14,6 +14,7 @@ use crate::timeago;\n \n use super::ingest::ingest_entry_markup;\n use super::nav::ThreadNav;\n+use super::new_thread::{fragment_new_thread_slot, login_to_post_hint_markup};\n use super::page::auth_strip;\n use super::paginator::{render_thread_paginator, PAGE_SIZE};\n use crate::html::{\n@@ -217,9 +218,6 @@ pub async fn home(\n let strip = auth_strip(&headers, &jar, &reduced_read);\n drop(reduced_read);\n \n- use crate::html::ui_action::{HtmlUiAction, UI_RPC_FIELD};\n- use crate::form_template::template_json_compact;\n-\n let page = layout(\n \"slug.social\",\n \"view-thread\",\n@@ -243,15 +241,13 @@ pub async fn home(\n }\n }\n p class=\"muted\" { \"dark = time-ordered · light = vote-ranked\" }\n- div class=\"thread-feed-toolbar\" {\n- form method=\"POST\" action=\"/ui\" {\n- input type=\"hidden\" name=(UI_RPC_FIELD) value=(template_json_compact(&HtmlUiAction::ExpandNewThreadForm {\n- room_wire: \"public\".into(),\n- }).expect(\"static json\"));\n- button type=\"submit\" class=\"section-add-btn\" { \"+\" }\n+ div id=\"new-thread-ui-slot\" {\n+ @if user.is_some() {\n+ (fragment_new_thread_slot(&nav, true, false))\n+ } @else {\n+ (login_to_post_hint_markup())\n }\n }\n- div id=\"new-thread-ui-slot\" {}\n (render_thread_feed(Some(&nav), \"thread-feed\", &public_rows, now))\n (cli_panel(&[\"npx slugsocial public forum list\"]))\n },\ndiff --git a/server/src/html/ui_action.rs b/server/src/html/ui_action.rs\nindex 5031ebfeb928f28e471f23210b8c644654adb7c7..da0c9b3541e8e4988a78768cddef22324755c3f2 100644\n--- a/server/src/html/ui_action.rs\n+++ b/server/src/html/ui_action.rs\n@@ -38,11 +38,6 @@ pub enum HtmlUiAction {\n RedactPost {\n post_id: String,\n },\n- /// Morph `#new-thread-ui-slot` inner to the collapsed compose toggle (or login hint).\n- /// Use `room_wire: \"public\"` for the public forum home; otherwise a private room id (`short/slug`).\n- ExpandNewThreadForm {\n- room_wire: String,\n- },\n /// Morph `#room-members-section` — members list open or collapsed (server-rendered).\n SetRoomMembersExpanded {\n room_wire: String,\n@@ -131,26 +126,6 @@ mod tests {\n );\n }\n \n- #[test]\n- fn expand_new_thread_form_public() {\n- let template = serde_json::json!({\n- \"action\": \"expand_new_thread_form\",\n- \"room_wire\": \"public\",\n- });\n- let mut form = HashMap::new();\n- form.insert(\n- UI_RPC_FIELD.to_string(),\n- serde_json::to_string(&template).unwrap(),\n- );\n- let a = parse_html_ui_from_form(&form).unwrap();\n- assert_eq!(\n- a,\n- HtmlUiAction::ExpandNewThreadForm {\n- room_wire: \"public\".into(),\n- }\n- );\n- }\n-\n #[test]\n fn expand_post_full_round_trip() {\n let template = serde_json::json!({\n","role":"user"}],"model":"~x-ai/grok-latest"}