{"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[aa0b175c] Enforce vote ratio constraints: both sides ≥ 1, max 100.\n\nZero on either side produces no valid graph edge; ratios above 100\nadd no meaningful signal. Enforce in the DSL parser, browser POST\nhandler, and reducer guard. Update browser pool test to use 99:1\ninstead of 100:0. Add unit and integration regression tests.\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 b79efdb4d52bd445a67f38cbfd61d3507d2b3014..bc8a0130b434cc7880a4bf16eb9237080c4aa383 100644\n--- a/server/src/api/ui_html.rs\n+++ b/server/src/api/ui_html.rs\n@@ -243,11 +243,23 @@ async fn dispatch_ui_action(\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- rl = 1;\n- rr = 1;\n+ let rl = ratio_left.trim().parse::().unwrap_or(0).max(0);\n+ let rr = ratio_right.trim().parse::().unwrap_or(0).max(0);\n+ if rl == 0 || rr == 0 {\n+ return form_js_error(\n+ err_tgt.as_ref(),\n+ \"invalid ratio\",\n+ \"Both ratio sides must be ≥ 1.\",\n+ )\n+ .into_response();\n+ }\n+ if rl > 100 || rr > 100 {\n+ return form_js_error(\n+ err_tgt.as_ref(),\n+ \"invalid ratio\",\n+ \"Ratio sides must be ≤ 100.\",\n+ )\n+ .into_response();\n }\n \n let text = format!(\ndiff --git a/server/src/dsl.rs b/server/src/dsl.rs\nindex faa8aac6616bc6ea2b102d08ae999c01a716ef6e..338feacc579a92bed291867cc0f2f62462737462 100644\n--- a/server/src/dsl.rs\n+++ b/server/src/dsl.rs\n@@ -545,9 +545,14 @@ fn parse_block_prefixed_statement(\n \n let ((ratio_left, ratio_right), k) = parse_comparison_at(s, i)\n .ok_or_else(|| DslError::Parse(format!(\"invalid comparison near: {}\", &s[i..])))?;\n- if ratio_left == 0 && ratio_right == 0 {\n+ if ratio_left == 0 || ratio_right == 0 {\n return Err(DslError::Parse(\n- \"vote ratio 0:0 is invalid; use 1:1 for a tie or omit the vote\".to_string(),\n+ \"vote ratio sides must be ≥ 1; use 1:1 for a tie or omit the vote\".to_string(),\n+ ));\n+ }\n+ if ratio_left > 100 || ratio_right > 100 {\n+ return Err(DslError::Parse(\n+ \"vote ratio sides must be ≤ 100\".to_string(),\n ));\n }\n i = skip_ws(s, k);\n@@ -929,11 +934,50 @@ mod tests {\n let err = parse_full(\"{tie placeholder}\\n~/a 0:0 ~/b\").unwrap_err();\n let DslError::Parse(msg) = err;\n assert!(\n- msg.contains(\"0:0\"),\n- \"expected 0:0 rejection message, got: {msg}\"\n+ msg.contains(\"≥ 1\"),\n+ \"expected zero-side rejection message, got: {msg}\"\n );\n }\n \n+ #[test]\n+ fn parse_vote_rejects_left_zero_ratio() {\n+ let err = parse_full(\"{prefer b}\\n~/a 0:5 ~/b\").unwrap_err();\n+ let DslError::Parse(msg) = err;\n+ assert!(\n+ msg.contains(\"≥ 1\"),\n+ \"expected zero-side rejection message, got: {msg}\"\n+ );\n+ }\n+\n+ #[test]\n+ fn parse_vote_rejects_right_zero_ratio() {\n+ let err = parse_full(\"{prefer a}\\n~/a 5:0 ~/b\").unwrap_err();\n+ let DslError::Parse(msg) = err;\n+ assert!(\n+ msg.contains(\"≥ 1\"),\n+ \"expected zero-side rejection message, got: {msg}\"\n+ );\n+ }\n+\n+ #[test]\n+ fn parse_vote_rejects_over_max_ratio() {\n+ let err = parse_full(\"{prefer a strongly}\\n~/a 101:1 ~/b\").unwrap_err();\n+ let DslError::Parse(msg) = err;\n+ assert!(\n+ msg.contains(\"≤ 100\"),\n+ \"expected max ratio rejection message, got: {msg}\"\n+ );\n+ }\n+\n+ #[test]\n+ fn parse_vote_accepts_max_ratio() {\n+ let doc = parse_full(\"{prefer a}\\n~/a 100:1 ~/b\").unwrap();\n+ assert!(matches!(\n+ doc.statements.last(),\n+ Some(Stmt::Vote { ratio_left: 100, ratio_right: 1, .. })\n+ ));\n+ }\n+\n #[test]\n fn parse_full_interleaves_prose() {\n let input = \"hello\\n#tag\\nworld\";\ndiff --git a/server/src/reducer.rs b/server/src/reducer.rs\nindex e949e8e092297eedd5c20c131f16ef0121f329b3..6841d35cfc9de2389f340a22b8a45acb335e36c3 100644\n--- a/server/src/reducer.rs\n+++ b/server/src/reducer.rs\n@@ -119,11 +119,11 @@ impl GroupState {\n let (i, j) = if a_idx < b_idx { (a_idx, b_idx) } else { (b_idx, a_idx) };\n self.voted_pairs.insert((i, j));\n \n- let mut w_a = vote.ratio_left.max(0) as f64;\n- let mut w_b = vote.ratio_right.max(0) as f64;\n- if w_a == 0.0 && w_b == 0.0 {\n- w_a = 1.0;\n- w_b = 1.0;\n+ let w_a = vote.ratio_left as f64;\n+ let w_b = vote.ratio_right as f64;\n+ if w_a == 0.0 || w_b == 0.0 {\n+ // Zero on either side produces no valid edge; drop the vote.\n+ return;\n }\n \n self.add_edge_weight(b_idx, a_idx, w_a);\ndiff --git a/server/tests/basic.rs b/server/tests/basic.rs\nindex 9d83e7a97e2c7494790db17c4b5b30c181705026..cc8c1a0d139f3722ba6ecd13dd001c65be835b67 100644\n--- a/server/tests/basic.rs\n+++ b/server/tests/basic.rs\n@@ -175,14 +175,14 @@ fn reducer_clamps_score_bounds() {\n let mut state = ReducerState::default();\n state.apply_event(ingest_event(\n 1,\n- \"@00000000-0000-0000-0000-000000000000:test:local/test\\n~/t/a {a}\\n~/t/b {b}\\n{huge}\\n~/t/a 1000:1 ~/t/b\\n\",\n+ \"@00000000-0000-0000-0000-000000000000:test:local/test\\n~/t/a {a}\\n~/t/b {b}\\n{huge}\\n~/t/a 100:1 ~/t/b\\n\",\n ));\n state.apply_event(ingest_event(\n 2,\n- \"@00000000-0000-0000-0000-000000000000:test:local/test\\n{huge}\\n~/t/a 1:1000 ~/t/b\\n\",\n+ \"@00000000-0000-0000-0000-000000000000:test:local/test\\n{huge}\\n~/t/a 1:100 ~/t/b\\n\",\n ));\n \n- assert_eq!(state.public().ranking_group.idx_to_item.len(), 2); // Should still work, scores clamped internally\n+ assert_eq!(state.public().ranking_group.idx_to_item.len(), 2); // Should still work, scores handled internally\n }\n \n // ============================================================================\n@@ -513,8 +513,8 @@ fn dsl_parse_rejects_zero_zero_vote_ratio() {\n .expect_err(\"0:0 vote must be rejected by the parser\");\n let slugsocial_server::dsl::DslError::Parse(msg) = err;\n assert!(\n- msg.contains(\"0:0\"),\n- \"expected message about invalid 0:0 ratio, got: {msg}\"\n+ msg.contains(\"≥ 1\"),\n+ \"expected message about invalid zero ratio, got: {msg}\"\n );\n \n let mut state = ReducerState::default();\n@@ -533,7 +533,7 @@ fn dsl_parse_rejects_zero_zero_vote_ratio() {\n #[test]\n fn reducer_negative_ratio_clamped_to_zero() {\n let _state = ReducerState::default();\n- // GroupState::apply_vote clamps negatives to 0, then 0:0 -> 1:1\n+ // GroupState::apply_vote clamps negatives to 0; when either side is 0 the vote is dropped.\n let mut group = GroupState::new();\n group.apply_vote(slugsocial_server::reducer::VoteData {\n ts: 1,\n@@ -546,12 +546,12 @@ fn reducer_negative_ratio_clamped_to_zero() {\n delegate: Some(\"00000000-0000-0000-0000-000000000000:test:local/test\".to_string()),\n thread_tag: \"t\".to_string(),\n });\n+ // Items are registered, but the zero-clamped vote produces no edges.\n assert_eq!(group.idx_to_item.len(), 2);\n- // Both edges should exist (negatives clamped to 0, then 0:0 -> 1:1)\n let a_idx = group.item_to_idx[&item_id(\"https://slug.social/~/t/a\")];\n let b_idx = group.item_to_idx[&item_id(\"https://slug.social/~/t/b\")];\n- assert!(group.edges.contains_key(&(a_idx, b_idx)));\n- assert!(group.edges.contains_key(&(b_idx, a_idx)));\n+ assert!(!group.edges.contains_key(&(a_idx, b_idx)));\n+ assert!(!group.edges.contains_key(&(b_idx, a_idx)));\n }\n \n \ndiff --git a/server/tests/integration_ui.rs b/server/tests/integration_ui.rs\nindex 23db7b5672418d5bb0ab7529e05ef1f89e59062a..09c5481f039d59efb617a82bafcc432a186e2d30 100644\n--- a/server/tests/integration_ui.rs\n+++ b/server/tests/integration_ui.rs\n@@ -256,3 +256,96 @@ async fn test_sse_public_thread_morph_includes_post_body_not_thread_not_found()\n );\n }\n \n+fn ui_vote_compare_post_rpc(\n+ room: &str,\n+ thread_tag: &str,\n+ left: &str,\n+ right: &str,\n+ ratio_left: &str,\n+ ratio_right: &str,\n+ explanation: &str,\n+) -> String {\n+ serde_json::json!({\n+ \"action\": \"vote_compare_post\",\n+ \"room\": room,\n+ \"thread_tag\": thread_tag,\n+ \"left_item\": left,\n+ \"right_item\": right,\n+ \"ratio_left\": ratio_left,\n+ \"ratio_right\": ratio_right,\n+ \"explanation\": explanation,\n+ \"next\": \"/vote\",\n+ })\n+ .to_string()\n+}\n+\n+#[tokio::test]\n+async fn test_vote_compare_post_rejects_zero_left_ratio() {\n+ let (addr, _tmp, _log, _handle) = create_test_server().await;\n+ let client = reqwest::Client::new();\n+ let bearer = test_bearer();\n+\n+ let rpc = ui_vote_compare_post_rpc(\"public\", \"test-vote\", \"~/a\", \"~/b\", \"0\", \"5\", \"prefer b\");\n+ let resp = client\n+ .post(format!(\"http://{addr}/ui\"))\n+ .header(\"Authorization\", format!(\"Bearer {bearer}\"))\n+ .form(&[(\"__rpc__\", rpc.as_str())])\n+ .send()\n+ .await\n+ .unwrap();\n+\n+ assert_eq!(resp.status(), reqwest::StatusCode::OK);\n+ let js = resp.text().await.unwrap();\n+ assert!(\n+ js.contains(\"invalid ratio\") || js.contains(\"≥ 1\"),\n+ \"expected zero-ratio rejection, got: {js}\"\n+ );\n+}\n+\n+#[tokio::test]\n+async fn test_vote_compare_post_rejects_zero_right_ratio() {\n+ let (addr, _tmp, _log, _handle) = create_test_server().await;\n+ let client = reqwest::Client::new();\n+ let bearer = test_bearer();\n+\n+ let rpc = ui_vote_compare_post_rpc(\"public\", \"test-vote\", \"~/a\", \"~/b\", \"5\", \"0\", \"prefer a\");\n+ let resp = client\n+ .post(format!(\"http://{addr}/ui\"))\n+ .header(\"Authorization\", format!(\"Bearer {bearer}\"))\n+ .form(&[(\"__rpc__\", rpc.as_str())])\n+ .send()\n+ .await\n+ .unwrap();\n+\n+ assert_eq!(resp.status(), reqwest::StatusCode::OK);\n+ let js = resp.text().await.unwrap();\n+ assert!(\n+ js.contains(\"invalid ratio\") || js.contains(\"≥ 1\"),\n+ \"expected zero-ratio rejection, got: {js}\"\n+ );\n+}\n+\n+#[tokio::test]\n+async fn test_vote_compare_post_rejects_over_max_ratio() {\n+ let (addr, _tmp, _log, _handle) = create_test_server().await;\n+ let client = reqwest::Client::new();\n+ let bearer = test_bearer();\n+\n+ let rpc =\n+ ui_vote_compare_post_rpc(\"public\", \"test-vote\", \"~/a\", \"~/b\", \"101\", \"1\", \"prefer a\");\n+ let resp = client\n+ .post(format!(\"http://{addr}/ui\"))\n+ .header(\"Authorization\", format!(\"Bearer {bearer}\"))\n+ .form(&[(\"__rpc__\", rpc.as_str())])\n+ .send()\n+ .await\n+ .unwrap();\n+\n+ assert_eq!(resp.status(), reqwest::StatusCode::OK);\n+ let js = resp.text().await.unwrap();\n+ assert!(\n+ js.contains(\"invalid ratio\") || js.contains(\"≤ 100\"),\n+ \"expected over-max ratio rejection, got: {js}\"\n+ );\n+}\n+\ndiff --git a/test/browser_vote_pool.clj b/test/browser_vote_pool.clj\nindex 23d0bd80b02bd8b1b48853454bed02793296550e..738608801027d1e662660b5d6c830b4ccd07c434 100644\n--- a/test/browser_vote_pool.clj\n+++ b/test/browser_vote_pool.clj\n@@ -38,8 +38,8 @@\n ;; Set the hidden ratio inputs so the alphabetically-earlier item wins.\n (defn- set-ratio! [pg left-text right-text]\n (let [[rl rr] (if (neg? (compare (leaf left-text) (leaf right-text)))\n- [100 0] ; left is earlier → prefer left\n- [0 100])] ; right is earlier → prefer right\n+ [99 1] ; left is earlier → prefer left\n+ [1 99])] ; right is earlier → prefer right\n (page/evaluate pg (str \"document.getElementById('vote-ratio-left').value='\" rl \"'\"))\n (page/evaluate pg (str \"document.getElementById('vote-ratio-right').value='\" rr \"'\"))))\n \n","role":"user"}],"model":"~x-ai/grok-latest"}