constitution · epochs · watch · epoch 3

comparison

c_06fce70179bc (tommy-mor) vs c_b0194743d156 (tommy-mor)

download prompt · raw event · cmp_390ce2234718b1

council reasoning

~anthropic/claude-sonnet-latest · winner B · 6:4 · permalink

B fixes a real correctness bug (root/tilde canonicalization mismatch causing top-level ontology children to be mis-keyed), adds targeted unit/integration/browser tests validating the fix, and introduces a clear invariant (SLUG_TILDE_ONTOLOGY_ROOT normalization) reused across modules. A is a substantial refactor moving fetch logic into a new SSE-based module with real functional improvement (async streaming, job-completion notification) but is mostly architectural churn/rename plus feature addition rather than a bugfix, and removes some existing test coverage without clearly stronger regression guarantees than B's added tests.

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

B fixes foundational CanonicalItemUrl storage identity (unifying `https://slug.social/~` vs `…/~/`, normalized_storage on rankings/lookups) so garden root children and sibling-rank actually resolve, with unit/integration/browser coverage. A is a large, useful fetch→SSE redesign plus module split and worker oneshots, but it mostly upgrades an already-working import path rather than correcting core graph key semantics.

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

Side B fixes a substantive correctness issue around canonical ontology root paths by introducing normalized storage for `~/`, updating lookups to use normalized keys, centralizing tilde-path conversion, and adding extensive regression tests covering root handling, rankings, and routing. Side A mainly refactors the fetch flow into an SSE-based implementation and reorganizes HTML helpers while adding logging and async plumbing, which is valuable but is largely an architectural/UI change rather than a fundamental correctness fix.

sides

A — c_06fce70179bc (tommy-mor)

message

[6d04afc2] refactor

diff preview

diff --git a/Cargo.lock b/Cargo.lock
index 2cea973082716e761ef6f5dd5886acc08ff9aac0..8c43fb75c472b102e6e1d3b837dce3355be898f2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -17,6 +17,28 @@ version = "1.0.102"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c"
 
+[[package]]
+name = "async-stream"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476"
+dependencies = [
+ "async-stream-impl",
+ "futures-core",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "async-stream-impl"
+version = "0.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
 [[package]]
 name = "async-trait"
 version = "0.1.89"
@@ -1242,9 +1264,11 @@ dependencies = [
 name = "sorter2-server"
 version = "0.0.1"
 dependencies = [
+ "async-stream",
  "axum",
  "axum-extra",
  "dotenvy",
+ "futures-util",
  "maud",
  "reqwest",
  "serde",
diff --git a/server/Cargo.toml b/server/Cargo.toml
index bd600138b613bd0f546bdec217a5334cdcb20aa5..c940acb687fb141d21760a3d6656172013cf6f41 100644
--- a/server/Cargo.toml
+++ b/server/Cargo.toml
@@ -18,6 +18,8 @@ tracing = "0.1"
 tracing-subscriber = { version = "0.3", features = ["env-filter"] }
 reqwest = { version = "0.12", features = ["json"] }
 dotenvy = "0.15"
+async-stream = "0.3"
+futures-util = { version = "0.3", default-features = false, features = ["std"] }
 
 [dev-dependencies]
 reqwest = { version = "0.12", features = ["json"] }
diff --git a/server/src/api/ui_html.rs b/server/src/api/ui_html.rs
index b33a84e8bb5e817b26592868d88090e6d664d950..7af6527d03c483f33f3469ce6766c01a554c5fe3 100644
--- a/server/src/api/ui_html.rs
+++ b/server/src/api/ui_html.rs
@@ -6,7 +6,8 @@ use axum::{
 use std::collections::HashMap;
 
 use crate::{
-    html::{entity_section, input_panel, js_string_literal, ranking_panel, JsBuilder},
+    fetch,
+    html::{input_panel, js_string_literal, ranking_panel, JsBuilder},
     parser::parse_reddit_url,
     path_types::ItemId,
     reddit::ensure_partial_tree,
@@ -89,18 +90,8 @@ pub async fn post_ui_html(
         },
         HtmlUiAction::FetchEntity { item } => {
             let id = parse_item_param(&item);
-            if id.is_root() {
-                return ui_js_warn("nothing to fetch for the root").into_response();
-            }
-            state.queue_entity_fetch(id.clone());
-            let tree = state.tree.read().await;
-            let empty = crate::reducer::NodeState::default();
-            let node = tree.get(&id).unwrap_or(&empty);
-            let panel = entity_section(&id, node, true);
-            JsBuilder::new()
-                .morph_selector("#entity-section", panel)
-                .into_response()
-        },
+            fetch::fetch_entity_stream(state, id).into_response()
+        }
     }
 }
 
diff --git a/server/src/fetch/html.rs b/server/src/fetch/html.rs
new file mode 100644
index 0000000000000000000000000000000000000000..63634508496e224c38b9ec0308b7a6086462f925
--- /dev/null
+++ b/server/src/fetch/html.rs
@@ -0,0 +1,67 @@
+//! Markup for entity import / “Fetch from Reddit” (`POST /ui`, SSE response).
+
+use maud::{html, Markup};
+
+use crate::{
+    form_template::template_json_compact,
+    path_types::ItemId,
+    reddit::is_fetchable,
+    reducer::NodeState,
+    ui_action::UI_RPC_FIELD,
+};
+
+fn entity_panel(node: &NodeState) -> Markup {
+    html! {
+        @if let Some(data) = &node.data {
+            div id="entity-panel" class="entity-card" {
+                h2 { (data.title) }
+                @if let Some(author) = &data.author {
+                    p class="muted small" { "by " (author) }
+                }
+                @if let Some(body) = &data.body_html {
+                    div class="entity-body" { (maud::PreEscaped(body)) }
+                }
+            }
+        }
+    }
+}
+
+/// Reddit/API import — `POST /ui` with `fetch_entity` returns an SSE stream.
+pub fn fetch_entity_panel(item: &ItemId, has_data: bool, fetching: bool) -> Markup {
+    if !is_fetchable(item) {
+        return html! {};
+    }
+    let label = if fetching {
+        "Fetching…"
+    } else if has_data {
+        "Fetch more"
+    } else {
+        "Fetch from Reddit"
+    };
+    let rpc = template_json_compact(&serde_json::json!({
+        "action": "fetch_entity",
+        "item": item.as_str(),
+    }))
+    .expect("fetch_entity rpc template");
+    html! {
+        form method="post" action="/ui" id="fetch-entity-form" class="fetch-entity-form" {
+            input type="hidden" name=(UI_RPC_FIELD) value=(rpc);
+            @if fetching {
+                button type="submit" class="btn-secondary" disabled { (label) }
+            } @else {
+                button type="submit" class="btn-secondary" { (label) }
+            }
+        }
+    }
+}
+
+/// Entity card + fetch control (target `#entity-section` for Idiomorph / SSE).
+pub fn entity_section(item: &ItemId, node: &NodeState, fetching: bool) -> Markup {
+    let has_data = node.data.is_some();
+    html! {
+        section id="entity-section" class="demo-panel" {
+            (entity_panel(node))
+            (fetch_entity_panel(item, has_data, fetching))
+        }
+    }
+}
diff --git a/server/src/fetch/mod.rs b/server/src/fetch/mod.rs
new file mode 100644
index 0000000000000000000000000000000000000000..2290f9d3a0f1cbf1806c6339f82a4515c11cc3d3
--- /dev/null
+++ b/server/src/fetch/mod.rs
@@ -0,0 +1,115 @@
+//! Entity import over `POST /ui` as SSE (Reddit worker in [`crate::reddit`]).
+
+pub mod html;
+
+use std::convert::Infallible;
+use std::time::Duration;
+
+use async_stream::stream;
+use axum::response::sse::{Event, KeepAlive, Sse};
+use futures_util::Stream;
+use serde::Serialize;
+use tokio::sync::oneshot;
+
+use crate::{
+    path_types::ItemId,
+    reddit::FetchJobResult,
+    reducer::NodeState,
+    state::AppState,
+};
+
+pub fn now_ms() -> i64 {
+    let t = std::time::SystemTime::now()
+        .duration_since(std::time::UNIX_EPOCH)
+        .unwrap_or_default();
+    t.as_millis() as i64
+}
+
+#[derive(Serialize)]
+struct SseMorphPayload {
+    selector: &'static str,
+    html: String,
+}
+
+fn morph_complete_event(html: maud::Markup) -> Event {
+    let payload = SseMorphPayload {
+        selector: "#entity-section",
+        html: html.into_string(),
+    };
+    let data = serde_json::to_string(&payload).unwrap_or_else(|_| "{}".into());
+    Event::default().event("complete").data(data)
+}
+
+/// Stream `fetching` → `complete` / `error` for [`crate::ui_action::HtmlUiAction::FetchEntity`].
+pub fn fetch_entity_stream(
+    state: AppState,
+    id: ItemId,
+) -> Sse<impl Stream<Item = Result<Event, Infallible>>> {
+    tracing::debug!(item = %id, "fetch entity stream opened");
+
+    let stream = stream! {
+        if id.is_root() {
+            yield Ok(Event::default().event("error").data("{\"message\":\"nothing to fetch for the root\"}"));
+            return;
+        }
+
+        if !crate::reddit::is_fetchable(&id) {
+            tracing::debug!(item = %id, "fetch stream: not fetchable");
+            yield Ok(Event::default().event("error").data("{\"message\":\"this page cannot be fetched from Reddit\"}"));
+            return;
+        }
+
+        let fetching_html = {
+            let tree = state.tree.read().await;
+            let empty = NodeState::default();
+            let node = tree.get(&id).unwrap_or(&empty);
+            html::entity_section(&id, node, true).into_string()
+        };
+        let fetching_payload = serde_json::json!({
+            "selector": "#entity-section",
+            "html": fetching_html,
+        });
+        yield Ok(Event::default().event("fetching").data(fetching_payload.to_string()));
+
+        let (tx, rx) = oneshot::channel();
+        state.reddit.request_fetch(id.clone(), true, Some(tx));
+        tracing::debug!(item = %id, "fetch stream: queued reddit job");
+
+        let result = match rx.await {
+            Ok(r) => r,
+            Err(_) => {
+                tracing::warn!(item = %id, "fetch stream: worker dropped oneshot");
+                FetchJobResult::Failed("reddit worker stopped".into())
+            }
+        };
+
+        tracing::debug!(item = %id, ?result, "fetch stream: job finished");
+
+        match result {
+            FetchJobResult::Imported | FetchJobResult::NotFound => {
+                let tree = state.tree.read().await;
+                let empty = NodeState::default();
+                let node = tree.get(&id).unwrap_or(&empty);
+                yield Ok(morph_complete_event(html::entity_section(&id, node, false)));
+            }
+            FetchJobResult::SkippedCached | FetchJobResult::SkippedDuplicate => {
+                let tree = state.tree.read().await;
+                let empty = NodeState::default();
+                let node = tree.get(&id).unwrap_or(&empty);
+                yield Ok(morph_complete_event(html::entity_section(&id, node, false)));
+            }
+            FetchJobResult::RateLimited { reset_secs } => {
+                yield Ok(Event::default().event("error").data(
+                    serde_json::json!({"message": format!("Reddit rate limit — retry in {reset_secs}s")}).to_string(),
+                ));
+            }
+            FetchJobResult::Failed(msg) => {
+                yield Ok(Event::default().event("error").data(
+                    serde_json::json!({"message": msg}).to_string(),
+                ));
+            }
+        }
+    };
+
+    Sse::new(stream).keep_alive(KeepAlive::new().interval(Duration::from_secs(15)))
+}
diff --git a/server/src/html/mod.rs b/server/src/html/mod.rs
index db5b4c7f06b0be64603981166835cde268234f67..9314a7556306ddab969b896dbf4126b542a46722 100644
--- a/server/src/html/mod.rs
+++ b/server/src/html/mod.rs
@@ -7,10 +7,10 @@ use axum::{
 use maud::{html, Markup, DOCTYPE};
 
 use crate::{
+    fetch::html::entity_section,
     form_template::template_json_compact,
     path_types::ItemId,
     ranking::{top_bottom, RankedItem},
-    reddit::is_fetchable,
     reducer::{GroupState, NodeState},
     state::AppState,
     ui_action::UI_RPC_FIELD,
@@ -149,62 +149,6 @@ pub fn breadcrumb_path(item: &ItemId) -> Markup {
     }
 }
 
-fn entity_panel(node: &NodeState) -> Markup {
-    html! {
-        @if let Some(data) = &node.data {
-            div id="entity-panel" class="entity-card" {
-                h2 { (data.title) }
-                @if let Some(author) = &data.author {
-                    p class="muted small" { "by " (author) }
-                }
-                @if let Some(body) = &data.body_html {
-                    div class="entity-body" { (maud::PreEscaped(body)) }
-                }
-            }
-        }
-    }
-}
-
-/// Reddit/API import control — only shown on fetchable pages; never auto-fires.
-pub fn fetch_entity_panel(item: &ItemId, has_data: bool, fetching: bool) -> Markup {
-    if !is_fetchable(item) {
-        return html! {};
-    }
-    let label = if fetching {
-        "Fetching…"
-    } else if has_data {
-        "Fetch more"
-    } else {
-        "Fetch from Reddit"
-    };
-    let rpc = template_json_compact(&serde_json::json!({
-        "action": "fetch_entity",
-        "item": item.as_str(),
-    }))
-    .expect("fetch_entity rpc template");
-    html! {
-        form method="post" action="/ui" id="fetch-entity-form" class="fetch-entity-form" {
-            input type="hidden" name=(UI_RPC_FIELD) value=(rpc);
-            @if fetching {
-                button type="submit" class="btn-secondary" disabled { (label) }
-            } @else {
-                button type="submit" class="btn-secondary" { (label) }
-            }
-        }
-    }
-}
-
-/// Entity 

… preview truncated; 22,618 characters omitted

download full diff A

B — c_b0194743d156 (tommy-mor)

message

[c59951f5] fixed canonical item paths business

diff preview

diff --git a/server/src/html/breadcrumb_path.rs b/server/src/html/breadcrumb_path.rs
index 12ad2c84faf2fbb693015d4552e45b5c54d587b9..c8a3937923161a6ff248bd77e87eff0dc6fe9ab0 100644
--- a/server/src/html/breadcrumb_path.rs
+++ b/server/src/html/breadcrumb_path.rs
@@ -1,4 +1,4 @@
-use crate::path_types::CanonicalItemUrl;
+use crate::path_types::{tilde_http_path_to_canonical, CanonicalItemUrl};
 
 /// Semantic view of an ontology path for rendering and routing decisions.
 pub(super) struct OntologyPath {
@@ -11,16 +11,7 @@ impl OntologyPath {
     /// Path is the `*path` segment from `/~/*path` (e.g. `topic/a`). Always treat it as under `~/`
     /// so it canonicalizes to `https://slug.social/~/…`, not the non-tilde site path.
     pub(super) fn from_input(path: &str) -> Self {
-        let p = path.trim_start_matches('/');
-        let raw = if p.starts_with("http://") || p.starts_with("https://") {
-            p.to_string()
-        } else if p.is_empty() {
-            "~/".to_string()
-        } else {
-            format!("~/{}", p)
-        };
-        let canonical = CanonicalItemUrl::parse(&raw)
-            .unwrap_or_else(|| CanonicalItemUrl::parse("~/").unwrap());
+        let canonical = tilde_http_path_to_canonical(path);
         Self::from_canonical(canonical)
     }
 
@@ -37,7 +28,7 @@ impl OntologyPath {
     }
 
     pub(super) fn root() -> Self {
-        Self::from_canonical(CanonicalItemUrl::parse("~/").unwrap())
+        Self::from_canonical(CanonicalItemUrl::ontology_root())
     }
 
     pub(super) fn is_root(&self) -> bool {
diff --git a/server/src/html/garden.rs b/server/src/html/garden.rs
index d58d9b46f575eb6b7e4971086b07dda75ca2f645..319feb15a6b68d2b5df98b4289fedbc9bdd048d3 100644
--- a/server/src/html/garden.rs
+++ b/server/src/html/garden.rs
@@ -459,6 +459,8 @@ struct ItemPageViewModel {
     item: String,
     body: Option<String>,
     sibling_rank: Option<SiblingRank>,
+    /// False at the tilde ontology root (`~/`): sibling-rank footnote does not apply.
+    item_has_parent: bool,
     child_rankings: ChildrenRankings,
     rank_history: Vec<RankHistoryEntryView>,
     /// Forum threads that mention or vote on this item.
@@ -470,11 +472,12 @@ fn build_sibling_rank(
     scope: &ScopeId,
     item: &CanonicalItemUrl,
 ) -> Option<SiblingRank> {
+    let item = item.clone().normalized_storage();
     let content = reduced
         .content_for_scope(scope)
         .unwrap_or_else(|| reduced.public());
     let group = &content.ranking_group;
-    let parent = item.parent()?;
+    let parent = item.parent()?.normalized_storage();
     let siblings: Vec<CanonicalItemUrl> = content
         .item_children
         .get(&parent)
@@ -492,7 +495,7 @@ fn build_sibling_rank(
     if scoped_idxs.is_empty() {
         return None;
     }
-    let current_idx = *group.item_to_idx.get(item)?;
+    let current_idx = *group.item_to_idx.get(&item)?;
     if !scoped_idxs.contains(&current_idx) {
         return None;
     }
@@ -520,7 +523,7 @@ fn build_sibling_rank(
         .filter_map(|li| local_to_global.get(*li).copied())
         .collect();
     let ranked = ranked_items_subset(group, &comp_global, 10000, 1e-8);
-    let position = ranked.iter().position(|r| &r.item == item)? + 1;
+    let position = ranked.iter().position(|r| r.item == item)? + 1;
     Some(SiblingRank {
         position,
         component_size: ranked.len(),
@@ -597,7 +600,9 @@ fn build_item_page_view_model(
         .content_for_scope(scope)
         .unwrap_or_else(|| reduced.public());
     let item_key = CanonicalItemUrl::parse(item)
-        .unwrap_or_else(|| CanonicalItemUrl::parse("~/").unwrap());
+        .unwrap_or_else(|| CanonicalItemUrl::parse("~/").unwrap())
+        .normalized_storage();
+    let item_has_parent = item_key.parent().is_some();
     let child_rankings = build_children_rankings(content, &item_key);
 
     let rank_history = build_rank_history(reduced, scope, item_key.as_str());
@@ -617,6 +622,7 @@ fn build_item_page_view_model(
             .cloned()
             .or_else(|| reduced.public().item_bodies.get(&item_key).cloned()),
         sibling_rank: build_sibling_rank(reduced, scope, &item_key),
+        item_has_parent,
         child_rankings,
         rank_history,
         threads,
@@ -652,7 +658,7 @@ async fn render_scope_view(
                             (format!("#{} of {}", rank.position, rank.component_size))
                         }
                         span class="muted" { (format!("({} siblings)", rank.sibling_total)) }
-                    } @else {
+                    } @else if model.item_has_parent {
                         span class="muted" { "unranked among siblings" }
                     }
                 }
@@ -815,6 +821,18 @@ mod tests {
         }));
     }
 
+    fn apply_ingest_room(state: &mut ReducerState, ts: i64, room_id: &str, raw: &str) {
+        state.apply_event(Event::Ingest(Ingest {
+            ts,
+            id: format!("ing-{ts}"),
+            raw: raw.to_string(),
+            principal: "testuser".to_string(),
+            delegate: Some("00000000-0000-0000-0000-000000000000:test:local/test".to_string()),
+            room_id: room_id.to_string(),
+            thread_tag: String::new(),
+        }));
+    }
+
     #[test]
     fn item_page_model_includes_body_and_unranked_without_votes() {
         let mut reduced = ReducerState::default();
@@ -885,4 +903,85 @@ mod tests {
                 || model.child_rankings.unranked_items.contains(&CanonicalItemUrl("https://slug.social/~/topic/kid2".to_string()))
         );
     }
+
+    #[test]
+    fn item_page_room_scope_root_lists_top_level_children() {
+        let mut reduced = ReducerState::default();
+        apply_ingest_room(
+            &mut reduced,
+            1,
+            "9ab12cd/my-room",
+            "@00000000-0000-0000-0000-000000000000:test:local/test\n~/t1 {a}\n~/t2 {b}\n",
+        );
+        use crate::path_types::CanonicalItemUrl;
+        let root = CanonicalItemUrl::ontology_root();
+        let model = build_item_page_view_model(
+            &reduced,
+            &ScopeId::Room("9ab12cd/my-room".to_string()),
+            root.as_str(),
+        );
+        assert!(!model.item_has_parent);
+        assert_eq!(model.child_rankings.unranked_items.len(), 2);
+        let set: std::collections::HashSet<&str> = model
+            .child_rankings
+            .unranked_items
+            .iter()
+            .map(|u| u.as_str())
+            .collect();
+        assert!(set.contains("https://slug.social/~/t1"));
+        assert!(set.contains("https://slug.social/~/t2"));
+    }
+
+    /// Top-level `~/a` vs `~/b` votes form one ranked component under the ontology root.
+    #[test]
+    fn item_page_room_scope_root_shows_ranked_child_group() {
+        let mut reduced = ReducerState::default();
+        apply_ingest_room(
+            &mut reduced,
+            1,
+            "9ab12cd/my-room",
+            "@00000000-0000-0000-0000-000000000000:test:local/test\n\
+             ~/a {a}\n~/b {b}\n~/a 2:1 ~/b {because}\n",
+        );
+        use crate::path_types::CanonicalItemUrl;
+        let root = CanonicalItemUrl::ontology_root();
+        let model = build_item_page_view_model(
+            &reduced,
+            &ScopeId::Room("9ab12cd/my-room".to_string()),
+            root.as_str(),
+        );
+        assert_eq!(model.child_rankings.component_rankings.len(), 1);
+        assert_eq!(model.child_rankings.component_rankings[0].pairs, 1);
+        let names: Vec<&str> = model.child_rankings.component_rankings[0]
+            .ranked
+            .iter()
+            .map(|r| r.item.as_str())
+            .collect();
+        assert_eq!(
+            names,
+            vec!["https://slug.social/~/a", "https://slug.social/~/b"]
+        );
+        assert!(model.child_rankings.unranked_items.is_empty());
+    }
+
+    /// Legacy `https://slug.social/~/` spelling still resolves children under the real root key.
+    #[test]
+    fn item_page_model_normalizes_legacy_tilde_root_storage_url() {
+        let mut reduced = ReducerState::default();
+        apply_ingest(
+            &mut reduced,
+            1,
+            "@00000000-0000-0000-0000-000000000000:test:local/test\n~/x {x}\n",
+        );
+        let model = build_item_page_view_model(
+            &reduced,
+            &ScopeId::Public,
+            "https://slug.social/~/",
+        );
+        assert_eq!(model.child_rankings.unranked_items.len(), 1);
+        assert_eq!(
+            model.child_rankings.unranked_items[0].as_str(),
+            "https://slug.social/~/x"
+        );
+    }
 }
diff --git a/server/src/path_types.rs b/server/src/path_types.rs
index 4c8075bbd488f1b9a5eda9e03ced83f6238c6d5e..361a9d446c9043cbdea5f060db2e8633c2fd9bf9 100644
--- a/server/src/path_types.rs
+++ b/server/src/path_types.rs
@@ -1,3 +1,5 @@
 //! Re-exports — implementations live in `slug-types` (`paths` module).
 
-pub use slug_types::paths::{CanonicalItemUrl, RelativePath, TildePath};
+pub use slug_types::paths::{
+    tilde_http_path_to_canonical, CanonicalItemUrl, RelativePath, TildeHttpPathTail, TildePath,
+};
diff --git a/server/src/scope_rank.rs b/server/src/scope_rank.rs
index dc640848232b7e79142bfeeea3003c9023f84854..d656b2f0a0a3623ca6b234b746beaaca8ae6017d 100644
--- a/server/src/scope_rank.rs
+++ b/server/src/scope_rank.rs
@@ -149,9 +149,10 @@ pub fn build_rankings_for_item_set(content: &ContentState, items_in_scope: &[Can
 /// Build connected-component rankings for direct children of parent_scope.
 /// Matches the HTML garden view: multiple components, isolates, no-vote items.
 pub fn build_children_rankings(content: &ContentState, parent: &CanonicalItemUrl) -> ChildrenRankings {
+    let parent = parent.clone().normalized_storage();
     let items: Vec<CanonicalItemUrl> = content
         .item_children
-        .get(parent)
+        .get(&parent)
         .map(|s| s.iter().cloned().collect())
         .unwrap_or_default();
     build_rankings_for_item_set(content, &items)
diff --git a/server/tests/integration.rs b/server/tests/integration.rs
index f9c218378f6a173e56ae1cec797b3c492986eac0..d4c5bfe9c6f1c71dc61878bd8c5e729b1b7c69ef 100644
--- a/server/tests/integration.rs
+++ b/server/tests/integration.rs
@@ -704,6 +704,62 @@ async fn test_private_room_post_links_use_private_garden_routes() {
     assert!(garden_body.contains(&format!("/r/{room_short}/{room_slug}/t/garden-thread")));
 }
 
+#[tokio::test]
+async fn test_private_room_garden_root_lists_top_level_tilde_children() {
+    let (addr, _tmp, _log, _handle) = create_test_server().await;
+    let client = reqwest::Client::builder()
+        .redirect(reqwest::redirect::Policy::none())
+        .build()
+        .unwrap();
+    let bearer = test_bearer();
+
+    let create = rpc_batch(
+        &client,
+        addr,
+        Some(&bearer),
+        serde_json::json!([{
+            "RoomCreate": { "slug": "garden-root-list" }
+        }]),
+    )
+    .await;
+    let room_id = create["results"][0]["result"]["RoomCreated"]["room_id"]
+        .as_str()
+        .unwrap()
+        .to_string();
+    let (room_short, room_slug) = room_id.split_once('/').unwrap();
+
+    let rpc = ui_post_ingest_rpc(
+        &room_id,
+        "ing",
+        "~/test1 {wow}\n~/test2 {wow2}\n~/test1 2:1 ~/test2 {because}\n",
+    );
+    let post = client
+        .post(format!("http://{addr}/ui"))
+        .header("Authorization", format!("Bearer {bearer}"))
+        .form(&[("__rpc__", rpc.as_str())])
+        .send()
+        .await
+        .unwrap();
+    assert_eq!(post.status(), reqwest::StatusCode::OK);
+
+    let root_page = client
+        .get(format!("http://{addr}/r/{room_short}/{room_slug}/~"))
+        .header("Authorization", format!("Bearer {bearer}"))
+        .send()
+        .await
+        .unwrap();
+    assert!(root_page.status().is_success());
+    let body = root_page.text().await.unwrap();
+ 

… preview truncated; 14,119 characters omitted

download full diff B

Hardlinks — judgments / attempts / prompt

prompt download

judgments

attempts

Prompt text is loaded only by the download route.