{"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[5350388a] Add pool-scoped voting: /vote?pool= picks pairs from children.\n\n- /vote now accepts an optional `pool` param (parent item path). When\n provided without left/right, it picks the first unvoted pair from the\n pool's children. When provided alongside left/right, it constrains\n \"next pair\" navigation to siblings within the pool.\n- \"vote on children\" button appears on item pages with ≥2 children,\n linking to /vote?pool=.\n- Pool is threaded through VoteComparePost → success JS so in-page\n morph after voting keeps the pool context for next-pair navigation.\n\nCo-Authored-By: Claude Sonnet 4.6 \n\nSide B — unified diff (full patch):\ndiff --git a/server/src/api/ui_html.rs b/server/src/api/ui_html.rs\nindex 5faa642451d69555cb391974beb0ad22c9355c8c..b79efdb4d52bd445a67f38cbfd61d3507d2b3014 100644\n--- a/server/src/api/ui_html.rs\n+++ b/server/src/api/ui_html.rs\n@@ -193,6 +193,7 @@ async fn dispatch_ui_action(\n ratio_right,\n explanation,\n next,\n+ pool,\n form_action,\n } => {\n if form_action != \"/ui\" {\n@@ -239,6 +240,9 @@ async fn dispatch_ui_action(\n .into_response();\n }\n };\n+ let pool_id = pool.as_deref().and_then(|p| {\n+ crate::path_types::ItemId::parse(p.trim()).map(|i| i.normalized_storage())\n+ });\n let mut rl = ratio_left.trim().parse::().unwrap_or(0).max(0);\n let mut rr = ratio_right.trim().parse::().unwrap_or(0).max(0);\n if rl == 0 && rr == 0 {\n@@ -294,6 +298,7 @@ async fn dispatch_ui_action(\n &thread_tag,\n &left_id,\n &right_id,\n+ pool_id.as_ref(),\n pid.as_str(),\n post_index,\n )\ndiff --git a/server/src/html/garden/pin.rs b/server/src/html/garden/pin.rs\nindex 5865cfdbc06aeb6555c97380e25591fae6b3d125..1820d7fe7ee167ecbf5ad5124f23b2ab92ffb01f 100644\n--- a/server/src/html/garden/pin.rs\n+++ b/server/src/html/garden/pin.rs\n@@ -79,7 +79,7 @@ pub(super) fn ont_pin_vote_controls(\n }\n }\n } @else {\n- a class=\"ont-vote-compare-btn\" href=(vote_compare_href(nav, pi, ¤t, None)) title=\"Compare and vote\" {\n+ a class=\"ont-vote-compare-btn\" href=(vote_compare_href(nav, pi, ¤t, None, None)) title=\"Compare and vote\" {\n span class=\"ont-vote-glyph\" aria-hidden=\"true\" { \"⚖\" }\n span { \"vote\" }\n }\n@@ -121,7 +121,7 @@ pub(super) fn child_row_pin_or_vote(\n if nv == 1 { \"\" } else { \"s\" },\n );\n @let aria = format!(\"Vote; {} pairwise {}\", nv, if nv == 1 { \"vote\" } else { \"votes\" });\n- a class=\"ont-garden-vote-ico\" href=(vote_compare_href(nav, pi, row_item, None)) title=(tip) aria-label=(aria) {\n+ a class=\"ont-garden-vote-ico\" href=(vote_compare_href(nav, pi, row_item, None, None)) title=(tip) aria-label=(aria) {\n span class=\"ont-garden-vote-glyph\" aria-hidden=\"true\" { \"⚖\" }\n span class=\"ont-garden-vote-count\" { (format!(\"{}\", nv)) }\n }\ndiff --git a/server/src/html/garden/render.rs b/server/src/html/garden/render.rs\nindex 5c3986ca36902f6c9019a4b5590f0b3b9d2cb4ff..bd8cbce059ee789de6e8dc9b6f69f54beee2f994 100644\n--- a/server/src/html/garden/render.rs\n+++ b/server/src/html/garden/render.rs\n@@ -29,6 +29,7 @@ use super::{\n item::{child_depth_from_uri, item_code_label, item_display_path, item_href},\n item_page::{build_item_page_view_model, sibling_nav_markup},\n pin::{child_row_pin_or_vote, ont_pin_vote_controls, pinned_item_from_jar},\n+ vote::vote_pool_href,\n };\n \n pub(super) async fn render_scope_view(\n@@ -186,12 +187,21 @@ pub(super) async fn render_scope_view(\n }\n \n section class=\"ont-tab-panel ont-tab-panel-children\" {\n+ @let total_children = model.child_rankings.component_rankings\n+ .iter().map(|c| c.ranked.len()).sum::()\n+ + model.child_rankings.unranked_items.len();\n h3 {\n \"ranked child groups\"\n @if model.child_depth > 1 {\n \" \"\n span class=\"muted\" { (format!(\"(depth {})\", model.child_depth)) }\n }\n+ @if total_children >= 2 {\n+ \" \"\n+ a class=\"ont-vote-children-btn\" href=(vote_pool_href(&nav, &model.item)) {\n+ \"vote on children\"\n+ }\n+ }\n }\n @if model.child_rankings.component_rankings.is_empty() {\n p class=\"muted\" { \"no voted pairs yet in this scope\" }\ndiff --git a/server/src/html/garden/tests.rs b/server/src/html/garden/tests.rs\nindex 6900a6795bcde866a176722149d6378e5127b4c3..c2036fca7752aef63d260e36cfe9649f63b5c550 100644\n--- a/server/src/html/garden/tests.rs\n+++ b/server/src/html/garden/tests.rs\n@@ -105,7 +105,7 @@ fn suggest_next_vote_pair_prefers_unvoted_sibling_pair() {\n let content = content_for_garden_view(&reduced, &ScopeId::Public);\n let a = ItemId::parse(\"~/topic/a\").unwrap().normalized_storage();\n let b = ItemId::parse(\"~/topic/b\").unwrap().normalized_storage();\n- let next = suggest_next_vote_pair(content, &a, &b).expect(\"next sibling pair\");\n+ let next = suggest_next_vote_pair(content, &a, &b, None).expect(\"next sibling pair\");\n assert_ne!(\n canonical_edge_items(&next.0, &next.1),\n canonical_edge_items(&a, &b)\ndiff --git a/server/src/html/garden/vote.rs b/server/src/html/garden/vote.rs\nindex 1d7fc8aa7436bfa9c1186dfd940a8d751ab7e088..2682cfcbd2f834b56459a02831aa225cffe67c58 100644\n--- a/server/src/html/garden/vote.rs\n+++ b/server/src/html/garden/vote.rs\n@@ -211,14 +211,15 @@ pub(crate) async fn vote_compare_post_success_js(\n _thread_tag: &str,\n left: &ItemId,\n right: &ItemId,\n+ pool: Option<&ItemId>,\n _post_id: &str,\n _post_idx: Option,\n ) -> String {\n let reduced = state.reduced.read().await;\n let content = content_for_garden_view(&reduced, &nav.scope());\n let edge_history = vote_edge_history_markup(content, left, right);\n- let next_pair = suggest_next_vote_pair(content, left, right);\n- let nav_markup = vote_compare_nav_markup(nav, next_pair.as_ref());\n+ let next_pair = suggest_next_vote_pair(content, left, right, pool);\n+ let nav_markup = vote_compare_nav_markup(nav, next_pair.as_ref(), pool);\n drop(reduced);\n JsBuilder::new()\n .morph_inner_selector(\"#vote-edge-history-region\", edge_history)\n@@ -231,27 +232,39 @@ pub(super) fn vote_compare_href(\n left: &ItemId,\n right: &ItemId,\n thread_override: Option<&str>,\n+ pool: Option<&ItemId>,\n ) -> String {\n let left_q = urlencoding::encode(left.as_str());\n let right_q = urlencoding::encode(right.as_str());\n- let base = format!(\n+ let mut base = format!(\n \"{}/vote?left={}&right={}\",\n nav.room_path_prefix_for_vote_compare(),\n left_q,\n right_q\n );\n if let Some(t) = thread_override.filter(|s| !s.is_empty()) {\n- format!(\"{}&thread={}\", base, urlencoding::encode(t))\n- } else {\n- base\n+ base = format!(\"{}&thread={}\", base, urlencoding::encode(t));\n+ }\n+ if let Some(p) = pool {\n+ base = format!(\"{}&pool={}\", base, urlencoding::encode(p.as_str()));\n }\n+ base\n+}\n+\n+pub(super) fn vote_pool_href(nav: &ThreadNav, pool_item_str: &str) -> String {\n+ format!(\n+ \"{}/vote?pool={}\",\n+ nav.room_path_prefix_for_vote_compare(),\n+ urlencoding::encode(pool_item_str)\n+ )\n }\n \n fn vote_compare_nav_markup(\n nav: &ThreadNav,\n next_pair: Option<&(ItemId, ItemId)>,\n+ pool: Option<&ItemId>,\n ) -> maud::Markup {\n- let next_pair_href = next_pair.map(|(nl, nr)| vote_compare_href(nav, nl, nr, None));\n+ let next_pair_href = next_pair.map(|(nl, nr)| vote_compare_href(nav, nl, nr, None, pool));\n html! {\n div class=\"vote-compare-nav\" {\n @if let Some(href) = &next_pair_href {\n@@ -267,8 +280,15 @@ pub(super) fn suggest_next_vote_pair(\n content: &ContentState,\n current_left: &ItemId,\n current_right: &ItemId,\n+ pool_parent: Option<&ItemId>,\n ) -> Option<(ItemId, ItemId)> {\n- let pool: Vec = if current_left.parent().as_ref().map(|p| p.as_str())\n+ let pool: Vec = if let Some(parent) = pool_parent {\n+ content\n+ .item_children\n+ .get(parent)\n+ .map(|s| s.iter().cloned().collect())\n+ .unwrap_or_default()\n+ } else if current_left.parent().as_ref().map(|p| p.as_str())\n == current_right.parent().as_ref().map(|p| p.as_str())\n {\n current_left\n@@ -322,10 +342,14 @@ pub(super) fn vote_compare_item_card(\n }\n #[derive(Debug, Deserialize)]\n pub struct VoteCompareQuery {\n- pub left: String,\n- pub right: String,\n+ #[serde(default)]\n+ pub left: Option,\n+ #[serde(default)]\n+ pub right: Option,\n #[serde(default)]\n pub thread: Option,\n+ #[serde(default)]\n+ pub pool: Option,\n }\n \n /// Public pairwise vote UI — `/vote?left=&right=&thread=`.\n@@ -376,17 +400,53 @@ async fn vote_compare_inner(\n jar: CookieJar,\n uri: Uri,\n ) -> axum::response::Response {\n- let left = match ItemId::parse(q.left.trim()) {\n- Some(i) => i.normalized_storage(),\n- None => return (StatusCode::NOT_FOUND, \"bad left item\").into_response(),\n+ let pool_id: Option = match q.pool.as_deref() {\n+ Some(p) => match ItemId::parse(p.trim()) {\n+ Some(i) => Some(i.normalized_storage()),\n+ None => return (StatusCode::BAD_REQUEST, \"bad pool item\").into_response(),\n+ },\n+ None => None,\n };\n- let right = match ItemId::parse(q.right.trim()) {\n- Some(i) => i.normalized_storage(),\n- None => return (StatusCode::NOT_FOUND, \"bad right item\").into_response(),\n+\n+ let (left, right) = match (q.left.as_deref(), q.right.as_deref()) {\n+ (Some(l), Some(r)) => {\n+ let left = match ItemId::parse(l.trim()) {\n+ Some(i) => i.normalized_storage(),\n+ None => return (StatusCode::NOT_FOUND, \"bad left item\").into_response(),\n+ };\n+ let right = match ItemId::parse(r.trim()) {\n+ Some(i) => i.normalized_storage(),\n+ None => return (StatusCode::NOT_FOUND, \"bad right item\").into_response(),\n+ };\n+ if left == right {\n+ return (StatusCode::BAD_REQUEST, \"items must differ\").into_response();\n+ }\n+ (left, right)\n+ }\n+ (None, None) => {\n+ let Some(pool) = pool_id.as_ref() else {\n+ return (StatusCode::BAD_REQUEST, \"provide left+right or pool\").into_response();\n+ };\n+ let reduced = state.reduced.read().await;\n+ let content = content_for_garden_view(&reduced, &nav.scope());\n+ let children: Vec = content\n+ .item_children\n+ .get(pool)\n+ .map(|s| s.iter().cloned().collect())\n+ .unwrap_or_default();\n+ if children.len() < 2 {\n+ drop(reduced);\n+ return (StatusCode::BAD_REQUEST, \"pool has fewer than 2 children to compare\").into_response();\n+ }\n+ let pair = suggest_next_pair_in_pool(&content.ranking_group, &children, None);\n+ drop(reduced);\n+ match pair {\n+ Some(p) => p,\n+ None => return (StatusCode::BAD_REQUEST, \"no pairs available in pool\").into_response(),\n+ }\n+ }\n+ _ => return (StatusCode::BAD_REQUEST, \"provide both left and right, or just pool\").into_response(),\n };\n- if left == right {\n- return (StatusCode::BAD_REQUEST, \"items must differ\").into_response();\n- }\n \n let reduced = state.reduced.read().await;\n let content = content_for_garden_view(&reduced, &nav.scope());\n@@ -409,7 +469,7 @@ async fn vote_compare_inner(\n let left_body = content.item_bodies.get(&left).cloned();\n let right_body = content.item_bodies.get(&right).cloned();\n let item_bodies_for_cards = content.item_bodies.clone();\n- let next_pair = suggest_next_vote_pair(content, &left, &right);\n+ let next_pair = suggest_next_vote_pair(content, &left, &right, pool_id.as_ref());\n drop(reduced);\n \n let title = format!(\n@@ -432,6 +492,7 @@ async fn vote_compare_inner(\n \"ratio_right\": {\"$form\": \"ratio_right\"},\n \"explanation\": {\"$form\": \"explanation\"},\n \"next\": next_path,\n+ \"pool\": pool_id.as_ref().map(|p| p.as_str()),\n \"form_action\": \"/ui\",\n }))\n .expect(\"vote compare rpc json\");\n@@ -456,7 +517,7 @@ async fn vote_compare_inner(\n Some(&item_bodies_for_cards),\n ))\n }\n- (vote_compare_nav_markup(&nav, next_pair.as_ref()))\n+ (vote_compare_nav_markup(&nav, next_pair.as_ref(), pool_id.as_ref()))\n div id=\"vote-edge-history-region\" {\n (edge_history)\n }\ndiff --git a/server/src/html/ui_action.rs b/server/src/html/ui_action.rs\nindex dd5294202569454acf9f41b458718700bbf96f39..2589a2cc00bb7b18cd19ebcbb938083122d6921d 100644\n--- a/server/src/html/ui_action.rs\n+++ b/server/src/html/ui_action.rs\n@@ -50,6 +50,9 @@ pub enum HtmlUiAction {\n explanation: String,\n /// Same-origin path after successful post (JS redirect).\n next: String,\n+ /// Pool parent item path, if the vote was initiated from a pool URL.\n+ #[serde(default)]\n+ pool: Option,\n #[serde(default = \"default_ui_form_action\")]\n form_action: String,\n },\n","role":"user"}],"model":"openai/gpt-chat-latest"}