constitution · epochs · watch · epoch 3

comparison

c_0e1a063d5849 (tommy-mor) vs c_5bc77fbfad41 (tommy-mor)

download prompt · raw event · cmp_ff662f3fcc78ad

council reasoning

~anthropic/claude-sonnet-latest · winner B · 7:3 · permalink

Side A merely removes an entire dead feature (tree.rs), which is a cleanup but adds no new functionality and discards ~800 lines of implemented logic/tests without replacement. Side B adds a small, real feature (view count display on vote compare pages) with proper wiring through layout functions and includes new integration test assertions verifying the behavior, making it a positive, tested contribution.

~x-ai/grok-latest · winner B · 1:3 · permalink

B adds a real product behavior—plumbing view counts into the vote-compare page via layout_full_bleed_chromeless and locking it in with integration assertions—whereas A only deletes the entire tree module and its exports with no replacement design. A small tested feature addition outlasts pure feature removal for project value.

openai/gpt-chat-latest · winner B · 9:1 · permalink

Side B fixes a functional omission by wiring the existing view-count mechanism into the fullscreen vote page: it computes the canonical view key, passes the count through `layout_full_bleed_chromeless`, and adds integration tests verifying the displayed count increments from 1 to 2. Side A simply removes the entire `tree` HTML module and its exports without showing a replacement or migration, so the patch appears to eliminate a substantial feature rather than add lasting functionality.

sides

A — c_0e1a063d5849 (tommy-mor)

message

[cdeb4072] tree nixed

diff preview

diff --git a/server/src/html/mod.rs b/server/src/html/mod.rs
index 82c5993fabfeaf2ea8b9034bccaef37924100264..9c5af9654c7010d2cdb100e4cf63ba63e77c8c57 100644
--- a/server/src/html/mod.rs
+++ b/server/src/html/mod.rs
@@ -12,7 +12,6 @@ mod editor;
 mod forum;
 mod garden;
 mod search;
-mod tree;
 use breadcrumb_path::OntologyPath;
 
 pub use auth::{auth_complete_page, auth_signed_in_fragment, choose_username_error_fragment, choose_username_page};
@@ -20,7 +19,6 @@ pub use editor::{editor_check, editor_page};
 pub use forum::{index, thread_feed_html, thread_post_expand, thread_post_view, thread_view};
 pub use garden::{garden_index, ontology_path};
 pub use search::{search_page, search_results_fragment};
-pub use tree::{tree_path, tree_root, tree_select, tree_toggle};
 
 // Embed CSS files at compile time
 const THEME_DEFAULT_CSS: &str = include_str!("../../static/theme_default.css");
diff --git a/server/src/html/tree.rs b/server/src/html/tree.rs
deleted file mode 100644
index 6aed7db08682f088df3d52d0358b8dc954e9e1df..0000000000000000000000000000000000000000
--- a/server/src/html/tree.rs
+++ /dev/null
@@ -1,819 +0,0 @@
-use axum::{
-    extract::{Path, State},
-    http::{header, StatusCode},
-    response::{Html, IntoResponse, Response},
-    Form,
-};
-use axum::response::Redirect;
-use axum_extra::extract::Query;
-use base64::engine::general_purpose::URL_SAFE_NO_PAD;
-use base64::Engine as _;
-use maud::{html, Markup};
-use serde::{Deserialize, Serialize};
-use std::collections::BTreeSet;
-
-use crate::{
-    canonical_path::canonicalize_item,
-    path_types::{CanonicalItemUrl, RelativePath},
-    scope_rank::ChildrenRankings,
-    state::AppState,
-};
-
-// Convenience alias used throughout this module.
-type CanonSet = BTreeSet<CanonicalItemUrl>;
-
-use super::{layout, render_linkified_with_embeds};
-
-/// Query-state for the expandable tree UI.
-#[derive(Debug, Clone, Default, Deserialize)]
-pub struct TreeQuery {
-    /// Opaque state blob (base64url postcard).
-    #[serde(default)]
-    pub s: Option<String>,
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-struct TreeStateV1 {
-    v: u8,
-    #[serde(default)]
-    open: Vec<String>,
-    #[serde(default)]
-    selected: Option<String>,
-}
-
-// Note: TreeStateV1/V2 intentionally use raw `String` / `Vec<String>` because
-// they are wire-format structs serialised with postcard.  All semantic types
-// (`CanonicalItemUrl`, `RelativePath`) are used in the in-memory
-// `DecodedTreeState` and in every function that works with live data.
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-enum SelectedRefV2 {
-    /// Index into the expanded open list.
-    I(u32),
-}
-
-#[derive(Debug, Clone, Serialize, Deserialize)]
-struct TreeStateV2 {
-    v: u8,
-    /// Common prefix shared by open paths (and optionally selected), ending on a `/` boundary.
-    #[serde(default)]
-    base: String,
-    /// Each entry is a relative path suffix (joined with `base`).
-    #[serde(default)]
-    open_suffixes: Vec<String>,
-    #[serde(default)]
-    selected: Option<SelectedRefV2>,
-}
-
-#[derive(Debug, Clone)]
-struct DecodedTreeState {
-    open: CanonSet,
-    selected: Option<CanonicalItemUrl>,
-}
-
-fn common_base_boundary(paths: &[String]) -> String {
-    if paths.is_empty() {
-        return String::new();
-    }
-    let mut prefix = paths[0].as_str();
-    for p in &paths[1..] {
-        let mut i = 0usize;
-        let bytes_a = prefix.as_bytes();
-        let bytes_b = p.as_bytes();
-        let n = bytes_a.len().min(bytes_b.len());
-        while i < n && bytes_a[i] == bytes_b[i] {
-            i += 1;
-        }
-        prefix = &prefix[..i];
-        if prefix.is_empty() {
-            break;
-        }
-    }
-    // Snap to last '/' boundary (include the slash).
-    match prefix.rfind('/') {
-        None => String::new(),
-        Some(idx) => prefix[..=idx].to_string(),
-    }
-}
-
-fn canon_root(root: &str) -> Option<CanonicalItemUrl> {
-    CanonicalItemUrl::parse(root)
-}
-
-fn canon_to_relative(root: &CanonicalItemUrl, item: &str) -> Option<RelativePath> {
-    // Only support ontology items under the same root.
-    let root_str = root.as_str();
-    let item_can = canonicalize_item(item);
-    if item_can.is_empty() {
-        return None;
-    }
-    // Root must be ontology (`https://slug.social/~/...`)
-    root.tilde_tail()?;
-    if item_can == root_str {
-        return RelativePath::new("");
-    }
-    let prefix = if root_str.ends_with('/') {
-        root_str.to_string()
-    } else {
-        format!("{}/", root_str)
-    };
-    if !item_can.starts_with(&prefix) {
-        return None;
-    }
-    let suffix = &item_can[prefix.len()..];
-    RelativePath::new(suffix)
-}
-
-fn relative_to_canon(root: &CanonicalItemUrl, rel: &RelativePath) -> Option<CanonicalItemUrl> {
-    rel.join_under_ontology_root(root)
-}
-
-fn encode_state_blob_v2(
-    root: &str,
-    open: &CanonSet,
-    selected: Option<&CanonicalItemUrl>,
-) -> String {
-    let Some(root_can) = canon_root(root) else {
-        return String::new();
-    };
-
-    // Convert to sorted relative paths (strings for wire encoding).
-    let mut rels: Vec<String> = open
-        .iter()
-        .filter_map(|it| canon_to_relative(&root_can, it.as_str()).map(|r| r.0.clone()))
-        .collect();
-    rels.sort();
-    rels.dedup();
-
-    let sel_rel: Option<String> = selected
-        .and_then(|s| canon_to_relative(&root_can, s.as_str()))
-        .map(|r| r.0.clone());
-
-    // In v2 we enforce: selected ∈ open. This allows selected to be encoded as an index only.
-    if let Some(sr) = &sel_rel {
-        rels.push(sr.clone());
-        rels.sort();
-        rels.dedup();
-    }
-
-    // base dedupe over open rels + selection (if present)
-    let mut base_inputs = rels.clone();
-    if let Some(sr) = &sel_rel {
-        base_inputs.push(sr.clone());
-    }
-    let base = common_base_boundary(&base_inputs);
-
-    let open_suffixes: Vec<String> = rels
-        .iter()
-        .map(|r| r.strip_prefix(&base).unwrap_or(r).to_string())
-        .collect();
-
-    let selected_ref: Option<SelectedRefV2> = sel_rel.and_then(|full| {
-        rels.iter()
-            .position(|r| r == &full)
-            .map(|idx| SelectedRefV2::I(idx as u32))
-    });
-
-    let st = TreeStateV2 {
-        v: 2,
-        base,
-        open_suffixes,
-        selected: selected_ref,
-    };
-    let bytes = postcard::to_allocvec(&st).unwrap_or_default();
-    URL_SAFE_NO_PAD.encode(bytes)
-}
-
-fn decode_state_blob_any(root: &str, s: &str) -> Option<DecodedTreeState> {
-    let root_can = canon_root(root)?;
-    let bytes = URL_SAFE_NO_PAD.decode(s).ok()?;
-    // Try v2 first.
-    if let Ok(st2) = postcard::from_bytes::<TreeStateV2>(&bytes) {
-        if st2.v == 2 {
-            let mut open: CanonSet = BTreeSet::new();
-            for suf in st2.open_suffixes {
-                let full_rel = format!("{}{}", st2.base, suf);
-                if let Some(rp) = RelativePath::new(&full_rel) {
-                    if let Some(c) = relative_to_canon(&root_can, &rp) {
-                        open.insert(c);
-                    }
-                }
-            }
-            let selected: Option<CanonicalItemUrl> = match st2.selected {
-                None => None,
-                Some(SelectedRefV2::I(i)) => {
-                    let idx = i as usize;
-                    // Index into the sorted open set (BTreeSet iteration is sorted).
-                    open.iter().nth(idx).cloned()
-                }
-                // v2 always encodes selected as an index; no string fallback
-            };
-            return Some(DecodedTreeState { open, selected });
-        }
-    }
-    // Fallback v1 (stored canonical-ish strings).
-    let st1: TreeStateV1 = postcard::from_bytes(&bytes).ok()?;
-    if st1.v != 1 {
-        return None;
-    }
-    let open: CanonSet = st1
-        .open
-        .into_iter()
-        .filter_map(|s| CanonicalItemUrl::parse(&canonicalize_item(&s)))
-        .collect();
-    let selected = st1
-        .selected
-        .as_ref()
-        .and_then(|s| CanonicalItemUrl::parse(&canonicalize_item(s)));
-    Some(DecodedTreeState { open, selected })
-}
-
-fn baseline_state_blob() -> String {
-    // Root doesn't affect empty state; V2 encodes open=[], selected=None.
-    // We still build it via V2 encoder for forward-compat.
-    encode_state_blob_v2("https://slug.social/~/", &CanonSet::new(), None)
-}
-
-fn href_for(root: &str, open: &CanonSet, selected: Option<&CanonicalItemUrl>) -> String {
-    let blob = encode_state_blob_v2(root, open, selected);
-    let base = format!("/tree/{}", root.trim_start_matches("https://slug.social/~/"))
-        .trim_end_matches('/')
-        .to_string();
-    format!("{base}?s={blob}")
-}
-
-fn tree_root_from_path(path: Option<&str>) -> String {
-    // Interpret /tree and /tree/*path as `~/...` under slug.social.
-    // Empty path => "~/"
-    match path {
-        None => canonicalize_item("~/"),
-        Some(p) if p.trim().is_empty() => canonicalize_item("~/"),
-        Some(p) => canonicalize_item(&format!("~/{}", p.trim_start_matches('/'))),
-    }
-}
-
-fn ranked_children_public(
-    reduced: &crate::reducer::ReducerState,
-    parent: &str,
-) -> Vec<CanonicalItemUrl> {
-    // Reducer parent keys are derived from `item_parent_path`, which uses
-    // item_children uses "https://slug.social/~" (no trailing slash) as the root
-    // parent key. Use ontology_root() for the root case, or parse the given parent.
-    let parent_can = if parent.trim_end_matches('/') == "https://slug.social/~" || parent == "https://slug.social/~/" {
-        CanonicalItemUrl::ontology_root()
-    } else {
-        CanonicalItemUrl::parse(parent.trim_end_matches('/'))
-            .unwrap_or_else(CanonicalItemUrl::ontology_root)
-    };
-    let rankings: ChildrenRankings =
-        crate::scope_rank::build_children_rankings(reduced.public(), &parent_can);
-    let mut out: Vec<CanonicalItemUrl> = Vec::new();
-    let mut seen: std::collections::HashSet<CanonicalItemUrl> = std::collections::HashSet::new();
-
-    for comp in rankings.component_rankings {
-        for r in comp.ranked {
-            seen.insert(r.item.clone());
-            out.push(r.item);
-        }
-    }
-    for it in rankings.unranked_items {
-        seen.insert(it.clone());
-        out.push(it);
-    }
-
-    // Also surface phantom intermediate nodes: keys of item_children that are
-    // direct children of parent but were never explicitly ingested as items
-    // (so they don't appear in any ranking). Example: ~/languages exists only as
-    // a parent of ~/languages/rust etc., never ranked at the root level.
-    let phantom_parent_prefix = format!("{}/", parent_can.as_str());
-    for key in reduced.public().item_children.keys() {
-        let key_str = key.as_str();
-        if !key_str.starts_with(&phantom_parent_prefix) {
-            continue;
-        }
-        // Must be a direct child: no further '/' after the prefix.
-        let tail = &key_str[phantom_parent_prefix.len()..];
-        if tail.contains('/') {
-            continue;
-        }
-        if seen.contains(key) {
-            continue;
-        }
-        seen.insert(key.clone());
-        out.push(key.clone());
-    }
-
-    out
-}
-
-fn node_id(path: &str) -> String {
-    // Stable DOM id derived from canonical path.
-    let mut h: u64 = 1469598103934665603; // FNV-1a 64-bit offset basis
-    for b in path.as_bytes() {
-        h ^= *b as u64;
-        h = h.wrapping_mul(1099511628211);
-    }
-    format!("node-{:016x}", h)
-}
-
-fn render_tree_node(
-    reduced: &crate::reducer::ReducerState,
-    path: &CanonicalItemUrl,
-    root: &str,
-    open: &CanonSet,
-    selected: Option<&CanonicalItemUrl>,
-) -> Markup {
-    let path_str = path.as_str();
-    let id = node_id(path_str);
-    let is_open = open.contains(path);
- 

… preview truncated; 17,487 characters omitted

download full diff A

B — c_5bc77fbfad41 (tommy-mor)

message

[d1912140] viewcount in votepage

diff preview

diff --git a/server/src/html/garden.rs b/server/src/html/garden.rs
index 86b4c184724910bb464682b9025d19ce6cd2050d..82c1b4b4f36ea13a906035a1789ba893222b3695 100644
--- a/server/src/html/garden.rs
+++ b/server/src/html/garden.rs
@@ -1397,10 +1397,14 @@ async fn vote_compare_inner(
     }
     };
 
+    let url_key = canonical_view_url(&uri);
+    let view_count = state.views.get_views(&url_key);
+
     let page = layout_full_bleed_chromeless(
         &title,
         "view-ontology view-ontology-light view-vote-compare view-vote-compare-fullscreen",
         body,
+        Some(view_count),
         theme_from_jar(&jar),
         &theme_next_from_uri(&uri),
     );
diff --git a/server/src/html/mod.rs b/server/src/html/mod.rs
index f1b0f31b0c516c2e71ca7938d1ec2764e3b077eb..fbc3fc4ed7c53cc68125fb50f5c4db9122f9a261 100644
--- a/server/src/html/mod.rs
+++ b/server/src/html/mod.rs
@@ -310,6 +310,7 @@ pub(super) fn layout_full_bleed_chromeless(
     title: &str,
     view: &str,
     body: Markup,
+    views: Option<u64>,
     theme: &str,
     theme_next: &str,
 ) -> Markup {
@@ -317,7 +318,7 @@ pub(super) fn layout_full_bleed_chromeless(
         title,
         view,
         body,
-        None,
+        views,
         theme,
         theme_next,
         None,
diff --git a/server/tests/integration.rs b/server/tests/integration.rs
index e96d11c820c3bbaa8bb55ad11636397ef225e55a..62c84862d5c2cba212f9ceabd6273203a43e804c 100644
--- a/server/tests/integration.rs
+++ b/server/tests/integration.rs
@@ -1421,12 +1421,24 @@ async fn test_view_counts_increment_and_display() {
         .await
         .unwrap();
     assert!(v1.status().is_success(), "vote compare GET 1: {}", v1.status());
+    let v1_body = v1.text().await.unwrap();
+    assert!(
+        v1_body.contains("1 views"),
+        "vote compare page should show view count, snippet: {}",
+        v1_body.chars().take(600).collect::<String>()
+    );
     let v2 = client
         .get(format!("http://{addr}{vote_q_left_first}"))
         .send()
         .await
         .unwrap();
     assert!(v2.status().is_success(), "vote compare GET 2: {}", v2.status());
+    let v2_body = v2.text().await.unwrap();
+    assert!(
+        v2_body.contains("2 views"),
+        "vote compare page should reflect incremented count, snippet: {}",
+        v2_body.chars().take(600).collect::<String>()
+    );
 
     assert_eq!(
         state.views.get_views(&vote_key),

download full diff B

Hardlinks — judgments / attempts / prompt

prompt download

judgments

attempts

Prompt text is loaded only by the download route.